annotate src/plugin.c @ 6822:7dba3e17cb21

[gaim-migrate @ 7366] Added plugin IPC. Its use is shown in plugins/ipc-test-server.c and plugins/ipc-test-client.c. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sat, 13 Sep 2003 09:31:03 +0000
parents 1b91cb6be4c3
children abd3c684da31
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 *
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5 *
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
7 * 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
8 * the Free Software Foundation; either version 2 of the License, or
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 * (at your option) any later version.
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 *
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * GNU General Public License for more details.
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 *
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 */
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5840
diff changeset
20 #include "internal.h"
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5573
diff changeset
22 #include "accountopt.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5840
diff changeset
23 #include "debug.h"
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5357
diff changeset
24 #include "notify.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5840
diff changeset
25 #include "prefs.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5840
diff changeset
26 #include "prpl.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5840
diff changeset
27 #include "request.h"
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6432
diff changeset
28 #include "signals.h"
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
29
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30 #ifdef _WIN32
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
31 # define PLUGIN_EXT ".dll"
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
32 #else
6639
1b91cb6be4c3 [gaim-migrate @ 7164]
Luke Schierer <lschiere@pidgin.im>
parents: 6635
diff changeset
33 #ifdef __hpux
1b91cb6be4c3 [gaim-migrate @ 7164]
Luke Schierer <lschiere@pidgin.im>
parents: 6635
diff changeset
34 # define PLUGIN_EXT ".sl"
1b91cb6be4c3 [gaim-migrate @ 7164]
Luke Schierer <lschiere@pidgin.im>
parents: 6635
diff changeset
35 #else
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
36 # define PLUGIN_EXT ".so"
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37 #endif
6639
1b91cb6be4c3 [gaim-migrate @ 7164]
Luke Schierer <lschiere@pidgin.im>
parents: 6635
diff changeset
38 #endif
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39
6822
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
40 typedef struct
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 GHashTable *commands;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
43 size_t command_count;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
44
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
45 } GaimPluginIpcInfo;
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 typedef struct
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
48 {
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
49 GaimCallback func;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
50 GaimSignalMarshalFunc marshal;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
51
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
52 int num_params;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
53 GaimValue **params;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
54 GaimValue *ret_value;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
55
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
56 } GaimPluginIpcCommand;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
57
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58 static GList *loaded_plugins = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59 static GList *plugins = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60 static GList *plugin_loaders = NULL;
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
61 static GList *protocol_plugins = NULL;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63 static size_t search_path_count = 0;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64 static char **search_paths = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
66 static void (*probe_cb)(void *) = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
67 static void *probe_cb_data = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68 static void (*load_cb)(GaimPlugin *, void *) = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69 static void *load_cb_data = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70 static void (*unload_cb)(GaimPlugin *, void *) = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71 static void *unload_cb_data = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73 #ifdef GAIM_PLUGINS
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
74 static int
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
75 is_so_file(const char *filename, const char *ext)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
76 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77 int len, extlen;
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 if (filename == NULL || *filename == '\0' || ext == NULL)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80 return 0;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82 extlen = strlen(ext);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 len = strlen(filename) - extlen;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85 if (len < 0)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86 return 0;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
88 return (!strncmp(filename + len, ext, extlen));
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91 static gboolean
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
92 loader_supports_file(GaimPlugin *loader, const char *filename)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93 {
6432
f9428d38c03b [gaim-migrate @ 6940]
Luke Schierer <lschiere@pidgin.im>
parents: 5981
diff changeset
94 GList *exts;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95
6432
f9428d38c03b [gaim-migrate @ 6940]
Luke Schierer <lschiere@pidgin.im>
parents: 5981
diff changeset
96 for (exts = GAIM_PLUGIN_LOADER_INFO(loader)->exts; exts != NULL; exts = exts->next) {
f9428d38c03b [gaim-migrate @ 6940]
Luke Schierer <lschiere@pidgin.im>
parents: 5981
diff changeset
97 if (is_so_file(filename, (char *)exts->data)) {
f9428d38c03b [gaim-migrate @ 6940]
Luke Schierer <lschiere@pidgin.im>
parents: 5981
diff changeset
98 return TRUE;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
99 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
101
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
102 return FALSE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
103 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
104
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
105 static GaimPlugin *
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
106 find_loader_for_plugin(const GaimPlugin *plugin)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
107 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
108 GaimPlugin *loader;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
109 GList *l;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
110
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111 if (plugin->path == NULL)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112 return NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114 for (l = gaim_plugins_get_loaded(); l != NULL; l = l->next) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
115 loader = l->data;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
117 if (loader->info->type == GAIM_PLUGIN_LOADER &&
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
118 loader_supports_file(loader, plugin->path)) {
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
120 return loader;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
121 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123 loader = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
125
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
126 return NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128
5449
9442e8d0b21d [gaim-migrate @ 5836]
Luke Schierer <lschiere@pidgin.im>
parents: 5443
diff changeset
129 #endif /* GAIM_PLUGINS */
9442e8d0b21d [gaim-migrate @ 5836]
Luke Schierer <lschiere@pidgin.im>
parents: 5443
diff changeset
130
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131 static gint
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
132 compare_prpl(GaimPlugin *a, GaimPlugin *b)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134 /* neg if a before b, 0 if equal, pos if a after b */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135 return ((GAIM_IS_PROTOCOL_PLUGIN(a)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136 ? GAIM_PLUGIN_PROTOCOL_INFO(a)->protocol : -1) -
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137 ((GAIM_IS_PROTOCOL_PLUGIN(b)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138 ? GAIM_PLUGIN_PROTOCOL_INFO(b)->protocol : -1)));
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
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141 GaimPlugin *
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
142 gaim_plugin_new(gboolean native, const char *path)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
143 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
144 GaimPlugin *plugin;
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 plugin = g_new0(GaimPlugin, 1);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
147
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
148 plugin->native_plugin = native;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149 plugin->path = (path == NULL ? NULL : g_strdup(path));
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151 return plugin;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
152 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
153
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
154 GaimPlugin *
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
155 gaim_plugin_probe(const char *filename)
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 #ifdef GAIM_PLUGINS
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
158 GaimPlugin *plugin = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159 GaimPlugin *loader;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
160 gboolean (*gaim_init_plugin)(GaimPlugin *);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
161
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
162 g_return_val_if_fail(filename != NULL, NULL);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
163
5973
53782414bc3a [gaim-migrate @ 6420]
Mark Doliner <mark@kingant.net>
parents: 5949
diff changeset
164 if (!g_file_test(filename, G_FILE_TEST_EXISTS))
53782414bc3a [gaim-migrate @ 6420]
Mark Doliner <mark@kingant.net>
parents: 5949
diff changeset
165 return NULL;
53782414bc3a [gaim-migrate @ 6420]
Mark Doliner <mark@kingant.net>
parents: 5949
diff changeset
166
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
167 plugin = gaim_plugins_find_with_filename(filename);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
168
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
169 if (plugin != NULL)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
170 return plugin;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
171
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
172 plugin = gaim_plugin_new(is_so_file(filename, PLUGIN_EXT), filename);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
173
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
174 if (plugin->native_plugin) {
5450
bb1e160467b6 [gaim-migrate @ 5838]
Nathan Walp <nwalp@pidgin.im>
parents: 5449
diff changeset
175 const char *error;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
176 plugin->handle = g_module_open(filename, 0);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
177
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
178 if (plugin->handle == NULL) {
5443
07358c067495 [gaim-migrate @ 5825]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
179 error = g_module_error();
5269
cd7e4ba049f9 [gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents: 5268
diff changeset
180 gaim_debug(GAIM_DEBUG_ERROR, "plugins", "%s is unloadable: %s\n",
5443
07358c067495 [gaim-migrate @ 5825]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
181 plugin->path, error ? error : "Unknown error.");
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
182
5269
cd7e4ba049f9 [gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents: 5268
diff changeset
183 gaim_plugin_destroy(plugin);
cd7e4ba049f9 [gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents: 5268
diff changeset
184
cd7e4ba049f9 [gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents: 5268
diff changeset
185 return NULL;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
186 }
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 if (!g_module_symbol(plugin->handle, "gaim_init_plugin",
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
189 (gpointer *)&gaim_init_plugin)) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
190 g_module_close(plugin->handle);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
191 plugin->handle = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
192
5443
07358c067495 [gaim-migrate @ 5825]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
193 error = g_module_error();
5211
0241d6b6702d [gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
194 gaim_debug(GAIM_DEBUG_ERROR, "plugins", "%s is unloadable: %s\n",
5443
07358c067495 [gaim-migrate @ 5825]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
195 plugin->path, error ? error : "Unknown error.");
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
196
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
197 gaim_plugin_destroy(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 return NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
200 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
201 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
202 else {
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
203 loader = find_loader_for_plugin(plugin);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
204
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
205 if (loader == NULL) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
206 gaim_plugin_destroy(plugin);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
207
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
208 return NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
209 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
210
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
211 gaim_init_plugin = GAIM_PLUGIN_LOADER_INFO(loader)->probe;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
212 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
213
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
214 plugin->error = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
215
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
216 if (!gaim_init_plugin(plugin) || plugin->info == NULL) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
217 gaim_plugin_destroy(plugin);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
218
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
219 return NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
220 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
221
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
222 return plugin;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
223 #else
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
224 return NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
225 #endif /* !GAIM_PLUGINS */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
226 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
227
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
228 gboolean
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
229 gaim_plugin_load(GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
230 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
231 #ifdef GAIM_PLUGINS
6486
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
232 GList *dep_list = NULL;
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
233 GList *l;
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
234
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
235 g_return_val_if_fail(plugin != NULL, FALSE);
5270
d1fe8e320dab [gaim-migrate @ 5642]
Christian Hammond <chipx86@chipx86.com>
parents: 5269
diff changeset
236 g_return_val_if_fail(plugin->error == NULL, FALSE);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
237
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
238 if (gaim_plugin_is_loaded(plugin))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
239 return TRUE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
240
6486
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
241 /*
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
242 * Go through the list of the plugin's dependencies.
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
243 *
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
244 * First pass: Make sure all the plugins needed are probed.
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
245 */
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
246 for (l = plugin->info->dependencies; l != NULL; l = l->next)
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
247 {
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
248 const char *dep_name = (const char *)l->data;
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
249 GaimPlugin *dep_plugin;
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
250
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
251 dep_plugin = gaim_plugins_find_with_id(dep_name);
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
252
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
253 if (dep_plugin == NULL)
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
254 {
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
255 char buf[BUFSIZ];
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
256
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
257 g_snprintf(buf, sizeof(buf),
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
258 _("The required plugin %s was not found. "
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
259 "Please install this plugin and try again."),
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
260 dep_name);
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
261
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
262 gaim_notify_error(NULL, NULL,
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
263 _("Gaim was unable to load your plugin."),
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
264 buf);
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
265
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
266 if (dep_list != NULL)
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
267 g_list_free(dep_list);
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
268
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
269 return FALSE;
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
270 }
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
271
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
272 dep_list = g_list_append(dep_list, dep_plugin);
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
273 }
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
274
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
275 /* Second pass: load all the required plugins. */
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
276 for (l = dep_list; l != NULL; l = l->next)
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
277 {
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
278 GaimPlugin *dep_plugin = (GaimPlugin *)l->data;
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
279
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
280 if (!gaim_plugin_is_loaded(dep_plugin))
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
281 {
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
282 if (!gaim_plugin_load(dep_plugin))
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
283 {
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
284 char buf[BUFSIZ];
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
285
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
286 g_snprintf(buf, sizeof(buf),
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
287 _("The required plugin %s was unable to load."),
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
288 plugin->info->name);
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
289
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
290 gaim_notify_error(NULL, NULL,
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
291 _("Gaim was unable to load your plugin."),
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
292 buf);
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
293
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
294 if (dep_list != NULL)
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
295 g_list_free(dep_list);
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
296
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
297 return FALSE;
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
298 }
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
299 }
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
300 }
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
301
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
302 if (dep_list != NULL)
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
303 g_list_free(dep_list);
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
304
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
305 if (plugin->native_plugin) {
5357
2a1c92df7024 [gaim-migrate @ 5733]
Christian Hammond <chipx86@chipx86.com>
parents: 5270
diff changeset
306 if (plugin->info != NULL) {
2a1c92df7024 [gaim-migrate @ 5733]
Christian Hammond <chipx86@chipx86.com>
parents: 5270
diff changeset
307 if (plugin->info->load != NULL)
2a1c92df7024 [gaim-migrate @ 5733]
Christian Hammond <chipx86@chipx86.com>
parents: 5270
diff changeset
308 plugin->info->load(plugin);
2a1c92df7024 [gaim-migrate @ 5733]
Christian Hammond <chipx86@chipx86.com>
parents: 5270
diff changeset
309 }
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
310 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
311 else {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
312 GaimPlugin *loader;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
313 GaimPluginLoaderInfo *loader_info;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
314
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
315 loader = find_loader_for_plugin(plugin);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
316
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
317 if (loader == NULL)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
318 return FALSE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
319
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
320 loader_info = GAIM_PLUGIN_LOADER_INFO(loader);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
321
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
322 if (loader_info->load != NULL)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
323 loader_info->load(plugin);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
324 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
325
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
326 loaded_plugins = g_list_append(loaded_plugins, plugin);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
327
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
328 plugin->loaded = TRUE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
329
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
330 /* TODO */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
331 if (load_cb != NULL)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
332 load_cb(plugin, load_cb_data);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
333
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
334 return TRUE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
335
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
336 #else
5449
9442e8d0b21d [gaim-migrate @ 5836]
Luke Schierer <lschiere@pidgin.im>
parents: 5443
diff changeset
337 return TRUE;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
338 #endif /* !GAIM_PLUGINS */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
339 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
340
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
341 gboolean
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
342 gaim_plugin_unload(GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
343 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
344 #ifdef GAIM_PLUGINS
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
345 g_return_val_if_fail(plugin != NULL, FALSE);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
346
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
347 loaded_plugins = g_list_remove(loaded_plugins, plugin);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
348
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
349 g_return_val_if_fail(gaim_plugin_is_loaded(plugin), FALSE);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
350
5211
0241d6b6702d [gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
351 gaim_debug(GAIM_DEBUG_INFO, "plugins", "Unloading plugin %s\n",
0241d6b6702d [gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
352 plugin->info->name);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
353
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
354 /* cancel any pending dialogs the plugin has */
5498
cce2d7868c78 [gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents: 5450
diff changeset
355 gaim_request_close_with_handle(plugin);
cce2d7868c78 [gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents: 5450
diff changeset
356 gaim_notify_close_with_handle(plugin);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
357
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
358 plugin->loaded = FALSE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
359
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
360 if (plugin->native_plugin) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
361 if (plugin->info->unload != NULL)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
362 plugin->info->unload(plugin);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
363
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
364 if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
365 GaimPluginProtocolInfo *prpl_info;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
366 GList *l;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
367
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
368 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
369
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5573
diff changeset
370 for (l = prpl_info->user_splits; l != NULL; l = l->next)
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5573
diff changeset
371 gaim_account_user_split_destroy(l->data);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
372
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5573
diff changeset
373 for (l = prpl_info->protocol_options; l != NULL; l = l->next)
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5573
diff changeset
374 gaim_account_option_destroy(l->data);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
375
5646
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5638
diff changeset
376 if (prpl_info->user_splits != NULL)
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5638
diff changeset
377 g_list_free(prpl_info->user_splits);
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5638
diff changeset
378
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5638
diff changeset
379 if (prpl_info->protocol_options != NULL)
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5638
diff changeset
380 g_list_free(prpl_info->protocol_options);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
381 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
382 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
383 else {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
384 GaimPlugin *loader;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
385 GaimPluginLoaderInfo *loader_info;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
386
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
387 loader = find_loader_for_plugin(plugin);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
388
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
389 if (loader == NULL)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
390 return FALSE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
391
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
392 loader_info = GAIM_PLUGIN_LOADER_INFO(loader);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
393
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
394 if (loader_info->load != NULL)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
395 loader_info->unload(plugin);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
396 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
397
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
398 gaim_signals_disconnect_by_handle(plugin);
6822
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
399 gaim_plugin_ipc_unregister_all(plugin);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
400
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
401 /* TODO */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
402 if (unload_cb != NULL)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
403 unload_cb(plugin, unload_cb_data);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
404
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
405 return TRUE;
5449
9442e8d0b21d [gaim-migrate @ 5836]
Luke Schierer <lschiere@pidgin.im>
parents: 5443
diff changeset
406 #else
9442e8d0b21d [gaim-migrate @ 5836]
Luke Schierer <lschiere@pidgin.im>
parents: 5443
diff changeset
407 return TRUE;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
408 #endif /* GAIM_PLUGINS */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
409 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
410
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
411 gboolean
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
412 gaim_plugin_reload(GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
413 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
414 #ifdef GAIM_PLUGINS
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
415 g_return_val_if_fail(plugin != NULL, FALSE);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
416 g_return_val_if_fail(gaim_plugin_is_loaded(plugin), FALSE);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
417
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
418 if (!gaim_plugin_unload(plugin))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
419 return FALSE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
420
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
421 if (!gaim_plugin_load(plugin))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
422 return FALSE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
423
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
424 return TRUE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
425 #else
5449
9442e8d0b21d [gaim-migrate @ 5836]
Luke Schierer <lschiere@pidgin.im>
parents: 5443
diff changeset
426 return TRUE;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
427 #endif /* !GAIM_PLUGINS */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
428 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
429
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
430 void
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
431 gaim_plugin_destroy(GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
432 {
5449
9442e8d0b21d [gaim-migrate @ 5836]
Luke Schierer <lschiere@pidgin.im>
parents: 5443
diff changeset
433 #ifdef GAIM_PLUGINS
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
434 g_return_if_fail(plugin != NULL);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
435
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
436 if (gaim_plugin_is_loaded(plugin))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
437 gaim_plugin_unload(plugin);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
438
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
439 plugins = g_list_remove(plugins, plugin);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
440
5243
f6e0c689a88b [gaim-migrate @ 5614]
Christian Hammond <chipx86@chipx86.com>
parents: 5242
diff changeset
441 if (plugin->info != NULL && plugin->info->dependencies != NULL)
f6e0c689a88b [gaim-migrate @ 5614]
Christian Hammond <chipx86@chipx86.com>
parents: 5242
diff changeset
442 g_list_free(plugin->info->dependencies);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
443
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
444 if (plugin->native_plugin) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
445
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
446 if (plugin->info != NULL && plugin->info->type == GAIM_PLUGIN_LOADER) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
447 GList *exts, *l, *next_l;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
448 GaimPlugin *p2;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
449
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
450 for (exts = GAIM_PLUGIN_LOADER_INFO(plugin)->exts;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
451 exts != NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
452 exts = exts->next) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
453
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
454 for (l = gaim_plugins_get_all(); l != NULL; l = next_l) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
455 next_l = l->next;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
456
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
457 p2 = l->data;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
458
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
459 if (p2->path != NULL && is_so_file(p2->path, exts->data))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
460 gaim_plugin_destroy(p2);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
461 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
462 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
463
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
464 g_list_free(GAIM_PLUGIN_LOADER_INFO(plugin)->exts);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
465
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
466 plugin_loaders = g_list_remove(plugin_loaders, plugin);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
467 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
468
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
469 if (plugin->info != NULL && plugin->info->destroy != NULL)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
470 plugin->info->destroy(plugin);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
471
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
472 if (plugin->handle != NULL)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
473 g_module_close(plugin->handle);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
474 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
475 else {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
476 GaimPlugin *loader;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
477 GaimPluginLoaderInfo *loader_info;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
478
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
479 loader = find_loader_for_plugin(plugin);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
480
5941
a3e60ff95b7d [gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
481 if (loader != NULL) {
a3e60ff95b7d [gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
482 loader_info = GAIM_PLUGIN_LOADER_INFO(loader);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
483
5941
a3e60ff95b7d [gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
484 if (loader_info->destroy != NULL)
a3e60ff95b7d [gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
485 loader_info->destroy(plugin);
a3e60ff95b7d [gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
486 }
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
487 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
488
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
489 if (plugin->path != NULL) g_free(plugin->path);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
490 if (plugin->error != NULL) g_free(plugin->error);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
491
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
492 g_free(plugin);
5449
9442e8d0b21d [gaim-migrate @ 5836]
Luke Schierer <lschiere@pidgin.im>
parents: 5443
diff changeset
493 #endif /* !GAIM_PLUGINS */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
494 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
495
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
496 gboolean
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
497 gaim_plugin_is_loaded(const GaimPlugin *plugin)
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 g_return_val_if_fail(plugin != NULL, FALSE);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
500
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
501 return plugin->loaded;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
502 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
503
6822
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
504 /**************************************************************************
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
505 * Plugin IPC
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
506 **************************************************************************/
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
507 static void
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
508 destroy_ipc_info(void *data)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
509 {
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
510 GaimPluginIpcCommand *ipc_command = (GaimPluginIpcCommand *)data;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
511 int i;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
512
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
513 for (i = 0; i < ipc_command->num_params; i++)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
514 gaim_value_destroy(ipc_command->params[i]);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
515
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
516 if (ipc_command->ret_value != NULL)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
517 gaim_value_destroy(ipc_command->ret_value);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
518
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
519 g_free(ipc_command);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
520 }
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
521
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
522 gboolean
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
523 gaim_plugin_ipc_register(GaimPlugin *plugin, const char *command,
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
524 GaimCallback func, GaimSignalMarshalFunc marshal,
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
525 GaimValue *ret_value, int num_params, ...)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
526 {
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
527 GaimPluginIpcInfo *ipc_info;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
528 GaimPluginIpcCommand *ipc_command;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
529
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
530 g_return_val_if_fail(plugin != NULL, FALSE);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
531 g_return_val_if_fail(command != NULL, FALSE);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
532 g_return_val_if_fail(func != NULL, FALSE);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
533 g_return_val_if_fail(marshal != NULL, FALSE);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
534
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
535 if (plugin->ipc_data == NULL)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
536 {
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
537 ipc_info = plugin->ipc_data = g_new0(GaimPluginIpcInfo, 1);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
538 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
539 g_free, destroy_ipc_info);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
540 }
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
541 else
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
542 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
543
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
544 ipc_command = g_new0(GaimPluginIpcCommand, 1);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
545 ipc_command->func = func;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
546 ipc_command->marshal = marshal;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
547 ipc_command->num_params = num_params;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
548 ipc_command->ret_value = ret_value;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
549
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
550 if (num_params > 0)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
551 {
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
552 va_list args;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
553 int i;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
554
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
555 ipc_command->params = g_new0(GaimValue *, num_params);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
556
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
557 va_start(args, num_params);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
558
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
559 for (i = 0; i < num_params; i++)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
560 ipc_command->params[i] = va_arg(args, GaimValue *);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
561
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
562 va_end(args);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
563 }
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
564
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
565 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
566
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
567 ipc_info->command_count++;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
568
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
569 return TRUE;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
570 }
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
571
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
572 void
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
573 gaim_plugin_ipc_unregister(GaimPlugin *plugin, const char *command)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
574 {
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
575 GaimPluginIpcInfo *ipc_info;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
576
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
577 g_return_if_fail(plugin != NULL);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
578 g_return_if_fail(command != NULL);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
579
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
580 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
581
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
582 if (ipc_info == NULL ||
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
583 g_hash_table_lookup(ipc_info->commands, command) == NULL)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
584 {
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
585 gaim_debug_error("plugins",
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
586 "IPC command '%s' was not registered for plugin %s\n",
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
587 command, plugin->info->name);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
588 return;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
589 }
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
590
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
591 g_hash_table_remove(ipc_info->commands, command);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
592
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
593 ipc_info->command_count--;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
594
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
595 if (ipc_info->command_count == 0)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
596 {
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
597 g_hash_table_destroy(ipc_info->commands);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
598 g_free(ipc_info);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
599
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
600 plugin->ipc_data = NULL;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
601 }
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
602 }
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
603
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
604 void
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
605 gaim_plugin_ipc_unregister_all(GaimPlugin *plugin)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
606 {
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
607 GaimPluginIpcInfo *ipc_info;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
608
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
609 g_return_if_fail(plugin != NULL);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
610
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
611 if (plugin->ipc_data == NULL)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
612 return; /* Silently ignore it. */
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
613
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
614 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
615
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
616 g_hash_table_destroy(ipc_info->commands);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
617 g_free(ipc_info);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
618
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
619 plugin->ipc_data = NULL;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
620 }
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
621
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
622 gboolean
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
623 gaim_plugin_ipc_get_params(GaimPlugin *plugin, const char *command,
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
624 GaimValue **ret_value, int *num_params,
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
625 GaimValue ***params)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
626 {
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
627 GaimPluginIpcInfo *ipc_info;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
628 GaimPluginIpcCommand *ipc_command;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
629
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
630 g_return_val_if_fail(plugin != NULL, FALSE);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
631 g_return_val_if_fail(command != NULL, FALSE);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
632
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
633 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
634
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
635 if (ipc_info == NULL ||
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
636 (ipc_command = g_hash_table_lookup(ipc_info->commands,
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
637 command)) == NULL)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
638 {
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
639 gaim_debug_error("plugins",
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
640 "IPC command '%s' was not registered for plugin %s\n",
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
641 command, plugin->info->name);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
642
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
643 return FALSE;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
644 }
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
645
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
646 if (num_params != NULL)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
647 *num_params = ipc_command->num_params;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
648
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
649 if (params != NULL)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
650 *params = ipc_command->params;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
651
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
652 if (ret_value != NULL)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
653 *ret_value = ipc_command->ret_value;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
654
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
655 return TRUE;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
656 }
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
657
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
658 void *
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
659 gaim_plugin_ipc_call(GaimPlugin *plugin, const char *command,
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
660 gboolean *ok, ...)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
661 {
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
662 GaimPluginIpcInfo *ipc_info;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
663 GaimPluginIpcCommand *ipc_command;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
664 va_list args;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
665 void *ret_value;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
666
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
667 if (ok != NULL)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
668 *ok = FALSE;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
669
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
670 g_return_val_if_fail(plugin != NULL, NULL);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
671 g_return_val_if_fail(command != NULL, NULL);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
672
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
673 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
674
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
675 if (ipc_info == NULL ||
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
676 (ipc_command = g_hash_table_lookup(ipc_info->commands,
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
677 command)) == NULL)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
678 {
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
679 gaim_debug_error("plugins",
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
680 "IPC command '%s' was not registered for plugin %s\n",
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
681 command, plugin->info->name);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
682
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
683 return NULL;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
684 }
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
685
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
686 va_start(args, ok);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
687 ipc_command->marshal(ipc_command->func, args, NULL, &ret_value);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
688 va_end(args);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
689
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
690 if (ok != NULL)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
691 *ok = TRUE;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
692
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
693 return ret_value;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
694 }
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
695
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
696 /**************************************************************************
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
697 * Plugins subsystem
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
698 **************************************************************************/
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
699 void
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
700 gaim_plugins_set_search_paths(size_t count, char **paths)
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 size_t s;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
703
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
704 g_return_if_fail(count > 0);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
705 g_return_if_fail(paths != NULL);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
706
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
707 if (search_paths != NULL) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
708 for (s = 0; s < search_path_count; s++)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
709 g_free(search_paths[s]);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
710
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
711 g_free(search_paths);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
712 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
713
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
714 search_paths = g_new0(char *, count);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
715
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
716 for (s = 0; s < count; s++) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
717 if (paths[s] == NULL)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
718 search_paths[s] = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
719 else
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
720 search_paths[s] = g_strdup(paths[s]);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
721 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
722
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
723 search_path_count = count;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
724 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
725
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
726 void
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
727 gaim_plugins_unload_all(void)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
728 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
729 #ifdef GAIM_PLUGINS
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
730
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
731 while (loaded_plugins != NULL)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
732 gaim_plugin_unload(loaded_plugins->data);
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 #endif /* GAIM_PLUGINS */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
735 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
736
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
737 void
5242
fd81a00480ac [gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents: 5211
diff changeset
738 gaim_plugins_destroy_all(void)
fd81a00480ac [gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents: 5211
diff changeset
739 {
fd81a00480ac [gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents: 5211
diff changeset
740 #ifdef GAIM_PLUGINS
fd81a00480ac [gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents: 5211
diff changeset
741
fd81a00480ac [gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents: 5211
diff changeset
742 while (plugins != NULL)
fd81a00480ac [gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents: 5211
diff changeset
743 gaim_plugin_destroy(plugins->data);
fd81a00480ac [gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents: 5211
diff changeset
744
fd81a00480ac [gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents: 5211
diff changeset
745 #endif /* GAIM_PLUGINS */
fd81a00480ac [gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents: 5211
diff changeset
746 }
5838
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5794
diff changeset
747
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5794
diff changeset
748 void
5949
90d0849abd3c [gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents: 5941
diff changeset
749 gaim_plugins_load_saved(const char *key)
5838
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5794
diff changeset
750 {
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5794
diff changeset
751 #ifdef GAIM_PLUGINS
5949
90d0849abd3c [gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents: 5941
diff changeset
752 GList *f, *files;
90d0849abd3c [gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents: 5941
diff changeset
753
90d0849abd3c [gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents: 5941
diff changeset
754 g_return_if_fail(key != NULL);
5838
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5794
diff changeset
755
5949
90d0849abd3c [gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents: 5941
diff changeset
756 files = gaim_prefs_get_string_list(key);
90d0849abd3c [gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents: 5941
diff changeset
757
90d0849abd3c [gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents: 5941
diff changeset
758 for (f = files; f; f = f->next) {
5838
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5794
diff changeset
759 gaim_plugin_load(gaim_plugin_probe(f->data));
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5794
diff changeset
760 g_free(f->data);
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5794
diff changeset
761 }
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5794
diff changeset
762
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5794
diff changeset
763 g_list_free(files);
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5794
diff changeset
764 #endif /* GAIM_PLUGINS */
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5794
diff changeset
765 }
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5794
diff changeset
766
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5794
diff changeset
767
5242
fd81a00480ac [gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents: 5211
diff changeset
768 void
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
769 gaim_plugins_probe(const char *ext)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
770 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
771 #ifdef GAIM_PLUGINS
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
772 GDir *dir;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
773 const gchar *file;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
774 gchar *path;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
775 GaimPlugin *plugin;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
776 size_t i;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
777
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
778 if (!g_module_supported())
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
779 return;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
780
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
781 for (i = 0; i < search_path_count; i++) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
782 if (search_paths[i] == NULL)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
783 continue;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
784
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
785 dir = g_dir_open(search_paths[i], 0, NULL);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
786
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
787 if (dir != NULL) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
788 while ((file = g_dir_read_name(dir)) != NULL) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
789 path = g_build_filename(search_paths[i], file, NULL);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
790
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
791 if (ext == NULL || is_so_file(file, ext))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
792 plugin = gaim_plugin_probe(path);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
793
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
794 g_free(path);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
795 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
796
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
797 g_dir_close(dir);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
798 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
799 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
800
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
801 if (probe_cb != NULL)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
802 probe_cb(probe_cb_data);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
803
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
804 #endif /* GAIM_PLUGINS */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
805 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
806
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
807 gboolean
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
808 gaim_plugin_register(GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
809 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
810 g_return_val_if_fail(plugin != NULL, FALSE);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
811
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
812 if (g_list_find(plugins, plugin))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
813 return TRUE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
814
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
815 /* Special exception for loader plugins. We want them loaded NOW! */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
816 if (plugin->info->type == GAIM_PLUGIN_LOADER) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
817 GList *exts;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
818
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
819 /* We'll just load this right now. */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
820 if (!gaim_plugin_load(plugin)) {
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 gaim_plugin_destroy(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 return FALSE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
825 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
826
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
827 plugin_loaders = g_list_append(plugin_loaders, plugin);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
828
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
829 for (exts = GAIM_PLUGIN_LOADER_INFO(plugin)->exts;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
830 exts != NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
831 exts = exts->next) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
832
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
833 gaim_plugins_probe(exts->data);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
834 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
835 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
836 else if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
837
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
838 /* We'll just load this right now. */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
839 if (!gaim_plugin_load(plugin)) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
840
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
841 gaim_plugin_destroy(plugin);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
842
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
843 return FALSE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
844 }
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 if (GAIM_PLUGIN_PROTOCOL_INFO(plugin)->protocol == GAIM_PROTO_ICQ ||
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
847 gaim_find_prpl(GAIM_PLUGIN_PROTOCOL_INFO(plugin)->protocol)) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
848
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
849 /* Nothing to see here--move along, move along */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
850 gaim_plugin_destroy(plugin);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
851
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
852 return FALSE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
853 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
854
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
855 protocol_plugins = g_list_insert_sorted(protocol_plugins, plugin,
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
856 (GCompareFunc)compare_prpl);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
857 }
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 plugins = g_list_append(plugins, plugin);
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 TRUE;
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
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
864 gboolean
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
865 gaim_plugins_enabled(void)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
866 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
867 #ifdef GAIM_PLUGINS
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
868 return TRUE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
869 #else
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
870 return FALSE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
871 #endif
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
872 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
873
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
874 void
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
875 gaim_plugins_register_probe_notify_cb(void (*func)(void *), void *data)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
876 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
877 /* TODO */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
878 probe_cb = func;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
879 probe_cb_data = data;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
880 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
881
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
882 void
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
883 gaim_plugins_unregister_probe_notify_cb(void (*func)(void *))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
884 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
885 /* TODO */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
886 probe_cb = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
887 probe_cb_data = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
888 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
889
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
890 void
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
891 gaim_plugins_register_load_notify_cb(void (*func)(GaimPlugin *, void *),
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
892 void *data)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
893 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
894 /* TODO */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
895 load_cb = func;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
896 load_cb_data = data;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
897 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
898
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
899 void
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
900 gaim_plugins_unregister_load_notify_cb(void (*func)(GaimPlugin *, void *))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
901 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
902 /* TODO */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
903 load_cb = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
904 load_cb_data = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
905 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
906
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
907 void
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
908 gaim_plugins_register_unload_notify_cb(void (*func)(GaimPlugin *, void *),
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
909 void *data)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
910 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
911 /* TODO */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
912 unload_cb = func;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
913 unload_cb_data = data;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
914 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
915
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
916 void
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
917 gaim_plugins_unregister_unload_notify_cb(void (*func)(GaimPlugin *, void *))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
918 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
919 /* TODO */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
920 unload_cb = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
921 unload_cb_data = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
922 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
923
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
924 GaimPlugin *
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
925 gaim_plugins_find_with_name(const char *name)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
926 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
927 GaimPlugin *plugin;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
928 GList *l;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
929
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
930 for (l = plugins; l != NULL; l = l->next) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
931 plugin = l->data;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
932
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
933 if (!strcmp(plugin->info->name, name))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
934 return plugin;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
935 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
936
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
937 return NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
938 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
939
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
940 GaimPlugin *
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
941 gaim_plugins_find_with_filename(const char *filename)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
942 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
943 GaimPlugin *plugin;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
944 GList *l;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
945
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
946 for (l = plugins; l != NULL; l = l->next) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
947 plugin = l->data;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
948
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
949 if (plugin->path != NULL && !strcmp(plugin->path, filename))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
950 return plugin;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
951 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
952
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
953 return NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
954 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
955
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
956 GaimPlugin *
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
957 gaim_plugins_find_with_id(const char *id)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
958 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
959 GaimPlugin *plugin;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
960 GList *l;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
961
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
962 g_return_val_if_fail(id != NULL, NULL);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
963
6486
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
964 for (l = plugins; l != NULL; l = l->next)
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
965 {
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
966 plugin = l->data;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
967
6486
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
968 if (plugin->info->id != NULL && !strcmp(plugin->info->id, id))
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
969 return plugin;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
970 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
971
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
972 return NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
973 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
974
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
975 GList *
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
976 gaim_plugins_get_loaded(void)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
977 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
978 return loaded_plugins;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
979 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
980
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
981 GList *
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
982 gaim_plugins_get_protocols(void)
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
983 {
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
984 return protocol_plugins;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
985 }
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
986
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
987 GList *
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
988 gaim_plugins_get_all(void)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
989 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
990 return plugins;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
991 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
992