summaryrefslogtreecommitdiffstats
path: root/kitchensync/libqopensync/member.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/member.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/member.cpp')
-rw-r--r--kitchensync/libqopensync/member.cpp73
1 files changed, 51 insertions, 22 deletions
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;
+ }
}