summaryrefslogtreecommitdiffstats
path: root/kitchensync/libqopensync/group.cpp
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/libqopensync/group.cpp
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/libqopensync/group.cpp')
-rw-r--r--kitchensync/libqopensync/group.cpp143
1 files changed, 99 insertions, 44 deletions
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;
}