annotate src/plugin.c @ 10702:f51e040affc6

[gaim-migrate @ 12284] I think this leaked committer: Tailor Script <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Sun, 20 Mar 2005 01:16:43 +0000
parents c604c88a7530
children b7f0bc436179
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 /*
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 * gaim
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3 *
8046
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7956
diff changeset
4 * Gaim is the legal property of its developers, whose names are too numerous
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7956
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7956
diff changeset
6 * source distribution.
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
7 *
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 * (at your option) any later version.
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 *
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * GNU General Public License for more details.
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 *
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 */
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5840
diff changeset
22 #include "internal.h"
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5573
diff changeset
24 #include "accountopt.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5840
diff changeset
25 #include "debug.h"
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5357
diff changeset
26 #include "notify.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5840
diff changeset
27 #include "prefs.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5840
diff changeset
28 #include "prpl.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5840
diff changeset
29 #include "request.h"
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6432
diff changeset
30 #include "signals.h"
9943
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9697
diff changeset
31 #include "version.h"
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
32
6822
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
33 typedef struct
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
34 {
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
35 GHashTable *commands;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
36 size_t command_count;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
37
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
38 } GaimPluginIpcInfo;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
39
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
40 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 GaimCallback func;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
43 GaimSignalMarshalFunc marshal;
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 int num_params;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
46 GaimValue **params;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
47 GaimValue *ret_value;
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 } GaimPluginIpcCommand;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
50
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
51 static GList *search_paths = NULL;
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
52 static GList *plugins = NULL;
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
53 static GList *load_queue = NULL;
6981
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
54 static GList *loaded_plugins = NULL;
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
55 static GList *plugin_loaders = NULL;
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
56 static GList *protocol_plugins = NULL;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58 static void (*probe_cb)(void *) = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59 static void *probe_cb_data = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60 static void (*load_cb)(GaimPlugin *, void *) = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61 static void *load_cb_data = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62 static void (*unload_cb)(GaimPlugin *, void *) = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63 static void *unload_cb_data = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65 #ifdef GAIM_PLUGINS
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
66 static gboolean
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
67 has_file_extension(const char *filename, const char *ext)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69 int len, extlen;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71 if (filename == NULL || *filename == '\0' || ext == NULL)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72 return 0;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
74 extlen = strlen(ext);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
75 len = strlen(filename) - extlen;
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 if (len < 0)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
78 return 0;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
79
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
80 return (strncmp(filename + len, ext, extlen) == 0);
5205
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
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 static gboolean
10682
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
84 is_native(const char *filename)
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
85 {
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
86 const char *last_period;
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
87
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
88 last_period = strrchr(filename, '.');
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
89 if (last_period == NULL)
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
90 return FALSE;
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
91
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
92 return !(strcmp(last_period, GAIM_PLUGIN_EXT_WIN32) &
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
93 strcmp(last_period, GAIM_PLUGIN_EXT_HPUX) &
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
94 strcmp(last_period, GAIM_PLUGIN_EXT_UNIX));
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
95 }
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
96
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
97 static char *
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
98 gaim_plugin_get_basename(const char *filename)
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
99 {
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
100 const char *basename;
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
101 const char *last_period;
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
102
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
103 basename = strrchr(filename, G_DIR_SEPARATOR);
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
104 if (basename != NULL)
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
105 basename++;
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
106 else
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
107 basename = filename;
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
108
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
109 if (is_native(basename) &&
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
110 ((last_period = strrchr(basename, '.')) != NULL))
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
111 return g_strndup(basename, (last_period - basename));
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
112
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
113 return g_strdup(basename);
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
114 }
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
115
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
116 static gboolean
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
117 loader_supports_file(GaimPlugin *loader, const char *filename)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
118 {
6432
f9428d38c03b [gaim-migrate @ 6940]
Luke Schierer <lschiere@pidgin.im>
parents: 5981
diff changeset
119 GList *exts;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
120
6432
f9428d38c03b [gaim-migrate @ 6940]
Luke Schierer <lschiere@pidgin.im>
parents: 5981
diff changeset
121 for (exts = GAIM_PLUGIN_LOADER_INFO(loader)->exts; exts != NULL; exts = exts->next) {
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
122 if (has_file_extension(filename, (char *)exts->data)) {
6432
f9428d38c03b [gaim-migrate @ 6940]
Luke Schierer <lschiere@pidgin.im>
parents: 5981
diff changeset
123 return TRUE;
5205
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
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127 return FALSE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
129
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130 static GaimPlugin *
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
131 find_loader_for_plugin(const GaimPlugin *plugin)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
132 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133 GaimPlugin *loader;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134 GList *l;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136 if (plugin->path == NULL)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137 return NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
139 for (l = gaim_plugins_get_loaded(); l != NULL; l = l->next) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140 loader = l->data;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
142 if (loader->info->type == GAIM_PLUGIN_LOADER &&
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
143 loader_supports_file(loader, plugin->path)) {
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
144
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
145 return loader;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
146 }
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 loader = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149 }
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 NULL;
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
5449
9442e8d0b21d [gaim-migrate @ 5836]
Luke Schierer <lschiere@pidgin.im>
parents: 5443
diff changeset
154 #endif /* GAIM_PLUGINS */
9442e8d0b21d [gaim-migrate @ 5836]
Luke Schierer <lschiere@pidgin.im>
parents: 5443
diff changeset
155
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
156 /**
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
157 * Negative if a before b, 0 if equal, positive if a after b.
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
158 */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159 static gint
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
160 compare_prpl(GaimPlugin *a, GaimPlugin *b)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
161 {
7956
1b8261f374ea [gaim-migrate @ 8631]
Nathan Walp <nwalp@pidgin.im>
parents: 7279
diff changeset
162 if(GAIM_IS_PROTOCOL_PLUGIN(a)) {
1b8261f374ea [gaim-migrate @ 8631]
Nathan Walp <nwalp@pidgin.im>
parents: 7279
diff changeset
163 if(GAIM_IS_PROTOCOL_PLUGIN(b))
1b8261f374ea [gaim-migrate @ 8631]
Nathan Walp <nwalp@pidgin.im>
parents: 7279
diff changeset
164 return strcmp(a->info->name, b->info->name);
1b8261f374ea [gaim-migrate @ 8631]
Nathan Walp <nwalp@pidgin.im>
parents: 7279
diff changeset
165 else
1b8261f374ea [gaim-migrate @ 8631]
Nathan Walp <nwalp@pidgin.im>
parents: 7279
diff changeset
166 return -1;
1b8261f374ea [gaim-migrate @ 8631]
Nathan Walp <nwalp@pidgin.im>
parents: 7279
diff changeset
167 } else {
1b8261f374ea [gaim-migrate @ 8631]
Nathan Walp <nwalp@pidgin.im>
parents: 7279
diff changeset
168 if(GAIM_IS_PROTOCOL_PLUGIN(b))
1b8261f374ea [gaim-migrate @ 8631]
Nathan Walp <nwalp@pidgin.im>
parents: 7279
diff changeset
169 return 1;
1b8261f374ea [gaim-migrate @ 8631]
Nathan Walp <nwalp@pidgin.im>
parents: 7279
diff changeset
170 else
1b8261f374ea [gaim-migrate @ 8631]
Nathan Walp <nwalp@pidgin.im>
parents: 7279
diff changeset
171 return 0;
1b8261f374ea [gaim-migrate @ 8631]
Nathan Walp <nwalp@pidgin.im>
parents: 7279
diff changeset
172 }
5205
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
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
175 GaimPlugin *
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
176 gaim_plugin_new(gboolean native, const char *path)
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 GaimPlugin *plugin;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
179
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
180 plugin = g_new0(GaimPlugin, 1);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
181
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
182 plugin->native_plugin = native;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
183 plugin->path = (path == NULL ? NULL : g_strdup(path));
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
184
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
185 return plugin;
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 GaimPlugin *
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
189 gaim_plugin_probe(const char *filename)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
190 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
191 #ifdef GAIM_PLUGINS
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
192 GaimPlugin *plugin = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
193 GaimPlugin *loader;
10124
b4efa002dad8 [gaim-migrate @ 11161]
Nathan Walp <nwalp@pidgin.im>
parents: 10087
diff changeset
194 gpointer unpunned;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
195 gboolean (*gaim_init_plugin)(GaimPlugin *);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
196
6981
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
197 gaim_debug_misc("plugins", "probing %s\n", filename);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
198 g_return_val_if_fail(filename != NULL, NULL);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
199
5973
53782414bc3a [gaim-migrate @ 6420]
Mark Doliner <mark@kingant.net>
parents: 5949
diff changeset
200 if (!g_file_test(filename, G_FILE_TEST_EXISTS))
53782414bc3a [gaim-migrate @ 6420]
Mark Doliner <mark@kingant.net>
parents: 5949
diff changeset
201 return NULL;
53782414bc3a [gaim-migrate @ 6420]
Mark Doliner <mark@kingant.net>
parents: 5949
diff changeset
202
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
203 /* If this plugin has already been probed then exit */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
204 plugin = gaim_plugins_find_with_filename(filename);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
205 if (plugin != NULL)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
206 return plugin;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
207
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10479
diff changeset
208 plugin = gaim_plugin_new(has_file_extension(filename, GAIM_PLUGIN_EXT), filename);
5205
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 if (plugin->native_plugin) {
5450
bb1e160467b6 [gaim-migrate @ 5838]
Nathan Walp <nwalp@pidgin.im>
parents: 5449
diff changeset
211 const char *error;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
212 plugin->handle = g_module_open(filename, 0);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
213
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
214 if (plugin->handle == NULL)
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
215 {
5443
07358c067495 [gaim-migrate @ 5825]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
216 error = g_module_error();
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
217 gaim_debug_error("plugins", "%s is unloadable: %s\n",
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
218 plugin->path, error ? error : "Unknown error.");
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
219
5269
cd7e4ba049f9 [gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents: 5268
diff changeset
220 gaim_plugin_destroy(plugin);
cd7e4ba049f9 [gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents: 5268
diff changeset
221
cd7e4ba049f9 [gaim-migrate @ 5641]
Christian Hammond <chipx86@chipx86.com>
parents: 5268
diff changeset
222 return NULL;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
223 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
224
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
225 if (!g_module_symbol(plugin->handle, "gaim_init_plugin",
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
226 &unpunned))
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
227 {
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
228 g_module_close(plugin->handle);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
229 plugin->handle = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
230
5443
07358c067495 [gaim-migrate @ 5825]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
231 error = g_module_error();
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
232 gaim_debug_error("plugins", "%s is unloadable: %s\n",
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
233 plugin->path, error ? error : "Unknown error.");
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
234
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
235 gaim_plugin_destroy(plugin);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
236
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
237 return NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
238 }
10124
b4efa002dad8 [gaim-migrate @ 11161]
Nathan Walp <nwalp@pidgin.im>
parents: 10087
diff changeset
239 gaim_init_plugin = unpunned;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
240 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
241 else {
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
242 loader = find_loader_for_plugin(plugin);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
243
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
244 if (loader == NULL) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
245 gaim_plugin_destroy(plugin);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
246
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
247 return NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
248 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
249
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
250 gaim_init_plugin = GAIM_PLUGIN_LOADER_INFO(loader)->probe;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
251 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
252
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
253 plugin->error = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
254
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
255 if (!gaim_init_plugin(plugin) || plugin->info == NULL) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
256 gaim_plugin_destroy(plugin);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
257
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
258 return NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
259 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
260
9943
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9697
diff changeset
261 if (plugin->info->magic != GAIM_PLUGIN_MAGIC ||
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9697
diff changeset
262 plugin->info->major_version != GAIM_MAJOR_VERSION ||
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9697
diff changeset
263 plugin->info->minor_version > GAIM_MINOR_VERSION)
8749
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
264 {
10156
0dbeb6d1e258 [gaim-migrate @ 11236]
Mark Doliner <mark@kingant.net>
parents: 10145
diff changeset
265 gaim_debug_error("plugins", "%s is unloadable: API version mismatch %d.%d.x (need %d.%d.x)\n",
0dbeb6d1e258 [gaim-migrate @ 11236]
Mark Doliner <mark@kingant.net>
parents: 10145
diff changeset
266 plugin->path, plugin->info->major_version, plugin->info->minor_version,
0dbeb6d1e258 [gaim-migrate @ 11236]
Mark Doliner <mark@kingant.net>
parents: 10145
diff changeset
267 GAIM_MAJOR_VERSION, GAIM_MINOR_VERSION);
0dbeb6d1e258 [gaim-migrate @ 11236]
Mark Doliner <mark@kingant.net>
parents: 10145
diff changeset
268 gaim_plugin_destroy(plugin);
0dbeb6d1e258 [gaim-migrate @ 11236]
Mark Doliner <mark@kingant.net>
parents: 10145
diff changeset
269 return NULL;
0dbeb6d1e258 [gaim-migrate @ 11236]
Mark Doliner <mark@kingant.net>
parents: 10145
diff changeset
270 }
0dbeb6d1e258 [gaim-migrate @ 11236]
Mark Doliner <mark@kingant.net>
parents: 10145
diff changeset
271
0dbeb6d1e258 [gaim-migrate @ 11236]
Mark Doliner <mark@kingant.net>
parents: 10145
diff changeset
272 /* If plugin is a PRPL, make sure it implements the required functions */
0dbeb6d1e258 [gaim-migrate @ 11236]
Mark Doliner <mark@kingant.net>
parents: 10145
diff changeset
273 if ((plugin->info->type == GAIM_PLUGIN_PROTOCOL) && (
0dbeb6d1e258 [gaim-migrate @ 11236]
Mark Doliner <mark@kingant.net>
parents: 10145
diff changeset
274 (GAIM_PLUGIN_PROTOCOL_INFO(plugin)->list_icon == NULL) ||
0dbeb6d1e258 [gaim-migrate @ 11236]
Mark Doliner <mark@kingant.net>
parents: 10145
diff changeset
275 (GAIM_PLUGIN_PROTOCOL_INFO(plugin)->login == NULL) ||
0dbeb6d1e258 [gaim-migrate @ 11236]
Mark Doliner <mark@kingant.net>
parents: 10145
diff changeset
276 (GAIM_PLUGIN_PROTOCOL_INFO(plugin)->close == NULL)))
0dbeb6d1e258 [gaim-migrate @ 11236]
Mark Doliner <mark@kingant.net>
parents: 10145
diff changeset
277 {
0dbeb6d1e258 [gaim-migrate @ 11236]
Mark Doliner <mark@kingant.net>
parents: 10145
diff changeset
278 gaim_debug_error("plugins", "%s is unloadable: Does not implement all required functions\n",
0dbeb6d1e258 [gaim-migrate @ 11236]
Mark Doliner <mark@kingant.net>
parents: 10145
diff changeset
279 plugin->path);
8749
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
280 gaim_plugin_destroy(plugin);
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
281 return NULL;
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
282 }
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
283
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
284 return plugin;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
285 #else
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
286 return NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
287 #endif /* !GAIM_PLUGINS */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
288 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
289
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
290 gboolean
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
291 gaim_plugin_load(GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
292 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
293 #ifdef GAIM_PLUGINS
6486
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
294 GList *dep_list = NULL;
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
295 GList *l;
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
296
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
297 g_return_val_if_fail(plugin != NULL, FALSE);
5270
d1fe8e320dab [gaim-migrate @ 5642]
Christian Hammond <chipx86@chipx86.com>
parents: 5269
diff changeset
298 g_return_val_if_fail(plugin->error == NULL, FALSE);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
299
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
300 if (gaim_plugin_is_loaded(plugin))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
301 return TRUE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
302
6486
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
303 /*
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
304 * Go through the list of the plugin's dependencies.
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
305 *
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
306 * First pass: Make sure all the plugins needed are probed.
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
307 */
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
308 for (l = plugin->info->dependencies; l != NULL; l = l->next)
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
309 {
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
310 const char *dep_name = (const char *)l->data;
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
311 GaimPlugin *dep_plugin;
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
312
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
313 dep_plugin = gaim_plugins_find_with_id(dep_name);
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
314
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
315 if (dep_plugin == NULL)
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
316 {
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
317 char buf[BUFSIZ];
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
318
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
319 g_snprintf(buf, sizeof(buf),
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
320 _("The required plugin %s was not found. "
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
321 "Please install this plugin and try again."),
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
322 dep_name);
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
323
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
324 gaim_notify_error(NULL, NULL,
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
325 _("Gaim was unable to load your plugin."),
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
326 buf);
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
327
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
328 if (dep_list != NULL)
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
329 g_list_free(dep_list);
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
330
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
331 return FALSE;
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
332 }
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
333
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
334 dep_list = g_list_append(dep_list, dep_plugin);
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
335 }
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
336
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
337 /* Second pass: load all the required plugins. */
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
338 for (l = dep_list; l != NULL; l = l->next)
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
339 {
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
340 GaimPlugin *dep_plugin = (GaimPlugin *)l->data;
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
341
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
342 if (!gaim_plugin_is_loaded(dep_plugin))
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
343 {
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
344 if (!gaim_plugin_load(dep_plugin))
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
345 {
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
346 char buf[BUFSIZ];
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
347
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
348 g_snprintf(buf, sizeof(buf),
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
349 _("The required plugin %s was unable to load."),
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
350 plugin->info->name);
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
351
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
352 gaim_notify_error(NULL, NULL,
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
353 _("Gaim was unable to load your plugin."),
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
354 buf);
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
355
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
356 if (dep_list != NULL)
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
357 g_list_free(dep_list);
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
358
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
359 return FALSE;
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
360 }
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
361 }
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
362 }
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
363
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
364 if (dep_list != NULL)
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
365 g_list_free(dep_list);
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
366
6981
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
367 if (plugin->native_plugin)
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
368 {
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
369 if (plugin->info != NULL && plugin->info->load != NULL)
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
370 {
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
371 if (!plugin->info->load(plugin))
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
372 return FALSE;
5357
2a1c92df7024 [gaim-migrate @ 5733]
Christian Hammond <chipx86@chipx86.com>
parents: 5270
diff changeset
373 }
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
374 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
375 else {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
376 GaimPlugin *loader;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
377 GaimPluginLoaderInfo *loader_info;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
378
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
379 loader = find_loader_for_plugin(plugin);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
380
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
381 if (loader == NULL)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
382 return FALSE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
383
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
384 loader_info = GAIM_PLUGIN_LOADER_INFO(loader);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
385
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
386 if (loader_info->load != NULL)
6981
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
387 {
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
388 if (!loader_info->load(plugin))
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
389 return FALSE;
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
390 }
5205
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
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
393 loaded_plugins = g_list_append(loaded_plugins, plugin);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
394
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
395 plugin->loaded = TRUE;
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 /* TODO */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
398 if (load_cb != NULL)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
399 load_cb(plugin, load_cb_data);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
400
8993
294ae6548d4e [gaim-migrate @ 9768]
Luke Schierer <lschiere@pidgin.im>
parents: 8986
diff changeset
401 gaim_signal_emit(gaim_plugins_get_handle(), "plugin-load", plugin);
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8759
diff changeset
402
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
403 return TRUE;
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 #else
5449
9442e8d0b21d [gaim-migrate @ 5836]
Luke Schierer <lschiere@pidgin.im>
parents: 5443
diff changeset
406 return TRUE;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
407 #endif /* !GAIM_PLUGINS */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
408 }
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 gboolean
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
411 gaim_plugin_unload(GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
412 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
413 #ifdef GAIM_PLUGINS
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
414 g_return_val_if_fail(plugin != NULL, FALSE);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
415
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
416 loaded_plugins = g_list_remove(loaded_plugins, plugin);
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 g_return_val_if_fail(gaim_plugin_is_loaded(plugin), FALSE);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
419
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
420 gaim_debug_info("plugins", "Unloading plugin %s\n", plugin->info->name);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
421
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
422 /* cancel any pending dialogs the plugin has */
5498
cce2d7868c78 [gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents: 5450
diff changeset
423 gaim_request_close_with_handle(plugin);
cce2d7868c78 [gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents: 5450
diff changeset
424 gaim_notify_close_with_handle(plugin);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
425
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
426 plugin->loaded = FALSE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
427
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
428 if (plugin->native_plugin) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
429 if (plugin->info->unload != NULL)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
430 plugin->info->unload(plugin);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
431
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
432 if (plugin->info->type == GAIM_PLUGIN_PROTOCOL) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
433 GaimPluginProtocolInfo *prpl_info;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
434 GList *l;
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 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
437
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5573
diff changeset
438 for (l = prpl_info->user_splits; l != NULL; l = l->next)
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5573
diff changeset
439 gaim_account_user_split_destroy(l->data);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
440
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5573
diff changeset
441 for (l = prpl_info->protocol_options; l != NULL; l = l->next)
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5573
diff changeset
442 gaim_account_option_destroy(l->data);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
443
5646
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5638
diff changeset
444 if (prpl_info->user_splits != NULL)
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5638
diff changeset
445 g_list_free(prpl_info->user_splits);
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5638
diff changeset
446
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5638
diff changeset
447 if (prpl_info->protocol_options != NULL)
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5638
diff changeset
448 g_list_free(prpl_info->protocol_options);
5205
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 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
451 else {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
452 GaimPlugin *loader;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
453 GaimPluginLoaderInfo *loader_info;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
454
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
455 loader = find_loader_for_plugin(plugin);
5205
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 if (loader == NULL)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
458 return FALSE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
459
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
460 loader_info = GAIM_PLUGIN_LOADER_INFO(loader);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
461
9697
f568b6655331 [gaim-migrate @ 10556]
Christian Hammond <chipx86@chipx86.com>
parents: 9667
diff changeset
462 if (loader_info->unload != NULL)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
463 loader_info->unload(plugin);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
464 }
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 gaim_signals_disconnect_by_handle(plugin);
6822
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
467 gaim_plugin_ipc_unregister_all(plugin);
5205
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 /* TODO */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
470 if (unload_cb != NULL)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
471 unload_cb(plugin, unload_cb_data);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
472
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8759
diff changeset
473 gaim_signal_emit(gaim_plugins_get_handle(), "plugin-unload", plugin);
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8759
diff changeset
474
10087
9fdbfe832fac [gaim-migrate @ 11098]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9943
diff changeset
475 gaim_prefs_disconnect_by_handle(plugin);
9fdbfe832fac [gaim-migrate @ 11098]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9943
diff changeset
476
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
477 return TRUE;
5449
9442e8d0b21d [gaim-migrate @ 5836]
Luke Schierer <lschiere@pidgin.im>
parents: 5443
diff changeset
478 #else
9442e8d0b21d [gaim-migrate @ 5836]
Luke Schierer <lschiere@pidgin.im>
parents: 5443
diff changeset
479 return TRUE;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
480 #endif /* GAIM_PLUGINS */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
481 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
482
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
483 gboolean
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
484 gaim_plugin_reload(GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
485 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
486 #ifdef GAIM_PLUGINS
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
487 g_return_val_if_fail(plugin != NULL, FALSE);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
488 g_return_val_if_fail(gaim_plugin_is_loaded(plugin), FALSE);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
489
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
490 if (!gaim_plugin_unload(plugin))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
491 return FALSE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
492
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
493 if (!gaim_plugin_load(plugin))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
494 return FALSE;
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 return TRUE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
497 #else
5449
9442e8d0b21d [gaim-migrate @ 5836]
Luke Schierer <lschiere@pidgin.im>
parents: 5443
diff changeset
498 return TRUE;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
499 #endif /* !GAIM_PLUGINS */
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
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
502 void
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
503 gaim_plugin_destroy(GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
504 {
5449
9442e8d0b21d [gaim-migrate @ 5836]
Luke Schierer <lschiere@pidgin.im>
parents: 5443
diff changeset
505 #ifdef GAIM_PLUGINS
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
506 g_return_if_fail(plugin != NULL);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
507
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
508 if (gaim_plugin_is_loaded(plugin))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
509 gaim_plugin_unload(plugin);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
510
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
511 plugins = g_list_remove(plugins, plugin);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
512
6981
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
513 if (load_queue != NULL)
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
514 load_queue = g_list_remove(load_queue, plugin);
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
515
9943
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9697
diff changeset
516 /* true, this may leak a little memory if there is a major version
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9697
diff changeset
517 * mismatch, but it's a lot better than trying to free something
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9697
diff changeset
518 * we shouldn't, and crashing while trying to load an old plugin */
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9697
diff changeset
519 if(plugin->info == NULL || plugin->info->magic != GAIM_PLUGIN_MAGIC ||
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9697
diff changeset
520 plugin->info->major_version != GAIM_MAJOR_VERSION) {
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9697
diff changeset
521 if(plugin->handle)
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9697
diff changeset
522 g_module_close(plugin->handle);
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9697
diff changeset
523 g_free(plugin);
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9697
diff changeset
524 return;
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9697
diff changeset
525 }
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9697
diff changeset
526
5243
f6e0c689a88b [gaim-migrate @ 5614]
Christian Hammond <chipx86@chipx86.com>
parents: 5242
diff changeset
527 if (plugin->info != NULL && plugin->info->dependencies != NULL)
f6e0c689a88b [gaim-migrate @ 5614]
Christian Hammond <chipx86@chipx86.com>
parents: 5242
diff changeset
528 g_list_free(plugin->info->dependencies);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
529
8749
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
530 if (plugin->native_plugin)
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
531 {
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
532 if (plugin->info != NULL && plugin->info->type == GAIM_PLUGIN_LOADER)
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
533 {
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
534 GaimPluginLoaderInfo *loader_info;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
535 GList *exts, *l, *next_l;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
536 GaimPlugin *p2;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
537
8749
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
538 loader_info = GAIM_PLUGIN_LOADER_INFO(plugin);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
539
9943
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9697
diff changeset
540 if (loader_info != NULL && loader_info->exts != NULL)
8749
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
541 {
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
542 for (exts = GAIM_PLUGIN_LOADER_INFO(plugin)->exts;
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
543 exts != NULL;
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
544 exts = exts->next) {
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
545
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
546 for (l = gaim_plugins_get_all(); l != NULL; l = next_l)
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
547 {
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
548 next_l = l->next;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
549
8749
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
550 p2 = l->data;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
551
8749
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
552 if (p2->path != NULL &&
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
553 has_file_extension(p2->path, exts->data))
8749
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
554 {
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
555 gaim_plugin_destroy(p2);
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
556 }
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
557 }
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
558 }
8749
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
559
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
560 g_list_free(loader_info->exts);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
561 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
562
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
563 plugin_loaders = g_list_remove(plugin_loaders, plugin);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
564 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
565
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
566 if (plugin->info != NULL && plugin->info->destroy != NULL)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
567 plugin->info->destroy(plugin);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
568
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
569 if (plugin->handle != NULL)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
570 g_module_close(plugin->handle);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
571 }
8749
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
572 else
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
573 {
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
574 GaimPlugin *loader;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
575 GaimPluginLoaderInfo *loader_info;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
576
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
577 loader = find_loader_for_plugin(plugin);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
578
8749
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
579 if (loader != NULL)
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
580 {
5941
a3e60ff95b7d [gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
581 loader_info = GAIM_PLUGIN_LOADER_INFO(loader);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
582
5941
a3e60ff95b7d [gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
583 if (loader_info->destroy != NULL)
a3e60ff95b7d [gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
584 loader_info->destroy(plugin);
a3e60ff95b7d [gaim-migrate @ 6381]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
585 }
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
586 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
587
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
588 if (plugin->path != NULL) g_free(plugin->path);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
589 if (plugin->error != NULL) g_free(plugin->error);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
590
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
591 g_free(plugin);
5449
9442e8d0b21d [gaim-migrate @ 5836]
Luke Schierer <lschiere@pidgin.im>
parents: 5443
diff changeset
592 #endif /* !GAIM_PLUGINS */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
593 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
594
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
595 gboolean
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
596 gaim_plugin_is_loaded(const GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
597 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
598 g_return_val_if_fail(plugin != NULL, FALSE);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
599
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
600 return plugin->loaded;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
601 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
602
6822
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 * Plugin IPC
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
605 **************************************************************************/
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
606 static void
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
607 destroy_ipc_info(void *data)
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 GaimPluginIpcCommand *ipc_command = (GaimPluginIpcCommand *)data;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
610 int i;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
611
9667
22928adecb84 [gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents: 9018
diff changeset
612 if (ipc_command->params != NULL)
22928adecb84 [gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents: 9018
diff changeset
613 {
22928adecb84 [gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents: 9018
diff changeset
614 for (i = 0; i < ipc_command->num_params; i++)
22928adecb84 [gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents: 9018
diff changeset
615 gaim_value_destroy(ipc_command->params[i]);
22928adecb84 [gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents: 9018
diff changeset
616
22928adecb84 [gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents: 9018
diff changeset
617 g_free(ipc_command->params);
22928adecb84 [gaim-migrate @ 10519]
Christian Hammond <chipx86@chipx86.com>
parents: 9018
diff changeset
618 }
6822
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
619
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
620 if (ipc_command->ret_value != NULL)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
621 gaim_value_destroy(ipc_command->ret_value);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
622
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
623 g_free(ipc_command);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
624 }
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
625
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
626 gboolean
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
627 gaim_plugin_ipc_register(GaimPlugin *plugin, const char *command,
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
628 GaimCallback func, GaimSignalMarshalFunc marshal,
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
629 GaimValue *ret_value, int num_params, ...)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
630 {
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
631 GaimPluginIpcInfo *ipc_info;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
632 GaimPluginIpcCommand *ipc_command;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
633
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
634 g_return_val_if_fail(plugin != NULL, FALSE);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
635 g_return_val_if_fail(command != NULL, FALSE);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
636 g_return_val_if_fail(func != NULL, FALSE);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
637 g_return_val_if_fail(marshal != NULL, FALSE);
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 if (plugin->ipc_data == NULL)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
640 {
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
641 ipc_info = plugin->ipc_data = g_new0(GaimPluginIpcInfo, 1);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
642 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
643 g_free, destroy_ipc_info);
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 else
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
646 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
647
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
648 ipc_command = g_new0(GaimPluginIpcCommand, 1);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
649 ipc_command->func = func;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
650 ipc_command->marshal = marshal;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
651 ipc_command->num_params = num_params;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
652 ipc_command->ret_value = ret_value;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
653
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
654 if (num_params > 0)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
655 {
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
656 va_list args;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
657 int i;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
658
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
659 ipc_command->params = g_new0(GaimValue *, num_params);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
660
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
661 va_start(args, num_params);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
662
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
663 for (i = 0; i < num_params; i++)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
664 ipc_command->params[i] = va_arg(args, GaimValue *);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
665
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
666 va_end(args);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
667 }
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
668
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
669 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
670
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
671 ipc_info->command_count++;
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 return TRUE;
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
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
676 void
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
677 gaim_plugin_ipc_unregister(GaimPlugin *plugin, const char *command)
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 GaimPluginIpcInfo *ipc_info;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
680
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
681 g_return_if_fail(plugin != NULL);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
682 g_return_if_fail(command != NULL);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
683
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
684 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data;
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 if (ipc_info == NULL ||
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
687 g_hash_table_lookup(ipc_info->commands, command) == NULL)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
688 {
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
689 gaim_debug_error("plugins",
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
690 "IPC command '%s' was not registered for plugin %s\n",
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
691 command, plugin->info->name);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
692 return;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
693 }
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 g_hash_table_remove(ipc_info->commands, command);
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 ipc_info->command_count--;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
698
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
699 if (ipc_info->command_count == 0)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
700 {
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
701 g_hash_table_destroy(ipc_info->commands);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
702 g_free(ipc_info);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
703
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
704 plugin->ipc_data = NULL;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
705 }
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
706 }
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
707
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
708 void
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
709 gaim_plugin_ipc_unregister_all(GaimPlugin *plugin)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
710 {
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
711 GaimPluginIpcInfo *ipc_info;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
712
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
713 g_return_if_fail(plugin != NULL);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
714
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
715 if (plugin->ipc_data == NULL)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
716 return; /* Silently ignore it. */
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
717
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
718 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
719
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
720 g_hash_table_destroy(ipc_info->commands);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
721 g_free(ipc_info);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
722
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
723 plugin->ipc_data = NULL;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
724 }
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
725
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
726 gboolean
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
727 gaim_plugin_ipc_get_params(GaimPlugin *plugin, const char *command,
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
728 GaimValue **ret_value, int *num_params,
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
729 GaimValue ***params)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
730 {
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
731 GaimPluginIpcInfo *ipc_info;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
732 GaimPluginIpcCommand *ipc_command;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
733
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
734 g_return_val_if_fail(plugin != NULL, FALSE);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
735 g_return_val_if_fail(command != NULL, FALSE);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
736
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
737 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
738
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
739 if (ipc_info == NULL ||
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
740 (ipc_command = g_hash_table_lookup(ipc_info->commands,
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
741 command)) == NULL)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
742 {
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
743 gaim_debug_error("plugins",
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
744 "IPC command '%s' was not registered for plugin %s\n",
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
745 command, plugin->info->name);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
746
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
747 return FALSE;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
748 }
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
749
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
750 if (num_params != NULL)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
751 *num_params = ipc_command->num_params;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
752
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
753 if (params != NULL)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
754 *params = ipc_command->params;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
755
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
756 if (ret_value != NULL)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
757 *ret_value = ipc_command->ret_value;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
758
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
759 return TRUE;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
760 }
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
761
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
762 void *
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
763 gaim_plugin_ipc_call(GaimPlugin *plugin, const char *command,
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
764 gboolean *ok, ...)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
765 {
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
766 GaimPluginIpcInfo *ipc_info;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
767 GaimPluginIpcCommand *ipc_command;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
768 va_list args;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
769 void *ret_value;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
770
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
771 if (ok != NULL)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
772 *ok = FALSE;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
773
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
774 g_return_val_if_fail(plugin != NULL, NULL);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
775 g_return_val_if_fail(command != NULL, NULL);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
776
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
777 ipc_info = (GaimPluginIpcInfo *)plugin->ipc_data;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
778
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
779 if (ipc_info == NULL ||
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
780 (ipc_command = g_hash_table_lookup(ipc_info->commands,
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
781 command)) == NULL)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
782 {
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
783 gaim_debug_error("plugins",
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
784 "IPC command '%s' was not registered for plugin %s\n",
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
785 command, plugin->info->name);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
786
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
787 return NULL;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
788 }
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
789
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
790 va_start(args, ok);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
791 ipc_command->marshal(ipc_command->func, args, NULL, &ret_value);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
792 va_end(args);
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
793
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
794 if (ok != NULL)
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
795 *ok = TRUE;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
796
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
797 return ret_value;
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
798 }
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
799
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
800 /**************************************************************************
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
801 * Plugins subsystem
7dba3e17cb21 [gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents: 6639
diff changeset
802 **************************************************************************/
10479
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
803 void *
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
804 gaim_plugins_get_handle(void) {
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
805 static int handle;
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
806
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
807 return &handle;
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
808 }
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
809
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
810 void
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
811 gaim_plugins_init(void) {
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
812 void *handle = gaim_plugins_get_handle();
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
813
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
814 gaim_signal_register(handle, "plugin-load",
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
815 gaim_marshal_VOID__POINTER,
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
816 NULL, 1,
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
817 gaim_value_new(GAIM_TYPE_SUBTYPE,
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
818 GAIM_SUBTYPE_PLUGIN));
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
819 gaim_signal_register(handle, "plugin-unload",
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
820 gaim_marshal_VOID__POINTER,
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
821 NULL, 1,
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
822 gaim_value_new(GAIM_TYPE_SUBTYPE,
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
823 GAIM_SUBTYPE_PLUGIN));
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
824 }
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
825
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
826 void
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
827 gaim_plugins_uninit(void) {
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
828 gaim_signals_disconnect_by_handle(gaim_plugins_get_handle());
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
829 }
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
830
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
831 /**************************************************************************
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
832 * Plugins API
12460aa2c820 [gaim-migrate @ 11766]
Nathan Walp <nwalp@pidgin.im>
parents: 10464
diff changeset
833 **************************************************************************/
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
834 void
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
835 gaim_plugins_add_search_path(const char *path)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
836 {
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
837 g_return_if_fail(path != NULL);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
838
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
839 if (g_list_find_custom(search_paths, path, (GCompareFunc)strcmp))
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
840 return;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
841
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
842 search_paths = g_list_append(search_paths, strdup(path));
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
843 }
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 void
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
846 gaim_plugins_unload_all(void)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
847 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
848 #ifdef GAIM_PLUGINS
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
849
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
850 while (loaded_plugins != NULL)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
851 gaim_plugin_unload(loaded_plugins->data);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
852
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
853 #endif /* GAIM_PLUGINS */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
854 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
855
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
856 void
5242
fd81a00480ac [gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents: 5211
diff changeset
857 gaim_plugins_destroy_all(void)
fd81a00480ac [gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents: 5211
diff changeset
858 {
fd81a00480ac [gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents: 5211
diff changeset
859 #ifdef GAIM_PLUGINS
fd81a00480ac [gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents: 5211
diff changeset
860
fd81a00480ac [gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents: 5211
diff changeset
861 while (plugins != NULL)
fd81a00480ac [gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents: 5211
diff changeset
862 gaim_plugin_destroy(plugins->data);
fd81a00480ac [gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents: 5211
diff changeset
863
fd81a00480ac [gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents: 5211
diff changeset
864 #endif /* GAIM_PLUGINS */
fd81a00480ac [gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents: 5211
diff changeset
865 }
5838
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5794
diff changeset
866
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5794
diff changeset
867 void
5949
90d0849abd3c [gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents: 5941
diff changeset
868 gaim_plugins_load_saved(const char *key)
5838
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5794
diff changeset
869 {
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5794
diff changeset
870 #ifdef GAIM_PLUGINS
5949
90d0849abd3c [gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents: 5941
diff changeset
871 GList *f, *files;
90d0849abd3c [gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents: 5941
diff changeset
872
90d0849abd3c [gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents: 5941
diff changeset
873 g_return_if_fail(key != NULL);
5838
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5794
diff changeset
874
5949
90d0849abd3c [gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents: 5941
diff changeset
875 files = gaim_prefs_get_string_list(key);
90d0849abd3c [gaim-migrate @ 6393]
Christian Hammond <chipx86@chipx86.com>
parents: 5941
diff changeset
876
7033
cf1126ba1834 [gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
877 for (f = files; f; f = f->next)
cf1126ba1834 [gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
878 {
10682
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
879 char *filename;
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
880 char *basename;
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
881 GaimPlugin *plugin;
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
882
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
883 if (f->data == NULL)
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
884 continue;
7033
cf1126ba1834 [gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
885
10682
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
886 filename = f->data;
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
887 /*
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
888 * We don't know if the filename uses Windows or Unix path
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
889 * separators (because people might be sharing a prefs.xml
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
890 * file across systems), so we find the last occurrence
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
891 * of either.
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
892 */
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
893 basename = strrchr(filename, '/');
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
894 if ((basename == NULL) || (basename < strrchr(filename, '\\')))
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
895 basename = strrchr(filename, '\\');
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
896 if (basename != NULL)
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
897 basename++;
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
898
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
899 if ((plugin = gaim_plugins_find_with_filename(filename)) != NULL)
7033
cf1126ba1834 [gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
900 {
10682
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
901 gaim_debug_info("plugins", "Loading saved plugin %s\n",
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
902 plugin->path);
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
903 gaim_plugin_load(plugin);
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
904 }
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
905 else if ((plugin = gaim_plugins_find_with_basename(basename)) != NULL)
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
906 {
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
907 gaim_debug_info("plugins", "Loading saved plugin %s\n",
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
908 plugin->path);
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
909 gaim_plugin_load(plugin);
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
910 }
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
911 else
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
912 {
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
913 gaim_debug_error("plugins", "Unable to find saved plugin %s\n",
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
914 filename);
7033
cf1126ba1834 [gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
915 }
cf1126ba1834 [gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
916
5838
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5794
diff changeset
917 g_free(f->data);
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5794
diff changeset
918 }
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5794
diff changeset
919
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5794
diff changeset
920 g_list_free(files);
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5794
diff changeset
921 #endif /* GAIM_PLUGINS */
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5794
diff changeset
922 }
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5794
diff changeset
923
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5794
diff changeset
924
5242
fd81a00480ac [gaim-migrate @ 5613]
Christian Hammond <chipx86@chipx86.com>
parents: 5211
diff changeset
925 void
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
926 gaim_plugins_probe(const char *ext)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
927 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
928 #ifdef GAIM_PLUGINS
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
929 GDir *dir;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
930 const gchar *file;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
931 gchar *path;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
932 GaimPlugin *plugin;
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
933 GList *cur;
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
934 const char *search_path;
5205
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 if (!g_module_supported())
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
937 return;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
938
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
939 /* Probe plugins */
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
940 for (cur = search_paths; cur != NULL; cur = cur->next)
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
941 {
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
942 search_path = cur->data;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
943
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
944 dir = g_dir_open(search_path, 0, NULL);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
945
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
946 if (dir != NULL)
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
947 {
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
948 while ((file = g_dir_read_name(dir)) != NULL)
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
949 {
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
950 path = g_build_filename(search_path, file, NULL);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
951
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
952 if (ext == NULL || has_file_extension(file, ext))
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
953 plugin = gaim_plugin_probe(path);
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 g_free(path);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
956 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
957
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
958 g_dir_close(dir);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
959 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
960 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
961
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
962 /* See if we have any plugins waiting to load */
6981
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
963 while (load_queue != NULL)
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
964 {
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
965 plugin = (GaimPlugin *)load_queue->data;
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
966
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
967 load_queue = g_list_remove(load_queue, plugin);
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
968
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
969 if (plugin == NULL || plugin->info == NULL)
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
970 continue;
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
971
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
972 if (plugin->info->type == GAIM_PLUGIN_LOADER)
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
973 {
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
974 /* We'll just load this right now. */
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
975 if (!gaim_plugin_load(plugin))
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
976 {
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
977 gaim_plugin_destroy(plugin);
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
978
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
979 continue;
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
980 }
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
981
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
982 plugin_loaders = g_list_append(plugin_loaders, plugin);
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
983
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
984 for (cur = GAIM_PLUGIN_LOADER_INFO(plugin)->exts;
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
985 cur != NULL;
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
986 cur = cur->next)
6981
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
987 {
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
988 gaim_plugins_probe(cur->data);
6981
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
989 }
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
990 }
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
991 else if (plugin->info->type == GAIM_PLUGIN_PROTOCOL)
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
992 {
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
993 /* We'll just load this right now. */
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
994 if (!gaim_plugin_load(plugin))
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
995 {
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
996 gaim_plugin_destroy(plugin);
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
997
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
998 continue;
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
999 }
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
1000
7956
1b8261f374ea [gaim-migrate @ 8631]
Nathan Walp <nwalp@pidgin.im>
parents: 7279
diff changeset
1001 if (gaim_find_prpl(plugin->info->id))
6981
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
1002 {
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
1003 /* Nothing to see here--move along, move along */
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
1004 gaim_plugin_destroy(plugin);
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
1005
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
1006 continue;
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
1007 }
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
1008
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
1009 protocol_plugins = g_list_insert_sorted(protocol_plugins, plugin,
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
1010 (GCompareFunc)compare_prpl);
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
1011 }
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
1012 }
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
1013
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1014 if (probe_cb != NULL)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1015 probe_cb(probe_cb_data);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1016
10450
577fdf4110fc [gaim-migrate @ 11715]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
1017 #else /* GAIM_PLUGINS */
577fdf4110fc [gaim-migrate @ 11715]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
1018 /* We just need to populate the protocol_plugins list with all the PRPLs */
577fdf4110fc [gaim-migrate @ 11715]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
1019 GList *cur;
577fdf4110fc [gaim-migrate @ 11715]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
1020 GaimPlugin *plugin;
577fdf4110fc [gaim-migrate @ 11715]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
1021
577fdf4110fc [gaim-migrate @ 11715]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
1022 for (cur = plugins; cur != NULL; cur = cur->next)
577fdf4110fc [gaim-migrate @ 11715]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
1023 {
577fdf4110fc [gaim-migrate @ 11715]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
1024 plugin = cur->data;
577fdf4110fc [gaim-migrate @ 11715]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
1025 if (plugin->info->type == GAIM_PLUGIN_PROTOCL)
577fdf4110fc [gaim-migrate @ 11715]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
1026 protocol_plugins = g_list_insert_sorted(protocol_plugins, plugin,
577fdf4110fc [gaim-migrate @ 11715]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
1027 (GCompareFunc)compare_prpl);
577fdf4110fc [gaim-migrate @ 11715]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
1028 }
577fdf4110fc [gaim-migrate @ 11715]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
1029
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1030 #endif /* GAIM_PLUGINS */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1031 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1032
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1033 gboolean
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1034 gaim_plugin_register(GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1035 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1036 g_return_val_if_fail(plugin != NULL, FALSE);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1037
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
1038 /* If this plugin has been registered already then exit */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1039 if (g_list_find(plugins, plugin))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1040 return TRUE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1041
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
1042 /* Ensure the plugin has the requisite information */
8749
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
1043 if (plugin->info->type == GAIM_PLUGIN_LOADER)
6981
abd3c684da31 [gaim-migrate @ 7537]
Christian Hammond <chipx86@chipx86.com>
parents: 6822
diff changeset
1044 {
8749
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
1045 GaimPluginLoaderInfo *loader_info;
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
1046
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
1047 loader_info = GAIM_PLUGIN_LOADER_INFO(plugin);
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
1048
9943
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9697
diff changeset
1049 if (loader_info == NULL)
8749
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
1050 {
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
1051 gaim_debug_error("plugins", "%s is unloadable\n",
9943
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9697
diff changeset
1052 plugin->path);
8749
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
1053 return FALSE;
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
1054 }
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
1055 }
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
1056 else if (plugin->info->type == GAIM_PLUGIN_PROTOCOL)
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
1057 {
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
1058 GaimPluginProtocolInfo *prpl_info;
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
1059
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
1060 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin);
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
1061
9943
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9697
diff changeset
1062 if (prpl_info == NULL)
8749
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
1063 {
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
1064 gaim_debug_error("plugins", "%s is unloadable\n",
9943
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9697
diff changeset
1065 plugin->path);
8749
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
1066 return FALSE;
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
1067 }
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
1068 }
8749
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
1069
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
1070 /* This plugin should be probed and maybe loaded--add it to the queue */
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10279
diff changeset
1071 load_queue = g_list_append(load_queue, plugin);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1072
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1073 plugins = g_list_append(plugins, plugin);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1074
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1075 return TRUE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1076 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1077
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1078 gboolean
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1079 gaim_plugins_enabled(void)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1080 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1081 #ifdef GAIM_PLUGINS
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1082 return TRUE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1083 #else
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1084 return FALSE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1085 #endif
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1086 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1087
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1088 void
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1089 gaim_plugins_register_probe_notify_cb(void (*func)(void *), void *data)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1090 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1091 /* TODO */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1092 probe_cb = func;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1093 probe_cb_data = data;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1094 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1095
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1096 void
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1097 gaim_plugins_unregister_probe_notify_cb(void (*func)(void *))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1098 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1099 /* TODO */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1100 probe_cb = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1101 probe_cb_data = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1102 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1103
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1104 void
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1105 gaim_plugins_register_load_notify_cb(void (*func)(GaimPlugin *, void *),
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1106 void *data)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1107 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1108 /* TODO */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1109 load_cb = func;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1110 load_cb_data = data;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1111 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1112
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1113 void
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1114 gaim_plugins_unregister_load_notify_cb(void (*func)(GaimPlugin *, void *))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1115 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1116 /* TODO */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1117 load_cb = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1118 load_cb_data = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1119 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1120
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1121 void
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1122 gaim_plugins_register_unload_notify_cb(void (*func)(GaimPlugin *, void *),
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1123 void *data)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1124 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1125 /* TODO */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1126 unload_cb = func;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1127 unload_cb_data = data;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1128 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1129
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1130 void
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1131 gaim_plugins_unregister_unload_notify_cb(void (*func)(GaimPlugin *, void *))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1132 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1133 /* TODO */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1134 unload_cb = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1135 unload_cb_data = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1136 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1137
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1138 GaimPlugin *
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1139 gaim_plugins_find_with_name(const char *name)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1140 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1141 GaimPlugin *plugin;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1142 GList *l;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1143
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1144 for (l = plugins; l != NULL; l = l->next) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1145 plugin = l->data;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1146
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1147 if (!strcmp(plugin->info->name, name))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1148 return plugin;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1149 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1150
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1151 return NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1152 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1153
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1154 GaimPlugin *
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1155 gaim_plugins_find_with_filename(const char *filename)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1156 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1157 GaimPlugin *plugin;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1158 GList *l;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1159
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1160 for (l = plugins; l != NULL; l = l->next) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1161 plugin = l->data;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1162
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1163 if (plugin->path != NULL && !strcmp(plugin->path, filename))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1164 return plugin;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1165 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1166
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1167 return NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1168 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1169
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1170 GaimPlugin *
7033
cf1126ba1834 [gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1171 gaim_plugins_find_with_basename(const char *basename)
cf1126ba1834 [gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1172 {
cf1126ba1834 [gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1173 GaimPlugin *plugin;
cf1126ba1834 [gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1174 GList *l;
10682
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
1175 char *basename_no_ext;
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
1176 char *tmp;
7033
cf1126ba1834 [gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1177
cf1126ba1834 [gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1178 g_return_val_if_fail(basename != NULL, NULL);
cf1126ba1834 [gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1179
10682
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
1180 basename_no_ext = gaim_plugin_get_basename(basename);
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
1181
7033
cf1126ba1834 [gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1182 for (l = plugins; l != NULL; l = l->next)
cf1126ba1834 [gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1183 {
cf1126ba1834 [gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1184 plugin = (GaimPlugin *)l->data;
cf1126ba1834 [gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1185
7278
6d5dc6a65c47 [gaim-migrate @ 7857]
Sean Egan <seanegan@gmail.com>
parents: 7033
diff changeset
1186 if (plugin->path != NULL) {
10682
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
1187 tmp = gaim_plugin_get_basename(plugin->path);
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
1188 if (!strcmp(tmp, basename_no_ext))
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
1189 {
7278
6d5dc6a65c47 [gaim-migrate @ 7857]
Sean Egan <seanegan@gmail.com>
parents: 7033
diff changeset
1190 g_free(tmp);
10682
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
1191 g_free(basename_no_ext);
7033
cf1126ba1834 [gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1192 return plugin;
7278
6d5dc6a65c47 [gaim-migrate @ 7857]
Sean Egan <seanegan@gmail.com>
parents: 7033
diff changeset
1193 }
7279
0d24c94e4fbc [gaim-migrate @ 7858]
Nathan Walp <nwalp@pidgin.im>
parents: 7278
diff changeset
1194 g_free(tmp);
7033
cf1126ba1834 [gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1195 }
cf1126ba1834 [gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1196 }
cf1126ba1834 [gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1197
10682
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
1198 g_free(basename_no_ext);
c604c88a7530 [gaim-migrate @ 12228]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
1199
7033
cf1126ba1834 [gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1200 return NULL;
cf1126ba1834 [gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1201 }
cf1126ba1834 [gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1202
cf1126ba1834 [gaim-migrate @ 7596]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1203 GaimPlugin *
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1204 gaim_plugins_find_with_id(const char *id)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1205 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1206 GaimPlugin *plugin;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1207 GList *l;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1208
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1209 g_return_val_if_fail(id != NULL, NULL);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1210
6486
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1211 for (l = plugins; l != NULL; l = l->next)
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1212 {
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1213 plugin = l->data;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1214
6486
fab81e4b885c [gaim-migrate @ 7000]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1215 if (plugin->info->id != NULL && !strcmp(plugin->info->id, id))
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1216 return plugin;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1217 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1218
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1219 return NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1220 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1221
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1222 GList *
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1223 gaim_plugins_get_loaded(void)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1224 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1225 return loaded_plugins;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1226 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1227
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1228 GList *
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
1229 gaim_plugins_get_protocols(void)
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
1230 {
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
1231 return protocol_plugins;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
1232 }
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
1233
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
1234 GList *
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1235 gaim_plugins_get_all(void)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1236 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1237 return plugins;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1238 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1239
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
1240
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
1241 GaimPluginAction *
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
1242 gaim_plugin_action_new(char* label, void (*callback)(GaimPluginAction *))
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
1243 {
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
1244 GaimPluginAction *act = g_new0(GaimPluginAction, 1);
9018
bb168141eb5f [gaim-migrate @ 9794]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1245
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
1246 act->label = label;
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
1247 act->callback = callback;
9018
bb168141eb5f [gaim-migrate @ 9794]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1248
bb168141eb5f [gaim-migrate @ 9794]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1249 return act;
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
1250 }