# HG changeset patch # User Nathan Walp # Date 1104992210 0 # Node ID 12460aa2c820720ef6a54a1df9ad4f349e57664e # Parent d497f3a2686f9149a37e12b9f6c2b4d45b7876f1 [gaim-migrate @ 11766] grim made me do it committer: Tailor Script diff -r d497f3a2686f -r 12460aa2c820 src/core.c --- a/src/core.c Thu Jan 06 05:49:36 2005 +0000 +++ b/src/core.c Thu Jan 06 06:16:50 2005 +0000 @@ -78,6 +78,10 @@ /* Initialize all static protocols. */ static_proto_init(); + /* Since plugins get probed so early we should probably initialize their + * subsystem right away too. + */ + gaim_plugins_init(); gaim_plugins_probe(NULL); if (ops != NULL) @@ -145,6 +149,7 @@ if (ops != NULL && ops->quit != NULL) ops->quit(); + gaim_plugins_uninit(); gaim_signals_uninit(); if (core->ui != NULL) { diff -r d497f3a2686f -r 12460aa2c820 src/plugin.c --- a/src/plugin.c Thu Jan 06 05:49:36 2005 +0000 +++ b/src/plugin.c Thu Jan 06 06:16:50 2005 +0000 @@ -33,11 +33,11 @@ #ifdef _WIN32 # define PLUGIN_EXT ".dll" #else -#ifdef __hpux -# define PLUGIN_EXT ".sl" -#else -# define PLUGIN_EXT ".so" -#endif +# ifdef __hpux +# define PLUGIN_EXT ".sl" +# else +# define PLUGIN_EXT ".so" +# endif #endif typedef struct @@ -72,16 +72,6 @@ static void (*unload_cb)(GaimPlugin *, void *) = NULL; static void *unload_cb_data = NULL; - -void * -gaim_plugins_get_handle(void) -{ - static int handle; - - return &handle; -} - - #ifdef GAIM_PLUGINS static gboolean has_file_extension(const char *filename, const char *ext) @@ -787,6 +777,37 @@ /************************************************************************** * Plugins subsystem **************************************************************************/ +void * +gaim_plugins_get_handle(void) { + static int handle; + + return &handle; +} + +void +gaim_plugins_init(void) { + void *handle = gaim_plugins_get_handle(); + + gaim_signal_register(handle, "plugin-load", + gaim_marshal_VOID__POINTER, + NULL, 1, + gaim_value_new(GAIM_TYPE_SUBTYPE, + GAIM_SUBTYPE_PLUGIN)); + gaim_signal_register(handle, "plugin-unload", + gaim_marshal_VOID__POINTER, + NULL, 1, + gaim_value_new(GAIM_TYPE_SUBTYPE, + GAIM_SUBTYPE_PLUGIN)); +} + +void +gaim_plugins_uninit(void) { + gaim_signals_disconnect_by_handle(gaim_plugins_get_handle()); +} + +/************************************************************************** + * Plugins API + **************************************************************************/ void gaim_plugins_add_search_path(const char *path) { @@ -871,23 +892,9 @@ GList *cur; const char *search_path; - void *handle; - if (!g_module_supported()) return; - handle = gaim_plugins_get_handle(); - - /* TODO: These signals need to be registered in an init function */ - gaim_debug_info("plugins", "registering plugin-load signal\n"); - gaim_signal_register(handle, "plugin-load", gaim_marshal_VOID__POINTER, NULL, - 1, gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_PLUGIN)); - - gaim_debug_info("plugins", "registering plugin-unload signal\n"); - gaim_signal_register(handle, "plugin-unload", gaim_marshal_VOID__POINTER, NULL, - 1, gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_PLUGIN)); - - /* Probe plugins */ for (cur = search_paths; cur != NULL; cur = cur->next) { diff -r d497f3a2686f -r 12460aa2c820 src/plugin.h --- a/src/plugin.h Thu Jan 06 05:49:36 2005 +0000 +++ b/src/plugin.h Thu Jan 06 06:16:50 2005 +0000 @@ -193,10 +193,6 @@ extern "C" { #endif - -void *gaim_plugins_get_handle(void); - - /**************************************************************************/ /** @name Plugin API */ /**************************************************************************/ @@ -517,6 +513,29 @@ /*@}*/ +/**************************************************************************/ +/** @name Plugins SubSytem API */ +/**************************************************************************/ +/*@{*/ + +/** + * Returns the plugin subsystem handle. + * + * @return The plugin sybsystem handle. + */ +void *gaim_plugins_get_handle(void); + +/** + * Initializes the plugin subsystem + */ +void gaim_plugins_init(void); + +/** + * Uninitializes the plugin subsystem + */ +void gaim_plugins_uninit(void); + +/*@}*/ /** * Allocates and returns a new GaimPluginAction.