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