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