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-11 14:34:11
|
Author: dgollub Date: Sun Jan 11 15:33:30 2009 New Revision: 5102 URL: http://www.opensync.org/changeset/5102 Log: Checkin ignore template Added: trunk/tests/CTestCustom.cmake Added: trunk/tests/CTestCustom.cmake ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/tests/CTestCustom.cmake Sun Jan 11 15:33:30 2009 (r5102) @@ -0,0 +1 @@ +SET( CTEST_CUSTOM_TESTS_IGNORE ${CTEST_CUSTOM_TESTS_IGNORE} ) |
From: <dg...@su...> - 2009-01-11 13:31:06
|
Author: dgollub Date: Sun Jan 11 14:30:27 2009 New Revision: 5101 URL: http://www.opensync.org/changeset/5101 Log: Drop C macro OSYNC_TESTCASE_DISABLED, introduce CMake macro OSYNC_TESTCASE_DISABLED. Testcases should now get ignored via CTest. This is done by changing the cmake testcase from OSYNC_TESTCASE_ADD to OSYNC_TESTCASE_DISABLED. Modified: trunk/tests/CMakeLists.txt trunk/tests/engine-tests/check_engine.c trunk/tests/support.c trunk/tests/support.h Modified: trunk/tests/CMakeLists.txt ============================================================================== --- trunk/tests/CMakeLists.txt Sun Jan 11 14:28:47 2009 (r5100) +++ trunk/tests/CMakeLists.txt Sun Jan 11 14:30:27 2009 (r5101) @@ -3,6 +3,9 @@ ADD_SUBDIRECTORY( mock-plugin ) +#### Contacts #################################### +SET( TICKETURL "https://opensync.org/ticket/" ) + ########### support ################# ADD_LIBRARY( support STATIC support.c ) TARGET_LINK_LIBRARIES( support opensync-testing ${CHECK_LIBRARIES} ) @@ -31,7 +34,7 @@ OSYNC_TESTCASE( engine engine_sync_reuse ) OSYNC_TESTCASE( engine engine_sync_stress ) OSYNC_TESTCASE( engine engine_sync_read_write ) -OSYNC_TESTCASE( engine engine_sync_read_write_stress ) +OSYNC_TESTCASE_DISABLED( engine engine_sync_read_write_stress "994" ) OSYNC_TESTCASE( engine engine_sync_read_write_stress2 ) ADD_CHECK_TEST( engine-error engine-tests/check_engine_error.c ${TEST_TARGET_LIBRARIES} ) @@ -56,3 +59,5 @@ ADD_CHECK_TEST( updater group-tests/check_updater.c ${TEST_TARGET_LIBRARIES} ) ADD_CHECK_TEST( xmlformat capabilities-tests/check_xmlformat.c ${TEST_TARGET_LIBRARIES} ) +CONFIGURE_FILE( "${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.cmake" + "${CMAKE_BINARY_DIR}/CTestCustom.ctest") Modified: trunk/tests/engine-tests/check_engine.c ============================================================================== --- trunk/tests/engine-tests/check_engine.c Sun Jan 11 14:28:47 2009 (r5100) +++ trunk/tests/engine-tests/check_engine.c Sun Jan 11 14:30:27 2009 (r5101) @@ -2017,7 +2017,7 @@ /* Disabled due to randomly failing - #994 * */ -OSYNC_TESTCASE_DISABLED(engine_sync_read_write_stress) +OSYNC_TESTCASE_ADD(engine_sync_read_write_stress) OSYNC_TESTCASE_ADD(engine_sync_read_write_stress2) Modified: trunk/tests/support.c ============================================================================== --- trunk/tests/support.c Sun Jan 11 14:28:47 2009 (r5100) +++ trunk/tests/support.c Sun Jan 11 14:30:27 2009 (r5101) @@ -25,14 +25,6 @@ if (strcmp(g_basename(argv[i]), tc[j].name)) continue; - if (!tc[j].func) { - fprintf(stderr, "Testcase \"%s\" disabled!", tc[j].name); - /* TODO: Return whatever needs to be returned that - * CTest/CDash list this as NOTRUN - */ - exit(127); - } - create_case(s, tc[j].name, tc[j].func); n++; } Modified: trunk/tests/support.h ============================================================================== --- trunk/tests/support.h Sun Jan 11 14:28:47 2009 (r5100) +++ trunk/tests/support.h Sun Jan 11 14:30:27 2009 (r5101) @@ -22,8 +22,6 @@ #define OSYNC_TESTCASE_ADD(x) { (#x), x }, -#define OSYNC_TESTCASE_DISABLED(x) { (#x), NULL }, - #define OSYNC_TESTCASE_END \ { NULL, NULL } \ }; \ |
From: <dg...@su...> - 2009-01-11 13:29:27
|
Author: dgollub Date: Sun Jan 11 14:28:47 2009 New Revision: 5100 URL: http://www.opensync.org/changeset/5100 Log: Add cmake macro OSYNC_TEST_DISABLED Modified: branches/3rd-party-cmake-modules/modules/Testing.cmake Modified: branches/3rd-party-cmake-modules/modules/Testing.cmake ============================================================================== --- branches/3rd-party-cmake-modules/modules/Testing.cmake Sun Jan 11 14:13:29 2009 (r5099) +++ branches/3rd-party-cmake-modules/modules/Testing.cmake Sun Jan 11 14:28:47 2009 (r5100) @@ -49,3 +49,13 @@ ENDMACRO( OSYNC_TESTCASE ) + +MACRO( OSYNC_TESTCASE_DISABLED _testSource _testDest _ticket ) + + OSYNC_TESTCASE( ${_testSource} ${_testDest} ) + SET( CTEST_CUSTOM_TESTS_IGNORE ${CTEST_CUSTOM_TESTS_IGNORE} "${_testDest}" ) + + MESSAGE( STATUS "Testcase \"${_testDest}\" disabled/ignored! ${TICKETURL}${_ticket}" ) + +ENDMACRO( OSYNC_TESTCASE_DISABLED ) + |
From: <dg...@su...> - 2009-01-11 13:14:07
|
Author: bricks Date: Sun Jan 11 14:13:29 2009 New Revision: 5099 URL: http://www.opensync.org/changeset/5099 Log: now fail macros compile if varargs are empty Modified: trunk/opensync/opensync.h Modified: trunk/opensync/opensync.h ============================================================================== --- trunk/opensync/opensync.h Sun Jan 11 13:51:57 2009 (r5098) +++ trunk/opensync/opensync.h Sun Jan 11 14:13:29 2009 (r5099) @@ -122,15 +122,15 @@ #define osync_return_if_fail_and_set_error(condition, error, errortype, format, ...) do { \ if (!(condition)) { \ - osync_error_set(error, errortype, format, __VA_ARGS__ ); \ + osync_error_set(error, errortype, format,## __VA_ARGS__, NULL ); \ return; \ - } while(0) + } } while(0) #define osync_return_val_if_fail_and_set_error(condition, val, error, errortype, format, ...) do { \ if (!(condition)) { \ - osync_error_set(error, errortype, format, __VA_ARGS__ ); \ + osync_error_set(error, errortype, format,## __VA_ARGS__, NULL ); \ return (val); \ - } while(0) + } } while(0) typedef int osync_bool; |
From: <dg...@su...> - 2009-01-11 12:56:06
|
Author: bricks Date: Sun Jan 11 12:48:50 2009 New Revision: 5097 URL: http://www.opensync.org/changeset/5097 Log: made osync_return_if_fail macros public and added osync_return_val_if_fail_and_set_error, osync_return_if_fail_and_set_error Modified: trunk/opensync/opensync.h trunk/opensync/opensync_internals.h Modified: trunk/opensync/opensync.h ============================================================================== --- trunk/opensync/opensync.h Sun Jan 11 06:42:43 2009 (r5096) +++ trunk/opensync/opensync.h Sun Jan 11 12:48:50 2009 (r5097) @@ -109,6 +109,29 @@ #define osync_assert_msg(x, msg) #endif +#define osync_return_if_fail(condition) do { \ + if (!(condition)) { \ + return; \ + } } while (0) + +#define osync_return_val_if_fail(condition, val) do { \ + if (!(condition)) { \ + return (val); \ + } } while (0) + + +#define osync_return_if_fail_and_set_error(condition, error, format, ...) do { \ + if (!(condition)) { \ + osync_error_set(error, OSYNC_ERROR_PARAMETER, format, __VA_ARGS__ ) \ + return; \ + } while(0) + +#define osync_return_val_if_fail_and_set_error(condition, val, error, format, ...) do { \ + if (!(condition)) { \ + osync_error_set(error, OSYNC_ERROR_PARAMETER, format, __VA_ARGS__ ) \ + return (val); \ + } while(0) + typedef int osync_bool; /************************************************************** Modified: trunk/opensync/opensync_internals.h ============================================================================== --- trunk/opensync/opensync_internals.h Sun Jan 11 06:42:43 2009 (r5096) +++ trunk/opensync/opensync_internals.h Sun Jan 11 12:48:50 2009 (r5097) @@ -35,17 +35,6 @@ extern int errno; #endif -#define osync_return_if_fail(condition) do { \ - if (!(condition)) { \ - return; \ - } } while (0) - -#define osync_return_val_if_fail(condition, val) do { \ - if (!(condition)) { \ - return (val); \ - } } while (0) - - #ifdef __GNUC__ #define OSYNC_UNUSED __attribute__ ((unused)) #else |
From: <dg...@su...> - 2009-01-11 12:52:42
|
Author: bricks Date: Sun Jan 11 13:51:57 2009 New Revision: 5098 URL: http://www.opensync.org/changeset/5098 Log: added a parameter for the error type in osync_return_if_fail macros Modified: trunk/opensync/opensync.h Modified: trunk/opensync/opensync.h ============================================================================== --- trunk/opensync/opensync.h Sun Jan 11 12:48:50 2009 (r5097) +++ trunk/opensync/opensync.h Sun Jan 11 13:51:57 2009 (r5098) @@ -120,17 +120,17 @@ } } while (0) -#define osync_return_if_fail_and_set_error(condition, error, format, ...) do { \ - if (!(condition)) { \ - osync_error_set(error, OSYNC_ERROR_PARAMETER, format, __VA_ARGS__ ) \ - return; \ - } while(0) +#define osync_return_if_fail_and_set_error(condition, error, errortype, format, ...) do { \ + if (!(condition)) { \ + osync_error_set(error, errortype, format, __VA_ARGS__ ); \ + return; \ + } while(0) -#define osync_return_val_if_fail_and_set_error(condition, val, error, format, ...) do { \ - if (!(condition)) { \ - osync_error_set(error, OSYNC_ERROR_PARAMETER, format, __VA_ARGS__ ) \ - return (val); \ - } while(0) +#define osync_return_val_if_fail_and_set_error(condition, val, error, errortype, format, ...) do { \ + if (!(condition)) { \ + osync_error_set(error, errortype, format, __VA_ARGS__ ); \ + return (val); \ + } while(0) typedef int osync_bool; |
From: <dg...@su...> - 2009-01-11 05:43:21
|
Author: dgollub Date: Sun Jan 11 06:42:43 2009 New Revision: 5096 URL: http://www.opensync.org/changeset/5096 Log: Register each engine testcase as one test. This allows more detailed regression tracking with ctest and cdash. Especallily this allows perforamnce tracking of single performance testcases. Modified: trunk/tests/CMakeLists.txt trunk/tests/engine-tests/check_engine.c trunk/tests/support.c trunk/tests/support.h Modified: trunk/tests/CMakeLists.txt ============================================================================== --- trunk/tests/CMakeLists.txt Sun Jan 11 06:40:56 2009 (r5095) +++ trunk/tests/CMakeLists.txt Sun Jan 11 06:42:43 2009 (r5096) @@ -21,7 +21,19 @@ ADD_CHECK_TEST( converter format-tests/check_converter.c ${TEST_TARGET_LIBRARIES} ) ADD_CHECK_TEST( datatest data-tests/check_data.c ${TEST_TARGET_LIBRARIES} ) ADD_CHECK_TEST( detect format-tests/check_detect.c ${TEST_TARGET_LIBRARIES} ) -ADD_CHECK_TEST( engine engine-tests/check_engine.c ${TEST_TARGET_LIBRARIES} ) + +BUILD_CHECK_TEST( engine engine-tests/check_engine.c ${TEST_TARGET_LIBRARIES} ) +OSYNC_TESTCASE( engine engine_new ) +OSYNC_TESTCASE( engine engine_init ) +OSYNC_TESTCASE( engine engine_sync ) +OSYNC_TESTCASE( engine engine_sync_multi_obj ) +OSYNC_TESTCASE( engine engine_sync_out_of_order ) +OSYNC_TESTCASE( engine engine_sync_reuse ) +OSYNC_TESTCASE( engine engine_sync_stress ) +OSYNC_TESTCASE( engine engine_sync_read_write ) +OSYNC_TESTCASE( engine engine_sync_read_write_stress ) +OSYNC_TESTCASE( engine engine_sync_read_write_stress2 ) + ADD_CHECK_TEST( engine-error engine-tests/check_engine_error.c ${TEST_TARGET_LIBRARIES} ) ADD_CHECK_TEST( formatenv format-tests/check_format_env.c ${TEST_TARGET_LIBRARIES} ) ADD_CHECK_TEST( group group-tests/check_group.c ${TEST_TARGET_LIBRARIES} ) Modified: trunk/tests/engine-tests/check_engine.c ============================================================================== --- trunk/tests/engine-tests/check_engine.c Sun Jan 11 06:40:56 2009 (r5095) +++ trunk/tests/engine-tests/check_engine.c Sun Jan 11 06:42:43 2009 (r5096) @@ -2013,11 +2013,12 @@ OSYNC_TESTCASE_ADD(engine_sync_reuse) OSYNC_TESTCASE_ADD(engine_sync_stress) +OSYNC_TESTCASE_ADD(engine_sync_read_write) /* Disabled due to randomly failing - #994 -OSYNC_TESTCASE_ADD(engine_sync_read_write_stress) + * */ +OSYNC_TESTCASE_DISABLED(engine_sync_read_write_stress) -OSYNC_TESTCASE_ADD(engine_sync_read_write) OSYNC_TESTCASE_ADD(engine_sync_read_write_stress2) //batch commit Modified: trunk/tests/support.c ============================================================================== --- trunk/tests/support.c Sun Jan 11 06:40:56 2009 (r5095) +++ trunk/tests/support.c Sun Jan 11 06:42:43 2009 (r5096) @@ -22,9 +22,17 @@ /* Also argv[0]! for symlink-ed calls */ for (i=0; argc > i; i++) { for (j=0; tc[j].name; j++) { - if (strcmp(argv[i], tc[j].name)) + if (strcmp(g_basename(argv[i]), tc[j].name)) continue; + if (!tc[j].func) { + fprintf(stderr, "Testcase \"%s\" disabled!", tc[j].name); + /* TODO: Return whatever needs to be returned that + * CTest/CDash list this as NOTRUN + */ + exit(127); + } + create_case(s, tc[j].name, tc[j].func); n++; } Modified: trunk/tests/support.h ============================================================================== --- trunk/tests/support.h Sun Jan 11 06:40:56 2009 (r5095) +++ trunk/tests/support.h Sun Jan 11 06:42:43 2009 (r5096) @@ -22,6 +22,8 @@ #define OSYNC_TESTCASE_ADD(x) { (#x), x }, +#define OSYNC_TESTCASE_DISABLED(x) { (#x), NULL }, + #define OSYNC_TESTCASE_END \ { NULL, NULL } \ }; \ |
From: <dg...@su...> - 2009-01-11 05:41:34
|
Author: dgollub Date: Sun Jan 11 06:40:56 2009 New Revision: 5095 URL: http://www.opensync.org/changeset/5095 Log: Introduce some more testing macros. Split ADD_CHECK_TEST, resulted in BUILD_CHECK_TEST, which really just build the test and don't add it to ctest. Add OSYNC_TESTCASE macro which calls single testcases of untis. Requires instrumented code. Modified: branches/3rd-party-cmake-modules/modules/Testing.cmake Modified: branches/3rd-party-cmake-modules/modules/Testing.cmake ============================================================================== --- branches/3rd-party-cmake-modules/modules/Testing.cmake Sun Jan 11 05:22:39 2009 (r5094) +++ branches/3rd-party-cmake-modules/modules/Testing.cmake Sun Jan 11 06:40:56 2009 (r5095) @@ -8,7 +8,7 @@ SET( CMAKE_MODULE_LINKER_FLAGS_PROFILING " -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Linker Flags" ) SET( CMAKE_EXEC_LINKER_FLAGS_PROFILING " -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Linker Flags" ) -MACRO( ADD_CHECK_TEST _testName _testSource ) +MACRO( BUILD_CHECK_TEST _testName _testSource ) if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) @@ -17,6 +17,35 @@ endif(COMMAND cmake_policy) ADD_EXECUTABLE( ${_testName} ${_testSource} ) TARGET_LINK_LIBRARIES( ${_testName} ${ARGN} ) + +ENDMACRO( BUILD_CHECK_TEST ) + +MACRO( ADD_CHECK_TEST _testName _testSource ) + + if(COMMAND cmake_policy) + cmake_policy(SET CMP0003 NEW) + ## The macro ADD_CHECK_TEST creates false warning. + cmake_policy(SET CMP0002 OLD) + endif(COMMAND cmake_policy) + BUILD_CHECK_TEST( ${_testName} ${_testSource} ${ARGN} ) + # ADD_EXECUTABLE( ${_testName} ${_testSource} ) + # TARGET_LINK_LIBRARIES( ${_testName} ${ARGN} ) ADD_TEST( ${_testName} ${CMAKE_CURRENT_BINARY_DIR}/${_testName} ) ENDMACRO( ADD_CHECK_TEST ) + +MACRO( OSYNC_TESTCASE _testSource _testDest ) + + if(COMMAND cmake_policy) + cmake_policy(SET CMP0003 NEW) + ## The macro ADD_CHECK_TEST creates false warning. + cmake_policy(SET CMP0002 OLD) + endif(COMMAND cmake_policy) + + # 1st Argument is the testcase name + # 2nd Argument is the executable name + # 3rd Argument the testcase name, again, as argument for the executable + ADD_TEST( ${_testDest} ${_testSource} ${_testDest} ) + +ENDMACRO( OSYNC_TESTCASE ) + |
From: <dg...@su...> - 2009-01-11 04:23:18
|
Author: ianmartin Date: Sun Jan 11 05:22:39 2009 New Revision: 5094 URL: http://www.opensync.org/changeset/5094 Log: Check for presence of libedataserver/eds-version.h as it was only added in 2.23 Modified: plugins/evolution2/CMakeLists.txt plugins/evolution2/src/evolution2_sync.c Modified: plugins/evolution2/CMakeLists.txt ============================================================================== --- plugins/evolution2/CMakeLists.txt Sun Jan 11 05:21:39 2009 (r5093) +++ plugins/evolution2/CMakeLists.txt Sun Jan 11 05:22:39 2009 (r5094) @@ -15,6 +15,9 @@ INCLUDE( OpenSyncInternal ) INCLUDE( Testing ) +INCLUDE( CheckIncludeFile ) +CHECK_INCLUDE_FILE( "libedataserver/eds-version.h" HAVE_EDS_VERSION_H ) + ADD_SUBDIRECTORY( src ) ADD_SUBDIRECTORY( tools ) ADD_SUBDIRECTORY( tests ) Modified: plugins/evolution2/src/evolution2_sync.c ============================================================================== --- plugins/evolution2/src/evolution2_sync.c Sun Jan 11 05:21:39 2009 (r5093) +++ plugins/evolution2/src/evolution2_sync.c Sun Jan 11 05:22:39 2009 (r5094) @@ -20,7 +20,9 @@ */ #include <string.h> +#ifdef HAVE_EDS_VERSION_H #include <libedataserver/eds-version.h> +#endif /* HAVE_EDS_VERSION_H */ #include <opensync/opensync.h> #include <opensync/opensync-format.h> @@ -136,8 +138,13 @@ static char *evo2_determine_version() { - char *version = osync_strdup_printf("%i.%i.%i", eds_major_version, eds_minor_version, eds_micro_version); - return version; + char *version = NULL; +#ifdef HAVE_EDS_VERSION + version = osync_strdup_printf("%i.%i.%i", eds_major_version, eds_minor_version, eds_micro_version); +#else + version = osync_strdup("Unknown"); +#endif /* HAVE_EDS_VERSION */ +return version; } |
From: <dg...@su...> - 2009-01-11 04:22:29
|
Author: dgollub Date: Sun Jan 11 05:21:39 2009 New Revision: 5093 URL: http://www.opensync.org/changeset/5093 Log: Introduce unittest macros: OSYNC_TESTCASE_START(unitname) OSYNC_TESTCASE_ADD(testcase) OSYNC_TESTCASE_END Those macros wrap the entire check-instrumentation. testcase function name needs to be added with OSYNC_TESTCASE_ADD, without string-quote. Those macros also introduce powerful test parameter handling. Calling the test-binary without parameter calls all testcases. Adding as parameter a "vaild" testcase name, just run this testcase. Example(s): ./engine engine_sync_stress Just runs the engine_sync_stress. ./engine engine_sync_stress engine_new Runs first sync_stress then the _new testcase. argv[0] is also handled. So calling symlinks is also possible: $ ln -s engine engine_sync_stress $ PATH=$PATH:. engine_sync_stress ./engine_sync_stress doesn't work yet, due to "./" Purpose of those marcros: faster debugging for single testcases. Running continous buildtests with all check-testcases as seperated CTest testcase. This requires a new CMake macro which also creates the corresponding sym-link. Modified: trunk/tests/engine-tests/check_engine.c trunk/tests/support.c trunk/tests/support.h Modified: trunk/tests/engine-tests/check_engine.c ============================================================================== --- trunk/tests/engine-tests/check_engine.c Sun Jan 11 03:48:10 2009 (r5092) +++ trunk/tests/engine-tests/check_engine.c Sun Jan 11 05:21:39 2009 (r5093) @@ -2003,45 +2003,26 @@ } END_TEST -Suite *engine_suite(void) -{ - Suite *s = suite_create("Engine"); -// Suite *s2 = suite_create("Engine"); - - create_case(s, "engine_new", engine_new); - create_case(s, "engine_init", engine_init); - create_case(s, "engine_sync", engine_sync); - create_case(s, "engine_sync_multi_obj", engine_sync_multi_obj); - create_case(s, "engine_sync_out_of_order", engine_sync_out_of_order); - create_case(s, "engine_sync_reuse", engine_sync_reuse); - create_case(s, "engine_sync_stress", engine_sync_stress); - - /* Disabled due to randomly failing - #994 - create_case(s, "engine_sync_read_write_stress", engine_sync_read_write_stress); - */ - - create_case(s, "engine_sync_read_write", engine_sync_read_write); - create_case(s, "engine_sync_read_write_stress2", engine_sync_read_write_stress2); - - //batch commit - //connect problem - //get_changes problem - - return s; -} +OSYNC_TESTCASE_START(engine) + +OSYNC_TESTCASE_ADD(engine_new) +OSYNC_TESTCASE_ADD(engine_init) +OSYNC_TESTCASE_ADD(engine_sync) +OSYNC_TESTCASE_ADD(engine_sync_multi_obj) +OSYNC_TESTCASE_ADD(engine_sync_out_of_order) +OSYNC_TESTCASE_ADD(engine_sync_reuse) +OSYNC_TESTCASE_ADD(engine_sync_stress) + +/* Disabled due to randomly failing - #994 +OSYNC_TESTCASE_ADD(engine_sync_read_write_stress) +*/ + +OSYNC_TESTCASE_ADD(engine_sync_read_write) +OSYNC_TESTCASE_ADD(engine_sync_read_write_stress2) + +//batch commit +//connect problem +//get_changes problem + +OSYNC_TESTCASE_END -int main(void) -{ - int nf; - - check_env(); - - Suite *s = engine_suite(); - - SRunner *sr; - sr = srunner_create(s); - srunner_run_all(sr, CK_VERBOSE); - nf = srunner_ntests_failed(sr); - srunner_free(sr); - return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE; -} Modified: trunk/tests/support.c ============================================================================== --- trunk/tests/support.c Sun Jan 11 03:48:10 2009 (r5092) +++ trunk/tests/support.c Sun Jan 11 05:21:39 2009 (r5093) @@ -7,6 +7,51 @@ char *olddir = NULL; + +void osync_testsuite_all(Suite *s, struct osync_testcase_s *tc) +{ + unsigned int i; + for (i=0; tc[i].name; i++) + create_case(s, tc[i].name, tc[i].func); +} + +unsigned int osync_testsuite_selected(Suite *s, int argc, char **argv, + struct osync_testcase_s *tc) +{ + unsigned int i, j, n=0; + /* Also argv[0]! for symlink-ed calls */ + for (i=0; argc > i; i++) { + for (j=0; tc[j].name; j++) { + if (strcmp(argv[i], tc[j].name)) + continue; + + create_case(s, tc[j].name, tc[j].func); + n++; + } + } + + return n; +} + +int osync_testsuite(int argc, char **argv, const char *unittest, + struct osync_testcase_s *tc) +{ + int nf; + Suite *s = suite_create(unittest); + SRunner *sr; + + check_env(); + + if (!osync_testsuite_selected(s, argc, argv, tc)) + osync_testsuite_all(s, tc); + + sr = srunner_create(s); + srunner_run_all(sr, CK_VERBOSE); + nf = srunner_ntests_failed(sr); + srunner_free(sr); + return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE; +} + static void reset_env(void) { g_unsetenv("CONNECT_ERROR"); Modified: trunk/tests/support.h ============================================================================== --- trunk/tests/support.h Sun Jan 11 03:48:10 2009 (r5092) +++ trunk/tests/support.h Sun Jan 11 05:21:39 2009 (r5093) @@ -1,3 +1,6 @@ +#ifndef OSYNC_TEST_SUPPORT +#define OSYNC_TEST_SUPPORT + #include <check.h> #include <opensync/opensync.h> @@ -13,6 +16,30 @@ #include "config.h" +#define OSYNC_TESTCASE_START(x) \ + const char *_unittest = (#x); \ + struct osync_testcase_s osync_testcase[] = { + +#define OSYNC_TESTCASE_ADD(x) { (#x), x }, + +#define OSYNC_TESTCASE_END \ + { NULL, NULL } \ + }; \ + \ +int main(int argc, char **argv) \ +{ \ + return osync_testsuite(argc, argv, _unittest, osync_testcase); \ +} + +struct osync_testcase_s { + const char *name; + void *func; +}; + + +int osync_testsuite(int argc, char **argv, const char *unittest, + struct osync_testcase_s *tc); + int num_client_connected; int num_client_main_connected; @@ -120,3 +147,5 @@ /* System Env helper */ void osync_testing_system_abort(const char *command); +#endif /* OSYNC_TEST_SUPPORT */ + |
From: <dg...@su...> - 2009-01-11 02:48:47
|
Author: dgollub Date: Sun Jan 11 03:48:10 2009 New Revision: 5092 URL: http://www.opensync.org/changeset/5092 Log: Return NULL if size or data is NULL. Modified: trunk/opensync/format/opensync_objformat.c trunk/opensync/format/opensync_objformat.h Modified: trunk/opensync/format/opensync_objformat.c ============================================================================== --- trunk/opensync/format/opensync_objformat.c Sun Jan 11 03:39:34 2009 (r5091) +++ trunk/opensync/format/opensync_objformat.c Sun Jan 11 03:48:10 2009 (r5092) @@ -222,6 +222,8 @@ char *osync_objformat_print(OSyncObjFormat *format, const char *data, unsigned int size) { osync_return_val_if_fail(format, NULL); + osync_return_val_if_fail(data, NULL); + osync_return_val_if_fail(size, NULL); if (!format->print_func) return g_strndup(data, size); Modified: trunk/opensync/format/opensync_objformat.h ============================================================================== --- trunk/opensync/format/opensync_objformat.h Sun Jan 11 03:39:34 2009 (r5091) +++ trunk/opensync/format/opensync_objformat.h Sun Jan 11 03:48:10 2009 (r5092) @@ -252,7 +252,8 @@ * @param format Pointer to the object format * @param data Pointer to the object to destroy * @param size Size in bytes of the object specified by the data parameter - * @returns Human readable string of the specified object. Caller is responsible for freeing the string + * @returns Human readable string of the specified object. Caller is responsible for freeing the string. + * Or NULL if size is 0 or data NULL. */ OSYNC_EXPORT char *osync_objformat_print(OSyncObjFormat *format, const char *data, unsigned int size); |
From: <dg...@su...> - 2009-01-11 02:40:11
|
Author: ianmartin Date: Sun Jan 11 03:39:34 2009 New Revision: 5091 URL: http://www.opensync.org/changeset/5091 Log: Use new OSyncAnchor API added in r5021. Fixes #1025, thanks to HaltonHuo Modified: plugins/evolution2/src/evolution2_ebook.c plugins/evolution2/src/evolution2_ecal.c Modified: plugins/evolution2/src/evolution2_ebook.c ============================================================================== --- plugins/evolution2/src/evolution2_ebook.c Sun Jan 11 03:26:25 2009 (r5090) +++ plugins/evolution2/src/evolution2_ebook.c Sun Jan 11 03:39:34 2009 (r5091) @@ -139,23 +139,36 @@ osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, data, info, ctx); OSyncObjTypeSink *sink = osync_plugin_info_get_sink(info); OSyncEvoEnv *env = (OSyncEvoEnv *)data; + osync_bool anchor_match; if (!(env->addressbook = evo2_ebook_open_book(osync_strdup(env->addressbook_path), &error))) { goto error; } - char *anchorpath = g_strdup_printf("%s/anchor.db", osync_plugin_info_get_configdir(info)); - if (!osync_anchor_compare(anchorpath, "contact", env->addressbook_path)) + OSyncAnchor *anchor = osync_objtype_sink_get_anchor(sink); + if (!anchor) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "Anchor missing for objtype \"%s\"", osync_objtype_sink_get_name(sink)); + goto error_free_book; + } + if (!osync_anchor_compare(anchor, env->addressbook_path, &anchor_match, &error)) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "Anchor comparison failed for objtype \"%s\"", osync_objtype_sink_get_name(sink)); + goto error_free_book; + } + if (!anchor_match) { + osync_trace(TRACE_INTERNAL, "EBook slow sync, due to anchor mismatch"); osync_objtype_sink_set_slowsync(sink, TRUE); - g_free(anchorpath); + } osync_context_report_success(ctx); osync_trace(TRACE_EXIT, "%s", __func__); return; - -error: + + error_free_book: + g_object_unref(env->addressbook); + env->addressbook = NULL; + error: osync_context_report_osyncerror(ctx, error); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error)); osync_error_unref(&error); @@ -183,24 +196,33 @@ OSyncError *error = NULL; GError *gerror=NULL; - char *anchorpath = g_strdup_printf("%s/anchor.db", osync_plugin_info_get_configdir(info)); - osync_anchor_update(anchorpath, "contact", env->addressbook_path); - g_free(anchorpath); - + OSyncObjTypeSink *sink = osync_plugin_info_get_sink(info); + OSyncAnchor *anchor = osync_objtype_sink_get_anchor(sink); + if (!anchor) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "Anchor missing for objtype \"%s\"", osync_objtype_sink_get_name(sink)); + goto error; + } + if (!osync_anchor_update(anchor, env->addressbook_path, &error)) + goto error; GList *changes = NULL; if (!e_book_get_changes(env->addressbook, env->change_id, &changes, &gerror)) { osync_error_set(&error, OSYNC_ERROR_GENERIC, "Unable to update EBook time of last sync: %s", gerror ? gerror->message : "None"); g_clear_error(&gerror); - osync_context_report_osyncerror(ctx, error); - osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error)); - osync_error_unref(&error); + goto error; } e_book_free_change_list(changes); osync_context_report_success(ctx); osync_trace(TRACE_EXIT, "%s", __func__); + return; + + error: + osync_context_report_osyncerror(ctx, error); + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error)); + osync_error_unref(&error); + } void evo2_report_change(OSyncContext *ctx, OSyncObjFormat *format, char *data, unsigned int size, const char *uid, OSyncChangeType changetype) @@ -411,6 +433,8 @@ functions.commit = evo2_ebook_modify; functions.sync_done = evo2_ebook_sync_done; + osync_objtype_sink_enable_anchor(sink, TRUE); + OSyncPluginConfig *config = osync_plugin_info_get_config(info); OSyncPluginResource *resource = osync_plugin_config_find_active_resource(config, "contact"); env->addressbook_path = osync_plugin_resource_get_url(resource); Modified: plugins/evolution2/src/evolution2_ecal.c ============================================================================== --- plugins/evolution2/src/evolution2_ecal.c Sun Jan 11 03:26:25 2009 (r5090) +++ plugins/evolution2/src/evolution2_ecal.c Sun Jan 11 03:39:34 2009 (r5091) @@ -90,22 +90,33 @@ OSyncObjTypeSink *sink = osync_plugin_info_get_sink(info); OSyncEvoCalendar * evo_cal = (OSyncEvoCalendar *)osync_objtype_sink_get_userdata(sink); - OSyncEvoEnv *env = (OSyncEvoEnv *)data; - if (!(evo_cal->calendar = evo2_ecal_open_cal(osync_strdup(evo_cal->uri), evo_cal->source_type, &error))) { goto error; } - char *anchorpath = g_strdup_printf("%s/anchor.db", osync_plugin_info_get_configdir(info)); - if (!osync_anchor_compare(anchorpath, evo_cal->objtype, evo_cal->uri)) - osync_objtype_sink_set_slowsync(sink, TRUE); - g_free(anchorpath); + OSyncAnchor *anchor = osync_objtype_sink_get_anchor(sink); + osync_bool anchor_match; + if (!anchor) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "Anchor missing for objtype \"%s\"", osync_objtype_sink_get_name(sink)); + goto error_free_cal; + } + if (!osync_anchor_compare(anchor, evo_cal->uri, &anchor_match, &error)) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "Anchor comparison failed for objtype \"%s\"", osync_objtype_sink_get_name(sink)); + goto error_free_cal; + } + if (!anchor_match) { + osync_trace(TRACE_INTERNAL, "ECal slow sync, due to anchor mismatch for objtype \"%s\"", osync_objtype_sink_get_name(sink)); + osync_objtype_sink_set_slowsync(sink, TRUE); + } osync_context_report_success(ctx); osync_trace(TRACE_EXIT, "%s", __func__); return; + error_free_cal: + g_object_unref(evo_cal->calendar); + evo_cal->calendar = NULL; error: osync_context_report_osyncerror(ctx, error); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error)); @@ -115,7 +126,6 @@ static void evo2_ecal_disconnect(void *data, OSyncPluginInfo *info, OSyncContext *ctx) { osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, data, info, ctx); - OSyncEvoEnv *env = (OSyncEvoEnv *)data; OSyncObjTypeSink *sink = osync_plugin_info_get_sink(info); OSyncEvoCalendar * evo_cal = (OSyncEvoCalendar *)osync_objtype_sink_get_userdata(sink); @@ -140,24 +150,31 @@ OSyncObjTypeSink *sink = osync_plugin_info_get_sink(info); OSyncEvoCalendar * evo_cal = (OSyncEvoCalendar *)osync_objtype_sink_get_userdata(sink); - char *anchorpath = g_strdup_printf("%s/anchor.db", osync_plugin_info_get_configdir(info)); - osync_anchor_update(anchorpath, evo_cal->objtype, evo_cal->uri); - g_free(anchorpath); - + OSyncAnchor *anchor = osync_objtype_sink_get_anchor(sink); + if (!anchor) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "Anchor missing for objtype \"%s\"", osync_objtype_sink_get_name(sink)); + goto error; + } + if (!osync_anchor_update(anchor, evo_cal->uri, &error)) + goto error; GList *changes = NULL; if (!e_cal_get_changes(evo_cal->calendar, env->change_id, &changes, &gerror)) { osync_error_set(&error, OSYNC_ERROR_GENERIC, "Unable to update %s ECal time of last sync: %s", evo_cal->objtype, gerror ? gerror->message : "None"); g_clear_error(&gerror); - osync_context_report_osyncerror(ctx, error); - osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error)); - osync_error_unref(&error); + goto error; } e_cal_free_change_list(changes); osync_context_report_success(ctx); osync_trace(TRACE_EXIT, "%s", __func__); + return; + + error: + osync_context_report_osyncerror(ctx, error); + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error)); + osync_error_unref(&error); } void evo2_ecal_report_change(OSyncContext *ctx, OSyncObjFormat *format, char *data, unsigned int size, const char *uid, OSyncChangeType changetype) @@ -269,7 +286,6 @@ static void evo2_ecal_modify(void *data, OSyncPluginInfo *info, OSyncContext *ctx, OSyncChange *change) { osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, data, info, ctx, change); - OSyncEvoEnv *env = (OSyncEvoEnv *)data; const char *uid = osync_change_get_uid(change); icalcomponent *icomp = NULL; @@ -410,6 +426,8 @@ functions.commit = evo2_ecal_modify; functions.sync_done = evo2_ecal_sync_done; + osync_objtype_sink_enable_anchor(sink, TRUE); + OSyncEvoCalendar *cal = osync_try_malloc0(sizeof(OSyncEvoCalendar), error); if (!cal) { return FALSE; |
From: <dg...@su...> - 2009-01-11 02:27:08
|
Author: dgollub Date: Sun Jan 11 03:26:25 2009 New Revision: 5090 URL: http://www.opensync.org/changeset/5090 Log: Add CTestConfig.cmake for CDash link: http://opensync.org/testing/index.php?project=evo2-sync Added: plugins/evolution2/CTestConfig.cmake Added: plugins/evolution2/CTestConfig.cmake ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/evolution2/CTestConfig.cmake Sun Jan 11 03:26:25 2009 (r5090) @@ -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 "evo2-sync") +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=evo2-sync") +set(CTEST_DROP_SITE_CDASH TRUE) |
From: <dg...@su...> - 2009-01-11 02:23:04
|
Author: dgollub Date: Sun Jan 11 03:22:24 2009 New Revision: 5089 URL: http://www.opensync.org/changeset/5089 Log: Introduce +osync_objtype_sink_load_anchor(), which is primarly of interest for unittesting (e.g. "osyncplugin" tool). Modified: trunk/opensync.sym trunk/opensync/client/opensync_client.c trunk/opensync/plugin/opensync_objtype_sink.c trunk/opensync/plugin/opensync_objtype_sink.h trunk/tools/osyncplugin.c Modified: trunk/opensync.sym ============================================================================== --- trunk/opensync.sym Sun Jan 11 01:25:49 2009 (r5088) +++ trunk/opensync.sym Sun Jan 11 03:22:24 2009 (r5089) @@ -408,6 +408,7 @@ osync_objtype_sink_get_write osync_objtype_sink_is_available osync_objtype_sink_is_enabled +osync_objtype_sink_load_anchor osync_objtype_sink_new osync_objtype_sink_nth_objformat_sink osync_objtype_sink_num_objformat_sinks Modified: trunk/opensync/client/opensync_client.c ============================================================================== --- trunk/opensync/client/opensync_client.c Sun Jan 11 01:25:49 2009 (r5088) +++ trunk/opensync/client/opensync_client.c Sun Jan 11 03:22:24 2009 (r5089) @@ -42,8 +42,6 @@ #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 @@ -564,7 +562,6 @@ char *groupname = NULL; char *configdir = NULL; char *formatdir = NULL; - char *anchorpath = NULL; int haspluginconfig = 0; OSyncPluginConfig *config = NULL; OSyncQueue *outgoing = NULL; @@ -695,35 +692,14 @@ 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%canchor.db", - osync_plugin_info_get_configdir(client->plugin_info), - G_DIR_SEPARATOR); - 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); + if (!osync_objtype_sink_load_anchor(sink, client->plugin_info, error)) { goto error_finalize; } - - osync_objtype_sink_set_anchor(sink, anchor); - } - osync_free(anchorpath); reply = osync_message_new_reply(message, error); if (!reply) Modified: trunk/opensync/plugin/opensync_objtype_sink.c ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink.c Sun Jan 11 01:25:49 2009 (r5088) +++ trunk/opensync/plugin/opensync_objtype_sink.c Sun Jan 11 03:22:24 2009 (r5089) @@ -26,6 +26,8 @@ #include "opensync/helper/opensync_anchor_internals.h" +#include "opensync_plugin_info.h" /* due to osync_plugin_info_get_configdir() */ + #include "opensync_objtype_sink.h" #include "opensync_objtype_sink_private.h" @@ -703,3 +705,35 @@ return sink->timeout.read; } +osync_bool osync_objtype_sink_load_anchor(OSyncObjTypeSink *sink, OSyncPluginInfo *plugin_info, OSyncError **error) +{ + char *anchorpath; + OSyncAnchor *anchor = NULL; + + osync_assert(sink); + + if (!osync_objtype_sink_has_anchor(sink)) + return TRUE; + + /* 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%canchor.db", + osync_plugin_info_get_configdir(plugin_info), + G_DIR_SEPARATOR); + + anchor = osync_anchor_new(anchorpath, sink->objtype, error); + if (!anchor) + goto error; + + osync_objtype_sink_set_anchor(sink, anchor); + + osync_free(anchorpath); + + return TRUE; +error: + osync_free(anchorpath); + return FALSE; +} + Modified: trunk/opensync/plugin/opensync_objtype_sink.h ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink.h Sun Jan 11 01:25:49 2009 (r5088) +++ trunk/opensync/plugin/opensync_objtype_sink.h Sun Jan 11 03:22:24 2009 (r5089) @@ -535,6 +535,19 @@ */ OSYNC_EXPORT void osync_objtype_sink_set_read_timeout(OSyncObjTypeSink *sink, unsigned int timeout); +/*! @brief Load the Anchor for a specific Sink if requested + * + * Load (i.e. connects) to the Anchor. If no Anchor is requested for this sink + * this functions just returns TRUE. + * + * @param sink Pointer to the sink + * @param info Pointer to the plugin info object + * @param error Pointer to error struct, get set on any error + * @returns TRUE on success, FALSE on any error + * + */ +OSYNC_EXPORT osync_bool osync_objtype_sink_load_anchor(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncError **error); + /*@}*/ #endif /* _OPENSYNC_OBJTYPE_SINK_H_ */ Modified: trunk/tools/osyncplugin.c ============================================================================== --- trunk/tools/osyncplugin.c Sun Jan 11 01:25:49 2009 (r5088) +++ trunk/tools/osyncplugin.c Sun Jan 11 03:22:24 2009 (r5089) @@ -449,8 +449,16 @@ static void *plugin_initialize(OSyncError **error) { + unsigned int n, num_sinks = osync_plugin_info_num_objtypes(plugin_info); void *plugin_data = osync_plugin_initialize(plugin, plugin_info, error); - + + + for (n = 0; n < num_sinks; n++) { + OSyncObjTypeSink *sink = osync_plugin_info_nth_objtype(plugin_info, n); + + if (!osync_objtype_sink_load_anchor(sink, plugin_info, error)) + return NULL; + } return plugin_data; } |
From: <dg...@su...> - 2009-01-11 00:26:32
|
Author: ianmartin Date: Sun Jan 11 01:25:49 2009 New Revision: 5088 URL: http://www.opensync.org/changeset/5088 Log: Utilities added to tools directory list_sources creates a list of sources known to the eds. Could be useful when trying to connect to another source than the default. test_uri tries to open the passed uri as an EBook or ECal Added: plugins/evolution2/tools/ plugins/evolution2/tools/CMakeLists.txt plugins/evolution2/tools/list_sources.c plugins/evolution2/tools/test_uri.c Modified: plugins/evolution2/CMakeLists.txt plugins/evolution2/src/evolution2_sync.c Modified: plugins/evolution2/CMakeLists.txt ============================================================================== --- plugins/evolution2/CMakeLists.txt Sun Jan 11 01:25:45 2009 (r5087) +++ plugins/evolution2/CMakeLists.txt Sun Jan 11 01:25:49 2009 (r5088) @@ -16,6 +16,7 @@ INCLUDE( Testing ) ADD_SUBDIRECTORY( src ) +ADD_SUBDIRECTORY( tools ) ADD_SUBDIRECTORY( tests ) Modified: plugins/evolution2/src/evolution2_sync.c ============================================================================== --- plugins/evolution2/src/evolution2_sync.c Sun Jan 11 01:25:45 2009 (r5087) +++ plugins/evolution2/src/evolution2_sync.c Sun Jan 11 01:25:49 2009 (r5088) @@ -56,132 +56,7 @@ g_free(env); } -GList *evo2_list_calendars(OSyncEvoEnv *env, void *data, OSyncError **error) -{ - GList *paths = NULL; - ESourceList *sources = NULL; - ESource *source = NULL; - osync_bool first = FALSE; - - if (!e_cal_get_sources(&sources, E_CAL_SOURCE_TYPE_EVENT, NULL)) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to list calendars. Unable to get sources"); - return NULL; - } - - GSList *g = NULL; - for (g = e_source_list_peek_groups (sources); g; g = g->next) { - ESourceGroup *group = E_SOURCE_GROUP (g->data); - GSList *s = NULL; - for (s = e_source_group_peek_sources (group); s; s = s->next) { - source = E_SOURCE (s->data); - evo2_location *path = g_malloc0(sizeof(evo2_location)); - if (!first) { - first = TRUE; - path->uri = g_strdup("default"); - } else { - path->uri = g_strdup(e_source_get_uri(source)); - } - path->name = g_strdup(e_source_peek_name(source)); - paths = g_list_append(paths, path); - } - } - return paths; -} - -GList *evo2_list_memos(OSyncEvoEnv *env, void *data, OSyncError **error) -{ - GList *paths = NULL; - ESourceList *sources = NULL; - ESource *source = NULL; - osync_bool first = FALSE; - - if (!e_cal_get_sources(&sources, E_CAL_SOURCE_TYPE_JOURNAL, NULL)) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to list memos. Unable to get sources"); - return NULL; - } - - GSList *g = NULL; - for (g = e_source_list_peek_groups (sources); g; g = g->next) { - ESourceGroup *group = E_SOURCE_GROUP (g->data); - GSList *s = NULL; - for (s = e_source_group_peek_sources (group); s; s = s->next) { - source = E_SOURCE (s->data); - evo2_location *path = g_malloc0(sizeof(evo2_location)); - if (!first) { - first = TRUE; - path->uri = g_strdup("default"); - } else { - path->uri = g_strdup(e_source_get_uri(source)); - } - path->name = g_strdup(e_source_peek_name(source)); - paths = g_list_append(paths, path); - } - } - return paths; -} -GList *evo2_list_tasks(OSyncEvoEnv *env, void *data, OSyncError **error) -{ - GList *paths = NULL; - ESourceList *sources = NULL; - ESource *source = NULL; - osync_bool first = FALSE; - - if (!e_cal_get_sources(&sources, E_CAL_SOURCE_TYPE_TODO, NULL)) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to list tasks. Unable to get sources"); - return NULL; - } - - GSList *g = NULL; - for (g = e_source_list_peek_groups (sources); g; g = g->next) { - ESourceGroup *group = E_SOURCE_GROUP (g->data); - GSList *s = NULL; - for (s = e_source_group_peek_sources (group); s; s = s->next) { - source = E_SOURCE (s->data); - evo2_location *path = g_malloc0(sizeof(evo2_location)); - if (!first) { - first = TRUE; - path->uri = g_strdup("default"); - } else { - path->uri = g_strdup(e_source_get_uri(source)); - } - path->name = g_strdup(e_source_peek_name(source)); - paths = g_list_append(paths, path); - } - } - return paths; -} - -GList *evo2_list_addressbooks(OSyncEvoEnv *env, void *data, OSyncError **error) -{ - GList *paths = NULL; - ESourceList *sources = NULL; - ESource *source = NULL; - osync_bool first = FALSE; - if (!e_book_get_addressbooks(&sources, NULL)) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to list addressbooks. Unable to get sources"); - return NULL; - } - - GSList *g = NULL; - for (g = e_source_list_peek_groups (sources); g; g = g->next) { - ESourceGroup *group = E_SOURCE_GROUP (g->data); - GSList *s = NULL; - for (s = e_source_group_peek_sources (group); s; s = s->next) { - source = E_SOURCE (s->data); - evo2_location *path = g_malloc0(sizeof(evo2_location)); - if (!first) { - first = TRUE; - path->uri = g_strdup("default"); - } else { - path->uri = g_strdup(e_source_get_uri(source)); - } - path->name = g_strdup(e_source_peek_name(source)); - paths = g_list_append(paths, path); - } - } - return paths; -} ESource *evo2_find_source(ESourceList *list, char *uri) { Added: plugins/evolution2/tools/CMakeLists.txt ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/evolution2/tools/CMakeLists.txt Sun Jan 11 01:25:49 2009 (r5088) @@ -0,0 +1,13 @@ +LINK_DIRECTORIES( ${OPENSYNC_LIBRARY_DIRS} ${GLIB2_LIBRARY_DIRS} ${LIBEBOOK_LIBRARY_DIRS} ${LIBECAL_LIBRARY_DIRS} ${LIBEDATABOOK_LIBRARY_DIRS} ${LIBEDATACAL_LIBRARY_DIRS} ${LIBEDATASERVER_LIBRARY_DIRS} ) +INCLUDE_DIRECTORIES( ${LIBEBOOK_INCLUDE_DIRS} ${LIBECAL_INCLUDE_DIRS} ${LIBEDATABOOK_INCLUDE_DIRS} ${LIBEDATACAL_INCLUDE_DIRS} ${LIBEDATASERVER_INCLUDE_DIRS} ${OPENSYNC_INCLUDE_DIRS} ${GLIB2_INCLUDE_DIRS} ) + +SET( list_sources_SRCS +list_sources.c +) + +ADD_EXECUTABLE( list_sources ${list_sources_SRCS} ) +TARGET_LINK_LIBRARIES( list_sources ${OPENSYNC_LIBRARIES} ${GLIB2_LIBRARIES} ${LIBEBOOK_LIBRARIES} ${LIBECAL_LIBRARIES} ${LIBEDATASERVER_LIBRARIES} ) + +ADD_EXECUTABLE( test_uri test_uri.c ) +TARGET_LINK_LIBRARIES( test_uri ${OPENSYNC_LIBRARIES} ${GLIB2_LIBRARIES} ${LIBEBOOK_LIBRARIES} ${LIBECAL_LIBRARIES} ${LIBEDATASERVER_LIBRARIES} ) + Added: plugins/evolution2/tools/list_sources.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/evolution2/tools/list_sources.c Sun Jan 11 01:25:49 2009 (r5088) @@ -0,0 +1,67 @@ +#include <glib.h> +#include <libecal/e-cal.h> +#include <libebook/e-book.h> +#include <libedataserver/e-data-server-util.h> + + +void print_sources(ESourceList *sources) +{ + ESource *source = NULL; + + GSList *g = NULL; + for (g = e_source_list_peek_groups (sources); g; g = g->next) { + ESourceGroup *group = E_SOURCE_GROUP (g->data); + printf("Group: %s\n", e_source_group_peek_name(group)); + + GSList *s = NULL; + for (s = e_source_group_peek_sources (group); s; s = s->next) { + source = E_SOURCE (s->data); + printf(" %s: %s\n", e_source_peek_name(source), e_source_get_uri(source)); + } + } +} + +void print_calendars(ECalSourceType source_type) { + ESourceList *sources = NULL; + if (e_cal_get_sources(&sources, source_type, NULL)) { + print_sources(sources); + } +} + +void print_memos() +{ + print_calendars(E_CAL_SOURCE_TYPE_JOURNAL); +} + +void print_tasks() +{ + print_calendars(E_CAL_SOURCE_TYPE_TODO); +} + +void print_events() +{ + print_calendars(E_CAL_SOURCE_TYPE_EVENT); +} + + +int main () { + ESourceList *sources = NULL; + printf("Addressbooks:\n"); + if (e_book_get_addressbooks(&sources, NULL)) { + print_sources(sources); + } + printf("\n"); + printf("Events:\n"); + print_events(); + printf("\n"); + + printf("Tasks:\n"); + print_tasks(); + printf("\n"); + + printf("Memos:\n"); + print_memos(); + + + return 0; +} Added: plugins/evolution2/tools/test_uri.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/evolution2/tools/test_uri.c Sun Jan 11 01:25:49 2009 (r5088) @@ -0,0 +1,79 @@ +#include <string.h> +#include <glib.h> +#include <libecal/e-cal.h> +#include <libebook/e-book.h> +#include <libedataserver/e-data-server-util.h> + +void open_calendar(const char *uri, ECalSourceType source_type) +{ + ECal *cal = NULL; + GError *gerror = NULL; + cal = e_cal_new_from_uri(uri, source_type); + + if (!cal) { + printf("Failed to allocate calendar\n"); + return; + } + if (!e_cal_open(cal, TRUE, &gerror)) { + printf("Failed to open calendar:\n%s\n", gerror->message); + g_clear_error(&gerror); + return; + } + printf("Successfully opened %s\n", uri); + g_object_unref(cal); +} + +void open_book(const char *uri) +{ + EBook *book = NULL; + GError *gerror = NULL; + book = e_book_new_from_uri(uri, &gerror); + + if (book) { + if (e_book_open(book, TRUE, &gerror)) { + printf("Successfully opened %s\n", uri); + } + g_object_unref(book); + } + if (gerror) { + printf("Failed to open addressbook:\n%s\n", gerror->message); + g_clear_error(&gerror); + } +} + +static void usage(char *progname, int exitcode) +{ + fprintf (stderr, "Usage: %s <objtype> <uri>\n\n", progname); + fprintf (stderr, "objtype may be one of:\n"); + fprintf (stderr, "--contact\n"); + fprintf (stderr, "--event\n"); + fprintf (stderr, "--note\n"); + fprintf (stderr, "--todo\n"); + fprintf (stderr, "\nWARNING: This program allows you to attempt to open ECals with the wrong source type. Doing so may break everything\n"); + exit(exitcode); +} + +int main(int argc, char *argv[]) +{ + + g_type_init(); + if (argc < 2) + usage(argv[0], 1); + if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) + usage(argv[0], 0); + + if (argc <3) + usage(argv[0], 1); + if (!strcmp(argv[1], "--contact")) { + open_book(argv[2]); + } else if (!strcmp(argv[1], "--event")) { + open_calendar(argv[2], E_CAL_SOURCE_TYPE_EVENT); + } else if (!strcmp(argv[1], "--todo")) { + open_calendar(argv[2], E_CAL_SOURCE_TYPE_TODO); + } else if (!strcmp(argv[1], "--note")) { + open_calendar(argv[2], E_CAL_SOURCE_TYPE_JOURNAL); + } else { + usage(argv[0], 1); + } + return 0; +} |
From: <dg...@su...> - 2009-01-11 00:26:24
|
Author: ianmartin Date: Sun Jan 11 01:25:45 2009 New Revision: 5087 URL: http://www.opensync.org/changeset/5087 Log: Add error handling to sync_done functions Modified: plugins/evolution2/src/evolution2_ebook.c plugins/evolution2/src/evolution2_ecal.c Modified: plugins/evolution2/src/evolution2_ebook.c ============================================================================== --- plugins/evolution2/src/evolution2_ebook.c Sun Jan 11 01:19:29 2009 (r5086) +++ plugins/evolution2/src/evolution2_ebook.c Sun Jan 11 01:25:45 2009 (r5087) @@ -180,6 +180,8 @@ { osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, data, info, ctx); OSyncEvoEnv *env = (OSyncEvoEnv *)data; + OSyncError *error = NULL; + GError *gerror=NULL; char *anchorpath = g_strdup_printf("%s/anchor.db", osync_plugin_info_get_configdir(info)); osync_anchor_update(anchorpath, "contact", env->addressbook_path); @@ -187,8 +189,15 @@ GList *changes = NULL; - e_book_get_changes(env->addressbook, env->change_id, &changes, NULL); - + if (!e_book_get_changes(env->addressbook, env->change_id, &changes, &gerror)) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "Unable to update EBook time of last sync: %s", gerror ? gerror->message : "None"); + g_clear_error(&gerror); + osync_context_report_osyncerror(ctx, error); + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error)); + osync_error_unref(&error); + } + + e_book_free_change_list(changes); osync_context_report_success(ctx); osync_trace(TRACE_EXIT, "%s", __func__); Modified: plugins/evolution2/src/evolution2_ecal.c ============================================================================== --- plugins/evolution2/src/evolution2_ecal.c Sun Jan 11 01:19:29 2009 (r5086) +++ plugins/evolution2/src/evolution2_ecal.c Sun Jan 11 01:25:45 2009 (r5087) @@ -19,6 +19,7 @@ */ #include <string.h> +#include <glib.h> #include <opensync/opensync.h> #include <opensync/opensync-context.h> @@ -133,6 +134,8 @@ { osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, data, info, ctx); OSyncEvoEnv *env = (OSyncEvoEnv *)data; + OSyncError *error = NULL; + GError *gerror = NULL; OSyncObjTypeSink *sink = osync_plugin_info_get_sink(info); OSyncEvoCalendar * evo_cal = (OSyncEvoCalendar *)osync_objtype_sink_get_userdata(sink); @@ -143,8 +146,15 @@ GList *changes = NULL; - e_cal_get_changes(evo_cal->calendar, env->change_id, &changes, NULL); - + if (!e_cal_get_changes(evo_cal->calendar, env->change_id, &changes, &gerror)) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "Unable to update %s ECal time of last sync: %s", evo_cal->objtype, gerror ? gerror->message : "None"); + g_clear_error(&gerror); + osync_context_report_osyncerror(ctx, error); + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error)); + osync_error_unref(&error); + } + + e_cal_free_change_list(changes); osync_context_report_success(ctx); osync_trace(TRACE_EXIT, "%s", __func__); |
From: <dg...@su...> - 2009-01-11 00:20:07
|
Author: dgollub Date: Sun Jan 11 01:19:29 2009 New Revision: 5086 URL: http://www.opensync.org/changeset/5086 Log: Fix vconvert-tool format detection. This "detection full" slighlty changed. In most cases regular detection is enough for vconvert, since no encapsulated formats are involved. "detection full" starts with encapsulator detection... and aborts if there is none. Added --format-config parameter to set conversion-path configs. Modified: format-plugins/vformat/tools/vconvert.c Modified: format-plugins/vformat/tools/vconvert.c ============================================================================== --- format-plugins/vformat/tools/vconvert.c Sun Jan 11 01:09:25 2009 (r5085) +++ format-plugins/vformat/tools/vconvert.c Sun Jan 11 01:19:29 2009 (r5086) @@ -50,6 +50,7 @@ fprintf (stderr, "Switches:\n"); fprintf (stderr, "--help\t\tShow this help message\n"); fprintf (stderr, "--out <file>\tStore the output in this file (No output to stdout)\n"); + fprintf (stderr, "--format-config <config>\t Apply conversion config (e.g. VCARD_EXTENSION=KDE)\n"); fprintf (stderr, "--to-vcard21\tConvert to vcard 2.1\n"); fprintf (stderr, "--to-vcard30\tConvert to vcard 3.0\n"); fprintf (stderr, "--to-vevent10\tConvert to vevent 1.0\n"); @@ -232,6 +233,7 @@ OSyncObjFormat *targetformat = NULL; conv_detection type = TARGET_AUTO; char *output = NULL; + char *format_config = NULL; char *filename = NULL; char *buffer = NULL; char *print = NULL; @@ -273,6 +275,11 @@ i++; if (!output) usage (argv[0], 1); + } else if (!strcmp (arg, "--format-config")) { + format_config = argv[i + 1]; + i++; + if (!format_config) + usage (argv[0], 1); } else if (!strcmp (arg, "--")) { break; } else if (arg[0] == '-') { @@ -309,13 +316,20 @@ goto error; } - // detect source and target xmlformat - sourceformat = NULL; - if (!(sourceformat = osync_format_env_detect_objformat_full(format_env, data, &error))) { - fprintf(stderr, "Unable to detect file format\n"); + // detect source and target xmlformat. First update the initial objformat. + // Then run decapsulator driven detection. + sourceformat = osync_format_env_detect_objformat(format_env, data); + if (sourceformat) + osync_data_set_objformat(data, sourceformat); + + sourceformat = osync_format_env_detect_objformat_full(format_env, data, &error); + if (sourceformat) + osync_data_set_objformat(data, sourceformat); + + if (osync_error_is_set(&error)) goto error; - } - osync_data_set_objformat(data, sourceformat); + + sourceformat = osync_data_get_objformat(data); targetformat = conv_run_detection(format_env, osync_objformat_get_name(sourceformat), type); if (!targetformat) { @@ -325,6 +339,9 @@ // find converter path OSyncFormatConverterPath *path = osync_format_env_find_path(format_env, sourceformat, targetformat, &error); + if (format_config) + osync_converter_path_set_config(path, format_config); + // convert data if (!osync_format_env_convert(format_env, path, data, &error)) { fprintf(stderr, "Unable to convert data\n"); |
From: <dg...@su...> - 2009-01-11 00:10:05
|
Author: ianmartin Date: Sun Jan 11 01:09:25 2009 New Revision: 5085 URL: http://www.opensync.org/changeset/5085 Log: Added missing libxml2 requirements in CMake files Modified: format-plugins/xmlformat/trunk/CMakeLists.txt format-plugins/xmlformat/trunk/src/CMakeLists.txt Modified: format-plugins/xmlformat/trunk/CMakeLists.txt ============================================================================== --- format-plugins/xmlformat/trunk/CMakeLists.txt Sun Jan 11 00:40:36 2009 (r5084) +++ format-plugins/xmlformat/trunk/CMakeLists.txt Sun Jan 11 01:09:25 2009 (r5085) @@ -9,6 +9,7 @@ SET( OPENSYNC_MIN_VERSION "0.39" ) FIND_PACKAGE( OpenSync REQUIRED ) FIND_PACKAGE( GLIB2 REQUIRED ) +FIND_PACKAGE( LibXml2 REQUIRED ) FIND_PACKAGE( Check ) INCLUDE( OpenSyncInternal ) Modified: format-plugins/xmlformat/trunk/src/CMakeLists.txt ============================================================================== --- format-plugins/xmlformat/trunk/src/CMakeLists.txt Sun Jan 11 00:40:36 2009 (r5084) +++ format-plugins/xmlformat/trunk/src/CMakeLists.txt Sun Jan 11 01:09:25 2009 (r5085) @@ -1,11 +1,11 @@ -LINK_DIRECTORIES( ${OPENSYNC_LIBRARY_DIRS} ${GLIB2_LIBRARY_DIRS} ) -INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} ${OPENSYNC_INCLUDE_DIRS} ${GLIB2_INCLUDE_DIRS} ) +LINK_DIRECTORIES( ${OPENSYNC_LIBRARY_DIRS} ${GLIB2_LIBRARY_DIRS} ${LIBXML2_LIBRARY_DIRS} ) +INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} ${OPENSYNC_INCLUDE_DIRS} ${GLIB2_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIRS} ) OPENSYNC_FORMAT_ADD( xmlformat xmlformat.c xmlformat_compare.c xmlformat_merge.c ) OPENSYNC_FORMAT_ADD( xmlformat-doc xmlformat-doc.c ) -TARGET_LINK_LIBRARIES( xmlformat ${OPENSYNC_LIBRARIES} ${GLIB2_LIBRARIES} ) -TARGET_LINK_LIBRARIES( xmlformat ${OPENSYNC_LIBRARIES} ${GLIB2_LIBRARIES} ) +TARGET_LINK_LIBRARIES( xmlformat ${OPENSYNC_LIBRARIES} ${GLIB2_LIBRARIES} ${LIBXML2_LIBRARIES} ) +TARGET_LINK_LIBRARIES( xmlformat-doc ${OPENSYNC_LIBRARIES} ${GLIB2_LIBRARIES} ${LIBXML2_LIBRARIES} ) # Required for UNITTESTING only ADD_LIBRARY( xmlformat-static STATIC xmlformat_compare.c xmlformat.c xmlformat_merge.c ) |
From: <dg...@su...> - 2009-01-10 23:41:13
|
Author: dgollub Date: Sun Jan 11 00:40:36 2009 New Revision: 5084 URL: http://www.opensync.org/changeset/5084 Log: Instrument osync_change_compare() with sensitive tracing Modified: trunk/opensync/data/opensync_change.c Modified: trunk/opensync/data/opensync_change.c ============================================================================== --- trunk/opensync/data/opensync_change.c Sat Jan 10 23:33:46 2009 (r5083) +++ trunk/opensync/data/opensync_change.c Sun Jan 11 00:40:36 2009 (r5084) @@ -184,7 +184,33 @@ osync_assert(leftchange); if (rightchange->changetype == leftchange->changetype) { - OSyncConvCmpResult ret = osync_data_compare(leftchange->data, rightchange->data); + OSyncConvCmpResult ret; + + if (osync_trace_is_enabled()) { + char *leftprint, *rightprint; + + leftprint = osync_data_get_printable(leftchange->data); + rightprint = osync_data_get_printable(rightchange->data); + + osync_trace(TRACE_SENSITIVE, "\nleft change (UID:%s):\n%s\n" + "right change (UID:%s):\n%s\n", + __NULLSTR(osync_change_get_uid(leftchange)), + __NULLSTR(leftprint), + __NULLSTR(osync_change_get_uid(rightchange)), + __NULLSTR(rightprint)); + + /* FIXME: free the result of objformat_print(). There is + * no object format specific destory function for print? + */ + + if (leftprint) + osync_free(leftprint); + + if (rightprint) + osync_free(rightprint); + } + + ret = osync_data_compare(leftchange->data, rightchange->data); osync_trace(TRACE_EXIT, "%s: Compare data: %i", __func__, ret); return ret; } else { |
From: <dg...@su...> - 2009-01-10 22:34:23
|
Author: dgollub Date: Sat Jan 10 23:33:46 2009 New Revision: 5083 URL: http://www.opensync.org/changeset/5083 Log: Don't return/fail if plugin init function returns NULL. Modified: trunk/tools/osyncplugin.c Modified: trunk/tools/osyncplugin.c ============================================================================== --- trunk/tools/osyncplugin.c Sat Jan 10 23:31:31 2009 (r5082) +++ trunk/tools/osyncplugin.c Sat Jan 10 23:33:46 2009 (r5083) @@ -451,8 +451,6 @@ { void *plugin_data = osync_plugin_initialize(plugin, plugin_info, error); - if (!plugin_data) - return NULL; return plugin_data; } |
From: <dg...@su...> - 2009-01-10 22:32:06
|
Author: dgollub Date: Sat Jan 10 23:31:31 2009 New Revision: 5082 URL: http://www.opensync.org/changeset/5082 Log: Use G_DIR_SEPARATOR to build the (temp.) anchor path. Modified: trunk/opensync/client/opensync_client.c Modified: trunk/opensync/client/opensync_client.c ============================================================================== --- trunk/opensync/client/opensync_client.c Sat Jan 10 23:30:51 2009 (r5081) +++ trunk/opensync/client/opensync_client.c Sat Jan 10 23:31:31 2009 (r5082) @@ -701,7 +701,9 @@ * 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)); + anchorpath = osync_strdup_printf("%s%canchor.db", + osync_plugin_info_get_configdir(client->plugin_info), + G_DIR_SEPARATOR); num_sinks = osync_plugin_info_num_objtypes(client->plugin_info); for (n = 0; n < num_sinks; n++) { |
From: <dg...@su...> - 2009-01-10 22:31:28
|
Author: dgollub Date: Sat Jan 10 23:30:51 2009 New Revision: 5081 URL: http://www.opensync.org/changeset/5081 Log: Fix setup_testbed, which got broken when dropping the ./formats directory. Modified: trunk/tests/support.c Modified: trunk/tests/support.c ============================================================================== --- trunk/tests/support.c Sat Jan 10 23:25:23 2009 (r5080) +++ trunk/tests/support.c Sat Jan 10 23:30:51 2009 (r5081) @@ -103,11 +103,6 @@ if (system(command)) abort(); g_free(command); - - command = g_strdup_printf("cp -R ../formats/*.%s %s/formats", G_MODULE_SUFFIX, testbed); - if (system(command)) - abort(); - g_free(command); command = g_strdup_printf("cp -R %s/../../misc/schemas/*.xsd %s", OPENSYNC_TESTDATA, testbed); if (system(command)) |
From: <dg...@su...> - 2009-01-10 22:29:26
|
Author: dgollub Date: Sat Jan 10 22:31:15 2009 New Revision: 5074 URL: http://www.opensync.org/changeset/5074 Log: Move file- and plain-format plugins to file-sync repo. Added: plugins/file-sync/src/file.c - copied unchanged from r5072, trunk/formats/file.c plugins/file-sync/src/file.h - copied unchanged from r5072, trunk/formats/file.h plugins/file-sync/src/plain.c - copied unchanged from r5072, trunk/formats/plain.c Copied: plugins/file-sync/src/file.c (from r5072, trunk/formats/file.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/file-sync/src/file.c Sat Jan 10 22:31:15 2009 (r5074, copy of r5072, trunk/formats/file.c) @@ -0,0 +1,260 @@ +/* + * opensync - A plugin for file objects for the opensync framework + * Copyright (C) 2004-2005 Armin Bauer <arm...@op...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "config.h" + +#include <string.h> +#include <glib.h> + +#include <opensync/opensync.h> +#include <opensync/opensync-serializer.h> +#include <opensync/opensync-format.h> + +#include "file.h" + +static OSyncConvCmpResult compare_file(const char *leftdata, unsigned int leftsize, const char *rightdata, unsigned int rightsize, void *user_data) +{ + OSyncFileFormat *leftfile = (OSyncFileFormat *)leftdata; + OSyncFileFormat *rightfile = (OSyncFileFormat *)rightdata; + + osync_trace(TRACE_ENTRY, "%s(%p, %i, %p, %i)", __func__, leftdata, leftsize, rightdata, rightsize); + osync_assert(leftdata); + osync_assert(rightdata); + + osync_assert(rightfile->path); + osync_assert(leftfile->path); + + osync_trace(TRACE_INTERNAL, "Comparing %s and %s", leftfile->path, rightfile->path); + + + if (!strcmp(leftfile->path, rightfile->path)) { + if (leftfile->size == rightfile->size) { + if (leftfile->size == 0 || !memcmp(leftfile->data, rightfile->data, rightfile->size)) { + osync_trace(TRACE_EXIT, "%s: Same", __func__); + return OSYNC_CONV_DATA_SAME; + } + } + + osync_trace(TRACE_EXIT, "%s: Similar", __func__); + return OSYNC_CONV_DATA_SIMILAR; + } + + osync_trace(TRACE_EXIT, "%s: Mismatch", __func__); + return OSYNC_CONV_DATA_MISMATCH; +} + +static osync_bool conv_file_to_plain(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *user_data, OSyncError **error) +{ + OSyncFileFormat *file = (OSyncFileFormat *)input; + char *plaindata = NULL; + osync_trace(TRACE_INTERNAL, "Converting file to plain"); + + *free_input = TRUE; + + /* Add a \0 to make a usable plain (text) format. input gets freed by destroy_func() */ + plaindata = osync_try_malloc0(file->size + 1, error); + memcpy(plaindata, file->data, file->size); + + *output = plaindata; + *outpsize = file->size + 1; + + return TRUE; +} + +static osync_bool conv_plain_to_file(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *userdata, OSyncError **error) +{ + OSyncFileFormat *file = NULL; + osync_trace(TRACE_INTERNAL, "Converting plain to file"); + + *free_input = FALSE; + file = osync_try_malloc0(sizeof(OSyncFileFormat), error); + if (!file) + return FALSE; + file->path = osync_rand_str(g_random_int_range(1, 100)); + + file->data = input; + file->size = inpsize - 1; + + *output = (char *)file; + *outpsize = sizeof(OSyncFileFormat); + return TRUE; +} + +static void destroy_file(char *input, unsigned int inpsize, void *user_data) +{ + OSyncFileFormat *file = (OSyncFileFormat *)input; + + if (file->data) + g_free(file->data); + + if (file->path) + g_free(file->path); + + g_free(file); +} + +static osync_bool duplicate_file(const char *uid, const char *input, unsigned int insize, char **newuid, char **output, unsigned int *outsize, osync_bool *dirty, void *user_data, OSyncError **error) +{ + OSyncFileFormat *file = (OSyncFileFormat *)input; + + char *newpath = g_strdup_printf ("%s-dupe", file->path); + g_free(file->path); + file->path = newpath; + *newuid = g_strdup(file->path); + *dirty = TRUE; + return TRUE; +} + +static osync_bool copy_file(const char *input, unsigned int inpsize, char **output, unsigned int *outpsize, void *user_data, OSyncError **error) +{ + OSyncFileFormat *inpfile = (OSyncFileFormat *)input; + + OSyncFileFormat *outfile = osync_try_malloc0(sizeof(OSyncFileFormat), error); + if (!outfile) + return FALSE; + + if (inpfile->data) { + outfile->data = g_malloc0(inpfile->size); + memcpy(outfile->data, inpfile->data, inpfile->size); + outfile->size = inpfile->size; + } + + outfile->path = g_strdup(inpfile->path); + + *output = (char *)outfile; + *outpsize = sizeof(OSyncFileFormat); + return TRUE; +} + +static time_t revision_file(const char *input, unsigned int inpsize, void *user_data, OSyncError **error) +{ + OSyncFileFormat *file = (OSyncFileFormat *)input; + time_t lastmod; + + osync_trace(TRACE_ENTRY, "%s(%p, %i, %p)", __func__, input, inpsize, error); + + lastmod = file->last_mod; + + osync_trace(TRACE_EXIT, "%s: %i", __func__, lastmod); + return lastmod; +} + +static char *print_file(const char *data, unsigned int size, void *user_data) +{ + OSyncFileFormat *file = (OSyncFileFormat *)data; + + char *printable = g_strdup_printf ("File %s: size: %i", file->path, file->size); + return printable; +} + +static osync_bool marshal_file(const char *input, unsigned int inpsize, OSyncMarshal *marshal, void *user_data, OSyncError **error) +{ + OSyncFileFormat *file = (OSyncFileFormat *)input; + osync_trace(TRACE_ENTRY, "%s(%p, %i, %p, %p)", __func__, input, inpsize, marshal, error); + + osync_marshal_write_string(marshal, file->path); + osync_marshal_write_buffer(marshal, file->data, file->size); + + osync_trace(TRACE_EXIT, "%s", __func__); + return TRUE; +} + +static osync_bool demarshal_file(OSyncMarshal *marshal, char **output, unsigned int *outpsize, void *user_data, OSyncError **error) +{ + OSyncFileFormat *file = NULL; + osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, marshal, output, outpsize, error); + + file = osync_try_malloc0(sizeof(OSyncFileFormat), error); + if (!file) + goto error; + + osync_marshal_read_string(marshal, &(file->path)); + osync_marshal_read_buffer(marshal, (void *)&(file->data), (int *)&(file->size)); + + *output = (char *)file; + *outpsize = sizeof(OSyncFileFormat); + + osync_trace(TRACE_EXIT, "%s", __func__); + return TRUE; + + error: + + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return FALSE; +} + +osync_bool get_format_info(OSyncFormatEnv *env, OSyncError **error) +{ + OSyncObjFormat *format = osync_objformat_new("file", "data", error); + if (!format) + return FALSE; + + osync_objformat_set_compare_func(format, compare_file); + osync_objformat_set_destroy_func(format, destroy_file); + osync_objformat_set_duplicate_func(format, duplicate_file); + osync_objformat_set_print_func(format, print_file); + osync_objformat_set_revision_func(format, revision_file); + osync_objformat_set_copy_func(format, copy_file); + + osync_objformat_set_marshal_func(format, marshal_file); + osync_objformat_set_demarshal_func(format, demarshal_file); + + osync_format_env_register_objformat(env, format); + osync_objformat_unref(format); + return TRUE; +} + +osync_bool get_conversion_info(OSyncFormatEnv *env, OSyncError **error) +{ + OSyncObjFormat *file = osync_format_env_find_objformat(env, "file"); + OSyncObjFormat *plain = NULL; + OSyncFormatConverter *conv = NULL; + + if (!file) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to find file format"); + return FALSE; + } + + plain = osync_format_env_find_objformat(env, "plain"); + if (!plain) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to find plain format"); + return FALSE; + } + + conv = osync_converter_new(OSYNC_CONVERTER_DECAP, file, plain, conv_file_to_plain, error); + if (!conv) + return FALSE; + + osync_format_env_register_converter(env, conv); + osync_converter_unref(conv); + + conv = osync_converter_new(OSYNC_CONVERTER_ENCAP, plain, file, conv_plain_to_file, error); + if (!conv) + return FALSE; + + osync_format_env_register_converter(env, conv); + osync_converter_unref(conv); + return TRUE; +} + +int get_version(void) +{ + return 1; +} Copied: plugins/file-sync/src/file.h (from r5072, trunk/formats/file.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/file-sync/src/file.h Sat Jan 10 22:31:15 2009 (r5074, copy of r5072, trunk/formats/file.h) @@ -0,0 +1,50 @@ +/* + * opensync - A file format for opensync + * Copyright (C) 2005 Armin Bauer <arm...@op...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 + * + */ + +#ifndef _FILE_H +#define _FILE_H + +#ifndef _WIN32 +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#endif //_WIN32 + +#ifdef _WIN32 +#define mode_t int +#define uid_t int +#define gid_t int +#endif //_WIN32 + +typedef struct OSyncFileFormat { + /** The mode of this file. See man fstat for explanation */ + mode_t mode; + /** The id of the user (owner) of this file */ + uid_t userid; + /** The id of the owning group of this file */ + gid_t groupid; + /** Time of the last modification */ + time_t last_mod; + char *path; + char *data; + unsigned int size; +} OSyncFileFormat; + +#endif //_FILE_H Copied: plugins/file-sync/src/plain.c (from r5072, trunk/formats/plain.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/file-sync/src/plain.c Sat Jan 10 22:31:15 2009 (r5074, copy of r5072, trunk/formats/plain.c) @@ -0,0 +1,184 @@ +/* + * data - A plugin for data objects for the opensync framework + * Copyright (C) 2004-2005 Armin Bauer <arm...@op...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include <string.h> +#include <glib.h> + +#include <opensync/opensync.h> +#include <opensync/opensync-serializer.h> +#include <opensync/opensync-format.h> +#include <opensync/opensync-xmlformat.h> + +static OSyncConvCmpResult compare_plain(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; + if (!rightsize) rightdata = NULL; + + if (!leftdata && !rightdata) + return OSYNC_CONV_DATA_SAME; + + if (leftdata && rightdata && (leftsize == rightsize)) { + if (!memcmp(leftdata, rightdata, leftsize)) + return OSYNC_CONV_DATA_SAME; + else + return OSYNC_CONV_DATA_MISMATCH; + } + + return OSYNC_CONV_DATA_MISMATCH; +} + +static osync_bool copy_plain(const char *input, unsigned int inpsize, char **output, unsigned int *outpsize, void *user_data, OSyncError **error) +{ + char *r = g_malloc0(inpsize); + + memcpy(r, input, inpsize); + *output = r; + *outpsize = inpsize; + return TRUE; +} + +static osync_bool conv_xmlformatnote_to_memo(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *userdata, OSyncError **error) +{ + const char *body = NULL; + OSyncXMLFormat *xmlformat = (OSyncXMLFormat *)input; + OSyncXMLFieldList *xmlfieldlist = osync_xmlformat_search_field(xmlformat, "Description", error, NULL); + OSyncXMLField *xmlfield = osync_xmlfieldlist_item(xmlfieldlist, 0); + + *free_input = TRUE; + if (xmlfield) { + body = osync_xmlfield_get_key_value(xmlfield, "Content"); + } + if (!body) { + body = ""; + } + *output = g_strdup(body); + *outpsize = strlen(body); + return TRUE; +} + +static osync_bool conv_memo_to_xmlformatnote(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *userdata, OSyncError **error) +{ + GString *str; + const char *p; + OSyncXMLFormat *ret = NULL; + OSyncXMLField *field = NULL; + + *free_input = TRUE; + + ret = osync_xmlformat_new("note", error); + if (!ret) + return FALSE; + + if (input && *input) { + field = osync_xmlfield_new(ret, "Description", error); + + str = g_string_new(""); + for (p = input; p && *p; p++) { + switch (*p) { + case '\r': + if (*(p+1) == '\n') + p++; + osync_trace(TRACE_INTERNAL, "[%s] escape carriage returns!!", __func__); + str = g_string_append (str, "\n"); + break; + default: + str = g_string_append_c (str, *p); + break; + } + } + osync_trace(TRACE_SENSITIVE, "Input : %s", str->str); + osync_xmlfield_add_key_value(field, "Content", str->str); + } + + osync_xmlformat_sort(ret); + + *output = (char *)ret; + *outpsize = osync_xmlformat_size(); + return TRUE; +} + +static void destroy_plain(char *input, unsigned int inpsize, void *user_data) +{ + g_free(input); +} + +osync_bool get_format_info(OSyncFormatEnv *env, OSyncError **error) +{ + OSyncObjFormat *format = osync_objformat_new("plain", "data", error); + if (!format) + return FALSE; + + osync_objformat_set_compare_func(format, compare_plain); + osync_objformat_set_copy_func(format, copy_plain); + osync_objformat_set_destroy_func(format, destroy_plain); + + osync_format_env_register_objformat(env, format); + osync_objformat_unref(format); + + /* "memo" is the same as "plain" expect the object type is fixed to "note" */ + format = osync_objformat_new("memo", "note", error); + if (!format) + return FALSE; + + osync_objformat_set_compare_func(format, compare_plain); + osync_objformat_set_copy_func(format, copy_plain); + osync_objformat_set_destroy_func(format, destroy_plain); + + osync_format_env_register_objformat(env, format); + osync_objformat_unref(format); + + return TRUE; +} + +osync_bool get_conversion_info(OSyncFormatEnv *env, OSyncError **error) +{ + OSyncObjFormat *memo = osync_format_env_find_objformat(env, "memo"); + OSyncObjFormat *xmlformatnote = osync_format_env_find_objformat(env, "xmlformat-note"); + OSyncFormatConverter *conv = NULL; + if (!memo) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to find memo format"); + return FALSE; + } + if (!xmlformatnote) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to find xmlformat-note format"); + return FALSE; + } + conv = osync_converter_new(OSYNC_CONVERTER_CONV, xmlformatnote, memo, conv_xmlformatnote_to_memo, error); + if (!conv) + return FALSE; + + osync_format_env_register_converter(env, conv); + osync_converter_unref(conv); + + conv = osync_converter_new(OSYNC_CONVERTER_CONV, memo, xmlformatnote, conv_memo_to_xmlformatnote, error); + if (!conv) + return FALSE; + + osync_format_env_register_converter(env, conv); + osync_converter_unref(conv); + return TRUE; +} + +int get_version(void) +{ + return 1; +} + |
From: <dg...@su...> - 2009-01-10 22:29:23
|
Author: dgollub Date: Sat Jan 10 22:29:58 2009 New Revision: 5073 URL: http://www.opensync.org/changeset/5073 Log: Get a copy of the "plain" plugin. Merging the xmlformat-note <-> memo conversion code. Added: format-plugins/xmlformat/trunk/src/xmlformat_note_memo.c - copied unchanged from r5072, trunk/formats/plain.c Copied: format-plugins/xmlformat/trunk/src/xmlformat_note_memo.c (from r5072, trunk/formats/plain.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ format-plugins/xmlformat/trunk/src/xmlformat_note_memo.c Sat Jan 10 22:29:58 2009 (r5073, copy of r5072, trunk/formats/plain.c) @@ -0,0 +1,184 @@ +/* + * data - A plugin for data objects for the opensync framework + * Copyright (C) 2004-2005 Armin Bauer <arm...@op...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include <string.h> +#include <glib.h> + +#include <opensync/opensync.h> +#include <opensync/opensync-serializer.h> +#include <opensync/opensync-format.h> +#include <opensync/opensync-xmlformat.h> + +static OSyncConvCmpResult compare_plain(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; + if (!rightsize) rightdata = NULL; + + if (!leftdata && !rightdata) + return OSYNC_CONV_DATA_SAME; + + if (leftdata && rightdata && (leftsize == rightsize)) { + if (!memcmp(leftdata, rightdata, leftsize)) + return OSYNC_CONV_DATA_SAME; + else + return OSYNC_CONV_DATA_MISMATCH; + } + + return OSYNC_CONV_DATA_MISMATCH; +} + +static osync_bool copy_plain(const char *input, unsigned int inpsize, char **output, unsigned int *outpsize, void *user_data, OSyncError **error) +{ + char *r = g_malloc0(inpsize); + + memcpy(r, input, inpsize); + *output = r; + *outpsize = inpsize; + return TRUE; +} + +static osync_bool conv_xmlformatnote_to_memo(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *userdata, OSyncError **error) +{ + const char *body = NULL; + OSyncXMLFormat *xmlformat = (OSyncXMLFormat *)input; + OSyncXMLFieldList *xmlfieldlist = osync_xmlformat_search_field(xmlformat, "Description", error, NULL); + OSyncXMLField *xmlfield = osync_xmlfieldlist_item(xmlfieldlist, 0); + + *free_input = TRUE; + if (xmlfield) { + body = osync_xmlfield_get_key_value(xmlfield, "Content"); + } + if (!body) { + body = ""; + } + *output = g_strdup(body); + *outpsize = strlen(body); + return TRUE; +} + +static osync_bool conv_memo_to_xmlformatnote(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *userdata, OSyncError **error) +{ + GString *str; + const char *p; + OSyncXMLFormat *ret = NULL; + OSyncXMLField *field = NULL; + + *free_input = TRUE; + + ret = osync_xmlformat_new("note", error); + if (!ret) + return FALSE; + + if (input && *input) { + field = osync_xmlfield_new(ret, "Description", error); + + str = g_string_new(""); + for (p = input; p && *p; p++) { + switch (*p) { + case '\r': + if (*(p+1) == '\n') + p++; + osync_trace(TRACE_INTERNAL, "[%s] escape carriage returns!!", __func__); + str = g_string_append (str, "\n"); + break; + default: + str = g_string_append_c (str, *p); + break; + } + } + osync_trace(TRACE_SENSITIVE, "Input : %s", str->str); + osync_xmlfield_add_key_value(field, "Content", str->str); + } + + osync_xmlformat_sort(ret); + + *output = (char *)ret; + *outpsize = osync_xmlformat_size(); + return TRUE; +} + +static void destroy_plain(char *input, unsigned int inpsize, void *user_data) +{ + g_free(input); +} + +osync_bool get_format_info(OSyncFormatEnv *env, OSyncError **error) +{ + OSyncObjFormat *format = osync_objformat_new("plain", "data", error); + if (!format) + return FALSE; + + osync_objformat_set_compare_func(format, compare_plain); + osync_objformat_set_copy_func(format, copy_plain); + osync_objformat_set_destroy_func(format, destroy_plain); + + osync_format_env_register_objformat(env, format); + osync_objformat_unref(format); + + /* "memo" is the same as "plain" expect the object type is fixed to "note" */ + format = osync_objformat_new("memo", "note", error); + if (!format) + return FALSE; + + osync_objformat_set_compare_func(format, compare_plain); + osync_objformat_set_copy_func(format, copy_plain); + osync_objformat_set_destroy_func(format, destroy_plain); + + osync_format_env_register_objformat(env, format); + osync_objformat_unref(format); + + return TRUE; +} + +osync_bool get_conversion_info(OSyncFormatEnv *env, OSyncError **error) +{ + OSyncObjFormat *memo = osync_format_env_find_objformat(env, "memo"); + OSyncObjFormat *xmlformatnote = osync_format_env_find_objformat(env, "xmlformat-note"); + OSyncFormatConverter *conv = NULL; + if (!memo) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to find memo format"); + return FALSE; + } + if (!xmlformatnote) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to find xmlformat-note format"); + return FALSE; + } + conv = osync_converter_new(OSYNC_CONVERTER_CONV, xmlformatnote, memo, conv_xmlformatnote_to_memo, error); + if (!conv) + return FALSE; + + osync_format_env_register_converter(env, conv); + osync_converter_unref(conv); + + conv = osync_converter_new(OSYNC_CONVERTER_CONV, memo, xmlformatnote, conv_memo_to_xmlformatnote, error); + if (!conv) + return FALSE; + + osync_format_env_register_converter(env, conv); + osync_converter_unref(conv); + return TRUE; +} + +int get_version(void) +{ + return 1; +} + |
From: <dg...@su...> - 2009-01-10 22:29:22
|
Author: dgollub Date: Sat Jan 10 23:06:42 2009 New Revision: 5077 URL: http://www.opensync.org/changeset/5077 Log: Drop xmlformat-note <-> memo conversion. This will be handled by the xmlformat-plugin. Drop obosolate includes. Modified: plugins/file-sync/src/file.c plugins/file-sync/src/plain.c Modified: plugins/file-sync/src/file.c ============================================================================== --- plugins/file-sync/src/file.c Sat Jan 10 23:00:32 2009 (r5076) +++ plugins/file-sync/src/file.c Sat Jan 10 23:06:42 2009 (r5077) @@ -22,7 +22,6 @@ #include <glib.h> #include <opensync/opensync.h> -#include <opensync/opensync-serializer.h> #include <opensync/opensync-format.h> #include "file.h" Modified: plugins/file-sync/src/plain.c ============================================================================== --- plugins/file-sync/src/plain.c Sat Jan 10 23:00:32 2009 (r5076) +++ plugins/file-sync/src/plain.c Sat Jan 10 23:06:42 2009 (r5077) @@ -22,9 +22,7 @@ #include <glib.h> #include <opensync/opensync.h> -#include <opensync/opensync-serializer.h> #include <opensync/opensync-format.h> -#include <opensync/opensync-xmlformat.h> static OSyncConvCmpResult compare_plain(const char *leftdata, unsigned int leftsize, const char *rightdata, unsigned int rightsize, void *user_data) { @@ -55,66 +53,6 @@ return TRUE; } -static osync_bool conv_xmlformatnote_to_memo(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *userdata, OSyncError **error) -{ - const char *body = NULL; - OSyncXMLFormat *xmlformat = (OSyncXMLFormat *)input; - OSyncXMLFieldList *xmlfieldlist = osync_xmlformat_search_field(xmlformat, "Description", error, NULL); - OSyncXMLField *xmlfield = osync_xmlfieldlist_item(xmlfieldlist, 0); - - *free_input = TRUE; - if (xmlfield) { - body = osync_xmlfield_get_key_value(xmlfield, "Content"); - } - if (!body) { - body = ""; - } - *output = g_strdup(body); - *outpsize = strlen(body); - return TRUE; -} - -static osync_bool conv_memo_to_xmlformatnote(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *userdata, OSyncError **error) -{ - GString *str; - const char *p; - OSyncXMLFormat *ret = NULL; - OSyncXMLField *field = NULL; - - *free_input = TRUE; - - ret = osync_xmlformat_new("note", error); - if (!ret) - return FALSE; - - if (input && *input) { - field = osync_xmlfield_new(ret, "Description", error); - - str = g_string_new(""); - for (p = input; p && *p; p++) { - switch (*p) { - case '\r': - if (*(p+1) == '\n') - p++; - osync_trace(TRACE_INTERNAL, "[%s] escape carriage returns!!", __func__); - str = g_string_append (str, "\n"); - break; - default: - str = g_string_append_c (str, *p); - break; - } - } - osync_trace(TRACE_SENSITIVE, "Input : %s", str->str); - osync_xmlfield_add_key_value(field, "Content", str->str); - } - - osync_xmlformat_sort(ret); - - *output = (char *)ret; - *outpsize = osync_xmlformat_size(); - return TRUE; -} - static void destroy_plain(char *input, unsigned int inpsize, void *user_data) { g_free(input); @@ -148,35 +86,6 @@ return TRUE; } -osync_bool get_conversion_info(OSyncFormatEnv *env, OSyncError **error) -{ - OSyncObjFormat *memo = osync_format_env_find_objformat(env, "memo"); - OSyncObjFormat *xmlformatnote = osync_format_env_find_objformat(env, "xmlformat-note"); - OSyncFormatConverter *conv = NULL; - if (!memo) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to find memo format"); - return FALSE; - } - if (!xmlformatnote) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to find xmlformat-note format"); - return FALSE; - } - conv = osync_converter_new(OSYNC_CONVERTER_CONV, xmlformatnote, memo, conv_xmlformatnote_to_memo, error); - if (!conv) - return FALSE; - - osync_format_env_register_converter(env, conv); - osync_converter_unref(conv); - - conv = osync_converter_new(OSYNC_CONVERTER_CONV, memo, xmlformatnote, conv_memo_to_xmlformatnote, error); - if (!conv) - return FALSE; - - osync_format_env_register_converter(env, conv); - osync_converter_unref(conv); - return TRUE; -} - int get_version(void) { return 1; |