changeset 10479:12460aa2c820

[gaim-migrate @ 11766] grim made me do it committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Thu, 06 Jan 2005 06:16:50 +0000
parents d497f3a2686f
children 8e0a91d11362
files src/core.c src/plugin.c src/plugin.h
diffstat 3 files changed, 64 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- 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) {
--- 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)
 	{
--- 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.