Mercurial > pidgin.yaz
annotate src/plugin.c @ 13020:72300c551dc2
[gaim-migrate @ 15373]
More whitespace from the tree.
committer: Tailor Script <tailor@pidgin.im>
author | Etan Reisner <pidgin@unreliablesource.net> |
---|---|
date | Mon, 23 Jan 2006 11:41:51 +0000 |
parents | 9d8025ec5e23 |
children | a0a4b44239e8 |
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" |
12695
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
31 #include "util.h" |
9943 | 32 #include "version.h" |
5205 | 33 |
6822
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
34 typedef struct |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
35 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
36 GHashTable *commands; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
37 size_t command_count; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
38 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
39 } GaimPluginIpcInfo; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
40 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
41 typedef struct |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
42 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
43 GaimCallback func; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
44 GaimSignalMarshalFunc marshal; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
45 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
46 int num_params; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
47 GaimValue **params; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
48 GaimValue *ret_value; |
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 } GaimPluginIpcCommand; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
51 |
10447 | 52 static GList *search_paths = NULL; |
53 static GList *plugins = NULL; | |
11950 | 54 static GList *loaded_plugins = NULL; |
55 static GList *protocol_plugins = NULL; | |
56 #ifdef GAIM_PLUGINS | |
10447 | 57 static GList *load_queue = NULL; |
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
58 static GList *plugin_loaders = NULL; |
11950 | 59 #endif |
5205 | 60 |
11963 | 61 /* |
62 * TODO: I think the intention was to allow multiple load and unload | |
63 * callback functions. Perhaps using a GList instead of a | |
64 * pointer to a single function. | |
65 */ | |
5205 | 66 static void (*probe_cb)(void *) = NULL; |
67 static void *probe_cb_data = NULL; | |
68 static void (*load_cb)(GaimPlugin *, void *) = NULL; | |
69 static void *load_cb_data = NULL; | |
70 static void (*unload_cb)(GaimPlugin *, void *) = NULL; | |
71 static void *unload_cb_data = NULL; | |
72 | |
73 #ifdef GAIM_PLUGINS | |
11950 | 74 |
10447 | 75 static gboolean |
76 has_file_extension(const char *filename, const char *ext) | |
5205 | 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 | |
10447 | 89 return (strncmp(filename + len, ext, extlen) == 0); |
5205 | 90 } |
91 | |
92 static gboolean | |
10682 | 93 is_native(const char *filename) |
94 { | |
95 const char *last_period; | |
96 | |
97 last_period = strrchr(filename, '.'); | |
98 if (last_period == NULL) | |
99 return FALSE; | |
100 | |
12077 | 101 return !(strcmp(last_period, ".dll") & |
102 strcmp(last_period, ".sl") & | |
103 strcmp(last_period, ".so")); | |
10682 | 104 } |
105 | |
106 static char * | |
107 gaim_plugin_get_basename(const char *filename) | |
108 { | |
109 const char *basename; | |
110 const char *last_period; | |
111 | |
112 basename = strrchr(filename, G_DIR_SEPARATOR); | |
113 if (basename != NULL) | |
114 basename++; | |
115 else | |
116 basename = filename; | |
117 | |
118 if (is_native(basename) && | |
119 ((last_period = strrchr(basename, '.')) != NULL)) | |
120 return g_strndup(basename, (last_period - basename)); | |
121 | |
122 return g_strdup(basename); | |
123 } | |
124 | |
125 static gboolean | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
126 loader_supports_file(GaimPlugin *loader, const char *filename) |
5205 | 127 { |
6432 | 128 GList *exts; |
5205 | 129 |
6432 | 130 for (exts = GAIM_PLUGIN_LOADER_INFO(loader)->exts; exts != NULL; exts = exts->next) { |
10447 | 131 if (has_file_extension(filename, (char *)exts->data)) { |
6432 | 132 return TRUE; |
5205 | 133 } |
134 } | |
135 | |
136 return FALSE; | |
137 } | |
138 | |
139 static GaimPlugin * | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
140 find_loader_for_plugin(const GaimPlugin *plugin) |
5205 | 141 { |
142 GaimPlugin *loader; | |
143 GList *l; | |
144 | |
145 if (plugin->path == NULL) | |
146 return NULL; | |
147 | |
148 for (l = gaim_plugins_get_loaded(); l != NULL; l = l->next) { | |
149 loader = l->data; | |
150 | |
151 if (loader->info->type == GAIM_PLUGIN_LOADER && | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
152 loader_supports_file(loader, plugin->path)) { |
5205 | 153 |
154 return loader; | |
155 } | |
156 | |
157 loader = NULL; | |
158 } | |
159 | |
160 return NULL; | |
161 } | |
162 | |
5449 | 163 #endif /* GAIM_PLUGINS */ |
164 | |
10447 | 165 /** |
166 * Negative if a before b, 0 if equal, positive if a after b. | |
167 */ | |
5205 | 168 static gint |
169 compare_prpl(GaimPlugin *a, GaimPlugin *b) | |
170 { | |
7956 | 171 if(GAIM_IS_PROTOCOL_PLUGIN(a)) { |
172 if(GAIM_IS_PROTOCOL_PLUGIN(b)) | |
173 return strcmp(a->info->name, b->info->name); | |
174 else | |
175 return -1; | |
176 } else { | |
177 if(GAIM_IS_PROTOCOL_PLUGIN(b)) | |
178 return 1; | |
179 else | |
180 return 0; | |
181 } | |
5205 | 182 } |
183 | |
184 GaimPlugin * | |
185 gaim_plugin_new(gboolean native, const char *path) | |
186 { | |
187 GaimPlugin *plugin; | |
188 | |
189 plugin = g_new0(GaimPlugin, 1); | |
190 | |
191 plugin->native_plugin = native; | |
192 plugin->path = (path == NULL ? NULL : g_strdup(path)); | |
193 | |
194 return plugin; | |
195 } | |
196 | |
197 GaimPlugin * | |
198 gaim_plugin_probe(const char *filename) | |
199 { | |
200 #ifdef GAIM_PLUGINS | |
201 GaimPlugin *plugin = NULL; | |
202 GaimPlugin *loader; | |
10124 | 203 gpointer unpunned; |
12342 | 204 gchar *basename = NULL; |
5205 | 205 gboolean (*gaim_init_plugin)(GaimPlugin *); |
206 | |
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
207 gaim_debug_misc("plugins", "probing %s\n", filename); |
5205 | 208 g_return_val_if_fail(filename != NULL, NULL); |
209 | |
5973 | 210 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) |
211 return NULL; | |
212 | |
10447 | 213 /* If this plugin has already been probed then exit */ |
12342 | 214 basename = gaim_plugin_get_basename(filename); |
215 plugin = gaim_plugins_find_with_basename(basename); | |
216 g_free(basename); | |
5205 | 217 if (plugin != NULL) |
12342 | 218 { |
12695
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
219 if (!strcmp(filename, plugin->path)) |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
220 return plugin; |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
221 else if (!gaim_plugin_is_unloadable(plugin)) |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
222 { |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
223 gaim_debug_info("plugins", "Not loading %s. " |
12342 | 224 "Another plugin with the same name (%s) has already been loaded.\n", |
225 filename, plugin->path); | |
12695
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
226 return plugin; |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
227 } |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
228 else |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
229 { |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
230 /* The old plugin was a different file and it was unloadable. |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
231 * There's no guarantee that this new file with the same name |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
232 * will be loadable, but unless it fails in one of the silent |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
233 * ways and the first one didn't, it's not any worse. The user |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
234 * will still see a greyed-out plugin, which is what we want. */ |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
235 gaim_plugin_destroy(plugin); |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
236 } |
12342 | 237 } |
5205 | 238 |
12066 | 239 plugin = gaim_plugin_new(has_file_extension(filename, G_MODULE_SUFFIX), filename); |
5205 | 240 |
12699
2b53185e5d8f
[gaim-migrate @ 15042]
Richard Laager <rlaager@wiktel.com>
parents:
12696
diff
changeset
|
241 if (plugin->native_plugin) { |
2b53185e5d8f
[gaim-migrate @ 15042]
Richard Laager <rlaager@wiktel.com>
parents:
12696
diff
changeset
|
242 const char *error; |
12623
70f18c73da9d
[gaim-migrate @ 14959]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12342
diff
changeset
|
243 #ifdef _WIN32 |
70f18c73da9d
[gaim-migrate @ 14959]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12342
diff
changeset
|
244 /* Suppress error popups for failing to load plugins */ |
70f18c73da9d
[gaim-migrate @ 14959]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12342
diff
changeset
|
245 UINT old_error_mode = SetErrorMode(SEM_FAILCRITICALERRORS); |
70f18c73da9d
[gaim-migrate @ 14959]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12342
diff
changeset
|
246 #endif |
12696 | 247 |
10737 | 248 /* |
10950 | 249 * We pass G_MODULE_BIND_LOCAL here to prevent symbols from |
250 * plugins being added to the global name space. | |
11378 | 251 * |
252 * G_MODULE_BIND_LOCAL was added in glib 2.3.3. | |
11950 | 253 * TODO: I guess there's nothing we can do about that? |
10737 | 254 */ |
11378 | 255 #if GLIB_CHECK_VERSION(2,3,3) |
10884 | 256 plugin->handle = g_module_open(filename, G_MODULE_BIND_LOCAL); |
11378 | 257 #else |
258 plugin->handle = g_module_open(filename, 0); | |
259 #endif | |
5205 | 260 |
10447 | 261 if (plugin->handle == NULL) |
262 { | |
12695
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
263 const char *error = g_module_error(); |
12704
69713c02a702
[gaim-migrate @ 15047]
Richard Laager <rlaager@wiktel.com>
parents:
12703
diff
changeset
|
264 if (error != NULL && gaim_str_has_prefix(error, filename)) |
12695
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
265 { |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
266 error = error + strlen(filename); |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
267 |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
268 /* These are just so we don't crash. If we |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
269 * got this far, they should always be true. */ |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
270 if (*error == ':') |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
271 error++; |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
272 if (*error == ' ') |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
273 error++; |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
274 } |
5205 | 275 |
12704
69713c02a702
[gaim-migrate @ 15047]
Richard Laager <rlaager@wiktel.com>
parents:
12703
diff
changeset
|
276 if (error == NULL || !*error) |
69713c02a702
[gaim-migrate @ 15047]
Richard Laager <rlaager@wiktel.com>
parents:
12703
diff
changeset
|
277 { |
69713c02a702
[gaim-migrate @ 15047]
Richard Laager <rlaager@wiktel.com>
parents:
12703
diff
changeset
|
278 plugin->error = g_strdup(_("Unknown error")); |
69713c02a702
[gaim-migrate @ 15047]
Richard Laager <rlaager@wiktel.com>
parents:
12703
diff
changeset
|
279 gaim_debug_error("plugins", "%s is unloadable: Unknown error\n", |
69713c02a702
[gaim-migrate @ 15047]
Richard Laager <rlaager@wiktel.com>
parents:
12703
diff
changeset
|
280 plugin->path); |
69713c02a702
[gaim-migrate @ 15047]
Richard Laager <rlaager@wiktel.com>
parents:
12703
diff
changeset
|
281 } |
69713c02a702
[gaim-migrate @ 15047]
Richard Laager <rlaager@wiktel.com>
parents:
12703
diff
changeset
|
282 else |
69713c02a702
[gaim-migrate @ 15047]
Richard Laager <rlaager@wiktel.com>
parents:
12703
diff
changeset
|
283 { |
69713c02a702
[gaim-migrate @ 15047]
Richard Laager <rlaager@wiktel.com>
parents:
12703
diff
changeset
|
284 plugin->error = g_strdup(error); |
69713c02a702
[gaim-migrate @ 15047]
Richard Laager <rlaager@wiktel.com>
parents:
12703
diff
changeset
|
285 gaim_debug_error("plugins", "%s is unloadable: %s\n", |
69713c02a702
[gaim-migrate @ 15047]
Richard Laager <rlaager@wiktel.com>
parents:
12703
diff
changeset
|
286 plugin->path, plugin->error); |
69713c02a702
[gaim-migrate @ 15047]
Richard Laager <rlaager@wiktel.com>
parents:
12703
diff
changeset
|
287 } |
12695
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
288 #if GLIB_CHECK_VERSION(2,3,3) |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
289 plugin->handle = g_module_open(filename, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL); |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
290 #else |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
291 plugin->handle = g_module_open(filename, G_MODULE_BIND_LAZY); |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
292 #endif |
5269
cd7e4ba049f9
[gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents:
5268
diff
changeset
|
293 |
12695
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
294 if (plugin->handle == NULL) |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
295 { |
12699
2b53185e5d8f
[gaim-migrate @ 15042]
Richard Laager <rlaager@wiktel.com>
parents:
12696
diff
changeset
|
296 #ifdef _WIN32 |
2b53185e5d8f
[gaim-migrate @ 15042]
Richard Laager <rlaager@wiktel.com>
parents:
12696
diff
changeset
|
297 /* Restore the original error mode */ |
2b53185e5d8f
[gaim-migrate @ 15042]
Richard Laager <rlaager@wiktel.com>
parents:
12696
diff
changeset
|
298 SetErrorMode(old_error_mode); |
2b53185e5d8f
[gaim-migrate @ 15042]
Richard Laager <rlaager@wiktel.com>
parents:
12696
diff
changeset
|
299 #endif |
12695
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
300 gaim_plugin_destroy(plugin); |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
301 return NULL; |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
302 } |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
303 else |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
304 { |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
305 /* We were able to load the plugin with lazy symbol binding. |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
306 * This means we're missing some symbol. Mark it as |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
307 * unloadable and keep going so we get the info to display |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
308 * to the user so they know to rebuild this plugin. */ |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
309 plugin->unloadable = TRUE; |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
310 } |
5205 | 311 } |
312 | |
313 if (!g_module_symbol(plugin->handle, "gaim_init_plugin", | |
10447 | 314 &unpunned)) |
315 { | |
11950 | 316 gaim_debug_error("plugins", "%s is not usable because the " |
317 "'gaim_init_plugin' symbol could not be " | |
318 "found. Does the plugin call the " | |
319 "GAIM_INIT_PLUGIN() macro?\n", plugin->path); | |
5205 | 320 |
11950 | 321 g_module_close(plugin->handle); |
5443 | 322 error = g_module_error(); |
11950 | 323 if (error != NULL) |
324 gaim_debug_error("plugins", "Error closing module %s: %s\n", | |
325 plugin->path, error); | |
326 plugin->handle = NULL; | |
5205 | 327 |
12699
2b53185e5d8f
[gaim-migrate @ 15042]
Richard Laager <rlaager@wiktel.com>
parents:
12696
diff
changeset
|
328 #ifdef _WIN32 |
2b53185e5d8f
[gaim-migrate @ 15042]
Richard Laager <rlaager@wiktel.com>
parents:
12696
diff
changeset
|
329 /* Restore the original error mode */ |
2b53185e5d8f
[gaim-migrate @ 15042]
Richard Laager <rlaager@wiktel.com>
parents:
12696
diff
changeset
|
330 SetErrorMode(old_error_mode); |
2b53185e5d8f
[gaim-migrate @ 15042]
Richard Laager <rlaager@wiktel.com>
parents:
12696
diff
changeset
|
331 #endif |
5205 | 332 gaim_plugin_destroy(plugin); |
333 return NULL; | |
334 } | |
10124 | 335 gaim_init_plugin = unpunned; |
12699
2b53185e5d8f
[gaim-migrate @ 15042]
Richard Laager <rlaager@wiktel.com>
parents:
12696
diff
changeset
|
336 |
2b53185e5d8f
[gaim-migrate @ 15042]
Richard Laager <rlaager@wiktel.com>
parents:
12696
diff
changeset
|
337 #ifdef _WIN32 |
2b53185e5d8f
[gaim-migrate @ 15042]
Richard Laager <rlaager@wiktel.com>
parents:
12696
diff
changeset
|
338 /* Restore the original error mode */ |
2b53185e5d8f
[gaim-migrate @ 15042]
Richard Laager <rlaager@wiktel.com>
parents:
12696
diff
changeset
|
339 SetErrorMode(old_error_mode); |
2b53185e5d8f
[gaim-migrate @ 15042]
Richard Laager <rlaager@wiktel.com>
parents:
12696
diff
changeset
|
340 #endif |
5205 | 341 } |
342 else { | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
343 loader = find_loader_for_plugin(plugin); |
5205 | 344 |
345 if (loader == NULL) { | |
346 gaim_plugin_destroy(plugin); | |
347 return NULL; | |
348 } | |
349 | |
350 gaim_init_plugin = GAIM_PLUGIN_LOADER_INFO(loader)->probe; | |
351 } | |
352 | |
12695
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
353 if (!gaim_init_plugin(plugin) || plugin->info == NULL) |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
354 { |
5205 | 355 gaim_plugin_destroy(plugin); |
356 return NULL; | |
357 } | |
358 | |
12703
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
359 /* Really old plugins. */ |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
360 if (plugin->info->magic != GAIM_PLUGIN_MAGIC) |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
361 { |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
362 if (plugin->info->magic >= 2 && plugin->info->magic <= 4) |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
363 { |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
364 struct _GaimPluginInfo2 |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
365 { |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
366 unsigned int api_version; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
367 GaimPluginType type; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
368 char *ui_requirement; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
369 unsigned long flags; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
370 GList *dependencies; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
371 GaimPluginPriority priority; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
372 |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
373 char *id; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
374 char *name; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
375 char *version; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
376 char *summary; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
377 char *description; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
378 char *author; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
379 char *homepage; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
380 |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
381 gboolean (*load)(GaimPlugin *plugin); |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
382 gboolean (*unload)(GaimPlugin *plugin); |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
383 void (*destroy)(GaimPlugin *plugin); |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
384 |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
385 void *ui_info; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
386 void *extra_info; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
387 GaimPluginUiInfo *prefs_info; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
388 GList *(*actions)(GaimPlugin *plugin, gpointer context); |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
389 } *info2 = (struct _GaimPluginInfo2 *)plugin->info; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
390 |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
391 /* This leaks... but only for ancient plugins, so deal with it. */ |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
392 plugin->info = g_new0(GaimPluginInfo, 1); |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
393 |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
394 /* We don't really need all these to display the plugin info, but |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
395 * I'm copying them all for good measure. */ |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
396 plugin->info->magic = info2->api_version; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
397 plugin->info->type = info2->type; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
398 plugin->info->ui_requirement = info2->ui_requirement; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
399 plugin->info->flags = info2->flags; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
400 plugin->info->dependencies = info2->dependencies; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
401 plugin->info->id = info2->id; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
402 plugin->info->name = info2->name; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
403 plugin->info->version = info2->version; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
404 plugin->info->summary = info2->summary; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
405 plugin->info->description = info2->description; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
406 plugin->info->author = info2->author; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
407 plugin->info->homepage = info2->homepage; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
408 plugin->info->load = info2->load; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
409 plugin->info->unload = info2->unload; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
410 plugin->info->destroy = info2->destroy; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
411 plugin->info->ui_info = info2->ui_info; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
412 plugin->info->extra_info = info2->extra_info; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
413 |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
414 if (info2->api_version >= 3) |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
415 plugin->info->prefs_info = info2->prefs_info; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
416 |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
417 if (info2->api_version >= 4) |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
418 plugin->info->actions = info2->actions; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
419 |
12704
69713c02a702
[gaim-migrate @ 15047]
Richard Laager <rlaager@wiktel.com>
parents:
12703
diff
changeset
|
420 |
69713c02a702
[gaim-migrate @ 15047]
Richard Laager <rlaager@wiktel.com>
parents:
12703
diff
changeset
|
421 plugin->error = g_strdup_printf(_("Plugin magic mismatch %d (need %d)"), |
69713c02a702
[gaim-migrate @ 15047]
Richard Laager <rlaager@wiktel.com>
parents:
12703
diff
changeset
|
422 plugin->info->magic, GAIM_PLUGIN_MAGIC); |
69713c02a702
[gaim-migrate @ 15047]
Richard Laager <rlaager@wiktel.com>
parents:
12703
diff
changeset
|
423 gaim_debug_error("plugins", "%s is unloadable: Plugin magic mismatch %d (need %d)\n", |
69713c02a702
[gaim-migrate @ 15047]
Richard Laager <rlaager@wiktel.com>
parents:
12703
diff
changeset
|
424 plugin->path, plugin->info->magic, GAIM_PLUGIN_MAGIC); |
12703
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
425 plugin->unloadable = TRUE; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
426 return plugin; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
427 } |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
428 |
12704
69713c02a702
[gaim-migrate @ 15047]
Richard Laager <rlaager@wiktel.com>
parents:
12703
diff
changeset
|
429 gaim_debug_error("plugins", "%s is unloadable: Plugin magic mismatch %d (need %d)\n", |
69713c02a702
[gaim-migrate @ 15047]
Richard Laager <rlaager@wiktel.com>
parents:
12703
diff
changeset
|
430 plugin->path, plugin->info->magic, GAIM_PLUGIN_MAGIC); |
12703
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
431 gaim_plugin_destroy(plugin); |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
432 return NULL; |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
433 } |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
434 |
df49362e0378
[gaim-migrate @ 15046]
Richard Laager <rlaager@wiktel.com>
parents:
12699
diff
changeset
|
435 if (plugin->info->major_version != GAIM_MAJOR_VERSION || |
9943 | 436 plugin->info->minor_version > GAIM_MINOR_VERSION) |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
437 { |
12704
69713c02a702
[gaim-migrate @ 15047]
Richard Laager <rlaager@wiktel.com>
parents:
12703
diff
changeset
|
438 plugin->error = g_strdup_printf(_("ABI version mismatch %d.%d.x (need %d.%d.x)"), |
12695
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
439 plugin->info->major_version, plugin->info->minor_version, |
10156 | 440 GAIM_MAJOR_VERSION, GAIM_MINOR_VERSION); |
12704
69713c02a702
[gaim-migrate @ 15047]
Richard Laager <rlaager@wiktel.com>
parents:
12703
diff
changeset
|
441 gaim_debug_error("plugins", "%s is unloadable: ABI version mismatch %d.%d.x (need %d.%d.x)\n", |
69713c02a702
[gaim-migrate @ 15047]
Richard Laager <rlaager@wiktel.com>
parents:
12703
diff
changeset
|
442 plugin->path, plugin->info->major_version, plugin->info->minor_version, |
69713c02a702
[gaim-migrate @ 15047]
Richard Laager <rlaager@wiktel.com>
parents:
12703
diff
changeset
|
443 GAIM_MAJOR_VERSION, GAIM_MINOR_VERSION); |
12695
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
444 plugin->unloadable = TRUE; |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
445 return plugin; |
10156 | 446 } |
447 | |
448 /* If plugin is a PRPL, make sure it implements the required functions */ | |
449 if ((plugin->info->type == GAIM_PLUGIN_PROTOCOL) && ( | |
450 (GAIM_PLUGIN_PROTOCOL_INFO(plugin)->list_icon == NULL) || | |
451 (GAIM_PLUGIN_PROTOCOL_INFO(plugin)->login == NULL) || | |
452 (GAIM_PLUGIN_PROTOCOL_INFO(plugin)->close == NULL))) | |
453 { | |
12704
69713c02a702
[gaim-migrate @ 15047]
Richard Laager <rlaager@wiktel.com>
parents:
12703
diff
changeset
|
454 plugin->error = g_strdup(_("Plugin does not implement all required functions")); |
69713c02a702
[gaim-migrate @ 15047]
Richard Laager <rlaager@wiktel.com>
parents:
12703
diff
changeset
|
455 gaim_debug_error("plugins", "%s is unloadable: Plugin does not implement all required functions\n", |
69713c02a702
[gaim-migrate @ 15047]
Richard Laager <rlaager@wiktel.com>
parents:
12703
diff
changeset
|
456 plugin->path); |
12695
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
457 plugin->unloadable = TRUE; |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
458 return plugin; |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
459 } |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
460 |
5205 | 461 return plugin; |
462 #else | |
463 return NULL; | |
464 #endif /* !GAIM_PLUGINS */ | |
465 } | |
466 | |
12332 | 467 static gint |
468 compare_plugins(gconstpointer a, gconstpointer b) | |
469 { | |
470 const GaimPlugin *plugina = a; | |
471 const GaimPlugin *pluginb = b; | |
472 | |
473 return strcmp(plugina->info->name, pluginb->info->name); | |
474 } | |
475 | |
5205 | 476 gboolean |
477 gaim_plugin_load(GaimPlugin *plugin) | |
478 { | |
479 #ifdef GAIM_PLUGINS | |
6486
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
480 GList *dep_list = NULL; |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
481 GList *l; |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
482 |
5205 | 483 g_return_val_if_fail(plugin != NULL, FALSE); |
484 | |
485 if (gaim_plugin_is_loaded(plugin)) | |
486 return TRUE; | |
487 | |
12695
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
488 if (gaim_plugin_is_unloadable(plugin)) |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
489 return FALSE; |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
490 |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
491 g_return_val_if_fail(plugin->error == NULL, FALSE); |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
492 |
6486
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
493 /* |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
494 * Go through the list of the plugin's dependencies. |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
495 * |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
496 * First pass: Make sure all the plugins needed are probed. |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
497 */ |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
498 for (l = plugin->info->dependencies; l != NULL; l = l->next) |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
499 { |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
500 const char *dep_name = (const char *)l->data; |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
501 GaimPlugin *dep_plugin; |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
502 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
503 dep_plugin = gaim_plugins_find_with_id(dep_name); |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
504 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
505 if (dep_plugin == NULL) |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
506 { |
12926
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
507 char *tmp; |
6486
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
508 |
12983
92ae94619e2c
[gaim-migrate @ 15336]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12926
diff
changeset
|
509 tmp = g_strdup_printf(_("The required plugin %s was not found. " |
12926
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
510 "Please install this plugin and try again."), |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
511 dep_name); |
6486
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
512 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
513 gaim_notify_error(NULL, NULL, |
12926
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
514 _("Gaim encountered errors loading the plugin."), tmp); |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
515 g_free(tmp); |
6486
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
516 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
517 if (dep_list != NULL) |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
518 g_list_free(dep_list); |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
519 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
520 return FALSE; |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
521 } |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
522 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
523 dep_list = g_list_append(dep_list, dep_plugin); |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
524 } |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
525 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
526 /* Second pass: load all the required plugins. */ |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
527 for (l = dep_list; l != NULL; l = l->next) |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
528 { |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
529 GaimPlugin *dep_plugin = (GaimPlugin *)l->data; |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
530 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
531 if (!gaim_plugin_is_loaded(dep_plugin)) |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
532 { |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
533 if (!gaim_plugin_load(dep_plugin)) |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
534 { |
12926
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
535 char *tmp; |
6486
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
536 |
12926
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
537 tmp = g_strdup_printf(_("The required plugin %s was unable to load."), |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
538 plugin->info->name); |
6486
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
539 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
540 gaim_notify_error(NULL, NULL, |
12926
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
541 _("Gaim was unable to load your plugin."), tmp); |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
542 g_free(tmp); |
6486
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
543 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
544 if (dep_list != NULL) |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
545 g_list_free(dep_list); |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
546 |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
547 return FALSE; |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
548 } |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
549 } |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
550 } |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
551 |
12926
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
552 /* Third pass: note that other plugins are dependencies of this plugin. |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
553 * This is done separately in case we had to bail out earlier. */ |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
554 for (l = dep_list; l != NULL; l = l->next) |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
555 { |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
556 GaimPlugin *dep_plugin = (GaimPlugin *)l->data; |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
557 dep_plugin->dependent_plugins = g_list_prepend(dep_plugin->dependent_plugins, plugin->info->id); |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
558 } |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
559 |
6486
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
560 if (dep_list != NULL) |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
561 g_list_free(dep_list); |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
562 |
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
563 if (plugin->native_plugin) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
564 { |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
565 if (plugin->info != NULL && plugin->info->load != NULL) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
566 { |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
567 if (!plugin->info->load(plugin)) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
568 return FALSE; |
5357
2a1c92df7024
[gaim-migrate @ 5733]
Christian Hammond <chipx86@chipx86.com>
parents:
5270
diff
changeset
|
569 } |
5205 | 570 } |
571 else { | |
572 GaimPlugin *loader; | |
573 GaimPluginLoaderInfo *loader_info; | |
574 | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
575 loader = find_loader_for_plugin(plugin); |
5205 | 576 |
577 if (loader == NULL) | |
578 return FALSE; | |
579 | |
580 loader_info = GAIM_PLUGIN_LOADER_INFO(loader); | |
581 | |
582 if (loader_info->load != NULL) | |
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
583 { |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
584 if (!loader_info->load(plugin)) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
585 return FALSE; |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
586 } |
5205 | 587 } |
588 | |
12332 | 589 loaded_plugins = g_list_insert_sorted(loaded_plugins, plugin, compare_plugins); |
5205 | 590 |
591 plugin->loaded = TRUE; | |
592 | |
593 /* TODO */ | |
594 if (load_cb != NULL) | |
595 load_cb(plugin, load_cb_data); | |
596 | |
8993 | 597 gaim_signal_emit(gaim_plugins_get_handle(), "plugin-load", plugin); |
8986 | 598 |
5205 | 599 return TRUE; |
600 | |
601 #else | |
5449 | 602 return TRUE; |
5205 | 603 #endif /* !GAIM_PLUGINS */ |
604 } | |
605 | |
606 gboolean | |
607 gaim_plugin_unload(GaimPlugin *plugin) | |
608 { | |
609 #ifdef GAIM_PLUGINS | |
12992
9d8025ec5e23
[gaim-migrate @ 15345]
Richard Laager <rlaager@wiktel.com>
parents:
12985
diff
changeset
|
610 GList *l; |
12985
de3a3669dbe1
[gaim-migrate @ 15338]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12983
diff
changeset
|
611 |
5205 | 612 g_return_val_if_fail(plugin != NULL, FALSE); |
613 | |
614 loaded_plugins = g_list_remove(loaded_plugins, plugin); | |
11950 | 615 if ((plugin->info != NULL) && GAIM_IS_PROTOCOL_PLUGIN(plugin)) |
616 protocol_plugins = g_list_remove(protocol_plugins, plugin); | |
5205 | 617 |
618 g_return_val_if_fail(gaim_plugin_is_loaded(plugin), FALSE); | |
619 | |
10447 | 620 gaim_debug_info("plugins", "Unloading plugin %s\n", plugin->info->name); |
5205 | 621 |
622 /* cancel any pending dialogs the plugin has */ | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5450
diff
changeset
|
623 gaim_request_close_with_handle(plugin); |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5450
diff
changeset
|
624 gaim_notify_close_with_handle(plugin); |
5205 | 625 |
626 plugin->loaded = FALSE; | |
627 | |
12926
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
628 /* Unload all plugins that depend on this plugin. */ |
12992
9d8025ec5e23
[gaim-migrate @ 15345]
Richard Laager <rlaager@wiktel.com>
parents:
12985
diff
changeset
|
629 while ((l = plugin->dependent_plugins) != NULL) |
12926
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
630 { |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
631 const char * dep_name = (const char *)l->data; |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
632 GaimPlugin *dep_plugin; |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
633 |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
634 dep_plugin = gaim_plugins_find_with_id(dep_name); |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
635 |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
636 if (dep_plugin != NULL && gaim_plugin_is_loaded(dep_plugin)) |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
637 { |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
638 if (!gaim_plugin_unload(dep_plugin)) |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
639 { |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
640 char *translated_name = g_strdup(_(dep_plugin->info->name)); |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
641 char *tmp; |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
642 |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
643 tmp = g_strdup_printf(_("The dependent plugin %s failed to unload."), |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
644 translated_name); |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
645 g_free(translated_name); |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
646 |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
647 gaim_notify_error(NULL, NULL, |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
648 _("Gaim encountered errors unloading the plugin."), tmp); |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
649 g_free(tmp); |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
650 } |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
651 } |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
652 } |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
653 |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
654 /* Remove this plugin from each dependency's dependent_plugins list. */ |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
655 for (l = plugin->info->dependencies; l != NULL; l = l->next) |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
656 { |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
657 const char *dep_name = (const char *)l->data; |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
658 GaimPlugin *dependency; |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
659 |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
660 dependency = gaim_plugins_find_with_id(dep_name); |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
661 |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
662 dependency->dependent_plugins = g_list_remove(dependency->dependent_plugins, plugin->info->id); |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
663 } |
2c4f20ff387c
[gaim-migrate @ 15279]
Richard Laager <rlaager@wiktel.com>
parents:
12704
diff
changeset
|
664 |
5205 | 665 if (plugin->native_plugin) { |
666 if (plugin->info->unload != NULL) | |
667 plugin->info->unload(plugin); | |
668 | |
669 if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) { | |
670 GaimPluginProtocolInfo *prpl_info; | |
671 GList *l; | |
672 | |
673 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); | |
674 | |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
675 for (l = prpl_info->user_splits; l != NULL; l = l->next) |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
676 gaim_account_user_split_destroy(l->data); |
5205 | 677 |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
678 for (l = prpl_info->protocol_options; l != NULL; l = l->next) |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
679 gaim_account_option_destroy(l->data); |
5205 | 680 |
12117 | 681 if (prpl_info->user_splits != NULL) { |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
682 g_list_free(prpl_info->user_splits); |
12117 | 683 prpl_info->user_splits = NULL; |
684 } | |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
685 |
12117 | 686 if (prpl_info->protocol_options != NULL) { |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
687 g_list_free(prpl_info->protocol_options); |
12117 | 688 prpl_info->protocol_options = NULL; |
689 } | |
5205 | 690 } |
691 } | |
692 else { | |
693 GaimPlugin *loader; | |
694 GaimPluginLoaderInfo *loader_info; | |
695 | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
696 loader = find_loader_for_plugin(plugin); |
5205 | 697 |
698 if (loader == NULL) | |
699 return FALSE; | |
700 | |
701 loader_info = GAIM_PLUGIN_LOADER_INFO(loader); | |
702 | |
9697
f568b6655331
[gaim-migrate @ 10556]
Christian Hammond <chipx86@chipx86.com>
parents:
9667
diff
changeset
|
703 if (loader_info->unload != NULL) |
5205 | 704 loader_info->unload(plugin); |
705 } | |
706 | |
707 gaim_signals_disconnect_by_handle(plugin); | |
6822
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
708 gaim_plugin_ipc_unregister_all(plugin); |
5205 | 709 |
710 /* TODO */ | |
711 if (unload_cb != NULL) | |
712 unload_cb(plugin, unload_cb_data); | |
713 | |
8986 | 714 gaim_signal_emit(gaim_plugins_get_handle(), "plugin-unload", plugin); |
715 | |
10087 | 716 gaim_prefs_disconnect_by_handle(plugin); |
717 | |
5205 | 718 return TRUE; |
5449 | 719 #else |
720 return TRUE; | |
5205 | 721 #endif /* GAIM_PLUGINS */ |
722 } | |
723 | |
724 gboolean | |
725 gaim_plugin_reload(GaimPlugin *plugin) | |
726 { | |
727 #ifdef GAIM_PLUGINS | |
728 g_return_val_if_fail(plugin != NULL, FALSE); | |
729 g_return_val_if_fail(gaim_plugin_is_loaded(plugin), FALSE); | |
730 | |
731 if (!gaim_plugin_unload(plugin)) | |
732 return FALSE; | |
733 | |
734 if (!gaim_plugin_load(plugin)) | |
735 return FALSE; | |
736 | |
737 return TRUE; | |
738 #else | |
5449 | 739 return TRUE; |
5205 | 740 #endif /* !GAIM_PLUGINS */ |
741 } | |
742 | |
743 void | |
744 gaim_plugin_destroy(GaimPlugin *plugin) | |
745 { | |
5449 | 746 #ifdef GAIM_PLUGINS |
5205 | 747 g_return_if_fail(plugin != NULL); |
748 | |
749 if (gaim_plugin_is_loaded(plugin)) | |
750 gaim_plugin_unload(plugin); | |
751 | |
752 plugins = g_list_remove(plugins, plugin); | |
753 | |
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
754 if (load_queue != NULL) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
755 load_queue = g_list_remove(load_queue, plugin); |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
756 |
9943 | 757 /* true, this may leak a little memory if there is a major version |
758 * mismatch, but it's a lot better than trying to free something | |
759 * we shouldn't, and crashing while trying to load an old plugin */ | |
760 if(plugin->info == NULL || plugin->info->magic != GAIM_PLUGIN_MAGIC || | |
761 plugin->info->major_version != GAIM_MAJOR_VERSION) { | |
762 if(plugin->handle) | |
763 g_module_close(plugin->handle); | |
764 g_free(plugin); | |
765 return; | |
766 } | |
767 | |
5243
f6e0c689a88b
[gaim-migrate @ 5614]
Christian Hammond <chipx86@chipx86.com>
parents:
5242
diff
changeset
|
768 if (plugin->info != NULL && plugin->info->dependencies != NULL) |
f6e0c689a88b
[gaim-migrate @ 5614]
Christian Hammond <chipx86@chipx86.com>
parents:
5242
diff
changeset
|
769 g_list_free(plugin->info->dependencies); |
5205 | 770 |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
771 if (plugin->native_plugin) |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
772 { |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
773 if (plugin->info != NULL && plugin->info->type == GAIM_PLUGIN_LOADER) |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
774 { |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
775 GaimPluginLoaderInfo *loader_info; |
5205 | 776 GList *exts, *l, *next_l; |
777 GaimPlugin *p2; | |
778 | |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
779 loader_info = GAIM_PLUGIN_LOADER_INFO(plugin); |
5205 | 780 |
9943 | 781 if (loader_info != NULL && loader_info->exts != NULL) |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
782 { |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
783 for (exts = GAIM_PLUGIN_LOADER_INFO(plugin)->exts; |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
784 exts != NULL; |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
785 exts = exts->next) { |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
786 |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
787 for (l = gaim_plugins_get_all(); l != NULL; l = next_l) |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
788 { |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
789 next_l = l->next; |
5205 | 790 |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
791 p2 = l->data; |
5205 | 792 |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
793 if (p2->path != NULL && |
10447 | 794 has_file_extension(p2->path, exts->data)) |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
795 { |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
796 gaim_plugin_destroy(p2); |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
797 } |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
798 } |
5205 | 799 } |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
800 |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
801 g_list_free(loader_info->exts); |
5205 | 802 } |
803 | |
804 plugin_loaders = g_list_remove(plugin_loaders, plugin); | |
805 } | |
806 | |
807 if (plugin->info != NULL && plugin->info->destroy != NULL) | |
808 plugin->info->destroy(plugin); | |
809 | |
810 if (plugin->handle != NULL) | |
811 g_module_close(plugin->handle); | |
812 } | |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
813 else |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
814 { |
5205 | 815 GaimPlugin *loader; |
816 GaimPluginLoaderInfo *loader_info; | |
817 | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
818 loader = find_loader_for_plugin(plugin); |
5205 | 819 |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
820 if (loader != NULL) |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
821 { |
5941
a3e60ff95b7d
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
822 loader_info = GAIM_PLUGIN_LOADER_INFO(loader); |
5205 | 823 |
5941
a3e60ff95b7d
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
824 if (loader_info->destroy != NULL) |
a3e60ff95b7d
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
825 loader_info->destroy(plugin); |
a3e60ff95b7d
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
826 } |
5205 | 827 } |
828 | |
829 if (plugin->path != NULL) g_free(plugin->path); | |
830 if (plugin->error != NULL) g_free(plugin->error); | |
831 | |
832 g_free(plugin); | |
5449 | 833 #endif /* !GAIM_PLUGINS */ |
5205 | 834 } |
835 | |
836 gboolean | |
837 gaim_plugin_is_loaded(const GaimPlugin *plugin) | |
838 { | |
839 g_return_val_if_fail(plugin != NULL, FALSE); | |
840 | |
841 return plugin->loaded; | |
842 } | |
843 | |
12695
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
844 gboolean |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
845 gaim_plugin_is_unloadable(const GaimPlugin *plugin) |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
846 { |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
847 g_return_val_if_fail(plugin != NULL, FALSE); |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
848 |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
849 return plugin->unloadable; |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
850 } |
0bc110c7ab91
[gaim-migrate @ 15038]
Richard Laager <rlaager@wiktel.com>
parents:
12623
diff
changeset
|
851 |
11772
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
852 const gchar * |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
853 gaim_plugin_get_id(const GaimPlugin *plugin) { |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
854 g_return_val_if_fail(plugin, NULL); |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
855 g_return_val_if_fail(plugin->info, NULL); |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
856 |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
857 return plugin->info->id; |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
858 } |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
859 |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
860 const gchar * |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
861 gaim_plugin_get_name(const GaimPlugin *plugin) { |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
862 g_return_val_if_fail(plugin, NULL); |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
863 g_return_val_if_fail(plugin->info, NULL); |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
864 |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
865 return plugin->info->name; |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
866 } |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
867 |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
868 const gchar * |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
869 gaim_plugin_get_version(const GaimPlugin *plugin) { |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
870 g_return_val_if_fail(plugin, NULL); |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
871 g_return_val_if_fail(plugin->info, NULL); |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
872 |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
873 return plugin->info->version; |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
874 } |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
875 |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
876 const gchar * |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
877 gaim_plugin_get_summary(const GaimPlugin *plugin) { |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
878 g_return_val_if_fail(plugin, NULL); |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
879 g_return_val_if_fail(plugin->info, NULL); |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
880 |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
881 return plugin->info->summary; |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
882 } |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
883 |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
884 const gchar * |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
885 gaim_plugin_get_description(const GaimPlugin *plugin) { |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
886 g_return_val_if_fail(plugin, NULL); |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
887 g_return_val_if_fail(plugin->info, NULL); |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
888 |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
889 return plugin->info->description; |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
890 } |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
891 |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
892 const gchar * |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
893 gaim_plugin_get_author(const GaimPlugin *plugin) { |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
894 g_return_val_if_fail(plugin, NULL); |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
895 g_return_val_if_fail(plugin->info, NULL); |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
896 |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
897 return plugin->info->author; |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
898 } |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
899 |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
900 const gchar * |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
901 gaim_plugin_get_homepage(const GaimPlugin *plugin) { |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
902 g_return_val_if_fail(plugin, NULL); |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
903 g_return_val_if_fail(plugin->info, NULL); |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
904 |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
905 return plugin->info->homepage; |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
906 } |
d1d5f27de95d
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
907 |
6822
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
908 /************************************************************************** |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
909 * Plugin IPC |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
910 **************************************************************************/ |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
911 static void |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
912 destroy_ipc_info(void *data) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
913 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
914 GaimPluginIpcCommand *ipc_command = (GaimPluginIpcCommand *)data; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
915 int i; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
916 |
9667
22928adecb84
[gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents:
9018
diff
changeset
|
917 if (ipc_command->params != NULL) |
22928adecb84
[gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents:
9018
diff
changeset
|
918 { |
22928adecb84
[gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents:
9018
diff
changeset
|
919 for (i = 0; i < ipc_command->num_params; i++) |
22928adecb84
[gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents:
9018
diff
changeset
|
920 gaim_value_destroy(ipc_command->params[i]); |
22928adecb84
[gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents:
9018
diff
changeset
|
921 |
22928adecb84
[gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents:
9018
diff
changeset
|
922 g_free(ipc_command->params); |
22928adecb84
[gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents:
9018
diff
changeset
|
923 } |
6822
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
924 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
925 if (ipc_command->ret_value != NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
926 gaim_value_destroy(ipc_command->ret_value); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
927 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
928 g_free(ipc_command); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
929 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
930 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
931 gboolean |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
932 gaim_plugin_ipc_register(GaimPlugin *plugin, const char *command, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
933 GaimCallback func, GaimSignalMarshalFunc marshal, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
934 GaimValue *ret_value, int num_params, ...) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
935 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
936 GaimPluginIpcInfo *ipc_info; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
937 GaimPluginIpcCommand *ipc_command; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
938 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
939 g_return_val_if_fail(plugin != NULL, FALSE); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
940 g_return_val_if_fail(command != NULL, FALSE); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
941 g_return_val_if_fail(func != NULL, FALSE); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
942 g_return_val_if_fail(marshal != NULL, FALSE); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
943 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
944 if (plugin->ipc_data == NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
945 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
946 ipc_info = plugin->ipc_data = g_new0(GaimPluginIpcInfo, 1); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
947 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
|
948 g_free, destroy_ipc_info); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
949 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
950 else |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
951 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
952 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
953 ipc_command = g_new0(GaimPluginIpcCommand, 1); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
954 ipc_command->func = func; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
955 ipc_command->marshal = marshal; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
956 ipc_command->num_params = num_params; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
957 ipc_command->ret_value = ret_value; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
958 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
959 if (num_params > 0) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
960 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
961 va_list args; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
962 int i; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
963 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
964 ipc_command->params = g_new0(GaimValue *, num_params); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
965 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
966 va_start(args, num_params); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
967 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
968 for (i = 0; i < num_params; i++) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
969 ipc_command->params[i] = va_arg(args, GaimValue *); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
970 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
971 va_end(args); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
972 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
973 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
974 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
|
975 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
976 ipc_info->command_count++; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
977 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
978 return TRUE; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
979 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
980 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
981 void |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
982 gaim_plugin_ipc_unregister(GaimPlugin *plugin, const char *command) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
983 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
984 GaimPluginIpcInfo *ipc_info; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
985 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
986 g_return_if_fail(plugin != NULL); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
987 g_return_if_fail(command != NULL); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
988 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
989 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
990 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
991 if (ipc_info == NULL || |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
992 g_hash_table_lookup(ipc_info->commands, command) == NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
993 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
994 gaim_debug_error("plugins", |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
995 "IPC command '%s' was not registered for plugin %s\n", |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
996 command, plugin->info->name); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
997 return; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
998 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
999 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1000 g_hash_table_remove(ipc_info->commands, command); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1001 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1002 ipc_info->command_count--; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1003 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1004 if (ipc_info->command_count == 0) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1005 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1006 g_hash_table_destroy(ipc_info->commands); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1007 g_free(ipc_info); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1008 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1009 plugin->ipc_data = NULL; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1010 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1011 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1012 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1013 void |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1014 gaim_plugin_ipc_unregister_all(GaimPlugin *plugin) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1015 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1016 GaimPluginIpcInfo *ipc_info; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1017 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1018 g_return_if_fail(plugin != NULL); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1019 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1020 if (plugin->ipc_data == NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1021 return; /* Silently ignore it. */ |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1022 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1023 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1024 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1025 g_hash_table_destroy(ipc_info->commands); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1026 g_free(ipc_info); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1027 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1028 plugin->ipc_data = NULL; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1029 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1030 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1031 gboolean |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1032 gaim_plugin_ipc_get_params(GaimPlugin *plugin, const char *command, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1033 GaimValue **ret_value, int *num_params, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1034 GaimValue ***params) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1035 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1036 GaimPluginIpcInfo *ipc_info; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1037 GaimPluginIpcCommand *ipc_command; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1038 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1039 g_return_val_if_fail(plugin != NULL, FALSE); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1040 g_return_val_if_fail(command != NULL, FALSE); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1041 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1042 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1043 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1044 if (ipc_info == NULL || |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1045 (ipc_command = g_hash_table_lookup(ipc_info->commands, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1046 command)) == NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1047 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1048 gaim_debug_error("plugins", |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1049 "IPC command '%s' was not registered for plugin %s\n", |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1050 command, plugin->info->name); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1051 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1052 return FALSE; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1053 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1054 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1055 if (num_params != NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1056 *num_params = ipc_command->num_params; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1057 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1058 if (params != NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1059 *params = ipc_command->params; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1060 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1061 if (ret_value != NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1062 *ret_value = ipc_command->ret_value; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1063 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1064 return TRUE; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1065 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1066 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1067 void * |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1068 gaim_plugin_ipc_call(GaimPlugin *plugin, const char *command, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1069 gboolean *ok, ...) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1070 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1071 GaimPluginIpcInfo *ipc_info; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1072 GaimPluginIpcCommand *ipc_command; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1073 va_list args; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1074 void *ret_value; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1075 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1076 if (ok != NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1077 *ok = FALSE; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1078 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1079 g_return_val_if_fail(plugin != NULL, NULL); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1080 g_return_val_if_fail(command != NULL, NULL); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1081 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1082 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1083 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1084 if (ipc_info == NULL || |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1085 (ipc_command = g_hash_table_lookup(ipc_info->commands, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1086 command)) == NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1087 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1088 gaim_debug_error("plugins", |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1089 "IPC command '%s' was not registered for plugin %s\n", |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1090 command, plugin->info->name); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1091 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1092 return NULL; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1093 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1094 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1095 va_start(args, ok); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1096 ipc_command->marshal(ipc_command->func, args, NULL, &ret_value); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1097 va_end(args); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1098 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1099 if (ok != NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1100 *ok = TRUE; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1101 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1102 return ret_value; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1103 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1104 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1105 /************************************************************************** |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1106 * Plugins subsystem |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1107 **************************************************************************/ |
10479 | 1108 void * |
1109 gaim_plugins_get_handle(void) { | |
1110 static int handle; | |
1111 | |
1112 return &handle; | |
1113 } | |
1114 | |
1115 void | |
1116 gaim_plugins_init(void) { | |
1117 void *handle = gaim_plugins_get_handle(); | |
1118 | |
1119 gaim_signal_register(handle, "plugin-load", | |
1120 gaim_marshal_VOID__POINTER, | |
1121 NULL, 1, | |
1122 gaim_value_new(GAIM_TYPE_SUBTYPE, | |
1123 GAIM_SUBTYPE_PLUGIN)); | |
1124 gaim_signal_register(handle, "plugin-unload", | |
1125 gaim_marshal_VOID__POINTER, | |
1126 NULL, 1, | |
1127 gaim_value_new(GAIM_TYPE_SUBTYPE, | |
1128 GAIM_SUBTYPE_PLUGIN)); | |
1129 } | |
1130 | |
1131 void | |
1132 gaim_plugins_uninit(void) { | |
1133 gaim_signals_disconnect_by_handle(gaim_plugins_get_handle()); | |
1134 } | |
1135 | |
1136 /************************************************************************** | |
1137 * Plugins API | |
1138 **************************************************************************/ | |
5205 | 1139 void |
10447 | 1140 gaim_plugins_add_search_path(const char *path) |
5205 | 1141 { |
10447 | 1142 g_return_if_fail(path != NULL); |
5205 | 1143 |
10447 | 1144 if (g_list_find_custom(search_paths, path, (GCompareFunc)strcmp)) |
1145 return; | |
5205 | 1146 |
10447 | 1147 search_paths = g_list_append(search_paths, strdup(path)); |
5205 | 1148 } |
1149 | |
1150 void | |
1151 gaim_plugins_unload_all(void) | |
1152 { | |
1153 #ifdef GAIM_PLUGINS | |
1154 | |
1155 while (loaded_plugins != NULL) | |
1156 gaim_plugin_unload(loaded_plugins->data); | |
1157 | |
1158 #endif /* GAIM_PLUGINS */ | |
1159 } | |
1160 | |
1161 void | |
5242
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1162 gaim_plugins_destroy_all(void) |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1163 { |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1164 #ifdef GAIM_PLUGINS |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1165 |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1166 while (plugins != NULL) |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1167 gaim_plugin_destroy(plugins->data); |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1168 |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1169 #endif /* GAIM_PLUGINS */ |
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1170 } |
5838 | 1171 |
1172 void | |
5949
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
1173 gaim_plugins_load_saved(const char *key) |
5838 | 1174 { |
1175 #ifdef GAIM_PLUGINS | |
5949
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
1176 GList *f, *files; |
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
1177 |
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
1178 g_return_if_fail(key != NULL); |
5838 | 1179 |
5949
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
1180 files = gaim_prefs_get_string_list(key); |
90d0849abd3c
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
1181 |
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1182 for (f = files; f; f = f->next) |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1183 { |
10682 | 1184 char *filename; |
1185 char *basename; | |
1186 GaimPlugin *plugin; | |
1187 | |
1188 if (f->data == NULL) | |
1189 continue; | |
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1190 |
10682 | 1191 filename = f->data; |
1192 /* | |
1193 * We don't know if the filename uses Windows or Unix path | |
1194 * separators (because people might be sharing a prefs.xml | |
1195 * file across systems), so we find the last occurrence | |
1196 * of either. | |
1197 */ | |
1198 basename = strrchr(filename, '/'); | |
1199 if ((basename == NULL) || (basename < strrchr(filename, '\\'))) | |
1200 basename = strrchr(filename, '\\'); | |
1201 if (basename != NULL) | |
1202 basename++; | |
1203 | |
1204 if ((plugin = gaim_plugins_find_with_filename(filename)) != NULL) | |
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1205 { |
10682 | 1206 gaim_debug_info("plugins", "Loading saved plugin %s\n", |
1207 plugin->path); | |
1208 gaim_plugin_load(plugin); | |
1209 } | |
1210 else if ((plugin = gaim_plugins_find_with_basename(basename)) != NULL) | |
1211 { | |
1212 gaim_debug_info("plugins", "Loading saved plugin %s\n", | |
1213 plugin->path); | |
1214 gaim_plugin_load(plugin); | |
1215 } | |
1216 else | |
1217 { | |
1218 gaim_debug_error("plugins", "Unable to find saved plugin %s\n", | |
1219 filename); | |
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1220 } |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1221 |
5838 | 1222 g_free(f->data); |
1223 } | |
1224 | |
1225 g_list_free(files); | |
1226 #endif /* GAIM_PLUGINS */ | |
1227 } | |
1228 | |
1229 | |
5242
fd81a00480ac
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1230 void |
5205 | 1231 gaim_plugins_probe(const char *ext) |
1232 { | |
1233 #ifdef GAIM_PLUGINS | |
1234 GDir *dir; | |
1235 const gchar *file; | |
1236 gchar *path; | |
1237 GaimPlugin *plugin; | |
10447 | 1238 GList *cur; |
1239 const char *search_path; | |
5205 | 1240 |
1241 if (!g_module_supported()) | |
1242 return; | |
1243 | |
10447 | 1244 /* Probe plugins */ |
1245 for (cur = search_paths; cur != NULL; cur = cur->next) | |
1246 { | |
1247 search_path = cur->data; | |
5205 | 1248 |
10447 | 1249 dir = g_dir_open(search_path, 0, NULL); |
5205 | 1250 |
10447 | 1251 if (dir != NULL) |
1252 { | |
1253 while ((file = g_dir_read_name(dir)) != NULL) | |
1254 { | |
1255 path = g_build_filename(search_path, file, NULL); | |
5205 | 1256 |
10447 | 1257 if (ext == NULL || has_file_extension(file, ext)) |
5205 | 1258 plugin = gaim_plugin_probe(path); |
1259 | |
1260 g_free(path); | |
1261 } | |
1262 | |
1263 g_dir_close(dir); | |
1264 } | |
1265 } | |
1266 | |
10447 | 1267 /* See if we have any plugins waiting to load */ |
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1268 while (load_queue != NULL) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1269 { |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1270 plugin = (GaimPlugin *)load_queue->data; |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1271 |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1272 load_queue = g_list_remove(load_queue, plugin); |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1273 |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1274 if (plugin == NULL || plugin->info == NULL) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1275 continue; |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1276 |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1277 if (plugin->info->type == GAIM_PLUGIN_LOADER) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1278 { |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1279 /* We'll just load this right now. */ |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1280 if (!gaim_plugin_load(plugin)) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1281 { |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1282 gaim_plugin_destroy(plugin); |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1283 |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1284 continue; |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1285 } |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1286 |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1287 plugin_loaders = g_list_append(plugin_loaders, plugin); |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1288 |
10447 | 1289 for (cur = GAIM_PLUGIN_LOADER_INFO(plugin)->exts; |
1290 cur != NULL; | |
1291 cur = cur->next) | |
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1292 { |
10447 | 1293 gaim_plugins_probe(cur->data); |
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1294 } |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1295 } |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1296 else if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1297 { |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1298 /* We'll just load this right now. */ |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1299 if (!gaim_plugin_load(plugin)) |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1300 { |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1301 gaim_plugin_destroy(plugin); |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1302 |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1303 continue; |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1304 } |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1305 |
11950 | 1306 /* Make sure we don't load two PRPLs with the same name? */ |
7956 | 1307 if (gaim_find_prpl(plugin->info->id)) |
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1308 { |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1309 /* Nothing to see here--move along, move along */ |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1310 gaim_plugin_destroy(plugin); |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1311 |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1312 continue; |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1313 } |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1314 |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1315 protocol_plugins = g_list_insert_sorted(protocol_plugins, plugin, |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1316 (GCompareFunc)compare_prpl); |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1317 } |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1318 } |
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1319 |
5205 | 1320 if (probe_cb != NULL) |
1321 probe_cb(probe_cb_data); | |
1322 #endif /* GAIM_PLUGINS */ | |
1323 } | |
1324 | |
1325 gboolean | |
1326 gaim_plugin_register(GaimPlugin *plugin) | |
1327 { | |
1328 g_return_val_if_fail(plugin != NULL, FALSE); | |
1329 | |
10447 | 1330 /* If this plugin has been registered already then exit */ |
5205 | 1331 if (g_list_find(plugins, plugin)) |
1332 return TRUE; | |
1333 | |
10447 | 1334 /* Ensure the plugin has the requisite information */ |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1335 if (plugin->info->type == GAIM_PLUGIN_LOADER) |
6981
abd3c684da31
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1336 { |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1337 GaimPluginLoaderInfo *loader_info; |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1338 |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1339 loader_info = GAIM_PLUGIN_LOADER_INFO(plugin); |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1340 |
9943 | 1341 if (loader_info == NULL) |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1342 { |
10447 | 1343 gaim_debug_error("plugins", "%s is unloadable\n", |
9943 | 1344 plugin->path); |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1345 return FALSE; |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1346 } |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1347 } |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1348 else if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1349 { |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1350 GaimPluginProtocolInfo *prpl_info; |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1351 |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1352 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1353 |
9943 | 1354 if (prpl_info == NULL) |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1355 { |
10447 | 1356 gaim_debug_error("plugins", "%s is unloadable\n", |
9943 | 1357 plugin->path); |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1358 return FALSE; |
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1359 } |
10447 | 1360 } |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1361 |
11950 | 1362 #ifdef GAIM_PLUGINS |
10447 | 1363 /* This plugin should be probed and maybe loaded--add it to the queue */ |
1364 load_queue = g_list_append(load_queue, plugin); | |
11950 | 1365 #else |
12081 | 1366 if (plugin->info != NULL) |
1367 { | |
1368 if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) | |
1369 protocol_plugins = g_list_insert_sorted(protocol_plugins, plugin, | |
1370 (GCompareFunc)compare_prpl); | |
1371 if (plugin->info->load != NULL) | |
1372 if (!plugin->info->load(plugin)) | |
1373 return FALSE; | |
1374 } | |
11950 | 1375 #endif |
5205 | 1376 |
1377 plugins = g_list_append(plugins, plugin); | |
1378 | |
1379 return TRUE; | |
1380 } | |
1381 | |
1382 gboolean | |
1383 gaim_plugins_enabled(void) | |
1384 { | |
1385 #ifdef GAIM_PLUGINS | |
1386 return TRUE; | |
1387 #else | |
1388 return FALSE; | |
1389 #endif | |
1390 } | |
1391 | |
1392 void | |
1393 gaim_plugins_register_probe_notify_cb(void (*func)(void *), void *data) | |
1394 { | |
1395 /* TODO */ | |
1396 probe_cb = func; | |
1397 probe_cb_data = data; | |
1398 } | |
1399 | |
1400 void | |
1401 gaim_plugins_unregister_probe_notify_cb(void (*func)(void *)) | |
1402 { | |
1403 /* TODO */ | |
1404 probe_cb = NULL; | |
1405 probe_cb_data = NULL; | |
1406 } | |
1407 | |
1408 void | |
1409 gaim_plugins_register_load_notify_cb(void (*func)(GaimPlugin *, void *), | |
1410 void *data) | |
1411 { | |
1412 /* TODO */ | |
1413 load_cb = func; | |
1414 load_cb_data = data; | |
1415 } | |
1416 | |
1417 void | |
1418 gaim_plugins_unregister_load_notify_cb(void (*func)(GaimPlugin *, void *)) | |
1419 { | |
1420 /* TODO */ | |
1421 load_cb = NULL; | |
1422 load_cb_data = NULL; | |
1423 } | |
1424 | |
1425 void | |
1426 gaim_plugins_register_unload_notify_cb(void (*func)(GaimPlugin *, void *), | |
1427 void *data) | |
1428 { | |
1429 /* TODO */ | |
1430 unload_cb = func; | |
1431 unload_cb_data = data; | |
1432 } | |
1433 | |
1434 void | |
1435 gaim_plugins_unregister_unload_notify_cb(void (*func)(GaimPlugin *, void *)) | |
1436 { | |
1437 /* TODO */ | |
1438 unload_cb = NULL; | |
1439 unload_cb_data = NULL; | |
1440 } | |
1441 | |
1442 GaimPlugin * | |
1443 gaim_plugins_find_with_name(const char *name) | |
1444 { | |
1445 GaimPlugin *plugin; | |
1446 GList *l; | |
1447 | |
1448 for (l = plugins; l != NULL; l = l->next) { | |
1449 plugin = l->data; | |
1450 | |
1451 if (!strcmp(plugin->info->name, name)) | |
1452 return plugin; | |
1453 } | |
1454 | |
1455 return NULL; | |
1456 } | |
1457 | |
1458 GaimPlugin * | |
1459 gaim_plugins_find_with_filename(const char *filename) | |
1460 { | |
1461 GaimPlugin *plugin; | |
1462 GList *l; | |
1463 | |
1464 for (l = plugins; l != NULL; l = l->next) { | |
1465 plugin = l->data; | |
1466 | |
1467 if (plugin->path != NULL && !strcmp(plugin->path, filename)) | |
1468 return plugin; | |
1469 } | |
1470 | |
1471 return NULL; | |
1472 } | |
1473 | |
1474 GaimPlugin * | |
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1475 gaim_plugins_find_with_basename(const char *basename) |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1476 { |
11950 | 1477 #ifdef GAIM_PLUGINS |
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1478 GaimPlugin *plugin; |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1479 GList *l; |
10682 | 1480 char *basename_no_ext; |
1481 char *tmp; | |
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1482 |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1483 g_return_val_if_fail(basename != NULL, NULL); |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1484 |
10682 | 1485 basename_no_ext = gaim_plugin_get_basename(basename); |
1486 | |
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1487 for (l = plugins; l != NULL; l = l->next) |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1488 { |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1489 plugin = (GaimPlugin *)l->data; |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1490 |
7278 | 1491 if (plugin->path != NULL) { |
10682 | 1492 tmp = gaim_plugin_get_basename(plugin->path); |
1493 if (!strcmp(tmp, basename_no_ext)) | |
1494 { | |
7278 | 1495 g_free(tmp); |
10682 | 1496 g_free(basename_no_ext); |
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1497 return plugin; |
7278 | 1498 } |
7279 | 1499 g_free(tmp); |
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1500 } |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1501 } |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1502 |
10682 | 1503 g_free(basename_no_ext); |
11950 | 1504 #endif /* GAIM_PLUGINS */ |
10682 | 1505 |
7033
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1506 return NULL; |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1507 } |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1508 |
cf1126ba1834
[gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1509 GaimPlugin * |
5205 | 1510 gaim_plugins_find_with_id(const char *id) |
1511 { | |
1512 GaimPlugin *plugin; | |
1513 GList *l; | |
1514 | |
1515 g_return_val_if_fail(id != NULL, NULL); | |
1516 | |
6486
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1517 for (l = plugins; l != NULL; l = l->next) |
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1518 { |
5205 | 1519 plugin = l->data; |
1520 | |
6486
fab81e4b885c
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1521 if (plugin->info->id != NULL && !strcmp(plugin->info->id, id)) |
5205 | 1522 return plugin; |
1523 } | |
1524 | |
1525 return NULL; | |
1526 } | |
1527 | |
1528 GList * | |
1529 gaim_plugins_get_loaded(void) | |
1530 { | |
1531 return loaded_plugins; | |
1532 } | |
1533 | |
1534 GList * | |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1535 gaim_plugins_get_protocols(void) |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1536 { |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1537 return protocol_plugins; |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1538 } |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1539 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1540 GList * |
5205 | 1541 gaim_plugins_get_all(void) |
1542 { | |
1543 return plugins; | |
1544 } | |
1545 | |
9015 | 1546 |
1547 GaimPluginAction * | |
1548 gaim_plugin_action_new(char* label, void (*callback)(GaimPluginAction *)) | |
1549 { | |
1550 GaimPluginAction *act = g_new0(GaimPluginAction, 1); | |
9018 | 1551 |
9015 | 1552 act->label = label; |
1553 act->callback = callback; | |
9018 | 1554 |
1555 return act; | |
9015 | 1556 } |