Mercurial > pidgin
annotate src/plugin.c @ 5259:750e4801819f
[gaim-migrate @ 5631]
i didn't mean to commit that
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Tue, 29 Apr 2003 00:23:19 +0000 |
parents | f6e0c689a88b |
children | 503cc9b0a8ef |
rev | line source |
---|---|
5205 | 1 /* |
2 * gaim | |
3 * | |
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 */ | |
20 | |
21 /* | |
22 * ---------------- | |
23 * The Plug-in plugin | |
24 * | |
25 * Plugin support is currently being maintained by Mike Saraf | |
26 * msaraf@dwc.edu | |
27 * | |
28 * Well, I didn't see any work done on it for a while, so I'm going to try | |
29 * my hand at it. - Eric warmenhoven@yahoo.com | |
30 * | |
31 * Mike is my roomate. I can assure you that he's lazy :-P | |
32 * -- Rob rob@marko.net | |
33 * | |
34 * Yeah, well now I'm re-writing a good portion of it! The perl stuff was | |
35 * a hack. Tsk tsk! -- Christian <chipx86@gnupdate.org> | |
36 */ | |
37 | |
38 #ifdef HAVE_CONFIG_H | |
39 #include <config.h> | |
40 #endif | |
41 | |
42 #include "gaim.h" | |
43 #include "prpl.h" | |
44 #include "event.h" | |
45 | |
46 #include <string.h> | |
47 | |
48 #include <sys/types.h> | |
49 #include <sys/stat.h> | |
50 | |
51 #include <unistd.h> | |
52 #include <stdio.h> | |
53 #include <stdlib.h> | |
54 | |
55 #ifdef _WIN32 | |
56 #include "win32dep.h" | |
57 #endif | |
58 | |
59 #ifdef _WIN32 | |
60 # define PLUGIN_EXT ".dll" | |
61 #else | |
62 # define PLUGIN_EXT ".so" | |
63 #endif | |
64 | |
65 static GList *loaded_plugins = NULL; | |
66 static GList *plugins = NULL; | |
67 static GList *plugin_loaders = NULL; | |
68 | |
69 static size_t search_path_count = 0; | |
70 static char **search_paths = NULL; | |
71 | |
72 static void (*probe_cb)(void *) = NULL; | |
73 static void *probe_cb_data = NULL; | |
74 static void (*load_cb)(GaimPlugin *, void *) = NULL; | |
75 static void *load_cb_data = NULL; | |
76 static void (*unload_cb)(GaimPlugin *, void *) = NULL; | |
77 static void *unload_cb_data = NULL; | |
78 | |
79 #ifdef GAIM_PLUGINS | |
80 static int | |
81 is_so_file(const char *filename, const char *ext) | |
82 { | |
83 int len, extlen; | |
84 | |
85 if (filename == NULL || *filename == '\0' || ext == NULL) | |
86 return 0; | |
87 | |
88 extlen = strlen(ext); | |
89 len = strlen(filename) - extlen; | |
90 | |
91 if (len < 0) | |
92 return 0; | |
93 | |
94 return (!strncmp(filename + len, ext, extlen)); | |
95 } | |
96 | |
97 static gboolean | |
98 __loader_supports_file(GaimPlugin *loader, const char *filename) | |
99 { | |
100 GList *l, *exts; | |
101 GaimPlugin *plugin; | |
102 | |
103 for (l = plugin_loaders; l != NULL; l = l->next) { | |
104 plugin = l->data; | |
105 | |
106 for (exts = GAIM_PLUGIN_LOADER_INFO(plugin)->exts; | |
107 exts != NULL; | |
108 exts = exts->next) { | |
109 | |
110 if (is_so_file(filename, (char *)exts->data)) | |
111 return TRUE; | |
112 } | |
113 } | |
114 | |
115 return FALSE; | |
116 } | |
117 | |
118 static GaimPlugin * | |
119 __find_loader_for_plugin(const GaimPlugin *plugin) | |
120 { | |
121 GaimPlugin *loader; | |
122 GList *l; | |
123 | |
124 if (plugin->path == NULL) | |
125 return NULL; | |
126 | |
127 for (l = gaim_plugins_get_loaded(); l != NULL; l = l->next) { | |
128 loader = l->data; | |
129 | |
130 if (loader->info->type == GAIM_PLUGIN_LOADER && | |
131 __loader_supports_file(loader, plugin->path)) { | |
132 | |
133 return loader; | |
134 } | |
135 | |
136 loader = NULL; | |
137 } | |
138 | |
139 return NULL; | |
140 } | |
141 | |
142 static gint | |
143 compare_prpl(GaimPlugin *a, GaimPlugin *b) | |
144 { | |
145 /* neg if a before b, 0 if equal, pos if a after b */ | |
146 return ((GAIM_IS_PROTOCOL_PLUGIN(a) | |
147 ? GAIM_PLUGIN_PROTOCOL_INFO(a)->protocol : -1) - | |
148 ((GAIM_IS_PROTOCOL_PLUGIN(b) | |
149 ? GAIM_PLUGIN_PROTOCOL_INFO(b)->protocol : -1))); | |
150 } | |
151 | |
152 #endif /* GAIM_PLUGINS */ | |
153 | |
154 GaimPlugin * | |
155 gaim_plugin_new(gboolean native, const char *path) | |
156 { | |
157 GaimPlugin *plugin; | |
158 | |
159 plugin = g_new0(GaimPlugin, 1); | |
160 | |
161 plugin->native_plugin = native; | |
162 plugin->path = (path == NULL ? NULL : g_strdup(path)); | |
163 | |
164 return plugin; | |
165 } | |
166 | |
167 GaimPlugin * | |
168 gaim_plugin_probe(const char *filename) | |
169 { | |
170 #ifdef GAIM_PLUGINS | |
171 GaimPlugin *plugin = NULL; | |
172 GaimPlugin *loader; | |
173 gboolean (*gaim_init_plugin)(GaimPlugin *); | |
174 | |
175 g_return_val_if_fail(filename != NULL, NULL); | |
176 | |
177 plugin = gaim_plugins_find_with_filename(filename); | |
178 | |
179 if (plugin != NULL) | |
180 return plugin; | |
181 | |
182 plugin = gaim_plugin_new(is_so_file(filename, PLUGIN_EXT), filename); | |
183 | |
184 if (plugin->native_plugin) { | |
185 plugin->handle = g_module_open(filename, 0); | |
186 | |
187 if (plugin->handle == NULL) { | |
188 plugin->error = g_strdup(g_module_error()); | |
189 | |
190 return plugin; | |
191 } | |
192 | |
193 if (!g_module_symbol(plugin->handle, "gaim_init_plugin", | |
194 (gpointer *)&gaim_init_plugin)) { | |
195 g_module_close(plugin->handle); | |
196 plugin->handle = NULL; | |
197 | |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
198 gaim_debug(GAIM_DEBUG_ERROR, "plugins", "%s is unloadable: %s\n", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
199 plugin->path, g_module_error()); |
5205 | 200 |
201 gaim_plugin_destroy(plugin); | |
202 | |
203 return NULL; | |
204 } | |
205 } | |
206 else { | |
207 loader = __find_loader_for_plugin(plugin); | |
208 | |
209 if (loader == NULL) { | |
210 gaim_plugin_destroy(plugin); | |
211 | |
212 return NULL; | |
213 } | |
214 | |
215 gaim_init_plugin = GAIM_PLUGIN_LOADER_INFO(loader)->probe; | |
216 } | |
217 | |
218 plugin->error = NULL; | |
219 | |
220 if (!gaim_init_plugin(plugin) || plugin->info == NULL) { | |
221 char buf[BUFSIZ]; | |
222 | |
223 g_snprintf(buf, sizeof(buf), | |
224 _("The plugin %s did not return any valid plugin " | |
225 "information"), | |
226 plugin->path); | |
227 | |
228 do_error_dialog(_("Gaim was unable to load your plugin."), buf, | |
229 GAIM_ERROR); | |
230 | |
231 gaim_plugin_destroy(plugin); | |
232 | |
233 return NULL; | |
234 } | |
235 | |
236 return plugin; | |
237 #else | |
238 return NULL; | |
239 #endif /* !GAIM_PLUGINS */ | |
240 } | |
241 | |
242 gboolean | |
243 gaim_plugin_load(GaimPlugin *plugin) | |
244 { | |
245 #ifdef GAIM_PLUGINS | |
246 g_return_val_if_fail(plugin != NULL, FALSE); | |
247 | |
248 if (gaim_plugin_is_loaded(plugin)) | |
249 return TRUE; | |
250 | |
251 if (plugin->native_plugin) { | |
252 if (plugin->info != NULL && plugin->info->load != NULL) | |
253 plugin->info->load(plugin); | |
254 } | |
255 else { | |
256 GaimPlugin *loader; | |
257 GaimPluginLoaderInfo *loader_info; | |
258 | |
259 loader = __find_loader_for_plugin(plugin); | |
260 | |
261 if (loader == NULL) | |
262 return FALSE; | |
263 | |
264 loader_info = GAIM_PLUGIN_LOADER_INFO(loader); | |
265 | |
266 if (loader_info->load != NULL) | |
267 loader_info->load(plugin); | |
268 } | |
269 | |
270 loaded_plugins = g_list_append(loaded_plugins, plugin); | |
271 | |
272 plugin->loaded = TRUE; | |
273 | |
274 /* TODO */ | |
275 if (load_cb != NULL) | |
276 load_cb(plugin, load_cb_data); | |
277 | |
278 return TRUE; | |
279 | |
280 #else | |
281 return FALSE; | |
282 #endif /* !GAIM_PLUGINS */ | |
283 } | |
284 | |
285 gboolean | |
286 gaim_plugin_unload(GaimPlugin *plugin) | |
287 { | |
288 #ifdef GAIM_PLUGINS | |
289 g_return_val_if_fail(plugin != NULL, FALSE); | |
290 | |
291 loaded_plugins = g_list_remove(loaded_plugins, plugin); | |
292 | |
293 g_return_val_if_fail(gaim_plugin_is_loaded(plugin), FALSE); | |
294 | |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
295 gaim_debug(GAIM_DEBUG_INFO, "plugins", "Unloading plugin %s\n", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
296 plugin->info->name); |
5205 | 297 |
298 /* cancel any pending dialogs the plugin has */ | |
299 do_ask_cancel_by_handle(plugin); | |
300 | |
301 plugin->loaded = FALSE; | |
302 | |
303 if (plugin->native_plugin) { | |
304 if (plugin->info->unload != NULL) | |
305 plugin->info->unload(plugin); | |
306 | |
307 if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) { | |
308 GaimPluginProtocolInfo *prpl_info; | |
309 GList *l; | |
310 struct proto_user_split *pus; | |
311 struct proto_user_opt *puo; | |
312 | |
313 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); | |
314 | |
315 for (l = prpl_info->user_splits; l != NULL; l = l->next) { | |
316 pus = l->data; | |
317 | |
318 g_free(pus->label); | |
319 g_free(pus->def); | |
320 g_free(pus); | |
321 } | |
322 | |
323 g_list_free(prpl_info->user_splits); | |
324 | |
325 for (l = prpl_info->user_opts; l != NULL; l = l->next) { | |
326 puo = l->data; | |
327 | |
328 g_free(puo->label); | |
329 g_free(puo->def); | |
330 g_free(puo); | |
331 } | |
332 | |
333 g_list_free(prpl_info->user_opts); | |
334 } | |
335 } | |
336 else { | |
337 GaimPlugin *loader; | |
338 GaimPluginLoaderInfo *loader_info; | |
339 | |
340 loader = __find_loader_for_plugin(plugin); | |
341 | |
342 if (loader == NULL) | |
343 return FALSE; | |
344 | |
345 loader_info = GAIM_PLUGIN_LOADER_INFO(loader); | |
346 | |
347 if (loader_info->load != NULL) | |
348 loader_info->unload(plugin); | |
349 } | |
350 | |
351 gaim_signals_disconnect_by_handle(plugin); | |
352 | |
353 /* TODO */ | |
354 if (unload_cb != NULL) | |
355 unload_cb(plugin, unload_cb_data); | |
356 | |
357 return TRUE; | |
358 #endif /* GAIM_PLUGINS */ | |
359 } | |
360 | |
361 gboolean | |
362 gaim_plugin_reload(GaimPlugin *plugin) | |
363 { | |
364 #ifdef GAIM_PLUGINS | |
365 g_return_val_if_fail(plugin != NULL, FALSE); | |
366 g_return_val_if_fail(gaim_plugin_is_loaded(plugin), FALSE); | |
367 | |
368 if (!gaim_plugin_unload(plugin)) | |
369 return FALSE; | |
370 | |
371 if (!gaim_plugin_load(plugin)) | |
372 return FALSE; | |
373 | |
374 return TRUE; | |
375 #else | |
376 return NULL; | |
377 #endif /* !GAIM_PLUGINS */ | |
378 } | |
379 | |
380 void | |
381 gaim_plugin_destroy(GaimPlugin *plugin) | |
382 { | |
383 g_return_if_fail(plugin != NULL); | |
384 | |
385 if (gaim_plugin_is_loaded(plugin)) | |
386 gaim_plugin_unload(plugin); | |
387 | |
388 plugins = g_list_remove(plugins, plugin); | |
389 | |
5243
f6e0c689a88b
[gaim-migrate @ 5614]
Christian Hammond <chipx86@chipx86.com>
parents:
5242
diff
changeset
|
390 if (plugin->info != NULL && plugin->info->dependencies != NULL) |
f6e0c689a88b
[gaim-migrate @ 5614]
Christian Hammond <chipx86@chipx86.com>
parents:
5242
diff
changeset
|
391 g_list_free(plugin->info->dependencies); |
5205 | 392 |
393 if (plugin->native_plugin) { | |
394 | |
395 if (plugin->info != NULL && plugin->info->type == GAIM_PLUGIN_LOADER) { | |
396 GList *exts, *l, *next_l; | |
397 GaimPlugin *p2; | |
398 | |
399 for (exts = GAIM_PLUGIN_LOADER_INFO(plugin)->exts; | |
400 exts != NULL; | |
401 exts = exts->next) { | |
402 | |
403 for (l = gaim_plugins_get_all(); l != NULL; l = next_l) { | |
404 next_l = l->next; | |
405 | |
406 p2 = l->data; | |
407 | |
408 if (p2->path != NULL && is_so_file(p2->path, exts->data)) | |
409 gaim_plugin_destroy(p2); | |
410 } | |
411 } | |
412 | |
413 g_list_free(GAIM_PLUGIN_LOADER_INFO(plugin)->exts); | |
414 | |
415 plugin_loaders = g_list_remove(plugin_loaders, plugin); | |
416 } | |
417 | |
418 if (plugin->info != NULL && plugin->info->destroy != NULL) | |
419 plugin->info->destroy(plugin); | |
420 | |
421 if (plugin->handle != NULL) | |
422 g_module_close(plugin->handle); | |
423 } | |
424 else { | |
425 GaimPlugin *loader; | |
426 GaimPluginLoaderInfo *loader_info; | |
427 | |
428 loader = __find_loader_for_plugin(plugin); | |
429 | |
430 if (loader == NULL) | |
431 return; | |
432 | |
433 loader_info = GAIM_PLUGIN_LOADER_INFO(loader); | |
434 | |
435 if (loader_info->destroy != NULL) | |
436 loader_info->destroy(plugin); | |
437 } | |
438 | |
439 if (plugin->path != NULL) g_free(plugin->path); | |
440 if (plugin->error != NULL) g_free(plugin->error); | |
441 | |
442 g_free(plugin); | |
443 } | |
444 | |
445 gboolean | |
446 gaim_plugin_is_loaded(const GaimPlugin *plugin) | |
447 { | |
448 g_return_val_if_fail(plugin != NULL, FALSE); | |
449 | |
450 return plugin->loaded; | |
451 } | |
452 | |
453 void | |
454 gaim_plugins_set_search_paths(size_t count, char **paths) | |
455 { | |
456 size_t s; | |
457 | |
458 g_return_if_fail(count > 0); | |
459 g_return_if_fail(paths != NULL); | |
460 | |
461 if (search_paths != NULL) { | |
462 for (s = 0; s < search_path_count; s++) | |
463 g_free(search_paths[s]); | |
464 | |
465 g_free(search_paths); | |
466 } | |
467 | |
468 search_paths = g_new0(char *, count); | |
469 | |
470 for (s = 0; s < count; s++) { | |
471 if (paths[s] == NULL) | |
472 search_paths[s] = NULL; | |
473 else | |
474 search_paths[s] = g_strdup(paths[s]); | |
475 } | |
476 | |
477 search_path_count = count; | |
478 } | |
479 | |
480 void | |
481 gaim_plugins_unload_all(void) | |
482 { | |
483 #ifdef GAIM_PLUGINS | |
484 | |
485 while (loaded_plugins != NULL) | |
486 gaim_plugin_unload(loaded_plugins->data); | |
487 | |
488 #endif /* GAIM_PLUGINS */ | |
489 } | |
490 | |
491 void | |
5242
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
492 gaim_plugins_destroy_all(void) |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
493 { |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
494 #ifdef GAIM_PLUGINS |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
495 |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
496 while (plugins != NULL) |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
497 gaim_plugin_destroy(plugins->data); |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
498 |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
499 #endif /* GAIM_PLUGINS */ |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
500 } |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
501 void |
5205 | 502 gaim_plugins_probe(const char *ext) |
503 { | |
504 #ifdef GAIM_PLUGINS | |
505 GDir *dir; | |
506 const gchar *file; | |
507 gchar *path; | |
508 GaimPlugin *plugin; | |
509 size_t i; | |
510 | |
511 if (!g_module_supported()) | |
512 return; | |
513 | |
514 for (i = 0; i < search_path_count; i++) { | |
515 if (search_paths[i] == NULL) | |
516 continue; | |
517 | |
518 dir = g_dir_open(search_paths[i], 0, NULL); | |
519 | |
520 if (dir != NULL) { | |
521 while ((file = g_dir_read_name(dir)) != NULL) { | |
522 path = g_build_filename(search_paths[i], file, NULL); | |
523 | |
524 if (ext == NULL || is_so_file(file, ext)) | |
525 plugin = gaim_plugin_probe(path); | |
526 | |
527 g_free(path); | |
528 } | |
529 | |
530 g_dir_close(dir); | |
531 } | |
532 } | |
533 | |
534 if (probe_cb != NULL) | |
535 probe_cb(probe_cb_data); | |
536 | |
537 #endif /* GAIM_PLUGINS */ | |
538 } | |
539 | |
540 gboolean | |
541 gaim_plugin_register(GaimPlugin *plugin) | |
542 { | |
543 #ifdef GAIM_PLUGINS | |
544 g_return_val_if_fail(plugin != NULL, FALSE); | |
545 | |
546 if (g_list_find(plugins, plugin)) | |
547 return TRUE; | |
548 | |
549 /* Special exception for loader plugins. We want them loaded NOW! */ | |
550 if (plugin->info->type == GAIM_PLUGIN_LOADER) { | |
551 GList *exts; | |
552 | |
553 /* We'll just load this right now. */ | |
554 if (!gaim_plugin_load(plugin)) { | |
555 | |
556 gaim_plugin_destroy(plugin); | |
557 | |
558 return FALSE; | |
559 } | |
560 | |
561 plugin_loaders = g_list_append(plugin_loaders, plugin); | |
562 | |
563 for (exts = GAIM_PLUGIN_LOADER_INFO(plugin)->exts; | |
564 exts != NULL; | |
565 exts = exts->next) { | |
566 | |
567 gaim_plugins_probe(exts->data); | |
568 } | |
569 } | |
570 else if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) { | |
571 | |
572 /* We'll just load this right now. */ | |
573 if (!gaim_plugin_load(plugin)) { | |
574 | |
575 gaim_plugin_destroy(plugin); | |
576 | |
577 return FALSE; | |
578 } | |
579 | |
580 if (GAIM_PLUGIN_PROTOCOL_INFO(plugin)->protocol == GAIM_PROTO_ICQ || | |
581 gaim_find_prpl(GAIM_PLUGIN_PROTOCOL_INFO(plugin)->protocol)) { | |
582 | |
583 /* Nothing to see here--move along, move along */ | |
584 gaim_plugin_destroy(plugin); | |
585 | |
586 return FALSE; | |
587 } | |
588 | |
589 protocols = g_slist_insert_sorted(protocols, plugin, | |
590 (GCompareFunc)compare_prpl); | |
591 } | |
592 | |
593 plugins = g_list_append(plugins, plugin); | |
594 | |
595 return TRUE; | |
596 #else | |
597 return FALSE; | |
598 #endif /* !GAIM_PLUGINS */ | |
599 } | |
600 | |
601 gboolean | |
602 gaim_plugins_enabled(void) | |
603 { | |
604 #ifdef GAIM_PLUGINS | |
605 return TRUE; | |
606 #else | |
607 return FALSE; | |
608 #endif | |
609 } | |
610 | |
611 void | |
612 gaim_plugins_register_probe_notify_cb(void (*func)(void *), void *data) | |
613 { | |
614 /* TODO */ | |
615 probe_cb = func; | |
616 probe_cb_data = data; | |
617 } | |
618 | |
619 void | |
620 gaim_plugins_unregister_probe_notify_cb(void (*func)(void *)) | |
621 { | |
622 /* TODO */ | |
623 probe_cb = NULL; | |
624 probe_cb_data = NULL; | |
625 } | |
626 | |
627 void | |
628 gaim_plugins_register_load_notify_cb(void (*func)(GaimPlugin *, void *), | |
629 void *data) | |
630 { | |
631 /* TODO */ | |
632 load_cb = func; | |
633 load_cb_data = data; | |
634 } | |
635 | |
636 void | |
637 gaim_plugins_unregister_load_notify_cb(void (*func)(GaimPlugin *, void *)) | |
638 { | |
639 /* TODO */ | |
640 load_cb = NULL; | |
641 load_cb_data = NULL; | |
642 } | |
643 | |
644 void | |
645 gaim_plugins_register_unload_notify_cb(void (*func)(GaimPlugin *, void *), | |
646 void *data) | |
647 { | |
648 /* TODO */ | |
649 unload_cb = func; | |
650 unload_cb_data = data; | |
651 } | |
652 | |
653 void | |
654 gaim_plugins_unregister_unload_notify_cb(void (*func)(GaimPlugin *, void *)) | |
655 { | |
656 /* TODO */ | |
657 unload_cb = NULL; | |
658 unload_cb_data = NULL; | |
659 } | |
660 | |
661 GaimPlugin * | |
662 gaim_plugins_find_with_name(const char *name) | |
663 { | |
664 GaimPlugin *plugin; | |
665 GList *l; | |
666 | |
667 for (l = plugins; l != NULL; l = l->next) { | |
668 plugin = l->data; | |
669 | |
670 if (!strcmp(plugin->info->name, name)) | |
671 return plugin; | |
672 } | |
673 | |
674 return NULL; | |
675 } | |
676 | |
677 GaimPlugin * | |
678 gaim_plugins_find_with_filename(const char *filename) | |
679 { | |
680 GaimPlugin *plugin; | |
681 GList *l; | |
682 | |
683 for (l = plugins; l != NULL; l = l->next) { | |
684 plugin = l->data; | |
685 | |
686 if (plugin->path != NULL && !strcmp(plugin->path, filename)) | |
687 return plugin; | |
688 } | |
689 | |
690 return NULL; | |
691 } | |
692 | |
693 GaimPlugin * | |
694 gaim_plugins_find_with_id(const char *id) | |
695 { | |
696 GaimPlugin *plugin; | |
697 GList *l; | |
698 | |
699 g_return_val_if_fail(id != NULL, NULL); | |
700 | |
701 for (l = plugins; l != NULL; l = l->next) { | |
702 plugin = l->data; | |
703 | |
704 if (!strcmp(plugin->info->id, id)) | |
705 return plugin; | |
706 } | |
707 | |
708 return NULL; | |
709 } | |
710 | |
711 GList * | |
712 gaim_plugins_get_loaded(void) | |
713 { | |
714 return loaded_plugins; | |
715 } | |
716 | |
717 GList * | |
718 gaim_plugins_get_all(void) | |
719 { | |
720 return plugins; | |
721 } | |
722 |