| 69 static void *probe_cb_data = NULL; |
69 static void *probe_cb_data = NULL; |
| 70 static void (*load_cb)(GaimPlugin *, void *) = NULL; |
70 static void (*load_cb)(GaimPlugin *, void *) = NULL; |
| 71 static void *load_cb_data = NULL; |
71 static void *load_cb_data = NULL; |
| 72 static void (*unload_cb)(GaimPlugin *, void *) = NULL; |
72 static void (*unload_cb)(GaimPlugin *, void *) = NULL; |
| 73 static void *unload_cb_data = NULL; |
73 static void *unload_cb_data = NULL; |
| 74 |
|
| 75 |
|
| 76 void * |
|
| 77 gaim_plugins_get_handle(void) |
|
| 78 { |
|
| 79 static int handle; |
|
| 80 |
|
| 81 return &handle; |
|
| 82 } |
|
| 83 |
|
| 84 |
74 |
| 85 #ifdef GAIM_PLUGINS |
75 #ifdef GAIM_PLUGINS |
| 86 static gboolean |
76 static gboolean |
| 87 has_file_extension(const char *filename, const char *ext) |
77 has_file_extension(const char *filename, const char *ext) |
| 88 { |
78 { |
| 784 return ret_value; |
774 return ret_value; |
| 785 } |
775 } |
| 786 |
776 |
| 787 /************************************************************************** |
777 /************************************************************************** |
| 788 * Plugins subsystem |
778 * Plugins subsystem |
| |
779 **************************************************************************/ |
| |
780 void * |
| |
781 gaim_plugins_get_handle(void) { |
| |
782 static int handle; |
| |
783 |
| |
784 return &handle; |
| |
785 } |
| |
786 |
| |
787 void |
| |
788 gaim_plugins_init(void) { |
| |
789 void *handle = gaim_plugins_get_handle(); |
| |
790 |
| |
791 gaim_signal_register(handle, "plugin-load", |
| |
792 gaim_marshal_VOID__POINTER, |
| |
793 NULL, 1, |
| |
794 gaim_value_new(GAIM_TYPE_SUBTYPE, |
| |
795 GAIM_SUBTYPE_PLUGIN)); |
| |
796 gaim_signal_register(handle, "plugin-unload", |
| |
797 gaim_marshal_VOID__POINTER, |
| |
798 NULL, 1, |
| |
799 gaim_value_new(GAIM_TYPE_SUBTYPE, |
| |
800 GAIM_SUBTYPE_PLUGIN)); |
| |
801 } |
| |
802 |
| |
803 void |
| |
804 gaim_plugins_uninit(void) { |
| |
805 gaim_signals_disconnect_by_handle(gaim_plugins_get_handle()); |
| |
806 } |
| |
807 |
| |
808 /************************************************************************** |
| |
809 * Plugins API |
| 789 **************************************************************************/ |
810 **************************************************************************/ |
| 790 void |
811 void |
| 791 gaim_plugins_add_search_path(const char *path) |
812 gaim_plugins_add_search_path(const char *path) |
| 792 { |
813 { |
| 793 g_return_if_fail(path != NULL); |
814 g_return_if_fail(path != NULL); |
| 869 gchar *path; |
890 gchar *path; |
| 870 GaimPlugin *plugin; |
891 GaimPlugin *plugin; |
| 871 GList *cur; |
892 GList *cur; |
| 872 const char *search_path; |
893 const char *search_path; |
| 873 |
894 |
| 874 void *handle; |
|
| 875 |
|
| 876 if (!g_module_supported()) |
895 if (!g_module_supported()) |
| 877 return; |
896 return; |
| 878 |
|
| 879 handle = gaim_plugins_get_handle(); |
|
| 880 |
|
| 881 /* TODO: These signals need to be registered in an init function */ |
|
| 882 gaim_debug_info("plugins", "registering plugin-load signal\n"); |
|
| 883 gaim_signal_register(handle, "plugin-load", gaim_marshal_VOID__POINTER, NULL, |
|
| 884 1, gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_PLUGIN)); |
|
| 885 |
|
| 886 gaim_debug_info("plugins", "registering plugin-unload signal\n"); |
|
| 887 gaim_signal_register(handle, "plugin-unload", gaim_marshal_VOID__POINTER, NULL, |
|
| 888 1, gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_PLUGIN)); |
|
| 889 |
|
| 890 |
897 |
| 891 /* Probe plugins */ |
898 /* Probe plugins */ |
| 892 for (cur = search_paths; cur != NULL; cur = cur->next) |
899 for (cur = search_paths; cur != NULL; cur = cur->next) |
| 893 { |
900 { |
| 894 search_path = cur->data; |
901 search_path = cur->data; |