diff src/plugins.c @ 142:fbabd28795d2

[gaim-migrate @ 152] Added auto-load for plugins. Rob pointed out this might be a bad idea: what if plugins modify the buddy list; the plugins are loaded before signon, thus before the buddy list appears. That would cause errors; then when the list does appear, the plugin doesn't work right because it didn't start off well. My response: EWarmenhoven: there are ways around that EWarmenhoven: in gaim_plugin_init you could have: EWarmenhoven: if (blist) { do_the_normal_thing(); } else { gaim_signal_connect(handle, event_signon, now_the_buddy_list_is_here, NULL); } EWarmenhoven: and actually, that's the way it should be for all plugins that modify the buddy list, because there will be at least one point during execution that it could be loaded when the person is signed off (and i'm not talking about when they first start it up, i'm talking about when they choose 'sign off' instead of 'close' in the buddy list menu) committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Thu, 20 Apr 2000 00:12:58 +0000
parents c009c4f4ad02
children 8ed64c704fb0
line wrap: on
line diff
--- a/src/plugins.c	Wed Apr 19 22:36:38 2000 +0000
+++ b/src/plugins.c	Thu Apr 20 00:12:58 2000 +0000
@@ -46,12 +46,12 @@
 
 /* ------------------ Global Variables ----------------------- */
 
+GList *plugins   = NULL;
 GList *callbacks = NULL;
 
 /* ------------------ Local Variables ------------------------ */
 
 static GtkWidget *plugin_dialog = NULL;
-static GList     *plugins = NULL;
 
 static GtkWidget *pluglist;
 static GtkWidget *plugtext;
@@ -62,12 +62,13 @@
 /* --------------- Function Declarations --------------------- */
 
        void show_plugins (GtkWidget *, gpointer);
+       void load_plugin  (char *);
 
        void gaim_signal_connect   (void *, enum gaim_event, void *, void *);
        void gaim_signal_disconnect(void *, enum gaim_event, void *);
 
 static void destroy_plugins  (GtkWidget *, gpointer);
-static void load_plugin  (GtkWidget *, gpointer);
+static void load_file        (GtkWidget *, gpointer);
 static void load_which_plugin(GtkWidget *, gpointer);
 static void unload           (GtkWidget *, gpointer);
 static void list_clicked     (GtkWidget *, struct gaim_plugin *);
@@ -82,7 +83,7 @@
 	plugin_dialog = NULL;
 }
 
-static void load_plugin(GtkWidget *w, gpointer data)
+static void load_file(GtkWidget *w, gpointer data)
 {
 	char *buf = g_malloc(BUF_LEN);
  
@@ -120,14 +121,22 @@
 }
 
 static void load_which_plugin(GtkWidget *w, gpointer data) {
+	load_plugin(gtk_file_selection_get_filename(
+					GTK_FILE_SELECTION(plugin_dialog)));
+
+	if (plugin_dialog)
+		gtk_widget_destroy(plugin_dialog);
+	plugin_dialog = NULL;
+}
+
+void load_plugin(char *filename) {
 	struct gaim_plugin *plug;
 	void (*gaim_plugin_init)();
 	char *(*cfunc)();
 	char *error;
 
 	plug = g_malloc(sizeof *plug);
-	plug->filename = g_strdup(gtk_file_selection_get_filename(
-					GTK_FILE_SELECTION(plugin_dialog)));
+	plug->filename = g_strdup(filename);
 	/* do NOT OR with RTLD_GLOBAL, otherwise plugins may conflict
 	 * (it's really just a way to work around other people's bad
 	 * programming, by not using RTLD_GLOBAL :P ) */
@@ -139,10 +148,6 @@
 		return;
 	}
 
-	if (plugin_dialog)
-		gtk_widget_destroy(plugin_dialog);
-	plugin_dialog = NULL;
-
 	gaim_plugin_init = dlsym(plug->handle, "gaim_plugin_init");
 	if ((error = (char *)dlerror()) != NULL) {
 		do_error_dialog(error, "Plugin Error");
@@ -222,7 +227,7 @@
 
 	add = gtk_button_new_with_label("Load Plugin");
 	gtk_signal_connect(GTK_OBJECT(add), "clicked",
-			   GTK_SIGNAL_FUNC(load_plugin), NULL);
+			   GTK_SIGNAL_FUNC(load_file), NULL);
 	gtk_box_pack_start(GTK_BOX(botbox), add, TRUE, FALSE, 5);
 
 	config = gtk_button_new_with_label("Configure Plugin");