From: <dg...@su...> - 2009-01-06 16:09:04
|
Author: henrik Date: Tue Jan 6 17:08:42 2009 New Revision: 5044 URL: http://www.opensync.org/changeset/5044 Log: Update to match latest OpenSync API changes (now compatible with -r5043): new anchor API, osync_plugin_set_useable_timeout not supported anymore; changed parameter list for discover function Modified: plugins/mozilla-sync/trunk/src/mozilla-sync.cpp Modified: plugins/mozilla-sync/trunk/src/mozilla-sync.cpp ============================================================================== --- plugins/mozilla-sync/trunk/src/mozilla-sync.cpp Tue Jan 6 15:05:53 2009 (r5043) +++ plugins/mozilla-sync/trunk/src/mozilla-sync.cpp Tue Jan 6 17:08:42 2009 (r5044) @@ -756,14 +756,15 @@ OSyncObjTypeSink *sink = osync_plugin_info_get_sink(pOSyncPluginInfo); OSyncMozillaDatabase *db = (OSyncMozillaDatabase*) osync_objtype_sink_get_userdata(sink); + OSyncError *error = NULL; - // TODO: / as directory separator is not portable - char *anchorpath = g_strdup_printf("%s" G_DIR_SEPARATOR_S "anchor.db", osync_plugin_info_get_configdir(pOSyncPluginInfo)); - LOG(10, "Updating anchor database [%s] key [%s] to value [%s]", anchorpath, db->szAnchorKey, db->szAnchorValue); - osync_anchor_update(anchorpath, db->szAnchorKey, db->szAnchorValue); - g_free(anchorpath); + LOG(10, "Updating anchor to value [%s]", db->szAnchorValue); + OSyncAnchor *anchor = osync_objtype_sink_get_anchor(sink); + if (!osync_anchor_update(anchor, db->szAnchorValue, &error)) { + osync_context_report_osyncerror(pOSyncContext, error); + LOG_EXIT_ERROR_OSYNC_SZ(10, &error, "Could not do osync_anchor_update"); + return; } - OSyncError *error = NULL; LOG(10, "Updating hash table"); if (!osync_hashtable_save(db->pOSyncHashTable, &error)) { osync_context_report_osyncerror(pOSyncContext, error); @@ -818,15 +819,20 @@ LOG_EXIT_ERROR_OSYNC_SZ(10, &error, "Could not load osync_hashtable_load"); return; } - char *anchorpath = g_strdup_printf("%s" G_DIR_SEPARATOR_S "anchor.db", osync_plugin_info_get_configdir(pOSyncPluginInfo)); - LOG(10, "Anchor database [%s] key [%s] value [%s]", anchorpath, db->szAnchorKey, db->szAnchorValue); - if (osync_anchor_compare(anchorpath, db->szAnchorKey, db->szAnchorValue)) { - LOG(10, "Found key with value; so do not force slow sync"); + + OSyncAnchor *anchor = osync_objtype_sink_get_anchor(sink); + osync_bool same; + if (!osync_anchor_compare(anchor, db->szAnchorValue, &same, &error)) { + osync_context_report_osyncerror(pOSyncContext, error); + LOG_EXIT_ERROR_OSYNC_SZ(10, &error, "Could not do osync_anchor_compare"); + return; } + + if (same) { + LOG(10, "Anchor matches; so do not force slow sync"); } else { - LOG(10, "Did not find key with value; so force slow sync"); + LOG(10, "Anchor does not match; so force slow sync"); osync_objtype_sink_set_slowsync(db->pOSyncObjTypeSink, TRUE); } - g_free(anchorpath); LOG(10, "Initializing Mozilla"); gboolean f; @@ -923,7 +929,7 @@ @param pOSyncPluginInfo On entry we have what we gave in get_sync_info. @param ppOSyncError Fill out in case of error **/ -static osync_bool mozilla_sync_discover(void *data, OSyncPluginInfo *pOSyncPluginInfo, OSyncError **ppOSyncError) +static osync_bool mozilla_sync_discover(OSyncPluginInfo *pOSyncPluginInfo, void *data, OSyncError **ppOSyncError) { LOG_ENTRY(10, "(%p, %p, %p)", data, pOSyncPluginInfo, ppOSyncError); @@ -995,7 +1001,7 @@ f=mozilla_config_check( &(pOSyncMozillaEnv->mozillaConfig), &szError, &logFunction); if (!f) { LOG_EXIT_ERROR_SZ(10, szError); return NULL; } - osync_plugin_set_useable_timeout(pOSyncPlugin, 5*60); // 5 minutes + osync_plugin_set_initialize_timeout(pOSyncPlugin, 3*60); // 3 minutes osync_plugin_set_finalize_timeout(pOSyncPlugin, 3*60); // 3 minutes @@ -1059,6 +1065,9 @@ continue; } + // Request anchor functionality from OpenSync + osync_objtype_sink_enable_anchor(sink, TRUE); + // TODO: Check the exact meaning of each timeout, and ajust accordingly osync_objtype_sink_set_connect_timeout(sink, 5*60); // 4 minutes osync_objtype_sink_set_disconnect_timeout(sink, 5*60); // 4 minutes @@ -1112,7 +1121,6 @@ if (capDef.fError) { LOG_EXIT_ERROR_OSYNC_SZ(10, capDef.ppOSyncError, "Could not add capability"); return NULL; } - LOG_EXIT(10, "(%p)", pOSyncMozillaEnv); return (void*) pOSyncMozillaEnv; } @@ -1174,7 +1182,6 @@ osync_plugin_set_finalize(pOSyncPlugin, mozilla_sync_finalize); osync_plugin_set_discover(pOSyncPlugin, mozilla_sync_discover); - osync_plugin_set_useable_timeout(pOSyncPlugin, 10*60); // 5 minutes osync_plugin_set_initialize_timeout(pOSyncPlugin, 5*60); // 3 minutes osync_plugin_set_finalize_timeout(pOSyncPlugin, 5*60); // 3 minutes osync_plugin_env_register_plugin(pOSyncPluginEnv, pOSyncPlugin); |