annotate src/perl.c @ 5186:a107115a13ae

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