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-30 20:26:44
|
Author: henrik Date: Mon Mar 30 22:26:32 2009 New Revision: 5474 URL: http://www.opensync.org/changeset/5474 Log: Updated mozilla-sync to latest API changes. However, we assert on: opensync_hashtable.c:283:E:osync_hashtable_slowsync: Assertion 'table' failed Modified: plugins/mozilla-sync/trunk/src/mozilla-sync.cpp plugins/mozilla-sync/trunk/src/mozilla-sync.h Modified: plugins/mozilla-sync/trunk/src/mozilla-sync.cpp ============================================================================== --- plugins/mozilla-sync/trunk/src/mozilla-sync.cpp Mon Mar 30 22:23:58 2009 (r5473) +++ plugins/mozilla-sync/trunk/src/mozilla-sync.cpp Mon Mar 30 22:26:32 2009 (r5474) @@ -71,7 +71,7 @@ #include <opensync/opensync-version.h> #include <opensync/opensync-data.h> #include <opensync/opensync-helper.h> -#include <opensync/opensync-capabilitiesr.h> +#include <opensync/opensync-capabilities.h> #include <opensync/opensync-xmlformat.h> #include "mozilla-xpcom.h" @@ -88,7 +88,6 @@ #include <libgen.h> #endif - #define LOGLEVEL 10000 /** Log a message using the @c pLogFunction passed **/ @@ -202,7 +201,8 @@ gboolean mozilla_sync_report_addressbook_changes_to_hash( OSyncMozillaDatabase *pOSyncMozillaDatabase, OSyncPluginInfo *pOSyncPluginInfo, - OSyncContext *pOSyncContext) { + OSyncContext *pOSyncContext, + OSyncHashTable *pHashTable) { LOG_ENTRY(10, "(%p, %p, %p)", pOSyncMozillaDatabase, pOSyncPluginInfo, pOSyncContext); @@ -214,7 +214,6 @@ OSyncError *pError = NULL; ThunderbirdAddressbook *pAB = pOSyncMozillaDatabase->pThunderbirdAddressbook; - OSyncHashTable *pHT = pOSyncMozillaDatabase->pOSyncHashTable; char *szError=NULL; if (!pAB->CardFirst(&szError, &logFunction)) @@ -242,9 +241,9 @@ // Identify the change osync_change_set_uid(pChange, szKey); osync_change_set_hash(pChange, szHash); - OSyncChangeType type = osync_hashtable_get_changetype(pHT, pChange); + OSyncChangeType type = osync_hashtable_get_changetype(pHashTable, pChange); osync_change_set_changetype(pChange, type); - osync_hashtable_update_change(pHT, pChange); + osync_hashtable_update_change(pHashTable, pChange); g_free(szHash); g_free(szKey); @@ -333,7 +332,8 @@ gboolean mozilla_sync_report_calendar_changes_to_hash( OSyncMozillaDatabase *pOSyncMozillaDatabase, OSyncPluginInfo *pOSyncPluginInfo, - OSyncContext *pOSyncContext) { + OSyncContext *pOSyncContext, + OSyncHashTable *pHashTable) { LOG_ENTRY(10, "(%p, %p, %p)", pOSyncMozillaDatabase, pOSyncPluginInfo, pOSyncContext); @@ -344,7 +344,6 @@ } OSyncError *pError = NULL; MozillaCalendar *pCal = pOSyncMozillaDatabase->pMozillaCalendar; - OSyncHashTable *pHT = pOSyncMozillaDatabase->pOSyncHashTable; char *szError=NULL; if (!pCal->EventFirst(&szError, &logFunction)) @@ -378,9 +377,9 @@ // Identify the change osync_change_set_uid(pChange, szKey); osync_change_set_hash(pChange, szHash); - OSyncChangeType type = osync_hashtable_get_changetype(pHT, pChange); + OSyncChangeType type = osync_hashtable_get_changetype(pHashTable, pChange); osync_change_set_changetype(pChange, type); - osync_hashtable_update_change(pHT, pChange); + osync_hashtable_update_change(pHashTable, pChange); g_free(szHash); // Bail out if no changes @@ -460,11 +459,11 @@ int i = 0; OSyncError *pError = NULL; + OSyncHashTable *pHashTable = osync_objtype_sink_get_hashtable(pOSyncObjTypeSink); // Thank you Michael Bell for corrections - // &&& osync_hashtable_reset_reports(pOSyncMozillaDatabase->pOSyncHashTable); - if (osync_objtype_sink_get_slowsync(pOSyncMozillaDatabase->pOSyncObjTypeSink) || fSlow) { + if (fSlow) { osync_trace(TRACE_INTERNAL, "Slow sync requested"); - if (!osync_hashtable_slowsync(pOSyncMozillaDatabase->pOSyncHashTable, &pError)) + if (!osync_hashtable_slowsync(pHashTable, &pError)) { osync_context_report_osyncerror(pOSyncContext, pError); osync_trace(TRACE_EXIT_ERROR, "%s - %s", __func__, osync_error_print_stack(&pError)); @@ -478,9 +477,9 @@ gboolean f; if (pOSyncMozillaDatabase->iMozillaDatabaseType==MOZILLA_DATABASE_TYPE_ADDRESSBOOK) { - f=mozilla_sync_report_addressbook_changes_to_hash(pOSyncMozillaDatabase, pOSyncPluginInfo, pOSyncContext); + f=mozilla_sync_report_addressbook_changes_to_hash(pOSyncMozillaDatabase, pOSyncPluginInfo, pOSyncContext, pHashTable); } else if (pOSyncMozillaDatabase->iMozillaDatabaseType==MOZILLA_DATABASE_TYPE_CALENDAR) { - f=mozilla_sync_report_calendar_changes_to_hash(pOSyncMozillaDatabase, pOSyncPluginInfo, pOSyncContext); + f=mozilla_sync_report_calendar_changes_to_hash(pOSyncMozillaDatabase, pOSyncPluginInfo, pOSyncContext, pHashTable); } else { LOG_EXIT_REPORT_ERROR_SZ(10, pOSyncContext, "Unknown iMozillaDatabaseType"); return; } @@ -498,7 +497,7 @@ LOG(10, "Checking for deleted [%s]", osync_objtype_sink_get_name(pOSyncObjTypeSink)); OSyncList *u; - OSyncList *uids = osync_hashtable_get_deleted(pOSyncMozillaDatabase->pOSyncHashTable); + OSyncList *uids = osync_hashtable_get_deleted(pHashTable); for (u = uids; u; u = u->next) { OSyncChange *change = osync_change_new(&pError); if (!change) { @@ -525,7 +524,7 @@ osync_context_report_change(pOSyncContext, change); - osync_hashtable_update_change(pOSyncMozillaDatabase->pOSyncHashTable, change); + osync_hashtable_update_change(pHashTable, change); osync_change_unref(change); } @@ -704,7 +703,7 @@ OSyncMozillaDatabase *pOSyncMozillaDatabase = (OSyncMozillaDatabase*) data; - OSyncHashTable *pHT = pOSyncMozillaDatabase->pOSyncHashTable; + OSyncHashTable *pHT = osync_objtype_sink_get_hashtable(pOSyncObjTypeSink); gboolean f; @@ -768,17 +767,11 @@ LOG(10, "Updating anchor to value [%s]", db->szAnchorValue); OSyncAnchor *anchor = osync_objtype_sink_get_anchor(pOSyncObjTypeSink); - if (!osync_anchor_update(anchor, db->szAnchorValue, &error)) { + if (!osync_anchor_update(anchor, db->szAnchorKey, db->szAnchorValue, &error)) { osync_context_report_osyncerror(pOSyncContext, error); LOG_EXIT_ERROR_OSYNC_SZ(10, &error, "Could not do osync_anchor_update"); return; } - LOG(10, "Updating hash table"); - if (!osync_hashtable_save(db->pOSyncHashTable, &error)) { - osync_context_report_osyncerror(pOSyncContext, error); - LOG_EXIT_ERROR_OSYNC_SZ(10, &error, "Could not save osync_hashtable_save"); - return; } - osync_context_report_success(pOSyncContext); LOG_EXIT(10, "void"); } @@ -811,29 +804,14 @@ osync_objtype_sink_set_batchcommit_timeout(pOSyncObjTypeSink, 4*60); // 4 minutes osync_objtype_sink_set_committedall_timeout(pOSyncObjTypeSink, 4*60); // 4 minutes osync_objtype_sink_set_syncdone_timeout(pOSyncObjTypeSink, 4*60); // 4 minutes - osync_objtype_sink_set_write_timeout(pOSyncObjTypeSink, 4*60); // 4 minutes osync_objtype_sink_set_read_timeout(pOSyncObjTypeSink, 4*60); // 4 minutes - char *tablepath = g_strdup_printf("%s" G_DIR_SEPARATOR_S "hashtable.db", osync_plugin_info_get_configdir(pOSyncPluginInfo)); - LOG(10, "Initializing hashtable [%s]", tablepath); - // Note that despite it's name, osync_hashtable_new, will re-use the hash-table, if it exists - db->pOSyncHashTable = osync_hashtable_new(tablepath, osync_objtype_sink_get_name(pOSyncObjTypeSink), &error); - g_free(tablepath); - - if (!db->pOSyncHashTable) { - osync_context_report_osyncerror(pOSyncContext, error); - LOG_EXIT_ERROR_OSYNC_SZ(10, &error, "Could not create osync_hashtable_new"); - return; } - - if (!osync_hashtable_load(db->pOSyncHashTable, &error)) { - osync_context_report_osyncerror(pOSyncContext, error); - LOG_EXIT_ERROR_OSYNC_SZ(10, &error, "Could not load osync_hashtable_load"); - return; } + osync_objtype_sink_enable_anchor(pOSyncObjTypeSink, TRUE); OSyncAnchor *anchor = osync_objtype_sink_get_anchor(pOSyncObjTypeSink); osync_bool same; - if (!osync_anchor_compare(anchor, db->szAnchorValue, &same, &error)) { + if (!osync_anchor_compare(anchor, db->szAnchorKey, db->szAnchorValue, &same, &error)) { osync_context_report_osyncerror(pOSyncContext, error); LOG_EXIT_ERROR_OSYNC_SZ(10, &error, "Could not do osync_anchor_compare"); return; } @@ -842,7 +820,7 @@ LOG(10, "Anchor matches; so do not force slow sync"); } else { LOG(10, "Anchor does not match; so force slow sync"); - osync_objtype_sink_set_slowsync(db->pOSyncObjTypeSink, TRUE); + osync_context_report_slowsync(pOSyncContext); } LOG(10, "Initializing Mozilla"); @@ -888,14 +866,9 @@ { LOG_ENTRY(10, "(%p, %p, %p, %p)", pOSyncObjTypeSink, pOSyncPluginInfo, pOSyncContext, data); - OSyncMozillaEnv *env = (OSyncMozillaEnv *)data; OSyncMozillaDatabase *db = (OSyncMozillaDatabase*) data; + OSyncMozillaEnv *env = db->pOSyncMozillaEnv; - if (db->pOSyncHashTable) { - osync_hashtable_unref(db->pOSyncHashTable); - db->pOSyncHashTable = NULL; - } - LOG(10, "Finalizing Thunderbird"); gboolean f; char *szError=NULL; @@ -958,8 +931,6 @@ OSyncMozillaDatabase *db = (OSyncMozillaDatabase*) o->data; if (db->pOSyncObjTypeSink) { const char *szSinkName = osync_objtype_sink_get_name(db->pOSyncObjTypeSink); - unsigned int nObjTypes = osync_objtype_sink_num_objformat_sinks(db->pOSyncObjTypeSink); - LOG(10, "Marking sink [%s] with [%d] object formats as available", szSinkName, nObjTypes); osync_objtype_sink_set_available(db->pOSyncObjTypeSink, TRUE); } } @@ -1021,7 +992,6 @@ OSyncMozillaDatabase *pOSyncMozillaDatabase; - if (pOSyncMozillaEnv->mozillaConfig.szAddressbookFile) { LOG(10, "Creating OSyncMozillaDatabase for Thunderbird addressbook"); pOSyncMozillaDatabase=(OSyncMozillaDatabase*)osync_try_malloc0(sizeof(OSyncMozillaDatabase), ppOSyncError); @@ -1090,25 +1060,17 @@ osync_objtype_sink_set_batchcommit_timeout(sink, 5*60); // 4 minutes osync_objtype_sink_set_committedall_timeout(sink, 5*60); // 4 minutes osync_objtype_sink_set_syncdone_timeout(sink, 5*60); // 4 minutes - osync_objtype_sink_set_write_timeout(sink, 5*60); // 4 minutes osync_objtype_sink_set_read_timeout(sink, 5*60); // 4 minutes db->pOSyncObjTypeSink = sink; - - /* All sinks have the same functions of course */ - OSyncObjTypeSinkFunctions functions; - memset(&functions, 0, sizeof(functions)); - functions.connect = mozilla_sync_connect; - functions.disconnect = mozilla_sync_disconnect; - functions.get_changes = mozilla_sync_get_changes; - functions.sync_done = mozilla_sync_done; - functions.commit = mozilla_sync_commit_change; - //functions.read = ??? - //functions.write = ??? - - /* We pass the OSyncMozillaDatabase 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, db); + + osync_objtype_sink_set_connect_func(sink, mozilla_sync_connect); + osync_objtype_sink_set_get_changes_func(sink, mozilla_sync_get_changes); + osync_objtype_sink_set_commit_func(sink, mozilla_sync_commit_change); + osync_objtype_sink_set_sync_done_func(sink, mozilla_sync_done); + + osync_objtype_sink_set_userdata(sink, db); + } OSyncCapabilities *pCapabilities = osync_capabilities_new(ppOSyncError); Modified: plugins/mozilla-sync/trunk/src/mozilla-sync.h ============================================================================== --- plugins/mozilla-sync/trunk/src/mozilla-sync.h Mon Mar 30 22:23:58 2009 (r5473) +++ plugins/mozilla-sync/trunk/src/mozilla-sync.h Mon Mar 30 22:26:32 2009 (r5474) @@ -52,7 +52,6 @@ const char *szAnchorValue; const char *szObjtype; const char *szObjformat; - OSyncHashTable *pOSyncHashTable; OSyncObjTypeSink *pOSyncObjTypeSink; OSyncMozillaEnv *pOSyncMozillaEnv; // TODO: This sould really be a union... |
From: <svn...@op...> - 2009-03-30 20:24:17
|
Author: henrik Date: Mon Mar 30 22:23:58 2009 New Revision: 5473 URL: http://www.opensync.org/changeset/5473 Log: small change so KEEP_TEMP_FILES does not fail Modified: plugins/mozilla-sync/trunk/tests/blackbox_test_common.shinc.in Modified: plugins/mozilla-sync/trunk/tests/blackbox_test_common.shinc.in ============================================================================== --- plugins/mozilla-sync/trunk/tests/blackbox_test_common.shinc.in Mon Mar 30 22:13:38 2009 (r5472) +++ plugins/mozilla-sync/trunk/tests/blackbox_test_common.shinc.in Mon Mar 30 22:23:58 2009 (r5473) @@ -67,10 +67,6 @@ rm -rf "${DIR}" || true done fi - else - for DIR in "${PATHS_TO_CLEAN[@]}"; do - echo "Not deleting [${DIR}]" - done fi } |
From: <svn...@op...> - 2009-03-30 20:13:50
|
Author: scriptor Date: Mon Mar 30 22:13:38 2009 New Revision: 5472 URL: http://www.opensync.org/changeset/5472 Log: ldap_plugin_check_anchor_system() MUST NOT be called from inside the get_changes function. It MUST be called from inside the connect function, instead. Otherwise: SIGSEGV in osync_context_report_slowsync(). Modified: plugins/ldap-sync/src/ldap_connect.c plugins/ldap-sync/src/ldap_plugin.c Modified: plugins/ldap-sync/src/ldap_connect.c ============================================================================== --- plugins/ldap-sync/src/ldap_connect.c Mon Mar 30 20:31:44 2009 (r5471) +++ plugins/ldap-sync/src/ldap_connect.c Mon Mar 30 22:13:38 2009 (r5472) @@ -431,6 +431,14 @@ } + + // Anchor system + ldap_plugin_check_anchor_system(ctx, sinkenv, &error); + + + + + // Set LDAP version on created connection ldap_plugin_set_ldap_protocol(ctx, info, sinkenv, &error); Modified: plugins/ldap-sync/src/ldap_plugin.c ============================================================================== --- plugins/ldap-sync/src/ldap_plugin.c Mon Mar 30 20:31:44 2009 (r5471) +++ plugins/ldap-sync/src/ldap_plugin.c Mon Mar 30 22:13:38 2009 (r5472) @@ -389,6 +389,11 @@ osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, ctx, sinkenv, error); + if (ctx == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ctx = NULL.\n", __FILE__, __LINE__); + goto error; + } + if (sinkenv == NULL) { osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: sinkenv = NULL.\n", __FILE__, __LINE__); goto error; @@ -2144,6 +2149,8 @@ /** * @brief Tries to get to know what has changed on the LDAP server * + * @sa http://localhost/libopensync-svn/group__OSyncObjTypeSinkAPI.html + * * @param sink From this the object type specific environment can be * gained. * @param info Environment for the whole plugin @@ -2247,7 +2254,7 @@ // Anchor system - ldap_plugin_check_anchor_system(ctx, sinkenv, &error); + // ldap_plugin_check_anchor_system(ctx, sinkenv, &error); // Now you can get the changes. These are the changes from the LDAP server. @@ -4385,6 +4392,14 @@ } + sinkenv->sink = osync_plugin_info_find_objtype(info, objtype); + if (!sinkenv->sink) { + osync_trace(TRACE_INTERNAL, "%s:%i: INFO: No sink available for objtype \"%s\". Apparently, this objtype has been disabled by configuration.\n", __FILE__, __LINE__, objtype); + goto out; + } + + + /* Every sink CAN have different functions ... */ osync_objtype_sink_set_connect_func(sinkenv->sink, ldap_plugin_connect); osync_objtype_sink_set_disconnect_func(sinkenv->sink, ldap_plugin_disconnect); @@ -4392,16 +4407,11 @@ osync_objtype_sink_set_commit_func(sinkenv->sink, ldap_plugin_commit_change); osync_objtype_sink_set_sync_done_func(sinkenv->sink, ldap_plugin_sync_done); - sinkenv->sink = osync_plugin_info_find_objtype(info, objtype); - if (!sinkenv->sink) { - osync_trace(TRACE_INTERNAL, "%s:%i: INFO: No sink available for objtype \"%s\". Apparently, this objtype has been disabled by configuration.\n", __FILE__, __LINE__, objtype); - goto out; - } if (!osync_objtype_sink_is_enabled(sinkenv->sink)) { - osync_trace(TRACE_INTERNAL, "%s:%i: INFO: sink for objtype \"%s\" is NOT enabled.", __FILE__, __LINE__, osync_objtype_sink_get_name(sinkenv->sink)); - goto out; - } + osync_trace(TRACE_INTERNAL, "%s:%i: INFO: sink for objtype \"%s\" is NOT enabled.", __FILE__, __LINE__, osync_objtype_sink_get_name(sinkenv->sink)); + goto out; + } |
From: <svn...@op...> - 2009-03-30 18:31:50
|
Author: scriptor Date: Mon Mar 30 20:31:44 2009 New Revision: 5471 URL: http://www.opensync.org/changeset/5471 Log: Additional tests using osynctool instead of osyncplugin. This way libopensync exit errors get detected, as well. Which is not possible with osyncplugin. The LDAP configuration file used by the test scripts can now be configured in test.conf (variable $CFG). Note: The $AUTH variable is used by the libldap utilities only. It must correspond with the authentication settings in the LDAP configuration file (variable $CFG). Or, at least both authentication settings must lead to write access to the LDAP server (so two different methods are very well possible). Added: plugins/ldap-sync/tests/check_osynctool1 (contents, props changed) plugins/ldap-sync/tests/check_osynctool2 (contents, props changed) Added: plugins/ldap-sync/tests/check_osynctool1 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/check_osynctool1 Mon Mar 30 20:31:44 2009 (r5471) @@ -0,0 +1,22 @@ +#!/bin/bash + + +FILE=$0 +OSYNCTOOL=$(which osynctool 2>/dev/null) +if test ! -f "$OSYNCTOOL"; then + echo "$FILE:$LINENO: ERROR: osynctool could not be found. Exiting." + exit 1 +fi + +if test ! -x "$OSYNCTOOL"; then + echo "$FILE:$LINENO: ERROR: osynctool could be found, but it is not executable. Exiting." + exit 1 +fi + + +$OSYNCTOOL --listplugins | grep -q "ldap-sync" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: ldap-sync was not included in pluginlist. Exiting." + exit 1 +fi Added: plugins/ldap-sync/tests/check_osynctool2 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/check_osynctool2 Mon Mar 30 20:31:44 2009 (r5471) @@ -0,0 +1,79 @@ +#!/bin/bash + + +FILE=$0 +OSYNCTOOL=$(which osynctool 2>/dev/null) +if test ! -f "$OSYNCTOOL"; then + echo "$FILE:$LINENO: ERROR: osynctool could not be found. Exiting." + exit 1 +fi + +if test ! -x "$OSYNCTOOL"; then + echo "$FILE:$LINENO: ERROR: osynctool could be found, but it is not executable. Exiting." + exit 1 +fi + + +$OSYNCTOOL --listformats | grep -q "ldap-evolutionperson" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: ldap-evolutionperson was not included in formatlist. Exiting." + exit 1 +fi + +$OSYNCTOOL --listformats | grep -q "ldap-inetorgperson" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: ldap-inetorgperson was not included in formatlist. Exiting." + exit 1 +fi + +$OSYNCTOOL --listformats | grep -q "ldap-event" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: ldap-event was not included in formatlist. Exiting." + exit 1 +fi + +$OSYNCTOOL --listformats | grep -q "ldap-todo" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: ldap-todo was not included in formatlist. Exiting." + exit 1 +fi + +$OSYNCTOOL --listformats | grep -q "ldap-note" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: ldap-note was not included in formatlist. Exiting." + exit 1 +fi + +$OSYNCTOOL --listformats | grep -q "xmlformat-contact$" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: xmlformat-contact was not included in formatlist. Exiting." + exit 1 +fi + +$OSYNCTOOL --listformats | grep -q "xmlformat-event$" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: xmlformat-event was not included in formatlist. Exiting." + exit 1 +fi + +$OSYNCTOOL --listformats | grep -q "xmlformat-todo$" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: xmlformat-todo was not included in formatlist. Exiting." + exit 1 +fi + +$OSYNCTOOL --listformats | grep -q "xmlformat-note$" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: xmlformat-note was not included in formatlist. Exiting." + exit 1 +fi + |
From: <svn...@op...> - 2009-03-30 18:30:39
|
Author: scriptor Date: Mon Mar 30 20:30:33 2009 New Revision: 5470 URL: http://www.opensync.org/changeset/5470 Log: Additional tests using osynctool instead of osyncplugin. This way libopensync exit errors get detected, as well. Which is not possible with osyncplugin. The LDAP configuration file used by the test scripts can now be configured in test.conf (variable $CFG). Note: The $AUTH variable is used by the libldap utilities only. It must correspond with the authentication settings in the LDAP configuration file (variable $CFG). Or, at least both authentication settings must lead to write access to the LDAP server (so two different methods are very well possible). Deleted: plugins/ldap-sync/tests/check_plugin1 plugins/ldap-sync/tests/check_plugin2 plugins/ldap-sync/tests/check_plugin3 Modified: plugins/ldap-sync/tests/check_add_modify_delete_and_sync plugins/ldap-sync/tests/check_add_modify_delete_four_ldifs_and_sync plugins/ldap-sync/tests/check_add_modify_delete_four_ldifs_and_valgrind_and_sync plugins/ldap-sync/tests/check_connect plugins/ldap-sync/tests/check_fastsync plugins/ldap-sync/tests/check_init plugins/ldap-sync/tests/check_modify_and_fastsync Modified: plugins/ldap-sync/tests/check_add_modify_delete_and_sync ============================================================================== --- plugins/ldap-sync/tests/check_add_modify_delete_and_sync Mon Mar 30 20:27:37 2009 (r5469) +++ plugins/ldap-sync/tests/check_add_modify_delete_and_sync Mon Mar 30 20:30:33 2009 (r5470) @@ -114,6 +114,13 @@ +if test -n "$TRACE_FILES"; then + echo "$FILE:$LINENO: Enabling OSYNC_TRACE." + export OSYNC_TRACE="$TRACE_FILES" +fi + + + Modified: plugins/ldap-sync/tests/check_add_modify_delete_four_ldifs_and_sync ============================================================================== --- plugins/ldap-sync/tests/check_add_modify_delete_four_ldifs_and_sync Mon Mar 30 20:27:37 2009 (r5469) +++ plugins/ldap-sync/tests/check_add_modify_delete_four_ldifs_and_sync Mon Mar 30 20:30:33 2009 (r5470) @@ -60,6 +60,16 @@ +if test -n "$TRACE_FILES"; then + echo "$FILE:$LINENO: Enabling OSYNC_TRACE." + export OSYNC_TRACE="$TRACE_FILES" +fi + + + + + + if test "$SYNCMETHOD" != "--fastsync"; then if test "$SYNCMETHOD" != "--slowsync"; then if test "$SYNCMETHOD" != "--sync"; then Modified: plugins/ldap-sync/tests/check_add_modify_delete_four_ldifs_and_valgrind_and_sync ============================================================================== --- plugins/ldap-sync/tests/check_add_modify_delete_four_ldifs_and_valgrind_and_sync Mon Mar 30 20:27:37 2009 (r5469) +++ plugins/ldap-sync/tests/check_add_modify_delete_four_ldifs_and_valgrind_and_sync Mon Mar 30 20:30:33 2009 (r5470) @@ -70,6 +70,13 @@ fi +if test -n "$TRACE_FILES"; then + echo "$FILE:$LINENO: Enabling OSYNC_TRACE." + export OSYNC_TRACE="$TRACE_FILES" +fi + + + Modified: plugins/ldap-sync/tests/check_connect ============================================================================== --- plugins/ldap-sync/tests/check_connect Mon Mar 30 20:27:37 2009 (r5469) +++ plugins/ldap-sync/tests/check_connect Mon Mar 30 20:30:33 2009 (r5470) @@ -54,6 +54,14 @@ +if test -n "$TRACE_FILES"; then + echo "$FILE:$LINENO: Enabling OSYNC_TRACE." + export OSYNC_TRACE="$TRACE_FILES" +fi + + + + echo "${PLUGINPATH} ${CFG}" Modified: plugins/ldap-sync/tests/check_fastsync ============================================================================== --- plugins/ldap-sync/tests/check_fastsync Mon Mar 30 20:27:37 2009 (r5469) +++ plugins/ldap-sync/tests/check_fastsync Mon Mar 30 20:30:33 2009 (r5470) @@ -53,6 +53,13 @@ fi +if test -n "$TRACE_FILES"; then + echo "$FILE:$LINENO: Enabling OSYNC_TRACE." + export OSYNC_TRACE="$TRACE_FILES" +fi + + + echo "${PLUGINPATH} ${CFG}" Modified: plugins/ldap-sync/tests/check_init ============================================================================== --- plugins/ldap-sync/tests/check_init Mon Mar 30 20:27:37 2009 (r5469) +++ plugins/ldap-sync/tests/check_init Mon Mar 30 20:30:33 2009 (r5470) @@ -57,6 +57,13 @@ fi +if test -n "$TRACE_FILES"; then + echo "$FILE:$LINENO: Enabling OSYNC_TRACE." + export OSYNC_TRACE="$TRACE_FILES" +fi + + + echo "${PLUGINPATH} ${CFG}" Modified: plugins/ldap-sync/tests/check_modify_and_fastsync ============================================================================== --- plugins/ldap-sync/tests/check_modify_and_fastsync Mon Mar 30 20:27:37 2009 (r5469) +++ plugins/ldap-sync/tests/check_modify_and_fastsync Mon Mar 30 20:30:33 2009 (r5470) @@ -50,6 +50,13 @@ +if test -n "$TRACE_FILES"; then + echo "$FILE:$LINENO: Enabling OSYNC_TRACE." + export OSYNC_TRACE="$TRACE_FILES" +fi + + + |
From: <svn...@op...> - 2009-03-30 18:27:50
|
Author: scriptor Date: Mon Mar 30 20:27:37 2009 New Revision: 5469 URL: http://www.opensync.org/changeset/5469 Log: Additional tests using osynctool instead of osyncplugin. This way libopensync exit errors get detected, as well. Which is not possible with osyncplugin. The LDAP configuration file used by the test scripts can now be configured in test.conf (variable $CFG). Note: The $AUTH variable is used by the libldap utilities only. It must correspond with the authentication settings in the LDAP configuration file (variable $CFG). Or, at least both authentication settings must lead to write access to the LDAP server (so two different methods are very well possible). Added: plugins/ldap-sync/tests/check_osyncplugin1 (contents, props changed) plugins/ldap-sync/tests/check_osynctool_add_file_and_sync (contents, props changed) plugins/ldap-sync/tests/check_osynctool_add_file_and_valgrind_and_sync (contents, props changed) plugins/ldap-sync/tests/check_osynctool_add_ldif_and_sync (contents, props changed) plugins/ldap-sync/tests/check_osynctool_add_ldif_and_valgrind_and_sync (contents, props changed) plugins/ldap-sync/tests/check_osynctool_common.inc (contents, props changed) plugins/ldap-sync/tests/check_osynctool_file1 (contents, props changed) plugins/ldap-sync/tests/file-sync.conf plugins/ldap-sync/tests/ldap-sync.conf plugins/ldap-sync/tests/note2.xml Modified: plugins/ldap-sync/tests/CMakeLists.txt plugins/ldap-sync/tests/check_slowsync plugins/ldap-sync/tests/check_sync plugins/ldap-sync/tests/note1.xml plugins/ldap-sync/tests/opensync.suppr plugins/ldap-sync/tests/remove_test_ldifs plugins/ldap-sync/tests/test.conf Modified: plugins/ldap-sync/tests/CMakeLists.txt ============================================================================== --- plugins/ldap-sync/tests/CMakeLists.txt Mon Mar 30 20:23:30 2009 (r5468) +++ plugins/ldap-sync/tests/CMakeLists.txt Mon Mar 30 20:27:37 2009 (r5469) @@ -138,6 +138,8 @@ ADD_TEST( stylesheet2.12 ${TESTDIR}/check_stylesheet2 ${XSLDIR}/xmlformat_note2ldap_note.xsl ${TESTDIR}/note1.xml) + ADD_TEST( stylesheet2.13 ${TESTDIR}/check_stylesheet2 ${XSLDIR}/xmlformat_note2ldap_note.xsl ${TESTDIR}/note2.xml) + ENDIF (XSLTPROC_EXECUTABLE) ENDIF (XMLLINT_EXECUTABLE) @@ -187,6 +189,8 @@ ADD_TEST( stylesheet4.7 ${TESTDIR}/check_stylesheet4 ${XSLDIR}/xmlformat_note2ldap_note.xsl ${XSLDIR}/ldap_note2xmlformat_note.xsl ${SCHEMADIR}/xmlformat-note.xsd ${XMLDIR}/note1.xml) + ADD_TEST( stylesheet4.8 ${TESTDIR}/check_stylesheet4 ${XSLDIR}/xmlformat_note2ldap_note.xsl ${XSLDIR}/ldap_note2xmlformat_note.xsl ${SCHEMADIR}/xmlformat-note.xsd ${XMLDIR}/note2.xml) + ENDIF (XSLTPROC_EXECUTABLE) ENDIF (XMLLINT_EXECUTABLE) @@ -224,7 +228,9 @@ ADD_TEST( stylesheet5.13 ${TESTDIR}/check_stylesheet5 ${XMLDIR}/note1.xml ${XSLDIR}/xmlformat_note2ldap_note.xsl ${XSLDIR}/ldap_note2xmlformat_note.xsl ) - # ADD_TEST( stylesheet5.14 ${TESTDIR}/check_stylesheet5 ${XMLDIR}/ldap_note1.xml ${XSLDIR}/ldap_note2xmlformat_note.xsl ${XSLDIR}/xmlformat_note2ldap_note.xsl ) + ADD_TEST( stylesheet5.14 ${TESTDIR}/check_stylesheet5 ${XMLDIR}/note2.xml ${XSLDIR}/xmlformat_note2ldap_note.xsl ${XSLDIR}/ldap_note2xmlformat_note.xsl ) + + # ADD_TEST( stylesheet5.15 ${TESTDIR}/check_stylesheet5 ${XMLDIR}/ldap_note1.xml ${XSLDIR}/ldap_note2xmlformat_note.xsl ${XSLDIR}/xmlformat_note2ldap_note.xsl ) ENDIF (XSLTPROC_EXECUTABLE) ENDIF (XMLLINT_EXECUTABLE) @@ -236,10 +242,10 @@ ########################################################## # Can the plugin be found, at all? # Using osyncplugin and osynctool from libopensync. -ADD_TEST( plugin1 ${TESTDIR}/check_plugin1 ) -ADD_TEST( plugin2 ${TESTDIR}/check_plugin2 ) -ADD_TEST( plugin3 ${TESTDIR}/check_plugin3 ) - +ADD_TEST( plugin1 ${TESTDIR}/check_osyncplugin1 ) +ADD_TEST( plugin2 ${TESTDIR}/check_osynctool1 ) +ADD_TEST( plugin3 ${TESTDIR}/check_osynctool2 ) +ADD_TEST( plugin4 ${TESTDIR}/check_osynctool_file1 ) ########################################################## @@ -410,7 +416,7 @@ ############################ -# Now with valgrind... +# Now osyncplugin with valgrind... IF (LDAPADD_EXECUTABLE) IF (LDAPMODIFY_EXECUTABLE) IF (LDAPDELETE_EXECUTABLE) @@ -436,5 +442,82 @@ + +########################################## +# Now we have a look at possible exit errors. +# We use osynctool, as osyncplugin does not seem to +# able to care about exit errors. +IF (LDAPADD_EXECUTABLE) + IF (LDAPMODIFY_EXECUTABLE) + IF (LDAPDELETE_EXECUTABLE) + + ADD_TEST( osynctool_add_contact1_ldif ${TESTDIR}/check_osynctool_add_ldif_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "contact" "${TESTDIR}/contact1.ldif" ) + + #ADD_TEST( osynctool_add_contact2_ldif ${TESTDIR}/check_osynctool_add_ldif_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "contact" "${TESTDIR}/contact2.ldif" ) + + ADD_TEST( osynctool_add_event_ldif ${TESTDIR}/check_osynctool_add_ldif_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "event" "${TESTDIR}/event1.ldif" ) + + #ADD_TEST( osynctool_add_todo_ldif ${TESTDIR}/check_osynctool_add_ldif_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "todo" "${TESTDIR}/todo1.ldif" ) + + ADD_TEST( osynctool_add_note_ldif ${TESTDIR}/check_osynctool_add_ldif_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "note" "${TESTDIR}/note1.ldif" ) + + + ADD_TEST( osynctool_add_contact1_xmlfile ${TESTDIR}/check_osynctool_add_file_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "contact" "${TESTDIR}/contact1.xml" ) + + #ADD_TEST( osynctool_add_contact2_xmlfile ${TESTDIR}/check_osynctool_add_file_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "contact" "${TESTDIR}/contact2.xml" ) + + #ADD_TEST( osynctool_add_event_xmlfile ${TESTDIR}/check_osynctool_add_file_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "event" "${TESTDIR}/event1.xml" ) + + #ADD_TEST( osynctool_add_todo_xmlfile ${TESTDIR}/check_osynctool_add_file_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "todo" "${TESTDIR}/todo1.xml" ) + + #ADD_TEST( osynctool_add_note_xmlfile ${TESTDIR}/check_osynctool_add_file_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "note" "${TESTDIR}/note1.xml" ) + + + ENDIF (LDAPDELETE_EXECUTABLE) + ENDIF (LDAPMODIFY_EXECUTABLE) +ENDIF (LDAPADD_EXECUTABLE) + + + + +############################ +# Now osynctool with valgrind... +IF (LDAPADD_EXECUTABLE) + IF (LDAPMODIFY_EXECUTABLE) + IF (LDAPDELETE_EXECUTABLE) + IF (VALGRIND_EXECUTABLE) + + #ADD_TEST( valgrind_osynctool_add_contact1_ldif ${TESTDIR}/check_osynctool_add_ldif_and_valgrind_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "contact" "${TESTDIR}/contact1.ldif" ) + + #ADD_TEST( valgrind_osynctool_add_contact2_ldif ${TESTDIR}/check_osynctool_add_ldif_and_valgrind_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "contact" "${TESTDIR}/contact2.ldif" ) + + #ADD_TEST( valgrind_osynctool_add_event_ldif ${TESTDIR}/check_osynctool_add_ldif_and_valgrind_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "event" "${TESTDIR}/event1.ldif" ) + + #ADD_TEST( valgrind_osynctool_add_todo_ldif ${TESTDIR}/check_osynctool_add_ldif_and_valgrind_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "todo" "${TESTDIR}/todo1.ldif" ) + + #ADD_TEST( valgrind_osynctool_add_note_ldif ${TESTDIR}/check_osynctool_add_ldif_and_valgrind_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "note" "${TESTDIR}/note1.ldif" ) + + + #ADD_TEST( valgrind_osynctool_add_contact1_xmlfile ${TESTDIR}/check_osynctool_add_file_and_valgrind_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "contact" "${TESTDIR}/contact1.xml" ) + + #ADD_TEST( valgrind_osynctool_add_contact2_xmlfile ${TESTDIR}/check_osynctool_add_file_and_valgrind_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "contact" "${TESTDIR}/contact2.xml" ) + + #ADD_TEST( valgrind_osynctool_add_event_xmlfile ${TESTDIR}/check_osynctool_add_file_and_valgrind_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "event" "${TESTDIR}/event1.xml" ) + + #ADD_TEST( valgrind_osynctool_add_todo_xmlfile ${TESTDIR}/check_osynctool_add_file_and_valgrind_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "todo" "${TESTDIR}/todo1.xml" ) + + #ADD_TEST( valgrind_osynctool_add_note_xmlfile ${TESTDIR}/check_osynctool_add_file_and_valgrind_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "note" "${TESTDIR}/note1.xml" ) + + + + + ENDIF (VALGRIND_EXECUTABLE) + ENDIF (LDAPDELETE_EXECUTABLE) + ENDIF (LDAPMODIFY_EXECUTABLE) +ENDIF (LDAPADD_EXECUTABLE) + + + + # vim:tw=0:nowrap Added: plugins/ldap-sync/tests/check_osyncplugin1 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/check_osyncplugin1 Mon Mar 30 20:27:37 2009 (r5469) @@ -0,0 +1,46 @@ +#!/bin/bash + + +FILE=$0 +OSYNCPLUGIN=$(which osyncplugin 2>/dev/null) +if test ! -f "$OSYNCPLUGIN"; then + echo "$FILE:$LINENO: ERROR: osyncplugin could not be found. Exiting." + exit 1 +fi + +if test ! -x "$OSYNCPLUGIN"; then + echo "$FILE:$LINENO: ERROR: osyncplugin could be found, but it is not executable. Exiting." + exit 1 +fi + + +SOURCE_DIR=`dirname $FILE` +if test ! -d "$SOURCE_DIR"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR\" is not a directory. Exiting." + exit 1 +fi + +if test ! -r "$SOURCE_DIR/test.conf"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR/test.conf\" could not be read. Exiting." + exit 1 +fi + +source "$SOURCE_DIR/test.conf" + + + +if test -n "$TRACE_FILES"; then + echo "$FILE:$LINENO: Enabling OSYNC_TRACE." + export OSYNC_TRACE="$TRACE_FILES" +fi + + + + + +$OSYNCPLUGIN --pluginlist | grep -q "ldap-sync" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: ldap-sync was not included in pluginlist. Exiting." + exit 1 +fi Added: plugins/ldap-sync/tests/check_osynctool_add_file_and_sync ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/check_osynctool_add_file_and_sync Mon Mar 30 20:27:37 2009 (r5469) @@ -0,0 +1,105 @@ +#!/bin/bash + +set -x + +FILE=$0 +OSYNCTOOL=$(which osynctool 2>/dev/null) +if test ! -f "$OSYNCTOOL"; then + echo "$FILE:$LINENO: ERROR: osynctool could not be found. Exiting." + exit 1 +fi + +if test ! -x "$OSYNCTOOL"; then + echo "$FILE:$LINENO: ERROR: osynctool could be found, but it is not executable. Exiting." + exit 1 +fi + + + +PLUGINNAME="ldap-sync" +PLUGINPATH="$1/src" +CFG="$2/src/$PLUGINNAME" +OBJECTTYPE="$3" +XMLFILE="$4" + + +SOURCE_DIR=`dirname $FILE` +if test ! -d "$SOURCE_DIR"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR\" is not a directory. Exiting." + exit 1 +fi + +if test ! -r "$SOURCE_DIR/test.conf"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR/test.conf\" could not be read. Exiting." + exit 1 +fi + +if test ! -r "$SOURCE_DIR/check_osynctool_common.inc"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR/test.conf\" could not be read. Exiting." + exit 1 +fi + +source "$SOURCE_DIR/test.conf" +source "$SOURCE_DIR/check_osynctool_common.inc" + +echo "PLUGINPATH = \"$PLUGINPATH\"" +echo "CFG = \"$CFG\"" + + +if test -n "$TRACE_FILES"; then + echo "$FILE:$LINENO: Enabling OSYNC_TRACE." + export OSYNC_TRACE="$TRACE_FILES" +fi + + +if test -z "$XMLFILE"; then + echo "$FILE:$LINENO: ERROR: \$XMLFILE is empty. Exiting." + exit 1 +fi + +if test ! -f "$XMLFILE"; then + echo "$FILE:$LINENO: ERROR: \"$XMLFILE\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$XMLFILE"; then + echo "$FILE:$LINENO: ERROR: \"$XMLFILE\" could be found, but it is not readable. Exiting." + exit 1 +fi + + +TMPDIR=`mktemp -d /tmp/ldap_sync_test.XXXXXX` || exit 1 +echo "TMPDIR = \"$TMPDIR\"" + + + + +# Set up test group +prologue; + +# Empty LDAP DIT +$SOURCE_DIR/remove_test_ldifs + +# Remove entry from directory used by file-sync +remove_file_by_objtype "$OBJECTTYPE" + +# Add *.ldif +add_file "$OBJECTTYPE" "$XMLFILE" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: add_file() has failed." + exit 1; +fi + +# osynctool should synchronize only one particular object type: +enable_only "$OBJECTTYPE" + +# Trigger synchronization +slow_sync "$OBJECTTYPE" +rv=$? + +# Shut down test group +epilogue + + +exit $rv Added: plugins/ldap-sync/tests/check_osynctool_add_file_and_valgrind_and_sync ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/check_osynctool_add_file_and_valgrind_and_sync Mon Mar 30 20:27:37 2009 (r5469) @@ -0,0 +1,112 @@ +#!/bin/bash + +set -x + +FILE=$0 +OSYNCTOOL=$(which osynctool 2>/dev/null) +if test ! -f "$OSYNCTOOL"; then + echo "$FILE:$LINENO: ERROR: osynctool could not be found. Exiting." + exit 1 +fi + +if test ! -x "$OSYNCTOOL"; then + echo "$FILE:$LINENO: ERROR: osynctool could be found, but it is not executable. Exiting." + exit 1 +fi + + + +PLUGINNAME="ldap-sync" +PLUGINPATH="$1/src" +CFG="$2/src/$PLUGINNAME" +OBJECTTYPE="$3" +XMLFILE="$4" + + +SOURCE_DIR=`dirname $FILE` +if test ! -d "$SOURCE_DIR"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR\" is not a directory. Exiting." + exit 1 +fi + +if test ! -r "$SOURCE_DIR/test.conf"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR/test.conf\" could not be read. Exiting." + exit 1 +fi + +if test ! -r "$SOURCE_DIR/check_osynctool_common.inc"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR/test.conf\" could not be read. Exiting." + exit 1 +fi + +source "$SOURCE_DIR/test.conf" +source "$SOURCE_DIR/check_osynctool_common.inc" + +echo "PLUGINPATH = \"$PLUGINPATH\"" +echo "CFG = \"$CFG\"" + + +if test -n "$TRACE_FILES"; then + echo "$FILE:$LINENO: Enabling OSYNC_TRACE." + export OSYNC_TRACE="$TRACE_FILES" +fi + + +if test -z "$XMLFILE"; then + echo "$FILE:$LINENO: ERROR: \$XMLFILE is empty. Exiting." + exit 1 +fi + +if test ! -f "$XMLFILE"; then + echo "$FILE:$LINENO: ERROR: \"$XMLFILE\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$XMLFILE"; then + echo "$FILE:$LINENO: ERROR: \"$XMLFILE\" could be found, but it is not readable. Exiting." + exit 1 +fi + + +if test -z "$VALGRIND"; then + echo "$FILE:$LINENO: ERROR: \$VALGRIND is empty. Exiting."; + exit 1; +fi + + + +TMPDIR=`mktemp -d /tmp/ldap_sync_test.XXXXXX` || exit 1 +echo "TMPDIR = \"$TMPDIR\"" + + + + +# Set up test group +prologue; + +# Empty LDAP DIT +$SOURCE_DIR/remove_test_ldifs + +# Remove entry from directory used by file-sync +remove_file_by_objtype "$OBJECTTYPE" + +# Add *.ldif +add_file "$OBJECTTYPE" "$XMLFILE" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: add_file() has failed." + exit 1; +fi + +# osynctool should synchronize only one particular object type: +enable_only "$OBJECTTYPE" + +# Trigger synchronization +valgrind_slow_sync "$OBJECTTYPE" +rv=$? + +# Shut down test group +epilogue + + +exit $rv Added: plugins/ldap-sync/tests/check_osynctool_add_ldif_and_sync ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/check_osynctool_add_ldif_and_sync Mon Mar 30 20:27:37 2009 (r5469) @@ -0,0 +1,105 @@ +#!/bin/bash + +set -x + +FILE=$0 +OSYNCTOOL=$(which osynctool 2>/dev/null) +if test ! -f "$OSYNCTOOL"; then + echo "$FILE:$LINENO: ERROR: osynctool could not be found. Exiting." + exit 1 +fi + +if test ! -x "$OSYNCTOOL"; then + echo "$FILE:$LINENO: ERROR: osynctool could be found, but it is not executable. Exiting." + exit 1 +fi + + + +PLUGINNAME="ldap-sync" +PLUGINPATH="$1/src" +CFG="$2/src/$PLUGINNAME" +OBJECTTYPE="$3" +LDIF="$4" + + +SOURCE_DIR=`dirname $FILE` +if test ! -d "$SOURCE_DIR"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR\" is not a directory. Exiting." + exit 1 +fi + +if test ! -r "$SOURCE_DIR/test.conf"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR/test.conf\" could not be read. Exiting." + exit 1 +fi + +if test ! -r "$SOURCE_DIR/check_osynctool_common.inc"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR/test.conf\" could not be read. Exiting." + exit 1 +fi + +source "$SOURCE_DIR/test.conf" +source "$SOURCE_DIR/check_osynctool_common.inc" + +echo "PLUGINPATH = \"$PLUGINPATH\"" +echo "CFG = \"$CFG\"" + + +if test -n "$TRACE_FILES"; then + echo "$FILE:$LINENO: Enabling OSYNC_TRACE." + export OSYNC_TRACE="$TRACE_FILES" +fi + +if test -z "$LDIF"; then + echo "$FILE:$LINENO: ERROR: \$LDIF is empty. Exiting." + exit 1 +fi + +if test ! -f "$LDIF"; then + echo "$FILE:$LINENO: ERROR: \"$LDIF\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$LDIF"; then + echo "$FILE:$LINENO: ERROR: \"$LDIF\" could be found, but it is not readable. Exiting." + exit 1 +fi + + + +TMPDIR=`mktemp -d /tmp/ldap_sync_test.XXXXXX` || exit 1 +echo "TMPDIR = \"$TMPDIR\"" + + + + +# Set up test group +prologue; + +# Empty LDAP DIT +$SOURCE_DIR/remove_test_ldifs + +# Remove entry from directory used by file-sync +remove_file_by_objtype "$OBJECTTYPE" + +# Add *.ldif +run_ldapadd "$LDIF" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapadd has failed." + exit 1; +fi + +# osynctool should synchronize only one particular object type: +enable_only "$OBJECTTYPE" + +# Trigger synchronization +slow_sync "$OBJECTTYPE" +rv=$? + +# Shut down test group +epilogue + + +exit $rv Added: plugins/ldap-sync/tests/check_osynctool_add_ldif_and_valgrind_and_sync ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/check_osynctool_add_ldif_and_valgrind_and_sync Mon Mar 30 20:27:37 2009 (r5469) @@ -0,0 +1,112 @@ +#!/bin/bash + +set -x + +FILE=$0 +OSYNCTOOL=$(which osynctool 2>/dev/null) +if test ! -f "$OSYNCTOOL"; then + echo "$FILE:$LINENO: ERROR: osynctool could not be found. Exiting." + exit 1 +fi + +if test ! -x "$OSYNCTOOL"; then + echo "$FILE:$LINENO: ERROR: osynctool could be found, but it is not executable. Exiting." + exit 1 +fi + + + +PLUGINNAME="ldap-sync" +PLUGINPATH="$1/src" +CFG="$2/src/$PLUGINNAME" +OBJECTTYPE="$3" +LDIF="$4" + + +SOURCE_DIR=`dirname $FILE` +if test ! -d "$SOURCE_DIR"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR\" is not a directory. Exiting." + exit 1 +fi + +if test ! -r "$SOURCE_DIR/test.conf"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR/test.conf\" could not be read. Exiting." + exit 1 +fi + +if test ! -r "$SOURCE_DIR/check_osynctool_common.inc"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR/test.conf\" could not be read. Exiting." + exit 1 +fi + +source "$SOURCE_DIR/test.conf" +source "$SOURCE_DIR/check_osynctool_common.inc" + +echo "PLUGINPATH = \"$PLUGINPATH\"" +echo "CFG = \"$CFG\"" + + +if test -n "$TRACE_FILES"; then + echo "$FILE:$LINENO: Enabling OSYNC_TRACE." + export OSYNC_TRACE="$TRACE_FILES" +fi + +if test -z "$LDIF"; then + echo "$FILE:$LINENO: ERROR: \$LDIF is empty. Exiting." + exit 1 +fi + +if test ! -f "$LDIF"; then + echo "$FILE:$LINENO: ERROR: \"$LDIF\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$LDIF"; then + echo "$FILE:$LINENO: ERROR: \"$LDIF\" could be found, but it is not readable. Exiting." + exit 1 +fi + + +if test -z "$VALGRIND"; then + echo "$FILE:$LINENO: ERROR: \$VALGRIND is empty. Exiting."; + exit 1; +fi + + + + +TMPDIR=`mktemp -d /tmp/ldap_sync_test.XXXXXX` || exit 1 +echo "TMPDIR = \"$TMPDIR\"" + + + + +# Set up test group +prologue; + +# Empty LDAP DIT +$SOURCE_DIR/remove_test_ldifs + +# Remove entry from directory used by file-sync +remove_file_by_objtype "$OBJECTTYPE" + +# Add *.ldif +run_ldapadd "$LDIF" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapadd has failed." + exit 1; +fi + +# osynctool should synchronize only one particular object type: +enable_only "$OBJECTTYPE" + +# Trigger synchronization +valgrind_slow_sync "$OBJECTTYPE" +rv=$? + +# Shut down test group +epilogue + + +exit $rv Added: plugins/ldap-sync/tests/check_osynctool_common.inc ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/check_osynctool_common.inc Mon Mar 30 20:27:37 2009 (r5469) @@ -0,0 +1,898 @@ +GROUPNAME="sync_test_group" + +check_plugin_available() +{ + plugin="$1" + + if test -z "$plugin"; then + echo "${FUNCNAME}(): ERROR: \$plugin is empty. Exiting." + exit 1; + fi + + if test -z "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL is empty. Exiting." + exit 1; + fi + + if test ! -f "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL does not exist. Exiting." + exit 1; + fi + + if test ! -x "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL does exist, but it is not executable. Exiting." + exit 1; + fi + + + $OSYNCTOOL --listplugins | grep -q "$plugin" + rv=$? + if test $rv -ne 0; then + echo "${FUNCNAME}(): ERROR: ldap-sync was not included in pluginlist. Exiting." + exit 1 + fi + +} + + + +check_ldap_formats() +{ + if test -z "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL is empty. Exiting." + exit 1; + fi + + if test ! -f "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL does not exist. Exiting." + exit 1; + fi + + if test ! -x "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL does exist, but it is not executable. Exiting." + exit 1; + fi + + + $OSYNCTOOL --listformats | grep -q "ldap-evolutionperson" + rv=$? + if test $rv -ne 0; then + echo "${FUNCNAME}(): ERROR: ldap-evolutionperson was not included in formatlist. Exiting." + exit 1 + fi + + $OSYNCTOOL --listformats | grep -q "ldap-inetorgperson" + rv=$? + if test $rv -ne 0; then + echo "${FUNCNAME}(): ERROR: ldap-inetorgperson was not included in formatlist. Exiting." + exit 1 + fi + + $OSYNCTOOL --listformats | grep -q "ldap-event" + rv=$? + if test $rv -ne 0; then + echo "${FUNCNAME}(): ERROR: ldap-event was not included in formatlist. Exiting." + exit 1 + fi + + $OSYNCTOOL --listformats | grep -q "ldap-todo" + rv=$? + if test $rv -ne 0; then + echo "${FUNCNAME}(): ERROR: ldap-todo was not included in formatlist. Exiting." + exit 1 + fi + + $OSYNCTOOL --listformats | grep -q "ldap-note" + rv=$? + if test $rv -ne 0; then + echo "${FUNCNAME}(): ERROR: ldap-note was not included in formatlist. Exiting." + exit 1 + fi +} + + + + + +check_xmlformats() +{ + if test -z "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL is empty. Exiting." + exit 1; + fi + + if test ! -f "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL does not exist. Exiting." + exit 1; + fi + + if test ! -x "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL does exist, but it is not executable. Exiting." + exit 1; + fi + + + $OSYNCTOOL --listformats | grep -q "xmlformat-contact$" + rv=$? + if test $rv -ne 0; then + echo "${FUNCNAME}(): ERROR: xmlformat-contact was not included in formatlist. Exiting." + exit 1 + fi + + $OSYNCTOOL --listformats | grep -q "xmlformat-event$" + rv=$? + if test $rv -ne 0; then + echo "${FUNCNAME}(): ERROR: xmlformat-event was not included in formatlist. Exiting." + exit 1 + fi + + $OSYNCTOOL --listformats | grep -q "xmlformat-todo$" + rv=$? + if test $rv -ne 0; then + echo "${FUNCNAME}(): ERROR: xmlformat-todo was not included in formatlist. Exiting." + exit 1 + fi + + $OSYNCTOOL --listformats | grep -q "xmlformat-note$" + rv=$? + if test $rv -ne 0; then + echo "${FUNCNAME}(): ERROR: xmlformat-note was not included in formatlist. Exiting." + exit 1 + fi +} + + + +configure_plugin() +{ + group="$1" + if test -z "$group"; then + echo "${FUNCNAME}(): ERROR: \$group is empty. Exiting."; + exit 1; + fi + + memberid="$2" + if test -z "$memberid"; then + echo "${FUNCNAME}(): ERROR: \$memberid is empty. Exiting."; + exit 1; + fi + + member_config_file="$3" + if test -z "$member_config_file"; then + echo "${FUNCNAME}(): ERROR: \$member_config_file is empty. Exiting."; + exit 1; + fi + + if test ! -f "$SOURCE_DIR/$member_config_file"; then + echo "${FUNCNAME}(): ERROR: $SOURCE_DIR/$member_config_file does not exist. Exiting."; + exit 1; + fi + + if test ! -r "$SOURCE_DIR/$member_config_file"; then + echo "${FUNCNAME}(): ERROR: $SOURCE_DIR/$member_config_file does exist, but it is not readable. Exiting."; + exit 1; + fi + + if test -z "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL is empty. Exiting." + exit 1; + fi + + if test ! -f "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL does not exist. Exiting." + exit 1; + fi + + if test ! -x "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL does exist, but it is not executable. Exiting." + exit 1; + fi + + if test -z "$TMPDIR"; then + echo "${FUNCNAME}(): ERROR: \$TMPDIR is empty. Exiting." + exit 1; + fi + + if test ! -d "$TMPDIR"; then + echo "${FUNCNAME}(): ERROR: \$TMPDIR is not a directory. Exiting." + exit 1; + fi + + + + # Thanks for this tip about fooling osynctool about the $EDITOR variable + # go to the author of the mozilla-sync plugin: Henrik Kaare Poulsen + # http://www.KaarPoSoft.dk/bluezync/ + # See mozilla-sync/trunk/tests/blackbox_test_common.shinc.inc + oldeditor="$EDITOR" + export EDITOR="cat >" + + + $OSYNCTOOL --configdir "$TMPDIR" --configure "$group" "$memberid" < "$SOURCE_DIR/$member_config_file" + + rv=$? + + export EDITOR="$oldeditor" + + + return $rv; +} + + + +setup_group() +{ + group="$1" + if test -z "$group"; then + echo "${FUNCNAME}(): ERROR: \$group is empty. Exiting."; + exit 1; + fi + + + if test -z "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL is empty. Exiting." + exit 1; + fi + + if test ! -f "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL does not exist. Exiting." + exit 1; + fi + + if test ! -x "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL does exist, but it is not executable. Exiting." + exit 1; + fi + + if test -z "$TMPDIR"; then + echo "${FUNCNAME}(): ERROR: \$TMPDIR is empty. Exiting." + exit 1; + fi + + if test ! -d "$TMPDIR"; then + echo "${FUNCNAME}(): ERROR: \$TMPDIR is not a directory. Exiting." + exit 1; + fi + + + + + $OSYNCTOOL --configdir "$TMPDIR" --addgroup "$group" + $OSYNCTOOL --configdir "$TMPDIR" --addmember "$group" "file-sync" + $OSYNCTOOL --configdir "$TMPDIR" --addmember "$group" "ldap-sync" + + + + configure_plugin "$group" "1" "file-sync.conf" + rv=$? + if test $rv -ne 0; then + echo "${FUNCNAME}(): ERROR: configure plugin \"$group\" \"1\" has failed. Exiting." + + $OSYNCTOOL --configdir "$TMPDIR" --delgroup "$group" + + exit $rv; + fi + + + + + configure_plugin "$group" "2" "ldap-sync.conf" + rv=$? + if test $rv -ne 0; then + echo "${FUNCNAME}(): ERROR: configure plugin \"$group\" \"1\" has failed. Exiting." + + $OSYNCTOOL --configdir "$TMPDIR" --delgroup "$group" + + exit $rv; + fi + + + # Let the configuration take into effect. + $OSYNCTOOL --configdir "$TMPDIR" --discover "$group" +} + + + +shutdown_group() +{ + group="$1" + if test -z "$group"; then + echo "${FUNCNAME}(): ERROR: \$group is empty. Exiting."; + exit 1; + fi + + + if test -z "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL is empty. Exiting." + exit 1; + fi + + if test ! -f "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL does not exist. Exiting." + exit 1; + fi + + if test ! -x "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL does exist, but it is not executable. Exiting." + exit 1; + fi + + if test -z "$TMPDIR"; then + echo "${FUNCNAME}(): ERROR: \$TMPDIR is empty. Exiting." + exit 1; + fi + + if test ! -d "$TMPDIR"; then + echo "${FUNCNAME}(): ERROR: \$TMPDIR is not a directory. Exiting." + exit 1; + fi + + + $OSYNCTOOL --configdir "$TMPDIR" --delmember "$group" 1 + $OSYNCTOOL --configdir "$TMPDIR" --delmember "$group" 2 + $OSYNCTOOL --configdir "$TMPDIR" --delgroup "$group" +} + + + +prologue() +{ + check_plugin_available "ldap-sync" + check_plugin_available "file-sync" + + check_ldap_formats; + check_xmlformats; + + setup_group "$GROUPNAME" +} + + + + +epilogue() +{ + shutdown_group "$GROUPNAME" + + if test -d "$TMPDIR"; then + rm -rf "$TMPDIR"; + fi +} + + + + +run_ldapadd() +{ + ldif="$1" + if test -z "$ldif"; then + echo "${FUNCNAME}(): ERROR: \$ldif is empty. Exiting." + exit 1; + fi + + if test ! -f "$ldif"; then + echo "${FUNCNAME}(): ERROR: $ldif does not exist. Exiting." + exit 1; + fi + + if test ! -r "$ldif"; then + echo "${FUNCNAME}(): ERROR: $ldif does exist, but it is not readable. Exiting." + exit 1; + fi + + + + LDAPADD=$(which ldapadd 2>/dev/null) + + if test ! -f "$LDAPADD"; then + echo "$FILE:$LINENO: ERROR: ldapadd could not be found. Exiting." + exit 1 + fi + + if test ! -x "$LDAPADD"; then + echo "$FILE:$LINENO: ERROR: ldapadd could be found, but is not executable. Exiting." + exit 1 + fi + + + + + + if test -z "$AUTH"; then + echo "${FUNCNAME}(): ERROR: \$AUTH is empty. Exiting." + exit 1; + fi + + if test -z "$LDAPADD"; then + echo "${FUNCNAME}(): ERROR: \$LDAPADD is empty. Exiting." + exit 1; + fi + + if test ! -f "$LDAPADD"; then + echo "${FUNCNAME}(): ERROR: $LDAPADD does not exist. Exiting." + exit 1; + fi + + if test ! -x "$LDAPADD"; then + echo "${FUNCNAME}(): ERROR: $LDAPADD does exist, but it is not ecutable. Exiting." + exit 1; + fi + + + + echo "Command: $LDAPADD $AUTH -a -f $ldif" + + $LDAPADD $AUTH -a -f $ldif + rv=$? + if test $rv -ne 0; then + echo "${FUNCNAME}(): ERROR: ldapadd has failed. Exiting." + exit $rv; + fi + + return $rv +} + + + +run_ldapmodify() +{ + entrymods="$1" + if test -z "$entrymods"; then + echo "${FUNCNAME}(): ERROR: \$entrymods is empty. Exiting." + exit 1; + fi + + if test ! -f "$entrymods"; then + echo "${FUNCNAME}(): ERROR: $entrymods does not exist. Exiting." + exit 1; + fi + + if test ! -r "$entrymods"; then + echo "${FUNCNAME}(): ERROR: $entrymods does exist, but it is not readable. Exiting." + exit 1; + fi + + + + if test -z "$AUTH"; then + echo "${FUNCNAME}(): ERROR: \$AUTH is empty. Exiting." + exit 1; + fi + + + LDAPMODIFY=$(which ldapmodify 2>/dev/null) + + + if test -z "$LDAPMODIFY"; then + echo "${FUNCNAME}(): ERROR: \$LDAPMODIFY is empty. Exiting." + exit 1; + fi + + if test ! -f "$LDAPMODIFY"; then + echo "${FUNCNAME}(): ERROR: $LDAPMODIFY does not exist. Exiting." + exit 1; + fi + + if test ! -x "$LDAPMODIFY"; then + echo "${FUNCNAME}(): ERROR: $LDAPMODIFY does exist, but it is not ecutable. Exiting." + exit 1; + fi + + + echo "Command: $LDAPMODIFY $AUTH -f $ENTRYMODS" + + $LDAPMODIFY $AUTH -f $ENTRYMODS + rv=$? + if test $rv -ne 0; then + echo "${FUNCNAME}(): ERROR: ldapmodify has failed. Exiting." + exit $rv; + fi + + return $rv; +} + + + +run_ldapdelete() +{ + ldif="$1" + if test -z "$ldif"; then + echo "${FUNCNAME}(): ERROR: \$ldif is empty. Exiting." + exit 1; + fi + + if test ! -f "$ldif"; then + echo "${FUNCNAME}(): ERROR: $ldif does not exist. Exiting." + exit 1; + fi + + if test ! -r "$ldif"; then + echo "${FUNCNAME}(): ERROR: $ldif does exist, but it is not readable. Exiting." + exit 1; + fi + + + + if test -z "$AUTH"; then + echo "${FUNCNAME}(): ERROR: \$AUTH is empty. Exiting." + exit 1; + fi + + + LDAPMODIFY=$(which ldapdelete 2>/dev/null) + + + if test -z "$LDAPDELETE"; then + echo "${FUNCNAME}(): ERROR: \$LDAPDELETE is empty. Exiting." + exit 1; + fi + + if test ! -f "$LDAPDELETE"; then + echo "${FUNCNAME}(): ERROR: $LDAPDELETE does not exist. Exiting." + exit 1; + fi + + if test ! -x "$LDAPDELETE"; then + echo "${FUNCNAME}(): ERROR: $LDAPDELETE does exist, but it is not ecutable. Exiting." + exit 1; + fi + + + + DN_FULL=$(head -n 1 $ldif) + if test -z "$DN_FULL"; then + echo "${FUNCNAME}(): ERROR: \$DN_FULL is empty. Exiting." + exit 1; + fi + + DN=${DN_FULL#dn:} + if test -z "$DN"; then + echo "${FUNCNAME}(): ERROR: \$DN is empty. Exiting." + exit 1; + fi + + echo "To be deleted: \"$DN\"" + echo "Command: $LDAPDELETE $AUTH -r $DN" + + $LDAPDELETE $AUTH -r $DN + rv=$? + if test $rv -ne 0; then + echo "${FUNCNAME}(): ERROR: ldapdelete has failed. Exiting." + exit $rv; + fi + + + return $rv; +} + + +remove_contact_files() +{ + if test -z "$CONTACT1_FILE"; then + echo "${FUNCNAME}(): ERROR: \$CONTACT1_FILE is empty. Ignoring." + elif test -f "$CONTACT1_FILE"; then + rm -f "$CONTACT1_FILE"; + fi + + + if test -z "$CONTACT2_FILE"; then + echo "${FUNCNAME}(): ERROR: \$CONTACT2_FILE is empty. Ignoring." + elif test -f "$CONTACT2_FILE"; then + rm -f "$CONTACT2_FILE"; + fi + + output=$(ls -al /tmp/file_contact) + echo -e "$output\n" +} + + +remove_event1_file() +{ + if test -z "$EVENT1_FILE"; then + echo "${FUNCNAME}(): ERROR: \$EVENT1_FILE is empty. Ignoring." + elif test -f "$EVENT1_FILE"; then + rm -f "$EVENT1_FILE"; + fi + + output=$(ls -al /tmp/file_event) + echo -e "$output\n" +} + + +remove_todo1_file() +{ + if test -z "$TODO1_FILE"; then + echo "${FUNCNAME}(): ERROR: \$TODO1_FILE is empty. Ignoring." + elif test -f "$TODO1_FILE"; then + rm -f "$TODO1_FILE"; + fi + + output=$(ls -al /tmp/file_todo) + echo -e "$output\n" +} + + +remove_note_files() +{ + if test -z "$NOTE1_FILE"; then + echo "${FUNCNAME}(): ERROR: \$NOTE1_FILE is empty. Ignoring." + elif test -f "$NOTE1_FILE"; then + rm -f "$NOTE1_FILE"; + fi + + if test -z "$NOTE2_FILE"; then + echo "${FUNCNAME}(): ERROR: \$NOTE2_FILE is empty. Ignoring." + elif test -f "$NOTE2_FILE"; then + rm -f "$NOTE2_FILE"; + fi + + output=$(ls -al /tmp/file_note) + echo -e "$output\n" +} + + +remove_file_by_objtype() +{ + objtype="$1" + + if test -z "$objtype"; then + echo "${FUNCNAME}(): ERROR: \$objtype is empty. Exiting."; + exit 1; + fi + + if test "$objtype" != "contact" -a "$objtype" != "event" -a "$objtype" != "todo" -a "$objtype" != "note"; then + echo "${FUNCNAME}(): ERROR: \"$objtype\" is wrong: \$objtype can only be either \"contact\" or \"event\" or \"todo\" or \"note\". Exiting." + exit 1; + fi + + + if test "$objtype" == "contact"; then + remove_contact_files + elif test "$objtype" == "event"; then + remove_event_file + elif test "$objtype" == "todo"; then + remove_todo_file + elif test "$objtype" == "note"; then + remove_note_files + fi +} + + + + + +remove_files() +{ + remove_contact_files + remove_note_files +} + + + +add_file() +{ + objtype="$1" + xmlfile="$2" + + + + if test -z "$objtype"; then + echo "$FILE:$LINENO: ERROR: \$objtype is empty. Exiting." + exit 1 + fi + + if test "$objtype" != "contact" -a "$objtype" != "event" -a "$objtype" != "todo" -a "$objtype" != "note"; then + echo "${FUNCNAME}(): ERROR: \"$objtype\" is wrong: \$objtype can only be either \"contact\" or \"event\" or \"todo\" or \"note\". Exiting." + exit 1; + fi + + if test -z "$xmlfile"; then + echo "$FILE:$LINENO: ERROR: \$xmlfile is empty. Exiting." + exit 1 + fi + + if test ! -f "$xmlfile"; then + echo "$FILE:$LINENO: ERROR: \"$xmlfile\" could not be found. Exiting." + exit 1 + fi + + if test ! -r "$xmlfile"; then + echo "$FILE:$LINENO: ERROR: \"$xmlfile\" could be found, but it is not readable. Exiting." + exit 1 + fi + + + +# if test "$objtype" == "contact"; then +# remove_contact_files +# elif test "$objtype" == "event"; then +# remove_event_file +# elif test "$objtype" == "todo"; then +# remove_todo_file +# elif test "$objtype" == "note"; then +# remove_note_files +# fi + + + if test "$objtype" == "contact"; then + cp -f "$xmlfile" $CONTACT1_FILE + + elif test "$objtype" == "event"; then + cp -f "$xmlfile" $EVENT1_FILE + + elif test "$objtype" == "todo"; then + cp -f "$xmlfile" $TODO1_FILE + + elif test "$objtype" == "note"; then + cp -f "$xmlfile" $NOTE1_FILE + + fi +} + + + + + +enable_only() +{ + objtype="$1" + + echo "${FUNCNAME}() has been called: objtype=\"$objtype\"." + + if test -z "$objtype"; then + echo "${FUNCNAME}(): ERROR: \$objtype is empty. Exiting."; + exit 1; + fi + + if test "$objtype" != "contact" -a "$objtype" != "event" -a "$objtype" != "todo" -a "$objtype" != "note"; then + echo "${FUNCNAME}(): ERROR: \"$objtype\" is wrong: \$objtype can only be either \"contact\" or \"event\" or \"todo\" or \"note\". Exiting." + exit 1; + fi + + + if test "$objtype" == "contact"; then + echo "${FUNCNAME}(): Enabling objtype \"contact\"." + $OSYNCTOOL --configdir "$TMPDIR" --enable-objtype "$GROUPNAME" "contact" + $OSYNCTOOL --configdir "$TMPDIR" --disable-objtype "$GROUPNAME" "event" + $OSYNCTOOL --configdir "$TMPDIR" --disable-objtype "$GROUPNAME" "todo" + $OSYNCTOOL --configdir "$TMPDIR" --disable-objtype "$GROUPNAME" "note" + elif test "$objtype" == "event"; then + echo "${FUNCNAME}(): Enabling objtype \"event\"." + $OSYNCTOOL --configdir "$TMPDIR" --disable-objtype "$GROUPNAME" "contact" + $OSYNCTOOL --configdir "$TMPDIR" --enable-objtype "$GROUPNAME" "event" + $OSYNCTOOL --configdir "$TMPDIR" --disable-objtype "$GROUPNAME" "todo" + $OSYNCTOOL --configdir "$TMPDIR" --disable-objtype "$GROUPNAME" "note" + elif test "$objtype" == "todo"; then + echo "${FUNCNAME}(): Enabling objtype \"todo\"." + $OSYNCTOOL --configdir "$TMPDIR" --disable-objtype "$GROUPNAME" "contact" + $OSYNCTOOL --configdir "$TMPDIR" --disable-objtype "$GROUPNAME" "event" + $OSYNCTOOL --configdir "$TMPDIR" --enable-objtype "$GROUPNAME" "todo" + $OSYNCTOOL --configdir "$TMPDIR" --disable-objtype "$GROUPNAME" "note" + elif test "$objtype" == "note"; then + echo "${FUNCNAME}(): Enabling objtype \"note\"." + $OSYNCTOOL --configdir "$TMPDIR" --disable-objtype "$GROUPNAME" "contact" + $OSYNCTOOL --configdir "$TMPDIR" --disable-objtype "$GROUPNAME" "event" + $OSYNCTOOL --configdir "$TMPDIR" --disable-objtype "$GROUPNAME" "todo" + $OSYNCTOOL --configdir "$TMPDIR" --enable-objtype "$GROUPNAME" "note" + fi +} + + + + + + + + + + + +slow_sync() +{ + group="$GROUPNAME" + objtype="$1" + + + if test -z "$group"; then + echo "${FUNCNAME}(): ERROR: \$group is empty. Exiting."; + exit 1; + fi + + + if test -z "$objtype"; then + echo "${FUNCNAME}(): ERROR: \$objtype is empty. Exiting."; + exit 1; + fi + + + if test -z "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL is empty. Exiting." + exit 1; + fi + + if test ! -f "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL does not exist. Exiting." + exit 1; + fi + + if test ! -x "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL does exist, but it is not executable. Exiting." + exit 1; + fi + + if test -z "$TMPDIR"; then + echo "${FUNCNAME}(): ERROR: \$TMPDIR is empty. Exiting." + exit 1; + fi + + if test ! -d "$TMPDIR"; then + echo "${FUNCNAME}(): ERROR: \$TMPDIR is not a directory. Exiting." + exit 1; + fi + + + $OSYNCTOOL --configdir "$TMPDIR" --sync "$group" --slow-sync "$objtype" --always-accept-forecast --conflict 2 + + +} + + + +valgrind_slow_sync() +{ + group="$GROUPNAME" + objtype="$1" + + + if test -z "$group"; then + echo "${FUNCNAME}(): ERROR: \$group is empty. Exiting."; + exit 1; + fi + + + if test -z "$objtype"; then + echo "${FUNCNAME}(): ERROR: \$objtype is empty. Exiting."; + exit 1; + fi + + + if test -z "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL is empty. Exiting." + exit 1; + fi + + if test ! -f "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL does not exist. Exiting." + exit 1; + fi + + if test ! -x "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL does exist, but it is not executable. Exiting." + exit 1; + fi + + if test -z "$TMPDIR"; then + echo "${FUNCNAME}(): ERROR: \$TMPDIR is empty. Exiting." + exit 1; + fi + + if test ! -d "$TMPDIR"; then + echo "${FUNCNAME}(): ERROR: \$TMPDIR is not a directory. Exiting." + exit 1; + fi + + if test -z "$VALGRIND"; then + echo "$FILE:$LINENO: ERROR: \$VALGRIND is empty. Exiting."; + exit 1; + fi + + + if test -n "$SUPPRESSION_FILE" -a -f "$SUPPRESSION_FILE" -a -r "$SUPPRESSION_FILE"; then + VALGRIND="$VALGRIND --suppressions=$SUPPRESSION_FILE" + fi + + + + $VALGRIND $OSYNCTOOL --configdir "$TMPDIR" --sync "$group" --slow-sync "$objtype" --always-accept-forecast --conflict 2 + + +} Added: plugins/ldap-sync/tests/check_osynctool_file1 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/check_osynctool_file1 Mon Mar 30 20:27:37 2009 (r5469) @@ -0,0 +1,66 @@ +#!/bin/bash + + +FILE=$0 +OSYNCTOOL=$(which osynctool 2>/dev/null) +if test ! -f "$OSYNCTOOL"; then + echo "$FILE:$LINENO: ERROR: osynctool could not be found. Exiting." + exit 1 +fi + +if test ! -x "$OSYNCTOOL"; then + echo "$FILE:$LINENO: ERROR: osynctool could be found, but it is not executable. Exiting." + exit 1 +fi + + + +PLUGINNAME="ldap-sync" +PLUGINPATH="$1/src" +CFG="$2/src/$PLUGINNAME" + + +if test -n "$TRACE_FILES"; then + echo "$FILE:$LINENO: Enabling OSYNC_TRACE." + export OSYNC_TRACE="$TRACE_FILES" +fi + + + +SOURCE_DIR=`dirname $FILE` +if test ! -d "$SOURCE_DIR"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR\" is not a directory. Exiting." + exit 1 +fi + +if test ! -r "$SOURCE_DIR/test.conf"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR/test.conf\" could not be read. Exiting." + exit 1 +fi + +if test ! -r "$SOURCE_DIR/check_osynctool_common.inc"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR/test.conf\" could not be read. Exiting." + exit 1 +fi + +source "$SOURCE_DIR/test.conf" +source "$SOURCE_DIR/check_osynctool_common.inc" + +echo "PLUGINPATH = \"$PLUGINPATH\"" +echo "CFG = \"$CFG\"" + + + +TMPDIR=`mktemp -d /tmp/ldap_sync_test.XXXXXX` || exit 1 +echo "TMPDIR = \"$TMPDIR\"" + + + + + +prologue; + +##### Here we could do something useful... + +epilogue + Modified: plugins/ldap-sync/tests/check_slowsync ============================================================================== --- plugins/ldap-sync/tests/check_slowsync Mon Mar 30 20:23:30 2009 (r5468) +++ plugins/ldap-sync/tests/check_slowsync Mon Mar 30 20:27:37 2009 (r5469) @@ -56,6 +56,10 @@ fi +if test -n "$TRACE_FILES"; then + echo "$FILE:$LINENO: Enabling OSYNC_TRACE." + export OSYNC_TRACE="$TRACE_FILES" +fi Modified: plugins/ldap-sync/tests/check_sync ============================================================================== --- plugins/ldap-sync/tests/check_sync Mon Mar 30 20:23:30 2009 (r5468) +++ plugins/ldap-sync/tests/check_sync Mon Mar 30 20:27:37 2009 (r5469) @@ -57,6 +57,13 @@ +if test -n "$TRACE_FILES"; then + echo "$FILE:$LINENO: Enabling OSYNC_TRACE." + export OSYNC_TRACE="$TRACE_FILES" +fi + + + echo "${PLUGINPATH} ${CFG}" Added: plugins/ldap-sync/tests/file-sync.conf ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/file-sync.conf Mon Mar 30 20:27:37 2009 (r5469) @@ -0,0 +1,45 @@ +<?xml version="1.0"?> +<config version="1.0"> + <Resources> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>file</Name> + </Format> + </Formats> + <ObjType>contact</ObjType> + <Path>/tmp/file_contact</Path> + </Resource> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>file</Name> + </Format> + </Formats> + <ObjType>event</ObjType> + <Path>/tmp/file_event</Path> + </Resource> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>file</Name> + </Format> + </Formats> + <ObjType>todo</ObjType> + <Path>/tmp/file_todo</Path> + </Resource> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>file</Name> + </Format> + </Formats> + <ObjType>note</ObjType> + <Path>/tmp/file_note</Path> + </Resource> + </Resources> +</config> Added: plugins/ldap-sync/tests/ldap-sync.conf ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/ldap-sync.conf Mon Mar 30 20:27:37 2009 (r5469) @@ -0,0 +1,191 @@ +<?xml version="1.0"?> +<config version="1.0"> + <AdvancedOptions> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>binddn</Name> + <Type>string</Type> + <Value>cn=ldap_user,ou=people,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>authcid</Name> + <Type>string</Type> + <Value>ldap_user</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>password</Name> + <Type>string</Type> + <Value>secret</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>anonymous</Name> + <Type>string</Type> + <Value>0</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>authmech</Name> + <Type>string</Type> + <Value>GSSAPI</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>encryption</Name> + <Type>string</Type> + <Value>0</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>ldap_read</Name> + <Type>string</Type> + <Value>1</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>ldap_write</Name> + <Type>string</Type> + <Value>1</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_contact</Name> + <Type>string</Type> + <Value>ou=addressbook,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_contact</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_contact</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_event</Name> + <Type>string</Type> + <Value>ou=calendar,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_event</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_event</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_todo</Name> + <Type>string</Type> + <Value>ou=todo,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_todo</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_todo</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_note</Name> + <Type>string</Type> + <Value>o=notes,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_note</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_note</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + </AdvancedOptions> + <Connection> + <ActiveConnection>Network</ActiveConnection> + <Network> + <Address>localhost</Address> + <Port>389</Port> + <Protocol>ldap</Protocol> + </Network> + </Connection> + <Resources> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-inetorgperson</Name> + </Format> + </Formats> + <ObjType>contact</ObjType> + </Resource> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-event</Name> + </Format> + </Formats> + <ObjType>event</ObjType> + </Resource> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-todo</Name> + </Format> + </Formats> + <ObjType>todo</ObjType> + </Resource> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-note</Name> + </Format> + </Formats> + <ObjType>note</ObjType> + </Resource> + </Resources> +</config> Modified: plugins/ldap-sync/tests/note1.xml ============================================================================== --- plugins/ldap-sync/tests/note1.xml Mon Mar 30 20:23:30 2009 (r5468) +++ plugins/ldap-sync/tests/note1.xml Mon Mar 30 20:27:37 2009 (r5469) @@ -1,28 +1,25 @@ <?xml version="1.0"?> <note> - <Attach> - <Content>file:///home/user1/.evolution/memos/local/system/200...@ho...-file</Content> - </Attach> <Categories> - <Category>development</Category> + <Category>Waiting</Category> </Categories> <Class> <Content>CONFIDENTIAL</Content> </Class> <Created> - <Content>20090103T144254</Content> + <Content>20090317T211814</Content> </Created> <DateCalendarCreated> - <Content>20090103T144254Z</Content> + <Content>20090228T003924Z</Content> </DateCalendarCreated> <DateStarted Value="DATE"> - <Content>20090103</Content> + <Content>20090228</Content> </DateStarted> <Description> - <Content>This is my first memo in evolution. It is confidential. With an attachment of 9 bytes.</Content> + <Content>This is my first memo. </Content> </Description> <LastModified> - <Content>20090103T144755</Content> + <Content>20090317T211814</Content> </LastModified> <Method> <Content>PUBLISH</Content> @@ -34,10 +31,9 @@ <Content>1</Content> </Sequence> <Summary> - <Content>1st memo</Content> + <Content>First memo.</Content> </Summary> -<Uid> - <Content>200...@ho...</Content> + <Uid> + <Content>200...@jl...</Content> </Uid> -</note> - +</note> \ No newline at end of file Added: plugins/ldap-sync/tests/note2.xml ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/note2.xml Mon Mar 30 20:27:37 2009 (r5469) @@ -0,0 +1,43 @@ +<?xml version="1.0"?> +<note> + <Attach> + <Content>file:///home/user1/.evolution/memos/local/system/200...@ho...-file</Content> + </Attach> + <Categories> + <Category>development</Category> + </Categories> + <Class> + <Content>CONFIDENTIAL</Content> + </Class> + <Created> + <Content>20090103T144254</Content> + </Created> + <DateCalendarCreated> + <Content>20090103T144254Z</Content> + </DateCalendarCreated> + <DateStarted Value="DATE"> + <Content>20090103</Content> + </DateStarted> + <Description> + <Content>This is my first memo in evolution. It is confidential. With an attachment of 9 bytes.</Content> + </Description> + <LastModified> + <Content>20090103T144755</Content> + </LastModified> + <Method> + <Content>PUBLISH</Content> + </Method> + <ProductID> + <Content>-//Ximian//NONSGML Evolution Calendar//EN</Content> + </ProductID> + <Sequence> + <Content>1</Content> + </Sequence> + <Summary> + <Content>1st memo</Content> + </Summary> +<Uid> + <Content>200...@ho...</Content> + </Uid> +</note> + Modified: plugins/ldap-sync/tests/opensync.suppr ============================================================================== --- plugins/ldap-sync/tests/opensync.suppr Mon Mar 30 20:23:30 2009 (r5468) +++ plugins/ldap-sync/tests/opensync.suppr Mon Mar 30 20:27:37 2009 (r5469) @@ -4200,3 +4200,111 @@ obj:* } +{ + <insert a suppression name here> + Memcheck:Leak + fun:malloc + fun:xmlDictCreate + fun:xmlInitParserCtxt + fun:xmlNewParserCtxt + fun:xmlCreateMemoryParserCtxt + fun:xmlReadMemory + obj:* + obj:* + fun:osync_converter_detect + fun:osync_format_converter_path_vertice_validate_path_with_detector + fun:osync_format_converter_path_vertice_get_next_vertice_neighbour + fun:osync_format_env_find_path_fn + fun:osync_format_env_find_path_formats_with_detectors + fun:osync_entry_engine_convert + fun:osync_sink_engine_convert_to_dest + fun:osync_obj_engine_prepare_write + fun:osync_obj_engine_command + fun:osync_engine_event + fun:_osync_engine_generate_multiplied_event + fun:_osync_engine_generate_event + fun:_osync_engine_event_callback + fun:osync_obj_engine_event + fun:osync_obj_engine_command + fun:osync_engine_command +} + + + +{ + <insert a suppression name here> + Memcheck:Leak + fun:calloc + fun:_dl_new_object + fun:_dl_map_object_from_fd + fun:_dl_map_object + fun:dl_open_worker + fun:_dl_catch_error + fun:_dl_open + fun:dlopen_doit + fun:_dl_catch_error + fun:_dlerror_run + fun:dlopen@@GLIBC_2.1 + fun:g_module_open + fun:osync_module_load + fun:osync_format_env_load_modules + fun:osync_format_env_load_plugins + fun:main +} + + +{ + <insert a suppression name here> + Memcheck:Leak + fun:malloc + fun:g_try_malloc + fun:osync_try_malloc0 + fun:osync_objtype_sink_new + fun:osync_member_parse_objtype + fun:osync_member_load + fun:osync_group_load_members + fun:osync_group_load + fun:osync_group_env_load_groups + fun:main +} + + +{ + <insert a suppression name here> + Memcheck:Leak + fun:calloc + fun:_dl_check_map_versions + fun:dl_open_worker + fun:_dl_catch_error + fun:_dl_open + fun:dlopen_doit + fun:_dl_catch_error + fun:_dlerror_run + fun:dlopen@@GLIBC_2.1 + fun:g_module_open + fun:osync_module_load + fun:osync_format_env_load_modules + fun:osync_format_env_load_plugins + fun:main +} + + +{ + <insert a suppression name here> + Memcheck:Leak + fun:malloc + obj:/usr/lib/libxml2.so.2.7.2 + fun:xmlSchemaInitTypes + fun:xmlSchemaParse + fun:osync_xmlformat_schema_new_path + fun:osync_xmlformat_schema_new + obj:* + obj:* + fun:osync_objformat_initialize + fun:osync_format_env_objformat_initialize + fun:osync_format_env_load_plugins + fun:main +} + + + Modified: plugins/ldap-sync/tests/remove_test_ldifs ============================================================================== --- plugins/ldap-sync/tests/remove_test_ldifs Mon Mar 30 20:23:30 2009 (r5468) +++ plugins/ldap-sync/tests/remove_test_ldifs Mon Mar 30 20:27:37 2009 (r5469) @@ -2,12 +2,6 @@ FILE=$0 -contact1_dn='uid=pas-id-49C8DD6D00000035,ou=addressbook,dc=example,dc=com' -contact2_dn='uid=pas-id-49C6A95E00000026,ou=addressbook,dc=example,dc=com' -event1_dn='documentIdentifier=200...@ho...,ou=calendar,dc=example,dc=com' -todo1_dn='documentIdentifier=200...@ho...,ou=todo,dc=example,dc=com' -note1_dn='documentIdentifier=200...@ho...,o=notes,dc=example,dc=com' - SOURCE_DIR=`dirname $FILE` if test ! -d "$SOURCE_DIR"; then echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR\" is not a directory. Exiting." @@ -27,6 +21,41 @@ fi +if test -z "$CONTACT1_DN"; then + echo "$FILE:$LINENO: ERROR: \$CONTACT1 is empty. Exiting."; + exit 1 +fi + + +if test -z "$CONTACT2_DN"; then + echo "$FILE:$LINENO: ERROR: \$CONTACT2 is empty. Exiting."; + exit 1 +fi + + +if test -z "$EVENT1_DN"; then + echo "$FILE:$LINENO: ERROR: \$EVENT1 is empty. Exiting."; + exit 1 +fi + + +if test -z "$TODO1_DN"; then + echo "$FILE:$LINENO: ERROR: \$TODO1 is empty. Exiting."; + exit 1 +fi + + +if test -z "$NOTE1_DN"; then + echo "$FILE:$LINENO: ERROR: \$NOTE1 is empty. Exiting."; + exit 1 +fi + +if test -z "$NOTE2_DN"; then + echo "$FILE:$LINENO: ERROR: \$NOTE1 is empty. Exiting."; + exit 1 +fi + + LDAPSEARCH=$(which ldapsearch 2>/dev/null) if test ! -f "$LDAPSEARCH"; then @@ -87,13 +116,14 @@ } -clear_dn "$contact1_dn" +clear_dn "$CONTACT1_DN" -clear_dn "$contact2_dn" +clear_dn "$CONTACT2_DN" -clear_dn "$event1_dn" +clear_dn "$EVENT1_DN" -clear_dn "$todo1_dn" +clear_dn "$TODO1_DN" -clear_dn "$note1_dn" +clear_dn "$NOTE1_DN" +clear_dn "$NOTE2_DN" Modified: plugins/ldap-sync/tests/test.conf ============================================================================== --- plugins/ldap-sync/tests/test.conf Mon Mar 30 20:23:30 2009 (r5468) +++ plugins/ldap-sync/tests/test.conf Mon Mar 30 20:27:37 2009 (r5469) @@ -1,11 +1,43 @@ +############ # Here you could override the filename of the configuration file for the plugin. # But you do not need to configure it, at all, because by default # "src/ldap-sync" of the source directory is parsed: # CFG="/home/user1/.opensync/group2/2/ldap-sync.conf" + + +############ +# How do you intend to authenticate against the LDAP server: AUTH="-Y DIGEST-MD5 -U ldap_user -w secret -Q" #AUTH="-Y GSSAPI -Q" + + BASE_CONTACT="ou=addressbook,dc=example,dc=com" BASE_EVENT="ou=calendar,dc=example,dc=com" BASE_TODO="ou=todo,dc=example,dc=com" BASE_NOTE="o=notes,dc=example,dc=com" -VALGRIND="valgrind --db-attach=no --num-callers=30 --gen-suppressions=all --leak-check=full --show-reachable=yes --error-exitcode=1 --track-origins=yes" + + +CONTACT1_DN='uid=pas-id-49C8DD6D00000035,ou=addressbook,dc=example,dc=com' +CONTACT2_DN='uid=pas-id-49C6A95E00000026,ou=addressbook,dc=example,dc=com' +EVENT1_DN='documentIdentifier=200...@ho...,ou=calendar,dc=example,dc=com' +TODO1_DN='documentIdentifier=200...@ho...,ou=todo,dc=example,dc=com' +NOTE1_DN='documentIdentifier=200...@ho...,o=notes,dc=example,dc=com' +NOTE2_DN='documentIdentifier=200...@ho...,o=notes,dc=example,dc=com' + +CONTACT1_FILE='/tmp/file_contact/pas-id-49C8DD6D00000035' +CONTACT2_FILE='/tmp/file_contact/pas-id-49C6A95E00000026' +EVENT1_FILE='/tmp/file_event/20090320T204925Z-32394-500-1-247_host.example.com' +TODO1_FILE='/tmp/file_todo/20090325T135501Z-32394-500-1-302_host.example.com' +NOTE1_FILE='/tmp/file_note/20090228T003924Z-14681-500-1-43_host.example.com' +NOTE2_FILE='/tmp/file_note/20090103T144254Z-31888-500-1-0_host.example.com' + +########## Without leak checking: +VALGRIND="valgrind --db-attach=no --num-callers=30 --gen-suppressions=all --leak-check=no --show-reachable=yes --error-exitcode=1 --track-origins=yes" + +########## With leak checking: +#VALGRIND="valgrind --db-attach=no --num-callers=30 --gen-suppressions=all --leak-check=full --show-reachable=yes --error-exitcode=1 --track-origins=yes" + +########## If you want to have libopensync trace files, define this variable: +# If the variable is empty, tracing is disabled. +TRACE_FILES="/tmp/trace" +#TRACE_FILES="" |
From: <svn...@op...> - 2009-03-30 18:23:23
|
Author: scriptor Date: Mon Mar 30 20:23:10 2009 New Revision: 5467 URL: http://www.opensync.org/changeset/5467 Log: Fixed 'ERROR: Could not find any node, where to add "AlarmAction"'. Modified: plugins/ldap-sync/src/ldap_connect.c plugins/ldap-sync/src/ldap_debug.c plugins/ldap-sync/src/ldap_format.c plugins/ldap-sync/src/ldap_format.h plugins/ldap-sync/src/ldap_plugin.c plugins/ldap-sync/src/ldap_plugin.h Modified: plugins/ldap-sync/src/ldap_connect.c ============================================================================== --- plugins/ldap-sync/src/ldap_connect.c Mon Mar 30 17:16:11 2009 (r5466) +++ plugins/ldap-sync/src/ldap_connect.c Mon Mar 30 20:23:10 2009 (r5467) @@ -1794,10 +1794,20 @@ // --------------------------------------------------------------- /* Search all entries that apply to the filter */ if (!ldap_plugin_call_ldap_search(ctx, sinkenv->ld, base, filter, LDAP_SCOPE_ONELEVEL, USER_ATTRIBUTES, sinkenv, &all_results, error)) { + int result_code = 0; + + if (!osync_error_is_set(error)) { osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ldap_plugin_call_ldap_search() has failed.\n", __FILE__, __LINE__); } + + ldap_get_option(sinkenv->ld, LDAP_OPT_RESULT_CODE, &result_code); + if (result_code == LDAP_NO_SUCH_OBJECT) { + ldap_plugin_printf("%s:%i: Either the searchbase (\"%s\") is really wrong, or the user does not have sufficient access permissions to this particular part of the DIT.", __FILE__, __LINE__, base); + } + + goto error; } @@ -1904,7 +1914,6 @@ osync_context_report_osyncwarning(ctx, *error); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - osync_error_unref(error); return FALSE; } @@ -1996,7 +2005,6 @@ osync_context_report_osyncwarning(ctx, *error); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - osync_error_unref(error); return FALSE; } @@ -3080,7 +3088,6 @@ osync_context_report_osyncwarning(ctx, *error); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - osync_error_unref(error); return FALSE; } Modified: plugins/ldap-sync/src/ldap_debug.c ============================================================================== --- plugins/ldap-sync/src/ldap_debug.c Mon Mar 30 17:16:11 2009 (r5466) +++ plugins/ldap-sync/src/ldap_debug.c Mon Mar 30 20:23:10 2009 (r5467) @@ -340,7 +340,9 @@ /** * @brief Prints the contents of an LDAP entry to the screen. * Mainly for debugging purposes + * * @param ldapdata An LDAP entry. + * * @returns Nothing. */ Modified: plugins/ldap-sync/src/ldap_format.c ============================================================================== --- plugins/ldap-sync/src/ldap_format.c Mon Mar 30 17:16:11 2009 (r5466) +++ plugins/ldap-sync/src/ldap_format.c Mon Mar 30 20:23:10 2009 (r5467) @@ -1086,7 +1086,7 @@ * @returns TRUE on success, FALSE in case of any errors. */ -static osync_bool ldap_format_parse_subentry(const xmlNode *xmlnode, const gchar *dn, complex_elements *element_lists, GList **ldap_entries, OSyncError **error) +static osync_bool ldap_format_parse_xml_subentry(const xmlNode *xmlnode, const gchar *dn, complex_elements *element_lists, GList **ldap_entries, OSyncError **error) { xmlChar *name = NULL; xmlChar *value = NULL; @@ -1127,6 +1127,8 @@ goto error; } + + name = (xmlChar *)xmlnode->name; if (name == NULL) { osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: name = NULL.\n", __FILE__, __LINE__); @@ -1207,7 +1209,7 @@ new_id = g_strdup_printf("%s", name); - // Regular cases: All the other cases. + // Regular cases of subentries: // name must be different from those special cases: if ( strncmp((char *)name, "TimezoneRule", 12) && @@ -1247,10 +1249,6 @@ osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: value = NULL.\n", __FILE__, __LINE__); goto error; } - - if (value[0] == 0) { - osync_trace(TRACE_ERROR, "%s:%i: WARNING: value[0] = 0; name = \"%s\". Ignoring.", __FILE__, __LINE__, name); - } } @@ -1258,6 +1256,13 @@ ldapmods_subentry = ldap_format_append_ldapmod(ldapmods_subentry, (gchar *)"objectClass", (gchar *)"organizationalUnit"); +#if 1 + // xxx jl: Wasn't here before... + if (name && name[0]) { + ldapmods_subentry = ldap_format_append_ldapmod(ldapmods_subentry, (gchar *)"ou", (gchar *)name); + } +#endif + if (value && value[0]) { ldapmods_subentry = ldap_format_append_ldapmod(ldapmods_subentry, (gchar *)"description", (gchar *)value); xmlFree(value); @@ -1340,7 +1345,7 @@ } - // Special cases: "TimezoneRule" and "TimezoneComponent". + // Special cases: 2nd level: "TimezoneRule", "TimezoneComponent" etc. if ( !strncmp((char *)name, "TimezoneRule", 12) || !strncmp((char *)name, "TimezoneComponent", 17) || @@ -2647,7 +2652,11 @@ node = root_node->xmlChildrenNode; - while(node) { +#ifdef DEBUG_convert_ldap2xmlinternal + osync_trace(TRACE_INTERNAL, "%s:%i: XML children node = %p", __FILE__, __LINE__, node); +#endif + + while (node) { xmlNode *node2 = NULL; @@ -2656,16 +2665,26 @@ continue; } +#ifdef DEBUG_convert_ldap2xmlinternal + osync_trace(TRACE_INTERNAL, "node->name = \"%s\"", node->name); +#endif if (xmlStrcmp(node->name, (xmlChar *)"subentry")) { node = node->next; continue; } +#ifdef DEBUG_convert_ldap2xmlinternal + ldap_plugin_printf("Subentry found with name = \"%s\"", name); +#endif + // OK. We have found a subentry. node2 = node->xmlChildrenNode; if (!node2) { +#ifdef DEBUG_convert_ldap2xmlinternal + osync_trace(TRACE_INTERNAL, "%s:%i: WARNING: node2 = NULL. There is no XML children node.", __FILE__, __LINE__); +#endif node = node->next; continue; } @@ -2677,18 +2696,20 @@ continue; } - +#if 0 #ifdef DEBUG_convert_ldap2xmlinternal - ldap_plugin_printf("%s:%i: node2->name = \"%s\"", __FILE__, __LINE__, node2->name); + ldap_plugin_printf("%s:%i:", __FILE__, __LINE__); + ldap_plugin_printf("token = \"%s\"", token); + ldap_plugin_printf("node2->name = \"%s\"", node2->name); +#endif #endif - if (g_strstr_len((gchar *)token, -1, (gchar *)node2->name)) { possible_parent = node2; } node = node->next; - } + } // while(node) if (possible_parent) { @@ -2713,6 +2734,241 @@ + +/** + * @brief This function parses the list of LDAP attributes of an LDAP entry + * that is called a subentry throughout this plugin. This prepares + * for generating an XML element. + * + * @param entry_list_index This is the index in the GList holding all the + * different LDAP entries of a complete subtree + * in the LDAP DIT. 0 means, it is the base entry + * of this subtree. + * @param mod This is an LDAPMod struct an ldap_entry struct. It holds + * one LDAP attribute and its value. + * @param name This variable gets filled with what will be the name + * of an XML element. + * @param value This variable gets filled with what will be the value + * (or the content) of an XML element. + * @param attr1_name This variable gets filled with what will be the + * name of the first XML attribute of an XML element. + * @param attr1_value This variable gets filled with what will be the + * value of the first XML attribute of an XML element. + * @param attr2_name This variable gets filled with what will be the + * name of the second XML attribute of an XML element. + * @param attr2_value This variable gets filled with what will be the + * value of the second XML attribute of an XML element. + * @param call_continue This variable gets filled with whether the caller + * should call continue in the list of mods and + * advance to the next mod of an LDAP entry. + * @param error The libopensync error pointer. + * + * @returns TRUE on success, FALSE in case of any error + */ + +osync_bool ldap_plugin_parse_attribute_list(const int entry_list_index, const LDAPMod *mod, xmlChar **name, xmlChar **value, xmlChar **attr1_name, xmlChar **attr1_value, xmlChar **attr2_name, xmlChar **attr2_value, osync_bool *call_continue, OSyncError **error) +{ + osync_trace(TRACE_ENTRY, "%s(%i, %p, %p, %p, %p, %p, %p, %p, %p)", __func__, index, mod, name, value, attr1_name, attr1_value, attr2_name, attr2_value, call_continue, error); + + + if (mod == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: mod = NULL.", __FILE__, __LINE__); + goto error; + } + + if (name == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: name = NULL.", __FILE__, __LINE__); + goto error; + } + + if (value == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: value = NULL.", __FILE__, __LINE__); + goto error; + } + + if (attr1_name == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: attr1_name = NULL.", __FILE__, __LINE__); + goto error; + } + + if (attr1_value == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: attr1_value = NULL.", __FILE__, __LINE__); + goto error; + } + + if (attr2_name == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: attr2_name = NULL.", __FILE__, __LINE__); + goto error; + } + + if (attr2_value == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: attr2_value = NULL.", __FILE__, __LINE__); + goto error; + } + + if (call_continue == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: call_continue = NULL.", __FILE__, __LINE__); + goto error; + } + + if (mod->mod_type == NULL) { + osync_trace(TRACE_ERROR, "%s:%i: ERROR: mod->mod_type = NULL.", __FILE__, __LINE__); + goto error; + } + + if (mod->mod_bvalues == NULL) { + osync_trace(TRACE_ERROR, "%s:%i: ERROR: mod->mod_bvalues = NULL.", __FILE__, __LINE__); + goto error; + } + + + + if (entry_list_index == 0) { + // This is the base entry. Its attribute name ("description") is + // at the same time the name of the XML element + *name = xmlStrdup((xmlChar *)mod->mod_type); + *value = xmlStrdup((xmlChar *)mod->mod_bvalues[0]->bv_val); + + } else { + // This is one of the subentries. They have all the objectClass + // "organizationalUnit". The attribute names MUST NOT be + // taken literally. In fact, "ou", "description", "postalAddress" + // "physicalDeliveryOfficeName", "registeredAddress" and + // "street" are shamelessly being abused for storing + // name and value of an XML element, and additionally + // of any possible first and second XML attribute. + if (!strcmp(mod->mod_type, "objectClass") || !strcmp(mod->mod_type, "objectclass")) { + // Not needed in XML document. + *call_continue = TRUE; + + // "ou" holds the name of an XML element plus a possible counter suffix. + // This suffix has to be cut off before adding to the XML tree. + // With an LDAP entry, however, each LDAP attribute must be unique. + // And the counter was necessary to enforce such uniqueness. + } else if (!strcmp(mod->mod_type, "ou")) { + char *n = mod->mod_bvalues[0]->bv_val; + + + if (!strncmp((char *)n, "TimezoneRule", 12)) { + *name = xmlStrdup((xmlChar *)"TimezoneRule"); + *value = xmlStrdup((xmlChar *)""); + } else if (!strncmp((char *)n, "TimezoneComponent", 17)) { + *name = xmlStrdup((xmlChar *)"TimezoneComponent"); + *value = xmlStrdup((xmlChar *)""); + } else if (!strncmp((char *)n, "postalAddress", 13)) { + *name = xmlStrdup((xmlChar *)"postalAddress"); + *value = xmlStrdup((xmlChar *)""); + } else if (!strncmp((char *)n, "AlarmAudio", 10)) { + *name = xmlStrdup((xmlChar *)"AlarmAudio"); + *value = xmlStrdup((xmlChar *)""); + } else if (!strncmp((char *)n, "AlarmDisplay", 12)) { + *name = xmlStrdup((xmlChar *)"AlarmDisplay"); + *value = xmlStrdup((xmlChar *)""); + } else if (!strncmp((char *)n, "AlarmEmail", 10)) { + *name = xmlStrdup((xmlChar *)"AlarmEmail"); + *value = xmlStrdup((xmlChar *)""); + } else if (!strncmp((char *)n, "AlarmProcedure", 14)) { + *name = xmlStrdup((xmlChar *)"AlarmProcedure"); + *value = xmlStrdup((xmlChar *)""); + } else if (!strncmp((char *)n, "RecurrenceRule", 14)) { + *name = xmlStrdup((xmlChar *)"RecurrenceRule"); + *value = xmlStrdup((xmlChar *)""); + } else if (!strncmp((char *)n, "RecurrenceRuleExtended", 22)) { + *name = xmlStrdup((xmlChar *)"RecurrenceRuleExtended"); + *value = xmlStrdup((xmlChar *)""); + } else if (!strncmp((char *)n, "AddressLabel", 12)) { + *name = xmlStrdup((xmlChar *)"AddressLabel"); + *value = xmlStrdup((xmlChar *)""); + } else if (!strncmp((char *)n, "Address", 7)) { + *name = xmlStrdup((xmlChar *)"Address"); + *value = xmlStrdup((xmlChar *)""); + } else { + *name = xmlStrdup((xmlChar *)(mod->mod_bvalues[0]->bv_val)); + } + + // EMail MUST NOT be set here. Rather it must be treated as + // as regular case. But its counter must also be cut off... + // We do it later... + + // Same is true for AddressLabel + + // And for Telephone. + + + // "description" holds the value of an XML element. + } else if (!strcmp(mod->mod_type, "description")) { + if ((xmlChar *)mod->mod_bvalues[0]->bv_val) { + *value = xmlStrdup((xmlChar *)mod->mod_bvalues[0]->bv_val); + } else { + *value = xmlStrdup((xmlChar *)""); + } + + // "postalAddress" holds the name of the first XML attribute + // of an XML element + } else if (!strcmp(mod->mod_type, "postalAddress")) { + *attr1_name = xmlStrdup((xmlChar *)mod->mod_bvalues[0]->bv_val); + + // "physicalDeliveryOfficeName" holds the value of the + // first XML attribute of an XML element + } else if (!strcmp(mod->mod_type, "physicalDeliveryOfficeName")) { + *attr1_value = xmlStrdup((xmlChar *) mod->mod_bvalues[0]->bv_val); + + // "registeredAddress" holds the name of the + // second XML attribute of an XML element + } else if (!strcmp(mod->mod_type, "registeredAddress")) { + *attr2_name = xmlStrdup((xmlChar *) mod->mod_bvalues[0]->bv_val); + + // "street" holds the value of second XML attribute of an XML element. + } else if (!strcmp(mod->mod_type, "street")) { + *attr2_value = xmlStrdup((xmlChar *) mod->mod_bvalues[0]->bv_val); + + } else if (!strcmp(mod->mod_type, "DateTimeStart")) { + *call_continue = TRUE; + + } else if (!strcmp(mod->mod_type, "TZName")) { + *call_continue = TRUE; + + } else if (!strcmp(mod->mod_type, "TZOffsetFrom")) { + *call_continue = TRUE; + + } else if (!strcmp(mod->mod_type, "TZOffsetTo")) { + *call_continue = TRUE; + + } else if (!strcmp(mod->mod_type, "Frequency")) { + *call_continue = TRUE; + + } else if (!strcmp(mod->mod_type, "Count")) { + *call_continue = TRUE; + + } else if (!strcmp(mod->mod_type, "Interval")) { + *call_continue = TRUE; + + } else if (!strcmp(mod->mod_type, "ByDay")) { + *call_continue = TRUE; + + } else { + *call_continue = TRUE; + } + + } // if (entry_list_index == 0) + + + + osync_trace(TRACE_EXIT, "%s()", __func__); + return TRUE; + +error: + if (!osync_error_is_set(error)) + osync_error_set(error, OSYNC_ERROR_GENERIC, "Unknown reason.\n"); + + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return FALSE; +} + + + + + /** * @brief This function converts a list of LDAP entries into an XML document. * @@ -2865,7 +3121,10 @@ #ifdef DEBUG_convert_ldap2xmlinternal + ldap_plugin_printf("Input:"); + ldap_plugin_dump_ldap_attributes(entry); ldap_plugin_printf("-----------------"); + ldap_plugin_printf("Parsing:"); ldap_plugin_printf("id = %s", entry->id); ldap_plugin_printf("dn = %s", entry->dn); #endif @@ -2876,151 +3135,79 @@ continue; } + + + // Add each LDAP entry (= base entry and its children) by looping // through all of the LDAP attributes xmlChar *name = NULL; xmlChar *value = NULL; - const xmlChar *attr1_name = NULL; - const xmlChar *attr1_value = NULL; - const xmlChar *attr2_name = NULL; - const xmlChar *attr2_value = NULL; + xmlChar *attr1_name = NULL; + xmlChar *attr1_value = NULL; + xmlChar *attr2_name = NULL; + xmlChar *attr2_value = NULL; + osync_bool first_level_still_to_be_added = FALSE; + for (j = 0 ; entry->mods[j] ; j++) { LDAPMod *mod = NULL; + osync_bool call_continue = FALSE; +#ifdef DEBUG_convert_ldap2xmlinternal + ldap_plugin_printf("j = %i", j); +#endif + mod = entry->mods[j]; if (mod == NULL) { - osync_trace(TRACE_ERROR, "%s:%i: ERROR: mod = NULL. Skipping this ldap entry.\n", __FILE__, __LINE__); - break; - } - - - if (mod->mod_type == NULL) { - osync_trace(TRACE_ERROR, "%s:%i: ERROR: mod->mod_type = NULL. Skipping this ldap entry.\n", __FILE__, __LINE__); - break; + osync_trace(TRACE_ERROR, "%s:%i: ERROR: mod = NULL. Skipping this LDAP attribute.\n", __FILE__, __LINE__); + continue; } + + // Actually, this would have been the function that would have had + // to advance in the list of mods, if appropriate - as it is for + // a subentry, for example. So that ALL of those names/values + // would have been defined. + if (!ldap_plugin_parse_attribute_list(i, mod, &name, &value, &attr1_name, &attr1_value, &attr2_name, &attr2_value, &call_continue, error)) { + if (!osync_error_is_set(error)) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: %s:%i: ldap_plugin_parse_attribute_list() has failed.", __FILE__, __LINE__); + } - if (mod->mod_bvalues == NULL) { - osync_trace(TRACE_ERROR, "%s:%i: ERROR: mod->mod_bvalues = NULL. Skipping this ldap entry.\n", __FILE__, __LINE__); - break; + goto error; } - k = 0; // k = 1 would be the terminating NULL - { - if (i == 0) { - // This is the base entry. Its attribute name ("description") is - // at the same time the name of the XML element - name = (xmlChar *)mod->mod_type; - value = (xmlChar *)mod->mod_bvalues[k]->bv_val; - - } else { - // This is one of the subentries. They have all the objectClass - // "organizationalUnit". The attribute names MUST NOT be - // taken literally. In fact, "ou", "description", "postalAddress" - // "physicalDeliveryOfficeName", "registeredAddress" and - // "street" are shamelessly being abused for storing - // name and value of an XML element, and additionally - // of any possible first and second XML attribute. - if (!strcmp(mod->mod_type, "objectClass") || !strcmp(mod->mod_type, "objectclass")) { - // Not needed in XML document. - continue; - - } else if (!strcmp(mod->mod_type, "ou")) { - name = (xmlChar *)mod->mod_bvalues[k]->bv_val; - - // Cut off any counter suffixes that may have been added - // to allow insertion into a typical LDAP DIT. - if (!strncmp((char *)name, "TimezoneRule", 12)) { - name = (xmlChar *)"TimezoneRule"; - value = (xmlChar *)""; - } else if (!strncmp((char *)name, "TimezoneComponent", 17)) { - name = (xmlChar *)"TimezoneComponent"; - value = (xmlChar *)""; - } else if (!strncmp((char *)name, "postalAddress", 13)) { - name = (xmlChar *)"postalAddress"; - value = (xmlChar *)""; - } else if (!strncmp((char *)name, "AlarmAudio", 10)) { - name = (xmlChar *)"AlarmAudio"; - value = (xmlChar *)""; - } else if (!strncmp((char *)name, "AlarmDisplay", 12)) { - name = (xmlChar *)"AlarmDisplay"; - value = (xmlChar *)""; - } else if (!strncmp((char *)name, "AlarmEmail", 10)) { - name = (xmlChar *)"AlarmEmail"; - value = (xmlChar *)""; - } else if (!strncmp((char *)name, "AlarmProcedure", 14)) { - name = (xmlChar *)"AlarmProcedure"; - value = (xmlChar *)""; - } else if (!strncmp((char *)name, "RecurrenceRule", 14)) { - name = (xmlChar *)"RecurrenceRule"; - value = (xmlChar *)""; - } else if (!strncmp((char *)name, "RecurrenceRuleExtended", 22)) { - name = (xmlChar *)"RecurrenceRuleExtended"; - value = (xmlChar *)""; - } else if (!strncmp((char *)name, "AddressLabel", 12)) { - name = (xmlChar *)"AddressLabel"; - - } else if (!strncmp((char *)name, "Address", 7)) { - name = (xmlChar *)"Address"; - value = (xmlChar *)""; - } - - // EMail MUST NOT be set here. Rather it must be treated as - // as regular case. But its counter must also be cut off... - // We do it later... - - // Same is true for AddressLabel - - // And for Telephone. - - } else if (!strcmp(mod->mod_type, "description")) { - if ((xmlChar *)mod->mod_bvalues[k]->bv_val) { - value = (xmlChar *)mod->mod_bvalues[k]->bv_val; - } else { - value = (xmlChar *)""; - } - - } else if (!strcmp(mod->mod_type, "postalAddress")) { - attr1_name = (xmlChar *)mod->mod_bvalues[k]->bv_val; - - } else if (!strcmp(mod->mod_type, "physicalDeliveryOfficeName")) { - attr1_value = (xmlChar *) mod->mod_bvalues[k]->bv_val; - - } else if (!strcmp(mod->mod_type, "registeredAddress")) { - attr2_name = (xmlChar *) mod->mod_bvalues[k]->bv_val; + if (call_continue) { + continue; + } - } else if (!strcmp(mod->mod_type, "street")) { - attr2_value = (xmlChar *) mod->mod_bvalues[k]->bv_val; + if (name == NULL) { + continue; + } - } else if (!strcmp(mod->mod_type, "DateTimeStart")) { - continue; - } else if (!strcmp(mod->mod_type, "TZName")) { - continue; - } else if (!strcmp(mod->mod_type, "TZOffsetFrom")) { - continue; - } else if (!strcmp(mod->mod_type, "TZOffsetTo")) { - continue; - } else if (!strcmp(mod->mod_type, "Frequency")) { - continue; - } else if (!strcmp(mod->mod_type, "Count")) { - continue; - } else if (!strcmp(mod->mod_type, "Interval")) { - continue; - } else if (!strcmp(mod->mod_type, "ByDay")) { - continue; - } + if (attr1_name && (attr1_value == NULL)) { + continue; + } + + if (attr1_value && (attr1_name == NULL)) { + continue; + } - } // if (i == 0) - } // for (k = 0; mod->mod_bvalues[k]; k++) + if (attr2_name && (attr2_value == NULL)) { + continue; + } + if (attr2_value && (attr2_name == NULL)) { + continue; + } #ifdef DEBUG_convert_ldap2xmlinternal if (name) { ldap_plugin_printf("name = %s", name); + } else { + ldap_plugin_printf("name = NULL."); } if (value) { @@ -3048,6 +3235,7 @@ if (name == NULL) { + osync_trace(TRACE_ERROR, "%s:%i: ERROR: name = NULL. i = %u, j = %u, k = %u. Continuing.\n", __FILE__, __LINE__, i, j, k); continue; } @@ -3059,19 +3247,46 @@ // Hmmm. value = NULL does NOT ALWAYS seem to be a problem. Strange... + // 30.03.2009: Well, it IS a problem. It CAN lead to + // "...ERROR: Could not find any node, where to add..." in + // ldap_format_add_xml_subsubentry(). if (value == NULL) { + #ifdef DEBUG_convert_ldap2xmlinternal osync_trace(TRACE_INTERNAL, "%s:%i: WARNING: value = NULL. name = \"%s\". i = %u, j = %u, k = %u. Continuing.\n", __FILE__, __LINE__, name, i, j, k); +// osync_trace(TRACE_INTERNAL, "%s:%i: WARNING: value = NULL. name = \"%s\". i = %u, j = %u, k = %u. We set value to an empty string and proceed instead of continueing.\n", __FILE__, __LINE__, name, i, j, k); #endif + continue; + + // This is NOT correct, if it were a sub-sub entry. + // It is correct ONLY, if it is a sub entry. + // value = (xmlChar *)""; } // Add the name - value pairs to the XML document. if (i == 0) { + +#ifdef DEBUG_convert_ldap2xmlinternal + ldap_plugin_printf("\n\n\nBase entry is about to be added: \"%s\"\n\n\n", name); +#endif + // Then this is the LDAP base entry. // Add the node to the parent. xmlNewTextChild(root_node, NULL, name, value); + if (name) { + xmlFree(name); + name = NULL; + } + + if (value) { + xmlFree(value); + value = NULL; + } + + continue; + } else { // Then this is one of the subentries. @@ -3129,7 +3344,7 @@ if (name) { if (name[0]) { if (!strncmp((char *)name, "EMail", 5)) { - name = (xmlChar *)"EMail"; + name = xmlStrdup((xmlChar *)"EMail"); } } } @@ -3140,33 +3355,48 @@ if (name) { if (name[0]) { if (!strncmp((char *)name, "AddressLabel", 12)) { - name = (xmlChar *)"AddressLabel"; + name = xmlStrdup((xmlChar *)"AddressLabel"); } } } + // Telephone: Likewise. Oh, dear. I have to // rewrite that mess eventually. if (name) { if (name[0]) { if (!strncmp((char *)name, "Telephone", 9)) { - name = (xmlChar *)"Telephone"; + name = xmlStrdup((xmlChar *)"Telephone"); } } } - // One of those irregular cases (second level...) + + // Now, finally add that entry to the XML tree. + + // Second level: One of those irregular cases if (where && where != entry->dn) { +#ifdef DEBUG_convert_ldap2xmlinternal + ldap_plugin_printf("\n\n\nSecond level (irregular case) is about to be added: \"%s\"\n\n\n", name); +#endif // char *token = strtok_r(where, ",", &saveptr); // strtok_r() is POSIX.1-2001, but not C99. char *token = strtok(where, ","); + if (token == NULL) { osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: token = NULL.\n", __FILE__, __LINE__); goto error; } + + if (value == NULL || value == (xmlChar *)"") { + osync_trace(TRACE_INTERNAL, "%s:%i: value is empty with name = \"%s\". Continuing.", __FILE__, __LINE__, name); + continue; + } + +#if 0 #ifdef DEBUG_convert_ldap2xmlinternal if (token) { ldap_plugin_printf("\n\ntoken = \"%s\"", token); @@ -3177,6 +3407,7 @@ ldap_plugin_printf("entry->id = \"%s\"", entry->id); ldap_plugin_printf("\n"); #endif +#endif if (!ldap_format_add_xml_subsubentry(root_node, (xmlChar *)token, name, value, attr1_name, attr1_value, attr2_name, attr2_value, error)) { osync_trace(TRACE_ERROR, "%s:%i: ERROR: ldap_format_add_xml_subsubentry() has failed.\n", __FILE__, __LINE__); @@ -3187,18 +3418,87 @@ } } else { - // Regular cases: + first_level_still_to_be_added = TRUE; + + + + +#if 0 + // 1st level: Regular cases: +#ifdef DEBUG_convert_ldap2xmlinternal + ldap_plugin_printf("\n\n\nFirst level (regular case) is about to be added: \"%s\".\n\n\n", name); +#endif + if (!ldap_format_add_xml_subentry(root_node, name, value, attr1_name, attr1_value, attr2_name, attr2_value, error)) { osync_trace(TRACE_ERROR, "%s:%i: ERROR: ldap_format_add_xml_subentry() has failed.\n", __FILE__, __LINE__); if (!osync_error_is_set(error)) osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ldap_format_add_xml_subentry() has failed.\n", __FILE__, __LINE__); goto error; - } - } + } // if (!ldap_format_add_xml_subentry()...) + +#endif + + + + + } // if (where && where != entry->dn) } // if (i == 0) } // for (j = 0 ; entry->mods[j] ; j++) + + + if (first_level_still_to_be_added) { + // 1st level: Regular cases: +#ifdef DEBUG_convert_ldap2xmlinternal + ldap_plugin_printf("\n\n\nFirst level (regular case) is about to be added: \"%s\".\n\n\n", name); +#endif + + if (!ldap_format_add_xml_subentry(root_node, name, value, attr1_name, attr1_value, attr2_name, attr2_value, error)) { + osync_trace(TRACE_ERROR, "%s:%i: ERROR: ldap_format_add_xml_subentry() has failed.\n", __FILE__, __LINE__); + if (!osync_error_is_set(error)) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ldap_format_add_xml_subentry() has failed.\n", __FILE__, __LINE__); + } + + goto error; + } // if (!ldap_format_add_xml_subentry()...) + + first_level_still_to_be_added = FALSE; // reset it to default setting + } // if (first_level_still_to_be_added) + + + + if (name) { + xmlFree(name); + name = NULL; + } + + if (value) { + xmlFree(value); + value = NULL; + } + + if (attr1_name) { + xmlFree(attr1_name); + attr1_name = NULL; + } + + if (attr1_value) { + xmlFree(attr1_value); + attr1_value = NULL; + } + + if (attr2_name) { + xmlFree(attr2_name); + attr2_name = NULL; + } + + if (attr2_value) { + xmlFree(attr2_value); + attr2_value = NULL; + } + + #ifdef DEBUG_convert_ldap2xmlinternal ldap_plugin_printf("\n"); #endif @@ -3540,11 +3840,11 @@ continue; } else { - if (!ldap_format_parse_subentry(subentry_node, dn, complex_element_lists, &ldap_subentries, error)) { + if (!ldap_format_parse_xml_subentry(subentry_node, dn, complex_element_lists, &ldap_subentries, error)) { if (!osync_error_is_set(error)) { - osync_trace(TRACE_ERROR, "%s:%i: ERROR: ldap_format_parse_subentry() has failed. Ignoring this xml subentry.\n", __FILE__, __LINE__); + osync_trace(TRACE_ERROR, "%s:%i: ERROR: ldap_format_parse_xml_subentry() has failed. Ignoring this xml subentry.\n", __FILE__, __LINE__); } else { - osync_trace(TRACE_ERROR, "%s:%i: ERROR: ldap_format_parse_subentry() has failed: \"%s\". Ignoring this xml subentry.\n", __FILE__, __LINE__, osync_error_print(error)); + osync_trace(TRACE_ERROR, "%s:%i: ERROR: ldap_format_parse_xml_subentry() has failed: \"%s\". Ignoring this xml subentry.\n", __FILE__, __LINE__, osync_error_print(error)); osync_error_unref(error); } @@ -3563,7 +3863,7 @@ for (i = 0; i < g_list_length(ldap_subentries); i++) { ldap_subentry = g_list_nth_data(ldap_subentries, i); if (!ldap_subentry) { - osync_trace(TRACE_ERROR, "%s:%i: ERROR: ldap_subentry is NULL. ldap_format_parse_subentry() must have failed. Ignoring this xml subentry.\n", __FILE__, __LINE__); + osync_trace(TRACE_ERROR, "%s:%i: ERROR: ldap_subentry is NULL. ldap_format_parse_xml_subentry() must have failed. Ignoring this xml subentry.\n", __FILE__, __LINE__); continue; } @@ -4683,7 +4983,7 @@ } - container = (glist_container *)g_malloc0(sizeof(glist_container)); + container = (glist_container *)g_malloc0(sizeof(glist_container) + 1); osync_assert(container); container->magic = "glist_container"; container->list = ldap_entries; Modified: plugins/ldap-sync/src/ldap_format.h ============================================================================== --- plugins/ldap-sync/src/ldap_format.h Mon Mar 30 17:16:11 2009 (r5466) +++ plugins/ldap-sync/src/ldap_format.h Mon Mar 30 20:23:10 2009 (r5467) @@ -71,7 +71,7 @@ static void ldap_format_free_ldap_entries (GList **entrylist); static void ldap_format_free_ldapmods_list(GList *ldapmods); static osync_bool ldap_format_get_attributes(const xmlNode *xmlnode, gchar **attr1_name, gchar **attr1_value, gchar **attr2_name, gchar **attr2_value, OSyncError **error); -static osync_bool ldap_format_parse_subentry(const xmlNode *xmlnode, const gchar *dn, complex_elements *complex_elements, GList **ldap_entries, OSyncError **error); +static osync_bool ldap_format_parse_xml_subentry(const xmlNode *xmlnode, const gchar *dn, complex_elements *complex_elements, GList **ldap_entries, OSyncError **error); static osync_bool ldap_format_parse_xmlinternal_child_nodes(xmlNode *xmlnode, const char *objtype, const char *dn, complex_elements *complex_elements, GList **potential_subentries, GList **ldapmods, OSyncError **error); static osync_bool ldap_format_post_stylesheet(OSyncXMLFormat *xmlformat, const char *objtype, const char *ldap_format_name, GList **ldap_entries, OSyncError **error); static osync_bool ldap_format_pre_stylesheet(GList *ldap_entries, const char *objtype, const char *ldap_format_name, xmlChar **xmlbuff, int *xmlbuff_size, OSyncError **error); Modified: plugins/ldap-sync/src/ldap_plugin.c ============================================================================== --- plugins/ldap-sync/src/ldap_plugin.c Mon Mar 30 17:16:11 2009 (r5466) +++ plugins/ldap-sync/src/ldap_plugin.c Mon Mar 30 20:23:10 2009 (r5467) @@ -2083,7 +2083,7 @@ if (!ldap_plugin_get_changed_ldap_entries(ctx, sinkenv, ldaplist_added, ldaplist_modified, deleted_uids, unmodified_uids, error)) { if (!osync_error_is_set(error)) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ldap_plugin_get_changed_ldap_entries.", __FILE__, __LINE__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ldap_plugin_get_changed_ldap_entries() has failed.", __FILE__, __LINE__); } goto error; Modified: plugins/ldap-sync/src/ldap_plugin.h ============================================================================== --- plugins/ldap-sync/src/ldap_plugin.h Mon Mar 30 17:16:11 2009 (r5466) +++ plugins/ldap-sync/src/ldap_plugin.h Mon Mar 30 20:23:10 2009 (r5467) @@ -445,6 +445,7 @@ int ldap_plugin_initialize_format(OSyncPluginInfo *info, sink_environment *sinkenv, OSyncPluginConfig *configdata, const char *objtype, const char *format, OSyncError **error); sink_environment *ldap_plugin_initialize_sink(OSyncPluginInfo *info, const char *objtype, const char *format, OSyncError **error); osync_bool ldap_plugin_is_on (const char *str); +osync_bool ldap_plugin_parse_attribute_list(const int entry_list_index, const LDAPMod *mod, xmlChar **name, xmlChar **value, xmlChar **attr1_name, xmlChar **attr1_value, xmlChar **attr2_name, xmlChar **attr2_value, osync_bool *call_continue, OSyncError **error); osync_bool ldap_plugin_parse_config (OSyncPluginInfo *info, sink_environment *sinkenv, const char *objtype, OSyncPluginConfig * config, OSyncError **error); osync_bool ldap_plugin_process_deleted_entries (OSyncContext *ctx, OSyncPluginInfo *info, sink_environment *sinkenv, OSyncError **error); osync_bool ldap_plugin_report_change(OSyncContext *ctx, const sink_environment *sinkenv, const osync_bool slow_sync_requested, OSyncChangeType changetype_from_caller, GList *to_be_reported, OSyncError **error); |
From: <svn...@op...> - 2009-03-30 15:16:22
|
Author: dgollub Date: Mon Mar 30 17:16:11 2009 New Revision: 5466 URL: http://www.opensync.org/changeset/5466 Log: Ported tomboy-sync to OSyncAnchor key=value API change. refs #1090 Modified: plugins/tomboy-sync/src/tomboy_sync.c plugins/tomboy-sync/src/tomboy_sync_dbus.c plugins/tomboy-sync/src/tomboy_sync_file.c Modified: plugins/tomboy-sync/src/tomboy_sync.c ============================================================================== --- plugins/tomboy-sync/src/tomboy_sync.c Mon Mar 30 17:10:59 2009 (r5465) +++ plugins/tomboy-sync/src/tomboy_sync.c Mon Mar 30 17:16:11 2009 (r5466) @@ -40,7 +40,7 @@ osync_bool anchormatch; - if ( !osync_anchor_compare(anchor, new_anchor, &anchormatch, error) ) { + if ( !osync_anchor_compare(anchor, "anchor_key1", new_anchor, &anchormatch, error) ) { /* anchor couldn't be compared */ goto error; } Modified: plugins/tomboy-sync/src/tomboy_sync_dbus.c ============================================================================== --- plugins/tomboy-sync/src/tomboy_sync_dbus.c Mon Mar 30 17:10:59 2009 (r5465) +++ plugins/tomboy-sync/src/tomboy_sync_dbus.c Mon Mar 30 17:16:11 2009 (r5466) @@ -227,7 +227,7 @@ OSyncTomboyEnv *tomboyenv = dir->env; OSyncAnchor *anchor = osync_objtype_sink_get_anchor(sink); - if ( !osync_anchor_update(anchor, tomboyenv->homedir_path, &error) ) { + if ( !osync_anchor_update(anchor, "anchor_key1", tomboyenv->homedir_path, &error) ) { goto error; } Modified: plugins/tomboy-sync/src/tomboy_sync_file.c ============================================================================== --- plugins/tomboy-sync/src/tomboy_sync_file.c Mon Mar 30 17:10:59 2009 (r5465) +++ plugins/tomboy-sync/src/tomboy_sync_file.c Mon Mar 30 17:16:11 2009 (r5466) @@ -263,7 +263,7 @@ OSyncAnchor *anchor = osync_objtype_sink_get_anchor(sink); - if( !osync_anchor_update(anchor, tomboyenv->homedir_path, &error) ) { + if( !osync_anchor_update(anchor, "anchor_key1", tomboyenv->homedir_path, &error) ) { goto error; } |
From: <svn...@op...> - 2009-03-30 15:11:10
|
Author: dgollub Date: Mon Mar 30 17:10:59 2009 New Revision: 5465 URL: http://www.opensync.org/changeset/5465 Log: Ported ldap-sync to OSyncAnchor key=value API change. refs #1090 Modified: plugins/ldap-sync/src/ldap_plugin.c Modified: plugins/ldap-sync/src/ldap_plugin.c ============================================================================== --- plugins/ldap-sync/src/ldap_plugin.c Mon Mar 30 17:06:09 2009 (r5464) +++ plugins/ldap-sync/src/ldap_plugin.c Mon Mar 30 17:10:59 2009 (r5465) @@ -410,7 +410,7 @@ } - timestamp = osync_anchor_retrieve(anchor, error); + timestamp = osync_anchor_retrieve(anchor, "latest_timestamp", error); if (timestamp) { osync_trace(TRACE_INTERNAL, "Latest timestamp in anchordb is: %s (objtype: \"%s\")\n", timestamp, osync_objtype_sink_get_name(sinkenv->sink)); @@ -428,7 +428,7 @@ if (sinkenv->latest_timestamp && sinkenv->latest_timestamp[0]) { - if (!osync_anchor_compare(anchor, sinkenv->latest_timestamp, &anchor_match, error)) { + if (!osync_anchor_compare(anchor, "latest_timestamp", sinkenv->latest_timestamp, &anchor_match, error)) { if (!osync_error_is_set(error)) { osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: osync_anchor_compare() has failed.", __FILE__, __LINE__); } @@ -4015,7 +4015,7 @@ goto error; } - if (!osync_anchor_update(anchor, sinkenv->latest_timestamp, &error)) { + if (!osync_anchor_update(anchor, "latest_timestamp", sinkenv->latest_timestamp, &error)) { if (!osync_error_is_set(&error)) { osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: osync_anchor_update() has failed.\n", __FILE__, __LINE__); } @@ -4107,7 +4107,7 @@ if (anchor == NULL) { osync_trace(TRACE_ERROR, "%s:%i: ERROR: anchor = NULL for objtype \"%s\". Ignoring for now.\n", __FILE__, __LINE__, osync_objtype_sink_get_name(sinkenv->sink)); } else { - timestamp = osync_anchor_retrieve(anchor, error); + timestamp = osync_anchor_retrieve(anchor, "latest_timestamp", error); #ifdef DEBUG_anchor ldap_plugin_printf("%s:%i: osync_anchor_retrieve() returned: \"%s\"", __FILE__, __LINE__, timestamp ? timestamp : "NULL"); #endif |
From: <svn...@op...> - 2009-03-30 15:06:23
|
Author: dgollub Date: Mon Mar 30 17:06:09 2009 New Revision: 5464 URL: http://www.opensync.org/changeset/5464 Log: Ported evolution2-sync to OSyncAnchor key=value API change. refs #1090 Modified: plugins/evolution2/src/evolution2_ebook.c plugins/evolution2/src/evolution2_ecal.c Modified: plugins/evolution2/src/evolution2_ebook.c ============================================================================== --- plugins/evolution2/src/evolution2_ebook.c Mon Mar 30 17:04:34 2009 (r5463) +++ plugins/evolution2/src/evolution2_ebook.c Mon Mar 30 17:06:09 2009 (r5464) @@ -148,7 +148,7 @@ osync_error_set(&error, OSYNC_ERROR_GENERIC, "Anchor missing for objtype \"%s\"", osync_objtype_sink_get_name(sink)); goto error_free_book; } - if (!osync_anchor_compare(anchor, env->addressbook_path, &anchor_match, &error)) { + if (!osync_anchor_compare(anchor, "path", env->addressbook_path, &anchor_match, &error)) { osync_error_set(&error, OSYNC_ERROR_GENERIC, "Anchor comparison failed for objtype \"%s\"", osync_objtype_sink_get_name(sink)); goto error_free_book; } @@ -199,7 +199,7 @@ osync_error_set(&error, OSYNC_ERROR_GENERIC, "Anchor missing for objtype \"%s\"", osync_objtype_sink_get_name(sink)); goto error; } - if (!osync_anchor_update(anchor, env->addressbook_path, &error)) + if (!osync_anchor_update(anchor, "path", env->addressbook_path, &error)) goto error; GList *changes = NULL; Modified: plugins/evolution2/src/evolution2_ecal.c ============================================================================== --- plugins/evolution2/src/evolution2_ecal.c Mon Mar 30 17:04:34 2009 (r5463) +++ plugins/evolution2/src/evolution2_ecal.c Mon Mar 30 17:06:09 2009 (r5464) @@ -98,7 +98,7 @@ osync_error_set(&error, OSYNC_ERROR_GENERIC, "Anchor missing for objtype \"%s\"", osync_objtype_sink_get_name(sink)); goto error_free_cal; } - if (!osync_anchor_compare(anchor, evo_cal->uri, &anchor_match, &error)) { + if (!osync_anchor_compare(anchor, "uri", evo_cal->uri, &anchor_match, &error)) { osync_error_set(&error, OSYNC_ERROR_GENERIC, "Anchor comparison failed for objtype \"%s\"", osync_objtype_sink_get_name(sink)); goto error_free_cal; } @@ -151,7 +151,7 @@ osync_error_set(&error, OSYNC_ERROR_GENERIC, "Anchor missing for objtype \"%s\"", osync_objtype_sink_get_name(sink)); goto error; } - if (!osync_anchor_update(anchor, evo_cal->uri, &error)) + if (!osync_anchor_update(anchor, "uri", evo_cal->uri, &error)) goto error; GList *changes = NULL; |
From: <svn...@op...> - 2009-03-30 15:04:48
|
Author: dgollub Date: Mon Mar 30 17:04:34 2009 New Revision: 5463 URL: http://www.opensync.org/changeset/5463 Log: Ported file-sync to OSyncAnchor key=value API change. refs #1090 Modified: plugins/file-sync/src/file_sync.c Modified: plugins/file-sync/src/file_sync.c ============================================================================== --- plugins/file-sync/src/file_sync.c Mon Mar 30 17:02:40 2009 (r5462) +++ plugins/file-sync/src/file_sync.c Mon Mar 30 17:04:34 2009 (r5463) @@ -62,7 +62,7 @@ OSyncAnchor *anchor = osync_objtype_sink_get_anchor(sink); osync_bool anchormatch; - if (!osync_anchor_compare(anchor, dir->path, &anchormatch, &error)) + if (!osync_anchor_compare(anchor, "path", dir->path, &anchormatch, &error)) goto error; if (!anchormatch) @@ -494,7 +494,7 @@ OSyncFileDir *dir = userdata; OSyncAnchor *anchor = osync_objtype_sink_get_anchor(sink); - if (!osync_anchor_update(anchor, dir->path, &error)) + if (!osync_anchor_update(anchor, "path", dir->path, &error)) goto error; osync_context_report_success(ctx); |
From: <svn...@op...> - 2009-03-30 15:02:48
|
Author: dgollub Date: Mon Mar 30 17:02:40 2009 New Revision: 5462 URL: http://www.opensync.org/changeset/5462 Log: Introduced OSyncAnchor key=value interface. This unfortuantely breaks the API and requires all plugins using the anchor to port. Porting instruction: char *anchor_value = plugin_specific_anchor(); -osync_anchor_compare(anchor, anchor_value, &anchormatch, &error); +osync_anchor_compare(anchor, "anchor_key"1, anchor_value, &anchormatch, &error); -osync_anchor_update(anchor, anchor_value, &error); +osync_anchor_update(anchor, "anchor_key1", anchor_value, &error); -osync_anchor_retrieve(anchor, &error); -osync_anchor_retrieve(anchor, "anchor_key1", &error); This key=value pair is per ObjTypeSink. This means you can reuse the key-name for each ObjTypeSink. Dropped old and unintended anchor.db file from test fixtures for filter_destobjtype_delete testcase fixes #1090 Deleted: trunk/tests/data/destobjtype_delete/configs/group/1/anchor.db Modified: trunk/docs/examples/plugins/src/plugin.c trunk/docs/examples/plugins/src/simple_plugin.c trunk/opensync/helper/opensync_anchor.c trunk/opensync/helper/opensync_anchor.h trunk/tests/mock-plugin/mock_sync.c Modified: trunk/docs/examples/plugins/src/plugin.c ============================================================================== --- trunk/docs/examples/plugins/src/plugin.c Mon Mar 30 14:32:13 2009 (r5461) +++ trunk/docs/examples/plugins/src/plugin.c Mon Mar 30 17:02:40 2009 (r5462) @@ -41,7 +41,7 @@ OSyncAnchor *anchor = osync_objtype_sink_get_anchor(sink); osync_bool anchormatch; - if (!osync_anchor_compare(anchor, "lanchor", &anchormatch, &error)) { + if (!osync_anchor_compare(anchor, "anchor_key", "dynamic_anchor_value", &anchormatch, &error)) { /* anchor couldn't be compared */ goto error; } @@ -236,7 +236,7 @@ //If we use anchors we have to update it now. //Now you get/calculate the current anchor of the device OSyncAnchor *anchor = osync_objtype_sink_get_anchor(sink); - if (!osync_anchor_update(anchor, "lanchor", &error)) { + if (!osync_anchor_update(anchor, "anchor_key", "dynamic_anchor_value", &error)) { goto error; } Modified: trunk/docs/examples/plugins/src/simple_plugin.c ============================================================================== --- trunk/docs/examples/plugins/src/simple_plugin.c Mon Mar 30 14:32:13 2009 (r5461) +++ trunk/docs/examples/plugins/src/simple_plugin.c Mon Mar 30 17:02:40 2009 (r5462) @@ -36,7 +36,7 @@ OSyncAnchor *anchor = osync_objtype_sink_get_anchor(sink); osync_bool anchormatch; - if (!osync_anchor_compare(anchor, "lanchor", &anchormatch, &error)) { + if (!osync_anchor_compare(anchor, "anchor_key", "dynamic_anchor_value", &anchormatch, &error)) { /* anchor couldn't be compared */ goto error; } @@ -167,7 +167,7 @@ //If we use anchors we have to update it now. //Now you get/calculate the current anchor of the device OSyncAnchor *anchor = osync_objtype_sink_get_anchor(sink); - if (!osync_anchor_update(anchor, "lanchor", &error)) + if (!osync_anchor_update(anchor, "anchor_key", "dynamic_anchor_value", &error)) goto error; //Answer the call Modified: trunk/opensync/helper/opensync_anchor.c ============================================================================== --- trunk/opensync/helper/opensync_anchor.c Mon Mar 30 14:32:13 2009 (r5461) +++ trunk/opensync/helper/opensync_anchor.c Mon Mar 30 17:02:40 2009 (r5462) @@ -32,7 +32,8 @@ char *query = NULL; osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, anchor, error); - query = osync_strdup("CREATE TABLE tbl_anchor (id INTEGER PRIMARY KEY, anchor VARCHAR, objtype VARCHAR UNIQUE)"); + /* TODO: How portable to other databes is UNIQUE? */ + query = osync_strdup("CREATE TABLE tbl_anchor (id INTEGER PRIMARY KEY, key VARCHAR UNIQUE, value VARCHAR, objtype VARCHAR)"); if (!osync_db_query(anchor->db, query, error)) { osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); @@ -125,15 +126,19 @@ } } -char *osync_anchor_retrieve(OSyncAnchor *anchor, OSyncError **error) +char *osync_anchor_retrieve(OSyncAnchor *anchor, const char *key, OSyncError **error) { char *retanchor = NULL; - char *query = NULL; + char *query = NULL, *escaped_key; osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, anchor, error); osync_assert(anchor); osync_assert(anchor->db); + osync_assert(key); - query = osync_strdup_printf("SELECT anchor FROM tbl_anchor WHERE objtype='%s'", anchor->objtype ? anchor->objtype : ""); + escaped_key = osync_db_sql_escape(key); + query = osync_strdup_printf("SELECT value FROM tbl_anchor WHERE key='%s' AND objtype='%s'", + escaped_key, anchor->objtype ? anchor->objtype : ""); + osync_free(escaped_key); retanchor = osync_db_query_single_string(anchor->db, query, error); osync_free(query); @@ -151,19 +156,22 @@ return NULL; } -osync_bool osync_anchor_update(OSyncAnchor *anchor, const char *value, OSyncError **error) +osync_bool osync_anchor_update(OSyncAnchor *anchor, const char *key, const char *value, OSyncError **error) { - char *escaped_value = NULL; + char *escaped_value = NULL, *escaped_key = NULL; char *query = NULL; osync_trace(TRACE_ENTRY, "%s(%p, %s, %p)", __func__, anchor, __NULLSTR(value), error); osync_assert(anchor); osync_assert(anchor->db); + osync_assert(key); osync_assert(value); + escaped_key = osync_db_sql_escape(key); escaped_value = osync_db_sql_escape(value); - query = osync_strdup_printf("REPLACE INTO tbl_anchor (objtype, anchor) VALUES('%s', '%s')", - anchor->objtype ? anchor->objtype : "", escaped_value); + query = osync_strdup_printf("REPLACE INTO tbl_anchor (objtype, key, value) VALUES('%s', '%s', '%s')", + anchor->objtype ? anchor->objtype : "", escaped_key, escaped_value); osync_free(escaped_value); + osync_free(escaped_key); if (!osync_db_query(anchor->db, query, error)) goto error; @@ -178,23 +186,25 @@ return FALSE; } -osync_bool osync_anchor_compare(OSyncAnchor *anchor, const char *new_anchor, osync_bool *same, OSyncError **error) +osync_bool osync_anchor_compare(OSyncAnchor *anchor, const char *key, const char *value, osync_bool *same, OSyncError **error) { - char *old_anchor = NULL; + char *old_value = NULL; - osync_trace(TRACE_ENTRY, "%s(%p, %s, %p, %p)", __func__, anchor, __NULLSTR(new_anchor), same, error); + osync_trace(TRACE_ENTRY, "%s(%p, %s, %s, %p, %p)", __func__, anchor, __NULLSTR(key), __NULLSTR(value), same, error); osync_assert(anchor); + osync_assert(key); + osync_assert(value); - old_anchor = osync_anchor_retrieve(anchor, error); - if (!old_anchor) + old_value = osync_anchor_retrieve(anchor, key, error); + if (!old_value) goto error; - if (!strcmp(old_anchor, new_anchor)) + if (!strcmp(old_value, value)) *same = TRUE; else *same = FALSE; - osync_free(old_anchor); + osync_free(old_value); osync_trace(TRACE_EXIT, "%s", __func__); return TRUE; Modified: trunk/opensync/helper/opensync_anchor.h ============================================================================== --- trunk/opensync/helper/opensync_anchor.h Mon Mar 30 14:32:13 2009 (r5461) +++ trunk/opensync/helper/opensync_anchor.h Mon Mar 30 17:02:40 2009 (r5462) @@ -28,10 +28,9 @@ * @ingroup OSyncHelper * @brief Functions to deal with anchors * - * The Anchor module stores some kind of data (called an "anchor") from the - * Member in a persistent database. This "anchor" gets updated once on each - * sync. If the "anchor" doesn't match on the next sync a slow-sync is - * triggered. + * The Anchor module stores anchors and peer states from the Member in a + * persistent database (which can be flushed by the Engien anytime!). + * This "anchor" shoudl get updated once on each sync. * * Example: * A random string gets generated by the member on each sync, eg. XYZ, and is @@ -50,37 +49,40 @@ */ /*@{*/ -/** @brief Compares the value of an anchor with the supplied value +/** @brief Compares the anchor value of key with the supplied value * * @param anchor Pointer to the anchor object - * @param new_anchor the value to compare with the stored value + * @param key the key of the value to compare + * @param value the value to compare with the stored anchor value * @param issame Pointer to osync_bool to determine the comaprsion result * @param error Pointer to error struct, which get set on any error * @returns TRUE if the anchor compare completed successful, FALSE on error. Not the return value of the comparsion! * */ -OSYNC_EXPORT osync_bool osync_anchor_compare(OSyncAnchor *anchor, const char *new_anchor, osync_bool *issame, OSyncError **error); +OSYNC_EXPORT osync_bool osync_anchor_compare(OSyncAnchor *anchor, const char *key, const char *value, osync_bool *issame, OSyncError **error); -/** @brief Updates the value of an anchor +/** @brief Updates the anchor value of the key * * @param anchor Pointer to the anchor object - * @param new_anchor the new value to set + * @param key the key of the value to set + * @param value the new value to set * @param error Pointer to error struct, which get set on any error * @returns TRUE if anchor update completed successful, FALSE on error. * */ -OSYNC_EXPORT osync_bool osync_anchor_update(OSyncAnchor *anchor, const char *new_anchor, OSyncError **error); +OSYNC_EXPORT osync_bool osync_anchor_update(OSyncAnchor *anchor, const char *key, const char *value, OSyncError **error); -/** @brief Retrieves the value of an anchor +/** @brief Retrieves the anchor value of the supplied key * * @param anchor Pointer to the anchor object + * @param key The key as string of the anchor value to retrieve * @param error Pointer to error struct, which get set on any error * @returns the value of the anchor if it was found, otherwise an empty string get retruned. * Caller is responsible for freeing the return value with osync_free(). * NULL on error of retrieving the anchor information. * */ -OSYNC_EXPORT char *osync_anchor_retrieve(OSyncAnchor *anchor, OSyncError **error); +OSYNC_EXPORT char *osync_anchor_retrieve(OSyncAnchor *anchor, const char *key, OSyncError **error); /*@}*/ Modified: trunk/tests/mock-plugin/mock_sync.c ============================================================================== --- trunk/tests/mock-plugin/mock_sync.c Mon Mar 30 14:32:13 2009 (r5461) +++ trunk/tests/mock-plugin/mock_sync.c Mon Mar 30 17:02:40 2009 (r5462) @@ -87,7 +87,7 @@ */ dir->connect_done = FALSE; - osync_assert_msg(osync_anchor_compare(anchor, dir->path, &anchor_compare_match, NULL), "Not expected to fail"); + osync_assert_msg(osync_anchor_compare(anchor, "path", dir->path, &anchor_compare_match, NULL), "Not expected to fail"); if (!anchor_compare_match) osync_context_report_slowsync(ctx); @@ -563,7 +563,7 @@ if (mock_get_error(info->memberid, "SYNC_DONE_TIMEOUT")) return; - osync_assert_msg(osync_anchor_update(anchor, dir->path, NULL), "Not expected to fail!"); + osync_assert_msg(osync_anchor_update(anchor, "path", dir->path, NULL), "Not expected to fail!"); osync_context_report_success(ctx); |
From: <svn...@op...> - 2009-03-30 12:32:20
|
Author: dgollub Date: Mon Mar 30 14:32:13 2009 New Revision: 5461 URL: http://www.opensync.org/changeset/5461 Log: Fix warning about different signess compare in string marshal functions. Spotted by Björn. Modified: trunk/opensync/common/opensync_marshal.c Modified: trunk/opensync/common/opensync_marshal.c ============================================================================== --- trunk/opensync/common/opensync_marshal.c Mon Mar 30 10:29:50 2009 (r5460) +++ trunk/opensync/common/opensync_marshal.c Mon Mar 30 14:32:13 2009 (r5461) @@ -105,14 +105,14 @@ void osync_marshal_write_string(OSyncMarshal *marshal, const char *value) { unsigned int length = 0; - if (value == NULL) { - length = -1; - g_byte_array_append( marshal->buffer, (unsigned char*)&length, sizeof( unsigned int ) ); - } else { - length = strlen( value ) + 1; - g_byte_array_append( marshal->buffer, (unsigned char*)&length, sizeof( unsigned int ) ); + + if (value) + length = strlen(value) + 1; + + g_byte_array_append( marshal->buffer, (unsigned char*)&length, sizeof( unsigned int ) ); + + if (value) g_byte_array_append( marshal->buffer, (unsigned char*)value, length ); - } } void osync_marshal_write_data(OSyncMarshal *marshal, const void *value, unsigned int size) @@ -174,7 +174,7 @@ unsigned int length = 0; osync_marshal_read_uint(marshal, &length); - if (length == -1) { + if (!length) { *value = NULL; return; } |
From: <svn...@op...> - 2009-03-30 11:05:49
|
Author: bellmich Date: Mon Mar 30 13:05:37 2009 New Revision: 1023 URL: http://libsyncml.opensync.org/changeset/1023 Log: - fixed duplicate disconnects which can cause memory leaks - fixed wrong trace statement Modified: trunk/libsyncml/sml_transport.c Modified: trunk/libsyncml/sml_transport.c ============================================================================== --- trunk/libsyncml/sml_transport.c Thu Mar 26 17:54:02 2009 (r1022) +++ trunk/libsyncml/sml_transport.c Mon Mar 30 13:05:37 2009 (r1023) @@ -148,6 +148,26 @@ smlTrace(TRACE_INTERNAL, "%s: No disconnect function", __func__); break; } + /* If there is a disconnect request + * but the connection is already down + * then an earlier disconnect happened + * (perhaps initiated by the remote peer) + * and we can ignore the disconnect. + */ + if (smlTransportIsServer(tsp) && !cmd->link->link_data) { + /* The SERVER is already disconnected. */ + smlTrace(TRACE_INTERNAL, + "%s: The server link was already disconnected.", + __func__); + break; + } + if (!smlTransportIsServer(tsp) && !tsp->connected) { + /* The CLIENT is already disconnected. */ + smlTrace(TRACE_INTERNAL, + "%s: The client was already disconnected.", + __func__); + break; + } tsp->functions.disconnect(tsp->transport_data, cmd->link ? cmd->link->link_data : NULL); break; } @@ -287,7 +307,7 @@ { if (!smlTransportIsServer(tsp)) g_error("A disconnect event with a link was received " \ - "but the transport layer is a server."); + "but the transport layer is not a server."); if (link->link_data) g_error("A disconnect event with a link was received " \ "but the link still contains the " \ |
From: <svn...@op...> - 2009-03-30 08:29:57
|
Author: bricks Date: Mon Mar 30 10:29:50 2009 New Revision: 5460 URL: http://www.opensync.org/changeset/5460 Log: ported tomboy-sync to latest api changes plugin needs an additional review Modified: plugins/tomboy-sync/src/tomboy_sync.c plugins/tomboy-sync/src/tomboy_sync.h plugins/tomboy-sync/src/tomboy_sync_dbus.c plugins/tomboy-sync/src/tomboy_sync_dbus.h plugins/tomboy-sync/src/tomboy_sync_file.c plugins/tomboy-sync/src/tomboy_sync_file.h Modified: plugins/tomboy-sync/src/tomboy_sync.c ============================================================================== --- plugins/tomboy-sync/src/tomboy_sync.c Mon Mar 30 07:00:46 2009 (r5459) +++ plugins/tomboy-sync/src/tomboy_sync.c Mon Mar 30 10:29:50 2009 (r5460) @@ -1,6 +1,6 @@ /* * tomboy-sync - A plugin for the opensync framework - * Copyright (C) 2008 Bjoern Ricks <bjo...@go...> + * Copyright (C) 2008-2009 Bjoern Ricks <bjo...@go...> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -33,12 +33,27 @@ if (dir->sink) osync_objtype_sink_unref(dir->sink); - if (dir->hashtable) - osync_hashtable_unref(dir->hashtable); - g_free(dir); } +osync_bool osync_tomboysync_compare_anchor(OSyncAnchor *anchor, OSyncContext *ctx, const char *new_anchor, OSyncError **error) { + + osync_bool anchormatch; + + if ( !osync_anchor_compare(anchor, new_anchor, &anchormatch, error) ) { + /* anchor couldn't be compared */ + goto error; + } + if ( !anchormatch ) { + /* request slow sync */ + osync_context_report_slowsync(ctx); + } + return TRUE; + +error: + return FALSE; +} + /* * validates a uuid and returns true if the uuid has the right format */ @@ -149,14 +164,15 @@ } } } - int i, numobjs = osync_plugin_info_num_objtypes(info); - for (i = 0; i < numobjs; i++) { + OSyncList *objtypes = osync_plugin_info_get_objtype_sinks(info); + OSyncList *o = NULL; + for (o = objtypes; o; o = o->next) { OSyncTomboyDir *dir = osync_try_malloc0(sizeof(OSyncTomboyDir), error); if (!dir) { goto error; } dir->env = tomboyenv; - dir->sink = osync_plugin_info_nth_objtype(info, i); + dir->sink = (OSyncObjTypeSink*)o->data; osync_assert(dir->sink); const char *objtype = osync_objtype_sink_get_name(dir->sink); @@ -183,72 +199,42 @@ } /* All sinks have the same functions of course */ - OSyncObjTypeSinkFunctions functions; - memset(&functions, 0, sizeof(functions)); #ifdef ENABLE_DBUS if ( usedbus ) { osync_trace(TRACE_INTERNAL, "using dbus for sync."); - functions.get_changes = osync_tomboysync_dbus_get_changes; - functions.commit = osync_tomboysync_dbus_commit_change; - functions.read = osync_tomboysync_dbus_read; - functions.write = osync_tomboysync_dbus_write; - functions.sync_done = osync_tomboysync_dbus_sync_done; + osync_objtype_sink_set_connect_func(dir->sink, osync_tomboysync_dbus_connect); + osync_objtype_sink_set_get_changes_func(dir->sink, osync_tomboysync_dbus_get_changes); + osync_objtype_sink_set_commit_func(dir->sink, osync_tomboysync_dbus_commit_change); + osync_objtype_sink_set_read_func(dir->sink, osync_tomboysync_dbus_read); + osync_objtype_sink_set_sync_done_func(dir->sink, osync_tomboysync_dbus_sync_done); } else { #endif /* ENABLE_DBUS */ osync_trace(TRACE_INTERNAL, "using file for sync."); - functions.get_changes = osync_tomboysync_file_get_changes; - functions.commit = osync_tomboysync_file_commit_change; - functions.read = osync_tomboysync_file_read; - functions.write = osync_tomboysync_file_write; - functions.sync_done = osync_tomboysync_file_sync_done; + osync_objtype_sink_set_connect_func(dir->sink, osync_tomboysync_file_connect); + osync_objtype_sink_set_get_changes_func(dir->sink, osync_tomboysync_file_get_changes); + osync_objtype_sink_set_commit_func(dir->sink, osync_tomboysync_file_commit_change); + osync_objtype_sink_set_read_func(dir->sink, osync_tomboysync_file_read); + osync_objtype_sink_set_sync_done_func(dir->sink, osync_tomboysync_file_sync_done); #ifdef ENABLE_DBUS } #endif /* ENABLE_DBUS */ /* We pass the OSyncTomboyDir object to the sink, so we dont have to look it up * again once the functions are called */ - osync_objtype_sink_set_functions(dir->sink, functions, dir); + osync_objtype_sink_set_userdata(dir->sink, dir); - osync_trace(TRACE_INTERNAL, "The configdir: %s", osync_plugin_info_get_configdir(info)); - char *tablepath = g_strdup_printf("%s/hashtable.db", osync_plugin_info_get_configdir(info)); - dir->hashtable = osync_hashtable_new(tablepath, objtype, error); - g_free(tablepath); + /* Request Hashtable */ + osync_objtype_sink_enable_hashtable(dir->sink, TRUE); - if (!dir->hashtable) - goto error; - - if (!osync_hashtable_load(dir->hashtable, error)) - goto error; - - char *path_field = g_strdup_printf("path_%s", osync_objtype_sink_get_name(dir->sink)); - OSyncAnchor *anchor = osync_objtype_sink_get_anchor(dir->sink); - osync_bool anchormatch; + /* Enable Anchors */ + osync_objtype_sink_enable_anchor(dir->sink, TRUE); - if ( !osync_anchor_compare(anchor, tomboyenv->homedir_path, &anchormatch, error) ) { - /* anchor couldn't be compared */ - goto error; - } - if ( !anchormatch ) { - /* request slow sync */ - osync_objtype_sink_set_slowsync(dir->sink, TRUE); - } - g_free(path_field); - -#ifdef ENABLE_DBUS - if (usedbus) { - if (!osync_tomboysync_dbus_initalize(tomboyenv,error)) { + if ( !usedbus ) { + if (!osync_tomboysync_file_initalize(tomboyenv, error)) { goto error; } } - else { -#endif /* ENABLE_DBUS */ - if (!osync_tomboysync_file_initalize(tomboyenv, error)) { - goto error; - } -#ifdef ENABLE_DBUS - } -#endif /* ENABLE_DBUS */ } osync_trace(TRACE_EXIT, "%s: %p", __func__); @@ -294,8 +280,7 @@ osync_plugin_info_set_version(info, version); osync_version_unref(version); - /* we can set here the capabilities, but for the file-sync - * plugin they are static and shipped with opensync */ + /* set here the capabilities in the future */ osync_trace(TRACE_EXIT, "%s", __func__); return TRUE; Modified: plugins/tomboy-sync/src/tomboy_sync.h ============================================================================== --- plugins/tomboy-sync/src/tomboy_sync.h Mon Mar 30 07:00:46 2009 (r5459) +++ plugins/tomboy-sync/src/tomboy_sync.h Mon Mar 30 10:29:50 2009 (r5460) @@ -1,6 +1,6 @@ /* * tomboy-sync - A plugin for the opensync framework - * Copyright (C) 2008 Bjoern Ricks <bjo...@go...> + * Copyright (C) 2008-2009 Bjoern Ricks <bjo...@go...> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -53,7 +53,6 @@ typedef struct OSyncTomboyDir { OSyncObjFormat *objformat; // GDir *dir; - OSyncHashTable *hashtable; OSyncObjTypeSink *sink; OSyncTomboyEnv *env; } OSyncTomboyDir; Modified: plugins/tomboy-sync/src/tomboy_sync_dbus.c ============================================================================== --- plugins/tomboy-sync/src/tomboy_sync_dbus.c Mon Mar 30 07:00:46 2009 (r5459) +++ plugins/tomboy-sync/src/tomboy_sync_dbus.c Mon Mar 30 10:29:50 2009 (r5460) @@ -1,6 +1,6 @@ /* * tomboy-sync - A plugin for the opensync framework - * Copyright (C) 2008 Bjoern Ricks <bjo...@go...> + * Copyright (C) 2008-2009 Bjoern Ricks <bjo...@go...> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -43,6 +43,7 @@ OSyncError *error = NULL; OSyncData *odata = NULL; OSyncObjFormat *tomboynoteformat = NULL; + OSyncHashTable *hashtable = osync_objtype_sink_get_hashtable(sink); GError *gerror = NULL; char **name_list; char **name_list_ptr; @@ -53,7 +54,7 @@ if ( slow_sync ) { osync_trace(TRACE_INTERNAL, "Slow sync requested"); /* prepare hashtable for slowsync (flush entries) */ - if (!osync_hashtable_slowsync(dir->hashtable, &error)) { + if (!osync_hashtable_slowsync(hashtable, &error)) { osync_context_report_osyncerror(ctx, error); osync_trace(TRACE_EXIT_ERROR, "%s - %s", __func__, osync_error_print(&error)); osync_error_unref(&error); @@ -118,10 +119,10 @@ osync_change_set_hash(change, hash); g_free(hash); - OSyncChangeType type = osync_hashtable_get_changetype(dir->hashtable, change); + OSyncChangeType type = osync_hashtable_get_changetype(hashtable, change); osync_change_set_changetype(change, type); /* if change is modified (other hashvalue then in the hashtable) write the new value to the hashtable */ - osync_hashtable_update_change(dir->hashtable, change); + osync_hashtable_update_change(hashtable, change); if (type == OSYNC_CHANGE_TYPE_UNMODIFIED) { g_free(uuid); @@ -150,7 +151,7 @@ g_strfreev(name_list); /* get all items which weren't changed in osync_tomboysync_file_report_dir. These items have to be deleted */ - OSyncList *u, *uids = osync_hashtable_get_deleted(dir->hashtable); + OSyncList *u, *uids = osync_hashtable_get_deleted(hashtable); for (u = uids; u; u = u->next) { OSyncChange *change = osync_change_new(&error); if (!change) { @@ -177,7 +178,7 @@ osync_context_report_change(ctx, change); - osync_hashtable_update_change(dir->hashtable, change); + osync_hashtable_update_change(hashtable, change); osync_change_unref(change); } @@ -193,6 +194,7 @@ OSyncTomboyDir *dir = (OSyncTomboyDir*)userdata; //OSyncTomboyEnv *tomboyenv = dir->env; OSyncData *odata = NULL; + OSyncHashTable *hashtable = osync_objtype_sink_get_hashtable(sink); int size; char *hash = NULL; @@ -210,7 +212,7 @@ hash = osync_tomboysync_generate_hash(buffer, size); osync_change_set_hash(change, hash); } - osync_hashtable_update_change(dir->hashtable, change); + osync_hashtable_update_change(hashtable, change); osync_context_report_success(ctx); g_free(hash); osync_trace(TRACE_EXIT, "%s", __func__); @@ -229,9 +231,6 @@ goto error; } - if (!osync_hashtable_save(dir->hashtable, &error)) - goto error; - osync_context_report_success(ctx); g_object_unref(dir->env->proxy); @@ -412,23 +411,46 @@ osync_bool osync_tomboysync_dbus_initalize(OSyncTomboyEnv *tomboyenv, OSyncError **error) { osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, tomboyenv, error); - osync_assert(tomboyenv); + + return TRUE; +error: + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return FALSE; +} + +void osync_tomboysync_dbus_connect(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *data) { + + osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, sink, info, ctx, data); + + OSyncError *error = NULL; + OSyncTomboyDir *dir = (OSyncTomboyDir*)data; + OSyncTomboyEnv *tomboyenv = dir->env; GError *gerror = NULL; g_type_init(); tomboyenv->connection = dbus_g_bus_get(DBUS_BUS_SESSION, &gerror); if (tomboyenv->connection == NULL) { - osync_error_set(error, OSYNC_ERROR_NO_CONNECTION, "Could not connect to dbus. Error \"%s\".", gerror->message); + osync_error_set(&error, OSYNC_ERROR_NO_CONNECTION, "Could not connect to dbus. Error \"%s\".", gerror->message); g_error_free(gerror); goto error; } tomboyenv->proxy = dbus_g_proxy_new_for_name(tomboyenv->connection, TOMBOY_DBUS_NAME, TOMBOY_DBUS_PATH, TOMBOY_DBUS_INTERFACE); - return TRUE; + + OSyncAnchor *anchor = osync_objtype_sink_get_anchor(dir->sink); + + if (!osync_tomboysync_compare_anchor(anchor, ctx, tomboyenv->homedir_path, &error) ) { + goto error; + } + + osync_context_report_success(ctx); + osync_trace(TRACE_EXIT, "%s", __func__); + return; error: - osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - return FALSE; + osync_context_report_osyncerror(ctx, error); + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error)); + osync_error_unref(&error); } #endif /* ENABLE_DBUS */ Modified: plugins/tomboy-sync/src/tomboy_sync_dbus.h ============================================================================== --- plugins/tomboy-sync/src/tomboy_sync_dbus.h Mon Mar 30 07:00:46 2009 (r5459) +++ plugins/tomboy-sync/src/tomboy_sync_dbus.h Mon Mar 30 10:29:50 2009 (r5460) @@ -1,6 +1,6 @@ /* * tomboy-sync - A plugin for the opensync framework - * Copyright (C) 2008 Bjoern Ricks <bjo...@go...> + * Copyright (C) 2008-2009 Bjoern Ricks <bjo...@go...> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -35,6 +35,8 @@ osync_bool osync_tomboysync_dbus_initalize(OSyncTomboyEnv *tomboyenv, OSyncError **error); +void osync_tomboysync_dbus_connect(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *data); + #endif /* ENABLE_DBUS */ #endif /* TOMBOY_SYNC_DBUS_H_ */ Modified: plugins/tomboy-sync/src/tomboy_sync_file.c ============================================================================== --- plugins/tomboy-sync/src/tomboy_sync_file.c Mon Mar 30 07:00:46 2009 (r5459) +++ plugins/tomboy-sync/src/tomboy_sync_file.c Mon Mar 30 10:29:50 2009 (r5460) @@ -1,6 +1,6 @@ /* * tomboy-sync - A plugin for the opensync framework - * Copyright (C) 2008 Bjoern Ricks <bjo...@go...> + * Copyright (C) 2008-2009 Bjoern Ricks <bjo...@go...> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -40,6 +40,7 @@ const char *homedir = tomboyenv->homedir_path; path = g_build_filename(homedir,".tomboy", NULL); osync_trace(TRACE_INTERNAL, "path %s", path); + OSyncHashTable *hashtable = osync_objtype_sink_get_hashtable(directory->sink); dir = g_dir_open(path, 0, &gerror); if (!dir) { @@ -96,10 +97,10 @@ osync_change_set_hash(change, hash); g_free(hash); - OSyncChangeType type = osync_hashtable_get_changetype(directory->hashtable, change); + OSyncChangeType type = osync_hashtable_get_changetype(hashtable, change); osync_change_set_changetype(change, type); /* if change is modified (other hashvalue then in the hashtable) write the new value to the hashtable */ - osync_hashtable_update_change(directory->hashtable, change); + osync_hashtable_update_change(hashtable, change); if (type == OSYNC_CHANGE_TYPE_UNMODIFIED) { g_free(filename); @@ -149,12 +150,13 @@ OSyncTomboyDir *dir = (OSyncTomboyDir*)userdata; OSyncFormatEnv *formatenv = osync_plugin_info_get_format_env(info); OSyncError *error = NULL; + OSyncHashTable *hashtable = osync_objtype_sink_get_hashtable(sink); /* is slowsync necessary */ if ( slow_sync ) { osync_trace(TRACE_INTERNAL, "Slow sync requested"); /* prepare hashtable for slowsync (flush entries) */ - if (!osync_hashtable_slowsync(dir->hashtable, &error)) + if (!osync_hashtable_slowsync(hashtable, &error)) { osync_context_report_osyncerror(ctx, error); osync_trace(TRACE_EXIT_ERROR, "%s - %s", __func__, osync_error_print(&error)); @@ -169,7 +171,7 @@ osync_tomboysync_file_report_dir(dir, info, NULL, ctx); /* get all items which weren't changed in osync_tomboysync_file_report_dir. These items have to be deleted */ - OSyncList *u, *uids = osync_hashtable_get_deleted(dir->hashtable); + OSyncList *u, *uids = osync_hashtable_get_deleted(hashtable); for (u = uids; u; u = u->next) { OSyncChange *change = osync_change_new(&error); if (!change) { @@ -198,7 +200,7 @@ osync_context_report_change(ctx, change); - osync_hashtable_update_change(dir->hashtable, change); + osync_hashtable_update_change(hashtable, change); osync_change_unref(change); } @@ -217,6 +219,7 @@ OSyncTomboyDir *dir = (OSyncTomboyDir*)userdata; OSyncTomboyEnv *tomboyenv = dir->env; + OSyncHashTable *hashtable = osync_objtype_sink_get_hashtable(sink); char *filename = NULL; char* tomboydir = NULL; @@ -241,7 +244,7 @@ g_free(filename); g_free(tomboydir); - osync_hashtable_update_change(dir->hashtable, change); + osync_hashtable_update_change(hashtable, change); g_free(hash); osync_context_report_success(ctx); @@ -264,9 +267,6 @@ goto error; } - if (!osync_hashtable_save(dir->hashtable, &error)) - goto error; - osync_context_report_success(ctx); osync_trace(TRACE_EXIT, "%s", __func__); @@ -409,7 +409,26 @@ osync_error_unref(&error); return FALSE; } - +void osync_tomboysync_file_connect(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *data) { + osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, sink, info, ctx, data); + + OSyncError *error = NULL; + OSyncTomboyDir *dir = (OSyncTomboyDir*)data; + OSyncTomboyEnv *tomboyenv = dir->env; + OSyncAnchor *anchor = osync_objtype_sink_get_anchor(dir->sink); + + if (!osync_tomboysync_compare_anchor(anchor, ctx, tomboyenv->homedir_path, &error) ) { + goto error; + } + + osync_context_report_success(ctx); + osync_trace(TRACE_EXIT, "%s", __func__); + return; +error: + osync_context_report_osyncerror(ctx, error); + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error)); + osync_error_unref(&error); +} osync_bool osync_tomboysync_file_initalize(OSyncTomboyEnv *tomboyenv, OSyncError **error) { osync_assert(tomboyenv); osync_assert(tomboyenv->homedir_path); Modified: plugins/tomboy-sync/src/tomboy_sync_file.h ============================================================================== --- plugins/tomboy-sync/src/tomboy_sync_file.h Mon Mar 30 07:00:46 2009 (r5459) +++ plugins/tomboy-sync/src/tomboy_sync_file.h Mon Mar 30 10:29:50 2009 (r5460) @@ -1,6 +1,6 @@ /* * tomboy-sync - A plugin for the opensync framework - * Copyright (C) 2008 Bjoern Ricks <bjo...@go...> + * Copyright (C) 2008-2009 Bjoern Ricks <bjo...@go...> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -35,4 +35,6 @@ osync_bool osync_tomboysync_file_initalize(OSyncTomboyEnv *tomboyenv, OSyncError **error); +void osync_tomboysync_file_connect(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *data); + #endif /* TOMBOY_SYNC_FILE_H_ */ |
From: <svn...@op...> - 2009-03-30 05:00:53
|
Author: dgollub Date: Mon Mar 30 07:00:46 2009 New Revision: 5459 URL: http://www.opensync.org/changeset/5459 Log: Fix compiler warning regarding comparing with different signess. This warning got introduced due marshal cleanup with r5458 Modified: plugins/file-sync/src/file.c Modified: plugins/file-sync/src/file.c ============================================================================== --- plugins/file-sync/src/file.c Mon Mar 30 06:59:57 2009 (r5458) +++ plugins/file-sync/src/file.c Mon Mar 30 07:00:46 2009 (r5459) @@ -184,7 +184,7 @@ goto error; osync_marshal_read_string(marshal, &(file->path)); - osync_marshal_read_buffer(marshal, (void *)&(file->data), (int *)&(file->size)); + osync_marshal_read_buffer(marshal, (void *)&(file->data), &(file->size)); *output = (char *)file; *outpsize = sizeof(OSyncFileFormat); |
From: <svn...@op...> - 2009-03-30 05:00:00
|
Author: dgollub Date: Mon Mar 30 06:59:57 2009 New Revision: 5458 URL: http://www.opensync.org/changeset/5458 Log: Cleaned up int vs. unsigned int for marshal API refs #974 Modified: trunk/opensync/common/opensync_marshal.c trunk/opensync/common/opensync_marshal.h trunk/opensync/ipc/opensync_message.c trunk/opensync/ipc/opensync_message_internals.h trunk/opensync/ipc/opensync_serializer.c trunk/tests/format-tests/check_objformat.c trunk/tests/mock-plugin/mock_format.c Modified: trunk/opensync/common/opensync_marshal.c ============================================================================== --- trunk/opensync/common/opensync_marshal.c Mon Mar 30 06:57:37 2009 (r5457) +++ trunk/opensync/common/opensync_marshal.c Mon Mar 30 06:59:57 2009 (r5458) @@ -104,28 +104,28 @@ void osync_marshal_write_string(OSyncMarshal *marshal, const char *value) { - int length = 0; + unsigned int length = 0; if (value == NULL) { length = -1; - g_byte_array_append( marshal->buffer, (unsigned char*)&length, sizeof( int ) ); + g_byte_array_append( marshal->buffer, (unsigned char*)&length, sizeof( unsigned int ) ); } else { - int length = strlen( value ) + 1; - g_byte_array_append( marshal->buffer, (unsigned char*)&length, sizeof( int ) ); + length = strlen( value ) + 1; + g_byte_array_append( marshal->buffer, (unsigned char*)&length, sizeof( unsigned int ) ); g_byte_array_append( marshal->buffer, (unsigned char*)value, length ); } } -void osync_marshal_write_data(OSyncMarshal *marshal, const void *value, int size) +void osync_marshal_write_data(OSyncMarshal *marshal, const void *value, unsigned int size) { /* TODO move this to PRIVATE API */ g_byte_array_append( marshal->buffer, value, size ); } -void osync_marshal_write_buffer(OSyncMarshal *marshal, const void *value, int size) +void osync_marshal_write_buffer(OSyncMarshal *marshal, const void *value, unsigned int size) { /* serialize the length of the data to make it possible to determine the end of this data blob in the serialized blob. This makes demarshaling possible! */ - osync_marshal_write_int(marshal, size); + osync_marshal_write_uint(marshal, size); if (size > 0) osync_marshal_write_data(marshal, value, size); } @@ -171,8 +171,8 @@ void osync_marshal_read_string(OSyncMarshal *marshal, char **value) { - int length = 0; - osync_marshal_read_int(marshal, &length); + unsigned int length = 0; + osync_marshal_read_uint(marshal, &length); if (length == -1) { *value = NULL; @@ -190,7 +190,7 @@ marshal->buffer_read_pos += length; } -void osync_marshal_read_const_data(OSyncMarshal *marshal, void **value, int size) +void osync_marshal_read_const_data(OSyncMarshal *marshal, void **value, unsigned int size) { osync_assert(marshal->buffer->len >= marshal->buffer_read_pos + size); @@ -198,7 +198,7 @@ marshal->buffer_read_pos += size; } -void osync_marshal_read_data(OSyncMarshal *marshal, void *value, int size) +void osync_marshal_read_data(OSyncMarshal *marshal, void *value, unsigned int size) { osync_assert(marshal->buffer->len >= marshal->buffer_read_pos + size); @@ -206,10 +206,10 @@ marshal->buffer_read_pos += size; } -void osync_marshal_read_buffer(OSyncMarshal *marshal, void **value, int *size) +void osync_marshal_read_buffer(OSyncMarshal *marshal, void **value, unsigned int *size) { /* Now, read the data from the marshal */ - osync_marshal_read_int(marshal, size); + osync_marshal_read_uint(marshal, size); if (*size > 0) { *value = g_malloc0(*size); Modified: trunk/opensync/common/opensync_marshal.h ============================================================================== --- trunk/opensync/common/opensync_marshal.h Mon Mar 30 06:57:37 2009 (r5457) +++ trunk/opensync/common/opensync_marshal.h Mon Mar 30 06:59:57 2009 (r5458) @@ -127,7 +127,7 @@ * @param value The data to append * @param size Size of corresponding data parameter */ -OSYNC_EXPORT void osync_marshal_write_data(OSyncMarshal *marshal, const void *value, int size); +OSYNC_EXPORT void osync_marshal_write_data(OSyncMarshal *marshal, const void *value, unsigned int size); /** @brief Appends data with a specific length to the serialized buffer, * plus the length of the data to determine the end. @@ -136,7 +136,7 @@ * @param value The data to append * @param size Size of corresponding data parameter */ -OSYNC_EXPORT void osync_marshal_write_buffer(OSyncMarshal *marshal, const void *value, int size); +OSYNC_EXPORT void osync_marshal_write_buffer(OSyncMarshal *marshal, const void *value, unsigned int size); /** @brief Read serialized integer from marshal buffer. This increments the read * position of the marshal buffer. @@ -179,7 +179,7 @@ * @param value Reference to store the pointer to the newly allocated data * @param size Size of data */ -OSYNC_EXPORT void osync_marshal_read_data(OSyncMarshal *marshal, void *value, int size); +OSYNC_EXPORT void osync_marshal_read_data(OSyncMarshal *marshal, void *value, unsigned int size); /** @brief Read serialized const data from marshal buffer. This increments the read * position of the marshal buffer. @@ -188,7 +188,7 @@ * @param value Reference to store the data pointer * @param size The size of data */ -OSYNC_EXPORT void osync_marshal_read_const_data(OSyncMarshal *marshal, void **value, int size); +OSYNC_EXPORT void osync_marshal_read_const_data(OSyncMarshal *marshal, void **value, unsigned int size); /** @brief Read serialized const string from marshal buffer. This increments the read * position of the marshal buffer. @@ -206,7 +206,7 @@ * @param value Reference to store the pointer to the newly allocated data * @param size Size of data */ -OSYNC_EXPORT void osync_marshal_read_buffer(OSyncMarshal *marshal, void **value, int *size); +OSYNC_EXPORT void osync_marshal_read_buffer(OSyncMarshal *marshal, void **value, unsigned int *size); /*@}*/ Modified: trunk/opensync/ipc/opensync_message.c ============================================================================== --- trunk/opensync/ipc/opensync_message.c Mon Mar 30 06:57:37 2009 (r5457) +++ trunk/opensync/ipc/opensync_message.c Mon Mar 30 06:59:57 2009 (r5458) @@ -225,12 +225,12 @@ osync_marshal_write_string(message->marshal, value); } -void osync_message_write_data(OSyncMessage *message, const void *value, int size) +void osync_message_write_data(OSyncMessage *message, const void *value, unsigned int size) { osync_marshal_write_data(message->marshal, value, size); } -void osync_message_write_buffer(OSyncMessage *message, const void *value, int size) +void osync_message_write_buffer(OSyncMessage *message, const void *value, unsigned int size) { osync_marshal_write_buffer(message->marshal, value, size); } @@ -261,17 +261,17 @@ osync_marshal_read_string(message->marshal, value); } -void osync_message_read_const_data(OSyncMessage *message, void **value, int size) +void osync_message_read_const_data(OSyncMessage *message, void **value, unsigned int size) { osync_marshal_read_const_data(message->marshal, value, size); } -void osync_message_read_data(OSyncMessage *message, void *value, int size) +void osync_message_read_data(OSyncMessage *message, void *value, unsigned int size) { osync_marshal_read_data(message->marshal, value, size); } -void osync_message_read_buffer(OSyncMessage *message, void **value, int *size) +void osync_message_read_buffer(OSyncMessage *message, void **value, unsigned int *size) { osync_marshal_read_buffer(message->marshal, value, size); } Modified: trunk/opensync/ipc/opensync_message_internals.h ============================================================================== --- trunk/opensync/ipc/opensync_message_internals.h Mon Mar 30 06:57:37 2009 (r5457) +++ trunk/opensync/ipc/opensync_message_internals.h Mon Mar 30 06:59:57 2009 (r5458) @@ -309,7 +309,7 @@ * @param value The data to append * @param size Size of corresponding data parameter */ -OSYNC_TEST_EXPORT void osync_message_write_data(OSyncMessage *message, const void *value, int size); +OSYNC_TEST_EXPORT void osync_message_write_data(OSyncMessage *message, const void *value, unsigned int size); /** @brief Appends data with a specific length to the serialized message buffer, * plus the length of the data to determine the end. @@ -318,7 +318,7 @@ * @param value The data to append * @param size Size of corresponding data parameter */ -OSYNC_TEST_EXPORT void osync_message_write_buffer(OSyncMessage *message, const void *value, int size); +OSYNC_TEST_EXPORT void osync_message_write_buffer(OSyncMessage *message, const void *value, unsigned int size); /** @brief Read serialized integer from message buffer. This increments the read * position of the message buffer. @@ -361,7 +361,7 @@ * @param value Reference to store the pointer to the newly allocated data * @param size Size of data */ -OSYNC_TEST_EXPORT void osync_message_read_data(OSyncMessage *message, void *value, int size); +OSYNC_TEST_EXPORT void osync_message_read_data(OSyncMessage *message, void *value, unsigned int size); /** @brief Read serialized const data from message buffer. This increments the read * position of the message buffer. @@ -370,7 +370,7 @@ * @param value Reference to store the data pointer * @param size The size of data */ -OSYNC_TEST_EXPORT void osync_message_read_const_data(OSyncMessage *message, void **value, int size); +OSYNC_TEST_EXPORT void osync_message_read_const_data(OSyncMessage *message, void **value, unsigned int size); /** @brief Read serialized const string from message buffer. This increments the read * position of the message buffer. @@ -388,7 +388,7 @@ * @param value Reference to store the pointer to the newly allocated data * @param size Size of data */ -OSYNC_TEST_EXPORT void osync_message_read_buffer(OSyncMessage *message, void **value, int *size); +OSYNC_TEST_EXPORT void osync_message_read_buffer(OSyncMessage *message, void **value, unsigned int *size); /*@}*/ Modified: trunk/opensync/ipc/opensync_serializer.c ============================================================================== --- trunk/opensync/ipc/opensync_serializer.c Mon Mar 30 06:57:37 2009 (r5457) +++ trunk/opensync/ipc/opensync_serializer.c Mon Mar 30 06:59:57 2009 (r5458) @@ -124,7 +124,7 @@ if (!osync_objformat_demarshal(format, marshal, &input_data, &input_size, error)) goto error; } else { - osync_message_read_buffer(message, (void *)&input_data, (int *)&input_size); + osync_message_read_buffer(message, (void *)&input_data, &input_size); /* If the format is a plain, then we have to remove * one from the input_size, since once one was added by Modified: trunk/tests/format-tests/check_objformat.c ============================================================================== --- trunk/tests/format-tests/check_objformat.c Mon Mar 30 06:57:37 2009 (r5457) +++ trunk/tests/format-tests/check_objformat.c Mon Mar 30 06:59:57 2009 (r5458) @@ -55,7 +55,7 @@ osync_bool demarshal_format(OSyncMarshal *marshal, char **output, unsigned int *outsize, void *user_data, OSyncError **error) { - osync_marshal_read_buffer(marshal, (void *)output, (int *)outsize); + osync_marshal_read_buffer(marshal, (void *)output, outsize); return TRUE; } Modified: trunk/tests/mock-plugin/mock_format.c ============================================================================== --- trunk/tests/mock-plugin/mock_format.c Mon Mar 30 06:57:37 2009 (r5457) +++ trunk/tests/mock-plugin/mock_format.c Mon Mar 30 06:59:57 2009 (r5458) @@ -218,7 +218,7 @@ osync_assert(file); osync_marshal_read_string(marshal, &(file->path)); - osync_marshal_read_buffer(marshal, (void *)&(file->data), (int *)&(file->size)); + osync_marshal_read_buffer(marshal, (void *)&(file->data), &(file->size)); *output = (char *)file; *outpsize = sizeof(OSyncFileFormat); |
From: <svn...@op...> - 2009-03-30 04:57:45
|
Author: dgollub Date: Mon Mar 30 06:57:37 2009 New Revision: 5457 URL: http://www.opensync.org/changeset/5457 Log: Drop legacy includes from vformat plugin. Modified: format-plugins/vformat/src/vcard.c format-plugins/vformat/src/vevent.c format-plugins/vformat/src/vjournal.c format-plugins/vformat/src/vnote.c format-plugins/vformat/src/vtodo.c format-plugins/vformat/tests/conversion.h format-plugins/vformat/tools/vconvert.c Modified: format-plugins/vformat/src/vcard.c ============================================================================== --- format-plugins/vformat/src/vcard.c Mon Mar 30 06:35:07 2009 (r5456) +++ format-plugins/vformat/src/vcard.c Mon Mar 30 06:57:37 2009 (r5457) @@ -19,7 +19,6 @@ */ #include <opensync/opensync.h> -#include <opensync/opensync-support.h> #include <opensync/opensync-serializer.h> #include <opensync/opensync-format.h> #include <glib.h> Modified: format-plugins/vformat/src/vevent.c ============================================================================== --- format-plugins/vformat/src/vevent.c Mon Mar 30 06:35:07 2009 (r5456) +++ format-plugins/vformat/src/vevent.c Mon Mar 30 06:57:37 2009 (r5457) @@ -19,7 +19,6 @@ */ #include <opensync/opensync.h> -#include <opensync/opensync-support.h> #include <opensync/opensync-serializer.h> #include <opensync/opensync-format.h> #include <glib.h> Modified: format-plugins/vformat/src/vjournal.c ============================================================================== --- format-plugins/vformat/src/vjournal.c Mon Mar 30 06:35:07 2009 (r5456) +++ format-plugins/vformat/src/vjournal.c Mon Mar 30 06:57:37 2009 (r5457) @@ -20,7 +20,6 @@ * */ #include "opensync/opensync.h" -#include "opensync/opensync-support.h" #include "opensync/opensync-serializer.h" #include "opensync/opensync-format.h" #include <glib.h> Modified: format-plugins/vformat/src/vnote.c ============================================================================== --- format-plugins/vformat/src/vnote.c Mon Mar 30 06:35:07 2009 (r5456) +++ format-plugins/vformat/src/vnote.c Mon Mar 30 06:57:37 2009 (r5457) @@ -19,7 +19,6 @@ * */ #include "opensync/opensync.h" -#include "opensync/opensync-support.h" #include "opensync/opensync-serializer.h" #include "opensync/opensync-format.h" #include <glib.h> Modified: format-plugins/vformat/src/vtodo.c ============================================================================== --- format-plugins/vformat/src/vtodo.c Mon Mar 30 06:35:07 2009 (r5456) +++ format-plugins/vformat/src/vtodo.c Mon Mar 30 06:57:37 2009 (r5457) @@ -20,7 +20,6 @@ */ #include "opensync/opensync.h" -#include "opensync/opensync-support.h" #include "opensync/opensync-serializer.h" #include "opensync/opensync-format.h" #include <glib.h> Modified: format-plugins/vformat/tests/conversion.h ============================================================================== --- format-plugins/vformat/tests/conversion.h Mon Mar 30 06:35:07 2009 (r5456) +++ format-plugins/vformat/tests/conversion.h Mon Mar 30 06:57:37 2009 (r5457) @@ -3,7 +3,6 @@ #include <time.h> #include <opensync/opensync-format.h> -#include <opensync/opensync-support.h> #include <opensync/opensync-data.h> void conv(const char *objtype, const char *filename, const char *extension); Modified: format-plugins/vformat/tools/vconvert.c ============================================================================== --- format-plugins/vformat/tools/vconvert.c Mon Mar 30 06:35:07 2009 (r5456) +++ format-plugins/vformat/tools/vconvert.c Mon Mar 30 06:57:37 2009 (r5457) @@ -25,7 +25,6 @@ #include <opensync/opensync.h> #include <opensync/opensync-format.h> -#include <opensync/opensync-support.h> #include <opensync/opensync-data.h> #include <stdio.h> |
From: <svn...@op...> - 2009-03-30 04:35:13
|
Author: dgollub Date: Mon Mar 30 06:35:07 2009 New Revision: 5456 URL: http://www.opensync.org/changeset/5456 Log: Fix data type of osync_group_get_conflict_resolution' paramter "winner" to long long int, which represents a mmeber id (which is long long int) refs #974 Modified: trunk/opensync/group/opensync_group.c trunk/opensync/group/opensync_group.h trunk/opensync/group/opensync_group_internals.h Modified: trunk/opensync/group/opensync_group.c ============================================================================== --- trunk/opensync/group/opensync_group.c Mon Mar 30 06:29:09 2009 (r5455) +++ trunk/opensync/group/opensync_group.c Mon Mar 30 06:35:07 2009 (r5456) @@ -974,21 +974,21 @@ return group->last_sync; } -void osync_group_set_conflict_resolution(OSyncGroup *group, OSyncConflictResolution res, int num) +void osync_group_set_conflict_resolution(OSyncGroup *group, OSyncConflictResolution res, long long int winner) { osync_assert(group); group->conflict_resolution = res; - group->conflict_winner = num; + group->conflict_winner = winner; } -void osync_group_get_conflict_resolution(OSyncGroup *group, OSyncConflictResolution *res, int *num) +void osync_group_get_conflict_resolution(OSyncGroup *group, OSyncConflictResolution *res, long long int *winner) { osync_assert(group); osync_assert(res); - osync_assert(num); + osync_assert(winner); *res = group->conflict_resolution; - *num = group->conflict_winner; + *winner = group->conflict_winner; } osync_bool osync_group_get_merger_enabled(OSyncGroup *group) Modified: trunk/opensync/group/opensync_group.h ============================================================================== --- trunk/opensync/group/opensync_group.h Mon Mar 30 06:29:09 2009 (r5455) +++ trunk/opensync/group/opensync_group.h Mon Mar 30 06:35:07 2009 (r5456) @@ -267,19 +267,19 @@ * * @param group The group * @param res The conflict resolution - * @param num The Member ID which solves the conflict (winner) + * @param winner The Member ID which solves the conflict (winner) * */ -OSYNC_EXPORT void osync_group_set_conflict_resolution(OSyncGroup *group, OSyncConflictResolution res, int num); +OSYNC_EXPORT void osync_group_set_conflict_resolution(OSyncGroup *group, OSyncConflictResolution res, long long int winner); /** @brief Get fixed conflict resolution for the group for all appearing conflicts * * @param group The group * @param res Pointer to set conflict resolution value - * @param num Pointer to set Member ID value which solves the conflict (winner) + * @param winner Pointer to set Member ID value which solves the conflict (winner) * */ -OSYNC_EXPORT void osync_group_get_conflict_resolution(OSyncGroup *group, OSyncConflictResolution *res, int *num); +OSYNC_EXPORT void osync_group_get_conflict_resolution(OSyncGroup *group, OSyncConflictResolution *res, long long int *winner); /** @brief Get group configured status of merger use. * Modified: trunk/opensync/group/opensync_group_internals.h ============================================================================== --- trunk/opensync/group/opensync_group_internals.h Mon Mar 30 06:29:09 2009 (r5455) +++ trunk/opensync/group/opensync_group_internals.h Mon Mar 30 06:35:07 2009 (r5456) @@ -52,7 +52,7 @@ /** The defined resolution for this group */ OSyncConflictResolution conflict_resolution; /** The winning side if the select resolution is choosen */ - int conflict_winner; + long long int conflict_winner; /** The configured merger status of this group */ osync_bool merger_enabled; /** The configured converter status of this group */ |
From: <svn...@op...> - 2009-03-30 04:29:25
|
Author: dgollub Date: Mon Mar 30 06:29:09 2009 New Revision: 5455 URL: http://www.opensync.org/changeset/5455 Log: Fixed data type of osync_mapping_engine_member_change()'s member id parameter, whichi is long long int - not int. refs #974 Modified: trunk/opensync/engine/opensync_mapping_engine.c trunk/opensync/engine/opensync_mapping_engine.h Modified: trunk/opensync/engine/opensync_mapping_engine.c ============================================================================== --- trunk/opensync/engine/opensync_mapping_engine.c Mon Mar 30 06:27:22 2009 (r5454) +++ trunk/opensync/engine/opensync_mapping_engine.c Mon Mar 30 06:29:09 2009 (r5455) @@ -560,7 +560,7 @@ return NULL; } -OSyncChange *osync_mapping_engine_member_change(OSyncMappingEngine *engine, int memberid) +OSyncChange *osync_mapping_engine_member_change(OSyncMappingEngine *engine, long long int memberid) { OSyncList *e = NULL; osync_assert(engine); Modified: trunk/opensync/engine/opensync_mapping_engine.h ============================================================================== --- trunk/opensync/engine/opensync_mapping_engine.h Mon Mar 30 06:27:22 2009 (r5454) +++ trunk/opensync/engine/opensync_mapping_engine.h Mon Mar 30 06:29:09 2009 (r5455) @@ -28,7 +28,7 @@ * @param memberid The member id of the request change. * @returns The pointer to the change of the member. NULL if member doesn't have an entry in this mapping. */ -OSYNC_EXPORT OSyncChange *osync_mapping_engine_member_change(OSyncMappingEngine *engine, int memberid); +OSYNC_EXPORT OSyncChange *osync_mapping_engine_member_change(OSyncMappingEngine *engine, long long int memberid); OSYNC_EXPORT OSyncMember *osync_mapping_engine_change_find_member(OSyncMappingEngine *engine, OSyncChange *change); |
From: <svn...@op...> - 2009-03-30 04:27:28
|
Author: dgollub Date: Mon Mar 30 06:27:22 2009 New Revision: 5454 URL: http://www.opensync.org/changeset/5454 Log: Fix data type of osync_group_find_member() parameter member id refs #974 Modified: trunk/opensync/group/opensync_group.c trunk/opensync/group/opensync_group.h Modified: trunk/opensync/group/opensync_group.c ============================================================================== --- trunk/opensync/group/opensync_group.c Mon Mar 30 06:22:15 2009 (r5453) +++ trunk/opensync/group/opensync_group.c Mon Mar 30 06:27:22 2009 (r5454) @@ -788,7 +788,7 @@ osync_member_unref(member); } -OSyncMember *osync_group_find_member(OSyncGroup *group, int id) +OSyncMember *osync_group_find_member(OSyncGroup *group, long long int id) { OSyncList *m = NULL; for (m = group->members; m; m = m->next) { Modified: trunk/opensync/group/opensync_group.h ============================================================================== --- trunk/opensync/group/opensync_group.h Mon Mar 30 06:22:15 2009 (r5453) +++ trunk/opensync/group/opensync_group.h Mon Mar 30 06:27:22 2009 (r5454) @@ -192,7 +192,7 @@ * @returns The member, or NULL if not found * */ -OSYNC_EXPORT OSyncMember *osync_group_find_member(OSyncGroup *group, int id); +OSYNC_EXPORT OSyncMember *osync_group_find_member(OSyncGroup *group, long long int id); /** * @brief Returns a OSyncList that contains the OSyncMembers of this group |
From: <svn...@op...> - 2009-03-30 04:22:26
|
Author: dgollub Date: Mon Mar 30 06:22:15 2009 New Revision: 5453 URL: http://www.opensync.org/changeset/5453 Log: Fix coding style. Change return value of osync_group_objtype_enabled() to osync_bool. refs #974 Modified: trunk/opensync/group/opensync_group.c trunk/opensync/group/opensync_group.h Modified: trunk/opensync/group/opensync_group.c ============================================================================== --- trunk/opensync/group/opensync_group.c Mon Mar 30 05:53:06 2009 (r5452) +++ trunk/opensync/group/opensync_group.c Mon Mar 30 06:22:15 2009 (r5453) @@ -888,7 +888,7 @@ } } -int osync_group_objtype_enabled(OSyncGroup *group, const char *objtype) +osync_bool osync_group_objtype_enabled(OSyncGroup *group, const char *objtype) { OSyncList *m = NULL; int enabled = -1; @@ -929,7 +929,7 @@ break; } } - return enabled; + return (enabled > 0) ? TRUE : FALSE; } void osync_group_add_filter(OSyncGroup *group, OSyncFilter *filter) Modified: trunk/opensync/group/opensync_group.h ============================================================================== --- trunk/opensync/group/opensync_group.h Mon Mar 30 05:53:06 2009 (r5452) +++ trunk/opensync/group/opensync_group.h Mon Mar 30 06:22:15 2009 (r5453) @@ -251,7 +251,7 @@ * @returns TRUE if object type is enabled in this group, otherwise FALSE * */ -OSYNC_EXPORT int osync_group_objtype_enabled(OSyncGroup *group, const char *objtype); +OSYNC_EXPORT osync_bool osync_group_objtype_enabled(OSyncGroup *group, const char *objtype); /** @brief Gets the last synchronization date from this group |
From: <svn...@op...> - 2009-03-30 03:53:16
|
Author: dgollub Date: Mon Mar 30 05:53:06 2009 New Revision: 5452 URL: http://www.opensync.org/changeset/5452 Log: Cleanup hashtable header Modified: trunk/opensync/helper/opensync_hashtable.h Modified: trunk/opensync/helper/opensync_hashtable.h ============================================================================== --- trunk/opensync/helper/opensync_hashtable.h Mon Mar 30 05:52:00 2009 (r5451) +++ trunk/opensync/helper/opensync_hashtable.h Mon Mar 30 05:53:06 2009 (r5452) @@ -118,10 +118,6 @@ */ OSYNC_EXPORT void osync_hashtable_update_change(OSyncHashTable *table, OSyncChange *change); -//OSYNC_EXPORT void osync_hashtable_report(OSyncHashTable *table, OSyncChange *change); -//OSYNC_EXPORT void osync_hashtable_reset_reports(OSyncHashTable *table); - - /** @brief Get a list of uids which are marked as deleted * * @param table The hashtable |
From: <svn...@op...> - 2009-03-30 03:52:11
|
Author: dgollub Date: Mon Mar 30 05:52:00 2009 New Revision: 5451 URL: http://www.opensync.org/changeset/5451 Log: Drop duplicated declartion of osync_objtype_sink_set_connect_done_func Modified: trunk/opensync/plugin/opensync_objtype_sink.h Modified: trunk/opensync/plugin/opensync_objtype_sink.h ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink.h Mon Mar 30 05:47:30 2009 (r5450) +++ trunk/opensync/plugin/opensync_objtype_sink.h Mon Mar 30 05:52:00 2009 (r5451) @@ -501,8 +501,6 @@ OSYNC_EXPORT void osync_objtype_sink_set_connect_func(OSyncObjTypeSink *sink, OSyncSinkConnectFn connect_func); -OSYNC_EXPORT void osync_objtype_sink_set_connect_done_func(OSyncObjTypeSink *sink, OSyncSinkConnectDoneFn connect_done_func); - OSYNC_EXPORT void osync_objtype_sink_set_get_changes_func(OSyncObjTypeSink *sink, OSyncSinkGetChangesFn get_changes_func); OSYNC_EXPORT void osync_objtype_sink_set_commit_func(OSyncObjTypeSink *sink, OSyncSinkCommitFn commit_func); |
From: <svn...@op...> - 2009-03-30 03:47:42
|
Author: dgollub Date: Mon Mar 30 05:47:30 2009 New Revision: 5450 URL: http://www.opensync.org/changeset/5450 Log: Port ldap-sync to slow-sync API change ref #1085 Modified: plugins/ldap-sync/src/ldap_plugin.c Modified: plugins/ldap-sync/src/ldap_plugin.c ============================================================================== --- plugins/ldap-sync/src/ldap_plugin.c Mon Mar 30 05:28:31 2009 (r5449) +++ plugins/ldap-sync/src/ldap_plugin.c Mon Mar 30 05:47:30 2009 (r5450) @@ -450,7 +450,7 @@ osync_trace(TRACE_INTERNAL, "%s:%i: Anchor value differs from our own one, therefore setting \"slow-sync\":\n", __FILE__, __LINE__); #ifndef DISABLE_SET_SLOWSYNC - osync_objtype_sink_set_slowsync(sinkenv->sink, TRUE); + osync_context_report_slowsync(ctx); #else ldap_plugin_printf("%s:%i:%s(): Temporarily disabled osync_objtype_sink_set_slowsync() in case of differing anchor values, because I cannot initialize sinkenv->latest_timestamp from the anchordb in ldap_plugin_initialize_sink(): osync_objtype_sink_get_anchor() always returns NULL rather than the anchor object.", __FILE__, __LINE__, __func__); #endif |