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