Mercurial > pidgin.yaz
annotate src/perl.c @ 4709:57d74064445a
[gaim-migrate @ 5020]
For the moment excluding wintrans and iconaway
committer: Tailor Script <tailor@pidgin.im>
author | Herman Bloggs <hermanator12002@yahoo.com> |
---|---|
date | Tue, 11 Mar 2003 20:29:15 +0000 |
parents | 283fb289c510 |
children | c4c28874ecd3 |
rev | line source |
---|---|
560 | 1 /* |
2 * gaim | |
3 * | |
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 * This was taken almost exactly from X-Chat. The power of the GPL. | |
21 * Translated from X-Chat to Gaim by Eric Warmenhoven. | |
22 * Originally by Erik Scrafford <eriks@chilisoft.com>. | |
597
3a24fd19ff5f
[gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
23 * X-Chat Copyright (C) 1998 Peter Zelezny. |
560 | 24 * |
25 */ | |
26 | |
27 #ifdef HAVE_CONFIG_H | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2048
diff
changeset
|
28 #include <config.h> |
1896
e556ffa08cce
[gaim-migrate @ 1906]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1850
diff
changeset
|
29 #ifdef DEBUG |
e556ffa08cce
[gaim-migrate @ 1906]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1850
diff
changeset
|
30 #undef DEBUG |
e556ffa08cce
[gaim-migrate @ 1906]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1850
diff
changeset
|
31 #endif |
560 | 32 #endif |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
33 #undef PACKAGE |
560 | 34 |
580
9a8b067eb368
[gaim-migrate @ 590]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
579
diff
changeset
|
35 #ifdef USE_PERL |
560 | 36 |
3395 | 37 #define group perl_group |
3630 | 38 #ifdef _WIN32 |
39 /* This took me an age to figure out.. without this __declspec(dllimport) | |
40 * will be ignored. | |
41 */ | |
42 #define HASATTRIBUTE | |
43 #endif | |
560 | 44 #include <EXTERN.h> |
45 #ifndef _SEM_SEMUN_UNDEFINED | |
46 #define HAS_UNION_SEMUN | |
47 #endif | |
48 #include <perl.h> | |
49 #include <XSUB.h> | |
3630 | 50 #ifndef _WIN32 |
560 | 51 #include <sys/mman.h> |
3630 | 52 #endif |
560 | 53 #include <sys/types.h> |
54 #include <sys/stat.h> | |
55 #include <fcntl.h> | |
56 #undef PACKAGE | |
57 #include <stdio.h> | |
3630 | 58 #ifndef _WIN32 |
800
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
59 #include <dirent.h> |
3630 | 60 #else |
61 /* We're using perl's win32 port of this */ | |
62 #define dirent direct | |
63 #endif | |
1238
78c4f497db2b
[gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1233
diff
changeset
|
64 #include <string.h> |
798
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
65 |
3395 | 66 #undef group |
590
91f877d86ca6
[gaim-migrate @ 600]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
581
diff
changeset
|
67 |
91f877d86ca6
[gaim-migrate @ 600]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
581
diff
changeset
|
68 /* perl module support */ |
4298 | 69 #ifdef OLD_PERL |
70 extern void boot_DynaLoader _((CV * cv)); | |
71 #else | |
72 extern void boot_DynaLoader _((pTHX_ CV * cv)); /* perl is so wacky */ | |
73 #endif | |
590
91f877d86ca6
[gaim-migrate @ 600]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
581
diff
changeset
|
74 |
91f877d86ca6
[gaim-migrate @ 600]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
581
diff
changeset
|
75 #undef _ |
1896
e556ffa08cce
[gaim-migrate @ 1906]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1850
diff
changeset
|
76 #ifdef DEBUG |
e556ffa08cce
[gaim-migrate @ 1906]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1850
diff
changeset
|
77 #undef DEBUG |
e556ffa08cce
[gaim-migrate @ 1906]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1850
diff
changeset
|
78 #endif |
3630 | 79 #ifdef _WIN32 |
80 #undef pipe | |
81 #endif | |
560 | 82 #include "gaim.h" |
2355
571971659533
[gaim-migrate @ 2368]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2345
diff
changeset
|
83 #include "prpl.h" |
4561 | 84 #include "sound.h" |
560 | 85 |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
86 struct perlscript { |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
87 char *name; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
88 char *version; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
89 char *shutdowncallback; /* bleh */ |
3563 | 90 struct gaim_plugin *plug; |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
91 }; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
92 |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
93 struct _perl_event_handlers { |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
94 char *event_type; |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
95 char *handler_name; |
3563 | 96 struct gaim_plugin *plug; |
781
95ebfdb31a9b
[gaim-migrate @ 791]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
780
diff
changeset
|
97 }; |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
98 |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
99 struct _perl_timeout_handlers { |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
100 char *handler_name; |
2512
bf7ec3874810
[gaim-migrate @ 2525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2511
diff
changeset
|
101 char *handler_args; |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
102 gint iotag; |
3563 | 103 struct gaim_plugin *plug; |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
104 }; |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
105 |
597
3a24fd19ff5f
[gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
106 static GList *perl_list = NULL; /* should probably extern this at some point */ |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
107 static GList *perl_timeout_handlers = NULL; |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
108 static GList *perl_event_handlers = NULL; |
560 | 109 static PerlInterpreter *my_perl = NULL; |
2329
a6d0edc31554
[gaim-migrate @ 2339]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2261
diff
changeset
|
110 static void perl_init(); |
560 | 111 |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
112 /* dealing with gaim */ |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
113 XS(XS_GAIM_register); /* set up hooks for script */ |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
114 XS(XS_GAIM_get_info); /* version, last to attempt signon, protocol */ |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
115 XS(XS_GAIM_print); /* lemme figure this one out... */ |
2261
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
116 XS(XS_GAIM_write_to_conv); /* write into conversation window */ |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
117 |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
118 /* list stuff */ |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
119 XS(XS_GAIM_buddy_list); /* all buddies */ |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
120 XS(XS_GAIM_online_list); /* online buddies */ |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
121 |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
122 /* server stuff */ |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
123 XS(XS_GAIM_command); /* send command to server */ |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
124 XS(XS_GAIM_user_info); /* given name, return struct buddy members */ |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
125 XS(XS_GAIM_print_to_conv); /* send message to someone */ |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
126 XS(XS_GAIM_print_to_chat); /* send message to chat room */ |
2261
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
127 XS(XS_GAIM_serv_send_im); /* send message to someone (but do not display) */ |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
128 |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
129 /* handler commands */ |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
130 XS(XS_GAIM_add_event_handler); /* when servers talk */ |
3456 | 131 XS(XS_GAIM_remove_event_handler); /* remove a handler */ |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
132 XS(XS_GAIM_add_timeout_handler); /* figure it out */ |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
133 |
3280 | 134 /* play sound */ |
4617 | 135 XS(XS_GAIM_play_sound); /*play a sound */ |
3280 | 136 |
4298 | 137 static void |
138 #ifdef OLD_PERL | |
139 xs_init() | |
140 #else | |
141 xs_init(pTHX) | |
142 #endif | |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
143 { |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
144 char *file = __FILE__; |
3551 | 145 |
146 /* This one allows dynamic loading of perl modules in perl | |
147 scripts by the 'use perlmod;' construction*/ | |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
148 newXS ("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); |
4298 | 149 |
3551 | 150 /* load up all the custom Gaim perl functions */ |
151 newXS ("GAIM::register", XS_GAIM_register, "GAIM"); | |
152 newXS ("GAIM::get_info", XS_GAIM_get_info, "GAIM"); | |
153 newXS ("GAIM::print", XS_GAIM_print, "GAIM"); | |
154 newXS ("GAIM::write_to_conv", XS_GAIM_write_to_conv, "GAIM"); | |
155 | |
156 newXS ("GAIM::buddy_list", XS_GAIM_buddy_list, "GAIM"); | |
157 newXS ("GAIM::online_list", XS_GAIM_online_list, "GAIM"); | |
158 | |
159 newXS ("GAIM::command", XS_GAIM_command, "GAIM"); | |
160 newXS ("GAIM::user_info", XS_GAIM_user_info, "GAIM"); | |
161 newXS ("GAIM::print_to_conv", XS_GAIM_print_to_conv, "GAIM"); | |
162 newXS ("GAIM::print_to_chat", XS_GAIM_print_to_chat, "GAIM"); | |
163 newXS ("GAIM::serv_send_im", XS_GAIM_serv_send_im, "GAIM"); | |
164 | |
165 newXS ("GAIM::add_event_handler", XS_GAIM_add_event_handler, "GAIM"); | |
166 newXS ("GAIM::remove_event_handler", XS_GAIM_remove_event_handler, "GAIM"); | |
167 newXS ("GAIM::add_timeout_handler", XS_GAIM_add_timeout_handler, "GAIM"); | |
168 | |
169 newXS ("GAIM::play_sound", XS_GAIM_play_sound, "GAIM"); | |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
170 } |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
171 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
172 static char *escape_quotes(char *buf) |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
173 { |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
174 static char *tmp_buf = NULL; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
175 char *i, *j; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
176 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
177 if (tmp_buf) |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
178 g_free(tmp_buf); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
179 tmp_buf = g_malloc(strlen(buf) * 2 + 1); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
180 for (i = buf, j = tmp_buf; *i; i++, j++) { |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
181 if (*i == '\'' || *i == '\\') |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
182 *j++ = '\\'; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
183 *j = *i; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
184 } |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
185 *j = '\0'; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
186 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
187 return (tmp_buf); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
188 } |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
189 |
3551 | 190 /* |
4617 | 191 2003/02/06: execute_perl modified by Mark Doliner <mark@kingant.net> |
192 Pass parameters by pushing them onto the stack rather than | |
193 passing an array of strings. This way, perl scripts can | |
194 modify the parameters and we can get the changed values | |
195 and then shoot ourselves. I mean, uh, use them. | |
196 | |
3551 | 197 2001/06/14: execute_perl replaced by Martin Persson <mep@passagen.se> |
4617 | 198 previous use of perl_eval leaked memory, replaced with |
199 a version that uses perl_call instead | |
4029 | 200 |
4617 | 201 30/11/2002: execute_perl modified by Eric Timme <timothy@voidnet.com> |
202 args changed to char** so that we can have preparsed | |
203 arguments again, and many headaches ensued! This essentially | |
204 means we replaced one hacked method with a messier hacked | |
205 method out of perceived necessity. Formerly execute_perl | |
206 required a single char_ptr, and it would insert it into an | |
207 array of character pointers and NULL terminate the new array. | |
208 Now we have to pass in pre-terminated character pointer arrays | |
209 to accomodate functions that want to pass in multiple arguments. | |
4029 | 210 |
4617 | 211 Previously arguments were preparsed because an argument list |
212 was constructed in the form 'arg one','arg two' and was | |
213 executed via a call like &funcname(arglist) (see .59.x), so | |
214 the arglist was magically pre-parsed because of the method. | |
215 With Martin Persson's change to perl_call we now need to | |
216 use a null terminated list of character pointers for arguments | |
217 if we wish them to be parsed. Lacking a better way to allow | |
218 for both single arguments and many I created a NULL terminated | |
219 array in every function that called execute_perl and passed | |
220 that list into the function. In the former version a single | |
221 character pointer was passed in, and was placed into an array | |
222 of character pointers with two elements, with a NULL element | |
223 tacked onto the back, but this method no longer seemed prudent. | |
224 | |
225 Enhancements in the future might be to get rid of pre-declaring | |
226 the array sizes? I am not comfortable enough with this | |
227 subject to attempt it myself and hope it to stand the test | |
228 of time. | |
3551 | 229 */ |
230 | |
231 static int | |
4029 | 232 execute_perl(char *function, char **args) |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
233 { |
4617 | 234 int count, i, ret_value = 1; |
235 SV *sv_args[5]; | |
236 STRLEN na; | |
3551 | 237 |
4617 | 238 /* |
239 * Set up the perl environment, push arguments onto the | |
240 * perl stack, then call the given function | |
241 */ | |
3551 | 242 dSP; |
4617 | 243 ENTER; |
244 SAVETMPS; | |
245 PUSHMARK(sp); | |
246 for (i=0; i<5; i++) | |
247 if (args[i]) { | |
248 sv_args[i] = sv_2mortal(newSVpv(args[i], 0)); | |
249 XPUSHs(sv_args[i]); | |
250 } | |
251 PUTBACK; | |
252 count = call_pv(function, G_EVAL | G_SCALAR); | |
253 SPAGAIN; | |
3551 | 254 |
4617 | 255 /* Check for "die," make sure we have 1 argument, and set our return value */ |
256 if (SvTRUE(ERRSV)) { | |
257 debug_printf("Perl function %s exited abnormally: %s\n", function, SvPV(ERRSV, na)); | |
258 POPs; | |
259 } else if (count != 1) { | |
260 /* This should NEVER happen. G_SCALAR ensures that we WILL have 1 parameter */ | |
261 debug_printf("Perl error from %s: expected 1 return value, but got %d\n", function, count); | |
262 } else { | |
263 ret_value = POPi; | |
264 } | |
3551 | 265 |
4617 | 266 /* Check for changed arguments */ |
267 for (i=0; i<5; i++) | |
268 if (args[i] && strcmp(args[i], SvPVX(sv_args[i]))) { | |
269 /* | |
270 * Shizzel. So the perl script changed one of the parameters, and we want | |
271 * this change to affect the original parameters. args[i] is just a tempory | |
272 * little list of pointers. We don't want to free args[i] here because the | |
273 * new parameter doesn't overwrite the data that args[i] points to. That is | |
274 * done by the function that called execute_perl. I'm not explaining this | |
275 * very well. See, it's aggregate... Oh, but if 2 perl scripts both modify | |
276 * the data, _that's_ a memleak. This is really kind of hackish. I should | |
277 * fix it. Look how long this comment is. Holy crap. | |
278 */ | |
279 args[i] = g_strdup(SvPV(sv_args[i], na)); | |
280 } | |
3551 | 281 |
4617 | 282 PUTBACK; |
283 FREETMPS; | |
284 LEAVE; | |
3551 | 285 |
4617 | 286 return ret_value; |
3551 | 287 } |
288 | |
289 void perl_unload_file(struct gaim_plugin *plug) { | |
4617 | 290 char *atmp[1] = { "" }; |
3551 | 291 struct perlscript *scp = NULL; |
292 struct _perl_timeout_handlers *thn; | |
293 struct _perl_event_handlers *ehn; | |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
294 |
3551 | 295 GList *pl = perl_list; |
296 | |
4298 | 297 debug_printf("Unloading %s\n", plug->path); |
3551 | 298 while (pl) { |
299 scp = pl->data; | |
3563 | 300 if (scp->plug == plug) { |
301 perl_list = g_list_remove(perl_list, scp); | |
302 if (scp->shutdowncallback[0]) | |
4029 | 303 execute_perl(scp->shutdowncallback, atmp); |
3563 | 304 g_free(scp->name); |
305 g_free(scp->version); | |
306 g_free(scp->shutdowncallback); | |
307 g_free(scp); | |
3551 | 308 break; |
3563 | 309 } |
4088 | 310 pl = pl->next; |
3551 | 311 } |
312 | |
313 pl = perl_timeout_handlers; | |
314 while (pl) { | |
315 thn = pl->data; | |
3563 | 316 if (thn && thn->plug == plug) { |
317 perl_timeout_handlers = g_list_remove(perl_timeout_handlers, thn); | |
3551 | 318 g_source_remove(thn->iotag); |
319 g_free(thn->handler_args); | |
320 g_free(thn->handler_name); | |
321 g_free(thn); | |
322 } | |
323 pl = pl->next; | |
324 } | |
325 | |
326 pl = perl_event_handlers; | |
327 while (pl) { | |
328 ehn = pl->data; | |
3563 | 329 if (ehn && ehn->plug == plug) { |
3551 | 330 perl_event_handlers = g_list_remove(perl_event_handlers, ehn); |
331 g_free(ehn->event_type); | |
332 g_free(ehn->handler_name); | |
333 g_free(ehn); | |
334 } | |
335 pl = pl->next; | |
336 } | |
337 | |
4617 | 338 plug->handle = NULL; |
3563 | 339 plugins = g_list_remove(plugins, plug); |
340 save_prefs(); | |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
341 } |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
342 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
343 int perl_load_file(char *script_name) |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
344 { |
4617 | 345 char *atmp[1] = { script_name }; |
4298 | 346 struct gaim_plugin *plug = NULL; |
3551 | 347 GList *p = probed_plugins; |
3563 | 348 GList *s; |
349 struct perlscript *scp; | |
350 int ret; | |
3551 | 351 |
2329
a6d0edc31554
[gaim-migrate @ 2339]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2261
diff
changeset
|
352 if (my_perl == NULL) |
a6d0edc31554
[gaim-migrate @ 2339]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2261
diff
changeset
|
353 perl_init(); |
3551 | 354 |
355 while (p) { | |
356 plug = (struct gaim_plugin *)p->data; | |
357 if (!strcmp(script_name, plug->path)) | |
358 break; | |
359 p = p->next; | |
360 } | |
361 | |
362 if (!plug) { | |
363 probe_perl(script_name); | |
364 } | |
3563 | 365 |
3551 | 366 plug->handle = plug->path; |
3563 | 367 plugins = g_list_append(plugins, plug); |
560 | 368 |
4029 | 369 ret = execute_perl("load_n_eval", atmp); |
3551 | 370 |
3563 | 371 s = perl_list; |
372 while (s) { | |
373 scp = s->data; | |
374 | |
375 if (!strcmp(scp->name, plug->desc.name) && | |
376 !strcmp(scp->version, plug->desc.version)) | |
377 break; | |
378 s = s->next; | |
3551 | 379 } |
380 | |
3563 | 381 if (!s) { |
382 g_snprintf(plug->error, sizeof(plug->error), _("GAIM::register not called with proper arguments. Consult PERL-HOWTO.")); | |
383 return 0; | |
3551 | 384 } |
3563 | 385 |
386 plug->error[0] = '\0'; | |
3551 | 387 return ret; |
800
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
388 } |
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
389 |
4298 | 390 struct gaim_plugin *probe_perl(char *filename) { |
3551 | 391 |
392 /* XXX This woulld be much faster if I didn't create a new | |
3563 | 393 * PerlInterpreter every time I probed a plugin */ |
800
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
394 |
3551 | 395 PerlInterpreter *prober = perl_alloc(); |
396 struct gaim_plugin * plug = NULL; | |
397 char *argv[] = {"", filename}; | |
398 int count; | |
399 perl_construct(prober); | |
400 perl_parse(prober, NULL, 2, argv, NULL); | |
401 | |
402 { | |
403 dSP; | |
404 ENTER; | |
405 SAVETMPS; | |
406 PUSHMARK(SP); | |
3556 | 407 |
408 count = perl_call_pv("description", G_NOARGS | G_ARRAY | G_EVAL); | |
3551 | 409 SPAGAIN; |
3556 | 410 if (count == (sizeof(struct gaim_plugin_description) - sizeof(int)) / sizeof(char*)) { |
3551 | 411 plug = g_new0(struct gaim_plugin, 1); |
412 plug->type = perl_script; | |
413 g_snprintf(plug->path, sizeof(plug->path), filename); | |
414 plug->desc.iconfile = g_strdup(POPp); | |
415 plug->desc.url = g_strdup(POPp); | |
416 plug->desc.authors = g_strdup(POPp); | |
417 plug->desc.description = g_strdup(POPp); | |
418 plug->desc.version = g_strdup(POPp); | |
419 plug->desc.name = g_strdup(POPp); | |
800
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
420 } |
3551 | 421 |
422 PUTBACK; | |
423 FREETMPS; | |
424 LEAVE; | |
800
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
425 } |
3551 | 426 perl_destruct(prober); |
427 perl_free(prober); | |
428 return plug; | |
800
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
429 } |
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
430 |
2329
a6d0edc31554
[gaim-migrate @ 2339]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2261
diff
changeset
|
431 static void perl_init() |
4617 | 432 { /* changed the name of the variable from load_file to |
3551 | 433 perl_definitions since now it does much more than defining |
434 the load_file sub. Moreover, deplaced the initialisation to | |
435 the xs_init function. (TheHobbit)*/ | |
4617 | 436 char *perl_args[] = { "", "-e", "0", "-w" }; |
437 char perl_definitions[] = | |
438 { | |
3551 | 439 /* We use to function one to load a file the other to |
440 execute the string obtained from the first and holding | |
441 the file conents. This allows to have a realy local $/ | |
442 without introducing temp variables to hold the old | |
443 value. Just a question of style:) */ | |
444 "sub load_file{" | |
445 "my $f_name=shift;" | |
446 "local $/=undef;" | |
447 "open FH,$f_name or return \"__FAILED__\";" | |
448 "$_=<FH>;" | |
449 "close FH;" | |
450 "return $_;" | |
451 "}" | |
452 "sub load_n_eval{" | |
453 "my $f_name=shift;" | |
454 "my $strin=load_file($f_name);" | |
455 "return 2 if($strin eq \"__FAILED__\");" | |
456 "eval $strin;" | |
457 "if($@){" | |
458 /*" #something went wrong\n"*/ | |
4050 | 459 "GAIM::print(\"Errors loading file $f_name:\\n\",\"$@\");" |
3551 | 460 "return 1;" |
461 "}" | |
462 "return 0;" | |
463 "}" | |
464 }; | |
560 | 465 |
466 my_perl = perl_alloc(); | |
467 perl_construct(my_perl); | |
3551 | 468 #ifdef DEBUG |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
469 perl_parse(my_perl, xs_init, 4, perl_args, NULL); |
3551 | 470 #else |
471 perl_parse(my_perl, xs_init, 3, perl_args, NULL); | |
472 #endif | |
4050 | 473 #ifdef HAVE_PERL_EVAL_PV |
3551 | 474 eval_pv(perl_definitions, TRUE); |
560 | 475 #else |
3551 | 476 perl_eval_pv(perl_definitions, TRUE); /* deprecated */ |
560 | 477 #endif |
478 | |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
479 |
560 | 480 } |
481 | |
482 void perl_end() | |
483 { | |
4617 | 484 char *atmp[1] = { "" }; |
565
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
485 struct perlscript *scp; |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
486 struct _perl_timeout_handlers *thn; |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
487 struct _perl_event_handlers *ehn; |
565
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
488 |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
489 while (perl_list) { |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
490 scp = perl_list->data; |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
491 perl_list = g_list_remove(perl_list, scp); |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
492 if (scp->shutdowncallback[0]) |
4029 | 493 execute_perl(scp->shutdowncallback, atmp); |
565
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
494 g_free(scp->name); |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
495 g_free(scp->version); |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
496 g_free(scp->shutdowncallback); |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
497 g_free(scp); |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
498 } |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
499 |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
500 while (perl_timeout_handlers) { |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
501 thn = perl_timeout_handlers->data; |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
502 perl_timeout_handlers = g_list_remove(perl_timeout_handlers, thn); |
2370
25e7c2a68ed2
[gaim-migrate @ 2383]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2355
diff
changeset
|
503 g_source_remove(thn->iotag); |
2512
bf7ec3874810
[gaim-migrate @ 2525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2511
diff
changeset
|
504 g_free(thn->handler_args); |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
505 g_free(thn->handler_name); |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
506 g_free(thn); |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
507 } |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
508 |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
509 while (perl_event_handlers) { |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
510 ehn = perl_event_handlers->data; |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
511 perl_event_handlers = g_list_remove(perl_event_handlers, ehn); |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
512 g_free(ehn->event_type); |
3551 | 513 debug_printf("handler_name: %s\n", ehn->handler_name); |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
514 g_free(ehn->handler_name); |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
515 g_free(ehn); |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
516 } |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
517 |
560 | 518 if (my_perl != NULL) { |
519 perl_destruct(my_perl); | |
520 perl_free(my_perl); | |
521 my_perl = NULL; | |
522 } | |
523 } | |
524 | |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
525 XS (XS_GAIM_register) |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
526 { |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
527 char *name, *ver, *callback, *unused; /* exactly like X-Chat, eh? :) */ |
2048
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1949
diff
changeset
|
528 unsigned int junk; |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
529 struct perlscript *scp; |
4298 | 530 struct gaim_plugin *plug = NULL; |
3563 | 531 GList *pl = plugins; |
4298 | 532 |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
533 dXSARGS; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
534 items = 0; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
535 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
536 name = SvPV (ST (0), junk); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
537 ver = SvPV (ST (1), junk); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
538 callback = SvPV (ST (2), junk); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
539 unused = SvPV (ST (3), junk); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
540 |
3563 | 541 while (pl) { |
542 plug = pl->data; | |
543 | |
544 if (!strcmp(name, plug->desc.name) && | |
545 !strcmp(ver, plug->desc.version)) { | |
546 break; | |
547 } | |
548 pl = pl->next; | |
549 } | |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
550 |
3563 | 551 if (plug) { |
552 scp = g_new0(struct perlscript, 1); | |
553 scp->name = g_strdup(name); | |
554 scp->version = g_strdup(ver); | |
555 scp->shutdowncallback = g_strdup(callback); | |
556 scp->plug = plug; | |
557 perl_list = g_list_append(perl_list, scp); | |
558 } | |
559 XST_mPV (0, plug->path); | |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
560 XSRETURN (1); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
561 } |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
562 |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
563 XS (XS_GAIM_get_info) |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
564 { |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
565 int i = 0; |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
566 dXSARGS; |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
567 items = 0; |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
568 |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
569 switch(SvIV(ST(0))) { |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
570 case 0: |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
571 XST_mPV(0, VERSION); |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
572 i = 1; |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
573 break; |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
574 case 1: |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
575 { |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
576 GSList *c = connections; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
577 struct gaim_connection *gc; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
578 |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
579 while (c) { |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
580 gc = (struct gaim_connection *)c->data; |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
581 XST_mIV(i++, (guint)gc); |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
582 c = c->next; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
583 } |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
584 } |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
585 break; |
591
a26eb4c472d8
[gaim-migrate @ 601]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
590
diff
changeset
|
586 case 2: |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
587 { |
2355
571971659533
[gaim-migrate @ 2368]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2345
diff
changeset
|
588 struct gaim_connection *gc = (struct gaim_connection *)SvIV(ST(1)); |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
589 if (g_slist_find(connections, gc)) |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
590 XST_mIV(i++, gc->protocol); |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
591 else |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
592 XST_mIV(i++, -1); |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
593 } |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
594 break; |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
595 case 3: |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
596 { |
2355
571971659533
[gaim-migrate @ 2368]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2345
diff
changeset
|
597 struct gaim_connection *gc = (struct gaim_connection *)SvIV(ST(1)); |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
598 if (g_slist_find(connections, gc)) |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
599 XST_mPV(i++, gc->username); |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
600 else |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
601 XST_mPV(i++, ""); |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
602 } |
2355
571971659533
[gaim-migrate @ 2368]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2345
diff
changeset
|
603 break; |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
604 case 4: |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
605 { |
2355
571971659533
[gaim-migrate @ 2368]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2345
diff
changeset
|
606 struct gaim_connection *gc = (struct gaim_connection *)SvIV(ST(1)); |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
607 if (g_slist_find(connections, gc)) |
4491 | 608 XST_mIV(i++, g_slist_index(gaim_accounts, gc->account)); |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
609 else |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
610 XST_mIV(i++, -1); |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
611 } |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
612 break; |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
613 case 5: |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
614 { |
4491 | 615 GSList *a = gaim_accounts; |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
616 while (a) { |
4491 | 617 struct gaim_account *account = a->data; |
618 XST_mPV(i++, account->username); | |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
619 a = a->next; |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
620 } |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
621 } |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
622 break; |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
623 case 6: |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
624 { |
4491 | 625 GSList *a = gaim_accounts; |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
626 while (a) { |
4491 | 627 struct gaim_account *account = a->data; |
628 XST_mIV(i++, account->protocol); | |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
629 a = a->next; |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
630 } |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
631 } |
591
a26eb4c472d8
[gaim-migrate @ 601]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
590
diff
changeset
|
632 break; |
2355
571971659533
[gaim-migrate @ 2368]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2345
diff
changeset
|
633 case 7: |
571971659533
[gaim-migrate @ 2368]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2345
diff
changeset
|
634 { |
571971659533
[gaim-migrate @ 2368]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2345
diff
changeset
|
635 struct gaim_connection *gc = (struct gaim_connection *)SvIV(ST(1)); |
571971659533
[gaim-migrate @ 2368]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2345
diff
changeset
|
636 if (g_slist_find(connections, gc)) |
3572 | 637 XST_mPV(i++, gc->prpl->name); |
2355
571971659533
[gaim-migrate @ 2368]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2345
diff
changeset
|
638 else |
571971659533
[gaim-migrate @ 2368]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2345
diff
changeset
|
639 XST_mPV(i++, "Unknown"); |
571971659533
[gaim-migrate @ 2368]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2345
diff
changeset
|
640 } |
571971659533
[gaim-migrate @ 2368]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2345
diff
changeset
|
641 break; |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
642 default: |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
643 XST_mPV(0, "Error2"); |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
644 i = 1; |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
645 } |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
646 |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
647 XSRETURN(i); |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
648 } |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
649 |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
650 XS (XS_GAIM_print) |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
651 { |
592
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
591
diff
changeset
|
652 char *title; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
591
diff
changeset
|
653 char *message; |
2048
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1949
diff
changeset
|
654 unsigned int junk; |
592
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
591
diff
changeset
|
655 dXSARGS; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
591
diff
changeset
|
656 items = 0; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
591
diff
changeset
|
657 |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
591
diff
changeset
|
658 title = SvPV(ST(0), junk); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
591
diff
changeset
|
659 message = SvPV(ST(1), junk); |
3551 | 660 do_error_dialog(title, message, GAIM_INFO); |
592
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
591
diff
changeset
|
661 XSRETURN(0); |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
662 } |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
663 |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
664 XS (XS_GAIM_buddy_list) |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
665 { |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
666 struct gaim_connection *gc; |
581
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
667 struct buddy *buddy; |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
668 struct group *g; |
4349 | 669 GSList *list = groups; |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
670 GSList *mem; |
581
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
671 int i = 0; |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
672 dXSARGS; |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
673 items = 0; |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
674 |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
675 gc = (struct gaim_connection *)SvIV(ST(0)); |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
676 |
581
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
677 while (list) { |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
678 g = (struct group *)list->data; |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
679 mem = g->members; |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
680 while (mem) { |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
681 buddy = (struct buddy *)mem->data; |
4491 | 682 if(buddy->account == gc->account) |
4349 | 683 XST_mPV(i++, buddy->name); |
581
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
684 mem = mem->next; |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
685 } |
940 | 686 list = g_slist_next(list); |
581
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
687 } |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
688 XSRETURN(i); |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
689 } |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
690 |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
691 XS (XS_GAIM_online_list) |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
692 { |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
693 struct gaim_connection *gc; |
581
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
694 struct buddy *b; |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
695 struct group *g; |
4349 | 696 GSList *list = groups; |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
697 GSList *mem; |
581
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
698 int i = 0; |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
699 dXSARGS; |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
700 items = 0; |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
701 |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
702 gc = (struct gaim_connection *)SvIV(ST(0)); |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
703 |
581
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
704 while (list) { |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
705 g = (struct group *)list->data; |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
706 mem = g->members; |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
707 while (mem) { |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
708 b = (struct buddy *)mem->data; |
4491 | 709 if (b->account == gc->account && b->present) XST_mPV(i++, b->name); |
581
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
710 mem = mem->next; |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
711 } |
940 | 712 list = g_slist_next(list); |
581
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
713 } |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
714 XSRETURN(i); |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
715 } |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
716 |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
717 XS (XS_GAIM_command) |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
718 { |
2048
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1949
diff
changeset
|
719 unsigned int junk; |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
720 char *command = NULL; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
721 dXSARGS; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
722 items = 0; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
723 |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
724 command = SvPV(ST(0), junk); |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
725 if (!command) XSRETURN(0); |
4617 | 726 if (!strncasecmp(command, "signon", 6)) { |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
727 int index = SvIV(ST(1)); |
4491 | 728 if (g_slist_nth_data(gaim_accounts, index)) |
729 serv_login(g_slist_nth_data(gaim_accounts, index)); | |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
730 } else if (!strncasecmp(command, "signoff", 7)) { |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
731 struct gaim_connection *gc = (struct gaim_connection *)SvIV(ST(1)); |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
732 if (g_slist_find(connections, gc)) signoff(gc); |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
733 else signoff_all(NULL, NULL); |
1730
2d7601acacdd
[gaim-migrate @ 1740]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
734 } else if (!strncasecmp(command, "info", 4)) { |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
735 struct gaim_connection *gc = (struct gaim_connection *)SvIV(ST(1)); |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
736 if (g_slist_find(connections, gc)) |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
737 serv_set_info(gc, SvPV(ST(2), junk)); |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
738 } else if (!strncasecmp(command, "away", 4)) { |
630
3d2f14064083
[gaim-migrate @ 640]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
628
diff
changeset
|
739 char *message = SvPV(ST(1), junk); |
1106
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1101
diff
changeset
|
740 static struct away_message a; |
630
3d2f14064083
[gaim-migrate @ 640]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
628
diff
changeset
|
741 g_snprintf(a.message, sizeof(a.message), "%s", message); |
3d2f14064083
[gaim-migrate @ 640]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
628
diff
changeset
|
742 do_away_message(NULL, &a); |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
743 } else if (!strncasecmp(command, "back", 4)) { |
628
a46a68d46d2b
[gaim-migrate @ 638]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
603
diff
changeset
|
744 do_im_back(); |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
745 } else if (!strncasecmp(command, "idle", 4)) { |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
746 GSList *c = connections; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
747 struct gaim_connection *gc; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
748 |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
749 while (c) { |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
750 gc = (struct gaim_connection *)c->data; |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
751 serv_set_idle(gc, SvIV(ST(1))); |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
752 c = c->next; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
753 } |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
754 } else if (!strncasecmp(command, "warn", 4)) { |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
755 GSList *c = connections; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
756 struct gaim_connection *gc; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
757 |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
758 while (c) { |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
759 gc = (struct gaim_connection *)c->data; |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
760 serv_warn(gc, SvPV(ST(1), junk), SvIV(ST(2))); |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
761 c = c->next; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
762 } |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
763 } |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
764 |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
765 XSRETURN(0); |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
766 } |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
767 |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
768 XS (XS_GAIM_user_info) |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
769 { |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
770 struct gaim_connection *gc; |
2048
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1949
diff
changeset
|
771 unsigned int junk; |
1114
c61f9c384413
[gaim-migrate @ 1124]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1106
diff
changeset
|
772 struct buddy *buddy = NULL; |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
773 dXSARGS; |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
774 items = 0; |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
775 |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
776 gc = (struct gaim_connection *)SvIV(ST(0)); |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
777 if (g_slist_find(connections, gc)) |
4687 | 778 buddy = gaim_find_buddy(gc->account, SvPV(ST(1), junk)); |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
779 |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
780 if (!buddy) |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
781 XSRETURN(0); |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
782 XST_mPV(0, buddy->name); |
4687 | 783 XST_mPV(1, gaim_get_buddy_alias(buddy)); |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
784 XST_mPV(2, buddy->present ? "Online" : "Offline"); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
785 XST_mIV(3, buddy->evil); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
786 XST_mIV(4, buddy->signon); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
787 XST_mIV(5, buddy->idle); |
4687 | 788 XSRETURN(6); |
597
3a24fd19ff5f
[gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
789 } |
3a24fd19ff5f
[gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
790 |
2261
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
791 XS (XS_GAIM_write_to_conv) |
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
792 { |
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
793 char *nick, *who, *what; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
794 struct gaim_conversation *c; |
2261
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
795 int junk; |
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
796 int send, wflags; |
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
797 dXSARGS; |
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
798 items = 0; |
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
799 |
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
800 nick = SvPV(ST(0), junk); |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
801 send = SvIV(ST(1)); |
2261
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
802 what = SvPV(ST(2), junk); |
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
803 who = SvPV(ST(3), junk); |
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
804 |
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
805 if (!*who) who=NULL; |
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
806 |
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
807 switch (send) { |
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
808 case 0: wflags=WFLAG_SEND; break; |
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
809 case 1: wflags=WFLAG_RECV; break; |
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
810 case 2: wflags=WFLAG_SYSTEM; break; |
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
811 default: wflags=WFLAG_RECV; |
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
812 } |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4432
diff
changeset
|
813 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
814 c = gaim_find_conversation(nick); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
815 |
2261
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
816 if (!c) |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4432
diff
changeset
|
817 c = gaim_conversation_new(GAIM_CONV_IM, NULL, nick); |
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4432
diff
changeset
|
818 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
819 gaim_conversation_write(c, who, what, -1, wflags, time(NULL)); |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
820 XSRETURN(0); |
2261
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
821 } |
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
822 |
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
823 XS (XS_GAIM_serv_send_im) |
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
824 { |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
825 struct gaim_connection *gc; |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
826 char *nick, *what; |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
827 int isauto; |
2261
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
828 int junk; |
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
829 dXSARGS; |
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
830 items = 0; |
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
831 |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
832 gc = (struct gaim_connection *)SvIV(ST(0)); |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
833 nick = SvPV(ST(1), junk); |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
834 what = SvPV(ST(2), junk); |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
835 isauto = SvIV(ST(3)); |
2261
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
836 |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
837 if (!g_slist_find(connections, gc)) { |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
838 XSRETURN(0); |
2261
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
839 return; |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
840 } |
3033 | 841 serv_send_im(gc, nick, what, -1, isauto); |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
842 XSRETURN(0); |
2261
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
843 } |
e243bf60f2d6
[gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
844 |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
845 XS (XS_GAIM_print_to_conv) |
597
3a24fd19ff5f
[gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
846 { |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
847 struct gaim_connection *gc; |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
848 char *nick, *what; |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
849 int isauto; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
850 struct gaim_conversation *c; |
2048
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1949
diff
changeset
|
851 unsigned int junk; |
597
3a24fd19ff5f
[gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
852 dXSARGS; |
3a24fd19ff5f
[gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
853 items = 0; |
3a24fd19ff5f
[gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
854 |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
855 gc = (struct gaim_connection *)SvIV(ST(0)); |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
856 nick = SvPV(ST(1), junk); |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
857 what = SvPV(ST(2), junk); |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
858 isauto = SvIV(ST(3)); |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
859 if (!g_slist_find(connections, gc)) { |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
860 XSRETURN(0); |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
861 return; |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
862 } |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4432
diff
changeset
|
863 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
864 c = gaim_find_conversation(nick); |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4432
diff
changeset
|
865 |
597
3a24fd19ff5f
[gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
866 if (!c) |
4491 | 867 c = gaim_conversation_new(GAIM_CONV_IM, gc->account, nick); |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4432
diff
changeset
|
868 else |
4491 | 869 gaim_conversation_set_account(c, gc->account); |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4432
diff
changeset
|
870 |
4617 | 871 gaim_conversation_write(c, NULL, what, -1, |
872 (WFLAG_SEND | (isauto ? WFLAG_AUTO : 0)), time(NULL)); | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
873 serv_send_im(gc, nick, what, -1, isauto ? IM_FLAG_AWAY : 0); |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
874 XSRETURN(0); |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
875 } |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
876 |
3280 | 877 |
878 | |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
879 XS (XS_GAIM_print_to_chat) |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
880 { |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
881 struct gaim_connection *gc; |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
882 int id; |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
883 char *what; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
884 struct gaim_conversation *b = NULL; |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
885 GSList *bcs; |
2048
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1949
diff
changeset
|
886 unsigned int junk; |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
887 dXSARGS; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
888 items = 0; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
889 |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
890 gc = (struct gaim_connection *)SvIV(ST(0)); |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
891 id = SvIV(ST(1)); |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
892 what = SvPV(ST(2), junk); |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
893 |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
894 if (!g_slist_find(connections, gc)) { |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
895 XSRETURN(0); |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
896 return; |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
897 } |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
898 bcs = gc->buddy_chats; |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
899 while (bcs) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
900 b = (struct gaim_conversation *)bcs->data; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
901 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
902 if (gaim_chat_get_id(gaim_conversation_get_chat_data(b)) == id) |
2345
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
903 break; |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
904 bcs = bcs->next; |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
905 b = NULL; |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
906 } |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
907 if (b) |
a49e8f1afbc4
[gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2329
diff
changeset
|
908 serv_chat_send(gc, id, what); |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
909 XSRETURN(0); |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
910 } |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
911 |
3517 | 912 int perl_event(enum gaim_event event, void *arg1, void *arg2, void *arg3, void *arg4, void *arg5) |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
913 { |
4617 | 914 char *buf[5] = { NULL, NULL, NULL, NULL, NULL }; /* Maximum of 5 args */ |
915 char tmpbuf1[16], tmpbuf2[16], tmpbuf3[1]; | |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
916 GList *handler; |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
917 struct _perl_event_handlers *data; |
4298 | 918 int handler_return; |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
919 |
4617 | 920 tmpbuf1[0] = '\0'; |
921 tmpbuf2[0] = '\0'; | |
922 tmpbuf3[0] = '\0'; | |
923 | |
924 /* Make a pretty array of char*'s with which to call perl functions */ | |
2511
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
925 switch (event) { |
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
926 case event_signon: |
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
927 case event_signoff: |
4617 | 928 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1); |
929 buf[0] = tmpbuf1; | |
2511
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
930 break; |
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
931 case event_away: |
4617 | 932 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1); |
933 buf[0] = tmpbuf1; | |
934 buf[1] = ((struct gaim_connection *)arg1)->away ? | |
935 ((struct gaim_connection *)arg1)->away : tmpbuf2; | |
2511
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
936 break; |
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
937 case event_im_recv: |
4658 | 938 if (!*(char**)arg2 || !*(char**)arg3) return 1; |
4617 | 939 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1); |
940 buf[0] = tmpbuf1; | |
4658 | 941 buf[1] = *(char **)arg2; |
942 buf[2] = *(char **)arg3; | |
2511
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
943 break; |
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
944 case event_im_send: |
4658 | 945 if (!*(char**)arg3) return 1; |
4617 | 946 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1); |
947 buf[0] = tmpbuf1; | |
948 buf[1] = arg2 ? arg2 : tmpbuf3; | |
4658 | 949 buf[2] = *(char **)arg3; |
2511
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
950 break; |
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
951 case event_buddy_signon: |
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
952 case event_buddy_signoff: |
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
953 case event_set_info: |
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
954 case event_buddy_away: |
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
955 case event_buddy_back: |
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
956 case event_buddy_idle: |
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
957 case event_buddy_unidle: |
4432 | 958 case event_got_typing: |
4617 | 959 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1); |
960 buf[0] = tmpbuf1; | |
961 buf[1] = arg2; | |
2511
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
962 break; |
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
963 case event_chat_invited: |
4617 | 964 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1); |
965 buf[0] = tmpbuf1; | |
966 buf[1] = arg2; | |
967 buf[2] = arg3; | |
968 buf[3] = arg4; | |
2511
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
969 break; |
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
970 case event_chat_join: |
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
971 case event_chat_buddy_join: |
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
972 case event_chat_buddy_leave: |
4617 | 973 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1); |
974 buf[0] = tmpbuf1; | |
975 g_snprintf(tmpbuf2, 16, "%d", (int)arg2); | |
976 buf[1] = tmpbuf2; | |
977 buf[2] = arg3; | |
2511
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
978 break; |
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
979 case event_chat_leave: |
4617 | 980 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1); |
981 buf[0] = tmpbuf1; | |
982 g_snprintf(tmpbuf2, 16, "%d", (int)arg2); | |
983 buf[1] = tmpbuf2; | |
2511
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
984 break; |
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
985 case event_chat_recv: |
4658 | 986 if (!*(char**)arg3 || !*(char**)arg4) return 1; |
4617 | 987 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1); |
988 buf[0] = tmpbuf1; | |
989 g_snprintf(tmpbuf2, 16, "%d", (int)arg2); | |
990 buf[1] = tmpbuf2; | |
991 buf[2] = *(char **)arg3; | |
4658 | 992 buf[3] = *(char **)arg4; |
2511
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
993 break; |
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
994 case event_chat_send_invite: |
4658 | 995 if (!*(char**)arg4) return 1; |
4617 | 996 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1); |
997 buf[0] = tmpbuf1; | |
998 g_snprintf(tmpbuf2, 16, "%d", (int)arg2); | |
999 buf[1] = tmpbuf2; | |
1000 buf[2] = arg3; | |
4658 | 1001 buf[3] = *(char **)arg4; |
2511
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
1002 break; |
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
1003 case event_chat_send: |
4658 | 1004 if (!*(char**)arg3) return 1; |
4617 | 1005 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1); |
1006 buf[0] = tmpbuf1; | |
1007 g_snprintf(tmpbuf2, 16, "%d", (int)arg2); | |
1008 buf[1] = tmpbuf2; | |
4658 | 1009 buf[2] = *(char **)arg3; |
2511
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
1010 break; |
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
1011 case event_warned: |
4617 | 1012 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1); |
1013 buf[0] = tmpbuf1; | |
1014 buf[1] = arg2 ? arg2 : tmpbuf3; | |
1015 g_snprintf(tmpbuf2, 16, "%d", (int)arg3); | |
1016 buf[2] = tmpbuf2; | |
2511
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
1017 break; |
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
1018 case event_quit: |
3517 | 1019 case event_blist_update: |
4617 | 1020 buf[0] = tmpbuf3; |
2511
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
1021 break; |
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
1022 case event_new_conversation: |
3510 | 1023 case event_del_conversation: |
4617 | 1024 buf[0] = arg1; |
2511
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
1025 break; |
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
1026 case event_im_displayed_sent: |
4658 | 1027 if (!*(char**)arg3) return 1; |
4617 | 1028 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1); |
1029 buf[0] = tmpbuf1; | |
1030 buf[1] = arg2; | |
4658 | 1031 buf[2] = *(char **)arg3; |
2511
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
1032 break; |
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
1033 case event_im_displayed_rcvd: |
4617 | 1034 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1); |
1035 buf[0] = tmpbuf1; | |
1036 buf[1] = arg2; | |
1037 buf[2] = arg3 ? arg3 : tmpbuf3; | |
2511
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
1038 break; |
3517 | 1039 case event_draw_menu: |
1040 /* we can't handle this usefully without gtk/perl bindings */ | |
1041 return 0; | |
2511
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
1042 default: |
3510 | 1043 debug_printf("someone forgot to handle %s in the perl binding\n", event_name(event)); |
2511
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
1044 return 0; |
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
1045 } |
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
1046 |
4617 | 1047 /* Call any applicable functions */ |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
1048 for (handler = perl_event_handlers; handler != NULL; handler = handler->next) { |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
1049 data = handler->data; |
2511
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
1050 if (!strcmp(event_name(event), data->event_type)) { |
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
1051 handler_return = execute_perl(data->handler_name, buf); |
3573 | 1052 if (handler_return) { |
1053 return handler_return; | |
2511
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
1054 } |
1100
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1055 } |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
1056 } |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
1057 |
4617 | 1058 /* Now make changes from perl scripts affect the real data */ |
1059 switch (event) { | |
1060 case event_im_recv: | |
1061 if (buf[1] != *(char **)arg2) { | |
1062 free(*(char **)arg2); | |
1063 *(char **)arg2 = buf[1]; | |
1064 } | |
1065 if (buf[2] != *(char **)arg3) { | |
1066 free(*(char **)arg3); | |
1067 *(char **)arg3 = buf[2]; | |
1068 } | |
1069 break; | |
1070 case event_im_send: | |
1071 if (buf[2] != *(char **)arg3) { | |
1072 free(*(char **)arg3); | |
1073 *(char **)arg3 = buf[2]; | |
1074 } | |
1075 break; | |
1076 case event_chat_recv: | |
1077 if (buf[2] != *(char **)arg3) { | |
1078 free(*(char **)arg3); | |
1079 *(char **)arg3 = buf[2]; | |
1080 } | |
1081 if (buf[3] != *(char **)arg4) { | |
1082 free(*(char **)arg4); | |
1083 *(char **)arg4 = buf[3]; | |
1084 } | |
1085 break; | |
1086 case event_chat_send_invite: | |
1087 if (buf[3] != *(char **)arg4) { | |
1088 free(*(char **)arg4); | |
1089 *(char **)arg4 = buf[3]; | |
1090 } | |
1091 break; | |
1092 case event_chat_send: | |
1093 if (buf[2] != *(char **)arg3) { | |
1094 free(*(char **)arg3); | |
1095 *(char **)arg3 = buf[2]; | |
1096 } | |
1097 break; | |
1098 case event_im_displayed_sent: | |
1099 if (buf[2] != *(char **)arg3) { | |
1100 free(*(char **)arg3); | |
1101 *(char **)arg3 = buf[2]; | |
1102 } | |
1103 break; | |
1104 default: | |
1105 break; | |
1106 } | |
2511
a83b4a5ffcd6
[gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2488
diff
changeset
|
1107 |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
1108 return 0; |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
1109 } |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
1110 |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
1111 XS (XS_GAIM_add_event_handler) |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
1112 { |
2048
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1949
diff
changeset
|
1113 unsigned int junk; |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
1114 struct _perl_event_handlers *handler; |
3563 | 1115 char *handle; |
1116 struct gaim_plugin *plug; | |
1117 GList *p = plugins; | |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
1118 dXSARGS; |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
1119 items = 0; |
3563 | 1120 |
1121 handle = SvPV(ST(0), junk); | |
1122 while (p) { | |
1123 plug = p->data; | |
1124 if (!strcmp(handle, plug->path)) | |
1125 break; | |
1126 p = p->next; | |
1127 } | |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
1128 |
3563 | 1129 if (p) { |
1130 handler = g_new0(struct _perl_event_handlers, 1); | |
1131 handler->event_type = g_strdup(SvPV(ST(1), junk)); | |
1132 handler->handler_name = g_strdup(SvPV(ST(2), junk)); | |
1133 handler->plug = plug; | |
1134 perl_event_handlers = g_list_append(perl_event_handlers, handler); | |
1135 debug_printf("registered perl event handler for %s\n", handler->event_type); | |
1136 } else { | |
1137 debug_printf("Invalid handle (%s) registering perl event handler\n", handle); | |
1138 } | |
1139 | |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
1140 XSRETURN_EMPTY; |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
1141 } |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
1142 |
3456 | 1143 XS (XS_GAIM_remove_event_handler) |
1144 { | |
1145 unsigned int junk; | |
1146 struct _perl_event_handlers *ehn; | |
1147 GList *cur = perl_event_handlers; | |
1148 dXSARGS; | |
4298 | 1149 items = 0; |
3456 | 1150 |
1151 while (cur) { | |
1152 GList *next = cur->next; | |
1153 ehn = cur->data; | |
1154 | |
1155 if (!strcmp(ehn->event_type, SvPV(ST(0), junk)) && | |
1156 !strcmp(ehn->handler_name, SvPV(ST(1), junk))) | |
1157 { | |
4617 | 1158 perl_event_handlers = g_list_remove(perl_event_handlers, ehn); |
3456 | 1159 g_free(ehn->event_type); |
1160 g_free(ehn->handler_name); | |
1161 g_free(ehn); | |
1162 } | |
1163 | |
1164 cur = next; | |
4617 | 1165 } |
3456 | 1166 } |
1167 | |
2370
25e7c2a68ed2
[gaim-migrate @ 2383]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2355
diff
changeset
|
1168 static int perl_timeout(gpointer data) |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
1169 { |
4617 | 1170 char *atmp[1] = { NULL }; |
2370
25e7c2a68ed2
[gaim-migrate @ 2383]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2355
diff
changeset
|
1171 struct _perl_timeout_handlers *handler = data; |
4029 | 1172 |
1173 atmp[0] = escape_quotes(handler->handler_args); | |
1174 execute_perl(handler->handler_name, atmp); | |
1175 | |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
1176 perl_timeout_handlers = g_list_remove(perl_timeout_handlers, handler); |
2512
bf7ec3874810
[gaim-migrate @ 2525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2511
diff
changeset
|
1177 g_free(handler->handler_args); |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
1178 g_free(handler->handler_name); |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
1179 g_free(handler); |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
1180 |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
1181 return 0; /* returning zero removes the timeout handler */ |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
1182 } |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
1183 |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
1184 XS (XS_GAIM_add_timeout_handler) |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
1185 { |
2048
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1949
diff
changeset
|
1186 unsigned int junk; |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
1187 long timeout; |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
1188 struct _perl_timeout_handlers *handler; |
3563 | 1189 char *handle; |
1190 struct gaim_plugin *plug; | |
1191 GList *p = plugins; | |
1192 | |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
1193 dXSARGS; |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
1194 items = 0; |
3563 | 1195 |
1196 handle = SvPV(ST(0), junk); | |
1197 while (p) { | |
1198 plug = p->data; | |
1199 if (!strcmp(handle, plug->path)) | |
1200 break; | |
1201 p = p->next; | |
1202 } | |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
1203 |
3563 | 1204 if (p) { |
1205 handler = g_new0(struct _perl_timeout_handlers, 1); | |
1206 timeout = 1000 * SvIV(ST(1)); | |
4298 | 1207 debug_printf("Adding timeout for %ld seconds.\n", timeout/1000); |
3563 | 1208 handler->plug = plug; |
1209 handler->handler_name = g_strdup(SvPV(ST(2), junk)); | |
1210 handler->handler_args = g_strdup(SvPV(ST(3), junk)); | |
1211 perl_timeout_handlers = g_list_append(perl_timeout_handlers, handler); | |
1212 handler->iotag = g_timeout_add(timeout, perl_timeout, handler); | |
1213 } else { | |
1214 debug_printf("Invalid handle (%s) in adding perl timeout handler.", handle); | |
1215 } | |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
1216 XSRETURN_EMPTY; |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
1217 } |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
1218 |
3280 | 1219 XS (XS_GAIM_play_sound) |
1220 { | |
1221 int id; | |
1222 dXSARGS; | |
1223 | |
4298 | 1224 items = 0; |
1225 | |
3280 | 1226 id = SvIV(ST(0)); |
1227 | |
4561 | 1228 gaim_sound_play_event(id); |
3280 | 1229 |
1230 XSRETURN_EMPTY; | |
1231 } | |
1232 | |
2370
25e7c2a68ed2
[gaim-migrate @ 2383]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2355
diff
changeset
|
1233 extern void unload_perl_scripts() |
798
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
1234 { |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
1235 perl_end(); |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
1236 perl_init(); |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
1237 } |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
1238 |
799
72f8ac951c11
[gaim-migrate @ 809]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
798
diff
changeset
|
1239 |
560 | 1240 #endif /* USE_PERL */ |