You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
(56) |
Apr
(109) |
May
(15) |
Jun
(3) |
Jul
(37) |
Aug
(96) |
Sep
(40) |
Oct
(4) |
Nov
(54) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(47) |
Feb
(30) |
Mar
(102) |
Apr
(120) |
May
(68) |
Jun
(54) |
Jul
(53) |
Aug
(122) |
Sep
(190) |
Oct
(71) |
Nov
(85) |
Dec
(108) |
2007 |
Jan
(72) |
Feb
(190) |
Mar
(53) |
Apr
(101) |
May
(145) |
Jun
(148) |
Jul
(167) |
Aug
(143) |
Sep
(23) |
Oct
(198) |
Nov
(223) |
Dec
(195) |
2008 |
Jan
(100) |
Feb
(129) |
Mar
(79) |
Apr
(77) |
May
(34) |
Jun
(95) |
Jul
(112) |
Aug
(160) |
Sep
(82) |
Oct
(124) |
Nov
(199) |
Dec
(355) |
2009 |
Jan
(436) |
Feb
(89) |
Mar
(298) |
Apr
(189) |
May
(33) |
Jun
(88) |
Jul
(105) |
Aug
(44) |
Sep
(181) |
Oct
(87) |
Nov
(75) |
Dec
(1) |
2010 |
Jan
(63) |
Feb
(21) |
Mar
(3) |
Apr
(1) |
May
(1) |
Jun
(3) |
Jul
(26) |
Aug
(37) |
Sep
(26) |
Oct
(15) |
Nov
(13) |
Dec
|
From: <svn...@op...> - 2009-03-29 14:50:10
|
Author: dgollub Date: Sun Mar 29 16:50:05 2009 New Revision: 5424 URL: http://www.opensync.org/changeset/5424 Log: Drop sanity check if the Sync-Mode reported during connect() is equal to the one reported by the mobile. The Sync-Mode defined by the engine is not fixed set during connect(). For this reason osync_objtype_sink_get_slowsync() got dropped. The Sync-Mode is only fixed and can be retrieved by connect_done() and get_change() (from the argument list). Modified: plugins/syncml/src/syncml_callbacks.c Modified: plugins/syncml/src/syncml_callbacks.c ============================================================================== --- plugins/syncml/src/syncml_callbacks.c Sun Mar 29 16:47:11 2009 (r5423) +++ plugins/syncml/src/syncml_callbacks.c Sun Mar 29 16:50:05 2009 (r5424) @@ -196,15 +196,8 @@ if (!database) goto error; - /* locate alert type of sink */ - if (osync_objtype_sink_get_slowsync(database->sink)) - sentType = SML_ALERT_SLOW_SYNC; - else - sentType = SML_ALERT_TWO_WAY; - /* update alert type of sink if necessary */ - if (recvType == SML_ALERT_SLOW_SYNC && - recvType != sentType) + if (recvType == SML_ALERT_SLOW_SYNC) { osync_trace(TRACE_INTERNAL, "%s: signal SLOW-SYNC", __func__); osync_objtype_sink_set_slowsync(database->sink, TRUE); |
From: <svn...@op...> - 2009-03-29 14:47:16
|
Author: dgollub Date: Sun Mar 29 16:47:11 2009 New Revision: 5423 URL: http://www.opensync.org/changeset/5423 Log: Port SyncML plugin to API changes reg. osync_objtype_sink_get_objtype() r5357 and the plugin sink function connect_done() r5422. Modified: plugins/syncml/src/syncml_callbacks.c plugins/syncml/src/syncml_common.c plugins/syncml/src/syncml_common.h plugins/syncml/src/syncml_ds_client.c plugins/syncml/src/syncml_ds_server.c Modified: plugins/syncml/src/syncml_callbacks.c ============================================================================== --- plugins/syncml/src/syncml_callbacks.c Sun Mar 29 16:40:22 2009 (r5422) +++ plugins/syncml/src/syncml_callbacks.c Sun Mar 29 16:47:11 2009 (r5423) @@ -201,7 +201,7 @@ sentType = SML_ALERT_SLOW_SYNC; else sentType = SML_ALERT_TWO_WAY; - + /* update alert type of sink if necessary */ if (recvType == SML_ALERT_SLOW_SYNC && recvType != sentType) @@ -230,8 +230,8 @@ goto error; } - /* locate alert type of sink */ - if (osync_objtype_sink_get_slowsync(database->sink)) + /* locate alert type of sink, which is reported by connect_done() */ + if (database->slowsync) sentType = SML_ALERT_SLOW_SYNC; else sentType = SML_ALERT_TWO_WAY; @@ -345,8 +345,7 @@ /* If a SLOW-SYNC happens then OpenSync only expects ADD commands. * If a REPLACE is detected instead of an ADD then this is fixed. */ - if (osync_objtype_sink_get_slowsync(database->sink) && - type == SML_CHANGE_REPLACE) + if (database->slowsync && type == SML_CHANGE_REPLACE) { osync_change_set_changetype(change, OSYNC_CHANGE_TYPE_ADDED); } else { Modified: plugins/syncml/src/syncml_common.c ============================================================================== --- plugins/syncml/src/syncml_common.c Sun Mar 29 16:40:22 2009 (r5422) +++ plugins/syncml/src/syncml_common.c Sun Mar 29 16:47:11 2009 (r5423) @@ -183,7 +183,7 @@ return OSYNC_CHANGE_TYPE_UNKNOWN; } -void syncml_connect_done(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *data) +void syncml_connect_done(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, osync_bool slow_sync, void *data) { osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, data, info, ctx); @@ -191,6 +191,9 @@ SmlDatabase *database = (SmlDatabase*)data; g_mutex_lock(database->alert_type_mutex); + + database->slowsync = slow_sync; + g_cond_signal(database->alert_type_cond); g_mutex_unlock(database->alert_type_mutex); Modified: plugins/syncml/src/syncml_common.h ============================================================================== --- plugins/syncml/src/syncml_common.h Sun Mar 29 16:40:22 2009 (r5422) +++ plugins/syncml/src/syncml_common.h Sun Mar 29 16:47:11 2009 (r5423) @@ -129,6 +129,8 @@ GMutex *alert_type_mutex; GCond *alert_type_cond; + + osync_bool slowsync; } SmlDatabase; struct commitContext { @@ -149,7 +151,7 @@ OSyncPluginInfo *info, OSyncError **oerror); void syncml_connect(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *data); -void syncml_connect_done(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *data); +void syncml_connect_done(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, osync_bool slow_sync, void *data); void sync_done(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *data); void disconnect(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *data); Modified: plugins/syncml/src/syncml_ds_client.c ============================================================================== --- plugins/syncml/src/syncml_ds_client.c Sun Mar 29 16:40:22 2009 (r5422) +++ plugins/syncml/src/syncml_ds_client.c Sun Mar 29 16:47:11 2009 (r5423) @@ -113,6 +113,8 @@ SmlDatabase *database = (SmlDatabase*)data; SmlPluginEnv *env = database->env; + database->slowsync = slow_sync; + if (env->state1 >= SML_DATA_SYNC_EVENT_GOT_ALL_CHANGES) { report_success_on_context(&(ctx)); } else { Modified: plugins/syncml/src/syncml_ds_server.c ============================================================================== --- plugins/syncml/src/syncml_ds_server.c Sun Mar 29 16:40:22 2009 (r5422) +++ plugins/syncml/src/syncml_ds_server.c Sun Mar 29 16:47:11 2009 (r5423) @@ -109,6 +109,8 @@ SmlDatabase *database = (SmlDatabase*)data; SmlPluginEnv *env = database->env; + database->slowsync = slow_sync; + database->getChangesCtx = ctx; osync_context_ref(database->getChangesCtx); |
From: <svn...@op...> - 2009-03-29 14:40:28
|
Author: dgollub Date: Sun Mar 29 16:40:22 2009 New Revision: 5422 URL: http://www.opensync.org/changeset/5422 Log: Added "osync_bool slowsync" to the connect_done plugin sink function paramter list. To determine the current sync mode (slow-/fast-sync). Also fixed a bug where connect_done() got called with the wrong sync mode. Due to the sepeartion of Client and ClientProxy and the missing update of the Sync Mode the connect_done() got called with fast-sync even if the engine was supposed to do a slow-sync and would call slow-ysnc with get_changes(). Added regression testcase inside mock-sync. Modified: trunk/opensync/client/opensync_client.c trunk/opensync/client/opensync_client_proxy.c trunk/opensync/client/opensync_client_proxy_internals.h trunk/opensync/engine/opensync_engine.c trunk/opensync/engine/opensync_obj_engine.c trunk/opensync/plugin/opensync_objtype_sink.c trunk/opensync/plugin/opensync_objtype_sink.h trunk/tests/mock-plugin/mock_sync.c trunk/tests/mock-plugin/mock_sync.h Modified: trunk/opensync/client/opensync_client.c ============================================================================== --- trunk/opensync/client/opensync_client.c Sun Mar 29 16:14:48 2009 (r5421) +++ trunk/opensync/client/opensync_client.c Sun Mar 29 16:40:22 2009 (r5422) @@ -969,19 +969,19 @@ osync_message_unref(reply); } else { - /* set slowsync. - otherwise disable slowsync - to avoid slowsyncs every time with the same initiliazed engine - without finalizing the engine the next sync with the same engine would be again a slow-sync. - (unittest: sync - testcases: sync_easy_new_del, sync_easy_new_mapping) */ - if (slowsync) - osync_objtype_sink_set_slowsync(sink, TRUE); - else - osync_objtype_sink_set_slowsync(sink, FALSE); + /* set slowsync. + otherwise disable slowsync - to avoid slowsyncs every time with the same initiliazed engine + without finalizing the engine the next sync with the same engine would be again a slow-sync. + (unittest: sync - testcases: sync_easy_new_del, sync_easy_new_mapping) */ + if (slowsync) + osync_objtype_sink_set_slowsync(sink, TRUE); + else + osync_objtype_sink_set_slowsync(sink, FALSE); context = _create_context(client, message, _osync_client_connect_callback, NULL, error); if (!context) goto error; - + osync_plugin_info_set_sink(client->plugin_info, sink); osync_objtype_sink_connect(sink, client->plugin_info, context); @@ -1001,6 +1001,7 @@ static osync_bool _osync_client_handle_connect_done(OSyncClient *client, OSyncMessage *message, OSyncError **error) { char *objtype = NULL; + int slowsync; OSyncMessage *reply = NULL; OSyncObjTypeSink *sink = NULL; OSyncContext *context = NULL; @@ -1008,7 +1009,8 @@ osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, client, message, error); osync_message_read_string(message, &objtype); - osync_trace(TRACE_INTERNAL, "Searching sink for %s", objtype); + osync_message_read_int(message, &slowsync); + osync_trace(TRACE_INTERNAL, "Searching sink for %s (slowsync: %d)", objtype, slowsync); if (objtype) { sink = osync_plugin_info_find_objtype(client->plugin_info, objtype); @@ -1036,6 +1038,13 @@ context = _create_context(client, message, _osync_client_connect_done_callback, NULL, error); if (!context) goto error; + + /* set slowsync (again) if the slow-sync got requested during the connect() call + of a member - and not during frontend/engine itself (e.g. anchor mismatch). */ + if (slowsync) + osync_objtype_sink_set_slowsync(sink, TRUE); + else + osync_objtype_sink_set_slowsync(sink, FALSE); osync_plugin_info_set_sink(client->plugin_info, sink); osync_objtype_sink_connect_done(sink, client->plugin_info, context); Modified: trunk/opensync/client/opensync_client_proxy.c ============================================================================== --- trunk/opensync/client/opensync_client_proxy.c Sun Mar 29 16:14:48 2009 (r5421) +++ trunk/opensync/client/opensync_client_proxy.c Sun Mar 29 16:40:22 2009 (r5422) @@ -1406,7 +1406,6 @@ osync_message_write_string(message, objtype); osync_message_write_int(message, slowsync); - if (!osync_queue_send_message_with_timeout(proxy->outgoing, proxy->incoming, message, timeout, error)) goto error_free_message; @@ -1425,7 +1424,7 @@ return FALSE; } -osync_bool osync_client_proxy_connect_done(OSyncClientProxy *proxy, sync_done_cb callback, void *userdata, const char *objtype, OSyncError **error) +osync_bool osync_client_proxy_connect_done(OSyncClientProxy *proxy, sync_done_cb callback, void *userdata, const char *objtype, osync_bool slowsync, OSyncError **error) { int timeout = 0; callContext *ctx = NULL; @@ -1456,6 +1455,7 @@ osync_message_set_handler(message, _osync_client_proxy_connect_done_handler, ctx); osync_message_write_string(message, objtype); + osync_message_write_int(message, slowsync); if (!osync_queue_send_message_with_timeout(proxy->outgoing, proxy->incoming, message, timeout, error)) goto error_free_message; Modified: trunk/opensync/client/opensync_client_proxy_internals.h ============================================================================== --- trunk/opensync/client/opensync_client_proxy_internals.h Sun Mar 29 16:14:48 2009 (r5421) +++ trunk/opensync/client/opensync_client_proxy_internals.h Sun Mar 29 16:40:22 2009 (r5422) @@ -64,7 +64,7 @@ OSyncObjTypeSink *osync_client_proxy_find_objtype_sink(OSyncClientProxy *proxy, const char *objtype); OSYNC_TEST_EXPORT osync_bool osync_client_proxy_connect(OSyncClientProxy *proxy, connect_cb callback, void *userdata, const char *objtype, osync_bool slowsync, OSyncError **error); -OSYNC_TEST_EXPORT osync_bool osync_client_proxy_connect_done(OSyncClientProxy *proxy, connect_done_cb callback, void *userdata, const char *objtype, OSyncError **error); +OSYNC_TEST_EXPORT osync_bool osync_client_proxy_connect_done(OSyncClientProxy *proxy, connect_done_cb callback, void *userdata, const char *objtype, osync_bool slowsync, OSyncError **error); OSYNC_TEST_EXPORT osync_bool osync_client_proxy_disconnect(OSyncClientProxy *proxy, disconnect_cb callback, void *userdata, const char *objtype, OSyncError **error); osync_bool osync_client_proxy_read(OSyncClientProxy *proxy, read_cb callback, void *userdata, OSyncChange *change, OSyncError **error); Modified: trunk/opensync/engine/opensync_engine.c ============================================================================== --- trunk/opensync/engine/opensync_engine.c Sun Mar 29 16:14:48 2009 (r5421) +++ trunk/opensync/engine/opensync_engine.c Sun Mar 29 16:40:22 2009 (r5422) @@ -1922,7 +1922,7 @@ /* Now we send connect_done to the main sink */ for (o = engine->proxies; o; o = o->next) { OSyncClientProxy *proxy = o->data; - if (!osync_client_proxy_connect_done(proxy, _osync_engine_connect_done_callback, engine, NULL, &locerror)) + if (!osync_client_proxy_connect_done(proxy, _osync_engine_connect_done_callback, engine, NULL, FALSE, &locerror)) goto error; } Modified: trunk/opensync/engine/opensync_obj_engine.c ============================================================================== --- trunk/opensync/engine/opensync_obj_engine.c Sun Mar 29 16:14:48 2009 (r5421) +++ trunk/opensync/engine/opensync_obj_engine.c Sun Mar 29 16:40:22 2009 (r5422) @@ -958,7 +958,7 @@ for (p = engine->active_sink_engines; p; p = p->next) { sinkengine = p->data; - if (!osync_client_proxy_connect_done(sinkengine->proxy, _osync_obj_engine_connect_done_callback, sinkengine, engine->objtype, error)) + if (!osync_client_proxy_connect_done(sinkengine->proxy, _osync_obj_engine_connect_done_callback, sinkengine, engine->objtype, engine->slowsync, error)) goto error; osync_sink_engine_ref(sinkengine); // Note that connect_done callback has a reference } Modified: trunk/opensync/plugin/opensync_objtype_sink.c ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink.c Sun Mar 29 16:14:48 2009 (r5421) +++ trunk/opensync/plugin/opensync_objtype_sink.c Sun Mar 29 16:40:22 2009 (r5422) @@ -396,7 +396,7 @@ if (!functions.connect_done) osync_context_report_success(ctx); else - functions.connect_done(sink, info, ctx, osync_objtype_sink_get_userdata(sink)); + functions.connect_done(sink, info, ctx, osync_objtype_sink_get_slowsync(sink), osync_objtype_sink_get_userdata(sink)); osync_trace(TRACE_EXIT, "%s", __func__); } Modified: trunk/opensync/plugin/opensync_objtype_sink.h ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink.h Sun Mar 29 16:14:48 2009 (r5421) +++ trunk/opensync/plugin/opensync_objtype_sink.h Sun Mar 29 16:40:22 2009 (r5422) @@ -38,7 +38,7 @@ typedef osync_bool (* OSyncSinkReadFn) (OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, OSyncChange *change, void *data); typedef void (* OSyncSinkBatchCommitFn) (OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, OSyncContext **, OSyncChange **changes, void *data); typedef void (* OSyncSinkSyncDoneFn) (OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *data); -typedef void (* OSyncSinkConnectDoneFn) (OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *data); +typedef void (* OSyncSinkConnectDoneFn) (OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, osync_bool slow_sync, void *data); typedef struct OSyncObjTypeSinkFunctions { OSyncSinkConnectFn connect; Modified: trunk/tests/mock-plugin/mock_sync.c ============================================================================== --- trunk/tests/mock-plugin/mock_sync.c Sun Mar 29 16:14:48 2009 (r5421) +++ trunk/tests/mock-plugin/mock_sync.c Sun Mar 29 16:40:22 2009 (r5422) @@ -101,11 +101,13 @@ return; } -static void mock_connect_done(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *data) +static void mock_connect_done(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, osync_bool slow_sync, void *data) { - osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, sink, info, ctx, data); + osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %i, %p)", __func__, sink, info, ctx, slow_sync, data); MockDir *dir = data; + dir->connect_done_slowsync = slow_sync; + if (mock_get_error(info->memberid, "CONNECT_DONE_ERROR")) { osync_context_report_error(ctx, OSYNC_ERROR_EXPECTED, "Triggering CONNECT_DONE_ERROR error"); return; @@ -388,6 +390,12 @@ osync_assert(dir->connect_done == TRUE); dir->connect_done = FALSE; + /* Validate that connect_doene and get_changes slow_sync + * is the same. To avoid mix-up of a "late slow-sync". + */ + if (!mock_get_error(info->memberid, "MAINSINK_CONNECT")) + osync_assert(dir->connect_done_slowsync == slow_sync); + if (mock_get_error(info->memberid, "GET_CHANGES_ERROR")) { osync_context_report_error(ctx, OSYNC_ERROR_EXPECTED, "Triggering GET_CHANGES_ERROR error"); osync_trace(TRACE_EXIT_ERROR, "%s - Triggering GET_CHANGES error", __func__); Modified: trunk/tests/mock-plugin/mock_sync.h ============================================================================== --- trunk/tests/mock-plugin/mock_sync.h Sun Mar 29 16:14:48 2009 (r5421) +++ trunk/tests/mock-plugin/mock_sync.h Sun Mar 29 16:40:22 2009 (r5422) @@ -67,6 +67,7 @@ mock_env *env; osync_bool committed_all; osync_bool connect_done; + osync_bool connect_done_slowsync; } MockDir; #endif //_MOCK_PLUGIN_H |
From: <svn...@op...> - 2009-03-29 14:14:54
|
Author: bricks Date: Sun Mar 29 16:14:48 2009 New Revision: 5421 URL: http://www.opensync.org/changeset/5421 Log: changed list pattern for all format related interfaces refs #975 Added: trunk/opensync/format/opensync_converter_internals.h Modified: trunk/opensync.sym trunk/opensync/engine/opensync_mapping_entry_engine.c trunk/opensync/format/opensync_converter.c trunk/opensync/format/opensync_converter.h trunk/opensync/format/opensync_format_env.c trunk/opensync/format/opensync_format_env.h trunk/opensync/format/opensync_format_env_internals.h trunk/tests/format-tests/check_conv.c trunk/tests/format-tests/check_converter.c Modified: trunk/opensync.sym ============================================================================== --- trunk/opensync.sym Sun Mar 29 15:28:07 2009 (r5420) +++ trunk/opensync.sym Sun Mar 29 16:14:48 2009 (r5421) @@ -62,9 +62,8 @@ osync_converter_new_detector osync_converter_path_add_edge osync_converter_path_get_config +osync_converter_path_get_edges osync_converter_path_new -osync_converter_path_nth_edge -osync_converter_path_num_edges osync_converter_path_ref osync_converter_path_set_config osync_converter_path_unref @@ -149,12 +148,10 @@ osync_format_env_find_path_formats osync_format_env_find_path_formats_with_detectors osync_format_env_find_path_with_detectors +osync_format_env_get_converters +osync_format_env_get_objformats osync_format_env_load_plugins osync_format_env_new -osync_format_env_nth_converter -osync_format_env_nth_objformat -osync_format_env_num_converters -osync_format_env_num_objformats osync_format_env_ref osync_format_env_register_converter osync_format_env_register_objformat Modified: trunk/opensync/engine/opensync_mapping_entry_engine.c ============================================================================== --- trunk/opensync/engine/opensync_mapping_entry_engine.c Sun Mar 29 15:28:07 2009 (r5420) +++ trunk/opensync/engine/opensync_mapping_entry_engine.c Sun Mar 29 16:14:48 2009 (r5421) @@ -30,6 +30,7 @@ #include "archive/opensync_archive_internals.h" #include "format/opensync_objformat_internals.h" +#include "format/opensync_converter_internals.h" #include "opensync_obj_engine.h" #include "opensync_obj_engine.h" Modified: trunk/opensync/format/opensync_converter.c ============================================================================== --- trunk/opensync/format/opensync_converter.c Sun Mar 29 15:28:07 2009 (r5420) +++ trunk/opensync/format/opensync_converter.c Sun Mar 29 16:14:48 2009 (r5421) @@ -28,6 +28,7 @@ #include "format/opensync_objformat_internals.h" #include "opensync_converter_private.h" +#include "opensync_converter_internals.h" OSyncFormatConverter *osync_converter_new(OSyncConverterType type, OSyncObjFormat *sourceformat, OSyncObjFormat *targetformat, OSyncFormatConvertFunc convert_func, OSyncError **error) { @@ -339,3 +340,7 @@ } } +OSyncList *osync_converter_path_get_edges(OSyncFormatConverterPath *path) { + return osync_list_copy(path->converters); +} + Modified: trunk/opensync/format/opensync_converter.h ============================================================================== --- trunk/opensync/format/opensync_converter.h Sun Mar 29 15:28:07 2009 (r5420) +++ trunk/opensync/format/opensync_converter.h Sun Mar 29 16:14:48 2009 (r5421) @@ -68,14 +68,14 @@ */ OSYNC_EXPORT OSyncFormatConverter *osync_converter_new_detector(OSyncObjFormat *sourceformat, OSyncObjFormat *targetformat, OSyncFormatDetectFunc detect_func, OSyncError **error); -/*! @brief Increase the reference count on a converter +/** @brief Increase the reference count on a converter * * @param converter Pointer to the converter * */ OSYNC_EXPORT OSyncFormatConverter *osync_converter_ref(OSyncFormatConverter *converter); -/*! @brief Decrease the reference count on a converter +/** @brief Decrease the reference count on a converter * * @param converter Pointer to the converter * @@ -158,26 +158,13 @@ */ OSYNC_EXPORT void osync_converter_path_add_edge(OSyncFormatConverterPath *path, OSyncFormatConverter *edge); -/** @brief Returns the number of converters in a converter path - * @param path Pointer to the converter path - * @returns the number of converters in the specified path - */ -OSYNC_EXPORT unsigned int osync_converter_path_num_edges(OSyncFormatConverterPath *path); - -/** @brief Returns the nth converter in a converter path - * @param path Pointer to the converter path - * @param nth The position of the converter to retrieve - * @returns the converter at the specified index - */ -OSYNC_EXPORT OSyncFormatConverter *osync_converter_path_nth_edge(OSyncFormatConverterPath *path, unsigned int nth); - /** @brief Returns configuration for converter path * @param path Pointer to the converter path * @returns The converter path configuration */ OSYNC_EXPORT const char *osync_converter_path_get_config(OSyncFormatConverterPath *path); -/*! @brief Sets the configuration for converter path +/** @brief Sets the configuration for converter path * @param path Pointer to the converter path * @param config The converter path configuration */ @@ -215,6 +202,13 @@ */ OSYNC_EXPORT void osync_converter_finalize(OSyncFormatConverter *converter); +/** + * @brief Returns a OSyncList of the format converters in this path + * @param path Pointer to the OSyncFormatConverterPath + * @return a shallow copy of the OSyncFormatConverter in the conversion path + */ +OSYNC_EXPORT OSyncList *osync_converter_path_get_edges(OSyncFormatConverterPath *path); + /*@}*/ #endif //_OPENSYNC_CONVERTER_H_ Added: trunk/opensync/format/opensync_converter_internals.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/opensync/format/opensync_converter_internals.h Sun Mar 29 16:14:48 2009 (r5421) @@ -0,0 +1,38 @@ +/* + * libopensync - A synchronization framework + * Copyright (C) 2009 Bjoern Ricks <bjo...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef _OPENSYNC_CONVERTER_INTERNALS_H_ +#define _OPENSYNC_CONVERTER_INTERNALS_H_ + +/** @brief Returns the number of converters in a converter path + * @param path Pointer to the converter path + * @returns the number of converters in the specified path + */ +OSYNC_TEST_EXPORT unsigned int osync_converter_path_num_edges(OSyncFormatConverterPath *path); + +/** @brief Returns the nth converter in a converter path + * @param path Pointer to the converter path + * @param nth The position of the converter to retrieve + * @returns the converter at the specified index + */ +OSYNC_TEST_EXPORT OSyncFormatConverter *osync_converter_path_nth_edge(OSyncFormatConverterPath *path, unsigned int nth); + + +#endif /* _OPENSYNC_CONVERTER_INTERNALS_H_ */ Modified: trunk/opensync/format/opensync_format_env.c ============================================================================== --- trunk/opensync/format/opensync_format_env.c Sun Mar 29 15:28:07 2009 (r5420) +++ trunk/opensync/format/opensync_format_env.c Sun Mar 29 16:14:48 2009 (r5421) @@ -32,6 +32,8 @@ #include "opensync_format_env_internals.h" #include "opensync_format_env_private.h" +#include "opensync_converter_internals.h" + static osync_bool osync_format_env_load_modules(OSyncFormatEnv *env, const char *path, osync_bool must_exist, OSyncError **error) @@ -847,6 +849,10 @@ return osync_list_nth_data(env->objformats, nth); } +OSyncList *osync_format_env_get_objformats(OSyncFormatEnv *env) { + return osync_list_copy(env->objformats); +} + void osync_format_env_register_converter(OSyncFormatEnv *env, OSyncFormatConverter *converter) { osync_assert(env); @@ -912,7 +918,7 @@ return r; } -int osync_format_env_num_converters(OSyncFormatEnv *env) +unsigned int osync_format_env_num_converters(OSyncFormatEnv *env) { osync_assert(env); return osync_list_length(env->converters); @@ -924,6 +930,10 @@ return osync_list_nth_data(env->converters, nth); } +OSyncList *osync_format_env_get_converters(OSyncFormatEnv *env) { + return osync_list_copy(env->converters); +} + void osync_format_env_register_filter(OSyncFormatEnv *env, OSyncCustomFilter *filter) { osync_assert(env); Modified: trunk/opensync/format/opensync_format_env.h ============================================================================== --- trunk/opensync/format/opensync_format_env.h Sun Mar 29 15:28:07 2009 (r5420) +++ trunk/opensync/format/opensync_format_env.h Sun Mar 29 16:14:48 2009 (r5421) @@ -100,22 +100,16 @@ */ OSYNC_EXPORT OSyncObjFormat *osync_format_env_find_objformat(OSyncFormatEnv *env, const char *name); -/** @brief Returns the number of available object formats +/** + * @brief Return a OSyncList of all formats which are store inside this format environment * - * @param env The format environment - * @returns The number of object formats - * - */ -OSYNC_EXPORT unsigned int osync_format_env_num_objformats(OSyncFormatEnv *env); - -/** @brief Gets the nth object format - * - * @param env The format environment - * @param nth The position of the object format to retrieve - * @returns The object format + * Please be aware that the returned list has to be freed with + * osync_list_free. If it isn't freed there will be a memory leak. * + * @param A pointer to a OSyncFormatEnv + * @return a shallow copy of all OSyncObjFormats stored in the format env */ -OSYNC_EXPORT OSyncObjFormat *osync_format_env_nth_objformat(OSyncFormatEnv *env, unsigned int nth); +OSYNC_EXPORT OSyncList *osync_format_env_get_objformats(OSyncFormatEnv *env); /** @brief Registers Format Converter or Detector to Format Environment * @@ -147,22 +141,16 @@ */ OSYNC_EXPORT OSyncList *osync_format_env_find_converters(OSyncFormatEnv *env, OSyncObjFormat *sourceformat, OSyncObjFormat *targetformat); -/** @brief Returns the number of available converters +/** + * @brief Return a OSyncList of all converters which are store in this format environment * - * @param env The format environment - * @returns The number of converters - * - */ -OSYNC_EXPORT int osync_format_env_num_converters(OSyncFormatEnv *env); - -/** @brief Gets the nth format converter - * - * @param env The format environment - * @param nth The position of the format converter to retrieve - * @returns The format converter + * Please be aware that the returned list has to be freed with + * osync_list_free. If it isn't freed there will be a memory leak. * + * @param A pointer to a OSyncFormatEnv + * @return a shallow copy of all OSyncFormatConverters stored in the format env */ -OSYNC_EXPORT OSyncFormatConverter *osync_format_env_nth_converter(OSyncFormatEnv *env, int nth); +OSYNC_EXPORT OSyncList *osync_format_env_get_converters(OSyncFormatEnv *env); /** @brief Tries to detect the format of the given data object * Modified: trunk/opensync/format/opensync_format_env_internals.h ============================================================================== --- trunk/opensync/format/opensync_format_env_internals.h Sun Mar 29 15:28:07 2009 (r5420) +++ trunk/opensync/format/opensync_format_env_internals.h Sun Mar 29 16:14:48 2009 (r5421) @@ -37,7 +37,7 @@ osync_bool osync_conv_convert_fn(OSyncFormatEnv *env, OSyncChange *change, OSyncPathTargetFn target_fn, const void *fndata, const char *extension_name, OSyncError **error); osync_bool osync_conv_convert_fmtlist(OSyncFormatEnv *env, OSyncChange *change, GList/*OSyncObjFormat * */ *targets); -/*! @brief The environment used for conversions +/** @brief The environment used for conversions */ struct OSyncFormatEnv { /** A List of formats */ @@ -53,7 +53,7 @@ int ref_count; }; -/*! @brief search tree for format converters +/** @brief search tree for format converters */ typedef struct OSyncFormatConverterTree { /* The converters that weren't reached yet */ @@ -125,6 +125,41 @@ */ OSYNC_TEST_EXPORT void osync_format_env_objformat_finalize(OSyncFormatEnv *env); +/** @brief Returns the number of available object formats + * + * @param env The format environment + * @returns The number of object formats + * + */ +OSYNC_TEST_EXPORT unsigned int osync_format_env_num_objformats(OSyncFormatEnv *env); + +/** @brief Gets the nth object format + * + * @param env The format environment + * @param nth The position of the object format to retrieve + * @returns The object format + * + */ +OSYNC_TEST_EXPORT OSyncObjFormat *osync_format_env_nth_objformat(OSyncFormatEnv *env, unsigned int nth); + +/** @brief Returns the number of available converters + * + * @param env The format environment + * @returns The number of converters + * + */ +OSYNC_TEST_EXPORT unsigned int osync_format_env_num_converters(OSyncFormatEnv *env); + +/** @brief Gets the nth format converter + * + * @param env The format environment + * @param nth The position of the format converter to retrieve + * @returns The format converter + * + */ +OSYNC_TEST_EXPORT OSyncFormatConverter *osync_format_env_nth_converter(OSyncFormatEnv *env, int nth); + + /*@}*/ #endif /* _OPENSYNC_FORMAT_ENV_INTERNALS_H_ */ Modified: trunk/tests/format-tests/check_conv.c ============================================================================== --- trunk/tests/format-tests/check_conv.c Sun Mar 29 15:28:07 2009 (r5420) +++ trunk/tests/format-tests/check_conv.c Sun Mar 29 16:14:48 2009 (r5421) @@ -3,6 +3,7 @@ #include <opensync/opensync-format.h> #include "opensync/format/opensync_filter_internals.h" #include "opensync/format/opensync_format_env_internals.h" +#include "opensync/format/opensync_converter_internals.h" START_TEST (conv_env_create) { Modified: trunk/tests/format-tests/check_converter.c ============================================================================== --- trunk/tests/format-tests/check_converter.c Sun Mar 29 15:28:07 2009 (r5420) +++ trunk/tests/format-tests/check_converter.c Sun Mar 29 16:14:48 2009 (r5421) @@ -3,6 +3,8 @@ #include <opensync/opensync-data.h> #include <opensync/opensync-format.h> +#include "opensync/format/opensync_converter_internals.h" + osync_bool converter_conv(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *userdata, OSyncError **error) { return TRUE; |
From: <svn...@op...> - 2009-03-29 13:28:11
|
Author: bricks Date: Sun Mar 29 15:28:07 2009 New Revision: 5420 URL: http://www.opensync.org/changeset/5420 Log: fixed symbol test Modified: trunk/opensync.sym Modified: trunk/opensync.sym ============================================================================== --- trunk/opensync.sym Sun Mar 29 15:20:43 2009 (r5419) +++ trunk/opensync.sym Sun Mar 29 15:28:07 2009 (r5420) @@ -95,6 +95,7 @@ osync_engine_discover_and_block osync_engine_finalize osync_engine_find_objengine +osync_engine_get_objengines osync_engine_initialize osync_engine_mapping_duplicate osync_engine_mapping_ignore_conflict @@ -107,7 +108,6 @@ osync_engine_member_update_get_member osync_engine_member_update_get_objtype osync_engine_new -osync_engine_get_objengines osync_engine_ref osync_engine_repair osync_engine_set_changestatus_callback @@ -339,7 +339,7 @@ osync_obj_engine_get_sinkengines osync_obj_engine_get_slowsync osync_obj_engine_initialize -osync_obj_engine_news +osync_obj_engine_new osync_obj_engine_receive_change osync_obj_engine_ref osync_obj_engine_set_callback |
From: <svn...@op...> - 2009-03-29 13:20:47
|
Author: paule Date: Sun Mar 29 15:20:43 2009 New Revision: 5419 URL: http://www.opensync.org/changeset/5419 Log: opie-sync: Fix for objtype sink enumeration API change Modified: plugins/opie-sync/src/opie_sync.c Modified: plugins/opie-sync/src/opie_sync.c ============================================================================== --- plugins/opie-sync/src/opie_sync.c Sun Mar 29 15:19:07 2009 (r5418) +++ plugins/opie-sync/src/opie_sync.c Sun Mar 29 15:20:43 2009 (r5419) @@ -701,9 +701,10 @@ { osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, data, info, error); - int i, numobjs = osync_plugin_info_num_objtypes(info); - for (i = 0; i < numobjs; i++) { - OSyncObjTypeSink *sink = osync_plugin_info_nth_objtype(info, i); + OSyncList *l, *list = NULL; + list = osync_plugin_info_get_objtype_sinks(info); + for (l=list; l; l = l->next) { + OSyncObjTypeSink *sink = (OSyncObjTypeSink *) l->data; g_assert(sink); osync_objtype_sink_set_available(sink, TRUE); |
From: <svn...@op...> - 2009-03-29 13:19:14
|
Author: paule Date: Sun Mar 29 15:19:07 2009 New Revision: 5418 URL: http://www.opensync.org/changeset/5418 Log: opie-sync: port to latest hashtable API change. Patch courtesy of Daniel Gollub. Modified: plugins/opie-sync/src/opie_sync.c plugins/opie-sync/src/opie_sync.h Modified: plugins/opie-sync/src/opie_sync.c ============================================================================== --- plugins/opie-sync/src/opie_sync.c Sun Mar 29 15:12:18 2009 (r5417) +++ plugins/opie-sync/src/opie_sync.c Sun Mar 29 15:19:07 2009 (r5418) @@ -284,16 +284,6 @@ goto error; } - /* Get hashtable */ - const char *configdir = osync_plugin_info_get_configdir(info); - char *tablepath = g_strdup_printf("%s/hashtable.db", configdir); - env->hashtable = osync_hashtable_new(tablepath, osync_objtype_sink_get_name(sink), &error); - g_free(tablepath); - if (!env->hashtable) - goto error; - if(!osync_hashtable_load(env->hashtable, &error)) - goto error; - if(env->objtype == OPIE_OBJECT_TYPE_NOTE) { /* Check if the notes resource has changed since the last sync */ OSyncAnchor *anchor = osync_objtype_sink_get_anchor(sink); @@ -318,13 +308,14 @@ { osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %d, %p)", __func__, sink, info, ctx, slow_sync, data); OpieSinkEnv *env = (OpieSinkEnv *)data; + OSyncHashTable *hashtable = osync_objtype_sink_get_hashtable(sink); OSyncError *error = NULL; if (slow_sync) { osync_trace(TRACE_INTERNAL, "Slow sync requested"); - if (!osync_hashtable_slowsync(env->hashtable, &error)) { + if (!osync_hashtable_slowsync(hashtable, &error)) { osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error)); osync_context_report_osyncerror(ctx, error); return; @@ -357,11 +348,11 @@ g_free(hash); /* Detect and set the type of change */ - OSyncChangeType changetype = osync_hashtable_get_changetype(env->hashtable, change); + OSyncChangeType changetype = osync_hashtable_get_changetype(hashtable, change); osync_change_set_changetype(change, changetype); /* Update the hashtable with the hash of the object */ - osync_hashtable_update_change(env->hashtable, change); + osync_hashtable_update_change(hashtable, change); if (changetype != OSYNC_CHANGE_TYPE_UNMODIFIED) { /* Convert category IDs to names that other systems can use */ @@ -404,7 +395,7 @@ } /* Check for deleted entries using the hashtable */ - OSyncList *u, *uids = osync_hashtable_get_deleted(env->hashtable); + OSyncList *u, *uids = osync_hashtable_get_deleted(hashtable); for (u = uids; u; u = u->next) { const char *uid = u->data; @@ -432,7 +423,7 @@ osync_context_report_change(ctx, change); - osync_hashtable_update_change(env->hashtable, change); + osync_hashtable_update_change(hashtable, change); osync_change_unref(change); } @@ -447,6 +438,7 @@ { osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p, %p)", __func__, sink, info, ctx, change, data); OpieSinkEnv *env = (OpieSinkEnv *)data; + OSyncHashTable *hashtable = osync_objtype_sink_get_hashtable(sink); OSyncError *error = NULL; const char *ext_uid = osync_change_get_uid(change); @@ -533,7 +525,7 @@ if(change_doc) xmlFreeDoc(change_doc); - osync_hashtable_update_change(env->hashtable, change); + osync_hashtable_update_change(hashtable, change); //Answer the call osync_context_report_success(ctx); @@ -566,10 +558,7 @@ if(!osync_anchor_update(anchor, env->plugin_env->notes_path, &error)) goto error; } - - if (!osync_hashtable_save(env->hashtable, &error)) - goto error; - + osync_context_report_success(ctx); osync_trace(TRACE_EXIT, "%s", __func__); return; @@ -583,10 +572,6 @@ static void opie_sync_disconnect(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *data) { OpieSinkEnv *env = (OpieSinkEnv *)data; - - /* Close the hashtable */ - osync_hashtable_unref(env->hashtable); - env->hashtable = NULL; //Answer the call osync_context_report_success(ctx); @@ -625,6 +610,9 @@ /* We pass the sink_env object to the sink, so we dont have to look it up * again once the functions are called */ osync_objtype_sink_set_functions(sink, functions, sink_env); + + /* Request a hashtable from the framework. */ + osync_objtype_sink_enable_hashtable(sink, TRUE); return sink_env; } Modified: plugins/opie-sync/src/opie_sync.h ============================================================================== --- plugins/opie-sync/src/opie_sync.h Sun Mar 29 15:12:18 2009 (r5417) +++ plugins/opie-sync/src/opie_sync.h Sun Mar 29 15:19:07 2009 (r5418) @@ -89,7 +89,6 @@ OpiePluginEnv* plugin_env; OSyncObjTypeSink* sink; xmlDoc* doc; - OSyncHashTable* hashtable; OSyncObjFormat* objformat; const char* listelement; const char* itemelement; |
From: <svn...@op...> - 2009-03-29 13:12:23
|
Author: bricks Date: Sun Mar 29 15:12:18 2009 New Revision: 5417 URL: http://www.opensync.org/changeset/5417 Log: changed list pattern for all engine related interfaces refs #975 Modified: trunk/opensync.sym trunk/opensync/engine/opensync_engine.c trunk/opensync/engine/opensync_engine.h trunk/opensync/engine/opensync_engine_internals.h trunk/opensync/engine/opensync_mapping_engine.c trunk/opensync/engine/opensync_mapping_engine.h trunk/opensync/engine/opensync_mapping_engine_internals.h trunk/opensync/engine/opensync_obj_engine.c trunk/opensync/engine/opensync_obj_engine.h trunk/opensync/engine/opensync_obj_engine_internals.h trunk/opensync/engine/opensync_sink_engine_internals.h trunk/opensync/plugin/opensync_plugin_env.h trunk/opensync/plugin/opensync_plugin_info.h trunk/tests/support.h Modified: trunk/opensync.sym ============================================================================== --- trunk/opensync.sym Sun Mar 29 14:36:42 2009 (r5416) +++ trunk/opensync.sym Sun Mar 29 15:12:18 2009 (r5417) @@ -107,8 +107,7 @@ osync_engine_member_update_get_member osync_engine_member_update_get_objtype osync_engine_new -osync_engine_nth_objengine -osync_engine_num_objengines +osync_engine_get_objengines osync_engine_ref osync_engine_repair osync_engine_set_changestatus_callback @@ -240,10 +239,9 @@ osync_mapping_add_entry osync_mapping_engine_change_find_member osync_mapping_engine_duplicate +osync_mapping_engine_get_changes osync_mapping_engine_ignore osync_mapping_engine_member_change -osync_mapping_engine_nth_change -osync_mapping_engine_num_changes osync_mapping_engine_solve osync_mapping_engine_supports_ignore osync_mapping_engine_supports_use_latest @@ -336,14 +334,12 @@ osync_obj_engine_event osync_obj_engine_finalize osync_obj_engine_get_mapping_entry_engines_of_member +osync_obj_engine_get_members osync_obj_engine_get_objtype +osync_obj_engine_get_sinkengines osync_obj_engine_get_slowsync osync_obj_engine_initialize -osync_obj_engine_new -osync_obj_engine_nth_member -osync_obj_engine_nth_sinkengine -osync_obj_engine_num_members -osync_obj_engine_num_sinkengines +osync_obj_engine_news osync_obj_engine_receive_change osync_obj_engine_ref osync_obj_engine_set_callback Modified: trunk/opensync/engine/opensync_engine.c ============================================================================== --- trunk/opensync/engine/opensync_engine.c Sun Mar 29 14:36:42 2009 (r5416) +++ trunk/opensync/engine/opensync_engine.c Sun Mar 29 15:12:18 2009 (r5417) @@ -2303,6 +2303,10 @@ return osync_list_nth_data(engine->object_engines, nth); } +OSyncList *osync_engine_get_objengines(OSyncEngine *engine) { + return osync_list_copy(engine->object_engines); +} + OSyncObjEngine *osync_engine_find_objengine(OSyncEngine *engine, const char *objtype) { OSyncList *p = NULL; Modified: trunk/opensync/engine/opensync_engine.h ============================================================================== --- trunk/opensync/engine/opensync_engine.h Sun Mar 29 14:36:42 2009 (r5416) +++ trunk/opensync/engine/opensync_engine.h Sun Mar 29 15:12:18 2009 (r5417) @@ -390,29 +390,12 @@ */ OSYNC_EXPORT OSyncObjEngine *osync_engine_find_objengine(OSyncEngine *engine, const char *objtype); -/** @brief Get the nth OSyncObjEngine of the OSyncEngine - * - * @param engine A pointer to the engine - * @param nth The position of the OSyncObjEngine to request - * @returns Pointer of the nth OSyncObjEngine - * - */ -OSYNC_EXPORT OSyncObjEngine *osync_engine_nth_objengine(OSyncEngine *engine, unsigned int nth); - -/** @brief Get the number of OSyncObjEngine-elements in OSyncEngine - * - * @param engine A pointer to the engine - * @returns Total number of OSyncObjEngine-elements - * - */ -OSYNC_EXPORT unsigned int osync_engine_num_objengines(OSyncEngine *engine); - OSYNC_EXPORT osync_bool osync_engine_mapping_solve(OSyncEngine *engine, OSyncMappingEngine *mapping_engine, OSyncChange *change, OSyncError **error); OSYNC_EXPORT osync_bool osync_engine_mapping_duplicate(OSyncEngine *engine, OSyncMappingEngine *mapping_engine, OSyncError **error); OSYNC_EXPORT osync_bool osync_engine_mapping_ignore_conflict(OSyncEngine *engine, OSyncMappingEngine *mapping_engine, OSyncError **error); OSYNC_EXPORT osync_bool osync_engine_mapping_use_latest(OSyncEngine *engine, OSyncMappingEngine *mapping_engine, OSyncError **error); -/*! @brief Repairs engine from failed synchronization processes. +/** @brief Repairs engine from failed synchronization processes. * * This needs to get called to repair every failed synchronization process, * when same engine should get used. (Without initalizing a new engine). @@ -424,6 +407,17 @@ */ OSYNC_EXPORT osync_bool osync_engine_repair(OSyncEngine *engine, OSyncError **error); +/** + * @brief Returns the list of ObjEngines + * + * Please be aware that the returned list has to be freed with + * osync_list_free. If it isn't freed there will be a memory leak. + * + * @param engine A Pointer to an OSyncEngine + * @return a shellow copy of the internal list + */ +OSYNC_EXPORT OSyncList *osync_engine_get_objengines(OSyncEngine *engine); + /*@}*/ #endif /*OPENSYNC_ENGINE_H_*/ Modified: trunk/opensync/engine/opensync_engine_internals.h ============================================================================== --- trunk/opensync/engine/opensync_engine_internals.h Sun Mar 29 14:36:42 2009 (r5416) +++ trunk/opensync/engine/opensync_engine_internals.h Sun Mar 29 15:12:18 2009 (r5417) @@ -166,6 +166,23 @@ */ unsigned int osync_engine_num_proxies_for_alternative_objtypes(OSyncEngine *engine, const char *objtype); +/** @brief Get the nth OSyncObjEngine of the OSyncEngine + * + * @param engine A pointer to the engine + * @param nth The position of the OSyncObjEngine to request + * @returns Pointer of the nth OSyncObjEngine + * + */ +OSYNC_TEST_EXPORT OSyncObjEngine *osync_engine_nth_objengine(OSyncEngine *engine, unsigned int nth); + +/** @brief Get the number of OSyncObjEngine-elements in OSyncEngine + * + * @param engine A pointer to the engine + * @returns Total number of OSyncObjEngine-elements + * + */ +OSYNC_TEST_EXPORT unsigned int osync_engine_num_objengines(OSyncEngine *engine); + /*@}*/ #endif /*OPENSYNC_ENGINE_INTERNALS_H_*/ Modified: trunk/opensync/engine/opensync_mapping_engine.c ============================================================================== --- trunk/opensync/engine/opensync_mapping_engine.c Sun Mar 29 14:36:42 2009 (r5416) +++ trunk/opensync/engine/opensync_mapping_engine.c Sun Mar 29 15:12:18 2009 (r5417) @@ -803,3 +803,31 @@ return FALSE; } +OSyncList *osync_mapping_engine_get_changes(OSyncMappingEngine *engine) { + OSyncList *list = engine->entries; + OSyncList *new_list = NULL; + OSyncMappingEntryEngine *entry = NULL; + + if (list) { + OSyncList *last; + + new_list = osync_list_alloc(); + entry = list->data; + new_list->data = entry->change; + new_list->prev = NULL; + last = new_list; + list = list->next; + while (list) { + last->next = osync_list_alloc(); + last->next->prev = last; + last = last->next; + entry = list->data; + last->data = entry->change; + list = list->next; + } + last->next = NULL; + } + + return new_list; +} + Modified: trunk/opensync/engine/opensync_mapping_engine.h ============================================================================== --- trunk/opensync/engine/opensync_mapping_engine.h Sun Mar 29 14:36:42 2009 (r5416) +++ trunk/opensync/engine/opensync_mapping_engine.h Sun Mar 29 15:12:18 2009 (r5417) @@ -22,16 +22,6 @@ #ifndef OPENSYNC_MAPPING_ENGINE_H_ #define OPENSYNC_MAPPING_ENGINE_H_ -OSYNC_EXPORT unsigned int osync_mapping_engine_num_changes(OSyncMappingEngine *engine); - -/** @brief Search for the nth entry in the mapping - * - * @param engine A pointer to the mapping engine - * @param nth The value of the position - * @returns The pointer to the nth change. NULL if there isn't enough entries in the mapping. - */ -OSYNC_EXPORT OSyncChange *osync_mapping_engine_nth_change(OSyncMappingEngine *engine, unsigned int nth); - /** @brief Search in the mapping for the change of the member. * * @param engine A pointer to the mapping engine @@ -57,4 +47,15 @@ */ OSYNC_EXPORT osync_bool osync_mapping_engine_duplicate(OSyncMappingEngine *existingMapping, OSyncError **error); +/** + * @brief Returns the list of OSyncChanges + * + * Please be aware that the returned list has to be freed with + * osync_list_free. If it isn't freed there will be a memory leak. + * + * @param engine A pointer to a OSyncMappingEngine + * @return A list containing the changes + */ +OSYNC_EXPORT OSyncList *osync_mapping_engine_get_changes(OSyncMappingEngine *engine); + #endif /*OPENSYNC_MAPPING_ENGINE_H_*/ Modified: trunk/opensync/engine/opensync_mapping_engine_internals.h ============================================================================== --- trunk/opensync/engine/opensync_mapping_engine_internals.h Sun Mar 29 14:36:42 2009 (r5416) +++ trunk/opensync/engine/opensync_mapping_engine_internals.h Sun Mar 29 15:12:18 2009 (r5417) @@ -66,6 +66,16 @@ OSyncMappingEntryEngine *osync_mapping_engine_get_entry(OSyncMappingEngine *engine, OSyncSinkEngine *sinkengine); +OSYNC_TEST_EXPORT unsigned int osync_mapping_engine_num_changes(OSyncMappingEngine *engine); + +/** @brief Search for the nth entry in the mapping + * + * @param engine A pointer to the mapping engine + * @param nth The value of the position + * @returns The pointer to the nth change. NULL if there isn't enough entries in the mapping. + */ +OSYNC_TEST_EXPORT OSyncChange *osync_mapping_engine_nth_change(OSyncMappingEngine *engine, unsigned int nth); + /*@}*/ #endif /* OPENSYNC_MAPPING_ENGINE_INTERNALS_H_ */ Modified: trunk/opensync/engine/opensync_obj_engine.c ============================================================================== --- trunk/opensync/engine/opensync_obj_engine.c Sun Mar 29 14:36:42 2009 (r5416) +++ trunk/opensync/engine/opensync_obj_engine.c Sun Mar 29 15:12:18 2009 (r5417) @@ -1241,6 +1241,10 @@ return osync_list_length(engine->active_sink_engines); } +OSyncList *osync_obj_engine_get_sinkengines(OSyncObjEngine *engine) { + return osync_list_copy(engine->active_sink_engines); +} + unsigned int osync_obj_engine_num_mapping_engines(OSyncObjEngine *engine) { osync_assert(engine); @@ -1262,6 +1266,35 @@ return osync_sink_engine_get_member(sinkengine); } +OSyncList *osync_obj_engine_get_members(OSyncObjEngine* engine) { + + OSyncList *list = engine->active_sink_engines; + OSyncList *new_list = NULL; + OSyncSinkEngine *sinkengine = NULL; + + if (list) { + OSyncList *last; + + new_list = osync_list_alloc(); + sinkengine = list->data; + new_list->data = osync_sink_engine_get_member(sinkengine); + new_list->prev = NULL; + last = new_list; + list = list->next; + while (list) { + last->next = osync_list_alloc(); + last->next->prev = last; + last = last->next; + sinkengine = list->data; + last->data = osync_sink_engine_get_member(sinkengine); + list = list->next; + } + last->next = NULL; + } + + return new_list; +} + const OSyncList *osync_obj_engine_get_mapping_entry_engines_of_member(OSyncObjEngine *engine, OSyncMember *member) { OSyncList *s; Modified: trunk/opensync/engine/opensync_obj_engine.h ============================================================================== --- trunk/opensync/engine/opensync_obj_engine.h Sun Mar 29 14:36:42 2009 (r5416) +++ trunk/opensync/engine/opensync_obj_engine.h Sun Mar 29 15:12:18 2009 (r5417) @@ -42,39 +42,7 @@ OSYNC_EXPORT void osync_obj_engine_set_error(OSyncObjEngine *engine, OSyncError *error); -/** @brief Get the nth OSyncSinkEngine of the OSyncObjEngine - * - * @param engine A pointer to the engine - * @param nth The position of the OSyncSinkEngine to request - * @returns Pointer of the nth OSyncSinkEngine, or NULL if not available - * - */ -OSYNC_EXPORT OSyncSinkEngine *osync_obj_engine_nth_sinkengine(OSyncObjEngine *engine, unsigned int nth); - -/*! @brief Get total number of Sink Engines - * - * @param engine Pointer to OSyncObjEngine - * @returns Total number of Sink Engines - */ -OSYNC_EXPORT unsigned int osync_obj_engine_num_sinkengines(OSyncObjEngine *engine); - -/*! @brief Get total number of Members - * - * @param engine Pointer to OSyncObjEngine - * @returns Total number of OSyncMember elements - */ -OSYNC_EXPORT unsigned int osync_obj_engine_num_members(OSyncObjEngine *engine); - -/** @brief Get the nth OSyncMember of the OSyncObjEngine - * - * @param engine A pointer to the engine - * @param nth The position of the OSyncMember to request - * @returns Pointer of the nth OSyncMember, or NULL if not available - * - */ -OSYNC_EXPORT OSyncMember *osync_obj_engine_nth_member(OSyncObjEngine *engine, unsigned int nth); - -/*! @brief Get list of OSyncMappingEntryEngines of the OSyncObjEngine +/** @brief Get list of OSyncMappingEntryEngines of the OSyncObjEngine * for a specific member * * @param engine Pointer to an OSyncObjEngine @@ -83,5 +51,27 @@ */ OSYNC_EXPORT const OSyncList *osync_obj_engine_get_mapping_entry_engines_of_member(OSyncObjEngine *engine, OSyncMember *member); +/** + * @brief Returns a OSyncList of all active sinkengines + * + * Please be aware that the returned list has to be freed with + * osync_list_free. If it isn't freed there will be a memory leak. + * + * @param A pointer to a OSyncObjEngine + * @return a shallow copy of active OSyncSinkEngines + */ +OSYNC_EXPORT OSyncList *osync_obj_engine_get_sinkengines(OSyncObjEngine *engine); + +/** + * @brief Returns a OSyncList of all members + * + * Please be aware that the returned list has to be freed with + * osync_list_free. If it isn't freed there will be a memory leak. + * + * @param A pointer to a OSyncObjEngine + * @return a shallow copy of the internal OSyncMembers + */ +OSYNC_EXPORT OSyncList *osync_obj_engine_get_members(OSyncObjEngine *engine); + #endif /* OPENSYNC_OBJ_ENGINE_H_ */ Modified: trunk/opensync/engine/opensync_obj_engine_internals.h ============================================================================== --- trunk/opensync/engine/opensync_obj_engine_internals.h Sun Mar 29 14:36:42 2009 (r5416) +++ trunk/opensync/engine/opensync_obj_engine_internals.h Sun Mar 29 15:12:18 2009 (r5417) @@ -149,5 +149,37 @@ */ OSyncSinkEngine *osync_obj_engine_find_proxy_sinkengine(OSyncObjEngine *engine, OSyncClientProxy *proxy); +/** @brief Get the nth OSyncSinkEngine of the OSyncObjEngine + * + * @param engine A pointer to the engine + * @param nth The position of the OSyncSinkEngine to request + * @returns Pointer of the nth OSyncSinkEngine, or NULL if not available + * + */ +OSYNC_TEST_EXPORT OSyncSinkEngine *osync_obj_engine_nth_sinkengine(OSyncObjEngine *engine, unsigned int nth); + +/** @brief Get total number of Sink Engines + * + * @param engine Pointer to OSyncObjEngine + * @returns Total number of Sink Engines + */ +OSYNC_TEST_EXPORT unsigned int osync_obj_engine_num_sinkengines(OSyncObjEngine *engine); + +/** @brief Get total number of Members + * + * @param engine Pointer to OSyncObjEngine + * @returns Total number of OSyncMember elements + */ +OSYNC_TEST_EXPORT unsigned int osync_obj_engine_num_members(OSyncObjEngine *engine); + +/** @brief Get the nth OSyncMember of the OSyncObjEngine + * + * @param engine A pointer to the engine + * @param nth The position of the OSyncMember to request + * @returns Pointer of the nth OSyncMember, or NULL if not available + * + */ +OSYNC_TEST_EXPORT OSyncMember *osync_obj_engine_nth_member(OSyncObjEngine *engine, unsigned int nth); + #endif /* OPENSYNC_OBJ_ENGINE_INTERNALS_H_ */ Modified: trunk/opensync/engine/opensync_sink_engine_internals.h ============================================================================== --- trunk/opensync/engine/opensync_sink_engine_internals.h Sun Mar 29 14:36:42 2009 (r5416) +++ trunk/opensync/engine/opensync_sink_engine_internals.h Sun Mar 29 15:12:18 2009 (r5417) @@ -21,7 +21,7 @@ #ifndef OPENSYNC_SINK_ENGINE_INTERNALS_H_ #define OPENSYNC_SINK_ENGINE_INTERNALS_H_ -/*! @brief OSyncSinkEngine struct members +/** @brief OSyncSinkEngine struct members * **/ struct OSyncSinkEngine { @@ -44,7 +44,7 @@ void osync_sink_engine_unref(OSyncSinkEngine *engine); osync_bool osync_sink_engine_is_connected(OSyncSinkEngine *engine); -/*! @brief Demerge all entries of OSyncSinkEngine +/** @brief Demerge all entries of OSyncSinkEngine * * If the Member/Client of the OSyncSinkEngine doesn't have capabilities * this functions is NOOP and just returns with TRUE, without error. @@ -58,7 +58,7 @@ */ osync_bool osync_sink_engine_demerge(OSyncSinkEngine *engine, OSyncArchive *archive, OSyncError **error); -/*! @brief Convert all entries of OSyncSinkEngine to destitination format +/** @brief Convert all entries of OSyncSinkEngine to destitination format * * This function converters all entries of the OSyncSinkEngine to the member * preferd/requested format (destination). @@ -70,7 +70,7 @@ */ osync_bool osync_sink_engine_convert_to_dest(OSyncSinkEngine *engine, OSyncFormatEnv *formatenv, OSyncError **error); -/*! @brief Write/commit all entries of OSyncSinkEngine to the client/peer +/** @brief Write/commit all entries of OSyncSinkEngine to the client/peer * * This function writes/commits all entries of the OSyncSinkEngine to the member. * Modified: trunk/opensync/plugin/opensync_plugin_env.h ============================================================================== --- trunk/opensync/plugin/opensync_plugin_env.h Sun Mar 29 14:36:42 2009 (r5416) +++ trunk/opensync/plugin/opensync_plugin_env.h Sun Mar 29 15:12:18 2009 (r5417) @@ -103,6 +103,9 @@ /* @brief Get all plugins which are registered in the Plugin Env * + * Please be aware that the returned list has to be freed with + * osync_list_free. If it isn't freed there will be a memory leak. + * * @param env Pointer to a OSyncPluginEnv * @return A shallow copy of the internal plugin list */ Modified: trunk/opensync/plugin/opensync_plugin_info.h ============================================================================== --- trunk/opensync/plugin/opensync_plugin_info.h Sun Mar 29 14:36:42 2009 (r5416) +++ trunk/opensync/plugin/opensync_plugin_info.h Sun Mar 29 15:12:18 2009 (r5417) @@ -113,6 +113,9 @@ /** * @brief Returns all Objtype Sinks as a list * + * Please be aware that the returned list has to be freed with + * osync_list_free. If it isn't freed there will be a memory leak. + * * @param Pointer to a OSyncPluginInfo * @return A shallow copy of the internal objtype list */ Modified: trunk/tests/support.h ============================================================================== --- trunk/tests/support.h Sun Mar 29 14:36:42 2009 (r5416) +++ trunk/tests/support.h Sun Mar 29 15:12:18 2009 (r5417) @@ -14,6 +14,7 @@ #include <opensync/opensync-plugin.h> #include "opensync/helper/opensync_hashtable_internals.h" +#include "opensync/engine/opensync_mapping_engine_internals.h" #include "config.h" |
From: <svn...@op...> - 2009-03-29 12:36:51
|
Author: dgollub Date: Sun Mar 29 14:36:42 2009 New Revision: 5416 URL: http://www.opensync.org/changeset/5416 Log: Tolerate NULL in osync_list_free and osync_list_free1 as list argument. This avoids sanity checks when dealing with osync_list which is now more common with the API list-pattern changes. Modified: trunk/opensync/common/opensync_list.c trunk/opensync/common/opensync_list.h Modified: trunk/opensync/common/opensync_list.c ============================================================================== --- trunk/opensync/common/opensync_list.c Sun Mar 29 00:02:50 2009 (r5415) +++ trunk/opensync/common/opensync_list.c Sun Mar 29 14:36:42 2009 (r5416) @@ -47,12 +47,14 @@ void osync_list_free (OSyncList *list) { + osync_return_if_fail(list); g_slice_free_chain (OSyncList, list, next); } void osync_list_free_1 (OSyncList *list) { + osync_return_if_fail(list); _osync_list_free1 (list); } Modified: trunk/opensync/common/opensync_list.h ============================================================================== --- trunk/opensync/common/opensync_list.h Sun Mar 29 00:02:50 2009 (r5415) +++ trunk/opensync/common/opensync_list.h Sun Mar 29 14:36:42 2009 (r5416) @@ -47,9 +47,15 @@ /* Doubly linked lists */ OSYNC_EXPORT OSyncList* osync_list_alloc (void); + +/* @note: Slightly modified from original glib version. + * osync_list_free() and osync_list_free1 will immeditally return + * if list is NULL + */ OSYNC_EXPORT void osync_list_free (OSyncList *list); OSYNC_EXPORT void osync_list_free_1 (OSyncList *list); #define osync_list_free1 osync_list_free_1 + OSYNC_EXPORT OSyncList* osync_list_append (OSyncList *list, void * data); OSYNC_EXPORT OSyncList* osync_list_prepend (OSyncList *list, |
From: <svn...@op...> - 2009-03-28 23:02:56
|
Author: dgollub Date: Sun Mar 29 00:02:50 2009 New Revision: 5415 URL: http://www.opensync.org/changeset/5415 Log: Port of OSyncPluginEnv API changes for syncml plugin. Dropped legacy includes. Modified: plugins/syncml/src/syncml_common.h plugins/syncml/src/syncml_ds_client.c plugins/syncml/src/syncml_ds_server.c Modified: plugins/syncml/src/syncml_common.h ============================================================================== --- plugins/syncml/src/syncml_common.h Sat Mar 28 23:39:18 2009 (r5414) +++ plugins/syncml/src/syncml_common.h Sun Mar 29 00:02:50 2009 (r5415) @@ -28,7 +28,6 @@ #include <opensync/opensync-format.h> #include <opensync/opensync-plugin.h> #include <opensync/opensync-capabilities.h> -#include <opensync/opensync-context.h> #include <opensync/opensync-data.h> #include <opensync/opensync-helper.h> #include <opensync/opensync-group.h> Modified: plugins/syncml/src/syncml_ds_client.c ============================================================================== --- plugins/syncml/src/syncml_ds_client.c Sat Mar 28 23:39:18 2009 (r5414) +++ plugins/syncml/src/syncml_ds_client.c Sun Mar 29 00:02:50 2009 (r5415) @@ -31,12 +31,10 @@ SmlError *error = NULL; OSyncPluginConfig *config = osync_plugin_info_get_config(info); OSyncFormatEnv *formatenv = osync_plugin_info_get_format_env(info); - unsigned int i, num_objtypes = osync_plugin_info_num_objtypes(info); - osync_trace(TRACE_INTERNAL, "%s: %d objtypes", __func__, num_objtypes); + OSyncList *l, *list = osync_plugin_info_get_objtype_sinks(info); - - for (i=0; i < num_objtypes; i++) { - OSyncObjTypeSink *sink = osync_plugin_info_nth_objtype(info, i); + for (l=list; l; l = l->next) { + OSyncObjTypeSink *sink = (OSyncObjTypeSink *) l->data; osync_bool sinkEnabled = osync_objtype_sink_is_enabled(sink); osync_trace(TRACE_INTERNAL, "%s: enabled => %d", __func__, sinkEnabled); if (!sinkEnabled) @@ -101,6 +99,9 @@ osync_error_set(oerror, OSYNC_ERROR_GENERIC, "%s", smlErrorPrint(&error)); smlErrorDeref(&error); oerror: + if (list) + osync_list_free(list); + osync_trace(TRACE_EXIT_ERROR, "%s - %s", __func__, osync_error_print(oerror)); return FALSE; } Modified: plugins/syncml/src/syncml_ds_server.c ============================================================================== --- plugins/syncml/src/syncml_ds_server.c Sat Mar 28 23:39:18 2009 (r5414) +++ plugins/syncml/src/syncml_ds_server.c Sun Mar 29 00:02:50 2009 (r5415) @@ -30,11 +30,10 @@ SmlError *error = NULL; OSyncPluginConfig *config = osync_plugin_info_get_config(info); OSyncFormatEnv *formatenv = osync_plugin_info_get_format_env(info); - unsigned int i, num_objtypes = osync_plugin_info_num_objtypes(info); - osync_trace(TRACE_INTERNAL, "%s: %d objtypes", __func__, num_objtypes); + OSyncList *l, *list = osync_plugin_info_get_objtype_sinks(info); - for (i=0; i < num_objtypes; i++) { - OSyncObjTypeSink *sink = osync_plugin_info_nth_objtype(info, i); + for (l=list; l; l = l->next) { + OSyncObjTypeSink *sink = (OSyncObjTypeSink *) l->data; osync_bool sinkEnabled = osync_objtype_sink_is_enabled(sink); osync_trace(TRACE_INTERNAL, "%s: enabled => %d", __func__, sinkEnabled); if (!sinkEnabled) @@ -86,12 +85,19 @@ &error)) goto error; } + + osync_list_free(list); + list = NULL; + osync_trace(TRACE_EXIT, "%s - TRUE", __func__); return TRUE; error: osync_error_set(oerror, OSYNC_ERROR_GENERIC, "%s", smlErrorPrint(&error)); smlErrorDeref(&error); oerror: + if (list) + osync_list_free(list); + osync_trace(TRACE_EXIT_ERROR, "%s - %s", __func__, osync_error_print(oerror)); return FALSE; } |
From: <svn...@op...> - 2009-03-28 22:39:27
|
Author: dgollub Date: Sat Mar 28 23:39:18 2009 New Revision: 5414 URL: http://www.opensync.org/changeset/5414 Log: Port file-sync plugin to latest OSyncPluginInfo API changes. Modified: plugins/file-sync/src/file_sync.c Modified: plugins/file-sync/src/file_sync.c ============================================================================== --- plugins/file-sync/src/file_sync.c Sat Mar 28 23:38:58 2009 (r5413) +++ plugins/file-sync/src/file_sync.c Sat Mar 28 23:39:18 2009 (r5414) @@ -526,7 +526,7 @@ GList *pathes = NULL; - sinks = osync_plugin_info_get_objtypes(info); + sinks = osync_plugin_info_get_objtype_sinks(info); for (s = sinks; s; s = s->next) { OSyncFileDir *dir = osync_try_malloc0(sizeof(OSyncFileDir), error); if (!dir) @@ -617,7 +617,7 @@ { osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, data, info, error); - OSyncList *s, *sinks = osync_plugin_info_get_objtypes(info); + OSyncList *s, *sinks = osync_plugin_info_get_objtype_sinks(info); for (s = sinks; s; s = s->next) { OSyncObjTypeSink *sink = (OSyncObjTypeSink *) s->data; g_assert(sink); |
From: <svn...@op...> - 2009-03-28 22:39:03
|
Author: dgollub Date: Sat Mar 28 23:38:58 2009 New Revision: 5413 URL: http://www.opensync.org/changeset/5413 Log: Port evo2-sync to latest OSyncPluginInfo API changes. Modified: plugins/evolution2/src/evolution2_sync.c Modified: plugins/evolution2/src/evolution2_sync.c ============================================================================== --- plugins/evolution2/src/evolution2_sync.c Sat Mar 28 23:36:14 2009 (r5412) +++ plugins/evolution2/src/evolution2_sync.c Sat Mar 28 23:38:58 2009 (r5413) @@ -156,9 +156,10 @@ OSyncEvoEnv *env = (OSyncEvoEnv *)data; - int i, numobjs = osync_plugin_info_num_objtypes(info); - for (i = 0; i < numobjs; i++) { - OSyncObjTypeSink *sink = osync_plugin_info_nth_objtype(info, i); + OSyncList *l, *list = NULL; + list = osync_plugin_info_get_objtype_sinks(info); + for (l=list; l; l = l->next) { + OSyncObjTypeSink *sink = (OSyncObjTypeSink *) l->data; osync_assert(sink); osync_objtype_sink_set_available(sink, TRUE); @@ -183,7 +184,7 @@ if (!evo2_ebook_discover(env, capabilities, error)) { goto error_free_capabilties; } - int numcalendars = g_list_length(env->calendars); + int i, numcalendars = g_list_length(env->calendars); for (i = 0; i < numcalendars; i++) { OSyncEvoCalendar *cal = (OSyncEvoCalendar *)g_list_nth_data(env->calendars, i); if (!cal || !evo2_ecal_discover(cal, capabilities, error)) { |
From: <svn...@op...> - 2009-03-28 22:36:17
|
Author: dgollub Date: Sat Mar 28 23:36:14 2009 New Revision: 5412 URL: http://www.opensync.org/changeset/5412 Log: Fix potentioanl memory leak in example plugins. osync_plugin_info_get_objtype_sinks() returns a copy of the original list which needs to be freed by the caller. Modified: trunk/docs/examples/plugins/src/plugin.c trunk/docs/examples/plugins/src/simple_plugin.c Modified: trunk/docs/examples/plugins/src/plugin.c ============================================================================== --- trunk/docs/examples/plugins/src/plugin.c Sat Mar 28 23:32:29 2009 (r5411) +++ trunk/docs/examples/plugins/src/plugin.c Sat Mar 28 23:36:14 2009 (r5412) @@ -346,6 +346,8 @@ osync_objtype_sink_enable_hashtable(sink, TRUE); } + + osync_list_free(list); //Now your return your environemtn struct. return (void *) env; Modified: trunk/docs/examples/plugins/src/simple_plugin.c ============================================================================== --- trunk/docs/examples/plugins/src/simple_plugin.c Sat Mar 28 23:32:29 2009 (r5411) +++ trunk/docs/examples/plugins/src/simple_plugin.c Sat Mar 28 23:36:14 2009 (r5412) @@ -267,6 +267,8 @@ * again once the functions are called */ osync_objtype_sink_set_functions(sink, functions, NULL); } + + osync_list_free(list); //Now your return your struct. return (void *) env; |
From: <svn...@op...> - 2009-03-28 22:32:35
|
Author: dgollub Date: Sat Mar 28 23:32:29 2009 New Revision: 5411 URL: http://www.opensync.org/changeset/5411 Log: Ported example plugins to OSyncPluginEnv API changes. Dropped sinkenv from simple_plugin to make it even simpler. Modified: trunk/docs/examples/plugins/src/plugin.c trunk/docs/examples/plugins/src/simple_plugin.c Modified: trunk/docs/examples/plugins/src/plugin.c ============================================================================== --- trunk/docs/examples/plugins/src/plugin.c Sat Mar 28 23:22:30 2009 (r5410) +++ trunk/docs/examples/plugins/src/plugin.c Sat Mar 28 23:32:29 2009 (r5411) @@ -308,9 +308,11 @@ /* * Process Ressource options */ - unsigned int i, numobjs = osync_plugin_info_num_objtypes(info); - for (i = 0; i < numobjs; i++) { - OSyncObjTypeSink *sink = osync_plugin_info_nth_objtype(info, i); + OSyncList *l, *list = NULL; + list = osync_plugin_info_get_objtype_sinks(info); + for (l=list; l; l = l->next) { + OSyncObjTypeSink *sink = (OSyncObjTypeSink *) l->data; + const char *objtype = osync_objtype_sink_get_name(sink); OSyncPluginResource *res = osync_plugin_config_find_active_resource(config, objtype); Modified: trunk/docs/examples/plugins/src/simple_plugin.c ============================================================================== --- trunk/docs/examples/plugins/src/simple_plugin.c Sat Mar 28 23:22:30 2009 (r5410) +++ trunk/docs/examples/plugins/src/simple_plugin.c Sat Mar 28 23:32:29 2009 (r5411) @@ -7,28 +7,6 @@ #include <string.h> -typedef struct { - OSyncList *sink_envs; -} plugin_environment; - -typedef struct { - OSyncObjTypeSink *sink; -} sink_environment; - -static void free_env(plugin_environment *env) -{ - while (env->sink_envs) { - sink_environment *sinkenv = env->sink_envs->data; - - if (sinkenv->sink) - osync_objtype_sink_unref(sinkenv->sink); - - env->sink_envs = osync_list_remove(env->sink_envs, sinkenv); - } - - osync_free(env); -} - static void connect(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *userdata) { osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, sink, info, ctx, userdata); @@ -36,8 +14,6 @@ //calls to your plugin) //cast void* userdata to the sink specific data type - //sink_environment *sinkenv = (sink_environment*)userdata; - OSyncError *error = NULL; @@ -85,7 +61,6 @@ osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, userdata, info, ctx); OSyncFormatEnv *formatenv = osync_plugin_info_get_format_env(info); - //sink_environment *sinkenv = (sink_environment*) userdata; OSyncError *error = NULL; @@ -156,7 +131,6 @@ static void commit_change(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, OSyncChange *change, void *userdata) { - //sink_environment *sinkenv = (sink_environment*)userdata;; /* * Here you have to add, modify or delete a object @@ -189,7 +163,6 @@ * This function will only be called if the sync was successful */ OSyncError *error = NULL; - //sink_environment *sinkenv = (sink_environment*)userdata; //If we use anchors we have to update it now. //Now you get/calculate the current anchor of the device @@ -208,8 +181,6 @@ static void disconnect(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *userdata) { - //sink_environment *sinkenv = (sink_environment*)userdata; - //Close all stuff you need to close //Answer the call @@ -218,10 +189,7 @@ static void finalize(void *userdata) { - plugin_environment *env = (plugin_environment *)userdata; - //Free all stuff that you have allocated here. - free_env(env); } @@ -239,12 +207,10 @@ * You need to specify the <some name>_environment somewhere with * all the members you need */ - plugin_environment *env = osync_try_malloc0(sizeof(plugin_environment), error); + void *env = NULL; if (!env) goto error; - env->sink_envs = NULL; - osync_trace(TRACE_INTERNAL, "The config: %s", osync_plugin_info_get_config(info)); /* @@ -271,16 +237,12 @@ /* * Process Ressource options */ - int i, numobjs = osync_plugin_info_num_objtypes(info); - for (i = 0; i < numobjs; i++) { - sink_environment *sinkenv = osync_try_malloc0(sizeof(sink_environment), error); - if (!sinkenv) - goto error_free_env; + OSyncList *l, *list = NULL; + list = osync_plugin_info_get_objtype_sinks(info); + for (l=list; l; l = l->next) { + OSyncObjTypeSink *sink = (OSyncObjTypeSink *) l->data ; - sinkenv->sink = osync_plugin_info_nth_objtype(info, i); - osync_assert(sinkenv->sink); - - const char *objtype = osync_objtype_sink_get_name(sinkenv->sink); + const char *objtype = osync_objtype_sink_get_name(sink); OSyncPluginResource *res = osync_plugin_config_find_active_resource(config, objtype); /* get objformat sinks */ @@ -303,16 +265,12 @@ /* We pass the OSyncFileDir object to the sink, so we dont have to look it up * again once the functions are called */ - osync_objtype_sink_set_functions(sinkenv->sink, functions, sinkenv); - - env->sink_envs = osync_list_append(env->sink_envs, sinkenv); + osync_objtype_sink_set_functions(sink, functions, NULL); } //Now your return your struct. return (void *) env; -error_free_env: - free_env(env); error: osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); return NULL; @@ -323,8 +281,6 @@ { osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, userdata, info, error); -// plugin_environment *env = (plugin_environment *)userdata; - // Report avaliable sinks... OSyncObjTypeSink *sink = osync_plugin_info_find_objtype(info, "<objtype e.g. note>"); if (!sink) { |
From: <svn...@op...> - 2009-03-28 22:22:35
|
Author: dgollub Date: Sat Mar 28 23:22:30 2009 New Revision: 5410 URL: http://www.opensync.org/changeset/5410 Log: Renamed osync_plugin_info_get_objtypes to osync_plugin_info_get_objtype_sinks. Thsi should avoid confusion between "objtype" which is often just const char* and between OSyncObjTypeSink. Modified: trunk/opensync.sym trunk/opensync/client/opensync_client.c trunk/opensync/plugin/opensync_plugin_info.c trunk/opensync/plugin/opensync_plugin_info.h trunk/opensync/plugin/opensync_plugin_info_private.h trunk/tests/engine-tests/check_engine_error.c trunk/tests/mock-plugin/mock_sync.c trunk/tools/osyncplugin.c trunk/wrapper/opensync-plugin.i Modified: trunk/opensync.sym ============================================================================== --- trunk/opensync.sym Sat Mar 28 22:57:04 2009 (r5409) +++ trunk/opensync.sym Sat Mar 28 23:22:30 2009 (r5410) @@ -558,7 +558,7 @@ osync_plugin_info_get_groupname osync_plugin_info_get_loop osync_plugin_info_get_main_sink -osync_plugin_info_get_objtypes +osync_plugin_info_get_objtype_sinks osync_plugin_info_get_version osync_plugin_info_new osync_plugin_info_ref Modified: trunk/opensync/client/opensync_client.c ============================================================================== --- trunk/opensync/client/opensync_client.c Sat Mar 28 22:57:04 2009 (r5409) +++ trunk/opensync/client/opensync_client.c Sat Mar 28 23:22:30 2009 (r5410) @@ -697,7 +697,7 @@ goto error; } - objtypesinks = osync_plugin_info_get_objtypes(client->plugin_info); + objtypesinks = osync_plugin_info_get_objtype_sinks(client->plugin_info); list = objtypesinks; while (list) { sink = (OSyncObjTypeSink*)list->data; @@ -847,7 +847,7 @@ else osync_message_write_int(reply, 0); - objtypesinks = osync_plugin_info_get_objtypes(client->plugin_info); + objtypesinks = osync_plugin_info_get_objtype_sinks(client->plugin_info); list = objtypesinks; while(list) { sink = (OSyncObjTypeSink*)list->data; Modified: trunk/opensync/plugin/opensync_plugin_info.c ============================================================================== --- trunk/opensync/plugin/opensync_plugin_info.c Sat Mar 28 22:57:04 2009 (r5409) +++ trunk/opensync/plugin/opensync_plugin_info.c Sat Mar 28 23:22:30 2009 (r5410) @@ -62,10 +62,10 @@ if (info->groupname) osync_free(info->groupname); - while (info->objtypes) { - OSyncObjTypeSink *sink = info->objtypes->data; + while (info->objtype_sinks) { + OSyncObjTypeSink *sink = info->objtype_sinks->data; osync_objtype_sink_unref(sink); - info->objtypes = osync_list_remove(info->objtypes, sink); + info->objtype_sinks = osync_list_remove(info->objtype_sinks, sink); } if (info->main_sink) @@ -149,7 +149,7 @@ osync_trace(TRACE_ENTRY, "%s(%p, %s)", __func__, info, name); osync_assert(info); - for (p = info->objtypes; p; p = p->next) { + for (p = info->objtype_sinks; p; p = p->next) { sink = p->data; if (g_ascii_strcasecmp(osync_objtype_sink_get_name(sink), name) == 0) goto done; @@ -167,13 +167,13 @@ void osync_plugin_info_add_objtype(OSyncPluginInfo *info, OSyncObjTypeSink *sink) { osync_assert(info); - info->objtypes = osync_list_append(info->objtypes, sink); + info->objtype_sinks = osync_list_append(info->objtype_sinks, sink); osync_objtype_sink_ref(sink); } -OSyncList *osync_plugin_info_get_objtypes(OSyncPluginInfo *info) { +OSyncList *osync_plugin_info_get_objtype_sinks(OSyncPluginInfo *info) { osync_assert(info); - return osync_list_copy(info->objtypes); + return osync_list_copy(info->objtype_sinks); } OSyncObjTypeSink *osync_plugin_info_get_main_sink(OSyncPluginInfo *info) Modified: trunk/opensync/plugin/opensync_plugin_info.h ============================================================================== --- trunk/opensync/plugin/opensync_plugin_info.h Sat Mar 28 22:57:04 2009 (r5409) +++ trunk/opensync/plugin/opensync_plugin_info.h Sat Mar 28 23:22:30 2009 (r5410) @@ -116,7 +116,7 @@ * @param Pointer to a OSyncPluginInfo * @return A shallow copy of the internal objtype list */ -OSYNC_EXPORT OSyncList *osync_plugin_info_get_objtypes(OSyncPluginInfo *info); +OSYNC_EXPORT OSyncList *osync_plugin_info_get_objtype_sinks(OSyncPluginInfo *info); /** @brief Returns the Main Sink * Modified: trunk/opensync/plugin/opensync_plugin_info_private.h ============================================================================== --- trunk/opensync/plugin/opensync_plugin_info_private.h Sat Mar 28 22:57:04 2009 (r5409) +++ trunk/opensync/plugin/opensync_plugin_info_private.h Sat Mar 28 23:22:30 2009 (r5410) @@ -34,7 +34,7 @@ struct OSyncPluginInfo { void *loop; OSyncPluginConfig *config; - OSyncList *objtypes; + OSyncList *objtype_sinks; char *configdir; /* The main sink */ Modified: trunk/tests/engine-tests/check_engine_error.c ============================================================================== --- trunk/tests/engine-tests/check_engine_error.c Sat Mar 28 22:57:04 2009 (r5409) +++ trunk/tests/engine-tests/check_engine_error.c Sat Mar 28 23:22:30 2009 (r5410) @@ -130,7 +130,7 @@ mock_env *env = osync_try_malloc0(sizeof(mock_env), error); osync_assert(env); - OSyncList *objtypesinks = osync_plugin_info_get_objtypes(info); + OSyncList *objtypesinks = osync_plugin_info_get_objtype_sinks(info); OSyncObjTypeSink *sink = (OSyncObjTypeSink*)objtypesinks->data; osync_assert(sink); Modified: trunk/tests/mock-plugin/mock_sync.c ============================================================================== --- trunk/tests/mock-plugin/mock_sync.c Sat Mar 28 22:57:04 2009 (r5409) +++ trunk/tests/mock-plugin/mock_sync.c Sat Mar 28 23:22:30 2009 (r5410) @@ -607,7 +607,7 @@ /* Now we register the objtypes that we can sync. This plugin is special. It can * synchronize any objtype we configure it to sync and where a conversion * path to the file format can be found */ - OSyncList *objtypesinks = osync_plugin_info_get_objtypes(info); + OSyncList *objtypesinks = osync_plugin_info_get_objtype_sinks(info); OSyncList *list = objtypesinks; while(list) { MockDir *dir = osync_try_malloc0(sizeof(MockDir), error); Modified: trunk/tools/osyncplugin.c ============================================================================== --- trunk/tools/osyncplugin.c Sat Mar 28 22:57:04 2009 (r5409) +++ trunk/tools/osyncplugin.c Sat Mar 28 23:22:30 2009 (r5410) @@ -452,7 +452,7 @@ osync_bool couldinit; couldinit = osync_plugin_initialize(plugin, &(plugin_data), plugin_info, error); - objtypesinks = osync_plugin_info_get_objtypes(plugin_info); + objtypesinks = osync_plugin_info_get_objtype_sinks(plugin_info); list = objtypesinks; while(list) { OSyncObjTypeSink *sink = (OSyncObjTypeSink*)list->data; @@ -619,7 +619,7 @@ } else { /* all available objtypes */ - objtypesinks = osync_plugin_info_get_objtypes(plugin_info); + objtypesinks = osync_plugin_info_get_objtype_sinks(plugin_info); list = objtypesinks; while(list) { sink = (OSyncObjTypeSink*)list->data; @@ -721,7 +721,7 @@ if (!connect_sink(cmd, sink, error)) goto error; } else { - objtypesinks = osync_plugin_info_get_objtypes(plugin_info); + objtypesinks = osync_plugin_info_get_objtype_sinks(plugin_info); list = objtypesinks; while(list) { sink = (OSyncObjTypeSink*)list->data; @@ -818,7 +818,7 @@ if (!disconnect_sink(cmd, sink, error)) goto error; } else { - objtypesinks = osync_plugin_info_get_objtypes(plugin_info); + objtypesinks = osync_plugin_info_get_objtype_sinks(plugin_info); list = objtypesinks; while(list) { sink = (OSyncObjTypeSink*)list->data; @@ -917,7 +917,7 @@ if (!commit_sink(cmd, sink, change, error)) goto error; } else { - objtypesinks = osync_plugin_info_get_objtypes(plugin_info); + objtypesinks = osync_plugin_info_get_objtype_sinks(plugin_info); list = objtypesinks; while(list){ sink = (OSyncObjTypeSink*)list->data; @@ -1037,7 +1037,7 @@ if (!syncdone_sink(cmd, sink, error)) goto error; } else { - objtypesinks = osync_plugin_info_get_objtypes(plugin_info); + objtypesinks = osync_plugin_info_get_objtype_sinks(plugin_info); list = objtypesinks; while(list) { sink = (OSyncObjTypeSink*)list->data; @@ -1127,7 +1127,7 @@ if (!committedall_sink(cmd, sink, error)) goto error; } else { - objtypesinks = osync_plugin_info_get_objtypes(plugin_info); + objtypesinks = osync_plugin_info_get_objtype_sinks(plugin_info); list = objtypesinks; while(list) { sink = (OSyncObjTypeSink*)list->data; Modified: trunk/wrapper/opensync-plugin.i ============================================================================== --- trunk/wrapper/opensync-plugin.i Sat Mar 28 22:57:04 2009 (r5409) +++ trunk/wrapper/opensync-plugin.i Sat Mar 28 23:22:30 2009 (r5410) @@ -193,8 +193,8 @@ osync_plugin_info_add_objtype(self, sink); } - unsigned int num_objtypes() { - OSyncList *objtypesinks = osync_plugin_info_get_objtypes(self); + unsigned int num_objtype_sinks() { + OSyncList *objtypesinks = osync_plugin_info_get_objtype_sinks(self); unsigned int num = osync_list_length(objtypesinks); osync_list_free(objtypesinks); return num; @@ -202,7 +202,7 @@ ObjTypeSink *nth_objtype(int nth) { /* TODO: return a list structure of phython */ - OSyncList *objtypesinks = osync_plugin_info_get_objtypes(self); + OSyncList *objtypesinks = osync_plugin_info_get_objtype_sinks(self); ObjTypeSink *ret = (ObjTypeSink*)osync_list_nth_data(objtypesinks, nth); if (ret) osync_objtype_sink_ref(ret); @@ -277,7 +277,7 @@ __oldinit = __init__ def __init__(self, *args): self.__oldinit(*args) - self.objtypes = _ListWrapper(self.num_objtypes, self.nth_objtype) + self.objtypes = _ListWrapper(self.num_objtype_sinks, self.nth_objtype) %} } |
From: <svn...@op...> - 2009-03-28 21:57:08
|
Author: dgollub Date: Sat Mar 28 22:57:04 2009 New Revision: 5409 URL: http://www.opensync.org/changeset/5409 Log: Port list_all_plugins example to latest OSyncPluginEnv API changes. Build got broken due to API change by r5383 Modified: trunk/docs/examples/applications/list_all_plugins.c Modified: trunk/docs/examples/applications/list_all_plugins.c ============================================================================== --- trunk/docs/examples/applications/list_all_plugins.c Sat Mar 28 22:43:27 2009 (r5408) +++ trunk/docs/examples/applications/list_all_plugins.c Sat Mar 28 22:57:04 2009 (r5409) @@ -5,11 +5,10 @@ OSyncPluginEnv *env; OSyncPlugin* plugin; + OSyncList *list, *l; osync_bool couldloadplugins; - int numplugins; - int i = 0; env = osync_plugin_env_new(NULL); /* load plugins from default dir */ @@ -20,13 +19,15 @@ return -1; } - numplugins = osync_plugin_env_num_plugins(env); - printf("found %i plugins\n", i); + list = osync_plugin_env_get_plugins(env); + printf("found %i plugins\n", osync_list_length(list)); - for( i=0; i < numplugins; i++ ) { - plugin = osync_plugin_env_nth_plugin(env, i); - printf("plugin nr. %i is %s\n", i+1, osync_plugin_get_name(plugin)); + for(l=list; l; l = l->next) { + plugin = (OSyncPlugin *) l->data; + printf("plugin: %s\n", osync_plugin_get_name(plugin)); } + + osync_list_free(list); /* free env */ osync_plugin_env_unref(env); |
From: <svn...@op...> - 2009-03-28 21:43:31
|
Author: dgollub Date: Sat Mar 28 22:43:27 2009 New Revision: 5408 URL: http://www.opensync.org/changeset/5408 Log: Ported osycntool to Engine-Event/Status API changes from r5407. Fixed some compiler warnings about unused variables and unhandeld valenums. Modified: osynctool/trunk/tools/osynctool.c Modified: osynctool/trunk/tools/osynctool.c ============================================================================== --- osynctool/trunk/tools/osynctool.c Sat Mar 28 22:42:14 2009 (r5407) +++ osynctool/trunk/tools/osynctool.c Sat Mar 28 22:43:27 2009 (r5408) @@ -175,7 +175,6 @@ static void osynctool_list_plugins(OSyncPluginEnv *env) { - int i; OSyncPlugin *plugin; OSyncList *plugins, *p; @@ -224,38 +223,45 @@ return NULL; } -static void member_status(OSyncMemberUpdate *status, void *user_data) +static void member_status(OSyncEngineMemberUpdate *status, void *user_data) { - osync_trace(TRACE_ENTRY, "%s(%p (%i), %p)", __func__, status, status->type, user_data); + osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, status, user_data); + + OSyncMember *member = osync_engine_member_update_get_member(status); + const char *objtype = osync_engine_member_update_get_objtype(status); + OSyncError *error = osync_engine_member_update_get_error(status); char *sink = NULL; - if (status->objtype == NULL) { + if (objtype == NULL) { sink = g_strdup("Main sink"); } else { - sink = g_strdup_printf("%s sink", status->objtype); + sink = g_strdup_printf("%s sink", objtype); } - switch (status->type) { - case OSYNC_CLIENT_EVENT_CONNECTED: - printf("%s of member %lli of type %s just connected\n", sink, osync_member_get_id(status->member), osync_member_get_pluginname(status->member)); + switch (osync_engine_member_update_get_event(status)) { + case OSYNC_ENGINE_MEMBER_EVENT_CONNECTED: + printf("%s of member %lli of type %s just connected\n", sink, osync_member_get_id(member), osync_member_get_pluginname(member)); + break; + case OSYNC_ENGINE_MEMBER_EVENT_CONNECT_DONE: + /* Special event - but not interesting for the normal user. */ break; - case OSYNC_CLIENT_EVENT_DISCONNECTED: - printf("%s of member %lli of type %s just disconnected\n", sink, osync_member_get_id(status->member), osync_member_get_pluginname(status->member)); + case OSYNC_ENGINE_MEMBER_EVENT_DISCONNECTED: + printf("%s of member %lli of type %s just disconnected\n", sink, osync_member_get_id(member), osync_member_get_pluginname(member)); break; - case OSYNC_CLIENT_EVENT_READ: - printf("%s of member %lli of type %s just sent all changes\n", sink, osync_member_get_id(status->member), osync_member_get_pluginname(status->member)); + case OSYNC_ENGINE_MEMBER_EVENT_READ: + printf("%s of member %lli of type %s just sent all changes\n", sink, osync_member_get_id(member), osync_member_get_pluginname(member)); break; - case OSYNC_CLIENT_EVENT_WRITTEN: - printf("%s of member %lli of type %s committed all changes.\n", sink, osync_member_get_id(status->member), osync_member_get_pluginname(status->member)); + case OSYNC_ENGINE_MEMBER_EVENT_WRITTEN: + printf("%s of member %lli of type %s committed all changes.\n", sink, osync_member_get_id(member), osync_member_get_pluginname(member)); break; - case OSYNC_CLIENT_EVENT_SYNC_DONE: - printf("%s of member %lli of type %s reported sync done.\n", sink, osync_member_get_id(status->member), osync_member_get_pluginname(status->member)); + case OSYNC_ENGINE_MEMBER_EVENT_SYNC_DONE: + printf("%s of member %lli of type %s reported sync done.\n", sink, osync_member_get_id(member), osync_member_get_pluginname(member)); break; - case OSYNC_CLIENT_EVENT_DISCOVERED: - printf("%s of member %lli of type %s discovered its objtypes.\n", sink, osync_member_get_id(status->member), osync_member_get_pluginname(status->member)); + case OSYNC_ENGINE_MEMBER_EVENT_DISCOVERED: + printf("%s of member %lli of type %s discovered its objtypes.\n", sink, osync_member_get_id(member), osync_member_get_pluginname(member)); break; - case OSYNC_CLIENT_EVENT_ERROR: - printf("%s of member %lli of type %s had an error: %s\n", sink, osync_member_get_id(status->member), osync_member_get_pluginname(status->member), osync_error_print(&(status->error))); + case OSYNC_ENGINE_MEMBER_EVENT_ERROR: + printf("%s of member %lli of type %s had an error: %s\n", sink, osync_member_get_id(member), osync_member_get_pluginname(member), osync_error_print(&error)); break; } @@ -370,64 +376,85 @@ return; } -static void entry_status(OSyncChangeUpdate *status, void *user_data) +static void entry_status(OSyncEngineChangeUpdate *status, void *user_data) { - osync_trace(TRACE_ENTRY, "%s(%p (%i), %p)", __func__, status, status->type, user_data); + osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, status, user_data); + + OSyncChange *change = osync_engine_change_update_get_change(status); + OSyncMember *member = osync_engine_change_update_get_member(status); + OSyncError *error = osync_engine_change_update_get_error(status); - switch (status->type) { - case OSYNC_CHANGE_EVENT_READ: + switch (osync_engine_change_update_get_event(status)) { + case OSYNC_ENGINE_CHANGE_EVENT_READ: printf("Received an entry %s (%s) from member %lli (%s). Changetype %s\n", - osync_change_get_uid(status->change), - osync_objformat_get_name(osync_change_get_objformat(status->change)), - osync_member_get_id(status->member), - osync_member_get_pluginname(status->member), - OSyncChangeType2String(osync_change_get_changetype(status->change))); + osync_change_get_uid(change), + osync_objformat_get_name(osync_change_get_objformat(change)), + osync_member_get_id(member), + osync_member_get_pluginname(member), + OSyncChangeType2String(osync_change_get_changetype(change))); break; - case OSYNC_CHANGE_EVENT_WRITTEN: + case OSYNC_ENGINE_CHANGE_EVENT_WRITTEN: printf("Sent an entry %s (%s) to member %lli (%s). Changetype %s\n", - osync_change_get_uid(status->change), - osync_objformat_get_name(osync_change_get_objformat(status->change)), - osync_member_get_id(status->member), - osync_member_get_pluginname(status->member), - OSyncChangeType2String(osync_change_get_changetype(status->change))); + osync_change_get_uid(change), + osync_objformat_get_name(osync_change_get_objformat(change)), + osync_member_get_id(member), + osync_member_get_pluginname(member), + OSyncChangeType2String(osync_change_get_changetype(change))); break; - case OSYNC_CHANGE_EVENT_ERROR: + case OSYNC_ENGINE_CHANGE_EVENT_ERROR: printf("Error for entry %s (%s) and member %lli (%s): %s\n", - osync_change_get_uid(status->change), - osync_objformat_get_name(osync_change_get_objformat(status->change)), - osync_member_get_id(status->member), - osync_member_get_pluginname(status->member), - osync_error_print(&(status->error))); + osync_change_get_uid(change), + osync_objformat_get_name(osync_change_get_objformat(change)), + osync_member_get_id(member), + osync_member_get_pluginname(member), + osync_error_print(&(error))); break; } osync_trace(TRACE_EXIT, "%s", __func__); } -static void mapping_status(OSyncMappingUpdate *status, void *user_data) +static void mapping_status(OSyncEngineMappingUpdate *status, void *user_data) { - switch (status->type) { - case OSYNC_MAPPING_EVENT_SOLVED: + + OSyncError *error = osync_engine_mapping_update_get_error(status); + + switch (osync_engine_mapping_update_get_event(status)) { + case OSYNC_ENGINE_MAPPING_EVENT_SOLVED: /*printf("Mapping solved\n");*/ break; - /*case OSYNC_MAPPING_EVENT_WRITTEN: - printf("Mapping Synced\n"); - break;*/ - case OSYNC_MAPPING_EVENT_ERROR: - printf("Mapping Error: %s\n", osync_error_print(&(status->error))); + case OSYNC_ENGINE_MAPPING_EVENT_ERROR: + printf("Mapping Error: %s\n", osync_error_print(&(error))); break; } } static void engine_status(OSyncEngineUpdate *status, void *user_data) { - switch (status->type) { + OSyncError *error = osync_engine_update_get_error(status); + + switch (osync_engine_update_get_event(status)) { case OSYNC_ENGINE_EVENT_CONNECTED: printf("All clients connected or error\n"); break; + case OSYNC_ENGINE_EVENT_CONNECT_DONE: + /* Not of interest for regular user. */ + break; case OSYNC_ENGINE_EVENT_READ: printf("All clients sent changes or error\n"); break; + case OSYNC_ENGINE_EVENT_MAPPED: + printf("All changes got mapped\n"); + break; + case OSYNC_ENGINE_EVENT_MULTIPLIED: + printf("All changes got multiplied\n"); + break; + case OSYNC_ENGINE_EVENT_PREPARED_WRITE: + printf("All changes got prepared for write\n"); + break; + case OSYNC_ENGINE_EVENT_PREPARED_MAP: + /* Not of interest for regular user. */ + break; case OSYNC_ENGINE_EVENT_WRITTEN: printf("All clients have written\n"); break; @@ -435,7 +462,7 @@ printf("All clients have disconnected\n"); break; case OSYNC_ENGINE_EVENT_ERROR: - printf("The sync failed: %s\n", osync_error_print(&(status->error))); + printf("The sync failed: %s\n", osync_error_print(&(error))); break; case OSYNC_ENGINE_EVENT_SUCCESSFUL: printf("The sync was successful\n"); @@ -449,6 +476,7 @@ case OSYNC_ENGINE_EVENT_SYNC_DONE: printf("All clients reported sync done\n"); break; + } } @@ -1371,7 +1399,6 @@ int main (int argc, char *argv[]) { OSyncError *error = NULL; - int i; char *groupname = NULL; char *membername = NULL; char *pluginname = NULL; |
From: <svn...@op...> - 2009-03-28 21:42:21
|
Author: dgollub Date: Sat Mar 28 22:42:14 2009 New Revision: 5407 URL: http://www.opensync.org/changeset/5407 Log: Cleaned up engine interface namespaces. And unexported Update struct and repalced them with an anonymous typdef struct. Renamed enum namespaces: OSYNC_MAPPING_EVENT_ to OSYNC_ENGINE_MAPPING_EVENT_ OSYNC_CLIENT_EVENT_ to OSYNC_ENGINE_MEMBER_EVENT_ OSYNC_CHANGE_EVENT_ to OSYNC_ENGINE_CHANGE_EVENT_ OSYNC_MAPPING_EVENT_ to OSYNC_ENGINE_MAPPING_EVENT_ Renamed structs and unexported to anonymouse typedefs: OSyncChangeUpdate to OSyncEngineChangeUpdate OSyncMemberUpdate to OSyncEngineMemberUpdate OSyncMappingUpdate to OSyncEngineMappingUpdate Added following interface to get data from the Update structs inside the Update-callbacks: OSyncError *osync_engine_change_update_get_error(OSyncEngineChangeUpdate *update); OSyncEngineChangeEvent osync_engine_change_update_get_event(OSyncEngineChangeUpdate *update); OSyncMember *osync_engine_change_update_get_member(OSyncEngineChangeUpdate *update); OSyncChange *osync_engine_change_update_get_change(OSyncEngineChangeUpdate *update); OSyncError *osync_engine_member_update_get_error(OSyncEngineMemberUpdate *update); OSyncEngineMemberEvent osync_engine_member_update_get_event(OSyncEngineMemberUpdate *update); OSyncMember *osync_engine_member_update_get_member(OSyncEngineMemberUpdate *update); const char *osync_engine_member_update_get_objtype(OSyncEngineMemberUpdate *update); OSyncError *osync_engine_mapping_update_get_error(OSyncEngineMappingUpdate *update); OSyncEngineMappingEvent osync_engine_mapping_update_get_event(OSyncEngineMappingUpdate *update); OSyncError *osync_engine_update_get_error(OSyncEngineUpdate *update); OSyncEngineEvent osync_engine_update_get_event(OSyncEngineUpdate *update); Modified: trunk/opensync.sym trunk/opensync/engine/opensync_engine.c trunk/opensync/engine/opensync_engine.h trunk/opensync/engine/opensync_engine_private.h trunk/opensync/engine/opensync_mapping_engine.c trunk/opensync/engine/opensync_obj_engine.c trunk/opensync/engine/opensync_status.c trunk/opensync/engine/opensync_status_internals.h trunk/opensync/opensync.h trunk/tests/support.c trunk/tests/support.h trunk/wrapper/opensync-engine.i Modified: trunk/opensync.sym ============================================================================== --- trunk/opensync.sym Sat Mar 28 21:06:04 2009 (r5406) +++ trunk/opensync.sym Sat Mar 28 22:42:14 2009 (r5407) @@ -86,6 +86,10 @@ osync_data_set_objtype osync_data_unref osync_engine_abort +osync_engine_change_update_get_change +osync_engine_change_update_get_error +osync_engine_change_update_get_event +osync_engine_change_update_get_member osync_engine_continue osync_engine_discover osync_engine_discover_and_block @@ -95,7 +99,13 @@ osync_engine_mapping_duplicate osync_engine_mapping_ignore_conflict osync_engine_mapping_solve +osync_engine_mapping_update_get_error +osync_engine_mapping_update_get_event osync_engine_mapping_use_latest +osync_engine_member_update_get_error +osync_engine_member_update_get_event +osync_engine_member_update_get_member +osync_engine_member_update_get_objtype osync_engine_new osync_engine_nth_objengine osync_engine_num_objengines @@ -110,6 +120,8 @@ osync_engine_synchronize osync_engine_synchronize_and_block osync_engine_unref +osync_engine_update_get_error +osync_engine_update_get_event osync_engine_wait_sync_end osync_entry_engine_get_changetype osync_entry_engine_is_dirty Modified: trunk/opensync/engine/opensync_engine.c ============================================================================== --- trunk/opensync/engine/opensync_engine.c Sat Mar 28 21:06:04 2009 (r5406) +++ trunk/opensync/engine/opensync_engine.c Sat Mar 28 22:42:14 2009 (r5407) @@ -337,7 +337,7 @@ osync_free(member_objtype); osync_engine_set_error(engine, error); - osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_CLIENT_EVENT_ERROR, NULL, error); + osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_ENGINE_MEMBER_EVENT_ERROR, NULL, error); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error)); } @@ -1264,10 +1264,10 @@ if (error) { osync_engine_set_error(engine, error); engine->proxy_errors = engine->proxy_errors | (0x1 << position); - osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_CLIENT_EVENT_ERROR, NULL, error); + osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_ENGINE_MEMBER_EVENT_ERROR, NULL, error); } else { engine->proxy_connects = engine->proxy_connects | (0x1 << position); - osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_CLIENT_EVENT_CONNECTED, NULL, NULL); + osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_ENGINE_MEMBER_EVENT_CONNECTED, NULL, NULL); } /* If MainSink request a SlowSync, flag all objengines with SlowSync */ @@ -1294,10 +1294,10 @@ if (error) { osync_engine_set_error(engine, error); engine->proxy_errors = engine->proxy_errors | (0x1 << position); - osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_CLIENT_EVENT_ERROR, NULL, error); + osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_ENGINE_MEMBER_EVENT_ERROR, NULL, error); } else { engine->proxy_connect_done = engine->proxy_connect_done | (0x1 << position); - osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_CLIENT_EVENT_CONNECT_DONE, NULL, NULL); + osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_ENGINE_MEMBER_EVENT_CONNECT_DONE, NULL, NULL); } _osync_engine_generate_connect_done_event(engine); @@ -1316,10 +1316,10 @@ if (error) { osync_engine_set_error(engine, error); engine->proxy_errors = engine->proxy_errors | (0x1 << position); - osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_CLIENT_EVENT_ERROR, NULL, error); + osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_ENGINE_MEMBER_EVENT_ERROR, NULL, error); } else { engine->proxy_disconnects = engine->proxy_disconnects | (0x1 << position); - osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_CLIENT_EVENT_DISCONNECTED, NULL, NULL); + osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_ENGINE_MEMBER_EVENT_DISCONNECTED, NULL, NULL); } _osync_engine_generate_disconnected_event(engine); @@ -1338,10 +1338,10 @@ if (error) { osync_engine_set_error(engine, error); engine->proxy_errors = engine->proxy_errors | (0x1 << position); - osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_CLIENT_EVENT_ERROR, NULL, error); + osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_ENGINE_MEMBER_EVENT_ERROR, NULL, error); } else { engine->proxy_get_changes = engine->proxy_get_changes | (0x1 << position); - osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_CLIENT_EVENT_READ, NULL, NULL); + osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_ENGINE_MEMBER_EVENT_READ, NULL, NULL); } _osync_engine_generate_get_changes_event(engine); @@ -1360,10 +1360,10 @@ if (error) { osync_engine_set_error(engine, error); engine->proxy_errors = engine->proxy_errors | (0x1 << position); - osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_CLIENT_EVENT_ERROR, NULL, error); + osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_ENGINE_MEMBER_EVENT_ERROR, NULL, error); } else { engine->proxy_written = engine->proxy_written | (0x1 << position); - osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_CLIENT_EVENT_WRITTEN, NULL, NULL); + osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_ENGINE_MEMBER_EVENT_WRITTEN, NULL, NULL); } _osync_engine_generate_written_event(engine); @@ -1382,10 +1382,10 @@ if (error) { osync_engine_set_error(engine, error); engine->proxy_errors = engine->proxy_errors | (0x1 << position); - osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_CLIENT_EVENT_ERROR, NULL, error); + osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_ENGINE_MEMBER_EVENT_ERROR, NULL, error); } else { engine->proxy_sync_done = engine->proxy_sync_done | (0x1 << position); - osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_CLIENT_EVENT_SYNC_DONE, NULL, NULL); + osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_ENGINE_MEMBER_EVENT_SYNC_DONE, NULL, NULL); } _osync_engine_generate_sync_done_event(engine); @@ -1516,9 +1516,9 @@ if (error) { osync_engine_set_error(engine, error); - osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_CLIENT_EVENT_ERROR, NULL, error); + osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_ENGINE_MEMBER_EVENT_ERROR, NULL, error); } else { - osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_CLIENT_EVENT_DISCOVERED, NULL, NULL); + osync_status_update_member(engine, osync_client_proxy_get_member(proxy), OSYNC_ENGINE_MEMBER_EVENT_DISCOVERED, NULL, NULL); } g_mutex_lock(engine->syncing_mutex); @@ -2337,24 +2337,94 @@ engine->changestat_userdata = user_data; } +OSyncError *osync_engine_change_update_get_error(OSyncEngineChangeUpdate *update) +{ + osync_return_val_if_fail(update, NULL); + return update->error; +} + +OSyncEngineChangeEvent osync_engine_change_update_get_event(OSyncEngineChangeUpdate *update) +{ + osync_return_val_if_fail(update, 0); + return update->type; +} + +OSyncMember *osync_engine_change_update_get_member(OSyncEngineChangeUpdate *update) +{ + osync_return_val_if_fail(update, NULL); + return update->member; +} + +OSyncChange *osync_engine_change_update_get_change(OSyncEngineChangeUpdate *update) +{ + osync_return_val_if_fail(update, NULL); + return update->change; +} + void osync_engine_set_mappingstatus_callback(OSyncEngine *engine, osync_status_mapping_cb callback, void *user_data) { engine->mapstat_callback = callback; engine->mapstat_userdata = user_data; } +OSyncError *osync_engine_mapping_update_get_error(OSyncEngineMappingUpdate *update) +{ + osync_return_val_if_fail(update, NULL); + return update->error; +} + +OSyncEngineMappingEvent osync_engine_mapping_update_get_event(OSyncEngineMappingUpdate *update) +{ + osync_return_val_if_fail(update, 0); + return update->type; +} + void osync_engine_set_enginestatus_callback(OSyncEngine *engine, osync_status_engine_cb callback, void *user_data) { engine->engstat_callback = callback; engine->engstat_userdata = user_data; } +OSyncError *osync_engine_update_get_error(OSyncEngineUpdate *update) +{ + osync_return_val_if_fail(update, NULL); + return update->error; +} + +OSyncEngineEvent osync_engine_update_get_event(OSyncEngineUpdate *update) +{ + osync_return_val_if_fail(update, 0); + return update->type; +} + void osync_engine_set_memberstatus_callback(OSyncEngine *engine, osync_status_member_cb callback, void *user_data) { engine->mebstat_callback = callback; engine->mebstat_userdata = user_data; } +OSyncError *osync_engine_member_update_get_error(OSyncEngineMemberUpdate *update) +{ + osync_return_val_if_fail(update, NULL); + return update->error; +} + +OSyncEngineMemberEvent osync_engine_member_update_get_event(OSyncEngineMemberUpdate *update) +{ + osync_return_val_if_fail(update, 0); + return update->type; +} +OSyncMember *osync_engine_member_update_get_member(OSyncEngineMemberUpdate *update) +{ + osync_return_val_if_fail(update, NULL); + return update->member; +} +const char *osync_engine_member_update_get_objtype(OSyncEngineMemberUpdate *update) +{ + osync_return_val_if_fail(update, NULL); + return update->objtype; +} + osync_bool osync_engine_abort(OSyncEngine *engine, OSyncError **error) { OSyncError *locerror = NULL; @@ -2546,7 +2616,7 @@ case OSYNC_ENGINE_EVENT_PREPARED_MAP: eventstr = "PREPARE_MAP"; break; - } + } return eventstr; } Modified: trunk/opensync/engine/opensync_engine.h ============================================================================== --- trunk/opensync/engine/opensync_engine.h Sat Mar 28 21:06:04 2009 (r5406) +++ trunk/opensync/engine/opensync_engine.h Sat Mar 28 22:42:14 2009 (r5407) @@ -142,81 +142,26 @@ } OSyncEngineEvent; typedef enum { - OSYNC_CLIENT_EVENT_CONNECTED = 1, - OSYNC_CLIENT_EVENT_CONNECT_DONE, - OSYNC_CLIENT_EVENT_ERROR, - OSYNC_CLIENT_EVENT_READ, - OSYNC_CLIENT_EVENT_WRITTEN, - OSYNC_CLIENT_EVENT_SYNC_DONE, - OSYNC_CLIENT_EVENT_DISCONNECTED, - OSYNC_CLIENT_EVENT_DISCOVERED -} OSyncMemberEvent; + OSYNC_ENGINE_MEMBER_EVENT_CONNECTED = 1, + OSYNC_ENGINE_MEMBER_EVENT_CONNECT_DONE, + OSYNC_ENGINE_MEMBER_EVENT_ERROR, + OSYNC_ENGINE_MEMBER_EVENT_READ, + OSYNC_ENGINE_MEMBER_EVENT_WRITTEN, + OSYNC_ENGINE_MEMBER_EVENT_SYNC_DONE, + OSYNC_ENGINE_MEMBER_EVENT_DISCONNECTED, + OSYNC_ENGINE_MEMBER_EVENT_DISCOVERED +} OSyncEngineMemberEvent; typedef enum { - OSYNC_CHANGE_EVENT_READ = 1, - OSYNC_CHANGE_EVENT_WRITTEN = 2, - OSYNC_CHANGE_EVENT_ERROR = 3 -} OSyncChangeEvent; + OSYNC_ENGINE_CHANGE_EVENT_READ = 1, + OSYNC_ENGINE_CHANGE_EVENT_WRITTEN, + OSYNC_ENGINE_CHANGE_EVENT_ERROR +} OSyncEngineChangeEvent; typedef enum { - OSYNC_MAPPING_EVENT_SOLVED = 1, - //OSYNC_MAPPING_EVENT_WRITTEN = 2, - OSYNC_MAPPING_EVENT_ERROR = 3 -} OSyncMappingEvent; - - -/** - * @brief Struct for the member status callback - */ -typedef struct OSyncMemberUpdate { - /** The type of the status update */ - OSyncMemberEvent type; - char *objtype; - /** The member for which the status update is */ - OSyncMember *member; - /** If the status was a error, this error will be set */ - OSyncError *error; -} OSyncMemberUpdate; - -/** - * @brief Struct for the change status callback - */ -typedef struct OSyncChangeUpdate { - /** The type of the status update */ - OSyncChangeEvent type; - /** The change for which the status update is */ - OSyncChange *change; - /** The id of the member which sent this change */ - OSyncMember *member; - /** The id of the mapping to which this change belongs if any */ - int mapping_id; - /** If the status was a error, this error will be set */ - OSyncError *error; -} OSyncChangeUpdate; - -/** - * @brief Struct for the mapping status callback - */ -typedef struct OSyncMappingUpdate { - /** The type of the status update */ - OSyncMappingEvent type; - /** If the mapping was already solved, this will have the id if the winning entry */ - long long int winner; - /** The mapping for which the status update is */ - OSyncMapping *mapping; - /** If the status was a error, this error will be set */ - OSyncError *error; -} OSyncMappingUpdate; - -/** - * @brief Struct for the engine status callback - */ -typedef struct OSyncEngineUpdate { - /** The type of the status update */ - OSyncEngineEvent type; - /** If the status was a error, this error will be set */ - OSyncError *error; -} OSyncEngineUpdate; + OSYNC_ENGINE_MAPPING_EVENT_SOLVED = 1, + OSYNC_ENGINE_MAPPING_EVENT_ERROR +} OSyncEngineMappingEvent; /** @brief This will create a new engine for the given group * @@ -342,11 +287,27 @@ OSYNC_EXPORT osync_bool osync_engine_continue(OSyncEngine *engine, OSyncError **error); typedef void (* osync_conflict_cb) (OSyncEngine *, OSyncMappingEngine *, void *); -typedef void (* osync_status_change_cb) (OSyncChangeUpdate *, void *); -typedef void (* osync_status_mapping_cb) (OSyncMappingUpdate *, void *); typedef void (* osync_multiply_cb) (OSyncEngine *, void *); -typedef void (* osync_status_member_cb) (OSyncMemberUpdate *, void *); + +typedef void (* osync_status_change_cb) (OSyncEngineChangeUpdate *, void *); +OSYNC_EXPORT OSyncError *osync_engine_change_update_get_error(OSyncEngineChangeUpdate *update); +OSYNC_EXPORT OSyncEngineChangeEvent osync_engine_change_update_get_event(OSyncEngineChangeUpdate *update); +OSYNC_EXPORT OSyncMember *osync_engine_change_update_get_member(OSyncEngineChangeUpdate *update); +OSYNC_EXPORT OSyncChange *osync_engine_change_update_get_change(OSyncEngineChangeUpdate *update); + +typedef void (* osync_status_member_cb) (OSyncEngineMemberUpdate *, void *); +OSYNC_EXPORT OSyncError *osync_engine_member_update_get_error(OSyncEngineMemberUpdate *update); +OSYNC_EXPORT OSyncEngineMemberEvent osync_engine_member_update_get_event(OSyncEngineMemberUpdate *update); +OSYNC_EXPORT OSyncMember *osync_engine_member_update_get_member(OSyncEngineMemberUpdate *update); +OSYNC_EXPORT const char *osync_engine_member_update_get_objtype(OSyncEngineMemberUpdate *update); + +typedef void (* osync_status_mapping_cb) (OSyncEngineMappingUpdate *, void *); +OSYNC_EXPORT OSyncError *osync_engine_mapping_update_get_error(OSyncEngineMappingUpdate *update); +OSYNC_EXPORT OSyncEngineMappingEvent osync_engine_mapping_update_get_event(OSyncEngineMappingUpdate *update); + typedef void (* osync_status_engine_cb) (OSyncEngineUpdate *, void *); +OSYNC_EXPORT OSyncError *osync_engine_update_get_error(OSyncEngineUpdate *update); +OSYNC_EXPORT OSyncEngineEvent osync_engine_update_get_event(OSyncEngineUpdate *update); /** @brief This will set the conflict handler for the given engine * Modified: trunk/opensync/engine/opensync_engine_private.h ============================================================================== --- trunk/opensync/engine/opensync_engine_private.h Sat Mar 28 21:06:04 2009 (r5406) +++ trunk/opensync/engine/opensync_engine_private.h Sat Mar 28 22:42:14 2009 (r5407) @@ -141,6 +141,59 @@ }; /** + * @brief Struct for the member status callback + */ +struct OSyncEngineMemberUpdate { + /** The type of the status update */ + OSyncEngineMemberEvent type; + char *objtype; + /** The member for which the status update is */ + OSyncMember *member; + /** If the status was a error, this error will be set */ + OSyncError *error; +}; + +/** + * @brief Struct for the change status callback + */ +struct OSyncEngineChangeUpdate { + /** The type of the status update */ + OSyncEngineChangeEvent type; + /** The change for which the status update is */ + OSyncChange *change; + /** The id of the member which sent this change */ + OSyncMember *member; + /** The id of the mapping to which this change belongs if any */ + int mapping_id; + /** If the status was a error, this error will be set */ + OSyncError *error; +} ; + +/** + * @brief Struct for the mapping status callback + */ +struct OSyncEngineMappingUpdate { + /** The type of the status update */ + OSyncEngineMappingEvent type; + /** If the mapping was already solved, this will have the id if the winning entry */ + long long int winner; + /** The mapping for which the status update is */ + OSyncMapping *mapping; + /** If the status was a error, this error will be set */ + OSyncError *error; +}; + +/** + * @brief Struct for the engine status callback + */ +struct OSyncEngineUpdate { + /** The type of the status update */ + OSyncEngineEvent type; + /** If the status was a error, this error will be set */ + OSyncError *error; +}; + +/** * @brief Set error for OSyncEngine. * * Stack error message. If an error is already set, the error get stacked. Modified: trunk/opensync/engine/opensync_mapping_engine.c ============================================================================== --- trunk/opensync/engine/opensync_mapping_engine.c Sat Mar 28 21:06:04 2009 (r5406) +++ trunk/opensync/engine/opensync_mapping_engine.c Sat Mar 28 22:42:14 2009 (r5407) @@ -493,7 +493,7 @@ return TRUE; } osync_assert(engine->master); - osync_status_update_mapping(engine->parent->parent, engine, OSYNC_MAPPING_EVENT_SOLVED, NULL); + osync_status_update_mapping(engine->parent->parent, engine, OSYNC_ENGINE_MAPPING_EVENT_SOLVED, NULL); if (is_same == prod(osync_list_length(engine->entries) - 1)) { OSyncList *e = NULL; @@ -583,7 +583,7 @@ entry = _osync_mapping_engine_find_entry(engine, change); engine->conflict = FALSE; osync_mapping_engine_set_master(engine, entry); - osync_status_update_mapping(engine->parent->parent, engine, OSYNC_MAPPING_EVENT_SOLVED, NULL); + osync_status_update_mapping(engine->parent->parent, engine, OSYNC_ENGINE_MAPPING_EVENT_SOLVED, NULL); engine->parent->conflicts = osync_list_remove(engine->parent->conflicts, engine); if (!osync_obj_engine_command(engine->parent, OSYNC_ENGINE_COMMAND_END_CONFLICTS, error)) @@ -619,7 +619,7 @@ osync_archive_save_ignored_conflict(archive, objtype, id, osync_change_get_changetype(entry->change), error); } - osync_status_update_mapping(engine->parent->parent, engine, OSYNC_MAPPING_EVENT_SOLVED, NULL); + osync_status_update_mapping(engine->parent->parent, engine, OSYNC_ENGINE_MAPPING_EVENT_SOLVED, NULL); engine->parent->conflicts = osync_list_remove(engine->parent->conflicts, engine); if (!osync_obj_engine_command(engine->parent, OSYNC_ENGINE_COMMAND_END_CONFLICTS, error)) @@ -646,7 +646,7 @@ osync_mapping_engine_set_master(engine, latest_entry); engine->conflict = FALSE; - osync_status_update_mapping(engine->parent->parent, engine, OSYNC_MAPPING_EVENT_SOLVED, NULL); + osync_status_update_mapping(engine->parent->parent, engine, OSYNC_ENGINE_MAPPING_EVENT_SOLVED, NULL); engine->parent->conflicts = osync_list_remove(engine->parent->conflicts, engine); if (!osync_obj_engine_command(engine->parent, OSYNC_ENGINE_COMMAND_END_CONFLICTS, error)) @@ -785,7 +785,7 @@ } objengine->conflicts = osync_list_remove(objengine->conflicts, existingMapping); - osync_status_update_mapping(objengine->parent, existingMapping, OSYNC_MAPPING_EVENT_SOLVED, NULL); + osync_status_update_mapping(objengine->parent, existingMapping, OSYNC_ENGINE_MAPPING_EVENT_SOLVED, NULL); if (!osync_obj_engine_command(objengine, OSYNC_ENGINE_COMMAND_END_CONFLICTS, error)) goto error; Modified: trunk/opensync/engine/opensync_obj_engine.c ============================================================================== --- trunk/opensync/engine/opensync_obj_engine.c Sat Mar 28 21:06:04 2009 (r5406) +++ trunk/opensync/engine/opensync_obj_engine.c Sat Mar 28 22:42:14 2009 (r5407) @@ -95,10 +95,10 @@ osync_trace(TRACE_INTERNAL, "Obj Engine received connect error: %s", osync_error_print(&error)); osync_obj_engine_set_error(engine, error); engine->sink_errors = engine->sink_errors | (0x1 << sinkengine->position); - osync_status_update_member(engine->parent, osync_client_proxy_get_member(proxy), OSYNC_CLIENT_EVENT_ERROR, engine->objtype, error); + osync_status_update_member(engine->parent, osync_client_proxy_get_member(proxy), OSYNC_ENGINE_MEMBER_EVENT_ERROR, engine->objtype, error); } else { engine->sink_connects = engine->sink_connects | (0x1 << sinkengine->position); - osync_status_update_member(engine->parent, osync_client_proxy_get_member(proxy), OSYNC_CLIENT_EVENT_CONNECTED, engine->objtype, NULL); + osync_status_update_member(engine->parent, osync_client_proxy_get_member(proxy), OSYNC_ENGINE_MEMBER_EVENT_CONNECTED, engine->objtype, NULL); } if (slowsync) { @@ -131,10 +131,10 @@ if (error) { osync_obj_engine_set_error(engine, error); engine->sink_errors = engine->sink_errors | (0x1 << sinkengine->position); - osync_status_update_member(engine->parent, osync_client_proxy_get_member(proxy), OSYNC_CLIENT_EVENT_ERROR, engine->objtype, error); + osync_status_update_member(engine->parent, osync_client_proxy_get_member(proxy), OSYNC_ENGINE_MEMBER_EVENT_ERROR, engine->objtype, error); } else { engine->sink_connect_done = engine->sink_connect_done | (0x1 << sinkengine->position); - osync_status_update_member(engine->parent, osync_client_proxy_get_member(proxy), OSYNC_CLIENT_EVENT_CONNECT_DONE, engine->objtype, NULL); + osync_status_update_member(engine->parent, osync_client_proxy_get_member(proxy), OSYNC_ENGINE_MEMBER_EVENT_CONNECT_DONE, engine->objtype, NULL); } if (osync_bitcount(engine->sink_errors | engine->sink_connect_done) == osync_obj_engine_num_sinkengines(engine)) { @@ -183,10 +183,10 @@ if (error) { osync_obj_engine_set_error(engine, error); engine->sink_errors = engine->sink_errors | (0x1 << sinkengine->position); - osync_status_update_member(engine->parent, osync_client_proxy_get_member(proxy), OSYNC_CLIENT_EVENT_ERROR, engine->objtype, error); + osync_status_update_member(engine->parent, osync_client_proxy_get_member(proxy), OSYNC_ENGINE_MEMBER_EVENT_ERROR, engine->objtype, error); } else { engine->sink_disconnects = engine->sink_disconnects | (0x1 << sinkengine->position); - osync_status_update_member(engine->parent, osync_client_proxy_get_member(proxy), OSYNC_CLIENT_EVENT_DISCONNECTED, engine->objtype, NULL); + osync_status_update_member(engine->parent, osync_client_proxy_get_member(proxy), OSYNC_ENGINE_MEMBER_EVENT_DISCONNECTED, engine->objtype, NULL); } _osync_obj_engine_generate_event_disconnected(engine, error); @@ -368,10 +368,10 @@ if (error) { osync_obj_engine_set_error(engine, error); engine->sink_errors = engine->sink_errors | (0x1 << sinkengine->position); - osync_status_update_member(engine->parent, osync_client_proxy_get_member(proxy), OSYNC_CLIENT_EVENT_ERROR, engine->objtype, error); + osync_status_update_member(engine->parent, osync_client_proxy_get_member(proxy), OSYNC_ENGINE_MEMBER_EVENT_ERROR, engine->objtype, error); } else { engine->sink_get_changes = engine->sink_get_changes | (0x1 << sinkengine->position); - osync_status_update_member(engine->parent, osync_client_proxy_get_member(proxy), OSYNC_CLIENT_EVENT_READ, engine->objtype, NULL); + osync_status_update_member(engine->parent, osync_client_proxy_get_member(proxy), OSYNC_ENGINE_MEMBER_EVENT_READ, engine->objtype, NULL); } if (osync_bitcount(engine->sink_errors | engine->sink_get_changes) == osync_obj_engine_num_sinkengines(engine)) { @@ -414,14 +414,14 @@ if (osync_entry_engine_matches(mapping_engine, change)) { osync_entry_engine_update(mapping_engine, change); - osync_status_update_change(sinkengine->engine->parent, change, osync_client_proxy_get_member(proxy), mapping_engine->mapping_engine->mapping, OSYNC_CHANGE_EVENT_READ, NULL); + osync_status_update_change(sinkengine->engine->parent, change, osync_client_proxy_get_member(proxy), mapping_engine->mapping_engine->mapping, OSYNC_ENGINE_CHANGE_EVENT_READ, NULL); osync_trace(TRACE_EXIT, "%s: Updated", __func__); return TRUE; } } - osync_status_update_change(sinkengine->engine->parent, change, osync_client_proxy_get_member(proxy), NULL, OSYNC_CHANGE_EVENT_READ, NULL); + osync_status_update_change(sinkengine->engine->parent, change, osync_client_proxy_get_member(proxy), NULL, OSYNC_ENGINE_CHANGE_EVENT_READ, NULL); /* If we couldnt find a match entry, we will append it the unmapped changes * and take care of it later */ @@ -530,8 +530,8 @@ /* Error handling (tests: single_commit_error, ...) */ /* TODO: Review differences between Mapping and Change status events - Are both really needed?! */ - osync_status_update_change(engine->parent, entry_engine->change, osync_client_proxy_get_member(proxy), entry_engine->mapping_engine->mapping, OSYNC_CHANGE_EVENT_ERROR, error); - osync_status_update_mapping(engine->parent, entry_engine->mapping_engine, OSYNC_MAPPING_EVENT_ERROR, error); + osync_status_update_change(engine->parent, entry_engine->change, osync_client_proxy_get_member(proxy), entry_engine->mapping_engine->mapping, OSYNC_ENGINE_CHANGE_EVENT_ERROR, error); + osync_status_update_mapping(engine->parent, entry_engine->mapping_engine, OSYNC_ENGINE_MAPPING_EVENT_ERROR, error); osync_obj_engine_set_error(engine, error); engine->sink_errors = engine->sink_errors | (0x1 << sinkengine->position); @@ -553,7 +553,7 @@ } osync_assert(entry_engine->mapping_engine); - osync_status_update_change(engine->parent, entry_engine->change, osync_client_proxy_get_member(proxy), entry_engine->mapping_engine->mapping, OSYNC_CHANGE_EVENT_WRITTEN, NULL); + osync_status_update_change(engine->parent, entry_engine->change, osync_client_proxy_get_member(proxy), entry_engine->mapping_engine->mapping, OSYNC_ENGINE_CHANGE_EVENT_WRITTEN, NULL); osync_entry_engine_update(entry_engine, NULL); osync_trace(TRACE_EXIT, "%s", __func__); @@ -574,10 +574,10 @@ if (error) { osync_obj_engine_set_error(engine, error); engine->sink_errors = engine->sink_errors | (0x1 << sinkengine->position); - osync_status_update_member(engine->parent, osync_client_proxy_get_member(proxy), OSYNC_CLIENT_EVENT_ERROR, engine->objtype, error); + osync_status_update_member(engine->parent, osync_client_proxy_get_member(proxy), OSYNC_ENGINE_MEMBER_EVENT_ERROR, engine->objtype, error); } else { engine->sink_written = engine->sink_written | (0x1 << sinkengine->position); - osync_status_update_member(engine->parent, osync_client_proxy_get_member(proxy), OSYNC_CLIENT_EVENT_WRITTEN, engine->objtype, NULL); + osync_status_update_member(engine->parent, osync_client_proxy_get_member(proxy), OSYNC_ENGINE_MEMBER_EVENT_WRITTEN, engine->objtype, NULL); } _osync_obj_engine_generate_written_event(engine, error); @@ -596,10 +596,10 @@ if (error) { osync_obj_engine_set_error(engine, error); engine->sink_errors = engine->sink_errors | (0x1 << sinkengine->position); - osync_status_update_member(engine->parent, osync_client_proxy_get_member(proxy), OSYNC_CLIENT_EVENT_ERROR, engine->objtype, error); + osync_status_update_member(engine->parent, osync_client_proxy_get_member(proxy), OSYNC_ENGINE_MEMBER_EVENT_ERROR, engine->objtype, error); } else { engine->sink_sync_done = engine->sink_sync_done | (0x1 << sinkengine->position); - osync_status_update_member(engine->parent, osync_client_proxy_get_member(proxy), OSYNC_CLIENT_EVENT_SYNC_DONE, engine->objtype, NULL); + osync_status_update_member(engine->parent, osync_client_proxy_get_member(proxy), OSYNC_ENGINE_MEMBER_EVENT_SYNC_DONE, engine->objtype, NULL); } if (osync_bitcount(engine->sink_errors | engine->sink_sync_done) == osync_obj_engine_num_sinkengines(engine)) { Modified: trunk/opensync/engine/opensync_status.c ============================================================================== --- trunk/opensync/engine/opensync_status.c Sat Mar 28 21:06:04 2009 (r5406) +++ trunk/opensync/engine/opensync_status.c Sat Mar 28 22:42:14 2009 (r5407) @@ -32,7 +32,7 @@ #include "opensync_mapping_engine_internals.h" -void osync_status_free_member_update(OSyncMemberUpdate *update) +void osync_status_free_member_update(OSyncEngineMemberUpdate *update) { osync_assert(update); @@ -57,7 +57,7 @@ osync_free(update); } -void osync_status_free_change_update(OSyncChangeUpdate *update) +void osync_status_free_change_update(OSyncEngineChangeUpdate *update) { osync_assert(update); @@ -72,7 +72,7 @@ osync_free(update); } -void osync_status_free_mapping_update(OSyncMappingUpdate *update) +void osync_status_free_mapping_update(OSyncEngineMappingUpdate *update) { osync_assert(update); @@ -116,13 +116,13 @@ osync_trace(TRACE_EXIT, "%s", __func__); } -void osync_status_update_member(OSyncEngine *engine, OSyncMember *member, OSyncMemberEvent type, const char *objtype, OSyncError *error) +void osync_status_update_member(OSyncEngine *engine, OSyncMember *member, OSyncEngineMemberEvent type, const char *objtype, OSyncError *error) { osync_trace(TRACE_ENTRY, "%s(%p, %p, %i, %s, %p)", __func__, engine, member, type, objtype, error); if (engine->mebstat_callback) { OSyncError *internal_error = NULL; - OSyncMemberUpdate *update = osync_try_malloc0(sizeof(OSyncMemberUpdate), &internal_error); + OSyncEngineMemberUpdate *update = osync_try_malloc0(sizeof(OSyncEngineMemberUpdate), &internal_error); if (!update) { osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&internal_error)); osync_error_unref(&internal_error); @@ -148,13 +148,13 @@ osync_trace(TRACE_EXIT, "%s", __func__); } -void osync_status_update_change(OSyncEngine *engine, OSyncChange *change, OSyncMember *member, OSyncMapping *mapping, OSyncChangeEvent type, OSyncError *error) +void osync_status_update_change(OSyncEngine *engine, OSyncChange *change, OSyncMember *member, OSyncMapping *mapping, OSyncEngineChangeEvent type, OSyncError *error) { osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p, %i, %p)", __func__, engine, change, member, mapping, type, error); if (engine->changestat_callback) { OSyncError *internal_error = NULL; - OSyncChangeUpdate *update = osync_try_malloc0(sizeof(OSyncChangeUpdate), &internal_error); + OSyncEngineChangeUpdate *update = osync_try_malloc0(sizeof(OSyncEngineChangeUpdate), &internal_error); if (!update) { osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&internal_error)); osync_error_unref(&internal_error); @@ -181,13 +181,13 @@ osync_trace(TRACE_EXIT, "%s", __func__); } -void osync_status_update_mapping(OSyncEngine *engine, OSyncMappingEngine *mapping, OSyncMappingEvent type, OSyncError *error) +void osync_status_update_mapping(OSyncEngine *engine, OSyncMappingEngine *mapping, OSyncEngineMappingEvent type, OSyncError *error) { osync_trace(TRACE_ENTRY, "%s(%p, %p, %i, %p)", __func__, engine, mapping, type, error); if (engine->mapstat_callback) { OSyncError *internal_error = NULL; - OSyncMappingUpdate *update = osync_try_malloc0(sizeof(OSyncMappingUpdate), &internal_error); + OSyncEngineMappingUpdate *update = osync_try_malloc0(sizeof(OSyncEngineMappingUpdate), &internal_error); if (!update) { osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&internal_error)); osync_error_unref(&internal_error); Modified: trunk/opensync/engine/opensync_status_internals.h ============================================================================== --- trunk/opensync/engine/opensync_status_internals.h Sat Mar 28 21:06:04 2009 (r5406) +++ trunk/opensync/engine/opensync_status_internals.h Sat Mar 28 22:42:14 2009 (r5407) @@ -29,17 +29,17 @@ /*@{*/ -void osync_status_free_member_update(OSyncMemberUpdate *update); +void osync_status_free_member_update(OSyncEngineMemberUpdate *update); void osync_status_free_engine_update(OSyncEngineUpdate *update); -void osync_status_free_change_update(OSyncChangeUpdate *update); -void osync_status_free_mapping_update(OSyncMappingUpdate *update); +void osync_status_free_change_update(OSyncEngineChangeUpdate *update); +void osync_status_free_mapping_update(OSyncEngineMappingUpdate *update); -void osync_status_update_member(OSyncEngine *engine, OSyncMember *member, OSyncMemberEvent type, const char *objtype, OSyncError *error); +void osync_status_update_member(OSyncEngine *engine, OSyncMember *member, OSyncEngineMemberEvent type, const char *objtype, OSyncError *error); void osync_status_update_engine(OSyncEngine *engine, OSyncEngineEvent type, OSyncError *error); -void osync_status_update_change(OSyncEngine *engine, OSyncChange *change, OSyncMember *member, OSyncMapping *mapping, OSyncChangeEvent type, OSyncError *error); +void osync_status_update_change(OSyncEngine *engine, OSyncChange *change, OSyncMember *member, OSyncMapping *mapping, OSyncEngineChangeEvent type, OSyncError *error); -void osync_status_update_mapping(OSyncEngine *engine, OSyncMappingEngine *mapping, OSyncMappingEvent type, OSyncError *error); +void osync_status_update_mapping(OSyncEngine *engine, OSyncMappingEngine *mapping, OSyncEngineMappingEvent type, OSyncError *error); /** * @brief Send conflict status for a mapping Modified: trunk/opensync/opensync.h ============================================================================== --- trunk/opensync/opensync.h Sat Mar 28 21:06:04 2009 (r5406) +++ trunk/opensync/opensync.h Sat Mar 28 22:42:14 2009 (r5407) @@ -217,6 +217,11 @@ typedef struct OSyncMappingEntryEngine OSyncMappingEntryEngine; typedef struct OSyncMappingEngine OSyncMappingEngine; +typedef struct OSyncEngineMemberUpdate OSyncEngineMemberUpdate; +typedef struct OSyncEngineChangeUpdate OSyncEngineChangeUpdate; +typedef struct OSyncEngineMappingUpdate OSyncEngineMappingUpdate; +typedef struct OSyncEngineUpdate OSyncEngineUpdate; + /* Client component */ typedef struct OSyncClient OSyncClient; typedef struct OSyncClientProxy OSyncClientProxy; Modified: trunk/tests/support.c ============================================================================== --- trunk/tests/support.c Sat Mar 28 21:06:04 2009 (r5406) +++ trunk/tests/support.c Sat Mar 28 22:42:14 2009 (r5407) @@ -298,83 +298,86 @@ g_free(content); } -void member_status(OSyncMemberUpdate *status, void *user_data) +void member_status(OSyncEngineMemberUpdate *status, void *user_data) { - osync_trace(TRACE_ENTRY, "%s(%p (%i), %p)", __func__, status, status->type, user_data); + osync_trace(TRACE_ENTRY, "%s(%p), %p)", __func__, status, user_data); fail_unless(GINT_TO_POINTER(1) == user_data, NULL); + + OSyncError *error = osync_engine_member_update_get_error(status); + const char *objtype = osync_engine_member_update_get_objtype(status); - switch (status->type) { - case OSYNC_CLIENT_EVENT_CONNECTED: - fail_unless(!osync_error_is_set(&(status->error)), NULL); + switch (osync_engine_member_update_get_event(status)) { + case OSYNC_ENGINE_MEMBER_EVENT_CONNECTED: + fail_unless(!osync_error_is_set(&(error)), NULL); - if (status->objtype == NULL) { + if (objtype == NULL) { num_client_main_connected++; } else { - fail_unless(!strncmp(status->objtype, "mockobjtype", 11), NULL); + fail_unless(!strncmp(objtype, "mockobjtype", 11), NULL); num_client_connected++; } break; - case OSYNC_CLIENT_EVENT_CONNECT_DONE: - fail_unless(!osync_error_is_set(&(status->error)), NULL); + case OSYNC_ENGINE_MEMBER_EVENT_CONNECT_DONE: + fail_unless(!osync_error_is_set(&(error)), NULL); - if (status->objtype == NULL) { + if (objtype == NULL) { num_client_main_connect_done++; } else { - fail_unless(!strncmp(status->objtype, "mockobjtype", 11), NULL); + fail_unless(!strncmp(objtype, "mockobjtype", 11), NULL); num_client_connect_done++; } break; - case OSYNC_CLIENT_EVENT_DISCONNECTED: - fail_unless(!osync_error_is_set(&(status->error)), NULL); + case OSYNC_ENGINE_MEMBER_EVENT_DISCONNECTED: + fail_unless(!osync_error_is_set(&(error)), NULL); - if (status->objtype == NULL) { + if (objtype == NULL) { num_client_main_disconnected++; } else { - fail_unless(!strncmp(status->objtype, "mockobjtype", 11), NULL); + fail_unless(!strncmp(objtype, "mockobjtype", 11), NULL); num_client_disconnected++; } break; - case OSYNC_CLIENT_EVENT_READ: - fail_unless(!osync_error_is_set(&(status->error)), NULL); + case OSYNC_ENGINE_MEMBER_EVENT_READ: + fail_unless(!osync_error_is_set(&(error)), NULL); - if (status->objtype == NULL) { + if (objtype == NULL) { num_client_main_read++; } else { - fail_unless(!strncmp(status->objtype, "mockobjtype", 11), NULL); + fail_unless(!strncmp(objtype, "mockobjtype", 11), NULL); num_client_read++; } break; - case OSYNC_CLIENT_EVENT_WRITTEN: - fail_unless(!osync_error_is_set(&(status->error)), NULL); + case OSYNC_ENGINE_MEMBER_EVENT_WRITTEN: + fail_unless(!osync_error_is_set(&(error)), NULL); - if (status->objtype == NULL) { + if (objtype == NULL) { num_client_main_written++; } else { - fail_unless(!strncmp(status->objtype, "mockobjtype", 11), NULL); + fail_unless(!strncmp(objtype, "mockobjtype", 11), NULL); num_client_written++; } break; - case OSYNC_CLIENT_EVENT_ERROR: - fail_unless(osync_error_is_set(&(status->error)), NULL); + case OSYNC_ENGINE_MEMBER_EVENT_ERROR: + fail_unless(osync_error_is_set(&(error)), NULL); num_client_errors++; break; - case OSYNC_CLIENT_EVENT_SYNC_DONE: - fail_unless(!osync_error_is_set(&(status->error)), NULL); + case OSYNC_ENGINE_MEMBER_EVENT_SYNC_DONE: + fail_unless(!osync_error_is_set(&(error)), NULL); - if (status->objtype == NULL) { + if (objtype == NULL) { num_client_main_sync_done++; } else { - fail_unless(!strncmp(status->objtype, "mockobjtype", 11), NULL); + fail_unless(!strncmp(objtype, "mockobjtype", 11), NULL); num_client_sync_done++; } break; - case OSYNC_CLIENT_EVENT_DISCOVERED: - fail_unless(!osync_error_is_set(&(status->error)), NULL); + case OSYNC_ENGINE_MEMBER_EVENT_DISCOVERED: + fail_unless(!osync_error_is_set(&(error)), NULL); num_client_discovered++; break; } @@ -382,21 +385,23 @@ osync_trace(TRACE_EXIT, "%s", __func__); } -void entry_status(OSyncChangeUpdate *status, void *user_data) +void entry_status(OSyncEngineChangeUpdate *status, void *user_data) { - osync_trace(TRACE_ENTRY, "%s(%p (%i), %p)", __func__, status, status->type, user_data); + osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, status, user_data); + + OSyncError *error = osync_engine_change_update_get_error(status); - switch (status->type) { - case OSYNC_CHANGE_EVENT_READ: - fail_unless(!osync_error_is_set(&(status->error)), NULL); + switch (osync_engine_change_update_get_event(status)) { + case OSYNC_ENGINE_CHANGE_EVENT_READ: + fail_unless(!osync_error_is_set(&(error)), NULL); num_change_read++; break; - case OSYNC_CHANGE_EVENT_WRITTEN: - fail_unless(!osync_error_is_set(&(status->error)), NULL); + case OSYNC_ENGINE_CHANGE_EVENT_WRITTEN: + fail_unless(!osync_error_is_set(&(error)), NULL); num_change_written++; break; - case OSYNC_CHANGE_EVENT_ERROR: - fail_unless(osync_error_is_set(&(status->error)), NULL); + case OSYNC_ENGINE_CHANGE_EVENT_ERROR: + fail_unless(osync_error_is_set(&(error)), NULL); num_change_error++; break; } @@ -406,62 +411,65 @@ void engine_status(OSyncEngineUpdate *status, void *user_data) { - osync_trace(TRACE_ENTRY, "%s(%p(%i), %p)", __func__, status, status->type, user_data); - switch (status->type) { + osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, status, user_data); + + OSyncError *error = osync_engine_update_get_error(status); + + switch (osync_engine_update_get_event(status)) { case OSYNC_ENGINE_EVENT_CONNECTED: - fail_unless(!osync_error_is_set(&(status->error)), NULL); + fail_unless(!osync_error_is_set(&(error)), NULL); num_engine_connected++; break; case OSYNC_ENGINE_EVENT_CONNECT_DONE: - fail_unless(!osync_error_is_set(&(status->error)), NULL); + fail_unless(!osync_error_is_set(&(error)), NULL); num_engine_connect_done++; break; case OSYNC_ENGINE_EVENT_READ: - fail_unless(!osync_error_is_set(&(status->error)), NULL); + fail_unless(!osync_error_is_set(&(error)), NULL); num_engine_read++; break; case OSYNC_ENGINE_EVENT_PREPARED_MAP: - fail_unless(!osync_error_is_set(&(status->error)), NULL); + fail_unless(!osync_error_is_set(&(error)), NULL); num_engine_prepared_map++; break; case OSYNC_ENGINE_EVENT_MAPPED: - fail_unless(!osync_error_is_set(&(status->error)), NULL); + fail_unless(!osync_error_is_set(&(error)), NULL); num_engine_mapped++; break; case OSYNC_ENGINE_EVENT_MULTIPLIED: - fail_unless(!osync_error_is_set(&(status->error)), NULL); + fail_unless(!osync_error_is_set(&(error)), NULL); num_engine_multiplied++; break; case OSYNC_ENGINE_EVENT_PREPARED_WRITE: - fail_unless(!osync_error_is_set(&(status->error)), NULL); + fail_unless(!osync_error_is_set(&(error)), NULL); num_engine_prepared_write++; break; case OSYNC_ENGINE_EVENT_WRITTEN: - fail_unless(!osync_error_is_set(&(status->error)), NULL); + fail_unless(!osync_error_is_set(&(error)), NULL); num_engine_written++; break; case OSYNC_ENGINE_EVENT_DISCONNECTED: - fail_unless(!osync_error_is_set(&(status->error)), NULL); + fail_unless(!osync_error_is_set(&(error)), NULL); num_engine_disconnected++; break; case OSYNC_ENGINE_EVENT_ERROR: - fail_unless(osync_error_is_set(&(status->error)), NULL); + fail_unless(osync_error_is_set(&(error)), NULL); num_engine_errors++; break; case OSYNC_ENGINE_EVENT_SUCCESSFUL: - fail_unless(!osync_error_is_set(&(status->error)), NULL); + fail_unless(!osync_error_is_set(&(error)), NULL); num_engine_successful++; break; case OSYNC_ENGINE_EVENT_PREV_UNCLEAN: - fail_unless(!osync_error_is_set(&(status->error)), NULL); + fail_unless(!osync_error_is_set(&(error)), NULL); num_engine_prev_unclean++; break; case OSYNC_ENGINE_EVENT_END_CONFLICTS: - fail_unless(!osync_error_is_set(&(status->error)), NULL); + fail_unless(!osync_error_is_set(&(error)), NULL); num_engine_end_conflicts++; break; case OSYNC_ENGINE_EVENT_SYNC_DONE: - fail_unless(!osync_error_is_set(&(status->error)), NULL); + fail_unless(!osync_error_is_set(&(error)), NULL); num_engine_sync_done++; break; } @@ -469,19 +477,21 @@ osync_trace(TRACE_EXIT, "%s", __func__); } -void mapping_status(OSyncMappingUpdate *status, void *user_data) +void mapping_status(OSyncEngineMappingUpdate *status, void *user_data) { - switch (status->type) { - case OSYNC_MAPPING_EVENT_SOLVED: - fail_unless(!osync_error_is_set(&(status->error)), NULL); + OSyncError *error = osync_engine_mapping_update_get_error(status); + + switch (osync_engine_mapping_update_get_event(status)) { + case OSYNC_ENGINE_MAPPING_EVENT_SOLVED: + fail_unless(!osync_error_is_set(&(error)), NULL); num_mapping_solved++; break; - /*case OSYNC_MAPPING_EVENT_WRITTEN: - fail_unless(!osync_error_is_set(&(status->error)), NULL); + /*case OSYNC_ENGINE_MAPPING_EVENT_WRITTEN: + fail_unless(!osync_error_is_set(&(error)), NULL); num_mapping_written++; break;*/ - case OSYNC_MAPPING_EVENT_ERROR: - fail_unless(osync_error_is_set(&(status->error)), NULL); + case OSYNC_ENGINE_MAPPING_EVENT_ERROR: + fail_unless(osync_error_is_set(&(error)), NULL); num_mapping_errors++; break; } Modified: trunk/tests/support.h ============================================================================== --- trunk/tests/support.h Sat Mar 28 21:06:04 2009 (r5406) +++ trunk/tests/support.h Sat Mar 28 22:42:14 2009 (r5407) @@ -107,10 +107,10 @@ void discover_all_once(OSyncEngine *engine, OSyncError **error); /* Status callbacks */ -void member_status(OSyncMemberUpdate *status, void *user_data); -void entry_status(OSyncChangeUpdate *status, void *user_data); +void member_status(OSyncEngineMemberUpdate *status, void *user_data); +void entry_status(OSyncEngineChangeUpdate *status, void *user_data); void engine_status(OSyncEngineUpdate *status, void *user_data); -void mapping_status(OSyncMappingUpdate *status, void *user_data); +void mapping_status(OSyncEngineMappingUpdate *status, void *user_data); /* Conflict handlers */ void conflict_handler_choose_first(OSyncEngine *engine, OSyncMappingEngine *mapping, void *user_data); Modified: trunk/wrapper/opensync-engine.i ============================================================================== --- trunk/wrapper/opensync-engine.i Sat Mar 28 21:06:04 2009 (r5406) +++ trunk/wrapper/opensync-engine.i Sat Mar 28 22:42:14 2009 (r5407) @@ -28,22 +28,22 @@ %constant int ENGINE_EVENT_PREV_UNCLEAN = OSYNC_ENGINE_EVENT_PREV_UNCLEAN; typedef enum {} MemberEvent; -%constant int CLIENT_EVENT_CONNECTED = OSYNC_CLIENT_EVENT_CONNECTED; -%constant int CLIENT_EVENT_ERROR = OSYNC_CLIENT_EVENT_ERROR; -%constant int CLIENT_EVENT_READ = OSYNC_CLIENT_EVENT_READ; -%constant int CLIENT_EVENT_WRITTEN = OSYNC_CLIENT_EVENT_WRITTEN; -%constant int CLIENT_EVENT_SYNC_DONE = OSYNC_CLIENT_EVENT_SYNC_DONE; -%constant int CLIENT_EVENT_DISCONNECTED = OSYNC_CLIENT_EVENT_DISCONNECTED; -%constant int CLIENT_EVENT_DISCOVERED = OSYNC_CLIENT_EVENT_DISCOVERED; +%constant int ENGINE_MEMBER_EVENT_CONNECTED = OSYNC_ENGINE_MEMBER_EVENT_CONNECTED; +%constant int ENGINE_MEMBER_EVENT_ERROR = OSYNC_ENGINE_MEMBER_EVENT_ERROR; +%constant int ENGINE_MEMBER_EVENT_READ = OSYNC_ENGINE_MEMBER_EVENT_READ; +%constant int ENGINE_MEMBER_EVENT_WRITTEN = OSYNC_ENGINE_MEMBER_EVENT_WRITTEN; +%constant int ENGINE_MEMBER_EVENT_SYNC_DONE = OSYNC_ENGINE_MEMBER_EVENT_SYNC_DONE; +%constant int ENGINE_MEMBER_EVENT_DISCONNECTED = OSYNC_ENGINE_MEMBER_EVENT_DISCONNECTED; +%constant int ENGINE_MEMBER_EVENT_DISCOVERED = OSYNC_ENGINE_MEMBER_EVENT_DISCOVERED; typedef enum {} ChangeEvent; -%constant int CHANGE_EVENT_READ = OSYNC_CHANGE_EVENT_READ; -%constant int CHANGE_EVENT_WRITTEN = OSYNC_CHANGE_EVENT_WRITTEN; -%constant int CHANGE_EVENT_ERROR = OSYNC_CHANGE_EVENT_ERROR; +%constant int ENGINE_CHANGE_EVENT_READ = OSYNC_ENGINE_CHANGE_EVENT_READ; +%constant int ENGINE_CHANGE_EVENT_WRITTEN = OSYNC_ENGINE_CHANGE_EVENT_WRITTEN; +%constant int ENGINE_CHANGE_EVENT_ERROR = OSYNC_ENGINE_CHANGE_EVENT_ERROR; typedef enum {} MappingEvent; -%constant int MAPPING_EVENT_SOLVED = OSYNC_MAPPING_EVENT_SOLVED; -%constant int MAPPING_EVENT_ERROR = OSYNC_MAPPING_EVENT_ERROR; +%constant int ENGINE_MAPPING_EVENT_SOLVED = OSYNC_ENGINE_MAPPING_EVENT_SOLVED; +%constant int ENGINE_MAPPING_EVENT_ERROR = OSYNC_ENGINE_MAPPING_EVENT_ERROR; /* modified from SWIG docs, typemap to pass a python callable (function) object */ %typemap(in) PyObject *pyfunc { @@ -176,9 +176,12 @@ static void enginestatus_cb_wrapper(OSyncEngineUpdate *arg, void *clientdata) { PyGILState_STATE pystate = PyGILState_Ensure(); + OSyncError *error = osync_engine_update_get_error(arg); + OSyncEngineEvent event = osync_engine_update_get_event(arg); + PyObject *pyfunc = clientdata; - PyObject *errobj = SWIG_NewPointerObj(arg->error, SWIGTYPE_p_Error, 0); - PyObject *args = Py_BuildValue("(iO)", arg->type, errobj); + PyObject *errobj = SWIG_NewPointerObj(error, SWIGTYPE_p_Error, 0); + PyObject *args = Py_BuildValue("(iO)", event, errobj); PyObject *result = PyEval_CallObject(pyfunc, args); Py_DECREF(args); Py_XDECREF(result); |
From: <svn...@op...> - 2009-03-28 20:06:12
|
Author: dgollub Date: Sat Mar 28 21:06:04 2009 New Revision: 5406 URL: http://www.opensync.org/changeset/5406 Log: Remove osync_remove_directory_recursively() from the public installed header. This function wasn't exported but got isntalled with the public headers. Added: trunk/opensync/common/opensync_file_internals.h Modified: trunk/opensync/common/opensync_file.h trunk/opensync/group/opensync_updater.c Modified: trunk/opensync/common/opensync_file.h ============================================================================== --- trunk/opensync/common/opensync_file.h Sat Mar 28 20:58:10 2009 (r5405) +++ trunk/opensync/common/opensync_file.h Sat Mar 28 21:06:04 2009 (r5406) @@ -56,18 +56,6 @@ */ OSYNC_EXPORT osync_bool osync_file_read(const char *filename, char **data, unsigned int *size, OSyncError **error); -/** @brief Removes a directory recursively - * - * Removes a directory recursively. This is an - * internal function for portability. - * - * @param dirname Directory which will be deleted - * @returns 0 if successful, -1 otherwise - * - */ - -int osync_remove_directory_recursively(const char *dirname); - /*@} */ #endif /* _OPENSYNC_FILE_H */ Added: trunk/opensync/common/opensync_file_internals.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/opensync/common/opensync_file_internals.h Sat Mar 28 21:06:04 2009 (r5406) @@ -0,0 +1,47 @@ +/* + * libopensync - A synchronization framework + * Copyright (C) 2004-2005 Armin Bauer <arm...@op...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef _OPENSYNC_FILE_INTERNALS_H +#define _OPENSYNC_FILE_INTERNALS_H + +/** + * @defgroup OSyncFileInternalAPI OpenSync File + * @ingroup OSyncCommonPrivate + * @brief Functions for handling common file operations + */ + +/*@{*/ + +/** @brief Removes a directory recursively + * + * Removes a directory recursively. This is an + * internal function for portability. + * + * @param dirname Directory which will be deleted + * @returns 0 if successful, -1 otherwise + * + */ + +int osync_remove_directory_recursively(const char *dirname); + +/*@} */ + +#endif /* _OPENSYNC_FILE_INTERNALS_H */ + Modified: trunk/opensync/group/opensync_updater.c ============================================================================== --- trunk/opensync/group/opensync_updater.c Sat Mar 28 20:58:10 2009 (r5405) +++ trunk/opensync/group/opensync_updater.c Sat Mar 28 21:06:04 2009 (r5406) @@ -38,6 +38,7 @@ #include "common/opensync_xml_internals.h" #include "common/opensync_file.h" +#include "common/opensync_file_internals.h" #include "opensync_updater.h" #include "opensync_updater_private.h" |
From: <svn...@op...> - 2009-03-28 19:58:27
|
Author: dgollub Date: Sat Mar 28 20:58:10 2009 New Revision: 5405 URL: http://www.opensync.org/changeset/5405 Log: Remove gmtime_r and localtime_r, which are only used internally, from the public API header. Added: trunk/opensync/format/opensync_time_internals.h Modified: trunk/opensync/format/opensync_time.c trunk/opensync/format/opensync_time.h trunk/tests/format-tests/check_time.c Modified: trunk/opensync/format/opensync_time.c ============================================================================== --- trunk/opensync/format/opensync_time.c Sat Mar 28 20:50:04 2009 (r5404) +++ trunk/opensync/format/opensync_time.c Sat Mar 28 20:58:10 2009 (r5405) @@ -24,6 +24,7 @@ #include "opensync.h" #include "opensync_time.h" +#include "opensync_time_internals.h" #include "opensync_time_private.h" #include "opensync_internals.h" Modified: trunk/opensync/format/opensync_time.h ============================================================================== --- trunk/opensync/format/opensync_time.h Sat Mar 28 20:50:04 2009 (r5404) +++ trunk/opensync/format/opensync_time.h Sat Mar 28 20:58:10 2009 (r5405) @@ -349,14 +349,6 @@ */ OSYNC_EXPORT struct tm *osync_time_relative2tm(const char *byday, const int bymonth, const int year); -#ifdef _WIN32 -/* Windows does not provide gmtime_r and localtime_r */ -/* This module uses these two functions internally */ -/* They are also exported for testing purposes */ -OSYNC_TEST_EXPORT inline struct tm* gmtime_r (const time_t *clock, struct tm *result); -OSYNC_TEST_EXPORT inline struct tm* localtime_r (const time_t *clock, struct tm *result); -#endif /* _WIN32 */ - /*@}*/ #endif /*_OPENSYNC_TIME_H_*/ Added: trunk/opensync/format/opensync_time_internals.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/opensync/format/opensync_time_internals.h Sat Mar 28 20:58:10 2009 (r5405) @@ -0,0 +1,36 @@ +/* +* libopensync - A synchronization framework +* Copyright (C) 2004-2005 Armin Bauer <arm...@op...> +* Copyright (C) 2006-2008 Daniel Gollub <dg...@su...> +* Copyright (C) 2007 Chris Frey <cd...@ne...> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +*/ + +#ifndef _OPENSYNC_TIME_INTERNALS_H_ +#define _OPENSYNC_TIME_INTERNALS_H_ + +#ifdef _WIN32 +/* Windows does not provide gmtime_r and localtime_r */ +/* This module uses these two functions internally */ +/* They are also exported for testing purposes */ +OSYNC_TEST_EXPORT inline struct tm* gmtime_r (const time_t *clock, struct tm *result); +OSYNC_TEST_EXPORT inline struct tm* localtime_r (const time_t *clock, struct tm *result); +#endif /* _WIN32 */ + + +#endif /* _OPENSYNC_TIME_INTERNALS_H_ */ + Modified: trunk/tests/format-tests/check_time.c ============================================================================== --- trunk/tests/format-tests/check_time.c Sat Mar 28 20:50:04 2009 (r5404) +++ trunk/tests/format-tests/check_time.c Sat Mar 28 20:58:10 2009 (r5405) @@ -9,6 +9,8 @@ #include "support.h" +#include "opensync/format/opensync_time_internals.h" + // this test assumes Eastern time, sorry. START_TEST (time_timezone_diff) { |
From: <svn...@op...> - 2009-03-28 19:50:15
|
Author: dgollub Date: Sat Mar 28 20:50:04 2009 New Revision: 5404 URL: http://www.opensync.org/changeset/5404 Log: Fix build of osynctool. Replaced opensync-merger.h include with opensync-capabilities.h Ported OSyncPluginEnv API use to latest list interface pattern cleanup refs #975 Modified: osynctool/trunk/tools/osynctool.c Modified: osynctool/trunk/tools/osynctool.c ============================================================================== --- osynctool/trunk/tools/osynctool.c Sat Mar 28 20:45:59 2009 (r5403) +++ osynctool/trunk/tools/osynctool.c Sat Mar 28 20:50:04 2009 (r5404) @@ -26,7 +26,7 @@ #include <opensync/opensync-plugin.h> #include <opensync/opensync-engine.h> #include <opensync/opensync-data.h> -#include <opensync/opensync-merger.h> +#include <opensync/opensync-capabilities.h> #include <stdio.h> @@ -177,15 +177,19 @@ { int i; OSyncPlugin *plugin; + OSyncList *plugins, *p; osync_trace(TRACE_ENTRY, "%s(%p)", __func__, env); printf("Available plugins:\n"); - for (i = 0; i < osync_plugin_env_num_plugins(env); i++) { - plugin = osync_plugin_env_nth_plugin(env, i); + plugins = osync_plugin_env_get_plugins(env); + for (p = plugins; p; p = p->next) { + plugin = (OSyncPlugin *) p->data; printf("%s\n", osync_plugin_get_name(plugin)); } + osync_list_free(plugins); + osync_trace(TRACE_EXIT, "%s", __func__); } |
From: <svn...@op...> - 2009-03-28 19:46:04
|
Author: dgollub Date: Sat Mar 28 20:45:59 2009 New Revision: 5403 URL: http://www.opensync.org/changeset/5403 Log: Ported file-sync plugin to OSyncPlugin list pattern API cleanup r5382 refs #975 Modified: plugins/file-sync/src/file_sync.c Modified: plugins/file-sync/src/file_sync.c ============================================================================== --- plugins/file-sync/src/file_sync.c Sat Mar 28 20:35:17 2009 (r5402) +++ plugins/file-sync/src/file_sync.c Sat Mar 28 20:45:59 2009 (r5403) @@ -513,6 +513,8 @@ * all _possible_ objtype sinks. */ static void *osync_filesync_initialize(OSyncPlugin *plugin, OSyncPluginInfo *info, OSyncError **error) { + OSyncList *s , *sinks = NULL; + osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, info, error); OSyncFileEnv *env = osync_try_malloc0(sizeof(OSyncFileEnv), error); @@ -524,14 +526,14 @@ GList *pathes = NULL; - int i, numobjs = osync_plugin_info_num_objtypes(info); - for (i = 0; i < numobjs; i++) { + sinks = osync_plugin_info_get_objtypes(info); + for (s = sinks; s; s = s->next) { OSyncFileDir *dir = osync_try_malloc0(sizeof(OSyncFileDir), error); if (!dir) goto error_free_env; dir->env = env; - dir->sink = osync_plugin_info_nth_objtype(info, i); + dir->sink = (OSyncObjTypeSink *) s->data; assert(dir->sink); const char *objtype = osync_objtype_sink_get_name(dir->sink); @@ -582,6 +584,7 @@ /* Request an hashtable from the framework. */ osync_objtype_sink_enable_hashtable(dir->sink, TRUE); } + osync_list_free(sinks); if (pathes) { g_list_foreach(pathes, (GFunc)g_free, NULL); @@ -594,6 +597,9 @@ error_free_env: free_env(env); error: + if (sinks) + osync_list_free(sinks); + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); return NULL; } @@ -611,13 +617,14 @@ { osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, data, info, error); - int i, numobjs = osync_plugin_info_num_objtypes(info); - for (i = 0; i < numobjs; i++) { - OSyncObjTypeSink *sink = osync_plugin_info_nth_objtype(info, i); + OSyncList *s, *sinks = osync_plugin_info_get_objtypes(info); + for (s = sinks; s; s = s->next) { + OSyncObjTypeSink *sink = (OSyncObjTypeSink *) s->data; g_assert(sink); osync_objtype_sink_set_available(sink, TRUE); } + osync_list_free(sinks); OSyncVersion *version = osync_version_new(error); osync_version_set_plugin(version, "file-sync"); |
From: <svn...@op...> - 2009-03-28 19:35:22
|
Author: dgollub Date: Sat Mar 28 20:35:17 2009 New Revision: 5402 URL: http://www.opensync.org/changeset/5402 Log: Fix osync_obj_engine_nth_sinkengine() interface which could return on a mixed-syncing group NULL even if _num_sinkengine() reports a different limit. Spotted by bricks. Modified: trunk/opensync/engine/opensync_obj_engine.c Modified: trunk/opensync/engine/opensync_obj_engine.c ============================================================================== --- trunk/opensync/engine/opensync_obj_engine.c Sat Mar 28 20:15:46 2009 (r5401) +++ trunk/opensync/engine/opensync_obj_engine.c Sat Mar 28 20:35:17 2009 (r5402) @@ -1226,12 +1226,18 @@ OSyncSinkEngine *osync_obj_engine_nth_sinkengine(OSyncObjEngine *engine, unsigned int nth) { osync_return_val_if_fail(engine, NULL); - return osync_list_nth_data(engine->sink_engines, nth); + /* This is an public interace - we only deal here with "real" and active + * sink_engines. Not with dummies. + */ + return osync_list_nth_data(engine->active_sink_engines, nth); } unsigned int osync_obj_engine_num_sinkengines(OSyncObjEngine *engine) { osync_assert(engine); + /* This is an public interace - we only deal here with "real" and active + * sink_engines. Not with dummies. + */ return osync_list_length(engine->active_sink_engines); } |
From: <svn...@op...> - 2009-03-28 19:15:50
|
Author: dgollub Date: Sat Mar 28 20:15:46 2009 New Revision: 5401 URL: http://www.opensync.org/changeset/5401 Log: Dropped legacy includes. Modified: trunk/docs/examples/plugins/src/plugin.c trunk/docs/examples/plugins/src/simple_plugin.c Modified: trunk/docs/examples/plugins/src/plugin.c ============================================================================== --- trunk/docs/examples/plugins/src/plugin.c Sat Mar 28 20:13:09 2009 (r5400) +++ trunk/docs/examples/plugins/src/plugin.c Sat Mar 28 20:15:46 2009 (r5401) @@ -2,7 +2,6 @@ #include <opensync/opensync-data.h> #include <opensync/opensync-format.h> #include <opensync/opensync-plugin.h> -#include <opensync/opensync-context.h> #include <opensync/opensync-helper.h> #include <opensync/opensync-version.h> Modified: trunk/docs/examples/plugins/src/simple_plugin.c ============================================================================== --- trunk/docs/examples/plugins/src/simple_plugin.c Sat Mar 28 20:13:09 2009 (r5400) +++ trunk/docs/examples/plugins/src/simple_plugin.c Sat Mar 28 20:15:46 2009 (r5401) @@ -2,10 +2,8 @@ #include <opensync/opensync-data.h> #include <opensync/opensync-format.h> #include <opensync/opensync-plugin.h> -#include <opensync/opensync-context.h> #include <opensync/opensync-helper.h> #include <opensync/opensync-version.h> -#include <opensync/opensync_list.h> #include <string.h> |
From: <svn...@op...> - 2009-03-28 19:13:13
|
Author: dgollub Date: Sat Mar 28 20:13:09 2009 New Revision: 5400 URL: http://www.opensync.org/changeset/5400 Log: Dropped legacy include. Modified: plugins/qtopia4-sync/src/qtopia4_plugin.cpp Modified: plugins/qtopia4-sync/src/qtopia4_plugin.cpp ============================================================================== --- plugins/qtopia4-sync/src/qtopia4_plugin.cpp Sat Mar 28 20:12:58 2009 (r5399) +++ plugins/qtopia4-sync/src/qtopia4_plugin.cpp Sat Mar 28 20:13:09 2009 (r5400) @@ -23,7 +23,6 @@ #include <opensync/opensync-data.h> #include <opensync/opensync-format.h> #include <opensync/opensync-plugin.h> -#include <opensync/opensync-context.h> #include <opensync/opensync-helper.h> #include <opensync/opensync-version.h> |