comparison 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
comparison
equal deleted inserted replaced
141:f90b022235fe 142:fbabd28795d2
141 return 0; 141 return 0;
142 } else if (!strcmp(tag, "options")) { 142 } else if (!strcmp(tag, "options")) {
143 return 1; 143 return 1;
144 } else if (!strcmp(tag, "away")) { 144 } else if (!strcmp(tag, "away")) {
145 return 2; 145 return 2;
146 } else if (!strcmp(tag, "plugins")) {
147 return 3;
146 } 148 }
147 149
148 return -1; 150 return -1;
149 } 151 }
150 152
230 } 232 }
231 233
232 fprintf(f, "}\n"); 234 fprintf(f, "}\n");
233 } 235 }
234 236
235 237 #ifdef GAIM_PLUGINS
236 238 static void gaimrc_write_plugins(FILE *f)
239 {
240 GList *pl = plugins;
241 struct gaim_plugin *p;
242
243 fprintf(f, "plugins {\n");
244
245 while (pl) {
246 char *path;
247
248 p = (struct gaim_plugin *)pl->data;
249
250 path = escape_text2(p->filename);
251
252 fprintf(f, "\tplugin { %s }\n", path);
253
254 free(path);
255
256 pl = pl->next;
257 }
258
259 fprintf(f, "}\n");
260 }
261
262 static void gaimrc_read_plugins(FILE *f)
263 {
264 struct parse *p;
265 char buf[4096];
266
267 buf[0] = 0;
268
269 while (buf[0] != '}')
270 {
271 if (!fgets(buf, sizeof(buf), f))
272 return;
273
274 if (buf[0] == '}')
275 return;
276
277 p = parse_line(buf);
278 if (!strcmp(p->option, "plugin"))
279 {
280 load_plugin(p->value[0]);
281 }
282 }
283 }
284 #endif /* GAIM_PLUGINS */
237 285
238 static struct aim_user *gaimrc_read_user(FILE *f) 286 static struct aim_user *gaimrc_read_user(FILE *f)
239 { 287 {
240 struct parse *p; 288 struct parse *p;
241 struct aim_user *u; 289 struct aim_user *u;
518 gaimrc_read_options(f); 566 gaimrc_read_options(f);
519 break; 567 break;
520 case 2: 568 case 2:
521 gaimrc_read_away(f); 569 gaimrc_read_away(f);
522 break; 570 break;
571 #ifdef GAIM_PLUGINS
572 case 3:
573 gaimrc_read_plugins(f);
574 break;
575 #endif
523 default: 576 default:
524 /* NOOP */ 577 /* NOOP */
525 break; 578 break;
526 } 579 }
527 } 580 }
541 if ((f = fopen(buf,"w"))) { 594 if ((f = fopen(buf,"w"))) {
542 fprintf(f, "# .gaimrc v%d\n", 2); 595 fprintf(f, "# .gaimrc v%d\n", 2);
543 gaimrc_write_users(f); 596 gaimrc_write_users(f);
544 gaimrc_write_options(f); 597 gaimrc_write_options(f);
545 gaimrc_write_away(f); 598 gaimrc_write_away(f);
599 #ifdef GAIM_PLUGINS
600 gaimrc_write_plugins(f);
601 #endif
546 fclose(f); 602 fclose(f);
547 chmod(buf, S_IRUSR | S_IWUSR); 603 chmod(buf, S_IRUSR | S_IWUSR);
548 } 604 }
549 605
550 } 606 }