changeset 5838:6aa7651c7c15

[gaim-migrate @ 6269] regain the ability to remember what plugins we had loaded committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Thu, 12 Jun 2003 05:01:11 +0000
parents a48c338dff6c
children 5e685e42931e
files src/main.c src/plugin.c src/plugin.h src/prefs.c
diffstat 4 files changed, 85 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/src/main.c	Thu Jun 12 04:20:08 2003 +0000
+++ b/src/main.c	Thu Jun 12 05:01:11 2003 +0000
@@ -914,6 +914,8 @@
 		gaim_prefs_sync();
 	}
 
+	/* load plugins we had when we quit */
+	gaim_plugins_load_all();
 
 	gaim_accounts_load();
 
--- a/src/plugin.c	Thu Jun 12 04:20:08 2003 +0000
+++ b/src/plugin.c	Thu Jun 12 05:01:11 2003 +0000
@@ -144,6 +144,26 @@
 
 #endif /* GAIM_PLUGINS */
 
+static void
+update_plugin_prefs(void)
+{
+	GList *pl;
+	GList *files = NULL;
+	GaimPlugin *p;
+
+	for (pl = gaim_plugins_get_loaded(); pl != NULL; pl = pl->next) {
+		p = pl->data;
+
+		if(p->info->type != GAIM_PLUGIN_PROTOCOL &&
+				p->info->type != GAIM_PLUGIN_LOADER) {
+			files = g_list_append(files, p->path);
+		}
+	}
+
+	gaim_prefs_set_string_list("/plugins/loaded", files);
+	g_list_free(files);
+}
+
 static gint
 compare_prpl(GaimPlugin *a, GaimPlugin *b)
 {
@@ -290,6 +310,7 @@
 	}
 
 	loaded_plugins = g_list_append(loaded_plugins, plugin);
+	update_plugin_prefs();
 
 	plugin->loaded = TRUE;
 
@@ -311,6 +332,7 @@
 	g_return_val_if_fail(plugin != NULL, FALSE);
 
 	loaded_plugins = g_list_remove(loaded_plugins, plugin);
+	update_plugin_prefs();
 
 	g_return_val_if_fail(gaim_plugin_is_loaded(plugin), FALSE);
 
@@ -523,6 +545,23 @@
 
 #endif /* GAIM_PLUGINS */
 }
+
+void
+gaim_plugins_load_all(void)
+{
+#ifdef GAIM_PLUGINS
+	GList *f, *files = gaim_prefs_get_string_list("/plugins/loaded");
+
+	for(f = files; f; f = f->next) {
+		gaim_plugin_load(gaim_plugin_probe(f->data));
+		g_free(f->data);
+	}
+
+	g_list_free(files);
+#endif /* GAIM_PLUGINS */
+}
+
+
 void
 gaim_plugins_probe(const char *ext)
 {
--- a/src/plugin.h	Thu Jun 12 04:20:08 2003 +0000
+++ b/src/plugin.h	Thu Jun 12 05:01:11 2003 +0000
@@ -250,6 +250,11 @@
 void gaim_plugins_destroy_all(void);
 
 /**
+ * Attempts to load all the plugins that were loaded when gaim last quit
+ */
+void gaim_plugins_load_all(void);
+
+/**
  * Probes for plugins in the registered module paths.
  *
  * @param ext The extension type to probe for, or @c NULL for all.
--- a/src/prefs.c	Thu Jun 12 04:20:08 2003 +0000
+++ b/src/prefs.c	Thu Jun 12 05:01:11 2003 +0000
@@ -100,6 +100,7 @@
 	gaim_prefs_add_none("/plugins/core");
 	gaim_prefs_add_none("/plugins/lopl");
 	gaim_prefs_add_none("/plugins/prpl");
+	gaim_prefs_add_string_list("/plugins/loaded", NULL);
 
 	/* XXX: this is where you would want to put prefs declarations */
 
@@ -763,43 +764,53 @@
 	}
 
 	if(!strcmp(element_name, "item")) {
-		struct gaim_pref *pref = find_pref(prefs_stack->data);
+		struct gaim_pref *pref;
+
+		pref_name_full = g_string_new("");
+
+		for(tmp = prefs_stack; tmp; tmp = tmp->next) {
+			pref_name_full = g_string_prepend(pref_name_full, tmp->data);
+			pref_name_full = g_string_prepend_c(pref_name_full, '/');
+		}
+
+		pref = find_pref(pref_name_full->str);
+
 		if(pref) {
 			pref->value.stringlist = g_list_append(pref->value.stringlist,
 					g_strdup(pref_value));
 		}
-		return;
-	} else if(!pref_name || !strcmp(pref_name, "/")) {
-		return;
-	}
+	} else {
+		if(!pref_name || !strcmp(pref_name, "/"))
+			return;
 
-	pref_name_full = g_string_new(pref_name);
+		pref_name_full = g_string_new(pref_name);
 
-	for(tmp = prefs_stack; tmp; tmp = tmp->next) {
+		for(tmp = prefs_stack; tmp; tmp = tmp->next) {
+			pref_name_full = g_string_prepend_c(pref_name_full, '/');
+			pref_name_full = g_string_prepend(pref_name_full, tmp->data);
+		}
+
 		pref_name_full = g_string_prepend_c(pref_name_full, '/');
-		pref_name_full = g_string_prepend(pref_name_full, tmp->data);
-	}
-
-	pref_name_full = g_string_prepend_c(pref_name_full, '/');
 
-	switch(pref_type) {
-		case GAIM_PREF_NONE:
-			break;
-		case GAIM_PREF_BOOLEAN:
-			gaim_prefs_set_bool(pref_name_full->str, atoi(pref_value));
-			break;
-		case GAIM_PREF_INT:
-			gaim_prefs_set_int(pref_name_full->str, atoi(pref_value));
-			break;
-		case GAIM_PREF_STRING:
-			gaim_prefs_set_string(pref_name_full->str, pref_value);
-			break;
-		case GAIM_PREF_STRING_LIST:
-			break;
+		switch(pref_type) {
+			case GAIM_PREF_NONE:
+				break;
+			case GAIM_PREF_BOOLEAN:
+				gaim_prefs_set_bool(pref_name_full->str, atoi(pref_value));
+				break;
+			case GAIM_PREF_INT:
+				gaim_prefs_set_int(pref_name_full->str, atoi(pref_value));
+				break;
+			case GAIM_PREF_STRING:
+				gaim_prefs_set_string(pref_name_full->str, pref_value);
+				break;
+			case GAIM_PREF_STRING_LIST:
+				gaim_prefs_set_string_list(pref_name_full->str, NULL);
+				break;
+		}
+		prefs_stack = g_list_prepend(prefs_stack, g_strdup(pref_name));
+		g_string_free(pref_name_full, TRUE);
 	}
-
-	prefs_stack = g_list_prepend(prefs_stack, g_strdup(pref_name));
-	g_string_free(pref_name_full, TRUE);
 }
 
 static void prefs_end_element_handler(GMarkupParseContext *context,