comparison libpurple/plugin.c @ 32779:d72f2f13b60f

merge of 'c8c73eea7431e6f940916315ace40a41c8da3faa' and 'fec428131bde0ae8247941bd6a3d996c984c9189'
author Ethan Blanton <elb@pidgin.im>
date Fri, 21 Oct 2011 14:36:18 +0000
parents 4f6b06139734
children
comparison
equal deleted inserted replaced
32778:14787acaf9d7 32779:d72f2f13b60f
62 static GList *load_queue = NULL; 62 static GList *load_queue = NULL;
63 static GList *plugin_loaders = NULL; 63 static GList *plugin_loaders = NULL;
64 static GList *plugins_to_disable = NULL; 64 static GList *plugins_to_disable = NULL;
65 #endif 65 #endif
66 66
67 static void (*probe_cb)(void *) = NULL;
68 static void *probe_cb_data = NULL;
69 static void (*load_cb)(PurplePlugin *, void *) = NULL;
70 static void *load_cb_data = NULL;
71 static void (*unload_cb)(PurplePlugin *, void *) = NULL;
72 static void *unload_cb_data = NULL;
73
74 #ifdef PURPLE_PLUGINS 67 #ifdef PURPLE_PLUGINS
75 68
76 static gboolean 69 static gboolean
77 has_file_extension(const char *filename, const char *ext) 70 has_file_extension(const char *filename, const char *ext)
78 { 71 {
613 606
614 loaded_plugins = g_list_insert_sorted(loaded_plugins, plugin, compare_plugins); 607 loaded_plugins = g_list_insert_sorted(loaded_plugins, plugin, compare_plugins);
615 608
616 plugin->loaded = TRUE; 609 plugin->loaded = TRUE;
617 610
618 if (load_cb != NULL)
619 load_cb(plugin, load_cb_data);
620
621 purple_signal_emit(purple_plugins_get_handle(), "plugin-load", plugin); 611 purple_signal_emit(purple_plugins_get_handle(), "plugin-load", plugin);
622 612
623 return TRUE; 613 return TRUE;
624 614
625 #else 615 #else
743 * unload failure. It's obviously okay now. 733 * unload failure. It's obviously okay now.
744 */ 734 */
745 g_free(plugin->error); 735 g_free(plugin->error);
746 plugin->error = NULL; 736 plugin->error = NULL;
747 737
748 if (unload_cb != NULL)
749 unload_cb(plugin, unload_cb_data);
750
751 purple_signal_emit(purple_plugins_get_handle(), "plugin-unload", plugin); 738 purple_signal_emit(purple_plugins_get_handle(), "plugin-unload", plugin);
752 739
753 purple_prefs_disconnect_by_handle(plugin); 740 purple_prefs_disconnect_by_handle(plugin);
754 741
755 return TRUE; 742 return TRUE;
1437 1424
1438 protocol_plugins = g_list_insert_sorted(protocol_plugins, plugin, 1425 protocol_plugins = g_list_insert_sorted(protocol_plugins, plugin,
1439 (GCompareFunc)compare_prpl); 1426 (GCompareFunc)compare_prpl);
1440 } 1427 }
1441 } 1428 }
1442
1443 if (probe_cb != NULL)
1444 probe_cb(probe_cb_data);
1445
1446 #endif /* PURPLE_PLUGINS */ 1429 #endif /* PURPLE_PLUGINS */
1447 } 1430 }
1448 1431
1449 gboolean 1432 gboolean
1450 purple_plugin_register(PurplePlugin *plugin) 1433 purple_plugin_register(PurplePlugin *plugin)
1509 #ifdef PURPLE_PLUGINS 1492 #ifdef PURPLE_PLUGINS
1510 return TRUE; 1493 return TRUE;
1511 #else 1494 #else
1512 return FALSE; 1495 return FALSE;
1513 #endif 1496 #endif
1514 }
1515
1516 void
1517 purple_plugins_register_probe_notify_cb(void (*func)(void *), void *data)
1518 {
1519 probe_cb = func;
1520 probe_cb_data = data;
1521 }
1522
1523 void
1524 purple_plugins_unregister_probe_notify_cb(void (*func)(void *))
1525 {
1526 probe_cb = NULL;
1527 probe_cb_data = NULL;
1528 }
1529
1530 void
1531 purple_plugins_register_load_notify_cb(void (*func)(PurplePlugin *, void *),
1532 void *data)
1533 {
1534 load_cb = func;
1535 load_cb_data = data;
1536 }
1537
1538 void
1539 purple_plugins_unregister_load_notify_cb(void (*func)(PurplePlugin *, void *))
1540 {
1541 load_cb = NULL;
1542 load_cb_data = NULL;
1543 }
1544
1545 void
1546 purple_plugins_register_unload_notify_cb(void (*func)(PurplePlugin *, void *),
1547 void *data)
1548 {
1549 unload_cb = func;
1550 unload_cb_data = data;
1551 }
1552
1553 void
1554 purple_plugins_unregister_unload_notify_cb(void (*func)(PurplePlugin *, void *))
1555 {
1556 unload_cb = NULL;
1557 unload_cb_data = NULL;
1558 } 1497 }
1559 1498
1560 PurplePlugin * 1499 PurplePlugin *
1561 purple_plugins_find_with_name(const char *name) 1500 purple_plugins_find_with_name(const char *name)
1562 { 1501 {