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