diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2023-05-04 17:19:02 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2023-05-04 17:19:02 +0900 |
commit | 860c879989e9e3f51f6654579e7bf3fddc652d85 (patch) | |
tree | fdfb273f697d363d8a59d2e208f6eb68f8e72b2b /kitchensync/libqopensync | |
parent | 5629ca069bd0c1d5c7bee83f3eac2b8418939854 (diff) | |
download | tdepim-860c879989e9e3f51f6654579e7bf3fddc652d85.tar.gz tdepim-860c879989e9e3f51f6654579e7bf3fddc652d85.zip |
Drop deprecated kitchensync code
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'kitchensync/libqopensync')
31 files changed, 0 insertions, 3559 deletions
diff --git a/kitchensync/libqopensync/CMakeLists.txt b/kitchensync/libqopensync/CMakeLists.txt deleted file mode 100644 index c933d2862..000000000 --- a/kitchensync/libqopensync/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ -################################################# -# -# (C) 2010-2011 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -include( ConfigureChecks.cmake ) - -include_directories( - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/.. - ${TDE_INCLUDE_DIR} - ${TQT_INCLUDE_DIRS} - ${OSENGINE_INCLUDE_DIRS} - ${OPENSYNC_INCLUDE_DIRS} -) - -link_directories( - ${TQT_LIBRARY_DIRS} -) - - -##### qopensync (shared) ######################## - -tde_add_library( qopensync SHARED AUTOMOC - SOURCES - callbackhandler.cpp conversion.cpp engine.cpp environment.cpp - filter.cpp group.cpp member.cpp plugin.cpp result.cpp syncmapping.cpp - syncupdates.cpp syncchange.cpp - VERSION 0.0.0 - LINK tdeui-shared ${OSENGINE_LIBRARIES} ${OPENSYNC_LIBRARIES} - DESTINATION ${LIB_INSTALL_DIR} -) diff --git a/kitchensync/libqopensync/ConfigureChecks.cmake b/kitchensync/libqopensync/ConfigureChecks.cmake deleted file mode 100644 index 92d329301..000000000 --- a/kitchensync/libqopensync/ConfigureChecks.cmake +++ /dev/null @@ -1,22 +0,0 @@ -################################################# -# -# (C) 2010-2011 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -# NOTE is needed libopensync-0.22 - -pkg_search_module( OPENSYNC opensync-1.0 ) -if( NOT OPENSYNC_FOUND ) - tde_message_fatal( "opensync-1.0 is requested, but was not found on your system" ) -endif( ) - -pkg_search_module( OSENGINE osengine-1.0 ) -if( NOT OSENGINE_FOUND ) - tde_message_fatal( "osengine-1.0 is requested, but was not found on your system" ) -endif( ) diff --git a/kitchensync/libqopensync/Makefile.am b/kitchensync/libqopensync/Makefile.am deleted file mode 100644 index 73bdae044..000000000 --- a/kitchensync/libqopensync/Makefile.am +++ /dev/null @@ -1,19 +0,0 @@ -INCLUDES = -I$(top_srcdir)/kitchensync/src \ - -I$(top_srcdir)/kitchensync \ - -I$(top_srcdir) \ - $(OPENSYNC_CFLAGS) \ - $(OPENSYNCENGINE_CFLAGS) \ - $(all_includes) - -lib_LTLIBRARIES = libqopensync.la - -libqopensync_la_SOURCES = callbackhandler.cpp conversion.cpp engine.cpp environment.cpp filter.cpp group.cpp \ - member.cpp plugin.cpp result.cpp syncmapping.cpp syncupdates.cpp \ - syncchange.cpp -libqopensync_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -no-undefined -libqopensync_la_LIBADD = $(LIB_TDEUI) $(OPENSYNC_LIBS) $(OPENSYNCENGINE_LIBS) - -METASOURCES = AUTO - -messages: rc.cpp - $(XGETTEXT) *.cpp *.h -o $(podir)/libqopensync.pot diff --git a/kitchensync/libqopensync/callbackhandler.cpp b/kitchensync/libqopensync/callbackhandler.cpp deleted file mode 100644 index f3ae4c68b..000000000 --- a/kitchensync/libqopensync/callbackhandler.cpp +++ /dev/null @@ -1,191 +0,0 @@ -/* - This file is part of libqopensync. - - Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include <osengine/engine.h> - -#include <libqopensync/engine.h> - -#include <tqapplication.h> - -#include "callbackhandler.h" - -using namespace QSync; - -class CallbackHandler::ConflictEvent : public TQCustomEvent -{ - public: - ConflictEvent( const SyncMapping& mapping ) - : TQCustomEvent( ConflictEventType ), mMapping( mapping ) - { - } - - SyncMapping mapping() const { return mMapping; } - - private: - SyncMapping mMapping; -}; - -class CallbackHandler::ChangeEvent : public TQCustomEvent -{ - public: - ChangeEvent( const SyncChangeUpdate& change ) - : TQCustomEvent( ChangeEventType ), mChange( change ) - { - } - - SyncChangeUpdate change() const { return mChange; } - - private: - SyncChangeUpdate mChange; -}; - -class CallbackHandler::MappingEvent : public TQCustomEvent -{ - public: - MappingEvent( const SyncMappingUpdate& mapping ) - : TQCustomEvent( MappingEventType ), mMapping( mapping ) - { - } - - SyncMappingUpdate mapping() const { return mMapping; } - - private: - SyncMappingUpdate mMapping; -}; - -class CallbackHandler::EngineEvent : public TQCustomEvent -{ - public: - EngineEvent( const SyncEngineUpdate& engine ) - : TQCustomEvent( EngineEventType ), mEngine( engine ) - { - } - - SyncEngineUpdate engine() const { return mEngine; } - - private: - SyncEngineUpdate mEngine; -}; - -class CallbackHandler::MemberEvent : public TQCustomEvent -{ - public: - MemberEvent( const SyncMemberUpdate& member ) - : TQCustomEvent( MemberEventType ), mMember( member ) - { - } - - SyncMemberUpdate member() const { return mMember; } - - private: - SyncMemberUpdate mMember; -}; - -CallbackHandler::CallbackHandler() -{ -} - -CallbackHandler::~CallbackHandler() -{ -} - -void CallbackHandler::setEngine( Engine *engine ) -{ - mEngine = engine; - - osengine_set_conflict_callback( engine->mEngine, &conflict_callback, this ); - osengine_set_changestatus_callback( engine->mEngine, &change_callback, this ); - osengine_set_mappingstatus_callback( engine->mEngine, &mapping_callback, this ); - osengine_set_enginestatus_callback( engine->mEngine, &engine_callback, this ); - osengine_set_memberstatus_callback( engine->mEngine, &member_callback, this ); -} - -Engine* CallbackHandler::engine() const -{ - return mEngine; -} - -void CallbackHandler::customEvent( TQCustomEvent *event ) -{ - if ( event->type() == static_cast<TQEvent::Type>( ConflictEventType ) ) { - ConflictEvent *conflictEvent = static_cast<ConflictEvent*>( event ); - emit conflict( conflictEvent->mapping() ); - } else if ( event->type() == static_cast<TQEvent::Type>( ChangeEventType ) ) { - ChangeEvent *changeEvent = static_cast<ChangeEvent*>( event ); - emit change( changeEvent->change() ); - } else if ( event->type() == static_cast<TQEvent::Type>( MappingEventType ) ) { - MappingEvent *mappingEvent = static_cast<MappingEvent*>( event ); - emit mapping( mappingEvent->mapping() ); - } else if ( event->type() == static_cast<TQEvent::Type>( EngineEventType ) ) { - EngineEvent *engineEvent = static_cast<EngineEvent*>( event ); - emit engine( engineEvent->engine() ); - } else if ( event->type() == static_cast<TQEvent::Type>( MemberEventType ) ) { - MemberEvent *memberEvent = static_cast<MemberEvent*>( event ); - emit member( memberEvent->member() ); - } -} - -void CallbackHandler::conflict_callback( OSyncEngine *engine, OSyncMapping *omapping, void *data ) -{ - SyncMapping mapping( omapping, engine ); - - CallbackHandler *handler = static_cast<CallbackHandler*>( data ); - - TQApplication::postEvent( handler, new ConflictEvent( mapping ) ); -} - -void CallbackHandler::change_callback( OSyncEngine*, OSyncChangeUpdate *update, void *data ) -{ - SyncChangeUpdate change( update ); - - CallbackHandler *handler = static_cast<CallbackHandler*>( data ); - - TQApplication::postEvent( handler, new ChangeEvent( change ) ); -} - -void CallbackHandler::mapping_callback( OSyncMappingUpdate *update, void *data ) -{ - CallbackHandler *handler = static_cast<CallbackHandler*>( data ); - - SyncMappingUpdate mapping( update, handler->engine()->mEngine ); - - TQApplication::postEvent( handler, new MappingEvent( mapping ) ); -} - -void CallbackHandler::engine_callback( OSyncEngine*, OSyncEngineUpdate *update, void *data ) -{ - SyncEngineUpdate engine( update ); - - CallbackHandler *handler = static_cast<CallbackHandler*>( data ); - - TQApplication::postEvent( handler, new EngineEvent( engine ) ); -} - -void CallbackHandler::member_callback( OSyncMemberUpdate *update, void *data ) -{ - SyncMemberUpdate member( update ); - - CallbackHandler *handler = static_cast<CallbackHandler*>( data ); - - TQApplication::postEvent( handler, new MemberEvent( member ) ); -} - -#include "callbackhandler.moc" diff --git a/kitchensync/libqopensync/callbackhandler.h b/kitchensync/libqopensync/callbackhandler.h deleted file mode 100644 index 703e81fb9..000000000 --- a/kitchensync/libqopensync/callbackhandler.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - This file is part of libqopensync. - - Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef TQSYNC_CALLBACKHANDLER_H -#define TQSYNC_CALLBACKHANDLER_H - -#include <libqopensync/syncmapping.h> -#include <libqopensync/syncupdates.h> - -#include <tqobject.h> - -class OSyncEngine; -class OSyncMapping; -class OSyncChangeUpdate; -class OSyncMappingUpdate; -class OSyncEngineUpdate; -class OSyncMemberUpdate; - -class TQCustomEvent; - -namespace QSync { - -class Engine; - -class CallbackHandler : public TQObject -{ - Q_OBJECT - - - public: - CallbackHandler(); - ~CallbackHandler(); - - void setEngine( Engine *engine ); - Engine* engine() const; - - signals: - void conflict( QSync::SyncMapping mapping ); - void change( const QSync::SyncChangeUpdate &update ); - void mapping( const QSync::SyncMappingUpdate &update ); - void engine( const QSync::SyncEngineUpdate &update ); - void member( const QSync::SyncMemberUpdate &update ); - - protected: - virtual void customEvent( TQCustomEvent *event ); - - private: - enum EventType { - ConflictEventType = 4044, - ChangeEventType, - MappingEventType, - EngineEventType, - MemberEventType - }; - - class ConflictEvent; - class ChangeEvent; - class MappingEvent; - class EngineEvent; - class MemberEvent; - - static void conflict_callback( OSyncEngine*, OSyncMapping*, void* ); - static void change_callback( OSyncEngine*, OSyncChangeUpdate*, void* ); - static void mapping_callback( OSyncMappingUpdate*, void* ); - static void engine_callback( OSyncEngine*, OSyncEngineUpdate*, void* ); - static void member_callback( OSyncMemberUpdate*, void* ); - - Engine* mEngine; -}; - -} - -#endif diff --git a/kitchensync/libqopensync/conversion.cpp b/kitchensync/libqopensync/conversion.cpp deleted file mode 100644 index 0be2fdb73..000000000 --- a/kitchensync/libqopensync/conversion.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - This file is part of libqopensync. - - Copyright (c) 2006 Tobias Koenig <tokoe@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include <opensync/opensync.h> - -#include "conversion.h" - -using namespace QSync; - -Conversion::Conversion() - : mEnvironment( 0 ) -{ -} - -Conversion::~Conversion() -{ -} - -bool Conversion::isValid() const -{ - return mEnvironment != 0; -} - -TQStringList Conversion::objectTypes() const -{ - Q_ASSERT( mEnvironment ); - - OSyncFormatEnv *formatEnv = osync_conv_env_new( mEnvironment ); - Q_ASSERT( formatEnv ); - - TQStringList types; - for ( int i = 0; i < osync_conv_num_objtypes( formatEnv ); i++ ) { - OSyncObjType *type = osync_conv_nth_objtype( formatEnv, i ); - types.append( TQString::fromUtf8( osync_objtype_get_name( type ) ) ); - } - - osync_conv_env_free( formatEnv ); - - return types; -} diff --git a/kitchensync/libqopensync/conversion.h b/kitchensync/libqopensync/conversion.h deleted file mode 100644 index 3e5204c9b..000000000 --- a/kitchensync/libqopensync/conversion.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - This file is part of libqopensync. - - Copyright (c) 2006 Tobias Koenig <tokoe@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef TQSYNC_CONVERSION_H -#define TQSYNC_CONVERSION_H - -#include <tqstringlist.h> - -class OSyncEnv; - -namespace QSync { - -class Conversion -{ - friend class Environment; - - public: - Conversion(); - ~Conversion(); - - /** - Returns whether the object is a valid conversion. - */ - bool isValid() const; - - /** - Returns the list of names of supported object types. - */ - TQStringList objectTypes() const; - - private: - OSyncEnv *mEnvironment; -}; - -} - -#endif - diff --git a/kitchensync/libqopensync/engine.cpp b/kitchensync/libqopensync/engine.cpp deleted file mode 100644 index 6d48c72ff..000000000 --- a/kitchensync/libqopensync/engine.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - This file is part of libqopensync. - - Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include <opensync/opensync.h> -#include <osengine/engine.h> - -#include "engine.h" - -using namespace QSync; - -Engine::Engine( const Group &group ) -{ - OSyncError *error = 0; - mEngine = osengine_new( group.mGroup, &error ); -} - -Engine::~Engine() -{ - osengine_free( mEngine ); - mEngine = 0; -} - -Result Engine::initialize() -{ - OSyncError *error = 0; - if ( !osengine_init( mEngine, &error ) ) - return Result( &error ); - else - return Result(); -} - -void Engine::finalize() -{ - osengine_finalize( mEngine ); -} - -Result Engine::synchronize() -{ - OSyncError *error = 0; - if ( !osengine_synchronize( mEngine, &error ) ) - return Result( &error ); - else - return Result(); -} - -void Engine::abort() -{ - osengine_abort( mEngine ); -} diff --git a/kitchensync/libqopensync/engine.h b/kitchensync/libqopensync/engine.h deleted file mode 100644 index e014d3f4b..000000000 --- a/kitchensync/libqopensync/engine.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - This file is part of libqopensync. - - Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef TQSYNC_ENGINE_H -#define TQSYNC_ENGINE_H - -#include <libqopensync/group.h> - -class OSyncEngine; - -namespace QSync { - -class Engine -{ - friend class CallbackHandler; - - public: - /** - Constructs an engine . - */ - Engine( const Group &group ); - - /** - Destroys the engine. - */ - ~Engine(); - - /** - Initializes the engine. - */ - Result initialize(); - - /** - Finalizes the engine. - */ - void finalize(); - - /** - Starts the synchronization process. - */ - Result synchronize(); - - /** - Stops the synchronization process. - */ - void abort(); - - private: - OSyncEngine *mEngine; -}; - -} - -#endif diff --git a/kitchensync/libqopensync/environment.cpp b/kitchensync/libqopensync/environment.cpp deleted file mode 100644 index f0d918083..000000000 --- a/kitchensync/libqopensync/environment.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/* - This file is part of libqopensync. - - Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "environment.h" - -#include <opensync/opensync.h> - -using namespace QSync; - -Environment::Environment() -{ - mEnvironment = osync_env_new(); -} - -Environment::~Environment() -{ - osync_env_free( mEnvironment ); -} - -Environment::GroupIterator Environment::groupBegin() -{ - GroupIterator it( this ); - it.mPos = 0; - - return it; -} - -Environment::GroupIterator Environment::groupEnd() -{ - GroupIterator it( this ); - it.mPos = groupCount(); - - return it; -} - -Environment::PluginIterator Environment::pluginBegin() -{ - PluginIterator it( this ); - it.mPos = 0; - - return it; -} - -Environment::PluginIterator Environment::pluginEnd() -{ - PluginIterator it( this ); - it.mPos = pluginCount(); - - return it; -} - -Result Environment::initialize() -{ - OSyncError *error = 0; - if ( !osync_env_initialize( mEnvironment, &error ) ) - return Result( &error ); - else - return Result(); -} - -Result Environment::finalize() -{ - OSyncError *error = 0; - if ( !osync_env_finalize( mEnvironment, &error ) ) - return Result( &error); - else - return Result(); -} - -int Environment::groupCount() const -{ - return osync_env_num_groups( mEnvironment ); -} - -Group Environment::groupAt( int pos ) const -{ - Group group; - - if ( pos < 0 || pos >= groupCount() ) - return group; - - OSyncGroup *ogroup = osync_env_nth_group( mEnvironment, pos ); - group.mGroup = ogroup; - - return group; -} - -Group Environment::groupByName( const TQString &name ) const -{ - Group group; - - OSyncGroup *ogroup = osync_env_find_group( mEnvironment, name.latin1() ); - if ( ogroup ) - group.mGroup = ogroup; - - return group; -} - -Group Environment::addGroup() -{ - Group group; - - OSyncGroup *ogroup = osync_group_new( mEnvironment ); - if ( ogroup ) - group.mGroup = ogroup; - - return group; -} - -Result Environment::removeGroup( const Group &group ) -{ - OSyncError *error = 0; - if ( !osync_group_delete( group.mGroup, &error ) ) - return Result( &error ); - else - return Result(); -} - -int Environment::pluginCount() const -{ - return osync_env_num_plugins( mEnvironment ); -} - -Plugin Environment::pluginAt( int pos ) const -{ - Plugin plugin; - - if ( pos < 0 || pos >= pluginCount() ) - return plugin; - - OSyncPlugin *oplugin = osync_env_nth_plugin( mEnvironment, pos ); - plugin.mPlugin = oplugin; - - return plugin; -} - -Plugin Environment::pluginByName( const TQString &name ) const -{ - Plugin plugin; - - OSyncPlugin *oplugin = osync_env_find_plugin( mEnvironment, name.latin1() ); - if ( oplugin ) - plugin.mPlugin = oplugin; - - return plugin; -} - -Conversion Environment::conversion() const -{ - Conversion conversion; - conversion.mEnvironment = mEnvironment; - - return conversion; -} diff --git a/kitchensync/libqopensync/environment.h b/kitchensync/libqopensync/environment.h deleted file mode 100644 index 469ffd972..000000000 --- a/kitchensync/libqopensync/environment.h +++ /dev/null @@ -1,199 +0,0 @@ -/* - This file is part of libqopensync. - - Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef OSYNC_ENVIRONMENT_H -#define OSYNC_ENVIRONMENT_H - -#include <tqstring.h> - -#include <libqopensync/group.h> -#include <libqopensync/plugin.h> -#include <libqopensync/result.h> -#include <libqopensync/conversion.h> - -struct OSyncEnv; - -namespace QSync { - -class Environment -{ - public: - Environment(); - ~Environment(); - - class GroupIterator - { - friend class Environment; - - public: - GroupIterator( Environment *environment ) - : mEnvironment( environment ), mPos( -1 ) - { - } - - GroupIterator( const GroupIterator &it ) - { - mEnvironment = it.mEnvironment; - mPos = it.mPos; - } - - Group operator*() - { - return mEnvironment->groupAt( mPos ); - } - - GroupIterator &operator++() { mPos++; return *this; } - GroupIterator &operator++( int ) { mPos++; return *this; } - GroupIterator &operator--() { mPos--; return *this; } - GroupIterator &operator--( int ) { mPos--; return *this; } - bool operator==( const GroupIterator &it ) { return mEnvironment == it.mEnvironment && mPos == it.mPos; } - bool operator!=( const GroupIterator &it ) { return mEnvironment == it.mEnvironment && mPos != it.mPos; } - - private: - Environment *mEnvironment; - int mPos; - }; - - class PluginIterator - { - friend class Environment; - - public: - PluginIterator( Environment *environment ) - : mEnvironment( environment ), mPos( -1 ) - { - } - - PluginIterator( const PluginIterator &it ) - { - mEnvironment = it.mEnvironment; - mPos = it.mPos; - } - - Plugin operator*() - { - return mEnvironment->pluginAt( mPos ); - } - - PluginIterator &operator++() { mPos++; return *this; } - PluginIterator &operator++( int ) { mPos++; return *this; } - PluginIterator &operator--() { mPos--; return *this; } - PluginIterator &operator--( int ) { mPos--; return *this; } - bool operator==( const PluginIterator &it ) { return mEnvironment == it.mEnvironment && mPos == it.mPos; } - bool operator!=( const PluginIterator &it ) { return mEnvironment == it.mEnvironment && mPos != it.mPos; } - - private: - Environment *mEnvironment; - int mPos; - }; - - /** - Returns an iterator pointing to the first item in the group list. - This iterator equals groupEnd() if the group list is empty. - */ - GroupIterator groupBegin(); - - /** - Returns an iterator pointing past the last item in the group list. - This iterator equals groupBegin() if the group list is empty. - */ - GroupIterator groupEnd(); - - /** - Returns an iterator pointing to the first item in the plugin list. - This iterator equals pluginEnd() if the group list is empty. - */ - PluginIterator pluginBegin(); - - /** - Returns an iterator pointing past the last item in the plugin list. - This iterator equals pluginBegin() if the plugin list is empty. - */ - PluginIterator pluginEnd(); - - /** - Initializes the environment ( e.g. loads the groups and plugins ). - Has to be called before the groups or plugins can be accessed. - */ - Result initialize(); - - /** - Finalizes the environment ( e.g. unloads the groups and plugins ). - Should be the last call before the object is deleted. - */ - Result finalize(); - - /** - Returns the number of groups. - */ - int groupCount() const; - - /** - Returns the group at position @param pos. - */ - Group groupAt( int pos ) const; - - /** - Returns a group by name or an invalid group when the group with this - name doesn't exists. - */ - Group groupByName( const TQString &name ) const; - - /** - Adds a new group to the environment. - - @returns the new group. - */ - Group addGroup(); - - /** - Removes a group from the environment. - */ - Result removeGroup( const Group &group ); - - /** - Returns the number of plugins. - */ - int pluginCount() const; - - /** - Returns the plugin at position @param pos. - */ - Plugin pluginAt( int pos ) const; - - /** - Returns a plugin by name or an invalid plugin when the plugin with this - name doesn't exists. - */ - Plugin pluginByName( const TQString &name ) const; - - /** - Returns the conversion object of this environment. - */ - Conversion conversion() const; - - private: - OSyncEnv *mEnvironment; -}; - -} - -#endif diff --git a/kitchensync/libqopensync/filter.cpp b/kitchensync/libqopensync/filter.cpp deleted file mode 100644 index dc5fe2eee..000000000 --- a/kitchensync/libqopensync/filter.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - This file is part of libqopensync. - - Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include <opensync/opensync.h> - -#include "filter.h" - -using namespace QSync; - -Filter::Filter() - : mFilter( 0 ) -{ -} - -Filter::~Filter() -{ -} - -bool Filter::isValid() const -{ - return (mFilter != 0); -} - -void Filter::setConfiguration( const TQString &configuration ) -{ - Q_ASSERT( mFilter ); - - osync_filter_set_config( mFilter, (const char*)configuration.utf8() ); -} - -TQString Filter::configuration() const -{ - Q_ASSERT( mFilter ); - - return TQString::fromUtf8( osync_filter_get_config( mFilter ) ); -} - diff --git a/kitchensync/libqopensync/filter.h b/kitchensync/libqopensync/filter.h deleted file mode 100644 index 94d419a9d..000000000 --- a/kitchensync/libqopensync/filter.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - This file is part of libqopensync. - - Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef TQSYNC_FILTER_H -#define TQSYNC_FILTER_H - -#include <tqstring.h> - -class OSyncFilter; - -namespace QSync { - -class Filter -{ - friend class Group; - - public: - Filter(); - ~Filter(); - - /** - Returns whether the object is a valid filter. - */ - bool isValid() const; - - /** - Sets the configuration string of this filter. The format of - string is filter specific. - */ - void setConfiguration( const TQString &configuration ); - - /** - Returns the configuration string of this filter. - */ - TQString configuration() const; - - bool operator==( const Filter &filter ) const { return mFilter == filter.mFilter; } - - private: - OSyncFilter *mFilter; -}; - -} - -#endif - diff --git a/kitchensync/libqopensync/group.cpp b/kitchensync/libqopensync/group.cpp deleted file mode 100644 index 85f6384de..000000000 --- a/kitchensync/libqopensync/group.cpp +++ /dev/null @@ -1,292 +0,0 @@ -/* - This file is part of libqopensync. - - Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -/** hack includes **/ -#include <tqdom.h> -#include <tqfile.h> -/** hack includes **/ - -#include <opensync/opensync.h> - -#include "conversion.h" -#include "group.h" - -using namespace QSync; - -/** - This class is a quick hack for OpenSync 0.19 and 0.20 because - the engine doesn't stores the filter settings itself when calling - osync_group_set_objtype_enabled(), so we have to store it for every - group in a separated config file. This class encapsulates it. - */ -GroupConfig::GroupConfig() - : mGroup( 0 ) -{ -} - -TQStringList GroupConfig::activeObjectTypes() const -{ - Q_ASSERT( mGroup ); - - const TQString fileName = TQString( "%1/filter.conf" ).arg( osync_group_get_configdir( mGroup ) ); - - TQFile file( fileName ); - if ( !file.open( IO_ReadOnly ) ) - return TQStringList(); - - TQDomDocument document; - - TQString message; - if ( !document.setContent( &file, &message ) ) { - tqDebug( "Error on loading %s: %s", fileName.latin1(), message.latin1() ); - return TQStringList(); - } - file.close(); - - TQStringList objectTypes; - - TQDomElement element = document.documentElement(); - TQDomNode node = element.firstChild(); - while ( !node.isNull() ) { - TQDomElement childElement = node.toElement(); - if ( !childElement.isNull() ) - objectTypes.append( childElement.tagName() ); - - node = node.nextSibling(); - } - - return objectTypes; -} - -void GroupConfig::setActiveObjectTypes( const TQStringList &objectTypes ) -{ - Q_ASSERT( mGroup ); - - TQDomDocument document( "Filter" ); - document.appendChild( document.createProcessingInstruction( - "xml", "version=\"1.0\" encoding=\"UTF-8\"" ) ); - - TQDomElement element = document.createElement( "filter" ); - document.appendChild( element ); - - for ( uint i = 0; i < objectTypes.count(); ++i ) { - TQDomElement entry = document.createElement( objectTypes[ i ] ); - element.appendChild( entry ); - } - - const TQString fileName = TQString( "%1/filter.conf" ).arg( osync_group_get_configdir( mGroup ) ); - - TQFile file( fileName ); - if ( !file.open( IO_WriteOnly ) ) - return; - - TQTextStream s( &file ); - s.setEncoding( TQTextStream::UnicodeUTF8 ); - s << document.toString(); - file.close(); -} - - -Group::Group() - : mGroup( 0 ) -{ -} - -Group::~Group() -{ -} - -bool Group::isValid() const -{ - return ( mGroup != 0 ); -} - -Group::Iterator Group::begin() -{ - Iterator it( this ); - it.mPos = 0; - - return it; -} - -Group::Iterator Group::end() -{ - Iterator it( this ); - it.mPos = memberCount(); - - return it; -} - -void Group::setName( const TQString &name ) -{ - Q_ASSERT( mGroup ); - - osync_group_set_name( mGroup, name.latin1() ); -} - -TQString Group::name() const -{ - Q_ASSERT( mGroup ); - - return TQString::fromLatin1( osync_group_get_name( mGroup ) ); -} - -void Group::setLastSynchronization( const TQDateTime &dateTime ) -{ - Q_ASSERT( mGroup ); - - if ( dateTime.isValid() ) - osync_group_set_last_synchronization( mGroup, dateTime.toTime_t() ); -} - -TQDateTime Group::lastSynchronization() const -{ - Q_ASSERT( mGroup ); - - TQDateTime dateTime; - time_t time = osync_group_get_last_synchronization( mGroup ); - if ( time != 0 ) - dateTime.setTime_t( time ); - - return dateTime; -} - -Group::LockType Group::lock() -{ - Q_ASSERT( mGroup ); - - OSyncLockState state = osync_group_lock( mGroup ); - switch ( state ) { - default: - case OSYNC_LOCK_OK: - return LockOk; - break; - case OSYNC_LOCKED: - return Locked; - break; - case OSYNC_LOCK_STALE: - return LockStale; - break; - } -} - -void Group::unlock( bool removeFile ) -{ - Q_ASSERT( mGroup ); - - osync_group_unlock( mGroup, removeFile ); -} - -Member Group::addMember() -{ - Q_ASSERT( mGroup ); - - OSyncMember *omember = osync_member_new( mGroup ); - - Member member; - member.mMember = omember; - - save(); - - return member; -} - -void Group::removeMember( const Member &member ) -{ - Q_ASSERT( mGroup ); - - osync_group_remove_member( mGroup, member.mMember ); -} - -int Group::memberCount() const -{ - Q_ASSERT( mGroup ); - - return osync_group_num_members( mGroup ); -} - -Member Group::memberAt( int pos ) const -{ - Q_ASSERT( mGroup ); - - Member member; - - if ( pos < 0 || pos >= memberCount() ) - return member; - - member.mMember = osync_group_nth_member( mGroup, pos ); - - return member; -} - -int Group::filterCount() const -{ - Q_ASSERT( mGroup ); - - return osync_group_num_filters( mGroup ); -} - -Filter Group::filterAt( int pos ) -{ - Q_ASSERT( mGroup ); - - Filter filter; - - if ( pos < 0 || pos >= filterCount() ) - return filter; - - filter.mFilter = osync_group_nth_filter( mGroup, pos ); - - return filter; -} - -Result Group::save() -{ - Q_ASSERT( mGroup ); - - OSyncError *error = 0; - if ( !osync_group_save( mGroup, &error ) ) - return Result( &error ); - else - return Result(); -} - -void Group::setObjectTypeEnabled( const TQString &objectType, bool enabled ) -{ - Q_ASSERT( mGroup ); - - osync_group_set_objtype_enabled( mGroup, objectType.utf8(), enabled ); -} - -bool Group::isObjectTypeEnabled( const TQString &objectType ) const -{ - return osync_group_objtype_enabled( mGroup, objectType.utf8() ); -} - -GroupConfig Group::config() const -{ - Q_ASSERT( mGroup ); - - GroupConfig config; - config.mGroup = mGroup; - - return config; -} diff --git a/kitchensync/libqopensync/group.h b/kitchensync/libqopensync/group.h deleted file mode 100644 index fe9ceaebb..000000000 --- a/kitchensync/libqopensync/group.h +++ /dev/null @@ -1,217 +0,0 @@ -/* - This file is part of libqopensync. - - Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef TQSYNC_GROUP_H -#define TQSYNC_GROUP_H - -#include <tqdatetime.h> -#include <tqstringlist.h> - -#include <libqopensync/filter.h> -#include <libqopensync/member.h> - -class OSyncGroup; - -namespace QSync { - -/** - @internal - */ -class GroupConfig -{ - friend class Group; - - public: - GroupConfig(); - - TQStringList activeObjectTypes() const; - void setActiveObjectTypes( const TQStringList &objectTypes ); - - private: - OSyncGroup *mGroup; -}; - - -class Group -{ - friend class Engine; - friend class Environment; - - public: - enum LockType - { - LockOk, - Locked, - LockStale - }; - - Group(); - ~Group(); - - /** - Returns whether the object is a valid group. - */ - bool isValid() const; - - class Iterator - { - friend class Group; - - public: - Iterator( Group *group ) - : mGroup( group ), mPos( -1 ) - { - } - - Iterator( const Iterator &it ) - { - mGroup = it.mGroup; - mPos = it.mPos; - } - - Member operator*() - { - return mGroup->memberAt( mPos ); - } - - Iterator &operator++() { mPos++; return *this; } - Iterator &operator++( int ) { mPos++; return *this; } - Iterator &operator--() { mPos--; return *this; } - Iterator &operator--( int ) { mPos--; return *this; } - bool operator==( const Iterator &it ) { return mGroup == it.mGroup && mPos == it.mPos; } - bool operator!=( const Iterator &it ) { return mGroup == it.mGroup && mPos != it.mPos; } - - private: - Group *mGroup; - int mPos; - }; - - /** - Returns an iterator pointing to the first item in the member list. - This iterator equals end() if the member list is empty. - */ - Iterator begin(); - - /** - Returns an iterator pointing past the last item in the member list. - This iterator equals begin() if the member list is empty. - */ - Iterator end(); - - /** - Sets the name of the group. - */ - void setName( const TQString &name ); - - /** - Returns the name of the group. - */ - TQString name() const; - - /** - Sets the time of the last successfull synchronization. - */ - void setLastSynchronization( const TQDateTime &dateTime ); - - /** - Returns the time of the last successfull synchronization. - */ - TQDateTime lastSynchronization() const; - - /** - Locks the group. - - @returns The the result of the locking request. - */ - LockType lock(); - - /** - Unlocks the group. - - @param removeFile Whether the lock file shall be removed. - */ - void unlock( bool removeFile = true ); - - /** - Adds a new member to the group. - - @returns the new member. - */ - Member addMember(); - - /** - Removes a member from the group. - */ - void removeMember( const Member &member ); - - /** - Returns the number of members. - */ - int memberCount() const; - - /** - Returns the member at position @param pos. - */ - Member memberAt( int pos ) const; - - /** - Returns the number of filters. - */ - int filterCount() const; - - /** - Returns the filter at position @param pos. - */ - Filter filterAt( int pos ); - - /** - Set, if the object type with given name is enabled for synchronisation for - this group. - */ - void setObjectTypeEnabled( const TQString &objectType, bool enabled ); - - /** - Returns whether the object type with given name is enabled for synchronisation for - this group. - */ - bool isObjectTypeEnabled( const TQString &objectType ) const; - - /** - Saves the configuration to hard disc. - */ - Result save(); - - /** - Returns the config object of this group. - - Note: This method is only available for OpenSync 0.19 and 0.20. - */ - GroupConfig config() const; - - bool operator==( const Group &group ) const { return mGroup == group.mGroup; } - - private: - OSyncGroup *mGroup; -}; - -} - -#endif diff --git a/kitchensync/libqopensync/groupenv.cpp b/kitchensync/libqopensync/groupenv.cpp deleted file mode 100644 index f392fd103..000000000 --- a/kitchensync/libqopensync/groupenv.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - This file is part of libqopensync. - - Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include <opensync/opensync.h> -#include <opensync/opensync-group.h> - -#include "group.h" -#include "result.h" - -#include "groupenv.h" - -using namespace QSync; - -GroupEnv::GroupEnv() -{ - OSyncError *error = 0; - mGroupEnv = osync_group_env_new( &error ); -} - -GroupEnv::~GroupEnv() -{ - osync_group_env_free( mGroupEnv ); -} - -Result GroupEnv::initialize() -{ - Q_ASSERT( mGroupEnv ); - - OSyncError *error = 0; - if ( !osync_group_env_load_groups( mGroupEnv, NULL, &error ) ) - return Result( &error ); - else - return Result(); -} - -void GroupEnv::finalize() -{ -} - -int GroupEnv::groupCount() const -{ - Q_ASSERT( mGroupEnv ); - - return osync_group_env_num_groups( mGroupEnv ); -} - -Group GroupEnv::groupAt( int pos ) const -{ - Q_ASSERT( mGroupEnv ); - - Group group; - - if ( pos < 0 || pos >= groupCount() ) - return group; - - OSyncGroup *ogroup = osync_group_env_nth_group( mGroupEnv, pos ); - group.mGroup = ogroup; - - return group; -} - -Group GroupEnv::groupByName( const TQString &name ) const -{ - Q_ASSERT( mGroupEnv ); - - Group group; - - OSyncGroup *ogroup = osync_group_env_find_group( mGroupEnv, name.latin1() ); - if ( ogroup ) - group.mGroup = ogroup; - - return group; -} - -Group GroupEnv::addGroup( const TQString &name ) -{ - Q_ASSERT( mGroupEnv ); - - Group group; - OSyncError *error = 0; - - OSyncGroup *ogroup = osync_group_new( &error ); - if ( ogroup ) - group.mGroup = ogroup; - - group.setName( name ); - - if ( !osync_group_env_add_group( mGroupEnv, ogroup, &error ) ) { - Result res( &error ); - tqDebug( "Error on adding group: %s", res.message().latin1() ); - } - - return group; -} - -void GroupEnv::removeGroup( const Group &group ) -{ - Q_ASSERT( mGroupEnv ); - - group.cleanup(); - - osync_group_env_remove_group( mGroupEnv, group.mGroup ); -} diff --git a/kitchensync/libqopensync/groupenv.h b/kitchensync/libqopensync/groupenv.h deleted file mode 100644 index 80179826d..000000000 --- a/kitchensync/libqopensync/groupenv.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - This file is part of libqopensync. - - Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef OSYNC_GROUPENV_H -#define OSYNC_GROUPENV_H - -#include <tqstring.h> - -struct OSyncGroupEnv; - -namespace QSync { - -class Group; -class Result; - -class GroupEnv -{ - public: - GroupEnv(); - ~GroupEnv(); - - /** - Initializes the environment ( e.g. loads the groups and plugins ). - Has to be called before the groups or plugins can be accessed. - */ - Result initialize(); - - /** - Finalizes the environment ( e.g. unloads the groups and plugins ). - Should be the last call before the object is deleted. - */ - void finalize(); - - /** - Returns the number of groups. - */ - int groupCount() const; - - /** - Returns the group at position @param pos. - */ - Group groupAt( int pos ) const; - - /** - Returns a group by name or an invalid group when the group with this - name doesn't exists. - */ - Group groupByName( const TQString &name ) const; - - /** - Adds a new group to the environment. - - @returns the new group. - */ - Group addGroup( const TQString &name ); - - /** - Removes a group from the environment. - */ - void removeGroup( const Group &group ); - - private: - OSyncGroupEnv *mGroupEnv; -}; - -} - -#endif diff --git a/kitchensync/libqopensync/member.cpp b/kitchensync/libqopensync/member.cpp deleted file mode 100644 index b672dd0f6..000000000 --- a/kitchensync/libqopensync/member.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* - This file is part of libqopensync. - - Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include <opensync/opensync.h> -#include <stdlib.h> - -#include "member.h" - -using namespace QSync; - -Member::Member() - : mMember( 0 ) -{ -} - -Member::~Member() -{ -} - -bool Member::isValid() const -{ - OSyncError *error = 0; - - if ( !mMember ) - return false; - - if ( !osync_member_instance_plugin( mMember, pluginName().utf8(), &error ) ) { - tqDebug( "Plugin %s is not valid: %s", pluginName().latin1(), osync_error_print( &error ) ); - osync_error_free( &error ); - return false; - } - - return true; -} - -TQString Member::configurationDirectory() const -{ - Q_ASSERT( mMember ); - - return TQString::fromLatin1( osync_member_get_configdir( mMember ) ); -} - -TQString Member::pluginName() const -{ - Q_ASSERT( mMember ); - - return TQString::fromLatin1( osync_member_get_pluginname( mMember ) ); -} - -Plugin Member::plugin() const -{ - Q_ASSERT( mMember ); - - Plugin plugin; - - OSyncPlugin *oplugin = osync_member_get_plugin( mMember ); - if ( oplugin ) - plugin.mPlugin = oplugin; - - return plugin; -} - -int Member::id() const -{ - Q_ASSERT( mMember ); - - return osync_member_get_id( mMember ); -} - -void Member::setName( const TQString &name ) -{ - Q_ASSERT( mMember ); - - osync_member_set_name( mMember, (const char*)name.utf8() ); -} - -TQString Member::name() const -{ - Q_ASSERT( mMember ); - - return TQString::fromUtf8( osync_member_get_name( mMember ) ); -} - -void Member::setConfiguration( const TQByteArray &configurationData ) -{ - Q_ASSERT( mMember ); - - osync_member_set_config( mMember, configurationData.data(), configurationData.size() ); -} - -Result Member::configuration( TQByteArray &configurationData, bool useDefault ) -{ - Q_ASSERT( mMember ); - - char *data; - int size; - - OSyncError *error = 0; - osync_bool ok = false; - if ( useDefault ) - ok = osync_member_get_config_or_default( mMember, &data, &size, &error ); - else - ok = osync_member_get_config( mMember, &data, &size, &error ); - - if ( !ok ) { - return Result( &error ); - } else { - configurationData.resize( size ); - memcpy( configurationData.data(), data, size ); - - return Result(); - } -} - -Result Member::save() -{ - Q_ASSERT( mMember ); - - OSyncError *error = 0; - if ( !osync_member_save( mMember, &error ) ) - return Result( &error ); - else - return Result(); -} - -Result Member::instance( const Plugin &plugin ) -{ - OSyncError *error = 0; - if ( !osync_member_instance_plugin( mMember, plugin.name().utf8(), &error ) ) - return Result( &error ); - else - return Result(); -} - -bool Member::operator==( const Member &member ) const -{ - return mMember == member.mMember; -} - -TQString Member::scanDevices( const TQString &query ) -{ - Q_ASSERT( mMember ); - - OSyncError *error = 0; - char *data = (char*)osync_member_call_plugin( mMember, "scan_devices", const_cast<char*>( query.utf8().data() ), &error ); - if ( error != 0 ) { - osync_error_free( &error ); - return TQString(); - } else { - TQString xml = TQString::fromUtf8( data ); - free( data ); - return xml; - } -} - -bool Member::testConnection( const TQString &configuration ) -{ - Q_ASSERT( mMember ); - - OSyncError *error = 0; - int *result = (int*)osync_member_call_plugin( mMember, "test_connection", const_cast<char*>( configuration.utf8().data() ), &error ); - if ( error != 0 ) { - osync_error_free( &error ); - return false; - } else { - bool value = ( *result == 1 ? true : false ); - free( result ); - return value; - } -} diff --git a/kitchensync/libqopensync/member.h b/kitchensync/libqopensync/member.h deleted file mode 100644 index 6fa3ee737..000000000 --- a/kitchensync/libqopensync/member.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - This file is part of libqopensync. - - Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef TQSYNC_MEMBER_H -#define TQSYNC_MEMBER_H - -#include <libqopensync/plugin.h> -#include <libqopensync/result.h> -#include <libqopensync/plugin.h> - -class OSyncMember; - -namespace QSync { - -class Member -{ - friend class Group; - friend class SyncChange; - friend class SyncMemberUpdate; - - public: - Member(); - ~Member(); - - /** - Returns whether the member object is valid. - */ - bool isValid() const; - - /** - Returns the configuration directory. - */ - TQString configurationDirectory() const; - - /** - Returns the name of the plugin, the member belongs to. - */ - TQString pluginName() const; - - /** - Returns the plugin, the member belongs to. - */ - Plugin plugin() const; - - /** - Returns the id of the plugin. - */ - int id() const; - - /** - Sets the name of this member. - */ - void setName( const TQString &name ); - - /** - Returns the name of this member. - */ - TQString name() const; - - /** - Sets the configuration data as byte array. The developer has to decide the - type of the data ( e.g. xml, plain text, binary ). - */ - void setConfiguration( const TQByteArray &configurationData ); - - /** - Gets the configuration data as byte array. The developer has to decide the - type of the data ( e.g. xml, plain text, binary ). - - @param useDefault If set to true, return default config, if no config - exists. If set to false, return error when no config - exists. - - @returns The result of this operation. - */ - Result configuration( TQByteArray &configurationData, - bool useDefault = true ); - - /** - Saves the changes to the configuration to hard disc. - */ - Result save(); - - /** - Make this member an instance of the given plugin. - */ - Result instance( const Plugin & ); - - bool operator==( const Member& ) const; - - /** - This method can be used to query the plugin for scanning devices. - The @param query is a plugin specific xml document as well as - the return value. - */ - TQString scanDevices( const TQString &query ); - - /** - This method can be used to test whether the plugin can connect - to the device with the given configuration. - */ - bool testConnection( const TQString &configuration ); - - private: - OSyncMember *mMember; -}; - -} - -#endif - diff --git a/kitchensync/libqopensync/plugin.cpp b/kitchensync/libqopensync/plugin.cpp deleted file mode 100644 index acd54447a..000000000 --- a/kitchensync/libqopensync/plugin.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - This file is part of libqopensync. - - Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include <opensync/opensync.h> - -#include "plugin.h" - -using namespace QSync; - -Plugin::Plugin() - : mPlugin( 0 ) -{ -} - -Plugin::~Plugin() -{ -} - -bool Plugin::isValid() const -{ - return ( mPlugin != 0 ); -} - -TQString Plugin::name() const -{ - Q_ASSERT( mPlugin ); - - return TQString::fromLatin1( osync_plugin_get_name( mPlugin ) ); -} - -TQString Plugin::longName() const -{ - Q_ASSERT( mPlugin ); - - return TQString::fromLatin1( osync_plugin_get_longname( mPlugin ) ); -} - -TQString Plugin::description() const -{ - Q_ASSERT( mPlugin ); - - return TQString::fromLatin1( osync_plugin_get_description( mPlugin ) ); -} - diff --git a/kitchensync/libqopensync/plugin.h b/kitchensync/libqopensync/plugin.h deleted file mode 100644 index 1c6c219eb..000000000 --- a/kitchensync/libqopensync/plugin.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - This file is part of libqopensync. - - Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef TQSYNC_PLUGIN_H -#define TQSYNC_PLUGIN_H - -#include <tqstring.h> - -class OSyncPlugin; - -namespace QSync { - -class Plugin -{ - friend class Environment; - friend class Member; - - public: - Plugin(); - ~Plugin(); - - /** - Returns whether the object is a valid plugin. - */ - bool isValid() const; - - /** - Returns the name of the plugin. - */ - TQString name() const; - - /** - Returns the long name of the plugin. - */ - TQString longName() const; - - /** - Returns the description of the plugin. - */ - TQString description() const; - - private: - OSyncPlugin *mPlugin; -}; - -} - -#endif - diff --git a/kitchensync/libqopensync/pluginenv.cpp b/kitchensync/libqopensync/pluginenv.cpp deleted file mode 100644 index 5efcb97b8..000000000 --- a/kitchensync/libqopensync/pluginenv.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - This file is part of libqopensync. - - Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> - Copyright (c) 2007 Daniel Gollub <dgollub@suse.de> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include <opensync/opensync.h> -#include <opensync/opensync-plugin.h> - -#include "plugin.h" -#include "result.h" - -#include "pluginenv.h" - -using namespace QSync; - -PluginEnv::PluginEnv() -{ - OSyncError *error = 0; - mPluginEnv = osync_plugin_env_new( &error ); -} - -PluginEnv::~PluginEnv() -{ - osync_plugin_env_free( mPluginEnv ); -} - -Result PluginEnv::initialize() -{ - OSyncError *error = 0; - if ( !osync_plugin_env_load( mPluginEnv, NULL, &error ) ) - return Result( &error ); - else - return Result(); -} - -Result PluginEnv::finalize() -{ - osync_plugin_env_free( mPluginEnv ); - return Result(); -} - -int PluginEnv::pluginCount() const -{ - return osync_plugin_env_num_plugins( mPluginEnv ); -} - -Plugin PluginEnv::pluginAt( int pos ) const -{ - Plugin plugin; - - if ( pos < 0 || pos >= pluginCount() ) - return plugin; - - OSyncPlugin *oplugin = osync_plugin_env_nth_plugin( mPluginEnv, pos ); - plugin.mPlugin = oplugin; - - return plugin; -} - -Plugin PluginEnv::pluginByName( const TQString &name ) const -{ - Plugin plugin; - - OSyncPlugin *oplugin = osync_plugin_env_find_plugin( mPluginEnv, name.latin1() ); - if ( oplugin ) - plugin.mPlugin = oplugin; - - return plugin; -} - -/* -Conversion PluginEnv::conversion() const -{ - Conversion conversion; - conversion.mPluginEnv = mPluginEnv; - - return conversion; -} -*/ diff --git a/kitchensync/libqopensync/pluginenv.h b/kitchensync/libqopensync/pluginenv.h deleted file mode 100644 index 2acc4e54a..000000000 --- a/kitchensync/libqopensync/pluginenv.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - This file is part of libqopensync. - - Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> - Copyright (c) 2007 Daniel Gollub <dgollub@suse.de> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef OSYNC_PLUGINENV_H -#define OSYNC_PLUGINENV_H - -#include <tqstring.h> - -struct OSyncPluginEnv; - -namespace QSync { - -class Plugin; -class Result; - -class PluginEnv -{ - public: - PluginEnv(); - ~PluginEnv(); - - /** - Initializes the environment ( e.g. loads the groups and plugins ). - Has to be called before the groups or plugins can be accessed. - */ - Result initialize(); - - /** - Finalizes the environment ( e.g. unloads the groups and plugins ). - Should be the last call before the object is deleted. - */ - Result finalize(); - - /** - Returns the number of plugins. - */ - int pluginCount() const; - - /** - Returns the plugin at position @param pos. - */ - Plugin pluginAt( int pos ) const; - - /** - Returns a plugin by name or an invalid plugin when the plugin with this - name doesn't exists. - */ - Plugin pluginByName( const TQString &name ) const; - - /** - Returns the conversion object of this environment. - */ -// Conversion conversion() const; - - private: - OSyncPluginEnv *mPluginEnv; -}; - -} - -#endif diff --git a/kitchensync/libqopensync/result.cpp b/kitchensync/libqopensync/result.cpp deleted file mode 100644 index d38c32a3d..000000000 --- a/kitchensync/libqopensync/result.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/* - This file is part of libqopensync. - - Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "result.h" - -#include <opensync/opensync.h> - -using namespace QSync; - -Result::Result() - : mType( NoError ) -{ -} - -Result::Result( Type type ) - : mType( type ) -{ -} - -Result::Result( OSyncError **error, bool deleteError ) -{ - OSyncErrorType otype = osync_error_get_type( error ); - Type type; - - switch ( otype ) { - case OSYNC_NO_ERROR: - type = NoError; - break; - default: - case OSYNC_ERROR_GENERIC: - type = GenericError; - break; - case OSYNC_ERROR_IO_ERROR: - type = IOError; - break; - case OSYNC_ERROR_NOT_SUPPORTED: - type = NotSupported; - break; - case OSYNC_ERROR_TIMEOUT: - type = Timeout; - break; - case OSYNC_ERROR_DISCONNECTED: - type = Disconnected; - break; - case OSYNC_ERROR_FILE_NOT_FOUND: - type = FileNotFound; - break; - case OSYNC_ERROR_EXISTS: - type = Exists; - break; - case OSYNC_ERROR_CONVERT: - type = Convert; - break; - case OSYNC_ERROR_MISCONFIGURATION: - type = Misconfiguration; - break; - case OSYNC_ERROR_INITIALIZATION: - type = Initialization; - break; - case OSYNC_ERROR_PARAMETER: - type = Parameter; - break; - case OSYNC_ERROR_EXPECTED: - type = Expected; - break; - case OSYNC_ERROR_NO_CONNECTION: - type = NoConnection; - break; - case OSYNC_ERROR_TEMPORARY: - type = Temporary; - break; - case OSYNC_ERROR_LOCKED: - type = Locked; - break; - case OSYNC_ERROR_PLUGIN_NOT_FOUND: - type = PluginNotFound; - break; - } - - mType = type; - mName = TQString::fromUtf8( osync_error_get_name( error ) ); - mMessage = TQString::fromUtf8( osync_error_print( error ) ); - - if ( deleteError ) - osync_error_free( error ); -} - -Result::~Result() -{ -} - -void Result::setName( const TQString &name ) -{ - mName = name; -} - -TQString Result::name() const -{ - return mName; -} - -void Result::setMessage( const TQString &message ) -{ - mMessage = message; -} - -TQString Result::message() const -{ - return mMessage; -} - -void Result::setType( Type type ) -{ - mType = type; -} - -Result::Type Result::type() const -{ - return mType; -} - -bool Result::isError() const -{ - return mType != NoError; -} - -Result::operator bool () const -{ - return ( mType != NoError ); -} - diff --git a/kitchensync/libqopensync/result.h b/kitchensync/libqopensync/result.h deleted file mode 100644 index 29d3dad8b..000000000 --- a/kitchensync/libqopensync/result.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - This file is part of libqopensync. - - Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef TQSYNC_RESULT_H -#define TQSYNC_RESULT_H - -#include <tqstring.h> - -struct OSyncError; - -namespace QSync { - -class Result -{ - public: - /** - Result types. - */ - enum Type { - NoError, - GenericError, - IOError, - NotSupported, - Timeout, - Disconnected, - FileNotFound, - Exists, - Convert, - Misconfiguration, - Initialization, - Parameter, - Expected, - NoConnection, - Temporary, - Locked, - PluginNotFound - }; - - /** - Constructs a NoError result. - */ - Result(); - - /** - Constructs a result of the given type. - */ - Result( Type type ); - - /** - Construct Result from OpenSync error object. Deletes the OpenSync error - object. - */ - Result( OSyncError **, bool deleteError = true ); - - /** - Destroys the result. - */ - ~Result(); - - /** - Sets the name of the result. - */ - void setName( const TQString &name ); - - /** - Returns the name of the result. - */ - TQString name() const; - - /** - Sets the message text of the result. - */ - void setMessage( const TQString &message ); - - /** - Returns the message text of the result. - */ - TQString message() const; - - /** - Sets the type of the result. - */ - void setType( Type type ); - - /** - Returns the type of the result. - */ - Type type() const; - - /** - Reimplemented boolean operator. - */ - operator bool () const; - - /** - Return true, if this Result is an error, return false otherwise. - */ - bool isError() const; - - private: - TQString mName; - TQString mMessage; - Type mType; -}; - -} - -#endif diff --git a/kitchensync/libqopensync/syncchange.cpp b/kitchensync/libqopensync/syncchange.cpp deleted file mode 100644 index 5dd72d7ff..000000000 --- a/kitchensync/libqopensync/syncchange.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - This file is part of libqopensync. - - Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include <opensync/file.h> -#include <opensync/opensync.h> - -#include "syncchange.h" - -using namespace QSync; - -SyncChange::SyncChange() -{ -} - -SyncChange::SyncChange( OSyncChange *change ) -{ - mSyncChange = change; -} - -SyncChange::~SyncChange() -{ -} - -bool SyncChange::isValid() const -{ - return ( mSyncChange != 0 ); -} - -void SyncChange::setUid( const TQString &uid ) -{ - osync_change_set_uid( mSyncChange, uid.utf8() ); -} - -TQString SyncChange::uid() const -{ - return TQString::fromUtf8( osync_change_get_uid( mSyncChange ) ); -} - -void SyncChange::setHash( const TQString &hash ) -{ - osync_change_set_hash( mSyncChange, hash.utf8() ); -} - -TQString SyncChange::hash() const -{ - return TQString::fromUtf8( osync_change_get_hash( mSyncChange ) ); -} - -void SyncChange::setData( const TQString &data ) -{ - osync_change_set_data( mSyncChange, const_cast<char*>( data.utf8().data() ), data.utf8().size(), true ); -} - -TQString SyncChange::data() const -{ - int size = osync_change_get_datasize( mSyncChange ); - - TQString content; - if ( objectFormatName() == "file" ) { - fileFormat *format = (fileFormat*)osync_change_get_data( mSyncChange ); - if ( format ) - content = TQString::fromUtf8( format->data, format->size ); - } else - content = TQString::fromUtf8( osync_change_get_data( mSyncChange ), size ); - - return content; -} - -bool SyncChange::hasData() const -{ - return osync_change_has_data( mSyncChange ); -} - -TQString SyncChange::objectFormatName() const -{ - OSyncObjFormat *format = osync_change_get_objformat( mSyncChange ); - Q_ASSERT( format ); - - return TQString::fromUtf8( osync_objformat_get_name( format ) ); -} - -Member SyncChange::member() const -{ - OSyncMember *omember = osync_change_get_member( mSyncChange ); - - Member m; - m.mMember = omember; - - return m; -} - -void SyncChange::setChangeType( Type changeType ) -{ - OSyncChangeType ochangeType; - - switch ( changeType ) { - case AddedChange: - ochangeType = CHANGE_ADDED; - break; - case UnmodifiedChange: - ochangeType = CHANGE_UNMODIFIED; - break; - case DeletedChange: - ochangeType = CHANGE_DELETED; - break; - case ModifiedChange: - ochangeType = CHANGE_MODIFIED; - break; - case UnknownChange: - default: - ochangeType = CHANGE_UNKNOWN; - break; - } - - osync_change_set_changetype( mSyncChange, ochangeType ); -} - -SyncChange::Type SyncChange::changeType() const -{ - OSyncChangeType ochangeType = osync_change_get_changetype( mSyncChange ); - - switch ( ochangeType ) { - case CHANGE_ADDED: - return AddedChange; - break; - case CHANGE_UNMODIFIED: - return UnmodifiedChange; - break; - case CHANGE_DELETED: - return DeletedChange; - break; - case CHANGE_MODIFIED: - return ModifiedChange; - break; - case CHANGE_UNKNOWN: - default: - return UnknownChange; - break; - } -} - diff --git a/kitchensync/libqopensync/syncchange.h b/kitchensync/libqopensync/syncchange.h deleted file mode 100644 index 4b356dcf5..000000000 --- a/kitchensync/libqopensync/syncchange.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - This file is part of libqopensync. - - Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef TQSYNC_SYNCCHANGE_H -#define TQSYNC_SYNCCHANGE_H - -#include <libqopensync/member.h> - -class OSyncChange; - -namespace QSync { - -class SyncChange -{ - friend class SyncMapping; - - public: - enum Type - { - UnknownChange, - AddedChange, - UnmodifiedChange, - DeletedChange, - ModifiedChange - }; - - SyncChange(); - SyncChange( OSyncChange* ); - ~SyncChange(); - - /** - Returns whether it's a valid SyncChange. - */ - bool isValid() const; - - /** - Sets the uid of this change. - */ - void setUid( const TQString &uid ); - - /** - Returns the uid of this change. - */ - TQString uid() const; - - /** - Sets the hash of this change. - */ - void setHash( const TQString &hash ); - - /** - Returns the hash of this change. - */ - TQString hash() const; - - /** - Sets the data provided by the plugin. - */ - void setData( const TQString &data ); - - /** - Returns the data provided by the plugin. - */ - TQString data() const; - - /** - Returns whether the change contains data. - */ - bool hasData() const; - - /** - Returns the object format name. - */ - TQString objectFormatName() const; - - /** - Returns the parent member of this change. - */ - Member member() const; - - /** - Sets the change type. - */ - void setChangeType( Type changeType ); - - /** - Returns the change type. - */ - Type changeType() const; - - private: - OSyncChange *mSyncChange; -}; - -} - -#endif - diff --git a/kitchensync/libqopensync/syncmapping.cpp b/kitchensync/libqopensync/syncmapping.cpp deleted file mode 100644 index 95939ab85..000000000 --- a/kitchensync/libqopensync/syncmapping.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - This file is part of libqopensync. - - Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include <tqstring.h> -#include <osengine/engine.h> - -#include "syncmapping.h" - -using namespace QSync; - -SyncMapping::SyncMapping() - : mEngine( 0 ), mMapping( 0 ) -{ -} - -SyncMapping::SyncMapping( OSyncMapping *mapping, OSyncEngine *engine ) - : mEngine( engine ), mMapping( mapping ) -{ -} - -SyncMapping::~SyncMapping() -{ -} - -bool SyncMapping::isValid() const -{ - return ( mEngine != 0 && mMapping != 0 ); -} - -long long SyncMapping::id() const -{ - Q_ASSERT( mMapping ); - - return osengine_mapping_get_id( mMapping ); -} - -void SyncMapping::duplicate() -{ - Q_ASSERT( mEngine ); - Q_ASSERT( mMapping ); - - osengine_mapping_duplicate( mEngine, mMapping ); -} - -void SyncMapping::solve( const SyncChange &change ) -{ - Q_ASSERT( mEngine ); - Q_ASSERT( mMapping ); - Q_ASSERT( change.isValid() ); - - osengine_mapping_solve( mEngine, mMapping, change.mSyncChange ); -} - -void SyncMapping::ignore() -{ - Q_ASSERT( mEngine ); - Q_ASSERT( mMapping ); - - //TODO: error should be returned as Result - OSyncError *error = 0; - osengine_mapping_ignore_conflict( mEngine, mMapping, &error ); -} - -int SyncMapping::changesCount() const -{ - Q_ASSERT( mMapping ); - - return osengine_mapping_num_changes( mMapping ); -} - -SyncChange SyncMapping::changeAt( int pos ) -{ - Q_ASSERT( mMapping ); - - if ( pos < 0 || pos >= osengine_mapping_num_changes( mMapping ) ) - return SyncChange(); - - OSyncChange *ochange = osengine_mapping_nth_change( mMapping, pos ); - - return SyncChange( ochange ); -} - diff --git a/kitchensync/libqopensync/syncmapping.h b/kitchensync/libqopensync/syncmapping.h deleted file mode 100644 index a9eee6709..000000000 --- a/kitchensync/libqopensync/syncmapping.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - This file is part of libqopensync. - - Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef TQSYNC_SYNCMAPPING_H -#define TQSYNC_SYNCMAPPING_H - -#include <libqopensync/syncchange.h> - -class OSyncEngine; -class OSyncMapping; - -namespace QSync { - -class SyncMapping -{ - friend class SyncMappingUpdate; - - public: - SyncMapping(); - SyncMapping( OSyncMapping*, OSyncEngine* ); - ~SyncMapping(); - - bool isValid() const; - - long long id() const; - - void duplicate(); - void solve( const SyncChange &change ); - void ignore(); - - int changesCount() const; - SyncChange changeAt( int pos ); - - private: - OSyncEngine *mEngine; - OSyncMapping *mMapping; -}; - -} - -#endif diff --git a/kitchensync/libqopensync/syncupdates.cpp b/kitchensync/libqopensync/syncupdates.cpp deleted file mode 100644 index 653ccf7f3..000000000 --- a/kitchensync/libqopensync/syncupdates.cpp +++ /dev/null @@ -1,251 +0,0 @@ -/* - This file is part of libqopensync. - - Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include <osengine/engine.h> - -#include "syncupdates.h" - -using namespace QSync; - -SyncMemberUpdate::SyncMemberUpdate() -{ -} - -SyncMemberUpdate::SyncMemberUpdate( OSyncMemberUpdate *update ) -{ - switch ( update->type ) { - case MEMBER_CONNECTED: - mType = Connected; - break; - case MEMBER_SENT_CHANGES: - mType = SentChanges; - break; - case MEMBER_COMMITTED_ALL: - mType = CommittedAll; - break; - case MEMBER_DISCONNECTED: - mType = Disconnected; - break; - case MEMBER_CONNECT_ERROR: - mType = ConnectError; - break; - case MEMBER_GET_CHANGES_ERROR: - mType = GetChangesError; - break; - case MEMBER_COMMITTED_ALL_ERROR: - mType = CommittedAllError; - break; - case MEMBER_SYNC_DONE_ERROR: - mType = SyncDoneError; - break; - case MEMBER_DISCONNECT_ERROR: - mType = DisconnectedError; - break; - } - - if ( update->error ) - mResult = Result( &(update->error) ); - - mMember.mMember = update->member; -} - -SyncMemberUpdate::~SyncMemberUpdate() -{ -} - -SyncMemberUpdate::Type SyncMemberUpdate::type() const -{ - return mType; -} - -Result SyncMemberUpdate::result() const -{ - return mResult; -} - -Member SyncMemberUpdate::member() const -{ - return mMember; -} - - -SyncChangeUpdate::SyncChangeUpdate() -{ -} - -SyncChangeUpdate::SyncChangeUpdate( OSyncChangeUpdate *update ) -{ - switch ( update->type ) { - case CHANGE_RECEIVED: - mType = Received; - break; - case CHANGE_RECEIVED_INFO: - mType = ReceivedInfo; - break; - case CHANGE_SENT: - mType = Sent; - break; - case CHANGE_WRITE_ERROR: - mType = WriteError; - break; - case CHANGE_RECV_ERROR: - mType = ReceiveError; - break; - } - - if ( update->error ) - mResult = Result( &(update->error) ); - - mChange = SyncChange( update->change ); - mMemberId = update->member_id; - mMappingId = update->mapping_id; -} - -SyncChangeUpdate::~SyncChangeUpdate() -{ -} - -SyncChangeUpdate::Type SyncChangeUpdate::type() const -{ - return mType; -} - -Result SyncChangeUpdate::result() const -{ - return mResult; -} - -SyncChange SyncChangeUpdate::change() const -{ - return mChange; -} - -int SyncChangeUpdate::memberId() const -{ - return mMemberId; -} - -int SyncChangeUpdate::mappingId() const -{ - return mMappingId; -} - -SyncMappingUpdate::SyncMappingUpdate() -{ -} - -SyncMappingUpdate::SyncMappingUpdate( OSyncMappingUpdate *update, OSyncEngine *engine ) -{ - switch ( update->type ) { - case MAPPING_SOLVED: - mType = Solved; - break; - case MAPPING_SYNCED: - mType = Synced; - break; - case MAPPING_WRITE_ERROR: - mType = WriteError; - break; - } - - if ( update->error ) - mResult = Result( &(update->error) ); - - mWinner = update->winner; - mMapping.mEngine = engine; - mMapping.mMapping = update->mapping; -} - -SyncMappingUpdate::~SyncMappingUpdate() -{ -} - -SyncMappingUpdate::Type SyncMappingUpdate::type() const -{ - return mType; -} - -Result SyncMappingUpdate::result() const -{ - return mResult; -} - -long long int SyncMappingUpdate::winner() const -{ - return mWinner; -} - -SyncMapping SyncMappingUpdate::mapping() const -{ - return mMapping; -} - -SyncEngineUpdate::SyncEngineUpdate() -{ -} - -SyncEngineUpdate::SyncEngineUpdate( OSyncEngineUpdate *update ) -{ - switch ( update->type ) { - case ENG_ENDPHASE_CON: - mType = EndPhaseConnected; - break; - case ENG_ENDPHASE_READ: - mType = EndPhaseRead; - break; - case ENG_ENDPHASE_WRITE: - mType = EndPhaseWrite; - break; - case ENG_ENDPHASE_DISCON: - mType = EndPhaseDisconnected; - break; - case ENG_ERROR: - mType = Error; - break; - case ENG_SYNC_SUCCESSFULL: - mType = SyncSuccessfull; - break; - case ENG_PREV_UNCLEAN: - mType = PrevUnclean; - break; - case ENG_END_CONFLICTS: - mType = EndConflicts; - break; - } - - if ( update->error ) - mResult = Result( &(update->error) ); -} - -SyncEngineUpdate::~SyncEngineUpdate() -{ -} - -SyncEngineUpdate::Type SyncEngineUpdate::type() const -{ - return mType; -} - -Result SyncEngineUpdate::result() const -{ - return mResult; -} - diff --git a/kitchensync/libqopensync/syncupdates.h b/kitchensync/libqopensync/syncupdates.h deleted file mode 100644 index 29f2ce782..000000000 --- a/kitchensync/libqopensync/syncupdates.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - This file is part of libqopensync. - - Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef TQSYNC_SYNCUPDATES_H -#define TQSYNC_SYNCUPDATES_H - -#include <libqopensync/member.h> -#include <libqopensync/result.h> -#include <libqopensync/syncchange.h> -#include <libqopensync/syncmapping.h> - -class OSyncMemberUpdate; -class OSyncChangeUpdate; -class OSyncMappingUpdate; -class OSyncEngineUpdate; -class OSyncMemberUpdate; - -namespace QSync { - -class SyncMemberUpdate -{ - friend class CallbackHandler; - - public: - enum Type { - Connected, - SentChanges, - CommittedAll, - Disconnected, - ConnectError, - GetChangesError, - CommittedAllError, - SyncDoneError, - DisconnectedError - }; - - SyncMemberUpdate(); - SyncMemberUpdate( OSyncMemberUpdate* ); - ~SyncMemberUpdate(); - - Type type() const; - Result result() const; - Member member() const; - - private: - Type mType; - Result mResult; - Member mMember; -}; - -class SyncChangeUpdate -{ - friend class CallbackHandler; - - public: - enum Type { - Received = 1, - ReceivedInfo, - Sent, - WriteError, - ReceiveError - }; - - SyncChangeUpdate(); - SyncChangeUpdate( OSyncChangeUpdate* ); - ~SyncChangeUpdate(); - - Type type() const; - Result result() const; - SyncChange change() const; - int memberId() const; - int mappingId() const; - - private: - Type mType; - Result mResult; - SyncChange mChange; - int mMemberId; - int mMappingId; -}; - -class SyncMappingUpdate -{ - friend class CallbackHandler; - - public: - enum Type { - Solved = 1, - Synced, - WriteError - }; - - SyncMappingUpdate(); - SyncMappingUpdate( OSyncMappingUpdate*, OSyncEngine* ); - ~SyncMappingUpdate(); - - Type type() const; - Result result() const; - long long int winner() const; - SyncMapping mapping() const; - - private: - Type mType; - Result mResult; - long long int mWinner; - SyncMapping mMapping; -}; - -class SyncEngineUpdate -{ - friend class CallbackHandler; - - public: - enum Type { - EndPhaseConnected = 1, - EndPhaseRead, - EndPhaseWrite, - EndPhaseDisconnected, - Error, - SyncSuccessfull, - PrevUnclean, - EndConflicts - }; - - SyncEngineUpdate(); - SyncEngineUpdate( OSyncEngineUpdate* ); - ~SyncEngineUpdate(); - - Type type() const; - Result result() const; - - private: - Type mType; - Result mResult; -}; - -} - -#endif |