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