|
From: <svn...@op...> - 2009-11-02 12:49:44
|
Author: dgollub Date: Mon Nov 2 13:49:22 2009 New Revision: 5914 URL: http://www.opensync.org/changeset/5914 Log: Introduced internal interfaces: - osync_plugin_{set,get}_external_command This functions get and set the default plugin external command. The default external_command value is set inside the XML external plugin configuration file. Once this configuration file got parsed (during plugin_env_load phase) osync_plugin_get_external_command will return the default external_command. If none external_command is set in the indiviual plugin-member-configuration (aka. OSyncPuginConfig) the external_command of OSyncPlugin gets used (osync_plugin_get_external_command) to spawn the external process. Modified: trunk/opensync/client/opensync_client_proxy.c trunk/opensync/engine/opensync_engine.c trunk/opensync/plugin/opensync_plugin.c trunk/opensync/plugin/opensync_plugin_env.c trunk/opensync/plugin/opensync_plugin_internals.h trunk/opensync/plugin/opensync_plugin_private.h Modified: trunk/opensync/client/opensync_client_proxy.c ============================================================================== --- trunk/opensync/client/opensync_client_proxy.c Mon Nov 2 13:27:58 2009 (r5913) +++ trunk/opensync/client/opensync_client_proxy.c Mon Nov 2 13:49:22 2009 (r5914) @@ -963,7 +963,7 @@ char *writefd = NULL; char *name = NULL; - osync_trace(TRACE_ENTRY, "%s(%p, %i, %s, %p)", __func__, proxy, type, path, error); + osync_trace(TRACE_ENTRY, "%s(%p, %i, %s, %s, %p)", __func__, proxy, type, path, __NULLSTR(external_command), error); osync_assert(proxy); osync_assert(type != OSYNC_START_TYPE_UNKNOWN); Modified: trunk/opensync/engine/opensync_engine.c ============================================================================== --- trunk/opensync/engine/opensync_engine.c Mon Nov 2 13:27:58 2009 (r5913) +++ trunk/opensync/engine/opensync_engine.c Mon Nov 2 13:49:22 2009 (r5914) @@ -36,6 +36,7 @@ #include "group/opensync_member_internals.h" #include "format/opensync_objformat_internals.h" #include "common/opensync_marshal_internals.h" +#include "plugin/opensync_plugin_internals.h" #include "opensync_status_internals.h" #include "opensync_obj_engine_internals.h" @@ -790,7 +791,7 @@ * command, if available */ if (!external_command) { - /* TODO: Grahams code to retrieve the external_command from the external-plugin config */ + external_command = osync_plugin_get_external_command(plugin); } } Modified: trunk/opensync/plugin/opensync_plugin.c ============================================================================== --- trunk/opensync/plugin/opensync_plugin.c Mon Nov 2 13:27:58 2009 (r5913) +++ trunk/opensync/plugin/opensync_plugin.c Mon Nov 2 13:49:22 2009 (r5914) @@ -65,6 +65,9 @@ if (plugin->description) osync_free(plugin->description); + + if (plugin->external_command) + osync_free(plugin->external_command); osync_free(plugin); } @@ -112,6 +115,20 @@ plugin->description = osync_strdup(description); } +const char *osync_plugin_get_external_command(OSyncPlugin *plugin) +{ + osync_assert(plugin); + return plugin->external_command; +} + +void osync_plugin_set_external_command(OSyncPlugin *plugin, const char *external_command) +{ + osync_assert(plugin); + if (plugin->external_command) + osync_free(plugin->external_command); + plugin->external_command = osync_strdup(external_command); +} + void *osync_plugin_get_data(OSyncPlugin *plugin) { osync_assert(plugin); Modified: trunk/opensync/plugin/opensync_plugin_env.c ============================================================================== --- trunk/opensync/plugin/opensync_plugin_env.c Mon Nov 2 13:27:58 2009 (r5913) +++ trunk/opensync/plugin/opensync_plugin_env.c Mon Nov 2 13:49:22 2009 (r5914) @@ -23,6 +23,7 @@ #include "opensync-module.h" #include "module/opensync_module_internals.h" +#include "plugin/opensync_plugin_internals.h" #include "opensync-plugin.h" #include "opensync_plugin_env_internals.h" @@ -291,6 +292,11 @@ osync_plugin_set_description(plugin, description); osync_plugin_set_start_type(plugin, OSYNC_START_TYPE_EXTERNAL); + if (command) { + osync_plugin_set_external_command(plugin, command); + osync_free(command); + } + if (!osync_plugin_env_register_plugin(env, plugin, error)) { osync_plugin_unref(plugin); goto error_free_module; Modified: trunk/opensync/plugin/opensync_plugin_internals.h ============================================================================== --- trunk/opensync/plugin/opensync_plugin_internals.h Mon Nov 2 13:27:58 2009 (r5913) +++ trunk/opensync/plugin/opensync_plugin_internals.h Mon Nov 2 13:49:22 2009 (r5914) @@ -33,6 +33,29 @@ /*@{*/ +/** @brief Get default external command of the plugin + * + * The default external command is set in the plugin external configuration (XML) file + * + * @param plugin The plugin to check + * @returns external command as const-char* string if a command is set, NULL otherwise. + * + */ +OSYNC_TEST_EXPORT const char *osync_plugin_get_external_command(OSyncPlugin *plugin); + +/** @brief Get default external command of the plugin + * + * External command as const-char* string get substitued with the pipe-path. + * For this, one %s is required, which will be substriuted with the pipe-path. + * + * Example: /usr/local/bin/foobar --pipe %s + * + * @param plugin The plugin to check + * @param external_command External command as const-char* string like-printf with %s which get substitured with pipe-path + * + */ +OSYNC_TEST_EXPORT void osync_plugin_set_external_command(OSyncPlugin *plugin, const char *external_command); + /** @brief Checks if a plugin is available and usable * * @param plugin The plugin to check Modified: trunk/opensync/plugin/opensync_plugin_private.h ============================================================================== --- trunk/opensync/plugin/opensync_plugin_private.h Mon Nov 2 13:27:58 2009 (r5913) +++ trunk/opensync/plugin/opensync_plugin_private.h Mon Nov 2 13:49:22 2009 (r5914) @@ -53,6 +53,10 @@ char *longname; /** A short description what the plugin does */ char *description; + + /** Default external command (optional) */ + char *external_command; + /** The function to initialize the plugin. */ initialize_fn initialize; /** The function to finalize the plugin. The input will be the output of the initialize function */ |