Mercurial > pidgin.yaz
annotate src/plugin.c @ 7499:e71678bfbe3f
[gaim-migrate @ 8112]
italian
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Thu, 13 Nov 2003 11:44:20 +0000 |
parents | 0d24c94e4fbc |
children | 1b8261f374ea |
rev | line source |
---|---|
5205 | 1 /* |
2 * gaim | |
3 * | |
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
20 #include "internal.h" |
5205 | 21 |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
22 #include "accountopt.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
23 #include "debug.h" |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5357
diff
changeset
|
24 #include "notify.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
25 #include "prefs.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
26 #include "prpl.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
27 #include "request.h" |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6432
diff
changeset
|
28 #include "signals.h" |
5205 | 29 |
30 #ifdef _WIN32 | |
31 # define PLUGIN_EXT ".dll" | |
32 #else | |
6639 | 33 #ifdef __hpux |
34 # define PLUGIN_EXT ".sl" | |
35 #else | |
5205 | 36 # define PLUGIN_EXT ".so" |
37 #endif | |
6639 | 38 #endif |
5205 | 39 |
6822
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
40 typedef struct |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
41 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
42 GHashTable *commands; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
43 size_t command_count; |
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 } GaimPluginIpcInfo; |
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 typedef struct |
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 GaimCallback func; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
50 GaimSignalMarshalFunc marshal; |
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 int num_params; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
53 GaimValue **params; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
54 GaimValue *ret_value; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
55 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
56 } GaimPluginIpcCommand; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
57 |
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
58 static GList *loaded_plugins = NULL; |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
59 static GList *plugins = NULL; |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
60 static GList *plugin_loaders = NULL; |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
61 static GList *protocol_plugins = NULL; |
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
62 static GList *load_queue = NULL; |
5205 | 63 |
64 static size_t search_path_count = 0; | |
65 static char **search_paths = NULL; | |
66 | |
67 static void (*probe_cb)(void *) = NULL; | |
68 static void *probe_cb_data = NULL; | |
69 static void (*load_cb)(GaimPlugin *, void *) = NULL; | |
70 static void *load_cb_data = NULL; | |
71 static void (*unload_cb)(GaimPlugin *, void *) = NULL; | |
72 static void *unload_cb_data = NULL; | |
73 | |
74 #ifdef GAIM_PLUGINS | |
75 static int | |
76 is_so_file(const char *filename, const char *ext) | |
77 { | |
78 int len, extlen; | |
79 | |
80 if (filename == NULL || *filename == '\0' || ext == NULL) | |
81 return 0; | |
82 | |
83 extlen = strlen(ext); | |
84 len = strlen(filename) - extlen; | |
85 | |
86 if (len < 0) | |
87 return 0; | |
88 | |
89 return (!strncmp(filename + len, ext, extlen)); | |
90 } | |
91 | |
92 static gboolean | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
93 loader_supports_file(GaimPlugin *loader, const char *filename) |
5205 | 94 { |
6432 | 95 GList *exts; |
5205 | 96 |
6432 | 97 for (exts = GAIM_PLUGIN_LOADER_INFO(loader)->exts; exts != NULL; exts = exts->next) { |
98 if (is_so_file(filename, (char *)exts->data)) { | |
99 return TRUE; | |
5205 | 100 } |
101 } | |
102 | |
103 return FALSE; | |
104 } | |
105 | |
106 static GaimPlugin * | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
107 find_loader_for_plugin(const GaimPlugin *plugin) |
5205 | 108 { |
109 GaimPlugin *loader; | |
110 GList *l; | |
111 | |
112 if (plugin->path == NULL) | |
113 return NULL; | |
114 | |
115 for (l = gaim_plugins_get_loaded(); l != NULL; l = l->next) { | |
116 loader = l->data; | |
117 | |
118 if (loader->info->type == GAIM_PLUGIN_LOADER && | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
119 loader_supports_file(loader, plugin->path)) { |
5205 | 120 |
121 return loader; | |
122 } | |
123 | |
124 loader = NULL; | |
125 } | |
126 | |
127 return NULL; | |
128 } | |
129 | |
5449 | 130 #endif /* GAIM_PLUGINS */ |
131 | |
5205 | 132 static gint |
133 compare_prpl(GaimPlugin *a, GaimPlugin *b) | |
134 { | |
135 /* neg if a before b, 0 if equal, pos if a after b */ | |
136 return ((GAIM_IS_PROTOCOL_PLUGIN(a) | |
137 ? GAIM_PLUGIN_PROTOCOL_INFO(a)->protocol : -1) - | |
138 ((GAIM_IS_PROTOCOL_PLUGIN(b) | |
139 ? GAIM_PLUGIN_PROTOCOL_INFO(b)->protocol : -1))); | |
140 } | |
141 | |
142 GaimPlugin * | |
143 gaim_plugin_new(gboolean native, const char *path) | |
144 { | |
145 GaimPlugin *plugin; | |
146 | |
147 plugin = g_new0(GaimPlugin, 1); | |
148 | |
149 plugin->native_plugin = native; | |
150 plugin->path = (path == NULL ? NULL : g_strdup(path)); | |
151 | |
152 return plugin; | |
153 } | |
154 | |
155 GaimPlugin * | |
156 gaim_plugin_probe(const char *filename) | |
157 { | |
158 #ifdef GAIM_PLUGINS | |
159 GaimPlugin *plugin = NULL; | |
160 GaimPlugin *loader; | |
161 gboolean (*gaim_init_plugin)(GaimPlugin *); | |
162 | |
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
163 gaim_debug_misc("plugins", "probing %s\n", filename); |
5205 | 164 g_return_val_if_fail(filename != NULL, NULL); |
165 | |
5973 | 166 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) |
167 return NULL; | |
168 | |
5205 | 169 plugin = gaim_plugins_find_with_filename(filename); |
170 | |
171 if (plugin != NULL) | |
172 return plugin; | |
173 | |
174 plugin = gaim_plugin_new(is_so_file(filename, PLUGIN_EXT), filename); | |
175 | |
176 if (plugin->native_plugin) { | |
5450 | 177 const char *error; |
5205 | 178 plugin->handle = g_module_open(filename, 0); |
179 | |
180 if (plugin->handle == NULL) { | |
5443 | 181 error = g_module_error(); |
5269
cd7e4ba049f9
[gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents:
5268
diff
changeset
|
182 gaim_debug(GAIM_DEBUG_ERROR, "plugins", "%s is unloadable: %s\n", |
5443 | 183 plugin->path, error ? error : "Unknown error."); |
5205 | 184 |
5269
cd7e4ba049f9
[gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents:
5268
diff
changeset
|
185 gaim_plugin_destroy(plugin); |
cd7e4ba049f9
[gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents:
5268
diff
changeset
|
186 |
cd7e4ba049f9
[gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents:
5268
diff
changeset
|
187 return NULL; |
5205 | 188 } |
189 | |
190 if (!g_module_symbol(plugin->handle, "gaim_init_plugin", | |
191 (gpointer *)&gaim_init_plugin)) { | |
192 g_module_close(plugin->handle); | |
193 plugin->handle = NULL; | |
194 | |
5443 | 195 error = g_module_error(); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
196 gaim_debug(GAIM_DEBUG_ERROR, "plugins", "%s is unloadable: %s\n", |
5443 | 197 plugin->path, error ? error : "Unknown error."); |
5205 | 198 |
199 gaim_plugin_destroy(plugin); | |
200 | |
201 return NULL; | |
202 } | |
203 } | |
204 else { | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
205 loader = find_loader_for_plugin(plugin); |
5205 | 206 |
207 if (loader == NULL) { | |
208 gaim_plugin_destroy(plugin); | |
209 | |
210 return NULL; | |
211 } | |
212 | |
213 gaim_init_plugin = GAIM_PLUGIN_LOADER_INFO(loader)->probe; | |
214 } | |
215 | |
216 plugin->error = NULL; | |
217 | |
218 if (!gaim_init_plugin(plugin) || plugin->info == NULL) { | |
219 gaim_plugin_destroy(plugin); | |
220 | |
221 return NULL; | |
222 } | |
223 | |
224 return plugin; | |
225 #else | |
226 return NULL; | |
227 #endif /* !GAIM_PLUGINS */ | |
228 } | |
229 | |
230 gboolean | |
231 gaim_plugin_load(GaimPlugin *plugin) | |
232 { | |
233 #ifdef GAIM_PLUGINS | |
6486
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
234 GList *dep_list = NULL; |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
235 GList *l; |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
236 |
5205 | 237 g_return_val_if_fail(plugin != NULL, FALSE); |
5270
d1fe8e320dab
[gaim-migrate @ 5642]
Christian Hammond <chipx86@chipx86.com>
parents:
5269
diff
changeset
|
238 g_return_val_if_fail(plugin->error == NULL, FALSE); |
5205 | 239 |
240 if (gaim_plugin_is_loaded(plugin)) | |
241 return TRUE; | |
242 | |
6486
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
243 /* |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
244 * Go through the list of the plugin's dependencies. |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
245 * |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
246 * First pass: Make sure all the plugins needed are probed. |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
247 */ |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
248 for (l = plugin->info->dependencies; l != NULL; l = l->next) |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
249 { |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
250 const char *dep_name = (const char *)l->data; |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
251 GaimPlugin *dep_plugin; |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
252 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
253 dep_plugin = gaim_plugins_find_with_id(dep_name); |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
254 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
255 if (dep_plugin == NULL) |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
256 { |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
257 char buf[BUFSIZ]; |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
258 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
259 g_snprintf(buf, sizeof(buf), |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
260 _("The required plugin %s was not found. " |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
261 "Please install this plugin and try again."), |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
262 dep_name); |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
263 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
264 gaim_notify_error(NULL, NULL, |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
265 _("Gaim was unable to load your plugin."), |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
266 buf); |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
267 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
268 if (dep_list != NULL) |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
269 g_list_free(dep_list); |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
270 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
271 return FALSE; |
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 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
274 dep_list = g_list_append(dep_list, dep_plugin); |
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 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
277 /* Second pass: load all the required plugins. */ |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
278 for (l = dep_list; l != NULL; l = l->next) |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
279 { |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
280 GaimPlugin *dep_plugin = (GaimPlugin *)l->data; |
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 if (!gaim_plugin_is_loaded(dep_plugin)) |
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 (!gaim_plugin_load(dep_plugin)) |
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 unable to load."), |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
290 plugin->info->name); |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
291 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
292 gaim_notify_error(NULL, NULL, |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
293 _("Gaim was unable to load your plugin."), |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
294 buf); |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
295 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
296 if (dep_list != NULL) |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
297 g_list_free(dep_list); |
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 return FALSE; |
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 } |
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 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
304 if (dep_list != NULL) |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
305 g_list_free(dep_list); |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
306 |
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
307 if (plugin->native_plugin) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
308 { |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
309 if (plugin->info != NULL && plugin->info->load != NULL) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
310 { |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
311 if (!plugin->info->load(plugin)) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
312 return FALSE; |
5357
2a1c92df7024
[gaim-migrate @ 5733]
Christian Hammond <chipx86@chipx86.com>
parents:
5270
diff
changeset
|
313 } |
5205 | 314 } |
315 else { | |
316 GaimPlugin *loader; | |
317 GaimPluginLoaderInfo *loader_info; | |
318 | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
319 loader = find_loader_for_plugin(plugin); |
5205 | 320 |
321 if (loader == NULL) | |
322 return FALSE; | |
323 | |
324 loader_info = GAIM_PLUGIN_LOADER_INFO(loader); | |
325 | |
326 if (loader_info->load != NULL) | |
6981
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 (!loader_info->load(plugin)) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
329 return FALSE; |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
330 } |
5205 | 331 } |
332 | |
333 loaded_plugins = g_list_append(loaded_plugins, plugin); | |
334 | |
335 plugin->loaded = TRUE; | |
336 | |
337 /* TODO */ | |
338 if (load_cb != NULL) | |
339 load_cb(plugin, load_cb_data); | |
340 | |
341 return TRUE; | |
342 | |
343 #else | |
5449 | 344 return TRUE; |
5205 | 345 #endif /* !GAIM_PLUGINS */ |
346 } | |
347 | |
348 gboolean | |
349 gaim_plugin_unload(GaimPlugin *plugin) | |
350 { | |
351 #ifdef GAIM_PLUGINS | |
352 g_return_val_if_fail(plugin != NULL, FALSE); | |
353 | |
354 loaded_plugins = g_list_remove(loaded_plugins, plugin); | |
355 | |
356 g_return_val_if_fail(gaim_plugin_is_loaded(plugin), FALSE); | |
357 | |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
358 gaim_debug(GAIM_DEBUG_INFO, "plugins", "Unloading plugin %s\n", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
359 plugin->info->name); |
5205 | 360 |
361 /* cancel any pending dialogs the plugin has */ | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5450
diff
changeset
|
362 gaim_request_close_with_handle(plugin); |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5450
diff
changeset
|
363 gaim_notify_close_with_handle(plugin); |
5205 | 364 |
365 plugin->loaded = FALSE; | |
366 | |
367 if (plugin->native_plugin) { | |
368 if (plugin->info->unload != NULL) | |
369 plugin->info->unload(plugin); | |
370 | |
371 if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) { | |
372 GaimPluginProtocolInfo *prpl_info; | |
373 GList *l; | |
374 | |
375 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); | |
376 | |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
377 for (l = prpl_info->user_splits; l != NULL; l = l->next) |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
378 gaim_account_user_split_destroy(l->data); |
5205 | 379 |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
380 for (l = prpl_info->protocol_options; l != NULL; l = l->next) |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
381 gaim_account_option_destroy(l->data); |
5205 | 382 |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
383 if (prpl_info->user_splits != NULL) |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
384 g_list_free(prpl_info->user_splits); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
385 |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
386 if (prpl_info->protocol_options != NULL) |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
387 g_list_free(prpl_info->protocol_options); |
5205 | 388 } |
389 } | |
390 else { | |
391 GaimPlugin *loader; | |
392 GaimPluginLoaderInfo *loader_info; | |
393 | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
394 loader = find_loader_for_plugin(plugin); |
5205 | 395 |
396 if (loader == NULL) | |
397 return FALSE; | |
398 | |
399 loader_info = GAIM_PLUGIN_LOADER_INFO(loader); | |
400 | |
401 if (loader_info->load != NULL) | |
402 loader_info->unload(plugin); | |
403 } | |
404 | |
405 gaim_signals_disconnect_by_handle(plugin); | |
6822
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
406 gaim_plugin_ipc_unregister_all(plugin); |
5205 | 407 |
408 /* TODO */ | |
409 if (unload_cb != NULL) | |
410 unload_cb(plugin, unload_cb_data); | |
411 | |
412 return TRUE; | |
5449 | 413 #else |
414 return TRUE; | |
5205 | 415 #endif /* GAIM_PLUGINS */ |
416 } | |
417 | |
418 gboolean | |
419 gaim_plugin_reload(GaimPlugin *plugin) | |
420 { | |
421 #ifdef GAIM_PLUGINS | |
422 g_return_val_if_fail(plugin != NULL, FALSE); | |
423 g_return_val_if_fail(gaim_plugin_is_loaded(plugin), FALSE); | |
424 | |
425 if (!gaim_plugin_unload(plugin)) | |
426 return FALSE; | |
427 | |
428 if (!gaim_plugin_load(plugin)) | |
429 return FALSE; | |
430 | |
431 return TRUE; | |
432 #else | |
5449 | 433 return TRUE; |
5205 | 434 #endif /* !GAIM_PLUGINS */ |
435 } | |
436 | |
437 void | |
438 gaim_plugin_destroy(GaimPlugin *plugin) | |
439 { | |
5449 | 440 #ifdef GAIM_PLUGINS |
5205 | 441 g_return_if_fail(plugin != NULL); |
442 | |
443 if (gaim_plugin_is_loaded(plugin)) | |
444 gaim_plugin_unload(plugin); | |
445 | |
446 plugins = g_list_remove(plugins, plugin); | |
447 | |
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
448 if (load_queue != NULL) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
449 load_queue = g_list_remove(load_queue, plugin); |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
450 |
5243
f6e0c689a88b
[gaim-migrate @ 5614]
Christian Hammond <chipx86@chipx86.com>
parents:
5242
diff
changeset
|
451 if (plugin->info != NULL && plugin->info->dependencies != NULL) |
f6e0c689a88b
[gaim-migrate @ 5614]
Christian Hammond <chipx86@chipx86.com>
parents:
5242
diff
changeset
|
452 g_list_free(plugin->info->dependencies); |
5205 | 453 |
454 if (plugin->native_plugin) { | |
455 | |
456 if (plugin->info != NULL && plugin->info->type == GAIM_PLUGIN_LOADER) { | |
457 GList *exts, *l, *next_l; | |
458 GaimPlugin *p2; | |
459 | |
460 for (exts = GAIM_PLUGIN_LOADER_INFO(plugin)->exts; | |
461 exts != NULL; | |
462 exts = exts->next) { | |
463 | |
464 for (l = gaim_plugins_get_all(); l != NULL; l = next_l) { | |
465 next_l = l->next; | |
466 | |
467 p2 = l->data; | |
468 | |
469 if (p2->path != NULL && is_so_file(p2->path, exts->data)) | |
470 gaim_plugin_destroy(p2); | |
471 } | |
472 } | |
473 | |
474 g_list_free(GAIM_PLUGIN_LOADER_INFO(plugin)->exts); | |
475 | |
476 plugin_loaders = g_list_remove(plugin_loaders, plugin); | |
477 } | |
478 | |
479 if (plugin->info != NULL && plugin->info->destroy != NULL) | |
480 plugin->info->destroy(plugin); | |
481 | |
482 if (plugin->handle != NULL) | |
483 g_module_close(plugin->handle); | |
484 } | |
485 else { | |
486 GaimPlugin *loader; | |
487 GaimPluginLoaderInfo *loader_info; | |
488 | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
489 loader = find_loader_for_plugin(plugin); |
5205 | 490 |
5941
a3e60ff95b7d
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
491 if (loader != NULL) { |
a3e60ff95b7d
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
492 loader_info = GAIM_PLUGIN_LOADER_INFO(loader); |
5205 | 493 |
5941
a3e60ff95b7d
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
494 if (loader_info->destroy != NULL) |
a3e60ff95b7d
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
495 loader_info->destroy(plugin); |
a3e60ff95b7d
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
496 } |
5205 | 497 } |
498 | |
499 if (plugin->path != NULL) g_free(plugin->path); | |
500 if (plugin->error != NULL) g_free(plugin->error); | |
501 | |
502 g_free(plugin); | |
5449 | 503 #endif /* !GAIM_PLUGINS */ |
5205 | 504 } |
505 | |
506 gboolean | |
507 gaim_plugin_is_loaded(const GaimPlugin *plugin) | |
508 { | |
509 g_return_val_if_fail(plugin != NULL, FALSE); | |
510 | |
511 return plugin->loaded; | |
512 } | |
513 | |
6822
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
514 /************************************************************************** |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
515 * Plugin IPC |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
516 **************************************************************************/ |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
517 static void |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
518 destroy_ipc_info(void *data) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
519 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
520 GaimPluginIpcCommand *ipc_command = (GaimPluginIpcCommand *)data; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
521 int i; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
522 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
523 for (i = 0; i < ipc_command->num_params; i++) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
524 gaim_value_destroy(ipc_command->params[i]); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
525 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
526 if (ipc_command->ret_value != NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
527 gaim_value_destroy(ipc_command->ret_value); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
528 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
529 g_free(ipc_command); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
530 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
531 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
532 gboolean |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
533 gaim_plugin_ipc_register(GaimPlugin *plugin, const char *command, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
534 GaimCallback func, GaimSignalMarshalFunc marshal, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
535 GaimValue *ret_value, int num_params, ...) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
536 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
537 GaimPluginIpcInfo *ipc_info; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
538 GaimPluginIpcCommand *ipc_command; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
539 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
540 g_return_val_if_fail(plugin != NULL, FALSE); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
541 g_return_val_if_fail(command != NULL, FALSE); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
542 g_return_val_if_fail(func != NULL, FALSE); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
543 g_return_val_if_fail(marshal != NULL, FALSE); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
544 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
545 if (plugin->ipc_data == NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
546 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
547 ipc_info = plugin->ipc_data = g_new0(GaimPluginIpcInfo, 1); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
548 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
|
549 g_free, destroy_ipc_info); |
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 else |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
552 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; |
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 ipc_command = g_new0(GaimPluginIpcCommand, 1); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
555 ipc_command->func = func; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
556 ipc_command->marshal = marshal; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
557 ipc_command->num_params = num_params; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
558 ipc_command->ret_value = 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 if (num_params > 0) |
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 va_list args; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
563 int i; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
564 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
565 ipc_command->params = g_new0(GaimValue *, num_params); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
566 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
567 va_start(args, num_params); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
568 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
569 for (i = 0; i < num_params; i++) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
570 ipc_command->params[i] = va_arg(args, GaimValue *); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
571 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
572 va_end(args); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
573 } |
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 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
|
576 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
577 ipc_info->command_count++; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
578 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
579 return TRUE; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
580 } |
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 void |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
583 gaim_plugin_ipc_unregister(GaimPlugin *plugin, const char *command) |
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 GaimPluginIpcInfo *ipc_info; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
586 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
587 g_return_if_fail(plugin != NULL); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
588 g_return_if_fail(command != NULL); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
589 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
590 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
591 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
592 if (ipc_info == NULL || |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
593 g_hash_table_lookup(ipc_info->commands, command) == NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
594 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
595 gaim_debug_error("plugins", |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
596 "IPC command '%s' was not registered for plugin %s\n", |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
597 command, plugin->info->name); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
598 return; |
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 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
601 g_hash_table_remove(ipc_info->commands, command); |
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 ipc_info->command_count--; |
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 if (ipc_info->command_count == 0) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
606 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
607 g_hash_table_destroy(ipc_info->commands); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
608 g_free(ipc_info); |
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 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 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
613 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
614 void |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
615 gaim_plugin_ipc_unregister_all(GaimPlugin *plugin) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
616 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
617 GaimPluginIpcInfo *ipc_info; |
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 g_return_if_fail(plugin != 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 if (plugin->ipc_data == NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
622 return; /* Silently ignore it. */ |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
623 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
624 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; |
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 g_hash_table_destroy(ipc_info->commands); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
627 g_free(ipc_info); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
628 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
629 plugin->ipc_data = NULL; |
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 gboolean |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
633 gaim_plugin_ipc_get_params(GaimPlugin *plugin, const char *command, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
634 GaimValue **ret_value, int *num_params, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
635 GaimValue ***params) |
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 GaimPluginIpcInfo *ipc_info; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
638 GaimPluginIpcCommand *ipc_command; |
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_return_val_if_fail(plugin != NULL, FALSE); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
641 g_return_val_if_fail(command != NULL, FALSE); |
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 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; |
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 if (ipc_info == NULL || |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
646 (ipc_command = g_hash_table_lookup(ipc_info->commands, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
647 command)) == NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
648 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
649 gaim_debug_error("plugins", |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
650 "IPC command '%s' was not registered for plugin %s\n", |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
651 command, plugin->info->name); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
652 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
653 return FALSE; |
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 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
656 if (num_params != NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
657 *num_params = ipc_command->num_params; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
658 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
659 if (params != NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
660 *params = ipc_command->params; |
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 if (ret_value != NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
663 *ret_value = ipc_command->ret_value; |
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 return TRUE; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
666 } |
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 void * |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
669 gaim_plugin_ipc_call(GaimPlugin *plugin, const char *command, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
670 gboolean *ok, ...) |
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 GaimPluginIpcInfo *ipc_info; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
673 GaimPluginIpcCommand *ipc_command; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
674 va_list args; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
675 void *ret_value; |
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 if (ok != NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
678 *ok = FALSE; |
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 g_return_val_if_fail(plugin != NULL, NULL); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
681 g_return_val_if_fail(command != NULL, NULL); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
682 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
683 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
684 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
685 if (ipc_info == NULL || |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
686 (ipc_command = g_hash_table_lookup(ipc_info->commands, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
687 command)) == NULL) |
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 gaim_debug_error("plugins", |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
690 "IPC command '%s' was not registered for plugin %s\n", |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
691 command, plugin->info->name); |
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 return NULL; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
694 } |
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 va_start(args, ok); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
697 ipc_command->marshal(ipc_command->func, args, NULL, &ret_value); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
698 va_end(args); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
699 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
700 if (ok != NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
701 *ok = TRUE; |
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 return ret_value; |
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 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
706 /************************************************************************** |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
707 * Plugins subsystem |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
708 **************************************************************************/ |
5205 | 709 void |
710 gaim_plugins_set_search_paths(size_t count, char **paths) | |
711 { | |
712 size_t s; | |
713 | |
714 g_return_if_fail(count > 0); | |
715 g_return_if_fail(paths != NULL); | |
716 | |
717 if (search_paths != NULL) { | |
718 for (s = 0; s < search_path_count; s++) | |
719 g_free(search_paths[s]); | |
720 | |
721 g_free(search_paths); | |
722 } | |
723 | |
724 search_paths = g_new0(char *, count); | |
725 | |
726 for (s = 0; s < count; s++) { | |
727 if (paths[s] == NULL) | |
728 search_paths[s] = NULL; | |
729 else | |
730 search_paths[s] = g_strdup(paths[s]); | |
731 } | |
732 | |
733 search_path_count = count; | |
734 } | |
735 | |
736 void | |
737 gaim_plugins_unload_all(void) | |
738 { | |
739 #ifdef GAIM_PLUGINS | |
740 | |
741 while (loaded_plugins != NULL) | |
742 gaim_plugin_unload(loaded_plugins->data); | |
743 | |
744 #endif /* GAIM_PLUGINS */ | |
745 } | |
746 | |
747 void | |
5242
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
748 gaim_plugins_destroy_all(void) |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
749 { |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
750 #ifdef GAIM_PLUGINS |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
751 |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
752 while (plugins != NULL) |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
753 gaim_plugin_destroy(plugins->data); |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
754 |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
755 #endif /* GAIM_PLUGINS */ |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
756 } |
5838 | 757 |
758 void | |
5949
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
759 gaim_plugins_load_saved(const char *key) |
5838 | 760 { |
761 #ifdef GAIM_PLUGINS | |
5949
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
762 GList *f, *files; |
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
763 |
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
764 g_return_if_fail(key != NULL); |
5838 | 765 |
5949
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
766 files = gaim_prefs_get_string_list(key); |
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
767 |
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
768 for (f = files; f; f = f->next) |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
769 { |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
770 char *filename = g_path_get_basename(f->data); |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
771 GaimPlugin *plugin = NULL; |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
772 |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
773 if (filename != NULL) |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
774 { |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
775 if ((plugin = gaim_plugins_find_with_basename(filename)) != NULL) |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
776 { |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
777 gaim_debug_info("plugins", "Loading saved plugin %s\n", |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
778 filename); |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
779 gaim_plugin_load(plugin); |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
780 } |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
781 else |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
782 { |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
783 gaim_debug_error("plugins", "Unable to find saved plugin %s\n", |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
784 filename); |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
785 } |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
786 |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
787 g_free(filename); |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
788 } |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
789 |
5838 | 790 g_free(f->data); |
791 } | |
792 | |
793 g_list_free(files); | |
794 #endif /* GAIM_PLUGINS */ | |
795 } | |
796 | |
797 | |
5242
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
798 void |
5205 | 799 gaim_plugins_probe(const char *ext) |
800 { | |
801 #ifdef GAIM_PLUGINS | |
802 GDir *dir; | |
803 const gchar *file; | |
804 gchar *path; | |
805 GaimPlugin *plugin; | |
806 size_t i; | |
807 | |
808 if (!g_module_supported()) | |
809 return; | |
810 | |
811 for (i = 0; i < search_path_count; i++) { | |
812 if (search_paths[i] == NULL) | |
813 continue; | |
814 | |
815 dir = g_dir_open(search_paths[i], 0, NULL); | |
816 | |
817 if (dir != NULL) { | |
818 while ((file = g_dir_read_name(dir)) != NULL) { | |
819 path = g_build_filename(search_paths[i], file, NULL); | |
820 | |
821 if (ext == NULL || is_so_file(file, ext)) | |
822 plugin = gaim_plugin_probe(path); | |
823 | |
824 g_free(path); | |
825 } | |
826 | |
827 g_dir_close(dir); | |
828 } | |
829 } | |
830 | |
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
831 /* See if we have any plugins waiting to load. */ |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
832 while (load_queue != NULL) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
833 { |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
834 plugin = (GaimPlugin *)load_queue->data; |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
835 |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
836 load_queue = g_list_remove(load_queue, plugin); |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
837 |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
838 if (plugin == NULL || plugin->info == NULL) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
839 continue; |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
840 |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
841 if (plugin->info->type == GAIM_PLUGIN_LOADER) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
842 { |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
843 GList *exts; |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
844 |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
845 /* We'll just load this right now. */ |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
846 if (!gaim_plugin_load(plugin)) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
847 { |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
848 gaim_plugin_destroy(plugin); |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
849 |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
850 continue; |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
851 } |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
852 |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
853 plugin_loaders = g_list_append(plugin_loaders, plugin); |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
854 |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
855 for (exts = GAIM_PLUGIN_LOADER_INFO(plugin)->exts; |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
856 exts != NULL; |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
857 exts = exts->next) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
858 { |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
859 gaim_plugins_probe(exts->data); |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
860 } |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
861 } |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
862 else if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
863 { |
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 /* We'll just load this right now. */ |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
866 if (!gaim_plugin_load(plugin)) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
867 { |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
868 gaim_plugin_destroy(plugin); |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
869 |
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 |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
873 if (GAIM_PLUGIN_PROTOCOL_INFO(plugin)->protocol == GAIM_PROTO_ICQ || |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
874 gaim_find_prpl(GAIM_PLUGIN_PROTOCOL_INFO(plugin)->protocol)) |
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 /* Nothing to see here--move along, move along */ |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
877 gaim_plugin_destroy(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 continue; |
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 |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
882 protocol_plugins = g_list_insert_sorted(protocol_plugins, plugin, |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
883 (GCompareFunc)compare_prpl); |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
884 } |
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 |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
887 if (load_queue != NULL) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
888 { |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
889 g_list_free(load_queue); |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
890 load_queue = NULL; |
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 |
5205 | 893 if (probe_cb != NULL) |
894 probe_cb(probe_cb_data); | |
895 | |
896 #endif /* GAIM_PLUGINS */ | |
897 } | |
898 | |
899 gboolean | |
900 gaim_plugin_register(GaimPlugin *plugin) | |
901 { | |
902 g_return_val_if_fail(plugin != NULL, FALSE); | |
903 | |
904 if (g_list_find(plugins, plugin)) | |
905 return TRUE; | |
906 | |
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
907 if (plugin->info->type == GAIM_PLUGIN_LOADER || |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
908 plugin->info->type == GAIM_PLUGIN_PROTOCOL) |
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 /* Special exception for loader plugins. We want them loaded NOW! */ |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
911 load_queue = g_list_append(load_queue, plugin); |
5205 | 912 } |
913 | |
914 plugins = g_list_append(plugins, plugin); | |
915 | |
916 return TRUE; | |
917 } | |
918 | |
919 gboolean | |
920 gaim_plugins_enabled(void) | |
921 { | |
922 #ifdef GAIM_PLUGINS | |
923 return TRUE; | |
924 #else | |
925 return FALSE; | |
926 #endif | |
927 } | |
928 | |
929 void | |
930 gaim_plugins_register_probe_notify_cb(void (*func)(void *), void *data) | |
931 { | |
932 /* TODO */ | |
933 probe_cb = func; | |
934 probe_cb_data = data; | |
935 } | |
936 | |
937 void | |
938 gaim_plugins_unregister_probe_notify_cb(void (*func)(void *)) | |
939 { | |
940 /* TODO */ | |
941 probe_cb = NULL; | |
942 probe_cb_data = NULL; | |
943 } | |
944 | |
945 void | |
946 gaim_plugins_register_load_notify_cb(void (*func)(GaimPlugin *, void *), | |
947 void *data) | |
948 { | |
949 /* TODO */ | |
950 load_cb = func; | |
951 load_cb_data = data; | |
952 } | |
953 | |
954 void | |
955 gaim_plugins_unregister_load_notify_cb(void (*func)(GaimPlugin *, void *)) | |
956 { | |
957 /* TODO */ | |
958 load_cb = NULL; | |
959 load_cb_data = NULL; | |
960 } | |
961 | |
962 void | |
963 gaim_plugins_register_unload_notify_cb(void (*func)(GaimPlugin *, void *), | |
964 void *data) | |
965 { | |
966 /* TODO */ | |
967 unload_cb = func; | |
968 unload_cb_data = data; | |
969 } | |
970 | |
971 void | |
972 gaim_plugins_unregister_unload_notify_cb(void (*func)(GaimPlugin *, void *)) | |
973 { | |
974 /* TODO */ | |
975 unload_cb = NULL; | |
976 unload_cb_data = NULL; | |
977 } | |
978 | |
979 GaimPlugin * | |
980 gaim_plugins_find_with_name(const char *name) | |
981 { | |
982 GaimPlugin *plugin; | |
983 GList *l; | |
984 | |
985 for (l = plugins; l != NULL; l = l->next) { | |
986 plugin = l->data; | |
987 | |
988 if (!strcmp(plugin->info->name, name)) | |
989 return plugin; | |
990 } | |
991 | |
992 return NULL; | |
993 } | |
994 | |
995 GaimPlugin * | |
996 gaim_plugins_find_with_filename(const char *filename) | |
997 { | |
998 GaimPlugin *plugin; | |
999 GList *l; | |
1000 | |
1001 for (l = plugins; l != NULL; l = l->next) { | |
1002 plugin = l->data; | |
1003 | |
1004 if (plugin->path != NULL && !strcmp(plugin->path, filename)) | |
1005 return plugin; | |
1006 } | |
1007 | |
1008 return NULL; | |
1009 } | |
1010 | |
1011 GaimPlugin * | |
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1012 gaim_plugins_find_with_basename(const char *basename) |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1013 { |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1014 GaimPlugin *plugin; |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1015 GList *l; |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1016 |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1017 g_return_val_if_fail(basename != NULL, NULL); |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1018 |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1019 for (l = plugins; l != NULL; l = l->next) |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1020 { |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1021 char *tmp; |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1022 |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1023 plugin = (GaimPlugin *)l->data; |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1024 |
7278 | 1025 if (plugin->path != NULL) { |
1026 tmp = g_path_get_basename(plugin->path); | |
1027 if (!strcmp(tmp, basename)) { | |
1028 g_free(tmp); | |
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1029 return plugin; |
7278 | 1030 } |
7279 | 1031 g_free(tmp); |
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1032 } |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1033 } |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1034 |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1035 return NULL; |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1036 } |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1037 |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1038 GaimPlugin * |
5205 | 1039 gaim_plugins_find_with_id(const char *id) |
1040 { | |
1041 GaimPlugin *plugin; | |
1042 GList *l; | |
1043 | |
1044 g_return_val_if_fail(id != NULL, NULL); | |
1045 | |
6486
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1046 for (l = plugins; l != NULL; l = l->next) |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1047 { |
5205 | 1048 plugin = l->data; |
1049 | |
6486
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1050 if (plugin->info->id != NULL && !strcmp(plugin->info->id, id)) |
5205 | 1051 return plugin; |
1052 } | |
1053 | |
1054 return NULL; | |
1055 } | |
1056 | |
1057 GList * | |
1058 gaim_plugins_get_loaded(void) | |
1059 { | |
1060 return loaded_plugins; | |
1061 } | |
1062 | |
1063 GList * | |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1064 gaim_plugins_get_protocols(void) |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1065 { |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1066 return protocol_plugins; |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1067 } |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1068 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1069 GList * |
5205 | 1070 gaim_plugins_get_all(void) |
1071 { | |
1072 return plugins; | |
1073 } | |
1074 |