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