Mercurial > pidgin
annotate src/plugin.c @ 12077:3cf98e532126
[gaim-migrate @ 14374]
Stu pointed out that I probably want to leave this how it was.
This should allow you to use the same 3rd party plugins
across platforms using the same prefs.xml?
committer: Tailor Script <tailor@pidgin.im>
| author | Mark Doliner <mark@kingant.net> |
|---|---|
| date | Mon, 14 Nov 2005 03:38:40 +0000 |
| parents | ee8312c764b1 |
| children | 5a08737f76c6 |
| rev | line source |
|---|---|
| 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
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
22 #include "internal.h" |
| 5205 | 23 |
|
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
24 #include "accountopt.h" |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
25 #include "debug.h" |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5357
diff
changeset
|
26 #include "notify.h" |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
27 #include "prefs.h" |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
28 #include "prpl.h" |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
29 #include "request.h" |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6432
diff
changeset
|
30 #include "signals.h" |
| 9943 | 31 #include "version.h" |
| 5205 | 32 |
|
6822
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
33 typedef struct |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
34 { |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
35 GHashTable *commands; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
36 size_t command_count; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
37 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
38 } GaimPluginIpcInfo; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
39 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
40 typedef struct |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
41 { |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
42 GaimCallback func; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
43 GaimSignalMarshalFunc marshal; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
44 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
45 int num_params; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
46 GaimValue **params; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
47 GaimValue *ret_value; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
48 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
49 } GaimPluginIpcCommand; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
50 |
| 10447 | 51 static GList *search_paths = NULL; |
| 52 static GList *plugins = NULL; | |
| 11950 | 53 static GList *loaded_plugins = NULL; |
| 54 static GList *protocol_plugins = NULL; | |
| 55 #ifdef GAIM_PLUGINS | |
| 10447 | 56 static GList *load_queue = NULL; |
|
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
57 static GList *plugin_loaders = NULL; |
| 11950 | 58 #endif |
| 5205 | 59 |
| 11963 | 60 /* |
| 61 * TODO: I think the intention was to allow multiple load and unload | |
| 62 * callback functions. Perhaps using a GList instead of a | |
| 63 * pointer to a single function. | |
| 64 */ | |
| 5205 | 65 static void (*probe_cb)(void *) = NULL; |
| 66 static void *probe_cb_data = NULL; | |
| 67 static void (*load_cb)(GaimPlugin *, void *) = NULL; | |
| 68 static void *load_cb_data = NULL; | |
| 69 static void (*unload_cb)(GaimPlugin *, void *) = NULL; | |
| 70 static void *unload_cb_data = NULL; | |
| 71 | |
| 72 #ifdef GAIM_PLUGINS | |
| 11950 | 73 |
| 10447 | 74 static gboolean |
| 75 has_file_extension(const char *filename, const char *ext) | |
| 5205 | 76 { |
| 77 int len, extlen; | |
| 78 | |
| 79 if (filename == NULL || *filename == '\0' || ext == NULL) | |
| 80 return 0; | |
| 81 | |
| 82 extlen = strlen(ext); | |
| 83 len = strlen(filename) - extlen; | |
| 84 | |
| 85 if (len < 0) | |
| 86 return 0; | |
| 87 | |
| 10447 | 88 return (strncmp(filename + len, ext, extlen) == 0); |
| 5205 | 89 } |
| 90 | |
| 91 static gboolean | |
| 10682 | 92 is_native(const char *filename) |
| 93 { | |
| 94 const char *last_period; | |
| 95 | |
| 96 last_period = strrchr(filename, '.'); | |
| 97 if (last_period == NULL) | |
| 98 return FALSE; | |
| 99 | |
| 12077 | 100 return !(strcmp(last_period, ".dll") & |
| 101 strcmp(last_period, ".sl") & | |
| 102 strcmp(last_period, ".so")); | |
| 10682 | 103 } |
| 104 | |
| 105 static char * | |
| 106 gaim_plugin_get_basename(const char *filename) | |
| 107 { | |
| 108 const char *basename; | |
| 109 const char *last_period; | |
| 110 | |
| 111 basename = strrchr(filename, G_DIR_SEPARATOR); | |
| 112 if (basename != NULL) | |
| 113 basename++; | |
| 114 else | |
| 115 basename = filename; | |
| 116 | |
| 117 if (is_native(basename) && | |
| 118 ((last_period = strrchr(basename, '.')) != NULL)) | |
| 119 return g_strndup(basename, (last_period - basename)); | |
| 120 | |
| 121 return g_strdup(basename); | |
| 122 } | |
| 123 | |
| 124 static gboolean | |
|
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
125 loader_supports_file(GaimPlugin *loader, const char *filename) |
| 5205 | 126 { |
| 6432 | 127 GList *exts; |
| 5205 | 128 |
| 6432 | 129 for (exts = GAIM_PLUGIN_LOADER_INFO(loader)->exts; exts != NULL; exts = exts->next) { |
| 10447 | 130 if (has_file_extension(filename, (char *)exts->data)) { |
| 6432 | 131 return TRUE; |
| 5205 | 132 } |
| 133 } | |
| 134 | |
| 135 return FALSE; | |
| 136 } | |
| 137 | |
| 138 static GaimPlugin * | |
|
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
139 find_loader_for_plugin(const GaimPlugin *plugin) |
| 5205 | 140 { |
| 141 GaimPlugin *loader; | |
| 142 GList *l; | |
| 143 | |
| 144 if (plugin->path == NULL) | |
| 145 return NULL; | |
| 146 | |
| 147 for (l = gaim_plugins_get_loaded(); l != NULL; l = l->next) { | |
| 148 loader = l->data; | |
| 149 | |
| 150 if (loader->info->type == GAIM_PLUGIN_LOADER && | |
|
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
151 loader_supports_file(loader, plugin->path)) { |
| 5205 | 152 |
| 153 return loader; | |
| 154 } | |
| 155 | |
| 156 loader = NULL; | |
| 157 } | |
| 158 | |
| 159 return NULL; | |
| 160 } | |
| 161 | |
| 5449 | 162 #endif /* GAIM_PLUGINS */ |
| 163 | |
| 10447 | 164 /** |
| 165 * Negative if a before b, 0 if equal, positive if a after b. | |
| 166 */ | |
| 5205 | 167 static gint |
| 168 compare_prpl(GaimPlugin *a, GaimPlugin *b) | |
| 169 { | |
| 7956 | 170 if(GAIM_IS_PROTOCOL_PLUGIN(a)) { |
| 171 if(GAIM_IS_PROTOCOL_PLUGIN(b)) | |
| 172 return strcmp(a->info->name, b->info->name); | |
| 173 else | |
| 174 return -1; | |
| 175 } else { | |
| 176 if(GAIM_IS_PROTOCOL_PLUGIN(b)) | |
| 177 return 1; | |
| 178 else | |
| 179 return 0; | |
| 180 } | |
| 5205 | 181 } |
| 182 | |
| 183 GaimPlugin * | |
| 184 gaim_plugin_new(gboolean native, const char *path) | |
| 185 { | |
| 186 GaimPlugin *plugin; | |
| 187 | |
| 188 plugin = g_new0(GaimPlugin, 1); | |
| 189 | |
| 190 plugin->native_plugin = native; | |
| 191 plugin->path = (path == NULL ? NULL : g_strdup(path)); | |
| 192 | |
| 193 return plugin; | |
| 194 } | |
| 195 | |
| 196 GaimPlugin * | |
| 197 gaim_plugin_probe(const char *filename) | |
| 198 { | |
| 199 #ifdef GAIM_PLUGINS | |
| 200 GaimPlugin *plugin = NULL; | |
| 201 GaimPlugin *loader; | |
| 10124 | 202 gpointer unpunned; |
| 5205 | 203 gboolean (*gaim_init_plugin)(GaimPlugin *); |
| 204 | |
|
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
205 gaim_debug_misc("plugins", "probing %s\n", filename); |
| 5205 | 206 g_return_val_if_fail(filename != NULL, NULL); |
| 207 | |
| 5973 | 208 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) |
| 209 return NULL; | |
| 210 | |
| 10447 | 211 /* If this plugin has already been probed then exit */ |
| 5205 | 212 plugin = gaim_plugins_find_with_filename(filename); |
| 213 if (plugin != NULL) | |
| 214 return plugin; | |
| 215 | |
| 12066 | 216 plugin = gaim_plugin_new(has_file_extension(filename, G_MODULE_SUFFIX), filename); |
| 5205 | 217 |
| 218 if (plugin->native_plugin) { | |
| 5450 | 219 const char *error; |
| 10737 | 220 /* |
| 10950 | 221 * We pass G_MODULE_BIND_LOCAL here to prevent symbols from |
| 222 * plugins being added to the global name space. | |
| 11378 | 223 * |
| 224 * G_MODULE_BIND_LOCAL was added in glib 2.3.3. | |
| 11950 | 225 * TODO: I guess there's nothing we can do about that? |
| 10737 | 226 */ |
| 11378 | 227 #if GLIB_CHECK_VERSION(2,3,3) |
| 10884 | 228 plugin->handle = g_module_open(filename, G_MODULE_BIND_LOCAL); |
| 11378 | 229 #else |
| 230 plugin->handle = g_module_open(filename, 0); | |
| 231 #endif | |
| 5205 | 232 |
| 10447 | 233 if (plugin->handle == NULL) |
| 234 { | |
| 5443 | 235 error = g_module_error(); |
| 10447 | 236 gaim_debug_error("plugins", "%s is unloadable: %s\n", |
| 237 plugin->path, error ? error : "Unknown error."); | |
| 5205 | 238 |
|
5269
cd7e4ba049f9
[gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents:
5268
diff
changeset
|
239 gaim_plugin_destroy(plugin); |
|
cd7e4ba049f9
[gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents:
5268
diff
changeset
|
240 |
|
cd7e4ba049f9
[gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents:
5268
diff
changeset
|
241 return NULL; |
| 5205 | 242 } |
| 243 | |
| 244 if (!g_module_symbol(plugin->handle, "gaim_init_plugin", | |
| 10447 | 245 &unpunned)) |
| 246 { | |
| 11950 | 247 gaim_debug_error("plugins", "%s is not usable because the " |
| 248 "'gaim_init_plugin' symbol could not be " | |
| 249 "found. Does the plugin call the " | |
| 250 "GAIM_INIT_PLUGIN() macro?\n", plugin->path); | |
| 5205 | 251 |
| 11950 | 252 g_module_close(plugin->handle); |
| 5443 | 253 error = g_module_error(); |
| 11950 | 254 if (error != NULL) |
| 255 gaim_debug_error("plugins", "Error closing module %s: %s\n", | |
| 256 plugin->path, error); | |
| 257 plugin->handle = NULL; | |
| 5205 | 258 |
| 259 gaim_plugin_destroy(plugin); | |
| 260 | |
| 261 return NULL; | |
| 262 } | |
| 10124 | 263 gaim_init_plugin = unpunned; |
| 5205 | 264 } |
| 265 else { | |
|
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
266 loader = find_loader_for_plugin(plugin); |
| 5205 | 267 |
| 268 if (loader == NULL) { | |
| 269 gaim_plugin_destroy(plugin); | |
| 270 | |
| 271 return NULL; | |
| 272 } | |
| 273 | |
| 274 gaim_init_plugin = GAIM_PLUGIN_LOADER_INFO(loader)->probe; | |
| 275 } | |
| 276 | |
| 277 plugin->error = NULL; | |
| 278 | |
| 279 if (!gaim_init_plugin(plugin) || plugin->info == NULL) { | |
| 280 gaim_plugin_destroy(plugin); | |
| 281 | |
| 282 return NULL; | |
| 283 } | |
| 284 | |
| 9943 | 285 if (plugin->info->magic != GAIM_PLUGIN_MAGIC || |
| 286 plugin->info->major_version != GAIM_MAJOR_VERSION || | |
| 287 plugin->info->minor_version > GAIM_MINOR_VERSION) | |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
288 { |
| 10156 | 289 gaim_debug_error("plugins", "%s is unloadable: API version mismatch %d.%d.x (need %d.%d.x)\n", |
| 290 plugin->path, plugin->info->major_version, plugin->info->minor_version, | |
| 291 GAIM_MAJOR_VERSION, GAIM_MINOR_VERSION); | |
| 292 gaim_plugin_destroy(plugin); | |
| 293 return NULL; | |
| 294 } | |
| 295 | |
| 296 /* If plugin is a PRPL, make sure it implements the required functions */ | |
| 297 if ((plugin->info->type == GAIM_PLUGIN_PROTOCOL) && ( | |
| 298 (GAIM_PLUGIN_PROTOCOL_INFO(plugin)->list_icon == NULL) || | |
| 299 (GAIM_PLUGIN_PROTOCOL_INFO(plugin)->login == NULL) || | |
| 300 (GAIM_PLUGIN_PROTOCOL_INFO(plugin)->close == NULL))) | |
| 301 { | |
| 302 gaim_debug_error("plugins", "%s is unloadable: Does not implement all required functions\n", | |
| 303 plugin->path); | |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
304 gaim_plugin_destroy(plugin); |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
305 return NULL; |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
306 } |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
307 |
| 5205 | 308 return plugin; |
| 309 #else | |
| 310 return NULL; | |
| 311 #endif /* !GAIM_PLUGINS */ | |
| 312 } | |
| 313 | |
| 314 gboolean | |
| 315 gaim_plugin_load(GaimPlugin *plugin) | |
| 316 { | |
| 317 #ifdef GAIM_PLUGINS | |
|
6486
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
318 GList *dep_list = NULL; |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
319 GList *l; |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
320 |
| 5205 | 321 g_return_val_if_fail(plugin != NULL, FALSE); |
|
5270
d1fe8e320dab
[gaim-migrate @ 5642]
Christian Hammond <chipx86@chipx86.com>
parents:
5269
diff
changeset
|
322 g_return_val_if_fail(plugin->error == NULL, FALSE); |
| 5205 | 323 |
| 324 if (gaim_plugin_is_loaded(plugin)) | |
| 325 return TRUE; | |
| 326 | |
|
6486
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
327 /* |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
328 * Go through the list of the plugin's dependencies. |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
329 * |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
330 * First pass: Make sure all the plugins needed are probed. |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
331 */ |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
332 for (l = plugin->info->dependencies; l != NULL; l = l->next) |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
333 { |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
334 const char *dep_name = (const char *)l->data; |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
335 GaimPlugin *dep_plugin; |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
336 |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
337 dep_plugin = gaim_plugins_find_with_id(dep_name); |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
338 |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
339 if (dep_plugin == NULL) |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
340 { |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
341 char buf[BUFSIZ]; |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
342 |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
343 g_snprintf(buf, sizeof(buf), |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
344 _("The required plugin %s was not found. " |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
345 "Please install this plugin and try again."), |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
346 dep_name); |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
347 |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
348 gaim_notify_error(NULL, NULL, |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
349 _("Gaim was unable to load your plugin."), |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
350 buf); |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
351 |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
352 if (dep_list != NULL) |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
353 g_list_free(dep_list); |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
354 |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
355 return FALSE; |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
356 } |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
357 |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
358 dep_list = g_list_append(dep_list, dep_plugin); |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
359 } |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
360 |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
361 /* Second pass: load all the required plugins. */ |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
362 for (l = dep_list; l != NULL; l = l->next) |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
363 { |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
364 GaimPlugin *dep_plugin = (GaimPlugin *)l->data; |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
365 |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
366 if (!gaim_plugin_is_loaded(dep_plugin)) |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
367 { |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
368 if (!gaim_plugin_load(dep_plugin)) |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
369 { |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
370 char buf[BUFSIZ]; |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
371 |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
372 g_snprintf(buf, sizeof(buf), |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
373 _("The required plugin %s was unable to load."), |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
374 plugin->info->name); |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
375 |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
376 gaim_notify_error(NULL, NULL, |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
377 _("Gaim was unable to load your plugin."), |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
378 buf); |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
379 |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
380 if (dep_list != NULL) |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
381 g_list_free(dep_list); |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
382 |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
383 return FALSE; |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
384 } |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
385 } |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
386 } |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
387 |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
388 if (dep_list != NULL) |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
389 g_list_free(dep_list); |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
390 |
|
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
391 if (plugin->native_plugin) |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
392 { |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
393 if (plugin->info != NULL && plugin->info->load != NULL) |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
394 { |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
395 if (!plugin->info->load(plugin)) |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
396 return FALSE; |
|
5357
2a1c92df7024
[gaim-migrate @ 5733]
Christian Hammond <chipx86@chipx86.com>
parents:
5270
diff
changeset
|
397 } |
| 5205 | 398 } |
| 399 else { | |
| 400 GaimPlugin *loader; | |
| 401 GaimPluginLoaderInfo *loader_info; | |
| 402 | |
|
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
403 loader = find_loader_for_plugin(plugin); |
| 5205 | 404 |
| 405 if (loader == NULL) | |
| 406 return FALSE; | |
| 407 | |
| 408 loader_info = GAIM_PLUGIN_LOADER_INFO(loader); | |
| 409 | |
| 410 if (loader_info->load != NULL) | |
|
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
411 { |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
412 if (!loader_info->load(plugin)) |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
413 return FALSE; |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
414 } |
| 5205 | 415 } |
| 416 | |
| 417 loaded_plugins = g_list_append(loaded_plugins, plugin); | |
| 418 | |
| 419 plugin->loaded = TRUE; | |
| 420 | |
| 421 /* TODO */ | |
| 422 if (load_cb != NULL) | |
| 423 load_cb(plugin, load_cb_data); | |
| 424 | |
| 8993 | 425 gaim_signal_emit(gaim_plugins_get_handle(), "plugin-load", plugin); |
| 8986 | 426 |
| 5205 | 427 return TRUE; |
| 428 | |
| 429 #else | |
| 5449 | 430 return TRUE; |
| 5205 | 431 #endif /* !GAIM_PLUGINS */ |
| 432 } | |
| 433 | |
| 434 gboolean | |
| 435 gaim_plugin_unload(GaimPlugin *plugin) | |
| 436 { | |
| 437 #ifdef GAIM_PLUGINS | |
| 438 g_return_val_if_fail(plugin != NULL, FALSE); | |
| 439 | |
| 440 loaded_plugins = g_list_remove(loaded_plugins, plugin); | |
| 11950 | 441 if ((plugin->info != NULL) && GAIM_IS_PROTOCOL_PLUGIN(plugin)) |
| 442 protocol_plugins = g_list_remove(protocol_plugins, plugin); | |
| 5205 | 443 |
| 444 g_return_val_if_fail(gaim_plugin_is_loaded(plugin), FALSE); | |
| 445 | |
| 10447 | 446 gaim_debug_info("plugins", "Unloading plugin %s\n", plugin->info->name); |
| 5205 | 447 |
| 448 /* cancel any pending dialogs the plugin has */ | |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5450
diff
changeset
|
449 gaim_request_close_with_handle(plugin); |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5450
diff
changeset
|
450 gaim_notify_close_with_handle(plugin); |
| 5205 | 451 |
| 452 plugin->loaded = FALSE; | |
| 453 | |
| 454 if (plugin->native_plugin) { | |
| 455 if (plugin->info->unload != NULL) | |
| 456 plugin->info->unload(plugin); | |
| 457 | |
| 458 if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) { | |
| 459 GaimPluginProtocolInfo *prpl_info; | |
| 460 GList *l; | |
| 461 | |
| 462 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); | |
| 463 | |
|
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
464 for (l = prpl_info->user_splits; l != NULL; l = l->next) |
|
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
465 gaim_account_user_split_destroy(l->data); |
| 5205 | 466 |
|
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
467 for (l = prpl_info->protocol_options; l != NULL; l = l->next) |
|
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
468 gaim_account_option_destroy(l->data); |
| 5205 | 469 |
|
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
470 if (prpl_info->user_splits != NULL) |
|
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
471 g_list_free(prpl_info->user_splits); |
|
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
472 |
|
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
473 if (prpl_info->protocol_options != NULL) |
|
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
474 g_list_free(prpl_info->protocol_options); |
| 5205 | 475 } |
| 476 } | |
| 477 else { | |
| 478 GaimPlugin *loader; | |
| 479 GaimPluginLoaderInfo *loader_info; | |
| 480 | |
|
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
481 loader = find_loader_for_plugin(plugin); |
| 5205 | 482 |
| 483 if (loader == NULL) | |
| 484 return FALSE; | |
| 485 | |
| 486 loader_info = GAIM_PLUGIN_LOADER_INFO(loader); | |
| 487 | |
|
9697
f568b6655331
[gaim-migrate @ 10556]
Christian Hammond <chipx86@chipx86.com>
parents:
9667
diff
changeset
|
488 if (loader_info->unload != NULL) |
| 5205 | 489 loader_info->unload(plugin); |
| 490 } | |
| 491 | |
| 492 gaim_signals_disconnect_by_handle(plugin); | |
|
6822
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
493 gaim_plugin_ipc_unregister_all(plugin); |
| 5205 | 494 |
| 495 /* TODO */ | |
| 496 if (unload_cb != NULL) | |
| 497 unload_cb(plugin, unload_cb_data); | |
| 498 | |
| 8986 | 499 gaim_signal_emit(gaim_plugins_get_handle(), "plugin-unload", plugin); |
| 500 | |
| 10087 | 501 gaim_prefs_disconnect_by_handle(plugin); |
| 502 | |
| 5205 | 503 return TRUE; |
| 5449 | 504 #else |
| 505 return TRUE; | |
| 5205 | 506 #endif /* GAIM_PLUGINS */ |
| 507 } | |
| 508 | |
| 509 gboolean | |
| 510 gaim_plugin_reload(GaimPlugin *plugin) | |
| 511 { | |
| 512 #ifdef GAIM_PLUGINS | |
| 513 g_return_val_if_fail(plugin != NULL, FALSE); | |
| 514 g_return_val_if_fail(gaim_plugin_is_loaded(plugin), FALSE); | |
| 515 | |
| 516 if (!gaim_plugin_unload(plugin)) | |
| 517 return FALSE; | |
| 518 | |
| 519 if (!gaim_plugin_load(plugin)) | |
| 520 return FALSE; | |
| 521 | |
| 522 return TRUE; | |
| 523 #else | |
| 5449 | 524 return TRUE; |
| 5205 | 525 #endif /* !GAIM_PLUGINS */ |
| 526 } | |
| 527 | |
| 528 void | |
| 529 gaim_plugin_destroy(GaimPlugin *plugin) | |
| 530 { | |
| 5449 | 531 #ifdef GAIM_PLUGINS |
| 5205 | 532 g_return_if_fail(plugin != NULL); |
| 533 | |
| 534 if (gaim_plugin_is_loaded(plugin)) | |
| 535 gaim_plugin_unload(plugin); | |
| 536 | |
| 537 plugins = g_list_remove(plugins, plugin); | |
| 538 | |
|
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
539 if (load_queue != NULL) |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
540 load_queue = g_list_remove(load_queue, plugin); |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
541 |
| 9943 | 542 /* true, this may leak a little memory if there is a major version |
| 543 * mismatch, but it's a lot better than trying to free something | |
| 544 * we shouldn't, and crashing while trying to load an old plugin */ | |
| 545 if(plugin->info == NULL || plugin->info->magic != GAIM_PLUGIN_MAGIC || | |
| 546 plugin->info->major_version != GAIM_MAJOR_VERSION) { | |
| 547 if(plugin->handle) | |
| 548 g_module_close(plugin->handle); | |
| 549 g_free(plugin); | |
| 550 return; | |
| 551 } | |
| 552 | |
|
5243
f6e0c689a88b
[gaim-migrate @ 5614]
Christian Hammond <chipx86@chipx86.com>
parents:
5242
diff
changeset
|
553 if (plugin->info != NULL && plugin->info->dependencies != NULL) |
|
f6e0c689a88b
[gaim-migrate @ 5614]
Christian Hammond <chipx86@chipx86.com>
parents:
5242
diff
changeset
|
554 g_list_free(plugin->info->dependencies); |
| 5205 | 555 |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
556 if (plugin->native_plugin) |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
557 { |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
558 if (plugin->info != NULL && plugin->info->type == GAIM_PLUGIN_LOADER) |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
559 { |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
560 GaimPluginLoaderInfo *loader_info; |
| 5205 | 561 GList *exts, *l, *next_l; |
| 562 GaimPlugin *p2; | |
| 563 | |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
564 loader_info = GAIM_PLUGIN_LOADER_INFO(plugin); |
| 5205 | 565 |
| 9943 | 566 if (loader_info != NULL && loader_info->exts != NULL) |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
567 { |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
568 for (exts = GAIM_PLUGIN_LOADER_INFO(plugin)->exts; |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
569 exts != NULL; |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
570 exts = exts->next) { |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
571 |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
572 for (l = gaim_plugins_get_all(); l != NULL; l = next_l) |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
573 { |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
574 next_l = l->next; |
| 5205 | 575 |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
576 p2 = l->data; |
| 5205 | 577 |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
578 if (p2->path != NULL && |
| 10447 | 579 has_file_extension(p2->path, exts->data)) |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
580 { |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
581 gaim_plugin_destroy(p2); |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
582 } |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
583 } |
| 5205 | 584 } |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
585 |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
586 g_list_free(loader_info->exts); |
| 5205 | 587 } |
| 588 | |
| 589 plugin_loaders = g_list_remove(plugin_loaders, plugin); | |
| 590 } | |
| 591 | |
| 592 if (plugin->info != NULL && plugin->info->destroy != NULL) | |
| 593 plugin->info->destroy(plugin); | |
| 594 | |
| 595 if (plugin->handle != NULL) | |
| 596 g_module_close(plugin->handle); | |
| 597 } | |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
598 else |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
599 { |
| 5205 | 600 GaimPlugin *loader; |
| 601 GaimPluginLoaderInfo *loader_info; | |
| 602 | |
|
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
603 loader = find_loader_for_plugin(plugin); |
| 5205 | 604 |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
605 if (loader != NULL) |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
606 { |
|
5941
a3e60ff95b7d
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
607 loader_info = GAIM_PLUGIN_LOADER_INFO(loader); |
| 5205 | 608 |
|
5941
a3e60ff95b7d
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
609 if (loader_info->destroy != NULL) |
|
a3e60ff95b7d
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
610 loader_info->destroy(plugin); |
|
a3e60ff95b7d
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
611 } |
| 5205 | 612 } |
| 613 | |
| 614 if (plugin->path != NULL) g_free(plugin->path); | |
| 615 if (plugin->error != NULL) g_free(plugin->error); | |
| 616 | |
| 617 g_free(plugin); | |
| 5449 | 618 #endif /* !GAIM_PLUGINS */ |
| 5205 | 619 } |
| 620 | |
| 621 gboolean | |
| 622 gaim_plugin_is_loaded(const GaimPlugin *plugin) | |
| 623 { | |
| 624 g_return_val_if_fail(plugin != NULL, FALSE); | |
| 625 | |
| 626 return plugin->loaded; | |
| 627 } | |
| 628 | |
|
11772
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
629 const gchar * |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
630 gaim_plugin_get_id(const GaimPlugin *plugin) { |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
631 g_return_val_if_fail(plugin, NULL); |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
632 g_return_val_if_fail(plugin->info, NULL); |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
633 |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
634 return plugin->info->id; |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
635 } |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
636 |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
637 const gchar * |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
638 gaim_plugin_get_name(const GaimPlugin *plugin) { |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
639 g_return_val_if_fail(plugin, NULL); |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
640 g_return_val_if_fail(plugin->info, NULL); |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
641 |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
642 return plugin->info->name; |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
643 } |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
644 |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
645 const gchar * |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
646 gaim_plugin_get_version(const GaimPlugin *plugin) { |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
647 g_return_val_if_fail(plugin, NULL); |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
648 g_return_val_if_fail(plugin->info, NULL); |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
649 |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
650 return plugin->info->version; |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
651 } |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
652 |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
653 const gchar * |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
654 gaim_plugin_get_summary(const GaimPlugin *plugin) { |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
655 g_return_val_if_fail(plugin, NULL); |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
656 g_return_val_if_fail(plugin->info, NULL); |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
657 |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
658 return plugin->info->summary; |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
659 } |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
660 |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
661 const gchar * |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
662 gaim_plugin_get_description(const GaimPlugin *plugin) { |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
663 g_return_val_if_fail(plugin, NULL); |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
664 g_return_val_if_fail(plugin->info, NULL); |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
665 |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
666 return plugin->info->description; |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
667 } |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
668 |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
669 const gchar * |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
670 gaim_plugin_get_author(const GaimPlugin *plugin) { |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
671 g_return_val_if_fail(plugin, NULL); |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
672 g_return_val_if_fail(plugin->info, NULL); |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
673 |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
674 return plugin->info->author; |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
675 } |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
676 |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
677 const gchar * |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
678 gaim_plugin_get_homepage(const GaimPlugin *plugin) { |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
679 g_return_val_if_fail(plugin, NULL); |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
680 g_return_val_if_fail(plugin->info, NULL); |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
681 |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
682 return plugin->info->homepage; |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
683 } |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
684 |
|
6822
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
685 /************************************************************************** |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
686 * Plugin IPC |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
687 **************************************************************************/ |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
688 static void |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
689 destroy_ipc_info(void *data) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
690 { |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
691 GaimPluginIpcCommand *ipc_command = (GaimPluginIpcCommand *)data; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
692 int i; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
693 |
|
9667
22928adecb84
[gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents:
9018
diff
changeset
|
694 if (ipc_command->params != NULL) |
|
22928adecb84
[gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents:
9018
diff
changeset
|
695 { |
|
22928adecb84
[gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents:
9018
diff
changeset
|
696 for (i = 0; i < ipc_command->num_params; i++) |
|
22928adecb84
[gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents:
9018
diff
changeset
|
697 gaim_value_destroy(ipc_command->params[i]); |
|
22928adecb84
[gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents:
9018
diff
changeset
|
698 |
|
22928adecb84
[gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents:
9018
diff
changeset
|
699 g_free(ipc_command->params); |
|
22928adecb84
[gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents:
9018
diff
changeset
|
700 } |
|
6822
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
701 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
702 if (ipc_command->ret_value != NULL) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
703 gaim_value_destroy(ipc_command->ret_value); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
704 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
705 g_free(ipc_command); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
706 } |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
707 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
708 gboolean |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
709 gaim_plugin_ipc_register(GaimPlugin *plugin, const char *command, |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
710 GaimCallback func, GaimSignalMarshalFunc marshal, |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
711 GaimValue *ret_value, int num_params, ...) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
712 { |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
713 GaimPluginIpcInfo *ipc_info; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
714 GaimPluginIpcCommand *ipc_command; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
715 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
716 g_return_val_if_fail(plugin != NULL, FALSE); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
717 g_return_val_if_fail(command != NULL, FALSE); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
718 g_return_val_if_fail(func != NULL, FALSE); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
719 g_return_val_if_fail(marshal != NULL, FALSE); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
720 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
721 if (plugin->ipc_data == NULL) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
722 { |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
723 ipc_info = plugin->ipc_data = g_new0(GaimPluginIpcInfo, 1); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
724 ipc_info->commands = g_hash_table_new_full(g_str_hash, g_str_equal, |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
725 g_free, destroy_ipc_info); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
726 } |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
727 else |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
728 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
729 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
730 ipc_command = g_new0(GaimPluginIpcCommand, 1); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
731 ipc_command->func = func; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
732 ipc_command->marshal = marshal; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
733 ipc_command->num_params = num_params; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
734 ipc_command->ret_value = ret_value; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
735 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
736 if (num_params > 0) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
737 { |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
738 va_list args; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
739 int i; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
740 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
741 ipc_command->params = g_new0(GaimValue *, num_params); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
742 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
743 va_start(args, num_params); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
744 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
745 for (i = 0; i < num_params; i++) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
746 ipc_command->params[i] = va_arg(args, GaimValue *); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
747 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
748 va_end(args); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
749 } |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
750 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
751 g_hash_table_replace(ipc_info->commands, g_strdup(command), ipc_command); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
752 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
753 ipc_info->command_count++; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
754 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
755 return TRUE; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
756 } |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
757 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
758 void |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
759 gaim_plugin_ipc_unregister(GaimPlugin *plugin, const char *command) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
760 { |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
761 GaimPluginIpcInfo *ipc_info; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
762 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
763 g_return_if_fail(plugin != NULL); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
764 g_return_if_fail(command != NULL); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
765 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
766 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
767 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
768 if (ipc_info == NULL || |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
769 g_hash_table_lookup(ipc_info->commands, command) == NULL) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
770 { |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
771 gaim_debug_error("plugins", |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
772 "IPC command '%s' was not registered for plugin %s\n", |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
773 command, plugin->info->name); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
774 return; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
775 } |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
776 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
777 g_hash_table_remove(ipc_info->commands, command); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
778 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
779 ipc_info->command_count--; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
780 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
781 if (ipc_info->command_count == 0) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
782 { |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
783 g_hash_table_destroy(ipc_info->commands); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
784 g_free(ipc_info); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
785 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
786 plugin->ipc_data = NULL; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
787 } |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
788 } |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
789 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
790 void |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
791 gaim_plugin_ipc_unregister_all(GaimPlugin *plugin) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
792 { |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
793 GaimPluginIpcInfo *ipc_info; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
794 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
795 g_return_if_fail(plugin != NULL); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
796 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
797 if (plugin->ipc_data == NULL) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
798 return; /* Silently ignore it. */ |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
799 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
800 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
801 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
802 g_hash_table_destroy(ipc_info->commands); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
803 g_free(ipc_info); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
804 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
805 plugin->ipc_data = NULL; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
806 } |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
807 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
808 gboolean |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
809 gaim_plugin_ipc_get_params(GaimPlugin *plugin, const char *command, |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
810 GaimValue **ret_value, int *num_params, |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
811 GaimValue ***params) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
812 { |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
813 GaimPluginIpcInfo *ipc_info; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
814 GaimPluginIpcCommand *ipc_command; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
815 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
816 g_return_val_if_fail(plugin != NULL, FALSE); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
817 g_return_val_if_fail(command != NULL, FALSE); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
818 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
819 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
820 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
821 if (ipc_info == NULL || |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
822 (ipc_command = g_hash_table_lookup(ipc_info->commands, |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
823 command)) == NULL) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
824 { |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
825 gaim_debug_error("plugins", |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
826 "IPC command '%s' was not registered for plugin %s\n", |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
827 command, plugin->info->name); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
828 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
829 return FALSE; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
830 } |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
831 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
832 if (num_params != NULL) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
833 *num_params = ipc_command->num_params; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
834 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
835 if (params != NULL) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
836 *params = ipc_command->params; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
837 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
838 if (ret_value != NULL) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
839 *ret_value = ipc_command->ret_value; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
840 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
841 return TRUE; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
842 } |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
843 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
844 void * |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
845 gaim_plugin_ipc_call(GaimPlugin *plugin, const char *command, |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
846 gboolean *ok, ...) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
847 { |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
848 GaimPluginIpcInfo *ipc_info; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
849 GaimPluginIpcCommand *ipc_command; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
850 va_list args; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
851 void *ret_value; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
852 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
853 if (ok != NULL) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
854 *ok = FALSE; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
855 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
856 g_return_val_if_fail(plugin != NULL, NULL); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
857 g_return_val_if_fail(command != NULL, NULL); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
858 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
859 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
860 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
861 if (ipc_info == NULL || |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
862 (ipc_command = g_hash_table_lookup(ipc_info->commands, |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
863 command)) == NULL) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
864 { |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
865 gaim_debug_error("plugins", |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
866 "IPC command '%s' was not registered for plugin %s\n", |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
867 command, plugin->info->name); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
868 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
869 return NULL; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
870 } |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
871 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
872 va_start(args, ok); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
873 ipc_command->marshal(ipc_command->func, args, NULL, &ret_value); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
874 va_end(args); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
875 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
876 if (ok != NULL) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
877 *ok = TRUE; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
878 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
879 return ret_value; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
880 } |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
881 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
882 /************************************************************************** |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
883 * Plugins subsystem |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
884 **************************************************************************/ |
| 10479 | 885 void * |
| 886 gaim_plugins_get_handle(void) { | |
| 887 static int handle; | |
| 888 | |
| 889 return &handle; | |
| 890 } | |
| 891 | |
| 892 void | |
| 893 gaim_plugins_init(void) { | |
| 894 void *handle = gaim_plugins_get_handle(); | |
| 895 | |
| 896 gaim_signal_register(handle, "plugin-load", | |
| 897 gaim_marshal_VOID__POINTER, | |
| 898 NULL, 1, | |
| 899 gaim_value_new(GAIM_TYPE_SUBTYPE, | |
| 900 GAIM_SUBTYPE_PLUGIN)); | |
| 901 gaim_signal_register(handle, "plugin-unload", | |
| 902 gaim_marshal_VOID__POINTER, | |
| 903 NULL, 1, | |
| 904 gaim_value_new(GAIM_TYPE_SUBTYPE, | |
| 905 GAIM_SUBTYPE_PLUGIN)); | |
| 906 } | |
| 907 | |
| 908 void | |
| 909 gaim_plugins_uninit(void) { | |
| 910 gaim_signals_disconnect_by_handle(gaim_plugins_get_handle()); | |
| 911 } | |
| 912 | |
| 913 /************************************************************************** | |
| 914 * Plugins API | |
| 915 **************************************************************************/ | |
| 5205 | 916 void |
| 10447 | 917 gaim_plugins_add_search_path(const char *path) |
| 5205 | 918 { |
| 10447 | 919 g_return_if_fail(path != NULL); |
| 5205 | 920 |
| 10447 | 921 if (g_list_find_custom(search_paths, path, (GCompareFunc)strcmp)) |
| 922 return; | |
| 5205 | 923 |
| 10447 | 924 search_paths = g_list_append(search_paths, strdup(path)); |
| 5205 | 925 } |
| 926 | |
| 927 void | |
| 928 gaim_plugins_unload_all(void) | |
| 929 { | |
| 930 #ifdef GAIM_PLUGINS | |
| 931 | |
| 932 while (loaded_plugins != NULL) | |
| 933 gaim_plugin_unload(loaded_plugins->data); | |
| 934 | |
| 935 #endif /* GAIM_PLUGINS */ | |
| 936 } | |
| 937 | |
| 938 void | |
|
5242
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
939 gaim_plugins_destroy_all(void) |
|
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
940 { |
|
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
941 #ifdef GAIM_PLUGINS |
|
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
942 |
|
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
943 while (plugins != NULL) |
|
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
944 gaim_plugin_destroy(plugins->data); |
|
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
945 |
|
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
946 #endif /* GAIM_PLUGINS */ |
|
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
947 } |
| 5838 | 948 |
| 949 void | |
|
5949
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
950 gaim_plugins_load_saved(const char *key) |
| 5838 | 951 { |
| 952 #ifdef GAIM_PLUGINS | |
|
5949
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
953 GList *f, *files; |
|
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
954 |
|
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
955 g_return_if_fail(key != NULL); |
| 5838 | 956 |
|
5949
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
957 files = gaim_prefs_get_string_list(key); |
|
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
958 |
|
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
959 for (f = files; f; f = f->next) |
|
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
960 { |
| 10682 | 961 char *filename; |
| 962 char *basename; | |
| 963 GaimPlugin *plugin; | |
| 964 | |
| 965 if (f->data == NULL) | |
| 966 continue; | |
|
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
967 |
| 10682 | 968 filename = f->data; |
| 969 /* | |
| 970 * We don't know if the filename uses Windows or Unix path | |
| 971 * separators (because people might be sharing a prefs.xml | |
| 972 * file across systems), so we find the last occurrence | |
| 973 * of either. | |
| 974 */ | |
| 975 basename = strrchr(filename, '/'); | |
| 976 if ((basename == NULL) || (basename < strrchr(filename, '\\'))) | |
| 977 basename = strrchr(filename, '\\'); | |
| 978 if (basename != NULL) | |
| 979 basename++; | |
| 980 | |
| 981 if ((plugin = gaim_plugins_find_with_filename(filename)) != NULL) | |
|
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
982 { |
| 10682 | 983 gaim_debug_info("plugins", "Loading saved plugin %s\n", |
| 984 plugin->path); | |
| 985 gaim_plugin_load(plugin); | |
| 986 } | |
| 987 else if ((plugin = gaim_plugins_find_with_basename(basename)) != NULL) | |
| 988 { | |
| 989 gaim_debug_info("plugins", "Loading saved plugin %s\n", | |
| 990 plugin->path); | |
| 991 gaim_plugin_load(plugin); | |
| 992 } | |
| 993 else | |
| 994 { | |
| 995 gaim_debug_error("plugins", "Unable to find saved plugin %s\n", | |
| 996 filename); | |
|
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
997 } |
|
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
998 |
| 5838 | 999 g_free(f->data); |
| 1000 } | |
| 1001 | |
| 1002 g_list_free(files); | |
| 1003 #endif /* GAIM_PLUGINS */ | |
| 1004 } | |
| 1005 | |
| 1006 | |
|
5242
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1007 void |
| 5205 | 1008 gaim_plugins_probe(const char *ext) |
| 1009 { | |
| 1010 #ifdef GAIM_PLUGINS | |
| 1011 GDir *dir; | |
| 1012 const gchar *file; | |
| 1013 gchar *path; | |
| 1014 GaimPlugin *plugin; | |
| 10447 | 1015 GList *cur; |
| 1016 const char *search_path; | |
| 5205 | 1017 |
| 1018 if (!g_module_supported()) | |
| 1019 return; | |
| 1020 | |
| 10447 | 1021 /* Probe plugins */ |
| 1022 for (cur = search_paths; cur != NULL; cur = cur->next) | |
| 1023 { | |
| 1024 search_path = cur->data; | |
| 5205 | 1025 |
| 10447 | 1026 dir = g_dir_open(search_path, 0, NULL); |
| 5205 | 1027 |
| 10447 | 1028 if (dir != NULL) |
| 1029 { | |
| 1030 while ((file = g_dir_read_name(dir)) != NULL) | |
| 1031 { | |
| 1032 path = g_build_filename(search_path, file, NULL); | |
| 5205 | 1033 |
| 10447 | 1034 if (ext == NULL || has_file_extension(file, ext)) |
| 5205 | 1035 plugin = gaim_plugin_probe(path); |
| 1036 | |
| 1037 g_free(path); | |
| 1038 } | |
| 1039 | |
| 1040 g_dir_close(dir); | |
| 1041 } | |
| 1042 } | |
| 1043 | |
| 10447 | 1044 /* See if we have any plugins waiting to load */ |
|
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1045 while (load_queue != NULL) |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1046 { |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1047 plugin = (GaimPlugin *)load_queue->data; |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1048 |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1049 load_queue = g_list_remove(load_queue, plugin); |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1050 |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1051 if (plugin == NULL || plugin->info == NULL) |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1052 continue; |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1053 |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1054 if (plugin->info->type == GAIM_PLUGIN_LOADER) |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1055 { |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1056 /* We'll just load this right now. */ |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1057 if (!gaim_plugin_load(plugin)) |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1058 { |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1059 gaim_plugin_destroy(plugin); |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1060 |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1061 continue; |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1062 } |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1063 |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1064 plugin_loaders = g_list_append(plugin_loaders, plugin); |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1065 |
| 10447 | 1066 for (cur = GAIM_PLUGIN_LOADER_INFO(plugin)->exts; |
| 1067 cur != NULL; | |
| 1068 cur = cur->next) | |
|
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1069 { |
| 10447 | 1070 gaim_plugins_probe(cur->data); |
|
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1071 } |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1072 } |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1073 else if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1074 { |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1075 /* We'll just load this right now. */ |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1076 if (!gaim_plugin_load(plugin)) |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1077 { |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1078 gaim_plugin_destroy(plugin); |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1079 |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1080 continue; |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1081 } |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1082 |
| 11950 | 1083 /* Make sure we don't load two PRPLs with the same name? */ |
| 7956 | 1084 if (gaim_find_prpl(plugin->info->id)) |
|
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1085 { |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1086 /* Nothing to see here--move along, move along */ |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1087 gaim_plugin_destroy(plugin); |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1088 |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1089 continue; |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1090 } |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1091 |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1092 protocol_plugins = g_list_insert_sorted(protocol_plugins, plugin, |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1093 (GCompareFunc)compare_prpl); |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1094 } |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1095 } |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1096 |
| 5205 | 1097 if (probe_cb != NULL) |
| 1098 probe_cb(probe_cb_data); | |
| 1099 #endif /* GAIM_PLUGINS */ | |
| 1100 } | |
| 1101 | |
| 1102 gboolean | |
| 1103 gaim_plugin_register(GaimPlugin *plugin) | |
| 1104 { | |
| 1105 g_return_val_if_fail(plugin != NULL, FALSE); | |
| 1106 | |
| 10447 | 1107 /* If this plugin has been registered already then exit */ |
| 5205 | 1108 if (g_list_find(plugins, plugin)) |
| 1109 return TRUE; | |
| 1110 | |
| 10447 | 1111 /* Ensure the plugin has the requisite information */ |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1112 if (plugin->info->type == GAIM_PLUGIN_LOADER) |
|
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1113 { |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1114 GaimPluginLoaderInfo *loader_info; |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1115 |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1116 loader_info = GAIM_PLUGIN_LOADER_INFO(plugin); |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1117 |
| 9943 | 1118 if (loader_info == NULL) |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1119 { |
| 10447 | 1120 gaim_debug_error("plugins", "%s is unloadable\n", |
| 9943 | 1121 plugin->path); |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1122 return FALSE; |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1123 } |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1124 } |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1125 else if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1126 { |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1127 GaimPluginProtocolInfo *prpl_info; |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1128 |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1129 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1130 |
| 9943 | 1131 if (prpl_info == NULL) |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1132 { |
| 10447 | 1133 gaim_debug_error("plugins", "%s is unloadable\n", |
| 9943 | 1134 plugin->path); |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1135 return FALSE; |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1136 } |
| 10447 | 1137 } |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1138 |
| 11950 | 1139 #ifdef GAIM_PLUGINS |
| 10447 | 1140 /* This plugin should be probed and maybe loaded--add it to the queue */ |
| 1141 load_queue = g_list_append(load_queue, plugin); | |
| 11950 | 1142 #else |
| 1143 if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) | |
| 1144 protocol_plugins = g_list_insert_sorted(protocol_plugins, plugin, | |
| 1145 (GCompareFunc)compare_prpl); | |
| 1146 #endif | |
| 5205 | 1147 |
| 1148 plugins = g_list_append(plugins, plugin); | |
| 1149 | |
| 1150 return TRUE; | |
| 1151 } | |
| 1152 | |
| 1153 gboolean | |
| 1154 gaim_plugins_enabled(void) | |
| 1155 { | |
| 1156 #ifdef GAIM_PLUGINS | |
| 1157 return TRUE; | |
| 1158 #else | |
| 1159 return FALSE; | |
| 1160 #endif | |
| 1161 } | |
| 1162 | |
| 1163 void | |
| 1164 gaim_plugins_register_probe_notify_cb(void (*func)(void *), void *data) | |
| 1165 { | |
| 1166 /* TODO */ | |
| 1167 probe_cb = func; | |
| 1168 probe_cb_data = data; | |
| 1169 } | |
| 1170 | |
| 1171 void | |
| 1172 gaim_plugins_unregister_probe_notify_cb(void (*func)(void *)) | |
| 1173 { | |
| 1174 /* TODO */ | |
| 1175 probe_cb = NULL; | |
| 1176 probe_cb_data = NULL; | |
| 1177 } | |
| 1178 | |
| 1179 void | |
| 1180 gaim_plugins_register_load_notify_cb(void (*func)(GaimPlugin *, void *), | |
| 1181 void *data) | |
| 1182 { | |
| 1183 /* TODO */ | |
| 1184 load_cb = func; | |
| 1185 load_cb_data = data; | |
| 1186 } | |
| 1187 | |
| 1188 void | |
| 1189 gaim_plugins_unregister_load_notify_cb(void (*func)(GaimPlugin *, void *)) | |
| 1190 { | |
| 1191 /* TODO */ | |
| 1192 load_cb = NULL; | |
| 1193 load_cb_data = NULL; | |
| 1194 } | |
| 1195 | |
| 1196 void | |
| 1197 gaim_plugins_register_unload_notify_cb(void (*func)(GaimPlugin *, void *), | |
| 1198 void *data) | |
| 1199 { | |
| 1200 /* TODO */ | |
| 1201 unload_cb = func; | |
| 1202 unload_cb_data = data; | |
| 1203 } | |
| 1204 | |
| 1205 void | |
| 1206 gaim_plugins_unregister_unload_notify_cb(void (*func)(GaimPlugin *, void *)) | |
| 1207 { | |
| 1208 /* TODO */ | |
| 1209 unload_cb = NULL; | |
| 1210 unload_cb_data = NULL; | |
| 1211 } | |
| 1212 | |
| 1213 GaimPlugin * | |
| 1214 gaim_plugins_find_with_name(const char *name) | |
| 1215 { | |
| 1216 GaimPlugin *plugin; | |
| 1217 GList *l; | |
| 1218 | |
| 1219 for (l = plugins; l != NULL; l = l->next) { | |
| 1220 plugin = l->data; | |
| 1221 | |
| 1222 if (!strcmp(plugin->info->name, name)) | |
| 1223 return plugin; | |
| 1224 } | |
| 1225 | |
| 1226 return NULL; | |
| 1227 } | |
| 1228 | |
| 1229 GaimPlugin * | |
| 1230 gaim_plugins_find_with_filename(const char *filename) | |
| 1231 { | |
| 1232 GaimPlugin *plugin; | |
| 1233 GList *l; | |
| 1234 | |
| 1235 for (l = plugins; l != NULL; l = l->next) { | |
| 1236 plugin = l->data; | |
| 1237 | |
| 1238 if (plugin->path != NULL && !strcmp(plugin->path, filename)) | |
| 1239 return plugin; | |
| 1240 } | |
| 1241 | |
| 1242 return NULL; | |
| 1243 } | |
| 1244 | |
| 1245 GaimPlugin * | |
|
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1246 gaim_plugins_find_with_basename(const char *basename) |
|
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1247 { |
| 11950 | 1248 #ifdef GAIM_PLUGINS |
|
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1249 GaimPlugin *plugin; |
|
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1250 GList *l; |
| 10682 | 1251 char *basename_no_ext; |
| 1252 char *tmp; | |
|
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1253 |
|
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1254 g_return_val_if_fail(basename != NULL, NULL); |
|
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1255 |
| 10682 | 1256 basename_no_ext = gaim_plugin_get_basename(basename); |
| 1257 | |
|
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1258 for (l = plugins; l != NULL; l = l->next) |
|
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1259 { |
|
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1260 plugin = (GaimPlugin *)l->data; |
|
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1261 |
| 7278 | 1262 if (plugin->path != NULL) { |
| 10682 | 1263 tmp = gaim_plugin_get_basename(plugin->path); |
| 1264 if (!strcmp(tmp, basename_no_ext)) | |
| 1265 { | |
| 7278 | 1266 g_free(tmp); |
| 10682 | 1267 g_free(basename_no_ext); |
|
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1268 return plugin; |
| 7278 | 1269 } |
| 7279 | 1270 g_free(tmp); |
|
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1271 } |
|
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1272 } |
|
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1273 |
| 10682 | 1274 g_free(basename_no_ext); |
| 11950 | 1275 #endif /* GAIM_PLUGINS */ |
| 10682 | 1276 |
|
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1277 return NULL; |
|
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1278 } |
|
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1279 |
|
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1280 GaimPlugin * |
| 5205 | 1281 gaim_plugins_find_with_id(const char *id) |
| 1282 { | |
| 1283 GaimPlugin *plugin; | |
| 1284 GList *l; | |
| 1285 | |
| 1286 g_return_val_if_fail(id != NULL, NULL); | |
| 1287 | |
|
6486
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1288 for (l = plugins; l != NULL; l = l->next) |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1289 { |
| 5205 | 1290 plugin = l->data; |
| 1291 | |
|
6486
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1292 if (plugin->info->id != NULL && !strcmp(plugin->info->id, id)) |
| 5205 | 1293 return plugin; |
| 1294 } | |
| 1295 | |
| 1296 return NULL; | |
| 1297 } | |
| 1298 | |
| 1299 GList * | |
| 1300 gaim_plugins_get_loaded(void) | |
| 1301 { | |
| 1302 return loaded_plugins; | |
| 1303 } | |
| 1304 | |
| 1305 GList * | |
|
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1306 gaim_plugins_get_protocols(void) |
|
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1307 { |
|
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1308 return protocol_plugins; |
|
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1309 } |
|
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1310 |
|
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1311 GList * |
| 5205 | 1312 gaim_plugins_get_all(void) |
| 1313 { | |
| 1314 return plugins; | |
| 1315 } | |
| 1316 | |
| 9015 | 1317 |
| 1318 GaimPluginAction * | |
| 1319 gaim_plugin_action_new(char* label, void (*callback)(GaimPluginAction *)) | |
| 1320 { | |
| 1321 GaimPluginAction *act = g_new0(GaimPluginAction, 1); | |
| 9018 | 1322 |
| 9015 | 1323 act->label = label; |
| 1324 act->callback = callback; | |
| 9018 | 1325 |
| 1326 return act; | |
| 9015 | 1327 } |
