Mercurial > pidgin.yaz
annotate src/plugin.c @ 8863:75849c0650e5
[gaim-migrate @ 9631]
paco-paco distracted me and i got confused where i was at. i actually just
committed the code for this, now the rest
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Mon, 03 May 2004 17:55:46 +0000 |
parents | 184b8c3b6d09 |
children | 8cf32769ba1b |
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" |
5205 | 31 |
32 #ifdef _WIN32 | |
33 # define PLUGIN_EXT ".dll" | |
34 #else | |
6639 | 35 #ifdef __hpux |
36 # define PLUGIN_EXT ".sl" | |
37 #else | |
5205 | 38 # define PLUGIN_EXT ".so" |
39 #endif | |
6639 | 40 #endif |
5205 | 41 |
6822
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
42 typedef struct |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
43 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
44 GHashTable *commands; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
45 size_t command_count; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
46 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
47 } GaimPluginIpcInfo; |
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 typedef struct |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
50 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
51 GaimCallback func; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
52 GaimSignalMarshalFunc marshal; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
53 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
54 int num_params; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
55 GaimValue **params; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
56 GaimValue *ret_value; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
57 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
58 } GaimPluginIpcCommand; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
59 |
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
60 static GList *loaded_plugins = NULL; |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
61 static GList *plugins = NULL; |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
62 static GList *plugin_loaders = NULL; |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
63 static GList *protocol_plugins = NULL; |
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
64 static GList *load_queue = NULL; |
5205 | 65 |
66 static size_t search_path_count = 0; | |
67 static char **search_paths = NULL; | |
68 | |
69 static void (*probe_cb)(void *) = NULL; | |
70 static void *probe_cb_data = NULL; | |
71 static void (*load_cb)(GaimPlugin *, void *) = NULL; | |
72 static void *load_cb_data = NULL; | |
73 static void (*unload_cb)(GaimPlugin *, void *) = NULL; | |
74 static void *unload_cb_data = NULL; | |
75 | |
76 #ifdef GAIM_PLUGINS | |
77 static int | |
78 is_so_file(const char *filename, const char *ext) | |
79 { | |
80 int len, extlen; | |
81 | |
82 if (filename == NULL || *filename == '\0' || ext == NULL) | |
83 return 0; | |
84 | |
85 extlen = strlen(ext); | |
86 len = strlen(filename) - extlen; | |
87 | |
88 if (len < 0) | |
89 return 0; | |
90 | |
91 return (!strncmp(filename + len, ext, extlen)); | |
92 } | |
93 | |
94 static gboolean | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
95 loader_supports_file(GaimPlugin *loader, const char *filename) |
5205 | 96 { |
6432 | 97 GList *exts; |
5205 | 98 |
6432 | 99 for (exts = GAIM_PLUGIN_LOADER_INFO(loader)->exts; exts != NULL; exts = exts->next) { |
100 if (is_so_file(filename, (char *)exts->data)) { | |
101 return TRUE; | |
5205 | 102 } |
103 } | |
104 | |
105 return FALSE; | |
106 } | |
107 | |
108 static GaimPlugin * | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
109 find_loader_for_plugin(const GaimPlugin *plugin) |
5205 | 110 { |
111 GaimPlugin *loader; | |
112 GList *l; | |
113 | |
114 if (plugin->path == NULL) | |
115 return NULL; | |
116 | |
117 for (l = gaim_plugins_get_loaded(); l != NULL; l = l->next) { | |
118 loader = l->data; | |
119 | |
120 if (loader->info->type == GAIM_PLUGIN_LOADER && | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
121 loader_supports_file(loader, plugin->path)) { |
5205 | 122 |
123 return loader; | |
124 } | |
125 | |
126 loader = NULL; | |
127 } | |
128 | |
129 return NULL; | |
130 } | |
131 | |
5449 | 132 #endif /* GAIM_PLUGINS */ |
133 | |
5205 | 134 static gint |
135 compare_prpl(GaimPlugin *a, GaimPlugin *b) | |
136 { | |
137 /* neg if a before b, 0 if equal, pos if a after b */ | |
7956 | 138 if(GAIM_IS_PROTOCOL_PLUGIN(a)) { |
139 if(GAIM_IS_PROTOCOL_PLUGIN(b)) | |
140 return strcmp(a->info->name, b->info->name); | |
141 else | |
142 return -1; | |
143 } else { | |
144 if(GAIM_IS_PROTOCOL_PLUGIN(b)) | |
145 return 1; | |
146 else | |
147 return 0; | |
148 } | |
5205 | 149 } |
150 | |
151 GaimPlugin * | |
152 gaim_plugin_new(gboolean native, const char *path) | |
153 { | |
154 GaimPlugin *plugin; | |
155 | |
156 plugin = g_new0(GaimPlugin, 1); | |
157 | |
158 plugin->native_plugin = native; | |
159 plugin->path = (path == NULL ? NULL : g_strdup(path)); | |
160 | |
161 return plugin; | |
162 } | |
163 | |
164 GaimPlugin * | |
165 gaim_plugin_probe(const char *filename) | |
166 { | |
167 #ifdef GAIM_PLUGINS | |
168 GaimPlugin *plugin = NULL; | |
169 GaimPlugin *loader; | |
170 gboolean (*gaim_init_plugin)(GaimPlugin *); | |
171 | |
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
172 gaim_debug_misc("plugins", "probing %s\n", filename); |
5205 | 173 g_return_val_if_fail(filename != NULL, NULL); |
174 | |
5973 | 175 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) |
176 return NULL; | |
177 | |
5205 | 178 plugin = gaim_plugins_find_with_filename(filename); |
179 | |
180 if (plugin != NULL) | |
181 return plugin; | |
182 | |
183 plugin = gaim_plugin_new(is_so_file(filename, PLUGIN_EXT), filename); | |
184 | |
185 if (plugin->native_plugin) { | |
5450 | 186 const char *error; |
5205 | 187 plugin->handle = g_module_open(filename, 0); |
188 | |
189 if (plugin->handle == NULL) { | |
5443 | 190 error = g_module_error(); |
5269
cd7e4ba049f9
[gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents:
5268
diff
changeset
|
191 gaim_debug(GAIM_DEBUG_ERROR, "plugins", "%s is unloadable: %s\n", |
5443 | 192 plugin->path, error ? error : "Unknown error."); |
5205 | 193 |
5269
cd7e4ba049f9
[gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents:
5268
diff
changeset
|
194 gaim_plugin_destroy(plugin); |
cd7e4ba049f9
[gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents:
5268
diff
changeset
|
195 |
cd7e4ba049f9
[gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents:
5268
diff
changeset
|
196 return NULL; |
5205 | 197 } |
198 | |
199 if (!g_module_symbol(plugin->handle, "gaim_init_plugin", | |
200 (gpointer *)&gaim_init_plugin)) { | |
201 g_module_close(plugin->handle); | |
202 plugin->handle = NULL; | |
203 | |
5443 | 204 error = g_module_error(); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
205 gaim_debug(GAIM_DEBUG_ERROR, "plugins", "%s is unloadable: %s\n", |
5443 | 206 plugin->path, error ? error : "Unknown error."); |
5205 | 207 |
208 gaim_plugin_destroy(plugin); | |
209 | |
210 return NULL; | |
211 } | |
212 } | |
213 else { | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
214 loader = find_loader_for_plugin(plugin); |
5205 | 215 |
216 if (loader == NULL) { | |
217 gaim_plugin_destroy(plugin); | |
218 | |
219 return NULL; | |
220 } | |
221 | |
222 gaim_init_plugin = GAIM_PLUGIN_LOADER_INFO(loader)->probe; | |
223 } | |
224 | |
225 plugin->error = NULL; | |
226 | |
227 if (!gaim_init_plugin(plugin) || plugin->info == NULL) { | |
228 gaim_plugin_destroy(plugin); | |
229 | |
230 return NULL; | |
231 } | |
232 | |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
233 if (plugin->info->api_version != GAIM_PLUGIN_API_VERSION) |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
234 { |
8759
184b8c3b6d09
[gaim-migrate @ 9514]
Christian Hammond <chipx86@chipx86.com>
parents:
8749
diff
changeset
|
235 gaim_debug(GAIM_DEBUG_ERROR, "plugins", "%s is unloadable: API version mismatch %d (need %d)\n", |
184b8c3b6d09
[gaim-migrate @ 9514]
Christian Hammond <chipx86@chipx86.com>
parents:
8749
diff
changeset
|
236 plugin->path, plugin->info->api_version, GAIM_PLUGIN_API_VERSION); |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
237 gaim_plugin_destroy(plugin); |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
238 return NULL; |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
239 } |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
240 |
5205 | 241 return plugin; |
242 #else | |
243 return NULL; | |
244 #endif /* !GAIM_PLUGINS */ | |
245 } | |
246 | |
247 gboolean | |
248 gaim_plugin_load(GaimPlugin *plugin) | |
249 { | |
250 #ifdef GAIM_PLUGINS | |
6486
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
251 GList *dep_list = NULL; |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
252 GList *l; |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
253 |
5205 | 254 g_return_val_if_fail(plugin != NULL, FALSE); |
5270
d1fe8e320dab
[gaim-migrate @ 5642]
Christian Hammond <chipx86@chipx86.com>
parents:
5269
diff
changeset
|
255 g_return_val_if_fail(plugin->error == NULL, FALSE); |
5205 | 256 |
257 if (gaim_plugin_is_loaded(plugin)) | |
258 return TRUE; | |
259 | |
6486
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
260 /* |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
261 * Go through the list of the plugin's dependencies. |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
262 * |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
263 * First pass: Make sure all the plugins needed are probed. |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
264 */ |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
265 for (l = plugin->info->dependencies; l != NULL; l = l->next) |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
266 { |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
267 const char *dep_name = (const char *)l->data; |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
268 GaimPlugin *dep_plugin; |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
269 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
270 dep_plugin = gaim_plugins_find_with_id(dep_name); |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
271 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
272 if (dep_plugin == NULL) |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
273 { |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
274 char buf[BUFSIZ]; |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
275 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
276 g_snprintf(buf, sizeof(buf), |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
277 _("The required plugin %s was not found. " |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
278 "Please install this plugin and try again."), |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
279 dep_name); |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
280 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
281 gaim_notify_error(NULL, NULL, |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
282 _("Gaim was unable to load your plugin."), |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
283 buf); |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
284 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
285 if (dep_list != NULL) |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
286 g_list_free(dep_list); |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
287 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
288 return FALSE; |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
289 } |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
290 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
291 dep_list = g_list_append(dep_list, dep_plugin); |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
292 } |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
293 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
294 /* Second pass: load all the required plugins. */ |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
295 for (l = dep_list; l != NULL; l = l->next) |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
296 { |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
297 GaimPlugin *dep_plugin = (GaimPlugin *)l->data; |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
298 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
299 if (!gaim_plugin_is_loaded(dep_plugin)) |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
300 { |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
301 if (!gaim_plugin_load(dep_plugin)) |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
302 { |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
303 char buf[BUFSIZ]; |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
304 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
305 g_snprintf(buf, sizeof(buf), |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
306 _("The required plugin %s was unable to load."), |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
307 plugin->info->name); |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
308 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
309 gaim_notify_error(NULL, NULL, |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
310 _("Gaim was unable to load your plugin."), |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
311 buf); |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
312 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
313 if (dep_list != NULL) |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
314 g_list_free(dep_list); |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
315 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
316 return FALSE; |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
317 } |
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 } |
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 if (dep_list != NULL) |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
322 g_list_free(dep_list); |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
323 |
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
324 if (plugin->native_plugin) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
325 { |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
326 if (plugin->info != NULL && plugin->info->load != NULL) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
327 { |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
328 if (!plugin->info->load(plugin)) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
329 return FALSE; |
5357
2a1c92df7024
[gaim-migrate @ 5733]
Christian Hammond <chipx86@chipx86.com>
parents:
5270
diff
changeset
|
330 } |
5205 | 331 } |
332 else { | |
333 GaimPlugin *loader; | |
334 GaimPluginLoaderInfo *loader_info; | |
335 | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
336 loader = find_loader_for_plugin(plugin); |
5205 | 337 |
338 if (loader == NULL) | |
339 return FALSE; | |
340 | |
341 loader_info = GAIM_PLUGIN_LOADER_INFO(loader); | |
342 | |
343 if (loader_info->load != NULL) | |
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
344 { |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
345 if (!loader_info->load(plugin)) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
346 return FALSE; |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
347 } |
5205 | 348 } |
349 | |
350 loaded_plugins = g_list_append(loaded_plugins, plugin); | |
351 | |
352 plugin->loaded = TRUE; | |
353 | |
354 /* TODO */ | |
355 if (load_cb != NULL) | |
356 load_cb(plugin, load_cb_data); | |
357 | |
358 return TRUE; | |
359 | |
360 #else | |
5449 | 361 return TRUE; |
5205 | 362 #endif /* !GAIM_PLUGINS */ |
363 } | |
364 | |
365 gboolean | |
366 gaim_plugin_unload(GaimPlugin *plugin) | |
367 { | |
368 #ifdef GAIM_PLUGINS | |
369 g_return_val_if_fail(plugin != NULL, FALSE); | |
370 | |
371 loaded_plugins = g_list_remove(loaded_plugins, plugin); | |
372 | |
373 g_return_val_if_fail(gaim_plugin_is_loaded(plugin), FALSE); | |
374 | |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
375 gaim_debug(GAIM_DEBUG_INFO, "plugins", "Unloading plugin %s\n", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
376 plugin->info->name); |
5205 | 377 |
378 /* cancel any pending dialogs the plugin has */ | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5450
diff
changeset
|
379 gaim_request_close_with_handle(plugin); |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5450
diff
changeset
|
380 gaim_notify_close_with_handle(plugin); |
5205 | 381 |
382 plugin->loaded = FALSE; | |
383 | |
384 if (plugin->native_plugin) { | |
385 if (plugin->info->unload != NULL) | |
386 plugin->info->unload(plugin); | |
387 | |
388 if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) { | |
389 GaimPluginProtocolInfo *prpl_info; | |
390 GList *l; | |
391 | |
392 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); | |
393 | |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
394 for (l = prpl_info->user_splits; l != NULL; l = l->next) |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
395 gaim_account_user_split_destroy(l->data); |
5205 | 396 |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
397 for (l = prpl_info->protocol_options; l != NULL; l = l->next) |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
398 gaim_account_option_destroy(l->data); |
5205 | 399 |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
400 if (prpl_info->user_splits != NULL) |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
401 g_list_free(prpl_info->user_splits); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
402 |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
403 if (prpl_info->protocol_options != NULL) |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
404 g_list_free(prpl_info->protocol_options); |
5205 | 405 } |
406 } | |
407 else { | |
408 GaimPlugin *loader; | |
409 GaimPluginLoaderInfo *loader_info; | |
410 | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
411 loader = find_loader_for_plugin(plugin); |
5205 | 412 |
413 if (loader == NULL) | |
414 return FALSE; | |
415 | |
416 loader_info = GAIM_PLUGIN_LOADER_INFO(loader); | |
417 | |
418 if (loader_info->load != NULL) | |
419 loader_info->unload(plugin); | |
420 } | |
421 | |
422 gaim_signals_disconnect_by_handle(plugin); | |
6822
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
423 gaim_plugin_ipc_unregister_all(plugin); |
5205 | 424 |
425 /* TODO */ | |
426 if (unload_cb != NULL) | |
427 unload_cb(plugin, unload_cb_data); | |
428 | |
429 return TRUE; | |
5449 | 430 #else |
431 return TRUE; | |
5205 | 432 #endif /* GAIM_PLUGINS */ |
433 } | |
434 | |
435 gboolean | |
436 gaim_plugin_reload(GaimPlugin *plugin) | |
437 { | |
438 #ifdef GAIM_PLUGINS | |
439 g_return_val_if_fail(plugin != NULL, FALSE); | |
440 g_return_val_if_fail(gaim_plugin_is_loaded(plugin), FALSE); | |
441 | |
442 if (!gaim_plugin_unload(plugin)) | |
443 return FALSE; | |
444 | |
445 if (!gaim_plugin_load(plugin)) | |
446 return FALSE; | |
447 | |
448 return TRUE; | |
449 #else | |
5449 | 450 return TRUE; |
5205 | 451 #endif /* !GAIM_PLUGINS */ |
452 } | |
453 | |
454 void | |
455 gaim_plugin_destroy(GaimPlugin *plugin) | |
456 { | |
5449 | 457 #ifdef GAIM_PLUGINS |
5205 | 458 g_return_if_fail(plugin != NULL); |
459 | |
460 if (gaim_plugin_is_loaded(plugin)) | |
461 gaim_plugin_unload(plugin); | |
462 | |
463 plugins = g_list_remove(plugins, plugin); | |
464 | |
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
465 if (load_queue != NULL) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
466 load_queue = g_list_remove(load_queue, plugin); |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
467 |
5243
f6e0c689a88b
[gaim-migrate @ 5614]
Christian Hammond <chipx86@chipx86.com>
parents:
5242
diff
changeset
|
468 if (plugin->info != NULL && plugin->info->dependencies != NULL) |
f6e0c689a88b
[gaim-migrate @ 5614]
Christian Hammond <chipx86@chipx86.com>
parents:
5242
diff
changeset
|
469 g_list_free(plugin->info->dependencies); |
5205 | 470 |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
471 if (plugin->native_plugin) |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
472 { |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
473 if (plugin->info != NULL && plugin->info->type == GAIM_PLUGIN_LOADER) |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
474 { |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
475 GaimPluginLoaderInfo *loader_info; |
5205 | 476 GList *exts, *l, *next_l; |
477 GaimPlugin *p2; | |
478 | |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
479 loader_info = GAIM_PLUGIN_LOADER_INFO(plugin); |
5205 | 480 |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
481 if (loader_info != NULL && plugin->info->api_version >= 3 && |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
482 loader_info->exts != NULL) |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
483 { |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
484 for (exts = GAIM_PLUGIN_LOADER_INFO(plugin)->exts; |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
485 exts != NULL; |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
486 exts = exts->next) { |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
487 |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
488 for (l = gaim_plugins_get_all(); l != NULL; l = next_l) |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
489 { |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
490 next_l = l->next; |
5205 | 491 |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
492 p2 = l->data; |
5205 | 493 |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
494 if (p2->path != NULL && |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
495 is_so_file(p2->path, exts->data)) |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
496 { |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
497 gaim_plugin_destroy(p2); |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
498 } |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
499 } |
5205 | 500 } |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
501 |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
502 g_list_free(loader_info->exts); |
5205 | 503 } |
504 | |
505 plugin_loaders = g_list_remove(plugin_loaders, plugin); | |
506 } | |
507 | |
508 if (plugin->info != NULL && plugin->info->destroy != NULL) | |
509 plugin->info->destroy(plugin); | |
510 | |
511 if (plugin->handle != NULL) | |
512 g_module_close(plugin->handle); | |
513 } | |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
514 else |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
515 { |
5205 | 516 GaimPlugin *loader; |
517 GaimPluginLoaderInfo *loader_info; | |
518 | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
519 loader = find_loader_for_plugin(plugin); |
5205 | 520 |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
521 if (loader != NULL) |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
522 { |
5941
a3e60ff95b7d
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
523 loader_info = GAIM_PLUGIN_LOADER_INFO(loader); |
5205 | 524 |
5941
a3e60ff95b7d
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
525 if (loader_info->destroy != NULL) |
a3e60ff95b7d
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
526 loader_info->destroy(plugin); |
a3e60ff95b7d
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
527 } |
5205 | 528 } |
529 | |
530 if (plugin->path != NULL) g_free(plugin->path); | |
531 if (plugin->error != NULL) g_free(plugin->error); | |
532 | |
533 g_free(plugin); | |
5449 | 534 #endif /* !GAIM_PLUGINS */ |
5205 | 535 } |
536 | |
537 gboolean | |
538 gaim_plugin_is_loaded(const GaimPlugin *plugin) | |
539 { | |
540 g_return_val_if_fail(plugin != NULL, FALSE); | |
541 | |
542 return plugin->loaded; | |
543 } | |
544 | |
6822
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
545 /************************************************************************** |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
546 * Plugin IPC |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
547 **************************************************************************/ |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
548 static void |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
549 destroy_ipc_info(void *data) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
550 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
551 GaimPluginIpcCommand *ipc_command = (GaimPluginIpcCommand *)data; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
552 int i; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
553 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
554 for (i = 0; i < ipc_command->num_params; i++) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
555 gaim_value_destroy(ipc_command->params[i]); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
556 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
557 if (ipc_command->ret_value != NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
558 gaim_value_destroy(ipc_command->ret_value); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
559 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
560 g_free(ipc_command); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
561 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
562 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
563 gboolean |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
564 gaim_plugin_ipc_register(GaimPlugin *plugin, const char *command, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
565 GaimCallback func, GaimSignalMarshalFunc marshal, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
566 GaimValue *ret_value, int num_params, ...) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
567 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
568 GaimPluginIpcInfo *ipc_info; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
569 GaimPluginIpcCommand *ipc_command; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
570 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
571 g_return_val_if_fail(plugin != NULL, FALSE); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
572 g_return_val_if_fail(command != NULL, FALSE); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
573 g_return_val_if_fail(func != NULL, FALSE); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
574 g_return_val_if_fail(marshal != NULL, FALSE); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
575 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
576 if (plugin->ipc_data == NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
577 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
578 ipc_info = plugin->ipc_data = g_new0(GaimPluginIpcInfo, 1); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
579 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
|
580 g_free, destroy_ipc_info); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
581 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
582 else |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
583 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
584 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
585 ipc_command = g_new0(GaimPluginIpcCommand, 1); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
586 ipc_command->func = func; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
587 ipc_command->marshal = marshal; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
588 ipc_command->num_params = num_params; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
589 ipc_command->ret_value = ret_value; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
590 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
591 if (num_params > 0) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
592 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
593 va_list args; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
594 int i; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
595 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
596 ipc_command->params = g_new0(GaimValue *, num_params); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
597 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
598 va_start(args, num_params); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
599 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
600 for (i = 0; i < num_params; i++) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
601 ipc_command->params[i] = va_arg(args, GaimValue *); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
602 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
603 va_end(args); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
604 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
605 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
606 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
|
607 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
608 ipc_info->command_count++; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
609 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
610 return TRUE; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
611 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
612 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
613 void |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
614 gaim_plugin_ipc_unregister(GaimPlugin *plugin, const char *command) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
615 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
616 GaimPluginIpcInfo *ipc_info; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
617 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
618 g_return_if_fail(plugin != NULL); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
619 g_return_if_fail(command != NULL); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
620 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
621 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
622 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
623 if (ipc_info == NULL || |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
624 g_hash_table_lookup(ipc_info->commands, command) == NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
625 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
626 gaim_debug_error("plugins", |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
627 "IPC command '%s' was not registered for plugin %s\n", |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
628 command, plugin->info->name); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
629 return; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
630 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
631 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
632 g_hash_table_remove(ipc_info->commands, command); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
633 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
634 ipc_info->command_count--; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
635 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
636 if (ipc_info->command_count == 0) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
637 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
638 g_hash_table_destroy(ipc_info->commands); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
639 g_free(ipc_info); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
640 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
641 plugin->ipc_data = NULL; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
642 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
643 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
644 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
645 void |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
646 gaim_plugin_ipc_unregister_all(GaimPlugin *plugin) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
647 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
648 GaimPluginIpcInfo *ipc_info; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
649 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
650 g_return_if_fail(plugin != NULL); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
651 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
652 if (plugin->ipc_data == NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
653 return; /* Silently ignore it. */ |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
654 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
655 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
656 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
657 g_hash_table_destroy(ipc_info->commands); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
658 g_free(ipc_info); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
659 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
660 plugin->ipc_data = NULL; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
661 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
662 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
663 gboolean |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
664 gaim_plugin_ipc_get_params(GaimPlugin *plugin, const char *command, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
665 GaimValue **ret_value, int *num_params, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
666 GaimValue ***params) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
667 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
668 GaimPluginIpcInfo *ipc_info; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
669 GaimPluginIpcCommand *ipc_command; |
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 g_return_val_if_fail(plugin != NULL, FALSE); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
672 g_return_val_if_fail(command != NULL, FALSE); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
673 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
674 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_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 if (ipc_info == NULL || |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
677 (ipc_command = g_hash_table_lookup(ipc_info->commands, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
678 command)) == NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
679 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
680 gaim_debug_error("plugins", |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
681 "IPC command '%s' was not registered for plugin %s\n", |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
682 command, plugin->info->name); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
683 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
684 return FALSE; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
685 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
686 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
687 if (num_params != NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
688 *num_params = ipc_command->num_params; |
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 if (params != NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
691 *params = ipc_command->params; |
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 if (ret_value != NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
694 *ret_value = ipc_command->ret_value; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
695 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
696 return TRUE; |
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 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
699 void * |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
700 gaim_plugin_ipc_call(GaimPlugin *plugin, const char *command, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
701 gboolean *ok, ...) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
702 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
703 GaimPluginIpcInfo *ipc_info; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
704 GaimPluginIpcCommand *ipc_command; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
705 va_list args; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
706 void *ret_value; |
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 if (ok != NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
709 *ok = FALSE; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
710 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
711 g_return_val_if_fail(plugin != NULL, NULL); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
712 g_return_val_if_fail(command != NULL, NULL); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
713 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
714 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
715 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
716 if (ipc_info == NULL || |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
717 (ipc_command = g_hash_table_lookup(ipc_info->commands, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
718 command)) == NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
719 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
720 gaim_debug_error("plugins", |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
721 "IPC command '%s' was not registered for plugin %s\n", |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
722 command, plugin->info->name); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
723 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
724 return NULL; |
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 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
727 va_start(args, ok); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
728 ipc_command->marshal(ipc_command->func, args, NULL, &ret_value); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
729 va_end(args); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
730 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
731 if (ok != NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
732 *ok = TRUE; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
733 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
734 return ret_value; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
735 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
736 |
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 * Plugins subsystem |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
739 **************************************************************************/ |
5205 | 740 void |
741 gaim_plugins_set_search_paths(size_t count, char **paths) | |
742 { | |
743 size_t s; | |
744 | |
745 g_return_if_fail(count > 0); | |
746 g_return_if_fail(paths != NULL); | |
747 | |
748 if (search_paths != NULL) { | |
749 for (s = 0; s < search_path_count; s++) | |
750 g_free(search_paths[s]); | |
751 | |
752 g_free(search_paths); | |
753 } | |
754 | |
755 search_paths = g_new0(char *, count); | |
756 | |
757 for (s = 0; s < count; s++) { | |
758 if (paths[s] == NULL) | |
759 search_paths[s] = NULL; | |
760 else | |
761 search_paths[s] = g_strdup(paths[s]); | |
762 } | |
763 | |
764 search_path_count = count; | |
765 } | |
766 | |
767 void | |
768 gaim_plugins_unload_all(void) | |
769 { | |
770 #ifdef GAIM_PLUGINS | |
771 | |
772 while (loaded_plugins != NULL) | |
773 gaim_plugin_unload(loaded_plugins->data); | |
774 | |
775 #endif /* GAIM_PLUGINS */ | |
776 } | |
777 | |
778 void | |
5242
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
779 gaim_plugins_destroy_all(void) |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
780 { |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
781 #ifdef GAIM_PLUGINS |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
782 |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
783 while (plugins != NULL) |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
784 gaim_plugin_destroy(plugins->data); |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
785 |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
786 #endif /* GAIM_PLUGINS */ |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
787 } |
5838 | 788 |
789 void | |
5949
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
790 gaim_plugins_load_saved(const char *key) |
5838 | 791 { |
792 #ifdef GAIM_PLUGINS | |
5949
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
793 GList *f, *files; |
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
794 |
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
795 g_return_if_fail(key != NULL); |
5838 | 796 |
5949
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
797 files = gaim_prefs_get_string_list(key); |
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
798 |
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
799 for (f = files; f; f = f->next) |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
800 { |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
801 char *filename = g_path_get_basename(f->data); |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
802 GaimPlugin *plugin = NULL; |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
803 |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
804 if (filename != NULL) |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
805 { |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
806 if ((plugin = gaim_plugins_find_with_basename(filename)) != NULL) |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
807 { |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
808 gaim_debug_info("plugins", "Loading saved plugin %s\n", |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
809 filename); |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
810 gaim_plugin_load(plugin); |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
811 } |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
812 else |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
813 { |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
814 gaim_debug_error("plugins", "Unable to find saved plugin %s\n", |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
815 filename); |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
816 } |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
817 |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
818 g_free(filename); |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
819 } |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
820 |
5838 | 821 g_free(f->data); |
822 } | |
823 | |
824 g_list_free(files); | |
825 #endif /* GAIM_PLUGINS */ | |
826 } | |
827 | |
828 | |
5242
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
829 void |
5205 | 830 gaim_plugins_probe(const char *ext) |
831 { | |
832 #ifdef GAIM_PLUGINS | |
833 GDir *dir; | |
834 const gchar *file; | |
835 gchar *path; | |
836 GaimPlugin *plugin; | |
837 size_t i; | |
838 | |
839 if (!g_module_supported()) | |
840 return; | |
841 | |
842 for (i = 0; i < search_path_count; i++) { | |
843 if (search_paths[i] == NULL) | |
844 continue; | |
845 | |
846 dir = g_dir_open(search_paths[i], 0, NULL); | |
847 | |
848 if (dir != NULL) { | |
849 while ((file = g_dir_read_name(dir)) != NULL) { | |
850 path = g_build_filename(search_paths[i], file, NULL); | |
851 | |
852 if (ext == NULL || is_so_file(file, ext)) | |
853 plugin = gaim_plugin_probe(path); | |
854 | |
855 g_free(path); | |
856 } | |
857 | |
858 g_dir_close(dir); | |
859 } | |
860 } | |
861 | |
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
862 /* See if we have any plugins waiting to load. */ |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
863 while (load_queue != NULL) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
864 { |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
865 plugin = (GaimPlugin *)load_queue->data; |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
866 |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
867 load_queue = g_list_remove(load_queue, plugin); |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
868 |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
869 if (plugin == NULL || plugin->info == NULL) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
870 continue; |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
871 |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
872 if (plugin->info->type == GAIM_PLUGIN_LOADER) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
873 { |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
874 GList *exts; |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
875 |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
876 /* We'll just load this right now. */ |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
877 if (!gaim_plugin_load(plugin)) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
878 { |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
879 gaim_plugin_destroy(plugin); |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
880 |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
881 continue; |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
882 } |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
883 |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
884 plugin_loaders = g_list_append(plugin_loaders, plugin); |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
885 |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
886 for (exts = GAIM_PLUGIN_LOADER_INFO(plugin)->exts; |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
887 exts != NULL; |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
888 exts = exts->next) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
889 { |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
890 gaim_plugins_probe(exts->data); |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
891 } |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
892 } |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
893 else if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
894 { |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
895 /* We'll just load this right now. */ |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
896 if (!gaim_plugin_load(plugin)) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
897 { |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
898 gaim_plugin_destroy(plugin); |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
899 |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
900 continue; |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
901 } |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
902 |
7956 | 903 if (gaim_find_prpl(plugin->info->id)) |
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
904 { |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
905 /* Nothing to see here--move along, move along */ |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
906 gaim_plugin_destroy(plugin); |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
907 |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
908 continue; |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
909 } |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
910 |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
911 protocol_plugins = g_list_insert_sorted(protocol_plugins, plugin, |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
912 (GCompareFunc)compare_prpl); |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
913 } |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
914 } |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
915 |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
916 if (load_queue != NULL) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
917 { |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
918 g_list_free(load_queue); |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
919 load_queue = NULL; |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
920 } |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
921 |
5205 | 922 if (probe_cb != NULL) |
923 probe_cb(probe_cb_data); | |
924 | |
925 #endif /* GAIM_PLUGINS */ | |
926 } | |
927 | |
928 gboolean | |
929 gaim_plugin_register(GaimPlugin *plugin) | |
930 { | |
931 g_return_val_if_fail(plugin != NULL, FALSE); | |
932 | |
933 if (g_list_find(plugins, plugin)) | |
934 return TRUE; | |
935 | |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
936 if (plugin->info->type == GAIM_PLUGIN_LOADER) |
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
937 { |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
938 GaimPluginLoaderInfo *loader_info; |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
939 |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
940 loader_info = GAIM_PLUGIN_LOADER_INFO(plugin); |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
941 |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
942 if (loader_info == NULL || |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
943 loader_info->api_version != GAIM_LOADER_API_VERSION) |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
944 { |
8759
184b8c3b6d09
[gaim-migrate @ 9514]
Christian Hammond <chipx86@chipx86.com>
parents:
8749
diff
changeset
|
945 gaim_debug(GAIM_DEBUG_ERROR, "plugins", "%s is unloadable: API version mismatch %d (need %d)\n", |
184b8c3b6d09
[gaim-migrate @ 9514]
Christian Hammond <chipx86@chipx86.com>
parents:
8749
diff
changeset
|
946 plugin->path, loader_info->api_version, GAIM_LOADER_API_VERSION); |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
947 return FALSE; |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
948 } |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
949 |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
950 load_queue = g_list_append(load_queue, plugin); |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
951 } |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
952 else if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
953 { |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
954 GaimPluginProtocolInfo *prpl_info; |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
955 |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
956 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
957 |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
958 if (prpl_info == NULL || |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
959 prpl_info->api_version != GAIM_PRPL_API_VERSION) |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
960 { |
8759
184b8c3b6d09
[gaim-migrate @ 9514]
Christian Hammond <chipx86@chipx86.com>
parents:
8749
diff
changeset
|
961 gaim_debug(GAIM_DEBUG_ERROR, "plugins", "%s is unloadable: API version mismatch %d (need %d)\n", |
184b8c3b6d09
[gaim-migrate @ 9514]
Christian Hammond <chipx86@chipx86.com>
parents:
8749
diff
changeset
|
962 plugin->path, prpl_info->api_version, GAIM_PRPL_API_VERSION); |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
963 return FALSE; |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
964 } |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
965 |
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
966 load_queue = g_list_append(load_queue, plugin); |
5205 | 967 } |
968 | |
969 plugins = g_list_append(plugins, plugin); | |
970 | |
971 return TRUE; | |
972 } | |
973 | |
974 gboolean | |
975 gaim_plugins_enabled(void) | |
976 { | |
977 #ifdef GAIM_PLUGINS | |
978 return TRUE; | |
979 #else | |
980 return FALSE; | |
981 #endif | |
982 } | |
983 | |
984 void | |
985 gaim_plugins_register_probe_notify_cb(void (*func)(void *), void *data) | |
986 { | |
987 /* TODO */ | |
988 probe_cb = func; | |
989 probe_cb_data = data; | |
990 } | |
991 | |
992 void | |
993 gaim_plugins_unregister_probe_notify_cb(void (*func)(void *)) | |
994 { | |
995 /* TODO */ | |
996 probe_cb = NULL; | |
997 probe_cb_data = NULL; | |
998 } | |
999 | |
1000 void | |
1001 gaim_plugins_register_load_notify_cb(void (*func)(GaimPlugin *, void *), | |
1002 void *data) | |
1003 { | |
1004 /* TODO */ | |
1005 load_cb = func; | |
1006 load_cb_data = data; | |
1007 } | |
1008 | |
1009 void | |
1010 gaim_plugins_unregister_load_notify_cb(void (*func)(GaimPlugin *, void *)) | |
1011 { | |
1012 /* TODO */ | |
1013 load_cb = NULL; | |
1014 load_cb_data = NULL; | |
1015 } | |
1016 | |
1017 void | |
1018 gaim_plugins_register_unload_notify_cb(void (*func)(GaimPlugin *, void *), | |
1019 void *data) | |
1020 { | |
1021 /* TODO */ | |
1022 unload_cb = func; | |
1023 unload_cb_data = data; | |
1024 } | |
1025 | |
1026 void | |
1027 gaim_plugins_unregister_unload_notify_cb(void (*func)(GaimPlugin *, void *)) | |
1028 { | |
1029 /* TODO */ | |
1030 unload_cb = NULL; | |
1031 unload_cb_data = NULL; | |
1032 } | |
1033 | |
1034 GaimPlugin * | |
1035 gaim_plugins_find_with_name(const char *name) | |
1036 { | |
1037 GaimPlugin *plugin; | |
1038 GList *l; | |
1039 | |
1040 for (l = plugins; l != NULL; l = l->next) { | |
1041 plugin = l->data; | |
1042 | |
1043 if (!strcmp(plugin->info->name, name)) | |
1044 return plugin; | |
1045 } | |
1046 | |
1047 return NULL; | |
1048 } | |
1049 | |
1050 GaimPlugin * | |
1051 gaim_plugins_find_with_filename(const char *filename) | |
1052 { | |
1053 GaimPlugin *plugin; | |
1054 GList *l; | |
1055 | |
1056 for (l = plugins; l != NULL; l = l->next) { | |
1057 plugin = l->data; | |
1058 | |
1059 if (plugin->path != NULL && !strcmp(plugin->path, filename)) | |
1060 return plugin; | |
1061 } | |
1062 | |
1063 return NULL; | |
1064 } | |
1065 | |
1066 GaimPlugin * | |
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1067 gaim_plugins_find_with_basename(const char *basename) |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1068 { |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1069 GaimPlugin *plugin; |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1070 GList *l; |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1071 |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1072 g_return_val_if_fail(basename != NULL, NULL); |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1073 |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1074 for (l = plugins; l != NULL; l = l->next) |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1075 { |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1076 char *tmp; |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1077 |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1078 plugin = (GaimPlugin *)l->data; |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1079 |
7278 | 1080 if (plugin->path != NULL) { |
1081 tmp = g_path_get_basename(plugin->path); | |
1082 if (!strcmp(tmp, basename)) { | |
1083 g_free(tmp); | |
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1084 return plugin; |
7278 | 1085 } |
7279 | 1086 g_free(tmp); |
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1087 } |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1088 } |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1089 |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1090 return NULL; |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1091 } |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1092 |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1093 GaimPlugin * |
5205 | 1094 gaim_plugins_find_with_id(const char *id) |
1095 { | |
1096 GaimPlugin *plugin; | |
1097 GList *l; | |
1098 | |
1099 g_return_val_if_fail(id != NULL, NULL); | |
1100 | |
6486
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1101 for (l = plugins; l != NULL; l = l->next) |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1102 { |
5205 | 1103 plugin = l->data; |
1104 | |
6486
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1105 if (plugin->info->id != NULL && !strcmp(plugin->info->id, id)) |
5205 | 1106 return plugin; |
1107 } | |
1108 | |
1109 return NULL; | |
1110 } | |
1111 | |
1112 GList * | |
1113 gaim_plugins_get_loaded(void) | |
1114 { | |
1115 return loaded_plugins; | |
1116 } | |
1117 | |
1118 GList * | |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1119 gaim_plugins_get_protocols(void) |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1120 { |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1121 return protocol_plugins; |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1122 } |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1123 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1124 GList * |
5205 | 1125 gaim_plugins_get_all(void) |
1126 { | |
1127 return plugins; | |
1128 } | |
1129 |