annotate src/plugin.c @ 14184:bf7a02c6bb00

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