Thu, 20 May 2004 05:11:44 +0000
[gaim-migrate @ 9761]
" This patch adds a Plugin Actions menu item after the
Account Actions menu. The Plugin Actions menu is
populated from the added 'actions' slot in
GaimPluginInfo. As a demonstration, the Idle Maker
plugin has been converted to no longer require GTK code
and the Preferences interface just to perform its
actions. Instead, it uses a Plugin Action to spawn a
Fields Request.
There's also a minor fix for consistency in the menu
building for buddy actions. The pre-existing method for
instructing a menu list to display a separator was to
insert a NULL rather than a proto_buddy_menu into the
GList of actions. The code for the buddy menus was
instead checking for a proto_buddy_menu with a '-'
label. This has been fixed, and it now correctly uses
NULL to indicate a separator."
"Date: 2004-05-16 02:25
Sender: taliesein
Logged In: YES
user_id=77326
I need to add a callback to this patch to watch for
loading/unloading of plugins (to determine when to rebuild
the menu). Since the appropriate way to handle Plugin
Actions is still mildly up for debate, I'm holding of on
correcting the patch until I know for sure whether I should
fix this patch, or scrap it and write a new one using a
different method."
"Date: 2004-05-18 12:26
Sender: taliesein
Logged In: YES
user_id=77326
I've completed changes to this patch to also add plugin load
and unload signals (it looks like plugin.c actually had
pre-signal callbacks in place, but they were never used or
converted to signals)
This patch now will correctly update the Plugin Action menu
as plugins load and unload."
I'm not entirely sure i like the ui of a plugins actions menu, but i think
that having some way for plugins to add actions on an account is a good
thing, and i'm not sure that every viable action fits under the accounts
actions menu. we may want to merge the two (the existing accounts actions
and this plugins actions), but both times it came up in #gaim no one seemed
to want to comment, and on one commented to the gaim-devel post either.
committer: Luke Schierer <lschiere@pidgin.im>
| 5205 | 1 | /* |
| 2 | * gaim | |
| 3 | * | |
| 8046 | 4 | * Gaim is the legal property of its developers, whose names are too numerous |
| 5 | * to list here. Please refer to the COPYRIGHT file distributed with this | |
| 6 | * source distribution. | |
| 5205 | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 21 | */ | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
22 | #include "internal.h" |
| 5205 | 23 | |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
24 | #include "accountopt.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
25 | #include "debug.h" |
|
5436
a0e0bacaa196
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5357
diff
changeset
|
26 | #include "notify.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
27 | #include "prefs.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
28 | #include "prpl.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
29 | #include "request.h" |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6432
diff
changeset
|
30 | #include "signals.h" |
| 5205 | 31 | |
| 32 | #ifdef _WIN32 | |
| 33 | # define PLUGIN_EXT ".dll" | |
| 34 | #else | |
| 6639 | 35 | #ifdef __hpux |
| 36 | # define PLUGIN_EXT ".sl" | |
| 37 | #else | |
| 5205 | 38 | # define PLUGIN_EXT ".so" |
| 39 | #endif | |
| 6639 | 40 | #endif |
| 5205 | 41 | |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
42 | typedef struct |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
43 | { |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
44 | GHashTable *commands; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
45 | size_t command_count; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
46 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
47 | } GaimPluginIpcInfo; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
48 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
49 | typedef struct |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
50 | { |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
51 | GaimCallback func; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
52 | GaimSignalMarshalFunc marshal; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
53 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
54 | int num_params; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
55 | GaimValue **params; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
56 | GaimValue *ret_value; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
57 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
58 | } GaimPluginIpcCommand; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
59 | |
|
6981
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
60 | static GList *loaded_plugins = NULL; |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
61 | static GList *plugins = NULL; |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
62 | static GList *plugin_loaders = NULL; |
|
5573
633880e3f137
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
63 | static GList *protocol_plugins = NULL; |
|
6981
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
64 | static GList *load_queue = NULL; |
| 5205 | 65 | |
| 66 | static size_t search_path_count = 0; | |
| 67 | static char **search_paths = NULL; | |
| 68 | ||
| 69 | static void (*probe_cb)(void *) = NULL; | |
| 70 | static void *probe_cb_data = NULL; | |
| 71 | static void (*load_cb)(GaimPlugin *, void *) = NULL; | |
| 72 | static void *load_cb_data = NULL; | |
| 73 | static void (*unload_cb)(GaimPlugin *, void *) = NULL; | |
| 74 | static void *unload_cb_data = NULL; | |
| 75 | ||
|
8986
30ba617356bb
[gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents:
8759
diff
changeset
|
76 | |
|
30ba617356bb
[gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents:
8759
diff
changeset
|
77 | void * |
|
30ba617356bb
[gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents:
8759
diff
changeset
|
78 | gaim_plugins_get_handle(void) |
|
30ba617356bb
[gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents:
8759
diff
changeset
|
79 | { |
|
30ba617356bb
[gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents:
8759
diff
changeset
|
80 | static int handle; |
|
30ba617356bb
[gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents:
8759
diff
changeset
|
81 | return &handle; |
|
30ba617356bb
[gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents:
8759
diff
changeset
|
82 | } |
|
30ba617356bb
[gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents:
8759
diff
changeset
|
83 | |
|
30ba617356bb
[gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents:
8759
diff
changeset
|
84 | |
| 5205 | 85 | #ifdef GAIM_PLUGINS |
| 86 | static int | |
| 87 | is_so_file(const char *filename, const char *ext) | |
| 88 | { | |
| 89 | int len, extlen; | |
| 90 | ||
| 91 | if (filename == NULL || *filename == '\0' || ext == NULL) | |
| 92 | return 0; | |
| 93 | ||
| 94 | extlen = strlen(ext); | |
| 95 | len = strlen(filename) - extlen; | |
| 96 | ||
| 97 | if (len < 0) | |
| 98 | return 0; | |
| 99 | ||
| 100 | return (!strncmp(filename + len, ext, extlen)); | |
| 101 | } | |
| 102 | ||
| 103 | static gboolean | |
|
5794
ebdbb7dc6658
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
104 | loader_supports_file(GaimPlugin *loader, const char *filename) |
| 5205 | 105 | { |
| 6432 | 106 | GList *exts; |
| 5205 | 107 | |
| 6432 | 108 | for (exts = GAIM_PLUGIN_LOADER_INFO(loader)->exts; exts != NULL; exts = exts->next) { |
| 109 | if (is_so_file(filename, (char *)exts->data)) { | |
| 110 | return TRUE; | |
| 5205 | 111 | } |
| 112 | } | |
| 113 | ||
| 114 | return FALSE; | |
| 115 | } | |
| 116 | ||
| 117 | static GaimPlugin * | |
|
5794
ebdbb7dc6658
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
118 | find_loader_for_plugin(const GaimPlugin *plugin) |
| 5205 | 119 | { |
| 120 | GaimPlugin *loader; | |
| 121 | GList *l; | |
| 122 | ||
| 123 | if (plugin->path == NULL) | |
| 124 | return NULL; | |
| 125 | ||
| 126 | for (l = gaim_plugins_get_loaded(); l != NULL; l = l->next) { | |
| 127 | loader = l->data; | |
| 128 | ||
| 129 | if (loader->info->type == GAIM_PLUGIN_LOADER && | |
|
5794
ebdbb7dc6658
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
130 | loader_supports_file(loader, plugin->path)) { |
| 5205 | 131 | |
| 132 | return loader; | |
| 133 | } | |
| 134 | ||
| 135 | loader = NULL; | |
| 136 | } | |
| 137 | ||
| 138 | return NULL; | |
| 139 | } | |
| 140 | ||
|
5449
4c350eb7d4a0
[gaim-migrate @ 5836]
Decklin Foster <decklin@red-bean.com>
parents:
5443
diff
changeset
|
141 | #endif /* GAIM_PLUGINS */ |
|
4c350eb7d4a0
[gaim-migrate @ 5836]
Decklin Foster <decklin@red-bean.com>
parents:
5443
diff
changeset
|
142 | |
| 5205 | 143 | static gint |
| 144 | compare_prpl(GaimPlugin *a, GaimPlugin *b) | |
| 145 | { | |
| 146 | /* neg if a before b, 0 if equal, pos if a after b */ | |
| 7956 | 147 | if(GAIM_IS_PROTOCOL_PLUGIN(a)) { |
| 148 | if(GAIM_IS_PROTOCOL_PLUGIN(b)) | |
| 149 | return strcmp(a->info->name, b->info->name); | |
| 150 | else | |
| 151 | return -1; | |
| 152 | } else { | |
| 153 | if(GAIM_IS_PROTOCOL_PLUGIN(b)) | |
| 154 | return 1; | |
| 155 | else | |
| 156 | return 0; | |
| 157 | } | |
| 5205 | 158 | } |
| 159 | ||
| 160 | GaimPlugin * | |
| 161 | gaim_plugin_new(gboolean native, const char *path) | |
| 162 | { | |
| 163 | GaimPlugin *plugin; | |
| 164 | ||
| 165 | plugin = g_new0(GaimPlugin, 1); | |
| 166 | ||
| 167 | plugin->native_plugin = native; | |
| 168 | plugin->path = (path == NULL ? NULL : g_strdup(path)); | |
| 169 | ||
| 170 | return plugin; | |
| 171 | } | |
| 172 | ||
| 173 | GaimPlugin * | |
| 174 | gaim_plugin_probe(const char *filename) | |
| 175 | { | |
| 176 | #ifdef GAIM_PLUGINS | |
| 177 | GaimPlugin *plugin = NULL; | |
| 178 | GaimPlugin *loader; | |
| 179 | gboolean (*gaim_init_plugin)(GaimPlugin *); | |
| 180 | ||
|
6981
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
181 | gaim_debug_misc("plugins", "probing %s\n", filename); |
| 5205 | 182 | g_return_val_if_fail(filename != NULL, NULL); |
| 183 | ||
|
5973
adc75f0fcaa3
[gaim-migrate @ 6420]
Mark Doliner <markdoliner@pidgin.im>
parents:
5949
diff
changeset
|
184 | if (!g_file_test(filename, G_FILE_TEST_EXISTS)) |
|
adc75f0fcaa3
[gaim-migrate @ 6420]
Mark Doliner <markdoliner@pidgin.im>
parents:
5949
diff
changeset
|
185 | return NULL; |
|
adc75f0fcaa3
[gaim-migrate @ 6420]
Mark Doliner <markdoliner@pidgin.im>
parents:
5949
diff
changeset
|
186 | |
| 5205 | 187 | plugin = gaim_plugins_find_with_filename(filename); |
| 188 | ||
| 189 | if (plugin != NULL) | |
| 190 | return plugin; | |
| 191 | ||
| 192 | plugin = gaim_plugin_new(is_so_file(filename, PLUGIN_EXT), filename); | |
| 193 | ||
| 194 | if (plugin->native_plugin) { | |
| 5450 | 195 | const char *error; |
| 5205 | 196 | plugin->handle = g_module_open(filename, 0); |
| 197 | ||
| 198 | if (plugin->handle == NULL) { | |
| 5443 | 199 | error = g_module_error(); |
|
5269
a318feccd844
[gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents:
5268
diff
changeset
|
200 | gaim_debug(GAIM_DEBUG_ERROR, "plugins", "%s is unloadable: %s\n", |
| 5443 | 201 | plugin->path, error ? error : "Unknown error."); |
| 5205 | 202 | |
|
5269
a318feccd844
[gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents:
5268
diff
changeset
|
203 | gaim_plugin_destroy(plugin); |
|
a318feccd844
[gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents:
5268
diff
changeset
|
204 | |
|
a318feccd844
[gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents:
5268
diff
changeset
|
205 | return NULL; |
| 5205 | 206 | } |
| 207 | ||
| 208 | if (!g_module_symbol(plugin->handle, "gaim_init_plugin", | |
| 209 | (gpointer *)&gaim_init_plugin)) { | |
| 210 | g_module_close(plugin->handle); | |
| 211 | plugin->handle = NULL; | |
| 212 | ||
| 5443 | 213 | error = g_module_error(); |
|
5211
94d9756c381f
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
214 | gaim_debug(GAIM_DEBUG_ERROR, "plugins", "%s is unloadable: %s\n", |
| 5443 | 215 | plugin->path, error ? error : "Unknown error."); |
| 5205 | 216 | |
| 217 | gaim_plugin_destroy(plugin); | |
| 218 | ||
| 219 | return NULL; | |
| 220 | } | |
| 221 | } | |
| 222 | else { | |
|
5794
ebdbb7dc6658
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
223 | loader = find_loader_for_plugin(plugin); |
| 5205 | 224 | |
| 225 | if (loader == NULL) { | |
| 226 | gaim_plugin_destroy(plugin); | |
| 227 | ||
| 228 | return NULL; | |
| 229 | } | |
| 230 | ||
| 231 | gaim_init_plugin = GAIM_PLUGIN_LOADER_INFO(loader)->probe; | |
| 232 | } | |
| 233 | ||
| 234 | plugin->error = NULL; | |
| 235 | ||
| 236 | if (!gaim_init_plugin(plugin) || plugin->info == NULL) { | |
| 237 | gaim_plugin_destroy(plugin); | |
| 238 | ||
| 239 | return NULL; | |
| 240 | } | |
| 241 | ||
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
242 | if (plugin->info->api_version != GAIM_PLUGIN_API_VERSION) |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
243 | { |
| 8759 | 244 | gaim_debug(GAIM_DEBUG_ERROR, "plugins", "%s is unloadable: API version mismatch %d (need %d)\n", |
| 245 | plugin->path, plugin->info->api_version, GAIM_PLUGIN_API_VERSION); | |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
246 | gaim_plugin_destroy(plugin); |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
247 | return NULL; |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
248 | } |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
249 | |
| 5205 | 250 | return plugin; |
| 251 | #else | |
| 252 | return NULL; | |
| 253 | #endif /* !GAIM_PLUGINS */ | |
| 254 | } | |
| 255 | ||
| 256 | gboolean | |
| 257 | gaim_plugin_load(GaimPlugin *plugin) | |
| 258 | { | |
| 259 | #ifdef GAIM_PLUGINS | |
|
6486
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
260 | GList *dep_list = NULL; |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
261 | GList *l; |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
262 | |
| 5205 | 263 | g_return_val_if_fail(plugin != NULL, FALSE); |
|
5270
74286f7fb991
[gaim-migrate @ 5642]
Christian Hammond <chipx86@chipx86.com>
parents:
5269
diff
changeset
|
264 | g_return_val_if_fail(plugin->error == NULL, FALSE); |
| 5205 | 265 | |
| 266 | if (gaim_plugin_is_loaded(plugin)) | |
| 267 | return TRUE; | |
| 268 | ||
|
6486
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
269 | /* |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
270 | * Go through the list of the plugin's dependencies. |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
271 | * |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
272 | * First pass: Make sure all the plugins needed are probed. |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
273 | */ |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
274 | for (l = plugin->info->dependencies; l != NULL; l = l->next) |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
275 | { |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
276 | const char *dep_name = (const char *)l->data; |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
277 | GaimPlugin *dep_plugin; |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
278 | |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
279 | dep_plugin = gaim_plugins_find_with_id(dep_name); |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
280 | |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
281 | if (dep_plugin == NULL) |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
282 | { |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
283 | char buf[BUFSIZ]; |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
284 | |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
285 | g_snprintf(buf, sizeof(buf), |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
286 | _("The required plugin %s was not found. " |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
287 | "Please install this plugin and try again."), |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
288 | dep_name); |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
289 | |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
290 | gaim_notify_error(NULL, NULL, |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
291 | _("Gaim was unable to load your plugin."), |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
292 | buf); |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
293 | |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
294 | if (dep_list != NULL) |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
295 | g_list_free(dep_list); |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
296 | |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
297 | return FALSE; |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
298 | } |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
299 | |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
300 | dep_list = g_list_append(dep_list, dep_plugin); |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
301 | } |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
302 | |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
303 | /* Second pass: load all the required plugins. */ |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
304 | for (l = dep_list; l != NULL; l = l->next) |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
305 | { |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
306 | GaimPlugin *dep_plugin = (GaimPlugin *)l->data; |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
307 | |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
308 | if (!gaim_plugin_is_loaded(dep_plugin)) |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
309 | { |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
310 | if (!gaim_plugin_load(dep_plugin)) |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
311 | { |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
312 | char buf[BUFSIZ]; |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
313 | |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
314 | g_snprintf(buf, sizeof(buf), |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
315 | _("The required plugin %s was unable to load."), |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
316 | plugin->info->name); |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
317 | |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
318 | gaim_notify_error(NULL, NULL, |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
319 | _("Gaim was unable to load your plugin."), |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
320 | buf); |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
321 | |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
322 | if (dep_list != NULL) |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
323 | g_list_free(dep_list); |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
324 | |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
325 | return FALSE; |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
326 | } |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
327 | } |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
328 | } |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
329 | |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
330 | if (dep_list != NULL) |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
331 | g_list_free(dep_list); |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
332 | |
|
6981
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
333 | if (plugin->native_plugin) |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
334 | { |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
335 | if (plugin->info != NULL && plugin->info->load != NULL) |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
336 | { |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
337 | if (!plugin->info->load(plugin)) |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
338 | return FALSE; |
|
5357
1fa9e57df50c
[gaim-migrate @ 5733]
Christian Hammond <chipx86@chipx86.com>
parents:
5270
diff
changeset
|
339 | } |
| 5205 | 340 | } |
| 341 | else { | |
| 342 | GaimPlugin *loader; | |
| 343 | GaimPluginLoaderInfo *loader_info; | |
| 344 | ||
|
5794
ebdbb7dc6658
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
345 | loader = find_loader_for_plugin(plugin); |
| 5205 | 346 | |
| 347 | if (loader == NULL) | |
| 348 | return FALSE; | |
| 349 | ||
| 350 | loader_info = GAIM_PLUGIN_LOADER_INFO(loader); | |
| 351 | ||
| 352 | if (loader_info->load != NULL) | |
|
6981
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
353 | { |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
354 | if (!loader_info->load(plugin)) |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
355 | return FALSE; |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
356 | } |
| 5205 | 357 | } |
| 358 | ||
| 359 | loaded_plugins = g_list_append(loaded_plugins, plugin); | |
| 360 | ||
| 361 | plugin->loaded = TRUE; | |
| 362 | ||
| 363 | /* TODO */ | |
| 364 | if (load_cb != NULL) | |
| 365 | load_cb(plugin, load_cb_data); | |
| 366 | ||
|
8986
30ba617356bb
[gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents:
8759
diff
changeset
|
367 | gaim_signal_emit(gaim_plugins_get_handle(), "plugin-unload", plugin); |
|
30ba617356bb
[gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents:
8759
diff
changeset
|
368 | |
| 5205 | 369 | return TRUE; |
| 370 | ||
| 371 | #else | |
|
5449
4c350eb7d4a0
[gaim-migrate @ 5836]
Decklin Foster <decklin@red-bean.com>
parents:
5443
diff
changeset
|
372 | return TRUE; |
| 5205 | 373 | #endif /* !GAIM_PLUGINS */ |
| 374 | } | |
| 375 | ||
| 376 | gboolean | |
| 377 | gaim_plugin_unload(GaimPlugin *plugin) | |
| 378 | { | |
| 379 | #ifdef GAIM_PLUGINS | |
| 380 | g_return_val_if_fail(plugin != NULL, FALSE); | |
| 381 | ||
| 382 | loaded_plugins = g_list_remove(loaded_plugins, plugin); | |
| 383 | ||
| 384 | g_return_val_if_fail(gaim_plugin_is_loaded(plugin), FALSE); | |
| 385 | ||
|
5211
94d9756c381f
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
386 | gaim_debug(GAIM_DEBUG_INFO, "plugins", "Unloading plugin %s\n", |
|
94d9756c381f
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
387 | plugin->info->name); |
| 5205 | 388 | |
| 389 | /* cancel any pending dialogs the plugin has */ | |
|
5498
01eec144d71b
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5450
diff
changeset
|
390 | gaim_request_close_with_handle(plugin); |
|
01eec144d71b
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5450
diff
changeset
|
391 | gaim_notify_close_with_handle(plugin); |
| 5205 | 392 | |
| 393 | plugin->loaded = FALSE; | |
| 394 | ||
| 395 | if (plugin->native_plugin) { | |
| 396 | if (plugin->info->unload != NULL) | |
| 397 | plugin->info->unload(plugin); | |
| 398 | ||
| 399 | if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) { | |
| 400 | GaimPluginProtocolInfo *prpl_info; | |
| 401 | GList *l; | |
| 402 | ||
| 403 | prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); | |
| 404 | ||
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
405 | for (l = prpl_info->user_splits; l != NULL; l = l->next) |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
406 | gaim_account_user_split_destroy(l->data); |
| 5205 | 407 | |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
408 | for (l = prpl_info->protocol_options; l != NULL; l = l->next) |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
409 | gaim_account_option_destroy(l->data); |
| 5205 | 410 | |
|
5646
0aa637549d87
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
411 | if (prpl_info->user_splits != NULL) |
|
0aa637549d87
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
412 | g_list_free(prpl_info->user_splits); |
|
0aa637549d87
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
413 | |
|
0aa637549d87
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
414 | if (prpl_info->protocol_options != NULL) |
|
0aa637549d87
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
415 | g_list_free(prpl_info->protocol_options); |
| 5205 | 416 | } |
| 417 | } | |
| 418 | else { | |
| 419 | GaimPlugin *loader; | |
| 420 | GaimPluginLoaderInfo *loader_info; | |
| 421 | ||
|
5794
ebdbb7dc6658
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
422 | loader = find_loader_for_plugin(plugin); |
| 5205 | 423 | |
| 424 | if (loader == NULL) | |
| 425 | return FALSE; | |
| 426 | ||
| 427 | loader_info = GAIM_PLUGIN_LOADER_INFO(loader); | |
| 428 | ||
| 429 | if (loader_info->load != NULL) | |
| 430 | loader_info->unload(plugin); | |
| 431 | } | |
| 432 | ||
| 433 | gaim_signals_disconnect_by_handle(plugin); | |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
434 | gaim_plugin_ipc_unregister_all(plugin); |
| 5205 | 435 | |
| 436 | /* TODO */ | |
| 437 | if (unload_cb != NULL) | |
| 438 | unload_cb(plugin, unload_cb_data); | |
| 439 | ||
|
8986
30ba617356bb
[gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents:
8759
diff
changeset
|
440 | /* I suppose this is the right place to call this... */ |
|
30ba617356bb
[gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents:
8759
diff
changeset
|
441 | gaim_signal_emit(gaim_plugins_get_handle(), "plugin-unload", plugin); |
|
30ba617356bb
[gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents:
8759
diff
changeset
|
442 | |
| 5205 | 443 | return TRUE; |
|
5449
4c350eb7d4a0
[gaim-migrate @ 5836]
Decklin Foster <decklin@red-bean.com>
parents:
5443
diff
changeset
|
444 | #else |
|
4c350eb7d4a0
[gaim-migrate @ 5836]
Decklin Foster <decklin@red-bean.com>
parents:
5443
diff
changeset
|
445 | return TRUE; |
| 5205 | 446 | #endif /* GAIM_PLUGINS */ |
| 447 | } | |
| 448 | ||
| 449 | gboolean | |
| 450 | gaim_plugin_reload(GaimPlugin *plugin) | |
| 451 | { | |
| 452 | #ifdef GAIM_PLUGINS | |
| 453 | g_return_val_if_fail(plugin != NULL, FALSE); | |
| 454 | g_return_val_if_fail(gaim_plugin_is_loaded(plugin), FALSE); | |
| 455 | ||
| 456 | if (!gaim_plugin_unload(plugin)) | |
| 457 | return FALSE; | |
| 458 | ||
| 459 | if (!gaim_plugin_load(plugin)) | |
| 460 | return FALSE; | |
| 461 | ||
| 462 | return TRUE; | |
| 463 | #else | |
|
5449
4c350eb7d4a0
[gaim-migrate @ 5836]
Decklin Foster <decklin@red-bean.com>
parents:
5443
diff
changeset
|
464 | return TRUE; |
| 5205 | 465 | #endif /* !GAIM_PLUGINS */ |
| 466 | } | |
| 467 | ||
| 468 | void | |
| 469 | gaim_plugin_destroy(GaimPlugin *plugin) | |
| 470 | { | |
|
5449
4c350eb7d4a0
[gaim-migrate @ 5836]
Decklin Foster <decklin@red-bean.com>
parents:
5443
diff
changeset
|
471 | #ifdef GAIM_PLUGINS |
| 5205 | 472 | g_return_if_fail(plugin != NULL); |
| 473 | ||
| 474 | if (gaim_plugin_is_loaded(plugin)) | |
| 475 | gaim_plugin_unload(plugin); | |
| 476 | ||
| 477 | plugins = g_list_remove(plugins, plugin); | |
| 478 | ||
|
6981
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
479 | if (load_queue != NULL) |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
480 | load_queue = g_list_remove(load_queue, plugin); |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
481 | |
|
5243
e8d35a430c6d
[gaim-migrate @ 5614]
Christian Hammond <chipx86@chipx86.com>
parents:
5242
diff
changeset
|
482 | if (plugin->info != NULL && plugin->info->dependencies != NULL) |
|
e8d35a430c6d
[gaim-migrate @ 5614]
Christian Hammond <chipx86@chipx86.com>
parents:
5242
diff
changeset
|
483 | g_list_free(plugin->info->dependencies); |
| 5205 | 484 | |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
485 | if (plugin->native_plugin) |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
486 | { |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
487 | if (plugin->info != NULL && plugin->info->type == GAIM_PLUGIN_LOADER) |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
488 | { |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
489 | GaimPluginLoaderInfo *loader_info; |
| 5205 | 490 | GList *exts, *l, *next_l; |
| 491 | GaimPlugin *p2; | |
| 492 | ||
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
493 | loader_info = GAIM_PLUGIN_LOADER_INFO(plugin); |
| 5205 | 494 | |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
495 | if (loader_info != NULL && plugin->info->api_version >= 3 && |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
496 | loader_info->exts != NULL) |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
497 | { |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
498 | for (exts = GAIM_PLUGIN_LOADER_INFO(plugin)->exts; |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
499 | exts != NULL; |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
500 | exts = exts->next) { |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
501 | |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
502 | for (l = gaim_plugins_get_all(); l != NULL; l = next_l) |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
503 | { |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
504 | next_l = l->next; |
| 5205 | 505 | |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
506 | p2 = l->data; |
| 5205 | 507 | |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
508 | if (p2->path != NULL && |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
509 | is_so_file(p2->path, exts->data)) |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
510 | { |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
511 | gaim_plugin_destroy(p2); |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
512 | } |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
513 | } |
| 5205 | 514 | } |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
515 | |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
516 | g_list_free(loader_info->exts); |
| 5205 | 517 | } |
| 518 | ||
| 519 | plugin_loaders = g_list_remove(plugin_loaders, plugin); | |
| 520 | } | |
| 521 | ||
| 522 | if (plugin->info != NULL && plugin->info->destroy != NULL) | |
| 523 | plugin->info->destroy(plugin); | |
| 524 | ||
| 525 | if (plugin->handle != NULL) | |
| 526 | g_module_close(plugin->handle); | |
| 527 | } | |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
528 | else |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
529 | { |
| 5205 | 530 | GaimPlugin *loader; |
| 531 | GaimPluginLoaderInfo *loader_info; | |
| 532 | ||
|
5794
ebdbb7dc6658
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
533 | loader = find_loader_for_plugin(plugin); |
| 5205 | 534 | |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
535 | if (loader != NULL) |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
536 | { |
|
5941
46e136a842b8
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
537 | loader_info = GAIM_PLUGIN_LOADER_INFO(loader); |
| 5205 | 538 | |
|
5941
46e136a842b8
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
539 | if (loader_info->destroy != NULL) |
|
46e136a842b8
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
540 | loader_info->destroy(plugin); |
|
46e136a842b8
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
541 | } |
| 5205 | 542 | } |
| 543 | ||
| 544 | if (plugin->path != NULL) g_free(plugin->path); | |
| 545 | if (plugin->error != NULL) g_free(plugin->error); | |
| 546 | ||
| 547 | g_free(plugin); | |
|
5449
4c350eb7d4a0
[gaim-migrate @ 5836]
Decklin Foster <decklin@red-bean.com>
parents:
5443
diff
changeset
|
548 | #endif /* !GAIM_PLUGINS */ |
| 5205 | 549 | } |
| 550 | ||
| 551 | gboolean | |
| 552 | gaim_plugin_is_loaded(const GaimPlugin *plugin) | |
| 553 | { | |
| 554 | g_return_val_if_fail(plugin != NULL, FALSE); | |
| 555 | ||
| 556 | return plugin->loaded; | |
| 557 | } | |
| 558 | ||
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
559 | /************************************************************************** |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
560 | * Plugin IPC |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
561 | **************************************************************************/ |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
562 | static void |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
563 | destroy_ipc_info(void *data) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
564 | { |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
565 | GaimPluginIpcCommand *ipc_command = (GaimPluginIpcCommand *)data; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
566 | int i; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
567 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
568 | for (i = 0; i < ipc_command->num_params; i++) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
569 | gaim_value_destroy(ipc_command->params[i]); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
570 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
571 | if (ipc_command->ret_value != NULL) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
572 | gaim_value_destroy(ipc_command->ret_value); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
573 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
574 | g_free(ipc_command); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
575 | } |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
576 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
577 | gboolean |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
578 | gaim_plugin_ipc_register(GaimPlugin *plugin, const char *command, |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
579 | GaimCallback func, GaimSignalMarshalFunc marshal, |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
580 | GaimValue *ret_value, int num_params, ...) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
581 | { |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
582 | GaimPluginIpcInfo *ipc_info; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
583 | GaimPluginIpcCommand *ipc_command; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
584 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
585 | g_return_val_if_fail(plugin != NULL, FALSE); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
586 | g_return_val_if_fail(command != NULL, FALSE); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
587 | g_return_val_if_fail(func != NULL, FALSE); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
588 | g_return_val_if_fail(marshal != NULL, FALSE); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
589 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
590 | if (plugin->ipc_data == NULL) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
591 | { |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
592 | ipc_info = plugin->ipc_data = g_new0(GaimPluginIpcInfo, 1); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
593 | ipc_info->commands = g_hash_table_new_full(g_str_hash, g_str_equal, |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
594 | g_free, destroy_ipc_info); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
595 | } |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
596 | else |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
597 | ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
598 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
599 | ipc_command = g_new0(GaimPluginIpcCommand, 1); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
600 | ipc_command->func = func; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
601 | ipc_command->marshal = marshal; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
602 | ipc_command->num_params = num_params; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
603 | ipc_command->ret_value = ret_value; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
604 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
605 | if (num_params > 0) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
606 | { |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
607 | va_list args; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
608 | int i; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
609 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
610 | ipc_command->params = g_new0(GaimValue *, num_params); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
611 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
612 | va_start(args, num_params); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
613 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
614 | for (i = 0; i < num_params; i++) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
615 | ipc_command->params[i] = va_arg(args, GaimValue *); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
616 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
617 | va_end(args); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
618 | } |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
619 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
620 | g_hash_table_replace(ipc_info->commands, g_strdup(command), ipc_command); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
621 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
622 | ipc_info->command_count++; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
623 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
624 | return TRUE; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
625 | } |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
626 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
627 | void |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
628 | gaim_plugin_ipc_unregister(GaimPlugin *plugin, const char *command) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
629 | { |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
630 | GaimPluginIpcInfo *ipc_info; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
631 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
632 | g_return_if_fail(plugin != NULL); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
633 | g_return_if_fail(command != NULL); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
634 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
635 | ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
636 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
637 | if (ipc_info == NULL || |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
638 | g_hash_table_lookup(ipc_info->commands, command) == NULL) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
639 | { |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
640 | gaim_debug_error("plugins", |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
641 | "IPC command '%s' was not registered for plugin %s\n", |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
642 | command, plugin->info->name); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
643 | return; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
644 | } |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
645 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
646 | g_hash_table_remove(ipc_info->commands, command); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
647 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
648 | ipc_info->command_count--; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
649 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
650 | if (ipc_info->command_count == 0) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
651 | { |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
652 | g_hash_table_destroy(ipc_info->commands); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
653 | g_free(ipc_info); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
654 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
655 | plugin->ipc_data = NULL; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
656 | } |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
657 | } |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
658 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
659 | void |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
660 | gaim_plugin_ipc_unregister_all(GaimPlugin *plugin) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
661 | { |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
662 | GaimPluginIpcInfo *ipc_info; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
663 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
664 | g_return_if_fail(plugin != NULL); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
665 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
666 | if (plugin->ipc_data == NULL) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
667 | return; /* Silently ignore it. */ |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
668 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
669 | ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
670 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
671 | g_hash_table_destroy(ipc_info->commands); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
672 | g_free(ipc_info); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
673 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
674 | plugin->ipc_data = NULL; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
675 | } |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
676 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
677 | gboolean |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
678 | gaim_plugin_ipc_get_params(GaimPlugin *plugin, const char *command, |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
679 | GaimValue **ret_value, int *num_params, |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
680 | GaimValue ***params) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
681 | { |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
682 | GaimPluginIpcInfo *ipc_info; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
683 | GaimPluginIpcCommand *ipc_command; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
684 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
685 | g_return_val_if_fail(plugin != NULL, FALSE); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
686 | g_return_val_if_fail(command != NULL, FALSE); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
687 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
688 | ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
689 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
690 | if (ipc_info == NULL || |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
691 | (ipc_command = g_hash_table_lookup(ipc_info->commands, |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
692 | command)) == NULL) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
693 | { |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
694 | gaim_debug_error("plugins", |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
695 | "IPC command '%s' was not registered for plugin %s\n", |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
696 | command, plugin->info->name); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
697 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
698 | return FALSE; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
699 | } |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
700 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
701 | if (num_params != NULL) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
702 | *num_params = ipc_command->num_params; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
703 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
704 | if (params != NULL) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
705 | *params = ipc_command->params; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
706 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
707 | if (ret_value != NULL) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
708 | *ret_value = ipc_command->ret_value; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
709 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
710 | return TRUE; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
711 | } |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
712 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
713 | void * |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
714 | gaim_plugin_ipc_call(GaimPlugin *plugin, const char *command, |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
715 | gboolean *ok, ...) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
716 | { |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
717 | GaimPluginIpcInfo *ipc_info; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
718 | GaimPluginIpcCommand *ipc_command; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
719 | va_list args; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
720 | void *ret_value; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
721 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
722 | if (ok != NULL) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
723 | *ok = FALSE; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
724 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
725 | g_return_val_if_fail(plugin != NULL, NULL); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
726 | g_return_val_if_fail(command != NULL, NULL); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
727 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
728 | ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
729 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
730 | if (ipc_info == NULL || |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
731 | (ipc_command = g_hash_table_lookup(ipc_info->commands, |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
732 | command)) == NULL) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
733 | { |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
734 | gaim_debug_error("plugins", |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
735 | "IPC command '%s' was not registered for plugin %s\n", |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
736 | command, plugin->info->name); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
737 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
738 | return NULL; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
739 | } |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
740 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
741 | va_start(args, ok); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
742 | ipc_command->marshal(ipc_command->func, args, NULL, &ret_value); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
743 | va_end(args); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
744 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
745 | if (ok != NULL) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
746 | *ok = TRUE; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
747 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
748 | return ret_value; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
749 | } |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
750 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
751 | /************************************************************************** |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
752 | * Plugins subsystem |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
753 | **************************************************************************/ |
| 5205 | 754 | void |
| 755 | gaim_plugins_set_search_paths(size_t count, char **paths) | |
| 756 | { | |
| 757 | size_t s; | |
| 758 | ||
| 759 | g_return_if_fail(count > 0); | |
| 760 | g_return_if_fail(paths != NULL); | |
| 761 | ||
| 762 | if (search_paths != NULL) { | |
| 763 | for (s = 0; s < search_path_count; s++) | |
| 764 | g_free(search_paths[s]); | |
| 765 | ||
| 766 | g_free(search_paths); | |
| 767 | } | |
| 768 | ||
| 769 | search_paths = g_new0(char *, count); | |
| 770 | ||
| 771 | for (s = 0; s < count; s++) { | |
| 772 | if (paths[s] == NULL) | |
| 773 | search_paths[s] = NULL; | |
| 774 | else | |
| 775 | search_paths[s] = g_strdup(paths[s]); | |
| 776 | } | |
| 777 | ||
| 778 | search_path_count = count; | |
| 779 | } | |
| 780 | ||
| 781 | void | |
| 782 | gaim_plugins_unload_all(void) | |
| 783 | { | |
| 784 | #ifdef GAIM_PLUGINS | |
| 785 | ||
| 786 | while (loaded_plugins != NULL) | |
| 787 | gaim_plugin_unload(loaded_plugins->data); | |
| 788 | ||
| 789 | #endif /* GAIM_PLUGINS */ | |
| 790 | } | |
| 791 | ||
| 792 | void | |
|
5242
155da5e9bbf0
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
793 | gaim_plugins_destroy_all(void) |
|
155da5e9bbf0
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
794 | { |
|
155da5e9bbf0
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
795 | #ifdef GAIM_PLUGINS |
|
155da5e9bbf0
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
796 | |
|
155da5e9bbf0
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
797 | while (plugins != NULL) |
|
155da5e9bbf0
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
798 | gaim_plugin_destroy(plugins->data); |
|
155da5e9bbf0
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
799 | |
|
155da5e9bbf0
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
800 | #endif /* GAIM_PLUGINS */ |
|
155da5e9bbf0
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
801 | } |
| 5838 | 802 | |
| 803 | void | |
|
5949
bb7cbf02dda9
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
804 | gaim_plugins_load_saved(const char *key) |
| 5838 | 805 | { |
| 806 | #ifdef GAIM_PLUGINS | |
|
5949
bb7cbf02dda9
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
807 | GList *f, *files; |
|
bb7cbf02dda9
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
808 | |
|
bb7cbf02dda9
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
809 | g_return_if_fail(key != NULL); |
| 5838 | 810 | |
|
5949
bb7cbf02dda9
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
811 | files = gaim_prefs_get_string_list(key); |
|
bb7cbf02dda9
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
812 | |
|
7033
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
813 | for (f = files; f; f = f->next) |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
814 | { |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
815 | char *filename = g_path_get_basename(f->data); |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
816 | GaimPlugin *plugin = NULL; |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
817 | |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
818 | if (filename != NULL) |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
819 | { |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
820 | if ((plugin = gaim_plugins_find_with_basename(filename)) != NULL) |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
821 | { |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
822 | gaim_debug_info("plugins", "Loading saved plugin %s\n", |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
823 | filename); |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
824 | gaim_plugin_load(plugin); |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
825 | } |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
826 | else |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
827 | { |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
828 | gaim_debug_error("plugins", "Unable to find saved plugin %s\n", |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
829 | filename); |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
830 | } |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
831 | |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
832 | g_free(filename); |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
833 | } |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
834 | |
| 5838 | 835 | g_free(f->data); |
| 836 | } | |
| 837 | ||
| 838 | g_list_free(files); | |
| 839 | #endif /* GAIM_PLUGINS */ | |
| 840 | } | |
| 841 | ||
| 842 | ||
|
5242
155da5e9bbf0
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
843 | void |
| 5205 | 844 | gaim_plugins_probe(const char *ext) |
| 845 | { | |
| 846 | #ifdef GAIM_PLUGINS | |
| 847 | GDir *dir; | |
| 848 | const gchar *file; | |
| 849 | gchar *path; | |
| 850 | GaimPlugin *plugin; | |
| 851 | size_t i; | |
| 852 | ||
|
8986
30ba617356bb
[gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents:
8759
diff
changeset
|
853 | void *handle; |
|
30ba617356bb
[gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents:
8759
diff
changeset
|
854 | |
| 5205 | 855 | if (!g_module_supported()) |
| 856 | return; | |
| 857 | ||
|
8986
30ba617356bb
[gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents:
8759
diff
changeset
|
858 | handle = gaim_plugins_get_handle(); |
|
30ba617356bb
[gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents:
8759
diff
changeset
|
859 | |
|
30ba617356bb
[gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents:
8759
diff
changeset
|
860 | gaim_debug_info("plugins", "registering plugin-load signal\n"); |
|
30ba617356bb
[gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents:
8759
diff
changeset
|
861 | gaim_signal_register(handle, "plugin-load", gaim_marshal_VOID__POINTER, NULL, |
|
30ba617356bb
[gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents:
8759
diff
changeset
|
862 | 1, gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_PLUGIN)); |
|
30ba617356bb
[gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents:
8759
diff
changeset
|
863 | |
|
30ba617356bb
[gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents:
8759
diff
changeset
|
864 | gaim_debug_info("plugins", "registering plugin-unload signal\n"); |
|
30ba617356bb
[gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents:
8759
diff
changeset
|
865 | gaim_signal_register(handle, "plugin-unload", gaim_marshal_VOID__POINTER, NULL, |
|
30ba617356bb
[gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents:
8759
diff
changeset
|
866 | 1, gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_PLUGIN)); |
|
30ba617356bb
[gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents:
8759
diff
changeset
|
867 | |
|
30ba617356bb
[gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents:
8759
diff
changeset
|
868 | |
| 5205 | 869 | for (i = 0; i < search_path_count; i++) { |
| 870 | if (search_paths[i] == NULL) | |
| 871 | continue; | |
| 872 | ||
| 873 | dir = g_dir_open(search_paths[i], 0, NULL); | |
| 874 | ||
| 875 | if (dir != NULL) { | |
| 876 | while ((file = g_dir_read_name(dir)) != NULL) { | |
| 877 | path = g_build_filename(search_paths[i], file, NULL); | |
| 878 | ||
| 879 | if (ext == NULL || is_so_file(file, ext)) | |
| 880 | plugin = gaim_plugin_probe(path); | |
| 881 | ||
| 882 | g_free(path); | |
| 883 | } | |
| 884 | ||
| 885 | g_dir_close(dir); | |
| 886 | } | |
| 887 | } | |
| 888 | ||
|
6981
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
889 | /* See if we have any plugins waiting to load. */ |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
890 | while (load_queue != NULL) |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
891 | { |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
892 | plugin = (GaimPlugin *)load_queue->data; |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
893 | |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
894 | load_queue = g_list_remove(load_queue, plugin); |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
895 | |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
896 | if (plugin == NULL || plugin->info == NULL) |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
897 | continue; |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
898 | |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
899 | if (plugin->info->type == GAIM_PLUGIN_LOADER) |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
900 | { |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
901 | GList *exts; |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
902 | |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
903 | /* We'll just load this right now. */ |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
904 | if (!gaim_plugin_load(plugin)) |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
905 | { |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
906 | gaim_plugin_destroy(plugin); |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
907 | |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
908 | continue; |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
909 | } |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
910 | |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
911 | plugin_loaders = g_list_append(plugin_loaders, plugin); |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
912 | |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
913 | for (exts = GAIM_PLUGIN_LOADER_INFO(plugin)->exts; |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
914 | exts != NULL; |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
915 | exts = exts->next) |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
916 | { |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
917 | gaim_plugins_probe(exts->data); |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
918 | } |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
919 | } |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
920 | else if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
921 | { |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
922 | /* We'll just load this right now. */ |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
923 | if (!gaim_plugin_load(plugin)) |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
924 | { |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
925 | gaim_plugin_destroy(plugin); |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
926 | |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
927 | continue; |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
928 | } |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
929 | |
| 7956 | 930 | if (gaim_find_prpl(plugin->info->id)) |
|
6981
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
931 | { |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
932 | /* Nothing to see here--move along, move along */ |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
933 | gaim_plugin_destroy(plugin); |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
934 | |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
935 | continue; |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
936 | } |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
937 | |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
938 | protocol_plugins = g_list_insert_sorted(protocol_plugins, plugin, |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
939 | (GCompareFunc)compare_prpl); |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
940 | } |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
941 | } |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
942 | |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
943 | if (load_queue != NULL) |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
944 | { |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
945 | g_list_free(load_queue); |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
946 | load_queue = NULL; |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
947 | } |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
948 | |
| 5205 | 949 | if (probe_cb != NULL) |
| 950 | probe_cb(probe_cb_data); | |
| 951 | ||
| 952 | #endif /* GAIM_PLUGINS */ | |
| 953 | } | |
| 954 | ||
| 955 | gboolean | |
| 956 | gaim_plugin_register(GaimPlugin *plugin) | |
| 957 | { | |
| 958 | g_return_val_if_fail(plugin != NULL, FALSE); | |
| 959 | ||
| 960 | if (g_list_find(plugins, plugin)) | |
| 961 | return TRUE; | |
| 962 | ||
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
963 | if (plugin->info->type == GAIM_PLUGIN_LOADER) |
|
6981
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
964 | { |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
965 | GaimPluginLoaderInfo *loader_info; |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
966 | |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
967 | loader_info = GAIM_PLUGIN_LOADER_INFO(plugin); |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
968 | |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
969 | if (loader_info == NULL || |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
970 | loader_info->api_version != GAIM_LOADER_API_VERSION) |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
971 | { |
| 8759 | 972 | gaim_debug(GAIM_DEBUG_ERROR, "plugins", "%s is unloadable: API version mismatch %d (need %d)\n", |
| 973 | plugin->path, loader_info->api_version, GAIM_LOADER_API_VERSION); | |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
974 | return FALSE; |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
975 | } |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
976 | |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
977 | load_queue = g_list_append(load_queue, plugin); |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
978 | } |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
979 | else if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
980 | { |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
981 | GaimPluginProtocolInfo *prpl_info; |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
982 | |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
983 | prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
984 | |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
985 | if (prpl_info == NULL || |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
986 | prpl_info->api_version != GAIM_PRPL_API_VERSION) |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
987 | { |
| 8759 | 988 | gaim_debug(GAIM_DEBUG_ERROR, "plugins", "%s is unloadable: API version mismatch %d (need %d)\n", |
| 989 | plugin->path, prpl_info->api_version, GAIM_PRPL_API_VERSION); | |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
990 | return FALSE; |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
991 | } |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
992 | |
|
6981
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
993 | load_queue = g_list_append(load_queue, plugin); |
| 5205 | 994 | } |
| 995 | ||
| 996 | plugins = g_list_append(plugins, plugin); | |
| 997 | ||
| 998 | return TRUE; | |
| 999 | } | |
| 1000 | ||
| 1001 | gboolean | |
| 1002 | gaim_plugins_enabled(void) | |
| 1003 | { | |
| 1004 | #ifdef GAIM_PLUGINS | |
| 1005 | return TRUE; | |
| 1006 | #else | |
| 1007 | return FALSE; | |
| 1008 | #endif | |
| 1009 | } | |
| 1010 | ||
| 1011 | void | |
| 1012 | gaim_plugins_register_probe_notify_cb(void (*func)(void *), void *data) | |
| 1013 | { | |
| 1014 | /* TODO */ | |
| 1015 | probe_cb = func; | |
| 1016 | probe_cb_data = data; | |
| 1017 | } | |
| 1018 | ||
| 1019 | void | |
| 1020 | gaim_plugins_unregister_probe_notify_cb(void (*func)(void *)) | |
| 1021 | { | |
| 1022 | /* TODO */ | |
| 1023 | probe_cb = NULL; | |
| 1024 | probe_cb_data = NULL; | |
| 1025 | } | |
| 1026 | ||
| 1027 | void | |
| 1028 | gaim_plugins_register_load_notify_cb(void (*func)(GaimPlugin *, void *), | |
| 1029 | void *data) | |
| 1030 | { | |
| 1031 | /* TODO */ | |
| 1032 | load_cb = func; | |
| 1033 | load_cb_data = data; | |
| 1034 | } | |
| 1035 | ||
| 1036 | void | |
| 1037 | gaim_plugins_unregister_load_notify_cb(void (*func)(GaimPlugin *, void *)) | |
| 1038 | { | |
| 1039 | /* TODO */ | |
| 1040 | load_cb = NULL; | |
| 1041 | load_cb_data = NULL; | |
| 1042 | } | |
| 1043 | ||
| 1044 | void | |
| 1045 | gaim_plugins_register_unload_notify_cb(void (*func)(GaimPlugin *, void *), | |
| 1046 | void *data) | |
| 1047 | { | |
| 1048 | /* TODO */ | |
| 1049 | unload_cb = func; | |
| 1050 | unload_cb_data = data; | |
| 1051 | } | |
| 1052 | ||
| 1053 | void | |
| 1054 | gaim_plugins_unregister_unload_notify_cb(void (*func)(GaimPlugin *, void *)) | |
| 1055 | { | |
| 1056 | /* TODO */ | |
| 1057 | unload_cb = NULL; | |
| 1058 | unload_cb_data = NULL; | |
| 1059 | } | |
| 1060 | ||
| 1061 | GaimPlugin * | |
| 1062 | gaim_plugins_find_with_name(const char *name) | |
| 1063 | { | |
| 1064 | GaimPlugin *plugin; | |
| 1065 | GList *l; | |
| 1066 | ||
| 1067 | for (l = plugins; l != NULL; l = l->next) { | |
| 1068 | plugin = l->data; | |
| 1069 | ||
| 1070 | if (!strcmp(plugin->info->name, name)) | |
| 1071 | return plugin; | |
| 1072 | } | |
| 1073 | ||
| 1074 | return NULL; | |
| 1075 | } | |
| 1076 | ||
| 1077 | GaimPlugin * | |
| 1078 | gaim_plugins_find_with_filename(const char *filename) | |
| 1079 | { | |
| 1080 | GaimPlugin *plugin; | |
| 1081 | GList *l; | |
| 1082 | ||
| 1083 | for (l = plugins; l != NULL; l = l->next) { | |
| 1084 | plugin = l->data; | |
| 1085 | ||
| 1086 | if (plugin->path != NULL && !strcmp(plugin->path, filename)) | |
| 1087 | return plugin; | |
| 1088 | } | |
| 1089 | ||
| 1090 | return NULL; | |
| 1091 | } | |
| 1092 | ||
| 1093 | GaimPlugin * | |
|
7033
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1094 | gaim_plugins_find_with_basename(const char *basename) |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1095 | { |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1096 | GaimPlugin *plugin; |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1097 | GList *l; |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1098 | |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1099 | g_return_val_if_fail(basename != NULL, NULL); |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1100 | |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1101 | for (l = plugins; l != NULL; l = l->next) |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1102 | { |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1103 | char *tmp; |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1104 | |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1105 | plugin = (GaimPlugin *)l->data; |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1106 | |
| 7278 | 1107 | if (plugin->path != NULL) { |
| 1108 | tmp = g_path_get_basename(plugin->path); | |
| 1109 | if (!strcmp(tmp, basename)) { | |
| 1110 | g_free(tmp); | |
|
7033
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1111 | return plugin; |
| 7278 | 1112 | } |
| 7279 | 1113 | g_free(tmp); |
|
7033
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1114 | } |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1115 | } |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1116 | |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1117 | return NULL; |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1118 | } |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1119 | |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1120 | GaimPlugin * |
| 5205 | 1121 | gaim_plugins_find_with_id(const char *id) |
| 1122 | { | |
| 1123 | GaimPlugin *plugin; | |
| 1124 | GList *l; | |
| 1125 | ||
| 1126 | g_return_val_if_fail(id != NULL, NULL); | |
| 1127 | ||
|
6486
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1128 | for (l = plugins; l != NULL; l = l->next) |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1129 | { |
| 5205 | 1130 | plugin = l->data; |
| 1131 | ||
|
6486
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1132 | if (plugin->info->id != NULL && !strcmp(plugin->info->id, id)) |
| 5205 | 1133 | return plugin; |
| 1134 | } | |
| 1135 | ||
| 1136 | return NULL; | |
| 1137 | } | |
| 1138 | ||
| 1139 | GList * | |
| 1140 | gaim_plugins_get_loaded(void) | |
| 1141 | { | |
| 1142 | return loaded_plugins; | |
| 1143 | } | |
| 1144 | ||
| 1145 | GList * | |
|
5573
633880e3f137
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1146 | gaim_plugins_get_protocols(void) |
|
633880e3f137
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1147 | { |
|
633880e3f137
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1148 | return protocol_plugins; |
|
633880e3f137
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1149 | } |
|
633880e3f137
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1150 | |
|
633880e3f137
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1151 | GList * |
| 5205 | 1152 | gaim_plugins_get_all(void) |
| 1153 | { | |
| 1154 | return plugins; | |
| 1155 | } | |
| 1156 |