summaryrefslogtreecommitdiffstats
path: root/kitchensync/libqopensync
diff options
context:
space:
mode:
Diffstat (limited to 'kitchensync/libqopensync')
-rw-r--r--kitchensync/libqopensync/Makefile.am12
-rw-r--r--kitchensync/libqopensync/callbackhandler.cpp23
-rw-r--r--kitchensync/libqopensync/callbackhandler.h6
-rw-r--r--kitchensync/libqopensync/conversion.cpp17
-rw-r--r--kitchensync/libqopensync/conversion.h6
-rw-r--r--kitchensync/libqopensync/engine.cpp40
-rw-r--r--kitchensync/libqopensync/engine.h11
-rw-r--r--kitchensync/libqopensync/filter.cpp1
-rw-r--r--kitchensync/libqopensync/group.cpp143
-rw-r--r--kitchensync/libqopensync/group.h104
-rw-r--r--kitchensync/libqopensync/groupenv.cpp121
-rw-r--r--kitchensync/libqopensync/groupenv.h86
-rw-r--r--kitchensync/libqopensync/member.cpp73
-rw-r--r--kitchensync/libqopensync/member.h21
-rw-r--r--kitchensync/libqopensync/plugin.cpp1
-rw-r--r--kitchensync/libqopensync/plugin.h2
-rw-r--r--kitchensync/libqopensync/pluginenv.cpp96
-rw-r--r--kitchensync/libqopensync/pluginenv.h80
-rw-r--r--kitchensync/libqopensync/result.cpp2
-rw-r--r--kitchensync/libqopensync/syncchange.cpp51
-rw-r--r--kitchensync/libqopensync/syncchange.h5
-rw-r--r--kitchensync/libqopensync/syncmapping.cpp43
-rw-r--r--kitchensync/libqopensync/syncmapping.h6
-rw-r--r--kitchensync/libqopensync/syncupdates.cpp102
-rw-r--r--kitchensync/libqopensync/syncupdates.h41
25 files changed, 707 insertions, 386 deletions
diff --git a/kitchensync/libqopensync/Makefile.am b/kitchensync/libqopensync/Makefile.am
index 2e12df6ca..772146a47 100644
--- a/kitchensync/libqopensync/Makefile.am
+++ b/kitchensync/libqopensync/Makefile.am
@@ -2,16 +2,20 @@ INCLUDES = -I$(top_srcdir)/kitchensync/src \
-I$(top_srcdir)/kitchensync \
-I$(top_srcdir) \
$(OPENSYNC_CFLAGS) \
- $(OPENSYNCENGINE_CFLAGS) \
+ $(GLIB_CFLAGS) \
$(all_includes)
lib_LTLIBRARIES = libqopensync.la
-libqopensync_la_SOURCES = callbackhandler.cpp conversion.cpp engine.cpp environment.cpp filter.cpp group.cpp \
+libqopensync_la_SOURCES = callbackhandler.cpp engine.cpp groupenv.cpp pluginenv.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_KDEUI) $(OPENSYNC_LIBS) $(OPENSYNCENGINE_LIBS)
+
+# FIXME: -no-undefined break the build for some unkown reason - libopensync broken?!
+#libqopensync_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -no-undefined
+libqopensync_la_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+libqopensync_la_LIBADD = $(LIB_KDEUI) $(OPENSYNC_LIBS)
+
METASOURCES = AUTO
diff --git a/kitchensync/libqopensync/callbackhandler.cpp b/kitchensync/libqopensync/callbackhandler.cpp
index 504afea99..894261b37 100644
--- a/kitchensync/libqopensync/callbackhandler.cpp
+++ b/kitchensync/libqopensync/callbackhandler.cpp
@@ -19,12 +19,13 @@
Boston, MA 02110-1301, USA.
*/
-#include <osengine/engine.h>
-
-#include <libqopensync/engine.h>
+#include <opensync/opensync.h>
+#include <opensync/opensync-engine.h>
#include <tqapplication.h>
+#include "engine.h"
+
#include "callbackhandler.h"
using namespace QSync;
@@ -111,11 +112,11 @@ 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 );
+ osync_engine_set_conflict_callback( engine->mEngine, &conflict_callback, this );
+ osync_engine_set_changestatus_callback( engine->mEngine, &change_callback, this );
+ osync_engine_set_mappingstatus_callback( engine->mEngine, &mapping_callback, this );
+ osync_engine_set_enginestatus_callback( engine->mEngine, &engine_callback, this );
+ osync_engine_set_memberstatus_callback( engine->mEngine, &member_callback, this );
}
Engine* CallbackHandler::engine() const
@@ -143,7 +144,7 @@ void CallbackHandler::customEvent( TQCustomEvent *event )
}
}
-void CallbackHandler::conflict_callback( OSyncEngine *engine, OSyncMapping *omapping, void *data )
+void CallbackHandler::conflict_callback( OSyncEngine *engine, OSyncMappingEngine *omapping, void *data )
{
SyncMapping mapping( omapping, engine );
@@ -152,7 +153,7 @@ void CallbackHandler::conflict_callback( OSyncEngine *engine, OSyncMapping *omap
TQApplication::postEvent( handler, new ConflictEvent( mapping ) );
}
-void CallbackHandler::change_callback( OSyncEngine*, OSyncChangeUpdate *update, void *data )
+void CallbackHandler::change_callback( OSyncChangeUpdate *update, void *data )
{
SyncChangeUpdate change( update );
@@ -170,7 +171,7 @@ void CallbackHandler::mapping_callback( OSyncMappingUpdate *update, void *data )
TQApplication::postEvent( handler, new MappingEvent( mapping ) );
}
-void CallbackHandler::engine_callback( OSyncEngine*, OSyncEngineUpdate *update, void *data )
+void CallbackHandler::engine_callback( OSyncEngineUpdate *update, void *data )
{
SyncEngineUpdate engine( update );
diff --git a/kitchensync/libqopensync/callbackhandler.h b/kitchensync/libqopensync/callbackhandler.h
index fa6b97c60..a2a4c6d13 100644
--- a/kitchensync/libqopensync/callbackhandler.h
+++ b/kitchensync/libqopensync/callbackhandler.h
@@ -76,10 +76,10 @@ class CallbackHandler : public QObject
class EngineEvent;
class MemberEvent;
- static void conflict_callback( OSyncEngine*, OSyncMapping*, void* );
- static void change_callback( OSyncEngine*, OSyncChangeUpdate*, void* );
+ static void conflict_callback( OSyncEngine*, OSyncMappingEngine*, void* );
+ static void change_callback( OSyncChangeUpdate*, void* );
static void mapping_callback( OSyncMappingUpdate*, void* );
- static void engine_callback( OSyncEngine*, OSyncEngineUpdate*, void* );
+ static void engine_callback( OSyncEngineUpdate*, void* );
static void member_callback( OSyncMemberUpdate*, void* );
Engine* mEngine;
diff --git a/kitchensync/libqopensync/conversion.cpp b/kitchensync/libqopensync/conversion.cpp
index 0be2fdb73..dac027b1c 100644
--- a/kitchensync/libqopensync/conversion.cpp
+++ b/kitchensync/libqopensync/conversion.cpp
@@ -20,6 +20,7 @@
*/
#include <opensync/opensync.h>
+#include <opensync/opensync-format.h>
#include "conversion.h"
@@ -43,16 +44,20 @@ TQStringList Conversion::objectTypes() const
{
Q_ASSERT( mEnvironment );
- OSyncFormatEnv *formatEnv = osync_conv_env_new( mEnvironment );
+ OSyncError *error = NULL;
+ OSyncFormatEnv *formatEnv = osync_format_env_new( &error );
Q_ASSERT( formatEnv );
+ osync_format_env_load_plugins(formatEnv, NULL, &error);
+
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 );
+ for (int i = 0; i < osync_format_env_num_objformats(formatEnv); i++) {
+ OSyncObjFormat *format = osync_format_env_nth_objformat(formatEnv, i);
+ types.append( TQString::fromUtf8( osync_objformat_get_objtype(format) ) );
+ }
+
+ osync_format_env_free( formatEnv );
return types;
}
diff --git a/kitchensync/libqopensync/conversion.h b/kitchensync/libqopensync/conversion.h
index e4b32c580..88447dbbe 100644
--- a/kitchensync/libqopensync/conversion.h
+++ b/kitchensync/libqopensync/conversion.h
@@ -24,13 +24,13 @@
#include <tqstringlist.h>
-class OSyncEnv;
+class OSyncGroupEnv;
namespace QSync {
class Conversion
{
- friend class Environment;
+ friend class PluginEnv;
public:
Conversion();
@@ -47,7 +47,7 @@ class Conversion
TQStringList objectTypes() const;
private:
- OSyncEnv *mEnvironment;
+ OSyncGroupEnv *mGroupEnv;
};
}
diff --git a/kitchensync/libqopensync/engine.cpp b/kitchensync/libqopensync/engine.cpp
index 6d48c72ff..64a11f0ed 100644
--- a/kitchensync/libqopensync/engine.cpp
+++ b/kitchensync/libqopensync/engine.cpp
@@ -20,7 +20,11 @@
*/
#include <opensync/opensync.h>
-#include <osengine/engine.h>
+#include <opensync/opensync-engine.h>
+
+#include "group.h"
+#include "member.h"
+#include "result.h"
#include "engine.h"
@@ -29,19 +33,21 @@ using namespace QSync;
Engine::Engine( const Group &group )
{
OSyncError *error = 0;
- mEngine = osengine_new( group.mGroup, &error );
+ mEngine = osync_engine_new( group.mGroup, &error );
}
Engine::~Engine()
{
- osengine_free( mEngine );
+ osync_engine_unref( mEngine );
mEngine = 0;
}
Result Engine::initialize()
{
+ Q_ASSERT( mEngine );
+
OSyncError *error = 0;
- if ( !osengine_init( mEngine, &error ) )
+ if ( !osync_engine_initialize ( mEngine, &error ) )
return Result( &error );
else
return Result();
@@ -49,13 +55,29 @@ Result Engine::initialize()
void Engine::finalize()
{
- osengine_finalize( mEngine );
+ Q_ASSERT( mEngine );
+
+ OSyncError *error = 0;
+ osync_engine_finalize( mEngine , &error );
}
Result Engine::synchronize()
{
+ Q_ASSERT( mEngine );
+
OSyncError *error = 0;
- if ( !osengine_synchronize( mEngine, &error ) )
+ if ( !osync_engine_synchronize( mEngine, &error ) )
+ return Result( &error );
+ else
+ return Result();
+}
+
+Result Engine::discover( const Member &member )
+{
+ Q_ASSERT( mEngine );
+
+ OSyncError *error = 0;
+ if ( !osync_engine_discover_and_block( mEngine, member.mMember, &error ) )
return Result( &error );
else
return Result();
@@ -63,5 +85,9 @@ Result Engine::synchronize()
void Engine::abort()
{
- osengine_abort( mEngine );
+ Q_ASSERT( mEngine );
+
+// TODO
+// osync_engine_abort( mEngine );
}
+
diff --git a/kitchensync/libqopensync/engine.h b/kitchensync/libqopensync/engine.h
index e62a5f689..c7314db47 100644
--- a/kitchensync/libqopensync/engine.h
+++ b/kitchensync/libqopensync/engine.h
@@ -22,12 +22,14 @@
#ifndef QSYNC_ENGINE_H
#define QSYNC_ENGINE_H
-#include <libqopensync/group.h>
-
class OSyncEngine;
namespace QSync {
+class Group;
+class Member;
+class Result;
+
class Engine
{
friend class CallbackHandler;
@@ -59,6 +61,11 @@ class Engine
Result synchronize();
/**
+ Starts the discover process for a certain member.
+ */
+ Result discover( const Member &member );
+
+ /**
Stops the synchronization process.
*/
void abort();
diff --git a/kitchensync/libqopensync/filter.cpp b/kitchensync/libqopensync/filter.cpp
index dc5fe2eee..35e128968 100644
--- a/kitchensync/libqopensync/filter.cpp
+++ b/kitchensync/libqopensync/filter.cpp
@@ -20,6 +20,7 @@
*/
#include <opensync/opensync.h>
+#include <opensync/opensync-format.h>
#include "filter.h"
diff --git a/kitchensync/libqopensync/group.cpp b/kitchensync/libqopensync/group.cpp
index bc94e2208..46e106098 100644
--- a/kitchensync/libqopensync/group.cpp
+++ b/kitchensync/libqopensync/group.cpp
@@ -25,86 +25,18 @@
/** hack includes **/
#include <opensync/opensync.h>
+#include <opensync/opensync-group.h>
#include "conversion.h"
+#include "filter.h"
+#include "member.h"
+#include "plugin.h"
+#include "result.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 ) ) {
- qDebug( "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 )
{
@@ -119,22 +51,6 @@ 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 );
@@ -188,18 +104,22 @@ Group::LockType Group::lock()
}
}
-void Group::unlock( bool removeFile )
+void Group::unlock()
{
Q_ASSERT( mGroup );
- osync_group_unlock( mGroup, removeFile );
+ osync_group_unlock( mGroup );
}
-Member Group::addMember()
+Member Group::addMember( const QSync::Plugin &plugin )
{
Q_ASSERT( mGroup );
- OSyncMember *omember = osync_member_new( mGroup );
+ OSyncError *error = 0;
+
+ OSyncMember *omember = osync_member_new( &error );
+ osync_group_add_member( mGroup, omember );
+ osync_member_set_pluginname( omember, plugin.name().utf8() );
Member member;
member.mMember = omember;
@@ -269,6 +189,30 @@ Result Group::save()
return Result();
}
+void Group::setUseMerger( bool use )
+{
+ Q_ASSERT( mGroup );
+ osync_group_set_merger_enabled( mGroup, use );
+}
+
+bool Group::useMerger() const
+{
+ Q_ASSERT( mGroup );
+ return osync_group_get_merger_enabled( mGroup );
+}
+
+void Group::setUseConverter( bool use )
+{
+ Q_ASSERT( mGroup );
+ osync_group_set_converter_enabled( mGroup, use );
+}
+
+bool Group::useConverter() const
+{
+ Q_ASSERT( mGroup );
+ return osync_group_get_converter_enabled( mGroup );
+}
+
void Group::setObjectTypeEnabled( const TQString &objectType, bool enabled )
{
Q_ASSERT( mGroup );
@@ -281,12 +225,13 @@ bool Group::isObjectTypeEnabled( const TQString &objectType ) const
return osync_group_objtype_enabled( mGroup, objectType.utf8() );
}
-GroupConfig Group::config() const
+Result Group::cleanup() const
{
Q_ASSERT( mGroup );
- GroupConfig config;
- config.mGroup = mGroup;
-
- return config;
+ OSyncError *error = 0;
+ if ( !osync_group_delete( mGroup, &error ) )
+ return Result( &error );
+ else
+ return Result();
}
diff --git a/kitchensync/libqopensync/group.h b/kitchensync/libqopensync/group.h
index 750e7c41c..1b1a532c3 100644
--- a/kitchensync/libqopensync/group.h
+++ b/kitchensync/libqopensync/group.h
@@ -25,35 +25,22 @@
#include <tqdatetime.h>
#include <tqstringlist.h>
-#include <libqopensync/filter.h>
-#include <libqopensync/member.h>
-
class OSyncGroup;
namespace QSync {
+class Filter;
+class Member;
+class Plugin;
+class Result;
+
/**
@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;
+ friend class GroupEnv;
public:
enum LockType
@@ -71,51 +58,6 @@ class 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.
*/
@@ -145,17 +87,15 @@ class Group
/**
Unlocks the group.
-
- @param removeFile Whether the lock file shall be removed.
*/
- void unlock( bool removeFile = true );
+ void unlock();
/**
Adds a new member to the group.
@returns the new member.
*/
- Member addMember();
+ Member addMember( const QSync::Plugin &plugin );
/**
Removes a member from the group.
@@ -195,19 +135,37 @@ class Group
bool isObjectTypeEnabled( const TQString &objectType ) const;
/**
- Saves the configuration to hard disc.
+ Sets whether this group uses the merger for synchronization.
*/
- Result save();
+ void setUseMerger( bool use );
+
+ /**
+ Returns whether this group uses the merger for synchronization.
+ */
+ bool useMerger() const;
+
+ /**
+ Sets whether this group uses the converter for synchronization.
+ */
+ void setUseConverter( bool use );
/**
- Returns the config object of this group.
+ Returns whether this group uses the converter for synchronization.
+ */
+ bool useConverter() const;
- Note: This method is only available for OpenSync 0.19 and 0.20.
+ /**
+ Saves the configuration to hard disc.
*/
- GroupConfig config() const;
+ Result save();
bool operator==( const Group &group ) const { return mGroup == group.mGroup; }
+ /**
+ Removes all group configurations from the hard disc.
+ */
+ Result cleanup() const;
+
private:
OSyncGroup *mGroup;
};
diff --git a/kitchensync/libqopensync/groupenv.cpp b/kitchensync/libqopensync/groupenv.cpp
new file mode 100644
index 000000000..bd6b3b680
--- /dev/null
+++ b/kitchensync/libqopensync/groupenv.cpp
@@ -0,0 +1,121 @@
+/*
+ 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 );
+ qDebug( "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
new file mode 100644
index 000000000..80179826d
--- /dev/null
+++ b/kitchensync/libqopensync/groupenv.h
@@ -0,0 +1,86 @@
+/*
+ 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
index 35cb04632..e56d11829 100644
--- a/kitchensync/libqopensync/member.cpp
+++ b/kitchensync/libqopensync/member.cpp
@@ -20,8 +20,12 @@
*/
#include <opensync/opensync.h>
+#include <opensync/opensync-group.h>
+
#include <stdlib.h>
+#include "result.h"
+
#include "member.h"
using namespace QSync;
@@ -42,9 +46,9 @@ bool Member::isValid() const
if ( !mMember )
return false;
- if ( !osync_member_instance_plugin( mMember, pluginName().utf8(), &error ) ) {
+ if ( !osync_member_load( mMember, configurationDirectory().utf8(), &error ) ) {
qDebug( "Plugin %s is not valid: %s", pluginName().latin1(), osync_error_print( &error ) );
- osync_error_free( &error );
+ osync_error_unref( &error );
return false;
}
@@ -65,19 +69,6 @@ TQString Member::pluginName() const
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 );
@@ -103,27 +94,28 @@ void Member::setConfiguration( const TQByteArray &configurationData )
{
Q_ASSERT( mMember );
- osync_member_set_config( mMember, configurationData.data(), configurationData.size() );
+ osync_member_set_config( mMember, configurationData.data() );
}
Result Member::configuration( TQByteArray &configurationData, bool useDefault )
{
Q_ASSERT( mMember );
- char *data;
- int size;
+ const char *data;
+ int size = 0;
OSyncError *error = 0;
- osync_bool ok = false;
if ( useDefault )
- ok = osync_member_get_config_or_default( mMember, &data, &size, &error );
+ data = osync_member_get_config_or_default( mMember, &error );
else
- ok = osync_member_get_config( mMember, &data, &size, &error );
+ data = osync_member_get_config( mMember, &error );
- if ( !ok ) {
+
+ if ( !data ) {
return Result( &error );
} else {
- configurationData.resize( size );
+ size = strlen(data);
+ configurationData.resize( size );
memcpy( configurationData.data(), data, size );
return Result();
@@ -141,10 +133,10 @@ Result Member::save()
return Result();
}
-Result Member::instance( const Plugin &plugin )
+Result Member::instance()
{
OSyncError *error = 0;
- if ( !osync_member_instance_plugin( mMember, plugin.name().utf8(), &error ) )
+ if ( !osync_member_load( mMember, configurationDirectory().utf8(), &error ) )
return Result( &error );
else
return Result();
@@ -155,34 +147,13 @@ 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 )
+Result Member::cleanup() const
{
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;
- }
+ if ( !osync_member_delete( mMember, &error ) )
+ return Result( &error );
+ else
+ return Result();
}
diff --git a/kitchensync/libqopensync/member.h b/kitchensync/libqopensync/member.h
index 294c19f15..215b0b148 100644
--- a/kitchensync/libqopensync/member.h
+++ b/kitchensync/libqopensync/member.h
@@ -22,19 +22,21 @@
#ifndef QSYNC_MEMBER_H
#define QSYNC_MEMBER_H
-#include <libqopensync/plugin.h>
-#include <libqopensync/result.h>
-#include <libqopensync/plugin.h>
+#include <tqstring.h>
class OSyncMember;
namespace QSync {
+class Result;
+
class Member
{
friend class Group;
+ friend class Engine;
friend class SyncChange;
friend class SyncMemberUpdate;
+ friend class SyncChangeUpdate;
public:
Member();
@@ -56,11 +58,6 @@ class Member
TQString pluginName() const;
/**
- Returns the plugin, the member belongs to.
- */
- Plugin plugin() const;
-
- /**
Returns the id of the plugin.
*/
int id() const;
@@ -102,7 +99,7 @@ class Member
/**
Make this member an instance of the given plugin.
*/
- Result instance( const Plugin & );
+ Result instance();
bool operator==( const Member& ) const;
@@ -119,6 +116,12 @@ class Member
*/
bool testConnection( const TQString &configuration );
+
+ /**
+ * Deletes the member's information from the hard disc.
+ */
+ Result cleanup() const;
+
private:
OSyncMember *mMember;
};
diff --git a/kitchensync/libqopensync/plugin.cpp b/kitchensync/libqopensync/plugin.cpp
index acd54447a..a9437f387 100644
--- a/kitchensync/libqopensync/plugin.cpp
+++ b/kitchensync/libqopensync/plugin.cpp
@@ -20,6 +20,7 @@
*/
#include <opensync/opensync.h>
+#include <opensync/opensync-plugin.h>
#include "plugin.h"
diff --git a/kitchensync/libqopensync/plugin.h b/kitchensync/libqopensync/plugin.h
index d26c2826c..ddddaadbb 100644
--- a/kitchensync/libqopensync/plugin.h
+++ b/kitchensync/libqopensync/plugin.h
@@ -30,7 +30,7 @@ namespace QSync {
class Plugin
{
- friend class Environment;
+ friend class PluginEnv;
friend class Member;
public:
diff --git a/kitchensync/libqopensync/pluginenv.cpp b/kitchensync/libqopensync/pluginenv.cpp
new file mode 100644
index 000000000..5efcb97b8
--- /dev/null
+++ b/kitchensync/libqopensync/pluginenv.cpp
@@ -0,0 +1,96 @@
+/*
+ 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
new file mode 100644
index 000000000..2acc4e54a
--- /dev/null
+++ b/kitchensync/libqopensync/pluginenv.h
@@ -0,0 +1,80 @@
+/*
+ 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
index d38c32a3d..13d06e71a 100644
--- a/kitchensync/libqopensync/result.cpp
+++ b/kitchensync/libqopensync/result.cpp
@@ -100,7 +100,7 @@ Result::Result( OSyncError **error, bool deleteError )
mMessage = TQString::fromUtf8( osync_error_print( error ) );
if ( deleteError )
- osync_error_free( error );
+ osync_error_unref( error );
}
Result::~Result()
diff --git a/kitchensync/libqopensync/syncchange.cpp b/kitchensync/libqopensync/syncchange.cpp
index 5dd72d7ff..d45be2e4a 100644
--- a/kitchensync/libqopensync/syncchange.cpp
+++ b/kitchensync/libqopensync/syncchange.cpp
@@ -19,8 +19,13 @@
Boston, MA 02110-1301, USA.
*/
+#include <stdlib.h>
+
#include <opensync/file.h>
+
#include <opensync/opensync.h>
+#include <opensync/opensync-data.h>
+#include <opensync/opensync-format.h>
#include "syncchange.h"
@@ -64,39 +69,50 @@ TQString SyncChange::hash() const
return TQString::fromUtf8( osync_change_get_hash( mSyncChange ) );
}
-void SyncChange::setData( const TQString &data )
+void SyncChange::setData( const TQString &data , OSyncObjFormat *format )
{
- osync_change_set_data( mSyncChange, const_cast<char*>( data.utf8().data() ), data.utf8().size(), true );
+ OSyncError *error = 0;
+
+ OSyncData *odata = osync_data_new( const_cast<char*>( data.utf8().data() ), data.utf8().size(), format, &error );
+ osync_change_set_data( mSyncChange, odata );
}
TQString SyncChange::data() const
{
- int size = osync_change_get_datasize( mSyncChange );
+ char *buf;
+ unsigned int size;
+
+ OSyncData *data = osync_change_get_data( mSyncChange );
+
+ osync_data_get_data( data, &buf, &size );
TQString content;
if ( objectFormatName() == "file" ) {
- fileFormat *format = (fileFormat*)osync_change_get_data( mSyncChange );
+ OSyncFileFormat *format = (OSyncFileFormat*) buf;
if ( format )
content = TQString::fromUtf8( format->data, format->size );
} else
- content = TQString::fromUtf8( osync_change_get_data( mSyncChange ), size );
+ content = TQString::fromUtf8( buf, size );
+
+ free( buf );
return content;
}
bool SyncChange::hasData() const
{
- return osync_change_has_data( mSyncChange );
+ return osync_data_has_data( osync_change_get_data( mSyncChange ) );
}
TQString SyncChange::objectFormatName() const
{
- OSyncObjFormat *format = osync_change_get_objformat( mSyncChange );
+ OSyncObjFormat *format = osync_data_get_objformat( osync_change_get_data( mSyncChange ) );
Q_ASSERT( format );
return TQString::fromUtf8( osync_objformat_get_name( format ) );
}
+/*
Member SyncChange::member() const
{
OSyncMember *omember = osync_change_get_member( mSyncChange );
@@ -106,6 +122,7 @@ Member SyncChange::member() const
return m;
}
+*/
void SyncChange::setChangeType( Type changeType )
{
@@ -113,20 +130,20 @@ void SyncChange::setChangeType( Type changeType )
switch ( changeType ) {
case AddedChange:
- ochangeType = CHANGE_ADDED;
+ ochangeType = OSYNC_CHANGE_TYPE_ADDED;
break;
case UnmodifiedChange:
- ochangeType = CHANGE_UNMODIFIED;
+ ochangeType = OSYNC_CHANGE_TYPE_UNMODIFIED;
break;
case DeletedChange:
- ochangeType = CHANGE_DELETED;
+ ochangeType = OSYNC_CHANGE_TYPE_DELETED;
break;
case ModifiedChange:
- ochangeType = CHANGE_MODIFIED;
+ ochangeType = OSYNC_CHANGE_TYPE_MODIFIED;
break;
case UnknownChange:
default:
- ochangeType = CHANGE_UNKNOWN;
+ ochangeType = OSYNC_CHANGE_TYPE_UNKNOWN;
break;
}
@@ -138,19 +155,19 @@ SyncChange::Type SyncChange::changeType() const
OSyncChangeType ochangeType = osync_change_get_changetype( mSyncChange );
switch ( ochangeType ) {
- case CHANGE_ADDED:
+ case OSYNC_CHANGE_TYPE_ADDED:
return AddedChange;
break;
- case CHANGE_UNMODIFIED:
+ case OSYNC_CHANGE_TYPE_UNMODIFIED:
return UnmodifiedChange;
break;
- case CHANGE_DELETED:
+ case OSYNC_CHANGE_TYPE_DELETED:
return DeletedChange;
break;
- case CHANGE_MODIFIED:
+ case OSYNC_CHANGE_TYPE_MODIFIED:
return ModifiedChange;
break;
- case CHANGE_UNKNOWN:
+ case OSYNC_CHANGE_TYPE_UNKNOWN:
default:
return UnknownChange;
break;
diff --git a/kitchensync/libqopensync/syncchange.h b/kitchensync/libqopensync/syncchange.h
index 53d9c4401..2afaddcc4 100644
--- a/kitchensync/libqopensync/syncchange.h
+++ b/kitchensync/libqopensync/syncchange.h
@@ -25,6 +25,7 @@
#include <libqopensync/member.h>
class OSyncChange;
+class OSyncObjFormat;
namespace QSync {
@@ -74,7 +75,7 @@ class SyncChange
/**
Sets the data provided by the plugin.
*/
- void setData( const TQString &data );
+ void setData( const TQString &data, OSyncObjFormat *format );
/**
Returns the data provided by the plugin.
@@ -94,7 +95,7 @@ class SyncChange
/**
Returns the parent member of this change.
*/
- Member member() const;
+// Member member() const;
/**
Sets the change type.
diff --git a/kitchensync/libqopensync/syncmapping.cpp b/kitchensync/libqopensync/syncmapping.cpp
index 95939ab85..d716af17a 100644
--- a/kitchensync/libqopensync/syncmapping.cpp
+++ b/kitchensync/libqopensync/syncmapping.cpp
@@ -20,19 +20,20 @@
*/
#include <tqstring.h>
-#include <osengine/engine.h>
+#include <opensync/opensync.h>
+#include <opensync/opensync-engine.h>
#include "syncmapping.h"
using namespace QSync;
SyncMapping::SyncMapping()
- : mEngine( 0 ), mMapping( 0 )
+ : mEngine( 0 ), mMappingEngine( 0 )
{
}
-SyncMapping::SyncMapping( OSyncMapping *mapping, OSyncEngine *engine )
- : mEngine( engine ), mMapping( mapping )
+SyncMapping::SyncMapping( OSyncMappingEngine *mapping, OSyncEngine *engine )
+ : mEngine( engine ), mMappingEngine( mapping )
{
}
@@ -42,58 +43,64 @@ SyncMapping::~SyncMapping()
bool SyncMapping::isValid() const
{
- return ( mEngine != 0 && mMapping != 0 );
+ return ( mEngine != 0 && mMappingEngine != 0 );
}
+/*
long long SyncMapping::id() const
{
- Q_ASSERT( mMapping );
+ Q_ASSERT( mMappingEngine );
- return osengine_mapping_get_id( mMapping );
+ return osync_mapping_engine_get_id( mMappingEngine );
}
+*/
void SyncMapping::duplicate()
{
Q_ASSERT( mEngine );
- Q_ASSERT( mMapping );
+ Q_ASSERT( mMappingEngine );
+
+ OSyncError *error = 0;
- osengine_mapping_duplicate( mEngine, mMapping );
+ osync_mapping_engine_duplicate( mMappingEngine, &error );
}
void SyncMapping::solve( const SyncChange &change )
{
Q_ASSERT( mEngine );
- Q_ASSERT( mMapping );
+ Q_ASSERT( mMappingEngine );
Q_ASSERT( change.isValid() );
- osengine_mapping_solve( mEngine, mMapping, change.mSyncChange );
+ OSyncError *error = 0;
+
+ osync_mapping_engine_solve( mMappingEngine, change.mSyncChange, &error );
}
void SyncMapping::ignore()
{
Q_ASSERT( mEngine );
- Q_ASSERT( mMapping );
+ Q_ASSERT( mMappingEngine );
//TODO: error should be returned as Result
OSyncError *error = 0;
- osengine_mapping_ignore_conflict( mEngine, mMapping, &error );
+ osync_mapping_engine_ignore( mMappingEngine, &error );
}
int SyncMapping::changesCount() const
{
- Q_ASSERT( mMapping );
+ Q_ASSERT( mMappingEngine );
- return osengine_mapping_num_changes( mMapping );
+ return osync_mapping_engine_num_changes( mMappingEngine );
}
SyncChange SyncMapping::changeAt( int pos )
{
- Q_ASSERT( mMapping );
+ Q_ASSERT( mMappingEngine );
- if ( pos < 0 || pos >= osengine_mapping_num_changes( mMapping ) )
+ if ( pos < 0 || pos >= osync_mapping_engine_num_changes( mMappingEngine ) )
return SyncChange();
- OSyncChange *ochange = osengine_mapping_nth_change( mMapping, pos );
+ OSyncChange *ochange = osync_mapping_engine_nth_change( mMappingEngine, pos );
return SyncChange( ochange );
}
diff --git a/kitchensync/libqopensync/syncmapping.h b/kitchensync/libqopensync/syncmapping.h
index 6de67330a..0351fa9f5 100644
--- a/kitchensync/libqopensync/syncmapping.h
+++ b/kitchensync/libqopensync/syncmapping.h
@@ -25,7 +25,7 @@
#include <libqopensync/syncchange.h>
class OSyncEngine;
-class OSyncMapping;
+class OSyncMappingEngine;
namespace QSync {
@@ -35,7 +35,7 @@ class SyncMapping
public:
SyncMapping();
- SyncMapping( OSyncMapping*, OSyncEngine* );
+ SyncMapping( OSyncMappingEngine*, OSyncEngine* );
~SyncMapping();
bool isValid() const;
@@ -51,7 +51,7 @@ class SyncMapping
private:
OSyncEngine *mEngine;
- OSyncMapping *mMapping;
+ OSyncMappingEngine *mMappingEngine;
};
}
diff --git a/kitchensync/libqopensync/syncupdates.cpp b/kitchensync/libqopensync/syncupdates.cpp
index 653ccf7f3..3ad273f9f 100644
--- a/kitchensync/libqopensync/syncupdates.cpp
+++ b/kitchensync/libqopensync/syncupdates.cpp
@@ -19,7 +19,8 @@
Boston, MA 02110-1301, USA.
*/
-#include <osengine/engine.h>
+#include <opensync/opensync.h>
+#include <opensync/opensync-engine.h>
#include "syncupdates.h"
@@ -32,32 +33,26 @@ SyncMemberUpdate::SyncMemberUpdate()
SyncMemberUpdate::SyncMemberUpdate( OSyncMemberUpdate *update )
{
switch ( update->type ) {
- case MEMBER_CONNECTED:
+ case OSYNC_CLIENT_EVENT_CONNECTED:
mType = Connected;
break;
- case MEMBER_SENT_CHANGES:
- mType = SentChanges;
- break;
- case MEMBER_COMMITTED_ALL:
- mType = CommittedAll;
- break;
- case MEMBER_DISCONNECTED:
+ case OSYNC_CLIENT_EVENT_DISCONNECTED:
mType = Disconnected;
break;
- case MEMBER_CONNECT_ERROR:
- mType = ConnectError;
+ case OSYNC_CLIENT_EVENT_READ:
+ mType = Read;
break;
- case MEMBER_GET_CHANGES_ERROR:
- mType = GetChangesError;
+ case OSYNC_CLIENT_EVENT_WRITTEN:
+ mType = Written;
break;
- case MEMBER_COMMITTED_ALL_ERROR:
- mType = CommittedAllError;
+ case OSYNC_CLIENT_EVENT_SYNC_DONE:
+ mType = SyncDone;
break;
- case MEMBER_SYNC_DONE_ERROR:
- mType = SyncDoneError;
+ case OSYNC_CLIENT_EVENT_DISCOVERED:
+ mType = Discovered;
break;
- case MEMBER_DISCONNECT_ERROR:
- mType = DisconnectedError;
+ case OSYNC_CLIENT_EVENT_ERROR:
+ mType = Error;
break;
}
@@ -94,20 +89,14 @@ SyncChangeUpdate::SyncChangeUpdate()
SyncChangeUpdate::SyncChangeUpdate( OSyncChangeUpdate *update )
{
switch ( update->type ) {
- case CHANGE_RECEIVED:
- mType = Received;
- break;
- case CHANGE_RECEIVED_INFO:
- mType = ReceivedInfo;
+ case OSYNC_CHANGE_EVENT_READ:
+ mType = Read;
break;
- case CHANGE_SENT:
- mType = Sent;
+ case OSYNC_CHANGE_EVENT_WRITTEN:
+ mType = Written;
break;
- case CHANGE_WRITE_ERROR:
- mType = WriteError;
- break;
- case CHANGE_RECV_ERROR:
- mType = ReceiveError;
+ case OSYNC_CHANGE_EVENT_ERROR:
+ mType = Error;
break;
}
@@ -115,7 +104,7 @@ SyncChangeUpdate::SyncChangeUpdate( OSyncChangeUpdate *update )
mResult = Result( &(update->error) );
mChange = SyncChange( update->change );
- mMemberId = update->member_id;
+ mMember.mMember = update->member;
mMappingId = update->mapping_id;
}
@@ -138,9 +127,9 @@ SyncChange SyncChangeUpdate::change() const
return mChange;
}
-int SyncChangeUpdate::memberId() const
+Member SyncChangeUpdate::member() const
{
- return mMemberId;
+ return mMember;
}
int SyncChangeUpdate::mappingId() const
@@ -155,14 +144,14 @@ SyncMappingUpdate::SyncMappingUpdate()
SyncMappingUpdate::SyncMappingUpdate( OSyncMappingUpdate *update, OSyncEngine *engine )
{
switch ( update->type ) {
- case MAPPING_SOLVED:
+ case OSYNC_MAPPING_EVENT_SOLVED:
mType = Solved;
break;
- case MAPPING_SYNCED:
- mType = Synced;
- break;
- case MAPPING_WRITE_ERROR:
- mType = WriteError;
+// case OSYNC_MAPPING_EVENT_SYNCED:
+ // mType = Synced;
+ // break;
+ case OSYNC_MAPPING_EVENT_ERROR:
+ mType = Error;
break;
}
@@ -171,7 +160,9 @@ SyncMappingUpdate::SyncMappingUpdate( OSyncMappingUpdate *update, OSyncEngine *e
mWinner = update->winner;
mMapping.mEngine = engine;
- mMapping.mMapping = update->mapping;
+
+ // TODO PORTING
+// mMapping.mMapping = update->mapping;
}
SyncMappingUpdate::~SyncMappingUpdate()
@@ -205,30 +196,33 @@ SyncEngineUpdate::SyncEngineUpdate()
SyncEngineUpdate::SyncEngineUpdate( OSyncEngineUpdate *update )
{
switch ( update->type ) {
- case ENG_ENDPHASE_CON:
- mType = EndPhaseConnected;
+ case OSYNC_ENGINE_EVENT_CONNECTED:
+ mType = Connected;
break;
- case ENG_ENDPHASE_READ:
- mType = EndPhaseRead;
+ case OSYNC_ENGINE_EVENT_READ:
+ mType = Read;
break;
- case ENG_ENDPHASE_WRITE:
- mType = EndPhaseWrite;
+ case OSYNC_ENGINE_EVENT_WRITTEN:
+ mType = Written;
break;
- case ENG_ENDPHASE_DISCON:
- mType = EndPhaseDisconnected;
+ case OSYNC_ENGINE_EVENT_DISCONNECTED:
+ mType = Disconnected;
break;
- case ENG_ERROR:
+ case OSYNC_ENGINE_EVENT_ERROR:
mType = Error;
break;
- case ENG_SYNC_SUCCESSFULL:
- mType = SyncSuccessfull;
+ case OSYNC_ENGINE_EVENT_SUCCESSFUL:
+ mType = SyncSuccessful;
break;
- case ENG_PREV_UNCLEAN:
+ case OSYNC_ENGINE_EVENT_PREV_UNCLEAN:
mType = PrevUnclean;
break;
- case ENG_END_CONFLICTS:
+ case OSYNC_ENGINE_EVENT_END_CONFLICTS:
mType = EndConflicts;
break;
+ case OSYNC_ENGINE_EVENT_SYNC_DONE:
+ mType = SyncDone;
+ break;
}
if ( update->error )
diff --git a/kitchensync/libqopensync/syncupdates.h b/kitchensync/libqopensync/syncupdates.h
index 14a2d9193..96741b059 100644
--- a/kitchensync/libqopensync/syncupdates.h
+++ b/kitchensync/libqopensync/syncupdates.h
@@ -42,14 +42,12 @@ class SyncMemberUpdate
public:
enum Type {
Connected,
- SentChanges,
- CommittedAll,
Disconnected,
- ConnectError,
- GetChangesError,
- CommittedAllError,
- SyncDoneError,
- DisconnectedError
+ Read,
+ Written,
+ SyncDone,
+ Discovered,
+ Error
};
SyncMemberUpdate();
@@ -72,11 +70,9 @@ class SyncChangeUpdate
public:
enum Type {
- Received = 1,
- ReceivedInfo,
- Sent,
- WriteError,
- ReceiveError
+ Read = 1,
+ Written,
+ Error
};
SyncChangeUpdate();
@@ -86,14 +82,14 @@ class SyncChangeUpdate
Type type() const;
Result result() const;
SyncChange change() const;
- int memberId() const;
+ Member member() const;
int mappingId() const;
private:
Type mType;
Result mResult;
SyncChange mChange;
- int mMemberId;
+ Member mMember;
int mMappingId;
};
@@ -104,8 +100,8 @@ class SyncMappingUpdate
public:
enum Type {
Solved = 1,
- Synced,
- WriteError
+ //Synced,
+ Error
};
SyncMappingUpdate();
@@ -130,14 +126,15 @@ class SyncEngineUpdate
public:
enum Type {
- EndPhaseConnected = 1,
- EndPhaseRead,
- EndPhaseWrite,
- EndPhaseDisconnected,
+ Connected = 1,
+ Read,
+ Written,
+ Disconnected,
Error,
- SyncSuccessfull,
+ SyncSuccessful,
PrevUnclean,
- EndConflicts
+ EndConflicts,
+ SyncDone
};
SyncEngineUpdate();