summaryrefslogtreecommitdiffstats
path: root/kitchensync
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-08 01:37:34 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-08 01:37:34 +0000
commitd4f48636cc2631625434326e146d04f503d0247a (patch)
treea371a2337bddce3de3fa3fcac52275a8204570d9 /kitchensync
parentd8b40941f9d1a221add0b9094eb09405a91a8aab (diff)
downloadtdepim-d4f48636cc2631625434326e146d04f503d0247a.tar.gz
tdepim-d4f48636cc2631625434326e146d04f503d0247a.zip
Reverse OpenSync patch as it causes a build failure on Debian
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1172771 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kitchensync')
-rw-r--r--kitchensync/configure.in.bot4
-rw-r--r--kitchensync/configure.in.in8
-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/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/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
-rw-r--r--kitchensync/src/Makefile.am2
-rw-r--r--kitchensync/src/configguifile.cpp40
-rw-r--r--kitchensync/src/configguisyncmlhttp.cpp4
-rw-r--r--kitchensync/src/configguisyncmlobex.cpp4
-rw-r--r--kitchensync/src/groupconfig.cpp58
-rw-r--r--kitchensync/src/groupconfig.h15
-rw-r--r--kitchensync/src/groupconfigcommon.cpp21
-rw-r--r--kitchensync/src/groupconfigcommon.h5
-rw-r--r--kitchensync/src/groupconfigdialog.cpp24
-rw-r--r--kitchensync/src/groupconfigdialog.h5
-rw-r--r--kitchensync/src/groupitem.cpp71
-rw-r--r--kitchensync/src/mainwidget.cpp20
-rw-r--r--kitchensync/src/memberconfig.cpp11
-rw-r--r--kitchensync/src/memberconfig.h2
-rw-r--r--kitchensync/src/multiconflictdialog.cpp6
-rw-r--r--kitchensync/src/pluginpicker.cpp14
-rw-r--r--kitchensync/src/singleconflictdialog.cpp14
-rw-r--r--kitchensync/src/syncprocess.cpp43
-rw-r--r--kitchensync/src/syncprocess.h4
-rw-r--r--kitchensync/src/syncprocessmanager.cpp48
-rw-r--r--kitchensync/src/syncprocessmanager.h23
44 files changed, 555 insertions, 601 deletions
diff --git a/kitchensync/configure.in.bot b/kitchensync/configure.in.bot
index 484225aab..a612d1b78 100644
--- a/kitchensync/configure.in.bot
+++ b/kitchensync/configure.in.bot
@@ -1,7 +1,7 @@
-if test "$HAVE_OPENSYNC" = 0; then
+if test "$HAVE_OPENSYNC" = 0 -o "$HAVE_OPENSYNC_ENGINE" = 0; then
echo ""
echo "You're missing a compatible version of libopensync."
- echo "Version 0.31 or greater is needed."
+ echo "Version 0.19 or greater is needed."
echo "kitchensync will not be built."
echo ""
all_tests=bad
diff --git a/kitchensync/configure.in.in b/kitchensync/configure.in.in
index 2aeebedcb..31bb902c6 100644
--- a/kitchensync/configure.in.in
+++ b/kitchensync/configure.in.in
@@ -29,7 +29,9 @@ export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:$prefix/lib/pkgconfig:/usr/local/lib/p
HAVE_OPENSYNC=0
-PKG_CHECK_MODULES(OPENSYNC, opensync-1.0 >= 0.33, HAVE_OPENSYNC=1,HAVE_OPENSYNC=0)
+HAVE_OPENSYNC_ENGINE=0
+PKG_CHECK_MODULES(OPENSYNC, opensync-1.0 >= 0.19, HAVE_OPENSYNC=1,HAVE_OPENSYNC=0)
+PKG_CHECK_MODULES(OPENSYNCENGINE, osengine-1.0 >= 0.19, HAVE_OPENSYNC_ENGINE=1, HAVE_OPENSYNC_ENGINE=0)
PKG_CHECK_MODULES(LIBXML, libxml-2.0, , HAVE_OPENSYNC=0)
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.6, , HAVE_OPENSYNC=0)
@@ -50,9 +52,9 @@ AC_SUBST(OPENSYNC_FORMATSDIR)
AC_SUBST(OPENSYNC_HEADERDIR)
dnl Check if we can compile KitchenSync
-AM_CONDITIONAL(compile_kitchensync, test "$HAVE_OPENSYNC" = 1)
+AM_CONDITIONAL(compile_kitchensync, test "$HAVE_OPENSYNC" = 1 -a "$HAVE_OPENSYNC_ENGINE" = 1)
-if test "$HAVE_OPENSYNC" = 1; then
+if test "$HAVE_OPENSYNC" = 1 -a "$HAVE_OPENSYNC_ENGINE" = 1 ; then
AC_MSG_RESULT([found])
else
AC_MSG_RESULT([not found])
diff --git a/kitchensync/libqopensync/Makefile.am b/kitchensync/libqopensync/Makefile.am
index 772146a47..2e12df6ca 100644
--- a/kitchensync/libqopensync/Makefile.am
+++ b/kitchensync/libqopensync/Makefile.am
@@ -2,20 +2,16 @@ INCLUDES = -I$(top_srcdir)/kitchensync/src \
-I$(top_srcdir)/kitchensync \
-I$(top_srcdir) \
$(OPENSYNC_CFLAGS) \
- $(GLIB_CFLAGS) \
+ $(OPENSYNCENGINE_CFLAGS) \
$(all_includes)
lib_LTLIBRARIES = libqopensync.la
-libqopensync_la_SOURCES = callbackhandler.cpp engine.cpp groupenv.cpp pluginenv.cpp filter.cpp group.cpp \
+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
-
-# 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)
-
+libqopensync_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -no-undefined
+libqopensync_la_LIBADD = $(LIB_KDEUI) $(OPENSYNC_LIBS) $(OPENSYNCENGINE_LIBS)
METASOURCES = AUTO
diff --git a/kitchensync/libqopensync/callbackhandler.cpp b/kitchensync/libqopensync/callbackhandler.cpp
index 894261b37..504afea99 100644
--- a/kitchensync/libqopensync/callbackhandler.cpp
+++ b/kitchensync/libqopensync/callbackhandler.cpp
@@ -19,12 +19,11 @@
Boston, MA 02110-1301, USA.
*/
-#include <opensync/opensync.h>
-#include <opensync/opensync-engine.h>
+#include <osengine/engine.h>
-#include <tqapplication.h>
+#include <libqopensync/engine.h>
-#include "engine.h"
+#include <tqapplication.h>
#include "callbackhandler.h"
@@ -112,11 +111,11 @@ void CallbackHandler::setEngine( Engine *engine )
{
mEngine = engine;
- 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 );
+ 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
@@ -144,7 +143,7 @@ void CallbackHandler::customEvent( TQCustomEvent *event )
}
}
-void CallbackHandler::conflict_callback( OSyncEngine *engine, OSyncMappingEngine *omapping, void *data )
+void CallbackHandler::conflict_callback( OSyncEngine *engine, OSyncMapping *omapping, void *data )
{
SyncMapping mapping( omapping, engine );
@@ -153,7 +152,7 @@ void CallbackHandler::conflict_callback( OSyncEngine *engine, OSyncMappingEngine
TQApplication::postEvent( handler, new ConflictEvent( mapping ) );
}
-void CallbackHandler::change_callback( OSyncChangeUpdate *update, void *data )
+void CallbackHandler::change_callback( OSyncEngine*, OSyncChangeUpdate *update, void *data )
{
SyncChangeUpdate change( update );
@@ -171,7 +170,7 @@ void CallbackHandler::mapping_callback( OSyncMappingUpdate *update, void *data )
TQApplication::postEvent( handler, new MappingEvent( mapping ) );
}
-void CallbackHandler::engine_callback( OSyncEngineUpdate *update, void *data )
+void CallbackHandler::engine_callback( OSyncEngine*, OSyncEngineUpdate *update, void *data )
{
SyncEngineUpdate engine( update );
diff --git a/kitchensync/libqopensync/callbackhandler.h b/kitchensync/libqopensync/callbackhandler.h
index a2a4c6d13..fa6b97c60 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*, OSyncMappingEngine*, void* );
- static void change_callback( OSyncChangeUpdate*, void* );
+ static void conflict_callback( OSyncEngine*, OSyncMapping*, void* );
+ static void change_callback( OSyncEngine*, OSyncChangeUpdate*, void* );
static void mapping_callback( OSyncMappingUpdate*, void* );
- static void engine_callback( OSyncEngineUpdate*, void* );
+ static void engine_callback( OSyncEngine*, OSyncEngineUpdate*, void* );
static void member_callback( OSyncMemberUpdate*, void* );
Engine* mEngine;
diff --git a/kitchensync/libqopensync/conversion.cpp b/kitchensync/libqopensync/conversion.cpp
index dac027b1c..0be2fdb73 100644
--- a/kitchensync/libqopensync/conversion.cpp
+++ b/kitchensync/libqopensync/conversion.cpp
@@ -20,7 +20,6 @@
*/
#include <opensync/opensync.h>
-#include <opensync/opensync-format.h>
#include "conversion.h"
@@ -44,20 +43,16 @@ TQStringList Conversion::objectTypes() const
{
Q_ASSERT( mEnvironment );
- OSyncError *error = NULL;
- OSyncFormatEnv *formatEnv = osync_format_env_new( &error );
+ OSyncFormatEnv *formatEnv = osync_conv_env_new( mEnvironment );
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 ) ) );
+ }
- 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 );
+ osync_conv_env_free( formatEnv );
return types;
}
diff --git a/kitchensync/libqopensync/conversion.h b/kitchensync/libqopensync/conversion.h
index 88447dbbe..e4b32c580 100644
--- a/kitchensync/libqopensync/conversion.h
+++ b/kitchensync/libqopensync/conversion.h
@@ -24,13 +24,13 @@
#include <tqstringlist.h>
-class OSyncGroupEnv;
+class OSyncEnv;
namespace QSync {
class Conversion
{
- friend class PluginEnv;
+ friend class Environment;
public:
Conversion();
@@ -47,7 +47,7 @@ class Conversion
TQStringList objectTypes() const;
private:
- OSyncGroupEnv *mGroupEnv;
+ OSyncEnv *mEnvironment;
};
}
diff --git a/kitchensync/libqopensync/engine.cpp b/kitchensync/libqopensync/engine.cpp
index 64a11f0ed..6d48c72ff 100644
--- a/kitchensync/libqopensync/engine.cpp
+++ b/kitchensync/libqopensync/engine.cpp
@@ -20,11 +20,7 @@
*/
#include <opensync/opensync.h>
-#include <opensync/opensync-engine.h>
-
-#include "group.h"
-#include "member.h"
-#include "result.h"
+#include <osengine/engine.h>
#include "engine.h"
@@ -33,21 +29,19 @@ using namespace QSync;
Engine::Engine( const Group &group )
{
OSyncError *error = 0;
- mEngine = osync_engine_new( group.mGroup, &error );
+ mEngine = osengine_new( group.mGroup, &error );
}
Engine::~Engine()
{
- osync_engine_unref( mEngine );
+ osengine_free( mEngine );
mEngine = 0;
}
Result Engine::initialize()
{
- Q_ASSERT( mEngine );
-
OSyncError *error = 0;
- if ( !osync_engine_initialize ( mEngine, &error ) )
+ if ( !osengine_init( mEngine, &error ) )
return Result( &error );
else
return Result();
@@ -55,29 +49,13 @@ Result Engine::initialize()
void Engine::finalize()
{
- Q_ASSERT( mEngine );
-
- OSyncError *error = 0;
- osync_engine_finalize( mEngine , &error );
+ osengine_finalize( mEngine );
}
Result Engine::synchronize()
{
- Q_ASSERT( mEngine );
-
OSyncError *error = 0;
- 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 ) )
+ if ( !osengine_synchronize( mEngine, &error ) )
return Result( &error );
else
return Result();
@@ -85,9 +63,5 @@ Result Engine::discover( const Member &member )
void Engine::abort()
{
- Q_ASSERT( mEngine );
-
-// TODO
-// osync_engine_abort( mEngine );
+ osengine_abort( mEngine );
}
-
diff --git a/kitchensync/libqopensync/engine.h b/kitchensync/libqopensync/engine.h
index c7314db47..e62a5f689 100644
--- a/kitchensync/libqopensync/engine.h
+++ b/kitchensync/libqopensync/engine.h
@@ -22,14 +22,12 @@
#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;
@@ -61,11 +59,6 @@ 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 35e128968..dc5fe2eee 100644
--- a/kitchensync/libqopensync/filter.cpp
+++ b/kitchensync/libqopensync/filter.cpp
@@ -20,7 +20,6 @@
*/
#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 46e106098..bc94e2208 100644
--- a/kitchensync/libqopensync/group.cpp
+++ b/kitchensync/libqopensync/group.cpp
@@ -25,18 +25,86 @@
/** 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 )
{
@@ -51,6 +119,22 @@ 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 );
@@ -104,22 +188,18 @@ Group::LockType Group::lock()
}
}
-void Group::unlock()
+void Group::unlock( bool removeFile )
{
Q_ASSERT( mGroup );
- osync_group_unlock( mGroup );
+ osync_group_unlock( mGroup, removeFile );
}
-Member Group::addMember( const QSync::Plugin &plugin )
+Member Group::addMember()
{
Q_ASSERT( mGroup );
- OSyncError *error = 0;
-
- OSyncMember *omember = osync_member_new( &error );
- osync_group_add_member( mGroup, omember );
- osync_member_set_pluginname( omember, plugin.name().utf8() );
+ OSyncMember *omember = osync_member_new( mGroup );
Member member;
member.mMember = omember;
@@ -189,30 +269,6 @@ 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 );
@@ -225,13 +281,12 @@ bool Group::isObjectTypeEnabled( const TQString &objectType ) const
return osync_group_objtype_enabled( mGroup, objectType.utf8() );
}
-Result Group::cleanup() const
+GroupConfig Group::config() const
{
Q_ASSERT( mGroup );
- OSyncError *error = 0;
- if ( !osync_group_delete( mGroup, &error ) )
- return Result( &error );
- else
- return Result();
+ GroupConfig config;
+ config.mGroup = mGroup;
+
+ return config;
}
diff --git a/kitchensync/libqopensync/group.h b/kitchensync/libqopensync/group.h
index 1b1a532c3..750e7c41c 100644
--- a/kitchensync/libqopensync/group.h
+++ b/kitchensync/libqopensync/group.h
@@ -25,22 +25,35 @@
#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 GroupEnv;
+ friend class Environment;
public:
enum LockType
@@ -58,6 +71,51 @@ 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.
*/
@@ -87,15 +145,17 @@ class Group
/**
Unlocks the group.
+
+ @param removeFile Whether the lock file shall be removed.
*/
- void unlock();
+ void unlock( bool removeFile = true );
/**
Adds a new member to the group.
@returns the new member.
*/
- Member addMember( const QSync::Plugin &plugin );
+ Member addMember();
/**
Removes a member from the group.
@@ -135,37 +195,19 @@ class Group
bool isObjectTypeEnabled( const TQString &objectType ) const;
/**
- Sets whether this group uses the merger for synchronization.
- */
- 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.
+ Saves the configuration to hard disc.
*/
- void setUseConverter( bool use );
+ Result save();
/**
- Returns whether this group uses the converter for synchronization.
- */
- bool useConverter() const;
+ Returns the config object of this group.
- /**
- Saves the configuration to hard disc.
+ Note: This method is only available for OpenSync 0.19 and 0.20.
*/
- Result save();
+ GroupConfig config() const;
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/member.cpp b/kitchensync/libqopensync/member.cpp
index e56d11829..35cb04632 100644
--- a/kitchensync/libqopensync/member.cpp
+++ b/kitchensync/libqopensync/member.cpp
@@ -20,12 +20,8 @@
*/
#include <opensync/opensync.h>
-#include <opensync/opensync-group.h>
-
#include <stdlib.h>
-#include "result.h"
-
#include "member.h"
using namespace QSync;
@@ -46,9 +42,9 @@ bool Member::isValid() const
if ( !mMember )
return false;
- if ( !osync_member_load( mMember, configurationDirectory().utf8(), &error ) ) {
+ if ( !osync_member_instance_plugin( mMember, pluginName().utf8(), &error ) ) {
qDebug( "Plugin %s is not valid: %s", pluginName().latin1(), osync_error_print( &error ) );
- osync_error_unref( &error );
+ osync_error_free( &error );
return false;
}
@@ -69,6 +65,19 @@ 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 );
@@ -94,28 +103,27 @@ void Member::setConfiguration( const TQByteArray &configurationData )
{
Q_ASSERT( mMember );
- osync_member_set_config( mMember, configurationData.data() );
+ osync_member_set_config( mMember, configurationData.data(), configurationData.size() );
}
Result Member::configuration( TQByteArray &configurationData, bool useDefault )
{
Q_ASSERT( mMember );
- const char *data;
- int size = 0;
+ char *data;
+ int size;
OSyncError *error = 0;
+ osync_bool ok = false;
if ( useDefault )
- data = osync_member_get_config_or_default( mMember, &error );
+ ok = osync_member_get_config_or_default( mMember, &data, &size, &error );
else
- data = osync_member_get_config( mMember, &error );
+ ok = osync_member_get_config( mMember, &data, &size, &error );
-
- if ( !data ) {
+ if ( !ok ) {
return Result( &error );
} else {
- size = strlen(data);
- configurationData.resize( size );
+ configurationData.resize( size );
memcpy( configurationData.data(), data, size );
return Result();
@@ -133,10 +141,10 @@ Result Member::save()
return Result();
}
-Result Member::instance()
+Result Member::instance( const Plugin &plugin )
{
OSyncError *error = 0;
- if ( !osync_member_load( mMember, configurationDirectory().utf8(), &error ) )
+ if ( !osync_member_instance_plugin( mMember, plugin.name().utf8(), &error ) )
return Result( &error );
else
return Result();
@@ -147,13 +155,34 @@ bool Member::operator==( const Member &member ) const
return mMember == member.mMember;
}
-Result Member::cleanup() const
+TQString Member::scanDevices( const TQString &query )
{
Q_ASSERT( mMember );
OSyncError *error = 0;
- if ( !osync_member_delete( mMember, &error ) )
- return Result( &error );
- else
- return Result();
+ 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
index 215b0b148..294c19f15 100644
--- a/kitchensync/libqopensync/member.h
+++ b/kitchensync/libqopensync/member.h
@@ -22,21 +22,19 @@
#ifndef QSYNC_MEMBER_H
#define QSYNC_MEMBER_H
-#include <tqstring.h>
+#include <libqopensync/plugin.h>
+#include <libqopensync/result.h>
+#include <libqopensync/plugin.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();
@@ -58,6 +56,11 @@ class Member
TQString pluginName() const;
/**
+ Returns the plugin, the member belongs to.
+ */
+ Plugin plugin() const;
+
+ /**
Returns the id of the plugin.
*/
int id() const;
@@ -99,7 +102,7 @@ class Member
/**
Make this member an instance of the given plugin.
*/
- Result instance();
+ Result instance( const Plugin & );
bool operator==( const Member& ) const;
@@ -116,12 +119,6 @@ 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 a9437f387..acd54447a 100644
--- a/kitchensync/libqopensync/plugin.cpp
+++ b/kitchensync/libqopensync/plugin.cpp
@@ -20,7 +20,6 @@
*/
#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 ddddaadbb..d26c2826c 100644
--- a/kitchensync/libqopensync/plugin.h
+++ b/kitchensync/libqopensync/plugin.h
@@ -30,7 +30,7 @@ namespace QSync {
class Plugin
{
- friend class PluginEnv;
+ friend class Environment;
friend class Member;
public:
diff --git a/kitchensync/libqopensync/result.cpp b/kitchensync/libqopensync/result.cpp
index 13d06e71a..d38c32a3d 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_unref( error );
+ osync_error_free( error );
}
Result::~Result()
diff --git a/kitchensync/libqopensync/syncchange.cpp b/kitchensync/libqopensync/syncchange.cpp
index d45be2e4a..5dd72d7ff 100644
--- a/kitchensync/libqopensync/syncchange.cpp
+++ b/kitchensync/libqopensync/syncchange.cpp
@@ -19,13 +19,8 @@
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"
@@ -69,50 +64,39 @@ TQString SyncChange::hash() const
return TQString::fromUtf8( osync_change_get_hash( mSyncChange ) );
}
-void SyncChange::setData( const TQString &data , OSyncObjFormat *format )
+void SyncChange::setData( const TQString &data )
{
- 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 );
+ osync_change_set_data( mSyncChange, const_cast<char*>( data.utf8().data() ), data.utf8().size(), true );
}
TQString SyncChange::data() const
{
- char *buf;
- unsigned int size;
-
- OSyncData *data = osync_change_get_data( mSyncChange );
-
- osync_data_get_data( data, &buf, &size );
+ int size = osync_change_get_datasize( mSyncChange );
TQString content;
if ( objectFormatName() == "file" ) {
- OSyncFileFormat *format = (OSyncFileFormat*) buf;
+ fileFormat *format = (fileFormat*)osync_change_get_data( mSyncChange );
if ( format )
content = TQString::fromUtf8( format->data, format->size );
} else
- content = TQString::fromUtf8( buf, size );
-
- free( buf );
+ content = TQString::fromUtf8( osync_change_get_data( mSyncChange ), size );
return content;
}
bool SyncChange::hasData() const
{
- return osync_data_has_data( osync_change_get_data( mSyncChange ) );
+ return osync_change_has_data( mSyncChange );
}
TQString SyncChange::objectFormatName() const
{
- OSyncObjFormat *format = osync_data_get_objformat( osync_change_get_data( mSyncChange ) );
+ 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 );
@@ -122,7 +106,6 @@ Member SyncChange::member() const
return m;
}
-*/
void SyncChange::setChangeType( Type changeType )
{
@@ -130,20 +113,20 @@ void SyncChange::setChangeType( Type changeType )
switch ( changeType ) {
case AddedChange:
- ochangeType = OSYNC_CHANGE_TYPE_ADDED;
+ ochangeType = CHANGE_ADDED;
break;
case UnmodifiedChange:
- ochangeType = OSYNC_CHANGE_TYPE_UNMODIFIED;
+ ochangeType = CHANGE_UNMODIFIED;
break;
case DeletedChange:
- ochangeType = OSYNC_CHANGE_TYPE_DELETED;
+ ochangeType = CHANGE_DELETED;
break;
case ModifiedChange:
- ochangeType = OSYNC_CHANGE_TYPE_MODIFIED;
+ ochangeType = CHANGE_MODIFIED;
break;
case UnknownChange:
default:
- ochangeType = OSYNC_CHANGE_TYPE_UNKNOWN;
+ ochangeType = CHANGE_UNKNOWN;
break;
}
@@ -155,19 +138,19 @@ SyncChange::Type SyncChange::changeType() const
OSyncChangeType ochangeType = osync_change_get_changetype( mSyncChange );
switch ( ochangeType ) {
- case OSYNC_CHANGE_TYPE_ADDED:
+ case CHANGE_ADDED:
return AddedChange;
break;
- case OSYNC_CHANGE_TYPE_UNMODIFIED:
+ case CHANGE_UNMODIFIED:
return UnmodifiedChange;
break;
- case OSYNC_CHANGE_TYPE_DELETED:
+ case CHANGE_DELETED:
return DeletedChange;
break;
- case OSYNC_CHANGE_TYPE_MODIFIED:
+ case CHANGE_MODIFIED:
return ModifiedChange;
break;
- case OSYNC_CHANGE_TYPE_UNKNOWN:
+ case CHANGE_UNKNOWN:
default:
return UnknownChange;
break;
diff --git a/kitchensync/libqopensync/syncchange.h b/kitchensync/libqopensync/syncchange.h
index 2afaddcc4..53d9c4401 100644
--- a/kitchensync/libqopensync/syncchange.h
+++ b/kitchensync/libqopensync/syncchange.h
@@ -25,7 +25,6 @@
#include <libqopensync/member.h>
class OSyncChange;
-class OSyncObjFormat;
namespace QSync {
@@ -75,7 +74,7 @@ class SyncChange
/**
Sets the data provided by the plugin.
*/
- void setData( const TQString &data, OSyncObjFormat *format );
+ void setData( const TQString &data );
/**
Returns the data provided by the plugin.
@@ -95,7 +94,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 d716af17a..95939ab85 100644
--- a/kitchensync/libqopensync/syncmapping.cpp
+++ b/kitchensync/libqopensync/syncmapping.cpp
@@ -20,20 +20,19 @@
*/
#include <tqstring.h>
-#include <opensync/opensync.h>
-#include <opensync/opensync-engine.h>
+#include <osengine/engine.h>
#include "syncmapping.h"
using namespace QSync;
SyncMapping::SyncMapping()
- : mEngine( 0 ), mMappingEngine( 0 )
+ : mEngine( 0 ), mMapping( 0 )
{
}
-SyncMapping::SyncMapping( OSyncMappingEngine *mapping, OSyncEngine *engine )
- : mEngine( engine ), mMappingEngine( mapping )
+SyncMapping::SyncMapping( OSyncMapping *mapping, OSyncEngine *engine )
+ : mEngine( engine ), mMapping( mapping )
{
}
@@ -43,64 +42,58 @@ SyncMapping::~SyncMapping()
bool SyncMapping::isValid() const
{
- return ( mEngine != 0 && mMappingEngine != 0 );
+ return ( mEngine != 0 && mMapping != 0 );
}
-/*
long long SyncMapping::id() const
{
- Q_ASSERT( mMappingEngine );
+ Q_ASSERT( mMapping );
- return osync_mapping_engine_get_id( mMappingEngine );
+ return osengine_mapping_get_id( mMapping );
}
-*/
void SyncMapping::duplicate()
{
Q_ASSERT( mEngine );
- Q_ASSERT( mMappingEngine );
-
- OSyncError *error = 0;
+ Q_ASSERT( mMapping );
- osync_mapping_engine_duplicate( mMappingEngine, &error );
+ osengine_mapping_duplicate( mEngine, mMapping );
}
void SyncMapping::solve( const SyncChange &change )
{
Q_ASSERT( mEngine );
- Q_ASSERT( mMappingEngine );
+ Q_ASSERT( mMapping );
Q_ASSERT( change.isValid() );
- OSyncError *error = 0;
-
- osync_mapping_engine_solve( mMappingEngine, change.mSyncChange, &error );
+ osengine_mapping_solve( mEngine, mMapping, change.mSyncChange );
}
void SyncMapping::ignore()
{
Q_ASSERT( mEngine );
- Q_ASSERT( mMappingEngine );
+ Q_ASSERT( mMapping );
//TODO: error should be returned as Result
OSyncError *error = 0;
- osync_mapping_engine_ignore( mMappingEngine, &error );
+ osengine_mapping_ignore_conflict( mEngine, mMapping, &error );
}
int SyncMapping::changesCount() const
{
- Q_ASSERT( mMappingEngine );
+ Q_ASSERT( mMapping );
- return osync_mapping_engine_num_changes( mMappingEngine );
+ return osengine_mapping_num_changes( mMapping );
}
SyncChange SyncMapping::changeAt( int pos )
{
- Q_ASSERT( mMappingEngine );
+ Q_ASSERT( mMapping );
- if ( pos < 0 || pos >= osync_mapping_engine_num_changes( mMappingEngine ) )
+ if ( pos < 0 || pos >= osengine_mapping_num_changes( mMapping ) )
return SyncChange();
- OSyncChange *ochange = osync_mapping_engine_nth_change( mMappingEngine, pos );
+ OSyncChange *ochange = osengine_mapping_nth_change( mMapping, pos );
return SyncChange( ochange );
}
diff --git a/kitchensync/libqopensync/syncmapping.h b/kitchensync/libqopensync/syncmapping.h
index 0351fa9f5..6de67330a 100644
--- a/kitchensync/libqopensync/syncmapping.h
+++ b/kitchensync/libqopensync/syncmapping.h
@@ -25,7 +25,7 @@
#include <libqopensync/syncchange.h>
class OSyncEngine;
-class OSyncMappingEngine;
+class OSyncMapping;
namespace QSync {
@@ -35,7 +35,7 @@ class SyncMapping
public:
SyncMapping();
- SyncMapping( OSyncMappingEngine*, OSyncEngine* );
+ SyncMapping( OSyncMapping*, OSyncEngine* );
~SyncMapping();
bool isValid() const;
@@ -51,7 +51,7 @@ class SyncMapping
private:
OSyncEngine *mEngine;
- OSyncMappingEngine *mMappingEngine;
+ OSyncMapping *mMapping;
};
}
diff --git a/kitchensync/libqopensync/syncupdates.cpp b/kitchensync/libqopensync/syncupdates.cpp
index 3ad273f9f..653ccf7f3 100644
--- a/kitchensync/libqopensync/syncupdates.cpp
+++ b/kitchensync/libqopensync/syncupdates.cpp
@@ -19,8 +19,7 @@
Boston, MA 02110-1301, USA.
*/
-#include <opensync/opensync.h>
-#include <opensync/opensync-engine.h>
+#include <osengine/engine.h>
#include "syncupdates.h"
@@ -33,26 +32,32 @@ SyncMemberUpdate::SyncMemberUpdate()
SyncMemberUpdate::SyncMemberUpdate( OSyncMemberUpdate *update )
{
switch ( update->type ) {
- case OSYNC_CLIENT_EVENT_CONNECTED:
+ case MEMBER_CONNECTED:
mType = Connected;
break;
- case OSYNC_CLIENT_EVENT_DISCONNECTED:
+ case MEMBER_SENT_CHANGES:
+ mType = SentChanges;
+ break;
+ case MEMBER_COMMITTED_ALL:
+ mType = CommittedAll;
+ break;
+ case MEMBER_DISCONNECTED:
mType = Disconnected;
break;
- case OSYNC_CLIENT_EVENT_READ:
- mType = Read;
+ case MEMBER_CONNECT_ERROR:
+ mType = ConnectError;
break;
- case OSYNC_CLIENT_EVENT_WRITTEN:
- mType = Written;
+ case MEMBER_GET_CHANGES_ERROR:
+ mType = GetChangesError;
break;
- case OSYNC_CLIENT_EVENT_SYNC_DONE:
- mType = SyncDone;
+ case MEMBER_COMMITTED_ALL_ERROR:
+ mType = CommittedAllError;
break;
- case OSYNC_CLIENT_EVENT_DISCOVERED:
- mType = Discovered;
+ case MEMBER_SYNC_DONE_ERROR:
+ mType = SyncDoneError;
break;
- case OSYNC_CLIENT_EVENT_ERROR:
- mType = Error;
+ case MEMBER_DISCONNECT_ERROR:
+ mType = DisconnectedError;
break;
}
@@ -89,14 +94,20 @@ SyncChangeUpdate::SyncChangeUpdate()
SyncChangeUpdate::SyncChangeUpdate( OSyncChangeUpdate *update )
{
switch ( update->type ) {
- case OSYNC_CHANGE_EVENT_READ:
- mType = Read;
+ case CHANGE_RECEIVED:
+ mType = Received;
break;
- case OSYNC_CHANGE_EVENT_WRITTEN:
- mType = Written;
+ case CHANGE_RECEIVED_INFO:
+ mType = ReceivedInfo;
break;
- case OSYNC_CHANGE_EVENT_ERROR:
- mType = Error;
+ case CHANGE_SENT:
+ mType = Sent;
+ break;
+ case CHANGE_WRITE_ERROR:
+ mType = WriteError;
+ break;
+ case CHANGE_RECV_ERROR:
+ mType = ReceiveError;
break;
}
@@ -104,7 +115,7 @@ SyncChangeUpdate::SyncChangeUpdate( OSyncChangeUpdate *update )
mResult = Result( &(update->error) );
mChange = SyncChange( update->change );
- mMember.mMember = update->member;
+ mMemberId = update->member_id;
mMappingId = update->mapping_id;
}
@@ -127,9 +138,9 @@ SyncChange SyncChangeUpdate::change() const
return mChange;
}
-Member SyncChangeUpdate::member() const
+int SyncChangeUpdate::memberId() const
{
- return mMember;
+ return mMemberId;
}
int SyncChangeUpdate::mappingId() const
@@ -144,14 +155,14 @@ SyncMappingUpdate::SyncMappingUpdate()
SyncMappingUpdate::SyncMappingUpdate( OSyncMappingUpdate *update, OSyncEngine *engine )
{
switch ( update->type ) {
- case OSYNC_MAPPING_EVENT_SOLVED:
+ case MAPPING_SOLVED:
mType = Solved;
break;
-// case OSYNC_MAPPING_EVENT_SYNCED:
- // mType = Synced;
- // break;
- case OSYNC_MAPPING_EVENT_ERROR:
- mType = Error;
+ case MAPPING_SYNCED:
+ mType = Synced;
+ break;
+ case MAPPING_WRITE_ERROR:
+ mType = WriteError;
break;
}
@@ -160,9 +171,7 @@ SyncMappingUpdate::SyncMappingUpdate( OSyncMappingUpdate *update, OSyncEngine *e
mWinner = update->winner;
mMapping.mEngine = engine;
-
- // TODO PORTING
-// mMapping.mMapping = update->mapping;
+ mMapping.mMapping = update->mapping;
}
SyncMappingUpdate::~SyncMappingUpdate()
@@ -196,33 +205,30 @@ SyncEngineUpdate::SyncEngineUpdate()
SyncEngineUpdate::SyncEngineUpdate( OSyncEngineUpdate *update )
{
switch ( update->type ) {
- case OSYNC_ENGINE_EVENT_CONNECTED:
- mType = Connected;
+ case ENG_ENDPHASE_CON:
+ mType = EndPhaseConnected;
break;
- case OSYNC_ENGINE_EVENT_READ:
- mType = Read;
+ case ENG_ENDPHASE_READ:
+ mType = EndPhaseRead;
break;
- case OSYNC_ENGINE_EVENT_WRITTEN:
- mType = Written;
+ case ENG_ENDPHASE_WRITE:
+ mType = EndPhaseWrite;
break;
- case OSYNC_ENGINE_EVENT_DISCONNECTED:
- mType = Disconnected;
+ case ENG_ENDPHASE_DISCON:
+ mType = EndPhaseDisconnected;
break;
- case OSYNC_ENGINE_EVENT_ERROR:
+ case ENG_ERROR:
mType = Error;
break;
- case OSYNC_ENGINE_EVENT_SUCCESSFUL:
- mType = SyncSuccessful;
+ case ENG_SYNC_SUCCESSFULL:
+ mType = SyncSuccessfull;
break;
- case OSYNC_ENGINE_EVENT_PREV_UNCLEAN:
+ case ENG_PREV_UNCLEAN:
mType = PrevUnclean;
break;
- case OSYNC_ENGINE_EVENT_END_CONFLICTS:
+ case ENG_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 96741b059..14a2d9193 100644
--- a/kitchensync/libqopensync/syncupdates.h
+++ b/kitchensync/libqopensync/syncupdates.h
@@ -42,12 +42,14 @@ class SyncMemberUpdate
public:
enum Type {
Connected,
+ SentChanges,
+ CommittedAll,
Disconnected,
- Read,
- Written,
- SyncDone,
- Discovered,
- Error
+ ConnectError,
+ GetChangesError,
+ CommittedAllError,
+ SyncDoneError,
+ DisconnectedError
};
SyncMemberUpdate();
@@ -70,9 +72,11 @@ class SyncChangeUpdate
public:
enum Type {
- Read = 1,
- Written,
- Error
+ Received = 1,
+ ReceivedInfo,
+ Sent,
+ WriteError,
+ ReceiveError
};
SyncChangeUpdate();
@@ -82,14 +86,14 @@ class SyncChangeUpdate
Type type() const;
Result result() const;
SyncChange change() const;
- Member member() const;
+ int memberId() const;
int mappingId() const;
private:
Type mType;
Result mResult;
SyncChange mChange;
- Member mMember;
+ int mMemberId;
int mMappingId;
};
@@ -100,8 +104,8 @@ class SyncMappingUpdate
public:
enum Type {
Solved = 1,
- //Synced,
- Error
+ Synced,
+ WriteError
};
SyncMappingUpdate();
@@ -126,15 +130,14 @@ class SyncEngineUpdate
public:
enum Type {
- Connected = 1,
- Read,
- Written,
- Disconnected,
+ EndPhaseConnected = 1,
+ EndPhaseRead,
+ EndPhaseWrite,
+ EndPhaseDisconnected,
Error,
- SyncSuccessful,
+ SyncSuccessfull,
PrevUnclean,
- EndConflicts,
- SyncDone
+ EndConflicts
};
SyncEngineUpdate();
diff --git a/kitchensync/src/Makefile.am b/kitchensync/src/Makefile.am
index 6527084cc..7f94fc173 100644
--- a/kitchensync/src/Makefile.am
+++ b/kitchensync/src/Makefile.am
@@ -24,7 +24,7 @@ libkitchensync_la_SOURCES = aboutpage.cpp mainwidget.cpp groupconfigdialog.cpp \
pluginpicker.cpp configgui.cpp configguiblank.cpp configguifile.cpp \
memberinfo.cpp groupconfigcommon.cpp kwidgetlist.cpp \
configguipalm.cpp conflictdialog.cpp singleconflictdialog.cpp \
- addresseediffalgo.cpp calendardiffalgo.cpp xmldiffalgo.cpp \
+ addresseediffalgo.cpp calendardiffalgo.cpp \
htmldiffalgodisplay.cpp genericdiffalgo.cpp multiconflictdialog.cpp \
configguiirmc.cpp \
configguisyncmlobex.cpp configguisyncmlhttp.cpp configguiopie.cpp \
diff --git a/kitchensync/src/configguifile.cpp b/kitchensync/src/configguifile.cpp
index a0c6a596d..6a8b0402c 100644
--- a/kitchensync/src/configguifile.cpp
+++ b/kitchensync/src/configguifile.cpp
@@ -55,20 +55,13 @@ void ConfigGuiFile::load( const TQString &xml )
TQDomDocument doc;
doc.setContent( xml );
TQDomElement docElement = doc.documentElement();
-
- TQDomNode node;
- for ( node = docElement.firstChild(); !node.isNull(); node = node.nextSibling() ) {
- TQDomElement e = node.toElement();
- if ( e.tagName() == "directory" ) {
- TQDomNode subNode;
- for ( subNode = e.firstChild(); !subNode.isNull(); subNode = subNode.nextSibling() ) {
- TQDomElement subElement = subNode.toElement();
- if ( subElement.tagName() == "path" ) {
- mFilename->setURL( subElement.text() );
- } else if ( subElement.tagName() == "recursive" ) {
- mRecursive->setChecked( subElement.text() == "TRUE" );
- }
- }
+ TQDomNode n;
+ for( n = docElement.firstChild(); !n.isNull(); n = n.nextSibling() ) {
+ TQDomElement e = n.toElement();
+ if ( e.tagName() == "path" ) {
+ mFilename->setURL( e.text() );
+ } else if ( e.tagName() == "recursive" ) {
+ mRecursive->setChecked( e.text() == "TRUE" );
}
}
}
@@ -76,18 +69,13 @@ void ConfigGuiFile::load( const TQString &xml )
TQString ConfigGuiFile::save() const
{
TQString xml;
- xml = "<config>\n";
- xml += " <directory>\n";
- xml += " <path>" + mFilename->url() + "</path>\n";
- xml += " <objtype>data</objtype>\n";
- xml += " <recursive>";
- if ( mRecursive->isChecked() )
- xml += "TRUE";
- else
- xml += "FALSE";
- xml += "</recursive>\n";
- xml += " </directory>\n";
- xml += "</config>\n";
+ xml = "<config>";
+ xml += "<path>" + mFilename->url() + "</path>";
+ xml += "<recursive>";
+ if ( mRecursive->isChecked() ) xml += "TRUE";
+ else xml += "FALSE";
+ xml += "</recursive>";
+ xml += "</config>";
return xml;
}
diff --git a/kitchensync/src/configguisyncmlhttp.cpp b/kitchensync/src/configguisyncmlhttp.cpp
index b07111675..26a8c2241 100644
--- a/kitchensync/src/configguisyncmlhttp.cpp
+++ b/kitchensync/src/configguisyncmlhttp.cpp
@@ -121,7 +121,7 @@ ConfigGuiSyncmlHttp::ConfigGuiSyncmlHttp( const QSync::Member &member, TQWidget
mGridLayout->addWidget( label, 5, 0 );
mRecvLimit = new TQSpinBox( optionWidget );
- mRecvLimit->setMinValue( 0 );
+ mRecvLimit->setMinValue( 1 );
mRecvLimit->setMaxValue( 65536 );
mGridLayout->addWidget( mRecvLimit, 5, 1 );
@@ -130,7 +130,7 @@ ConfigGuiSyncmlHttp::ConfigGuiSyncmlHttp( const QSync::Member &member, TQWidget
mGridLayout->addWidget( label, 6, 0 );
mMaxObjSize = new TQSpinBox( optionWidget );
- mMaxObjSize->setMinValue( 0 );
+ mMaxObjSize->setMinValue( 1 );
mMaxObjSize->setMaxValue( 65536 );
mGridLayout->addWidget( mMaxObjSize, 6, 1 );
diff --git a/kitchensync/src/configguisyncmlobex.cpp b/kitchensync/src/configguisyncmlobex.cpp
index ea952ef4a..372cf9261 100644
--- a/kitchensync/src/configguisyncmlobex.cpp
+++ b/kitchensync/src/configguisyncmlobex.cpp
@@ -153,7 +153,7 @@ ConfigGuiSyncmlObex::ConfigGuiSyncmlObex( const QSync::Member &member, TQWidget
mGridLayout->addWidget( label, 14, 0 );
mRecvLimit = new TQSpinBox( optionsWidget );
- mRecvLimit->setMinValue( 0 );
+ mRecvLimit->setMinValue( 1 );
mRecvLimit->setMaxValue( 65536 );
mGridLayout->addWidget( mRecvLimit, 14, 1 );
@@ -162,7 +162,7 @@ ConfigGuiSyncmlObex::ConfigGuiSyncmlObex( const QSync::Member &member, TQWidget
mGridLayout->addWidget( label, 15, 0 );
mMaxObjSize = new TQSpinBox( optionsWidget );
- mMaxObjSize->setMinValue( 0 );
+ mMaxObjSize->setMinValue( 1 );
mMaxObjSize->setMaxValue( 65536 );
mGridLayout->addWidget( mMaxObjSize, 15, 1 );
diff --git a/kitchensync/src/groupconfig.cpp b/kitchensync/src/groupconfig.cpp
index 7e0af734a..cfedcbfad 100644
--- a/kitchensync/src/groupconfig.cpp
+++ b/kitchensync/src/groupconfig.cpp
@@ -27,10 +27,8 @@
#include "syncprocess.h"
#include "syncprocessmanager.h"
-#include <libqopensync/engine.h>
#include <libqopensync/group.h>
#include <libqopensync/plugin.h>
-#include <libqopensync/result.h>
#include <kdialog.h>
#include <kiconloader.h>
@@ -42,7 +40,6 @@
#include <tqlabel.h>
#include <tqlayout.h>
#include <tqpushbutton.h>
-#include <tqtimer.h>
GroupConfig::GroupConfig( TQWidget *parent )
: TQWidget( parent )
@@ -87,6 +84,14 @@ GroupConfig::GroupConfig( TQWidget *parent )
mMemberView = new KJanusWidget( this, 0, KJanusWidget::IconList );
topLayout->addWidget( mMemberView );
+ TQBoxLayout *buttonLayout = new TQHBoxLayout( topLayout );
+
+ TQPushButton *addButton = new TQPushButton( i18n("Add Member..."), this );
+ connect( addButton, TQT_SIGNAL( clicked() ), TQT_SLOT( addMember() ) );
+ buttonLayout->addWidget( addButton );
+
+ buttonLayout->addStretch( 1 );
+
icon = KGlobal::iconLoader()->loadIcon( "bookmark", KIcon::Desktop );
TQFrame *page = mMemberView->addPage( i18n("Group"),
i18n("General Group Settings"), icon );
@@ -94,8 +99,6 @@ GroupConfig::GroupConfig( TQWidget *parent )
mCommonConfig = new GroupConfigCommon( page );
pageLayout->addWidget( mCommonConfig );
-
- connect( mMemberView, TQT_SIGNAL( aboutToShowPage( TQWidget* ) ), TQT_SLOT( memberWidgetSelected( TQWidget* ) ) );
}
void GroupConfig::setSyncProcess( SyncProcess *process )
@@ -110,9 +113,9 @@ void GroupConfig::setSyncProcess( SyncProcess *process )
void GroupConfig::updateMembers()
{
- TQMap<TQWidget*, MemberConfig *>::ConstIterator memberIt;
+ TQValueList<MemberConfig *>::ConstIterator memberIt;
for ( memberIt = mMemberConfigs.begin(); memberIt != mMemberConfigs.end(); ++memberIt )
- memberIt.data()->saveData();
+ (*memberIt)->saveData();
TQValueList<TQFrame *>::ConstIterator it2;
for ( it2 = mConfigPages.begin(); it2 != mConfigPages.end(); ++it2 ) {
@@ -122,9 +125,10 @@ void GroupConfig::updateMembers()
mConfigPages.clear();
mMemberConfigs.clear();
- const QSync::Group group = mProcess->group();
- for ( int i = 0; i < group.memberCount(); ++i ) {
- QSync::Member member = group.memberAt( i );
+ QSync::Group group = mProcess->group();
+ QSync::Group::Iterator it( group.begin() );
+ for ( ; it != group.end(); ++it ) {
+ QSync::Member member = *it;
MemberInfo mi( member );
TQFrame *page = mMemberView->addPage( mi.name(),
TQString( "%1 (%2)" ).arg( mi.name() ).arg(member.pluginName()), mi.desktopIcon() );
@@ -133,7 +137,7 @@ void GroupConfig::updateMembers()
mConfigPages.append( page );
MemberConfig *memberConfig = new MemberConfig( page, member );
- mMemberConfigs.insert( page, memberConfig );
+ mMemberConfigs.append( memberConfig );
pageLayout->addWidget( memberConfig );
memberConfig->loadData();
@@ -144,30 +148,15 @@ void GroupConfig::saveConfig()
{
mProcess->group().save();
- TQMap<TQWidget*, MemberConfig*>::ConstIterator it;
+ TQValueList<MemberConfig *>::ConstIterator it;
for ( it = mMemberConfigs.begin(); it != mMemberConfigs.end(); ++it )
- it.data()->saveData();
+ (*it)->saveData();
mCommonConfig->save();
- const QSync::Group group = mProcess->group();
- for ( int i = 0; i < group.memberCount(); ++i ) {
- const QSync::Member member = group.memberAt( i );
- mProcess->engine()->discover( member );
- }
-
mProcess->reinitEngine();
}
-void GroupConfig::memberWidgetSelected( TQWidget *wdg )
-{
- /**
- * Emit 'true' whenever a real member widget is selected by the
- * user.
- */
- emit memberSelected( wdg != mCommonConfig->parentWidget() );
-}
-
void GroupConfig::addMember()
{
QSync::Plugin plugin = PluginPickerDialog::getPlugin( this );
@@ -187,17 +176,4 @@ void GroupConfig::addMember()
}
}
-void GroupConfig::removeMember()
-{
- TQWidget *selectedWidget = mMemberView->pageWidget( mMemberView->activePageIndex() );
- if ( selectedWidget && mMemberConfigs.contains( selectedWidget ) ) {
- MemberConfig *config = mMemberConfigs[ selectedWidget ];
-
- SyncProcessManager::self()->removeMember( mProcess, config->member() );
- mMemberConfigs.remove( selectedWidget );
-
- TQTimer::singleShot( 0, this, TQT_SLOT( updateMembers() ) );
- }
-}
-
#include "groupconfig.moc"
diff --git a/kitchensync/src/groupconfig.h b/kitchensync/src/groupconfig.h
index 4deb8f255..8dc300b6b 100644
--- a/kitchensync/src/groupconfig.h
+++ b/kitchensync/src/groupconfig.h
@@ -40,19 +40,12 @@ class GroupConfig : public QWidget
void setSyncProcess( SyncProcess *process );
- void saveConfig();
-
- public slots:
- void addMember();
- void removeMember();
-
void updateMembers();
- signals:
- void memberSelected( bool );
+ void saveConfig();
protected slots:
- void memberWidgetSelected( TQWidget* );
+ void addMember();
private:
TQLabel *mNameLabel;
@@ -62,8 +55,8 @@ class GroupConfig : public QWidget
SyncProcess *mProcess;
GroupConfigCommon *mCommonConfig;
- TQMap<TQWidget*, MemberConfig*> mMemberConfigs;
- TQValueList<TQFrame*> mConfigPages;
+ TQValueList<MemberConfig *> mMemberConfigs;
+ TQValueList<TQFrame *> mConfigPages;
};
#endif
diff --git a/kitchensync/src/groupconfigcommon.cpp b/kitchensync/src/groupconfigcommon.cpp
index 360746893..9f629c4d2 100644
--- a/kitchensync/src/groupconfigcommon.cpp
+++ b/kitchensync/src/groupconfigcommon.cpp
@@ -30,15 +30,14 @@
#include <tqcheckbox.h>
#include <libqopensync/group.h>
-//#include <libqopensync/conversion.h>
+#include <libqopensync/conversion.h>
+#include <libqopensync/environment.h>
#include "syncprocess.h"
#include "syncprocessmanager.h"
#include "groupconfigcommon.h"
-// TODO: port ObjectTypeSelector to ported solution of Conversation class
-#if 0
ObjectTypeSelector::ObjectTypeSelector( TQWidget *parent )
: TQWidget( parent )
{
@@ -125,7 +124,6 @@ void ObjectTypeSelector::save( QSync::Group group )
QSync::GroupConfig config = group.config();
config.setActiveObjectTypes( objectTypes );
}
-#endif
GroupConfigCommon::GroupConfigCommon( TQWidget *parent )
: TQWidget( parent )
@@ -137,11 +135,10 @@ GroupConfigCommon::GroupConfigCommon( TQWidget *parent )
mGroupName = new KLineEdit( this );
layout->addWidget( mGroupName, 0, 1 );
- //layout->addWidget( new TQLabel( i18n( "Object Types to be Synchronized:"), this ), 1, 0, Qt::AlignTop );
+ layout->addWidget( new TQLabel( i18n( "Object Types to be Synchronized:"), this ), 1, 0, Qt::AlignTop );
- // TODO port ObjectTypeSelector class..
- //mObjectTypeSelector = new ObjectTypeSelector( this );
- //layout->addWidget( mObjectTypeSelector, 1, 1 );
+ mObjectTypeSelector = new ObjectTypeSelector( this );
+ layout->addWidget( mObjectTypeSelector, 1, 1 );
layout->setRowStretch( 2, 1 );
}
@@ -151,15 +148,11 @@ void GroupConfigCommon::setSyncProcess( SyncProcess *syncProcess )
mSyncProcess = syncProcess;
mGroupName->setText( mSyncProcess->group().name() );
-
- // TODO port ObjectTypeSelector class..
- //mObjectTypeSelector->load( mSyncProcess->group() );
+ mObjectTypeSelector->load( mSyncProcess->group() );
}
void GroupConfigCommon::save()
{
mSyncProcess->group().setName( mGroupName->text() );
-
- // TODO port ObjectTypeSelector class..
- //mObjectTypeSelector->save( mSyncProcess->group() );
+ mObjectTypeSelector->save( mSyncProcess->group() );
}
diff --git a/kitchensync/src/groupconfigcommon.h b/kitchensync/src/groupconfigcommon.h
index 15ec5e5ab..25a0ceb0c 100644
--- a/kitchensync/src/groupconfigcommon.h
+++ b/kitchensync/src/groupconfigcommon.h
@@ -30,8 +30,6 @@ class KLineEdit;
class SyncProcess;
class TQCheckBox;
-//TODO: Conversation needs to be ported before...
-#if 0
class ObjectTypeSelector : public TQWidget
{
public:
@@ -43,7 +41,6 @@ class ObjectTypeSelector : public TQWidget
private:
TQMap<TQString,TQCheckBox *> mObjectTypeChecks;
};
-#endif
class GroupConfigCommon : public QWidget
{
@@ -55,7 +52,7 @@ class GroupConfigCommon : public QWidget
private:
KLineEdit *mGroupName;
- // ObjectTypeSelector *mObjectTypeSelector;
+ ObjectTypeSelector *mObjectTypeSelector;
SyncProcess *mSyncProcess;
};
diff --git a/kitchensync/src/groupconfigdialog.cpp b/kitchensync/src/groupconfigdialog.cpp
index d0b5894f9..4d8be65d0 100644
--- a/kitchensync/src/groupconfigdialog.cpp
+++ b/kitchensync/src/groupconfigdialog.cpp
@@ -28,7 +28,7 @@
GroupConfigDialog::GroupConfigDialog( TQWidget *parent, SyncProcess *process )
: KDialogBase( parent, 0, true, i18n("Configure Synchronization Group"),
- Ok | User1 | User2, Ok )
+ Ok )
{
TQFrame *topFrame = makeMainWidget();
@@ -40,13 +40,6 @@ GroupConfigDialog::GroupConfigDialog( TQWidget *parent, SyncProcess *process )
mConfigWidget->setSyncProcess( process );
setInitialSize( configDialogSize( "size_groupconfigdialog" ) );
-
- enableButton( User1, false );
- setButtonText( User1, i18n( "Remove Member" ) );
-
- connect( mConfigWidget, TQT_SIGNAL( memberSelected( bool ) ), TQT_SLOT( memberSelected( bool ) ) );
-
- setButtonText( User2, i18n("Add Member...") );
}
GroupConfigDialog::~GroupConfigDialog()
@@ -61,19 +54,4 @@ void GroupConfigDialog::slotOk()
accept();
}
-void GroupConfigDialog::slotUser1()
-{
- mConfigWidget->removeMember();
-}
-
-void GroupConfigDialog::slotUser2()
-{
- mConfigWidget->addMember();
-}
-
-void GroupConfigDialog::memberSelected( bool selected )
-{
- enableButton( User1, selected );
-}
-
#include "groupconfigdialog.moc"
diff --git a/kitchensync/src/groupconfigdialog.h b/kitchensync/src/groupconfigdialog.h
index 8dde4da77..5fd70884f 100644
--- a/kitchensync/src/groupconfigdialog.h
+++ b/kitchensync/src/groupconfigdialog.h
@@ -35,11 +35,6 @@ class GroupConfigDialog : public KDialogBase
protected slots:
void slotOk();
- void slotUser1();
- void slotUser2();
-
- private slots:
- void memberSelected( bool );
private:
GroupConfig *mConfigWidget;
diff --git a/kitchensync/src/groupitem.cpp b/kitchensync/src/groupitem.cpp
index fe4b2fdcd..784991c6f 100644
--- a/kitchensync/src/groupitem.cpp
+++ b/kitchensync/src/groupitem.cpp
@@ -33,9 +33,6 @@
#include <tqprogressbar.h>
#include <tqvbox.h>
-#include <libqopensync/plugin.h>
-#include <libqopensync/pluginenv.h>
-
#include "memberinfo.h"
#include "multiconflictdialog.h"
#include "singleconflictdialog.h"
@@ -153,9 +150,12 @@ void GroupItem::update()
mProgressBar->reset();
mProgressBar->hide();
- const QSync::Group group = mSyncProcess->group();
- for ( int i = 0; i < group.memberCount(); ++i ) {
- MemberItem *item = new MemberItem( mBox, mSyncProcess, group.memberAt( i ) );
+ QSync::Group group = mSyncProcess->group();
+ QSync::Group::Iterator memberIt( group.begin() );
+ QSync::Group::Iterator memberEndIt( group.end() );
+
+ for ( ; memberIt != memberEndIt; ++memberIt ) {
+ MemberItem *item = new MemberItem( mBox, mSyncProcess, *memberIt );
item->show();
item->setStatusMessage( i18n( "Ready" ) );
mMemberItems.append( item );
@@ -187,11 +187,14 @@ void GroupItem::conflict( QSync::SyncMapping mapping )
void GroupItem::change( const QSync::SyncChangeUpdate &update )
{
switch ( update.type() ) {
- case QSync::SyncChangeUpdate::Read:
+ case QSync::SyncChangeUpdate::Received:
mProcessedItems++;
mStatus->setText( i18n( "%1 entries read" ).arg( mProcessedItems ) );
break;
- case QSync::SyncChangeUpdate::Written:
+ case QSync::SyncChangeUpdate::ReceivedInfo:
+ mStatus->setText( i18n( "Receive information" ) );
+ break;
+ case QSync::SyncChangeUpdate::Sent:
mProcessedItems--;
mStatus->setText( i18n( "%1 entries written" ).arg( mMaxProcessedItems - mProcessedItems ) );
@@ -208,7 +211,11 @@ void GroupItem::change( const QSync::SyncChangeUpdate &update )
mProgressBar->setProgress( 100 - progress );
}
break;
- case QSync::SyncChangeUpdate::Error:
+ case QSync::SyncChangeUpdate::WriteError:
+ mStatus->setText( i18n( "Error" ) );
+ KPassivePopup::message( update.result().message(), this );
+ break;
+ case QSync::SyncChangeUpdate::ReceiveError:
mStatus->setText( i18n( "Error" ) );
KPassivePopup::message( update.result().message(), this );
break;
@@ -225,21 +232,21 @@ void GroupItem::mapping( const QSync::SyncMappingUpdate& )
void GroupItem::engine( const QSync::SyncEngineUpdate &update )
{
switch ( update.type() ) {
- case QSync::SyncEngineUpdate::Connected:
+ case QSync::SyncEngineUpdate::EndPhaseConnected:
mStatus->setText( i18n( "Connected" ) );
mProgressBar->setProgress( 0 );
mSynchronizing = true;
mSyncAction->setText( "Abort Synchronization" );
break;
- case QSync::SyncEngineUpdate::Read:
+ case QSync::SyncEngineUpdate::EndPhaseRead:
mStatus->setText( i18n( "Data read" ) );
break;
- case QSync::SyncEngineUpdate::Written:
+ case QSync::SyncEngineUpdate::EndPhaseWrite:
mStatus->setText( i18n( "Data written" ) );
mProgressBar->setProgress( 100 );
mProcessedItems = mMaxProcessedItems = 0;
break;
- case QSync::SyncEngineUpdate::Disconnected:
+ case QSync::SyncEngineUpdate::EndPhaseDisconnected:
mStatus->setText( i18n( "Disconnected" ) );
break;
case QSync::SyncEngineUpdate::Error:
@@ -250,7 +257,7 @@ void GroupItem::engine( const QSync::SyncEngineUpdate &update )
mSynchronizing = false;
mSyncAction->setText( i18n( "Synchronize Now" ) );
break;
- case QSync::SyncEngineUpdate::SyncSuccessful:
+ case QSync::SyncEngineUpdate::SyncSuccessfull:
mStatus->setText( i18n( "Successfully synchronized" ) );
mSyncProcess->group().setLastSynchronization( TQDateTime::currentDateTime() );
mSyncProcess->group().save();
@@ -281,22 +288,28 @@ void GroupItem::member( const QSync::SyncMemberUpdate &update )
case QSync::SyncMemberUpdate::Connected:
(*it)->setStatusMessage( i18n( "Connected" ) );
break;
- case QSync::SyncMemberUpdate::Read:
+ case QSync::SyncMemberUpdate::SentChanges:
(*it)->setStatusMessage( i18n( "Changes read" ) );
break;
- case QSync::SyncMemberUpdate::Written:
+ case QSync::SyncMemberUpdate::CommittedAll:
(*it)->setStatusMessage( i18n( "Changes written" ) );
break;
case QSync::SyncMemberUpdate::Disconnected:
(*it)->setStatusMessage( i18n( "Disconnected" ) );
break;
- case QSync::SyncMemberUpdate::SyncDone:
- (*it)->setStatusMessage( i18n( "Synchronization done" ) );
+ case QSync::SyncMemberUpdate::ConnectError:
+ (*it)->setStatusMessage( i18n( "Error: %1" ).arg( update.result().message() ) );
break;
- case QSync::SyncMemberUpdate::Discovered:
- (*it)->setStatusMessage( i18n( "Discovered" ) );
+ case QSync::SyncMemberUpdate::GetChangesError:
+ (*it)->setStatusMessage( i18n( "Error: %1" ).arg( update.result().message() ) );
break;
- case QSync::SyncMemberUpdate::Error:
+ case QSync::SyncMemberUpdate::CommittedAllError:
+ (*it)->setStatusMessage( i18n( "Error: %1" ).arg( update.result().message() ) );
+ break;
+ case QSync::SyncMemberUpdate::SyncDoneError:
+ (*it)->setStatusMessage( i18n( "Error: %1" ).arg( update.result().message() ) );
+ break;
+ case QSync::SyncMemberUpdate::DisconnectedError:
(*it)->setStatusMessage( i18n( "Error: %1" ).arg( update.result().message() ) );
break;
default:
@@ -339,8 +352,11 @@ MemberItem::MemberItem( TQWidget *parent, SyncProcess *process,
TQFont boldFont;
boldFont.setBold( true );
- const MemberInfo mi( member );
- const TQPixmap icon = mi.smallIcon();
+ MemberInfo mi( member );
+
+ TQPixmap icon = mi.smallIcon();
+
+ QSync::Plugin plugin = member.plugin();
TQVBoxLayout *layout = new TQVBoxLayout( this );
@@ -362,14 +378,7 @@ MemberItem::MemberItem( TQWidget *parent, SyncProcess *process,
mStatus = new TQLabel( box );
mMemberName->setText( member.name() );
-
- const QSync::PluginEnv *env = SyncProcessManager::self()->pluginEnv();
- const QSync::Plugin plugin = env->pluginByName( member.pluginName() );
-
- if ( plugin.isValid() )
- mDescription->setText( plugin.longName() );
- else
- mDescription->setText( i18n("Plugin \"%1\" can't get initialized!").arg( member.pluginName() ) );
+ mDescription->setText( plugin.longName() );
}
void MemberItem::setStatusMessage( const TQString &msg )
diff --git a/kitchensync/src/mainwidget.cpp b/kitchensync/src/mainwidget.cpp
index 02b279b3e..d04542f9d 100644
--- a/kitchensync/src/mainwidget.cpp
+++ b/kitchensync/src/mainwidget.cpp
@@ -26,7 +26,7 @@
#include "syncprocess.h"
#include "syncprocessmanager.h"
-#include <libqopensync/result.h>
+#include <libqopensync/environment.h>
#include <kaboutdata.h>
#include <kaction.h>
@@ -46,6 +46,13 @@ MainWidget::MainWidget( KXMLGUIClient *guiClient, TQWidget *widget, const char *
initGUI();
initActions();
+ /** apply object type filter hack **/
+ int count = SyncProcessManager::self()->count();
+ for ( int i = 0; i < count; ++i ) {
+ SyncProcessManager::self()->at( i )->applyObjectTypeFilter();
+ }
+ /** apply object type filter hack **/
+
mGroupView->updateView();
connect( SyncProcessManager::self(), TQT_SIGNAL( changed() ),
@@ -118,19 +125,12 @@ void MainWidget::addGroup()
{
bool ok;
TQString name = KInputDialog::getText( i18n("Create Synchronization Group"),
- i18n("Name for new synchronization group."), i18n( "Default" ), &ok, this );
+ i18n("Name for new synchronization group."), TQString::null, &ok, this );
if ( ok ) {
- SyncProcess *process = SyncProcessManager::self()->byGroupName( name );
- if ( process ) {
- KMessageBox::error( this, i18n( "A group with the same name exists already.\nPlease choose another name." ),
- i18n( "Duplicated Group Name" ) );
- return;
- }
-
SyncProcessManager::self()->addGroup( name );
enableActions();
- process = SyncProcessManager::self()->byGroupName( name );
+ SyncProcess *process = SyncProcessManager::self()->byGroupName( name );
if ( process )
editGroup( process );
}
diff --git a/kitchensync/src/memberconfig.cpp b/kitchensync/src/memberconfig.cpp
index d3d08a63b..37755a504 100644
--- a/kitchensync/src/memberconfig.cpp
+++ b/kitchensync/src/memberconfig.cpp
@@ -23,8 +23,6 @@
#include "configgui.h"
#include "memberinfo.h"
-#include <libqopensync/result.h>
-
#include <klocale.h>
#include <kmessagebox.h>
@@ -69,16 +67,13 @@ void MemberConfig::saveData()
if ( txt.isEmpty() ) {
KMessageBox::sorry( this, i18n("Configuration of %1 is empty.").arg( mMember.pluginName() ) );
} else {
- mMember.setConfiguration( txt.utf8() );
+ TQByteArray cfg = txt.utf8();
+ cfg.truncate(cfg.size() - 1); /* discard NUL terminator */
+ mMember.setConfiguration( cfg );
mMember.setName( mGui->instanceName() );
// TODO: Check for save() error.
mMember.save();
}
}
-QSync::Member MemberConfig::member() const
-{
- return mMember;
-}
-
#include "memberconfig.moc"
diff --git a/kitchensync/src/memberconfig.h b/kitchensync/src/memberconfig.h
index b2a3569d4..c6457972d 100644
--- a/kitchensync/src/memberconfig.h
+++ b/kitchensync/src/memberconfig.h
@@ -38,8 +38,6 @@ class MemberConfig : public QWidget
void loadData();
void saveData();
- QSync::Member member() const;
-
private:
QSync::Member mMember;
diff --git a/kitchensync/src/multiconflictdialog.cpp b/kitchensync/src/multiconflictdialog.cpp
index 88d42d3b3..7d7805c42 100644
--- a/kitchensync/src/multiconflictdialog.cpp
+++ b/kitchensync/src/multiconflictdialog.cpp
@@ -39,10 +39,8 @@ class ChangeItem : public KWidgetListItem
{
TQGridLayout *layout = new TQGridLayout( this, 2, 1, KDialog::marginHint(), KDialog::spacingHint() );
- // TODO change doesn't contain member as struct member .. use SyncMapping to determine the correct member.
- //MemberInfo mi( change.member() );
- //layout->addWidget( new TQLabel( mi.name(), this ), 0, 0 );
- layout->addWidget( new TQLabel( "PORTING TODO", this ), 0, 0 );
+ MemberInfo mi( change.member() );
+ layout->addWidget( new TQLabel( mi.name(), this ), 0, 0 );
TQString type;
switch ( change.changeType() ) {
diff --git a/kitchensync/src/pluginpicker.cpp b/kitchensync/src/pluginpicker.cpp
index 5dda30bfe..d981599bd 100644
--- a/kitchensync/src/pluginpicker.cpp
+++ b/kitchensync/src/pluginpicker.cpp
@@ -24,7 +24,7 @@
#include "memberinfo.h"
#include "syncprocessmanager.h"
-#include <libqopensync/pluginenv.h>
+#include <libqopensync/environment.h>
#include <kdialog.h>
#include <kglobal.h>
@@ -77,14 +77,12 @@ void PluginPicker::updatePluginList()
{
mPluginList->clear();
- const QSync::PluginEnv *env = SyncProcessManager::self()->pluginEnv();
-
- for ( int i = 0; i < env->pluginCount(); ++i ) {
- QSync::Plugin plugin = env->pluginAt( i );
-
- if ( plugin.isValid() )
- mPluginList->appendItem( new PluginItem( mPluginList, plugin ) );
+ QSync::Environment *env = SyncProcessManager::self()->environment();
+ QSync::Environment::PluginIterator it( env->pluginBegin() );
+ for( ; it != env->pluginEnd(); ++it ) {
+ QSync::Plugin plugin = *it;
+ mPluginList->appendItem( new PluginItem( mPluginList, plugin ) );
}
}
diff --git a/kitchensync/src/singleconflictdialog.cpp b/kitchensync/src/singleconflictdialog.cpp
index 121ec50cb..8975b6f98 100644
--- a/kitchensync/src/singleconflictdialog.cpp
+++ b/kitchensync/src/singleconflictdialog.cpp
@@ -27,7 +27,6 @@
#include "addresseediffalgo.h"
#include "genericdiffalgo.h"
-#include "xmldiffalgo.h"
#include "htmldiffalgodisplay.h"
#include "memberinfo.h"
@@ -44,22 +43,16 @@ SingleConflictDialog::SingleConflictDialog( QSync::SyncMapping &mapping, TQWidge
if ( format == "file" ) {
mDiffAlgo = new KSync::GenericDiffAlgo( leftChange.data(), rightChange.data() );
- } else if ( format == "vcard21" || format == "vcard30" ) {
- mDiffAlgo = new KSync::AddresseeDiffAlgo( leftChange.data(), rightChange.data() );
+ } else if ( format == "vcard" ) {
} else if ( format == "calendar" ) {
- } else if ( format == "xmlformat-contact" || format == "xmlformat-note"
- || format == "xmlformat-event" || format == "xmlformat-todo") {
- mDiffAlgo = new KSync::XmlDiffAlgo( leftChange.data(), rightChange.data() );
+ } else if ( format == "xml-contact" ) {
+ mDiffAlgo = new KSync::AddresseeDiffAlgo( leftChange.data(), rightChange.data() );
}
-// TODO: SyncChange doesn't have member as struct member anymore ...
-// Use SyncMapping to determine the member .. see msynctool for example implementation of conlicthandler
-#if 0
MemberInfo miLeft( leftChange.member() );
mDiffAlgoDisplay->setLeftSourceTitle( miLeft.name() );
MemberInfo miRight( rightChange.member() );
mDiffAlgoDisplay->setRightSourceTitle( miRight.name() );
-#endif
if ( mDiffAlgo ) {
mDiffAlgo->addDisplay( mDiffAlgoDisplay );
@@ -106,7 +99,6 @@ void SingleConflictDialog::initGUI()
TQGridLayout *layout = new TQGridLayout( this, 3, 4, KDialog::marginHint(), KDialog::spacingHint() );
layout->addMultiCellWidget( new TQLabel( i18n( "A conflict has appeared, please solve it manually." ), this ), 0, 0, 0, 3 );
-
mDiffAlgoDisplay = new KSync::HTMLDiffAlgoDisplay( this );
layout->addMultiCellWidget( mDiffAlgoDisplay, 1, 1, 0, 3 );
diff --git a/kitchensync/src/syncprocess.cpp b/kitchensync/src/syncprocess.cpp
index 2ff93bcd4..60310b803 100644
--- a/kitchensync/src/syncprocess.cpp
+++ b/kitchensync/src/syncprocess.cpp
@@ -19,12 +19,10 @@
*/
#include <libqopensync/engine.h>
-#include <libqopensync/member.h>
-#include <libqopensync/result.h>
+#include <libqopensync/environment.h>
#include <kdebug.h>
#include <klocale.h>
-#include <kmessagebox.h>
#include "syncprocess.h"
#include "syncprocessmanager.h"
@@ -62,8 +60,8 @@ TQString SyncProcess::memberStatus( const QSync::Member& ) const
QSync::Result SyncProcess::addMember( const QSync::Plugin &plugin )
{
- QSync::Member member = mGroup.addMember( plugin );
- QSync::Result result = member.instance();
+ QSync::Member member = mGroup.addMember();
+ QSync::Result result = member.instance( plugin );
if ( !result.isError() )
mGroup.save();
@@ -71,27 +69,40 @@ QSync::Result SyncProcess::addMember( const QSync::Plugin &plugin )
return result;
}
-void SyncProcess::removeMember( const QSync::Member &member )
-{
- member.cleanup();
- mGroup.removeMember( member );
- mGroup.save();
-}
-
void SyncProcess::reinitEngine()
{
mEngine->finalize();
delete mEngine;
mEngine = new QSync::Engine( mGroup );
Result result = mEngine->initialize();
- if ( result.isError() ) {
+ if ( result.isError() )
kdDebug() << "SyncProcess::reinitEngine: " << result.message() << endl;
- KMessageBox::error( 0, i18n("Error initializing Synchronization Engine for group \"%1\":\n %2")
- .arg( mGroup.name() ).arg( result.message() ) );
- }
+ applyObjectTypeFilter();
emit engineChanged( mEngine );
}
+void SyncProcess::applyObjectTypeFilter()
+{
+ const QSync::Conversion conversion = SyncProcessManager::self()->environment()->conversion();
+ const TQStringList objectTypes = conversion.objectTypes();
+ const TQStringList activeObjectTypes = mGroup.config().activeObjectTypes();
+
+ for ( uint i = 0; i < objectTypes.count(); ++i ) {
+ if ( activeObjectTypes.contains( objectTypes[ i ] ) ) {
+ kdDebug() << "Enabled object type: " << objectTypes[ i ] << endl;
+ /*
+ * This is not required. Also this lead to filtering problems when sync with "file-sync".
+ * Uncomment this line again when OpenSync is fixed!
+ *
+ * mGroup.setObjectTypeEnabled( objectTypes[ i ], true );
+ */
+ } else {
+ kdDebug() << "Disabled object type: " << objectTypes[ i ] << endl;
+ mGroup.setObjectTypeEnabled( objectTypes[ i ], false );
+ }
+ }
+}
+
#include "syncprocess.moc"
diff --git a/kitchensync/src/syncprocess.h b/kitchensync/src/syncprocess.h
index 6cdefc408..ef23f7c52 100644
--- a/kitchensync/src/syncprocess.h
+++ b/kitchensync/src/syncprocess.h
@@ -44,10 +44,12 @@ class SyncProcess : public QObject
TQString memberStatus( const QSync::Member &member ) const;
QSync::Result addMember( const QSync::Plugin &plugin );
- void removeMember( const QSync::Member &member );
void reinitEngine();
+ /** apply object type filter hack **/
+ void applyObjectTypeFilter();
+
signals:
/**
This signal is emitted whenever the engine has changed ( reinitialized ).
diff --git a/kitchensync/src/syncprocessmanager.cpp b/kitchensync/src/syncprocessmanager.cpp
index 27e09a25e..fda111efd 100644
--- a/kitchensync/src/syncprocessmanager.cpp
+++ b/kitchensync/src/syncprocessmanager.cpp
@@ -23,10 +23,7 @@
#include "syncprocess.h"
-#include <libqopensync/groupenv.h>
-#include <libqopensync/member.h>
-#include <libqopensync/pluginenv.h>
-#include <libqopensync/result.h>
+#include <libqopensync/environment.h>
#include <kstaticdeleter.h>
#include <kmessagebox.h>
@@ -46,24 +43,14 @@ SyncProcessManager *SyncProcessManager::self()
SyncProcessManager::SyncProcessManager()
{
- mGroupEnv = new QSync::GroupEnv;
- QSync::Result result = mGroupEnv->initialize();
+ mEnvironment = new QSync::Environment;
+ QSync::Result result = mEnvironment->initialize();
if ( result.isError() ) {
KMessageBox::error( 0, i18n("Error initializing OpenSync.\n%1")
.arg( result.message() ) );
} else {
- initGroup( mGroupEnv );
+ init( mEnvironment );
}
-
- mPluginEnv = new QSync::PluginEnv;
- result = mPluginEnv->initialize();
- if ( result.isError() ) {
- KMessageBox::error( 0, i18n("Error initializing OpenSync.\n%1")
- .arg( result.message() ) );
- } else {
-// initPlugin( mPluginEnv );
- }
-
}
SyncProcessManager::~SyncProcessManager()
@@ -74,8 +61,8 @@ SyncProcessManager::~SyncProcessManager()
mProcesses.clear();
- mGroupEnv->finalize();
- delete mGroupEnv;
+ mEnvironment->finalize();
+ delete mEnvironment;
}
int SyncProcessManager::count() const
@@ -115,7 +102,8 @@ void SyncProcessManager::addGroup( const TQString &name )
{
SyncProcess* process = byGroupName( name );
if ( !process ) {
- QSync::Group group = mGroupEnv->addGroup( name );
+ QSync::Group group = mEnvironment->addGroup();
+ group.setName( name );
group.save();
mProcesses.append( new SyncProcess( group ) );
@@ -132,21 +120,22 @@ void SyncProcessManager::remove( SyncProcess *syncProcess )
const QSync::Group group = syncProcess->group();
delete syncProcess;
- mGroupEnv->removeGroup( group );
+ mEnvironment->removeGroup( group );
emit changed();
}
}
-void SyncProcessManager::initGroup( QSync::GroupEnv *groupEnv )
+void SyncProcessManager::init( QSync::Environment *environment )
{
- for ( int i = 0; i < groupEnv->groupCount(); ++i ) {
+ QSync::Environment::GroupIterator it( environment->groupBegin() );
+ for ( ; it != environment->groupEnd(); ++it ) {
/**
* We check whether the group is valid before we append them
* to mProcesses. That avoids crashes if the plugin of one of
* the members isn't loaded (e.g. not installed).
*/
- const QSync::Group group = groupEnv->groupAt( i );
+ const QSync::Group group = *it;
int count = group.memberCount();
bool isValid = true;
@@ -160,7 +149,7 @@ void SyncProcessManager::initGroup( QSync::GroupEnv *groupEnv )
}
if ( isValid )
- mProcesses.append( new SyncProcess( group ) );
+ mProcesses.append( new SyncProcess( *it ) );
}
emit changed();
@@ -180,13 +169,4 @@ QSync::Result SyncProcessManager::addMember( SyncProcess *process,
return result;
}
-void SyncProcessManager::removeMember( SyncProcess *process, const QSync::Member &member )
-{
- Q_ASSERT( process );
-
- process->removeMember( member );
- process->group().save();
- emit syncProcessChanged( process );
-}
-
#include "syncprocessmanager.moc"
diff --git a/kitchensync/src/syncprocessmanager.h b/kitchensync/src/syncprocessmanager.h
index 38004977d..b95018a84 100644
--- a/kitchensync/src/syncprocessmanager.h
+++ b/kitchensync/src/syncprocessmanager.h
@@ -26,8 +26,7 @@
#include <libqopensync/group.h>
namespace QSync {
-class GroupEnv;
-class PluginEnv;
+class Environment;
}
class SyncProcess;
@@ -44,14 +43,9 @@ class SyncProcessManager : public QObject
~SyncProcessManager();
/**
- Return OpenSync GroupEnv.
+ Return OpenSync Environment.
*/
- QSync::GroupEnv *groupEnv() const { return mGroupEnv; }
-
- /**
- Return OpenSync PluginEnv.
- */
- QSync::PluginEnv *pluginEnv() const { return mPluginEnv; }
+ QSync::Environment *environment() const { return mEnvironment; }
/**
Returns the number of SyncProcesses.
@@ -88,11 +82,6 @@ class SyncProcessManager : public QObject
*/
QSync::Result addMember( SyncProcess *process, const QSync::Plugin &plugin );
- /**
- Removes the @param member from the group of @param process.
- */
- void removeMember( SyncProcess *process, const QSync::Member &member );
-
signals:
void changed();
void syncProcessChanged( SyncProcess *process );
@@ -100,12 +89,10 @@ class SyncProcessManager : public QObject
private:
SyncProcessManager();
- void initGroup( QSync::GroupEnv *groupEnv );
-// void initPlugin( QSync::PluginEnv *pluginEnv );
+ void init( QSync::Environment *environment );
TQValueList<SyncProcess*> mProcesses;
- QSync::GroupEnv *mGroupEnv;
- QSync::PluginEnv *mPluginEnv;
+ QSync::Environment *mEnvironment;
static SyncProcessManager *mSelf;
};