Mercurial > pidgin
comparison src/plugin.c @ 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 | 5e93fc46d1af |
| children | 8f5ccf9e590a |
comparison
equal
deleted
inserted
replaced
| 5837:a48c338dff6c | 5838:6aa7651c7c15 |
|---|---|
| 142 return NULL; | 142 return NULL; |
| 143 } | 143 } |
| 144 | 144 |
| 145 #endif /* GAIM_PLUGINS */ | 145 #endif /* GAIM_PLUGINS */ |
| 146 | 146 |
| 147 static void | |
| 148 update_plugin_prefs(void) | |
| 149 { | |
| 150 GList *pl; | |
| 151 GList *files = NULL; | |
| 152 GaimPlugin *p; | |
| 153 | |
| 154 for (pl = gaim_plugins_get_loaded(); pl != NULL; pl = pl->next) { | |
| 155 p = pl->data; | |
| 156 | |
| 157 if(p->info->type != GAIM_PLUGIN_PROTOCOL && | |
| 158 p->info->type != GAIM_PLUGIN_LOADER) { | |
| 159 files = g_list_append(files, p->path); | |
| 160 } | |
| 161 } | |
| 162 | |
| 163 gaim_prefs_set_string_list("/plugins/loaded", files); | |
| 164 g_list_free(files); | |
| 165 } | |
| 166 | |
| 147 static gint | 167 static gint |
| 148 compare_prpl(GaimPlugin *a, GaimPlugin *b) | 168 compare_prpl(GaimPlugin *a, GaimPlugin *b) |
| 149 { | 169 { |
| 150 /* neg if a before b, 0 if equal, pos if a after b */ | 170 /* neg if a before b, 0 if equal, pos if a after b */ |
| 151 return ((GAIM_IS_PROTOCOL_PLUGIN(a) | 171 return ((GAIM_IS_PROTOCOL_PLUGIN(a) |
| 288 if (loader_info->load != NULL) | 308 if (loader_info->load != NULL) |
| 289 loader_info->load(plugin); | 309 loader_info->load(plugin); |
| 290 } | 310 } |
| 291 | 311 |
| 292 loaded_plugins = g_list_append(loaded_plugins, plugin); | 312 loaded_plugins = g_list_append(loaded_plugins, plugin); |
| 313 update_plugin_prefs(); | |
| 293 | 314 |
| 294 plugin->loaded = TRUE; | 315 plugin->loaded = TRUE; |
| 295 | 316 |
| 296 /* TODO */ | 317 /* TODO */ |
| 297 if (load_cb != NULL) | 318 if (load_cb != NULL) |
| 309 { | 330 { |
| 310 #ifdef GAIM_PLUGINS | 331 #ifdef GAIM_PLUGINS |
| 311 g_return_val_if_fail(plugin != NULL, FALSE); | 332 g_return_val_if_fail(plugin != NULL, FALSE); |
| 312 | 333 |
| 313 loaded_plugins = g_list_remove(loaded_plugins, plugin); | 334 loaded_plugins = g_list_remove(loaded_plugins, plugin); |
| 335 update_plugin_prefs(); | |
| 314 | 336 |
| 315 g_return_val_if_fail(gaim_plugin_is_loaded(plugin), FALSE); | 337 g_return_val_if_fail(gaim_plugin_is_loaded(plugin), FALSE); |
| 316 | 338 |
| 317 gaim_debug(GAIM_DEBUG_INFO, "plugins", "Unloading plugin %s\n", | 339 gaim_debug(GAIM_DEBUG_INFO, "plugins", "Unloading plugin %s\n", |
| 318 plugin->info->name); | 340 plugin->info->name); |
| 521 while (plugins != NULL) | 543 while (plugins != NULL) |
| 522 gaim_plugin_destroy(plugins->data); | 544 gaim_plugin_destroy(plugins->data); |
| 523 | 545 |
| 524 #endif /* GAIM_PLUGINS */ | 546 #endif /* GAIM_PLUGINS */ |
| 525 } | 547 } |
| 548 | |
| 549 void | |
| 550 gaim_plugins_load_all(void) | |
| 551 { | |
| 552 #ifdef GAIM_PLUGINS | |
| 553 GList *f, *files = gaim_prefs_get_string_list("/plugins/loaded"); | |
| 554 | |
| 555 for(f = files; f; f = f->next) { | |
| 556 gaim_plugin_load(gaim_plugin_probe(f->data)); | |
| 557 g_free(f->data); | |
| 558 } | |
| 559 | |
| 560 g_list_free(files); | |
| 561 #endif /* GAIM_PLUGINS */ | |
| 562 } | |
| 563 | |
| 564 | |
| 526 void | 565 void |
| 527 gaim_plugins_probe(const char *ext) | 566 gaim_plugins_probe(const char *ext) |
| 528 { | 567 { |
| 529 #ifdef GAIM_PLUGINS | 568 #ifdef GAIM_PLUGINS |
| 530 GDir *dir; | 569 GDir *dir; |
