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