Mercurial > pidgin
annotate src/plugin.c @ 12520:d85c2bfb2ea2
[gaim-migrate @ 14832]
Fix a warning. Everyone should be using --enable-debug. ;)
committer: Tailor Script <tailor@pidgin.im>
| author | Richard Laager <rlaager@wiktel.com> |
|---|---|
| date | Sat, 17 Dec 2005 05:25:03 +0000 |
| parents | 0692d20d9d81 |
| children | 70f18c73da9d |
| 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; |
| 12342 | 203 gchar *basename = NULL; |
| 5205 | 204 gboolean (*gaim_init_plugin)(GaimPlugin *); |
| 205 | |
|
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
206 gaim_debug_misc("plugins", "probing %s\n", filename); |
| 5205 | 207 g_return_val_if_fail(filename != NULL, NULL); |
| 208 | |
| 5973 | 209 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) |
| 210 return NULL; | |
| 211 | |
| 10447 | 212 /* If this plugin has already been probed then exit */ |
| 12342 | 213 basename = gaim_plugin_get_basename(filename); |
| 214 plugin = gaim_plugins_find_with_basename(basename); | |
| 215 g_free(basename); | |
| 5205 | 216 if (plugin != NULL) |
| 12342 | 217 { |
| 218 if (strcmp(filename, plugin->path)) | |
| 219 gaim_debug_info("plugins", "Not loading %s." | |
| 220 "Another plugin with the same name (%s) has already been loaded.\n", | |
| 221 filename, plugin->path); | |
| 5205 | 222 return plugin; |
| 12342 | 223 } |
| 5205 | 224 |
| 12066 | 225 plugin = gaim_plugin_new(has_file_extension(filename, G_MODULE_SUFFIX), filename); |
| 5205 | 226 |
| 227 if (plugin->native_plugin) { | |
| 5450 | 228 const char *error; |
| 10737 | 229 /* |
| 10950 | 230 * We pass G_MODULE_BIND_LOCAL here to prevent symbols from |
| 231 * plugins being added to the global name space. | |
| 11378 | 232 * |
| 233 * G_MODULE_BIND_LOCAL was added in glib 2.3.3. | |
| 11950 | 234 * TODO: I guess there's nothing we can do about that? |
| 10737 | 235 */ |
| 11378 | 236 #if GLIB_CHECK_VERSION(2,3,3) |
| 10884 | 237 plugin->handle = g_module_open(filename, G_MODULE_BIND_LOCAL); |
| 11378 | 238 #else |
| 239 plugin->handle = g_module_open(filename, 0); | |
| 240 #endif | |
| 5205 | 241 |
| 10447 | 242 if (plugin->handle == NULL) |
| 243 { | |
| 5443 | 244 error = g_module_error(); |
| 10447 | 245 gaim_debug_error("plugins", "%s is unloadable: %s\n", |
| 246 plugin->path, error ? error : "Unknown error."); | |
| 5205 | 247 |
|
5269
cd7e4ba049f9
[gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents:
5268
diff
changeset
|
248 gaim_plugin_destroy(plugin); |
|
cd7e4ba049f9
[gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents:
5268
diff
changeset
|
249 |
|
cd7e4ba049f9
[gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents:
5268
diff
changeset
|
250 return NULL; |
| 5205 | 251 } |
| 252 | |
| 253 if (!g_module_symbol(plugin->handle, "gaim_init_plugin", | |
| 10447 | 254 &unpunned)) |
| 255 { | |
| 11950 | 256 gaim_debug_error("plugins", "%s is not usable because the " |
| 257 "'gaim_init_plugin' symbol could not be " | |
| 258 "found. Does the plugin call the " | |
| 259 "GAIM_INIT_PLUGIN() macro?\n", plugin->path); | |
| 5205 | 260 |
| 11950 | 261 g_module_close(plugin->handle); |
| 5443 | 262 error = g_module_error(); |
| 11950 | 263 if (error != NULL) |
| 264 gaim_debug_error("plugins", "Error closing module %s: %s\n", | |
| 265 plugin->path, error); | |
| 266 plugin->handle = NULL; | |
| 5205 | 267 |
| 268 gaim_plugin_destroy(plugin); | |
| 269 | |
| 270 return NULL; | |
| 271 } | |
| 10124 | 272 gaim_init_plugin = unpunned; |
| 5205 | 273 } |
| 274 else { | |
|
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
275 loader = find_loader_for_plugin(plugin); |
| 5205 | 276 |
| 277 if (loader == NULL) { | |
| 278 gaim_plugin_destroy(plugin); | |
| 279 | |
| 280 return NULL; | |
| 281 } | |
| 282 | |
| 283 gaim_init_plugin = GAIM_PLUGIN_LOADER_INFO(loader)->probe; | |
| 284 } | |
| 285 | |
| 286 plugin->error = NULL; | |
| 287 | |
| 288 if (!gaim_init_plugin(plugin) || plugin->info == NULL) { | |
| 289 gaim_plugin_destroy(plugin); | |
| 290 | |
| 291 return NULL; | |
| 292 } | |
| 293 | |
| 9943 | 294 if (plugin->info->magic != GAIM_PLUGIN_MAGIC || |
| 295 plugin->info->major_version != GAIM_MAJOR_VERSION || | |
| 296 plugin->info->minor_version > GAIM_MINOR_VERSION) | |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
297 { |
| 10156 | 298 gaim_debug_error("plugins", "%s is unloadable: API version mismatch %d.%d.x (need %d.%d.x)\n", |
| 299 plugin->path, plugin->info->major_version, plugin->info->minor_version, | |
| 300 GAIM_MAJOR_VERSION, GAIM_MINOR_VERSION); | |
| 301 gaim_plugin_destroy(plugin); | |
| 302 return NULL; | |
| 303 } | |
| 304 | |
| 305 /* If plugin is a PRPL, make sure it implements the required functions */ | |
| 306 if ((plugin->info->type == GAIM_PLUGIN_PROTOCOL) && ( | |
| 307 (GAIM_PLUGIN_PROTOCOL_INFO(plugin)->list_icon == NULL) || | |
| 308 (GAIM_PLUGIN_PROTOCOL_INFO(plugin)->login == NULL) || | |
| 309 (GAIM_PLUGIN_PROTOCOL_INFO(plugin)->close == NULL))) | |
| 310 { | |
| 311 gaim_debug_error("plugins", "%s is unloadable: Does not implement all required functions\n", | |
| 312 plugin->path); | |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
313 gaim_plugin_destroy(plugin); |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
314 return NULL; |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
315 } |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
316 |
| 5205 | 317 return plugin; |
| 318 #else | |
| 319 return NULL; | |
| 320 #endif /* !GAIM_PLUGINS */ | |
| 321 } | |
| 322 | |
| 12332 | 323 static gint |
| 324 compare_plugins(gconstpointer a, gconstpointer b) | |
| 325 { | |
| 326 const GaimPlugin *plugina = a; | |
| 327 const GaimPlugin *pluginb = b; | |
| 328 | |
| 329 return strcmp(plugina->info->name, pluginb->info->name); | |
| 330 } | |
| 331 | |
| 5205 | 332 gboolean |
| 333 gaim_plugin_load(GaimPlugin *plugin) | |
| 334 { | |
| 335 #ifdef GAIM_PLUGINS | |
|
6486
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
336 GList *dep_list = NULL; |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
337 GList *l; |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
338 |
| 5205 | 339 g_return_val_if_fail(plugin != NULL, FALSE); |
|
5270
d1fe8e320dab
[gaim-migrate @ 5642]
Christian Hammond <chipx86@chipx86.com>
parents:
5269
diff
changeset
|
340 g_return_val_if_fail(plugin->error == NULL, FALSE); |
| 5205 | 341 |
| 342 if (gaim_plugin_is_loaded(plugin)) | |
| 343 return TRUE; | |
| 344 | |
|
6486
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
345 /* |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
346 * Go through the list of the plugin's dependencies. |
|
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 * First pass: Make sure all the plugins needed are probed. |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
349 */ |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
350 for (l = plugin->info->dependencies; l != NULL; l = l->next) |
|
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 const char *dep_name = (const char *)l->data; |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
353 GaimPlugin *dep_plugin; |
|
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 dep_plugin = gaim_plugins_find_with_id(dep_name); |
|
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 if (dep_plugin == NULL) |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
358 { |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
359 char buf[BUFSIZ]; |
|
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 g_snprintf(buf, sizeof(buf), |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
362 _("The required plugin %s was not found. " |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
363 "Please install this plugin and try again."), |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
364 dep_name); |
|
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 gaim_notify_error(NULL, NULL, |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
367 _("Gaim was unable to load your plugin."), |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
368 buf); |
|
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 if (dep_list != NULL) |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
371 g_list_free(dep_list); |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
372 |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
373 return FALSE; |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
374 } |
|
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 dep_list = g_list_append(dep_list, dep_plugin); |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
377 } |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
378 |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
379 /* Second pass: load all the required plugins. */ |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
380 for (l = dep_list; l != NULL; l = l->next) |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
381 { |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
382 GaimPlugin *dep_plugin = (GaimPlugin *)l->data; |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
383 |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
384 if (!gaim_plugin_is_loaded(dep_plugin)) |
|
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 if (!gaim_plugin_load(dep_plugin)) |
|
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 char buf[BUFSIZ]; |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
389 |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
390 g_snprintf(buf, sizeof(buf), |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
391 _("The required plugin %s was unable to load."), |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
392 plugin->info->name); |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
393 |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
394 gaim_notify_error(NULL, NULL, |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
395 _("Gaim was unable to load your plugin."), |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
396 buf); |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
397 |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
398 if (dep_list != NULL) |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
399 g_list_free(dep_list); |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
400 |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
401 return FALSE; |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
402 } |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
403 } |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
404 } |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
405 |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
406 if (dep_list != NULL) |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
407 g_list_free(dep_list); |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
408 |
|
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
409 if (plugin->native_plugin) |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
410 { |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
411 if (plugin->info != NULL && plugin->info->load != NULL) |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
412 { |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
413 if (!plugin->info->load(plugin)) |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
414 return FALSE; |
|
5357
2a1c92df7024
[gaim-migrate @ 5733]
Christian Hammond <chipx86@chipx86.com>
parents:
5270
diff
changeset
|
415 } |
| 5205 | 416 } |
| 417 else { | |
| 418 GaimPlugin *loader; | |
| 419 GaimPluginLoaderInfo *loader_info; | |
| 420 | |
|
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
421 loader = find_loader_for_plugin(plugin); |
| 5205 | 422 |
| 423 if (loader == NULL) | |
| 424 return FALSE; | |
| 425 | |
| 426 loader_info = GAIM_PLUGIN_LOADER_INFO(loader); | |
| 427 | |
| 428 if (loader_info->load != NULL) | |
|
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
429 { |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
430 if (!loader_info->load(plugin)) |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
431 return FALSE; |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
432 } |
| 5205 | 433 } |
| 434 | |
| 12332 | 435 loaded_plugins = g_list_insert_sorted(loaded_plugins, plugin, compare_plugins); |
| 5205 | 436 |
| 437 plugin->loaded = TRUE; | |
| 438 | |
| 439 /* TODO */ | |
| 440 if (load_cb != NULL) | |
| 441 load_cb(plugin, load_cb_data); | |
| 442 | |
| 8993 | 443 gaim_signal_emit(gaim_plugins_get_handle(), "plugin-load", plugin); |
| 8986 | 444 |
| 5205 | 445 return TRUE; |
| 446 | |
| 447 #else | |
| 5449 | 448 return TRUE; |
| 5205 | 449 #endif /* !GAIM_PLUGINS */ |
| 450 } | |
| 451 | |
| 452 gboolean | |
| 453 gaim_plugin_unload(GaimPlugin *plugin) | |
| 454 { | |
| 455 #ifdef GAIM_PLUGINS | |
| 456 g_return_val_if_fail(plugin != NULL, FALSE); | |
| 457 | |
| 458 loaded_plugins = g_list_remove(loaded_plugins, plugin); | |
| 11950 | 459 if ((plugin->info != NULL) && GAIM_IS_PROTOCOL_PLUGIN(plugin)) |
| 460 protocol_plugins = g_list_remove(protocol_plugins, plugin); | |
| 5205 | 461 |
| 462 g_return_val_if_fail(gaim_plugin_is_loaded(plugin), FALSE); | |
| 463 | |
| 10447 | 464 gaim_debug_info("plugins", "Unloading plugin %s\n", plugin->info->name); |
| 5205 | 465 |
| 466 /* cancel any pending dialogs the plugin has */ | |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5450
diff
changeset
|
467 gaim_request_close_with_handle(plugin); |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5450
diff
changeset
|
468 gaim_notify_close_with_handle(plugin); |
| 5205 | 469 |
| 470 plugin->loaded = FALSE; | |
| 471 | |
| 472 if (plugin->native_plugin) { | |
| 473 if (plugin->info->unload != NULL) | |
| 474 plugin->info->unload(plugin); | |
| 475 | |
| 476 if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) { | |
| 477 GaimPluginProtocolInfo *prpl_info; | |
| 478 GList *l; | |
| 479 | |
| 480 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); | |
| 481 | |
|
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
482 for (l = prpl_info->user_splits; l != NULL; l = l->next) |
|
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
483 gaim_account_user_split_destroy(l->data); |
| 5205 | 484 |
|
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
485 for (l = prpl_info->protocol_options; l != NULL; l = l->next) |
|
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
486 gaim_account_option_destroy(l->data); |
| 5205 | 487 |
| 12117 | 488 if (prpl_info->user_splits != NULL) { |
|
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
489 g_list_free(prpl_info->user_splits); |
| 12117 | 490 prpl_info->user_splits = NULL; |
| 491 } | |
|
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
492 |
| 12117 | 493 if (prpl_info->protocol_options != NULL) { |
|
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
494 g_list_free(prpl_info->protocol_options); |
| 12117 | 495 prpl_info->protocol_options = NULL; |
| 496 } | |
| 5205 | 497 } |
| 498 } | |
| 499 else { | |
| 500 GaimPlugin *loader; | |
| 501 GaimPluginLoaderInfo *loader_info; | |
| 502 | |
|
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
503 loader = find_loader_for_plugin(plugin); |
| 5205 | 504 |
| 505 if (loader == NULL) | |
| 506 return FALSE; | |
| 507 | |
| 508 loader_info = GAIM_PLUGIN_LOADER_INFO(loader); | |
| 509 | |
|
9697
f568b6655331
[gaim-migrate @ 10556]
Christian Hammond <chipx86@chipx86.com>
parents:
9667
diff
changeset
|
510 if (loader_info->unload != NULL) |
| 5205 | 511 loader_info->unload(plugin); |
| 512 } | |
| 513 | |
| 514 gaim_signals_disconnect_by_handle(plugin); | |
|
6822
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
515 gaim_plugin_ipc_unregister_all(plugin); |
| 5205 | 516 |
| 517 /* TODO */ | |
| 518 if (unload_cb != NULL) | |
| 519 unload_cb(plugin, unload_cb_data); | |
| 520 | |
| 8986 | 521 gaim_signal_emit(gaim_plugins_get_handle(), "plugin-unload", plugin); |
| 522 | |
| 10087 | 523 gaim_prefs_disconnect_by_handle(plugin); |
| 524 | |
| 5205 | 525 return TRUE; |
| 5449 | 526 #else |
| 527 return TRUE; | |
| 5205 | 528 #endif /* GAIM_PLUGINS */ |
| 529 } | |
| 530 | |
| 531 gboolean | |
| 532 gaim_plugin_reload(GaimPlugin *plugin) | |
| 533 { | |
| 534 #ifdef GAIM_PLUGINS | |
| 535 g_return_val_if_fail(plugin != NULL, FALSE); | |
| 536 g_return_val_if_fail(gaim_plugin_is_loaded(plugin), FALSE); | |
| 537 | |
| 538 if (!gaim_plugin_unload(plugin)) | |
| 539 return FALSE; | |
| 540 | |
| 541 if (!gaim_plugin_load(plugin)) | |
| 542 return FALSE; | |
| 543 | |
| 544 return TRUE; | |
| 545 #else | |
| 5449 | 546 return TRUE; |
| 5205 | 547 #endif /* !GAIM_PLUGINS */ |
| 548 } | |
| 549 | |
| 550 void | |
| 551 gaim_plugin_destroy(GaimPlugin *plugin) | |
| 552 { | |
| 5449 | 553 #ifdef GAIM_PLUGINS |
| 5205 | 554 g_return_if_fail(plugin != NULL); |
| 555 | |
| 556 if (gaim_plugin_is_loaded(plugin)) | |
| 557 gaim_plugin_unload(plugin); | |
| 558 | |
| 559 plugins = g_list_remove(plugins, plugin); | |
| 560 | |
|
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
561 if (load_queue != NULL) |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
562 load_queue = g_list_remove(load_queue, plugin); |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
563 |
| 9943 | 564 /* true, this may leak a little memory if there is a major version |
| 565 * mismatch, but it's a lot better than trying to free something | |
| 566 * we shouldn't, and crashing while trying to load an old plugin */ | |
| 567 if(plugin->info == NULL || plugin->info->magic != GAIM_PLUGIN_MAGIC || | |
| 568 plugin->info->major_version != GAIM_MAJOR_VERSION) { | |
| 569 if(plugin->handle) | |
| 570 g_module_close(plugin->handle); | |
| 571 g_free(plugin); | |
| 572 return; | |
| 573 } | |
| 574 | |
|
5243
f6e0c689a88b
[gaim-migrate @ 5614]
Christian Hammond <chipx86@chipx86.com>
parents:
5242
diff
changeset
|
575 if (plugin->info != NULL && plugin->info->dependencies != NULL) |
|
f6e0c689a88b
[gaim-migrate @ 5614]
Christian Hammond <chipx86@chipx86.com>
parents:
5242
diff
changeset
|
576 g_list_free(plugin->info->dependencies); |
| 5205 | 577 |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
578 if (plugin->native_plugin) |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
579 { |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
580 if (plugin->info != NULL && plugin->info->type == GAIM_PLUGIN_LOADER) |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
581 { |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
582 GaimPluginLoaderInfo *loader_info; |
| 5205 | 583 GList *exts, *l, *next_l; |
| 584 GaimPlugin *p2; | |
| 585 | |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
586 loader_info = GAIM_PLUGIN_LOADER_INFO(plugin); |
| 5205 | 587 |
| 9943 | 588 if (loader_info != NULL && loader_info->exts != NULL) |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
589 { |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
590 for (exts = GAIM_PLUGIN_LOADER_INFO(plugin)->exts; |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
591 exts != NULL; |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
592 exts = exts->next) { |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
593 |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
594 for (l = gaim_plugins_get_all(); l != NULL; l = next_l) |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
595 { |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
596 next_l = l->next; |
| 5205 | 597 |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
598 p2 = l->data; |
| 5205 | 599 |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
600 if (p2->path != NULL && |
| 10447 | 601 has_file_extension(p2->path, exts->data)) |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
602 { |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
603 gaim_plugin_destroy(p2); |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
604 } |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
605 } |
| 5205 | 606 } |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
607 |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
608 g_list_free(loader_info->exts); |
| 5205 | 609 } |
| 610 | |
| 611 plugin_loaders = g_list_remove(plugin_loaders, plugin); | |
| 612 } | |
| 613 | |
| 614 if (plugin->info != NULL && plugin->info->destroy != NULL) | |
| 615 plugin->info->destroy(plugin); | |
| 616 | |
| 617 if (plugin->handle != NULL) | |
| 618 g_module_close(plugin->handle); | |
| 619 } | |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
620 else |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
621 { |
| 5205 | 622 GaimPlugin *loader; |
| 623 GaimPluginLoaderInfo *loader_info; | |
| 624 | |
|
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
625 loader = find_loader_for_plugin(plugin); |
| 5205 | 626 |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
627 if (loader != NULL) |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
628 { |
|
5941
a3e60ff95b7d
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
629 loader_info = GAIM_PLUGIN_LOADER_INFO(loader); |
| 5205 | 630 |
|
5941
a3e60ff95b7d
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
631 if (loader_info->destroy != NULL) |
|
a3e60ff95b7d
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
632 loader_info->destroy(plugin); |
|
a3e60ff95b7d
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
633 } |
| 5205 | 634 } |
| 635 | |
| 636 if (plugin->path != NULL) g_free(plugin->path); | |
| 637 if (plugin->error != NULL) g_free(plugin->error); | |
| 638 | |
| 639 g_free(plugin); | |
| 5449 | 640 #endif /* !GAIM_PLUGINS */ |
| 5205 | 641 } |
| 642 | |
| 643 gboolean | |
| 644 gaim_plugin_is_loaded(const GaimPlugin *plugin) | |
| 645 { | |
| 646 g_return_val_if_fail(plugin != NULL, FALSE); | |
| 647 | |
| 648 return plugin->loaded; | |
| 649 } | |
| 650 | |
|
11772
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
651 const gchar * |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
652 gaim_plugin_get_id(const GaimPlugin *plugin) { |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
653 g_return_val_if_fail(plugin, NULL); |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
654 g_return_val_if_fail(plugin->info, NULL); |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
655 |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
656 return plugin->info->id; |
|
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 |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
659 const gchar * |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
660 gaim_plugin_get_name(const GaimPlugin *plugin) { |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
661 g_return_val_if_fail(plugin, NULL); |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
662 g_return_val_if_fail(plugin->info, NULL); |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
663 |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
664 return plugin->info->name; |
|
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 |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
667 const gchar * |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
668 gaim_plugin_get_version(const GaimPlugin *plugin) { |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
669 g_return_val_if_fail(plugin, NULL); |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
670 g_return_val_if_fail(plugin->info, NULL); |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
671 |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
672 return plugin->info->version; |
|
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 |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
675 const gchar * |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
676 gaim_plugin_get_summary(const GaimPlugin *plugin) { |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
677 g_return_val_if_fail(plugin, NULL); |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
678 g_return_val_if_fail(plugin->info, NULL); |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
679 |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
680 return plugin->info->summary; |
|
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 |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
683 const gchar * |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
684 gaim_plugin_get_description(const GaimPlugin *plugin) { |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
685 g_return_val_if_fail(plugin, NULL); |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
686 g_return_val_if_fail(plugin->info, NULL); |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
687 |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
688 return plugin->info->description; |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
689 } |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
690 |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
691 const gchar * |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
692 gaim_plugin_get_author(const GaimPlugin *plugin) { |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
693 g_return_val_if_fail(plugin, NULL); |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
694 g_return_val_if_fail(plugin->info, NULL); |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
695 |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
696 return plugin->info->author; |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
697 } |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
698 |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
699 const gchar * |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
700 gaim_plugin_get_homepage(const GaimPlugin *plugin) { |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
701 g_return_val_if_fail(plugin, NULL); |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
702 g_return_val_if_fail(plugin->info, NULL); |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
703 |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
704 return plugin->info->homepage; |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
705 } |
|
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
706 |
|
6822
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 * Plugin IPC |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
709 **************************************************************************/ |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
710 static void |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
711 destroy_ipc_info(void *data) |
|
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 GaimPluginIpcCommand *ipc_command = (GaimPluginIpcCommand *)data; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
714 int i; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
715 |
|
9667
22928adecb84
[gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents:
9018
diff
changeset
|
716 if (ipc_command->params != NULL) |
|
22928adecb84
[gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents:
9018
diff
changeset
|
717 { |
|
22928adecb84
[gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents:
9018
diff
changeset
|
718 for (i = 0; i < ipc_command->num_params; i++) |
|
22928adecb84
[gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents:
9018
diff
changeset
|
719 gaim_value_destroy(ipc_command->params[i]); |
|
22928adecb84
[gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents:
9018
diff
changeset
|
720 |
|
22928adecb84
[gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents:
9018
diff
changeset
|
721 g_free(ipc_command->params); |
|
22928adecb84
[gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents:
9018
diff
changeset
|
722 } |
|
6822
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
723 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
724 if (ipc_command->ret_value != NULL) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
725 gaim_value_destroy(ipc_command->ret_value); |
|
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 g_free(ipc_command); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
728 } |
|
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 gboolean |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
731 gaim_plugin_ipc_register(GaimPlugin *plugin, const char *command, |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
732 GaimCallback func, GaimSignalMarshalFunc marshal, |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
733 GaimValue *ret_value, int num_params, ...) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
734 { |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
735 GaimPluginIpcInfo *ipc_info; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
736 GaimPluginIpcCommand *ipc_command; |
|
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 g_return_val_if_fail(plugin != NULL, FALSE); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
739 g_return_val_if_fail(command != NULL, FALSE); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
740 g_return_val_if_fail(func != NULL, FALSE); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
741 g_return_val_if_fail(marshal != NULL, FALSE); |
|
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 if (plugin->ipc_data == NULL) |
|
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 ipc_info = plugin->ipc_data = g_new0(GaimPluginIpcInfo, 1); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
746 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
|
747 g_free, destroy_ipc_info); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
748 } |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
749 else |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
750 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
751 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
752 ipc_command = g_new0(GaimPluginIpcCommand, 1); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
753 ipc_command->func = func; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
754 ipc_command->marshal = marshal; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
755 ipc_command->num_params = num_params; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
756 ipc_command->ret_value = ret_value; |
|
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 if (num_params > 0) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
759 { |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
760 va_list args; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
761 int i; |
|
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 ipc_command->params = g_new0(GaimValue *, num_params); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
764 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
765 va_start(args, num_params); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
766 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
767 for (i = 0; i < num_params; i++) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
768 ipc_command->params[i] = va_arg(args, GaimValue *); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
769 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
770 va_end(args); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
771 } |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
772 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
773 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
|
774 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
775 ipc_info->command_count++; |
|
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 return TRUE; |
|
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 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
780 void |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
781 gaim_plugin_ipc_unregister(GaimPlugin *plugin, const char *command) |
|
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 GaimPluginIpcInfo *ipc_info; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
784 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
785 g_return_if_fail(plugin != NULL); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
786 g_return_if_fail(command != 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 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; |
|
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 if (ipc_info == NULL || |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
791 g_hash_table_lookup(ipc_info->commands, command) == NULL) |
|
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 gaim_debug_error("plugins", |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
794 "IPC command '%s' was not registered for plugin %s\n", |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
795 command, plugin->info->name); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
796 return; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
797 } |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
798 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
799 g_hash_table_remove(ipc_info->commands, command); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
800 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
801 ipc_info->command_count--; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
802 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
803 if (ipc_info->command_count == 0) |
|
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 g_hash_table_destroy(ipc_info->commands); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
806 g_free(ipc_info); |
|
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 plugin->ipc_data = NULL; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
809 } |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
810 } |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
811 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
812 void |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
813 gaim_plugin_ipc_unregister_all(GaimPlugin *plugin) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
814 { |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
815 GaimPluginIpcInfo *ipc_info; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
816 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
817 g_return_if_fail(plugin != NULL); |
|
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 if (plugin->ipc_data == NULL) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
820 return; /* Silently ignore it. */ |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
821 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
822 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
823 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
824 g_hash_table_destroy(ipc_info->commands); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
825 g_free(ipc_info); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
826 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
827 plugin->ipc_data = NULL; |
|
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 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
830 gboolean |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
831 gaim_plugin_ipc_get_params(GaimPlugin *plugin, const char *command, |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
832 GaimValue **ret_value, int *num_params, |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
833 GaimValue ***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 GaimPluginIpcInfo *ipc_info; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
836 GaimPluginIpcCommand *ipc_command; |
|
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 g_return_val_if_fail(plugin != NULL, FALSE); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
839 g_return_val_if_fail(command != NULL, FALSE); |
|
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 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; |
|
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 if (ipc_info == NULL || |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
844 (ipc_command = g_hash_table_lookup(ipc_info->commands, |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
845 command)) == NULL) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
846 { |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
847 gaim_debug_error("plugins", |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
848 "IPC command '%s' was not registered for plugin %s\n", |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
849 command, plugin->info->name); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
850 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
851 return FALSE; |
|
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 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
854 if (num_params != NULL) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
855 *num_params = ipc_command->num_params; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
856 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
857 if (params != NULL) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
858 *params = ipc_command->params; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
859 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
860 if (ret_value != NULL) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
861 *ret_value = ipc_command->ret_value; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
862 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
863 return TRUE; |
|
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 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
866 void * |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
867 gaim_plugin_ipc_call(GaimPlugin *plugin, const char *command, |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
868 gboolean *ok, ...) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
869 { |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
870 GaimPluginIpcInfo *ipc_info; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
871 GaimPluginIpcCommand *ipc_command; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
872 va_list args; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
873 void *ret_value; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
874 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
875 if (ok != NULL) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
876 *ok = FALSE; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
877 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
878 g_return_val_if_fail(plugin != NULL, NULL); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
879 g_return_val_if_fail(command != NULL, NULL); |
|
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 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; |
|
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 if (ipc_info == NULL || |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
884 (ipc_command = g_hash_table_lookup(ipc_info->commands, |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
885 command)) == NULL) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
886 { |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
887 gaim_debug_error("plugins", |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
888 "IPC command '%s' was not registered for plugin %s\n", |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
889 command, plugin->info->name); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
890 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
891 return NULL; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
892 } |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
893 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
894 va_start(args, ok); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
895 ipc_command->marshal(ipc_command->func, args, NULL, &ret_value); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
896 va_end(args); |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
897 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
898 if (ok != NULL) |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
899 *ok = TRUE; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
900 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
901 return ret_value; |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
902 } |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
903 |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
904 /************************************************************************** |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
905 * Plugins subsystem |
|
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
906 **************************************************************************/ |
| 10479 | 907 void * |
| 908 gaim_plugins_get_handle(void) { | |
| 909 static int handle; | |
| 910 | |
| 911 return &handle; | |
| 912 } | |
| 913 | |
| 914 void | |
| 915 gaim_plugins_init(void) { | |
| 916 void *handle = gaim_plugins_get_handle(); | |
| 917 | |
| 918 gaim_signal_register(handle, "plugin-load", | |
| 919 gaim_marshal_VOID__POINTER, | |
| 920 NULL, 1, | |
| 921 gaim_value_new(GAIM_TYPE_SUBTYPE, | |
| 922 GAIM_SUBTYPE_PLUGIN)); | |
| 923 gaim_signal_register(handle, "plugin-unload", | |
| 924 gaim_marshal_VOID__POINTER, | |
| 925 NULL, 1, | |
| 926 gaim_value_new(GAIM_TYPE_SUBTYPE, | |
| 927 GAIM_SUBTYPE_PLUGIN)); | |
| 928 } | |
| 929 | |
| 930 void | |
| 931 gaim_plugins_uninit(void) { | |
| 932 gaim_signals_disconnect_by_handle(gaim_plugins_get_handle()); | |
| 933 } | |
| 934 | |
| 935 /************************************************************************** | |
| 936 * Plugins API | |
| 937 **************************************************************************/ | |
| 5205 | 938 void |
| 10447 | 939 gaim_plugins_add_search_path(const char *path) |
| 5205 | 940 { |
| 10447 | 941 g_return_if_fail(path != NULL); |
| 5205 | 942 |
| 10447 | 943 if (g_list_find_custom(search_paths, path, (GCompareFunc)strcmp)) |
| 944 return; | |
| 5205 | 945 |
| 10447 | 946 search_paths = g_list_append(search_paths, strdup(path)); |
| 5205 | 947 } |
| 948 | |
| 949 void | |
| 950 gaim_plugins_unload_all(void) | |
| 951 { | |
| 952 #ifdef GAIM_PLUGINS | |
| 953 | |
| 954 while (loaded_plugins != NULL) | |
| 955 gaim_plugin_unload(loaded_plugins->data); | |
| 956 | |
| 957 #endif /* GAIM_PLUGINS */ | |
| 958 } | |
| 959 | |
| 960 void | |
|
5242
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
961 gaim_plugins_destroy_all(void) |
|
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
962 { |
|
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
963 #ifdef GAIM_PLUGINS |
|
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
964 |
|
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
965 while (plugins != NULL) |
|
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
966 gaim_plugin_destroy(plugins->data); |
|
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
967 |
|
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
968 #endif /* GAIM_PLUGINS */ |
|
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
969 } |
| 5838 | 970 |
| 971 void | |
|
5949
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
972 gaim_plugins_load_saved(const char *key) |
| 5838 | 973 { |
| 974 #ifdef GAIM_PLUGINS | |
|
5949
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
975 GList *f, *files; |
|
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
976 |
|
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
977 g_return_if_fail(key != NULL); |
| 5838 | 978 |
|
5949
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
979 files = gaim_prefs_get_string_list(key); |
|
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
980 |
|
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
981 for (f = files; f; f = f->next) |
|
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
982 { |
| 10682 | 983 char *filename; |
| 984 char *basename; | |
| 985 GaimPlugin *plugin; | |
| 986 | |
| 987 if (f->data == NULL) | |
| 988 continue; | |
|
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
989 |
| 10682 | 990 filename = f->data; |
| 991 /* | |
| 992 * We don't know if the filename uses Windows or Unix path | |
| 993 * separators (because people might be sharing a prefs.xml | |
| 994 * file across systems), so we find the last occurrence | |
| 995 * of either. | |
| 996 */ | |
| 997 basename = strrchr(filename, '/'); | |
| 998 if ((basename == NULL) || (basename < strrchr(filename, '\\'))) | |
| 999 basename = strrchr(filename, '\\'); | |
| 1000 if (basename != NULL) | |
| 1001 basename++; | |
| 1002 | |
| 1003 if ((plugin = gaim_plugins_find_with_filename(filename)) != NULL) | |
|
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1004 { |
| 10682 | 1005 gaim_debug_info("plugins", "Loading saved plugin %s\n", |
| 1006 plugin->path); | |
| 1007 gaim_plugin_load(plugin); | |
| 1008 } | |
| 1009 else if ((plugin = gaim_plugins_find_with_basename(basename)) != NULL) | |
| 1010 { | |
| 1011 gaim_debug_info("plugins", "Loading saved plugin %s\n", | |
| 1012 plugin->path); | |
| 1013 gaim_plugin_load(plugin); | |
| 1014 } | |
| 1015 else | |
| 1016 { | |
| 1017 gaim_debug_error("plugins", "Unable to find saved plugin %s\n", | |
| 1018 filename); | |
|
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1019 } |
|
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1020 |
| 5838 | 1021 g_free(f->data); |
| 1022 } | |
| 1023 | |
| 1024 g_list_free(files); | |
| 1025 #endif /* GAIM_PLUGINS */ | |
| 1026 } | |
| 1027 | |
| 1028 | |
|
5242
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1029 void |
| 5205 | 1030 gaim_plugins_probe(const char *ext) |
| 1031 { | |
| 1032 #ifdef GAIM_PLUGINS | |
| 1033 GDir *dir; | |
| 1034 const gchar *file; | |
| 1035 gchar *path; | |
| 1036 GaimPlugin *plugin; | |
| 10447 | 1037 GList *cur; |
| 1038 const char *search_path; | |
| 5205 | 1039 |
| 1040 if (!g_module_supported()) | |
| 1041 return; | |
| 1042 | |
| 10447 | 1043 /* Probe plugins */ |
| 1044 for (cur = search_paths; cur != NULL; cur = cur->next) | |
| 1045 { | |
| 1046 search_path = cur->data; | |
| 5205 | 1047 |
| 10447 | 1048 dir = g_dir_open(search_path, 0, NULL); |
| 5205 | 1049 |
| 10447 | 1050 if (dir != NULL) |
| 1051 { | |
| 1052 while ((file = g_dir_read_name(dir)) != NULL) | |
| 1053 { | |
| 1054 path = g_build_filename(search_path, file, NULL); | |
| 5205 | 1055 |
| 10447 | 1056 if (ext == NULL || has_file_extension(file, ext)) |
| 5205 | 1057 plugin = gaim_plugin_probe(path); |
| 1058 | |
| 1059 g_free(path); | |
| 1060 } | |
| 1061 | |
| 1062 g_dir_close(dir); | |
| 1063 } | |
| 1064 } | |
| 1065 | |
| 10447 | 1066 /* See if we have any plugins waiting to load */ |
|
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1067 while (load_queue != NULL) |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1068 { |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1069 plugin = (GaimPlugin *)load_queue->data; |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1070 |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1071 load_queue = g_list_remove(load_queue, plugin); |
|
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 if (plugin == NULL || plugin->info == NULL) |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1074 continue; |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1075 |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1076 if (plugin->info->type == GAIM_PLUGIN_LOADER) |
|
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 /* We'll just load this right now. */ |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1079 if (!gaim_plugin_load(plugin)) |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1080 { |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1081 gaim_plugin_destroy(plugin); |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1082 |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1083 continue; |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1084 } |
|
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 plugin_loaders = g_list_append(plugin_loaders, plugin); |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1087 |
| 10447 | 1088 for (cur = GAIM_PLUGIN_LOADER_INFO(plugin)->exts; |
| 1089 cur != NULL; | |
| 1090 cur = cur->next) | |
|
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1091 { |
| 10447 | 1092 gaim_plugins_probe(cur->data); |
|
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1093 } |
|
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 else if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1096 { |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1097 /* We'll just load this right now. */ |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1098 if (!gaim_plugin_load(plugin)) |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1099 { |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1100 gaim_plugin_destroy(plugin); |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1101 |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1102 continue; |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1103 } |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1104 |
| 11950 | 1105 /* Make sure we don't load two PRPLs with the same name? */ |
| 7956 | 1106 if (gaim_find_prpl(plugin->info->id)) |
|
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1107 { |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1108 /* Nothing to see here--move along, move along */ |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1109 gaim_plugin_destroy(plugin); |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1110 |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1111 continue; |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1112 } |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1113 |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1114 protocol_plugins = g_list_insert_sorted(protocol_plugins, plugin, |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1115 (GCompareFunc)compare_prpl); |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1116 } |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1117 } |
|
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1118 |
| 5205 | 1119 if (probe_cb != NULL) |
| 1120 probe_cb(probe_cb_data); | |
| 1121 #endif /* GAIM_PLUGINS */ | |
| 1122 } | |
| 1123 | |
| 1124 gboolean | |
| 1125 gaim_plugin_register(GaimPlugin *plugin) | |
| 1126 { | |
| 1127 g_return_val_if_fail(plugin != NULL, FALSE); | |
| 1128 | |
| 10447 | 1129 /* If this plugin has been registered already then exit */ |
| 5205 | 1130 if (g_list_find(plugins, plugin)) |
| 1131 return TRUE; | |
| 1132 | |
| 10447 | 1133 /* Ensure the plugin has the requisite information */ |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1134 if (plugin->info->type == GAIM_PLUGIN_LOADER) |
|
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1135 { |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1136 GaimPluginLoaderInfo *loader_info; |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1137 |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1138 loader_info = GAIM_PLUGIN_LOADER_INFO(plugin); |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1139 |
| 9943 | 1140 if (loader_info == NULL) |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1141 { |
| 10447 | 1142 gaim_debug_error("plugins", "%s is unloadable\n", |
| 9943 | 1143 plugin->path); |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1144 return FALSE; |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1145 } |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1146 } |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1147 else if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1148 { |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1149 GaimPluginProtocolInfo *prpl_info; |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1150 |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1151 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1152 |
| 9943 | 1153 if (prpl_info == NULL) |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1154 { |
| 10447 | 1155 gaim_debug_error("plugins", "%s is unloadable\n", |
| 9943 | 1156 plugin->path); |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1157 return FALSE; |
|
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1158 } |
| 10447 | 1159 } |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1160 |
| 11950 | 1161 #ifdef GAIM_PLUGINS |
| 10447 | 1162 /* This plugin should be probed and maybe loaded--add it to the queue */ |
| 1163 load_queue = g_list_append(load_queue, plugin); | |
| 11950 | 1164 #else |
| 12081 | 1165 if (plugin->info != NULL) |
| 1166 { | |
| 1167 if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) | |
| 1168 protocol_plugins = g_list_insert_sorted(protocol_plugins, plugin, | |
| 1169 (GCompareFunc)compare_prpl); | |
| 1170 if (plugin->info->load != NULL) | |
| 1171 if (!plugin->info->load(plugin)) | |
| 1172 return FALSE; | |
| 1173 } | |
| 11950 | 1174 #endif |
| 5205 | 1175 |
| 1176 plugins = g_list_append(plugins, plugin); | |
| 1177 | |
| 1178 return TRUE; | |
| 1179 } | |
| 1180 | |
| 1181 gboolean | |
| 1182 gaim_plugins_enabled(void) | |
| 1183 { | |
| 1184 #ifdef GAIM_PLUGINS | |
| 1185 return TRUE; | |
| 1186 #else | |
| 1187 return FALSE; | |
| 1188 #endif | |
| 1189 } | |
| 1190 | |
| 1191 void | |
| 1192 gaim_plugins_register_probe_notify_cb(void (*func)(void *), void *data) | |
| 1193 { | |
| 1194 /* TODO */ | |
| 1195 probe_cb = func; | |
| 1196 probe_cb_data = data; | |
| 1197 } | |
| 1198 | |
| 1199 void | |
| 1200 gaim_plugins_unregister_probe_notify_cb(void (*func)(void *)) | |
| 1201 { | |
| 1202 /* TODO */ | |
| 1203 probe_cb = NULL; | |
| 1204 probe_cb_data = NULL; | |
| 1205 } | |
| 1206 | |
| 1207 void | |
| 1208 gaim_plugins_register_load_notify_cb(void (*func)(GaimPlugin *, void *), | |
| 1209 void *data) | |
| 1210 { | |
| 1211 /* TODO */ | |
| 1212 load_cb = func; | |
| 1213 load_cb_data = data; | |
| 1214 } | |
| 1215 | |
| 1216 void | |
| 1217 gaim_plugins_unregister_load_notify_cb(void (*func)(GaimPlugin *, void *)) | |
| 1218 { | |
| 1219 /* TODO */ | |
| 1220 load_cb = NULL; | |
| 1221 load_cb_data = NULL; | |
| 1222 } | |
| 1223 | |
| 1224 void | |
| 1225 gaim_plugins_register_unload_notify_cb(void (*func)(GaimPlugin *, void *), | |
| 1226 void *data) | |
| 1227 { | |
| 1228 /* TODO */ | |
| 1229 unload_cb = func; | |
| 1230 unload_cb_data = data; | |
| 1231 } | |
| 1232 | |
| 1233 void | |
| 1234 gaim_plugins_unregister_unload_notify_cb(void (*func)(GaimPlugin *, void *)) | |
| 1235 { | |
| 1236 /* TODO */ | |
| 1237 unload_cb = NULL; | |
| 1238 unload_cb_data = NULL; | |
| 1239 } | |
| 1240 | |
| 1241 GaimPlugin * | |
| 1242 gaim_plugins_find_with_name(const char *name) | |
| 1243 { | |
| 1244 GaimPlugin *plugin; | |
| 1245 GList *l; | |
| 1246 | |
| 1247 for (l = plugins; l != NULL; l = l->next) { | |
| 1248 plugin = l->data; | |
| 1249 | |
| 1250 if (!strcmp(plugin->info->name, name)) | |
| 1251 return plugin; | |
| 1252 } | |
| 1253 | |
| 1254 return NULL; | |
| 1255 } | |
| 1256 | |
| 1257 GaimPlugin * | |
| 1258 gaim_plugins_find_with_filename(const char *filename) | |
| 1259 { | |
| 1260 GaimPlugin *plugin; | |
| 1261 GList *l; | |
| 1262 | |
| 1263 for (l = plugins; l != NULL; l = l->next) { | |
| 1264 plugin = l->data; | |
| 1265 | |
| 1266 if (plugin->path != NULL && !strcmp(plugin->path, filename)) | |
| 1267 return plugin; | |
| 1268 } | |
| 1269 | |
| 1270 return NULL; | |
| 1271 } | |
| 1272 | |
| 1273 GaimPlugin * | |
|
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1274 gaim_plugins_find_with_basename(const char *basename) |
|
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1275 { |
| 11950 | 1276 #ifdef GAIM_PLUGINS |
|
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1277 GaimPlugin *plugin; |
|
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1278 GList *l; |
| 10682 | 1279 char *basename_no_ext; |
| 1280 char *tmp; | |
|
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1281 |
|
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1282 g_return_val_if_fail(basename != NULL, NULL); |
|
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1283 |
| 10682 | 1284 basename_no_ext = gaim_plugin_get_basename(basename); |
| 1285 | |
|
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1286 for (l = plugins; l != NULL; l = l->next) |
|
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1287 { |
|
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1288 plugin = (GaimPlugin *)l->data; |
|
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1289 |
| 7278 | 1290 if (plugin->path != NULL) { |
| 10682 | 1291 tmp = gaim_plugin_get_basename(plugin->path); |
| 1292 if (!strcmp(tmp, basename_no_ext)) | |
| 1293 { | |
| 7278 | 1294 g_free(tmp); |
| 10682 | 1295 g_free(basename_no_ext); |
|
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1296 return plugin; |
| 7278 | 1297 } |
| 7279 | 1298 g_free(tmp); |
|
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1299 } |
|
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1300 } |
|
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1301 |
| 10682 | 1302 g_free(basename_no_ext); |
| 11950 | 1303 #endif /* GAIM_PLUGINS */ |
| 10682 | 1304 |
|
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1305 return NULL; |
|
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1306 } |
|
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1307 |
|
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1308 GaimPlugin * |
| 5205 | 1309 gaim_plugins_find_with_id(const char *id) |
| 1310 { | |
| 1311 GaimPlugin *plugin; | |
| 1312 GList *l; | |
| 1313 | |
| 1314 g_return_val_if_fail(id != NULL, NULL); | |
| 1315 | |
|
6486
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1316 for (l = plugins; l != NULL; l = l->next) |
|
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1317 { |
| 5205 | 1318 plugin = l->data; |
| 1319 | |
|
6486
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1320 if (plugin->info->id != NULL && !strcmp(plugin->info->id, id)) |
| 5205 | 1321 return plugin; |
| 1322 } | |
| 1323 | |
| 1324 return NULL; | |
| 1325 } | |
| 1326 | |
| 1327 GList * | |
| 1328 gaim_plugins_get_loaded(void) | |
| 1329 { | |
| 1330 return loaded_plugins; | |
| 1331 } | |
| 1332 | |
| 1333 GList * | |
|
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1334 gaim_plugins_get_protocols(void) |
|
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1335 { |
|
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1336 return protocol_plugins; |
|
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1337 } |
|
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1338 |
|
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1339 GList * |
| 5205 | 1340 gaim_plugins_get_all(void) |
| 1341 { | |
| 1342 return plugins; | |
| 1343 } | |
| 1344 | |
| 9015 | 1345 |
| 1346 GaimPluginAction * | |
| 1347 gaim_plugin_action_new(char* label, void (*callback)(GaimPluginAction *)) | |
| 1348 { | |
| 1349 GaimPluginAction *act = g_new0(GaimPluginAction, 1); | |
| 9018 | 1350 |
| 9015 | 1351 act->label = label; |
| 1352 act->callback = callback; | |
| 9018 | 1353 |
| 1354 return act; | |
| 9015 | 1355 } |
