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_ */ |