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