Sat, 24 Mar 2007 20:25:01 +0000
A small fix to the patch from ecoffey: Gary pointed out that the strcmp()
was unnecessary and that the logic could be made more clear.
| 5205 | 1 | /* |
| 15884 | 2 | * purple |
| 5205 | 3 | * |
| 15884 | 4 | * Purple is the legal property of its developers, whose names are too numerous |
| 8046 | 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
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
22 | #include "internal.h" |
| 5205 | 23 | |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
24 | #include "accountopt.h" |
|
14787
2adb9bac76b5
[gaim-migrate @ 17479]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14254
diff
changeset
|
25 | #include "core.h" |
|
13136
0438506e90ac
[gaim-migrate @ 15497]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13107
diff
changeset
|
26 | #include "dbus-maybe.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
27 | #include "debug.h" |
|
5436
a0e0bacaa196
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5357
diff
changeset
|
28 | #include "notify.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
29 | #include "prefs.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
30 | #include "prpl.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5840
diff
changeset
|
31 | #include "request.h" |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6432
diff
changeset
|
32 | #include "signals.h" |
|
12695
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
33 | #include "util.h" |
| 9943 | 34 | #include "version.h" |
| 5205 | 35 | |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
36 | typedef struct |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
37 | { |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
38 | GHashTable *commands; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
39 | size_t command_count; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
40 | |
| 15884 | 41 | } PurplePluginIpcInfo; |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
42 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
43 | typedef struct |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
44 | { |
| 15884 | 45 | PurpleCallback func; |
| 46 | PurpleSignalMarshalFunc marshal; | |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
47 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
48 | int num_params; |
| 15884 | 49 | PurpleValue **params; |
| 50 | PurpleValue *ret_value; | |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
51 | |
| 15884 | 52 | } PurplePluginIpcCommand; |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
53 | |
|
10447
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
54 | static GList *search_paths = NULL; |
|
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
55 | static GList *plugins = NULL; |
|
11950
a522c2da66e5
[gaim-migrate @ 14241]
Evan Schoenberg <evands@pidgin.im>
parents:
11772
diff
changeset
|
56 | static GList *loaded_plugins = NULL; |
|
a522c2da66e5
[gaim-migrate @ 14241]
Evan Schoenberg <evands@pidgin.im>
parents:
11772
diff
changeset
|
57 | static GList *protocol_plugins = NULL; |
| 15884 | 58 | #ifdef PURPLE_PLUGINS |
|
10447
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
59 | static GList *load_queue = NULL; |
|
6981
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
60 | static GList *plugin_loaders = NULL; |
|
11950
a522c2da66e5
[gaim-migrate @ 14241]
Evan Schoenberg <evands@pidgin.im>
parents:
11772
diff
changeset
|
61 | #endif |
| 5205 | 62 | |
|
11963
3af2d2a60564
[gaim-migrate @ 14254]
Mark Doliner <markdoliner@pidgin.im>
parents:
11950
diff
changeset
|
63 | /* |
|
3af2d2a60564
[gaim-migrate @ 14254]
Mark Doliner <markdoliner@pidgin.im>
parents:
11950
diff
changeset
|
64 | * TODO: I think the intention was to allow multiple load and unload |
|
3af2d2a60564
[gaim-migrate @ 14254]
Mark Doliner <markdoliner@pidgin.im>
parents:
11950
diff
changeset
|
65 | * callback functions. Perhaps using a GList instead of a |
|
3af2d2a60564
[gaim-migrate @ 14254]
Mark Doliner <markdoliner@pidgin.im>
parents:
11950
diff
changeset
|
66 | * pointer to a single function. |
|
3af2d2a60564
[gaim-migrate @ 14254]
Mark Doliner <markdoliner@pidgin.im>
parents:
11950
diff
changeset
|
67 | */ |
| 5205 | 68 | static void (*probe_cb)(void *) = NULL; |
| 69 | static void *probe_cb_data = NULL; | |
| 15884 | 70 | static void (*load_cb)(PurplePlugin *, void *) = NULL; |
| 5205 | 71 | static void *load_cb_data = NULL; |
| 15884 | 72 | static void (*unload_cb)(PurplePlugin *, void *) = NULL; |
| 5205 | 73 | static void *unload_cb_data = NULL; |
| 74 | ||
| 15884 | 75 | #ifdef PURPLE_PLUGINS |
|
11950
a522c2da66e5
[gaim-migrate @ 14241]
Evan Schoenberg <evands@pidgin.im>
parents:
11772
diff
changeset
|
76 | |
|
10447
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
77 | static gboolean |
|
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
78 | has_file_extension(const char *filename, const char *ext) |
| 5205 | 79 | { |
| 80 | int len, extlen; | |
| 81 | ||
| 82 | if (filename == NULL || *filename == '\0' || ext == NULL) | |
| 83 | return 0; | |
| 84 | ||
| 85 | extlen = strlen(ext); | |
| 86 | len = strlen(filename) - extlen; | |
| 87 | ||
| 88 | if (len < 0) | |
| 89 | return 0; | |
| 90 | ||
|
10447
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
91 | return (strncmp(filename + len, ext, extlen) == 0); |
| 5205 | 92 | } |
| 93 | ||
| 94 | static gboolean | |
|
10682
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
95 | is_native(const char *filename) |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
96 | { |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
97 | const char *last_period; |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
98 | |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
99 | last_period = strrchr(filename, '.'); |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
100 | if (last_period == NULL) |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
101 | return FALSE; |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
102 | |
|
12077
484da2b29933
[gaim-migrate @ 14374]
Mark Doliner <markdoliner@pidgin.im>
parents:
12066
diff
changeset
|
103 | return !(strcmp(last_period, ".dll") & |
|
484da2b29933
[gaim-migrate @ 14374]
Mark Doliner <markdoliner@pidgin.im>
parents:
12066
diff
changeset
|
104 | strcmp(last_period, ".sl") & |
|
484da2b29933
[gaim-migrate @ 14374]
Mark Doliner <markdoliner@pidgin.im>
parents:
12066
diff
changeset
|
105 | strcmp(last_period, ".so")); |
|
10682
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
106 | } |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
107 | |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
108 | static char * |
| 15884 | 109 | purple_plugin_get_basename(const char *filename) |
|
10682
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
110 | { |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
111 | const char *basename; |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
112 | const char *last_period; |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
113 | |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
114 | basename = strrchr(filename, G_DIR_SEPARATOR); |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
115 | if (basename != NULL) |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
116 | basename++; |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
117 | else |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
118 | basename = filename; |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
119 | |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
120 | if (is_native(basename) && |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
121 | ((last_period = strrchr(basename, '.')) != NULL)) |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
122 | return g_strndup(basename, (last_period - basename)); |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
123 | |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
124 | return g_strdup(basename); |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
125 | } |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
126 | |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
127 | static gboolean |
| 15884 | 128 | loader_supports_file(PurplePlugin *loader, const char *filename) |
| 5205 | 129 | { |
| 6432 | 130 | GList *exts; |
| 5205 | 131 | |
| 15884 | 132 | for (exts = PURPLE_PLUGIN_LOADER_INFO(loader)->exts; exts != NULL; exts = exts->next) { |
|
10447
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
133 | if (has_file_extension(filename, (char *)exts->data)) { |
| 6432 | 134 | return TRUE; |
| 5205 | 135 | } |
| 136 | } | |
| 137 | ||
| 138 | return FALSE; | |
| 139 | } | |
| 140 | ||
| 15884 | 141 | static PurplePlugin * |
| 142 | find_loader_for_plugin(const PurplePlugin *plugin) | |
| 5205 | 143 | { |
| 15884 | 144 | PurplePlugin *loader; |
| 5205 | 145 | GList *l; |
| 146 | ||
| 147 | if (plugin->path == NULL) | |
| 148 | return NULL; | |
| 149 | ||
| 15884 | 150 | for (l = purple_plugins_get_loaded(); l != NULL; l = l->next) { |
| 5205 | 151 | loader = l->data; |
| 152 | ||
| 15884 | 153 | if (loader->info->type == PURPLE_PLUGIN_LOADER && |
|
5794
ebdbb7dc6658
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
154 | loader_supports_file(loader, plugin->path)) { |
| 5205 | 155 | |
| 156 | return loader; | |
| 157 | } | |
| 158 | ||
| 159 | loader = NULL; | |
| 160 | } | |
| 161 | ||
| 162 | return NULL; | |
| 163 | } | |
| 164 | ||
| 15884 | 165 | #endif /* PURPLE_PLUGINS */ |
|
5449
4c350eb7d4a0
[gaim-migrate @ 5836]
Decklin Foster <decklin@red-bean.com>
parents:
5443
diff
changeset
|
166 | |
|
10447
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
167 | /** |
|
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
168 | * Negative if a before b, 0 if equal, positive if a after b. |
|
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
169 | */ |
| 5205 | 170 | static gint |
| 15884 | 171 | compare_prpl(PurplePlugin *a, PurplePlugin *b) |
| 5205 | 172 | { |
| 15884 | 173 | if(PURPLE_IS_PROTOCOL_PLUGIN(a)) { |
| 174 | if(PURPLE_IS_PROTOCOL_PLUGIN(b)) | |
| 7956 | 175 | return strcmp(a->info->name, b->info->name); |
| 176 | else | |
| 177 | return -1; | |
| 178 | } else { | |
| 15884 | 179 | if(PURPLE_IS_PROTOCOL_PLUGIN(b)) |
| 7956 | 180 | return 1; |
| 181 | else | |
| 182 | return 0; | |
| 183 | } | |
| 5205 | 184 | } |
| 185 | ||
| 15884 | 186 | PurplePlugin * |
| 187 | purple_plugin_new(gboolean native, const char *path) | |
| 5205 | 188 | { |
| 15884 | 189 | PurplePlugin *plugin; |
| 5205 | 190 | |
| 15884 | 191 | plugin = g_new0(PurplePlugin, 1); |
| 5205 | 192 | |
| 193 | plugin->native_plugin = native; | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14024
diff
changeset
|
194 | plugin->path = g_strdup(path); |
| 5205 | 195 | |
| 15884 | 196 | PURPLE_DBUS_REGISTER_POINTER(plugin, PurplePlugin); |
|
13136
0438506e90ac
[gaim-migrate @ 15497]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13107
diff
changeset
|
197 | |
| 5205 | 198 | return plugin; |
| 199 | } | |
| 200 | ||
| 15884 | 201 | PurplePlugin * |
| 202 | purple_plugin_probe(const char *filename) | |
| 5205 | 203 | { |
| 15884 | 204 | #ifdef PURPLE_PLUGINS |
| 205 | PurplePlugin *plugin = NULL; | |
| 206 | PurplePlugin *loader; | |
| 10124 | 207 | gpointer unpunned; |
|
12342
da61b726d595
[gaim-migrate @ 14646]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12332
diff
changeset
|
208 | gchar *basename = NULL; |
| 15884 | 209 | gboolean (*purple_init_plugin)(PurplePlugin *); |
| 5205 | 210 | |
| 15884 | 211 | purple_debug_misc("plugins", "probing %s\n", filename); |
| 5205 | 212 | g_return_val_if_fail(filename != NULL, NULL); |
| 213 | ||
|
5973
adc75f0fcaa3
[gaim-migrate @ 6420]
Mark Doliner <markdoliner@pidgin.im>
parents:
5949
diff
changeset
|
214 | if (!g_file_test(filename, G_FILE_TEST_EXISTS)) |
|
adc75f0fcaa3
[gaim-migrate @ 6420]
Mark Doliner <markdoliner@pidgin.im>
parents:
5949
diff
changeset
|
215 | return NULL; |
|
adc75f0fcaa3
[gaim-migrate @ 6420]
Mark Doliner <markdoliner@pidgin.im>
parents:
5949
diff
changeset
|
216 | |
|
10447
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
217 | /* If this plugin has already been probed then exit */ |
| 15884 | 218 | basename = purple_plugin_get_basename(filename); |
| 219 | plugin = purple_plugins_find_with_basename(basename); | |
|
12342
da61b726d595
[gaim-migrate @ 14646]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12332
diff
changeset
|
220 | g_free(basename); |
| 5205 | 221 | if (plugin != NULL) |
|
12342
da61b726d595
[gaim-migrate @ 14646]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12332
diff
changeset
|
222 | { |
|
12695
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
223 | if (!strcmp(filename, plugin->path)) |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
224 | return plugin; |
| 15884 | 225 | else if (!purple_plugin_is_unloadable(plugin)) |
|
12695
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
226 | { |
| 15884 | 227 | purple_debug_info("plugins", "Not loading %s. " |
|
12342
da61b726d595
[gaim-migrate @ 14646]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12332
diff
changeset
|
228 | "Another plugin with the same name (%s) has already been loaded.\n", |
|
da61b726d595
[gaim-migrate @ 14646]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12332
diff
changeset
|
229 | filename, plugin->path); |
|
12695
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
230 | return plugin; |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
231 | } |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
232 | else |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
233 | { |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
234 | /* The old plugin was a different file and it was unloadable. |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
235 | * There's no guarantee that this new file with the same name |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
236 | * will be loadable, but unless it fails in one of the silent |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
237 | * ways and the first one didn't, it's not any worse. The user |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
238 | * will still see a greyed-out plugin, which is what we want. */ |
| 15884 | 239 | purple_plugin_destroy(plugin); |
|
12695
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
240 | } |
|
12342
da61b726d595
[gaim-migrate @ 14646]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12332
diff
changeset
|
241 | } |
| 5205 | 242 | |
| 15884 | 243 | plugin = purple_plugin_new(has_file_extension(filename, G_MODULE_SUFFIX), filename); |
| 5205 | 244 | |
|
12699
81611fa7a208
[gaim-migrate @ 15042]
Richard Laager <rlaager@pidgin.im>
parents:
12696
diff
changeset
|
245 | if (plugin->native_plugin) { |
|
81611fa7a208
[gaim-migrate @ 15042]
Richard Laager <rlaager@pidgin.im>
parents:
12696
diff
changeset
|
246 | const char *error; |
|
12623
4f1fe7e1f808
[gaim-migrate @ 14959]
Daniel Atallah <datallah@pidgin.im>
parents:
12342
diff
changeset
|
247 | #ifdef _WIN32 |
|
4f1fe7e1f808
[gaim-migrate @ 14959]
Daniel Atallah <datallah@pidgin.im>
parents:
12342
diff
changeset
|
248 | /* Suppress error popups for failing to load plugins */ |
|
4f1fe7e1f808
[gaim-migrate @ 14959]
Daniel Atallah <datallah@pidgin.im>
parents:
12342
diff
changeset
|
249 | UINT old_error_mode = SetErrorMode(SEM_FAILCRITICALERRORS); |
|
4f1fe7e1f808
[gaim-migrate @ 14959]
Daniel Atallah <datallah@pidgin.im>
parents:
12342
diff
changeset
|
250 | #endif |
| 12696 | 251 | |
|
10737
c7759d698996
[gaim-migrate @ 12339]
Mark Doliner <markdoliner@pidgin.im>
parents:
10682
diff
changeset
|
252 | /* |
|
10950
72a6cc0fc7a8
[gaim-migrate @ 12750]
Richard Laager <rlaager@pidgin.im>
parents:
10884
diff
changeset
|
253 | * We pass G_MODULE_BIND_LOCAL here to prevent symbols from |
|
72a6cc0fc7a8
[gaim-migrate @ 12750]
Richard Laager <rlaager@pidgin.im>
parents:
10884
diff
changeset
|
254 | * plugins being added to the global name space. |
|
11378
5857f76fb6b2
[gaim-migrate @ 13604]
Mark Doliner <markdoliner@pidgin.im>
parents:
11256
diff
changeset
|
255 | * |
|
5857f76fb6b2
[gaim-migrate @ 13604]
Mark Doliner <markdoliner@pidgin.im>
parents:
11256
diff
changeset
|
256 | * G_MODULE_BIND_LOCAL was added in glib 2.3.3. |
|
11950
a522c2da66e5
[gaim-migrate @ 14241]
Evan Schoenberg <evands@pidgin.im>
parents:
11772
diff
changeset
|
257 | * TODO: I guess there's nothing we can do about that? |
|
10737
c7759d698996
[gaim-migrate @ 12339]
Mark Doliner <markdoliner@pidgin.im>
parents:
10682
diff
changeset
|
258 | */ |
|
11378
5857f76fb6b2
[gaim-migrate @ 13604]
Mark Doliner <markdoliner@pidgin.im>
parents:
11256
diff
changeset
|
259 | #if GLIB_CHECK_VERSION(2,3,3) |
|
10884
672f44600655
[gaim-migrate @ 12582]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10737
diff
changeset
|
260 | plugin->handle = g_module_open(filename, G_MODULE_BIND_LOCAL); |
|
11378
5857f76fb6b2
[gaim-migrate @ 13604]
Mark Doliner <markdoliner@pidgin.im>
parents:
11256
diff
changeset
|
261 | #else |
|
5857f76fb6b2
[gaim-migrate @ 13604]
Mark Doliner <markdoliner@pidgin.im>
parents:
11256
diff
changeset
|
262 | plugin->handle = g_module_open(filename, 0); |
|
5857f76fb6b2
[gaim-migrate @ 13604]
Mark Doliner <markdoliner@pidgin.im>
parents:
11256
diff
changeset
|
263 | #endif |
| 5205 | 264 | |
|
10447
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
265 | if (plugin->handle == NULL) |
|
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
266 | { |
|
12695
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
267 | const char *error = g_module_error(); |
| 15884 | 268 | if (error != NULL && purple_str_has_prefix(error, filename)) |
|
12695
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
269 | { |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
270 | error = error + strlen(filename); |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
271 | |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
272 | /* These are just so we don't crash. If we |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
273 | * got this far, they should always be true. */ |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
274 | if (*error == ':') |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
275 | error++; |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
276 | if (*error == ' ') |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
277 | error++; |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
278 | } |
| 5205 | 279 | |
|
12704
f4cbb5550f67
[gaim-migrate @ 15047]
Richard Laager <rlaager@pidgin.im>
parents:
12703
diff
changeset
|
280 | if (error == NULL || !*error) |
|
f4cbb5550f67
[gaim-migrate @ 15047]
Richard Laager <rlaager@pidgin.im>
parents:
12703
diff
changeset
|
281 | { |
|
f4cbb5550f67
[gaim-migrate @ 15047]
Richard Laager <rlaager@pidgin.im>
parents:
12703
diff
changeset
|
282 | plugin->error = g_strdup(_("Unknown error")); |
| 15884 | 283 | purple_debug_error("plugins", "%s is not loadable: Unknown error\n", |
|
12704
f4cbb5550f67
[gaim-migrate @ 15047]
Richard Laager <rlaager@pidgin.im>
parents:
12703
diff
changeset
|
284 | plugin->path); |
|
f4cbb5550f67
[gaim-migrate @ 15047]
Richard Laager <rlaager@pidgin.im>
parents:
12703
diff
changeset
|
285 | } |
|
f4cbb5550f67
[gaim-migrate @ 15047]
Richard Laager <rlaager@pidgin.im>
parents:
12703
diff
changeset
|
286 | else |
|
f4cbb5550f67
[gaim-migrate @ 15047]
Richard Laager <rlaager@pidgin.im>
parents:
12703
diff
changeset
|
287 | { |
|
f4cbb5550f67
[gaim-migrate @ 15047]
Richard Laager <rlaager@pidgin.im>
parents:
12703
diff
changeset
|
288 | plugin->error = g_strdup(error); |
| 15884 | 289 | purple_debug_error("plugins", "%s is not loadable: %s\n", |
|
12704
f4cbb5550f67
[gaim-migrate @ 15047]
Richard Laager <rlaager@pidgin.im>
parents:
12703
diff
changeset
|
290 | plugin->path, plugin->error); |
|
f4cbb5550f67
[gaim-migrate @ 15047]
Richard Laager <rlaager@pidgin.im>
parents:
12703
diff
changeset
|
291 | } |
|
12695
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
292 | #if GLIB_CHECK_VERSION(2,3,3) |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
293 | plugin->handle = g_module_open(filename, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL); |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
294 | #else |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
295 | plugin->handle = g_module_open(filename, G_MODULE_BIND_LAZY); |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
296 | #endif |
|
5269
a318feccd844
[gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents:
5268
diff
changeset
|
297 | |
|
12695
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
298 | if (plugin->handle == NULL) |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
299 | { |
|
12699
81611fa7a208
[gaim-migrate @ 15042]
Richard Laager <rlaager@pidgin.im>
parents:
12696
diff
changeset
|
300 | #ifdef _WIN32 |
|
81611fa7a208
[gaim-migrate @ 15042]
Richard Laager <rlaager@pidgin.im>
parents:
12696
diff
changeset
|
301 | /* Restore the original error mode */ |
|
81611fa7a208
[gaim-migrate @ 15042]
Richard Laager <rlaager@pidgin.im>
parents:
12696
diff
changeset
|
302 | SetErrorMode(old_error_mode); |
|
81611fa7a208
[gaim-migrate @ 15042]
Richard Laager <rlaager@pidgin.im>
parents:
12696
diff
changeset
|
303 | #endif |
| 15884 | 304 | purple_plugin_destroy(plugin); |
|
12695
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
305 | return NULL; |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
306 | } |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
307 | else |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
308 | { |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
309 | /* We were able to load the plugin with lazy symbol binding. |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
310 | * This means we're missing some symbol. Mark it as |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
311 | * unloadable and keep going so we get the info to display |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
312 | * to the user so they know to rebuild this plugin. */ |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
313 | plugin->unloadable = TRUE; |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
314 | } |
| 5205 | 315 | } |
| 316 | ||
| 15884 | 317 | if (!g_module_symbol(plugin->handle, "purple_init_plugin", |
|
10447
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
318 | &unpunned)) |
|
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
319 | { |
| 15884 | 320 | purple_debug_error("plugins", "%s is not usable because the " |
| 321 | "'purple_init_plugin' symbol could not be " | |
|
11950
a522c2da66e5
[gaim-migrate @ 14241]
Evan Schoenberg <evands@pidgin.im>
parents:
11772
diff
changeset
|
322 | "found. Does the plugin call the " |
| 15884 | 323 | "PURPLE_INIT_PLUGIN() macro?\n", plugin->path); |
| 5205 | 324 | |
|
11950
a522c2da66e5
[gaim-migrate @ 14241]
Evan Schoenberg <evands@pidgin.im>
parents:
11772
diff
changeset
|
325 | g_module_close(plugin->handle); |
| 5443 | 326 | error = g_module_error(); |
|
11950
a522c2da66e5
[gaim-migrate @ 14241]
Evan Schoenberg <evands@pidgin.im>
parents:
11772
diff
changeset
|
327 | if (error != NULL) |
| 15884 | 328 | purple_debug_error("plugins", "Error closing module %s: %s\n", |
|
11950
a522c2da66e5
[gaim-migrate @ 14241]
Evan Schoenberg <evands@pidgin.im>
parents:
11772
diff
changeset
|
329 | plugin->path, error); |
|
a522c2da66e5
[gaim-migrate @ 14241]
Evan Schoenberg <evands@pidgin.im>
parents:
11772
diff
changeset
|
330 | plugin->handle = NULL; |
| 5205 | 331 | |
|
12699
81611fa7a208
[gaim-migrate @ 15042]
Richard Laager <rlaager@pidgin.im>
parents:
12696
diff
changeset
|
332 | #ifdef _WIN32 |
|
81611fa7a208
[gaim-migrate @ 15042]
Richard Laager <rlaager@pidgin.im>
parents:
12696
diff
changeset
|
333 | /* Restore the original error mode */ |
|
81611fa7a208
[gaim-migrate @ 15042]
Richard Laager <rlaager@pidgin.im>
parents:
12696
diff
changeset
|
334 | SetErrorMode(old_error_mode); |
|
81611fa7a208
[gaim-migrate @ 15042]
Richard Laager <rlaager@pidgin.im>
parents:
12696
diff
changeset
|
335 | #endif |
| 15884 | 336 | purple_plugin_destroy(plugin); |
| 5205 | 337 | return NULL; |
| 338 | } | |
| 15884 | 339 | purple_init_plugin = unpunned; |
|
12699
81611fa7a208
[gaim-migrate @ 15042]
Richard Laager <rlaager@pidgin.im>
parents:
12696
diff
changeset
|
340 | |
|
81611fa7a208
[gaim-migrate @ 15042]
Richard Laager <rlaager@pidgin.im>
parents:
12696
diff
changeset
|
341 | #ifdef _WIN32 |
|
81611fa7a208
[gaim-migrate @ 15042]
Richard Laager <rlaager@pidgin.im>
parents:
12696
diff
changeset
|
342 | /* Restore the original error mode */ |
|
81611fa7a208
[gaim-migrate @ 15042]
Richard Laager <rlaager@pidgin.im>
parents:
12696
diff
changeset
|
343 | SetErrorMode(old_error_mode); |
|
81611fa7a208
[gaim-migrate @ 15042]
Richard Laager <rlaager@pidgin.im>
parents:
12696
diff
changeset
|
344 | #endif |
| 5205 | 345 | } |
| 346 | else { | |
|
5794
ebdbb7dc6658
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
347 | loader = find_loader_for_plugin(plugin); |
| 5205 | 348 | |
| 349 | if (loader == NULL) { | |
| 15884 | 350 | purple_plugin_destroy(plugin); |
| 5205 | 351 | return NULL; |
| 352 | } | |
| 353 | ||
| 15884 | 354 | purple_init_plugin = PURPLE_PLUGIN_LOADER_INFO(loader)->probe; |
| 5205 | 355 | } |
| 356 | ||
| 15884 | 357 | if (!purple_init_plugin(plugin) || plugin->info == NULL) |
|
12695
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
358 | { |
| 15884 | 359 | purple_plugin_destroy(plugin); |
| 5205 | 360 | return NULL; |
| 361 | } | |
|
14787
2adb9bac76b5
[gaim-migrate @ 17479]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14254
diff
changeset
|
362 | else if (plugin->info->ui_requirement && |
| 15884 | 363 | strcmp(plugin->info->ui_requirement, purple_core_get_ui())) |
|
14787
2adb9bac76b5
[gaim-migrate @ 17479]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14254
diff
changeset
|
364 | { |
|
14918
db9f9d302973
[gaim-migrate @ 17625]
Mark Doliner <markdoliner@pidgin.im>
parents:
14895
diff
changeset
|
365 | plugin->error = g_strdup_printf(_("You are using %s, but this plugin requires %s."), |
| 15884 | 366 | purple_core_get_ui(), plugin->info->ui_requirement); |
| 367 | purple_debug_error("plugins", "%s is not loadable: The UI requirement is not met.\n", plugin->path); | |
|
14787
2adb9bac76b5
[gaim-migrate @ 17479]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14254
diff
changeset
|
368 | plugin->unloadable = TRUE; |
|
2adb9bac76b5
[gaim-migrate @ 17479]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14254
diff
changeset
|
369 | return plugin; |
|
2adb9bac76b5
[gaim-migrate @ 17479]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14254
diff
changeset
|
370 | } |
| 5205 | 371 | |
|
15938
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
372 | /* |
|
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
373 | * Check to make sure a plugin has defined an id. |
|
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
374 | * Not having this check caused purple_plugin_unload to |
|
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
375 | * enter an infinite loop in certain situations by passing |
|
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
376 | * purple_find_plugin_by_id a NULL value. -- ecoffey |
|
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
377 | */ |
|
15951
079275c87868
A small fix to the patch from ecoffey: Gary pointed out that the strcmp()
Richard Laager <rlaager@pidgin.im>
parents:
15938
diff
changeset
|
378 | if (plugin->info->id == NULL || *plugin->info->id == '\0') |
|
15938
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
379 | { |
|
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
380 | plugin->error = g_strdup_printf(_("This plugin has not defined an ID.")); |
|
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
381 | purple_debug_error("plugins", "%s is not loadable: info->id is not defined.\n", plugin->path); |
|
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
382 | plugin->unloadable = TRUE; |
|
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
383 | return plugin; |
|
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
384 | } |
|
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
385 | |
|
12703
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
386 | /* Really old plugins. */ |
| 15884 | 387 | if (plugin->info->magic != PURPLE_PLUGIN_MAGIC) |
|
12703
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
388 | { |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
389 | if (plugin->info->magic >= 2 && plugin->info->magic <= 4) |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
390 | { |
| 15884 | 391 | struct _PurplePluginInfo2 |
|
12703
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
392 | { |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
393 | unsigned int api_version; |
| 15884 | 394 | PurplePluginType type; |
|
12703
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
395 | char *ui_requirement; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
396 | unsigned long flags; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
397 | GList *dependencies; |
| 15884 | 398 | PurplePluginPriority priority; |
|
14895
38793d566e1c
[gaim-migrate @ 17600]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14894
diff
changeset
|
399 | |
|
12703
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
400 | char *id; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
401 | char *name; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
402 | char *version; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
403 | char *summary; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
404 | char *description; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
405 | char *author; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
406 | char *homepage; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
407 | |
| 15884 | 408 | gboolean (*load)(PurplePlugin *plugin); |
| 409 | gboolean (*unload)(PurplePlugin *plugin); | |
| 410 | void (*destroy)(PurplePlugin *plugin); | |
|
12703
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
411 | |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
412 | void *ui_info; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
413 | void *extra_info; |
| 15884 | 414 | PurplePluginUiInfo *prefs_info; |
| 415 | GList *(*actions)(PurplePlugin *plugin, gpointer context); | |
| 416 | } *info2 = (struct _PurplePluginInfo2 *)plugin->info; | |
|
12703
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
417 | |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
418 | /* This leaks... but only for ancient plugins, so deal with it. */ |
| 15884 | 419 | plugin->info = g_new0(PurplePluginInfo, 1); |
|
12703
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
420 | |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
421 | /* We don't really need all these to display the plugin info, but |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
422 | * I'm copying them all for good measure. */ |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
423 | plugin->info->magic = info2->api_version; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
424 | plugin->info->type = info2->type; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
425 | plugin->info->ui_requirement = info2->ui_requirement; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
426 | plugin->info->flags = info2->flags; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
427 | plugin->info->dependencies = info2->dependencies; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
428 | plugin->info->id = info2->id; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
429 | plugin->info->name = info2->name; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
430 | plugin->info->version = info2->version; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
431 | plugin->info->summary = info2->summary; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
432 | plugin->info->description = info2->description; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
433 | plugin->info->author = info2->author; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
434 | plugin->info->homepage = info2->homepage; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
435 | plugin->info->load = info2->load; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
436 | plugin->info->unload = info2->unload; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
437 | plugin->info->destroy = info2->destroy; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
438 | plugin->info->ui_info = info2->ui_info; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
439 | plugin->info->extra_info = info2->extra_info; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
440 | |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
441 | if (info2->api_version >= 3) |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
442 | plugin->info->prefs_info = info2->prefs_info; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
443 | |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
444 | if (info2->api_version >= 4) |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
445 | plugin->info->actions = info2->actions; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
446 | |
|
12704
f4cbb5550f67
[gaim-migrate @ 15047]
Richard Laager <rlaager@pidgin.im>
parents:
12703
diff
changeset
|
447 | |
|
f4cbb5550f67
[gaim-migrate @ 15047]
Richard Laager <rlaager@pidgin.im>
parents:
12703
diff
changeset
|
448 | plugin->error = g_strdup_printf(_("Plugin magic mismatch %d (need %d)"), |
| 15884 | 449 | plugin->info->magic, PURPLE_PLUGIN_MAGIC); |
| 450 | purple_debug_error("plugins", "%s is not loadable: Plugin magic mismatch %d (need %d)\n", | |
| 451 | plugin->path, plugin->info->magic, PURPLE_PLUGIN_MAGIC); | |
|
12703
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
452 | plugin->unloadable = TRUE; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
453 | return plugin; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
454 | } |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
455 | |
| 15884 | 456 | purple_debug_error("plugins", "%s is not loadable: Plugin magic mismatch %d (need %d)\n", |
| 457 | plugin->path, plugin->info->magic, PURPLE_PLUGIN_MAGIC); | |
| 458 | purple_plugin_destroy(plugin); | |
|
12703
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
459 | return NULL; |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
460 | } |
|
77b2e8d93ab8
[gaim-migrate @ 15046]
Richard Laager <rlaager@pidgin.im>
parents:
12699
diff
changeset
|
461 | |
| 15884 | 462 | if (plugin->info->major_version != PURPLE_MAJOR_VERSION || |
| 463 | plugin->info->minor_version > PURPLE_MINOR_VERSION) | |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
464 | { |
|
12704
f4cbb5550f67
[gaim-migrate @ 15047]
Richard Laager <rlaager@pidgin.im>
parents:
12703
diff
changeset
|
465 | plugin->error = g_strdup_printf(_("ABI version mismatch %d.%d.x (need %d.%d.x)"), |
|
12695
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
466 | plugin->info->major_version, plugin->info->minor_version, |
| 15884 | 467 | PURPLE_MAJOR_VERSION, PURPLE_MINOR_VERSION); |
| 468 | purple_debug_error("plugins", "%s is not loadable: ABI version mismatch %d.%d.x (need %d.%d.x)\n", | |
|
12704
f4cbb5550f67
[gaim-migrate @ 15047]
Richard Laager <rlaager@pidgin.im>
parents:
12703
diff
changeset
|
469 | plugin->path, plugin->info->major_version, plugin->info->minor_version, |
| 15884 | 470 | PURPLE_MAJOR_VERSION, PURPLE_MINOR_VERSION); |
|
12695
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
471 | plugin->unloadable = TRUE; |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
472 | return plugin; |
|
10156
463aca04c29a
[gaim-migrate @ 11236]
Mark Doliner <markdoliner@pidgin.im>
parents:
10145
diff
changeset
|
473 | } |
|
463aca04c29a
[gaim-migrate @ 11236]
Mark Doliner <markdoliner@pidgin.im>
parents:
10145
diff
changeset
|
474 | |
| 15884 | 475 | if (plugin->info->type == PURPLE_PLUGIN_PROTOCOL) |
|
10156
463aca04c29a
[gaim-migrate @ 11236]
Mark Doliner <markdoliner@pidgin.im>
parents:
10145
diff
changeset
|
476 | { |
|
13311
0d7ab73ca418
[gaim-migrate @ 15676]
Richard Laager <rlaager@pidgin.im>
parents:
13251
diff
changeset
|
477 | /* If plugin is a PRPL, make sure it implements the required functions */ |
| 15884 | 478 | if ((PURPLE_PLUGIN_PROTOCOL_INFO(plugin)->list_icon == NULL) || |
| 479 | (PURPLE_PLUGIN_PROTOCOL_INFO(plugin)->login == NULL) || | |
| 480 | (PURPLE_PLUGIN_PROTOCOL_INFO(plugin)->close == NULL)) | |
|
13311
0d7ab73ca418
[gaim-migrate @ 15676]
Richard Laager <rlaager@pidgin.im>
parents:
13251
diff
changeset
|
481 | { |
|
0d7ab73ca418
[gaim-migrate @ 15676]
Richard Laager <rlaager@pidgin.im>
parents:
13251
diff
changeset
|
482 | plugin->error = g_strdup(_("Plugin does not implement all required functions")); |
| 15884 | 483 | purple_debug_error("plugins", "%s is not loadable: Plugin does not implement all required functions\n", |
|
13311
0d7ab73ca418
[gaim-migrate @ 15676]
Richard Laager <rlaager@pidgin.im>
parents:
13251
diff
changeset
|
484 | plugin->path); |
|
0d7ab73ca418
[gaim-migrate @ 15676]
Richard Laager <rlaager@pidgin.im>
parents:
13251
diff
changeset
|
485 | plugin->unloadable = TRUE; |
|
0d7ab73ca418
[gaim-migrate @ 15676]
Richard Laager <rlaager@pidgin.im>
parents:
13251
diff
changeset
|
486 | return plugin; |
|
0d7ab73ca418
[gaim-migrate @ 15676]
Richard Laager <rlaager@pidgin.im>
parents:
13251
diff
changeset
|
487 | } |
|
0d7ab73ca418
[gaim-migrate @ 15676]
Richard Laager <rlaager@pidgin.im>
parents:
13251
diff
changeset
|
488 | |
|
0d7ab73ca418
[gaim-migrate @ 15676]
Richard Laager <rlaager@pidgin.im>
parents:
13251
diff
changeset
|
489 | /* For debugging, let's warn about prpl prefs. */ |
|
0d7ab73ca418
[gaim-migrate @ 15676]
Richard Laager <rlaager@pidgin.im>
parents:
13251
diff
changeset
|
490 | if (plugin->info->prefs_info != NULL) |
|
0d7ab73ca418
[gaim-migrate @ 15676]
Richard Laager <rlaager@pidgin.im>
parents:
13251
diff
changeset
|
491 | { |
| 15884 | 492 | purple_debug_error("plugins", "%s has a prefs_info, but is a prpl. This is no longer supported.\n", |
|
13311
0d7ab73ca418
[gaim-migrate @ 15676]
Richard Laager <rlaager@pidgin.im>
parents:
13251
diff
changeset
|
493 | plugin->path); |
|
0d7ab73ca418
[gaim-migrate @ 15676]
Richard Laager <rlaager@pidgin.im>
parents:
13251
diff
changeset
|
494 | } |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
495 | } |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
496 | |
| 5205 | 497 | return plugin; |
| 498 | #else | |
| 499 | return NULL; | |
| 15884 | 500 | #endif /* !PURPLE_PLUGINS */ |
| 5205 | 501 | } |
| 502 | ||
| 15884 | 503 | #ifdef PURPLE_PLUGINS |
|
12332
9841e312051d
[gaim-migrate @ 14636]
Mark Doliner <markdoliner@pidgin.im>
parents:
12117
diff
changeset
|
504 | static gint |
|
9841e312051d
[gaim-migrate @ 14636]
Mark Doliner <markdoliner@pidgin.im>
parents:
12117
diff
changeset
|
505 | compare_plugins(gconstpointer a, gconstpointer b) |
|
9841e312051d
[gaim-migrate @ 14636]
Mark Doliner <markdoliner@pidgin.im>
parents:
12117
diff
changeset
|
506 | { |
| 15884 | 507 | const PurplePlugin *plugina = a; |
| 508 | const PurplePlugin *pluginb = b; | |
|
12332
9841e312051d
[gaim-migrate @ 14636]
Mark Doliner <markdoliner@pidgin.im>
parents:
12117
diff
changeset
|
509 | |
|
9841e312051d
[gaim-migrate @ 14636]
Mark Doliner <markdoliner@pidgin.im>
parents:
12117
diff
changeset
|
510 | return strcmp(plugina->info->name, pluginb->info->name); |
|
9841e312051d
[gaim-migrate @ 14636]
Mark Doliner <markdoliner@pidgin.im>
parents:
12117
diff
changeset
|
511 | } |
| 15884 | 512 | #endif /* PURPLE_PLUGINS */ |
|
12332
9841e312051d
[gaim-migrate @ 14636]
Mark Doliner <markdoliner@pidgin.im>
parents:
12117
diff
changeset
|
513 | |
| 5205 | 514 | gboolean |
| 15884 | 515 | purple_plugin_load(PurplePlugin *plugin) |
| 5205 | 516 | { |
| 15884 | 517 | #ifdef PURPLE_PLUGINS |
|
6486
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
518 | GList *dep_list = NULL; |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
519 | GList *l; |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
520 | |
| 5205 | 521 | g_return_val_if_fail(plugin != NULL, FALSE); |
| 522 | ||
| 15884 | 523 | if (purple_plugin_is_loaded(plugin)) |
| 5205 | 524 | return TRUE; |
| 525 | ||
| 15884 | 526 | if (purple_plugin_is_unloadable(plugin)) |
|
12695
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
527 | return FALSE; |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
528 | |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
529 | g_return_val_if_fail(plugin->error == NULL, FALSE); |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
530 | |
|
6486
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
531 | /* |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
532 | * Go through the list of the plugin's dependencies. |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
533 | * |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
534 | * First pass: Make sure all the plugins needed are probed. |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
535 | */ |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
536 | for (l = plugin->info->dependencies; l != NULL; l = l->next) |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
537 | { |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
538 | const char *dep_name = (const char *)l->data; |
| 15884 | 539 | PurplePlugin *dep_plugin; |
|
6486
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
540 | |
| 15884 | 541 | dep_plugin = purple_plugins_find_with_id(dep_name); |
|
6486
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
542 | |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
543 | if (dep_plugin == NULL) |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
544 | { |
| 12926 | 545 | char *tmp; |
|
6486
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
546 | |
| 12983 | 547 | tmp = g_strdup_printf(_("The required plugin %s was not found. " |
| 12926 | 548 | "Please install this plugin and try again."), |
| 549 | dep_name); | |
|
6486
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
550 | |
| 15884 | 551 | purple_notify_error(NULL, NULL, |
|
15444
b793ef258d23
I think this changes every user-visible string that contains 'Gaim.' We probably want the UI to be able
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
552 | _("Unable to load the plugin"), tmp); |
| 12926 | 553 | g_free(tmp); |
|
6486
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
554 | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14024
diff
changeset
|
555 | g_list_free(dep_list); |
|
6486
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
556 | |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
557 | return FALSE; |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
558 | } |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
559 | |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
560 | dep_list = g_list_append(dep_list, dep_plugin); |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
561 | } |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
562 | |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
563 | /* Second pass: load all the required plugins. */ |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
564 | for (l = dep_list; l != NULL; l = l->next) |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
565 | { |
| 15884 | 566 | PurplePlugin *dep_plugin = (PurplePlugin *)l->data; |
|
6486
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
567 | |
| 15884 | 568 | if (!purple_plugin_is_loaded(dep_plugin)) |
|
6486
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
569 | { |
| 15884 | 570 | if (!purple_plugin_load(dep_plugin)) |
|
6486
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
571 | { |
| 12926 | 572 | char *tmp; |
|
6486
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
573 | |
| 12926 | 574 | tmp = g_strdup_printf(_("The required plugin %s was unable to load."), |
| 575 | plugin->info->name); | |
|
6486
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
576 | |
| 15884 | 577 | purple_notify_error(NULL, NULL, |
|
15444
b793ef258d23
I think this changes every user-visible string that contains 'Gaim.' We probably want the UI to be able
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
578 | _("Unable to load your plugin."), tmp); |
| 12926 | 579 | g_free(tmp); |
|
6486
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
580 | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14024
diff
changeset
|
581 | g_list_free(dep_list); |
|
6486
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
582 | |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
583 | return FALSE; |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
584 | } |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
585 | } |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
586 | } |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
587 | |
| 12926 | 588 | /* Third pass: note that other plugins are dependencies of this plugin. |
| 589 | * This is done separately in case we had to bail out earlier. */ | |
| 590 | for (l = dep_list; l != NULL; l = l->next) | |
| 591 | { | |
| 15884 | 592 | PurplePlugin *dep_plugin = (PurplePlugin *)l->data; |
| 12926 | 593 | dep_plugin->dependent_plugins = g_list_prepend(dep_plugin->dependent_plugins, plugin->info->id); |
| 594 | } | |
| 595 | ||
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14024
diff
changeset
|
596 | g_list_free(dep_list); |
|
6486
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
597 | |
|
6981
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
598 | if (plugin->native_plugin) |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
599 | { |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
600 | if (plugin->info != NULL && plugin->info->load != NULL) |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
601 | { |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
602 | if (!plugin->info->load(plugin)) |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
603 | return FALSE; |
|
5357
1fa9e57df50c
[gaim-migrate @ 5733]
Christian Hammond <chipx86@chipx86.com>
parents:
5270
diff
changeset
|
604 | } |
| 5205 | 605 | } |
| 606 | else { | |
| 15884 | 607 | PurplePlugin *loader; |
| 608 | PurplePluginLoaderInfo *loader_info; | |
| 5205 | 609 | |
|
5794
ebdbb7dc6658
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
610 | loader = find_loader_for_plugin(plugin); |
| 5205 | 611 | |
| 612 | if (loader == NULL) | |
| 613 | return FALSE; | |
| 614 | ||
| 15884 | 615 | loader_info = PURPLE_PLUGIN_LOADER_INFO(loader); |
| 5205 | 616 | |
| 617 | if (loader_info->load != NULL) | |
|
6981
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
618 | { |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
619 | if (!loader_info->load(plugin)) |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
620 | return FALSE; |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
621 | } |
| 5205 | 622 | } |
| 623 | ||
|
12332
9841e312051d
[gaim-migrate @ 14636]
Mark Doliner <markdoliner@pidgin.im>
parents:
12117
diff
changeset
|
624 | loaded_plugins = g_list_insert_sorted(loaded_plugins, plugin, compare_plugins); |
| 5205 | 625 | |
| 626 | plugin->loaded = TRUE; | |
| 627 | ||
| 628 | /* TODO */ | |
| 629 | if (load_cb != NULL) | |
| 630 | load_cb(plugin, load_cb_data); | |
| 631 | ||
| 15884 | 632 | purple_signal_emit(purple_plugins_get_handle(), "plugin-load", plugin); |
|
8986
30ba617356bb
[gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents:
8759
diff
changeset
|
633 | |
| 5205 | 634 | return TRUE; |
| 635 | ||
| 636 | #else | |
|
5449
4c350eb7d4a0
[gaim-migrate @ 5836]
Decklin Foster <decklin@red-bean.com>
parents:
5443
diff
changeset
|
637 | return TRUE; |
| 15884 | 638 | #endif /* !PURPLE_PLUGINS */ |
| 5205 | 639 | } |
| 640 | ||
| 641 | gboolean | |
| 15884 | 642 | purple_plugin_unload(PurplePlugin *plugin) |
| 5205 | 643 | { |
| 15884 | 644 | #ifdef PURPLE_PLUGINS |
|
12992
4bb06c9c1fb3
[gaim-migrate @ 15345]
Richard Laager <rlaager@pidgin.im>
parents:
12985
diff
changeset
|
645 | GList *l; |
| 12985 | 646 | |
| 5205 | 647 | g_return_val_if_fail(plugin != NULL, FALSE); |
| 648 | ||
| 649 | loaded_plugins = g_list_remove(loaded_plugins, plugin); | |
| 15884 | 650 | if ((plugin->info != NULL) && PURPLE_IS_PROTOCOL_PLUGIN(plugin)) |
|
11950
a522c2da66e5
[gaim-migrate @ 14241]
Evan Schoenberg <evands@pidgin.im>
parents:
11772
diff
changeset
|
651 | protocol_plugins = g_list_remove(protocol_plugins, plugin); |
| 5205 | 652 | |
| 15884 | 653 | g_return_val_if_fail(purple_plugin_is_loaded(plugin), FALSE); |
| 5205 | 654 | |
| 15884 | 655 | purple_debug_info("plugins", "Unloading plugin %s\n", plugin->info->name); |
| 5205 | 656 | |
| 657 | /* cancel any pending dialogs the plugin has */ | |
| 15884 | 658 | purple_request_close_with_handle(plugin); |
| 659 | purple_notify_close_with_handle(plugin); | |
| 5205 | 660 | |
| 661 | plugin->loaded = FALSE; | |
| 662 | ||
| 12926 | 663 | /* Unload all plugins that depend on this plugin. */ |
|
12992
4bb06c9c1fb3
[gaim-migrate @ 15345]
Richard Laager <rlaager@pidgin.im>
parents:
12985
diff
changeset
|
664 | while ((l = plugin->dependent_plugins) != NULL) |
| 12926 | 665 | { |
| 666 | const char * dep_name = (const char *)l->data; | |
| 15884 | 667 | PurplePlugin *dep_plugin; |
| 12926 | 668 | |
| 15884 | 669 | dep_plugin = purple_plugins_find_with_id(dep_name); |
| 12926 | 670 | |
| 15884 | 671 | if (dep_plugin != NULL && purple_plugin_is_loaded(dep_plugin)) |
| 12926 | 672 | { |
| 15884 | 673 | if (!purple_plugin_unload(dep_plugin)) |
| 12926 | 674 | { |
| 675 | char *translated_name = g_strdup(_(dep_plugin->info->name)); | |
| 676 | char *tmp; | |
| 677 | ||
| 678 | tmp = g_strdup_printf(_("The dependent plugin %s failed to unload."), | |
| 679 | translated_name); | |
| 680 | g_free(translated_name); | |
| 681 | ||
| 15884 | 682 | purple_notify_error(NULL, NULL, |
|
15444
b793ef258d23
I think this changes every user-visible string that contains 'Gaim.' We probably want the UI to be able
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
683 | _("There were errors unloading the plugin."), tmp); |
| 12926 | 684 | g_free(tmp); |
| 685 | } | |
| 686 | } | |
| 687 | } | |
| 688 | ||
| 689 | /* Remove this plugin from each dependency's dependent_plugins list. */ | |
| 690 | for (l = plugin->info->dependencies; l != NULL; l = l->next) | |
| 691 | { | |
| 692 | const char *dep_name = (const char *)l->data; | |
| 15884 | 693 | PurplePlugin *dependency; |
| 12926 | 694 | |
| 15884 | 695 | dependency = purple_plugins_find_with_id(dep_name); |
| 12926 | 696 | |
| 697 | dependency->dependent_plugins = g_list_remove(dependency->dependent_plugins, plugin->info->id); | |
| 698 | } | |
| 699 | ||
| 5205 | 700 | if (plugin->native_plugin) { |
| 701 | if (plugin->info->unload != NULL) | |
| 702 | plugin->info->unload(plugin); | |
| 703 | ||
| 15884 | 704 | if (plugin->info->type == PURPLE_PLUGIN_PROTOCOL) { |
| 705 | PurplePluginProtocolInfo *prpl_info; | |
| 5205 | 706 | GList *l; |
| 707 | ||
| 15884 | 708 | prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin); |
| 5205 | 709 | |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
710 | for (l = prpl_info->user_splits; l != NULL; l = l->next) |
| 15884 | 711 | purple_account_user_split_destroy(l->data); |
| 5205 | 712 | |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
713 | for (l = prpl_info->protocol_options; l != NULL; l = l->next) |
| 15884 | 714 | purple_account_option_destroy(l->data); |
| 5205 | 715 | |
| 12117 | 716 | if (prpl_info->user_splits != NULL) { |
|
5646
0aa637549d87
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
717 | g_list_free(prpl_info->user_splits); |
| 12117 | 718 | prpl_info->user_splits = NULL; |
| 719 | } | |
|
5646
0aa637549d87
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
720 | |
| 12117 | 721 | if (prpl_info->protocol_options != NULL) { |
|
5646
0aa637549d87
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
722 | g_list_free(prpl_info->protocol_options); |
| 12117 | 723 | prpl_info->protocol_options = NULL; |
| 724 | } | |
| 5205 | 725 | } |
| 726 | } | |
| 727 | else { | |
| 15884 | 728 | PurplePlugin *loader; |
| 729 | PurplePluginLoaderInfo *loader_info; | |
| 5205 | 730 | |
|
5794
ebdbb7dc6658
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
731 | loader = find_loader_for_plugin(plugin); |
| 5205 | 732 | |
| 733 | if (loader == NULL) | |
| 734 | return FALSE; | |
| 735 | ||
| 15884 | 736 | loader_info = PURPLE_PLUGIN_LOADER_INFO(loader); |
| 5205 | 737 | |
|
9697
9f014c2d2538
[gaim-migrate @ 10556]
Christian Hammond <chipx86@chipx86.com>
parents:
9667
diff
changeset
|
738 | if (loader_info->unload != NULL) |
| 5205 | 739 | loader_info->unload(plugin); |
| 740 | } | |
| 741 | ||
| 15884 | 742 | purple_signals_disconnect_by_handle(plugin); |
| 743 | purple_plugin_ipc_unregister_all(plugin); | |
| 5205 | 744 | |
| 745 | /* TODO */ | |
| 746 | if (unload_cb != NULL) | |
| 747 | unload_cb(plugin, unload_cb_data); | |
| 748 | ||
| 15884 | 749 | purple_signal_emit(purple_plugins_get_handle(), "plugin-unload", plugin); |
|
8986
30ba617356bb
[gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents:
8759
diff
changeset
|
750 | |
| 15884 | 751 | purple_prefs_disconnect_by_handle(plugin); |
|
10087
e5b80a38939d
[gaim-migrate @ 11098]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9943
diff
changeset
|
752 | |
| 5205 | 753 | return TRUE; |
|
5449
4c350eb7d4a0
[gaim-migrate @ 5836]
Decklin Foster <decklin@red-bean.com>
parents:
5443
diff
changeset
|
754 | #else |
|
4c350eb7d4a0
[gaim-migrate @ 5836]
Decklin Foster <decklin@red-bean.com>
parents:
5443
diff
changeset
|
755 | return TRUE; |
| 15884 | 756 | #endif /* PURPLE_PLUGINS */ |
| 5205 | 757 | } |
| 758 | ||
| 759 | gboolean | |
| 15884 | 760 | purple_plugin_reload(PurplePlugin *plugin) |
| 5205 | 761 | { |
| 15884 | 762 | #ifdef PURPLE_PLUGINS |
| 5205 | 763 | g_return_val_if_fail(plugin != NULL, FALSE); |
| 15884 | 764 | g_return_val_if_fail(purple_plugin_is_loaded(plugin), FALSE); |
| 5205 | 765 | |
| 15884 | 766 | if (!purple_plugin_unload(plugin)) |
| 5205 | 767 | return FALSE; |
| 768 | ||
| 15884 | 769 | if (!purple_plugin_load(plugin)) |
| 5205 | 770 | return FALSE; |
| 771 | ||
| 772 | return TRUE; | |
| 773 | #else | |
|
5449
4c350eb7d4a0
[gaim-migrate @ 5836]
Decklin Foster <decklin@red-bean.com>
parents:
5443
diff
changeset
|
774 | return TRUE; |
| 15884 | 775 | #endif /* !PURPLE_PLUGINS */ |
| 5205 | 776 | } |
| 777 | ||
| 778 | void | |
| 15884 | 779 | purple_plugin_destroy(PurplePlugin *plugin) |
| 5205 | 780 | { |
| 15884 | 781 | #ifdef PURPLE_PLUGINS |
| 5205 | 782 | g_return_if_fail(plugin != NULL); |
| 783 | ||
| 15884 | 784 | if (purple_plugin_is_loaded(plugin)) |
| 785 | purple_plugin_unload(plugin); | |
| 5205 | 786 | |
| 787 | plugins = g_list_remove(plugins, plugin); | |
| 788 | ||
|
6981
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
789 | if (load_queue != NULL) |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
790 | load_queue = g_list_remove(load_queue, plugin); |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
791 | |
| 9943 | 792 | /* true, this may leak a little memory if there is a major version |
| 793 | * mismatch, but it's a lot better than trying to free something | |
| 794 | * we shouldn't, and crashing while trying to load an old plugin */ | |
| 15884 | 795 | if(plugin->info == NULL || plugin->info->magic != PURPLE_PLUGIN_MAGIC || |
| 796 | plugin->info->major_version != PURPLE_MAJOR_VERSION) | |
|
14024
60730ce4455c
[gaim-migrate @ 16515]
Mark Doliner <markdoliner@pidgin.im>
parents:
14016
diff
changeset
|
797 | { |
| 9943 | 798 | if(plugin->handle) |
| 799 | g_module_close(plugin->handle); | |
|
13136
0438506e90ac
[gaim-migrate @ 15497]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13107
diff
changeset
|
800 | |
|
14024
60730ce4455c
[gaim-migrate @ 16515]
Mark Doliner <markdoliner@pidgin.im>
parents:
14016
diff
changeset
|
801 | g_free(plugin->path); |
|
60730ce4455c
[gaim-migrate @ 16515]
Mark Doliner <markdoliner@pidgin.im>
parents:
14016
diff
changeset
|
802 | g_free(plugin->error); |
|
60730ce4455c
[gaim-migrate @ 16515]
Mark Doliner <markdoliner@pidgin.im>
parents:
14016
diff
changeset
|
803 | |
| 15884 | 804 | PURPLE_DBUS_UNREGISTER_POINTER(plugin); |
|
14024
60730ce4455c
[gaim-migrate @ 16515]
Mark Doliner <markdoliner@pidgin.im>
parents:
14016
diff
changeset
|
805 | |
| 9943 | 806 | g_free(plugin); |
| 807 | return; | |
| 808 | } | |
| 809 | ||
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14024
diff
changeset
|
810 | if (plugin->info != NULL) |
|
5243
e8d35a430c6d
[gaim-migrate @ 5614]
Christian Hammond <chipx86@chipx86.com>
parents:
5242
diff
changeset
|
811 | g_list_free(plugin->info->dependencies); |
| 5205 | 812 | |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
813 | if (plugin->native_plugin) |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
814 | { |
| 15884 | 815 | if (plugin->info != NULL && plugin->info->type == PURPLE_PLUGIN_LOADER) |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
816 | { |
| 15884 | 817 | PurplePluginLoaderInfo *loader_info; |
| 5205 | 818 | GList *exts, *l, *next_l; |
| 15884 | 819 | PurplePlugin *p2; |
| 5205 | 820 | |
| 15884 | 821 | loader_info = PURPLE_PLUGIN_LOADER_INFO(plugin); |
| 5205 | 822 | |
| 9943 | 823 | if (loader_info != NULL && loader_info->exts != NULL) |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
824 | { |
| 15884 | 825 | for (exts = PURPLE_PLUGIN_LOADER_INFO(plugin)->exts; |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
826 | exts != NULL; |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
827 | exts = exts->next) { |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
828 | |
| 15884 | 829 | for (l = purple_plugins_get_all(); l != NULL; l = next_l) |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
830 | { |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
831 | next_l = l->next; |
| 5205 | 832 | |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
833 | p2 = l->data; |
| 5205 | 834 | |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
835 | if (p2->path != NULL && |
|
10447
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
836 | has_file_extension(p2->path, exts->data)) |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
837 | { |
| 15884 | 838 | purple_plugin_destroy(p2); |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
839 | } |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
840 | } |
| 5205 | 841 | } |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
842 | |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
843 | g_list_free(loader_info->exts); |
| 5205 | 844 | } |
| 845 | ||
| 846 | plugin_loaders = g_list_remove(plugin_loaders, plugin); | |
| 847 | } | |
| 848 | ||
| 849 | if (plugin->info != NULL && plugin->info->destroy != NULL) | |
| 850 | plugin->info->destroy(plugin); | |
| 851 | ||
| 852 | if (plugin->handle != NULL) | |
| 853 | g_module_close(plugin->handle); | |
| 854 | } | |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
855 | else |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
856 | { |
| 15884 | 857 | PurplePlugin *loader; |
| 858 | PurplePluginLoaderInfo *loader_info; | |
| 5205 | 859 | |
|
5794
ebdbb7dc6658
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
860 | loader = find_loader_for_plugin(plugin); |
| 5205 | 861 | |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
862 | if (loader != NULL) |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
863 | { |
| 15884 | 864 | loader_info = PURPLE_PLUGIN_LOADER_INFO(loader); |
| 5205 | 865 | |
|
5941
46e136a842b8
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
866 | if (loader_info->destroy != NULL) |
|
46e136a842b8
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
867 | loader_info->destroy(plugin); |
|
46e136a842b8
[gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
868 | } |
| 5205 | 869 | } |
| 870 | ||
|
14016
2d2e0f347601
[gaim-migrate @ 16502]
Mark Doliner <markdoliner@pidgin.im>
parents:
13670
diff
changeset
|
871 | g_free(plugin->path); |
|
2d2e0f347601
[gaim-migrate @ 16502]
Mark Doliner <markdoliner@pidgin.im>
parents:
13670
diff
changeset
|
872 | g_free(plugin->error); |
| 5205 | 873 | |
| 15884 | 874 | PURPLE_DBUS_UNREGISTER_POINTER(plugin); |
|
13136
0438506e90ac
[gaim-migrate @ 15497]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13107
diff
changeset
|
875 | |
| 5205 | 876 | g_free(plugin); |
| 15884 | 877 | #endif /* !PURPLE_PLUGINS */ |
| 5205 | 878 | } |
| 879 | ||
| 880 | gboolean | |
| 15884 | 881 | purple_plugin_is_loaded(const PurplePlugin *plugin) |
| 5205 | 882 | { |
| 883 | g_return_val_if_fail(plugin != NULL, FALSE); | |
| 884 | ||
| 885 | return plugin->loaded; | |
| 886 | } | |
| 887 | ||
|
12695
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
888 | gboolean |
| 15884 | 889 | purple_plugin_is_unloadable(const PurplePlugin *plugin) |
|
12695
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
890 | { |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
891 | g_return_val_if_fail(plugin != NULL, FALSE); |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
892 | |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
893 | return plugin->unloadable; |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
894 | } |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12623
diff
changeset
|
895 | |
|
11772
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
896 | const gchar * |
| 15884 | 897 | purple_plugin_get_id(const PurplePlugin *plugin) { |
|
11772
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
898 | g_return_val_if_fail(plugin, NULL); |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
899 | g_return_val_if_fail(plugin->info, NULL); |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
900 | |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
901 | return plugin->info->id; |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
902 | } |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
903 | |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
904 | const gchar * |
| 15884 | 905 | purple_plugin_get_name(const PurplePlugin *plugin) { |
|
11772
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
906 | g_return_val_if_fail(plugin, NULL); |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
907 | g_return_val_if_fail(plugin->info, NULL); |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
908 | |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
909 | return plugin->info->name; |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
910 | } |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
911 | |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
912 | const gchar * |
| 15884 | 913 | purple_plugin_get_version(const PurplePlugin *plugin) { |
|
11772
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
914 | g_return_val_if_fail(plugin, NULL); |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
915 | g_return_val_if_fail(plugin->info, NULL); |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
916 | |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
917 | return plugin->info->version; |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
918 | } |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
919 | |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
920 | const gchar * |
| 15884 | 921 | purple_plugin_get_summary(const PurplePlugin *plugin) { |
|
11772
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
922 | g_return_val_if_fail(plugin, NULL); |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
923 | g_return_val_if_fail(plugin->info, NULL); |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
924 | |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
925 | return plugin->info->summary; |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
926 | } |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
927 | |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
928 | const gchar * |
| 15884 | 929 | purple_plugin_get_description(const PurplePlugin *plugin) { |
|
11772
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
930 | g_return_val_if_fail(plugin, NULL); |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
931 | g_return_val_if_fail(plugin->info, NULL); |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
932 | |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
933 | return plugin->info->description; |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
934 | } |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
935 | |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
936 | const gchar * |
| 15884 | 937 | purple_plugin_get_author(const PurplePlugin *plugin) { |
|
11772
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
938 | g_return_val_if_fail(plugin, NULL); |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
939 | g_return_val_if_fail(plugin->info, NULL); |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
940 | |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
941 | return plugin->info->author; |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
942 | } |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
943 | |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
944 | const gchar * |
| 15884 | 945 | purple_plugin_get_homepage(const PurplePlugin *plugin) { |
|
11772
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
946 | g_return_val_if_fail(plugin, NULL); |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
947 | g_return_val_if_fail(plugin->info, NULL); |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
948 | |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
949 | return plugin->info->homepage; |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
950 | } |
|
0124b31e896a
[gaim-migrate @ 14063]
Gary Kramlich <grim@reaperworld.com>
parents:
11378
diff
changeset
|
951 | |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
952 | /************************************************************************** |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
953 | * Plugin IPC |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
954 | **************************************************************************/ |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
955 | static void |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
956 | destroy_ipc_info(void *data) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
957 | { |
| 15884 | 958 | PurplePluginIpcCommand *ipc_command = (PurplePluginIpcCommand *)data; |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
959 | int i; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
960 | |
|
9667
f66efc2631b3
[gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents:
9018
diff
changeset
|
961 | if (ipc_command->params != NULL) |
|
f66efc2631b3
[gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents:
9018
diff
changeset
|
962 | { |
|
f66efc2631b3
[gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents:
9018
diff
changeset
|
963 | for (i = 0; i < ipc_command->num_params; i++) |
| 15884 | 964 | purple_value_destroy(ipc_command->params[i]); |
|
9667
f66efc2631b3
[gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents:
9018
diff
changeset
|
965 | |
|
f66efc2631b3
[gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents:
9018
diff
changeset
|
966 | g_free(ipc_command->params); |
|
f66efc2631b3
[gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents:
9018
diff
changeset
|
967 | } |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
968 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
969 | if (ipc_command->ret_value != NULL) |
| 15884 | 970 | purple_value_destroy(ipc_command->ret_value); |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
971 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
972 | g_free(ipc_command); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
973 | } |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
974 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
975 | gboolean |
| 15884 | 976 | purple_plugin_ipc_register(PurplePlugin *plugin, const char *command, |
| 977 | PurpleCallback func, PurpleSignalMarshalFunc marshal, | |
| 978 | PurpleValue *ret_value, int num_params, ...) | |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
979 | { |
| 15884 | 980 | PurplePluginIpcInfo *ipc_info; |
| 981 | PurplePluginIpcCommand *ipc_command; | |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
982 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
983 | g_return_val_if_fail(plugin != NULL, FALSE); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
984 | g_return_val_if_fail(command != NULL, FALSE); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
985 | g_return_val_if_fail(func != NULL, FALSE); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
986 | g_return_val_if_fail(marshal != NULL, FALSE); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
987 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
988 | if (plugin->ipc_data == NULL) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
989 | { |
| 15884 | 990 | ipc_info = plugin->ipc_data = g_new0(PurplePluginIpcInfo, 1); |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
991 | ipc_info->commands = g_hash_table_new_full(g_str_hash, g_str_equal, |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
992 | g_free, destroy_ipc_info); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
993 | } |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
994 | else |
| 15884 | 995 | ipc_info = (PurplePluginIpcInfo *)plugin->ipc_data; |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
996 | |
| 15884 | 997 | ipc_command = g_new0(PurplePluginIpcCommand, 1); |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
998 | ipc_command->func = func; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
999 | ipc_command->marshal = marshal; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1000 | ipc_command->num_params = num_params; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1001 | ipc_command->ret_value = ret_value; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1002 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1003 | if (num_params > 0) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1004 | { |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1005 | va_list args; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1006 | int i; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1007 | |
| 15884 | 1008 | ipc_command->params = g_new0(PurpleValue *, num_params); |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1009 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1010 | va_start(args, num_params); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1011 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1012 | for (i = 0; i < num_params; i++) |
| 15884 | 1013 | ipc_command->params[i] = va_arg(args, PurpleValue *); |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1014 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1015 | va_end(args); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1016 | } |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1017 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1018 | g_hash_table_replace(ipc_info->commands, g_strdup(command), ipc_command); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1019 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1020 | ipc_info->command_count++; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1021 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1022 | return TRUE; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1023 | } |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1024 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1025 | void |
| 15884 | 1026 | purple_plugin_ipc_unregister(PurplePlugin *plugin, const char *command) |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1027 | { |
| 15884 | 1028 | PurplePluginIpcInfo *ipc_info; |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1029 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1030 | g_return_if_fail(plugin != NULL); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1031 | g_return_if_fail(command != NULL); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1032 | |
| 15884 | 1033 | ipc_info = (PurplePluginIpcInfo *)plugin->ipc_data; |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1034 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1035 | if (ipc_info == NULL || |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1036 | g_hash_table_lookup(ipc_info->commands, command) == NULL) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1037 | { |
| 15884 | 1038 | purple_debug_error("plugins", |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1039 | "IPC command '%s' was not registered for plugin %s\n", |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1040 | command, plugin->info->name); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1041 | return; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1042 | } |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1043 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1044 | g_hash_table_remove(ipc_info->commands, command); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1045 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1046 | ipc_info->command_count--; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1047 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1048 | if (ipc_info->command_count == 0) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1049 | { |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1050 | g_hash_table_destroy(ipc_info->commands); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1051 | g_free(ipc_info); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1052 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1053 | plugin->ipc_data = NULL; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1054 | } |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1055 | } |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1056 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1057 | void |
| 15884 | 1058 | purple_plugin_ipc_unregister_all(PurplePlugin *plugin) |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1059 | { |
| 15884 | 1060 | PurplePluginIpcInfo *ipc_info; |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1061 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1062 | g_return_if_fail(plugin != NULL); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1063 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1064 | if (plugin->ipc_data == NULL) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1065 | return; /* Silently ignore it. */ |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1066 | |
| 15884 | 1067 | ipc_info = (PurplePluginIpcInfo *)plugin->ipc_data; |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1068 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1069 | g_hash_table_destroy(ipc_info->commands); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1070 | g_free(ipc_info); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1071 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1072 | plugin->ipc_data = NULL; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1073 | } |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1074 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1075 | gboolean |
| 15884 | 1076 | purple_plugin_ipc_get_params(PurplePlugin *plugin, const char *command, |
| 1077 | PurpleValue **ret_value, int *num_params, | |
| 1078 | PurpleValue ***params) | |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1079 | { |
| 15884 | 1080 | PurplePluginIpcInfo *ipc_info; |
| 1081 | PurplePluginIpcCommand *ipc_command; | |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1082 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1083 | g_return_val_if_fail(plugin != NULL, FALSE); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1084 | g_return_val_if_fail(command != NULL, FALSE); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1085 | |
| 15884 | 1086 | ipc_info = (PurplePluginIpcInfo *)plugin->ipc_data; |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1087 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1088 | if (ipc_info == NULL || |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1089 | (ipc_command = g_hash_table_lookup(ipc_info->commands, |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1090 | command)) == NULL) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1091 | { |
| 15884 | 1092 | purple_debug_error("plugins", |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1093 | "IPC command '%s' was not registered for plugin %s\n", |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1094 | command, plugin->info->name); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1095 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1096 | return FALSE; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1097 | } |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1098 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1099 | if (num_params != NULL) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1100 | *num_params = ipc_command->num_params; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1101 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1102 | if (params != NULL) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1103 | *params = ipc_command->params; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1104 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1105 | if (ret_value != NULL) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1106 | *ret_value = ipc_command->ret_value; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1107 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1108 | return TRUE; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1109 | } |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1110 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1111 | void * |
| 15884 | 1112 | purple_plugin_ipc_call(PurplePlugin *plugin, const char *command, |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1113 | gboolean *ok, ...) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1114 | { |
| 15884 | 1115 | PurplePluginIpcInfo *ipc_info; |
| 1116 | PurplePluginIpcCommand *ipc_command; | |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1117 | va_list args; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1118 | void *ret_value; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1119 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1120 | if (ok != NULL) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1121 | *ok = FALSE; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1122 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1123 | g_return_val_if_fail(plugin != NULL, NULL); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1124 | g_return_val_if_fail(command != NULL, NULL); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1125 | |
| 15884 | 1126 | ipc_info = (PurplePluginIpcInfo *)plugin->ipc_data; |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1127 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1128 | if (ipc_info == NULL || |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1129 | (ipc_command = g_hash_table_lookup(ipc_info->commands, |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1130 | command)) == NULL) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1131 | { |
| 15884 | 1132 | purple_debug_error("plugins", |
|
6822
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1133 | "IPC command '%s' was not registered for plugin %s\n", |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1134 | command, plugin->info->name); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1135 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1136 | return NULL; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1137 | } |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1138 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1139 | va_start(args, ok); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1140 | ipc_command->marshal(ipc_command->func, args, NULL, &ret_value); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1141 | va_end(args); |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1142 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1143 | if (ok != NULL) |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1144 | *ok = TRUE; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1145 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1146 | return ret_value; |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1147 | } |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1148 | |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1149 | /************************************************************************** |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1150 | * Plugins subsystem |
|
4adcde13ad17
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6639
diff
changeset
|
1151 | **************************************************************************/ |
| 10479 | 1152 | void * |
| 15884 | 1153 | purple_plugins_get_handle(void) { |
| 10479 | 1154 | static int handle; |
| 1155 | ||
| 1156 | return &handle; | |
| 1157 | } | |
| 1158 | ||
| 1159 | void | |
| 15884 | 1160 | purple_plugins_init(void) { |
| 1161 | void *handle = purple_plugins_get_handle(); | |
| 10479 | 1162 | |
| 15884 | 1163 | purple_plugins_add_search_path(LIBDIR); |
|
15523
8505bd287c48
This renames the binary to 'pidgin', and I think it properly
Sean Egan <seanegan@pidgin.im>
parents:
15444
diff
changeset
|
1164 | |
| 15884 | 1165 | purple_signal_register(handle, "plugin-load", |
| 1166 | purple_marshal_VOID__POINTER, | |
| 10479 | 1167 | NULL, 1, |
| 15884 | 1168 | purple_value_new(PURPLE_TYPE_SUBTYPE, |
| 1169 | PURPLE_SUBTYPE_PLUGIN)); | |
| 1170 | purple_signal_register(handle, "plugin-unload", | |
| 1171 | purple_marshal_VOID__POINTER, | |
| 10479 | 1172 | NULL, 1, |
| 15884 | 1173 | purple_value_new(PURPLE_TYPE_SUBTYPE, |
| 1174 | PURPLE_SUBTYPE_PLUGIN)); | |
| 10479 | 1175 | } |
| 1176 | ||
| 1177 | void | |
| 15884 | 1178 | purple_plugins_uninit(void) { |
| 1179 | purple_signals_disconnect_by_handle(purple_plugins_get_handle()); | |
| 10479 | 1180 | } |
| 1181 | ||
| 1182 | /************************************************************************** | |
| 1183 | * Plugins API | |
| 1184 | **************************************************************************/ | |
| 5205 | 1185 | void |
| 15884 | 1186 | purple_plugins_add_search_path(const char *path) |
| 5205 | 1187 | { |
|
10447
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
1188 | g_return_if_fail(path != NULL); |
| 5205 | 1189 | |
|
10447
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
1190 | if (g_list_find_custom(search_paths, path, (GCompareFunc)strcmp)) |
|
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
1191 | return; |
| 5205 | 1192 | |
|
10447
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
1193 | search_paths = g_list_append(search_paths, strdup(path)); |
| 5205 | 1194 | } |
| 1195 | ||
| 1196 | void | |
| 15884 | 1197 | purple_plugins_unload_all(void) |
| 5205 | 1198 | { |
| 15884 | 1199 | #ifdef PURPLE_PLUGINS |
| 5205 | 1200 | |
| 1201 | while (loaded_plugins != NULL) | |
| 15884 | 1202 | purple_plugin_unload(loaded_plugins->data); |
| 5205 | 1203 | |
| 15884 | 1204 | #endif /* PURPLE_PLUGINS */ |
| 5205 | 1205 | } |
| 1206 | ||
| 1207 | void | |
| 15884 | 1208 | purple_plugins_destroy_all(void) |
|
5242
155da5e9bbf0
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1209 | { |
| 15884 | 1210 | #ifdef PURPLE_PLUGINS |
|
5242
155da5e9bbf0
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1211 | |
|
155da5e9bbf0
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1212 | while (plugins != NULL) |
| 15884 | 1213 | purple_plugin_destroy(plugins->data); |
|
5242
155da5e9bbf0
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1214 | |
| 15884 | 1215 | #endif /* PURPLE_PLUGINS */ |
|
5242
155da5e9bbf0
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1216 | } |
| 5838 | 1217 | |
| 1218 | void | |
| 15884 | 1219 | purple_plugins_save_loaded(const char *key) |
| 15357 | 1220 | { |
| 15884 | 1221 | #ifdef PURPLE_PLUGINS |
| 15357 | 1222 | GList *pl; |
| 1223 | GList *files = NULL; | |
| 15884 | 1224 | PurplePlugin *p; |
| 15357 | 1225 | |
| 15884 | 1226 | for (pl = purple_plugins_get_loaded(); pl != NULL; pl = pl->next) { |
| 15357 | 1227 | p = pl->data; |
| 1228 | ||
| 15884 | 1229 | if (p->info->type != PURPLE_PLUGIN_PROTOCOL && |
| 1230 | p->info->type != PURPLE_PLUGIN_LOADER) { | |
| 15357 | 1231 | files = g_list_append(files, p->path); |
| 1232 | } | |
| 1233 | } | |
| 1234 | ||
| 15884 | 1235 | purple_prefs_set_path_list(key, files); |
| 15357 | 1236 | g_list_free(files); |
| 1237 | #endif | |
| 1238 | } | |
| 1239 | ||
| 1240 | void | |
| 15884 | 1241 | purple_plugins_load_saved(const char *key) |
| 5838 | 1242 | { |
| 15884 | 1243 | #ifdef PURPLE_PLUGINS |
|
5949
bb7cbf02dda9
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
1244 | GList *f, *files; |
|
bb7cbf02dda9
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
1245 | |
|
bb7cbf02dda9
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
1246 | g_return_if_fail(key != NULL); |
| 5838 | 1247 | |
| 15884 | 1248 | files = purple_prefs_get_path_list(key); |
|
5949
bb7cbf02dda9
[gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents:
5941
diff
changeset
|
1249 | |
|
7033
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1250 | for (f = files; f; f = f->next) |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1251 | { |
|
10682
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
1252 | char *filename; |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
1253 | char *basename; |
| 15884 | 1254 | PurplePlugin *plugin; |
|
10682
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
1255 | |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
1256 | if (f->data == NULL) |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
1257 | continue; |
|
7033
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1258 | |
|
10682
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
1259 | filename = f->data; |
|
13528
541152b0fad0
[gaim-migrate @ 15903]
Daniel Atallah <datallah@pidgin.im>
parents:
13311
diff
changeset
|
1260 | |
|
10682
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
1261 | /* |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
1262 | * We don't know if the filename uses Windows or Unix path |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
1263 | * separators (because people might be sharing a prefs.xml |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
1264 | * file across systems), so we find the last occurrence |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
1265 | * of either. |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
1266 | */ |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
1267 | basename = strrchr(filename, '/'); |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
1268 | if ((basename == NULL) || (basename < strrchr(filename, '\\'))) |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
1269 | basename = strrchr(filename, '\\'); |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
1270 | if (basename != NULL) |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
1271 | basename++; |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
1272 | |
|
13528
541152b0fad0
[gaim-migrate @ 15903]
Daniel Atallah <datallah@pidgin.im>
parents:
13311
diff
changeset
|
1273 | /* Strip the extension */ |
|
13567
4ec075b1ae40
[gaim-migrate @ 15945]
Daniel Atallah <datallah@pidgin.im>
parents:
13528
diff
changeset
|
1274 | if (basename) |
| 15884 | 1275 | basename = purple_plugin_get_basename(filename); |
|
13528
541152b0fad0
[gaim-migrate @ 15903]
Daniel Atallah <datallah@pidgin.im>
parents:
13311
diff
changeset
|
1276 | |
| 15884 | 1277 | if ((plugin = purple_plugins_find_with_filename(filename)) != NULL) |
|
7033
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1278 | { |
| 15884 | 1279 | purple_debug_info("plugins", "Loading saved plugin %s\n", |
|
10682
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
1280 | plugin->path); |
| 15884 | 1281 | purple_plugin_load(plugin); |
|
10682
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
1282 | } |
| 15884 | 1283 | else if (basename && (plugin = purple_plugins_find_with_basename(basename)) != NULL) |
|
10682
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
1284 | { |
| 15884 | 1285 | purple_debug_info("plugins", "Loading saved plugin %s\n", |
|
10682
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
1286 | plugin->path); |
| 15884 | 1287 | purple_plugin_load(plugin); |
|
10682
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
1288 | } |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
1289 | else |
|
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
1290 | { |
| 15884 | 1291 | purple_debug_error("plugins", "Unable to find saved plugin %s\n", |
|
10682
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
1292 | filename); |
|
7033
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1293 | } |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1294 | |
|
13528
541152b0fad0
[gaim-migrate @ 15903]
Daniel Atallah <datallah@pidgin.im>
parents:
13311
diff
changeset
|
1295 | g_free(basename); |
|
541152b0fad0
[gaim-migrate @ 15903]
Daniel Atallah <datallah@pidgin.im>
parents:
13311
diff
changeset
|
1296 | |
| 5838 | 1297 | g_free(f->data); |
| 1298 | } | |
| 1299 | ||
| 1300 | g_list_free(files); | |
| 15884 | 1301 | #endif /* PURPLE_PLUGINS */ |
| 5838 | 1302 | } |
| 1303 | ||
| 1304 | ||
|
5242
155da5e9bbf0
[gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1305 | void |
| 15884 | 1306 | purple_plugins_probe(const char *ext) |
| 5205 | 1307 | { |
| 15884 | 1308 | #ifdef PURPLE_PLUGINS |
| 5205 | 1309 | GDir *dir; |
| 1310 | const gchar *file; | |
| 1311 | gchar *path; | |
| 15884 | 1312 | PurplePlugin *plugin; |
|
10447
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
1313 | GList *cur; |
|
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
1314 | const char *search_path; |
| 5205 | 1315 | |
| 1316 | if (!g_module_supported()) | |
| 1317 | return; | |
| 1318 | ||
|
10447
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
1319 | /* Probe plugins */ |
|
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
1320 | for (cur = search_paths; cur != NULL; cur = cur->next) |
|
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
1321 | { |
|
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
1322 | search_path = cur->data; |
| 5205 | 1323 | |
|
10447
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
1324 | dir = g_dir_open(search_path, 0, NULL); |
| 5205 | 1325 | |
|
10447
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
1326 | if (dir != NULL) |
|
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
1327 | { |
|
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
1328 | while ((file = g_dir_read_name(dir)) != NULL) |
|
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
1329 | { |
|
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
1330 | path = g_build_filename(search_path, file, NULL); |
| 5205 | 1331 | |
|
10447
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
1332 | if (ext == NULL || has_file_extension(file, ext)) |
| 15884 | 1333 | plugin = purple_plugin_probe(path); |
| 5205 | 1334 | |
| 1335 | g_free(path); | |
| 1336 | } | |
| 1337 | ||
| 1338 | g_dir_close(dir); | |
| 1339 | } | |
| 1340 | } | |
| 1341 | ||
|
10447
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
1342 | /* See if we have any plugins waiting to load */ |
|
6981
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1343 | while (load_queue != NULL) |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1344 | { |
| 15884 | 1345 | plugin = (PurplePlugin *)load_queue->data; |
|
6981
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1346 | |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1347 | load_queue = g_list_remove(load_queue, plugin); |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1348 | |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1349 | if (plugin == NULL || plugin->info == NULL) |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1350 | continue; |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1351 | |
| 15884 | 1352 | if (plugin->info->type == PURPLE_PLUGIN_LOADER) |
|
6981
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1353 | { |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1354 | /* We'll just load this right now. */ |
| 15884 | 1355 | if (!purple_plugin_load(plugin)) |
|
6981
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1356 | { |
| 15884 | 1357 | purple_plugin_destroy(plugin); |
|
6981
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1358 | |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1359 | continue; |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1360 | } |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1361 | |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1362 | plugin_loaders = g_list_append(plugin_loaders, plugin); |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1363 | |
| 15884 | 1364 | for (cur = PURPLE_PLUGIN_LOADER_INFO(plugin)->exts; |
|
10447
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
1365 | cur != NULL; |
|
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
1366 | cur = cur->next) |
|
6981
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1367 | { |
| 15884 | 1368 | purple_plugins_probe(cur->data); |
|
6981
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1369 | } |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1370 | } |
| 15884 | 1371 | else if (plugin->info->type == PURPLE_PLUGIN_PROTOCOL) |
|
6981
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1372 | { |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1373 | /* We'll just load this right now. */ |
| 15884 | 1374 | if (!purple_plugin_load(plugin)) |
|
6981
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1375 | { |
| 15884 | 1376 | purple_plugin_destroy(plugin); |
|
6981
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1377 | |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1378 | continue; |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1379 | } |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1380 | |
|
11950
a522c2da66e5
[gaim-migrate @ 14241]
Evan Schoenberg <evands@pidgin.im>
parents:
11772
diff
changeset
|
1381 | /* Make sure we don't load two PRPLs with the same name? */ |
| 15884 | 1382 | if (purple_find_prpl(plugin->info->id)) |
|
6981
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1383 | { |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1384 | /* Nothing to see here--move along, move along */ |
| 15884 | 1385 | purple_plugin_destroy(plugin); |
|
6981
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1386 | |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1387 | continue; |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1388 | } |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1389 | |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1390 | protocol_plugins = g_list_insert_sorted(protocol_plugins, plugin, |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1391 | (GCompareFunc)compare_prpl); |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1392 | } |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1393 | } |
|
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1394 | |
| 5205 | 1395 | if (probe_cb != NULL) |
| 1396 | probe_cb(probe_cb_data); | |
| 15884 | 1397 | #endif /* PURPLE_PLUGINS */ |
| 5205 | 1398 | } |
| 1399 | ||
| 1400 | gboolean | |
| 15884 | 1401 | purple_plugin_register(PurplePlugin *plugin) |
| 5205 | 1402 | { |
| 1403 | g_return_val_if_fail(plugin != NULL, FALSE); | |
| 1404 | ||
|
10447
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
1405 | /* If this plugin has been registered already then exit */ |
| 5205 | 1406 | if (g_list_find(plugins, plugin)) |
| 1407 | return TRUE; | |
| 1408 | ||
|
10447
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
1409 | /* Ensure the plugin has the requisite information */ |
| 15884 | 1410 | if (plugin->info->type == PURPLE_PLUGIN_LOADER) |
|
6981
749f11b02abf
[gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
1411 | { |
| 15884 | 1412 | PurplePluginLoaderInfo *loader_info; |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1413 | |
| 15884 | 1414 | loader_info = PURPLE_PLUGIN_LOADER_INFO(plugin); |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1415 | |
| 9943 | 1416 | if (loader_info == NULL) |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1417 | { |
| 15884 | 1418 | purple_debug_error("plugins", "%s is not loadable, loader plugin missing loader_info\n", |
| 9943 | 1419 | plugin->path); |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1420 | return FALSE; |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1421 | } |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1422 | } |
| 15884 | 1423 | else if (plugin->info->type == PURPLE_PLUGIN_PROTOCOL) |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1424 | { |
| 15884 | 1425 | PurplePluginProtocolInfo *prpl_info; |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1426 | |
| 15884 | 1427 | prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin); |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1428 | |
| 9943 | 1429 | if (prpl_info == NULL) |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1430 | { |
| 15884 | 1431 | purple_debug_error("plugins", "%s is not loadable, protocol plugin missing prpl_info\n", |
| 9943 | 1432 | plugin->path); |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1433 | return FALSE; |
|
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1434 | } |
|
10447
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
1435 | } |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
1436 | |
| 15884 | 1437 | #ifdef PURPLE_PLUGINS |
|
10447
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
1438 | /* This plugin should be probed and maybe loaded--add it to the queue */ |
|
887380ec66f5
[gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents:
10279
diff
changeset
|
1439 | load_queue = g_list_append(load_queue, plugin); |
|
11950
a522c2da66e5
[gaim-migrate @ 14241]
Evan Schoenberg <evands@pidgin.im>
parents:
11772
diff
changeset
|
1440 | #else |
|
12081
26a81230ffb1
[gaim-migrate @ 14378]
Evan Schoenberg <evands@pidgin.im>
parents:
12077
diff
changeset
|
1441 | if (plugin->info != NULL) |
|
26a81230ffb1
[gaim-migrate @ 14378]
Evan Schoenberg <evands@pidgin.im>
parents:
12077
diff
changeset
|
1442 | { |
| 15884 | 1443 | if (plugin->info->type == PURPLE_PLUGIN_PROTOCOL) |
|
12081
26a81230ffb1
[gaim-migrate @ 14378]
Evan Schoenberg <evands@pidgin.im>
parents:
12077
diff
changeset
|
1444 | protocol_plugins = g_list_insert_sorted(protocol_plugins, plugin, |
|
26a81230ffb1
[gaim-migrate @ 14378]
Evan Schoenberg <evands@pidgin.im>
parents:
12077
diff
changeset
|
1445 | (GCompareFunc)compare_prpl); |
|
26a81230ffb1
[gaim-migrate @ 14378]
Evan Schoenberg <evands@pidgin.im>
parents:
12077
diff
changeset
|
1446 | if (plugin->info->load != NULL) |
|
26a81230ffb1
[gaim-migrate @ 14378]
Evan Schoenberg <evands@pidgin.im>
parents:
12077
diff
changeset
|
1447 | if (!plugin->info->load(plugin)) |
|
26a81230ffb1
[gaim-migrate @ 14378]
Evan Schoenberg <evands@pidgin.im>
parents:
12077
diff
changeset
|
1448 | return FALSE; |
|
26a81230ffb1
[gaim-migrate @ 14378]
Evan Schoenberg <evands@pidgin.im>
parents:
12077
diff
changeset
|
1449 | } |
|
11950
a522c2da66e5
[gaim-migrate @ 14241]
Evan Schoenberg <evands@pidgin.im>
parents:
11772
diff
changeset
|
1450 | #endif |
| 5205 | 1451 | |
| 1452 | plugins = g_list_append(plugins, plugin); | |
| 1453 | ||
| 1454 | return TRUE; | |
| 1455 | } | |
| 1456 | ||
| 1457 | gboolean | |
| 15884 | 1458 | purple_plugins_enabled(void) |
| 5205 | 1459 | { |
| 15884 | 1460 | #ifdef PURPLE_PLUGINS |
| 5205 | 1461 | return TRUE; |
| 1462 | #else | |
| 1463 | return FALSE; | |
| 1464 | #endif | |
| 1465 | } | |
| 1466 | ||
| 1467 | void | |
| 15884 | 1468 | purple_plugins_register_probe_notify_cb(void (*func)(void *), void *data) |
| 5205 | 1469 | { |
| 1470 | /* TODO */ | |
| 1471 | probe_cb = func; | |
| 1472 | probe_cb_data = data; | |
| 1473 | } | |
| 1474 | ||
| 1475 | void | |
| 15884 | 1476 | purple_plugins_unregister_probe_notify_cb(void (*func)(void *)) |
| 5205 | 1477 | { |
| 1478 | /* TODO */ | |
| 1479 | probe_cb = NULL; | |
| 1480 | probe_cb_data = NULL; | |
| 1481 | } | |
| 1482 | ||
| 1483 | void | |
| 15884 | 1484 | purple_plugins_register_load_notify_cb(void (*func)(PurplePlugin *, void *), |
| 5205 | 1485 | void *data) |
| 1486 | { | |
| 1487 | /* TODO */ | |
| 1488 | load_cb = func; | |
| 1489 | load_cb_data = data; | |
| 1490 | } | |
| 1491 | ||
| 1492 | void | |
| 15884 | 1493 | purple_plugins_unregister_load_notify_cb(void (*func)(PurplePlugin *, void *)) |
| 5205 | 1494 | { |
| 1495 | /* TODO */ | |
| 1496 | load_cb = NULL; | |
| 1497 | load_cb_data = NULL; | |
| 1498 | } | |
| 1499 | ||
| 1500 | void | |
| 15884 | 1501 | purple_plugins_register_unload_notify_cb(void (*func)(PurplePlugin *, void *), |
| 5205 | 1502 | void *data) |
| 1503 | { | |
| 1504 | /* TODO */ | |
| 1505 | unload_cb = func; | |
| 1506 | unload_cb_data = data; | |
| 1507 | } | |
| 1508 | ||
| 1509 | void | |
| 15884 | 1510 | purple_plugins_unregister_unload_notify_cb(void (*func)(PurplePlugin *, void *)) |
| 5205 | 1511 | { |
| 1512 | /* TODO */ | |
| 1513 | unload_cb = NULL; | |
| 1514 | unload_cb_data = NULL; | |
| 1515 | } | |
| 1516 | ||
| 15884 | 1517 | PurplePlugin * |
| 1518 | purple_plugins_find_with_name(const char *name) | |
| 5205 | 1519 | { |
| 15884 | 1520 | PurplePlugin *plugin; |
| 5205 | 1521 | GList *l; |
| 1522 | ||
| 1523 | for (l = plugins; l != NULL; l = l->next) { | |
| 1524 | plugin = l->data; | |
| 1525 | ||
| 1526 | if (!strcmp(plugin->info->name, name)) | |
| 1527 | return plugin; | |
| 1528 | } | |
| 1529 | ||
| 1530 | return NULL; | |
| 1531 | } | |
| 1532 | ||
| 15884 | 1533 | PurplePlugin * |
| 1534 | purple_plugins_find_with_filename(const char *filename) | |
| 5205 | 1535 | { |
| 15884 | 1536 | PurplePlugin *plugin; |
| 5205 | 1537 | GList *l; |
| 1538 | ||
| 1539 | for (l = plugins; l != NULL; l = l->next) { | |
| 1540 | plugin = l->data; | |
| 1541 | ||
| 1542 | if (plugin->path != NULL && !strcmp(plugin->path, filename)) | |
| 1543 | return plugin; | |
| 1544 | } | |
| 1545 | ||
| 1546 | return NULL; | |
| 1547 | } | |
| 1548 | ||
| 15884 | 1549 | PurplePlugin * |
| 1550 | purple_plugins_find_with_basename(const char *basename) | |
|
7033
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1551 | { |
| 15884 | 1552 | #ifdef PURPLE_PLUGINS |
| 1553 | PurplePlugin *plugin; | |
|
7033
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1554 | GList *l; |
|
10682
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
1555 | char *tmp; |
|
7033
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1556 | |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1557 | g_return_val_if_fail(basename != NULL, NULL); |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1558 | |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1559 | for (l = plugins; l != NULL; l = l->next) |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1560 | { |
| 15884 | 1561 | plugin = (PurplePlugin *)l->data; |
|
7033
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1562 | |
| 7278 | 1563 | if (plugin->path != NULL) { |
| 15884 | 1564 | tmp = purple_plugin_get_basename(plugin->path); |
|
13528
541152b0fad0
[gaim-migrate @ 15903]
Daniel Atallah <datallah@pidgin.im>
parents:
13311
diff
changeset
|
1565 | if (!strcmp(tmp, basename)) |
|
10682
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
1566 | { |
| 7278 | 1567 | g_free(tmp); |
|
7033
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1568 | return plugin; |
| 7278 | 1569 | } |
| 7279 | 1570 | g_free(tmp); |
|
7033
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1571 | } |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1572 | } |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1573 | |
| 15884 | 1574 | #endif /* PURPLE_PLUGINS */ |
|
10682
c293ad49121e
[gaim-migrate @ 12228]
Richard Laager <rlaager@pidgin.im>
parents:
10504
diff
changeset
|
1575 | |
|
7033
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1576 | return NULL; |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1577 | } |
|
f6096f69a11e
[gaim-migrate @ 7596]
Robert McQueen <robot101@debian.org>
parents:
6982
diff
changeset
|
1578 | |
| 15884 | 1579 | PurplePlugin * |
| 1580 | purple_plugins_find_with_id(const char *id) | |
| 5205 | 1581 | { |
| 15884 | 1582 | PurplePlugin *plugin; |
| 5205 | 1583 | GList *l; |
| 1584 | ||
| 1585 | g_return_val_if_fail(id != NULL, NULL); | |
| 1586 | ||
|
6486
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1587 | for (l = plugins; l != NULL; l = l->next) |
|
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1588 | { |
| 5205 | 1589 | plugin = l->data; |
| 1590 | ||
|
6486
18da8fdbc85b
[gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1591 | if (plugin->info->id != NULL && !strcmp(plugin->info->id, id)) |
| 5205 | 1592 | return plugin; |
| 1593 | } | |
| 1594 | ||
| 1595 | return NULL; | |
| 1596 | } | |
| 1597 | ||
| 1598 | GList * | |
| 15884 | 1599 | purple_plugins_get_loaded(void) |
| 5205 | 1600 | { |
| 1601 | return loaded_plugins; | |
| 1602 | } | |
| 1603 | ||
| 1604 | GList * | |
| 15884 | 1605 | purple_plugins_get_protocols(void) |
|
5573
633880e3f137
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1606 | { |
|
633880e3f137
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1607 | return protocol_plugins; |
|
633880e3f137
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1608 | } |
|
633880e3f137
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1609 | |
|
633880e3f137
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1610 | GList * |
| 15884 | 1611 | purple_plugins_get_all(void) |
| 5205 | 1612 | { |
| 1613 | return plugins; | |
| 1614 | } | |
| 1615 | ||
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1616 | |
| 15884 | 1617 | PurplePluginAction * |
| 1618 | purple_plugin_action_new(const char* label, void (*callback)(PurplePluginAction *)) | |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1619 | { |
| 15884 | 1620 | PurplePluginAction *act = g_new0(PurplePluginAction, 1); |
|
9018
b13b46fa2f16
[gaim-migrate @ 9794]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1621 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
12992
diff
changeset
|
1622 | act->label = g_strdup(label); |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1623 | act->callback = callback; |
|
9018
b13b46fa2f16
[gaim-migrate @ 9794]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1624 | |
|
b13b46fa2f16
[gaim-migrate @ 9794]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1625 | return act; |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1626 | } |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
12992
diff
changeset
|
1627 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
12992
diff
changeset
|
1628 | void |
| 15884 | 1629 | purple_plugin_action_free(PurplePluginAction *action) |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
12992
diff
changeset
|
1630 | { |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
12992
diff
changeset
|
1631 | g_return_if_fail(action != NULL); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
12992
diff
changeset
|
1632 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
12992
diff
changeset
|
1633 | g_free(action->label); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
12992
diff
changeset
|
1634 | g_free(action); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
12992
diff
changeset
|
1635 | } |