annotate src/module.c @ 4376:2c985a9e994c

[gaim-migrate @ 4642] The conversations list is no longer public, and shouldn't have been in aim.c. This should fix some crashes that may have resulted in the notify and timestamp plugins. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Tue, 21 Jan 2003 05:20:10 +0000
parents 24d2881f75d2
children 3fef2d45dce0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /*
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 * gaim
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 *
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 *
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 * (at your option) any later version.
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 *
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 * GNU General Public License for more details.
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 *
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 *
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 * ----------------
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 * The Plug-in plug
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 *
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 * Plugin support is currently being maintained by Mike Saraf
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 * msaraf@dwc.edu
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 *
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 * Well, I didn't see any work done on it for a while, so I'm going to try
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 * my hand at it. - Eric warmenhoven@yahoo.com
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 *
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 * Mike is my roomate. I can assure you that he's lazy :-P -- Rob rob@marko.net
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 *
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 #ifdef HAVE_CONFIG_H
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 #include <config.h>
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 #endif
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36
2414
70cb0ce6991a [gaim-migrate @ 2427]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2405
diff changeset
37 #include "gaim.h"
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3565
diff changeset
38 #include "prpl.h"
2414
70cb0ce6991a [gaim-migrate @ 2427]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2405
diff changeset
39
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 #include <string.h>
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 #include <sys/time.h>
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 #include <sys/types.h>
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 #include <sys/stat.h>
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 #include <unistd.h>
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 #include <stdio.h>
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 #include <stdlib.h>
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
50 #ifdef _WIN32
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
51 #include "win32dep.h"
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
52 #endif
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
53
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 /* ------------------ Global Variables ----------------------- */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56 GList *plugins = NULL;
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
57 GList *probed_plugins = NULL;
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 GList *callbacks = NULL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59
2405
6e637ad18494 [gaim-migrate @ 2418]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2393
diff changeset
60 char *last_dir = NULL;
6e637ad18494 [gaim-migrate @ 2418]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2393
diff changeset
61
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62 /* --------------- Function Declarations --------------------- */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63
3466
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3461
diff changeset
64 struct gaim_plugin * load_plugin(const char *);
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
65 #ifdef GAIM_PLUGINS
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66 void unload_plugin(struct gaim_plugin *p);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67 void gaim_signal_connect(GModule *, enum gaim_event, void *, void *);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 void gaim_signal_disconnect(GModule *, enum gaim_event, void *);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69 void gaim_plugin_unload(GModule *);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71 /* --------------- Static Function Declarations ------------- */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73 static void plugin_remove_callbacks(GModule *);
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
74 #endif
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75 /* ------------------ Code Below ---------------------------- */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
77 static int is_so_file(char *filename, char *ext)
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
78 {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
79 int len;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
80 if (!filename) return 0;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
81 if (!filename[0]) return 0;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
82 len = strlen(filename);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
83 len -= strlen(ext);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
84 if (len < 0) return 0;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
85 return (!strncmp(filename + len, ext, strlen(ext)));
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
86 }
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
87
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
88 void gaim_probe_plugins() {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
89 GDir *dir;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
90 const gchar *file;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
91 gchar *path;
3717
988485669631 [gaim-migrate @ 3850]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
92 /*struct gaim_plugin_description *plugdes;*/
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
93 struct gaim_plugin *plug;
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
94 char *probedirs[3];
3565
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3563
diff changeset
95 int l;
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
96 #if GAIM_PLUGINS
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
97 char *(*gaim_plugin_init)(GModule *);
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3565
diff changeset
98 char *(*gaim_prpl_init)(struct prpl *);
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
99 char *(*cfunc)();
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3565
diff changeset
100 struct prpl * new_prpl;
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
101 struct gaim_plugin_description *(*desc)();
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
102 GModule *handle;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
103 #endif
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
104
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
105 probedirs[0] = LIBDIR;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
106 probedirs[1] = gaim_user_dir();
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
107 probedirs[2] = 0;
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
108
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
109 for (l=0; probedirs[l]; l++) {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
110 dir = g_dir_open(probedirs[l], 0, NULL);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
111 if (dir) {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
112 while ((file = g_dir_read_name(dir))) {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
113 #ifdef GAIM_PLUGINS
3717
988485669631 [gaim-migrate @ 3850]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
114 if (is_so_file((char*)file,
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
115 #ifndef _WIN32
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
116 ".so"
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
117 #else
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
118 ".dll"
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
119 #endif
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
120 ) && g_module_supported()) {
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
121 path = g_build_filename(probedirs[l], file, NULL);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
122 handle = g_module_open(path, 0);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
123 if (!handle) {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
124 debug_printf("%s is unloadable: %s\n", file, g_module_error());
4135
4927f8dd046f [gaim-migrate @ 4353]
Christian Hammond <chipx86@chipx86.com>
parents: 3835
diff changeset
125 g_free(path);
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
126 continue;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
127 }
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3565
diff changeset
128 if (g_module_symbol(handle, "gaim_prpl_init", (gpointer *)&gaim_prpl_init)) {
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3565
diff changeset
129 plug = g_new0(struct gaim_plugin, 1);
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3565
diff changeset
130 g_snprintf(plug->path, sizeof(plug->path), path);
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3565
diff changeset
131 plug->type = plugin;
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3565
diff changeset
132
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3565
diff changeset
133 new_prpl = g_new0(struct prpl, 1);
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3565
diff changeset
134 new_prpl->plug = plug;
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3565
diff changeset
135 gaim_prpl_init(new_prpl);
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3565
diff changeset
136 if (new_prpl->protocol == PROTO_ICQ ||
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3565
diff changeset
137 find_prpl(new_prpl->protocol)) {
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3565
diff changeset
138 /* Nothing to see here--move along, move along */
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3565
diff changeset
139 unload_protocol(new_prpl);
4135
4927f8dd046f [gaim-migrate @ 4353]
Christian Hammond <chipx86@chipx86.com>
parents: 3835
diff changeset
140 g_free(path);
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3565
diff changeset
141 continue;
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3565
diff changeset
142 }
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3565
diff changeset
143 protocols = g_slist_insert_sorted(protocols, new_prpl, (GCompareFunc)proto_compare);
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3565
diff changeset
144 g_module_close(handle);
4135
4927f8dd046f [gaim-migrate @ 4353]
Christian Hammond <chipx86@chipx86.com>
parents: 3835
diff changeset
145 g_free(path);
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3565
diff changeset
146 continue;
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3565
diff changeset
147 }
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3565
diff changeset
148
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
149 if (!g_module_symbol(handle, "gaim_plugin_init", (gpointer *)&gaim_plugin_init)) {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
150 debug_printf("%s is unloadable %s\n", file, g_module_error());
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
151 g_module_close(handle);
4135
4927f8dd046f [gaim-migrate @ 4353]
Christian Hammond <chipx86@chipx86.com>
parents: 3835
diff changeset
152 g_free(path);
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
153 continue;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
154 }
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
155 plug = g_new0(struct gaim_plugin, 1);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
156 g_snprintf(plug->path, sizeof(plug->path), path);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
157 plug->type = plugin;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
158 g_free(path);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
159 if (g_module_symbol(handle, "gaim_plugin_desc", (gpointer *)&desc)) {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
160 memcpy(&(plug->desc), desc(), sizeof(plug->desc));
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
161 } else {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
162 if (g_module_symbol(handle, "name", (gpointer *)&cfunc)) {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
163 plug->desc.name = g_strdup(cfunc());
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
164 }
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
165 if (g_module_symbol(handle, "description", (gpointer *)&cfunc)) {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
166 plug->desc.description = g_strdup(cfunc());
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
167 }
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
168 }
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
169 probed_plugins = g_list_append(probed_plugins, plug);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
170 g_module_close(handle);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
171 }
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
172 #endif
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
173 #ifdef USE_PERL
3717
988485669631 [gaim-migrate @ 3850]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
174 if (is_so_file((char*)file, ".pl")) {
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
175 path = g_build_filename(probedirs[l], file, NULL);
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
176 plug = probe_perl(path);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
177 if (plug)
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
178 probed_plugins = g_list_append(probed_plugins, plug);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
179 g_free(path);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
180 }
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
181 #endif
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
182 }
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
183 g_dir_close(dir);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
184 }
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
185 }
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
186 }
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
187
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
188 #ifdef GAIM_PLUGINS
3466
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3461
diff changeset
189 struct gaim_plugin *load_plugin(const char *filename)
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
190 {
3717
988485669631 [gaim-migrate @ 3850]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
191 struct gaim_plugin *plug=NULL;
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
192 struct gaim_plugin_description *desc;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
193 struct gaim_plugin_description *(*gaim_plugin_desc)();
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
194 char *(*cfunc)();
3717
988485669631 [gaim-migrate @ 3850]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
195 /*GList *c = plugins;*/
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
196 GList *p = probed_plugins;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
197 char *(*gaim_plugin_init)(GModule *);
3717
988485669631 [gaim-migrate @ 3850]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
198 char *error=NULL;
988485669631 [gaim-migrate @ 3850]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
199 char *retval;
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
200 gboolean newplug = FALSE;
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
201
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
202 if (!g_module_supported())
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
203 return NULL;
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
204 if (!filename || !strlen(filename))
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
205 return NULL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
206
3565
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3563
diff changeset
207 #ifdef USE_PERL
3717
988485669631 [gaim-migrate @ 3850]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
208 if (is_so_file((char*)filename, ".pl")) {
988485669631 [gaim-migrate @ 3850]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
209 /* perl_load_file is returning an int.. this should be fixed */
988485669631 [gaim-migrate @ 3850]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
210 return (struct gaim_plugin *)perl_load_file((char*)filename);
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
211 }
3565
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3563
diff changeset
212 #endif
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
213
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
214 while (filename && p) {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
215 plug = (struct gaim_plugin *)p->data;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
216 if (!strcmp(filename, plug->path))
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
217 break;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
218 p = p->next;
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
219 }
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
220
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
221 if (plug && plug->handle) {
3835
b359aab1c576 [gaim-migrate @ 3985]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
222 return plug;
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
223 }
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
224
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
225 if (!plug) {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
226 plug = g_new0(struct gaim_plugin, 1);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
227 g_snprintf(plug->path, sizeof(plug->path), filename);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
228 newplug = TRUE;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
229 }
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
230
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
231 debug_printf("Loading %s\n", filename);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
232 plug->handle = g_module_open(filename, 0);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
233 if (!plug->handle) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
234 error = (char *)g_module_error();
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
235 plug->handle = NULL;
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
236 g_snprintf(plug->error, sizeof(plug->error), error);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
237 return NULL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
238 }
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
239
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
240 if (!g_module_symbol(plug->handle, "gaim_plugin_init", (gpointer *)&gaim_plugin_init)) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
241 g_module_close(plug->handle);
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
242 plug->handle = NULL;
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
243 g_snprintf(plug->error, sizeof(plug->error), error);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
244 return NULL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
245 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
246
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
247 plug->error[0] = '\0';
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2511
diff changeset
248 retval = gaim_plugin_init(plug->handle);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
249 debug_printf("loaded plugin returned %s\n", retval ? retval : "NULL");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
250 if (retval) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
251 plugin_remove_callbacks(plug->handle);
3427
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3163
diff changeset
252 do_error_dialog("Gaim was unable to load your plugin.", retval, GAIM_ERROR);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
253 g_module_close(plug->handle);
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
254 plug->handle = NULL;
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
255 return NULL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
256 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
257
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
258 plugins = g_list_append(plugins, plug);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
259
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
260 if (newplug) {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
261 g_snprintf(plug->path, sizeof(plug->path), filename);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
262 if (g_module_symbol(plug->handle, "gaim_plugin_desc", (gpointer *)&gaim_plugin_desc)) {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
263 desc = gaim_plugin_desc();
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
264 plug->desc.name = desc->name;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
265 } else {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
266 if (g_module_symbol(plug->handle, "name", (gpointer *)&cfunc)) {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
267 plug->desc.name = g_strdup(cfunc());
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
268 }
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
269 if (g_module_symbol(plug->handle, "description", (gpointer *)&cfunc)) {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
270 plug->desc.description = g_strdup(cfunc());
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
271 }
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
272 }
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
273 probed_plugins = g_list_append(probed_plugins, plug);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
274 }
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
275
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
276 save_prefs();
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
277 return plug;
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
278
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
279 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
280
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
281 static void unload_gaim_plugin(struct gaim_plugin *p)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
282 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
283 void (*gaim_plugin_remove)();
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
284
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
285 debug_printf("Unloading %s\n", g_module_name(p->handle));
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
286
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4135
diff changeset
287 /* cancel any pending dialogs the plugin has */
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4135
diff changeset
288 do_ask_cancel_by_handle(p->handle);
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4135
diff changeset
289
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
290 /* Attempt to call the plugin's remove function (if there) */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
291 if (g_module_symbol(p->handle, "gaim_plugin_remove", (gpointer *)&gaim_plugin_remove))
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2511
diff changeset
292 gaim_plugin_remove();
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
293
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
294 plugin_remove_callbacks(p->handle);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
295
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
296 plugins = g_list_remove(plugins, p);
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
297 p->handle = NULL;
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
298 save_prefs();
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
299 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
300
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
301 void unload_plugin(struct gaim_plugin *p)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
302 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
303 GModule *handle = p->handle;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
304 unload_gaim_plugin(p);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
305 g_module_close(handle);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
306 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
307
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
308 static gboolean unload_timeout(gpointer handle)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
309 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
310 g_module_close(handle);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
311 return FALSE;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
312 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
313
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
314 void gaim_plugin_unload(GModule *handle)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
315 {
2494
2c1950c5544a [gaim-migrate @ 2507]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2465
diff changeset
316 GList *pl = plugins;
2511
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
317 struct gaim_plugin *p = NULL;
2494
2c1950c5544a [gaim-migrate @ 2507]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2465
diff changeset
318 void (*gaim_plugin_remove)();
2c1950c5544a [gaim-migrate @ 2507]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2465
diff changeset
319
2c1950c5544a [gaim-migrate @ 2507]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2465
diff changeset
320 while (pl) {
2c1950c5544a [gaim-migrate @ 2507]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2465
diff changeset
321 p = pl->data;
2c1950c5544a [gaim-migrate @ 2507]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2465
diff changeset
322 if (p->handle == handle)
2c1950c5544a [gaim-migrate @ 2507]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2465
diff changeset
323 break;
2c1950c5544a [gaim-migrate @ 2507]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2465
diff changeset
324 pl = pl->next;
2c1950c5544a [gaim-migrate @ 2507]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2465
diff changeset
325 }
2c1950c5544a [gaim-migrate @ 2507]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2465
diff changeset
326 if (!pl)
2c1950c5544a [gaim-migrate @ 2507]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2465
diff changeset
327 return;
2c1950c5544a [gaim-migrate @ 2507]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2465
diff changeset
328
2c1950c5544a [gaim-migrate @ 2507]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2465
diff changeset
329 debug_printf("Unloading %s\n", g_module_name(p->handle));
2c1950c5544a [gaim-migrate @ 2507]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2465
diff changeset
330
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4135
diff changeset
331 /* cancel any pending dialogs the plugin has */
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4135
diff changeset
332 do_ask_cancel_by_handle(p->handle);
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4135
diff changeset
333
2494
2c1950c5544a [gaim-migrate @ 2507]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2465
diff changeset
334 if (g_module_symbol(p->handle, "gaim_plugin_remove", (gpointer *)&gaim_plugin_remove))
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2511
diff changeset
335 gaim_plugin_remove();
2494
2c1950c5544a [gaim-migrate @ 2507]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2465
diff changeset
336 plugin_remove_callbacks(p->handle);
2c1950c5544a [gaim-migrate @ 2507]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2465
diff changeset
337 plugins = g_list_remove(plugins, p);
2c1950c5544a [gaim-migrate @ 2507]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2465
diff changeset
338 g_free(p);
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
339 /* XXX CUI need to tell UI what happened, but not like this
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
340 update_show_plugins(); */
2494
2c1950c5544a [gaim-migrate @ 2507]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2465
diff changeset
341
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
342 g_timeout_add(5000, unload_timeout, handle);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
343 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
344
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
345 /* Remove all callbacks associated with plugin handle */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
346 static void plugin_remove_callbacks(GModule *handle)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
347 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
348 GList *c = callbacks;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
349 struct gaim_callback *g;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
350
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
351 debug_printf("%d callbacks to search\n", g_list_length(callbacks));
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
352
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
353 while (c) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
354 g = (struct gaim_callback *)c->data;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
355 if (g->handle == handle) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
356 c = g_list_next(c);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
357 callbacks = g_list_remove(callbacks, (gpointer)g);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
358 debug_printf("Removing callback, %d remain\n", g_list_length(callbacks));
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
359 } else
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
360 c = g_list_next(c);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
361 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
362 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
363
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
364 void gaim_signal_connect(GModule *handle, enum gaim_event which, void *func, void *data)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
365 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
366 struct gaim_callback *call = g_new0(struct gaim_callback, 1);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
367 call->handle = handle;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
368 call->event = which;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
369 call->function = func;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
370 call->data = data;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
371
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
372 callbacks = g_list_append(callbacks, call);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
373 debug_printf("Adding callback %d\n", g_list_length(callbacks));
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
374 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
375
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
376 void gaim_signal_disconnect(GModule *handle, enum gaim_event which, void *func)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
377 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
378 GList *c = callbacks;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
379 struct gaim_callback *g = NULL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
380
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
381 while (c) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
382 g = (struct gaim_callback *)c->data;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
383 if (handle == g->handle && func == g->function) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
384 callbacks = g_list_remove(callbacks, c->data);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
385 g_free(g);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
386 c = callbacks;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
387 if (c == NULL)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
388 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
389 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
390 c = g_list_next(c);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
391 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
392 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
394 #endif /* GAIM_PLUGINS */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
395
2511
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
396 char *event_name(enum gaim_event event)
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
397 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
398 static char buf[128];
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
399 switch (event) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
400 case event_signon:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
401 sprintf(buf, "event_signon");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
402 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
403 case event_signoff:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
404 sprintf(buf, "event_signoff");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
405 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
406 case event_away:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
407 sprintf(buf, "event_away");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
408 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
409 case event_back:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
410 sprintf(buf, "event_back");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
411 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
412 case event_im_recv:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
413 sprintf(buf, "event_im_recv");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
414 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
415 case event_im_send:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
416 sprintf(buf, "event_im_send");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
417 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
418 case event_buddy_signon:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
419 sprintf(buf, "event_buddy_signon");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
420 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
421 case event_buddy_signoff:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
422 sprintf(buf, "event_buddy_signoff");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
423 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
424 case event_buddy_away:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
425 sprintf(buf, "event_buddy_away");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
426 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
427 case event_buddy_back:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
428 sprintf(buf, "event_buddy_back");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
429 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
430 case event_buddy_idle:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
431 sprintf(buf, "event_buddy_idle");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
432 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
433 case event_buddy_unidle:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
434 sprintf(buf, "event_buddy_unidle");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
435 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
436 case event_blist_update:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
437 sprintf(buf, "event_blist_update");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
438 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
439 case event_chat_invited:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
440 sprintf(buf, "event_chat_invited");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
441 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
442 case event_chat_join:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
443 sprintf(buf, "event_chat_join");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
444 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
445 case event_chat_leave:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
446 sprintf(buf, "event_chat_leave");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
447 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
448 case event_chat_buddy_join:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
449 sprintf(buf, "event_chat_buddy_join");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
450 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
451 case event_chat_buddy_leave:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
452 sprintf(buf, "event_chat_buddy_leave");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
453 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
454 case event_chat_recv:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
455 sprintf(buf, "event_chat_recv");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
456 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
457 case event_chat_send:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
458 sprintf(buf, "event_chat_send");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
459 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
460 case event_warned:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
461 sprintf(buf, "event_warned");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
462 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
463 case event_error:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
464 sprintf(buf, "event_error");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
465 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
466 case event_quit:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
467 sprintf(buf, "event_quit");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
468 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
469 case event_new_conversation:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
470 sprintf(buf, "event_new_conversation");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
471 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
472 case event_set_info:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
473 sprintf(buf, "event_set_info");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
474 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
475 case event_draw_menu:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
476 sprintf(buf, "event_draw_menu");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
477 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
478 case event_im_displayed_sent:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
479 sprintf(buf, "event_im_displayed_sent");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
480 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
481 case event_im_displayed_rcvd:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
482 sprintf(buf, "event_im_displayed_rcvd");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
483 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
484 case event_chat_send_invite:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
485 sprintf(buf, "event_chat_send_invite");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
486 break;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2823
diff changeset
487 case event_got_typing:
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2823
diff changeset
488 sprintf(buf, "event_got_typing");
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2823
diff changeset
489 break;
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents: 3466
diff changeset
490 case event_del_conversation:
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents: 3466
diff changeset
491 sprintf(buf, "event_del_conversation");
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents: 3466
diff changeset
492 break;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents: 3466
diff changeset
493 case event_connecting:
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents: 3466
diff changeset
494 sprintf(buf, "event_connecting");
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents: 3466
diff changeset
495 break;
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
496 default:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
497 sprintf(buf, "event_unknown");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
498 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
499 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
500 return buf;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
501 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
502
3517
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
503 int plugin_event(enum gaim_event event, ...)
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
504 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
505 #ifdef GAIM_PLUGINS
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
506 GList *c = callbacks;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
507 struct gaim_callback *g;
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
508 #endif
3517
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
509 va_list arrg;
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
510 void *arg1 = NULL,
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
511 *arg2 = NULL,
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
512 *arg3 = NULL,
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
513 *arg4 = NULL,
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
514 *arg5 = NULL;
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
515
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
516
4306
24d2881f75d2 [gaim-migrate @ 4560]
Sean Egan <seanegan@gmail.com>
parents: 4249
diff changeset
517 /* debug_printf("%s\n", event_name(event)); */
2463
0be6fadaa64f [gaim-migrate @ 2476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2443
diff changeset
518
0be6fadaa64f [gaim-migrate @ 2476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2443
diff changeset
519 #ifdef GAIM_PLUGINS
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
520 while (c) {
3517
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
521 void (*cbfunc)(void *, ...);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
522
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
523 g = (struct gaim_callback *)c->data;
2511
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
524 if (g->event == event && g->function != NULL) {
3517
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
525 cbfunc=g->function;
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
526 va_start(arrg, event);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
527 switch (event) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
528
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
529 /* no args */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
530 case event_blist_update:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
531 case event_quit:
3517
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
532 cbfunc(g->data);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
533 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
534
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
535 /* one arg */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
536 case event_signon:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
537 case event_signoff:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
538 case event_new_conversation:
3461
c11960537fee [gaim-migrate @ 3510]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
539 case event_del_conversation:
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
540 case event_error:
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents: 3466
diff changeset
541 case event_connecting:
3517
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
542 arg1 = va_arg(arrg, void *);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
543 cbfunc(arg1, g->data);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
544 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
545
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
546 /* two args */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
547 case event_buddy_signon:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
548 case event_buddy_signoff:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
549 case event_buddy_away:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
550 case event_buddy_back:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
551 case event_buddy_idle:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
552 case event_buddy_unidle:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
553 case event_set_info:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
554 case event_draw_menu:
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2823
diff changeset
555 case event_got_typing:
3517
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
556 arg1 = va_arg(arrg, void *);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
557 arg2 = va_arg(arrg, void *);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
558 cbfunc(arg1, arg2, g->data);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
559 break;
3517
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
560 case event_chat_leave:
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
561 {
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
562 int id;
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
563 arg1 = va_arg(arrg, void*);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
564 id = va_arg(arrg, int);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
565 cbfunc(arg1, id, g->data);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
566 }
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
567 break;
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
568 /* three args */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
569 case event_im_send:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
570 case event_im_displayed_sent:
3517
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
571 case event_away:
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
572 arg1 = va_arg(arrg, void *);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
573 arg2 = va_arg(arrg, void *);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
574 arg3 = va_arg(arrg, void *);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
575 cbfunc(arg1, arg2, arg3, g->data);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
576 break;
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
577 case event_chat_buddy_join:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
578 case event_chat_buddy_leave:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
579 case event_chat_send:
3517
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
580 case event_chat_join:
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
581 {
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
582 int id;
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
583 arg1 = va_arg(arrg, void*);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
584 id = va_arg(arrg, int);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
585 arg3 = va_arg(arrg, void*);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
586 cbfunc(arg1, id, arg3, g->data);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
587 }
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
588 break;
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
589 case event_warned:
3517
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
590 {
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
591 int id;
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
592 arg1 = va_arg(arrg, void*);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
593 arg2 = va_arg(arrg, void*);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
594 id = va_arg(arrg, int);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
595 cbfunc(arg1, arg2, id, g->data);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
596 }
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
597 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
598 /* four args */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
599 case event_im_recv:
3517
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
600 case event_chat_invited:
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
601 arg1 = va_arg(arrg, void *);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
602 arg2 = va_arg(arrg, void *);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
603 arg3 = va_arg(arrg, void *);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
604 arg4 = va_arg(arrg, void *);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
605 cbfunc(arg1, arg2, arg3, arg4, g->data);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
606 break;
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
607 case event_chat_recv:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
608 case event_chat_send_invite:
3517
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
609 {
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
610 int id;
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
611 arg1 = va_arg(arrg, void *);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
612 id = va_arg(arrg, int);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
613
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
614 arg3 = va_arg(arrg, void *);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
615 arg4 = va_arg(arrg, void *);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
616 cbfunc(arg1, id, arg3, arg4, g->data);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
617 }
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
618 break;
3517
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
619 /* five args */
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
620 case event_im_displayed_rcvd:
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
621 {
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
622 time_t time;
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
623 arg1 = va_arg(arrg, void *);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
624 arg2 = va_arg(arrg, void *);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
625 arg3 = va_arg(arrg, void *);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
626 arg4 = va_arg(arrg, void *);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
627 time = va_arg(arrg, time_t);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
628 cbfunc(arg1, arg2, arg3, arg4, time, g->data);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
629 }
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
630 break;
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
631 default:
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
632 debug_printf("unknown event %d\n", event);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
633 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
634 }
3517
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
635 va_end(arrg);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
636 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
637 c = c->next;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
638 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
639 #endif /* GAIM_PLUGINS */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
640 #ifdef USE_PERL
3517
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
641 va_start(arrg, event);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
642 arg1 = va_arg(arrg, void *);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
643 arg2 = va_arg(arrg, void *);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
644 arg3 = va_arg(arrg, void *);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
645 arg4 = va_arg(arrg, void *);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
646 arg5 = va_arg(arrg, void *);
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
647 return perl_event(event, arg1, arg2, arg3, arg4, arg5);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
648 #else
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
649 return 0;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
650 #endif
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
651 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
652
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
653 /* Calls the gaim_plugin_remove function in any loaded plugin that has one */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
654 #ifdef GAIM_PLUGINS
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
655 void remove_all_plugins()
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
656 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
657 GList *c = plugins;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
658 struct gaim_plugin *p;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
659 void (*gaim_plugin_remove)();
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
660
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
661 while (c) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
662 p = (struct gaim_plugin *)c->data;
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
663 if (p->type == plugin) {
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
664 if (g_module_symbol(p->handle, "gaim_plugin_remove", (gpointer *)&gaim_plugin_remove))
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
665 gaim_plugin_remove();
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
666 }
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
667 g_free(p);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
668 c = c->next;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
669 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
670 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
671 #endif