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: <dg...@su...> - 2009-01-06 01:13:17
|
Author: dgollub Date: Tue Jan 6 02:12:56 2009 New Revision: 5034 URL: http://www.opensync.org/changeset/5034 Log: Kill some duplicated code in xmlformat-init function. Modified: format-plugins/xmlformat/trunk/src/xmlformat.c Modified: format-plugins/xmlformat/trunk/src/xmlformat.c ============================================================================== --- format-plugins/xmlformat/trunk/src/xmlformat.c Tue Jan 6 02:08:18 2009 (r5033) +++ format-plugins/xmlformat/trunk/src/xmlformat.c Tue Jan 6 02:12:56 2009 (r5034) @@ -402,11 +402,8 @@ /* register xmlformat-contact */ format = osync_objformat_new("xmlformat-contact", "contact", &error); - if (!format) { - osync_trace(TRACE_ERROR, "Unable to register format xmlformat: %s", osync_error_print(&error)); - osync_error_unref(&error); - return FALSE; - } + if (!format) + goto error; osync_objformat_set_initialize_func(format, initialize_contact); osync_objformat_set_finalize_func(format, finalize); @@ -433,11 +430,8 @@ /* register xmlformat-event */ format = osync_objformat_new("xmlformat-event", "event", &error); - if (!format) { - osync_trace(TRACE_ERROR, "Unable to register format xmlformat: %s", osync_error_print(&error)); - osync_error_unref(&error); - return FALSE; - } + if (!format) + goto error; osync_objformat_set_initialize_func(format, initialize_event); osync_objformat_set_finalize_func(format, finalize); @@ -464,11 +458,8 @@ /* register xmlformat-todo */ format = osync_objformat_new("xmlformat-todo", "todo", &error); - if (!format) { - osync_trace(TRACE_ERROR, "Unable to register format xmlfomat: %s", osync_error_print(&error)); - osync_error_unref(&error); - return FALSE; - } + if (!format) + goto error; osync_objformat_set_initialize_func(format, initialize_todo); osync_objformat_set_finalize_func(format, finalize); @@ -495,11 +486,8 @@ /* register xmlformat-note */ format = osync_objformat_new("xmlformat-note", "note", &error); - if (!format) { - osync_trace(TRACE_ERROR, "Unable to register format xmlfomat: %s", osync_error_print(&error)); - osync_error_unref(&error); - return FALSE; - } + if (!format) + goto error; osync_objformat_set_initialize_func(format, initialize_note); osync_objformat_set_finalize_func(format, finalize); @@ -524,6 +512,11 @@ osync_objformat_unref(format); return TRUE; + +error: + osync_trace(TRACE_ERROR, "Unable to register format xmlformat: %s", osync_error_print(&error)); + osync_error_unref(&error); + return FALSE; } int get_version(void) |
From: <dg...@su...> - 2009-01-06 01:08:39
|
Author: dgollub Date: Tue Jan 6 02:08:18 2009 New Revision: 5033 URL: http://www.opensync.org/changeset/5033 Log: Check xmlformat-plugin init function. Modified: format-plugins/xmlformat/trunk/tests/check_xmlformat.c format-plugins/xmlformat/trunk/tests/support.c Modified: format-plugins/xmlformat/trunk/tests/check_xmlformat.c ============================================================================== --- format-plugins/xmlformat/trunk/tests/check_xmlformat.c Tue Jan 6 01:57:53 2009 (r5032) +++ format-plugins/xmlformat/trunk/tests/check_xmlformat.c Tue Jan 6 02:08:18 2009 (r5033) @@ -1,5 +1,23 @@ #include "support.h" +START_TEST (xmlformat_init) +{ + char *testbed = setup_testbed("xmlformats"); + + OSyncError *error = NULL; + OSyncFormatEnv *formatenv = osync_format_env_new(&error); + fail_unless(formatenv != NULL, NULL); + fail_unless(error == NULL, NULL); + + fail_unless(osync_format_env_load_plugins(formatenv, testbed, &error), NULL); + fail_unless(error == NULL, NULL); + + osync_format_env_unref(formatenv); + + destroy_testbed(testbed); +} +END_TEST + START_TEST (xmlformat_compare_test) { char *testbed = setup_testbed("xmlformats"); @@ -239,6 +257,7 @@ Suite *s = suite_create("XMLFormat"); // Suite *s2 = suite_create("XMLFormat"); + create_case(s, "xmlformat_init", xmlformat_init); create_case(s, "xmlformat_compare_test", xmlformat_compare_test); create_case(s, "xmlformat_compare_field2null", xmlformat_compare_field2null); create_case(s, "xmlformat_compare_ignore_fields", xmlformat_compare_ignore_fields); Modified: format-plugins/xmlformat/trunk/tests/support.c ============================================================================== --- format-plugins/xmlformat/trunk/tests/support.c Tue Jan 6 01:57:53 2009 (r5032) +++ format-plugins/xmlformat/trunk/tests/support.c Tue Jan 6 02:08:18 2009 (r5033) @@ -35,12 +35,7 @@ g_free(dirname); } - command = g_strdup_printf("mkdir %s/formats", testbed); - if (system(command)) - abort(); - g_free(command); - - command = g_strdup_printf("cp -R ../src/*.%s %s/formats", G_MODULE_SUFFIX, testbed); + command = g_strdup_printf("cp -R ../src/*.%s %s/", G_MODULE_SUFFIX, testbed); if (system(command)) abort(); g_free(command); |
From: <dg...@su...> - 2009-01-06 00:58:13
|
Author: dgollub Date: Tue Jan 6 01:57:53 2009 New Revision: 5032 URL: http://www.opensync.org/changeset/5032 Log: Add CTestConfig.cmake for CDash on http://opensync.org/testing Added: format-plugins/xmlformat/trunk/CTestConfig.cmake Added: format-plugins/xmlformat/trunk/CTestConfig.cmake ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ format-plugins/xmlformat/trunk/CTestConfig.cmake Tue Jan 6 01:57:53 2009 (r5032) @@ -0,0 +1,13 @@ +## This file should be placed in the root directory of your project. +## Then modify the CMakeLists.txt file in the root directory of your +## project to incorporate the testing dashboard. +## # The following are required to uses Dart and the Cdash dashboard +## ENABLE_TESTING() +## INCLUDE(Dart) +set(CTEST_PROJECT_NAME "xmlformat-plugin") +set(CTEST_NIGHTLY_START_TIME "00:00:00 CET") + +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "opensync.org") +set(CTEST_DROP_LOCATION "/testing/submit.php?project=xmlformat-plugin") +set(CTEST_DROP_SITE_CDASH TRUE) |
From: <dg...@su...> - 2009-01-06 00:53:58
|
Author: dgollub Date: Tue Jan 6 01:53:36 2009 New Revision: 5031 URL: http://www.opensync.org/changeset/5031 Log: Extended testsuite with merger/demerger testcases. Modified: format-plugins/xmlformat/trunk/src/CMakeLists.txt format-plugins/xmlformat/trunk/src/xmlformat.h format-plugins/xmlformat/trunk/tests/CMakeLists.txt format-plugins/xmlformat/trunk/tests/check_xmlformat.c Modified: format-plugins/xmlformat/trunk/src/CMakeLists.txt ============================================================================== --- format-plugins/xmlformat/trunk/src/CMakeLists.txt Tue Jan 6 01:36:05 2009 (r5030) +++ format-plugins/xmlformat/trunk/src/CMakeLists.txt Tue Jan 6 01:53:36 2009 (r5031) @@ -6,8 +6,7 @@ TARGET_LINK_LIBRARIES( xmlformat ${OPENSYNC_LIBRARIES} ${GLIB2_LIBRARIES} ) # Required for UNITTESTING only -ADD_LIBRARY( xmlformat-compare STATIC xmlformat_compare.c ) -ADD_LIBRARY( xmlformat-merge STATIC xmlformat_merge.c ) +ADD_LIBRARY( xmlformat-static STATIC xmlformat_compare.c xmlformat.c xmlformat_merge.c ) ###### INSTALL ################### Modified: format-plugins/xmlformat/trunk/src/xmlformat.h ============================================================================== --- format-plugins/xmlformat/trunk/src/xmlformat.h Tue Jan 6 01:36:05 2009 (r5030) +++ format-plugins/xmlformat/trunk/src/xmlformat.h Tue Jan 6 01:53:36 2009 (r5031) @@ -72,5 +72,8 @@ osync_bool merge_xmlformat(char **buf, unsigned int *size, const char *entirebuf, unsigned int entiresize, OSyncCapabilities *caps, void *user_data, OSyncError **error); osync_bool demerge_xmlformat(char **buf, unsigned int *size, OSyncCapabilities *caps, void *user_data, OSyncError **error); +osync_bool marshal_xmlformat(const char *input, unsigned int inpsize, OSyncMarshal *marshal, void *userdata, OSyncError **error); +osync_bool demarshal_xmlformat(OSyncMarshal *marshal, char **output, unsigned int *outpsize, void *userdata, OSyncError **error); + #endif /* XMLFORMAT_H_ */ Modified: format-plugins/xmlformat/trunk/tests/CMakeLists.txt ============================================================================== --- format-plugins/xmlformat/trunk/tests/CMakeLists.txt Tue Jan 6 01:36:05 2009 (r5030) +++ format-plugins/xmlformat/trunk/tests/CMakeLists.txt Tue Jan 6 01:53:36 2009 (r5031) @@ -8,8 +8,8 @@ ############ unit tests ########################## -SET( TEST_TARGET_LIBRARIES support ) +SET( TEST_TARGET_LIBRARIES support xmlformat-static ) -ADD_CHECK_TEST( xmlformat check_xmlformat.c xmlformat-compare ${TEST_TARGET_LIBRARIES} ) -ADD_CHECK_TEST( merging check_merger.c xmlformat-compare xmlformat-merge ${TEST_TARGET_LIBRARIES} ) +ADD_CHECK_TEST( xmlformat check_xmlformat.c ${TEST_TARGET_LIBRARIES} ) +ADD_CHECK_TEST( merging check_merger.c ${TEST_TARGET_LIBRARIES} ) Modified: format-plugins/xmlformat/trunk/tests/check_xmlformat.c ============================================================================== --- format-plugins/xmlformat/trunk/tests/check_xmlformat.c Tue Jan 6 01:36:05 2009 (r5030) +++ format-plugins/xmlformat/trunk/tests/check_xmlformat.c Tue Jan 6 01:53:36 2009 (r5031) @@ -174,6 +174,66 @@ } END_TEST +START_TEST (xmlformat_marshal) +{ + char *testbed = setup_testbed("xmlformats"); + + char *buffer1; + unsigned int size1; + OSyncError *error = NULL; + + fail_unless(osync_file_read( "contact1.xml", &buffer1, &size1, &error), NULL); + + OSyncXMLFormat *xmlformat1 = osync_xmlformat_parse(buffer1, size1, &error); + fail_unless(xmlformat1 != NULL, NULL); + fail_unless(error == NULL, NULL); + g_free(buffer1); + + OSyncMarshal *marshal = osync_marshal_new(&error); + fail_unless(marshal != NULL, "Unexpected."); + fail_unless(error == NULL, "Unexpected."); + + fail_unless(marshal_xmlformat((char *) xmlformat1, osync_xmlformat_size(), marshal, NULL, &error), NULL); + + osync_xmlformat_unref((OSyncXMLFormat*)xmlformat1); + osync_marshal_unref(marshal); + + + destroy_testbed(testbed); +} +END_TEST + +START_TEST (xmlformat_demarshal) +{ + char *testbed = setup_testbed("xmlformats"); + + char *buffer1; + unsigned int size1; + OSyncError *error = NULL; + + fail_unless(osync_file_read( "contact1.xml", &buffer1, &size1, &error), NULL); + + OSyncXMLFormat *xmlformat1 = osync_xmlformat_parse(buffer1, size1, &error); + fail_unless(xmlformat1 != NULL, NULL); + fail_unless(error == NULL, NULL); + g_free(buffer1); + + OSyncMarshal *marshal = osync_marshal_new(&error); + fail_unless(marshal != NULL, "Unexpected."); + fail_unless(error == NULL, "Unexpected."); + + fail_unless(marshal_xmlformat((char *) xmlformat1, osync_xmlformat_size(), marshal, NULL, &error), NULL); + + osync_xmlformat_unref((OSyncXMLFormat*)xmlformat1); + + fail_unless(demarshal_xmlformat(marshal, (char **)&xmlformat1, &size1, NULL, &error), NULL); + + osync_marshal_unref(marshal); + + destroy_testbed(testbed); +} +END_TEST + Suite *xmlformat_suite(void) { Suite *s = suite_create("XMLFormat"); @@ -182,6 +242,8 @@ create_case(s, "xmlformat_compare_test", xmlformat_compare_test); create_case(s, "xmlformat_compare_field2null", xmlformat_compare_field2null); create_case(s, "xmlformat_compare_ignore_fields", xmlformat_compare_ignore_fields); + create_case(s, "xmlformat_marshal", xmlformat_marshal); + create_case(s, "xmlformat_demarshal", xmlformat_demarshal); return s; } |
From: <dg...@su...> - 2009-01-06 00:36:25
|
Author: dgollub Date: Tue Jan 6 01:36:05 2009 New Revision: 5030 URL: http://www.opensync.org/changeset/5030 Log: Ported merging testsuite for xmlformat-plugin. Modified: format-plugins/xmlformat/trunk/src/CMakeLists.txt format-plugins/xmlformat/trunk/tests/CMakeLists.txt format-plugins/xmlformat/trunk/tests/check_merger.c Modified: format-plugins/xmlformat/trunk/src/CMakeLists.txt ============================================================================== --- format-plugins/xmlformat/trunk/src/CMakeLists.txt Tue Jan 6 01:35:23 2009 (r5029) +++ format-plugins/xmlformat/trunk/src/CMakeLists.txt Tue Jan 6 01:36:05 2009 (r5030) @@ -7,6 +7,7 @@ # Required for UNITTESTING only ADD_LIBRARY( xmlformat-compare STATIC xmlformat_compare.c ) +ADD_LIBRARY( xmlformat-merge STATIC xmlformat_merge.c ) ###### INSTALL ################### Modified: format-plugins/xmlformat/trunk/tests/CMakeLists.txt ============================================================================== --- format-plugins/xmlformat/trunk/tests/CMakeLists.txt Tue Jan 6 01:35:23 2009 (r5029) +++ format-plugins/xmlformat/trunk/tests/CMakeLists.txt Tue Jan 6 01:36:05 2009 (r5030) @@ -11,4 +11,5 @@ SET( TEST_TARGET_LIBRARIES support ) ADD_CHECK_TEST( xmlformat check_xmlformat.c xmlformat-compare ${TEST_TARGET_LIBRARIES} ) +ADD_CHECK_TEST( merging check_merger.c xmlformat-compare xmlformat-merge ${TEST_TARGET_LIBRARIES} ) Modified: format-plugins/xmlformat/trunk/tests/check_merger.c ============================================================================== --- format-plugins/xmlformat/trunk/tests/check_merger.c Tue Jan 6 01:35:23 2009 (r5029) +++ format-plugins/xmlformat/trunk/tests/check_merger.c Tue Jan 6 01:36:05 2009 (r5030) @@ -1,33 +1,8 @@ #include "support.h" -#include <opensync/opensync-merger.h> +#include <opensync/opensync-capabilities.h> +#include <opensync/opensync-serializer.h> #include <opensync/opensync-xmlformat.h> -#include "opensync/merger/opensync-merger_internals.h" -#include "opensync/xmlformat/opensync_xmlformat_internals.h" - - -START_TEST (merger_new) -{ - char *testbed = setup_testbed("merger"); - - OSyncError *error = NULL; - OSyncCapabilities *capabilities = osync_capabilities_new(&error); - fail_unless(capabilities != NULL, NULL); - fail_unless(error == NULL, NULL); - - OSyncMerger *merger = osync_merger_new(capabilities, &error); - fail_unless(merger != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_merger_ref(merger); - osync_merger_unref(merger); - - osync_merger_unref(merger); - osync_capabilities_unref(capabilities); - - destroy_testbed(testbed); -} -END_TEST START_TEST (merger_merge) { @@ -35,6 +10,7 @@ char *buffer; unsigned int size; + unsigned int xmlformat_size = osync_xmlformat_size(); OSyncError *error = NULL; OSyncXMLFormat *xmlformat, *xmlformat_entire; OSyncCapabilities *capabilities; @@ -58,13 +34,8 @@ fail_unless(capabilities != NULL, NULL); fail_unless(error == NULL, NULL); g_free(buffer); - osync_capabilities_sort(capabilities); - OSyncMerger *merger = osync_merger_new(capabilities, &error); - fail_unless(merger != NULL, NULL); - fail_unless(error == NULL, NULL); - osync_merger_merge(merger, xmlformat, xmlformat_entire); - osync_merger_unref(merger); + fail_unless(merge_xmlformat((char **) &xmlformat, &xmlformat_size, (char *) xmlformat_entire, osync_xmlformat_size(), capabilities, NULL, &error), NULL); osync_capabilities_unref(capabilities); osync_xmlformat_unref(xmlformat); @@ -80,6 +51,7 @@ char *buffer; unsigned int size; + unsigned int xmlformat_size = osync_xmlformat_size(); OSyncError *error = NULL; OSyncXMLFormat *xmlformat, *xmlformat_entire; OSyncCapabilities *capabilities; @@ -104,21 +76,15 @@ fail_unless(error == NULL, NULL); //printf("\n%s", buffer); g_free(buffer); - osync_capabilities_sort(capabilities); //osync_xmlformat_assemble(xmlformat, &buffer, &size); printf("\n%s", buffer); g_free(buffer); //osync_xmlformat_assemble(xmlformat_entire, &buffer, &size); printf("\n%s", buffer); g_free(buffer); - OSyncMerger *merger = osync_merger_new(capabilities, &error); - fail_unless(merger != NULL, NULL); - fail_unless(error == NULL, NULL); - osync_merger_merge(merger, xmlformat, xmlformat_entire); + fail_unless(merge_xmlformat((char **) &xmlformat, &xmlformat_size, (char *) xmlformat_entire, osync_xmlformat_size(), capabilities, NULL, &error), NULL); //osync_xmlformat_assemble(xmlformat, &buffer, &size); printf("\nMERGED:\n%s", buffer); g_free(buffer); - osync_merger_demerge(merger, xmlformat); + fail_unless(demerge_xmlformat((char **) &xmlformat, &xmlformat_size, capabilities, NULL, &error), NULL); //osync_xmlformat_assemble(xmlformat, &buffer, &size); printf("\nDEMERGED:\n%s", buffer); g_free(buffer); - osync_merger_unref(merger); - osync_capabilities_unref(capabilities); osync_xmlformat_unref(xmlformat); osync_xmlformat_unref(xmlformat_entire); @@ -130,7 +96,6 @@ Suite *filter_suite(void) { Suite *s = suite_create("Merger"); - create_case(s, "merger_new", merger_new); create_case(s, "merger_merge", merger_merge); create_case(s, "merger_demerge", merger_demerge); return s; |
From: <dg...@su...> - 2009-01-06 00:35:42
|
Author: dgollub Date: Tue Jan 6 01:35:23 2009 New Revision: 5029 URL: http://www.opensync.org/changeset/5029 Log: Get capabilities copy for "contact-full.xml" and other testdata. Added: format-plugins/xmlformat/trunk/tests/data/merger/ (props changed) - copied from r5028, trunk/tests/data/capabilities/ |
From: <dg...@su...> - 2009-01-06 00:33:19
|
Author: dgollub Date: Tue Jan 6 01:33:00 2009 New Revision: 5028 URL: http://www.opensync.org/changeset/5028 Log: Remove (wrong) copy. Deleted: format-plugins/xmlformat/trunk/tests/data/merger/ |
From: <dg...@su...> - 2009-01-06 00:31:00
|
Author: dgollub Date: Tue Jan 6 01:30:39 2009 New Revision: 5027 URL: http://www.opensync.org/changeset/5027 Log: Create a copy of merger testing fixtures. Added: format-plugins/xmlformat/trunk/tests/data/merger/ - copied from r5026, trunk/tests/data/xmlformats/ |
From: <dg...@su...> - 2009-01-06 00:16:45
|
Author: dgollub Date: Tue Jan 6 01:16:24 2009 New Revision: 5026 URL: http://www.opensync.org/changeset/5026 Log: Fix invalid osync_trace() argument list. Modified: format-plugins/xmlformat/trunk/src/xmlformat_merge.c Modified: format-plugins/xmlformat/trunk/src/xmlformat_merge.c ============================================================================== --- format-plugins/xmlformat/trunk/src/xmlformat_merge.c Tue Jan 6 01:05:07 2009 (r5025) +++ format-plugins/xmlformat/trunk/src/xmlformat_merge.c Tue Jan 6 01:16:24 2009 (r5026) @@ -184,7 +184,7 @@ OSyncCapability *cur_capability; int rc; - osync_trace(TRACE_ENTRY, "%s(%p, %p:%u, %p, %p, %p, %p)", __func__, buf, size, *size, caps, error); + osync_trace(TRACE_ENTRY, "%s(%p, %p:%u, %p, %p)", __func__, buf, size, *size, caps, error); osync_assert(*size == osync_xmlformat_size()); |
From: <dg...@su...> - 2009-01-06 00:05:29
|
Author: dgollub Date: Tue Jan 6 01:05:07 2009 New Revision: 5025 URL: http://www.opensync.org/changeset/5025 Log: Ported xmlformat-plugin to latest format-plugin prototype changes. Added userdata pointer als (second) parameter. Removed unneeded assemble/parse calls in merge/demerge function. Adapted merge/demerge function to latest prototype change. Modified: format-plugins/xmlformat/trunk/src/xmlformat.c format-plugins/xmlformat/trunk/src/xmlformat.h format-plugins/xmlformat/trunk/src/xmlformat_merge.c Modified: format-plugins/xmlformat/trunk/src/xmlformat.c ============================================================================== --- format-plugins/xmlformat/trunk/src/xmlformat.c Tue Jan 6 01:02:57 2009 (r5024) +++ format-plugins/xmlformat/trunk/src/xmlformat.c Tue Jan 6 01:05:07 2009 (r5025) @@ -24,12 +24,12 @@ #include "xmlformat.h" -void destroy_xmlformat(char *input, unsigned int inpsize) +void destroy_xmlformat(char *input, unsigned int inpsize, void *userdata) { osync_xmlformat_unref((OSyncXMLFormat *)input); } -static osync_bool duplicate_xmlformat(const char *uid, const char *input, unsigned int insize, char **newuid, char **output, unsigned int *outsize, osync_bool *dirty, OSyncError **error) +static osync_bool duplicate_xmlformat(const char *uid, const char *input, unsigned int insize, char **newuid, char **output, unsigned int *outsize, osync_bool *dirty, void *userdata, OSyncError **error) { char *buffer = NULL; unsigned int size; @@ -53,7 +53,7 @@ } -osync_bool copy_xmlformat(const char *input, unsigned int inpsize, char **output, unsigned int *outpsize, OSyncError **error) +osync_bool copy_xmlformat(const char *input, unsigned int inpsize, char **output, unsigned int *outpsize, void *userdata, OSyncError **error) { OSyncXMLFormat *xmlformat = NULL; osync_trace(TRACE_ENTRY, "%s(%p, %i, %p, %p, %p)", __func__, input, inpsize, output, outpsize, error); @@ -69,7 +69,7 @@ osync_trace(TRACE_EXIT, "%s", __func__); return TRUE; } -char *print_xmlformat(const char *data, unsigned int size) +char *print_xmlformat(const char *data, unsigned int size, void *userdata) { char *buffer; unsigned int i; @@ -83,7 +83,7 @@ return buffer; } -osync_bool marshal_xmlformat(const char *input, unsigned int inpsize, OSyncMarshal *marshal, OSyncError **error) +osync_bool marshal_xmlformat(const char *input, unsigned int inpsize, OSyncMarshal *marshal, void *userdata, OSyncError **error) { char *buffer; unsigned int size; @@ -98,7 +98,7 @@ return TRUE; } -osync_bool demarshal_xmlformat(OSyncMarshal *marshal, char **output, unsigned int *outpsize, OSyncError **error) +osync_bool demarshal_xmlformat(OSyncMarshal *marshal, char **output, unsigned int *outpsize, void *userdata, OSyncError **error) { void *buffer = NULL; unsigned int size = 0; @@ -125,7 +125,7 @@ } -static OSyncConvCmpResult compare_contact(const char *leftdata, unsigned int leftsize, const char *rightdata, unsigned int rightsize) +static OSyncConvCmpResult compare_contact(const char *leftdata, unsigned int leftsize, const char *rightdata, unsigned int rightsize, void *userdata) { char* keys_content[] = {"Content", NULL}; char* keys_name[] = {"FirstName", "LastName", NULL}; @@ -148,7 +148,7 @@ return ret; } -static void create_contact(char **data, unsigned int *size) +static void create_contact(char **data, unsigned int *size, void *userdata) { OSyncError *error = NULL; *data = (char *)osync_xmlformat_new("contact", &error); @@ -156,7 +156,7 @@ osync_trace(TRACE_ERROR, "%s: %s", __func__, osync_error_print(&error)); } -static OSyncConvCmpResult compare_event(const char *leftdata, unsigned int leftsize, const char *rightdata, unsigned int rightsize) +static OSyncConvCmpResult compare_event(const char *leftdata, unsigned int leftsize, const char *rightdata, unsigned int rightsize, void *userdata) { char* keys_content[] = {"Content", NULL}; OSyncXMLPoints points[] = { @@ -183,7 +183,7 @@ return ret; } -void create_event(char **data, unsigned int *size) +void create_event(char **data, unsigned int *size, void *userdata) { OSyncError *error = NULL; *data = (char *)osync_xmlformat_new("event", &error); @@ -191,7 +191,7 @@ osync_trace(TRACE_ERROR, "%s: %s", __func__, osync_error_print(&error)); } -static OSyncConvCmpResult compare_todo(const char *leftdata, unsigned int leftsize, const char *rightdata, unsigned int rightsize) +static OSyncConvCmpResult compare_todo(const char *leftdata, unsigned int leftsize, const char *rightdata, unsigned int rightsize, void *userdata) { char* keys_content[] = {"Content", NULL}; OSyncXMLPoints points[] = { @@ -218,7 +218,7 @@ return ret; } -static void create_todo(char **data, unsigned int *size) +static void create_todo(char **data, unsigned int *size, void *userdata) { OSyncError *error = NULL; *data = (char *)osync_xmlformat_new("todo", &error); @@ -226,7 +226,7 @@ osync_trace(TRACE_ERROR, "%s: %s", __func__, osync_error_print(&error)); } -static OSyncConvCmpResult compare_note(const char *leftdata, unsigned int leftsize, const char *rightdata, unsigned int rightsize) +static OSyncConvCmpResult compare_note(const char *leftdata, unsigned int leftsize, const char *rightdata, unsigned int rightsize, void *userdata) { char* keys_content[] = {"Content", NULL}; OSyncXMLPoints points[] = { @@ -251,7 +251,7 @@ return ret; } -static void create_note(char **data, unsigned int *size) +static void create_note(char **data, unsigned int *size, void *userdata) { OSyncError *error = NULL; *data = (char *)osync_xmlformat_new("note", &error); @@ -296,22 +296,22 @@ return -1; } -static time_t get_contact_revision(const char *data, unsigned int size, OSyncError **error) +static time_t get_contact_revision(const char *data, unsigned int size, void *userdata, OSyncError **error) { return get_revision(data, size, "Revision", error); } -static time_t get_event_revision(const char *data, unsigned int size, OSyncError **error) +static time_t get_event_revision(const char *data, unsigned int size, void *userdata, OSyncError **error) { return get_revision(data, size, "LastModified", error); } -static time_t get_note_revision(const char *data, unsigned int size, OSyncError **error) +static time_t get_note_revision(const char *data, unsigned int size, void *userdata, OSyncError **error) { return get_revision(data, size, "LastModified", error); } -static time_t get_todo_revision(const char *data, unsigned int size, OSyncError **error) +static time_t get_todo_revision(const char *data, unsigned int size, void *userdata, OSyncError **error) { return get_revision(data, size, "LastModified", error); } Modified: format-plugins/xmlformat/trunk/src/xmlformat.h ============================================================================== --- format-plugins/xmlformat/trunk/src/xmlformat.h Tue Jan 6 01:02:57 2009 (r5024) +++ format-plugins/xmlformat/trunk/src/xmlformat.h Tue Jan 6 01:05:07 2009 (r5025) @@ -61,16 +61,16 @@ } XMLFormat; -void destroy_xmlformat(char *input, unsigned int inpsize); -osync_bool copy_xmlformat(const char *input, unsigned int inpsize, char **output, unsigned int *outpsize, OSyncError **error); -char *print_xmlformat(const char *data, unsigned int size); +void destroy_xmlformat(char *input, unsigned int inpsize, void *userdata); +osync_bool copy_xmlformat(const char *input, unsigned int inpsize, char **output, unsigned int *outpsize, void *userdata, OSyncError **error); +char *print_xmlformat(const char *data, unsigned int size, void *userdata); int xmlformat_get_points(OSyncXMLPoints points[], int* cur_pos, int basic_points, const char* fieldname); OSyncConvCmpResult xmlformat_compare(OSyncXMLFormat *xmlformat1, OSyncXMLFormat *xmlformat2, OSyncXMLPoints points[], int basic_points, int treshold); -osync_bool merge_xmlformat(const char *buf, unsigned int size, char **destbuf, unsigned int *destsize, const char *entirebuf, unsigned int entiresize, OSyncCapabilities *caps, OSyncError **error); -osync_bool demerge_xmlformat(const char *buf, unsigned int size, char **destbuf, unsigned int *destsize, OSyncCapabilities *caps, OSyncError **error); +osync_bool merge_xmlformat(char **buf, unsigned int *size, const char *entirebuf, unsigned int entiresize, OSyncCapabilities *caps, void *user_data, OSyncError **error); +osync_bool demerge_xmlformat(char **buf, unsigned int *size, OSyncCapabilities *caps, void *user_data, OSyncError **error); #endif /* XMLFORMAT_H_ */ Modified: format-plugins/xmlformat/trunk/src/xmlformat_merge.c ============================================================================== --- format-plugins/xmlformat/trunk/src/xmlformat_merge.c Tue Jan 6 01:02:57 2009 (r5024) +++ format-plugins/xmlformat/trunk/src/xmlformat_merge.c Tue Jan 6 01:05:07 2009 (r5025) @@ -24,7 +24,7 @@ #include <opensync/opensync-merger.h> -osync_bool merge_xmlformat(const char *buf, unsigned int size, char **destbuf, unsigned int *destsize, const char *entirebuf, unsigned int entiresize, OSyncCapabilities *caps, OSyncError **error) +osync_bool merge_xmlformat(char **buf, unsigned int *size, const char *entirebuf, unsigned int entiresize, OSyncCapabilities *caps, void *userdata, OSyncError **error) { OSyncXMLField *old_cur, *new_cur, *tmp; OSyncCapability *cap_cur; @@ -32,13 +32,13 @@ int ret; const char *objtype; - osync_trace(TRACE_ENTRY, "%s(%p, %u, %p, %p, %p, %p, %u, %p, %p)", __func__, buf, size, destbuf, destsize, entirebuf, entiresize, caps, error); + osync_trace(TRACE_ENTRY, "%s(%p, %p:%u, %p, %p, %p, %p, %u, %p, %p)", __func__, buf, size, *size, entirebuf, entiresize, caps, error); - osync_assert(osync_xmlformat_size() == size); + osync_assert(osync_xmlformat_size() == *size); osync_assert(osync_xmlformat_size() == entiresize); - xmlformat = (OSyncXMLFormat *) buf; + xmlformat = (OSyncXMLFormat *) *buf; entire = (OSyncXMLFormat *) entirebuf; objtype = osync_xmlformat_get_objtype(xmlformat); @@ -161,6 +161,8 @@ continue; } g_assert_not_reached(); + osync_error_set(error, OSYNC_ERROR_GENERIC, "Unexpected error during XMLFormat merging"); + goto error; } /* FIXME: Merger is broken! @@ -168,19 +170,6 @@ Avoid it! Ticket: #754 */ osync_assert(osync_xmlformat_is_sorted(xmlformat)); - if (osync_trace_is_enabled()) { - char *buf; - - if (!osync_xmlformat_assemble(xmlformat, &buf, NULL)) - goto error; - - osync_trace(TRACE_SENSITIVE, "XMLFormat Merged:\n%s ", buf); - osync_free(buf); - } - - *destbuf = (char *) xmlformat; - *destsize = osync_xmlformat_size(); - osync_trace(TRACE_EXIT, "%s", __func__); return TRUE; @@ -188,18 +177,18 @@ return FALSE; } -osync_bool demerge_xmlformat(const char *buf, unsigned int size, char **destbuf, unsigned int *destsize, OSyncCapabilities *caps, OSyncError **error) +osync_bool demerge_xmlformat(char **buf, unsigned int *size, OSyncCapabilities *caps, void *userdata, OSyncError **error) { OSyncXMLFormat *xmlformat; OSyncXMLField *cur_xmlfield, *tmp; OSyncCapability *cur_capability; int rc; - osync_trace(TRACE_ENTRY, "%s(%p, %u, %p, %p, %p, %p)", __func__, buf, size, destbuf, destsize, caps, error); + osync_trace(TRACE_ENTRY, "%s(%p, %p:%u, %p, %p, %p, %p)", __func__, buf, size, *size, caps, error); - osync_assert(size == osync_xmlformat_size()); + osync_assert(*size == osync_xmlformat_size()); - xmlformat = (OSyncXMLFormat *) buf; + xmlformat = (OSyncXMLFormat *) *buf; cur_capability = osync_capabilities_get_first(caps, osync_xmlformat_get_objtype(xmlformat)); cur_xmlfield = osync_xmlformat_get_first_field(xmlformat); @@ -272,25 +261,11 @@ continue; } g_assert_not_reached(); + osync_error_set(error, OSYNC_ERROR_GENERIC, "Unexpected error during XMLFormat de-merging"); + goto error; } - - end: - if (osync_trace_is_enabled()) { - char *buf; - unsigned int bufsize; - - if (!osync_xmlformat_assemble(xmlformat, &buf, &bufsize)) - goto error; - - osync_trace(TRACE_SENSITIVE, "XMLFormat Demerged:\n%s ", buf); - osync_free(buf); - } - - *destbuf = (char *) xmlformat; - *destsize = osync_xmlformat_size(); - osync_trace(TRACE_EXIT, "%s", __func__); return TRUE; |
From: <dg...@su...> - 2009-01-06 00:03:23
|
Author: dgollub Date: Tue Jan 6 01:02:57 2009 New Revision: 5024 URL: http://www.opensync.org/changeset/5024 Log: Changed merger/demerger format-plugin function prototypes, to use the format "input" pointer also as output reference. This avoids that the plugin needs to duplicate the memory. Initial implementation of demarshaling archive-store data (aka. the "entire entry") for merger() function call. Modified: trunk/opensync/engine/opensync_engine.c trunk/opensync/engine/opensync_obj_engine.c trunk/opensync/format/opensync_objformat.c trunk/opensync/format/opensync_objformat.h trunk/opensync/format/opensync_objformat_internals.h Modified: trunk/opensync/engine/opensync_engine.c ============================================================================== --- trunk/opensync/engine/opensync_engine.c Mon Jan 5 22:52:16 2009 (r5023) +++ trunk/opensync/engine/opensync_engine.c Tue Jan 6 01:02:57 2009 (r5024) @@ -264,8 +264,8 @@ { OSyncCapabilities *caps; OSyncObjFormat *objformat = osync_change_get_objformat(change); - char *entirebuf, *buffer, *outbuf; - unsigned int entsize, size = 0, outsize; + char *entirebuf, *buffer; + unsigned int entsize, size = 0; osync_trace(TRACE_INTERNAL, "Merge."); member = osync_client_proxy_get_member(proxy); @@ -278,19 +278,34 @@ int ret = osync_archive_load_data(engine->archive, uid, osync_change_get_objtype(change), &entirebuf, &entsize, &error); if (ret < 0) { goto error; - } + } if (ret > 0) { + OSyncMarshal *marshal; + + marshal = osync_marshal_new(&error); + if (!marshal) + goto error; + + osync_marshal_write_buffer(marshal, entirebuf, entsize); + + if (!osync_objformat_demarshal(objformat, marshal, &entirebuf, &entsize, &error)) { + osync_marshal_unref(marshal); + goto error; + } + + osync_marshal_unref(marshal); osync_data_get_data(osync_change_get_data(change), &buffer, &size); - ret = osync_objformat_merge(objformat, buffer, size, &outbuf, &outsize, entirebuf, entsize, caps, &error); + ret = osync_objformat_merge(objformat, &buffer, &size, entirebuf, entsize, caps, &error); osync_free(entirebuf); - osync_data_set_data(osync_change_get_data(change), outbuf, outsize); - if (ret != TRUE) goto error; + + osync_trace(TRACE_SENSITIVE, "Merge result:\n%s\n", + osync_objformat_print(objformat, buffer, size)); } } } Modified: trunk/opensync/engine/opensync_obj_engine.c ============================================================================== --- trunk/opensync/engine/opensync_obj_engine.c Mon Jan 5 22:52:16 2009 (r5023) +++ trunk/opensync/engine/opensync_obj_engine.c Tue Jan 6 01:02:57 2009 (r5024) @@ -1118,8 +1118,8 @@ { - char *buffer = NULL, *outbuf, *marshalbuf; - unsigned int outsize = 0, size = 0, marshalsize; + char *buffer = NULL, *marshalbuf; + unsigned int size = 0, marshalsize; const char *objtype = NULL; OSyncMapping *mapping = NULL; OSyncMarshal *marshal = NULL; @@ -1151,10 +1151,11 @@ osync_marshal_unref(marshal); - if (!osync_objformat_demerge(objformat, buffer, size, &outbuf, &outsize, caps, error)) + if (!osync_objformat_demerge(objformat, &buffer, &size, caps, error)) goto error; - osync_data_set_data(osync_change_get_data(entry_engine->change), outbuf, outsize); + osync_trace(TRACE_SENSITIVE, "Post Demerge:\n%s\n", + osync_objformat_print(objformat, buffer, size)); } Modified: trunk/opensync/format/opensync_objformat.c ============================================================================== --- trunk/opensync/format/opensync_objformat.c Mon Jan 5 22:52:16 2009 (r5023) +++ trunk/opensync/format/opensync_objformat.c Tue Jan 6 01:02:57 2009 (r5024) @@ -306,14 +306,13 @@ } osync_bool osync_objformat_merge(OSyncObjFormat *format, - const char *input, unsigned int inpsize, - char **output, unsigned int *outpsize, + char **data, unsigned int *size, const char *entire, unsigned int entsize, OSyncCapabilities *caps, OSyncError **error) { osync_assert(format); osync_return_val_if_fail(format->merge_func, TRUE); - return format->merge_func(input, inpsize, output, outpsize, entire, entsize, caps, format->user_data, error); + return format->merge_func(data, size, entire, entsize, caps, format->user_data, error); } void osync_objformat_set_demerge_func(OSyncObjFormat *format, OSyncFormatDemergeFunc demerge_func) @@ -323,13 +322,12 @@ } osync_bool osync_objformat_demerge(OSyncObjFormat *format, - const char *input, unsigned int inpsize, - char **output, unsigned int *outpsize, + char **data, unsigned int *size, OSyncCapabilities *caps, OSyncError **error) { osync_assert(format); osync_return_val_if_fail(format->demerge_func, TRUE); - return format->demerge_func(input, inpsize, output, outpsize, caps, format->user_data, error); + return format->demerge_func(data, size, caps, format->user_data, error); } Modified: trunk/opensync/format/opensync_objformat.h ============================================================================== --- trunk/opensync/format/opensync_objformat.h Mon Jan 5 22:52:16 2009 (r5023) +++ trunk/opensync/format/opensync_objformat.h Tue Jan 6 01:02:57 2009 (r5024) @@ -44,8 +44,8 @@ typedef osync_bool (* OSyncFormatDemarshalFunc) (OSyncMarshal *marshal, char **output, unsigned int *outpsize, void *user_data, OSyncError **error); typedef osync_bool (* OSyncFormatValidateFunc) (const char *data, unsigned int size, void *user_data, OSyncError **error); -typedef osync_bool (* OSyncFormatMergeFunc) (const char *input, unsigned int inpsize, char **output, unsigned int *outpsize, const char *entire, unsigned int entsize, OSyncCapabilities *caps,void *user_data, OSyncError **error); -typedef osync_bool (* OSyncFormatDemergeFunc) (const char *input, unsigned int inpsize, char **output, unsigned int *outpsize, OSyncCapabilities *caps, void *user_data, OSyncError **error); +typedef osync_bool (* OSyncFormatMergeFunc) (char **data, unsigned int *size, const char *entire, unsigned int entsize, OSyncCapabilities *caps, void *user_data, OSyncError **error); +typedef osync_bool (* OSyncFormatDemergeFunc) (char **data, unsigned int *size, OSyncCapabilities *caps, void *user_data, OSyncError **error); /** * @brief Creates a new object format Modified: trunk/opensync/format/opensync_objformat_internals.h ============================================================================== --- trunk/opensync/format/opensync_objformat_internals.h Mon Jan 5 22:52:16 2009 (r5023) +++ trunk/opensync/format/opensync_objformat_internals.h Tue Jan 6 01:02:57 2009 (r5024) @@ -182,19 +182,15 @@ * @brief Merge supplied data in format specific way * * @param format Pointer to the object format - * @param input Pointer to a buffer to merge - * @param inpsize Size in bytes of the buffer specified by the input parameter - * @param output Pointer to the output buffer for the result of the merge - * @param outpsize Size in bytes of the output buffer specified by the output parameter - * @param entire Pointer to the base data ("entire"-data) to merge with the buffer of parameter input + * @param data Reference of buffer which stores data to merge + * @param size Refernce of size in bytes of the buffer specified by the data paramter * @param entsize Size in bytes of the base data buffer specified by the entire parameter * @param caps The capabilities list which describes what must get merged: entire -> input * @param error Pointer to an error struct * @returns TRUE if data got merged successfully, otherwise FALSE */ OSYNC_TEST_EXPORT osync_bool osync_objformat_merge(OSyncObjFormat *format, - const char *input, unsigned int inpsize, - char **output, unsigned int *outpsize, + char **data, unsigned int *size, const char *entire, unsigned int entsize, OSyncCapabilities *caps, OSyncError **error); @@ -202,17 +198,14 @@ * @brief Demrge supplied data in format specific way * * @param format Pointer to the object format - * @param input Pointer to a buffer to demerge - * @param inpsize Size in bytes of the buffer specified by the input parameter - * @param output Pointer to the output buffer for the result of the demerge - * @param outpsize Size in bytes of the output buffer specified by the output parameter + * @param data Pointer to the buffer which should get demerged + * @param size Reference of size in bytes of the buffer specified by the data parameter * @param caps The capabilities list which describes what must get demerged * @param error Pointer to an error struct * @returns TRUE if data got demerged successfully, otherwise FALSE */ OSYNC_TEST_EXPORT osync_bool osync_objformat_demerge(OSyncObjFormat *format, - const char *input, unsigned int inpsize, - char **output, unsigned int *outpsize, + char **data, unsigned int *size, OSyncCapabilities *caps, OSyncError **error); /** |
From: <dg...@su...> - 2009-01-05 21:52:38
|
Author: dgollub Date: Mon Jan 5 22:52:16 2009 New Revision: 5023 URL: http://www.opensync.org/changeset/5023 Log: Print object format name in entry-status callbacks. Modified: osynctool/trunk/tools/osynctool.c Modified: osynctool/trunk/tools/osynctool.c ============================================================================== --- osynctool/trunk/tools/osynctool.c Mon Jan 5 21:31:55 2009 (r5022) +++ osynctool/trunk/tools/osynctool.c Mon Jan 5 22:52:16 2009 (r5023) @@ -363,22 +363,25 @@ switch (status->type) { case OSYNC_CHANGE_EVENT_READ: - printf("Received an entry %s from member %lli (%s). Changetype %s\n", + printf("Received an entry %s (%s) from member %lli (%s). Changetype %s\n", osync_change_get_uid(status->change), + osync_objformat_get_name(osync_change_get_objformat(status->change)), osync_member_get_id(status->member), osync_member_get_pluginname(status->member), OSyncChangeType2String(osync_change_get_changetype(status->change))); break; case OSYNC_CHANGE_EVENT_WRITTEN: - printf("Sent an entry %s to member %lli (%s). Changetype %s\n", + printf("Sent an entry %s (%s) to member %lli (%s). Changetype %s\n", osync_change_get_uid(status->change), + osync_objformat_get_name(osync_change_get_objformat(status->change)), osync_member_get_id(status->member), osync_member_get_pluginname(status->member), OSyncChangeType2String(osync_change_get_changetype(status->change))); break; case OSYNC_CHANGE_EVENT_ERROR: - printf("Error for entry %s and member %lli (%s): %s\n", + printf("Error for entry %s (%s) and member %lli (%s): %s\n", osync_change_get_uid(status->change), + osync_objformat_get_name(osync_change_get_objformat(status->change)), osync_member_get_id(status->member), osync_member_get_pluginname(status->member), osync_error_print(&(status->error))); |
From: <dg...@su...> - 2009-01-05 20:32:20
|
Author: dgollub Date: Mon Jan 5 21:31:55 2009 New Revision: 5022 URL: http://www.opensync.org/changeset/5022 Log: Reference port of OSyncAnchor API change. See r5021 Modified: plugins/file-sync/src/file_sync.c Modified: plugins/file-sync/src/file_sync.c ============================================================================== --- plugins/file-sync/src/file_sync.c Mon Jan 5 21:31:24 2009 (r5021) +++ plugins/file-sync/src/file_sync.c Mon Jan 5 21:31:55 2009 (r5022) @@ -63,16 +63,15 @@ OSyncObjTypeSink *sink = osync_plugin_info_get_sink(info); OSyncFileDir *dir = osync_objtype_sink_get_userdata(sink); + OSyncAnchor *anchor = osync_objtype_sink_get_anchor(sink); + osync_bool anchormatch; - char *anchorpath = g_strdup_printf("%s/anchor.db", osync_plugin_info_get_configdir(info)); - char *path_field = g_strdup_printf("path_%s", osync_objtype_sink_get_name(dir->sink)); + if (!osync_anchor_compare(anchor, dir->path, &anchormatch, &error)) + goto error; - if (!osync_anchor_compare(anchorpath, path_field, dir->path)) + if (!anchormatch) osync_objtype_sink_set_slowsync(dir->sink, TRUE); - g_free(anchorpath); - g_free(path_field); - if (!g_file_test(dir->path, G_FILE_TEST_IS_DIR)) { osync_error_set(&error, OSYNC_ERROR_GENERIC, "\"%s\" is not a directory", dir->path); goto error; @@ -495,12 +494,10 @@ OSyncObjTypeSink *sink = osync_plugin_info_get_sink(info); OSyncFileDir *dir = osync_objtype_sink_get_userdata(sink); + OSyncAnchor *anchor = osync_objtype_sink_get_anchor(sink); - char *anchorpath = g_strdup_printf("%s/anchor.db", osync_plugin_info_get_configdir(info)); - char *path_field = g_strdup_printf("path_%s", osync_objtype_sink_get_name(sink)); - osync_anchor_update(anchorpath, path_field, dir->path); - g_free(anchorpath); - g_free(path_field); + if (!osync_anchor_update(anchor, dir->path, &error)) + goto error; if (!osync_hashtable_save(dir->hashtable, &error)) goto error; @@ -582,6 +579,10 @@ * again once the functions are called */ osync_objtype_sink_set_functions(dir->sink, functions, dir); + + /* Request an anchor from the framework. */ + osync_objtype_sink_enable_anchor(dir->sink, TRUE); + 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); |
From: <dg...@su...> - 2009-01-05 20:31:47
|
Author: dgollub Date: Mon Jan 5 21:31:24 2009 New Revision: 5021 URL: http://www.opensync.org/changeset/5021 Log: Introduced new OSyncArchive interface. The new OSyncArchive doesn't require anylonger to get a file-location specified. The database location is now handled internally and doesn't require special handling by the plugin anylonger. This allows later to easily add support further database-connectinos without any additional porting of plugins. Internally there is still a light dependency on sqlite3, which can be fixed without breaking the public API of the OSyncArchive. Porting instruction for plugins which using OSyncAnchor: Most important changes: osync_anchor_compare() doesn't return the comparsion result anylonger! Instead it returns FALSE on an error when quering the database in the background, TRUE otherwise. An additional parameter got added to determine if the anchor value is the same. - if (!osync_anchor_compare(anchorpath, key, value)) - osync_objtype_sink_set_slowsync(sink, TRUE); + if (!osync_anchor_compare(anchor, value, &anchormatch, &error)) + goto error; + if (!anchormatch) # osync_objtype_sink_set_slowsync(sink, TRUE); Also the first argument of osync_anchor_compare() and osync_anchor_update() changed. Instead of the anchor-database file location, an OSyncArchive pointer is required. You can get the pointer by calling: OSyncObjTypeSink *sink = osync_plugin_info_get_sink(plugin_info); + OSyncAnchor *anchor = osync_objtype_sink_get_anchor(sink); The key parameter from osync_anchor_compare() and osync_anchor_update() got completely removed. This is not required anylonger since the OSyncArchive is Object Type Sink specific. So for each sink you have a different OSyncArchive object. OSyncArchive is also available for the main-sink! Example of osync_anchor_udpate() port in the sync_done() function: - const char *key = "foo"; - osync_anchor_update(anchorpath, key, value); + OSyncAnchor *anchor = osync_objtype_sink_get_anchor(sink); + if (!osync_anchor_update(anchor, value, &error)) + goto error; Last but not least. OSyncAnchor is stil optional! If your plugin requries an OSyncArchive, it needs to be requested when initailizing the OSyncObjTypeSinks in the plugin initialize function, by calling: + /* Request an anchor from the framework. */ + osync_objtype_sink_enable_anchor(sink, TRUE); Otherwise the call of osync_objtype_sink_get_anchor() will return NULL. Reference counting of the anchor is done inside the engine. Added: trunk/opensync/helper/opensync_anchor_internals.h (contents, props changed) - copied, changed from r5017, trunk/opensync/helper/opensync_anchor_private.h Modified: trunk/opensync.sym trunk/opensync/client/opensync_client.c trunk/opensync/helper/opensync_anchor.c trunk/opensync/helper/opensync_anchor.h trunk/opensync/helper/opensync_anchor_private.h trunk/opensync/plugin/opensync_objtype_sink.c trunk/opensync/plugin/opensync_objtype_sink.h trunk/opensync/plugin/opensync_objtype_sink_internals.h trunk/opensync/plugin/opensync_objtype_sink_private.h trunk/tests/mock-plugin/mock_sync.c trunk/wrapper/opensync-helper.i Modified: trunk/opensync.sym ============================================================================== --- trunk/opensync.sym Mon Jan 5 21:04:22 2009 (r5020) +++ trunk/opensync.sym Mon Jan 5 21:31:24 2009 (r5021) @@ -394,7 +394,9 @@ osync_objtype_sink_connect osync_objtype_sink_connect_done osync_objtype_sink_disconnect +osync_objtype_sink_enable_anchor osync_objtype_sink_find_objformat_sink +osync_objtype_sink_get_anchor osync_objtype_sink_get_changes osync_objtype_sink_get_getchanges osync_objtype_sink_get_name Modified: trunk/opensync/client/opensync_client.c ============================================================================== --- trunk/opensync/client/opensync_client.c Mon Jan 5 21:04:22 2009 (r5020) +++ trunk/opensync/client/opensync_client.c Mon Jan 5 21:31:24 2009 (r5021) @@ -42,6 +42,8 @@ #include "opensync_client_internals.h" #include "opensync_client_private.h" +#include "helper/opensync_anchor_internals.h" + #ifdef OPENSYNC_UNITTESTS #include "plugin/opensync_plugin_info_private.h" /* FIXME: access directly private header */ #endif @@ -562,6 +564,7 @@ char *groupname = NULL; char *configdir = NULL; char *formatdir = NULL; + char *anchorpath = NULL; int haspluginconfig = 0; OSyncPluginConfig *config = NULL; OSyncQueue *outgoing = NULL; @@ -572,6 +575,7 @@ const char *preferred_format = NULL; OSyncList *o = NULL; OSyncObjFormatSink *format_sink = NULL; + unsigned int n, num_sinks; osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, client, message, error); @@ -691,6 +695,34 @@ goto error; } + + + /* FIXME: Get rid of file lcoation! + * Later with fruther OSyncDB modifications this should be file-hiarchy indepdendent. + * And The first arg should just consists of the Member ID + */ + anchorpath = osync_strdup_printf("%s/anchor.db", osync_plugin_info_get_configdir(client->plugin_info)); + + num_sinks = osync_plugin_info_num_objtypes(client->plugin_info); + for (n = 0; n < num_sinks; n++) { + OSyncAnchor *anchor = NULL; + + sink = osync_plugin_info_nth_objtype(client->plugin_info, n); + + if (!osync_objtype_sink_has_anchor(sink)) + continue; + + anchor = osync_anchor_new(anchorpath, objtype, error); + if (!anchor) { + osync_free(anchorpath); + goto error_finalize; + } + + osync_objtype_sink_set_anchor(sink, anchor); + + } + osync_free(anchorpath); + reply = osync_message_new_reply(message, error); if (!reply) goto error_finalize; Modified: trunk/opensync/helper/opensync_anchor.c ============================================================================== --- trunk/opensync/helper/opensync_anchor.c Mon Jan 5 21:04:22 2009 (r5020) +++ trunk/opensync/helper/opensync_anchor.c Mon Jan 5 21:31:24 2009 (r5021) @@ -24,18 +24,17 @@ #include "opensync-helper.h" #include "opensync-db.h" +#include "opensync_anchor_internals.h" #include "opensync_anchor_private.h" -/* start private api */ - -static osync_bool osync_anchor_db_create(OSyncDB *db, OSyncError **error) +osync_bool osync_anchor_create(OSyncAnchor *anchor, OSyncError **error) { char *query = NULL; - osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, db, error); + osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, anchor, error); query = g_strdup("CREATE TABLE tbl_anchor (id INTEGER PRIMARY KEY, anchor VARCHAR, objtype VARCHAR UNIQUE)"); - if (!osync_db_query(db, query, error)) { + if (!osync_db_query(anchor->db, query, error)) { osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); g_free(query); return FALSE; @@ -47,162 +46,161 @@ return TRUE; } -static OSyncDB *osync_anchor_db_new(const char *filename, OSyncError **error) +OSyncAnchor *osync_anchor_new(const char *filename, const char *objtype, OSyncError **error) { - OSyncDB *db = NULL; + OSyncAnchor *anchor = NULL; int ret = 0; - osync_trace(TRACE_ENTRY, "%s(%s, %p)", __func__, filename, error); + osync_trace(TRACE_ENTRY, "%s(%s, %s, %p)", __func__, __NULLSTR(filename), __NULLSTR(objtype), error); - db = osync_db_new(error); - if (!db) + anchor = osync_try_malloc0(sizeof(OSyncAnchor), error); + if (!anchor) goto error; - if (!osync_db_open(db, filename, error)) { + anchor->ref_count = 1; + + /* Could be NULL, which means object type neutral + * or data for the main-sink. + */ + if (objtype) + anchor->objtype = osync_strdup(objtype); + + anchor->db = osync_db_new(error); + if (!anchor->db) + goto error_free_anchor; + + if (!osync_db_open(anchor->db, filename, error)) { osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); goto error_free_db; } - ret = osync_db_table_exists(db, "tbl_anchor", error); + ret = osync_db_table_exists(anchor->db, "tbl_anchor", error); if (ret > 0) { - osync_trace(TRACE_EXIT, "%s: %p", __func__, db); - return db; + osync_trace(TRACE_EXIT, "%s: %p", __func__, anchor->db); + return anchor; /* error if ret == -1 */ } else if (ret < 0) { goto error_free_db; } - /* ret equal 0 means table does not exist yet. continue and create one. */ - if (!osync_anchor_db_create(db, error)) + /* ret equal 0 means table does not exist yet. continue and create one. */ + if (!osync_anchor_create(anchor, error)) goto error_free_db; - osync_trace(TRACE_EXIT, "%s: %p", __func__, db); - return db; + osync_trace(TRACE_EXIT, "%s: %p", __func__, anchor); + return anchor; error_free_db: - g_free(db); + g_free(anchor->db); + error_free_anchor: + osync_anchor_unref(anchor); error: osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); return NULL; } -static void osync_anchor_db_free(OSyncDB *db) +OSyncAnchor *osync_anchor_ref(OSyncAnchor *anchor) { - osync_assert(db); - - if (!osync_db_close(db, NULL)) - osync_trace(TRACE_INTERNAL, "Can't close database"); + osync_return_val_if_fail(anchor, NULL); + + g_atomic_int_inc(&(anchor->ref_count)); - g_free(db); + return anchor; } -static char *osync_anchor_db_retrieve(OSyncDB *db, const char *key) +void osync_anchor_unref(OSyncAnchor *anchor) { - char *retanchor = NULL; - char *escaped_key = NULL; - char *query = NULL; - osync_trace(TRACE_ENTRY, "%s(%p, %s)", __func__, db, key); - osync_assert(db); - osync_assert(key); - - escaped_key = osync_db_sql_escape(key); - query = g_strdup_printf("SELECT anchor FROM tbl_anchor WHERE objtype='%s'", escaped_key); - retanchor = osync_db_query_single_string(db, query, NULL); - g_free(query); - g_free(escaped_key); + osync_return_if_fail(anchor); + + if (g_atomic_int_dec_and_test(&(anchor->ref_count))) { - osync_trace(TRACE_EXIT, "%s: %s", __func__, retanchor); - return retanchor; -} + if (!osync_db_close(anchor->db, NULL)) + osync_trace(TRACE_INTERNAL, "Can't close database"); -static void osync_anchor_db_update(OSyncDB *db, const char *key, const char *anchor) -{ - char *escaped_key = NULL; - char *escaped_anchor = NULL; - char *query = NULL; - osync_trace(TRACE_ENTRY, "%s(%p, %, %s)", __func__, db, key, anchor); - osync_assert(db); - osync_assert(key); - - escaped_key = osync_db_sql_escape(key); - escaped_anchor = osync_db_sql_escape(anchor); - query = g_strdup_printf("REPLACE INTO tbl_anchor (objtype, anchor) VALUES('%s', '%s')", escaped_key, escaped_anchor); - g_free(escaped_key); - g_free(escaped_anchor); - - /* TODO: Add Error handling in this function for osync_db_query() */ - if (!osync_db_query(db, query, NULL)) { - osync_trace(TRACE_INTERNAL, "Unable put anchor!"); - } - g_free(query); + if (anchor->objtype) + osync_free(anchor->objtype); - osync_trace(TRACE_EXIT, "%s", __func__); -} + g_free(anchor->db); -/* end private api */ + osync_free(anchor); + } +} -osync_bool osync_anchor_compare(const char *anchordb, const char *key, const char *new_anchor) +char *osync_anchor_retrieve(OSyncAnchor *anchor, OSyncError **error) { - OSyncDB *db = NULL; - char *old_anchor = NULL; - osync_bool retval = FALSE; + char *retanchor = NULL; + char *query = NULL; + osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, anchor, error); + osync_assert(anchor); + osync_assert(anchor->db); - osync_trace(TRACE_ENTRY, "%s(%s, %s, %s)", __func__, anchordb, key, new_anchor); - osync_assert(anchordb); + query = g_strdup_printf("SELECT anchor FROM tbl_anchor WHERE objtype='%s'", anchor->objtype ? anchor->objtype : ""); + retanchor = osync_db_query_single_string(anchor->db, query, error); + g_free(query); - db = osync_anchor_db_new(anchordb, NULL); - if (!db) - return FALSE; + if (osync_error_is_set(error)) + goto error; - old_anchor = osync_anchor_db_retrieve(db, key); - if (old_anchor) { - if (!strcmp(old_anchor, new_anchor)) { - retval = TRUE; - } else { - retval = FALSE; - } - g_free(old_anchor); - } + if (!retanchor) + retanchor = osync_strdup(""); - osync_anchor_db_free(db); + osync_trace(TRACE_EXIT, "%s: %s", __func__, retanchor); + return retanchor; - osync_trace(TRACE_EXIT, "%s: %i", __func__, retval); - return retval; +error: + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return NULL; } -void osync_anchor_update(const char *anchordb, const char *key, const char *new_anchor) +osync_bool osync_anchor_update(OSyncAnchor *anchor, const char *value, OSyncError **error) { - OSyncDB *db = NULL; - osync_trace(TRACE_ENTRY, "%s(%s, %s, %s)", __func__, anchordb, key, new_anchor); - osync_assert(anchordb); - - db = osync_anchor_db_new(anchordb, NULL); - if (!db) - return; + char *escaped_value = 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(value); + + escaped_value = osync_db_sql_escape(value); + query = g_strdup_printf("REPLACE INTO tbl_anchor (objtype, anchor) VALUES('%s', '%s')", + anchor->objtype ? anchor->objtype : "", escaped_value); + g_free(escaped_value); - osync_anchor_db_update(db, key, new_anchor); + if (!osync_db_query(anchor->db, query, error)) + goto error; - osync_anchor_db_free(db); + g_free(query); osync_trace(TRACE_EXIT, "%s", __func__); - return; + return TRUE; + +error: + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return FALSE; } -char *osync_anchor_retrieve(const char *anchordb, const char *key) +osync_bool osync_anchor_compare(OSyncAnchor *anchor, const char *new_anchor, osync_bool *same, OSyncError **error) { - OSyncDB *db = NULL; - char *retval = NULL; + char *old_anchor = NULL; - osync_trace(TRACE_ENTRY, "%s(%s, %s)", __func__, anchordb, key); - osync_assert(anchordb); + osync_trace(TRACE_ENTRY, "%s(%p, %s, %p, %p)", __func__, anchor, __NULLSTR(new_anchor), same, error); + osync_assert(anchor); - db = osync_anchor_db_new(anchordb, NULL); - if (!db) - return NULL; + old_anchor = osync_anchor_retrieve(anchor, error); + if (!old_anchor) + goto error; - retval = osync_anchor_db_retrieve(db, key); + if (!strcmp(old_anchor, new_anchor)) + *same = TRUE; + else + *same = FALSE; - osync_anchor_db_free(db); + g_free(old_anchor); - osync_trace(TRACE_EXIT, "%s: %s", __func__, retval); - return retval; + osync_trace(TRACE_EXIT, "%s", __func__); + return TRUE; + +error: + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return FALSE; } + Modified: trunk/opensync/helper/opensync_anchor.h ============================================================================== --- trunk/opensync/helper/opensync_anchor.h Mon Jan 5 21:04:22 2009 (r5020) +++ trunk/opensync/helper/opensync_anchor.h Mon Jan 5 21:31:24 2009 (r5021) @@ -52,31 +52,35 @@ /** @brief Compares the value of an anchor with the supplied value * - * @param anchordb the full path to the anchor database file - * @param key the key of the anchor to look up + * @param anchor Pointer to the anchor object * @param new_anchor the value to compare with the stored value - * @returns TRUE if the anchor matches, FALSE otherwise + * @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(const char *anchordb, const char *key, const char *new_anchor); +OSYNC_EXPORT osync_bool osync_anchor_compare(OSyncAnchor *anchor, const char *new_anchor, osync_bool *issame, OSyncError **error); /** @brief Updates the value of an anchor * - * @param anchordb the full path to the anchor database file - * @param key the key of the anchor to look up + * @param anchor Pointer to the anchor object * @param new_anchor 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 void osync_anchor_update(const char *anchordb, const char *key, const char *new_anchor); +OSYNC_EXPORT osync_bool osync_anchor_update(OSyncAnchor *anchor, const char *new_anchor, OSyncError **error); /** @brief Retrieves the value of an anchor * - * @param anchordb the full path to the anchor database file - * @param key the key of the anchor to look up - * @returns the value of the anchor if it was found, otherwise NULL + * @param anchor Pointer to the anchor object + * @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(const char *anchordb, const char *key); +OSYNC_EXPORT char *osync_anchor_retrieve(OSyncAnchor *anchor, OSyncError **error); /*@}*/ Copied and modified: trunk/opensync/helper/opensync_anchor_internals.h (from r5017, trunk/opensync/helper/opensync_anchor_private.h) ============================================================================== --- trunk/opensync/helper/opensync_anchor_private.h Mon Jan 5 17:59:09 2009 (r5017, copy source) +++ trunk/opensync/helper/opensync_anchor_internals.h Mon Jan 5 21:31:24 2009 (r5021) @@ -18,77 +18,54 @@ * */ -#ifndef OPENSYNC_ANCHOR_PRIVATE_H_ -#define OPENSYNC_ANCHOR_PRIVATE_H_ +#ifndef OPENSYNC_ANCHOR_INTERNALS_H_ +#define OPENSYNC_ANCHOR_INTERNALS_H_ /** - * @defgroup OSyncHelperPrivate OpenSync Helper Module Private + * @defgroup OSyncHelperInternals OpenSync Helper Module Internals * @ingroup OSyncPrivate - * @defgroup OSyncAnchorPrivateAPI OpenSync Anchor Private + * @defgroup OSyncAnchorInternalsAPI OpenSync Anchor Internals * @ingroup OSyncHelperPrivate * @brief Internal functions to deal with anchors */ -/*@{*/ - -/** - * @brief OSyncAnchor struct - */ -struct OSyncAnchor { - /* Reference counting */ - int ref_count; - /* Pointer to the OSyncDatabase */ - OSyncDB *db; -}; - /** * @brief Create the anchor table in the specified database * - * @param db Pointer to the database + * @param anchor Pointer to the anchor * @param error Pointer to an error struct * @returns TRUE if the table was created successfully, FALSE otherwise * */ -static osync_bool osync_anchor_db_create(OSyncDB *db, OSyncError **error); +osync_bool osync_anchor_create(OSyncAnchor *anchor, OSyncError **error); /** * @brief Create an anchor database * * @param filename the full path to the database file to create + * @param objtype Object Type to assoicate this anchor, NULL for main-sink. * @param error Pointer to an error struct - * @returns a pointer to the new database - * - */ -static OSyncDB *osync_anchor_db_new(const char *filename, OSyncError **error); - -/** - * @brief Close and free an anchor database handle - * - * @param db Pointer to the database + * @returns a pointer to the new database, NULL on error * */ -static void osync_anchor_db_free(OSyncDB *db); +OSyncAnchor *osync_anchor_new(const char *filename, const char *objtype, OSyncError **error); /** - * @brief Retrieves the value of an anchor + * @brief Increase the reference count on an anchor * - * @param db Pointer to the database - * @param key the key of the anchor to look up - * @returns the value of the anchor if it was found, otherwise NULL + * @param anchor Pointer to the anchor * */ -static char *osync_anchor_db_retrieve(OSyncDB *db, const char *key); +OSyncAnchor *osync_anchor_ref(OSyncAnchor *anchor); /** - * @brief Updates the value of an anchor + * @brief Decrease the reference count on an anchor * - * @param db Pointer to the database - * @param key the key of the anchor to look up - * @param anchor the new value to set + * @param anchor Pointer to the anchor * */ -static void osync_anchor_db_update(OSyncDB *db, const char *key, const char *anchor); +void osync_anchor_unref(OSyncAnchor *anchor); /*@}*/ -#endif /* OPENSYNC_ANCHOR_PRIVATE_H_ */ +#endif /* OPENSYNC_ANCHOR_INTERNALS_H_ */ Modified: trunk/opensync/helper/opensync_anchor_private.h ============================================================================== --- trunk/opensync/helper/opensync_anchor_private.h Mon Jan 5 21:04:22 2009 (r5020) +++ trunk/opensync/helper/opensync_anchor_private.h Mon Jan 5 21:31:24 2009 (r5021) @@ -39,56 +39,10 @@ int ref_count; /* Pointer to the OSyncDatabase */ OSyncDB *db; + /* Associated object type */ + char *objtype; }; -/** - * @brief Create the anchor table in the specified database - * - * @param db Pointer to the database - * @param error Pointer to an error struct - * @returns TRUE if the table was created successfully, FALSE otherwise - * - */ -static osync_bool osync_anchor_db_create(OSyncDB *db, OSyncError **error); - -/** - * @brief Create an anchor database - * - * @param filename the full path to the database file to create - * @param error Pointer to an error struct - * @returns a pointer to the new database - * - */ -static OSyncDB *osync_anchor_db_new(const char *filename, OSyncError **error); - -/** - * @brief Close and free an anchor database handle - * - * @param db Pointer to the database - * - */ -static void osync_anchor_db_free(OSyncDB *db); - -/** - * @brief Retrieves the value of an anchor - * - * @param db Pointer to the database - * @param key the key of the anchor to look up - * @returns the value of the anchor if it was found, otherwise NULL - * - */ -static char *osync_anchor_db_retrieve(OSyncDB *db, const char *key); - -/** - * @brief Updates the value of an anchor - * - * @param db Pointer to the database - * @param key the key of the anchor to look up - * @param anchor the new value to set - * - */ -static void osync_anchor_db_update(OSyncDB *db, const char *key, const char *anchor); - /*@}*/ #endif /* OPENSYNC_ANCHOR_PRIVATE_H_ */ Modified: trunk/opensync/plugin/opensync_objtype_sink.c ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink.c Mon Jan 5 21:04:22 2009 (r5020) +++ trunk/opensync/plugin/opensync_objtype_sink.c Mon Jan 5 21:31:24 2009 (r5021) @@ -24,6 +24,8 @@ #include "opensync-context.h" #include "opensync-format.h" +#include "opensync/helper/opensync_anchor_internals.h" + #include "opensync_objtype_sink.h" #include "opensync_objtype_sink_private.h" @@ -72,6 +74,9 @@ osync_objformat_sink_unref(sink->objformatsinks->data); sink->objformatsinks = osync_list_remove(sink->objformatsinks, sink->objformatsinks->data); } + + if (sink->anchor) + osync_anchor_unref(sink->anchor); if (sink->preferred_format) g_free(sink->preferred_format); @@ -83,6 +88,33 @@ } } +void osync_objtype_sink_enable_anchor(OSyncObjTypeSink *sink, osync_bool enable) +{ + osync_return_if_fail(sink); + sink->anchor_requested = enable; +} + +osync_bool osync_objtype_sink_has_anchor(OSyncObjTypeSink *sink) +{ + osync_return_val_if_fail(sink, FALSE); + return sink->anchor_requested; +} + +OSyncAnchor *osync_objtype_sink_get_anchor(OSyncObjTypeSink *sink) +{ + osync_return_val_if_fail(sink, NULL); + return sink->anchor; +} + +void osync_objtype_sink_set_anchor(OSyncObjTypeSink *sink, OSyncAnchor *anchor) +{ + osync_return_if_fail(sink); + if (sink->anchor) + osync_anchor_unref(sink->anchor); + + sink->anchor = osync_anchor_ref(anchor); +} + const char *osync_objtype_sink_get_name(OSyncObjTypeSink *sink) { osync_assert(sink); Modified: trunk/opensync/plugin/opensync_objtype_sink.h ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink.h Mon Jan 5 21:04:22 2009 (r5020) +++ trunk/opensync/plugin/opensync_objtype_sink.h Mon Jan 5 21:31:24 2009 (r5021) @@ -90,6 +90,35 @@ */ OSYNC_EXPORT void osync_objtype_sink_unref(OSyncObjTypeSink *sink); +/*! @brief Request an anchor for this Sink + * + * If for this sink an anchor is required, this needs to be requested by this + * function. If anchor gets enabled/requested inside the plugin, the framework + * will take care about preparing the anchor. The created anchor can be accessed + * by using the function osync_objtype_sink_get_anchor() + * + * By default no anchor is requested/enabled. + * + * @param sink Pointer to the sink + * @param enable Flag to enable, disbable anchor. + * + */ +OSYNC_EXPORT void osync_objtype_sink_enable_anchor(OSyncObjTypeSink *sink, osync_bool enable); + +/*! @brief Get the pointer to the sink OSyncAnchor + * + * This Anchor is sink specific and can store persistent, sink specific data. + * Originally designed to detect if a certain value changed since last + * synchronization on the peer. E.g. to decided if a slow-sync is requried + * or not. + * + * @param sink Pointer to the sink + * @returns the name of the object type of the specified sink + * + */ +OSYNC_EXPORT OSyncAnchor *osync_objtype_sink_get_anchor(OSyncObjTypeSink *sink); + + /*! @brief Return the name of the object type of a sink * * @param sink Pointer to the sink Modified: trunk/opensync/plugin/opensync_objtype_sink_internals.h ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink_internals.h Mon Jan 5 21:04:22 2009 (r5020) +++ trunk/opensync/plugin/opensync_objtype_sink_internals.h Mon Jan 5 21:31:24 2009 (r5021) @@ -29,6 +29,27 @@ */ /*@{*/ + +/*! @brief Check if sink has an anchor request. + * + * @param sink Pointer to the sink + * @returns TRUE if the sink has an anchor request, FALSE otherwise + */ +osync_bool osync_objtype_sink_has_anchor(OSyncObjTypeSink *sink); + +/*! @brief Set the OSyncAnchor for this sink + * + * This Anchor is sink specific and can store persistent, sink specific data. + * Originally designed to detect if a certain value changed since last + * synchronization on the peer. E.g. to decided if a slow-sync is requried + * or not. + * + * @param sink Pointer to the sink + * @param anchor Pointer to the Anchor object + * + */ +void osync_objtype_sink_set_anchor(OSyncObjTypeSink *sink, OSyncAnchor *anchor); + /*! @brief Checks if sink has a read single entries function (read) * * @param sink Pointer to the sink Modified: trunk/opensync/plugin/opensync_objtype_sink_private.h ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink_private.h Mon Jan 5 21:04:22 2009 (r5020) +++ trunk/opensync/plugin/opensync_objtype_sink_private.h Mon Jan 5 21:31:24 2009 (r5021) @@ -68,10 +68,17 @@ } OSyncObjTypeSinkFunctionTimeouts; struct OSyncObjTypeSink { + /** The sink anchor if requested by the plugin */ + OSyncAnchor *anchor; + + /** Flag if anchor is requested by plugin */ + osync_bool anchor_requested; + /** The preferred step or target format for the conversion path of this sink */ char *preferred_format; /** The format which can be synchronized by this sink */ OSyncList *objformatsinks; + /** The functions to be called */ OSyncObjTypeSinkFunctions functions; void *userdata; @@ -103,7 +110,9 @@ /** The request status of a slow-sync of this sink */ osync_bool slowsync; + /** Referce counting */ int ref_count; + /** List to pile up changes for batch commit */ GList *commit_changes; GList *commit_contexts; Modified: trunk/tests/mock-plugin/mock_sync.c ============================================================================== --- trunk/tests/mock-plugin/mock_sync.c Mon Jan 5 21:04:22 2009 (r5020) +++ trunk/tests/mock-plugin/mock_sync.c Mon Jan 5 21:31:24 2009 (r5021) @@ -52,7 +52,9 @@ static void mock_connect(void *data, OSyncPluginInfo *info, OSyncContext *ctx) { + osync_bool anchor_compare_match; OSyncObjTypeSink *sink = osync_plugin_info_get_sink(info); + OSyncAnchor *anchor = osync_objtype_sink_get_anchor(sink); MockDir *dir = osync_objtype_sink_get_userdata(sink); osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, data, info, ctx); @@ -86,14 +88,11 @@ */ dir->connect_done = FALSE; - char *anchorpath = g_strdup_printf("%s/anchor.db", osync_plugin_info_get_configdir(info)); - char *path_field = g_strdup_printf("path_%s", osync_objtype_sink_get_name(sink)); - if (!osync_anchor_compare(anchorpath, path_field, dir->path)) + osync_assert_msg(osync_anchor_compare(anchor, dir->path, &anchor_compare_match, NULL), "Not expected to fail"); + + if (!anchor_compare_match) osync_objtype_sink_set_slowsync(sink, TRUE); - g_free(anchorpath); - g_free(path_field); - osync_assert(g_file_test(dir->path, G_FILE_TEST_IS_DIR)); end: @@ -542,6 +541,7 @@ { osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, data, info, ctx); OSyncObjTypeSink *sink = osync_plugin_info_get_sink(info); + OSyncAnchor *anchor = osync_objtype_sink_get_anchor(sink); MockDir *dir = osync_objtype_sink_get_userdata(sink); if (mock_get_error(info->memberid, "SYNC_DONE_ERROR")) { @@ -551,12 +551,7 @@ if (mock_get_error(info->memberid, "SYNC_DONE_TIMEOUT")) return; - char *anchorpath = g_strdup_printf("%s/anchor.db", osync_plugin_info_get_configdir(info)); - char *path_field = g_strdup_printf("path_%s", osync_objtype_sink_get_name(sink)); - osync_anchor_update(anchorpath, path_field, dir->path); - g_free(anchorpath); - g_free(path_field); - + osync_assert_msg(osync_anchor_update(anchor, dir->path, NULL), "Not expected to fail!"); osync_assert(osync_hashtable_save(dir->hashtable, NULL)); osync_context_report_success(ctx); @@ -680,6 +675,9 @@ * again once the functions are called */ osync_objtype_sink_set_functions(sink, functions, dir); + /* Request an Anchor */ + osync_objtype_sink_enable_anchor(sink, TRUE); + //Lets reduce the timeouts a bit so the checks work faster osync_objtype_sink_set_connect_timeout(sink, 2); osync_objtype_sink_set_getchanges_timeout(sink, 2); Modified: trunk/wrapper/opensync-helper.i ============================================================================== --- trunk/wrapper/opensync-helper.i Mon Jan 5 21:04:22 2009 (r5020) +++ trunk/wrapper/opensync-helper.i Mon Jan 5 21:31:24 2009 (r5021) @@ -1,14 +1,34 @@ %inline %{ - static bool anchor_compare(const char *anchordb, const char *key, const char *new_anchor) { - return osync_anchor_compare(anchordb, key, new_anchor); + static bool anchor_compare(OSyncAnchor *anchor, const char *new_anchor) { + Error *err = NULL; + bool ret; + + osync_anchor_compare(anchor, new_anchor, &ret, &err); + + if (raise_exception_on_error(err)) + return FALSE; + + return ret; } - static void anchor_update(const char *anchordb, const char *key, const char *new_anchor) { - osync_anchor_update(anchordb, key, new_anchor); + static bool anchor_update(OSyncAnchor *anchor, const char *new_anchor) { + Error *err = NULL; + osync_anchor_update(anchor, new_anchor, &err); + if (raise_exception_on_error(err)) + return FALSE; + + return TRUE; } - static char *anchor_retrieve(const char *anchordb, const char *key) { - return osync_anchor_retrieve(anchordb, key); + static char *anchor_retrieve(OSyncAnchor *anchor) { + Error *err = NULL; + char *ret; + ret = osync_anchor_retrieve(anchor, &err); + + if (raise_exception_on_error(err)) + return NULL; + + return ret; } %} |
From: <dg...@su...> - 2009-01-05 20:04:46
|
Author: bricks Date: Mon Jan 5 21:04:22 2009 New Revision: 5020 URL: http://www.opensync.org/changeset/5020 Log: added cmake dir Added: trunk/docs/examples/applications/cmake/ (props changed) |
From: <dg...@su...> - 2009-01-05 19:50:37
|
Author: bricks Date: Mon Jan 5 20:50:13 2009 New Revision: 5019 URL: http://www.opensync.org/changeset/5019 Log: moved example-plugin to examples/plugins Added: trunk/docs/examples/plugins/ (props changed) - copied from r5017, trunk/docs/example-plugin/ Deleted: trunk/docs/example-plugin/ |
From: <dg...@su...> - 2009-01-05 19:49:50
|
Author: bricks Date: Mon Jan 5 20:49:21 2009 New Revision: 5018 URL: http://www.opensync.org/changeset/5018 Log: created application example for listing all existing groups Added: trunk/docs/examples/ trunk/docs/examples/applications/ trunk/docs/examples/applications/CMakeLists.txt trunk/docs/examples/applications/list_all_groups.c Added: trunk/docs/examples/applications/CMakeLists.txt ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/docs/examples/applications/CMakeLists.txt Mon Jan 5 20:49:21 2009 (r5018) @@ -0,0 +1,17 @@ +PROJECT( opensync-example-applications C ) + +cmake_minimum_required(VERSION 2.4.4) + +SET( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules" ) + +FIND_PACKAGE( OpenSync REQUIRED ) +#INCLUDE( OpenSyncInternal ) + +LINK_DIRECTORIES( ${OPENSYNC_LIBRARY_DIRS} ) +INCLUDE_DIRECTORIES( ${OPENSYNC_INCLUDE_DIRS} ) + +# create executables +SET( appl_SRCS list_all_groups.c ) +SET( appl_NAME list_all_groups ) +ADD_EXECUTABLE( ${appl_NAME} ${appl_SRCS} ) +TARGET_LINK_LIBRARIES( ${appl_NAME} ${OPENSYNC_LIBRARIES} ) \ No newline at end of file Added: trunk/docs/examples/applications/list_all_groups.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/docs/examples/applications/list_all_groups.c Mon Jan 5 20:49:21 2009 (r5018) @@ -0,0 +1,28 @@ +#include <opensync/opensync.h> +#include <opensync/opensync-group.h> + +int main(int argc, char *argv[]) { + + int numgroups = 0; + int i; + + osync_bool couldloadgroups; + + OSyncGroup *group = NULL; + OSyncGroupEnv *groupenv = NULL; + + groupenv = osync_group_env_new(NULL); + /* load groups from default dir */ + couldloadgroups = osync_group_env_load_groups(groupenv, NULL, NULL); + + if ( !couldloadgroups ) { + /* print error to stderr */ + return -1; + } + + numgroups = osync_group_env_num_groups(groupenv); + for( i = 0; i < numgroups; i++ ) { + group = osync_group_env_nth_group(groupenv, i); + } + +} |
From: <dg...@su...> - 2009-01-05 16:59:31
|
Author: dgollub Date: Mon Jan 5 17:59:09 2009 New Revision: 5017 URL: http://www.opensync.org/changeset/5017 Log: Initial OSyncAnchor struct. Renamed opaque OSyncAnchorDB (which didn't exist) to OSyncAnchor. Modified: trunk/opensync/helper/opensync_anchor_private.h trunk/opensync/opensync.h Modified: trunk/opensync/helper/opensync_anchor_private.h ============================================================================== --- trunk/opensync/helper/opensync_anchor_private.h Mon Jan 5 17:50:21 2009 (r5016) +++ trunk/opensync/helper/opensync_anchor_private.h Mon Jan 5 17:59:09 2009 (r5017) @@ -32,6 +32,16 @@ /*@{*/ /** + * @brief OSyncAnchor struct + */ +struct OSyncAnchor { + /* Reference counting */ + int ref_count; + /* Pointer to the OSyncDatabase */ + OSyncDB *db; +}; + +/** * @brief Create the anchor table in the specified database * * @param db Pointer to the database Modified: trunk/opensync/opensync.h ============================================================================== --- trunk/opensync/opensync.h Mon Jan 5 17:50:21 2009 (r5016) +++ trunk/opensync/opensync.h Mon Jan 5 17:59:09 2009 (r5017) @@ -207,7 +207,7 @@ typedef struct OSyncModule OSyncModule; /* Helper component */ -typedef struct OSyncAnchorDB OSyncAnchorDB; +typedef struct OSyncAnchor OSyncAnchor; typedef struct OSyncHashTable OSyncHashTable; /* IPC component */ |
From: <dg...@su...> - 2009-01-05 16:50:43
|
Author: dgollub Date: Mon Jan 5 17:50:21 2009 New Revision: 5016 URL: http://www.opensync.org/changeset/5016 Log: Dropped OSyncPluginEnv is_useable() interface. Dropped unexported symbols from previous commit: osync_plugin_get_discover_timeout osync_plugin_get_finalize_timeout osync_plugin_get_initialize_timeout ... the plugin-usable interfaces which got dropped. Modified: trunk/opensync.sym trunk/opensync/plugin/opensync_plugin_env.h trunk/opensync/plugin/opensync_plugin_env_internals.h Modified: trunk/opensync.sym ============================================================================== --- trunk/opensync.sym Mon Jan 5 17:46:09 2009 (r5015) +++ trunk/opensync.sym Mon Jan 5 17:50:21 2009 (r5016) @@ -546,7 +546,6 @@ osync_plugin_env_new osync_plugin_env_nth_plugin osync_plugin_env_num_plugins -osync_plugin_env_plugin_is_usable osync_plugin_env_ref osync_plugin_env_register_plugin osync_plugin_env_unref @@ -554,13 +553,9 @@ osync_plugin_get_config_type osync_plugin_get_data osync_plugin_get_description -osync_plugin_get_discover_timeout -osync_plugin_get_finalize_timeout -osync_plugin_get_initialize_timeout osync_plugin_get_longname osync_plugin_get_name osync_plugin_get_start_type -osync_plugin_get_useable_timeout osync_plugin_info_add_objtype osync_plugin_info_find_objtype osync_plugin_info_get_capabilities @@ -587,7 +582,6 @@ osync_plugin_info_set_version osync_plugin_info_unref osync_plugin_initialize -osync_plugin_is_usable osync_plugin_localization_get_encoding osync_plugin_localization_get_language osync_plugin_localization_get_timezone @@ -635,7 +629,6 @@ osync_plugin_set_longname osync_plugin_set_name osync_plugin_set_start_type -osync_plugin_set_useable_timeout osync_plugin_unref osync_queue_connect osync_queue_create Modified: trunk/opensync/plugin/opensync_plugin_env.h ============================================================================== --- trunk/opensync/plugin/opensync_plugin_env.h Mon Jan 5 17:46:09 2009 (r5015) +++ trunk/opensync/plugin/opensync_plugin_env.h Mon Jan 5 17:50:21 2009 (r5016) @@ -122,16 +122,6 @@ */ OSYNC_EXPORT OSyncPlugin *osync_plugin_env_nth_plugin(OSyncPluginEnv *env, int nth); -/*! @brief Checks if plugin is usable - * - * @param env Pointer to a OSyncPluginEnv environment - * @param pluginname The name of the plugin - * @param error Pointer to error-struct - * @returns TRUE if plugin is usable, FALSE otherwise - * - */ -OSYNC_EXPORT osync_bool osync_plugin_env_plugin_is_usable(OSyncPluginEnv *env, const char *pluginname, OSyncError **error); - /*@}*/ #endif /* _OPENSYNC_PLUGIN_ENV_H_ */ Modified: trunk/opensync/plugin/opensync_plugin_env_internals.h ============================================================================== --- trunk/opensync/plugin/opensync_plugin_env_internals.h Mon Jan 5 17:46:09 2009 (r5015) +++ trunk/opensync/plugin/opensync_plugin_env_internals.h Mon Jan 5 17:50:21 2009 (r5016) @@ -39,6 +39,16 @@ */ osync_bool osync_plugin_env_load_module(OSyncPluginEnv *env, const char *filename, OSyncError **error); +/*! @brief Checks if plugin is usable + * + * @param env Pointer to a OSyncPluginEnv environment + * @param pluginname The name of the plugin + * @param error Pointer to error-struct + * @returns TRUE if plugin is usable, FALSE otherwise + * + */ +OSYNC_TEST_EXPORT osync_bool osync_plugin_env_plugin_is_usable(OSyncPluginEnv *env, const char *pluginname, OSyncError **error); + /*@}*/ #endif /* _OPENSYNC_PLUGIN_ENV_INTERNALS_H_ */ |
From: <dg...@su...> - 2009-01-05 16:46:31
|
Author: dgollub Date: Mon Jan 5 17:46:09 2009 New Revision: 5015 URL: http://www.opensync.org/changeset/5015 Log: Dropped osync_plugin_usebale* from public API. This implementation is incomplete, and couldn't be used to date, due to missing usable-register-function. Modified: trunk/opensync/plugin/opensync_plugin.c trunk/opensync/plugin/opensync_plugin.h trunk/opensync/plugin/opensync_plugin_internals.h trunk/wrapper/opensync-plugin.i Modified: trunk/opensync/plugin/opensync_plugin.c ============================================================================== --- trunk/opensync/plugin/opensync_plugin.c Mon Jan 5 11:26:38 2009 (r5014) +++ trunk/opensync/plugin/opensync_plugin.c Mon Jan 5 17:46:09 2009 (r5015) @@ -22,8 +22,8 @@ #include "opensync_internals.h" #include "opensync-plugin.h" -#include "opensync_plugin_private.h" #include "opensync_plugin_internals.h" +#include "opensync_plugin_private.h" OSyncPlugin *osync_plugin_new(OSyncError **error) { Modified: trunk/opensync/plugin/opensync_plugin.h ============================================================================== --- trunk/opensync/plugin/opensync_plugin.h Mon Jan 5 11:26:38 2009 (r5014) +++ trunk/opensync/plugin/opensync_plugin.h Mon Jan 5 17:46:09 2009 (r5015) @@ -24,7 +24,6 @@ typedef void * (* initialize_fn) (OSyncPlugin *, OSyncPluginInfo *, OSyncError **); typedef void (* finalize_fn) (void *); typedef osync_bool (* discover_fn) (void *, OSyncPluginInfo *, OSyncError **); -typedef osync_bool (* usable_fn) (OSyncError **); /*! @brief Gives information about wether the plugin * has to be configured or not @@ -213,17 +212,6 @@ */ OSYNC_EXPORT void osync_plugin_set_data(OSyncPlugin *plugin, void *data); - -/*! @brief Checks if a plugin is available and usable - * - * @param plugin The plugin to check - * @param error If the return was FALSE, will contain information on why the plugin is not available - * @returns TRUE if the plugin was found and is usable, FALSE otherwise - * - */ -OSYNC_EXPORT osync_bool osync_plugin_is_usable(OSyncPlugin *plugin, OSyncError **error); - - /*! @brief Set timeout interval for plugin discovery * * @param plugin The plugin to check @@ -248,15 +236,6 @@ */ OSYNC_EXPORT void osync_plugin_set_finalize_timeout(OSyncPlugin *plugin, unsigned int timeout); -/*! @brief Set timeout interval for plugin "usable" function - * - * @param plugin The plugin to check - * @param timeout Timeout value - * - */ -OSYNC_EXPORT void osync_plugin_set_useable_timeout(OSyncPlugin *plugin, unsigned int timeout); - - /*! @brief Initialize Plugin * * @param plugin Pointer to the plugin Modified: trunk/opensync/plugin/opensync_plugin_internals.h ============================================================================== --- trunk/opensync/plugin/opensync_plugin_internals.h Mon Jan 5 11:26:38 2009 (r5014) +++ trunk/opensync/plugin/opensync_plugin_internals.h Mon Jan 5 17:46:09 2009 (r5015) @@ -21,6 +21,9 @@ #ifndef _OPENSYNC_PLUGIN_INTERNALS_H_ #define _OPENSYNC_PLUGIN_INTERNALS_H_ +/* TODO: Removed from 0.40 Public API. Untested and uncomplete. */ +typedef osync_bool (* usable_fn) (OSyncError **); + /** * @defgroup OSyncPluginPrivateAPI OpenSync Plugin Internals * @ingroup OSyncPrivate @@ -29,6 +32,22 @@ */ /*@{*/ +/*! @brief Checks if a plugin is available and usable + * + * @param plugin The plugin to check + * @param error If the return was FALSE, will contain information on why the plugin is not available + * @returns TRUE if the plugin was found and is usable, FALSE otherwise + * + */ +OSYNC_TEST_EXPORT osync_bool osync_plugin_is_usable(OSyncPlugin *plugin, OSyncError **error); + +/*! @brief Set timeout interval for plugin "usable" function + * + * @param plugin The plugin to check + * @param timeout Timeout value + * + */ +OSYNC_TEST_EXPORT void osync_plugin_set_useable_timeout(OSyncPlugin *plugin, unsigned int timeout); /*! @brief Get timeout interval for plugin "usable" function * @@ -36,7 +55,7 @@ * @return Timeout value * */ -OSYNC_EXPORT unsigned int osync_plugin_get_useable_timeout(OSyncPlugin *plugin); +OSYNC_TEST_EXPORT unsigned int osync_plugin_get_useable_timeout(OSyncPlugin *plugin); /*! @brief Get timeout interval for plugin initialization * @@ -44,7 +63,7 @@ * @return Timeout value * */ -OSYNC_EXPORT unsigned int osync_plugin_get_initialize_timeout(OSyncPlugin *plugin); +OSYNC_TEST_EXPORT unsigned int osync_plugin_get_initialize_timeout(OSyncPlugin *plugin); /*! @brief Get timeout interval for plugin finalization * @@ -52,7 +71,7 @@ * @return Timeout value * */ -OSYNC_EXPORT unsigned int osync_plugin_get_finalize_timeout(OSyncPlugin *plugin); +OSYNC_TEST_EXPORT unsigned int osync_plugin_get_finalize_timeout(OSyncPlugin *plugin); /*! @brief Get timeout interval for plugin discovery * @@ -60,7 +79,7 @@ * @return Timeout value * */ -OSYNC_EXPORT unsigned int osync_plugin_get_discover_timeout(OSyncPlugin *plugin); +OSYNC_TEST_EXPORT unsigned int osync_plugin_get_discover_timeout(OSyncPlugin *plugin); /*@}*/ Modified: trunk/wrapper/opensync-plugin.i ============================================================================== --- trunk/wrapper/opensync-plugin.i Mon Jan 5 11:26:38 2009 (r5014) +++ trunk/wrapper/opensync-plugin.i Mon Jan 5 17:46:09 2009 (r5015) @@ -77,19 +77,11 @@ wrapper_exception("osync_plugin_discover failed but did not set error code"); } - bool is_usable() { - Error *err = NULL; - bool ret = osync_plugin_is_usable(self, &err); - raise_exception_on_error(err); - return ret; - } - %pythoncode %{ name = property(get_name, set_name) longname = property(get_longname, set_longname) description = property(get_description, set_description) config_type = property(get_config_type, set_config_type) - is_usable = property(is_usable) %} }; @@ -138,13 +130,6 @@ return plugin; } - bool plugin_is_usable(const char *pluginname) { - Error *err = NULL; - bool ret = osync_plugin_env_plugin_is_usable(self, pluginname, &err); - raise_exception_on_error(err); - return ret; - } - %pythoncode %{ # extend the SWIG-generated constructor, so that we can setup our list-wrapper classes __oldinit = __init__ |
From: <dg...@su...> - 2009-01-05 15:11:46
|
Author: bellmich Date: Mon Jan 5 16:11:25 2009 New Revision: 885 URL: http://libsyncml.opensync.org/changeset/885 Log: found a new glib suppression Modified: trunk/tests/valgrind.supp Modified: trunk/tests/valgrind.supp ============================================================================== --- trunk/tests/valgrind.supp Mon Jan 5 13:52:54 2009 (r884) +++ trunk/tests/valgrind.supp Mon Jan 5 16:11:25 2009 (r885) @@ -200,3 +200,16 @@ fun:g_type_init_with_debug_flags fun:g_type_init } + +{ + g_type_init - 7 + Memcheck:Leak + fun:malloc + fun:g_malloc + fun:g_slice_alloc + fun:g_hash_table_new_full + fun:g_hash_table_new + obj:* + fun:g_type_init_with_debug_flags + fun:g_type_init +} |
From: <dg...@su...> - 2009-01-05 12:53:19
|
Author: bellmich Date: Mon Jan 5 13:52:54 2009 New Revision: 884 URL: http://libsyncml.opensync.org/changeset/884 Log: bugfix for ticket #207 Modified: trunk/libsyncml/transports/obex_server.c trunk/libsyncml/transports/obex_server_internals.h Modified: trunk/libsyncml/transports/obex_server.c ============================================================================== --- trunk/libsyncml/transports/obex_server.c Mon Jan 5 11:07:49 2009 (r883) +++ trunk/libsyncml/transports/obex_server.c Mon Jan 5 13:52:54 2009 (r884) @@ -610,7 +610,8 @@ CHECK_ERROR_REF smlAssert(tsp); smlAssert(tsp->transport_data); - SmlTransportObexServerEnv *env = tsp->transport_data; + SmlTransportObexServerEnv *env = tsp->transport_data; + smlAssert(env->handle == NULL); switch (env->type) { #ifdef ENABLE_OPENOBEX_TCP @@ -622,7 +623,7 @@ if (!env->handle) { smlErrorSet(error, SML_ERROR_GENERIC, "Unable to create OBEX IRDA transport."); - goto error_free_env; + goto error; } OBEX_SetUserData(env->handle, env); /* prepare IP address etc. */ @@ -631,7 +632,7 @@ size_t size = sizeof(struct sockaddr_in); struct sockaddr_in *addr = smlTryMalloc0(size, error); if (!addr) - goto error_close_handle; + goto error; addr->sin_family = PF_INET; addr->sin_port = htons(env->port); addr->sin_addr.s_addr = INADDR_ANY; @@ -642,7 +643,7 @@ "Unable to register INET OBEX server. %s (%i).", strerror(errno), errno); smlSafeFree((gpointer *)&addr); - goto error_close_handle; + goto error; } smlSafeFree((gpointer *)&addr); break; @@ -655,7 +656,7 @@ if (!env->handle) { smlErrorSet(error, SML_ERROR_GENERIC, "Unable to create OBEX IRDA transport."); - goto error_free_env; + goto error; } OBEX_SetUserData(env->handle, env); /* register server */ @@ -664,10 +665,11 @@ smlErrorSet(error, SML_ERROR_GENERIC, "Unable to register IRDA OBEX server. %s (%i).", strerror(errno), errno); - goto error_close_handle; + goto error; } break; case SML_TRANSPORT_CONNECTION_TYPE_BLUETOOTH: +#ifdef ENABLE_BLUETOOTH /* init object */ env->handle = OBEX_Init(OBEX_TRANS_BLUETOOTH, _smlTransportObexServerMainEvent, @@ -675,7 +677,7 @@ if (!env->handle) { smlErrorSet(error, SML_ERROR_GENERIC, "Unable to create OBEX Bluetooth transport."); - goto error_free_env; + goto error; } OBEX_SetUserData(env->handle, env); /* register server */ @@ -684,20 +686,23 @@ smlErrorSet(error, SML_ERROR_GENERIC, "Unable to register Bluetooth OBEX server. %s (%i).", strerror(errno), errno); - goto error_close_handle; + goto error; } +#else + smlErrorSet(error, SML_ERROR_GENERIC, "Bluetooth not enabled"); + goto error; +#endif break; default: smlErrorSet(error, SML_ERROR_GENERIC, "Unknown obex type"); - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); - return FALSE; + goto error; } smlTrace(TRACE_INTERNAL, "%s: server registered successfully", __func__); /* Now we create a source that watches for incoming connection requests */ env->functions = smlTryMalloc0(sizeof(GSourceFuncs), error); if (!env->functions) - goto error_close_handle; + goto error; env->functions->prepare = _fd_prepare; env->functions->check = _fd_check; env->functions->dispatch = _fd_dispatch; @@ -714,12 +719,14 @@ smlTrace(TRACE_EXIT, "%s: %p", __func__, env); return TRUE; -error_close_handle: - OBEX_Cleanup(env->handle); -error_free_env: - smlSafeFree((gpointer *)&env); -// error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); +error: + if (env->handle) { + OBEX_Cleanup(env->handle); + env->handle = NULL; + } + if (env) + smlSafeFree((gpointer *)&env); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); return FALSE; } Modified: trunk/libsyncml/transports/obex_server_internals.h ============================================================================== --- trunk/libsyncml/transports/obex_server_internals.h Mon Jan 5 11:07:49 2009 (r883) +++ trunk/libsyncml/transports/obex_server_internals.h Mon Jan 5 13:52:54 2009 (r884) @@ -32,7 +32,9 @@ SmlTransport *tsp; char *path; uint16_t port; +#ifdef ENABLE_BLUETOOTH bdaddr_t *bdaddr; +#endif char *irda_service; obex_t *handle; |
From: <dg...@su...> - 2009-01-05 10:30:34
|
Author: bellmich Date: Mon Jan 5 11:30:14 2009 New Revision: 145 URL: http://libwbxml.opensync.org/changeset/145 Log: updated ChangeLog for release of 0.10.1 Modified: wbxml2/trunk/ChangeLog Modified: wbxml2/trunk/ChangeLog ============================================================================== --- wbxml2/trunk/ChangeLog Mon Jan 5 11:15:25 2009 (r144) +++ wbxml2/trunk/ChangeLog Mon Jan 5 11:30:14 2009 (r145) @@ -1,3 +1,9 @@ + * Removed a useless buffer which only creates a memory leak. + * The installation of the documentation can be disabled. + * LIBDATA_INSTALL_DIR was introduced (used by pkgconfig). + * All tests are executed as standalone tests to get more + detailed informations if a test fails. + * The timezone of the nightly build-time was fixed. 2008-12-05 Michael Bell <mic...@we...> * Fixed ticket #14 with patch from ticket (hexadecimal integer support for Wireless-Village) |
From: <dg...@su...> - 2009-01-05 10:27:01
|
Author: bricks Date: Mon Jan 5 11:26:38 2009 New Revision: 5014 URL: http://www.opensync.org/changeset/5014 Log: Adapted tomboy-format to new format functions signatures Modified: format-plugins/tomboy-note/src/tomboy_note.c format-plugins/tomboy-note/src/tomboy_note.h format-plugins/tomboy-note/tests/parser_test.c Modified: format-plugins/tomboy-note/src/tomboy_note.c ============================================================================== --- format-plugins/tomboy-note/src/tomboy_note.c Mon Jan 5 11:17:47 2009 (r5013) +++ format-plugins/tomboy-note/src/tomboy_note.c Mon Jan 5 11:26:38 2009 (r5014) @@ -52,7 +52,7 @@ time_t rawtime; struct tm * timeinfo; char *retval; - + retval = g_malloc0(DATE_TIME_SIZE); time(&rawtime); timeinfo = localtime(&rawtime); @@ -70,7 +70,7 @@ if (strlen(datetime) != DATE_TIME_SIZE-1) { return FALSE; } - if( datetime[4] != '-' || datetime[7] != '-' || datetime[10] != 'T' || datetime[13] != ':' || datetime[16] != ':' + if( datetime[4] != '-' || datetime[7] != '-' || datetime[10] != 'T' || datetime[13] != ':' || datetime[16] != ':' || datetime[19] != '.' || datetime[27] != '+' || datetime[30] != ':') { return FALSE; } @@ -78,13 +78,13 @@ } void tomboynote_validate_and_set_datetime(xmlNodePtr node) { - + osync_assert(node); - + GDate *date; char *date_text; xmlChar *org_date; - + date = g_date_new(); org_date = xmlNodeGetContent(node); if ( node->children ) { @@ -97,7 +97,7 @@ if (!date_text) { date_text = tomboynote_create_datetime_now(); xmlNodeSetContent(node, BAD_CAST date_text); - } + } else { if (tomboynote_validate_datetime(date_text)) { return; @@ -108,7 +108,7 @@ if (!g_date_valid(date)) { date_text = tomboynote_create_datetime_now(); xmlNodeSetContent(node, BAD_CAST date_text); - } + } else { date_text = g_malloc0(DATE_TIME_SIZE); g_date_strftime(date_text, DATE_TIME_SIZE, DATE_TIME_FORMAT, date); @@ -119,10 +119,10 @@ } else { date_text = tomboynote_create_datetime_now(); - xmlNodeSetContent(node, BAD_CAST date_text); + xmlNodeSetContent(node, BAD_CAST date_text); } g_date_free(date); - + osync_trace(TRACE_INTERNAL, "validate date \"%s\" created \"%s\"", __NULLSTR((char *)org_date), __NULLSTR(date_text)); return; @@ -369,7 +369,7 @@ xmlNodePtr tmp_node; xmlAttrPtr version; xmlAttrPtr xml_preserve; - + const char *content_text; doc = xmlNewDoc(BAD_CAST "1.0"); @@ -399,7 +399,7 @@ // osync_trace(TRACE_SENSITIVE, "Input XMLFormat is:\n%s", str); g_free(str); - //TODO: always free old content_text + //TODO: always free old content_text OSyncXMLField *xmlfield = osync_xmlformat_get_first_field(xmlformat); for(; xmlfield != NULL; xmlfield = osync_xmlfield_get_next(xmlfield)) { if ( !strcmp(osync_xmlfield_get_name(xmlfield),"Categories") ) { @@ -432,7 +432,7 @@ // Date format yyyy-MM-ddTHH:mm:ss.fffffffzzz e.g.: 2008-05-21T13:42:11.9863920+02:00 // add <last-change-date> // From Tomboy Comment: - // "Indicates the last time note content data changed. + // "Indicates the last time note content data changed. // Does not include tag/notebook changes (see MetadataChangeDate)" xmlAddChild(note, last_change_date); // add <last-metadata-change-date> @@ -479,7 +479,7 @@ if (!*output) { goto error; } - + osync_trace(TRACE_EXIT, "%s", __func__); return TRUE; error: @@ -489,6 +489,23 @@ } osync_bool detect_tomboynote(const char *data, int size, void *userdata) { + osync_trace(TRACE_ENTRY, "%s (%p,%d,%p)", __func__, data, size, userdata); + + return validate_tomboynote(data, size, NULL, NULL); + + osync_trace(TRACE_EXIT, "%s", __func__); + return FALSE; +} + +// format functions + +static void destroy_tomboynote(char *input, unsigned int inpsize, void *user_data) +{ + g_free(input); +} + +osync_bool validate_tomboynote(const char *data, unsigned int size, void *user_data, OSyncError **error) +{ osync_trace(TRACE_ENTRY, "%s (%p,%d)", __func__, data, size); xmlDocPtr doc; @@ -508,36 +525,29 @@ osync_trace(TRACE_EXIT, "%s could not create context", __func__); return FALSE; } - doc = xmlCtxtReadMemory(ctxt,data,size,NULL,NULL,0); + doc = xmlCtxtReadMemory(ctxt, data, size, NULL, NULL,0); if (doc == NULL) { osync_trace(TRACE_EXIT, "%s could not read memory", __func__); - goto FREE_CONTEXT; + goto free_context; } if ( !tomboynote_validate(doc, NULL) ) { - osync_trace(TRACE_EXIT, "%s could not validate xml.", __func__); - goto FREE_DOC; + osync_trace(TRACE_EXIT_ERROR, "%s could not validate xml.", __func__); + goto free_doc; } xmlFreeDoc(doc); xmlFreeParserCtxt(ctxt); osync_trace(TRACE_EXIT, "%s valid tomboy-note", __func__); return TRUE; -FREE_DOC: +free_doc: xmlFreeDoc(doc); -FREE_CONTEXT: +free_context: xmlFreeParserCtxt(ctxt); return FALSE; } -// format functions - -static void destroy_tomboynote(char *input, unsigned int inpsize) -{ - g_free(input); -} - -static void create_tomboynote(char **data, unsigned int *size) { +static void create_tomboynote(char **data, unsigned int *size, void *user_data) { osync_trace(TRACE_ENTRY, "%s (%p,%p)", __func__, data, size); xmlNsPtr ns; @@ -579,6 +589,7 @@ osync_objformat_set_create_func(format, create_tomboynote); osync_objformat_set_destroy_func(format, destroy_tomboynote); + osync_objformat_set_validate_func(format, validate_tomboynote); /* osync_objformat_set_compare_func(format, compare_tomboynote); osync_objformat_set_duplicate_func(format, duplicate_xmlformat); Modified: format-plugins/tomboy-note/src/tomboy_note.h ============================================================================== --- format-plugins/tomboy-note/src/tomboy_note.h Mon Jan 5 11:17:47 2009 (r5013) +++ format-plugins/tomboy-note/src/tomboy_note.h Mon Jan 5 11:26:38 2009 (r5014) @@ -47,6 +47,8 @@ osync_bool conv_xmlformat_to_tomboynote(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *userdata, OSyncError **error); osync_bool detect_tomboynote(const char *data, int size, void *userdata); +osync_bool validate_tomboynote(const char *data, unsigned int size, void *user_data, OSyncError **error); + void* tomboynote_initialize(OSyncError **error); void tomboynote_finalize(void *userdata); Modified: format-plugins/tomboy-note/tests/parser_test.c ============================================================================== --- format-plugins/tomboy-note/tests/parser_test.c Mon Jan 5 11:17:47 2009 (r5013) +++ format-plugins/tomboy-note/tests/parser_test.c Mon Jan 5 11:26:38 2009 (r5014) @@ -120,6 +120,7 @@ } END_TEST +/* START_TEST (tomboynote_test_converter) { osync_bool free; char *output; @@ -132,9 +133,11 @@ OSyncXMLFormat * xmlformat = (OSyncXMLFormat*)output; //osync_xmlformat_assemble(xmlformat, &cstr, &size); //printf("Output: %s\n", cstr); - fail_unless( osync_xmlformat_validate(xmlformat,&error) ); + //FIXME: write test if xmlformat is converted correctly + //fail_unless( osync_xmlformat_validate(xmlformat,&error) ); } END_TEST +*/ START_TEST (tomboynote_test_detector) { fail_unless( detect_tomboynote(good_content, strlen(good_content), NULL) ); @@ -160,13 +163,7 @@ char* datetime_invalid_12 = "1234-56-78T91:23:45.6789123+45:6z"; char* datetime_invalid_13 = "12a3-56-78T91:23:45.6789123+45:6z"; char *empty = ""; - char *now; - char *datetime_text; - char *output; - const char *node_data; - unsigned int size; - osync_bool free_input; - + fail_if(tomboynote_validate_datetime(NULL)); fail_if(tomboynote_validate_datetime(datetime)); fail_if(tomboynote_validate_datetime(empty)); @@ -197,7 +194,7 @@ tcase_add_test (tc_parser, tomboynote_test_parse_content); tcase_add_test (tc_parser, tomboynote_test_parse_nodes); tcase_add_test (tc_parser, tomboynote_test_parse_tags); - tcase_add_test (tc_parser, tomboynote_test_converter); + /*tcase_add_test (tc_parser, tomboynote_test_converter);*/ tcase_add_test (tc_parser, tomboynote_test_detector); tcase_add_test (tc_parser, tomboynote_test_datetime); suite_add_tcase (s, tc_parser); |
From: <dg...@su...> - 2009-01-05 10:18:08
|
Author: bricks Date: Mon Jan 5 11:17:47 2009 New Revision: 5013 URL: http://www.opensync.org/changeset/5013 Log: Adapted vformat to new format functions signatures 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 Modified: format-plugins/vformat/src/vcard.c ============================================================================== --- format-plugins/vformat/src/vcard.c Mon Jan 5 10:46:15 2009 (r5012) +++ format-plugins/vformat/src/vcard.c Mon Jan 5 11:17:47 2009 (r5013) @@ -25,7 +25,7 @@ #include <glib.h> #include <string.h> -static OSyncConvCmpResult compare_vcard(const char *leftdata, unsigned int leftsize, const char *rightdata, unsigned int rightsize) +static OSyncConvCmpResult compare_vcard(const char *leftdata, unsigned int leftsize, const char *rightdata, unsigned int rightsize, void *user_data) { /* Consider empty block equal NULL pointers */ if (!leftsize) leftdata = NULL; @@ -68,7 +68,7 @@ return FALSE; } -static void destroy_vcard(char *input, unsigned int inpsize) +static void destroy_vcard(char *input, unsigned int inpsize, void *user_data) { g_free(input); } Modified: format-plugins/vformat/src/vevent.c ============================================================================== --- format-plugins/vformat/src/vevent.c Mon Jan 5 10:46:15 2009 (r5012) +++ format-plugins/vformat/src/vevent.c Mon Jan 5 11:17:47 2009 (r5013) @@ -34,7 +34,7 @@ * osync_env_format_set_like(). */ -static OSyncConvCmpResult compare_vevent(const char *leftdata, unsigned int leftsize, const char *rightdata, unsigned int rightsize) +static OSyncConvCmpResult compare_vevent(const char *leftdata, unsigned int leftsize, const char *rightdata, unsigned int rightsize, void *user_data) { /* Consider empty block equal NULL pointers */ if (!leftsize) leftdata = NULL; @@ -53,7 +53,7 @@ return OSYNC_CONV_DATA_MISMATCH; } -static osync_bool detect_plain_as_vevent10(const char *data, int size, void *userdata) +static osync_bool detect_plain_as_vevent10(const char *data, int size, void *user_data) { osync_trace(TRACE_INTERNAL, "start: %s", __func__); @@ -63,7 +63,7 @@ return g_pattern_match_simple("*BEGIN:VCALENDAR*VERSION:1.0*BEGIN:VEVENT*", data); } -static osync_bool detect_plain_as_vevent20(const char *data, int size, void *userdata) +static osync_bool detect_plain_as_vevent20(const char *data, int size, void *user_data) { osync_trace(TRACE_INTERNAL, "start: %s", __func__); @@ -73,7 +73,7 @@ return g_pattern_match_simple("*BEGIN:VCALENDAR*VERSION:2.0*BEGIN:VEVENT*", data); } -static void destroy_vevent(char *input, unsigned int inpsize) +static void destroy_vevent(char *input, unsigned int inpsize, void *user_data) { g_free(input); } Modified: format-plugins/vformat/src/vjournal.c ============================================================================== --- format-plugins/vformat/src/vjournal.c Mon Jan 5 10:46:15 2009 (r5012) +++ format-plugins/vformat/src/vjournal.c Mon Jan 5 11:17:47 2009 (r5013) @@ -26,7 +26,7 @@ #include <glib.h> #include <string.h> -static OSyncConvCmpResult compare_vjournal(const char *leftdata, unsigned int leftsize, const char *rightdata, unsigned int rightsize) +static OSyncConvCmpResult compare_vjournal(const char *leftdata, unsigned int leftsize, const char *rightdata, unsigned int rightsize, void *user_data) { /* Consider empty block equal NULL pointers */ if (!leftsize) leftdata = NULL; @@ -55,7 +55,7 @@ return g_pattern_match_simple("*BEGIN:VJOURNAL*", data); } -static void destroy_vjournal(char *input, unsigned int inpsize) +static void destroy_vjournal(char *input, unsigned int inpsize, void *user_data) { g_free(input); } Modified: format-plugins/vformat/src/vnote.c ============================================================================== --- format-plugins/vformat/src/vnote.c Mon Jan 5 10:46:15 2009 (r5012) +++ format-plugins/vformat/src/vnote.c Mon Jan 5 11:17:47 2009 (r5013) @@ -25,7 +25,7 @@ #include <glib.h> #include <string.h> -static OSyncConvCmpResult compare_vnote(const char *leftdata, unsigned int leftsize, const char *rightdata, unsigned int rightsize) +static OSyncConvCmpResult compare_vnote(const char *leftdata, unsigned int leftsize, const char *rightdata, unsigned int rightsize, void *user_data) { /* Consider empty block equal NULL pointers */ if (!leftsize) leftdata = NULL; @@ -54,7 +54,7 @@ return g_pattern_match_simple("*BEGIN:VNOTE*VERSION:1.1*", data); } -static void destroy_vnote(char *input, unsigned int inpsize) +static void destroy_vnote(char *input, unsigned int inpsize, void *user_data) { g_free(input); } Modified: format-plugins/vformat/src/vtodo.c ============================================================================== --- format-plugins/vformat/src/vtodo.c Mon Jan 5 10:46:15 2009 (r5012) +++ format-plugins/vformat/src/vtodo.c Mon Jan 5 11:17:47 2009 (r5013) @@ -27,7 +27,7 @@ #include <string.h> /** @defgroup todo_vtodo todo/vtodo data format */ -static OSyncConvCmpResult compare_vtodo(const char *leftdata, unsigned int leftsize, const char *rightdata, unsigned int rightsize) +static OSyncConvCmpResult compare_vtodo(const char *leftdata, unsigned int leftsize, const char *rightdata, unsigned int rightsize, void *user_data) { /* Consider empty block equal NULL pointers */ if (!leftsize) leftdata = NULL; @@ -46,7 +46,7 @@ return OSYNC_CONV_DATA_MISMATCH; } -static osync_bool detect_plain_as_vtodo10(const char *data, int size, void *userdata) +static osync_bool detect_plain_as_vtodo10(const char *data, int size, void *user_data) { osync_trace(TRACE_INTERNAL, "start: %s", __func__); @@ -56,7 +56,7 @@ return g_pattern_match_simple("*BEGIN:VCALENDAR*VERSION:1.0*BEGIN:VTODO*", data); } -static osync_bool detect_plain_as_vtodo20(const char *data, int size, void *userdata) +static osync_bool detect_plain_as_vtodo20(const char *data, int size, void *user_data) { osync_trace(TRACE_INTERNAL, "start: %s", __func__); @@ -66,7 +66,7 @@ return g_pattern_match_simple("*BEGIN:VCALENDAR*VERSION:2.0*BEGIN:VTODO*", data); } -static void destroy_vtodo(char *input, unsigned int inpsize) +static void destroy_vtodo(char *input, unsigned int inpsize, void *user_data) { g_free(input); } |