annotate plugins/perl/perl.c @ 5946:209cae24a51d

[gaim-migrate @ 6387] new -> new_pass committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Mon, 23 Jun 2003 06:59:54 +0000
parents 83507b72ae6d
children 547ba881bc7e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 /*
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 * gaim
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3 *
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5 *
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 * (at your option) any later version.
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 *
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * GNU General Public License for more details.
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 *
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 *
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 * This was taken almost exactly from X-Chat. The power of the GPL.
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 * Translated from X-Chat to Gaim by Eric Warmenhoven.
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 * Originally by Erik Scrafford <eriks@chilisoft.com>.
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23 * X-Chat Copyright (C) 1998 Peter Zelezny.
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
24 *
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25 */
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
26 #ifdef DEBUG
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
27 # undef DEBUG
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
28 #endif
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
29
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30 #undef PACKAGE
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
31
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
32 #define group perl_group
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
33
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
34 #ifdef _WIN32
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
35 /* This took me an age to figure out.. without this __declspec(dllimport)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
36 * will be ignored.
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37 */
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
38 # define HASATTRIBUTE
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39 #endif
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
40
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
41 #include <EXTERN.h>
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
42
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
43 #ifndef _SEM_SEMUN_UNDEFINED
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
44 # define HAS_UNION_SEMUN
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
45 #endif
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
46
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
47 #include <perl.h>
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 #include <XSUB.h>
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
49
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50 #ifndef _WIN32
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
51 # include <sys/mman.h>
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52 #endif
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
53
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54 #undef PACKAGE
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
55
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56 #ifndef _WIN32
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
57 # include <dirent.h>
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58 #else
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
59 /* We're using perl's win32 port of this */
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
60 # define dirent direct
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61 #endif
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63 #undef group
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 /* perl module support */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
66 #ifdef OLD_PERL
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
67 extern void boot_DynaLoader _((CV * cv));
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68 #else
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69 extern void boot_DynaLoader _((pTHX_ CV * cv)); /* perl is so wacky */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70 #endif
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72 #undef _
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73 #ifdef DEBUG
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
74 # undef DEBUG
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
75 #endif
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
76 #ifdef _WIN32
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
77 # undef pipe
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
78 #endif
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
79
5912
b3c412884a22 [gaim-migrate @ 6344]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5873
diff changeset
80 #ifdef _WIN32
b3c412884a22 [gaim-migrate @ 6344]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5873
diff changeset
81 #define _WIN32DEP_H_
b3c412884a22 [gaim-migrate @ 6344]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5873
diff changeset
82 #endif
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
83 #include "internal.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
84
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
85 #include "debug.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
86 #include "prpl.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
87 #include "notify.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
88 #include "server.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
89 #include "sound.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
90
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
91 #include "ui.h"
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93 #ifndef call_pv
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 # define call_pv(i,j) perl_call_pv((i), (j))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95 #endif
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97 #define PERL_PLUGIN_ID "core-perl"
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
99 struct perlscript {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100 char *name;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
101 char *version;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
102 char *shutdowncallback; /* bleh */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
103 GaimPlugin *plug;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
104 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
105
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
106 struct _perl_event_handlers {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
107 char *event_type;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
108 char *handler_name;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
109 GaimPlugin *plug;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
110 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112 struct _perl_timeout_handlers {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113 char *handler_name;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114 char *handler_args;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
115 gint iotag;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116 GaimPlugin *plug;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
117 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
118
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5408
diff changeset
119 static GaimPlugin *my_plugin = NULL;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
120 static GList *perl_list = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
121 static GList *perl_timeout_handlers = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122 static GList *perl_event_handlers = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123 static PerlInterpreter *my_perl = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 static void perl_init();
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 /* dealing with gaim */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127 XS(XS_GAIM_register); /* set up hooks for script */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128 XS(XS_GAIM_get_info); /* version, last to attempt signon, protocol */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
129 XS(XS_GAIM_print); /* lemme figure this one out... */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130 XS(XS_GAIM_write_to_conv); /* write into conversation window */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
132 /* list stuff */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133 XS(XS_GAIM_buddy_list); /* all buddies */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134 XS(XS_GAIM_online_list); /* online buddies */
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 /* server stuff */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137 XS(XS_GAIM_command); /* send command to server */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138 XS(XS_GAIM_user_info); /* given name, return struct buddy members */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
139 XS(XS_GAIM_print_to_conv); /* send message to someone */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140 XS(XS_GAIM_print_to_chat); /* send message to chat room */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141 XS(XS_GAIM_serv_send_im); /* send message to someone (but do not display) */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
142
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
143 /* handler commands */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
144 XS(XS_GAIM_add_event_handler); /* when servers talk */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
145 XS(XS_GAIM_remove_event_handler); /* remove a handler */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
146 XS(XS_GAIM_add_timeout_handler); /* figure it out */
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 /* play sound */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149 XS(XS_GAIM_play_sound); /*play a sound */
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 static void
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
152 #ifdef OLD_PERL
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
153 xs_init()
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
154 #else
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
155 xs_init(pTHX)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
156 #endif
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
157 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
158 char *file = __FILE__;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
160 /* This one allows dynamic loading of perl modules in perl
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
161 scripts by the 'use perlmod;' construction*/
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
162 newXS ("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
163
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
164 /* load up all the custom Gaim perl functions */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
165 newXS ("GAIM::register", XS_GAIM_register, "GAIM");
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
166 newXS ("GAIM::get_info", XS_GAIM_get_info, "GAIM");
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
167 newXS ("GAIM::print", XS_GAIM_print, "GAIM");
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
168 newXS ("GAIM::write_to_conv", XS_GAIM_write_to_conv, "GAIM");
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
169
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
170 newXS ("GAIM::buddy_list", XS_GAIM_buddy_list, "GAIM");
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
171 newXS ("GAIM::online_list", XS_GAIM_online_list, "GAIM");
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
172
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
173 newXS ("GAIM::command", XS_GAIM_command, "GAIM");
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
174 newXS ("GAIM::user_info", XS_GAIM_user_info, "GAIM");
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
175 newXS ("GAIM::print_to_conv", XS_GAIM_print_to_conv, "GAIM");
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
176 newXS ("GAIM::print_to_chat", XS_GAIM_print_to_chat, "GAIM");
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
177 newXS ("GAIM::serv_send_im", XS_GAIM_serv_send_im, "GAIM");
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
178
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
179 newXS ("GAIM::add_event_handler", XS_GAIM_add_event_handler, "GAIM");
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
180 newXS ("GAIM::remove_event_handler", XS_GAIM_remove_event_handler, "GAIM");
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
181 newXS ("GAIM::add_timeout_handler", XS_GAIM_add_timeout_handler, "GAIM");
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
182
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
183 newXS ("GAIM::play_sound", XS_GAIM_play_sound, "GAIM");
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
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
186 static char *
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
187 escape_quotes(const char *buf)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
188 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
189 static char *tmp_buf = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
190 const char *i;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
191 char *j;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
192
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
193 if (tmp_buf)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
194 g_free(tmp_buf);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
195
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
196 tmp_buf = g_malloc(strlen(buf) * 2 + 1);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
197
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
198 for (i = buf, j = tmp_buf; *i; i++, j++) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
199 if (*i == '\'' || *i == '\\')
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
200 *j++ = '\\';
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
201
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
202 *j = *i;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
203 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
204
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
205 *j = '\0';
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
206
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
207 return tmp_buf;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
208 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
209
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
210 /*
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
211 2003/02/06: execute_perl modified by Mark Doliner <mark@kingant.net>
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
212 Pass parameters by pushing them onto the stack rather than
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
213 passing an array of strings. This way, perl scripts can
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
214 modify the parameters and we can get the changed values
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
215 and then shoot ourselves. I mean, uh, use them.
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
216
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
217 2001/06/14: execute_perl replaced by Martin Persson <mep@passagen.se>
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
218 previous use of perl_eval leaked memory, replaced with
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
219 a version that uses perl_call instead
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
220
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
221 30/11/2002: execute_perl modified by Eric Timme <timothy@voidnet.com>
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
222 args changed to char** so that we can have preparsed
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
223 arguments again, and many headaches ensued! This essentially
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
224 means we replaced one hacked method with a messier hacked
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
225 method out of perceived necessity. Formerly execute_perl
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
226 required a single char_ptr, and it would insert it into an
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
227 array of character pointers and NULL terminate the new array.
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
228 Now we have to pass in pre-terminated character pointer arrays
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
229 to accomodate functions that want to pass in multiple arguments.
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
230
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
231 Previously arguments were preparsed because an argument list
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
232 was constructed in the form 'arg one','arg two' and was
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
233 executed via a call like &funcname(arglist) (see .59.x), so
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
234 the arglist was magically pre-parsed because of the method.
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
235 With Martin Persson's change to perl_call we now need to
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
236 use a null terminated list of character pointers for arguments
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
237 if we wish them to be parsed. Lacking a better way to allow
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
238 for both single arguments and many I created a NULL terminated
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
239 array in every function that called execute_perl and passed
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
240 that list into the function. In the former version a single
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
241 character pointer was passed in, and was placed into an array
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
242 of character pointers with two elements, with a NULL element
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
243 tacked onto the back, but this method no longer seemed prudent.
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
244
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
245 Enhancements in the future might be to get rid of pre-declaring
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
246 the array sizes? I am not comfortable enough with this
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
247 subject to attempt it myself and hope it to stand the test
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
248 of time.
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
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
251 static int
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
252 execute_perl(const char *function, int argc, char **args)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
253 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
254 int count = 0, i, ret_value = 1;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
255 SV *sv_args[argc];
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
256 STRLEN na;
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 /*
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
259 * Set up the perl environment, push arguments onto the
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
260 * perl stack, then call the given function
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
261 */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
262 dSP;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
263 ENTER;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
264 SAVETMPS;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
265 PUSHMARK(sp);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
266
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
267 for (i = 0; i < argc; i++) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
268 if (args[i]) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
269 sv_args[i] = sv_2mortal(newSVpv(args[i], 0));
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
270 XPUSHs(sv_args[i]);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
271 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
272 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
273
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
274 PUTBACK;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
275 count = call_pv(function, G_EVAL | G_SCALAR);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
276 SPAGAIN;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
277
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
278 /*
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
279 * Check for "die," make sure we have 1 argument, and set our
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
280 * return value.
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
281 */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
282 if (SvTRUE(ERRSV)) {
5227
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
283 gaim_debug(GAIM_DEBUG_ERROR, "perl",
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
284 "Perl function %s exited abnormally: %s\n",
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
285 function, SvPV(ERRSV, na));
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
286 POPs;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
287 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
288 else if (count != 1) {
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 * This should NEVER happen. G_SCALAR ensures that we WILL
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
291 * have 1 parameter.
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
292 */
5227
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
293 gaim_debug(GAIM_DEBUG_ERROR, "perl",
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
294 "Perl error from %s: expected 1 return value, "
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
295 "but got %d\n", function, count);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
296 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
297 else
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
298 ret_value = POPi;
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 /* Check for changed arguments */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
301 for (i = 0; i < argc; i++) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
302 if (args[i] && strcmp(args[i], SvPVX(sv_args[i]))) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
303 /*
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
304 * Shizzel. So the perl script changed one of the parameters,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
305 * and we want this change to affect the original parameters.
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
306 * args[i] is just a tempory little list of pointers. We don't
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
307 * want to free args[i] here because the new parameter doesn't
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
308 * overwrite the data that args[i] points to. That is done by
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
309 * the function that called execute_perl. I'm not explaining this
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
310 * very well. See, it's aggregate... Oh, but if 2 perl scripts
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
311 * both modify the data, _that's_ a memleak. This is really kind
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
312 * of hackish. I should fix it. Look how long this comment is.
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
313 * Holy crap.
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
314 */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
315 args[i] = g_strdup(SvPV(sv_args[i], na));
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
316 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
317 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
318
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
319 PUTBACK;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
320 FREETMPS;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
321 LEAVE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
322
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
323 return ret_value;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
324 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
325
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
326 static void
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
327 perl_unload_file(GaimPlugin *plug)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
328 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
329 char *atmp[2] = { "", NULL };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
330 struct perlscript *scp = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
331 struct _perl_timeout_handlers *thn;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
332 struct _perl_event_handlers *ehn;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
333 GList *pl;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
334
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
335 for (pl = perl_list; pl != NULL; pl = pl->next) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
336 scp = pl->data;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
337
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
338 if (scp->plug == plug) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
339 perl_list = g_list_remove(perl_list, scp);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
340
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
341 if (scp->shutdowncallback[0])
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
342 execute_perl(scp->shutdowncallback, 1, atmp);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
343
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
344 g_free(scp->name);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
345 g_free(scp->version);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
346 g_free(scp->shutdowncallback);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
347 g_free(scp);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
348
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
349 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
350 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
351 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
352
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
353 for (pl = perl_timeout_handlers; pl != NULL; pl = pl->next) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
354 thn = pl->data;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
355
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
356 if (thn && thn->plug == plug) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
357 perl_timeout_handlers = g_list_remove(perl_timeout_handlers, thn);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
358
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
359 g_source_remove(thn->iotag);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
360 g_free(thn->handler_args);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
361 g_free(thn->handler_name);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
362 g_free(thn);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
363 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
364 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
365
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
366 for (pl = perl_event_handlers; pl != NULL; pl = pl->next) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
367 ehn = pl->data;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
368
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
369 if (ehn && ehn->plug == plug) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
370 perl_event_handlers = g_list_remove(perl_event_handlers, ehn);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
371
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
372 g_free(ehn->event_type);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
373 g_free(ehn->handler_name);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
374 g_free(ehn);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
375 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
376 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
377 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
378
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
379 static int
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
380 perl_load_file(char *script_name, GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
381 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
382 char *atmp[2] = { script_name, NULL };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
383 GList *s;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
384 struct perlscript *scp;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
385 int ret;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
386
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
387 if (my_perl == NULL)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
388 perl_init();
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
389
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
390 plugin->handle = plugin->path;
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 ret = execute_perl("load_n_eval", 1, atmp);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
393
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
394 for (s = perl_list; s != NULL; s = s->next) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
395 scp = s->data;
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 if (!strcmp(scp->name, plugin->info->name) &&
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
398 !strcmp(scp->version, plugin->info->version)) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
399
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
400 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
401 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
402 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
403
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
404 if (!s) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
405 plugin->error = g_strdup(_("GAIM::register not called with "
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
406 "proper arguments. Consult PERL-HOWTO."));
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
407
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
408 return 0;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
409 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
410
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
411 return ret;
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
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
414 static void
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
415 perl_init(void)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
416 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
417 /* changed the name of the variable from load_file to
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
418 perl_definitions since now it does much more than defining
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
419 the load_file sub. Moreover, deplaced the initialisation to
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
420 the xs_init function. (TheHobbit)*/
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
421 char *perl_args[] = { "", "-e", "0", "-w" };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
422 char perl_definitions[] =
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
423 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
424 /* We use to function one to load a file the other to
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
425 execute the string obtained from the first and holding
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
426 the file conents. This allows to have a realy local $/
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
427 without introducing temp variables to hold the old
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
428 value. Just a question of style:) */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
429 "sub load_file{"
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
430 "my $f_name=shift;"
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
431 "local $/=undef;"
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
432 "open FH,$f_name or return \"__FAILED__\";"
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
433 "$_=<FH>;"
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
434 "close FH;"
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
435 "return $_;"
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
436 "}"
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
437 "sub load_n_eval{"
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
438 "my $f_name=shift;"
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
439 "my $strin=load_file($f_name);"
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
440 "return 2 if($strin eq \"__FAILED__\");"
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
441 "eval $strin;"
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
442 "if($@){"
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
443 /*" #something went wrong\n"*/
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
444 "GAIM::print(\"Errors loading file $f_name:\\n\",\"$@\");"
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
445 "return 1;"
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
446 "}"
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
447 "return 0;"
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
448 "}"
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 my_perl = perl_alloc();
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
452 perl_construct(my_perl);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
453 #ifdef DEBUG
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
454 perl_parse(my_perl, xs_init, 4, perl_args, NULL);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
455 #else
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
456 perl_parse(my_perl, xs_init, 3, perl_args, NULL);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
457 #endif
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
458 #ifdef HAVE_PERL_EVAL_PV
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
459 eval_pv(perl_definitions, TRUE);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
460 #else
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
461 perl_eval_pv(perl_definitions, TRUE); /* deprecated */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
462 #endif
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
463 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
464
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
465 static void
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
466 perl_end(void)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
467 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
468 char *atmp[2] = { "", NULL };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
469 struct perlscript *scp;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
470 struct _perl_timeout_handlers *thn;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
471 struct _perl_event_handlers *ehn;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
472
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
473 while (perl_list) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
474 scp = perl_list->data;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
475 perl_list = g_list_remove(perl_list, scp);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
476
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
477 if (scp->shutdowncallback[0])
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
478 execute_perl(scp->shutdowncallback, 1, atmp);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
479
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
480 g_free(scp->name);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
481 g_free(scp->version);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
482 g_free(scp->shutdowncallback);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
483 g_free(scp);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
484 }
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 while (perl_timeout_handlers) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
487 thn = perl_timeout_handlers->data;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
488 perl_timeout_handlers = g_list_remove(perl_timeout_handlers, thn);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
489 g_source_remove(thn->iotag);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
490 g_free(thn->handler_args);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
491 g_free(thn->handler_name);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
492 g_free(thn);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
493 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
494
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
495 while (perl_event_handlers) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
496 ehn = perl_event_handlers->data;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
497 perl_event_handlers = g_list_remove(perl_event_handlers, ehn);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
498 g_free(ehn->event_type);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
499 g_free(ehn->handler_name);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
500 g_free(ehn);
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
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
503 if (my_perl != NULL) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
504 perl_destruct(my_perl);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
505 perl_free(my_perl);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
506 my_perl = 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 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
509
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
510 XS (XS_GAIM_register)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
511 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
512 char *name, *ver, *callback, *unused; /* exactly like X-Chat, eh? :) */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
513 unsigned int junk;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
514 struct perlscript *scp;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
515 GaimPlugin *plug = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
516 GList *pl;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
517
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
518 dXSARGS;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
519 items = 0;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
520
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
521 name = SvPV(ST(0), junk);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
522 ver = SvPV(ST(1), junk);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
523 callback = SvPV(ST(2), junk);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
524 unused = SvPV(ST(3), junk);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
525
5227
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
526 gaim_debug(GAIM_DEBUG_INFO, "perl",
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
527 "GAIM::register(%s, %s)\n", name, ver);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
528
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
529 for (pl = gaim_plugins_get_all(); pl != NULL; pl = pl->next) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
530 plug = pl->data;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
531
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
532 if (!strcmp(name, plug->info->name) &&
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
533 !strcmp(ver, plug->info->version)) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
534
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
535 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
536 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
537
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
538 plug = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
539 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
540
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
541 if (plug) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
542 scp = g_new0(struct perlscript, 1);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
543 scp->name = g_strdup(name);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
544 scp->version = g_strdup(ver);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
545 scp->shutdowncallback = g_strdup(callback);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
546 scp->plug = plug;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
547 perl_list = g_list_append(perl_list, scp);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
548 XST_mPV(0, plug->path);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
549 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
550 else
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
551 XST_mPV(0, NULL);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
552
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
553 XSRETURN (1);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
554 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
555
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
556 XS (XS_GAIM_get_info)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
557 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
558 int i = 0;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
559 dXSARGS;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
560 items = 0;
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 switch(SvIV(ST(0))) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
563 case 0:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
564 XST_mPV(0, VERSION);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
565 i = 1;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
566 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
567
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
568 case 1:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
569 {
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
570 GList *c = gaim_connections_get_all();
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
571 GaimConnection *gc;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
572
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
573 while (c) {
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
574 gc = (GaimConnection *)c->data;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
575 XST_mIV(i++, (guint)gc);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
576 c = c->next;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
577 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
578 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
579 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
580
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
581 case 2:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
582 {
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
583 GaimConnection *gc =
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
584 (GaimConnection *)SvIV(ST(1));
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
585 GaimAccount *account = gaim_connection_get_account(gc);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
586
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
587 if (g_list_find(gaim_connections_get_all(), gc))
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
588 XST_mIV(i++, gaim_account_get_protocol(account));
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
589 else
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
590 XST_mIV(i++, -1);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
591 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
592 break;
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 case 3:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
595 {
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
596 GaimConnection *gc =
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
597 (GaimConnection *)SvIV(ST(1));
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
598 GaimAccount *account = gaim_connection_get_account(gc);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
599
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
600 if (g_list_find(gaim_connections_get_all(), gc))
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
601 XST_mPV(i++, gaim_account_get_username(account));
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
602 else
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
603 XST_mPV(i++, "");
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
604 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
605 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
606
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
607 case 4:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
608 {
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
609 GaimConnection *gc =
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
610 (GaimConnection *)SvIV(ST(1));
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
611 GaimAccount *account = gaim_connection_get_account(gc);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
612
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
613 if (g_list_find(gaim_connections_get_all(), gc))
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
614 XST_mIV(i++, g_list_index(gaim_accounts_get_all(),
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
615 account));
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
616 else
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
617 XST_mIV(i++, -1);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
618 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
619 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
620
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
621 case 5:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
622 {
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
623 GList *a = gaim_accounts_get_all();
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
624 while (a) {
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
625 GaimAccount *account = a->data;
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
626 XST_mPV(i++, gaim_account_get_username(account));
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
627 a = a->next;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
628 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
629 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
630 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
631
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
632 case 6:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
633 {
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
634 GList *a = gaim_accounts_get_all();
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
635 while (a) {
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
636 GaimAccount *account = a->data;
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
637 XST_mIV(i++, gaim_account_get_protocol(account));
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
638 a = a->next;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
639 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
640 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
641 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
642
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
643 case 7:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
644 {
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
645 GaimConnection *gc =
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
646 (GaimConnection *)SvIV(ST(1));
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
647
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
648 if (g_list_find(gaim_connections_get_all(), gc))
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
649 XST_mPV(i++, gc->prpl->info->name);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
650 else
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
651 XST_mPV(i++, "Unknown");
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
652 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
653 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
654
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
655 default:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
656 XST_mPV(0, "Error2");
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
657 i = 1;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
658 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
659
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
660 XSRETURN(i);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
661 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
662
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
663 XS (XS_GAIM_print)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
664 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
665 char *title;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
666 char *message;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
667 unsigned int junk;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
668 dXSARGS;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
669 items = 0;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
670
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
671 title = SvPV(ST(0), junk);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
672 message = SvPV(ST(1), junk);
5445
ad9b6e65713b [gaim-migrate @ 5827]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
673 gaim_notify_info(my_plugin, NULL, title, message);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
674 XSRETURN(0);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
675 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
676
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
677 XS (XS_GAIM_buddy_list)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
678 {
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
679 GaimConnection *gc;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
680 struct buddy *buddy;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
681 struct group *g;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
682 GaimBlistNode *gnode,*bnode;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
683 int i = 0;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
684 dXSARGS;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
685 items = 0;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
686
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
687 gc = (GaimConnection *)SvIV(ST(0));
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
688
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
689 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
690 if(!GAIM_BLIST_NODE_IS_GROUP(gnode))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
691 continue;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
692 g = (struct group *)gnode;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
693 for(bnode = gnode->child; bnode; bnode = bnode->next) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
694 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
695 continue;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
696 buddy = (struct buddy *)bnode;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
697 if(buddy->account == gc->account)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
698 XST_mPV(i++, buddy->name);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
699 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
700 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
701 XSRETURN(i);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
702 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
703
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
704 XS (XS_GAIM_online_list)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
705 {
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
706 GaimConnection *gc;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
707 struct buddy *b;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
708 struct group *g;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
709 GaimBlistNode *gnode,*bnode;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
710 int i = 0;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
711 dXSARGS;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
712 items = 0;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
713
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
714 gc = (GaimConnection *)SvIV(ST(0));
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
715
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
716 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
717 if(!GAIM_BLIST_NODE_IS_GROUP(gnode))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
718 continue;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
719 g = (struct group *)gnode;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
720 for(bnode = gnode->child; bnode; bnode = bnode->next) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
721 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
722 continue;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
723 b = (struct buddy *)bnode;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
724 if (b->account == gc->account && GAIM_BUDDY_IS_ONLINE(b)) XST_mPV(i++, b->name);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
725 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
726 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
727 XSRETURN(i);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
728 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
729
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
730 XS (XS_GAIM_command)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
731 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
732 unsigned int junk;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
733 char *command = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
734 dXSARGS;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
735 items = 0;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
736
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
737 command = SvPV(ST(0), junk);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
738 if (!command) XSRETURN(0);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
739 if (!strncasecmp(command, "signon", 6)) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
740 int index = SvIV(ST(1));
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
741 if (g_list_nth_data(gaim_accounts_get_all(), index))
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
742 serv_login(g_list_nth_data(gaim_accounts_get_all(), index));
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
743 } else if (!strncasecmp(command, "signoff", 7)) {
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
744 GaimConnection *gc = (GaimConnection *)SvIV(ST(1));
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
745 if (g_list_find(gaim_connections_get_all(), gc))
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
746 gaim_connection_disconnect(gc);
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
747 else
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
748 gaim_connections_disconnect_all();
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
749 } else if (!strncasecmp(command, "info", 4)) {
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
750 GaimConnection *gc = (GaimConnection *)SvIV(ST(1));
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
751 if (g_list_find(gaim_connections_get_all(), gc))
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
752 serv_set_info(gc, SvPV(ST(2), junk));
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
753 } else if (!strncasecmp(command, "away", 4)) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
754 char *message = SvPV(ST(1), junk);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
755 static struct away_message a;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
756 g_snprintf(a.message, sizeof(a.message), "%s", message);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
757 do_away_message(NULL, &a);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
758 } else if (!strncasecmp(command, "back", 4)) {
5775
171fdd5493b9 [gaim-migrate @ 6200]
Nathan Walp <nwalp@pidgin.im>
parents: 5676
diff changeset
759 do_im_back(NULL, NULL);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
760 } else if (!strncasecmp(command, "idle", 4)) {
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
761 GList *c = gaim_connections_get_all();
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
762 GaimConnection *gc;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
763
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
764 while (c) {
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
765 gc = (GaimConnection *)c->data;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
766 serv_set_idle(gc, SvIV(ST(1)));
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
767 c = c->next;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
768 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
769 } else if (!strncasecmp(command, "warn", 4)) {
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
770 GList *c = gaim_connections_get_all();
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
771 GaimConnection *gc;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
772
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
773 while (c) {
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
774 gc = (GaimConnection *)c->data;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
775 serv_warn(gc, SvPV(ST(1), junk), SvIV(ST(2)));
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
776 c = c->next;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
777 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
778 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
779
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
780 XSRETURN(0);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
781 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
782
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
783 XS (XS_GAIM_user_info)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
784 {
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
785 GaimConnection *gc;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
786 unsigned int junk;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
787 struct buddy *buddy = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
788 dXSARGS;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
789 items = 0;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
790
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
791 gc = (GaimConnection *)SvIV(ST(0));
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
792 if (g_list_find(gaim_connections_get_all(), gc))
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
793 buddy = gaim_find_buddy(gc->account, SvPV(ST(1), junk));
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
794
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
795 if (!buddy)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
796 XSRETURN(0);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
797 XST_mPV(0, buddy->name);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
798 XST_mPV(1, gaim_get_buddy_alias(buddy));
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
799 XST_mPV(2, GAIM_BUDDY_IS_ONLINE(buddy) ? "Online" : "Offline");
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
800 XST_mIV(3, buddy->evil);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
801 XST_mIV(4, buddy->signon);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
802 XST_mIV(5, buddy->idle);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
803 XSRETURN(6);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
804 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
805
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
806 XS (XS_GAIM_write_to_conv)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
807 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
808 char *nick, *who, *what;
5676
dae79aefac8d [gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents: 5586
diff changeset
809 GaimConversation *c;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
810 int junk;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
811 int send, wflags;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
812 dXSARGS;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
813 items = 0;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
814
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
815 nick = SvPV(ST(0), junk);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
816 send = SvIV(ST(1));
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
817 what = SvPV(ST(2), junk);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
818 who = SvPV(ST(3), junk);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
819
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
820 if (!*who) who=NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
821
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
822 switch (send) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
823 case 0: wflags=WFLAG_SEND; break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
824 case 1: wflags=WFLAG_RECV; break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
825 case 2: wflags=WFLAG_SYSTEM; break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
826 default: wflags=WFLAG_RECV;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
827 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
828
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
829 c = gaim_find_conversation(nick);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
830
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
831 if (!c)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
832 c = gaim_conversation_new(GAIM_CONV_IM, NULL, nick);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
833
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
834 gaim_conversation_write(c, who, what, -1, wflags, time(NULL));
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
835 XSRETURN(0);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
836 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
837
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
838 XS (XS_GAIM_serv_send_im)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
839 {
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
840 GaimConnection *gc;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
841 char *nick, *what;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
842 int isauto;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
843 int junk;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
844 dXSARGS;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
845 items = 0;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
846
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
847 gc = (GaimConnection *)SvIV(ST(0));
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
848 nick = SvPV(ST(1), junk);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
849 what = SvPV(ST(2), junk);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
850 isauto = SvIV(ST(3));
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
851
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
852 if (!g_list_find(gaim_connections_get_all(), gc)) {
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
853 XSRETURN(0);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
854 return;
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 serv_send_im(gc, nick, what, -1, isauto);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
857 XSRETURN(0);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
858 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
859
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
860 XS (XS_GAIM_print_to_conv)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
861 {
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
862 GaimConnection *gc;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
863 char *nick, *what;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
864 int isauto;
5676
dae79aefac8d [gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents: 5586
diff changeset
865 GaimConversation *c;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
866 unsigned int junk;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
867 dXSARGS;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
868 items = 0;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
869
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
870 gc = (GaimConnection *)SvIV(ST(0));
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
871 nick = SvPV(ST(1), junk);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
872 what = SvPV(ST(2), junk);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
873 isauto = SvIV(ST(3));
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
874 if (!g_list_find(gaim_connections_get_all(), gc)) {
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
875 XSRETURN(0);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
876 return;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
877 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
878
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
879 c = gaim_find_conversation(nick);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
880
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
881 if (!c)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
882 c = gaim_conversation_new(GAIM_CONV_IM, gc->account, nick);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
883 else
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
884 gaim_conversation_set_account(c, gc->account);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
885
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
886 gaim_conversation_write(c, NULL, what, -1,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
887 (WFLAG_SEND | (isauto ? WFLAG_AUTO : 0)), time(NULL));
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
888 serv_send_im(gc, nick, what, -1, isauto ? IM_FLAG_AWAY : 0);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
889 XSRETURN(0);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
890 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
891
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
892
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
893
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
894 XS (XS_GAIM_print_to_chat)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
895 {
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
896 GaimConnection *gc;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
897 int id;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
898 char *what;
5676
dae79aefac8d [gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents: 5586
diff changeset
899 GaimConversation *b = NULL;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
900 GSList *bcs;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
901 unsigned int junk;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
902 dXSARGS;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
903 items = 0;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
904
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
905 gc = (GaimConnection *)SvIV(ST(0));
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
906 id = SvIV(ST(1));
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
907 what = SvPV(ST(2), junk);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
908
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
909 if (!g_list_find(gaim_connections_get_all(), gc)) {
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
910 XSRETURN(0);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
911 return;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
912 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
913 bcs = gc->buddy_chats;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
914 while (bcs) {
5676
dae79aefac8d [gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents: 5586
diff changeset
915 b = (GaimConversation *)bcs->data;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
916
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
917 if (gaim_chat_get_id(gaim_conversation_get_chat_data(b)) == id)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
918 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
919 bcs = bcs->next;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
920 b = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
921 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
922 if (b)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
923 serv_chat_send(gc, id, what);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
924 XSRETURN(0);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
925 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
926
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
927 static int
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
928 perl_event(GaimEvent event, void *unused, va_list args)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
929 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
930 char *buf[5] = { NULL, NULL, NULL, NULL, NULL }; /* Maximum of 5 args */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
931 void *arg1 = NULL, *arg2 = NULL, *arg3 = NULL, *arg4 = NULL, *arg5 = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
932 char tmpbuf1[16], tmpbuf2[16], tmpbuf3[1];
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
933 GList *handler;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
934 struct _perl_event_handlers *data;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
935 int handler_return;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
936
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
937 arg1 = va_arg(args, void *);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
938 arg2 = va_arg(args, void *);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
939 arg3 = va_arg(args, void *);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
940 arg4 = va_arg(args, void *);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
941 arg5 = va_arg(args, void *);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
942
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
943 tmpbuf1[0] = '\0';
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
944 tmpbuf2[0] = '\0';
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
945 tmpbuf3[0] = '\0';
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
946
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
947 /* Make a pretty array of char*'s with which to call perl functions */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
948 switch (event) {
5408
2af3224b329a [gaim-migrate @ 5784]
Christian Hammond <chipx86@chipx86.com>
parents: 5227
diff changeset
949 case event_connecting:
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
950 case event_signon:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
951 case event_signoff:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
952 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
953 buf[0] = tmpbuf1;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
954 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
955 case event_away:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
956 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
957 buf[0] = tmpbuf1;
5586
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
958 buf[1] = ((GaimConnection *)arg1)->away ?
cde28f5c47d4 [gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents: 5470
diff changeset
959 ((GaimConnection *)arg1)->away : tmpbuf2;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
960 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
961 case event_im_recv:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
962 if (!*(char**)arg2 || !*(char**)arg3) return 1;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
963 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
964 buf[0] = tmpbuf1;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
965 buf[1] = *(char **)arg2;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
966 buf[2] = *(char **)arg3;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
967 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
968 case event_im_send:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
969 if (!*(char**)arg3) return 1;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
970 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
971 buf[0] = tmpbuf1;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
972 buf[1] = arg2 ? arg2 : tmpbuf3;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
973 buf[2] = *(char **)arg3;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
974 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
975 case event_buddy_signon:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
976 case event_buddy_signoff:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
977 case event_set_info:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
978 case event_buddy_away:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
979 case event_buddy_back:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
980 case event_buddy_idle:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
981 case event_buddy_unidle:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
982 case event_got_typing:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
983 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
984 buf[0] = tmpbuf1;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
985 buf[1] = arg2;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
986 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
987 case event_chat_invited:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
988 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
989 buf[0] = tmpbuf1;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
990 buf[1] = arg2;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
991 buf[2] = arg3;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
992 buf[3] = arg4;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
993 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
994 case event_chat_join:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
995 case event_chat_buddy_join:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
996 case event_chat_buddy_leave:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
997 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
998 buf[0] = tmpbuf1;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
999 g_snprintf(tmpbuf2, 16, "%d", (int)arg2);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1000 buf[1] = tmpbuf2;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1001 buf[2] = arg3;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1002 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1003 case event_chat_leave:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1004 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1005 buf[0] = tmpbuf1;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1006 g_snprintf(tmpbuf2, 16, "%d", (int)arg2);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1007 buf[1] = tmpbuf2;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1008 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1009 case event_chat_recv:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1010 if (!*(char**)arg3 || !*(char**)arg4) return 1;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1011 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1012 buf[0] = tmpbuf1;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1013 g_snprintf(tmpbuf2, 16, "%d", (int)arg2);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1014 buf[1] = tmpbuf2;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1015 buf[2] = *(char **)arg3;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1016 buf[3] = *(char **)arg4;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1017 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1018 case event_chat_send_invite:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1019 if (!*(char**)arg4) return 1;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1020 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1021 buf[0] = tmpbuf1;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1022 g_snprintf(tmpbuf2, 16, "%d", (int)arg2);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1023 buf[1] = tmpbuf2;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1024 buf[2] = arg3;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1025 buf[3] = *(char **)arg4;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1026 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1027 case event_chat_send:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1028 if (!*(char**)arg3) return 1;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1029 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1030 buf[0] = tmpbuf1;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1031 g_snprintf(tmpbuf2, 16, "%d", (int)arg2);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1032 buf[1] = tmpbuf2;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1033 buf[2] = *(char **)arg3;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1034 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1035 case event_warned:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1036 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1037 buf[0] = tmpbuf1;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1038 buf[1] = arg2 ? arg2 : tmpbuf3;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1039 g_snprintf(tmpbuf2, 16, "%d", (int)arg3);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1040 buf[2] = tmpbuf2;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1041 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1042 case event_quit:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1043 case event_blist_update:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1044 buf[0] = tmpbuf3;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1045 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1046 case event_new_conversation:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1047 case event_del_conversation:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1048 buf[0] = arg1;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1049 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1050 case event_im_displayed_sent:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1051 if (!*(char**)arg3) return 1;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1052 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1053 buf[0] = tmpbuf1;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1054 buf[1] = arg2;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1055 buf[2] = *(char **)arg3;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1056 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1057 case event_im_displayed_rcvd:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1058 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1059 buf[0] = tmpbuf1;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1060 buf[1] = arg2;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1061 buf[2] = arg3 ? arg3 : tmpbuf3;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1062 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1063 case event_draw_menu:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1064 /* we can't handle this usefully without gtk/perl bindings */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1065 return 0;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1066 default:
5227
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
1067 gaim_debug(GAIM_DEBUG_WARNING, "perl",
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
1068 "Someone forgot to handle %s in the perl binding\n",
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
1069 gaim_event_get_name(event));
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1070 return 0;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1071 }
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 /* Call any applicable functions */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1074 for (handler = perl_event_handlers;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1075 handler != NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1076 handler = handler->next) {
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 data = handler->data;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1079
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1080 if (!strcmp(gaim_event_get_name(event), data->event_type)) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1081
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1082 handler_return = execute_perl(data->handler_name, 5, buf);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1083
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1084 if (handler_return)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1085 return handler_return;
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
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1089 /* Now make changes from perl scripts affect the real data */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1090 switch (event) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1091 case event_im_recv:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1092 if (buf[1] != *(char **)arg2) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1093 free(*(char **)arg2);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1094 *(char **)arg2 = buf[1];
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 if (buf[2] != *(char **)arg3) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1097 free(*(char **)arg3);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1098 *(char **)arg3 = buf[2];
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1099 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1100 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1101 case event_im_send:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1102 if (buf[2] != *(char **)arg3) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1103 free(*(char **)arg3);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1104 *(char **)arg3 = buf[2];
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1105 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1106 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1107 case event_chat_recv:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1108 if (buf[2] != *(char **)arg3) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1109 free(*(char **)arg3);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1110 *(char **)arg3 = buf[2];
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 if (buf[3] != *(char **)arg4) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1113 free(*(char **)arg4);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1114 *(char **)arg4 = buf[3];
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 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1117 case event_chat_send_invite:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1118 if (buf[3] != *(char **)arg4) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1119 free(*(char **)arg4);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1120 *(char **)arg4 = buf[3];
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1121 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1122 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1123 case event_chat_send:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1124 if (buf[2] != *(char **)arg3) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1125 free(*(char **)arg3);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1126 *(char **)arg3 = buf[2];
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1127 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1128 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1129 case event_im_displayed_sent:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1130 if (buf[2] != *(char **)arg3) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1131 free(*(char **)arg3);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1132 *(char **)arg3 = buf[2];
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1133 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1134 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1135 default:
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1136 break;
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
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1139 return 0;
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
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1142 XS (XS_GAIM_add_event_handler)
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 unsigned int junk;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1145 struct _perl_event_handlers *handler;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1146 char *handle;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1147 GaimPlugin *plug;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1148 GList *p;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1149 dXSARGS;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1150 items = 0;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1151
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1152 handle = SvPV(ST(0), junk);
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 for (p = gaim_plugins_get_all(); p != NULL; p = p->next) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1155 plug = p->data;
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 if (!strcmp(handle, plug->path))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1158 break;
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
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1161 if (p) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1162 handler = g_new0(struct _perl_event_handlers, 1);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1163 handler->event_type = g_strdup(SvPV(ST(1), junk));
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1164 handler->handler_name = g_strdup(SvPV(ST(2), junk));
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1165 handler->plug = plug;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1166 perl_event_handlers = g_list_append(perl_event_handlers, handler);
5227
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
1167 gaim_debug(GAIM_DEBUG_INFO, "perl",
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
1168 "Registered perl event handler for %s\n",
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
1169 handler->event_type);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1170 } else {
5227
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
1171 gaim_debug(GAIM_DEBUG_ERROR, "perl",
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
1172 "Invalid handle (%s) registering perl event handler\n",
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
1173 handle);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1174 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1175
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1176 XSRETURN_EMPTY;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1177 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1178
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1179 XS (XS_GAIM_remove_event_handler)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1180 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1181 unsigned int junk;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1182 struct _perl_event_handlers *ehn;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1183 GList *cur = perl_event_handlers;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1184 dXSARGS;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1185 items = 0;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1186
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1187 while (cur) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1188 GList *next = cur->next;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1189 ehn = cur->data;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1190
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1191 if (!strcmp(ehn->event_type, SvPV(ST(0), junk)) &&
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1192 !strcmp(ehn->handler_name, SvPV(ST(1), junk)))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1193 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1194 perl_event_handlers = g_list_remove(perl_event_handlers, ehn);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1195 g_free(ehn->event_type);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1196 g_free(ehn->handler_name);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1197 g_free(ehn);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1198 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1199
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1200 cur = next;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1201 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1202 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1203
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1204 static int
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1205 perl_timeout(gpointer data)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1206 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1207 char *atmp[2] = { NULL, NULL };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1208 struct _perl_timeout_handlers *handler = data;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1209
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1210 atmp[0] = escape_quotes(handler->handler_args);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1211 execute_perl(handler->handler_name, 1, atmp);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1212
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1213 perl_timeout_handlers = g_list_remove(perl_timeout_handlers, handler);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1214 g_free(handler->handler_args);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1215 g_free(handler->handler_name);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1216 g_free(handler);
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 return 0; /* returning zero removes the timeout handler */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1219 }
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 XS (XS_GAIM_add_timeout_handler)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1222 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1223 unsigned int junk;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1224 long timeout;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1225 struct _perl_timeout_handlers *handler;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1226 char *handle;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1227 GaimPlugin *plug;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1228 GList *p;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1229
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1230 dXSARGS;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1231 items = 0;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1232
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1233 handle = SvPV(ST(0), junk);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1234
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1235 for (p = gaim_plugins_get_all(); p != NULL; p = p->next) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1236 plug = p->data;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1237
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1238 if (!strcmp(handle, plug->path))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1239 break;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1240 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1241
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1242 if (p) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1243 handler = g_new0(struct _perl_timeout_handlers, 1);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1244 timeout = 1000 * SvIV(ST(1));
5227
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
1245 gaim_debug(GAIM_DEBUG_INFO, "perl",
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
1246 "Adding timeout for %ld seconds.\n", timeout/1000);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1247 handler->plug = plug;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1248 handler->handler_name = g_strdup(SvPV(ST(2), junk));
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1249 handler->handler_args = g_strdup(SvPV(ST(3), junk));
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1250 perl_timeout_handlers = g_list_append(perl_timeout_handlers, handler);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1251 handler->iotag = g_timeout_add(timeout, perl_timeout, handler);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1252 } else {
5227
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
1253 gaim_debug(GAIM_DEBUG_ERROR, "perl",
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
1254 "Invalid handle (%s) in adding perl timeout handler.",
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
1255 handle);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1256 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1257 XSRETURN_EMPTY;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1258 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1259
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1260 XS (XS_GAIM_play_sound)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1261 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1262 int id;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1263 dXSARGS;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1264
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1265 items = 0;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1266
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1267 id = SvIV(ST(0));
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1268
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1269 gaim_sound_play_event(id);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1270
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1271 XSRETURN_EMPTY;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1272 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1273
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1274 static gboolean
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1275 probe_perl_plugin(GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1276 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1277 /* XXX This would be much faster if I didn't create a new
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1278 * PerlInterpreter every time I probed a plugin */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1279
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1280 GaimPluginInfo *info;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1281 PerlInterpreter *prober = perl_alloc();
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1282 char *argv[] = {"", plugin->path };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1283 int count;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1284 gboolean status = TRUE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1285
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1286 perl_construct(prober);
5922
83507b72ae6d [gaim-migrate @ 6362]
Luke Schierer <lschiere@pidgin.im>
parents: 5912
diff changeset
1287 perl_parse(prober, xs_init, 2, argv, NULL);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1288
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1289 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1290 dSP;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1291 ENTER;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1292 SAVETMPS;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1293 PUSHMARK(SP);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1294
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1295 count = perl_call_pv("description", G_NOARGS | G_ARRAY | G_EVAL);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1296 SPAGAIN;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1297
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1298 if (count == 6) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1299 info = g_new0(GaimPluginInfo, 1);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1300
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1301 info->api_version = 2;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1302 info->type = GAIM_PLUGIN_STANDARD;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1303
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1304 info->dependencies = g_list_append(info->dependencies,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1305 PERL_PLUGIN_ID);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1306
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1307 POPp; /* iconfile */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1308
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1309 info->homepage = g_strdup(POPp);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1310 info->author = g_strdup(POPp);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1311 info->description = g_strdup(POPp);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1312 info->version = g_strdup(POPp);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1313 info->name = g_strdup(POPp);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1314
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1315 plugin->info = info;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1316
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1317 if (!gaim_plugin_register(plugin))
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1318 status = FALSE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1319 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1320 else
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1321 status = FALSE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1322
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1323 PUTBACK;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1324 FREETMPS;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1325 LEAVE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1326 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1327
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1328 perl_destruct(prober);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1329 perl_free(prober);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1330
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1331 return status;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1332 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1333
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1334 static gboolean
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1335 load_perl_plugin(GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1336 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1337 perl_load_file(plugin->path, plugin);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1338
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1339 return TRUE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1340 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1341
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1342 static gboolean
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1343 unload_perl_plugin(GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1344 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1345 perl_unload_file(plugin);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1346
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1347 return TRUE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1348 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1349
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1350 static void
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1351 destroy_perl_plugin(GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1352 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1353 if (plugin->info != NULL) {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1354 g_free(plugin->info->name);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1355 g_free(plugin->info->version);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1356 g_free(plugin->info->description);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1357 g_free(plugin->info->author);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1358 g_free(plugin->info->homepage);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1359 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1360 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1361
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1362 static gboolean
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1363 plugin_unload(GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1364 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1365 perl_end();
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1366
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1367 return TRUE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1368 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1369
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1370 static GaimPluginLoaderInfo loader_info =
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1371 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1372 NULL, /**< exts */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1373
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1374 probe_perl_plugin, /**< probe */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1375 load_perl_plugin, /**< load */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1376 unload_perl_plugin, /**< unload */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1377 destroy_perl_plugin, /**< destroy */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1378 perl_event /**< broadcast */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1379 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1380
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1381 static GaimPluginInfo info =
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1382 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1383 2, /**< api_version */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1384 GAIM_PLUGIN_LOADER, /**< type */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1385 NULL, /**< ui_requirement */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1386 0, /**< flags */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1387 NULL, /**< dependencies */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1388 GAIM_PRIORITY_DEFAULT, /**< priority */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1389
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1390 PERL_PLUGIN_ID, /**< id */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1391 N_("Perl Plugin Loader"), /**< name */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1392 VERSION, /**< version */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1393 N_("Provides support for loading perl plugins."), /**< summary */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1394 N_("Provides support for loading perl plugins."), /**< description */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1395 "Christian Hammond <chipx86@gnupdate.org>", /**< author */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1396 WEBSITE, /**< homepage */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1397
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1398 NULL, /**< load */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1399 plugin_unload, /**< unload */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1400 NULL, /**< destroy */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1401
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1402 NULL, /**< ui_info */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1403 &loader_info /**< extra_info */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1404 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1405
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1406 static void
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
1407 init_plugin(GaimPlugin *plugin)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1408 {
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5408
diff changeset
1409 my_plugin = plugin;
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5408
diff changeset
1410
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1411 loader_info.exts = g_list_append(loader_info.exts, "pl");
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1412 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1413
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
1414 GAIM_INIT_PLUGIN(perl, init_plugin, info);