Tue, 26 Aug 2003 02:55:29 +0000
[gaim-migrate @ 7155]
A patch from Bjoern Voigt that allows the languages in the about window
to be i10ned. Bjoern, I was having some problems emailing you earlier.
I just wanted to say that I've been rather busy and wasn't sure when I
would be able to commit this. Thanks for the patch, it looks nice. I
hand applied it because I'm a freak, and I think there may have been some
other changes to that code since the patch was made. Anyhoo, you might
just want to double check everything.
Fixed some compile warnings:
util.c: In function `_parse_font_tag':
util.c:313: warning: suggest explicit braces to avoid ambiguous `else'
util.c: In function `yahoo_html_to_codes':
util.c:456: warning: unused variable `m'
util.c:456: warning: unused variable `n'
util.c:456: warning: unused variable `vstart'
committer: Mark Doliner <markdoliner@pidgin.im>
| 5205 | 1 | /* |
| 2 | * gaim | |
| 3 | * | |
| 4 | * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
| 5 | * | |
| 6 | * This program is free software; you can redistribute it and/or modify | |
| 7 | * it under the terms of the GNU General Public License as published by | |
| 8 | * the Free Software Foundation; either version 2 of the License, or | |
| 9 | * (at your option) any later version. | |
| 10 | * | |
| 11 | * This program is distributed in the hope that it will be useful, | |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | * GNU General Public License for more details. | |
| 15 | * | |
| 16 | * You should have received a copy of the GNU General Public License | |
| 17 | * along with this program; if not, write to the Free Software | |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 19 | */ | |
| 20 | ||
| 21 | /* | |
| 22 | * ---------------- | |
| 23 | * The Plug-in plugin | |
| 24 | * | |
| 25 | * Plugin support is currently being maintained by Mike Saraf | |
| 26 | * msaraf@dwc.edu | |
| 27 | * | |
| 28 | * Well, I didn't see any work done on it for a while, so I'm going to try | |
| 29 | * my hand at it. - Eric warmenhoven@yahoo.com | |
| 30 | * | |
| 31 | * Mike is my roomate. I can assure you that he's lazy :-P | |
| 32 | * -- Rob rob@marko.net | |
| 33 | * | |
| 34 | * Yeah, well now I'm re-writing a good portion of it! The perl stuff was | |
| 35 | * a hack. Tsk tsk! -- Christian <chipx86@gnupdate.org> | |
| 36 | */ | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
37 | #include "internal.h" |
| 5205 | 38 | |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
39 | #include "accountopt.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
40 | #include "debug.h" |
|
5436
a0e0bacaa196
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5357
diff
changeset
|
41 | #include "notify.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
42 | #include "prefs.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
43 | #include "prpl.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
44 | #include "request.h" |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6432
diff
changeset
|
45 | #include "signals.h" |
| 5205 | 46 | |
| 47 | #ifdef _WIN32 | |
| 48 | # define PLUGIN_EXT ".dll" | |
| 49 | #else | |
| 50 | # define PLUGIN_EXT ".so" | |
| 51 | #endif | |
| 52 | ||
| 53 | static GList *loaded_plugins = NULL; | |
| 54 | static GList *plugins = NULL; | |
| 55 | static GList *plugin_loaders = NULL; | |
|
5573
633880e3f137
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
56 | static GList *protocol_plugins = NULL; |
| 5205 | 57 | |
| 58 | static size_t search_path_count = 0; | |
| 59 | static char **search_paths = NULL; | |
| 60 | ||
| 61 | static void (*probe_cb)(void *) = NULL; | |
| 62 | static void *probe_cb_data = NULL; | |
| 63 | static void (*load_cb)(GaimPlugin *, void *) = NULL; | |
| 64 | static void *load_cb_data = NULL; | |
| 65 | static void (*unload_cb)(GaimPlugin *, void *) = NULL; | |
| 66 | static void *unload_cb_data = NULL; | |
| 67 | ||
| 68 | #ifdef GAIM_PLUGINS | |
| 69 | static int | |
| 70 | is_so_file(const char *filename, const char *ext) | |
| 71 | { | |
| 72 | int len, extlen; | |
| 73 | ||
| 74 | if (filename == NULL || *filename == '\0' || ext == NULL) | |
| 75 | return 0; | |
| 76 | ||
| 77 | extlen = strlen(ext); | |
| 78 | len = strlen(filename) - extlen; | |
| 79 | ||
| 80 | if (len < 0) | |
| 81 | return 0; | |
| 82 | ||
| 83 | return (!strncmp(filename + len, ext, extlen)); | |
| 84 | } | |
| 85 | ||
| 86 | static gboolean | |
|
5794
ebdbb7dc6658
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
87 | loader_supports_file(GaimPlugin *loader, const char *filename) |
| 5205 | 88 | { |
| 6432 | 89 | GList *exts; |
| 5205 | 90 | |
| 6432 | 91 | for (exts = GAIM_PLUGIN_LOADER_INFO(loader)->exts; exts != NULL; exts = exts->next) { |
| 92 | if (is_so_file(filename, (char *)exts->data)) { | |
| 93 | return TRUE; | |
| 5205 | 94 | } |
| 95 | } | |
| 96 | ||
| 97 | return FALSE; | |
| 98 | } | |
| 99 | ||
| 100 | static GaimPlugin * | |
|
5794
ebdbb7dc6658
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
101 | find_loader_for_plugin(const GaimPlugin *plugin) |
| 5205 | 102 | { |
| 103 | GaimPlugin *loader; | |
| 104 | GList *l; | |
| 105 | ||
| 106 | if (plugin->path == NULL) | |
| 107 | return NULL; | |
| 108 | ||
| 109 | for (l = gaim_plugins_get_loaded(); l != NULL; l = l->next) { | |
| 110 | loader = l->data; | |
| 111 | ||
| 112 | if (loader->info->type == GAIM_PLUGIN_LOADER && | |
|
5794
ebdbb7dc6658
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
113 | loader_supports_file(loader, plugin->path)) { |
| 5205 | 114 | |
| 115 | return loader; | |
| 116 | } | |
| 117 | ||
| 118 | loader = NULL; | |
| 119 | } | |
| 120 | ||
| 121 | return NULL; | |
| 122 | } | |
| 123 | ||
|
5449
4c350eb7d4a0
[gaim-migrate @ 5836]
Decklin Foster <decklin@red-bean.com>
parents:
5443
diff
changeset
|
124 | #endif /* GAIM_PLUGINS */ |
|
4c350eb7d4a0
[gaim-migrate @ 5836]
Decklin Foster <decklin@red-bean.com>
parents:
5443
diff
changeset
|
125 | |
| 5205 | 126 | static gint |
| 127 | compare_prpl(GaimPlugin *a, GaimPlugin *b) | |
| 128 | { | |
| 129 | /* neg if a before b, 0 if equal, pos if a after b */ | |
| 130 | return ((GAIM_IS_PROTOCOL_PLUGIN(a) | |
| 131 | ? GAIM_PLUGIN_PROTOCOL_INFO(a)->protocol : -1) - | |
| 132 | ((GAIM_IS_PROTOCOL_PLUGIN(b) | |
| 133 | ? GAIM_PLUGIN_PROTOCOL_INFO(b)->protocol : -1))); | |
| 134 | } | |
| 135 | ||
| 136 | GaimPlugin * | |
| 137 | gaim_plugin_new(gboolean native, const char *path) | |
| 138 | { | |
| 139 | GaimPlugin *plugin; | |
| 140 | ||
| 141 | plugin = g_new0(GaimPlugin, 1); | |
| 142 | ||
| 143 | plugin->native_plugin = native; | |
| 144 | plugin->path = (path == NULL ? NULL : g_strdup(path)); | |
| 145 | ||
| 146 | return plugin; | |
| 147 | } | |
| 148 | ||
| 149 | GaimPlugin * | |
| 150 | gaim_plugin_probe(const char *filename) | |
| 151 | { | |
| 152 | #ifdef GAIM_PLUGINS | |
| 153 | GaimPlugin *plugin = NULL; | |
| 154 | GaimPlugin *loader; | |
| 155 | gboolean (*gaim_init_plugin)(GaimPlugin *); | |
| 156 | ||
| 157 | g_return_val_if_fail(filename != NULL, NULL); | |
| 158 | ||
|
5973
adc75f0fcaa3
[gaim-migrate @ 6420]
Mark Doliner <markdoliner@pidgin.im>
parents:
5949
diff
changeset
|
159 | if (!g_file_test(filename, G_FILE_TEST_EXISTS)) |
|
adc75f0fcaa3
[gaim-migrate @ 6420]
Mark Doliner <markdoliner@pidgin.im>
parents:
5949
diff
changeset
|
160 | return NULL; |
|
adc75f0fcaa3
[gaim-migrate @ 6420]
Mark Doliner <markdoliner@pidgin.im>
parents:
5949
diff
changeset
|
161 | |
| 5205 | 162 | plugin = gaim_plugins_find_with_filename(filename); |
| 163 | ||
| 164 | if (plugin != NULL) | |
| 165 | return plugin; | |
| 166 | ||
| 167 | plugin = gaim_plugin_new(is_so_file(filename, PLUGIN_EXT), filename); | |
| 168 | ||
| 169 | if (plugin->native_plugin) { | |
| 5450 | 170 | const char *error; |
| 5205 | 171 | plugin->handle = g_module_open(filename, 0); |
| 172 | ||
| 173 | if (plugin->handle == NULL) { | |
| 5443 | 174 | error = g_module_error(); |
|
5269
a318feccd844
[gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents:
5268
diff
changeset
|
175 | gaim_debug(GAIM_DEBUG_ERROR, "plugins", "%s is unloadable: %s\n", |
| 5443 | 176 | plugin->path, error ? error : "Unknown error."); |
| 5205 | 177 | |
|
5269
a318feccd844
[gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents:
5268
diff
changeset
|
178 | gaim_plugin_destroy(plugin); |
|
a318feccd844
[gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents:
5268
diff
changeset
|
179 | |
|
a318feccd844
[gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents:
5268
diff
changeset
|
180 | return NULL; |
| 5205 | 181 | } |
| 182 | ||
| 183 | if (!g_module_symbol(plugin->handle, "gaim_init_plugin", | |
| 184 | (gpointer *)&gaim_init_plugin)) { | |
| 185 | g_module_close(plugin->handle); | |
| 186 | plugin->handle = NULL; | |
| 187 | ||
| 5443 | 188 | error = g_module_error(); |
|
5211
94d9756c381f
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
189 | gaim_debug(GAIM_DEBUG_ERROR, "plugins", "%s is unloadable: %s\n", |
| 5443 | 190 | plugin->path, error ? error : "Unknown error."); |
| 5205 | 191 | |
| 192 | gaim_plugin_destroy(plugin); | |
| 193 | ||
| 194 | return NULL; | |
| 195 | } | |
| 196 | } | |
| 197 | else { | |
|
5794
ebdbb7dc6658
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
198 | loader = find_loader_for_plugin(plugin); |
| 5205 | 199 | |
| 200 | if (loader == NULL) { | |
| 201 | gaim_plugin_destroy(plugin); | |
| 202 | ||
| 203 | return NULL; | |
| 204 | } | |
| 205 | ||
| 206 | gaim_init_plugin = GAIM_PLUGIN_LOADER_INFO(loader)->probe; | |
| 207 | } | |
| 208 | ||
| 209 | plugin->error = NULL; | |
| 210 | ||
| 211 | if (!gaim_init_plugin(plugin) || plugin->info == NULL) { | |
| 212 | char buf[BUFSIZ]; | |
| 213 | ||
| 214 | g_snprintf(buf, sizeof(buf), | |
| 215 | _("The plugin %s did not return any valid plugin " | |
| 216 | "information"), | |
| 217 | plugin->path); | |
| 218 | ||
|
5436
a0e0bacaa196
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5357
diff
changeset
|
219 | gaim_notify_error(NULL, NULL, |
|
a0e0bacaa196
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5357
diff
changeset
|
220 | _("Gaim was unable to load your plugin."), buf); |
| 5205 | 221 | |
| 222 | gaim_plugin_destroy(plugin); | |
| 223 | ||
| 224 | return NULL; | |
| 225 | } | |
| 226 | ||
| 227 | return plugin; | |
| 228 | #else | |
| 229 | return NULL; | |
| 230 | #endif /* !GAIM_PLUGINS */ | |
| 231 | } | |
| 232 | ||
| 233 | gboolean | |
| 234 | gaim_plugin_load(GaimPlugin *plugin) | |
| 235 | { | |
| 236 | #ifdef GAIM_PLUGINS | |
|
6486
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
237 | GList *dep_list = NULL; |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
238 | GList *l; |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
239 | |
| 5205 | 240 | g_return_val_if_fail(plugin != NULL, FALSE); |
|
5270
74286f7fb991
[gaim-migrate @ 5642]
Christian Hammond <chipx86@chipx86.com>
parents:
5269
diff
changeset
|
241 | g_return_val_if_fail(plugin->error == NULL, FALSE); |
| 5205 | 242 | |
| 243 | if (gaim_plugin_is_loaded(plugin)) | |
| 244 | return TRUE; | |
| 245 | ||
|
6486
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
246 | /* |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
247 | * Go through the list of the plugin's dependencies. |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
248 | * |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
249 | * First pass: Make sure all the plugins needed are probed. |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
250 | */ |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
251 | for (l = plugin->info->dependencies; l != NULL; l = l->next) |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
252 | { |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
253 | const char *dep_name = (const char *)l->data; |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
254 | GaimPlugin *dep_plugin; |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
255 | |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
256 | dep_plugin = gaim_plugins_find_with_id(dep_name); |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
257 | |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
258 | if (dep_plugin == NULL) |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
259 | { |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
260 | char buf[BUFSIZ]; |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
261 | |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
262 | g_snprintf(buf, sizeof(buf), |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
263 | _("The required plugin %s was not found. " |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
264 | "Please install this plugin and try again."), |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
265 | dep_name); |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
266 | |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
267 | gaim_notify_error(NULL, NULL, |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
268 | _("Gaim was unable to load your plugin."), |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
269 | buf); |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
270 | |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
271 | if (dep_list != NULL) |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
272 | g_list_free(dep_list); |
|
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 | return FALSE; |
|
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 | |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
277 | dep_list = g_list_append(dep_list, 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 | |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
280 | /* Second pass: load all the required plugins. */ |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
281 | for (l = dep_list; l != NULL; l = l->next) |
|
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 | GaimPlugin *dep_plugin = (GaimPlugin *)l->data; |
|
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 | if (!gaim_plugin_is_loaded(dep_plugin)) |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
286 | { |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
287 | if (!gaim_plugin_load(dep_plugin)) |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
288 | { |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
289 | char buf[BUFSIZ]; |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
290 | |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
291 | g_snprintf(buf, sizeof(buf), |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
292 | _("The required plugin %s was unable to load."), |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
293 | plugin->info->name); |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
294 | |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
295 | gaim_notify_error(NULL, NULL, |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
296 | _("Gaim was unable to load your plugin."), |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
297 | buf); |
|
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 | if (dep_list != NULL) |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
300 | g_list_free(dep_list); |
|
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 | return FALSE; |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
303 | } |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
304 | } |
|
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 | |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
307 | if (dep_list != NULL) |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
308 | g_list_free(dep_list); |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
309 | |
| 5205 | 310 | if (plugin->native_plugin) { |
|
5357
1fa9e57df50c
[gaim-migrate @ 5733]
Christian Hammond <chipx86@chipx86.com>
parents:
5270
diff
changeset
|
311 | if (plugin->info != NULL) { |
|
1fa9e57df50c
[gaim-migrate @ 5733]
Christian Hammond <chipx86@chipx86.com>
parents:
5270
diff
changeset
|
312 | if (plugin->info->load != NULL) |
|
1fa9e57df50c
[gaim-migrate @ 5733]
Christian Hammond <chipx86@chipx86.com>
parents:
5270
diff
changeset
|
313 | plugin->info->load(plugin); |
|
1fa9e57df50c
[gaim-migrate @ 5733]
Christian Hammond <chipx86@chipx86.com>
parents:
5270
diff
changeset
|
314 | } |
| 5205 | 315 | } |
| 316 | else { | |
| 317 | GaimPlugin *loader; | |
| 318 | GaimPluginLoaderInfo *loader_info; | |
| 319 | ||
|
5794
ebdbb7dc6658
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
320 | loader = find_loader_for_plugin(plugin); |
| 5205 | 321 | |
| 322 | if (loader == NULL) | |
| 323 | return FALSE; | |
| 324 | ||
| 325 | loader_info = GAIM_PLUGIN_LOADER_INFO(loader); | |
| 326 | ||
| 327 | if (loader_info->load != NULL) | |
| 328 | loader_info->load(plugin); | |
| 329 | } | |
| 330 | ||
| 331 | loaded_plugins = g_list_append(loaded_plugins, plugin); | |
| 332 | ||
| 333 | plugin->loaded = TRUE; | |
| 334 | ||
| 335 | /* TODO */ | |
| 336 | if (load_cb != NULL) | |
| 337 | load_cb(plugin, load_cb_data); | |
| 338 | ||
| 339 | return TRUE; | |
| 340 | ||
| 341 | #else | |
|
5449
4c350eb7d4a0
[gaim-migrate @ 5836]
Decklin Foster <decklin@red-bean.com>
parents:
5443
diff
changeset
|
342 | return TRUE; |
| 5205 | 343 | #endif /* !GAIM_PLUGINS */ |
| 344 | } | |
| 345 | ||
| 346 | gboolean | |
| 347 | gaim_plugin_unload(GaimPlugin *plugin) | |
| 348 | { | |
| 349 | #ifdef GAIM_PLUGINS | |
| 350 | g_return_val_if_fail(plugin != NULL, FALSE); | |
| 351 | ||
| 352 | loaded_plugins = g_list_remove(loaded_plugins, plugin); | |
| 353 | ||
| 354 | g_return_val_if_fail(gaim_plugin_is_loaded(plugin), FALSE); | |
| 355 | ||
|
5211
94d9756c381f
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
356 | gaim_debug(GAIM_DEBUG_INFO, "plugins", "Unloading plugin %s\n", |
|
94d9756c381f
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
357 | plugin->info->name); |
| 5205 | 358 | |
| 359 | /* cancel any pending dialogs the plugin has */ | |
|
5498
01eec144d71b
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5450
diff
changeset
|
360 | gaim_request_close_with_handle(plugin); |
|
01eec144d71b
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5450
diff
changeset
|
361 | gaim_notify_close_with_handle(plugin); |
| 5205 | 362 | |
| 363 | plugin->loaded = FALSE; | |
| 364 | ||
| 365 | if (plugin->native_plugin) { | |
| 366 | if (plugin->info->unload != NULL) | |
| 367 | plugin->info->unload(plugin); | |
| 368 | ||
| 369 | if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) { | |
| 370 | GaimPluginProtocolInfo *prpl_info; | |
| 371 | GList *l; | |
| 372 | ||
| 373 | prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); | |
| 374 | ||
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
375 | for (l = prpl_info->user_splits; l != NULL; l = l->next) |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
376 | gaim_account_user_split_destroy(l->data); |
| 5205 | 377 | |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
378 | for (l = prpl_info->protocol_options; l != NULL; l = l->next) |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
379 | gaim_account_option_destroy(l->data); |
| 5205 | 380 | |
|
5646
0aa637549d87
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
381 | if (prpl_info->user_splits != NULL) |
|
0aa637549d87
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
382 | g_list_free(prpl_info->user_splits); |
|
0aa637549d87
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
383 | |
|
0aa637549d87
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
384 | if (prpl_info->protocol_options != NULL) |
|
0aa637549d87
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
385 | g_list_free(prpl_info->protocol_options); |
| 5205 | 386 | } |
| 387 | } | |
| 388 | else { | |
| 389 | GaimPlugin *loader; | |
| 390 | GaimPluginLoaderInfo *loader_info; | |
| 391 | ||
|
5794
ebdbb7dc6658
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
392 | loader = find_loader_for_plugin(plugin); |
| 5205 | 393 | |
| 394 | if (loader == NULL) | |
| 395 | return FALSE; | |
| 396 | ||
| 397 | loader_info = GAIM_PLUGIN_LOADER_INFO(loader); | |
| 398 | ||
| 399 | if (loader_info->load != NULL) | |
| 400 | loader_info->unload(plugin); | |
| 401 | } | |
| 402 | ||
| 403 | gaim_signals_disconnect_by_handle(plugin); | |
| 404 | ||
| 405 | /* TODO */ | |
| 406 | if (unload_cb != NULL) | |
| 407 | unload_cb(plugin, unload_cb_data); | |
| 408 | ||
| 409 | return TRUE; | |
|
5449
4c350eb7d4a0
[gaim-migrate @ 5836]
Decklin Foster <decklin@red-bean.com>
parents:
5443
diff
changeset
|
410 | #else |
|
4c350eb7d4a0
[gaim-migrate @ 5836]
Decklin Foster <decklin@red-bean.com>
parents:
5443
diff
changeset
|
411 | return TRUE; |
| 5205 | 412 | #endif /* GAIM_PLUGINS */ |
| 413 | } | |
| 414 | ||
| 415 | gboolean | |
| 416 | gaim_plugin_reload(GaimPlugin *plugin) | |
| 417 | { | |
| 418 | #ifdef GAIM_PLUGINS | |
| 419 | g_return_val_if_fail(plugin != NULL, FALSE); | |
| 420 | g_return_val_if_fail(gaim_plugin_is_loaded(plugin), FALSE); | |
| 421 | ||
| 422 | if (!gaim_plugin_unload(plugin)) | |
| 423 | return FALSE; | |
| 424 | ||
| 425 | if (!gaim_plugin_load(plugin)) | |
| 426 | return FALSE; | |
| 427 | ||
| 428 | return TRUE; | |
| 429 | #else | |
|
5449
4c350eb7d4a0
[gaim-migrate @ 5836]
Decklin Foster <decklin@red-bean.com>
parents:
5443
diff
changeset
|
430 | return TRUE; |
| 5205 | 431 | #endif /* !GAIM_PLUGINS */ |
| 432 | } | |
| 433 | ||
| 434 | void | |
| 435 | gaim_plugin_destroy(GaimPlugin *plugin) | |
| 436 | { | |
|
5449
4c350eb7d4a0
[gaim-migrate @ 5836]
Decklin Foster <decklin@red-bean.com>
parents:
5443
diff
changeset
|
437 | #ifdef GAIM_PLUGINS |
| 5205 | 438 | g_return_if_fail(plugin != NULL); |
| 439 | ||
| 440 | if (gaim_plugin_is_loaded(plugin)) | |
| 441 | gaim_plugin_unload(plugin); | |
| 442 | ||
| 443 | plugins = g_list_remove(plugins, plugin); | |
| 444 | ||
|
5243
e8d35a430c6d
[gaim-migrate @ 5614]
Christian Hammond <chipx86@chipx86.com>
parents:
5242
diff
changeset
|
445 | if (plugin->info != NULL && plugin->info->dependencies != NULL) |
|
e8d35a430c6d
[gaim-migrate @ 5614]
Christian Hammond <chipx86@chipx86.com>
parents:
5242
diff
changeset
|
446 | g_list_free(plugin->info->dependencies); |
| 5205 | 447 | |
| 448 | if (plugin->native_plugin) { | |
| 449 | ||
| 450 | if (plugin->info != NULL && plugin->info->type == GAIM_PLUGIN_LOADER) { | |
| 451 | GList *exts, *l, *next_l; | |
| 452 | GaimPlugin *p2; | |
| 453 | ||
| 454 | for (exts = GAIM_PLUGIN_LOADER_INFO(plugin)->exts; | |
| 455 | exts != NULL; | |
| 456 | exts = exts->next) { | |
| 457 | ||
| 458 | for (l = gaim_plugins_get_all(); l != NULL; l = next_l) { | |
| 459 | next_l = l->next; | |
| 460 | ||
| 461 | p2 = l->data; | |
| 462 | ||
| 463 | if (p2->path != NULL && is_so_file(p2->path, exts->data)) | |
| 464 | gaim_plugin_destroy(p2); | |
| 465 | } | |
| 466 | } | |
| 467 | ||
| 468 | g_list_free(GAIM_PLUGIN_LOADER_INFO(plugin)->exts); | |
| 469 | ||
| 470 | plugin_loaders = g_list_remove(plugin_loaders, plugin); | |
| 471 | } | |
| 472 | ||
| 473 | if (plugin->info != NULL && plugin->info->destroy != NULL) | |
| 474 | plugin->info->destroy(plugin); | |
| 475 | ||
| 476 | if (plugin->handle != NULL) | |
| 477 | g_module_close(plugin->handle); | |
| 478 | } | |
| 479 | else { | |
| 480 | GaimPlugin *loader; | |
| 481 | GaimPluginLoaderInfo *loader_info; | |
| 482 | ||
|
5794
ebdbb7dc6658
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
483 | loader = find_loader_for_plugin(plugin); |
| 5205 | 484 | |
|
5941
46e136a842b8
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
485 | if (loader != NULL) { |
|
46e136a842b8
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
486 | loader_info = GAIM_PLUGIN_LOADER_INFO(loader); |
| 5205 | 487 | |
|
5941
46e136a842b8
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
488 | if (loader_info->destroy != NULL) |
|
46e136a842b8
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
489 | loader_info->destroy(plugin); |
|
46e136a842b8
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
490 | } |
| 5205 | 491 | } |
| 492 | ||
| 493 | if (plugin->path != NULL) g_free(plugin->path); | |
| 494 | if (plugin->error != NULL) g_free(plugin->error); | |
| 495 | ||
| 496 | g_free(plugin); | |
|
5449
4c350eb7d4a0
[gaim-migrate @ 5836]
Decklin Foster <decklin@red-bean.com>
parents:
5443
diff
changeset
|
497 | #endif /* !GAIM_PLUGINS */ |
| 5205 | 498 | } |
| 499 | ||
| 500 | gboolean | |
| 501 | gaim_plugin_is_loaded(const GaimPlugin *plugin) | |
| 502 | { | |
| 503 | g_return_val_if_fail(plugin != NULL, FALSE); | |
| 504 | ||
| 505 | return plugin->loaded; | |
| 506 | } | |
| 507 | ||
| 508 | void | |
| 509 | gaim_plugins_set_search_paths(size_t count, char **paths) | |
| 510 | { | |
| 511 | size_t s; | |
| 512 | ||
| 513 | g_return_if_fail(count > 0); | |
| 514 | g_return_if_fail(paths != NULL); | |
| 515 | ||
| 516 | if (search_paths != NULL) { | |
| 517 | for (s = 0; s < search_path_count; s++) | |
| 518 | g_free(search_paths[s]); | |
| 519 | ||
| 520 | g_free(search_paths); | |
| 521 | } | |
| 522 | ||
| 523 | search_paths = g_new0(char *, count); | |
| 524 | ||
| 525 | for (s = 0; s < count; s++) { | |
| 526 | if (paths[s] == NULL) | |
| 527 | search_paths[s] = NULL; | |
| 528 | else | |
| 529 | search_paths[s] = g_strdup(paths[s]); | |
| 530 | } | |
| 531 | ||
| 532 | search_path_count = count; | |
| 533 | } | |
| 534 | ||
| 535 | void | |
| 536 | gaim_plugins_unload_all(void) | |
| 537 | { | |
| 538 | #ifdef GAIM_PLUGINS | |
| 539 | ||
| 540 | while (loaded_plugins != NULL) | |
| 541 | gaim_plugin_unload(loaded_plugins->data); | |
| 542 | ||
| 543 | #endif /* GAIM_PLUGINS */ | |
| 544 | } | |
| 545 | ||
| 546 | void | |
|
5242
155da5e9bbf0
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
547 | gaim_plugins_destroy_all(void) |
|
155da5e9bbf0
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
548 | { |
|
155da5e9bbf0
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
549 | #ifdef GAIM_PLUGINS |
|
155da5e9bbf0
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
550 | |
|
155da5e9bbf0
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
551 | while (plugins != NULL) |
|
155da5e9bbf0
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
552 | gaim_plugin_destroy(plugins->data); |
|
155da5e9bbf0
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
553 | |
|
155da5e9bbf0
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
554 | #endif /* GAIM_PLUGINS */ |
|
155da5e9bbf0
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
555 | } |
| 5838 | 556 | |
| 557 | void | |
|
5949
bb7cbf02dda9
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
558 | gaim_plugins_load_saved(const char *key) |
| 5838 | 559 | { |
| 560 | #ifdef GAIM_PLUGINS | |
|
5949
bb7cbf02dda9
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
561 | GList *f, *files; |
|
bb7cbf02dda9
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
562 | |
|
bb7cbf02dda9
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
563 | g_return_if_fail(key != NULL); |
| 5838 | 564 | |
|
5949
bb7cbf02dda9
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
565 | files = gaim_prefs_get_string_list(key); |
|
bb7cbf02dda9
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
566 | |
|
bb7cbf02dda9
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
567 | for (f = files; f; f = f->next) { |
| 5838 | 568 | gaim_plugin_load(gaim_plugin_probe(f->data)); |
| 569 | g_free(f->data); | |
| 570 | } | |
| 571 | ||
| 572 | g_list_free(files); | |
| 573 | #endif /* GAIM_PLUGINS */ | |
| 574 | } | |
| 575 | ||
| 576 | ||
|
5242
155da5e9bbf0
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
577 | void |
| 5205 | 578 | gaim_plugins_probe(const char *ext) |
| 579 | { | |
| 580 | #ifdef GAIM_PLUGINS | |
| 581 | GDir *dir; | |
| 582 | const gchar *file; | |
| 583 | gchar *path; | |
| 584 | GaimPlugin *plugin; | |
| 585 | size_t i; | |
| 586 | ||
| 587 | if (!g_module_supported()) | |
| 588 | return; | |
| 589 | ||
| 590 | for (i = 0; i < search_path_count; i++) { | |
| 591 | if (search_paths[i] == NULL) | |
| 592 | continue; | |
| 593 | ||
| 594 | dir = g_dir_open(search_paths[i], 0, NULL); | |
| 595 | ||
| 596 | if (dir != NULL) { | |
| 597 | while ((file = g_dir_read_name(dir)) != NULL) { | |
| 598 | path = g_build_filename(search_paths[i], file, NULL); | |
| 599 | ||
| 600 | if (ext == NULL || is_so_file(file, ext)) | |
| 601 | plugin = gaim_plugin_probe(path); | |
| 602 | ||
| 603 | g_free(path); | |
| 604 | } | |
| 605 | ||
| 606 | g_dir_close(dir); | |
| 607 | } | |
| 608 | } | |
| 609 | ||
| 610 | if (probe_cb != NULL) | |
| 611 | probe_cb(probe_cb_data); | |
| 612 | ||
| 613 | #endif /* GAIM_PLUGINS */ | |
| 614 | } | |
| 615 | ||
| 616 | gboolean | |
| 617 | gaim_plugin_register(GaimPlugin *plugin) | |
| 618 | { | |
| 619 | g_return_val_if_fail(plugin != NULL, FALSE); | |
| 620 | ||
| 621 | if (g_list_find(plugins, plugin)) | |
| 622 | return TRUE; | |
| 623 | ||
| 624 | /* Special exception for loader plugins. We want them loaded NOW! */ | |
| 625 | if (plugin->info->type == GAIM_PLUGIN_LOADER) { | |
| 626 | GList *exts; | |
| 627 | ||
| 628 | /* We'll just load this right now. */ | |
| 629 | if (!gaim_plugin_load(plugin)) { | |
| 630 | ||
| 631 | gaim_plugin_destroy(plugin); | |
| 632 | ||
| 633 | return FALSE; | |
| 634 | } | |
| 635 | ||
| 636 | plugin_loaders = g_list_append(plugin_loaders, plugin); | |
| 637 | ||
| 638 | for (exts = GAIM_PLUGIN_LOADER_INFO(plugin)->exts; | |
| 639 | exts != NULL; | |
| 640 | exts = exts->next) { | |
| 641 | ||
| 642 | gaim_plugins_probe(exts->data); | |
| 643 | } | |
| 644 | } | |
| 645 | else if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) { | |
| 646 | ||
| 647 | /* We'll just load this right now. */ | |
| 648 | if (!gaim_plugin_load(plugin)) { | |
| 649 | ||
| 650 | gaim_plugin_destroy(plugin); | |
| 651 | ||
| 652 | return FALSE; | |
| 653 | } | |
| 654 | ||
| 655 | if (GAIM_PLUGIN_PROTOCOL_INFO(plugin)->protocol == GAIM_PROTO_ICQ || | |
| 656 | gaim_find_prpl(GAIM_PLUGIN_PROTOCOL_INFO(plugin)->protocol)) { | |
| 657 | ||
| 658 | /* Nothing to see here--move along, move along */ | |
| 659 | gaim_plugin_destroy(plugin); | |
| 660 | ||
| 661 | return FALSE; | |
| 662 | } | |
| 663 | ||
|
5573
633880e3f137
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
664 | protocol_plugins = g_list_insert_sorted(protocol_plugins, plugin, |
|
633880e3f137
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
665 | (GCompareFunc)compare_prpl); |
| 5205 | 666 | } |
| 667 | ||
| 668 | plugins = g_list_append(plugins, plugin); | |
| 669 | ||
| 670 | return TRUE; | |
| 671 | } | |
| 672 | ||
| 673 | gboolean | |
| 674 | gaim_plugins_enabled(void) | |
| 675 | { | |
| 676 | #ifdef GAIM_PLUGINS | |
| 677 | return TRUE; | |
| 678 | #else | |
| 679 | return FALSE; | |
| 680 | #endif | |
| 681 | } | |
| 682 | ||
| 683 | void | |
| 684 | gaim_plugins_register_probe_notify_cb(void (*func)(void *), void *data) | |
| 685 | { | |
| 686 | /* TODO */ | |
| 687 | probe_cb = func; | |
| 688 | probe_cb_data = data; | |
| 689 | } | |
| 690 | ||
| 691 | void | |
| 692 | gaim_plugins_unregister_probe_notify_cb(void (*func)(void *)) | |
| 693 | { | |
| 694 | /* TODO */ | |
| 695 | probe_cb = NULL; | |
| 696 | probe_cb_data = NULL; | |
| 697 | } | |
| 698 | ||
| 699 | void | |
| 700 | gaim_plugins_register_load_notify_cb(void (*func)(GaimPlugin *, void *), | |
| 701 | void *data) | |
| 702 | { | |
| 703 | /* TODO */ | |
| 704 | load_cb = func; | |
| 705 | load_cb_data = data; | |
| 706 | } | |
| 707 | ||
| 708 | void | |
| 709 | gaim_plugins_unregister_load_notify_cb(void (*func)(GaimPlugin *, void *)) | |
| 710 | { | |
| 711 | /* TODO */ | |
| 712 | load_cb = NULL; | |
| 713 | load_cb_data = NULL; | |
| 714 | } | |
| 715 | ||
| 716 | void | |
| 717 | gaim_plugins_register_unload_notify_cb(void (*func)(GaimPlugin *, void *), | |
| 718 | void *data) | |
| 719 | { | |
| 720 | /* TODO */ | |
| 721 | unload_cb = func; | |
| 722 | unload_cb_data = data; | |
| 723 | } | |
| 724 | ||
| 725 | void | |
| 726 | gaim_plugins_unregister_unload_notify_cb(void (*func)(GaimPlugin *, void *)) | |
| 727 | { | |
| 728 | /* TODO */ | |
| 729 | unload_cb = NULL; | |
| 730 | unload_cb_data = NULL; | |
| 731 | } | |
| 732 | ||
| 733 | GaimPlugin * | |
| 734 | gaim_plugins_find_with_name(const char *name) | |
| 735 | { | |
| 736 | GaimPlugin *plugin; | |
| 737 | GList *l; | |
| 738 | ||
| 739 | for (l = plugins; l != NULL; l = l->next) { | |
| 740 | plugin = l->data; | |
| 741 | ||
| 742 | if (!strcmp(plugin->info->name, name)) | |
| 743 | return plugin; | |
| 744 | } | |
| 745 | ||
| 746 | return NULL; | |
| 747 | } | |
| 748 | ||
| 749 | GaimPlugin * | |
| 750 | gaim_plugins_find_with_filename(const char *filename) | |
| 751 | { | |
| 752 | GaimPlugin *plugin; | |
| 753 | GList *l; | |
| 754 | ||
| 755 | for (l = plugins; l != NULL; l = l->next) { | |
| 756 | plugin = l->data; | |
| 757 | ||
| 758 | if (plugin->path != NULL && !strcmp(plugin->path, filename)) | |
| 759 | return plugin; | |
| 760 | } | |
| 761 | ||
| 762 | return NULL; | |
| 763 | } | |
| 764 | ||
| 765 | GaimPlugin * | |
| 766 | gaim_plugins_find_with_id(const char *id) | |
| 767 | { | |
| 768 | GaimPlugin *plugin; | |
| 769 | GList *l; | |
| 770 | ||
| 771 | g_return_val_if_fail(id != NULL, NULL); | |
| 772 | ||
|
6486
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
773 | for (l = plugins; l != NULL; l = l->next) |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
774 | { |
| 5205 | 775 | plugin = l->data; |
| 776 | ||
|
6486
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
777 | if (plugin->info->id != NULL && !strcmp(plugin->info->id, id)) |
| 5205 | 778 | return plugin; |
| 779 | } | |
| 780 | ||
| 781 | return NULL; | |
| 782 | } | |
| 783 | ||
| 784 | GList * | |
| 785 | gaim_plugins_get_loaded(void) | |
| 786 | { | |
| 787 | return loaded_plugins; | |
| 788 | } | |
| 789 | ||
| 790 | GList * | |
|
5573
633880e3f137
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
791 | gaim_plugins_get_protocols(void) |
|
633880e3f137
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
792 | { |
|
633880e3f137
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
793 | return protocol_plugins; |
|
633880e3f137
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
794 | } |
|
633880e3f137
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
795 | |
|
633880e3f137
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
796 | GList * |
| 5205 | 797 | gaim_plugins_get_all(void) |
| 798 | { | |
| 799 | return plugins; | |
| 800 | } | |
| 801 |