summaryrefslogtreecommitdiffstats
path: root/kitchensync/libqopensync/member.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-07 22:30:29 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-07 22:30:29 +0000
commitd8b40941f9d1a221add0b9094eb09405a91a8aab (patch)
tree0b8e9b6347f6e75925bb3c386a47c5300b1a4775 /kitchensync/libqopensync/member.cpp
parent009631d0fc83f471d6c515e2a5001337a5a2ea21 (diff)
downloadtdepim-d8b40941f9d1a221add0b9094eb09405a91a8aab.tar.gz
tdepim-d8b40941f9d1a221add0b9094eb09405a91a8aab.zip
Part 2/2 of Chakra patch commit
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1172727 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kitchensync/libqopensync/member.cpp')
-rw-r--r--kitchensync/libqopensync/member.cpp73
1 files changed, 22 insertions, 51 deletions
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();
}