From: <svn...@op...> - 2010-10-06 08:55:58
|
Author: deloptes Date: Wed Oct 6 10:55:48 2010 New Revision: 6143 URL: http://www.opensync.org/changeset/6143 Log: - working on configure/discover/init and sync Modified: plugins/akonadi-sync/trunk/CMakeLists.txt plugins/akonadi-sync/trunk/src/akonadi-sync plugins/akonadi-sync/trunk/src/akonadi_opensync.cpp plugins/akonadi-sync/trunk/src/akonadisink.h plugins/akonadi-sync/trunk/src/datasink.cpp plugins/akonadi-sync/trunk/src/datasink.h plugins/akonadi-sync/trunk/src/sinkbase.cpp plugins/akonadi-sync/trunk/src/sinkbase.h Modified: plugins/akonadi-sync/trunk/CMakeLists.txt ============================================================================== --- plugins/akonadi-sync/trunk/CMakeLists.txt Mon Oct 4 23:20:12 2010 (r6142) +++ plugins/akonadi-sync/trunk/CMakeLists.txt Wed Oct 6 10:55:48 2010 (r6143) @@ -21,7 +21,7 @@ # SET( CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -ggdb -g -O2 -Wall -W " ${CMAKE_CXX_FLAGS_DEBUG} ${KDE4_ENABLE_EXCEPTIONS} ) #ADD_DEFINITIONS(-g -O2 -fsigned-char -freg-struct-return -Wall -W -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Winline -Werror) -# ADD_DEFINITIONS( -DDEBUG -g -O2 -Wall -W -fexceptions) +ADD_DEFINITIONS( -DDEBUG -g -O2 -Wall -W -fexceptions) # -Werror FIND_PACKAGE( KdepimLibs REQUIRED ) Modified: plugins/akonadi-sync/trunk/src/akonadi-sync ============================================================================== --- plugins/akonadi-sync/trunk/src/akonadi-sync Mon Oct 4 23:20:12 2010 (r6142) +++ plugins/akonadi-sync/trunk/src/akonadi-sync Wed Oct 6 10:55:48 2010 (r6143) @@ -43,17 +43,10 @@ <Enabled>1</Enabled> <Formats> <Format> - <Name>vjournal</Name> + <Name>vnote11</Name> </Format> - </Formats> - <ObjType>journal</ObjType> - <Url>default</Url> - </Resource> - <Resource> - <Enabled>1</Enabled> - <Formats> <Format> - <Name>vnote11</Name> + <Name>vjournal</Name> </Format> </Formats> <ObjType>note</ObjType> Modified: plugins/akonadi-sync/trunk/src/akonadi_opensync.cpp ============================================================================== --- plugins/akonadi-sync/trunk/src/akonadi_opensync.cpp Mon Oct 4 23:20:12 2010 (r6142) +++ plugins/akonadi-sync/trunk/src/akonadi_opensync.cpp Wed Oct 6 10:55:48 2010 (r6143) @@ -88,15 +88,15 @@ else if ( sinkName == "contact" ) ds = new DataSink( DataSink::Contacts ); // FIXME: implement todos an journal (notes) - else if ( sinkName == "journal" ) + else if ( sinkName == "note" ) ds = new DataSink( DataSink::Journals ); else if ( sinkName == "todo" ) ds = new DataSink( DataSink::Todos ); - else if ( sinkName == "note" ) - ds = new DataSink( DataSink::Notes ); +// else if ( sinkName == "note" ) +// ds = new DataSink( DataSink::Notes ); else continue; - + if ( !ds->initialize( plugin, info, sink, error ) ) { delete ds; delete mainSink; @@ -108,13 +108,16 @@ return mainSink; } + + //FIXME: this probably a bug in opoensync // replace & static QString toXml(QString str) { - str.replace("<","<").replace(">",">").replace("&","and"); - return str; + str.replace("<","<").replace(">",">").replace("&","and"); + return str; } + static osync_bool testSupport(OSyncPluginInfo *info, OSyncPluginConfig *config, const char* mType, @@ -144,28 +147,37 @@ res = osync_plugin_config_find_active_resource(config ,mType); if ( ! res) { - res = osync_plugin_resource_new( error ); - osync_plugin_resource_enable(res,FALSE); +// res = osync_plugin_resource_new( error ); +// osync_plugin_resource_add_objformat_sink( res, osync_objformat_sink_new( objFormat, error ) ); +// osync_plugin_resource_enable(res,FALSE); +// osync_plugin_config_add_resource( config, res ); + kDebug() << "No support for " << mType << " disabled"; +// osync_objtype_sink_set_enabled( sinkEvent, FALSE ); + osync_objtype_sink_set_enabled( sinkEvent, FALSE ); + osync_objtype_sink_set_available( sinkEvent, FALSE ); continue; } - osync_plugin_resource_add_objformat_sink( res, osync_objformat_sink_new( objFormat, error ) ); + osync_plugin_resource_set_objtype( res, mType ); - QString myname = toXml(col.name()); + QString myname =QString::fromLatin1( osync_plugin_resource_get_name( res ) ); // + if ( myname.size() > 0 ) + myname.append(';').append(toXml(col.name())); + else + myname = toXml(col.name()); osync_plugin_resource_set_name( res, myname.toUtf8() ); // TODO: full path instead of the name + // osync_plugin_resource_set_url( res, col.url().url().toLatin1() ); - osync_plugin_resource_set_mime( res, mimeType ); - if (osync_plugin_resource_is_enabled(res)) { -// osync_plugin_config_add_resource( config, res ); - osync_objtype_sink_add_objformat_sink(sinkEvent,osync_objformat_sink_new (objFormat, error)); - osync_objtype_sink_set_enabled( sinkEvent, TRUE ); - osync_objtype_sink_set_available( sinkEvent, TRUE ); - } +// if (osync_plugin_resource_is_enabled(res)) { +// osync_plugin_resource_set_preferred_format( res, objFormat ); +// } + osync_plugin_resource_enable(res,TRUE); + osync_objtype_sink_set_enabled( sinkEvent, TRUE ); + osync_objtype_sink_set_available( sinkEvent, TRUE ); } -// osync_objtype_sink_add_objformat_sink( sinkEvent, "vevent20" ); + osync_plugin_info_add_objtype( info, sinkEvent ); - - return TRUE; + return TRUE; } static osync_bool akonadi_discover(OSyncPluginInfo *info, void *userdata, OSyncError **error ) @@ -181,37 +193,30 @@ } if ( !Akonadi::Control::start() ) return false; + + /* + Check for support of following types + text/directory - this is the addressbook + application/x-vnd.kde.contactgroup - is contact group ... I'm not sure about it ATM + text/calendar - this is general mime for the whole calendar, but we are interested in the details + application/x-vnd.akonadi.calendar.event, + application/x-vnd.akonadi.calendar.todo, + application/x-vnd.akonadi.calendar.journal, + application/x-vnd.akonadi.calendar.freebusy - this will be most probably ignored, so not checkign for it + */ - /* - Check for support of following types - - text/calendar - this is general mime for the whole calendar, but we are interested in the details - application/x-vnd.akonadi.calendar.event, - application/x-vnd.akonadi.calendar.todo, - application/x-vnd.akonadi.calendar.journal, - application/x-vnd.akonadi.calendar.freebusy - this will be most probably ignored, so not checkign for it - */ - - if ( ! testSupport(info, config, "event", "application/x-vnd.akonadi.calendar.event", "vevent20" ,error) ) - kDebug() << "NO support for vevent20"; -// return false; - - if ( ! testSupport(info, config, "todo", "application/x-vnd.akonadi.calendar.todo", "vtodo10" ,error) ) - kDebug() << "NO support for vtodo10"; -// return false; - - if ( ! testSupport(info, config, "journal", "application/x-vnd.akonadi.calendar.journal", "vjournal" ,error) ) - kDebug() << "NO support for vjournal"; -// return false; - // fetch all address books - if ( ! testSupport(info, config, "contact", "application/x-vnd.kde.contactgroup", "vcard30" ,error) ) - kDebug() << "NO support for vcard30"; -// return false; - // fetch all notes - if ( ! testSupport(info, config, "note", "application/x-vnd.kde.notes", "vnote11" ,error) ) - kDebug() << "NO support for vnote11"; -// return false; - // set information about the peer (KDE itself) +// testSupport(info, config, "contact", "application/x-vnd.kde.contactgroup", "vcard20" ,error); + testSupport(info, config, "contact", "application/x-vnd.kde.contactgroup", "vcard30" ,error); + + testSupport(info, config, "event", "application/x-vnd.akonadi.calendar.event", "vevent20" ,error); + +// testSupport(info, config, "todo", "application/x-vnd.akonadi.calendar.todo", "vtodo10" ,error); + testSupport(info, config, "todo", "application/x-vnd.akonadi.calendar.todo", "vtodo20" ,error); + + testSupport(info, config, "note", "application/x-vnd.akonadi.calendar.journal", "vjournal" ,error); +// testSupport(info, config, "note", "application/x-vnd.kde.notes", "vnote11" ,error); + + // set information about the peer (KDE itself) { OSyncVersion *version = osync_version_new(error); osync_version_set_plugin(version, "Akonadi-sync"); @@ -229,7 +234,7 @@ osync_trace(TRACE_ENTRY, "%s(%p)", __func__, userdata); kDebug(); AkonadiSink *sink = reinterpret_cast<AkonadiSink*>( userdata ); - sink->disconnect(); + sink->disconnect(); // delete sink; delete kcd; kcd = 0; Modified: plugins/akonadi-sync/trunk/src/akonadisink.h ============================================================================== --- plugins/akonadi-sync/trunk/src/akonadisink.h Mon Oct 4 23:20:12 2010 (r6142) +++ plugins/akonadi-sync/trunk/src/akonadisink.h Wed Oct 6 10:55:48 2010 (r6143) @@ -30,9 +30,9 @@ */ class AkonadiSink : public SinkBase { - Q_OBJECT + Q_OBJECT - public: +public: AkonadiSink(); ~AkonadiSink(); Modified: plugins/akonadi-sync/trunk/src/datasink.cpp ============================================================================== --- plugins/akonadi-sync/trunk/src/datasink.cpp Mon Oct 4 23:20:12 2010 (r6142) +++ plugins/akonadi-sync/trunk/src/datasink.cpp Wed Oct 6 10:55:48 2010 (r6143) @@ -48,7 +48,6 @@ using namespace Akonadi; typedef boost::shared_ptr<KCal::Incidence> IncidencePtr; -typedef boost::shared_ptr<KABC::Addressee> Incidence2Ptr; DataSink::DataSink ( int type ) : SinkBase ( GetChanges | Commit | SyncDone ), @@ -89,10 +88,10 @@ { kDebug() << "sink is not enabled.."; // osync_objtype_sink_remove_objformat_sink( sink ); - osync_objtype_sink_set_available(sink, FALSE); - return false; + osync_objtype_sink_set_available(sink, FALSE); +// return false; } else { - osync_objtype_sink_set_available(sink, TRUE); + osync_objtype_sink_set_available(sink, TRUE); } OSyncPluginResource *resource = osync_plugin_config_find_active_resource ( config, osync_objtype_sink_get_name ( sink ) ); @@ -111,7 +110,8 @@ { if ( !strcmp ( "vcard21", tobjformat ) ) m_Format = "vcard21"; - else if ( !strcmp ( "vcard30", tobjformat ) ) + // always prefer newer format + if ( !strcmp ( "vcard30", tobjformat ) ) m_Format = "vcard30"; break; } @@ -119,18 +119,21 @@ { if ( !strcmp ( "vevent10", tobjformat ) ) m_Format = "vevent10"; - else if ( !strcmp ( "vevent20", tobjformat ) ) + // always prefer newer format + if ( !strcmp ( "vevent20", tobjformat ) ) m_Format = "vevent20"; break; } - case Notes: +// case Notes: +// { +// if ( !strcmp ( "vnote11", tobjformat ) ) +// m_Format = "vnote11"; +// break; +// } + case Journals: { if ( !strcmp ( "vnote11", tobjformat ) ) m_Format = "vnote11"; - break; - } - case Journals: - { if ( !strcmp ( "vjournal", tobjformat ) ) m_Format = "vjournal"; break; @@ -139,7 +142,8 @@ { if ( !strcmp ( "vtodo10", tobjformat ) ) m_Format = "vtodo10"; - else if ( !strcmp ( "vtodo20", tobjformat ) ) + // always prefer newer format + if ( !strcmp ( "vtodo20", tobjformat ) ) m_Format = "vtodo20"; break; } @@ -153,7 +157,7 @@ osync_objtype_sink_set_userdata ( sink, this ); osync_objtype_sink_enable_hashtable ( sink , TRUE ); - + wrapSink ( sink ); return true; @@ -200,8 +204,8 @@ osync_trace ( TRACE_EXIT_ERROR, "%s: %s", __PRETTY_FUNCTION__, osync_error_print ( &oerror ) ); return; } - - Collection col = collection(); // osync_objtype_sink_get_name(sink()) + + Collection col = collection(); if ( !col.isValid() ) { kDebug() << "No collection"; @@ -220,7 +224,7 @@ return; } } - + ItemFetchJob *job = new ItemFetchJob ( col ); job->fetchScope().fetchFullPayload ( true ); kDebug() << "Fetched FullPayload" ; @@ -245,7 +249,7 @@ Q_FOREACH ( const Item& item, items ) { reportChange ( item ); } - kDebug() << "done"; + kDebug() << "done"; } void DataSink::reportChange ( const Item& item ) @@ -288,17 +292,17 @@ osync_change_set_hash ( change, QString::number ( item.revision() ).toLatin1() ); osync_data_set_objtype( odata, osync_objtype_sink_get_name( sink() ) ); osync_change_set_data ( change, odata ); - + osync_data_unref ( odata ); - + OSyncChangeType changetype = osync_hashtable_get_changetype ( hashtable, change ); osync_change_set_changetype ( change, changetype ); osync_hashtable_update_change ( hashtable, change ); - + if ( changetype != OSYNC_CHANGE_TYPE_UNMODIFIED ) osync_context_report_change ( context(), change ); - - /* + + /* kDebug() << "changeid:" << osync_change_get_uid ( change ) << "; " << "itemid:" << item.id() << "; " @@ -322,6 +326,8 @@ OSyncHashTable *hashtable = osync_objtype_sink_get_hashtable ( sink() ); OSyncList *u, *uids = osync_hashtable_get_deleted ( hashtable ); + OSyncFormatEnv *formatenv = osync_plugin_info_get_format_env( pluginInfo() ); + OSyncObjFormat *format = osync_format_env_find_objformat( formatenv, m_Format.toLatin1() ); for ( u = uids; u; u = u->next ) { QString uid ( ( char * ) u->data ); @@ -334,12 +340,24 @@ warning ( error ); continue; } + error = 0; + OSyncData *data = osync_data_new( NULL, 0, format, &error ); + if ( !data ) { + osync_change_unref( change ); + warning( error ); + continue; + } osync_change_set_uid ( change, uid.toLatin1() ); osync_change_set_changetype ( change, OSYNC_CHANGE_TYPE_DELETED ); + + osync_data_set_objtype( data, osync_objtype_sink_get_name( sink() ) ); + osync_change_set_data( change, data ); osync_hashtable_update_change ( hashtable, change ); -// do we need reporting it osync_context_report_change(context(), change); + //FIXME raport if change is at our side + osync_context_report_change ( context(), change ); osync_change_unref ( change ); + osync_data_unref(data); } osync_list_free ( uids ); @@ -357,13 +375,13 @@ osync_data_get_data ( osync_change_get_data ( change ), &plain, /*size*/0 ); QString str = QString::fromLatin1 ( plain ); QString id = QString::fromLatin1 ( osync_change_get_uid ( change ) ); - Collection col = collection(); + Collection col = collection(); switch ( osync_change_get_changetype ( change ) ) { case OSYNC_CHANGE_TYPE_ADDED: { -// const Item item = createItem ( change ); + // TODO: proper error handling (report errors to the sync engine) if ( !col.isValid() ) // error handling return; @@ -387,7 +405,7 @@ Item item = fetchItem ( id ); setPayload ( &item, str ); - if ( ! item.isValid() ) // TODO proper error handling + if ( ! item.isValid() ) // TODO proper error handling return; ItemModifyJob *modifyJob = new Akonadi::ItemModifyJob ( item ); @@ -441,9 +459,9 @@ kDebug() << "type = contacts"; KABC::VCardConverter converter; KABC::Addressee vcard = converter.parseVCard ( str.toUtf8() ); - item->setMimeType ( "text/directory" ); + item->setMimeType ( "text/directory" ); item->setPayload<KABC::Addressee> ( vcard ); - kDebug() << "payload: " << vcard.toString().toUtf8(); + kDebug() << "payload: " << vcard.toString().toUtf8(); break; } case Calendars: @@ -497,23 +515,13 @@ const Item DataSink::fetchItem ( const QString& id ) { kDebug(); - Collection col = collection(); - ItemFetchJob *fetchJob = new ItemFetchJob ( col ); + ItemFetchJob *fetchJob = new ItemFetchJob ( collection() ); fetchJob->fetchScope().fullPayload(); if ( fetchJob->exec() ) - { foreach ( const Item &item, fetchJob->items() ) - { - - kDebug() << "item " << item.remoteId(); - if ( item.remoteId().toLatin1() == id ) - { - kDebug() << "got item"; - return item; - } - } - } + if ( !strcmp(item.remoteId().toLatin1(), id.toLatin1() )) + return item; // no such item found? return Item(); Modified: plugins/akonadi-sync/trunk/src/datasink.h ============================================================================== --- plugins/akonadi-sync/trunk/src/datasink.h Mon Oct 4 23:20:12 2010 (r6142) +++ plugins/akonadi-sync/trunk/src/datasink.h Wed Oct 6 10:55:48 2010 (r6143) @@ -75,7 +75,9 @@ void reportChange( const Item& item, const QString& format ); /** - * Reimplement in subclass to provide data about changes to opensync. Note, that you must call DataSink::reportChange( Item, QString, int ) after you have organized data to be send to opensync. + * Reimplement in subclass to provide data about changes to opensync. + * Note, that you must call DataSink::reportChange( Item, QString, int ) + * after you have organized data to be send to opensync. */ void reportChange( const Item & item ); Modified: plugins/akonadi-sync/trunk/src/sinkbase.cpp ============================================================================== --- plugins/akonadi-sync/trunk/src/sinkbase.cpp Mon Oct 4 23:20:12 2010 (r6142) +++ plugins/akonadi-sync/trunk/src/sinkbase.cpp Wed Oct 6 10:55:48 2010 (r6143) @@ -27,7 +27,7 @@ osync_trace( TRACE_ENTRY, "%s(%p,%p, %p, %p)", __PRETTY_FUNCTION__, sink, info, ctx, userdata); \ SinkBase *sb = reinterpret_cast<SinkBase*>(userdata ); \ sb->setContext( ctx ); \ - sb->setPluginInfo( info ); + sb->setPluginInfo( info ); extern "C" { @@ -36,13 +36,13 @@ { WRAP( ) sb->connect(); - osync_trace( TRACE_EXIT, "%s", __PRETTY_FUNCTION__ ); + osync_trace( TRACE_EXIT, "%s", __PRETTY_FUNCTION__ ); } static void disconnect_wrapper(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *userdata) { WRAP( ) sb->disconnect(); - osync_trace( TRACE_EXIT, "%s", __PRETTY_FUNCTION__ ); + osync_trace( TRACE_EXIT, "%s", __PRETTY_FUNCTION__ ); } static void get_changes_wrapper(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, osync_bool slow_sync, void *userdata) { @@ -51,19 +51,25 @@ if ( slow_sync ) sb->setSlowSink(slow_sync); sb->getChanges(); - osync_trace( TRACE_EXIT, "%s", __PRETTY_FUNCTION__ ); + osync_trace( TRACE_EXIT, "%s", __PRETTY_FUNCTION__ ); } static void sync_done_wrapper(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *userdata) { WRAP( ) sb->syncDone(); - osync_trace( TRACE_EXIT, "%s", __PRETTY_FUNCTION__ ); + osync_trace( TRACE_EXIT, "%s", __PRETTY_FUNCTION__ ); } static void commit_wrapper(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, OSyncChange *change, void *userdata) { WRAP( ) sb->commit(change); - osync_trace( TRACE_EXIT, "%s", __PRETTY_FUNCTION__ ); + osync_trace( TRACE_EXIT, "%s", __PRETTY_FUNCTION__ ); + } + + static void commitAll_wrapper(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *userdata) { + WRAP( ) + sb->commitAll(); + osync_trace( TRACE_EXIT, "%s", __PRETTY_FUNCTION__ ); } // static void read_wrapper(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, OSyncChange *change, void *userdata) { @@ -71,13 +77,7 @@ // sb->commit(change); // osync_trace( TRACE_EXIT, "%s", __PRETTY_FUNCTION__ ); // } -// - static void commitAll_wrapper(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *userdata) { - WRAP( ) - sb->commitAll(); - osync_trace( TRACE_EXIT, "%s", __PRETTY_FUNCTION__ ); - } -// +// // static void commit_all_wrapper(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, OSyncChange *change, void *userdata) { // WRAP( ) // sb->commitAll(change); @@ -91,16 +91,16 @@ mContext( 0 ), mSink( 0 ), mPluginInfo( 0 ), - m_canConnect(false), - m_canDisconnect(false), - m_canCommit (false), - m_canCommitAll (false), + m_canConnect(false), + m_canDisconnect(false), + m_canCommit (false), + m_canCommitAll (false), // unused m_canBatchCommit(false), - m_canGetChanges(false), - m_canWrite (false), - m_canRead (false), - m_canSyncDone (false), - m_SlowSync (false) + m_canGetChanges(false), + m_canWrite (false), + m_canRead (false), + m_canSyncDone (false), + m_SlowSync (false) { m_canConnect = ( features & Connect ) ? true : false; @@ -117,12 +117,12 @@ SinkBase::~SinkBase() { - if ( mContext) - osync_context_unref(mContext); + if ( mContext) + osync_context_unref(mContext); if ( mSink ) osync_objtype_sink_unref( mSink ); if (mPluginInfo) - osync_plugin_info_unref(mPluginInfo); + osync_plugin_info_unref(mPluginInfo); } void SinkBase::connect() @@ -207,7 +207,7 @@ Q_ASSERT( sink ); Q_ASSERT( mSink == 0 ); mSink = sink; - + kDebug() << ">> m_canConnect:" << m_canConnect; kDebug() << ">> m_canDisconnect:" << m_canDisconnect; kDebug() << ">> m_canCommit:" << m_canCommit; @@ -216,39 +216,38 @@ kDebug() << ">> m_canCommitAll:" << m_canGetChanges; kDebug() << ">> m_canRead:" << m_canConnect; kDebug() << ">> m_canSyncDone:" << m_canGetChanges; - + if ( m_canConnect ) { osync_objtype_sink_set_connect_func(sink, connect_wrapper); - osync_objtype_sink_set_connect_timeout(sink, 5); + osync_objtype_sink_set_connect_timeout(sink, 5); } if ( m_canDisconnect ) { osync_objtype_sink_set_disconnect_func(sink, disconnect_wrapper); - osync_objtype_sink_set_disconnect_timeout(sink, 5); + osync_objtype_sink_set_disconnect_timeout(sink, 5); } if ( m_canGetChanges ) { osync_objtype_sink_set_get_changes_func(sink, get_changes_wrapper); - osync_objtype_sink_set_getchanges_timeout(sink, 5); + osync_objtype_sink_set_getchanges_timeout(sink, 5); } if ( m_canCommit ) { osync_objtype_sink_set_commit_func(sink, commit_wrapper); - osync_objtype_sink_set_commit_timeout(sink, 5); + osync_objtype_sink_set_commit_timeout(sink, 5); + } + if ( m_canCommitAll ) { + osync_objtype_sink_set_committed_all_func(sink, commitAll_wrapper); + osync_objtype_sink_set_committedall_timeout(sink, 5); + } + if ( m_canSyncDone ) { + osync_objtype_sink_set_sync_done_func(sink, sync_done_wrapper); + osync_objtype_sink_set_syncdone_timeout(sink, 5); } // TODO: check if relevant for akonadi // if ( m_canWrite ) // osync_objtype_sink_set_write(sink, TRUE); -// if ( m_canCommitAll || m_isContact || m_isEvent || m_isNote || m_isJournal || m_isTodo) { - if ( m_canCommitAll ) { - osync_objtype_sink_set_committed_all_func(sink, commitAll_wrapper); - osync_objtype_sink_set_committedall_timeout(sink, 5); - } // if ( m_canRead ) { // osync_objtype_sink_set_read_func(sink, read_wrapper); // osync_objtype_sink_set_read_timeout(sink, 5); // } - if ( m_canSyncDone ) { - osync_objtype_sink_set_sync_done_func(sink, sync_done_wrapper); - osync_objtype_sink_set_syncdone_timeout(sink, 5); - } } Modified: plugins/akonadi-sync/trunk/src/sinkbase.h ============================================================================== --- plugins/akonadi-sync/trunk/src/sinkbase.h Mon Oct 4 23:20:12 2010 (r6142) +++ plugins/akonadi-sync/trunk/src/sinkbase.h Wed Oct 6 10:55:48 2010 (r6143) @@ -1,7 +1,7 @@ /* Copyright (c) 2008 Volker Krause <vk...@kd...> Copyright (c) 2010 Emanoil Kotsev <del...@ya...> - + $Id$ This library is free software; you can redistribute it and/or modify it @@ -34,19 +34,19 @@ */ class SinkBase : public QObject { - Q_OBJECT + Q_OBJECT - public: +public: enum Feature { - Connect = 1, - Disconnect = 2, - GetChanges = 4, - Commit = 8, - Write = 16, - CommittedAll = 32, - Read = 64, - BatchCommit = 128, - SyncDone = 256 + Connect = 1, + Disconnect = 2, + GetChanges = 4, + Commit = 8, + Write = 16, + CommittedAll = 32, + Read = 64, + BatchCommit = 128, + SyncDone = 256 }; SinkBase( int features ); @@ -61,30 +61,36 @@ virtual void commitAll(); virtual void syncDone(); - OSyncContext* context() const { return mContext; } + OSyncContext* context() const { + return mContext; + } void setContext( OSyncContext *context ); - OSyncPluginInfo *pluginInfo() const { return mPluginInfo; } + OSyncPluginInfo *pluginInfo() const { + return mPluginInfo; + } void setPluginInfo( OSyncPluginInfo *info ); void setSlowSink (osync_bool); osync_bool getSlowSink (); - protected: +protected: void success() const; void error( OSyncErrorType type, const QString &msg ) const; void warning( OSyncError *error ) const; void wrapSink( OSyncObjTypeSink* sink ); - OSyncObjTypeSink* sink() const { return mSink; } + OSyncObjTypeSink* sink() const { + return mSink; + } bool m_isContact, m_isEvent, m_isTodo, m_isNote, m_isJournal; //TODO intended to be private - private: +private: mutable OSyncContext *mContext; OSyncObjTypeSink *mSink; OSyncPluginInfo *mPluginInfo; // what do we have and what can we do - bool m_canConnect, m_canDisconnect, m_canCommit, m_canCommitAll, - m_canGetChanges, m_canWrite, m_canRead, m_canSyncDone; + bool m_canConnect, m_canDisconnect, m_canCommit, m_canCommitAll, + m_canGetChanges, m_canWrite, m_canRead, m_canSyncDone; // unused bool m_canCommitRead, m_canBatchCommit; osync_bool m_SlowSync; }; |