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