diff src/gaimrc.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 350d88f043b6
children 595c26ef5527
line wrap: on
line diff
--- a/src/gaimrc.c	Wed Apr 19 22:36:38 2000 +0000
+++ b/src/gaimrc.c	Thu Apr 20 00:12:58 2000 +0000
@@ -143,6 +143,8 @@
 		return 1;
 	} else if (!strcmp(tag, "away")) {
 		return 2;
+	} else if (!strcmp(tag, "plugins")) {
+		return 3;
 	}
 
 	return -1;
@@ -232,8 +234,54 @@
 	fprintf(f, "}\n");
 }
 
+#ifdef GAIM_PLUGINS
+static void gaimrc_write_plugins(FILE *f)
+{
+	GList *pl = plugins;
+	struct gaim_plugin *p;
 
+	fprintf(f, "plugins {\n");
 
+	while (pl) {
+		char *path;
+
+		p = (struct gaim_plugin *)pl->data;
+
+		path = escape_text2(p->filename);
+
+		fprintf(f, "\tplugin { %s }\n", path);
+
+		free(path);
+
+		pl = pl->next;
+	}
+
+	fprintf(f, "}\n");
+}
+
+static void gaimrc_read_plugins(FILE *f)
+{
+	struct parse *p;
+	char buf[4096];
+
+	buf[0] = 0;
+	
+	while (buf[0] != '}')
+	{
+		if (!fgets(buf, sizeof(buf), f))
+			return;
+		
+		if (buf[0] == '}')
+			return;
+
+		p = parse_line(buf);
+		if (!strcmp(p->option, "plugin"))
+		{
+			load_plugin(p->value[0]);
+		}
+	}
+}
+#endif /* GAIM_PLUGINS */
 
 static struct aim_user *gaimrc_read_user(FILE *f)
 {
@@ -520,6 +568,11 @@
                                 case 2:
                                         gaimrc_read_away(f);
                                         break;
+#ifdef GAIM_PLUGINS
+				case 3:
+					gaimrc_read_plugins(f);
+					break;
+#endif
 				default:
 					/* NOOP */
 					break;
@@ -543,6 +596,9 @@
 			gaimrc_write_users(f);
                         gaimrc_write_options(f);
                         gaimrc_write_away(f);
+#ifdef GAIM_PLUGINS
+			gaimrc_write_plugins(f);
+#endif
                         fclose(f);
                         chmod(buf, S_IRUSR | S_IWUSR);
                 }