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