You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
(56) |
Apr
(109) |
May
(15) |
Jun
(3) |
Jul
(37) |
Aug
(96) |
Sep
(40) |
Oct
(4) |
Nov
(54) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(47) |
Feb
(30) |
Mar
(102) |
Apr
(120) |
May
(68) |
Jun
(54) |
Jul
(53) |
Aug
(122) |
Sep
(190) |
Oct
(71) |
Nov
(85) |
Dec
(108) |
2007 |
Jan
(72) |
Feb
(190) |
Mar
(53) |
Apr
(101) |
May
(145) |
Jun
(148) |
Jul
(167) |
Aug
(143) |
Sep
(23) |
Oct
(198) |
Nov
(223) |
Dec
(195) |
2008 |
Jan
(100) |
Feb
(129) |
Mar
(79) |
Apr
(77) |
May
(34) |
Jun
(95) |
Jul
(112) |
Aug
(160) |
Sep
(82) |
Oct
(124) |
Nov
(199) |
Dec
(355) |
2009 |
Jan
(436) |
Feb
(89) |
Mar
(298) |
Apr
(189) |
May
(33) |
Jun
(88) |
Jul
(105) |
Aug
(44) |
Sep
(181) |
Oct
(87) |
Nov
(75) |
Dec
(1) |
2010 |
Jan
(63) |
Feb
(21) |
Mar
(3) |
Apr
(1) |
May
(1) |
Jun
(3) |
Jul
(26) |
Aug
(37) |
Sep
(26) |
Oct
(15) |
Nov
(13) |
Dec
|
From: <svn...@op...> - 2009-11-01 21:46:25
|
Author: scriptor Date: Sun Nov 1 22:46:11 2009 New Revision: 5905 URL: http://www.opensync.org/changeset/5905 Log: I have removed the dependency on libgcrypt. Throughout the ldap_plugin in its current version none of the functions of the md5_crypt.c file is being used (except for ldap_plugin_init_md5(), which is superflous). The hash values are rather taken either from the entryCSN attribute or the modifyTimestamp attribute of an LDAP entry. So no need for md5sum. Deleted: plugins/ldap-sync/src/md5_crypt.c Modified: plugins/ldap-sync/CMakeLists.txt plugins/ldap-sync/src/CMakeLists.txt plugins/ldap-sync/src/ldap_plugin.c plugins/ldap-sync/src/ldap_plugin.h Modified: plugins/ldap-sync/CMakeLists.txt ============================================================================== --- plugins/ldap-sync/CMakeLists.txt Sun Nov 1 22:45:41 2009 (r5904) +++ plugins/ldap-sync/CMakeLists.txt Sun Nov 1 22:46:11 2009 (r5905) @@ -30,6 +30,7 @@ cmake_minimum_required(VERSION 2.4) IF(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) + cmake_policy(SET CMP0010 NEW) ENDIF(COMMAND cmake_policy) # SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) @@ -44,7 +45,6 @@ FIND_PACKAGE( LibXslt REQUIRED ) FIND_PACKAGE( LibLdap ) FIND_PACKAGE( LibMozLdap ) -FIND_PACKAGE( LibGCrypt REQUIRED ) FIND_PACKAGE( LibSASL2 REQUIRED ) FIND_PACKAGE( LibGSSAPIV2 ) FIND_PACKAGE( Check ) Modified: plugins/ldap-sync/src/CMakeLists.txt ============================================================================== --- plugins/ldap-sync/src/CMakeLists.txt Sun Nov 1 22:45:41 2009 (r5904) +++ plugins/ldap-sync/src/CMakeLists.txt Sun Nov 1 22:46:11 2009 (r5905) @@ -118,8 +118,8 @@ INCLUDE( Compiler ) -OPENSYNC_PLUGIN_ADD( ldap-sync ldap_plugin.c ldap_connect.c ldap_sasl.c md5_crypt.c ldap_debug.c) -OPENSYNC_FORMAT_ADD( ldap-format ldap_format.c md5_crypt.c ldap_debug.c) +OPENSYNC_PLUGIN_ADD( ldap-sync ldap_plugin.c ldap_connect.c ldap_sasl.c ldap_debug.c) +OPENSYNC_FORMAT_ADD( ldap-format ldap_format.c ldap_debug.c) Modified: plugins/ldap-sync/src/ldap_plugin.c ============================================================================== --- plugins/ldap-sync/src/ldap_plugin.c Sun Nov 1 22:45:41 2009 (r5904) +++ plugins/ldap-sync/src/ldap_plugin.c Sun Nov 1 22:46:11 2009 (r5905) @@ -4781,10 +4781,6 @@ plugin_env->sink_envs = NULL; - // Initialize gcrypt library - ldap_plugin_init_md5(0); - - // Now we register all of the objtypes that we can sync. sink_environment *contact_env = ldap_plugin_initialize_sink(info, OBJECTTYPE_CONTACT, FORMAT_LDAP_EVOLUTIONPERSON, error); osync_trace(TRACE_INTERNAL, "%s:%i: sink_environment *contact_env = %p", __FILE__, __LINE__, contact_env); Modified: plugins/ldap-sync/src/ldap_plugin.h ============================================================================== --- plugins/ldap-sync/src/ldap_plugin.h Sun Nov 1 22:45:41 2009 (r5904) +++ plugins/ldap-sync/src/ldap_plugin.h Sun Nov 1 22:46:11 2009 (r5905) @@ -542,13 +542,5 @@ int ldap_plugin_lutil_sasl_interact (LDAP *ld, unsigned flags, lutilSASLdefaults *defaults, void *in); - -// md5_crypt.c: -gchar *ldap_plugin_encrypt_md5 (const void *passwd, const size_t size); -gboolean ldap_plugin_init_md5 (gboolean warnings); -char *ldap_plugin_get_hash_from_xmlchars(const xmlChar *mem, const size_t len); -char *ldap_plugin_get_hash_from_xmlinternal(const xmlDoc *xmlcard); - - #endif // #ifndef _LDAP_PLUGIN_H |
From: <svn...@op...> - 2009-11-01 21:45:57
|
Author: scriptor Date: Sun Nov 1 22:45:41 2009 New Revision: 5904 URL: http://www.opensync.org/changeset/5904 Log: When an mkdir command for the trace files fails, this should be a visible error. So that it gets noticed by the user running the tests. Modified: plugins/ldap-sync/tests/check_osynctool_common.inc Modified: plugins/ldap-sync/tests/check_osynctool_common.inc ============================================================================== --- plugins/ldap-sync/tests/check_osynctool_common.inc Sun Nov 1 19:22:17 2009 (r5903) +++ plugins/ldap-sync/tests/check_osynctool_common.inc Sun Nov 1 22:45:41 2009 (r5904) @@ -17,6 +17,14 @@ if test -z "$TRACE_FILES"; then echo -e "\n\n\nGenerating trace files (OSYNC_TRACE, SYNCML_TRACE) has been disabled." return 0; + else + echo -e "\n\n\nCreating directory ${TRACE_FILES}\n\n\n" + mkdir -p "${TRACE_FILES}" + rv=$? + if test $rv -ne 0; then + echo -e "\n\n${FUNCNAME}(): ERROR: mkdir -p has failed. Exiting.\n\n" + exit 1 + fi fi @@ -26,12 +34,22 @@ if test ! -d "$osync_trace_dir"; then mkdir -p "$osync_trace_dir" + rv=$? + if test $rv -ne 0; then + echo -e "\n\n${FUNCNAME}(): ERROR: mkdir -p has failed. Exiting.\n\n" + exit 1 + fi else rm -f ${osync_trace_dir}${PATH_SEPARATOR}Thread* fi if test ! -d "$syncml_trace_dir"; then mkdir -p "$syncml_trace_dir" + rv=$? + if test $rv -ne 0; then + echo -e "\n\n${FUNCNAME}(): ERROR: mkdir -p has failed. Exiting.\n\n" + exit 1 + fi else rm -f ${syncml_trace_dir}${PATH_SEPARATOR}Thread* fi @@ -79,6 +97,11 @@ if test ! -d "$osync_trace_dir"; then mkdir -p "$osync_trace_dir" + rv=$? + if test $rv -ne 0; then + echo -e "\n\n${FUNCNAME}(): ERROR: mkdir -p has failed. Exiting.\n\n" + exit 1 + fi else rm -f ${osync_trace_dir}${PATH_SEPARATOR}Thread* fi @@ -88,6 +111,11 @@ if test ! -d "${new_osync_trace_dir}"; then mkdir -p "${new_osync_trace_dir}" + rv=$? + if test $rv -ne 0; then + echo -e "\n\n${FUNCNAME}(): ERROR: mkdir -p has failed. Exiting.\n\n" + exit 1 + fi else rm -f ${new_osync_trace_dir}${PATH_SEPARATOR}Thread* fi @@ -99,6 +127,11 @@ if test ! -d "$syncml_trace_dir"; then mkdir -p "$syncml_trace_dir" + rv=$? + if test $rv -ne 0; then + echo -e "\n\n${FUNCNAME}(): ERROR: mkdir -p has failed. Exiting.\n\n" + exit 1 + fi else rm -f ${syncml_trace_dir}${PATH_SEPARATOR}Thread* fi @@ -107,6 +140,11 @@ new_syncml_trace_dir="${syncml_trace_dir}${PATH_SEPARATOR}${subdir}" if test ! -d "${new_syncml_trace_dir}"; then mkdir -p "${new_syncml_trace_dir}" + rv=$? + if test $rv -ne 0; then + echo -e "\n\n${FUNCNAME}(): ERROR: mkdir -p has failed. Exiting.\n\n" + exit 1 + fi else rm -f ${new_syncml_trace_dir}${PATH_SEPARATOR}Thread* fi |
From: <svn...@op...> - 2009-11-01 18:22:33
|
Author: dgollub Date: Sun Nov 1 19:22:17 2009 New Revision: 5903 URL: http://www.opensync.org/changeset/5903 Log: Fix memory allocator erros if format example plugin got installed. Allocating size of 0 by osync_try_malloc0 causes: ERROR: No memory left (tried to allocate 0 bytes) Modified: trunk/docs/examples/plugins/src/format.c Modified: trunk/docs/examples/plugins/src/format.c ============================================================================== --- trunk/docs/examples/plugins/src/format.c Sun Nov 1 18:39:06 2009 (r5902) +++ trunk/docs/examples/plugins/src/format.c Sun Nov 1 19:22:17 2009 (r5903) @@ -13,6 +13,10 @@ char *data; } converter_data; +typedef struct format_userdata { + char *data1; + int data2; +} format_userdata; static OSyncConvCmpResult compare_format1(const char *leftdata, unsigned int leftsize, const char *rightdata, unsigned int rightsize, void *data, OSyncError **error) { @@ -145,7 +149,7 @@ * function. If the data should be passes to all format * functions it has to be returned as a pointer. */ - char *format_specific_data = osync_try_malloc0(0, error); + char *format_specific_data = osync_try_malloc0(sizeof(format_userdata), error); return (void *)format_specific_data; } |
From: <svn...@op...> - 2009-11-01 17:39:24
|
Author: henrik Date: Sun Nov 1 18:39:06 2009 New Revision: 5902 URL: http://www.opensync.org/changeset/5902 Log: Rename OSyncConfigurationType to OSyncPluginConfigurationType following latest API change Modified: osynctool/trunk/tools/osynctool.c Modified: osynctool/trunk/tools/osynctool.c ============================================================================== --- osynctool/trunk/tools/osynctool.c Sun Nov 1 18:12:45 2009 (r5901) +++ osynctool/trunk/tools/osynctool.c Sun Nov 1 18:39:06 2009 (r5902) @@ -1112,7 +1112,7 @@ OSyncGroup *group = NULL; OSyncPlugin *plugin = NULL; OSyncPluginConfig *config = NULL; - OSyncConfigurationType type = OSYNC_PLUGIN_NO_CONFIGURATION; + OSyncPluginConfigurationType type = OSYNC_PLUGIN_NO_CONFIGURATION; osync_trace(TRACE_ENTRY, "%s(%p, %p, %s, %s, %p)", __func__, env, pluginenv, groupname, memberid, error); |
From: <svn...@op...> - 2009-11-01 17:12:58
|
Author: henrik Date: Sun Nov 1 18:12:45 2009 New Revision: 5901 URL: http://www.opensync.org/changeset/5901 Log: Until now, the mozilla-sync plugin has been running in the OpenSync process, and accessing the mozilla data in a non-thread-safe way. The mozilla-sync plugin is now replaced by a simple stub, running with OSYNC_START_TYPE_EXTERNAL. See http://old.nabble.com/-trunk--OSYNC_START_TYPE_EXTERNAL-example---OSyncClient-API-changes-ts26137387.html This means, that the bulk of the work is now done in the blueZync plugin, by calling thunderbird --mozilla-sync /path/to/pipe The implementation is still not thread-safe, but with the threading capabilities of Thunderbird 3, it will be possible to make a thread-safe implementation for Thunderbird 3. The blueZync plugin can be found here: http://bluezync.kaarposoft.dk/ Deleted: plugins/mozilla-sync/trunk/CTestConfig.cmake plugins/mozilla-sync/trunk/src/calendar-event.cpp plugins/mozilla-sync/trunk/src/calendar-event.h plugins/mozilla-sync/trunk/src/mozilla-calendar.cpp plugins/mozilla-sync/trunk/src/mozilla-calendar.h plugins/mozilla-sync/trunk/src/mozilla-config.cpp plugins/mozilla-sync/trunk/src/mozilla-config.h plugins/mozilla-sync/trunk/src/mozilla-connect-test.cpp plugins/mozilla-sync/trunk/src/mozilla-headers.h plugins/mozilla-sync/trunk/src/mozilla-sync-utils.h plugins/mozilla-sync/trunk/src/mozilla-sync.h plugins/mozilla-sync/trunk/src/mozilla-utils.cpp plugins/mozilla-sync/trunk/src/mozilla-utils.h plugins/mozilla-sync/trunk/src/mozilla-xpcom.cpp plugins/mozilla-sync/trunk/src/mozilla-xpcom.h plugins/mozilla-sync/trunk/src/nsProfileDirServiceProvider.cpp plugins/mozilla-sync/trunk/src/nsProfileDirServiceProvider.h plugins/mozilla-sync/trunk/src/thunderbird-addressbook.cpp plugins/mozilla-sync/trunk/src/thunderbird-addressbook.h plugins/mozilla-sync/trunk/src/thunderbird-card.cpp plugins/mozilla-sync/trunk/src/thunderbird-card.h plugins/mozilla-sync/trunk/tests/ Modified: plugins/mozilla-sync/trunk/CMakeLists.txt plugins/mozilla-sync/trunk/src/CMakeLists.txt plugins/mozilla-sync/trunk/src/mozilla-sync plugins/mozilla-sync/trunk/src/mozilla-sync.cpp Modified: plugins/mozilla-sync/trunk/CMakeLists.txt ============================================================================== --- plugins/mozilla-sync/trunk/CMakeLists.txt Sun Nov 1 17:26:59 2009 (r5900) +++ plugins/mozilla-sync/trunk/CMakeLists.txt Sun Nov 1 18:12:45 2009 (r5901) @@ -40,23 +40,8 @@ SET( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${DESTDIR}${CMAKE_INSTALL_PREFIX}/share/libopensync1/cmake/modules/" "${CMAKE_SOURCE_DIR}/cmake/modules" ) FIND_PACKAGE( GLIB2 2.14 REQUIRED) -FIND_PACKAGE( LibXml2 REQUIRED ) FIND_PACKAGE( OpenSync REQUIRED ) -FIND_PACKAGE( ThunderbirdXpcom REQUIRED ) -STRING (REGEX REPLACE "^([0-9]+)\\.([0-9]+)$" "\\1\\2" _CALENDAR_VERSION "${SUNBIRD_VERSION}" ) -STRING (REGEX REPLACE "^0*([0-9]+)$" "\\1" CALENDAR_VERSION "${_CALENDAR_VERSION}" ) -MESSAGE ( "CALENDAR_VERSION=[${CALENDAR_VERSION}]" ) - -### SEEMS THAT WE CANNOT LINK TO GLUE SINCE IT IS NOT THREAD SAFE, AND WE WILL SEGFAULT -SET(XPCOM_GLUE FALSE) - -IF (XPCOM_GLUE) - ADD_DEFINITIONS( -DXPCOM_GLUE ) - SET( XPCOM_LIBRARIES /home/henrik/my/software/gecko-sdk/lib/libxpcomglue.a ) -ELSE (XPCOM_GLUE) -# SET( XPCOM_LIBRARIES ${LIBTBXPCOM_XPCOM} ) -ENDIF (XPCOM_GLUE) INCLUDE( OpenSyncInternal ) @@ -65,15 +50,6 @@ ADD_SUBDIRECTORY( src ) -MESSAGE ( "ENABLE_TESTING [${ENABLE_TESTING}]" ) -IF( ENABLE_TESTING ) - MESSAGE( "TESTING ENABLED" ) - ENABLE_TESTING() - INCLUDE( Dart ) - FIND_PACKAGE( Check REQUIRED ) - ADD_SUBDIRECTORY( tests ) -ENDIF ( ENABLE_TESTING ) - # cmake is great. but four back-slashes to escape a dot? Go figure... SET ( CPACK_SOURCE_IGNORE_FILES "\\\\.svn/;.*~" ) @@ -88,3 +64,4 @@ # For debugging... #INCLUDE ( CMakePrintSystemInformation ) + Modified: plugins/mozilla-sync/trunk/src/CMakeLists.txt ============================================================================== --- plugins/mozilla-sync/trunk/src/CMakeLists.txt Sun Nov 1 17:26:59 2009 (r5900) +++ plugins/mozilla-sync/trunk/src/CMakeLists.txt Sun Nov 1 18:12:45 2009 (r5901) @@ -22,84 +22,26 @@ # ================================================================ -MESSAGE("LIBTBXPCOM_INCLUDE_DIR ${LIBTBXPCOM_INCLUDE_DIR}") -MESSAGE("XPCOM_LIBRARIES ${XPCOM_LIBRARIES}") - -#ADD_DEFINITIONS( -Wall ) -#ADD_DEFINITIONS( -fdiagnostics-show-option ) - -ADD_DEFINITIONS ( -DCALENDAR_VERSION="${CALENDAR_VERSION}" ) - INCLUDE_DIRECTORIES( ${OPENSYNC_INCLUDE_DIRS} - ${XPCOM_INCLUDE_DIRS} - ${LIBXML2_INCLUDE_DIRS} - ${GLIB2_INCLUDE_DIRS} - ${ICAL_INCLUDE_DIRS} ) + ${GLIB2_INCLUDE_DIRS} +) LINK_DIRECTORIES( ${OPENSYNC_LIBRARY_DIRS} - ${XPCOM_LIBRARY_DIRS} - ${LIBXML2_LIBRARY_DIRS} ${GLIB2_LIBRARY_DIRS} - ${ICAL_LIBRARY_DIRS} ) - -SET( COMMON_SOURCE_FILES - mozilla-config.cpp - mozilla-utils.cpp - mozilla-xpcom.cpp - nsProfileDirServiceProvider.cpp - thunderbird-card.cpp - thunderbird-addressbook.cpp - mozilla-calendar.cpp - calendar-event.cpp -) -###### PLUGIN ################### - - -OPENSYNC_PLUGIN_ADD( mozilla-sync ${COMMON_SOURCE_FILES} mozilla-sync.cpp ) + ) -IF (XPCOM_GLUE) - SET_TARGET_PROPERTIES(mozilla-sync PROPERTIES SKIP_BUILD_RPATH yes) -ENDIF (XPCOM_GLUE) - -MESSAGE ( STATUS "XPCOM_LIBRARIES=[${XPCOM_LIBRARIES}]" ) -TARGET_LINK_LIBRARIES( mozilla-sync - ${OPENSYNC_LIBRARIES} ${XPCOM_LIBRARIES} - ${ICAL_LIBRARIES} ${LIBXML2_LIBRARIES} ${GLIB2_LIBRARIES} ) -#SET_TARGET_PROPERTIES(mozilla-sync PROPERTIES LINK_FLAGS "-rdynamic -Wl,--export-dynamic") -#SET_TARGET_PROPERTIES(mozilla-sync PROPERTIES LINKER_LANGUAGE C) -#SET_TARGET_PROPERTIES(mozilla-sync PROPERTIES LINK_FLAGS "-lstdc++") +OPENSYNC_PLUGIN_ADD( mozilla-sync mozilla-sync.cpp ) -###### PLUGIN ################### - OPENSYNC_PLUGIN_DESCRIPTIONS( mozilla-sync-desc.xml ) OPENSYNC_PLUGIN_CAPABILITIES( mozilla-sync-caps.xml ) OPENSYNC_PLUGIN_CONFIG( mozilla-sync ) OPENSYNC_PLUGIN_INSTALL( mozilla-sync ) - -###### CONNECTION TEST ################### - -# ### TODO ### -# mozilla-connect-test does not handle the new configuration format - -# With this we get some logging on stdout from nsProfileDirServiceProvider -#ADD_DEFINITIONS( -DNSPROFILEDIRSERVICEPROVIDER_DEBUG ) - -#ADD_EXECUTABLE (mozilla-connect-test ${COMMON_SOURCE_FILES} mozilla-connect-test.cpp) - -### WE MUST NOT HAVE -rdynamic OR EVERYTING WILL FAIL WITH SEGMENTATION FAULT -#SET( CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") - -#IF (XPCOM_GLUE) -# SET_TARGET_PROPERTIES(mozilla-connect-test PROPERTIES SKIP_BUILD_RPATH yes) -#ENDIF (XPCOM_GLUE) - -#TARGET_LINK_LIBRARIES( mozilla-connect-test -# ${XPCOM_LIBRARIES} -# ${ICAL_LIBRARIES} ${LIBXML2_LIBRARIES} ${GLIB2_LIBRARIES} ) +TARGET_LINK_LIBRARIES( mozilla-sync + ${OPENSYNC_LIBRARIES} ${GLIB2_LIBRARIES} ) Modified: plugins/mozilla-sync/trunk/src/mozilla-sync ============================================================================== --- plugins/mozilla-sync/trunk/src/mozilla-sync Sun Nov 1 17:26:59 2009 (r5900) +++ plugins/mozilla-sync/trunk/src/mozilla-sync Sun Nov 1 18:12:45 2009 (r5901) @@ -8,36 +8,16 @@ <config> -<AdvancedOptions> - - <AdvancedOption> - <!-- profile-directory is where the user's thunderbird profile lives. - Use the full pathname. Tilde ~ is *not* recognized. - Remove or leave blank to have mozilla-sync try to find - default profile directory automatically. --> - - <DisplayName>Profile directory</DisplayName> - <Name>profile-directory</Name> - <Type>string</Type> - <Value>/home/someone/.thunderbird/ab1cde23</Value> - </AdvancedOption> - -</AdvancedOptions> - - <Resources> <Resource> - <!-- addressbook-file is the name of the addressbook file. - Should have .mab extension. - Relative to profile-directory --> <Enabled>1</Enabled> <Formats> <Format> <Name>xmlformat-contact</Name> </Format> </Formats> - <Name>abook.mab</Name> + <Name>MyAddressBook</Name> <ObjType>contact</ObjType> </Resource> @@ -63,5 +43,8 @@ </Resources> +<ExternalPlugin> + <ExternalCommand>thunderbird -mozilla-sync %s</ExternalCommand> +</ExternalPlugin> </config> Modified: plugins/mozilla-sync/trunk/src/mozilla-sync.cpp ============================================================================== --- plugins/mozilla-sync/trunk/src/mozilla-sync.cpp Sun Nov 1 17:26:59 2009 (r5900) +++ plugins/mozilla-sync/trunk/src/mozilla-sync.cpp Sun Nov 1 18:12:45 2009 (r5901) @@ -30,61 +30,17 @@ ================================================================ */ -/** @mainpage - -Clickable map of main parts: - -@dot -digraph G -{ - rankdir = BT; - - edge [color="midnightblue"]; - node [fontname="FreeSans.ttf",fontsize=10,shape=record]; - - n1 [label="mozilla-sync", URL="\ref mozilla-sync.cpp"]; - n11 [label="mozilla-config", URL="\ref mozilla-config.cpp"]; - n11 -> n1; - n12 [label="mozilla-xpcom", URL="\ref mozilla-xpcom.cpp"]; - n12 -> n1; - n121 [label="nsProfileDirServiceProvider", URL="\ref nsProfileDirServiceProvider"]; - n121 -> n12; - n13 [label="ThunderbirdAddressbook",URL="\ref ThunderbirdAddressbook"]; - n13 -> n1; - n131 [label="ThunderbirdCard", URL="\ref ThunderbirdCard"]; - n131 -> n13; - n14 [label="MozillaCalendar",URL="\ref MozillaCalendar"]; - n14 -> n1; - n141 [label="calendar-event", URL="\ref calendar-event.cpp"]; - n141 -> n14; -} -@enddot - -**/ - #include <stdlib.h> #include <stdio.h> #include <string.h> -#include "mozilla-headers.h" +#include <glib.h> #include <opensync/opensync.h> -#include <opensync/opensync-format.h> #include <opensync/opensync-plugin.h> #include <opensync/opensync-version.h> -#include <opensync/opensync-data.h> -#include <opensync/opensync-helper.h> -#include <opensync/opensync-capabilities.h> -#include <opensync/opensync-xmlformat.h> - -#include "thunderbird-card.h" -#include "calendar-event.h" -#include "thunderbird-addressbook.h" -#include "mozilla-calendar.h" -#include "mozilla-xpcom.h" -#include "mozilla-sync.h" #ifdef _WIN32 #ifndef __func__ @@ -123,16 +79,6 @@ osync_trace(TRACE_EXIT, "%s(%d)%s: %s", g_basename(__FILE__), __LINE__, __func__, __szMsg); \ g_free(__szMsg); } } -#define LOG_EXIT_ERROR_SZ(level, message) { \ - osync_trace(TRACE_EXIT_ERROR, "%s(%d)%s: %s", g_basename(__FILE__), __LINE__, __func__, message); \ - osync_error_set(ppOSyncError, OSYNC_ERROR_GENERIC, message); \ - ERR_PRINTF("%s(%d)%s: ****** %s\n", g_basename(__FILE__), __LINE__, __func__, message); } - -#define LOG_EXIT_ERROR_OSYNC(level, ppOSyncError) { \ - const char *__szOErr=""; \ - if (ppOSyncError) __szOErr=osync_error_print_stack(ppOSyncError); \ - osync_trace(TRACE_EXIT_ERROR, "%s(%d)%s: %s", g_basename(__FILE__), __LINE__, __func__, __szOErr); \ - ERR_PRINTF("%s(%d)%s: ****** %s\n", g_basename(__FILE__), __LINE__, __func__, __szOErr); } #define LOG_EXIT_ERROR_OSYNC_SZ(level, ppOSyncError, message) { \ const char *__szOErr=""; \ @@ -140,992 +86,18 @@ osync_trace(TRACE_EXIT_ERROR, "%s(%d)%s: %s: %s", g_basename(__FILE__), __LINE__, __func__, message, __szOErr); \ ERR_PRINTF("%s(%d)%s: ****** %s\n", g_basename(__FILE__), __LINE__, __func__, __szOErr); } -#define LOG_EXIT_REPORT_ERROR_SZ(level, context, message) { \ - ERR_PRINTF("%s(%d)%s: ****** %s\n", g_basename(__FILE__), __LINE__, __func__, message); \ - OSyncError *__pError = NULL; \ - osync_error_set(&__pError, OSYNC_ERROR_GENERIC, message); \ - osync_context_report_osyncerror(context, __pError); \ - osync_trace(TRACE_EXIT_ERROR, "%s(%d)%s: %s", g_basename(__FILE__), __LINE__, __func__, message); } - -#define LOG_EXIT_REPORT_ERROR_MSG(level, context, message, ...) { \ - if (level<=LOGLEVEL) { \ - char *__szMsg=g_strdup_printf(message,## __VA_ARGS__); \ - ERR_PRINTF("%s(%d)%s: ****** %s\n", g_basename(__FILE__), __LINE__, __func__, __szMsg); \ - OSyncError *__pError = NULL; \ - osync_error_set(&__pError, OSYNC_ERROR_GENERIC, __szMsg); \ - osync_context_report_osyncerror(context, __pError); \ - osync_trace(TRACE_EXIT_ERROR, __szMsg); \ - g_free(__szMsg); } } - - -#define LOG_EXIT_REPORT_ERROR_OSYNC(level, context, pError) { \ - const char *__szOErr=""; \ - if (pError) __szOErr=osync_error_print_stack(&pError); \ - ERR_PRINTF("%s(%d)%s: ****** %s\n", g_basename(__FILE__), __LINE__, __func__, __szOErr); \ - osync_context_report_osyncerror(context, pError); \ - osync_trace(TRACE_EXIT_ERROR, "%s(%d)%s: %s", g_basename(__FILE__), __LINE__, __func__, __szOErr); } - -#define GFREE(p) { if (p) g_free(p); } - -// TODO: osync_error_unref(ppOSyncError); - - -// ------------------------------------------------------------ -/** Function to log output from child functions called - @param level Log level - @param sensitive True if output could contain personal info - @param szFile Name of file we are logging from - @param iLine Line number in szFile - @param szFunc Name of function we are logging from - @param szFormat format specifier and arguments for vprintf -**/ -void logFunction(int level, bool sensitive, const char* szFile, int iLine, const char *szFunc, const char* szFormat, ...) { - if (level>LOGLEVEL) return; - va_list ap; - va_start(ap, szFormat); - char *__szMsg=g_strdup_vprintf(szFormat, ap); - OSyncTraceType t=TRACE_INTERNAL; - if (sensitive) t=TRACE_SENSITIVE; - -#ifdef WIN32 - char *_szFile=g_strdup(szFile); - osync_trace(TRACE_INTERNAL, "%s(%d)%s: %s", g_basename(_szFile), iLine, szFunc, __szMsg); - g_free(_szFile); -#else - osync_trace(TRACE_INTERNAL, "%s(%d)%s: %s", g_basename(szFile), iLine, szFunc, __szMsg); -#endif - - g_free(__szMsg); - va_end(ap); -} - extern "C" { -// ---------------------------------------- -/** @brief Report address book changes since last sync into the hash-table provided - - @param pOSyncMozillaDatabase The database we have to report on - @param pOSyncPluginInfo On entry we have what we gave in get_sync_info. - @param pOSyncContext The context of the connect (e.g. to report error) - @param pHashTable The hash table to report changes into - @return TRUE on success; FALSE on error -**/ -gboolean mozilla_sync_report_addressbook_changes_to_hash( - OSyncMozillaDatabase *pOSyncMozillaDatabase, - OSyncPluginInfo *pOSyncPluginInfo, - OSyncContext *pOSyncContext, - OSyncHashTable *pHashTable) { - - LOG_ENTRY(10, "(%p, %p, %p)", pOSyncMozillaDatabase, pOSyncPluginInfo, pOSyncContext); - - if (pOSyncMozillaDatabase->iMozillaDatabaseType!=MOZILLA_DATABASE_TYPE_ADDRESSBOOK) { - LOG_EXIT_REPORT_ERROR_SZ(10, pOSyncContext, - g_strdup_printf("Expected MOZILLA_DATABASE_TYPE_ADDRESSBOOK; got [%d]", pOSyncMozillaDatabase->iMozillaDatabaseType)); - return FALSE; - } - - OSyncError *pError = NULL; - ThunderbirdAddressbook *pAB = pOSyncMozillaDatabase->pThunderbirdAddressbook; - - char *szError=NULL; - if (!pAB->CardFirst(&szError, &logFunction)) - { LOG_EXIT_REPORT_ERROR_SZ(10, pOSyncContext, szError); return FALSE; } - - if (pAB->CardDone()) { - LOG(10, "No address cards in address book"); - } else { - while(!pAB->CardDone()) { - - // Get information on the current card - ThunderbirdCard *pCard=pAB->CardCurrent(); - char *szKey=pCard->GetKey(pAB->myAddrDatabase, &szError, &logFunction); - if (!szKey) { LOG_EXIT_REPORT_ERROR_SZ(0, pOSyncContext, szError); return FALSE; } - char *szHash=pCard->GetHash(&szError, &logFunction); - if (!szHash) { LOG_EXIT_REPORT_ERROR_SZ(0, pOSyncContext, szError); return FALSE; } - - // Now get ready to describe the change - OSyncChange *pChange = osync_change_new(&pError); - if (!pChange) { - LOG_EXIT_REPORT_ERROR_OSYNC(0, pOSyncContext, pError); - return FALSE; - } - - // Identify the change - osync_change_set_uid(pChange, szKey); - osync_change_set_hash(pChange, szHash); - OSyncChangeType type = osync_hashtable_get_changetype(pHashTable, pChange); - osync_change_set_changetype(pChange, type); - osync_hashtable_update_change(pHashTable, pChange); - g_free(szHash); - g_free(szKey); - - if (type != OSYNC_CHANGE_TYPE_UNMODIFIED) { - - // Let's be sure we have the right format - const char *szExpectedFormat="xmlformat-contact"; - if (strcmp(pOSyncMozillaDatabase->szObjformat, szExpectedFormat)!=0) { - LOG_EXIT_REPORT_ERROR_SZ(0, pOSyncContext, - g_strdup_printf("Wrong object format. OSyncMozillaDatabase says [%s], we wanted [%s]", - pOSyncMozillaDatabase->szObjformat,szExpectedFormat)); - return FALSE; } - - // Get the format - OSyncObjFormat *pOSyncObjFormat = - osync_format_env_find_objformat(pOSyncMozillaDatabase->pOSyncMozillaEnv->pOSyncFormatEnv, - pOSyncMozillaDatabase->szObjformat); - if (!pOSyncObjFormat) { - LOG_EXIT_REPORT_ERROR_SZ(0, pOSyncContext, "Could not get OSyncObjFormat"); - return FALSE; } - - - char *szXML=pCard->GetXML(&szError, &logFunction); - LOG(20, "The xml of the card"); - LOG_SENSITIVE(20, "%s", szXML); - if (!szXML) { LOG_EXIT_REPORT_ERROR_SZ(0, pOSyncContext, szError); return FALSE; } - //OSyncXMLFormat *pXMLFormat = osync_xmlformat_new(pOSyncMozillaDatabase->szObjformat, &pError); - - OSyncXMLFormat *pXMLFormat = osync_xmlformat_parse(szXML, strlen(szXML), &pError); - if (!pXMLFormat) { - LOG_EXIT_REPORT_ERROR_OSYNC(0, pOSyncContext, pError); - return FALSE; - } - if (!osync_xmlformat_sort(pXMLFormat, &pError)) { - LOG_EXIT_REPORT_ERROR_OSYNC(0, pOSyncContext, pError); - return FALSE; - } - GFREE(szXML); - OSyncData *odata = NULL; - - odata = osync_data_new((char*)pXMLFormat, osync_xmlformat_size(), pOSyncObjFormat, &pError); - - if (!odata) { - LOG_EXIT_REPORT_ERROR_OSYNC(0, pOSyncContext, pError); - return FALSE; - } - //if (!odata) { - //osync_change_unref(change); - //osync_context_report_osyncwarning(ctx, error); - //osync_error_unref(&error); - //g_free(data); - // continue; - //} - - osync_change_set_objtype(pChange, osync_objtype_sink_get_name(pOSyncMozillaDatabase->pOSyncObjTypeSink)); - osync_data_set_objtype(odata, osync_objtype_sink_get_name(pOSyncMozillaDatabase->pOSyncObjTypeSink)); - - - - // Report the change - osync_change_set_data(pChange, odata); - osync_data_unref(odata); - osync_context_report_change(pOSyncContext, pChange); - } - - osync_change_unref(pChange); - if (!pAB->CardNext(&szError, &logFunction)) - { LOG_EXIT_REPORT_ERROR_SZ(10, pOSyncContext, szError); return FALSE; } - } - } - - LOG_EXIT(10, "TRUE"); - return TRUE; - -} - - -// ---------------------------------------- -/** @brief Report calendar changes since last sync into the provided hash table - - @todo mozilla_sync_report_calendar_changes_to_hash and mozilla_sync_report_addressbook_changes_to_hash - are quite similar. Could we merge them? - - @param pOSyncMozillaDatabase The database we have to report on - @param pOSyncPluginInfo On entry we have what we gave in get_sync_info. - @param pOSyncContext The context of the connect (e.g. to report error) - @param pHashTable The hash table to report changes into - @return TRUE on success; FALSE on error -**/ -gboolean mozilla_sync_report_calendar_changes_to_hash( - OSyncMozillaDatabase *pOSyncMozillaDatabase, - OSyncPluginInfo *pOSyncPluginInfo, - OSyncContext *pOSyncContext, - OSyncHashTable *pHashTable) { - - LOG_ENTRY(10, "(%p, %p, %p)", pOSyncMozillaDatabase, pOSyncPluginInfo, pOSyncContext); - - if (pOSyncMozillaDatabase->iMozillaDatabaseType!=MOZILLA_DATABASE_TYPE_CALENDAR) { - LOG_EXIT_REPORT_ERROR_SZ(10, pOSyncContext, - g_strdup_printf("Expected MOZILLA_DATABASE_TYPE_CALENDAR; got [%d]", pOSyncMozillaDatabase->iMozillaDatabaseType)); - return FALSE; - } - OSyncError *pError = NULL; - MozillaCalendar *pCal = pOSyncMozillaDatabase->pMozillaCalendar; - - char *szError=NULL; - if (!pCal->EventFirst(&szError, &logFunction)) - { LOG_EXIT_REPORT_ERROR_SZ(10, pOSyncContext, szError); return FALSE; } - - if (pCal->EventDone()) { - LOG(10, "No events in calendar"); - } else { - while(!pCal->EventDone()) { - - // Get information on the current event - - char *szKey; - char *szHash; - char *szTitle; - - gboolean f; - f=pCal->CurrentKeyHashTitle(&szKey, &szHash, &szTitle, &szError, &logFunction); - if (!f) { - LOG_EXIT_REPORT_ERROR_OSYNC(0, pOSyncContext, pError); - return FALSE; - } - - // Now get ready to describe the change - OSyncChange *pChange = osync_change_new(&pError); - if (!pChange) { - LOG_EXIT_REPORT_ERROR_OSYNC(0, pOSyncContext, pError); - return FALSE; - } - - // Identify the change - osync_change_set_uid(pChange, szKey); - osync_change_set_hash(pChange, szHash); - OSyncChangeType type = osync_hashtable_get_changetype(pHashTable, pChange); - osync_change_set_changetype(pChange, type); - osync_hashtable_update_change(pHashTable, pChange); - g_free(szHash); - - // Bail out if no changes - if (type == OSYNC_CHANGE_TYPE_UNMODIFIED) { - LOG(20, "key=[%s] hash=[%s]", szKey, szHash); - LOG_SENSITIVE(20, "key=[%s] hash=[%s] title=[%s] UNMODIFIED", szKey, szHash, szTitle); - if (!pCal->EventNext(&szError, &logFunction)) - { LOG_EXIT_REPORT_ERROR_SZ(10, pOSyncContext, szError); return FALSE; } - continue; - } - - // Let's be sure we have the right format - const char *szExpectedFormat="vevent20"; - if (strcmp(pOSyncMozillaDatabase->szObjformat, szExpectedFormat)!=0) { - LOG_EXIT_REPORT_ERROR_SZ(0, pOSyncContext, - g_strdup_printf("Wrong object format. OSyncMozillaDatabase says [%s], we wanted [%s]", - pOSyncMozillaDatabase->szObjformat,szExpectedFormat)); - return FALSE; } - - // Get the format - OSyncObjFormat *pOSyncObjFormat = - osync_format_env_find_objformat(pOSyncMozillaDatabase->pOSyncMozillaEnv->pOSyncFormatEnv, - pOSyncMozillaDatabase->szObjformat); - if (!pOSyncObjFormat) { - LOG_EXIT_REPORT_ERROR_SZ(0, pOSyncContext, "Could not get OSyncObjFormat"); - return FALSE; } - - - char *szICS=pCal->CurrentICS(&szError, &logFunction); - LOG_SENSITIVE(30, "%s", szICS); - if (!szICS) { LOG_EXIT_REPORT_ERROR_SZ(0, pOSyncContext, szError); return FALSE; } - - OSyncData *odata = NULL; - odata = osync_data_new(szICS, strlen(szICS), pOSyncObjFormat, &pError); - - if (!odata) { - LOG_EXIT_REPORT_ERROR_OSYNC(0, pOSyncContext, pError); - return FALSE; - } - - osync_change_set_objtype(pChange, osync_objtype_sink_get_name(pOSyncMozillaDatabase->pOSyncObjTypeSink)); - osync_data_set_objtype(odata, osync_objtype_sink_get_name(pOSyncMozillaDatabase->pOSyncObjTypeSink)); - - - // Report the change - osync_change_set_data(pChange, odata); - osync_data_unref(odata); - osync_context_report_change(pOSyncContext, pChange); - osync_change_unref(pChange); - if (!pCal->EventNext(&szError, &logFunction)) - { LOG_EXIT_REPORT_ERROR_SZ(10, pOSyncContext, szError); return FALSE; } - } - } - - LOG_EXIT(10, "TRUE"); - return TRUE; - -} - - -// ---------------------------------------- -/** @brief Get changes since last sync (or all changes on slow sync) - - @param data The OSyncMozillaEnv - @param pOSyncObjTypeSink The ObjectType sink we shall get changes for. - @param pOSyncPluginInfo On entry we have what we gave in get_sync_info. - @param pOSyncContext The context of the connect (e.g. to report error) - @param fSlow True if we are doing a slow sync, meaning we want to get *all* changes -**/ -static void mozilla_sync_get_changes( - OSyncObjTypeSink* pOSyncObjTypeSink, - OSyncPluginInfo *pOSyncPluginInfo, - OSyncContext *pOSyncContext, - osync_bool fSlow, - void *data) -{ - LOG_ENTRY(10, "(%p, %p, %p, %d, %p)", pOSyncObjTypeSink, pOSyncPluginInfo, pOSyncContext, fSlow, data); - OSyncMozillaDatabase *pOSyncMozillaDatabase = (OSyncMozillaDatabase*) data; - int i = 0; - OSyncError *pError = NULL; - - OSyncHashTable *pHashTable = osync_objtype_sink_get_hashtable(pOSyncObjTypeSink); - // Thank you Michael Bell for corrections - if (fSlow) { - osync_trace(TRACE_INTERNAL, "Slow sync requested"); - if (!osync_hashtable_slowsync(pHashTable, &pError)) - { - osync_context_report_osyncerror(pOSyncContext, pError); - osync_trace(TRACE_EXIT_ERROR, "%s - %s", __func__, osync_error_print_stack(&pError)); - osync_error_unref(&pError); - return; - } - } - - LOG(10, "Getting changes for [%s]", osync_objtype_sink_get_name(pOSyncObjTypeSink)); - - gboolean f; - - if (pOSyncMozillaDatabase->iMozillaDatabaseType==MOZILLA_DATABASE_TYPE_ADDRESSBOOK) { - f=mozilla_sync_report_addressbook_changes_to_hash(pOSyncMozillaDatabase, pOSyncPluginInfo, pOSyncContext, pHashTable); - } else if (pOSyncMozillaDatabase->iMozillaDatabaseType==MOZILLA_DATABASE_TYPE_CALENDAR) { - f=mozilla_sync_report_calendar_changes_to_hash(pOSyncMozillaDatabase, pOSyncPluginInfo, pOSyncContext, pHashTable); - } else { - LOG_EXIT_REPORT_ERROR_SZ(10, pOSyncContext, "Unknown iMozillaDatabaseType"); return; - } - - if (!f) return; - - OSyncObjFormat *pOSyncObjFormat = - osync_format_env_find_objformat(pOSyncMozillaDatabase->pOSyncMozillaEnv->pOSyncFormatEnv, - pOSyncMozillaDatabase->szObjformat); - if (!pOSyncObjFormat) { - LOG_EXIT_REPORT_ERROR_SZ(0, pOSyncContext, "Could not get OSyncObjFormat"); - return; } - - - LOG(10, "Checking for deleted [%s]", osync_objtype_sink_get_name(pOSyncObjTypeSink)); - - OSyncList *u; - OSyncList *uids = osync_hashtable_get_deleted(pHashTable); - for (u = uids; u; u = u->next) { - OSyncChange *change = osync_change_new(&pError); - if (!change) { - LOG_EXIT_REPORT_ERROR_OSYNC(0, pOSyncContext, pError); - osync_error_unref(&pError); - continue; - } - const char *uid = (const char*) u->data; - - osync_change_set_uid(change, uid); - osync_change_set_changetype(change, OSYNC_CHANGE_TYPE_DELETED); - - OSyncData *odata = osync_data_new(NULL, 0, pOSyncObjFormat, &pError); - if (!odata) { - LOG_EXIT_REPORT_ERROR_OSYNC(0, pOSyncContext, pError); - osync_change_unref(change); - osync_error_unref(&pError); - continue; - } - - osync_data_set_objtype(odata, osync_objtype_sink_get_name(pOSyncMozillaDatabase->pOSyncObjTypeSink)); - osync_change_set_data(change, odata); - osync_data_unref(odata); - - osync_context_report_change(pOSyncContext, change); - - osync_hashtable_update_change(pHashTable, change); - - osync_change_unref(change); - } - osync_list_free(uids); - - osync_context_report_success(pOSyncContext); - LOG(10, "Done getting changes for [%s]", osync_objtype_sink_get_name(pOSyncObjTypeSink)); - LOG_EXIT(10, "void"); -} - - -// ---------------------------------------- -/** @brief Commit change into Mozilla calendar - - @param pCalendar The calendar to commit the change into - @param changeType The type of change as reported by OpenSync - @param szKey The key of the mozilla addressbook card - @param szXML The full XML representation of the mozilla addressbook card - @param pHT Pointer to hash table to update - @param pOSyncContext The context of the connect (e.g. to report error) - @param pChange The change we shall commit - -**/ -static gboolean mozilla_sync_commit_calendar_change( - MozillaCalendar *pCalendar, - OSyncChangeType changeType, - const char *szKey, - const char *szXML, - OSyncHashTable *pHT, - OSyncContext *pOSyncContext, - OSyncChange *pChange) -{ - - LOG_ENTRY(10, "(%p, %d, %s, %p, %p, %p)", pCalendar, changeType, szKey, pHT, pOSyncContext, pChange); - LOG_SENSITIVE(10, "szXML=[%s]", szXML); - gboolean f; - char *szError=NULL; - char *szNewKey=NULL; - char *szNewHash=NULL; - if (changeType==OSYNC_CHANGE_TYPE_ADDED) { - f=pCalendar->AddEvent(szXML, &szNewKey, &szNewHash, &szError, &logFunction); - LOG(10, "Adding key=[%s] hash=[%s] to hash table", szNewKey, szNewHash); - if (!f) { LOG_EXIT_REPORT_ERROR_SZ(0, pOSyncContext, szError); return FALSE; } - /* Inform OpenSync about the new ID */ - - osync_change_set_uid(pChange, szNewKey); - osync_change_set_hash(pChange, szNewHash); - osync_hashtable_update_change(pHT, pChange); - - GFREE(szNewKey); GFREE(szNewHash); - } - - else if (changeType==OSYNC_CHANGE_TYPE_MODIFIED) { - - f=pCalendar->ModifyEvent(szKey, szXML, &szNewHash, &szError, &logFunction); - if (!f) { LOG_EXIT_REPORT_ERROR_SZ(0, pOSyncContext, szError); return FALSE; } - - LOG(10, "Modifying key=[%s] hash=[%s] in hash table", szKey, szNewHash); - // %%%%%%%%%% %%%%%%%%%% - osync_change_set_hash(pChange, szNewHash); - osync_hashtable_update_change(pHT, pChange); - - } - - else if (changeType==OSYNC_CHANGE_TYPE_DELETED) { - f=pCalendar->DeleteEvent(szKey, &szError, &logFunction); - if (!f) { LOG_EXIT_REPORT_ERROR_SZ(0, pOSyncContext, szError); return FALSE; } - - osync_hashtable_update_change(pHT, pChange); - } - - LOG_EXIT(10, "TRUE"); - return TRUE; -} - -// ---------------------------------------- -/** @brief Commit change into thunderbird - - @param pThunderbirdAddressbook The address book to commit the change into - @param changeType The type of change as reported by OpenSync - @param szKey The key of the mozilla addressbook card - @param szXML The full XML representation of the mozilla addressbook card - @param pHT Pointer to hash table to update - @param pOSyncContext The context of the connect (e.g. to report error) - @param pChange The change we shall commit -**/ -static gboolean mozilla_sync_commit_addressbook_change( - ThunderbirdAddressbook *pThunderbirdAddressbook, - OSyncChangeType changeType, - const char *szKey, - const char *szXML, - OSyncHashTable *pHT, - OSyncContext *pOSyncContext, - OSyncChange *pChange) -{ - LOG_ENTRY(10, "(%p, %d, %s, %p, %p, %p)", pThunderbirdAddressbook, changeType, szKey, pHT, pOSyncContext, pChange); - LOG_SENSITIVE(10, "szXML=[%s]", szXML); - - gboolean f; - char *szError=NULL; - if (changeType==OSYNC_CHANGE_TYPE_ADDED) { - ThunderbirdCard *pCard = new ThunderbirdCard(); - f=pCard->CreateFromXML(szXML, &szError, &logFunction); - if (!f) { LOG_EXIT_REPORT_ERROR_SZ(0, pOSyncContext, szError); return FALSE; } - f=pThunderbirdAddressbook->AddCard(pCard, &szError, &logFunction); - if (!f) { LOG_EXIT_REPORT_ERROR_SZ(0, pOSyncContext, szError); return FALSE; } - char *szKey=pCard->GetKey(pThunderbirdAddressbook->myAddrDatabase, &szError, &logFunction); - if (!szKey) { LOG_EXIT_REPORT_ERROR_SZ(0, pOSyncContext, szError); return FALSE; } - char *szHash=pCard->GetHash(&szError, &logFunction); - if (!szHash) { LOG_EXIT_REPORT_ERROR_SZ(0, pOSyncContext, szError); return FALSE; } - - osync_change_set_uid(pChange, szKey); - osync_change_set_hash(pChange, szHash); - osync_hashtable_update_change(pHT, pChange); - - GFREE(szKey); GFREE(szHash); - delete pCard; - - } - else if (changeType==OSYNC_CHANGE_TYPE_MODIFIED) { - // %%%%%%%%%% %%%%%%%%%% - char *szHash; - f=pThunderbirdAddressbook->ModifyCardFromXML(szKey, szXML, &szHash, &szError, &logFunction); - osync_change_set_hash(pChange, szHash); - if (!f) { LOG_EXIT_REPORT_ERROR_SZ(0, pOSyncContext, szError); return FALSE; } - GFREE(szHash); - } - else if (changeType==OSYNC_CHANGE_TYPE_DELETED) { - f=pThunderbirdAddressbook->DeleteCard(szKey, &szError, &logFunction); - if (!f) { LOG_EXIT_REPORT_ERROR_SZ(0, pOSyncContext, szError); return FALSE; } - - osync_hashtable_update_change(pHT, pChange); - - } - - - LOG_EXIT(10, "TRUE"); - return TRUE; -} - -// ---------------------------------------- -/** @brief Commit change - - @param data The OSyncMozillaEnv - @param pOSyncObjTypeSink The ObjectType sink we shall commit the change into. - @param pOSyncPluginInfo On entry we have what we gave in get_sync_info. - @param pOSyncContext The context of the connect (e.g. to report error) - @param pChange The change we shall commit -**/ -static void mozilla_sync_commit_change( - OSyncObjTypeSink* pOSyncObjTypeSink, - OSyncPluginInfo *pOSyncPluginInfo, - OSyncContext *pOSyncContext, - OSyncChange *pChange, void *data) -{ - LOG_ENTRY(10, "(%p, %p, %p, %p)", pOSyncObjTypeSink, pOSyncPluginInfo, pOSyncContext, data); - - - // Log what we are about to do - OSyncChangeType changeType = osync_change_get_changetype(pChange); - const char *szKey = osync_change_get_uid(pChange); - switch (changeType) { - case OSYNC_CHANGE_TYPE_ADDED: - LOG(10, "Adding new"); - break; - case OSYNC_CHANGE_TYPE_MODIFIED: - LOG(10, "Modifying [%s]", szKey); - break; - case OSYNC_CHANGE_TYPE_DELETED: - LOG(10, "Deleting [%s]", szKey); - break; - default: - LOG_EXIT_REPORT_ERROR_SZ(0, pOSyncContext, "Unknown change type"); - return; - break; - } - - - OSyncMozillaDatabase *pOSyncMozillaDatabase = (OSyncMozillaDatabase*) data; - OSyncHashTable *pHT = osync_objtype_sink_get_hashtable(pOSyncObjTypeSink); - - gboolean f; - OSyncError *pError = NULL; - - OSyncData *pOSyncData=osync_change_get_data(pChange); - if (!pOSyncData) { LOG_EXIT_REPORT_ERROR_SZ(10, pOSyncContext, "Change has no data"); return; } - void *pVoidBuffer; - unsigned int uiSize; - osync_data_get_data(pOSyncData, (char**) &pVoidBuffer, &uiSize); - - OSyncObjFormat *pOSyncObjFormat=osync_change_get_objformat(pChange); - const char *szObjFormat=osync_objformat_get_name(pOSyncObjFormat); - LOG(10, "ObjFormat [%s]", szObjFormat); - - if (pOSyncMozillaDatabase->iMozillaDatabaseType==MOZILLA_DATABASE_TYPE_ADDRESSBOOK) { - if (changeType != OSYNC_CHANGE_TYPE_DELETED) - if (strcmp(szObjFormat, "xmlformat-contact")) - { LOG_EXIT_REPORT_ERROR_MSG(10, pOSyncContext, - "Invalid object format [%s]; expected [xmlformat-contact]", szObjFormat); return; } - char *szXML=NULL; - if ( (changeType==OSYNC_CHANGE_TYPE_ADDED) || (changeType==OSYNC_CHANGE_TYPE_MODIFIED) ) { - OSyncXMLFormat *pXMLFormat = (OSyncXMLFormat *)pVoidBuffer; - unsigned int size; - if (!osync_xmlformat_assemble(pXMLFormat, &szXML, &size, &pError)) { - LOG_EXIT_REPORT_ERROR_OSYNC(0, pOSyncContext, pError); - return; - } - if (!osync_xmlformat_sort(pXMLFormat, &pError)) { - LOG_EXIT_REPORT_ERROR_OSYNC(0, pOSyncContext, pError); - return; - } - LOG_SENSITIVE(1000, "%s", szXML); - } - ThunderbirdAddressbook *pAB = pOSyncMozillaDatabase->pThunderbirdAddressbook; - f=mozilla_sync_commit_addressbook_change(pAB, changeType, szKey, szXML, pHT, pOSyncContext, pChange); - } else if (pOSyncMozillaDatabase->iMozillaDatabaseType==MOZILLA_DATABASE_TYPE_CALENDAR) { - if (changeType != OSYNC_CHANGE_TYPE_DELETED) - if (strcmp(szObjFormat, "vevent20")) - { LOG_EXIT_REPORT_ERROR_MSG(10, pOSyncContext, - "Invalid object format [%s]; expected [vevent20]", szObjFormat); return; } - MozillaCalendar *pCal = pOSyncMozillaDatabase->pMozillaCalendar; - f=mozilla_sync_commit_calendar_change(pCal, changeType, szKey, (const char*) pVoidBuffer, pHT, pOSyncContext, pChange); - } else { - LOG_EXIT_REPORT_ERROR_SZ(10, pOSyncContext, "Unknown iMozillaDatabaseType"); return; - } - - if (f) osync_context_report_success(pOSyncContext); - LOG_EXIT(10, "void"); -} - -// ---------------------------------------- -/** @brief Called when sync is complete - - @param data The OSyncMozillaEnv - @param pOSyncObjTypeSink The ObjectType sink for which the sync is complete. - @param pOSyncPluginInfo On entry we have what we gave in get_sync_info. - @param pOSyncContext The context (e.g. to report error) -**/ -static void mozilla_sync_done(OSyncObjTypeSink* pOSyncObjTypeSink, - OSyncPluginInfo *pOSyncPluginInfo, - OSyncContext *pOSyncContext, - void *data) -{ - LOG_ENTRY(10, "(%p, %p, %p)", pOSyncPluginInfo, pOSyncContext, data); - - OSyncMozillaDatabase *db = (OSyncMozillaDatabase*) data; - - OSyncError *error = NULL; - - LOG(10, "Updating anchor to value [%s]", db->szAnchorValue); - OSyncSinkStateDB *pStateDB = osync_objtype_sink_get_state_db(pOSyncObjTypeSink); - if (!osync_sink_state_set(pStateDB, db->szAnchorKey, db->szAnchorValue, &error)) { - osync_context_report_osyncerror(pOSyncContext, error); - LOG_EXIT_ERROR_OSYNC_SZ(10, &error, "Could not do osync_anchor_update"); - return; } - - osync_context_report_success(pOSyncContext); - LOG_EXIT(10, "void"); -} - - -// ---------------------------------------- -/** @brief Connect to sink - - @param data The OSyncMozillaEnv - @param pOSyncObjTypeSink The ObjectType sink we shall try to connect to. - @param pOSyncPluginInfo On entry we have what we gave in get_sync_info. - @param pOSyncContext The context of the connect (e.g. to report error) -**/ -static void mozilla_sync_connect( - OSyncObjTypeSink* pOSyncObjTypeSink, - OSyncPluginInfo *pOSyncPluginInfo, - OSyncContext *pOSyncContext, - void *data) -{ - - LOG_ENTRY(10, "(%p, %p, %p, %p)", pOSyncObjTypeSink, pOSyncPluginInfo, pOSyncContext, data); - - OSyncError *error = NULL; - - OSyncMozillaDatabase *db = (OSyncMozillaDatabase*) data; - OSyncMozillaEnv *env = db->pOSyncMozillaEnv; - - // TODO: Check the exact meaning of each timeout, and ajust accordingly - osync_objtype_sink_set_getchanges_timeout(pOSyncObjTypeSink, 4*60); // 4 minutes - osync_objtype_sink_set_commit_timeout(pOSyncObjTypeSink, 4*60); // 4 minutes - osync_objtype_sink_set_committedall_timeout(pOSyncObjTypeSink, 4*60); // 4 minutes - osync_objtype_sink_set_syncdone_timeout(pOSyncObjTypeSink, 4*60); // 4 minutes - osync_objtype_sink_set_read_timeout(pOSyncObjTypeSink, 4*60); // 4 minutes - - - osync_objtype_sink_enable_state_db(pOSyncObjTypeSink, TRUE); - OSyncSinkStateDB *pStateDB = osync_objtype_sink_get_state_db(pOSyncObjTypeSink); - osync_bool same; - if (!osync_sink_state_equal(pStateDB, db->szAnchorKey, db->szAnchorValue, &same, &error)) { - osync_context_report_osyncerror(pOSyncContext, error); - LOG_EXIT_ERROR_OSYNC_SZ(10, &error, "Could not do osync_anchor_compare"); - return; } - - if (same) { - LOG(10, "Anchor matches; so do not force slow sync"); - } else { - LOG(10, "Anchor does not match; so force slow sync"); - osync_context_report_slowsync(pOSyncContext); - } - - LOG(10, "Initializing Mozilla"); - gboolean f; - char *szError=NULL; - - f=mozilla_startup( - env->mozillaConfig.szProfileDirectory, - &(env->xpcomWasStarted), - &szError, &logFunction); - if (!f) { LOG_EXIT_REPORT_ERROR_SZ(10, pOSyncContext, szError); return; } - - if (db->iMozillaDatabaseType==MOZILLA_DATABASE_TYPE_ADDRESSBOOK) { - LOG(10, "Initializing Thunderbird address book"); - db->pThunderbirdAddressbook=new ThunderbirdAddressbook; - f=db->pThunderbirdAddressbook->Init(env->mozillaConfig.szAddressbookFile, &szError, &logFunction); - if (!f) { LOG_EXIT_REPORT_ERROR_SZ(10, pOSyncContext, szError); return; } - } else if (db->iMozillaDatabaseType==MOZILLA_DATABASE_TYPE_CALENDAR) { - LOG(10, "Initializing Mozilla calendar"); - db->pMozillaCalendar=new MozillaCalendar; - f=db->pMozillaCalendar->Init(env->mozillaConfig.szCalendarId, &szError, &logFunction); - if (!f) { LOG_EXIT_REPORT_ERROR_SZ(10, pOSyncContext, szError); return; } - } else { - LOG_EXIT_REPORT_ERROR_SZ(10, pOSyncContext, "Unknown iMozillaDatabaseType"); return; - } - - osync_context_report_success(pOSyncContext); - LOG_EXIT(10, "void"); -} - -// ---------------------------------------- -/** @brief Disconnect from sink - - @param data The OSyncMozillaEnv - @param pOSyncObjTypeSink The ObjectType sink we shall disconnect from. - @param pOSyncPluginInfo On entry we have what we gave in get_sync_info. - @param pOSyncContext The context of the connect (e.g. to report error) -**/ -static void mozilla_sync_disconnect( - OSyncObjTypeSink* pOSyncObjTypeSink, - OSyncPluginInfo *pOSyncPluginInfo, - OSyncContext *pOSyncContext, - void *data) -{ - LOG_ENTRY(10, "(%p, %p, %p, %p)", pOSyncObjTypeSink, pOSyncPluginInfo, pOSyncContext, data); - - OSyncMozillaDatabase *db = (OSyncMozillaDatabase*) data; - OSyncMozillaEnv *env = db->pOSyncMozillaEnv; - - LOG(10, "Finalizing Thunderbird"); - gboolean f; - char *szError=NULL; - f=db->pThunderbirdAddressbook->Close(&szError, &logFunction); - if (!f) { LOG_EXIT_REPORT_ERROR_SZ(10, pOSyncContext, szError); return; } - - if (env->xpcomWasStarted) { - LOG(10, "NOT finalizing Mozilla"); - } else { - LOG(10, "Finalizing Mozilla"); - f=mozilla_shutdown(&szError, &logFunction); - if (!f) { LOG_EXIT_REPORT_ERROR_SZ(10, pOSyncContext, szError); return; } - } - - osync_context_report_success(pOSyncContext); - - LOG_EXIT(10, "void"); - -} - - -// ---------------------------------------- -/** @brief Discover sinks - - Here we actually tell opensync which sinks are available. - For this plugin, we go through the list of databases and enable all, since all have been configured. - - @param data The OSyncMozillaEnv - @param pOSyncPluginInfo On entry we have what we gave in get_sync_info. - @param ppOSyncError Fill out in case of error -**/ -static osync_bool mozilla_sync_discover(OSyncPluginInfo *pOSyncPluginInfo, void *data, OSyncError **ppOSyncError) -{ - LOG_ENTRY(10, "(%p, %p, %p)", data, pOSyncPluginInfo, ppOSyncError); - - if (!data) { - LOG_EXIT(10, "We where called with data=NULL, so we can do nothing"); - return TRUE; - } - - OSyncMozillaEnv *env = (OSyncMozillaEnv *)data; - GList *o = env->pGListMozillaDatabases; - for (; o; o = o->next) { - OSyncMozillaDatabase *db = (OSyncMozillaDatabase*) o->data; - if (db->pOSyncObjTypeSink) { - const char *szSinkName = osync_objtype_sink_get_name(db->pOSyncObjTypeSink); - osync_objtype_sink_set_available(db->pOSyncObjTypeSink, TRUE); - } - } - - OSyncVersion *version = osync_version_new(ppOSyncError); - if (!version) - { LOG_EXIT_ERROR_OSYNC_SZ(10, ppOSyncError, "Could not get osync_version_new"); return FALSE; } - osync_version_set_plugin(version, "mozilla-sync"); - osync_version_set_vendor(version, "KaarPoSoft"); - //osync_version_set_modelversion(version, "version"); - //osync_version_set_firmwareversion(version, "firmwareversion"); - //osync_version_set_softwareversion(version, "softwareversion"); - //osync_version_set_hardwareversion(version, "hardwareversion"); - osync_plugin_info_set_version(pOSyncPluginInfo, version); - osync_version_unref(version); - - LOG_EXIT(10, "TRUE"); - return TRUE; -} - - -// ---------------------------------------- -/** @brief initialize use of the mozilla-sync plugin - - In initialize, we get and parse the config for the plugin. - Here we also must register all _possible_ objtype sinks - - @param pOSyncPlugin Not used - @param pOSyncPluginInfo On entry we have what we gave in get_sync_info. Now TODO - @param ppOSyncError Fill out in case of error -**/ static void *mozilla_sync_initialize(OSyncPlugin *pOSyncPlugin, OSyncPluginInfo *pOSyncPluginInfo, OSyncError **ppOSyncError) { - LOG_ENTRY(10, "(%p, %p, %p)",pOSyncPlugin, pOSyncPluginInfo, ppOSyncError); - - LOG(10, "Initial"); - - OSyncPluginConfig *pOSyncPluginConfig = NULL; - - LOG(10, "Initializing OSyncMozillaEnv"); - OSyncMozillaEnv *pOSyncMozillaEnv = (OSyncMozillaEnv*)osync_try_malloc0(sizeof(OSyncMozillaEnv), ppOSyncError); - if (!pOSyncMozillaEnv) - { LOG_EXIT_ERROR_OSYNC_SZ(10, ppOSyncError, "Could not create OSyncMozillaEnv"); return NULL; } - memset(pOSyncMozillaEnv, 0, sizeof(OSyncMozillaEnv)); - pOSyncMozillaEnv->pOSyncFormatEnv = osync_plugin_info_get_format_env(pOSyncPluginInfo); - - LOG(10, "Reading configuration"); - - pOSyncPluginConfig=osync_plugin_info_get_config(pOSyncPluginInfo); - gboolean f; - char *szError=NULL; - f=mozilla_config_extract(pOSyncPluginConfig, &(pOSyncMozillaEnv->mozillaConfig), &szError, &logFunction); - if (!f) { LOG_EXIT_ERROR_SZ(10, szError); return NULL; } - f=mozilla_config_check( &(pOSyncMozillaEnv->mozillaConfig), &szError, &logFunction); - if (!f) { LOG_EXIT_ERROR_SZ(10, szError); return NULL; } - - - osync_plugin_set_initialize_timeout(pOSyncPlugin, 3*60); // 3 minutes - osync_plugin_set_finalize_timeout(pOSyncPlugin, 3*60); // 3 minutes - - OSyncMozillaDatabase *pOSyncMozillaDatabase; - - if (pOSyncMozillaEnv->mozillaConfig.szAddressbookFile) { - LOG(10, "Creating OSyncMozillaDatabase for Thunderbird addressbook"); - pOSyncMozillaDatabase=(OSyncMozillaDatabase*)osync_try_malloc0(sizeof(OSyncMozillaDatabase), ppOSyncError); - memset(pOSyncMozillaDatabase, 0, sizeof(OSyncMozillaDatabase)); - if (!pOSyncMozillaDatabase) - { LOG_EXIT_ERROR_OSYNC_SZ(10, ppOSyncError, "Could not create OSyncMozillaDatabase"); return NULL; } - - - pOSyncMozillaDatabase->iMozillaDatabaseType=MOZILLA_DATABASE_TYPE_ADDRESSBOOK; - pOSyncMozillaDatabase->pOSyncMozillaEnv=pOSyncMozillaEnv; - pOSyncMozillaDatabase->szAnchorKey="ThunderbirdAddressbook"; - pOSyncMozillaDatabase->szAnchorValue= - g_strjoin(G_DIR_SEPARATOR_S, pOSyncMozillaDatabase->pOSyncMozillaEnv->mozillaConfig.szProfileDirectory, - pOSyncMozillaDatabase->pOSyncMozillaEnv->mozillaConfig.szAddressbookFile, NULL); - pOSyncMozillaDatabase->szObjtype=g_strdup("contact"); - pOSyncMozillaDatabase->szObjformat=g_strdup("xmlformat-contact"); - - pOSyncMozillaEnv->pGListMozillaDatabases=NULL; - pOSyncMozillaEnv->pGListMozillaDatabases=g_list_append(pOSyncMozillaEnv->pGListMozillaDatabases, pOSyncMozillaDatabase); - } - - - if (pOSyncMozillaEnv->mozillaConfig.szCalendarId) { - LOG(10, "Creating OSyncMozillaDatabase for Sunbird/Lightning calendar"); - pOSyncMozillaDatabase=(OSyncMozillaDatabase*)osync_try_malloc0(sizeof(OSyncMozillaDatabase), ppOSyncError); - memset(pOSyncMozillaDatabase, 0, sizeof(OSyncMozillaDatabase)); - if (!pOSyncMozillaDatabase) - { LOG_EXIT_ERROR_OSYNC_SZ(10, ppOSyncError, "Could not create OSyncMozillaDatabase"); return NULL; } - - pOSyncMozillaDatabase->iMozillaDatabaseType=MOZILLA_DATABASE_TYPE_CALENDAR; - pOSyncMozillaDatabase->pOSyncMozillaEnv=pOSyncMozillaEnv; - pOSyncMozillaDatabase->szAnchorKey="MozillaCalendar"; - pOSyncMozillaDatabase->szAnchorValue= - g_strjoin(G_DIR_SEPARATOR_S, pOSyncMozillaDatabase->pOSyncMozillaEnv->mozillaConfig.szProfileDirectory, - pOSyncMozillaDatabase->pOSyncMozillaEnv->mozillaConfig.szCalendarId, NULL); - pOSyncMozillaDatabase->szObjtype=g_strdup("event"); - pOSyncMozillaDatabase->szObjformat=g_strdup("vevent20"); - - pOSyncMozillaEnv->pGListMozillaDatabases=g_list_append(pOSyncMozillaEnv->pGListMozillaDatabases, pOSyncMozillaDatabase); - } - - - /* Now we register the objtypes that we can sync. */ - LOG(10, "Configuring formats for OSyncMozillaDatabases"); - int i=0; - GList *o = pOSyncMozillaEnv->pGListMozillaDatabases; - for (; o; o = o->next, i++) { - LOG(10, "Configuring formats for OSyncMozillaDatabase #%d", i); - OSyncMozillaDatabase *db = (OSyncMozillaDatabase*) o->data; - - OSyncObjTypeSink *sink = osync_plugin_info_find_objtype(pOSyncPluginInfo, db->szObjtype); - if (!sink) { - LOG(0, "Group is not configured to handle object type [%s], although mozilla-sync is!", db->szObjtype); - osync_objtype_sink_unref(sink); - continue; - } - - // Request state database functionality from OpenSync - osync_objtype_sink_enable_state_db(sink, TRUE); - - // Request a hashtable from OpenSync - osync_objtype_sink_enable_hashtable(sink, TRUE); - - // TODO: Check the exact meaning of each timeout, and ajust accordingly - osync_objtype_sink_set_connect_timeout(sink, 5*60); // 4 minutes - osync_objtype_sink_set_disconnect_timeout(sink, 5*60); // 4 minutes - osync_objtype_sink_set_getchanges_timeout(sink, 5*60); // 4 minutes - osync_objtype_sink_set_commit_timeout(sink, 5*60); // 4 minutes - osync_objtype_sink_set_committedall_timeout(sink, 5*60); // 4 minutes - osync_objtype_sink_set_syncdone_timeout(sink, 5*60); // 4 minutes - osync_objtype_sink_set_read_timeout(sink, 5*60); // 4 minutes - - db->pOSyncObjTypeSink = sink; - - osync_objtype_sink_set_connect_func(sink, mozilla_sync_connect); - osync_objtype_sink_set_get_changes_func(sink, mozilla_sync_get_changes); - osync_objtype_sink_set_commit_func(sink, mozilla_sync_commit_change); - osync_objtype_sink_set_sync_done_func(sink, mozilla_sync_done); - - osync_objtype_sink_set_userdata(sink, db); - - } - - LOG_EXIT(10, "(%p)", pOSyncMozillaEnv); - return (void*) pOSyncMozillaEnv; - return NULL; } - -void freeMozillaDatabase(void* voidOSyncMozillaDatabase, void* notused) { - OSyncMozillaDatabase *pDB=(OSyncMozillaDatabase*) voidOSyncMozillaDatabase; - - if (pDB->iMozillaDatabaseType==MOZILLA_DATABASE_TYPE_ADDRESSBOOK) { - if (pDB->pThunderbirdAddressbook) delete pDB->pThunderbirdAddressbook; - } else if (pDB->iMozillaDatabaseType==MOZILLA_DATABASE_TYPE_CALENDAR) { - if (pDB->pMozillaCalendar) delete pDB->pMozillaCalendar; - } -} - - -// ---------------------------------------- -/** @brief finalize use of the mozilla-sync plugin - - Simply free the mozilla-sync environment - - @param data The OSyncMozillaEnv -**/ static void mozilla_sync_finalize(void *data) { - LOG_ENTRY(10, "(%p)", data); - OSyncMozillaEnv *pOSyncMozillaEnv = (OSyncMozillaEnv*) data; - if (pOSyncMozillaEnv) { - // Hope OpenSync is freeing pOSyncFormatEnv - g_list_foreach(pOSyncMozillaEnv->pGListMozillaDatabases, freeMozillaDatabase, NULL); - free(pOSyncMozillaEnv); - } - LOG_EXIT(10, ""); } - // ---------------------------------------- /** @brief register the mozilla-sync plugin @@ -1144,14 +116,11 @@ osync_plugin_set_name(pOSyncPlugin, "mozilla-sync"); osync_plugin_set_longname(pOSyncPlugin, "Mozilla Synchronization Plugin"); osync_plugin_set_description(pOSyncPlugin, "Synchronize with Mozilla (moz-abdirectory)"); + osync_plugin_set_start_type(pOSyncPlugin, OSYNC_START_TYPE_EXTERNAL); osync_plugin_set_config_type(pOSyncPlugin, OSYNC_PLUGIN_NEEDS_CONFIGURATION); osync_plugin_set_initialize(pOSyncPlugin, mozilla_sync_initialize); osync_plugin_set_finalize(pOSyncPlugin, mozilla_sync_finalize); - osync_plugin_set_discover(pOSyncPlugin, mozilla_sync_discover); - - osync_plugin_set_initialize_timeout(pOSyncPlugin, 5*60); // 3 minutes - osync_plugin_set_finalize_timeout(pOSyncPlugin, 5*60); // 3 minutes osync_bool f; f=osync_plugin_env_register_plugin(pOSyncPluginEnv, pOSyncPlugin, ppOSyncError); @@ -1177,3 +146,4 @@ } } // extern "C" + |
From: <svn...@op...> - 2009-11-01 16:27:13
|
Author: bricks Date: Sun Nov 1 17:26:59 2009 New Revision: 5900 URL: http://www.opensync.org/changeset/5900 Log: fixed some compiler warnings and indentation Modified: trunk/docs/examples/plugins/src/external_demo.c Modified: trunk/docs/examples/plugins/src/external_demo.c ============================================================================== --- trunk/docs/examples/plugins/src/external_demo.c Sun Nov 1 17:24:51 2009 (r5899) +++ trunk/docs/examples/plugins/src/external_demo.c Sun Nov 1 17:26:59 2009 (r5900) @@ -126,15 +126,15 @@ osync_client_set_plugin(client, plugin); - printf("[EXTERNAL-DEMO]: OSyncPlugin:%p OSyncClient:%p\n", __func__, plugin, client); - printf("[EXTERNAL-DEMO]: Starting (blocking) OSyncClient ...\n", __func__, plugin, client); + printf("[EXTERNAL-DEMO]: %s OSyncPlugin:%p OSyncClient:%p\n", __func__, plugin, client); + printf("[EXTERNAL-DEMO]: Starting (blocking) OSyncClient ...\n"); - if (!osync_client_run_and_block(client, &error)) + if (!osync_client_run_and_block(client, &error)) goto error; - printf("[EXTERNAL-DEMO]: OSyncClient completed.", __func__, plugin, client); + printf("[EXTERNAL-DEMO]: OSyncClient completed."); - osync_client_unref(client); + osync_client_unref(client); return 0; |
From: <svn...@op...> - 2009-11-01 16:25:05
|
Author: bricks Date: Sun Nov 1 17:24:51 2009 New Revision: 5899 URL: http://www.opensync.org/changeset/5899 Log: renamed OSyncConfigurationType to OSyncPluginConfigurationType Modified: trunk/opensync/plugin/opensync_plugin.c trunk/opensync/plugin/opensync_plugin.h trunk/opensync/plugin/opensync_plugin_private.h Modified: trunk/opensync/plugin/opensync_plugin.c ============================================================================== --- trunk/opensync/plugin/opensync_plugin.c Sun Nov 1 16:42:50 2009 (r5898) +++ trunk/opensync/plugin/opensync_plugin.c Sun Nov 1 17:24:51 2009 (r5899) @@ -124,13 +124,13 @@ plugin->plugin_data = data; } -OSyncConfigurationType osync_plugin_get_config_type(OSyncPlugin *plugin) +OSyncPluginConfigurationType osync_plugin_get_config_type(OSyncPlugin *plugin) { osync_assert(plugin); return plugin->config_type; } -void osync_plugin_set_config_type(OSyncPlugin *plugin, OSyncConfigurationType config_type) +void osync_plugin_set_config_type(OSyncPlugin *plugin, OSyncPluginConfigurationType config_type) { osync_assert(plugin); plugin->config_type = config_type; Modified: trunk/opensync/plugin/opensync_plugin.h ============================================================================== --- trunk/opensync/plugin/opensync_plugin.h Sun Nov 1 16:42:50 2009 (r5898) +++ trunk/opensync/plugin/opensync_plugin.h Sun Nov 1 17:24:51 2009 (r5899) @@ -76,7 +76,7 @@ OSYNC_PLUGIN_OPTIONAL_CONFIGURATION = 1, /** Plugin must be configured to run correctly */ OSYNC_PLUGIN_NEEDS_CONFIGURATION = 2 -} OSyncConfigurationType; +} OSyncPluginConfigurationType; /** @brief Registers a new plugin * @@ -155,14 +155,14 @@ * @param plugin Pointer to the plugin * @returns The configuration requirement type of the plugin */ -OSYNC_EXPORT OSyncConfigurationType osync_plugin_get_config_type(OSyncPlugin *plugin); +OSYNC_EXPORT OSyncPluginConfigurationType osync_plugin_get_config_type(OSyncPlugin *plugin); /** @brief Sets whether or not the plugin requires configuration * * @param plugin Pointer to the plugin * @param type The configuration requirement type of the plugin */ -OSYNC_EXPORT void osync_plugin_set_config_type(OSyncPlugin *plugin, OSyncConfigurationType type); +OSYNC_EXPORT void osync_plugin_set_config_type(OSyncPlugin *plugin, OSyncPluginConfigurationType type); /** @brief Returns start type of plugin Modified: trunk/opensync/plugin/opensync_plugin_private.h ============================================================================== --- trunk/opensync/plugin/opensync_plugin_private.h Sun Nov 1 16:42:50 2009 (r5898) +++ trunk/opensync/plugin/opensync_plugin_private.h Sun Nov 1 17:24:51 2009 (r5899) @@ -62,7 +62,7 @@ usable_fn useable; /** Does the plugin have configuration options? */ - OSyncConfigurationType config_type; + OSyncPluginConfigurationType config_type; /** The start type of the plugin. Thread, Process or External. */ OSyncStartType start_type; /** The timeout values of the plugin functions */ |
From: <svn...@op...> - 2009-11-01 15:43:12
|
Author: dgollub Date: Sun Nov 1 16:42:50 2009 New Revision: 5898 URL: http://www.opensync.org/changeset/5898 Log: Retrieve the external_command directly in _osync_engine_initialize_member() since this function honors the OSyncConfigurationType or if the plugin already has a configuration. Another reason is that this avoids too many calls of osync_member_get_config_or_default() Modified: trunk/opensync/engine/opensync_engine.c trunk/opensync/group/opensync_member.c trunk/opensync/group/opensync_member_internals.h Modified: trunk/opensync/engine/opensync_engine.c ============================================================================== --- trunk/opensync/engine/opensync_engine.c Sun Nov 1 16:01:04 2009 (r5897) +++ trunk/opensync/engine/opensync_engine.c Sun Nov 1 16:42:50 2009 (r5898) @@ -734,6 +734,7 @@ OSyncPluginConfig *config = NULL; OSyncPlugin *plugin = NULL; OSyncClientProxy *proxy = NULL; + const char *external_command = NULL; osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, engine, member, error); @@ -773,9 +774,26 @@ osync_client_proxy_set_context(proxy, engine->context); osync_client_proxy_set_change_callback(proxy, _osync_engine_receive_change, engine); - const char *external_command=NULL; - if (osync_plugin_get_start_type(plugin)==OSYNC_START_TYPE_EXTERNAL) - external_command=osync_member_get_external_command(member); + if (osync_plugin_get_start_type(plugin) == OSYNC_START_TYPE_EXTERNAL) { + + + /* First try to get the indiviual external_command from the member plugin configuration */ + if (config) { + OSyncPluginExternalPlugin *externalplugin = osync_plugin_config_get_externalplugin(config); + + if (externalplugin) + external_command = osync_plugin_externalplugin_get_external_command(externalplugin); + + } + + /* If no PluginConfig specific external_command got set, use the default external-plugin config + * command, if available + */ + if (!external_command) { + /* TODO: Grahams code to retrieve the external_command from the external-plugin config */ + } + + } if (!osync_client_proxy_spawn(proxy, osync_plugin_get_start_type(plugin), osync_member_get_configdir(member), external_command, error)) goto error_free_proxy; Modified: trunk/opensync/group/opensync_member.c ============================================================================== --- trunk/opensync/group/opensync_member.c Sun Nov 1 16:01:04 2009 (r5897) +++ trunk/opensync/group/opensync_member.c Sun Nov 1 16:42:50 2009 (r5898) @@ -832,18 +832,6 @@ return new_list; } -const char *osync_member_get_external_command(OSyncMember *member) -{ - osync_assert(member); - OSyncError *error = NULL; - OSyncPluginConfig *config = osync_member_get_config_or_default(member, &error); - if (config) { - OSyncPluginExternalPlugin *externalplugin = osync_plugin_config_get_externalplugin(config); - if (externalplugin) return osync_plugin_externalplugin_get_external_command(externalplugin); - } - return NULL; -} - osync_bool osync_member_objtype_enabled(OSyncMember *member, const char *objtype) { OSyncObjTypeSink *sink = NULL; Modified: trunk/opensync/group/opensync_member_internals.h ============================================================================== --- trunk/opensync/group/opensync_member_internals.h Sun Nov 1 16:01:04 2009 (r5897) +++ trunk/opensync/group/opensync_member_internals.h Sun Nov 1 16:42:50 2009 (r5898) @@ -184,25 +184,6 @@ */ OSYNC_TEST_EXPORT osync_bool osync_member_save_capabilities(OSyncMember *member, OSyncCapabilities* capabilities, OSyncError** error); - -/** @brief Returns the external command of a member - * - * If the plugin is of type OSYNC_START_TYPE_EXTERNAL, an external command can be executed by OpenSync. - * The external_command should be a string in printf format, with one %s. - * Before the command is executed, a variant of printf will be called - * to replace the %s with the path to the plugin pipe. - * The resulting command will be exectued with the glib function - * g_spawn_command_line_async. - * - * The external command is specified in the plugin configuration file for the member, e.g. - * <ExternalPlugin><ExternalCommand>the command</ExternalCommand></ExternalPlugin> - * - * @param plugin Pointer to the plugin - * @returns External command of the plugin - * - */ -OSYNC_TEST_EXPORT const char *osync_member_get_external_command(OSyncMember *member); - /*@}*/ #endif /* _OPENSYNC_MEMBER_INTERNALS_H_ */ |
From: <svn...@op...> - 2009-11-01 15:01:25
|
Author: dgollub Date: Sun Nov 1 16:01:04 2009 New Revision: 5897 URL: http://www.opensync.org/changeset/5897 Log: Fix various test-suite regression by commit r5896 which get caused by a segfault. Due to a missing initization by NULL of an OSyncError *struct Modified: trunk/opensync/group/opensync_member.c Modified: trunk/opensync/group/opensync_member.c ============================================================================== --- trunk/opensync/group/opensync_member.c Sun Nov 1 15:32:43 2009 (r5896) +++ trunk/opensync/group/opensync_member.c Sun Nov 1 16:01:04 2009 (r5897) @@ -835,7 +835,7 @@ const char *osync_member_get_external_command(OSyncMember *member) { osync_assert(member); - OSyncError *error; + OSyncError *error = NULL; OSyncPluginConfig *config = osync_member_get_config_or_default(member, &error); if (config) { OSyncPluginExternalPlugin *externalplugin = osync_plugin_config_get_externalplugin(config); |
From: <svn...@op...> - 2009-11-01 14:33:08
|
Author: henrik Date: Sun Nov 1 15:32:43 2009 New Revision: 5896 URL: http://www.opensync.org/changeset/5896 Log: Plugins of type OSYNC_START_TYPE_EXTERNAL needs to be able to spawn an external command to run the actual plugin code. This patch allows a member to set an ExternalCommand in the plugin configuration file. This command will be executed by the proxy to start up the external process. The external_command should be a string in printf format, with one %s. Before the command is executed, a variant of printf will be called to replace the %s with the path to the plugin pipe. Example: <ExternalPlugin> <ExternalCommand>thunderbird -mozilla-sync %s</ExternalCommand> </ExternalPlugin> Added to public API: osync_plugin_config_get_externalplugin osync_plugin_config_set_externalplugin osync_plugin_externalplugin_new osync_plugin_externalplugin_unref osync_plugin_externalplugin_ref osync_plugin_externalplugin_get_external_command osync_plugin_externalplugin_set_external_command (as well as the changed format for the plugin configuration file) Changed internal interface: From osync_bool osync_client_proxy_spawn(OSyncClientProxy *proxy, OSyncStartType type, const char *path, OSyncError **error) To osync_bool osync_client_proxy_spawn(OSyncClientProxy *proxy, OSyncStartType type, const char *path, const char* external_command, OSyncError **error) Added: trunk/opensync/plugin/opensync_plugin_externalplugin.c trunk/opensync/plugin/opensync_plugin_externalplugin.h trunk/opensync/plugin/opensync_plugin_externalplugin_private.h Modified: trunk/misc/schemas/plugin_config.xsd trunk/opensync.sym trunk/opensync/CMakeLists.txt trunk/opensync/client/opensync_client_proxy.c trunk/opensync/client/opensync_client_proxy_internals.h trunk/opensync/engine/opensync_engine.c trunk/opensync/group/opensync_member.c trunk/opensync/group/opensync_member.h trunk/opensync/group/opensync_member_internals.h trunk/opensync/opensync-plugin.h trunk/opensync/opensync.h trunk/opensync/plugin/opensync_plugin_config.c trunk/opensync/plugin/opensync_plugin_config.h trunk/opensync/plugin/opensync_plugin_config_private.h trunk/tests/client-tests/check_proxy.c Modified: trunk/misc/schemas/plugin_config.xsd ============================================================================== --- trunk/misc/schemas/plugin_config.xsd Fri Oct 30 22:30:07 2009 (r5895) +++ trunk/misc/schemas/plugin_config.xsd Sun Nov 1 15:32:43 2009 (r5896) @@ -9,6 +9,7 @@ <xsd:element maxOccurs="1" minOccurs="0" name="Connection" type="Connection"/> <xsd:element maxOccurs="1" minOccurs="0" name="Localization" type="Localization"/> <xsd:element maxOccurs="1" minOccurs="0" name="Resources" type="Resources"/> + <xsd:element maxOccurs="1" minOccurs="0" name="ExternalPlugin" type="ExternalPlugin"/> </xsd:sequence> <xsd:attribute name="version" type="xsd:string"/> </xsd:complexType> @@ -164,4 +165,10 @@ </xsd:all> </xsd:complexType> + <xsd:complexType name="ExternalPlugin"> + <xsd:all> + <xsd:element maxOccurs="1" minOccurs="1" name="ExternalCommand" type="xsd:string" /> + </xsd:all> + </xsd:complexType> + </xsd:schema> Modified: trunk/opensync.sym ============================================================================== --- trunk/opensync.sym Fri Oct 30 22:30:07 2009 (r5895) +++ trunk/opensync.sym Sun Nov 1 15:32:43 2009 (r5896) @@ -511,6 +511,7 @@ osync_plugin_config_get_advancedoptions osync_plugin_config_get_authentication osync_plugin_config_get_connection +osync_plugin_config_get_externalplugin osync_plugin_config_get_localization osync_plugin_config_get_resources osync_plugin_config_is_supported @@ -520,6 +521,7 @@ osync_plugin_config_remove_resource osync_plugin_config_set_authentication osync_plugin_config_set_connection +osync_plugin_config_set_externalplugin osync_plugin_config_set_localization osync_plugin_config_set_supported osync_plugin_config_unref @@ -566,6 +568,11 @@ osync_plugin_env_ref osync_plugin_env_register_plugin osync_plugin_env_unref +osync_plugin_externalplugin_get_external_command +osync_plugin_externalplugin_new +osync_plugin_externalplugin_ref +osync_plugin_externalplugin_set_external_command +osync_plugin_externalplugin_unref osync_plugin_finalize osync_plugin_get_config_type osync_plugin_get_data Modified: trunk/opensync/CMakeLists.txt ============================================================================== --- trunk/opensync/CMakeLists.txt Fri Oct 30 22:30:07 2009 (r5895) +++ trunk/opensync/CMakeLists.txt Sun Nov 1 15:32:43 2009 (r5896) @@ -60,6 +60,7 @@ plugin/opensync_plugin_info.c plugin/opensync_plugin_localization.c plugin/opensync_plugin_resource.c + plugin/opensync_plugin_externalplugin.c plugin/opensync_objtype_sink.c version/opensync_version.c xmlformat/opensync_xmlfield.c Modified: trunk/opensync/client/opensync_client_proxy.c ============================================================================== --- trunk/opensync/client/opensync_client_proxy.c Fri Oct 30 22:30:07 2009 (r5895) +++ trunk/opensync/client/opensync_client_proxy.c Sun Nov 1 15:32:43 2009 (r5896) @@ -952,7 +952,7 @@ return proxy->member; } -osync_bool osync_client_proxy_spawn(OSyncClientProxy *proxy, OSyncStartType type, const char *path, OSyncError **error) +osync_bool osync_client_proxy_spawn(OSyncClientProxy *proxy, OSyncStartType type, const char *path, const char* external_command, OSyncError **error) { OSyncQueue *read1 = NULL; OSyncQueue *read2 = NULL; @@ -1080,6 +1080,22 @@ goto error; } else { name = osync_strdup_printf("%s%cpluginpipe", path, G_DIR_SEPARATOR); + + if (external_command) { + char *command = osync_strdup_printf(external_command, name); + osync_trace(TRACE_INTERNAL, "g_spawn_command_line_async(%s)", command); + GError *gerror = NULL; + gboolean f = g_spawn_command_line_async(command, &gerror); + if (!f) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to g_spawn_command_line_async(%s): %s", command, gerror->message); + g_error_free (gerror); + osync_free(command); + goto error; + } + osync_free(command); + } + + proxy->outgoing = osync_queue_new(name, error); osync_free(name); if (!proxy->outgoing) Modified: trunk/opensync/client/opensync_client_proxy_internals.h ============================================================================== --- trunk/opensync/client/opensync_client_proxy_internals.h Fri Oct 30 22:30:07 2009 (r5895) +++ trunk/opensync/client/opensync_client_proxy_internals.h Sun Nov 1 15:32:43 2009 (r5896) @@ -44,7 +44,7 @@ void osync_client_proxy_set_change_callback(OSyncClientProxy *proxy, change_cb cb, void *userdata); OSyncMember *osync_client_proxy_get_member(OSyncClientProxy *proxy); -OSYNC_TEST_EXPORT osync_bool osync_client_proxy_spawn(OSyncClientProxy *proxy, OSyncStartType type, const char *path, OSyncError **error); +OSYNC_TEST_EXPORT osync_bool osync_client_proxy_spawn(OSyncClientProxy *proxy, OSyncStartType type, const char *path, const char* external_command, OSyncError **error); OSYNC_TEST_EXPORT osync_bool osync_client_proxy_shutdown(OSyncClientProxy *proxy, OSyncError **error); OSYNC_TEST_EXPORT osync_bool osync_client_proxy_initialize(OSyncClientProxy *proxy, initialize_cb callback, void *userdata, const char *formatdir, const char *plugindir, const char *plugin, const char *groupname, const char *configdir, OSyncPluginConfig *config, OSyncError **error); Modified: trunk/opensync/engine/opensync_engine.c ============================================================================== --- trunk/opensync/engine/opensync_engine.c Fri Oct 30 22:30:07 2009 (r5895) +++ trunk/opensync/engine/opensync_engine.c Sun Nov 1 15:32:43 2009 (r5896) @@ -773,7 +773,11 @@ osync_client_proxy_set_context(proxy, engine->context); osync_client_proxy_set_change_callback(proxy, _osync_engine_receive_change, engine); - if (!osync_client_proxy_spawn(proxy, osync_plugin_get_start_type(plugin), osync_member_get_configdir(member), error)) + const char *external_command=NULL; + if (osync_plugin_get_start_type(plugin)==OSYNC_START_TYPE_EXTERNAL) + external_command=osync_member_get_external_command(member); + + if (!osync_client_proxy_spawn(proxy, osync_plugin_get_start_type(plugin), osync_member_get_configdir(member), external_command, error)) goto error_free_proxy; engine->busy = TRUE; Modified: trunk/opensync/group/opensync_member.c ============================================================================== --- trunk/opensync/group/opensync_member.c Fri Oct 30 22:30:07 2009 (r5895) +++ trunk/opensync/group/opensync_member.c Sun Nov 1 15:32:43 2009 (r5896) @@ -832,6 +832,18 @@ return new_list; } +const char *osync_member_get_external_command(OSyncMember *member) +{ + osync_assert(member); + OSyncError *error; + OSyncPluginConfig *config = osync_member_get_config_or_default(member, &error); + if (config) { + OSyncPluginExternalPlugin *externalplugin = osync_plugin_config_get_externalplugin(config); + if (externalplugin) return osync_plugin_externalplugin_get_external_command(externalplugin); + } + return NULL; +} + osync_bool osync_member_objtype_enabled(OSyncMember *member, const char *objtype) { OSyncObjTypeSink *sink = NULL; Modified: trunk/opensync/group/opensync_member.h ============================================================================== --- trunk/opensync/group/opensync_member.h Fri Oct 30 22:30:07 2009 (r5895) +++ trunk/opensync/group/opensync_member.h Sun Nov 1 15:32:43 2009 (r5896) @@ -334,6 +334,7 @@ */ OSYNC_EXPORT osync_bool osync_member_plugin_is_uptodate(OSyncMember *member); + /*@}*/ #endif /* _OPENSYNC_MEMBER_H_ */ Modified: trunk/opensync/group/opensync_member_internals.h ============================================================================== --- trunk/opensync/group/opensync_member_internals.h Fri Oct 30 22:30:07 2009 (r5895) +++ trunk/opensync/group/opensync_member_internals.h Sun Nov 1 15:32:43 2009 (r5896) @@ -184,6 +184,25 @@ */ OSYNC_TEST_EXPORT osync_bool osync_member_save_capabilities(OSyncMember *member, OSyncCapabilities* capabilities, OSyncError** error); + +/** @brief Returns the external command of a member + * + * If the plugin is of type OSYNC_START_TYPE_EXTERNAL, an external command can be executed by OpenSync. + * The external_command should be a string in printf format, with one %s. + * Before the command is executed, a variant of printf will be called + * to replace the %s with the path to the plugin pipe. + * The resulting command will be exectued with the glib function + * g_spawn_command_line_async. + * + * The external command is specified in the plugin configuration file for the member, e.g. + * <ExternalPlugin><ExternalCommand>the command</ExternalCommand></ExternalPlugin> + * + * @param plugin Pointer to the plugin + * @returns External command of the plugin + * + */ +OSYNC_TEST_EXPORT const char *osync_member_get_external_command(OSyncMember *member); + /*@}*/ #endif /* _OPENSYNC_MEMBER_INTERNALS_H_ */ Modified: trunk/opensync/opensync-plugin.h ============================================================================== --- trunk/opensync/opensync-plugin.h Fri Oct 30 22:30:07 2009 (r5895) +++ trunk/opensync/opensync-plugin.h Sun Nov 1 15:32:43 2009 (r5896) @@ -33,6 +33,7 @@ #include "plugin/opensync_plugin_connection.h" #include "plugin/opensync_plugin_localization.h" #include "plugin/opensync_plugin_resource.h" +#include "plugin/opensync_plugin_externalplugin.h" #include "plugin/opensync_objtype_sink.h" OPENSYNC_END_DECLS Modified: trunk/opensync/opensync.h ============================================================================== --- trunk/opensync/opensync.h Fri Oct 30 22:30:07 2009 (r5895) +++ trunk/opensync/opensync.h Sun Nov 1 15:32:43 2009 (r5896) @@ -222,6 +222,7 @@ typedef struct OSyncPluginConnection OSyncPluginConnection; typedef struct OSyncPluginLocalization OSyncPluginLocalization; typedef struct OSyncPluginResource OSyncPluginResource; +typedef struct OSyncPluginExternalPlugin OSyncPluginExternalPlugin; /* Engine component */ typedef struct OSyncEngine OSyncEngine; Modified: trunk/opensync/plugin/opensync_plugin_config.c ============================================================================== --- trunk/opensync/plugin/opensync_plugin_config.c Fri Oct 30 22:30:07 2009 (r5895) +++ trunk/opensync/plugin/opensync_plugin_config.c Sun Nov 1 15:32:43 2009 (r5896) @@ -33,6 +33,7 @@ #include "opensync_plugin_connection_internals.h" #include "opensync_plugin_localization_private.h" /* FIXME: direct access to private header */ #include "opensync_plugin_resource_private.h" /* FIXME: direct access to private header */ +#include "opensync_plugin_externalplugin_private.h" /* FIXME: direct access to private header */ #include "opensync_plugin_config_private.h" #include "opensync_plugin_config_internals.h" @@ -209,6 +210,47 @@ return FALSE; } +static osync_bool _osync_plugin_config_parse_externalplugin(OSyncPluginConfig *config, xmlNode *cur, OSyncError **error) +{ + OSyncPluginExternalPlugin *externalplugin = NULL; + osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, config, cur, error); + + if (cur == NULL) { // don't set externalplugin if ExternalPlugin tag is empty + osync_trace(TRACE_EXIT, "%s", __func__); + return TRUE; + } + + externalplugin = osync_plugin_externalplugin_new(error); + if (!externalplugin) + goto error; + + for (; cur != NULL; cur = cur->next) { + char *str = NULL; + if (cur->type != XML_ELEMENT_NODE) + continue; + + str = (char*)xmlNodeGetContent(cur); + if (!str) + continue; + + if (!xmlStrcmp(cur->name, (const xmlChar *)"ExternalCommand")) { + osync_plugin_externalplugin_set_external_command(externalplugin, str); + } + + osync_xml_free(str); + } + + osync_plugin_config_set_externalplugin(config, externalplugin); + osync_plugin_externalplugin_unref(externalplugin); + + osync_trace(TRACE_EXIT, "%s", __func__); + return TRUE; + + error: + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return FALSE; +} + static osync_bool _osync_plugin_config_parse_connection_bluetooth(OSyncPluginConnection *conn, xmlNode *cur, OSyncError **error) { osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, conn, cur, error); @@ -728,6 +770,9 @@ } else if (!xmlStrcmp(cur->name, (const xmlChar *)"Resources")) { config->supported |= OPENSYNC_PLUGIN_CONFIG_RESOURCES; ret = _osync_plugin_config_parse_resources(config, cur->xmlChildrenNode, error); + } else if (!xmlStrcmp(cur->name, (const xmlChar *)"ExternalPlugin")) { + config->supported |= OPENSYNC_PLUGIN_CONFIG_EXTERNALPLUGIN; + ret = _osync_plugin_config_parse_externalplugin(config, cur->xmlChildrenNode, error); } else { osync_error_set(error, OSYNC_ERROR_MISCONFIGURATION, "Unknown configuration field \"%s\"", cur->name); goto error; @@ -824,6 +869,28 @@ return FALSE; } +static osync_bool _osync_plugin_config_assemble_externalplugin(xmlNode *cur, OSyncPluginExternalPlugin *externalplugin, OSyncError **error) +{ + const char *external_command; + xmlNode *node = NULL; + osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, cur, externalplugin, error); + + node = xmlNewChild(cur, NULL, (xmlChar*)"ExternalPlugin", NULL); + if (!node) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "No memory left to assemble configuration."); + goto error; + } + + if ((external_command = osync_plugin_externalplugin_get_external_command(externalplugin))) + xmlNewChild(node, NULL, (xmlChar*)"ExternalCommand", (xmlChar*)external_command); + + osync_trace(TRACE_EXIT, "%s", __func__); + return TRUE; + error: + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return FALSE; +} + static osync_bool _osync_plugin_config_assemble_connection(xmlNode *cur, OSyncPluginConnection *conn, OSyncError **error) { char *str; @@ -1308,6 +1375,9 @@ config->resources = osync_list_remove(config->resources, res); } + if (config->externalplugin) + osync_plugin_externalplugin_unref(config->externalplugin); + if (config->schemadir) osync_free(config->schemadir); @@ -1330,6 +1400,7 @@ OSyncPluginConnection *conn; OSyncPluginAuthentication *auth; OSyncPluginLocalization *local; + OSyncPluginExternalPlugin *externalplugin; OSyncList *resources; OSyncList *options; char *version_str = NULL; @@ -1382,6 +1453,11 @@ if (!_osync_plugin_config_assemble_resources(doc->children, resources, error)) goto error_and_free; + /* ExternalPlugin */ + if ((externalplugin = osync_plugin_config_get_externalplugin(config))) + if (!_osync_plugin_config_assemble_externalplugin(doc->children, externalplugin, error)) + goto error_and_free; + xmlSaveFormatFile(path, doc, 1); osync_xml_free_doc(doc); @@ -1567,6 +1643,26 @@ return NULL; } +/* External Plugin */ +OSyncPluginExternalPlugin *osync_plugin_config_get_externalplugin(OSyncPluginConfig *config) +{ + osync_assert(config); + return config->externalplugin; +} + +void osync_plugin_config_set_externalplugin(OSyncPluginConfig *config, OSyncPluginExternalPlugin *externalplugin) +{ + osync_assert(config); + + if (config->externalplugin) { + osync_plugin_externalplugin_unref(config->externalplugin); + config->externalplugin = NULL; + } + + if (externalplugin) { + config->externalplugin = osync_plugin_externalplugin_ref(externalplugin); + } +} OSyncPluginConnection *osync_plugin_config_get_connection(OSyncPluginConfig *config) { Modified: trunk/opensync/plugin/opensync_plugin_config.h ============================================================================== --- trunk/opensync/plugin/opensync_plugin_config.h Fri Oct 30 22:30:07 2009 (r5895) +++ trunk/opensync/plugin/opensync_plugin_config.h Sun Nov 1 15:32:43 2009 (r5896) @@ -47,7 +47,9 @@ /** Resources */ OPENSYNC_PLUGIN_CONFIG_RESOURCES = (1 << 3), /** Connection options */ - OPENSYNC_PLUGIN_CONFIG_CONNECTION = (1 << 4) + OPENSYNC_PLUGIN_CONFIG_CONNECTION = (1 << 4), + /** External Plugin */ + OPENSYNC_PLUGIN_CONFIG_EXTERNALPLUGIN = (1 << 5) } OSyncPluginConfigSupportedFlag; /** @brief Set of OSyncPluginConfigSupportedFlags @@ -217,6 +219,21 @@ */ OSYNC_EXPORT void osync_plugin_config_set_connection(OSyncPluginConfig *config, OSyncPluginConnection *connection); +/* External Plugin */ +/**@brief Get the external plugin settings from a config + * + * @param config An OSyncPluginConfig + * @returns an OSyncPluginExternalPlugin with the details of the external plugin or NULL if no external plugin settings configured + */ +OSYNC_EXPORT OSyncPluginExternalPlugin *osync_plugin_config_get_externalplugin(OSyncPluginConfig *config); + +/**@brief Set the external plugin configuration + * + * @param config An OSyncPluginConfig + * @param authentication The new external plugin settings as an OSyncPluginExternalPlugin + */ +OSYNC_EXPORT void osync_plugin_config_set_externalplugin(OSyncPluginConfig *config, OSyncPluginExternalPlugin *externalplugin); + /*@}*/ #endif /*_OPENSYNC_PLUGIN_CONFIG_H_*/ Modified: trunk/opensync/plugin/opensync_plugin_config_private.h ============================================================================== --- trunk/opensync/plugin/opensync_plugin_config_private.h Fri Oct 30 22:30:07 2009 (r5895) +++ trunk/opensync/plugin/opensync_plugin_config_private.h Sun Nov 1 15:32:43 2009 (r5896) @@ -44,6 +44,8 @@ OSyncPluginLocalization *localization; /** List of resource configurations */ OSyncList *resources; + /** External plugin configuration */ + OSyncPluginExternalPlugin *externalplugin; /** Flags to store supported config options */ OSyncPluginConfigSupportedFlags supported; Added: trunk/opensync/plugin/opensync_plugin_externalplugin.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/opensync/plugin/opensync_plugin_externalplugin.c Sun Nov 1 15:32:43 2009 (r5896) @@ -0,0 +1,75 @@ +/* + * libopensync - A synchronization framework + * Copyright (C) 2009 Henrik Kaare Poulsen + * + * 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 "opensync.h" +#include "opensync_internals.h" + +#include "opensync-plugin.h" +#include "opensync_plugin_externalplugin_private.h" + +OSyncPluginExternalPlugin *osync_plugin_externalplugin_new(OSyncError **error) +{ + OSyncPluginExternalPlugin *externalplugin = osync_try_malloc0(sizeof(OSyncPluginExternalPlugin), error); + if (!externalplugin) + return NULL; + + externalplugin->ref_count = 1; + + return externalplugin; +} + +OSyncPluginExternalPlugin *osync_plugin_externalplugin_ref(OSyncPluginExternalPlugin *externalplugin) +{ + osync_assert(externalplugin); + + g_atomic_int_inc(&(externalplugin->ref_count)); + + return externalplugin; +} + +void osync_plugin_externalplugin_unref(OSyncPluginExternalPlugin *externalplugin) +{ + osync_assert(externalplugin); + + if (g_atomic_int_dec_and_test(&(externalplugin->ref_count))) { + if (externalplugin->external_command) + osync_free(externalplugin->external_command); + osync_free(externalplugin); + } +} + + +const char *osync_plugin_externalplugin_get_external_command(OSyncPluginExternalPlugin *externalplugin) +{ + osync_assert(externalplugin); + return externalplugin->external_command; +} + +void osync_plugin_externalplugin_set_external_command(OSyncPluginExternalPlugin *externalplugin, const char *external_command) +{ + osync_assert(externalplugin); + + if (externalplugin->external_command) + osync_free(externalplugin->external_command); + + externalplugin->external_command = osync_strdup(external_command); +} + + Added: trunk/opensync/plugin/opensync_plugin_externalplugin.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/opensync/plugin/opensync_plugin_externalplugin.h Sun Nov 1 15:32:43 2009 (r5896) @@ -0,0 +1,87 @@ +/* + * libopensync - A synchronization framework + * Copyright (C) 2009 Henrik Kaare Poulsen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef _OPENSYNC_PLUGIN_EXTERNALPLUGIN_H_ +#define _OPENSYNC_PLUGIN_EXTERNALPLUGIN_H_ + +/** + * @defgroup OSyncPluginExternalPluginAPI OpenSync Plugin ExternalPlugin + * @ingroup OSyncPlugin + * @brief Functions for configuring external plugin + * + */ +/*@{*/ + + +/** @brief Create a new OSyncPluginExternalPlugin object + * + * @param error Pointer to an error struct + * @returns the newly created object, or NULL in case of an error. + * + */ +OSYNC_EXPORT OSyncPluginExternalPlugin *osync_plugin_externalplugin_new(OSyncError **error); + +/** @brief Decrease the reference count on an OSyncPluginExternalPlugin object + * + * @param external_plugin Pointer to the OSyncPluginExternalPlugin object + * + */ +OSYNC_EXPORT void osync_plugin_externalplugin_unref(OSyncPluginExternalPlugin *external_plugin); + +/** @brief Increase the reference count on an OSyncPluginExternalPlugin object + * + * @param external_plugin Pointer to the OSyncPluginExternalPlugin object + * @returns The OSyncPluginExternalPlugin object passed in + * + */ +OSYNC_EXPORT OSyncPluginExternalPlugin *osync_plugin_externalplugin_ref(OSyncPluginExternalPlugin *external_plugin); + + +/** @brief Get the command to start the external plugin process + * + * @param external_plugin Pointer to the OSyncPluginExternalPlugin object + * @returns the external command or NULL if not set + * + */ +OSYNC_EXPORT const char *osync_plugin_externalplugin_get_external_command(OSyncPluginExternalPlugin *external_plugin); + +/** @brief Set the command to start the external plugin process + * + * If the plugin is of type OSYNC_START_TYPE_EXTERNAL, an external command can be executed by OpenSync. + * The external_command should be a string in printf format, with one %s. + * Before the command is executed, a variant of printf will be called + * to replace the %s with the path to the plugin pipe. + * The resulting command will be exectued with the glib function + * g_spawn_command_line_async. + * + * Example: "thunderbird -mozilla-sync %s" + * + * @param external_plugin Pointer to the OSyncPluginExternalPlugin object + * @param external_command The external command to set + * + */ +OSYNC_EXPORT void osync_plugin_externalplugin_set_external_command(OSyncPluginExternalPlugin *external_plugin, const char *external_command); + + + +/*@}*/ + +#endif /*_OPENSYNC_PLUGIN_EXTERNALPLUGIN_H_*/ + Added: trunk/opensync/plugin/opensync_plugin_externalplugin_private.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/opensync/plugin/opensync_plugin_externalplugin_private.h Sun Nov 1 15:32:43 2009 (r5896) @@ -0,0 +1,49 @@ +/* + * libopensync - A synchronization framework + * Copyright (C) 2009 Henrik Kaare Poulsen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef _OPENSYNC_PLUGIN_EXTERNALPLUGIN_PRIVATE_H_ +#define _OPENSYNC_PLUGIN_EXTERNALPLUGIN_PRIVATE_H_ + +/** + * @defgroup OSyncPluginExternalPluginPrivateAPI OpenSync Plugin ExternalPlugin Private + * @ingroup OSyncPluginPrivate + */ + +/*@{*/ + +/** + * @brief Gives information for plugin of type OSYNC_START_TYPE_EXTERNAL + **/ +struct OSyncPluginExternalPlugin { + /** Command to be executed to start the external process. + In printf format; should have one %s + which will be replaced with + the path of the plugin pipe to the client process + */ + char *external_command; + + /** Object reference counting */ + int ref_count; +}; + +/*@}*/ + +#endif /* _OPENSYNC_PLUGIN_EXTERNALPLUGIN_PRIVATE_H_ */ + Modified: trunk/tests/client-tests/check_proxy.c ============================================================================== --- trunk/tests/client-tests/check_proxy.c Fri Oct 30 22:30:07 2009 (r5895) +++ trunk/tests/client-tests/check_proxy.c Sun Nov 1 15:32:43 2009 (r5896) @@ -39,7 +39,7 @@ fail_unless(proxy != NULL, NULL); fail_unless(error == NULL, NULL); - fail_unless(osync_client_proxy_spawn(proxy, OSYNC_START_TYPE_THREAD, NULL, &error), NULL); + fail_unless(osync_client_proxy_spawn(proxy, OSYNC_START_TYPE_THREAD, NULL, NULL, &error), NULL); fail_unless(error == NULL, NULL); fail_unless(osync_client_proxy_shutdown(proxy, &error), NULL); @@ -110,7 +110,7 @@ fail_unless(proxy != NULL, NULL); fail_unless(error == NULL, NULL); - fail_unless(osync_client_proxy_spawn(proxy, OSYNC_START_TYPE_THREAD, NULL, &error), NULL); + fail_unless(osync_client_proxy_spawn(proxy, OSYNC_START_TYPE_THREAD, NULL, NULL, &error), NULL); fail_unless(error == NULL, NULL); OSyncPluginConfig *config = simple_plugin_config(NULL, "data1", "mockobjtype1", "mockformat1", NULL); @@ -159,7 +159,7 @@ fail_unless(proxy != NULL, NULL); fail_unless(error == NULL, NULL); - fail_unless(osync_client_proxy_spawn(proxy, OSYNC_START_TYPE_THREAD, NULL, &error), NULL); + fail_unless(osync_client_proxy_spawn(proxy, OSYNC_START_TYPE_THREAD, NULL, NULL, &error), NULL); fail_unless(error == NULL, NULL); OSyncPluginConfig *config = simple_plugin_config(NULL, "data1", "mockobjtype1", "mockformat1", NULL); @@ -225,7 +225,7 @@ fail_unless(proxy != NULL, NULL); fail_unless(error == NULL, NULL); - fail_unless(osync_client_proxy_spawn(proxy, OSYNC_START_TYPE_THREAD, NULL, &error), NULL); + fail_unless(osync_client_proxy_spawn(proxy, OSYNC_START_TYPE_THREAD, NULL, NULL, &error), NULL); fail_unless(error == NULL, NULL); OSyncPluginConfig *config = simple_plugin_config(NULL, "data1", "mockobjtype1", "mockformat1", NULL); |
From: <svn...@op...> - 2009-10-30 21:30:31
|
Author: dgollub Date: Fri Oct 30 22:30:07 2009 New Revision: 5895 URL: http://www.opensync.org/changeset/5895 Log: Added reference implementation of an EXTERNAL plugin, which can be a standalone userspace application. Currently a stub plugin-module is required to register the plugin to OpenSync's plugin environment and configure the start type to OSYNC_START_TYPE_EXTERNAL. This will be obsolate soon and replaced by simple config files instead, so no programming of a stub plugin is required .. Proof of Concept: ~~~~~~~~~~~~~~~~~ $ ./example_external_demo ~/.config/opensync/0.40/group6/1/pluginpipe & [1] 10841 $ [EXTERNAL-DEMO]: OSyncPlugin:0x40159d OSyncClient:0x603040 [EXTERNAL-DEMO]: Starting (blocking) OSyncClient ... $ $ osynctool --sync external Synchronizing group "external" [EXTERNAL-DEMO]: initialize data sink of member 2 of type file-sync just connected Main sink of member 2 of type file-sync just connected data sink of member 1 of type external-demo just connected Main sink of member 1 of type external-demo just connected All clients connected or error [EXTERNAL-DEMO]: get_changes slow_sync: no data sink of member 2 of type file-sync just sent all changes data sink of member 1 of type external-demo just sent all changes Main sink of member 1 of type external-demo just sent all changes Main sink of member 2 of type file-sync just sent all changes [...] The sync was successful data sink of member 1 of type external-demo just disconnected Main sink of member 1 of type external-demo just disconnected data sink of member 2 of type file-sync just disconnected Main sink of member 2 of type file-sync just disconnected All clients have disconnected [EXTERNAL-DEMO]: OSyncClient completed. [1]+ Done ./example_external_demo ~/.config/opensync/0.40/group6/1/pluginpipe $ Added: trunk/docs/examples/plugins/src/external-demo trunk/docs/examples/plugins/src/external_demo.c trunk/docs/examples/plugins/src/external_plugin.c - copied, changed from r5893, trunk/docs/examples/plugins/src/simple_plugin.c Modified: trunk/docs/examples/plugins/src/CMakeLists.txt Modified: trunk/docs/examples/plugins/src/CMakeLists.txt ============================================================================== --- trunk/docs/examples/plugins/src/CMakeLists.txt Fri Oct 30 22:09:28 2009 (r5894) +++ trunk/docs/examples/plugins/src/CMakeLists.txt Fri Oct 30 22:30:07 2009 (r5895) @@ -11,6 +11,15 @@ TARGET_LINK_LIBRARIES( example_plugin ${OPENSYNC_LIBRARIES} ) OPENSYNC_PLUGIN_INSTALL( example_plugin ) +### External Synchronization Plugin ######## +OPENSYNC_PLUGIN_ADD( example_external_plugin external_plugin.c ) +OPENSYNC_PLUGIN_CONFIG(external-demo ) +TARGET_LINK_LIBRARIES( example_external_plugin ${OPENSYNC_LIBRARIES} ) +OPENSYNC_PLUGIN_INSTALL( example_external_plugin ) + +ADD_EXECUTABLE( example_external_demo external_demo.c ) +TARGET_LINK_LIBRARIES( example_external_demo ${OPENSYNC_LIBRARIES} ) + ### Format Plugin ######################## OPENSYNC_FORMAT_ADD( format_plugin format.c ) TARGET_LINK_LIBRARIES( format_plugin ${OPENSYNC_LIBRARIES} ) Added: trunk/docs/examples/plugins/src/external-demo ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/docs/examples/plugins/src/external-demo Fri Oct 30 22:30:07 2009 (r5895) @@ -0,0 +1,15 @@ +<?xml version="1.0"?> +<config version="1.0"> + <Resources> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>file</Name> + </Format> + </Formats> + <ObjType>data</ObjType> + <Url></Url> + </Resource> + </Resources> +</config> Added: trunk/docs/examples/plugins/src/external_demo.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/docs/examples/plugins/src/external_demo.c Fri Oct 30 22:30:07 2009 (r5895) @@ -0,0 +1,146 @@ +/* + * external_demo.c - example implementation of an userspace process + * which acts as external OpenSync plugin + * + * Copyright (C) 2009 Daniel Gollub <go...@b1...> + * + * 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 <opensync/opensync.h> +#include <opensync/opensync-client.h> +#include <opensync/opensync-data.h> +#include <opensync/opensync-format.h> +#include <opensync/opensync-plugin.h> +#include <opensync/opensync-helper.h> +#include <opensync/opensync-version.h> + +static void get_changes(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, osync_bool slow_sync, void *data) +{ + printf("[EXTERNAL-DEMO]: %s slow_sync: %s\n", __func__, slow_sync ? "yes" : "no"); + + /** XXX: here you get your changes and report them via osync_context_report_change() */ + + osync_context_report_success(ctx); +} + +static void *initialize(OSyncPlugin *plugin, OSyncPluginInfo *info, OSyncError **error) +{ + OSyncList *sinks, *s; + + osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, info, error); + + printf("[EXTERNAL-DEMO]: %s\n", __func__); + + sinks = osync_plugin_info_get_objtype_sinks(info); + for (s = sinks; s; s = s->next) { + OSyncObjTypeSink *sink = s->data; + + /* Here you register all your objtype sink functions ... */ + osync_objtype_sink_set_get_changes_func(sink, get_changes); + /* You can also add sink function for + * - connect() + * - disconnect() + * - commit() + * - sync_done() + * - ... + */ + } + + osync_trace(TRACE_EXIT, "%s: %p", __func__, NULL); + return (void *) NULL; + +error: + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return NULL; +} + +static void finalize(void *data) +{ + printf("[EXTERNAL-DEMO]: %s\n", __func__); +} + +static osync_bool discover(OSyncPluginInfo *info, void *data, OSyncError **error) +{ + + printf("[EXTERNAL-DEMO]: %s\n", __func__); + OSyncList *s, *sinks = osync_plugin_info_get_objtype_sinks(info); + for (s = sinks; s; s = s->next) { + OSyncObjTypeSink *sink = (OSyncObjTypeSink *) s->data; + osync_objtype_sink_set_available(sink, TRUE); + } + osync_list_free(sinks); + + OSyncVersion *version = osync_version_new(error); + osync_version_set_plugin(version, "external-demo"); + osync_plugin_info_set_version(info, version); + osync_version_unref(version); + + return TRUE; +} + +int main(int argc, char **argv) +{ + const char *pipe_path; + OSyncError *error = NULL; + OSyncClient *client = NULL; + OSyncPlugin *plugin = NULL; + + if (!argv[1]) { + fprintf(stderr, "pipe path is missing!\n"); + return 1; + } + + pipe_path = argv[1]; + + + /** Plugin **/ + plugin = osync_plugin_new(&error); + if (!plugin) + goto error; + + osync_plugin_set_initialize(plugin, initialize); + osync_plugin_set_finalize(plugin, finalize); + osync_plugin_set_discover(plugin, discover); + + + /** Client */ + client = osync_client_new(&error); + if (!client) + goto error; + + osync_client_set_pipe_path(client, pipe_path); + osync_client_set_plugin(client, plugin); + + + printf("[EXTERNAL-DEMO]: OSyncPlugin:%p OSyncClient:%p\n", __func__, plugin, client); + printf("[EXTERNAL-DEMO]: Starting (blocking) OSyncClient ...\n", __func__, plugin, client); + + if (!osync_client_run_and_block(client, &error)) + goto error; + + printf("[EXTERNAL-DEMO]: OSyncClient completed.", __func__, plugin, client); + + osync_client_unref(client); + + return 0; + +error: + fprintf(stderr, "[EXTERNAL-DEMO] Error: %s\n", osync_error_print(&error)); + osync_error_unref(&error); + return 1; +} + Copied and modified: trunk/docs/examples/plugins/src/external_plugin.c (from r5893, trunk/docs/examples/plugins/src/simple_plugin.c) ============================================================================== --- trunk/docs/examples/plugins/src/simple_plugin.c Fri Oct 23 20:12:54 2009 (r5893, copy source) +++ trunk/docs/examples/plugins/src/external_plugin.c Fri Oct 30 22:30:07 2009 (r5895) @@ -1,332 +1,26 @@ +/* + * + * !!! This is only a temporary solution and will be soon obsolete. !!! + * + * This plugin is just a stub to register an external plugin to the plugin-env + * In the future this will be done via configuration files. + * + */ + #include <opensync/opensync.h> -#include <opensync/opensync-data.h> -#include <opensync/opensync-format.h> #include <opensync/opensync-plugin.h> -#include <opensync/opensync-helper.h> -#include <opensync/opensync-version.h> - -#include <string.h> - -static void connect(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *userdata) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, sink, info, ctx, userdata); - //Each time you get passed a context (which is used to track - //calls to your plugin) - - //cast void* userdata to the sink specific data type - - OSyncError *error = NULL; - - /* - * Now connect to your devices and report - * - * an error via: - * osync_context_report_error(ctx, ERROR_CODE, "Some message"); - * - * or success via: - * osync_context_report_success(ctx); - * - * You have to use one of these 2 somewhere to answer the context. - * - */ - - //you can also use the anchor system to detect a device reset - //or some parameter change here. Check the docs to see how it works - //Now you get the last stored anchor from the device - OSyncSinkStateDB *state_db = osync_objtype_sink_get_state_db(sink); - osync_bool anchormatch; - - if (!osync_sink_state_equal(state_db, "anchor_key", "dynamic_anchor_value", &anchormatch, &error)) { - /* anchor couldn't be compared */ - goto error; - } - - if (!anchormatch) { - /* request slow sync */ - osync_context_report_slowsync(ctx); - } - - 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); -} - -static void get_changes(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, osync_bool slow_sync, void *userdata) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, userdata, info, ctx); - - OSyncFormatEnv *formatenv = osync_plugin_info_get_format_env(info); - - OSyncError *error = NULL; - - /* - * Now you can get the changes. - * Loop over all changes you get and do the following: - */ - - do { - char *uid = osync_strdup("<some uid>"); - - //Now get the data of this change - char *data = NULL; - - - /* Determine the "Change Type" of this change (e.g. ADDED, MODIFIED, DELETED, ...) */ - OSyncChangeType changetype = OSYNC_CHANGE_TYPE_ADDED; - - //Make the new change to report - OSyncChange *change = osync_change_new(&error); - if (!change) { - osync_context_report_osyncwarning(ctx, error); - osync_error_unref(&error); - continue; - } - - //Now set the uid of the object - osync_change_set_uid(change, uid); - - osync_change_set_changetype(change, changetype); - - if (changetype == OSYNC_CHANGE_TYPE_UNMODIFIED) { - osync_free(uid); - osync_change_unref(change); - continue; - } - - osync_free(uid); - - OSyncObjFormat *format = osync_format_env_find_objformat(formatenv, "<objformat>"); - - OSyncData *odata = osync_data_new(data, 0, format, &error); - if (!odata) { - osync_change_unref(change); - osync_context_report_osyncwarning(ctx, error); - osync_error_unref(&error); - continue; - } - - osync_data_set_objtype(odata, osync_objtype_sink_get_name(sink)); - - //Now you can set the data for the object - osync_change_set_data(change, odata); - osync_data_unref(odata); - - // just report the change via - osync_context_report_change(ctx, change); - - osync_change_unref(change); - - osync_free(uid); - } while(0); - - //Now we need to answer the call - osync_context_report_success(ctx); - osync_trace(TRACE_EXIT, "%s", __func__); -} - -static void commit_change(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, OSyncChange *change, void *userdata) -{ - - /* - * Here you have to add, modify or delete a object - * - */ - switch (osync_change_get_changetype(change)) { - case OSYNC_CHANGE_TYPE_DELETED: - //Delete the change - //Dont forget to answer the call on error - break; - case OSYNC_CHANGE_TYPE_ADDED: - //Add the change - //Dont forget to answer the call on error - break; - case OSYNC_CHANGE_TYPE_MODIFIED: - //Modify the change - //Dont forget to answer the call on error - break; - default: - ; - } - - //Answer the call - osync_context_report_success(ctx); -} - -static void sync_done(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *userdata) -{ - /* - * This function will only be called if the sync was successful - */ - OSyncError *error = NULL; - - //If we use anchors we have to update it now. - //Now you get/calculate the current anchor of the device - OSyncSinkStateDB *state_db = osync_objtype_sink_get_state_db(sink); - if (!osync_sink_state_set(state_db, "anchor_key", "dynamic_anchor_value", &error)) - goto error; - - //Answer the call - osync_context_report_success(ctx); - return; -error: - osync_context_report_osyncerror(ctx, error); - osync_error_unref(&error); - return; -} - -static void disconnect(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *userdata) -{ - //Close all stuff you need to close - - //Answer the call - osync_context_report_success(ctx); -} - -static void finalize(void *userdata) -{ - //Free all stuff that you have allocated here. -} - - -static void *initialize(OSyncPlugin *plugin, OSyncPluginInfo *info, OSyncError **error) -{ - /* - * get the config - */ - OSyncPluginConfig *config = osync_plugin_info_get_config(info); - if (!config) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to get config."); - goto error; - } - /* - * You need to specify the <some name>_environment somewhere with - * all the members you need - */ - void *env = NULL; - if (!env) - goto error; - - osync_trace(TRACE_INTERNAL, "The config: %s", osync_plugin_info_get_config(info)); - - /* - * Process the config here and set the options on your environment - */ - /* - * Process plugin specific advanced options - */ - OSyncList *optslist = osync_plugin_config_get_advancedoptions(config); - OSyncList *o; - for (o = optslist; o; o = o->next) { - OSyncPluginAdvancedOption *option = o->data; - - const char *val = osync_plugin_advancedoption_get_value(option); - const char *name = osync_plugin_advancedoption_get_name(option); - - if (!strcmp(name,"<your-option>")) { - if (!strcmp(val, "<your-value>")) { - /* - * set a varaible to a specific value - */; - } - } - } - osync_list_free(optslist); - - /* - * Process Ressource options - */ - OSyncList *l, *list = NULL; - list = osync_plugin_info_get_objtype_sinks(info); - for (l=list; l; l = l->next) { - OSyncObjTypeSink *sink = (OSyncObjTypeSink *) l->data ; - - const char *objtype = osync_objtype_sink_get_name(sink); - OSyncPluginResource *res = osync_plugin_config_find_active_resource(config, objtype); - - /* get objformat sinks */ - OSyncList *s = NULL; - OSyncList *objformats = osync_plugin_resource_get_objformat_sinks(res); - for (s = objformats; s; s = s->next) { - OSyncObjFormatSink *fsink = s->data; // there could be only one sink - const char *objformat = osync_objformat_sink_get_objformat(fsink); - osync_assert(objformat); - osync_trace(TRACE_INTERNAL, "objtype %s has objformat %s", objtype, objformat); - } - osync_list_free(objformats); - /* Every sink can have different functions ... */ - osync_objtype_sink_set_connect_func(sink, connect); - osync_objtype_sink_set_disconnect_func(sink, disconnect); - osync_objtype_sink_set_get_changes_func(sink, get_changes); - osync_objtype_sink_set_commit_func(sink, commit_change); - osync_objtype_sink_set_sync_done_func(sink, sync_done); - - /* - * If you need plugin specific userdata passed to this - * plugin sink functions. You can set it with: - * - * osync_objtype_sink_set_userdata(sink, userdata_pointer); - */ - } - - osync_list_free(list); - - //Now your return your struct. - return (void *) env; - -error: - osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - return NULL; -} - -/* Here we actually tell opensync which sinks are available. */ -static osync_bool discover(OSyncPluginInfo *info, void *userdata, OSyncError **error) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, userdata, info, error); - - // Report avaliable sinks... - OSyncObjTypeSink *sink = osync_plugin_info_find_objtype(info, "<objtype e.g. note>"); - if (!sink) { - return FALSE; - } - osync_objtype_sink_set_available(sink, TRUE); - - OSyncVersion *version = osync_version_new(error); - osync_version_set_plugin(version, "<your plugin-name>"); - //osync_version_set_version(version, "version"); - //osync_version_set_modelversion(version, "version"); - //osync_version_set_firmwareversion(version, "firmwareversion"); - //osync_version_set_softwareversion(version, "softwareversion"); - //osync_version_set_hardwareversion(version, "hardwareversion"); - osync_plugin_info_set_version(info, version); - osync_version_unref(version); - - osync_trace(TRACE_EXIT, "%s", __func__); - return TRUE; -} - osync_bool get_sync_info(OSyncPluginEnv *env, OSyncError **error) { - //Now you can create a new plugin information and fill in the details - //Note that you can create several plugins here OSyncPlugin *plugin = osync_plugin_new(error); if (!plugin) goto error; //Tell opensync something about your plugin - osync_plugin_set_name(plugin, "short name, maybe < 15 chars"); + osync_plugin_set_name(plugin, "external-demo"); osync_plugin_set_longname(plugin, "long name. maybe < 50 chars"); osync_plugin_set_description(plugin, "A longer description. < 200 chars"); - - //Now set the function we made earlier - osync_plugin_set_initialize(plugin, initialize); - osync_plugin_set_finalize(plugin, finalize); - osync_plugin_set_discover(plugin, discover); + osync_plugin_set_start_type(plugin, OSYNC_START_TYPE_EXTERNAL); if (!osync_plugin_env_register_plugin(env, plugin, error)) goto error; @@ -343,3 +37,4 @@ { return 1; } + |
From: <svn...@op...> - 2009-10-30 21:09:47
|
Author: dgollub Date: Fri Oct 30 22:09:28 2009 New Revision: 5894 URL: http://www.opensync.org/changeset/5894 Log: API changes for osync_client_run_and_block() Added parameter: OSyncError** which gets set on any error. Additionally the return type changed to osync_bool. The return value is FALSE on any error, on success TRUE. New OSyncClient interfaces: * osync_client_{get,set}_plugin * osync_client_{get,set}_pipe_path This changes allow to assemble plugins which run as an external process: OSYNC_START_TYPE_EXTERNAL Such plugins assemble OSyncPlugin* and OSyncClient* and need to set the pipe path to the "pluginpipe" in the member direcotry. Modified: trunk/opensync.sym trunk/opensync/client/opensync_client.c trunk/opensync/client/opensync_client.h trunk/opensync/client/opensync_client_internals.h trunk/opensync/client/opensync_client_private.h trunk/opensync/client/osplugin.c Modified: trunk/opensync.sym ============================================================================== --- trunk/opensync.sym Fri Oct 23 20:12:54 2009 (r5893) +++ trunk/opensync.sym Fri Oct 30 22:09:28 2009 (r5894) @@ -53,12 +53,16 @@ osync_change_set_objtype osync_change_set_uid osync_change_unref +osync_client_get_pipe_path +osync_client_get_plugin osync_client_new osync_client_ref osync_client_run osync_client_run_and_block osync_client_set_incoming_queue osync_client_set_outgoing_queue +osync_client_set_pipe_path +osync_client_set_plugin osync_client_unref osync_context_new osync_context_ref Modified: trunk/opensync/client/opensync_client.c ============================================================================== --- trunk/opensync/client/opensync_client.c Fri Oct 23 20:12:54 2009 (r5893) +++ trunk/opensync/client/opensync_client.c Fri Oct 30 22:09:28 2009 (r5894) @@ -1705,6 +1705,42 @@ } } +void osync_client_set_plugin(OSyncClient *client, OSyncPlugin *plugin) +{ + osync_return_if_fail(client); + osync_return_if_fail(plugin); + + if (client->plugin) + osync_plugin_unref(client->plugin); + + + client->plugin = osync_plugin_ref(plugin); +} + +OSyncPlugin *osync_client_get_plugin(OSyncClient *client) +{ + osync_return_val_if_fail(client, NULL); + return client->plugin; +} + +void osync_client_set_pipe_path(OSyncClient *client, const char *pipe_path) +{ + osync_return_if_fail(client); + osync_return_if_fail(pipe_path); + + if (client->pipe_path) + osync_free(client->pipe_path); + + + client->pipe_path = osync_strdup(pipe_path); +} + +const char *osync_client_get_pipe_path(OSyncClient *client) +{ + osync_return_val_if_fail(client, NULL); + return client->pipe_path; +} + osync_bool osync_client_set_incoming_queue(OSyncClient *client, OSyncQueue *incoming, OSyncError **error) { osync_queue_set_message_handler(incoming, _osync_client_message_handler, client); @@ -1739,21 +1775,94 @@ return FALSE; } -void osync_client_run_and_block(OSyncClient *client) +osync_bool osync_client_run_and_block(OSyncClient *client, OSyncError **error) { + + if (!osync_client_setup_pipes(client, NULL, error)) + goto error; + + if (!osync_client_connect_pipes(client, error)) + goto error; + client->syncloop = g_main_loop_new(client->context, TRUE); g_main_loop_run(client->syncloop); + + return TRUE; + +error: + return FALSE; } osync_bool osync_client_run(OSyncClient *client, OSyncError **error) { + if (!osync_client_setup_pipes(client, NULL, error)) + goto error; + + if (!osync_client_connect_pipes(client, error)) + goto error; + client->thread = osync_thread_new(client->context, error); if (!client->thread) - return FALSE; + goto error; osync_thread_start(client->thread); return TRUE; + +error: + return FALSE; +} + +osync_bool osync_client_setup_pipes(OSyncClient *client, const char *pipe_path, OSyncError **error) +{ + OSyncQueue *incoming = NULL; + + const char *path = NULL; + + if (pipe_path) { + path = pipe_path; + } else if (client->pipe_path) { + path = client->pipe_path; + } else { + /* If there are no pipes - which is perfectly fine - this is just NOP */ + return TRUE; + } + + /* Create connection pipes **/ + incoming = osync_queue_new(path, error); + if (!incoming) + goto error; + + if (!osync_queue_create(incoming, error)) + goto error_free_queue; + + if (!osync_client_set_incoming_queue(client, incoming, error)) + goto error_remove_queue; + + osync_queue_unref(incoming); + + return TRUE; + +error_remove_queue: + osync_queue_remove(incoming, NULL); +error_free_queue: + osync_queue_unref(incoming); +error: + return FALSE; +} + +osync_bool osync_client_connect_pipes(OSyncClient *client, OSyncError **error) +{ + /* Nop pipes are perfeclty fine - this function does NOP in this case */ + if (!client->incoming) + return TRUE; + + /* Skip if queues already connected - this is different for each plugin start type */ + if (osync_queue_is_connected(client->incoming)) + return TRUE; + + /* We now connect to our incoming queue */ + return osync_queue_connect(client->incoming, OSYNC_QUEUE_RECEIVER, error); } static gboolean osyncClientConnectCallback(gpointer data) @@ -1762,8 +1871,9 @@ client = data; osync_trace(TRACE_INTERNAL, "About to connect to the incoming queue"); + /* We now connect to our incoming queue */ - if (!osync_queue_connect(client->incoming, OSYNC_QUEUE_RECEIVER, NULL)) + if (!osync_client_connect_pipes(client, NULL)) return TRUE; return FALSE; @@ -1772,23 +1882,15 @@ osync_bool osync_client_run_external(OSyncClient *client, char *pipe_path, OSyncPlugin *plugin, OSyncError **error) { - OSyncQueue *incoming = NULL; GSource *source = NULL; osync_trace(TRACE_ENTRY, "%s(%p, %s, %p, %p)", __func__, client, pipe_path, plugin, error); - /* Create connection pipes **/ - incoming = osync_queue_new(pipe_path, error); - if (!incoming) + + if (!osync_client_setup_pipes(client, pipe_path, error)) goto error; - if (!osync_queue_create(incoming, error)) - goto error_free_queue; - - if (!osync_client_set_incoming_queue(client, incoming, error)) - goto error_remove_queue; - client->thread = osync_thread_new(client->context, error); if (!client->thread) - goto error_remove_queue; + goto error; osync_thread_start(client->thread); @@ -1799,15 +1901,9 @@ g_source_set_callback(source, osyncClientConnectCallback, client, NULL); g_source_attach(source, client->context); - osync_queue_unref(incoming); osync_trace(TRACE_EXIT, "%s", __func__); return TRUE; - - error_remove_queue: - osync_queue_remove(incoming, NULL); - error_free_queue: - osync_queue_unref(incoming); error: osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); return FALSE; Modified: trunk/opensync/client/opensync_client.h ============================================================================== --- trunk/opensync/client/opensync_client.h Fri Oct 23 20:12:54 2009 (r5893) +++ trunk/opensync/client/opensync_client.h Fri Oct 30 22:09:28 2009 (r5894) @@ -28,7 +28,14 @@ OSYNC_EXPORT osync_bool osync_client_set_incoming_queue(OSyncClient *client, OSyncQueue *incoming, OSyncError **error); OSYNC_EXPORT osync_bool osync_client_set_outgoing_queue(OSyncClient *client, OSyncQueue *outgoing, OSyncError **error); -OSYNC_EXPORT void osync_client_run_and_block(OSyncClient *client); +OSYNC_EXPORT void osync_client_set_plugin(OSyncClient *client, OSyncPlugin *plugin); +OSYNC_EXPORT OSyncPlugin *osync_client_get_plugin(OSyncClient *client); + +OSYNC_EXPORT void osync_client_set_pipe_path(OSyncClient *client, const char *pipe_path); +OSYNC_EXPORT const char *osync_client_get_pipe_path(OSyncClient *client); + +OSYNC_EXPORT osync_bool osync_client_run_and_block(OSyncClient *client, OSyncError **error); OSYNC_EXPORT osync_bool osync_client_run(OSyncClient *client, OSyncError **error); + #endif /*OPENSYNC_CLIENT_H_*/ Modified: trunk/opensync/client/opensync_client_internals.h ============================================================================== --- trunk/opensync/client/opensync_client_internals.h Fri Oct 23 20:12:54 2009 (r5893) +++ trunk/opensync/client/opensync_client_internals.h Fri Oct 30 22:09:28 2009 (r5894) @@ -28,4 +28,7 @@ OSYNC_TEST_EXPORT osync_bool osync_client_run_external(OSyncClient *client, char *pipe_path, OSyncPlugin *plugin, OSyncError **error); +osync_bool osync_client_setup_pipes(OSyncClient *client, const char *pipe_path, OSyncError **error); +osync_bool osync_client_connect_pipes(OSyncClient *client, OSyncError **error); + #endif /*OPENSYNC_CLIENT_INTERNALS_H_*/ Modified: trunk/opensync/client/opensync_client_private.h ============================================================================== --- trunk/opensync/client/opensync_client_private.h Fri Oct 23 20:12:54 2009 (r5893) +++ trunk/opensync/client/opensync_client_private.h Fri Oct 30 22:09:28 2009 (r5894) @@ -34,6 +34,9 @@ OSyncFormatEnv *format_env; void *plugin_data; OSyncThread *thread; + + /* pipe path for the queue */ + char *pipe_path; }; #endif /*OPENSYNC_CLIENT_PRIVATE_H_*/ Modified: trunk/opensync/client/osplugin.c ============================================================================== --- trunk/opensync/client/osplugin.c Fri Oct 23 20:12:54 2009 (r5893) +++ trunk/opensync/client/osplugin.c Fri Oct 30 22:09:28 2009 (r5894) @@ -123,7 +123,8 @@ osync_queue_unref(incoming); } - osync_client_run_and_block(client); + if (!osync_client_run_and_block(client, &error)) + goto error; osync_client_unref(client); |
From: <svn...@op...> - 2009-10-23 18:13:06
|
Author: scriptor Date: Fri Oct 23 20:12:54 2009 New Revision: 5893 URL: http://www.opensync.org/changeset/5893 Log: - The version of a binary package ("make package") should be in line with the version of a source code package ("make package_source"). I have adjusted CMakeLists.txt accordingly. - I have added OPENSYNC_MIN_VERSION. - I have added messages for the presence/lack of the check libraries. So that the user knows, why the test suite can not be built, if it is missing. - I have fixed an entry with the TARGET_LINK_LIBRARIES macro in src/CMakeLists.txt. cmake of a newer version (2.6.3) complained about that. - I have increased the version to 0.40. - As of today the LDAP plugin build has been tested on linux (fedora 10 and 11) and freebsd-7.2. Modified: plugins/ldap-sync/CMakeLists.txt plugins/ldap-sync/src/CMakeLists.txt Modified: plugins/ldap-sync/CMakeLists.txt ============================================================================== --- plugins/ldap-sync/CMakeLists.txt Fri Oct 23 20:12:45 2009 (r5892) +++ plugins/ldap-sync/CMakeLists.txt Fri Oct 23 20:12:54 2009 (r5893) @@ -23,7 +23,9 @@ PROJECT( libopensync-plugin-ldap ) -SET( VERSION "0.39" ) +SET( VERSION "0.40" ) +SET( CPACK_PACKAGE_VERSION "${VERSION}" ) +SET( OPENSYNC_MIN_VERSION "${VERSION}" ) cmake_minimum_required(VERSION 2.4) IF(COMMAND cmake_policy) @@ -47,6 +49,9 @@ FIND_PACKAGE( LibGSSAPIV2 ) FIND_PACKAGE( Check ) +IF ( NOT CHECK_FOUND ) + MESSAGE( STATUS " Could NOT find the check library: \"check\" or \"libcheck\": http://check.sourceforge.net/ . The test suite can NOT be built, therefore.") +ENDIF ( NOT CHECK_FOUND ) # By default use openldap, if available. # Fall back to mozldap only, if necessary (and possible, of course). Modified: plugins/ldap-sync/src/CMakeLists.txt ============================================================================== --- plugins/ldap-sync/src/CMakeLists.txt Fri Oct 23 20:12:45 2009 (r5892) +++ plugins/ldap-sync/src/CMakeLists.txt Fri Oct 23 20:12:54 2009 (r5893) @@ -124,8 +124,8 @@ -TARGET_LINK_LIBRARIES( ldap-sync ${OPENSYNC_LIBRARIES} ${GLIB2_LIBRARIES} ${LIBXML2_LIBRARY_DIRS} ${LIBXSLT_LIBRARIES} ${_LDAP_LIBRARIES} ${GCRYPT_LIBRARY} ${SASL2_LIBRARY}) -TARGET_LINK_LIBRARIES( ldap-format ${OPENSYNC_LIBRARIES} ${GLIB2_LIBRARIES} ${LIBXML2_LIBRARY_DIRS} ${LIBXSLT_LIBRARIES} ${_LDAP_LIBRARIES} ${GCRYPT_LIBRARY}) +TARGET_LINK_LIBRARIES( ldap-sync ${OPENSYNC_LIBRARIES} ${GLIB2_LIBRARIES} ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${_LDAP_LIBRARIES} ${GCRYPT_LIBRARY} ${SASL2_LIBRARY}) +TARGET_LINK_LIBRARIES( ldap-format ${OPENSYNC_LIBRARIES} ${GLIB2_LIBRARIES} ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${_LDAP_LIBRARIES} ${GCRYPT_LIBRARY}) |
From: <svn...@op...> - 2009-10-23 18:12:56
|
Author: scriptor Date: Fri Oct 23 20:12:45 2009 New Revision: 5892 URL: http://www.opensync.org/changeset/5892 Log: Changed an error message. Modified: plugins/ldap-sync/misc/clean_ldap.sh Modified: plugins/ldap-sync/misc/clean_ldap.sh ============================================================================== --- plugins/ldap-sync/misc/clean_ldap.sh Fri Oct 23 20:10:15 2009 (r5891) +++ plugins/ldap-sync/misc/clean_ldap.sh Fri Oct 23 20:12:45 2009 (r5892) @@ -29,12 +29,18 @@ if test -f "$tmpfile"; then - rm -f "$tmpfile"; -fi + if test -w "$tmpfile"; then + rm -f "$tmpfile"; -if test -f "$tmpfile"; then - echo "$file:$LINENO: ERROR: $tmpfile already exists and is NOT writable. Exiting." - exit 1 + if test -f "$tmpfile"; then + echo "$file:$LINENO: ERROR: $tmpfile still exists, although rm has been called. As it seems, it is NOT writable. Exiting." + exit 1 + fi + + else + echo "$file:$LINENO: ERROR: $tmpfile already exists and is NOT writable. Exiting." + exit 1 + fi fi @@ -50,7 +56,7 @@ if test $rv -ne 0; then echo -e "The command \n\n$cmd\n\nhas failed. Exiting." - exit + exit 1 fi return $rv |
From: <svn...@op...> - 2009-10-23 18:10:31
|
Author: scriptor Date: Fri Oct 23 20:10:15 2009 New Revision: 5891 URL: http://www.opensync.org/changeset/5891 Log: Downgraded some error messages. Modified: plugins/ldap-sync/src/ldap_format.c Modified: plugins/ldap-sync/src/ldap_format.c ============================================================================== --- plugins/ldap-sync/src/ldap_format.c Thu Oct 22 23:34:00 2009 (r5890) +++ plugins/ldap-sync/src/ldap_format.c Fri Oct 23 20:10:15 2009 (r5891) @@ -1242,9 +1242,9 @@ } if (value[0] == 0) { - osync_trace(TRACE_ERROR, "%s:%i: WARNING: value[0] = 0; name = \"%s\". Ignoring.", __FILE__, __LINE__, name); + osync_trace(TRACE_INTERNAL, "%s:%i: WARNING: value[0] = 0; name = \"%s\". Ignoring.", __FILE__, __LINE__, name); } - } + } // if (strncmp((char *)name, "TimezoneRule", 12) ... if (!strncmp((char *)name, "AddressLabel", 12)) { @@ -1404,7 +1404,7 @@ if (child_value[0] == 0) { - osync_trace(TRACE_ERROR, "%s:%i: WARNING: child_value[0] = 0. Ignoring this node with child_name = \"%s\"\n", __FILE__, __LINE__, child_name); + osync_trace(TRACE_INTERNAL, "%s:%i: WARNING: child_value[0] = 0. Ignoring this node with child_name = \"%s\"\n", __FILE__, __LINE__, child_name); continue; } @@ -4122,7 +4122,7 @@ } if (value[0] == 0) { - osync_trace(TRACE_ERROR, "%s:%i: WARNING: value[0] = 0. Skipping this xmlnode. name = \"%s\".\n", __FILE__, __LINE__, (char *)name ? (char *)name : "NULL"); + osync_trace(TRACE_INTERNAL, "%s:%i: WARNING: value[0] = 0. Skipping this xmlnode. name = \"%s\".\n", __FILE__, __LINE__, (char *)name ? (char *)name : "NULL"); if (value) { xmlFree(value); value = NULL; @@ -4143,7 +4143,7 @@ // Workaround for one particular telephone number that does not comply // with the syntax requirements of the LDAP schema "evolutionPerson": if ((!strcmp((char *)name, "telephoneNumber") || (!strcmp((char *)name, "mobile"))) && !strcmp((char *)value, "*100#")) { - osync_trace(TRACE_INTERNAL, "WARNING: Omitting this entry because of syntax violation of the underlying LDAP schema and because of a strange behaviour of slapd afterwards: It keeps this error message for all kinds of succeeding entries, even if they do not contain any telephoneNumber attributes, at all.\n"); + osync_trace(TRACE_INTERNAL, "%s:%i: WARNING: Omitting this attribute (\"%s: %s\") because of syntax violation of the underlying LDAP schema and because of a strange behaviour of slapd afterwards: It keeps this error message for all kinds of succeeding entries, even if they do not contain any telephoneNumber attributes, at all.\n", __FILE__, __LINE__, name, value); if (value) { |
From: <svn...@op...> - 2009-10-23 15:09:25
|
Author: bellmich Date: Fri Oct 23 17:09:12 2009 New Revision: 1349 URL: http://libsyncml.opensync.org/changeset/1349 Log: fixed test (because of CR/CRLF normalization to LF) Modified: trunk/tests/check_xml_parser.c Modified: trunk/tests/check_xml_parser.c ============================================================================== --- trunk/tests/check_xml_parser.c Fri Oct 23 16:58:22 2009 (r1348) +++ trunk/tests/check_xml_parser.c Fri Oct 23 17:09:12 2009 (r1349) @@ -1211,7 +1211,7 @@ const char *data2 = sml_data_sync_change_item_get_data(item); - sml_fail_unless(!strcmp(data2, "data\r\n\r\nda"), NULL); + sml_fail_unless(!strcmp(data2, "data\n\nda"), NULL); smlCommandUnref(cmd); sml_fail_unless(smlParserGetCommand(parser, &cmd, &error) == SML_PARSER_RESULT_CLOSE, NULL); |
From: <svn...@op...> - 2009-10-23 14:58:41
|
Author: bellmich Date: Fri Oct 23 16:58:22 2009 New Revision: 1348 URL: http://libsyncml.opensync.org/changeset/1348 Log: a small fix to reduce the number of Solaris SEGVs Modified: trunk/tests/check_data_sync_api.c Modified: trunk/tests/check_data_sync_api.c ============================================================================== --- trunk/tests/check_data_sync_api.c Sun Oct 18 12:30:32 2009 (r1347) +++ trunk/tests/check_data_sync_api.c Fri Oct 23 16:58:22 2009 (r1348) @@ -628,8 +628,17 @@ SmlDataSyncTestClient *client = list->data; if (!sml_data_sync_run(client->client, &error)) goto error; + /* It is necessary to perform the first request alone + * because otherwise the test can fail on Solaris + * because Solaris uses an outdated libsoup 2.2. + */ + if (list == clients) { + /* first client => wait for Soup Session init */ + usleep(5000); + } } } else { + /* OBEX */ GList *list = clients; for (; list; list = list->next) { |
From: <svn...@op...> - 2009-10-22 21:34:16
|
Author: paule Date: Thu Oct 22 23:34:00 2009 New Revision: 5890 URL: http://www.opensync.org/changeset/5890 Log: API documentation: minor fix to OSyncStartType documentation Modified: trunk/opensync/opensync.h Modified: trunk/opensync/opensync.h ============================================================================== --- trunk/opensync/opensync.h Thu Oct 22 23:28:15 2009 (r5889) +++ trunk/opensync/opensync.h Thu Oct 22 23:34:00 2009 (r5890) @@ -146,7 +146,7 @@ * Determines how the sync process is to be run. */ typedef enum { - /** The start type is unknown, there was an error */ + /** The start type is unknown (has not been set) */ OSYNC_START_TYPE_UNKNOWN, /** Start as child process */ OSYNC_START_TYPE_PROCESS, |
From: <svn...@op...> - 2009-10-22 21:28:32
|
Author: paule Date: Thu Oct 22 23:28:15 2009 New Revision: 5889 URL: http://www.opensync.org/changeset/5889 Log: API documentation: document OSyncStartType enum. Fixes bug #921. Modified: trunk/opensync/opensync.h Modified: trunk/opensync/opensync.h ============================================================================== --- trunk/opensync/opensync.h Thu Oct 22 22:42:43 2009 (r5888) +++ trunk/opensync/opensync.h Thu Oct 22 23:28:15 2009 (r5889) @@ -140,10 +140,19 @@ * Enums *************************************************************/ +/*! @ingroup OSyncPlugin + * @brief The possible start types of a plugin or client proxy + * + * Determines how the sync process is to be run. + */ typedef enum { + /** The start type is unknown, there was an error */ OSYNC_START_TYPE_UNKNOWN, + /** Start as child process */ OSYNC_START_TYPE_PROCESS, + /** Start in a separate thread */ OSYNC_START_TYPE_THREAD, + /** Start as a separate external process */ OSYNC_START_TYPE_EXTERNAL } OSyncStartType; @@ -151,11 +160,11 @@ * @brief The possible returns of a change comparison */ typedef enum { - /** The result is unknown, there was a error */ + /** The result is unknown, there was an error */ OSYNC_CONV_DATA_UNKNOWN = 0, /** The changes are not the same */ OSYNC_CONV_DATA_MISMATCH = 1, - /** The changs are not the same but look similar */ + /** The changes are not the same but look similar */ OSYNC_CONV_DATA_SIMILAR = 2, /** The changes are exactly the same */ OSYNC_CONV_DATA_SAME = 3 |
From: <svn...@op...> - 2009-10-22 20:42:56
|
Author: cdfrey Date: Thu Oct 22 22:42:43 2009 New Revision: 5888 URL: http://www.opensync.org/changeset/5888 Log: Fixed "out of memory" bug where xmlformat->child_count == 0 Modified: trunk/opensync/xmlformat/opensync_xmlformat.c Modified: trunk/opensync/xmlformat/opensync_xmlformat.c ============================================================================== --- trunk/opensync/xmlformat/opensync_xmlformat.c Thu Oct 22 22:22:11 2009 (r5887) +++ trunk/opensync/xmlformat/opensync_xmlformat.c Thu Oct 22 22:42:43 2009 (r5888) @@ -177,6 +177,9 @@ if (!xmlfieldlist) goto error; + if (xmlformat->child_count == 0) + goto empty; /* nothing to do */ + liste = osync_try_malloc0(sizeof(OSyncXMLField *) * xmlformat->child_count, error); if (!liste) goto error; @@ -233,7 +236,7 @@ xmlFreeNode(key->node); g_free(key); g_free(liste); - + empty: osync_trace(TRACE_EXIT, "%s: %p", __func__, xmlfieldlist); return xmlfieldlist; |
From: <svn...@op...> - 2009-10-22 20:22:29
|
Author: cdfrey Date: Thu Oct 22 22:22:11 2009 New Revision: 5887 URL: http://www.opensync.org/changeset/5887 Log: Added explanation message of why we're running out of memory Modified: trunk/opensync/common/opensync_memory.c Modified: trunk/opensync/common/opensync_memory.c ============================================================================== --- trunk/opensync/common/opensync_memory.c Thu Oct 22 17:20:12 2009 (r5886) +++ trunk/opensync/common/opensync_memory.c Thu Oct 22 22:22:11 2009 (r5887) @@ -35,7 +35,7 @@ #endif /*OPENSYNC_UNITTESTS*/ if (!result) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "No memory left"); + osync_error_set(error, OSYNC_ERROR_GENERIC, "No memory left (tried to allocate %u bytes)", size); return NULL; } memset(result, 0, size); |
From: <svn...@op...> - 2009-10-22 15:20:25
|
Author: henrik Date: Thu Oct 22 17:20:12 2009 New Revision: 5886 URL: http://www.opensync.org/changeset/5886 Log: Look also for thunderbird/nspr in incude directories. Add nspr4 libraries under Windows Modified: branches/3rd-party-cmake-modules/modules/FindThunderbirdXpcom.cmake Modified: branches/3rd-party-cmake-modules/modules/FindThunderbirdXpcom.cmake ============================================================================== --- branches/3rd-party-cmake-modules/modules/FindThunderbirdXpcom.cmake Thu Oct 22 17:18:43 2009 (r5885) +++ branches/3rd-party-cmake-modules/modules/FindThunderbirdXpcom.cmake Thu Oct 22 17:20:12 2009 (r5886) @@ -42,7 +42,7 @@ MESSAGE ( FATAL_ERROR "*** *** Did not find Thunderbird include directory with mozilla-config.h" ) ENDIF ( NOT THUNDERBIRD_XPCOM_MAIN_INCLUDE_DIR ) FIND_PATH ( NSPR_MAIN_INCLUDE_DIR nspr.h - PATH_SUFFIXES nspr nspr4 + PATH_SUFFIXES nspr nspr4 thunderbird/nspr PATHS /opt/local/include/ /sw/include/ @@ -124,6 +124,9 @@ # Thunderbird 3 IF ( THUNDERBIRD_VERSION_MAIN STREQUAL "3" ) SET ( THUNDERBIRD_XPCOM_LIBRARIES "xpcomglue_s;xpcom" ) + IF ( WIN32 ) + SET ( THUNDERBIRD_XPCOM_LIBRARIES "xpcomglue_s;xpcom;nspr4" ) + ENDIF ( WIN32 ) ENDIF ( THUNDERBIRD_VERSION_MAIN STREQUAL "3" ) # So, by now we should have the following variables set: |
From: <svn...@op...> - 2009-10-22 15:19:02
|
Author: henrik Date: Thu Oct 22 17:18:43 2009 New Revision: 5885 URL: http://www.opensync.org/changeset/5885 Log: Corrected LOG handling for Windows Modified: plugins/mozilla-sync/trunk/src/nsProfileDirServiceProvider.cpp Modified: plugins/mozilla-sync/trunk/src/nsProfileDirServiceProvider.cpp ============================================================================== --- plugins/mozilla-sync/trunk/src/nsProfileDirServiceProvider.cpp Thu Oct 22 17:18:16 2009 (r5884) +++ plugins/mozilla-sync/trunk/src/nsProfileDirServiceProvider.cpp Thu Oct 22 17:18:43 2009 (r5885) @@ -54,12 +54,18 @@ #include "nsProfileDirServiceProvider.h" +#ifdef _WIN32 +#ifndef __func__ +#define __func__ __FUNCTION__ +#endif +#endif + // Define NSPROFILEDIRSERVICEPROVIDER_DEBUG to get a message on stdout when functions are called. // Handy when nothing works, and you have to figure out if the service was used at all... #define NSPROFILEDIRSERVICEPROVIDER_DEBUG 1 #ifdef NSPROFILEDIRSERVICEPROVIDER_DEBUG -#define LOG(level, message ...) \ - { printf("nsProfileDirServiceProvider::%s(%d): ", __func__, __LINE__); printf(message); printf("\n"); } +#define LOG(level, message, ...) \ + { printf("nsProfileDirServiceProvider::%s(%d): ", __func__, __LINE__); printf(message,## __VA_ARGS__); printf("\n"); } #else #define LOG(level, message, ...) #endif |
From: <svn...@op...> - 2009-10-22 15:18:30
|
Author: henrik Date: Thu Oct 22 17:18:16 2009 New Revision: 5884 URL: http://www.opensync.org/changeset/5884 Log: Additional message for debugging Modified: plugins/mozilla-sync/trunk/src/CMakeLists.txt Modified: plugins/mozilla-sync/trunk/src/CMakeLists.txt ============================================================================== --- plugins/mozilla-sync/trunk/src/CMakeLists.txt Thu Oct 22 17:17:42 2009 (r5883) +++ plugins/mozilla-sync/trunk/src/CMakeLists.txt Thu Oct 22 17:18:16 2009 (r5884) @@ -63,6 +63,7 @@ SET_TARGET_PROPERTIES(mozilla-sync PROPERTIES SKIP_BUILD_RPATH yes) ENDIF (XPCOM_GLUE) +MESSAGE ( STATUS "XPCOM_LIBRARIES=[${XPCOM_LIBRARIES}]" ) TARGET_LINK_LIBRARIES( mozilla-sync ${OPENSYNC_LIBRARIES} ${XPCOM_LIBRARIES} ${ICAL_LIBRARIES} ${LIBXML2_LIBRARIES} ${GLIB2_LIBRARIES} ) |
From: <svn...@op...> - 2009-10-22 15:17:56
|
Author: henrik Date: Thu Oct 22 17:17:42 2009 New Revision: 5883 URL: http://www.opensync.org/changeset/5883 Log: Minor corrections for the dummy Thunderbird 3 implementation Modified: plugins/mozilla-sync/trunk/src/thunderbird-card.cpp Modified: plugins/mozilla-sync/trunk/src/thunderbird-card.cpp ============================================================================== --- plugins/mozilla-sync/trunk/src/thunderbird-card.cpp Thu Oct 22 09:32:35 2009 (r5882) +++ plugins/mozilla-sync/trunk/src/thunderbird-card.cpp Thu Oct 22 17:17:42 2009 (r5883) @@ -416,7 +416,6 @@ #ifdef TBIRD_3 nsString s; s=NS_ConvertUTF8toUTF16(sz); - MOZ_ERROR_CHECK_FALSE(rv, "NS_ConvertUTF8toUTF16"); rv=myCard->SetPropertyAsAString(pXmlEntryDef->szProperty, s); #else PRUnichar *c16=NS_strdup(NS_ConvertUTF8toUTF16(sz).get()); @@ -625,6 +624,7 @@ nsCString cs; rv=myCard->GetPropertyAsAUTF8String(OPEN_SYNC_KEY, cs); MOZ_ERROR_CHECK(rv, "nsIAbMDBCard::GetStringAttribute"); + return "x"; #else @@ -688,6 +688,7 @@ #ifdef TBIRD_3 gchar *sz; GET_PROPERTY(myCard, "LastModifiedDate", sz) + return sz; #else PRUint32 kk; rv=myCard->GetLastModifiedDate(&kk); |