annotate src/perl.c @ 3621:e9f66d245253

[gaim-migrate @ 3742] Give a totsize of -1 if you want the filesize to be unknown upon asking. committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Thu, 10 Oct 2002 05:57:07 +0000
parents 163205125ee2
children 9682c0e022c6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
560
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /*
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 * gaim
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 *
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 *
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 * (at your option) any later version.
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 *
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 * GNU General Public License for more details.
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 *
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 *
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 * This was taken almost exactly from X-Chat. The power of the GPL.
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 * Translated from X-Chat to Gaim by Eric Warmenhoven.
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 * Originally by Erik Scrafford <eriks@chilisoft.com>.
597
3a24fd19ff5f [gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
23 * X-Chat Copyright (C) 1998 Peter Zelezny.
560
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 *
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 */
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 #ifdef HAVE_CONFIG_H
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2048
diff changeset
28 #include <config.h>
1896
e556ffa08cce [gaim-migrate @ 1906]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1850
diff changeset
29 #ifdef DEBUG
e556ffa08cce [gaim-migrate @ 1906]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1850
diff changeset
30 #undef DEBUG
e556ffa08cce [gaim-migrate @ 1906]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1850
diff changeset
31 #endif
560
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 #endif
561
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
33 #undef PACKAGE
560
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34
580
9a8b067eb368 [gaim-migrate @ 590]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 579
diff changeset
35 #ifdef USE_PERL
560
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36
3395
c731327dbc47 [gaim-migrate @ 3414]
Sean Egan <seanegan@gmail.com>
parents: 3280
diff changeset
37 #define group perl_group
c731327dbc47 [gaim-migrate @ 3414]
Sean Egan <seanegan@gmail.com>
parents: 3280
diff changeset
38
560
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 #include <EXTERN.h>
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 #ifndef _SEM_SEMUN_UNDEFINED
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 #define HAS_UNION_SEMUN
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 #endif
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 #include <perl.h>
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 #include <XSUB.h>
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 #include <sys/mman.h>
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 #include <sys/types.h>
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 #include <sys/stat.h>
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 #include <fcntl.h>
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 #undef PACKAGE
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50 #include <stdio.h>
800
022048cde898 [gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 799
diff changeset
51 #include <dirent.h>
1238
78c4f497db2b [gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1233
diff changeset
52 #include <string.h>
798
9dc39872e1f9 [gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 797
diff changeset
53
3395
c731327dbc47 [gaim-migrate @ 3414]
Sean Egan <seanegan@gmail.com>
parents: 3280
diff changeset
54 #undef group
590
91f877d86ca6 [gaim-migrate @ 600]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 581
diff changeset
55
91f877d86ca6 [gaim-migrate @ 600]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 581
diff changeset
56 /* perl module support */
91f877d86ca6 [gaim-migrate @ 600]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 581
diff changeset
57 extern void xs_init _((void));
91f877d86ca6 [gaim-migrate @ 600]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 581
diff changeset
58 extern void boot_DynaLoader _((CV * cv)); /* perl is so wacky */
91f877d86ca6 [gaim-migrate @ 600]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 581
diff changeset
59
91f877d86ca6 [gaim-migrate @ 600]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 581
diff changeset
60 #undef _
1896
e556ffa08cce [gaim-migrate @ 1906]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1850
diff changeset
61 #ifdef DEBUG
e556ffa08cce [gaim-migrate @ 1906]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1850
diff changeset
62 #undef DEBUG
e556ffa08cce [gaim-migrate @ 1906]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1850
diff changeset
63 #endif
560
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 #include "gaim.h"
2355
571971659533 [gaim-migrate @ 2368]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2345
diff changeset
65 #include "prpl.h"
560
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66
561
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
67 struct perlscript {
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
68 char *name;
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
69 char *version;
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
70 char *shutdowncallback; /* bleh */
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
71 struct gaim_plugin *plug;
561
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
72 };
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
73
780
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
74 struct _perl_event_handlers {
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
75 char *event_type;
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
76 char *handler_name;
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
77 struct gaim_plugin *plug;
781
95ebfdb31a9b [gaim-migrate @ 791]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 780
diff changeset
78 };
780
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
79
573
9566a53cde23 [gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 565
diff changeset
80 struct _perl_timeout_handlers {
9566a53cde23 [gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 565
diff changeset
81 char *handler_name;
2512
bf7ec3874810 [gaim-migrate @ 2525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2511
diff changeset
82 char *handler_args;
573
9566a53cde23 [gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 565
diff changeset
83 gint iotag;
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
84 struct gaim_plugin *plug;
573
9566a53cde23 [gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 565
diff changeset
85 };
9566a53cde23 [gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 565
diff changeset
86
597
3a24fd19ff5f [gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
87 static GList *perl_list = NULL; /* should probably extern this at some point */
573
9566a53cde23 [gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 565
diff changeset
88 static GList *perl_timeout_handlers = NULL;
780
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
89 static GList *perl_event_handlers = NULL;
560
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90 static PerlInterpreter *my_perl = NULL;
2329
a6d0edc31554 [gaim-migrate @ 2339]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2261
diff changeset
91 static void perl_init();
560
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
92
579
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
93 /* dealing with gaim */
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
94 XS(XS_GAIM_register); /* set up hooks for script */
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
95 XS(XS_GAIM_get_info); /* version, last to attempt signon, protocol */
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
96 XS(XS_GAIM_print); /* lemme figure this one out... */
2261
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
97 XS(XS_GAIM_write_to_conv); /* write into conversation window */
579
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
98
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
99 /* list stuff */
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
100 XS(XS_GAIM_buddy_list); /* all buddies */
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
101 XS(XS_GAIM_online_list); /* online buddies */
579
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
102
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
103 /* server stuff */
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
104 XS(XS_GAIM_command); /* send command to server */
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
105 XS(XS_GAIM_user_info); /* given name, return struct buddy members */
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
106 XS(XS_GAIM_print_to_conv); /* send message to someone */
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
107 XS(XS_GAIM_print_to_chat); /* send message to chat room */
2261
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
108 XS(XS_GAIM_serv_send_im); /* send message to someone (but do not display) */
579
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
109
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
110 /* handler commands */
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
111 XS(XS_GAIM_add_event_handler); /* when servers talk */
3456
b48065e52337 [gaim-migrate @ 3503]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
112 XS(XS_GAIM_remove_event_handler); /* remove a handler */
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
113 XS(XS_GAIM_add_timeout_handler); /* figure it out */
579
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
114
3280
c98c1e0281ff [gaim-migrate @ 3298]
Sean Egan <seanegan@gmail.com>
parents: 3167
diff changeset
115 /* play sound */
c98c1e0281ff [gaim-migrate @ 3298]
Sean Egan <seanegan@gmail.com>
parents: 3167
diff changeset
116 XS(XS_GAIM_play_sound); /*play a sound*/
c98c1e0281ff [gaim-migrate @ 3298]
Sean Egan <seanegan@gmail.com>
parents: 3167
diff changeset
117
561
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
118 void xs_init()
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
119 {
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
120 char *file = __FILE__;
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
121
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
122 /* This one allows dynamic loading of perl modules in perl
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
123 scripts by the 'use perlmod;' construction*/
561
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
124 newXS ("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
125
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
126 /* load up all the custom Gaim perl functions */
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
127 newXS ("GAIM::register", XS_GAIM_register, "GAIM");
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
128 newXS ("GAIM::get_info", XS_GAIM_get_info, "GAIM");
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
129 newXS ("GAIM::print", XS_GAIM_print, "GAIM");
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
130 newXS ("GAIM::write_to_conv", XS_GAIM_write_to_conv, "GAIM");
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
131
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
132 newXS ("GAIM::buddy_list", XS_GAIM_buddy_list, "GAIM");
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
133 newXS ("GAIM::online_list", XS_GAIM_online_list, "GAIM");
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
134
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
135 newXS ("GAIM::command", XS_GAIM_command, "GAIM");
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
136 newXS ("GAIM::user_info", XS_GAIM_user_info, "GAIM");
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
137 newXS ("GAIM::print_to_conv", XS_GAIM_print_to_conv, "GAIM");
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
138 newXS ("GAIM::print_to_chat", XS_GAIM_print_to_chat, "GAIM");
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
139 newXS ("GAIM::serv_send_im", XS_GAIM_serv_send_im, "GAIM");
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
140
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
141 newXS ("GAIM::add_event_handler", XS_GAIM_add_event_handler, "GAIM");
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
142 newXS ("GAIM::remove_event_handler", XS_GAIM_remove_event_handler, "GAIM");
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
143 newXS ("GAIM::add_timeout_handler", XS_GAIM_add_timeout_handler, "GAIM");
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
144
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
145 newXS ("GAIM::play_sound", XS_GAIM_play_sound, "GAIM");
561
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
146 }
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
147
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
148 static char *escape_quotes(char *buf)
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
149 {
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
150 static char *tmp_buf = NULL;
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
151 char *i, *j;
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
152
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
153 if (tmp_buf)
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
154 g_free(tmp_buf);
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
155 tmp_buf = g_malloc(strlen(buf) * 2 + 1);
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
156 for (i = buf, j = tmp_buf; *i; i++, j++) {
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
157 if (*i == '\'' || *i == '\\')
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
158 *j++ = '\\';
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
159 *j = *i;
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
160 }
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
161 *j = '\0';
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
162
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
163 return (tmp_buf);
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
164 }
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
165
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
166 /*
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
167 2001/06/14: execute_perl replaced by Martin Persson <mep@passagen.se>
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
168 previous use of perl_eval leaked memory, replaced with
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
169 a version that uses perl_call instead
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
170 */
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
171
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
172 static int
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
173 execute_perl(char *function, char *args)
561
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
174 {
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
175 char *perl_args[2] = { args, NULL }, buf[512];
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
176 int count, ret_value = 1;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
177 SV *sv;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
178
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
179 dSP;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
180 ENTER;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
181 SAVETMPS;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
182 PUSHMARK(sp);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
183 count = perl_call_argv(function, G_EVAL | G_SCALAR, perl_args);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
184 SPAGAIN;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
185
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
186 sv = GvSV(gv_fetchpv("@", TRUE, SVt_PV));
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
187 if (SvTRUE(sv)) {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
188 snprintf(buf, 512, "Perl error: %s\n", SvPV(sv, count));
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
189 debug_printf(buf);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
190 POPs;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
191 } else if (count != 1) {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
192 snprintf(buf, 512, "Perl error: expected 1 value from %s, "
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
193 "got: %d\n", function, count);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
194 debug_printf(buf);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
195 } else {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
196 ret_value = POPi;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
197 }
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
198
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
199 PUTBACK;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
200 FREETMPS;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
201 LEAVE;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
202
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
203 return ret_value;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
204
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
205 }
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
206
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
207 void perl_unload_file(struct gaim_plugin *plug) {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
208 struct perlscript *scp = NULL;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
209 struct _perl_timeout_handlers *thn;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
210 struct _perl_event_handlers *ehn;
561
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
211
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
212 GList *pl = perl_list;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
213
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
214 debug_printf("Unloading %s\n", plug->handle);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
215 while (pl) {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
216 scp = pl->data;
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
217 if (scp->plug == plug) {
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
218 perl_list = g_list_remove(perl_list, scp);
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
219 if (scp->shutdowncallback[0])
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
220 execute_perl(scp->shutdowncallback, "");
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
221 perl_list = g_list_remove(perl_list, scp);
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
222 g_free(scp->name);
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
223 g_free(scp->version);
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
224 g_free(scp->shutdowncallback);
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
225 g_free(scp);
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
226 break;
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
227 }
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
228 }
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
229
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
230 pl = perl_timeout_handlers;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
231 while (pl) {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
232 thn = pl->data;
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
233 if (thn && thn->plug == plug) {
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
234 perl_timeout_handlers = g_list_remove(perl_timeout_handlers, thn);
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
235 g_source_remove(thn->iotag);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
236 g_free(thn->handler_args);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
237 g_free(thn->handler_name);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
238 g_free(thn);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
239 }
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
240 pl = pl->next;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
241 }
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
242
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
243 pl = perl_event_handlers;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
244 while (pl) {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
245 ehn = pl->data;
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
246 if (ehn && ehn->plug == plug) {
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
247 perl_event_handlers = g_list_remove(perl_event_handlers, ehn);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
248 g_free(ehn->event_type);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
249 g_free(ehn->handler_name);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
250 g_free(ehn);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
251 }
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
252 pl = pl->next;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
253 }
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
254
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
255 plug->handle=NULL;
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
256 plugins = g_list_remove(plugins, plug);
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
257 save_prefs();
561
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
258 }
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
259
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
260 int perl_load_file(char *script_name)
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
261 {
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
262 struct gaim_plugin *plug;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
263 GList *p = probed_plugins;
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
264 GList *s;
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
265 struct perlscript *scp;
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
266 int ret;
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
267
2329
a6d0edc31554 [gaim-migrate @ 2339]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2261
diff changeset
268 if (my_perl == NULL)
a6d0edc31554 [gaim-migrate @ 2339]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2261
diff changeset
269 perl_init();
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
270
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
271 while (p) {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
272 plug = (struct gaim_plugin *)p->data;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
273 if (!strcmp(script_name, plug->path))
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
274 break;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
275 p = p->next;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
276 }
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
277
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
278 if (!plug) {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
279 probe_perl(script_name);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
280 }
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
281
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
282 plug->handle = plug->path;
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
283 plugins = g_list_append(plugins, plug);
560
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
284
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
285 ret = execute_perl("load_n_eval", script_name);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
286
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
287 s = perl_list;
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
288 while (s) {
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
289 scp = s->data;
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
290
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
291 if (!strcmp(scp->name, plug->desc.name) &&
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
292 !strcmp(scp->version, plug->desc.version))
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
293 break;
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
294 s = s->next;
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
295 }
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
296
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
297 if (!s) {
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
298 g_snprintf(plug->error, sizeof(plug->error), _("GAIM::register not called with proper arguments. Consult PERL-HOWTO."));
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
299 return 0;
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
300 }
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
301
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
302 plug->error[0] = '\0';
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
303 return ret;
800
022048cde898 [gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 799
diff changeset
304 }
022048cde898 [gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 799
diff changeset
305
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
306 struct gaim_plugin *probe_perl(const char *filename) {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
307
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
308 /* XXX This woulld be much faster if I didn't create a new
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
309 * PerlInterpreter every time I probed a plugin */
800
022048cde898 [gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 799
diff changeset
310
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
311 PerlInterpreter *prober = perl_alloc();
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
312 struct gaim_plugin * plug = NULL;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
313 char *argv[] = {"", filename};
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
314 int count;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
315 perl_construct(prober);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
316 perl_parse(prober, NULL, 2, argv, NULL);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
317
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
318 {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
319 dSP;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
320 ENTER;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
321 SAVETMPS;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
322 PUSHMARK(SP);
3556
4d70a24c0fd6 [gaim-migrate @ 3646]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
323
4d70a24c0fd6 [gaim-migrate @ 3646]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
324 count = perl_call_pv("description", G_NOARGS | G_ARRAY | G_EVAL);
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
325 SPAGAIN;
3556
4d70a24c0fd6 [gaim-migrate @ 3646]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
326 if (count == (sizeof(struct gaim_plugin_description) - sizeof(int)) / sizeof(char*)) {
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
327 plug = g_new0(struct gaim_plugin, 1);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
328 plug->type = perl_script;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
329 g_snprintf(plug->path, sizeof(plug->path), filename);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
330 plug->desc.iconfile = g_strdup(POPp);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
331 plug->desc.url = g_strdup(POPp);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
332 plug->desc.authors = g_strdup(POPp);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
333 plug->desc.description = g_strdup(POPp);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
334 plug->desc.version = g_strdup(POPp);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
335 plug->desc.name = g_strdup(POPp);
800
022048cde898 [gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 799
diff changeset
336 }
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
337
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
338 PUTBACK;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
339 FREETMPS;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
340 LEAVE;
800
022048cde898 [gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 799
diff changeset
341 }
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
342 perl_destruct(prober);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
343 perl_free(prober);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
344 return plug;
800
022048cde898 [gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 799
diff changeset
345 }
022048cde898 [gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 799
diff changeset
346
2329
a6d0edc31554 [gaim-migrate @ 2339]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2261
diff changeset
347 static void perl_init()
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
348 { /*changed the name of the variable from load_file to
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
349 perl_definitions since now it does much more than defining
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
350 the load_file sub. Moreover, deplaced the initialisation to
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
351 the xs_init function. (TheHobbit)*/
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
352 char *perl_args[] = { "", "-e", "0", "-w" };
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
353 char perl_definitions[] =
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
354 {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
355 /* We use to function one to load a file the other to
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
356 execute the string obtained from the first and holding
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
357 the file conents. This allows to have a realy local $/
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
358 without introducing temp variables to hold the old
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
359 value. Just a question of style:) */
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
360 "sub load_file{"
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
361 "my $f_name=shift;"
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
362 "local $/=undef;"
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
363 "open FH,$f_name or return \"__FAILED__\";"
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
364 "$_=<FH>;"
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
365 "close FH;"
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
366 "return $_;"
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
367 "}"
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
368 "sub load_n_eval{"
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
369 "my $f_name=shift;"
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
370 "my $strin=load_file($f_name);"
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
371 "return 2 if($strin eq \"__FAILED__\");"
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
372 "eval $strin;"
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
373 "if($@){"
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
374 /*" #something went wrong\n"*/
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
375 "GAIM::print\"Errors loading file $f_name:\\n\";"
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
376 "GAIM::print\"$@\\n\";"
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
377 "return 1;"
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
378 "}"
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
379 "return 0;"
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
380 "}"
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
381 };
560
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
382
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
383 my_perl = perl_alloc();
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
384 perl_construct(my_perl);
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
385 #ifdef DEBUG
561
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
386 perl_parse(my_perl, xs_init, 4, perl_args, NULL);
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
387 #else
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
388 perl_parse(my_perl, xs_init, 3, perl_args, NULL);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
389 #endif
560
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
390 #ifndef HAVE_PERL_EVAL_PV
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
391 eval_pv(perl_definitions, TRUE);
560
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
392 #else
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
393 perl_eval_pv(perl_definitions, TRUE); /* deprecated */
560
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
394 #endif
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
395
579
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
396
560
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
397 }
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
398
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
399 void perl_end()
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
400 {
565
7209b474bdc3 [gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 562
diff changeset
401 struct perlscript *scp;
573
9566a53cde23 [gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 565
diff changeset
402 struct _perl_timeout_handlers *thn;
780
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
403 struct _perl_event_handlers *ehn;
565
7209b474bdc3 [gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 562
diff changeset
404
7209b474bdc3 [gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 562
diff changeset
405 while (perl_list) {
7209b474bdc3 [gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 562
diff changeset
406 scp = perl_list->data;
7209b474bdc3 [gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 562
diff changeset
407 perl_list = g_list_remove(perl_list, scp);
7209b474bdc3 [gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 562
diff changeset
408 if (scp->shutdowncallback[0])
7209b474bdc3 [gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 562
diff changeset
409 execute_perl(scp->shutdowncallback, "");
7209b474bdc3 [gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 562
diff changeset
410 g_free(scp->name);
7209b474bdc3 [gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 562
diff changeset
411 g_free(scp->version);
7209b474bdc3 [gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 562
diff changeset
412 g_free(scp->shutdowncallback);
7209b474bdc3 [gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 562
diff changeset
413 g_free(scp);
7209b474bdc3 [gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 562
diff changeset
414 }
7209b474bdc3 [gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 562
diff changeset
415
573
9566a53cde23 [gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 565
diff changeset
416 while (perl_timeout_handlers) {
9566a53cde23 [gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 565
diff changeset
417 thn = perl_timeout_handlers->data;
9566a53cde23 [gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 565
diff changeset
418 perl_timeout_handlers = g_list_remove(perl_timeout_handlers, thn);
2370
25e7c2a68ed2 [gaim-migrate @ 2383]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2355
diff changeset
419 g_source_remove(thn->iotag);
2512
bf7ec3874810 [gaim-migrate @ 2525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2511
diff changeset
420 g_free(thn->handler_args);
573
9566a53cde23 [gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 565
diff changeset
421 g_free(thn->handler_name);
9566a53cde23 [gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 565
diff changeset
422 g_free(thn);
9566a53cde23 [gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 565
diff changeset
423 }
9566a53cde23 [gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 565
diff changeset
424
780
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
425 while (perl_event_handlers) {
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
426 ehn = perl_event_handlers->data;
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
427 perl_event_handlers = g_list_remove(perl_event_handlers, ehn);
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
428 g_free(ehn->event_type);
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
429 debug_printf("handler_name: %s\n", ehn->handler_name);
780
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
430 g_free(ehn->handler_name);
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
431 g_free(ehn);
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
432 }
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
433
560
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
434 if (my_perl != NULL) {
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
435 perl_destruct(my_perl);
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
436 perl_free(my_perl);
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
437 my_perl = NULL;
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
438 }
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
439 }
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
440
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
441 XS (XS_GAIM_register)
561
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
442 {
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
443 char *name, *ver, *callback, *unused; /* exactly like X-Chat, eh? :) */
2048
3366311426df [gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1949
diff changeset
444 unsigned int junk;
561
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
445 struct perlscript *scp;
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
446 struct gaim_plugin *plug;
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
447 GList *pl = plugins;
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
448
561
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
449 dXSARGS;
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
450 items = 0;
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
451
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
452 name = SvPV (ST (0), junk);
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
453 ver = SvPV (ST (1), junk);
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
454 callback = SvPV (ST (2), junk);
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
455 unused = SvPV (ST (3), junk);
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
456
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
457 while (pl) {
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
458 plug = pl->data;
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
459
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
460 if (!strcmp(name, plug->desc.name) &&
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
461 !strcmp(ver, plug->desc.version)) {
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
462 break;
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
463 }
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
464 pl = pl->next;
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
465 }
561
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
466
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
467 if (plug) {
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
468 scp = g_new0(struct perlscript, 1);
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
469 scp->name = g_strdup(name);
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
470 scp->version = g_strdup(ver);
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
471 scp->shutdowncallback = g_strdup(callback);
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
472 scp->plug = plug;
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
473 perl_list = g_list_append(perl_list, scp);
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
474 }
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
475 XST_mPV (0, plug->path);
561
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
476 XSRETURN (1);
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
477 }
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
478
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
479 XS (XS_GAIM_get_info)
579
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
480 {
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
481 int i = 0;
579
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
482 dXSARGS;
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
483 items = 0;
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
484
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
485 switch(SvIV(ST(0))) {
579
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
486 case 0:
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
487 XST_mPV(0, VERSION);
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
488 i = 1;
579
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
489 break;
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
490 case 1:
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
491 {
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
492 GSList *c = connections;
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
493 struct gaim_connection *gc;
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
494
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
495 while (c) {
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
496 gc = (struct gaim_connection *)c->data;
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
497 XST_mIV(i++, (guint)gc);
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
498 c = c->next;
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
499 }
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
500 }
579
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
501 break;
591
a26eb4c472d8 [gaim-migrate @ 601]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 590
diff changeset
502 case 2:
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
503 {
2355
571971659533 [gaim-migrate @ 2368]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2345
diff changeset
504 struct gaim_connection *gc = (struct gaim_connection *)SvIV(ST(1));
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
505 if (g_slist_find(connections, gc))
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
506 XST_mIV(i++, gc->protocol);
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
507 else
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
508 XST_mIV(i++, -1);
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
509 }
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
510 break;
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
511 case 3:
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
512 {
2355
571971659533 [gaim-migrate @ 2368]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2345
diff changeset
513 struct gaim_connection *gc = (struct gaim_connection *)SvIV(ST(1));
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
514 if (g_slist_find(connections, gc))
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
515 XST_mPV(i++, gc->username);
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
516 else
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
517 XST_mPV(i++, "");
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
518 }
2355
571971659533 [gaim-migrate @ 2368]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2345
diff changeset
519 break;
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
520 case 4:
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
521 {
2355
571971659533 [gaim-migrate @ 2368]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2345
diff changeset
522 struct gaim_connection *gc = (struct gaim_connection *)SvIV(ST(1));
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
523 if (g_slist_find(connections, gc))
2397
520257562955 [gaim-migrate @ 2410]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2370
diff changeset
524 XST_mIV(i++, g_slist_index(aim_users, gc->user));
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
525 else
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
526 XST_mIV(i++, -1);
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
527 }
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
528 break;
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
529 case 5:
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
530 {
2397
520257562955 [gaim-migrate @ 2410]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2370
diff changeset
531 GSList *a = aim_users;
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
532 while (a) {
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
533 struct aim_user *u = a->data;
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
534 XST_mPV(i++, u->username);
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
535 a = a->next;
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
536 }
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
537 }
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
538 break;
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
539 case 6:
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
540 {
2397
520257562955 [gaim-migrate @ 2410]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2370
diff changeset
541 GSList *a = aim_users;
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
542 while (a) {
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
543 struct aim_user *u = a->data;
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
544 XST_mIV(i++, u->protocol);
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
545 a = a->next;
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
546 }
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
547 }
591
a26eb4c472d8 [gaim-migrate @ 601]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 590
diff changeset
548 break;
2355
571971659533 [gaim-migrate @ 2368]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2345
diff changeset
549 case 7:
571971659533 [gaim-migrate @ 2368]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2345
diff changeset
550 {
571971659533 [gaim-migrate @ 2368]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2345
diff changeset
551 struct gaim_connection *gc = (struct gaim_connection *)SvIV(ST(1));
571971659533 [gaim-migrate @ 2368]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2345
diff changeset
552 if (g_slist_find(connections, gc))
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3563
diff changeset
553 XST_mPV(i++, gc->prpl->name);
2355
571971659533 [gaim-migrate @ 2368]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2345
diff changeset
554 else
571971659533 [gaim-migrate @ 2368]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2345
diff changeset
555 XST_mPV(i++, "Unknown");
571971659533 [gaim-migrate @ 2368]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2345
diff changeset
556 }
571971659533 [gaim-migrate @ 2368]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2345
diff changeset
557 break;
579
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
558 default:
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
559 XST_mPV(0, "Error2");
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
560 i = 1;
579
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
561 }
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
562
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
563 XSRETURN(i);
579
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
564 }
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
565
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
566 XS (XS_GAIM_print)
579
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
567 {
592
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 591
diff changeset
568 char *title;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 591
diff changeset
569 char *message;
2048
3366311426df [gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1949
diff changeset
570 unsigned int junk;
592
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 591
diff changeset
571 dXSARGS;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 591
diff changeset
572 items = 0;
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 591
diff changeset
573
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 591
diff changeset
574 title = SvPV(ST(0), junk);
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 591
diff changeset
575 message = SvPV(ST(1), junk);
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3517
diff changeset
576 do_error_dialog(title, message, GAIM_INFO);
592
7c75d69a1129 [gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 591
diff changeset
577 XSRETURN(0);
579
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
578 }
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
579
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
580 XS (XS_GAIM_buddy_list)
579
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
581 {
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
582 struct gaim_connection *gc;
581
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
583 struct buddy *buddy;
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
584 struct group *g;
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
585 GSList *list = NULL;
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
586 GSList *mem;
581
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
587 int i = 0;
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
588 dXSARGS;
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
589 items = 0;
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
590
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
591 gc = (struct gaim_connection *)SvIV(ST(0));
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
592 if (g_slist_find(connections, gc))
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
593 list = gc->groups;
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
594
581
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
595 while (list) {
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
596 g = (struct group *)list->data;
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
597 mem = g->members;
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
598 while (mem) {
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
599 buddy = (struct buddy *)mem->data;
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
600 XST_mPV(i++, buddy->name);
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
601 mem = mem->next;
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
602 }
940
9fca1293f871 [gaim-migrate @ 950]
Rob Flynn <gaim@robflynn.com>
parents: 905
diff changeset
603 list = g_slist_next(list);
581
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
604 }
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
605 XSRETURN(i);
579
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
606 }
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
607
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
608 XS (XS_GAIM_online_list)
579
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
609 {
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
610 struct gaim_connection *gc;
581
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
611 struct buddy *b;
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
612 struct group *g;
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
613 GSList *list = NULL;
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
614 GSList *mem;
581
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
615 int i = 0;
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
616 dXSARGS;
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
617 items = 0;
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
618
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
619 gc = (struct gaim_connection *)SvIV(ST(0));
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
620 if (g_slist_find(connections, gc))
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
621 list = gc->groups;
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
622
581
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
623 while (list) {
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
624 g = (struct group *)list->data;
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
625 mem = g->members;
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
626 while (mem) {
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
627 b = (struct buddy *)mem->data;
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
628 if (b->present) XST_mPV(i++, b->name);
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
629 mem = mem->next;
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
630 }
940
9fca1293f871 [gaim-migrate @ 950]
Rob Flynn <gaim@robflynn.com>
parents: 905
diff changeset
631 list = g_slist_next(list);
581
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
632 }
c72e5ee07d0a [gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 580
diff changeset
633 XSRETURN(i);
579
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
634 }
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
635
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
636 XS (XS_GAIM_command)
579
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
637 {
2048
3366311426df [gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1949
diff changeset
638 unsigned int junk;
603
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 597
diff changeset
639 char *command = NULL;
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 597
diff changeset
640 dXSARGS;
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 597
diff changeset
641 items = 0;
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 597
diff changeset
642
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 597
diff changeset
643 command = SvPV(ST(0), junk);
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 597
diff changeset
644 if (!command) XSRETURN(0);
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 597
diff changeset
645 if (!strncasecmp(command, "signon", 6)) {
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
646 int index = SvIV(ST(1));
2397
520257562955 [gaim-migrate @ 2410]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2370
diff changeset
647 if (g_slist_nth_data(aim_users, index))
520257562955 [gaim-migrate @ 2410]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2370
diff changeset
648 serv_login(g_slist_nth_data(aim_users, index));
603
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 597
diff changeset
649 } else if (!strncasecmp(command, "signoff", 7)) {
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
650 struct gaim_connection *gc = (struct gaim_connection *)SvIV(ST(1));
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
651 if (g_slist_find(connections, gc)) signoff(gc);
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
652 else signoff_all(NULL, NULL);
1730
2d7601acacdd [gaim-migrate @ 1740]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
653 } else if (!strncasecmp(command, "info", 4)) {
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
654 struct gaim_connection *gc = (struct gaim_connection *)SvIV(ST(1));
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
655 if (g_slist_find(connections, gc))
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
656 serv_set_info(gc, SvPV(ST(2), junk));
603
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 597
diff changeset
657 } else if (!strncasecmp(command, "away", 4)) {
630
3d2f14064083 [gaim-migrate @ 640]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 628
diff changeset
658 char *message = SvPV(ST(1), junk);
1106
5bc8fdacd2cb [gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1101
diff changeset
659 static struct away_message a;
630
3d2f14064083 [gaim-migrate @ 640]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 628
diff changeset
660 g_snprintf(a.message, sizeof(a.message), "%s", message);
3d2f14064083 [gaim-migrate @ 640]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 628
diff changeset
661 do_away_message(NULL, &a);
603
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 597
diff changeset
662 } else if (!strncasecmp(command, "back", 4)) {
628
a46a68d46d2b [gaim-migrate @ 638]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 603
diff changeset
663 do_im_back();
603
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 597
diff changeset
664 } else if (!strncasecmp(command, "idle", 4)) {
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
665 GSList *c = connections;
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
666 struct gaim_connection *gc;
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
667
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
668 while (c) {
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
669 gc = (struct gaim_connection *)c->data;
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
670 serv_set_idle(gc, SvIV(ST(1)));
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
671 c = c->next;
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
672 }
603
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 597
diff changeset
673 } else if (!strncasecmp(command, "warn", 4)) {
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
674 GSList *c = connections;
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
675 struct gaim_connection *gc;
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
676
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
677 while (c) {
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
678 gc = (struct gaim_connection *)c->data;
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
679 serv_warn(gc, SvPV(ST(1), junk), SvIV(ST(2)));
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
680 c = c->next;
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
681 }
603
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 597
diff changeset
682 }
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 597
diff changeset
683
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 597
diff changeset
684 XSRETURN(0);
579
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
685 }
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
686
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
687 XS (XS_GAIM_user_info)
579
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
688 {
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
689 struct gaim_connection *gc;
2048
3366311426df [gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1949
diff changeset
690 unsigned int junk;
1114
c61f9c384413 [gaim-migrate @ 1124]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1106
diff changeset
691 struct buddy *buddy = NULL;
579
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
692 dXSARGS;
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
693 items = 0;
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
694
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
695 gc = (struct gaim_connection *)SvIV(ST(0));
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
696 if (g_slist_find(connections, gc))
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
697 buddy = find_buddy(gc, SvPV(ST(1), junk));
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
698
579
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
699 if (!buddy)
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
700 XSRETURN(0);
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
701 XST_mPV(0, buddy->name);
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
702 XST_mPV(1, buddy->show);
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
703 XST_mPV(2, buddy->present ? "Online" : "Offline");
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
704 XST_mIV(3, buddy->evil);
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
705 XST_mIV(4, buddy->signon);
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
706 XST_mIV(5, buddy->idle);
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
707 XST_mIV(6, buddy->uc);
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
708 XST_mIV(7, buddy->caps);
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
709 XSRETURN(8);
597
3a24fd19ff5f [gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
710 }
3a24fd19ff5f [gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
711
2261
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
712 XS (XS_GAIM_write_to_conv)
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
713 {
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
714 char *nick, *who, *what;
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
715 struct conversation *c;
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
716 int junk;
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
717 int send, wflags;
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
718 dXSARGS;
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
719 items = 0;
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
720
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
721 nick = SvPV(ST(0), junk);
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
722 send = SvIV(ST(1));
2261
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
723 what = SvPV(ST(2), junk);
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
724 who = SvPV(ST(3), junk);
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
725
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
726 if (!*who) who=NULL;
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
727
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
728 switch (send) {
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
729 case 0: wflags=WFLAG_SEND; break;
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
730 case 1: wflags=WFLAG_RECV; break;
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
731 case 2: wflags=WFLAG_SYSTEM; break;
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
732 default: wflags=WFLAG_RECV;
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
733 }
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
734
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
735 c = find_conversation(nick);
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
736 if (!c)
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
737 c = new_conversation(nick);
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
738
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2712
diff changeset
739 write_to_conv(c, what, wflags, who, time(NULL), -1);
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
740 XSRETURN(0);
2261
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
741 }
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
742
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
743 XS (XS_GAIM_serv_send_im)
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
744 {
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
745 struct gaim_connection *gc;
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
746 char *nick, *what;
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
747 int isauto;
2261
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
748 int junk;
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
749 dXSARGS;
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
750 items = 0;
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
751
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
752 gc = (struct gaim_connection *)SvIV(ST(0));
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
753 nick = SvPV(ST(1), junk);
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
754 what = SvPV(ST(2), junk);
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
755 isauto = SvIV(ST(3));
2261
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
756
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
757 if (!g_slist_find(connections, gc)) {
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
758 XSRETURN(0);
2261
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
759 return;
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
760 }
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 2856
diff changeset
761 serv_send_im(gc, nick, what, -1, isauto);
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
762 XSRETURN(0);
2261
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
763 }
e243bf60f2d6 [gaim-migrate @ 2271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
764
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
765 XS (XS_GAIM_print_to_conv)
597
3a24fd19ff5f [gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
766 {
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
767 struct gaim_connection *gc;
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
768 char *nick, *what;
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
769 int isauto;
597
3a24fd19ff5f [gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
770 struct conversation *c;
2048
3366311426df [gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1949
diff changeset
771 unsigned int junk;
597
3a24fd19ff5f [gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
772 dXSARGS;
3a24fd19ff5f [gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
773 items = 0;
3a24fd19ff5f [gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
774
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
775 gc = (struct gaim_connection *)SvIV(ST(0));
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
776 nick = SvPV(ST(1), junk);
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
777 what = SvPV(ST(2), junk);
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
778 isauto = SvIV(ST(3));
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
779 if (!g_slist_find(connections, gc)) {
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
780 XSRETURN(0);
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
781 return;
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
782 }
597
3a24fd19ff5f [gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
783 c = find_conversation(nick);
3a24fd19ff5f [gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
784 if (!c)
3a24fd19ff5f [gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 592
diff changeset
785 c = new_conversation(nick);
2488
e87e4a9e6566 [gaim-migrate @ 2501]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2397
diff changeset
786 set_convo_gc(c, gc);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2712
diff changeset
787 write_to_conv(c, what, WFLAG_SEND | (isauto ? WFLAG_AUTO : 0), NULL, time(NULL), -1);
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 2856
diff changeset
788 serv_send_im(c->gc, nick, what, -1, isauto ? IM_FLAG_AWAY : 0);
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
789 XSRETURN(0);
579
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
790 }
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
791
3280
c98c1e0281ff [gaim-migrate @ 3298]
Sean Egan <seanegan@gmail.com>
parents: 3167
diff changeset
792
c98c1e0281ff [gaim-migrate @ 3298]
Sean Egan <seanegan@gmail.com>
parents: 3167
diff changeset
793
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
794 XS (XS_GAIM_print_to_chat)
603
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 597
diff changeset
795 {
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
796 struct gaim_connection *gc;
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
797 int id;
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
798 char *what;
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
799 struct conversation *b = NULL;
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
800 GSList *bcs;
2048
3366311426df [gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1949
diff changeset
801 unsigned int junk;
603
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 597
diff changeset
802 dXSARGS;
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 597
diff changeset
803 items = 0;
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 597
diff changeset
804
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
805 gc = (struct gaim_connection *)SvIV(ST(0));
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
806 id = SvIV(ST(1));
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
807 what = SvPV(ST(2), junk);
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
808
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
809 if (!g_slist_find(connections, gc)) {
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
810 XSRETURN(0);
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
811 return;
603
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 597
diff changeset
812 }
2345
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
813 bcs = gc->buddy_chats;
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
814 while (bcs) {
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
815 b = (struct conversation *)bcs->data;
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
816 if (b->id == id)
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
817 break;
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
818 bcs = bcs->next;
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
819 b = NULL;
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
820 }
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
821 if (b)
a49e8f1afbc4 [gaim-migrate @ 2358]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2329
diff changeset
822 serv_chat_send(gc, id, what);
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
823 XSRETURN(0);
603
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 597
diff changeset
824 }
9b0717b4a490 [gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 597
diff changeset
825
3517
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
826 int perl_event(enum gaim_event event, void *arg1, void *arg2, void *arg3, void *arg4, void *arg5)
579
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
827 {
2511
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
828 char *buf = NULL;
780
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
829 GList *handler;
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
830 struct _perl_event_handlers *data;
1100
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1030
diff changeset
831 SV *handler_return;
780
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
832
2511
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
833 switch (event) {
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
834 case event_signon:
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
835 case event_signoff:
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
836 buf = g_strdup_printf("'%lu'", (unsigned long)arg1);
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
837 break;
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
838 case event_away:
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
839 buf = g_strdup_printf("'%lu','%s'", (unsigned long)arg1,
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
840 ((struct gaim_connection *)arg1)->away ?
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
841 escape_quotes(((struct gaim_connection *)arg1)->away) : "");
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
842 break;
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
843 case event_im_recv:
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
844 {
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
845 char *tmp = *(char **)arg2 ? g_strdup(escape_quotes(*(char **)arg2)) : g_malloc0(1);
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
846 buf = g_strdup_printf("'%lu','%s','%s'", (unsigned long)arg1, tmp,
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
847 *(char **)arg3 ? escape_quotes(*(char **)arg3) : "");
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
848 g_free(tmp);
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
849 }
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
850 break;
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
851 case event_im_send:
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
852 {
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
853 char *tmp = arg2 ? g_strdup(escape_quotes(arg2)) : g_malloc0(1);
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
854 buf = g_strdup_printf("'%lu','%s','%s'", (unsigned long)arg1, tmp,
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
855 *(char **)arg3 ? escape_quotes(*(char **)arg3) : "");
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
856 g_free(tmp);
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
857 }
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
858 break;
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
859 case event_buddy_signon:
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
860 case event_buddy_signoff:
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
861 case event_set_info:
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
862 case event_buddy_away:
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
863 case event_buddy_back:
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
864 case event_buddy_idle:
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
865 case event_buddy_unidle:
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
866 buf = g_strdup_printf("'%lu','%s'", (unsigned long)arg1, escape_quotes(arg2));
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
867 break;
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
868 case event_chat_invited:
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
869 {
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
870 char *tmp2, *tmp3, *tmp4;
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
871 tmp2 = g_strdup(escape_quotes(arg2));
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
872 tmp3 = g_strdup(escape_quotes(arg3));
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
873 tmp4 = arg4 ? g_strdup(escape_quotes(arg4)) : g_malloc0(1);
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
874 buf = g_strdup_printf("'%lu','%s','%s','%s'", (unsigned long)arg1, tmp2, tmp3, tmp4);
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
875 g_free(tmp2);
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
876 g_free(tmp3);
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
877 g_free(tmp4);
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
878 }
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
879 break;
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
880 case event_chat_join:
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
881 case event_chat_buddy_join:
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
882 case event_chat_buddy_leave:
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
883 buf = g_strdup_printf("'%lu','%d','%s'", (unsigned long)arg1, (int)arg2,
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
884 escape_quotes(arg3));
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
885 break;
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
886 case event_chat_leave:
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
887 buf = g_strdup_printf("'%lu','%d'", (unsigned long)arg1, (int)arg2);
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
888 break;
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
889 case event_chat_recv:
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
890 {
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
891 char *t3, *t4;
3167
dab4da8ca29a [gaim-migrate @ 3183]
Sean Egan <seanegan@gmail.com>
parents: 3166
diff changeset
892 t3 = g_strdup(escape_quotes(*(char **)arg3));
dab4da8ca29a [gaim-migrate @ 3183]
Sean Egan <seanegan@gmail.com>
parents: 3166
diff changeset
893 t4 = *(char **)arg4 ? g_strdup(escape_quotes(*(char **)arg4)) : g_malloc0(1);
dab4da8ca29a [gaim-migrate @ 3183]
Sean Egan <seanegan@gmail.com>
parents: 3166
diff changeset
894 buf = g_strdup_printf("'%lu','%d','%s','%s'", (unsigned long)arg1, (int)arg2, t3, t4);
2511
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
895 g_free(t3);
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
896 g_free(t4);
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
897 }
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
898 break;
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
899 case event_chat_send_invite:
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
900 {
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
901 char *t3, *t4;
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
902 t3 = g_strdup(escape_quotes(arg3));
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
903 t4 = *(char **)arg4 ? g_strdup(escape_quotes(*(char **)arg4)) : g_malloc0(1);
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
904 buf = g_strdup_printf("'%lu','%d','%s','%s'", (unsigned long)arg1, (int)arg2, t3, t4);
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
905 g_free(t3);
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
906 g_free(t4);
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
907 }
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
908 break;
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
909 case event_chat_send:
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
910 buf = g_strdup_printf("'%lu','%d','%s'", (unsigned long)arg1, (int)arg2,
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
911 *(char **)arg3 ? escape_quotes(*(char **)arg3) : "");
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
912 break;
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
913 case event_warned:
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
914 buf = g_strdup_printf("'%lu','%s','%d'", (unsigned long)arg1,
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
915 arg2 ? escape_quotes(arg2) : "", (int)arg3);
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
916 break;
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
917 case event_quit:
3517
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
918 case event_blist_update:
2511
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
919 buf = g_malloc0(1);
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
920 break;
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
921 case event_new_conversation:
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents: 3456
diff changeset
922 case event_del_conversation:
2511
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
923 buf = g_strdup_printf("'%s'", escape_quotes(arg1));
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
924 break;
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
925 case event_im_displayed_sent:
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
926 {
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
927 char *tmp2, *tmp3;
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
928 tmp2 = g_strdup(escape_quotes(arg2));
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
929 tmp3 = *(char **)arg3 ? g_strdup(escape_quotes(*(char **)arg3)) : g_malloc0(1);
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
930 buf = g_strdup_printf("'%lu','%s','%s'", (unsigned long)arg1, tmp2, tmp3);
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
931 g_free(tmp2);
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
932 g_free(tmp3);
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
933 }
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
934 break;
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
935 case event_im_displayed_rcvd:
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
936 {
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
937 char *tmp2, *tmp3;
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
938 tmp2 = g_strdup(escape_quotes(arg2));
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
939 tmp3 = arg3 ? g_strdup(escape_quotes(arg3)) : g_malloc0(1);
2696
c17afaccaf09 [gaim-migrate @ 2709]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2677
diff changeset
940 buf = g_strdup_printf("'%lu','%s','%s'", (unsigned long)arg1, tmp2, tmp3);
2511
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
941 g_free(tmp2);
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
942 g_free(tmp3);
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
943 }
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
944 break;
3517
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
945 case event_draw_menu:
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
946 /* we can't handle this usefully without gtk/perl bindings */
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3510
diff changeset
947 return 0;
2511
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
948 default:
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents: 3456
diff changeset
949 debug_printf("someone forgot to handle %s in the perl binding\n", event_name(event));
2511
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
950 return 0;
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
951 }
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
952
780
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
953 for (handler = perl_event_handlers; handler != NULL; handler = handler->next) {
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
954 data = handler->data;
2511
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
955 if (!strcmp(event_name(event), data->event_type)) {
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
956 handler_return = execute_perl(data->handler_name, buf);
3573
163205125ee2 [gaim-migrate @ 3671]
Sean Egan <seanegan@gmail.com>
parents: 3572
diff changeset
957 if (handler_return) {
2511
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
958 if (buf)
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
959 g_free(buf);
3573
163205125ee2 [gaim-migrate @ 3671]
Sean Egan <seanegan@gmail.com>
parents: 3572
diff changeset
960 return handler_return;
2511
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
961 }
1100
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1030
diff changeset
962 }
780
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
963 }
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
964
2511
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
965 if (buf)
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
966 g_free(buf);
a83b4a5ffcd6 [gaim-migrate @ 2524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2488
diff changeset
967
780
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
968 return 0;
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
969 }
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
970
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
971 XS (XS_GAIM_add_event_handler)
780
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
972 {
2048
3366311426df [gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1949
diff changeset
973 unsigned int junk;
780
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
974 struct _perl_event_handlers *handler;
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
975 char *handle;
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
976 struct gaim_plugin *plug;
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
977 GList *p = plugins;
780
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
978 dXSARGS;
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
979 items = 0;
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
980
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
981 handle = SvPV(ST(0), junk);
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
982 while (p) {
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
983 plug = p->data;
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
984 if (!strcmp(handle, plug->path))
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
985 break;
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
986 p = p->next;
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
987 }
780
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
988
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
989 if (p) {
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
990 handler = g_new0(struct _perl_event_handlers, 1);
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
991 handler->event_type = g_strdup(SvPV(ST(1), junk));
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
992 handler->handler_name = g_strdup(SvPV(ST(2), junk));
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
993 handler->plug = plug;
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
994 perl_event_handlers = g_list_append(perl_event_handlers, handler);
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
995 debug_printf("registered perl event handler for %s\n", handler->event_type);
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
996 } else {
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
997 debug_printf("Invalid handle (%s) registering perl event handler\n", handle);
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
998 }
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
999
780
c714def9cebb [gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 749
diff changeset
1000 XSRETURN_EMPTY;
579
7b501c39a6ee [gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 577
diff changeset
1001 }
561
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
1002
3456
b48065e52337 [gaim-migrate @ 3503]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1003 XS (XS_GAIM_remove_event_handler)
b48065e52337 [gaim-migrate @ 3503]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1004 {
b48065e52337 [gaim-migrate @ 3503]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1005 unsigned int junk;
b48065e52337 [gaim-migrate @ 3503]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1006 struct _perl_event_handlers *ehn;
b48065e52337 [gaim-migrate @ 3503]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1007 GList *cur = perl_event_handlers;
b48065e52337 [gaim-migrate @ 3503]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1008 dXSARGS;
b48065e52337 [gaim-migrate @ 3503]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1009
b48065e52337 [gaim-migrate @ 3503]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1010 while (cur) {
b48065e52337 [gaim-migrate @ 3503]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1011 GList *next = cur->next;
b48065e52337 [gaim-migrate @ 3503]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1012 ehn = cur->data;
b48065e52337 [gaim-migrate @ 3503]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1013
b48065e52337 [gaim-migrate @ 3503]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1014 if (!strcmp(ehn->event_type, SvPV(ST(0), junk)) &&
b48065e52337 [gaim-migrate @ 3503]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1015 !strcmp(ehn->handler_name, SvPV(ST(1), junk)))
b48065e52337 [gaim-migrate @ 3503]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1016 {
b48065e52337 [gaim-migrate @ 3503]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1017 perl_event_handlers = g_list_remove(perl_event_handlers, ehn);
b48065e52337 [gaim-migrate @ 3503]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1018 g_free(ehn->event_type);
b48065e52337 [gaim-migrate @ 3503]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1019 g_free(ehn->handler_name);
b48065e52337 [gaim-migrate @ 3503]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1020 g_free(ehn);
b48065e52337 [gaim-migrate @ 3503]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1021 }
b48065e52337 [gaim-migrate @ 3503]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1022
b48065e52337 [gaim-migrate @ 3503]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1023 cur = next;
b48065e52337 [gaim-migrate @ 3503]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1024 }
b48065e52337 [gaim-migrate @ 3503]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1025 }
b48065e52337 [gaim-migrate @ 3503]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
1026
2370
25e7c2a68ed2 [gaim-migrate @ 2383]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2355
diff changeset
1027 static int perl_timeout(gpointer data)
573
9566a53cde23 [gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 565
diff changeset
1028 {
2370
25e7c2a68ed2 [gaim-migrate @ 2383]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2355
diff changeset
1029 struct _perl_timeout_handlers *handler = data;
2512
bf7ec3874810 [gaim-migrate @ 2525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2511
diff changeset
1030 execute_perl(handler->handler_name, escape_quotes(handler->handler_args));
573
9566a53cde23 [gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 565
diff changeset
1031 perl_timeout_handlers = g_list_remove(perl_timeout_handlers, handler);
2512
bf7ec3874810 [gaim-migrate @ 2525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2511
diff changeset
1032 g_free(handler->handler_args);
573
9566a53cde23 [gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 565
diff changeset
1033 g_free(handler->handler_name);
9566a53cde23 [gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 565
diff changeset
1034 g_free(handler);
9566a53cde23 [gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 565
diff changeset
1035
9566a53cde23 [gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 565
diff changeset
1036 return 0; /* returning zero removes the timeout handler */
9566a53cde23 [gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 565
diff changeset
1037 }
9566a53cde23 [gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 565
diff changeset
1038
1101
0ef4386edc29 [gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1100
diff changeset
1039 XS (XS_GAIM_add_timeout_handler)
561
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
1040 {
2048
3366311426df [gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1949
diff changeset
1041 unsigned int junk;
573
9566a53cde23 [gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 565
diff changeset
1042 long timeout;
9566a53cde23 [gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 565
diff changeset
1043 struct _perl_timeout_handlers *handler;
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
1044 char *handle;
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
1045 struct gaim_plugin *plug;
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
1046 GList *p = plugins;
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
1047
573
9566a53cde23 [gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 565
diff changeset
1048 dXSARGS;
9566a53cde23 [gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 565
diff changeset
1049 items = 0;
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
1050
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
1051 handle = SvPV(ST(0), junk);
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
1052 while (p) {
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
1053 plug = p->data;
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
1054 if (!strcmp(handle, plug->path))
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
1055 break;
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
1056 p = p->next;
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
1057 }
573
9566a53cde23 [gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 565
diff changeset
1058
3563
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
1059 if (p) {
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
1060 handler = g_new0(struct _perl_timeout_handlers, 1);
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
1061 timeout = 1000 * SvIV(ST(1));
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
1062 debug_printf("Adding timeout for %d seconds.\n", timeout/1000);
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
1063 handler->plug = plug;
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
1064 handler->handler_name = g_strdup(SvPV(ST(2), junk));
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
1065 handler->handler_args = g_strdup(SvPV(ST(3), junk));
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
1066 perl_timeout_handlers = g_list_append(perl_timeout_handlers, handler);
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
1067 handler->iotag = g_timeout_add(timeout, perl_timeout, handler);
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
1068 } else {
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
1069 debug_printf("Invalid handle (%s) in adding perl timeout handler.", handle);
e120097bbd72 [gaim-migrate @ 3658]
Sean Egan <seanegan@gmail.com>
parents: 3556
diff changeset
1070 }
573
9566a53cde23 [gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 565
diff changeset
1071 XSRETURN_EMPTY;
561
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
1072 }
9b36c91cce26 [gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 560
diff changeset
1073
3280
c98c1e0281ff [gaim-migrate @ 3298]
Sean Egan <seanegan@gmail.com>
parents: 3167
diff changeset
1074 XS (XS_GAIM_play_sound)
c98c1e0281ff [gaim-migrate @ 3298]
Sean Egan <seanegan@gmail.com>
parents: 3167
diff changeset
1075 {
c98c1e0281ff [gaim-migrate @ 3298]
Sean Egan <seanegan@gmail.com>
parents: 3167
diff changeset
1076 int id;
c98c1e0281ff [gaim-migrate @ 3298]
Sean Egan <seanegan@gmail.com>
parents: 3167
diff changeset
1077 dXSARGS;
c98c1e0281ff [gaim-migrate @ 3298]
Sean Egan <seanegan@gmail.com>
parents: 3167
diff changeset
1078
c98c1e0281ff [gaim-migrate @ 3298]
Sean Egan <seanegan@gmail.com>
parents: 3167
diff changeset
1079 id = SvIV(ST(0));
c98c1e0281ff [gaim-migrate @ 3298]
Sean Egan <seanegan@gmail.com>
parents: 3167
diff changeset
1080
c98c1e0281ff [gaim-migrate @ 3298]
Sean Egan <seanegan@gmail.com>
parents: 3167
diff changeset
1081 play_sound(id);
c98c1e0281ff [gaim-migrate @ 3298]
Sean Egan <seanegan@gmail.com>
parents: 3167
diff changeset
1082
c98c1e0281ff [gaim-migrate @ 3298]
Sean Egan <seanegan@gmail.com>
parents: 3167
diff changeset
1083 XSRETURN_EMPTY;
c98c1e0281ff [gaim-migrate @ 3298]
Sean Egan <seanegan@gmail.com>
parents: 3167
diff changeset
1084 }
c98c1e0281ff [gaim-migrate @ 3298]
Sean Egan <seanegan@gmail.com>
parents: 3167
diff changeset
1085
2370
25e7c2a68ed2 [gaim-migrate @ 2383]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2355
diff changeset
1086 extern void unload_perl_scripts()
798
9dc39872e1f9 [gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 797
diff changeset
1087 {
9dc39872e1f9 [gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 797
diff changeset
1088 perl_end();
9dc39872e1f9 [gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 797
diff changeset
1089 perl_init();
9dc39872e1f9 [gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 797
diff changeset
1090 }
9dc39872e1f9 [gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 797
diff changeset
1091
799
72f8ac951c11 [gaim-migrate @ 809]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 798
diff changeset
1092
560
cf3da01f451c [gaim-migrate @ 570]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1093 #endif /* USE_PERL */