Mercurial > pidgin.yaz
annotate src/perl.c @ 2217:f7f5a23b6f76
[gaim-migrate @ 2227]
forgot this detail
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Thu, 06 Sep 2001 00:24:06 +0000 |
parents | b66aca8e8dce |
children | 8c4ff1a368bd |
rev | line source |
---|---|
560 | 1 /* |
2 * gaim | |
3 * | |
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 * This was taken almost exactly from X-Chat. The power of the GPL. | |
21 * Translated from X-Chat to Gaim by Eric Warmenhoven. | |
22 * Originally by Erik Scrafford <eriks@chilisoft.com>. | |
597
3a24fd19ff5f
[gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
23 * X-Chat Copyright (C) 1998 Peter Zelezny. |
560 | 24 * |
25 */ | |
26 | |
27 #ifdef HAVE_CONFIG_H | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2048
diff
changeset
|
28 #include <config.h> |
1896
e556ffa08cce
[gaim-migrate @ 1906]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1850
diff
changeset
|
29 #ifdef DEBUG |
e556ffa08cce
[gaim-migrate @ 1906]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1850
diff
changeset
|
30 #undef DEBUG |
e556ffa08cce
[gaim-migrate @ 1906]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1850
diff
changeset
|
31 #endif |
560 | 32 #endif |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
33 #undef PACKAGE |
560 | 34 |
580
9a8b067eb368
[gaim-migrate @ 590]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
579
diff
changeset
|
35 #ifdef USE_PERL |
560 | 36 |
37 #include <EXTERN.h> | |
38 #ifndef _SEM_SEMUN_UNDEFINED | |
39 #define HAS_UNION_SEMUN | |
40 #endif | |
41 #include <perl.h> | |
42 #include <XSUB.h> | |
43 #include <sys/mman.h> | |
44 #include <sys/types.h> | |
45 #include <sys/stat.h> | |
46 #include <fcntl.h> | |
47 #undef PACKAGE | |
48 #include <stdio.h> | |
800
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
49 #include <dirent.h> |
1238
78c4f497db2b
[gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1233
diff
changeset
|
50 #include <string.h> |
798
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
51 #include <gtk/gtk.h> |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
52 |
590
91f877d86ca6
[gaim-migrate @ 600]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
581
diff
changeset
|
53 |
91f877d86ca6
[gaim-migrate @ 600]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
581
diff
changeset
|
54 /* perl module support */ |
91f877d86ca6
[gaim-migrate @ 600]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
581
diff
changeset
|
55 extern void xs_init _((void)); |
91f877d86ca6
[gaim-migrate @ 600]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
581
diff
changeset
|
56 extern void boot_DynaLoader _((CV * cv)); /* perl is so wacky */ |
91f877d86ca6
[gaim-migrate @ 600]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
581
diff
changeset
|
57 |
91f877d86ca6
[gaim-migrate @ 600]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
581
diff
changeset
|
58 #undef _ |
1896
e556ffa08cce
[gaim-migrate @ 1906]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1850
diff
changeset
|
59 #ifdef DEBUG |
e556ffa08cce
[gaim-migrate @ 1906]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1850
diff
changeset
|
60 #undef DEBUG |
e556ffa08cce
[gaim-migrate @ 1906]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1850
diff
changeset
|
61 #endif |
560 | 62 #include "gaim.h" |
63 | |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
64 struct perlscript { |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
65 char *name; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
66 char *version; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
67 char *shutdowncallback; /* bleh */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
68 }; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
69 |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
70 struct _perl_event_handlers { |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
71 char *event_type; |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
72 char *handler_name; |
781
95ebfdb31a9b
[gaim-migrate @ 791]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
780
diff
changeset
|
73 }; |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
74 |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
75 struct _perl_timeout_handlers { |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
76 char *handler_name; |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
77 gint iotag; |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
78 }; |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
79 |
597
3a24fd19ff5f
[gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
80 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
|
81 static GList *perl_timeout_handlers = NULL; |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
82 static GList *perl_event_handlers = NULL; |
560 | 83 static PerlInterpreter *my_perl = NULL; |
1187
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
84 static char* last_dir = NULL; |
560 | 85 |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
86 /* dealing with gaim */ |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
87 XS(XS_GAIM_register); /* set up hooks for script */ |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
88 XS(XS_GAIM_get_info); /* version, last to attempt signon, protocol */ |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
89 XS(XS_GAIM_print); /* lemme figure this one out... */ |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
90 |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
91 /* list stuff */ |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
92 XS(XS_GAIM_buddy_list); /* all buddies */ |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
93 XS(XS_GAIM_online_list); /* online buddies */ |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
94 |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
95 /* server stuff */ |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
96 XS(XS_GAIM_command); /* send command to server */ |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
97 XS(XS_GAIM_user_info); /* given name, return struct buddy members */ |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
98 XS(XS_GAIM_print_to_conv); /* send message to someone */ |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
99 XS(XS_GAIM_print_to_chat); /* send message to chat room */ |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
100 |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
101 /* handler commands */ |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
102 XS(XS_GAIM_add_event_handler); /* when servers talk */ |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
103 XS(XS_GAIM_add_timeout_handler); /* figure it out */ |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
104 |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
105 void xs_init() |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
106 { |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
107 char *file = __FILE__; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
108 newXS ("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
109 } |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
110 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
111 static char *escape_quotes(char *buf) |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
112 { |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
113 static char *tmp_buf = NULL; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
114 char *i, *j; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
115 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
116 if (tmp_buf) |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
117 g_free(tmp_buf); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
118 tmp_buf = g_malloc(strlen(buf) * 2 + 1); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
119 for (i = buf, j = tmp_buf; *i; i++, j++) { |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
120 if (*i == '\'' || *i == '\\') |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
121 *j++ = '\\'; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
122 *j = *i; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
123 } |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
124 *j = '\0'; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
125 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
126 return (tmp_buf); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
127 } |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
128 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
129 static SV *execute_perl(char *function, char *args) |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
130 { |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
131 static char *perl_cmd = NULL; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
132 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
133 if (perl_cmd) |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
134 g_free(perl_cmd); |
1850
193420b4ca39
[gaim-migrate @ 1860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1764
diff
changeset
|
135 perl_cmd = g_malloc(strlen(function) + (strlen(args) * 2) + 2 + 10); |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
136 sprintf(perl_cmd, "&%s('%s')", function, escape_quotes(args)); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
137 #ifndef HAVE_PERL_EVAL_PV |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
138 return (perl_eval_pv(perl_cmd, TRUE)); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
139 #else |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
140 return (Perl_eval_pv(perl_cmd, TRUE)); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
141 #endif |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
142 } |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
143 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
144 int perl_load_file(char *script_name) |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
145 { |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
146 SV *return_val; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
147 return_val = execute_perl("load_file", script_name); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
148 return SvNV (return_val); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
149 } |
560 | 150 |
800
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
151 static int is_pl_file(char *filename) |
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
152 { |
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
153 int len; |
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
154 if (!filename) return 0; |
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
155 if (!filename[0]) return 0; |
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
156 len = strlen(filename); |
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
157 len -= 3; |
805
2f0655e185b8
[gaim-migrate @ 815]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
800
diff
changeset
|
158 if (len < 0) return 0; |
800
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
159 return (!strncmp(filename + len, ".pl", 3)); |
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
160 } |
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
161 |
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
162 void perl_autoload() |
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
163 { |
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
164 DIR *dir; |
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
165 struct dirent *ent; |
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
166 char *buf; |
1238
78c4f497db2b
[gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1233
diff
changeset
|
167 char *path; |
800
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
168 |
1238
78c4f497db2b
[gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1233
diff
changeset
|
169 path = gaim_user_dir(); |
800
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
170 dir = opendir(path); |
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
171 if (dir) { |
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
172 while ((ent = readdir(dir))) { |
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
173 if (strcmp(ent->d_name, ".") && strcmp(ent->d_name, "..")) { |
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
174 if (is_pl_file(ent->d_name)) { |
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
175 buf = g_malloc(strlen(path) + strlen(ent->d_name) + 2); |
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
176 sprintf(buf, "%s/%s", path, ent->d_name); |
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
177 perl_load_file(buf); |
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
178 g_free(buf); |
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
179 } |
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
180 } |
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
181 } |
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
182 closedir(dir); |
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
183 } |
1238
78c4f497db2b
[gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1233
diff
changeset
|
184 g_free(path); |
800
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
185 } |
022048cde898
[gaim-migrate @ 810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
799
diff
changeset
|
186 |
581
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
187 void perl_init() |
560 | 188 { |
947
1d021b2eb65d
[gaim-migrate @ 957]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
189 char *perl_args[] = {"", "-e", "0", "-w"}; |
560 | 190 char load_file[] = |
191 "sub load_file()\n" | |
192 "{\n" | |
193 " (my $file_name) = @_;\n" | |
194 " open FH, $file_name or return 2;\n" | |
947
1d021b2eb65d
[gaim-migrate @ 957]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
195 " my $is = $/;\n" |
560 | 196 " local($/) = undef;\n" |
197 " $file = <FH>;\n" | |
198 " close FH;\n" | |
947
1d021b2eb65d
[gaim-migrate @ 957]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
199 " $/ = $is;\n" |
1d021b2eb65d
[gaim-migrate @ 957]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
940
diff
changeset
|
200 " $file = \"\\@ISA = qw(Exporter DynaLoader);\\n\" . $file;\n" |
560 | 201 " eval $file;\n" |
202 " eval $file if $@;\n" | |
203 " return 1 if $@;\n" | |
204 " return 0;\n" | |
205 "}"; | |
206 | |
207 my_perl = perl_alloc(); | |
208 perl_construct(my_perl); | |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
209 perl_parse(my_perl, xs_init, 4, perl_args, NULL); |
560 | 210 #ifndef HAVE_PERL_EVAL_PV |
211 perl_eval_pv(load_file, TRUE); | |
212 #else | |
213 Perl_eval_pv(load_file, TRUE); | |
214 #endif | |
215 | |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
216 newXS ("GAIM::register", XS_GAIM_register, "GAIM"); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
217 newXS ("GAIM::get_info", XS_GAIM_get_info, "GAIM"); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
218 newXS ("GAIM::print", XS_GAIM_print, "GAIM"); |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
219 |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
220 newXS ("GAIM::buddy_list", XS_GAIM_buddy_list, "GAIM"); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
221 newXS ("GAIM::online_list", XS_GAIM_online_list, "GAIM"); |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
222 |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
223 newXS ("GAIM::command", XS_GAIM_command, "GAIM"); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
224 newXS ("GAIM::user_info", XS_GAIM_user_info, "GAIM"); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
225 newXS ("GAIM::print_to_conv", XS_GAIM_print_to_conv, "GAIM"); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
226 newXS ("GAIM::print_to_chat", XS_GAIM_print_to_chat, "GAIM"); |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
227 |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
228 newXS ("GAIM::add_event_handler", XS_GAIM_add_event_handler, "GAIM"); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
229 newXS ("GAIM::add_timeout_handler", XS_GAIM_add_timeout_handler, "GAIM"); |
560 | 230 } |
231 | |
232 void perl_end() | |
233 { | |
565
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
234 struct perlscript *scp; |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
235 struct _perl_timeout_handlers *thn; |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
236 struct _perl_event_handlers *ehn; |
565
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
237 |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
238 while (perl_list) { |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
239 scp = perl_list->data; |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
240 perl_list = g_list_remove(perl_list, scp); |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
241 if (scp->shutdowncallback[0]) |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
242 execute_perl(scp->shutdowncallback, ""); |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
243 g_free(scp->name); |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
244 g_free(scp->version); |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
245 g_free(scp->shutdowncallback); |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
246 g_free(scp); |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
247 } |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
248 |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
249 while (perl_timeout_handlers) { |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
250 thn = perl_timeout_handlers->data; |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
251 perl_timeout_handlers = g_list_remove(perl_timeout_handlers, thn); |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
252 gtk_timeout_remove(thn->iotag); |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
253 g_free(thn->handler_name); |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
254 g_free(thn); |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
255 } |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
256 |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
257 while (perl_event_handlers) { |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
258 ehn = perl_event_handlers->data; |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
259 perl_event_handlers = g_list_remove(perl_event_handlers, ehn); |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
260 g_free(ehn->event_type); |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
261 g_free(ehn->handler_name); |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
262 g_free(ehn); |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
263 } |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
264 |
560 | 265 if (my_perl != NULL) { |
266 perl_destruct(my_perl); | |
267 perl_free(my_perl); | |
268 my_perl = NULL; | |
269 } | |
270 } | |
271 | |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
272 XS (XS_GAIM_register) |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
273 { |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
274 char *name, *ver, *callback, *unused; /* exactly like X-Chat, eh? :) */ |
2048
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1949
diff
changeset
|
275 unsigned int junk; |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
276 struct perlscript *scp; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
277 dXSARGS; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
278 items = 0; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
279 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
280 name = SvPV (ST (0), junk); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
281 ver = SvPV (ST (1), junk); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
282 callback = SvPV (ST (2), junk); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
283 unused = SvPV (ST (3), junk); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
284 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
285 scp = g_new0(struct perlscript, 1); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
286 scp->name = g_strdup(name); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
287 scp->version = g_strdup(ver); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
288 scp->shutdowncallback = g_strdup(callback); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
289 perl_list = g_list_append(perl_list, scp); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
290 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
291 XST_mPV (0, VERSION); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
292 XSRETURN (1); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
293 } |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
294 |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
295 XS (XS_GAIM_get_info) |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
296 { |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
297 int i = 0; |
2048
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1949
diff
changeset
|
298 unsigned int junk; |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
299 dXSARGS; |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
300 items = 0; |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
301 |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
302 switch(atoi(SvPV(ST(0), junk))) { |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
303 case 0: |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
304 XST_mPV(0, VERSION); |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
305 i = 1; |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
306 break; |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
307 case 1: |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
308 { |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
309 GSList *c = connections; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
310 struct gaim_connection *gc; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
311 |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
312 while (c) { |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
313 gc = (struct gaim_connection *)c->data; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
314 XST_mPV(i++, gc->username); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
315 c = c->next; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
316 } |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
317 } |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
318 break; |
591
a26eb4c472d8
[gaim-migrate @ 601]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
590
diff
changeset
|
319 case 2: |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
320 { |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
321 GList *u = aim_users; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
322 struct aim_user *a; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
323 char *name = g_strdup(normalize(SvPV(ST(1), junk))); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
324 |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
325 while (u) { |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
326 a = (struct aim_user *)u->data; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
327 if (!strcasecmp(normalize(a->username), name)) |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
328 XST_mIV(i++, a->protocol); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
329 u = u->next; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
330 } |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
331 g_free(name); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
332 } |
591
a26eb4c472d8
[gaim-migrate @ 601]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
590
diff
changeset
|
333 break; |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
334 default: |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
335 XST_mPV(0, "Error2"); |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
336 i = 1; |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
337 } |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
338 |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
339 XSRETURN(i); |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
340 } |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
341 |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
342 XS (XS_GAIM_print) |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
343 { |
592
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
591
diff
changeset
|
344 char *title; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
591
diff
changeset
|
345 char *message; |
2048
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1949
diff
changeset
|
346 unsigned int junk; |
592
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
591
diff
changeset
|
347 dXSARGS; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
591
diff
changeset
|
348 items = 0; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
591
diff
changeset
|
349 |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
591
diff
changeset
|
350 title = SvPV(ST(0), junk); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
591
diff
changeset
|
351 message = SvPV(ST(1), junk); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
591
diff
changeset
|
352 do_error_dialog(message, title); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
591
diff
changeset
|
353 XSRETURN(0); |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
354 } |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
355 |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
356 XS (XS_GAIM_buddy_list) |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
357 { |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
358 char *acct; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
359 struct gaim_connection *gc; |
581
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
360 struct buddy *buddy; |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
361 struct group *g; |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
362 GSList *list = NULL; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
363 GSList *mem; |
581
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
364 int i = 0; |
2048
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1949
diff
changeset
|
365 unsigned int junk; |
581
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
366 dXSARGS; |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
367 items = 0; |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
368 |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
369 acct = SvPV(ST(0), junk); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
370 gc = find_gaim_conn_by_name(acct); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
371 if (gc) list = gc->groups; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
372 |
581
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
373 while (list) { |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
374 g = (struct group *)list->data; |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
375 mem = g->members; |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
376 while (mem) { |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
377 buddy = (struct buddy *)mem->data; |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
378 XST_mPV(i++, buddy->name); |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
379 mem = mem->next; |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
380 } |
940 | 381 list = g_slist_next(list); |
581
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
382 } |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
383 XSRETURN(i); |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
384 } |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
385 |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
386 XS (XS_GAIM_online_list) |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
387 { |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
388 char *acct; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
389 struct gaim_connection *gc; |
581
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
390 struct buddy *b; |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
391 struct group *g; |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
392 GSList *list = NULL; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
393 GSList *mem; |
581
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
394 int i = 0; |
2048
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1949
diff
changeset
|
395 unsigned int junk; |
581
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
396 dXSARGS; |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
397 items = 0; |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
398 |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
399 acct = SvPV(ST(0), junk); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
400 gc = find_gaim_conn_by_name(acct); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
401 if (gc) list = gc->groups; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
402 |
581
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
403 while (list) { |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
404 g = (struct group *)list->data; |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
405 mem = g->members; |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
406 while (mem) { |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
407 b = (struct buddy *)mem->data; |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
408 if (b->present) XST_mPV(i++, b->name); |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
409 mem = mem->next; |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
410 } |
940 | 411 list = g_slist_next(list); |
581
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
412 } |
c72e5ee07d0a
[gaim-migrate @ 591]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
580
diff
changeset
|
413 XSRETURN(i); |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
414 } |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
415 |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
416 XS (XS_GAIM_command) |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
417 { |
2048
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1949
diff
changeset
|
418 unsigned int junk; |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
419 char *command = NULL; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
420 dXSARGS; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
421 items = 0; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
422 |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
423 command = SvPV(ST(0), junk); |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
424 if (!command) XSRETURN(0); |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
425 if (!strncasecmp(command, "signon", 6)) { |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
426 char *who = SvPV(ST(1), junk); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
427 struct aim_user *u = find_user(who, -1); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
428 if (u) serv_login(u); |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
429 } else if (!strncasecmp(command, "signoff", 7)) { |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
430 char *who = SvPV(ST(1), junk); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
431 struct gaim_connection *gc = find_gaim_conn_by_name(who); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
432 if (gc) signoff(gc); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
433 else signoff_all(NULL, NULL); |
1730
2d7601acacdd
[gaim-migrate @ 1740]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
434 } else if (!strncasecmp(command, "info", 4)) { |
2d7601acacdd
[gaim-migrate @ 1740]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
435 GSList *c = connections; |
2d7601acacdd
[gaim-migrate @ 1740]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
436 struct gaim_connection *gc; |
2d7601acacdd
[gaim-migrate @ 1740]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
437 while (c) { |
2d7601acacdd
[gaim-migrate @ 1740]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
438 gc = (struct gaim_connection *)c->data; |
2d7601acacdd
[gaim-migrate @ 1740]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
439 serv_set_info(gc, SvPV(ST(1), junk)); |
2d7601acacdd
[gaim-migrate @ 1740]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
440 c = c->next; |
2d7601acacdd
[gaim-migrate @ 1740]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
441 } |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
442 } else if (!strncasecmp(command, "away", 4)) { |
630
3d2f14064083
[gaim-migrate @ 640]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
628
diff
changeset
|
443 char *message = SvPV(ST(1), junk); |
1106
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1101
diff
changeset
|
444 static struct away_message a; |
630
3d2f14064083
[gaim-migrate @ 640]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
628
diff
changeset
|
445 g_snprintf(a.message, sizeof(a.message), "%s", message); |
3d2f14064083
[gaim-migrate @ 640]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
628
diff
changeset
|
446 do_away_message(NULL, &a); |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
447 } else if (!strncasecmp(command, "back", 4)) { |
628
a46a68d46d2b
[gaim-migrate @ 638]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
603
diff
changeset
|
448 do_im_back(); |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
449 } else if (!strncasecmp(command, "idle", 4)) { |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
450 GSList *c = connections; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
451 struct gaim_connection *gc; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
452 |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
453 while (c) { |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
454 gc = (struct gaim_connection *)c->data; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
455 serv_set_idle(gc, atoi(SvPV(ST(1), junk))); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
456 gc->is_idle = 1; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
457 c = c->next; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
458 } |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
459 } else if (!strncasecmp(command, "warn", 4)) { |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
460 GSList *c = connections; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
461 struct gaim_connection *gc; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
462 |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
463 while (c) { |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
464 gc = (struct gaim_connection *)c->data; |
1734
dd78a230aa06
[gaim-migrate @ 1744]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1730
diff
changeset
|
465 serv_warn(gc, SvPV(ST(1), junk), atoi(SvPV(ST(2), junk))); |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
466 c = c->next; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
467 } |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
468 } |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
469 |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
470 XSRETURN(0); |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
471 } |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
472 |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
473 XS (XS_GAIM_user_info) |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
474 { |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
475 GSList *c = connections; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
476 struct gaim_connection *gc; |
2048
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1949
diff
changeset
|
477 unsigned int junk; |
1114
c61f9c384413
[gaim-migrate @ 1124]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1106
diff
changeset
|
478 struct buddy *buddy = NULL; |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
479 char *nick; |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
480 dXSARGS; |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
481 items = 0; |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
482 |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
483 nick = SvPV(ST(0), junk); |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
484 if (!nick[0]) |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
485 XSRETURN(0); |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
486 while (c) { |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
487 gc = (struct gaim_connection *)c->data; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
488 buddy = find_buddy(gc, nick); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
489 if (buddy) c = NULL; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
490 else c = c->next; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
491 } |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
492 if (!buddy) |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
493 XSRETURN(0); |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
494 XST_mPV(0, buddy->name); |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
495 XST_mPV(1, buddy->show); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
496 XST_mPV(2, buddy->present ? "Online" : "Offline"); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
497 XST_mIV(3, buddy->evil); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
498 XST_mIV(4, buddy->signon); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
499 XST_mIV(5, buddy->idle); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
500 XST_mIV(6, buddy->uc); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
501 XST_mIV(7, buddy->caps); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
502 XSRETURN(8); |
597
3a24fd19ff5f
[gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
503 } |
3a24fd19ff5f
[gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
504 |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
505 XS (XS_GAIM_print_to_conv) |
597
3a24fd19ff5f
[gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
506 { |
1730
2d7601acacdd
[gaim-migrate @ 1740]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
507 char *nick, *what, *isauto; |
597
3a24fd19ff5f
[gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
508 struct conversation *c; |
2048
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1949
diff
changeset
|
509 unsigned int junk; |
597
3a24fd19ff5f
[gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
510 dXSARGS; |
3a24fd19ff5f
[gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
511 items = 0; |
3a24fd19ff5f
[gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
512 |
3a24fd19ff5f
[gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
513 nick = SvPV(ST(0), junk); |
3a24fd19ff5f
[gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
514 what = SvPV(ST(1), junk); |
1730
2d7601acacdd
[gaim-migrate @ 1740]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
515 isauto = SvPV(ST(2), junk); |
597
3a24fd19ff5f
[gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
516 c = find_conversation(nick); |
3a24fd19ff5f
[gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
517 if (!c) |
3a24fd19ff5f
[gaim-migrate @ 607]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
518 c = new_conversation(nick); |
1764 | 519 write_to_conv(c, what, WFLAG_SEND, NULL, time((time_t)NULL)); |
1730
2d7601acacdd
[gaim-migrate @ 1740]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
520 serv_send_im(c->gc, nick, what, atoi(isauto)); |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
521 } |
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
522 |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
523 XS (XS_GAIM_print_to_chat) |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
524 { |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
525 char *nick, *what, *tmp; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
526 GSList *c = connections; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
527 struct gaim_connection *gc; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
528 struct conversation *b = NULL; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
529 GSList *bcs; |
2048
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1949
diff
changeset
|
530 unsigned int junk; |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
531 dXSARGS; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
532 items = 0; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
533 |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
534 nick = SvPV(ST(0), junk); |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
535 what = SvPV(ST(1), junk); |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
536 tmp = g_strdup(normalize(nick)); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
537 while (c) { |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
538 gc = (struct gaim_connection *)c->data; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
539 bcs = gc->buddy_chats; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
540 while (bcs) { |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
541 b = (struct conversation *)bcs->data; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
542 if (!strcmp(normalize(b->name), tmp)) |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
543 break; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
544 bcs = bcs->next; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
545 b = NULL; |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
546 } |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
547 serv_chat_send(b->gc, b->id, what); |
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
548 c = c->next; |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
549 } |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
550 XSRETURN(0); |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
551 } |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
597
diff
changeset
|
552 |
806
67bdecdecbb7
[gaim-migrate @ 816]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
805
diff
changeset
|
553 int perl_event(char *event, char *args) |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
554 { |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
555 GList *handler; |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
556 struct _perl_event_handlers *data; |
1100
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
557 SV *handler_return; |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
558 |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
559 for (handler = perl_event_handlers; handler != NULL; handler = handler->next) { |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
560 data = handler->data; |
1100
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
561 if (!strcmp(event, data->event_type)) { |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
562 handler_return = execute_perl(data->handler_name, args); |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
563 if (SvIV(handler_return)) |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
564 return SvIV(handler_return); |
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
565 } |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
566 } |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
567 |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
568 return 0; |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
569 } |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
570 |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
571 XS (XS_GAIM_add_event_handler) |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
572 { |
2048
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1949
diff
changeset
|
573 unsigned int junk; |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
574 struct _perl_event_handlers *handler; |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
575 dXSARGS; |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
576 items = 0; |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
577 |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
578 handler = g_new0(struct _perl_event_handlers, 1); |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
579 handler->event_type = g_strdup(SvPV(ST(0), junk)); |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
580 handler->handler_name = g_strdup(SvPV(ST(1), junk)); |
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
581 perl_event_handlers = g_list_append(perl_event_handlers, handler); |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1241
diff
changeset
|
582 debug_printf("registered perl event handler for %s\n", handler->event_type); |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
749
diff
changeset
|
583 XSRETURN_EMPTY; |
579
7b501c39a6ee
[gaim-migrate @ 589]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
577
diff
changeset
|
584 } |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
585 |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
586 static int perl_timeout(struct _perl_timeout_handlers *handler) |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
587 { |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
588 execute_perl(handler->handler_name, ""); |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
589 perl_timeout_handlers = g_list_remove(perl_timeout_handlers, handler); |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
590 g_free(handler->handler_name); |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
591 g_free(handler); |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
592 |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
593 return 0; /* returning zero removes the timeout handler */ |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
594 } |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
595 |
1101
0ef4386edc29
[gaim-migrate @ 1111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1100
diff
changeset
|
596 XS (XS_GAIM_add_timeout_handler) |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
597 { |
2048
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1949
diff
changeset
|
598 unsigned int junk; |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
599 long timeout; |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
600 struct _perl_timeout_handlers *handler; |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
601 dXSARGS; |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
602 items = 0; |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
603 |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
604 handler = g_new0(struct _perl_timeout_handlers, 1); |
806
67bdecdecbb7
[gaim-migrate @ 816]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
805
diff
changeset
|
605 timeout = 1000 * atol(SvPV(ST(0), junk)); |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
606 handler->handler_name = g_strdup(SvPV(ST(1), junk)); |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
607 perl_timeout_handlers = g_list_append(perl_timeout_handlers, handler); |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
608 handler->iotag = gtk_timeout_add(timeout, (GtkFunction)perl_timeout, handler); |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
609 XSRETURN_EMPTY; |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
610 } |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
611 |
1187
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
612 static GtkWidget *config = NULL; |
798
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
613 |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
614 static void cfdes(GtkWidget *m, gpointer n) { |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
615 if (config) gtk_widget_destroy(config); |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
616 config = NULL; |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
617 } |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
618 |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
619 static void do_load(GtkWidget *m, gpointer n) { |
1949
3397860c22e9
[gaim-migrate @ 1959]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1947
diff
changeset
|
620 const char *file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(config)); |
3397860c22e9
[gaim-migrate @ 1959]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1947
diff
changeset
|
621 gchar *f = NULL; |
3397860c22e9
[gaim-migrate @ 1959]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1947
diff
changeset
|
622 if (!file || !strlen(file)) { |
798
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
623 perl_end(); |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
624 perl_init(); |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
625 return; |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
626 } |
1187
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
627 |
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
628 if (file_is_dir(file, config)) { |
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
629 return; |
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
630 } |
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
631 |
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
632 if (last_dir) { |
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
633 g_free(last_dir); |
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
634 } |
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
635 last_dir = g_dirname(file); |
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
636 |
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
637 debug_printf("Loading perl script: %s\n", file); |
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
638 |
1949
3397860c22e9
[gaim-migrate @ 1959]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1947
diff
changeset
|
639 f = g_strdup(file); |
3397860c22e9
[gaim-migrate @ 1959]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1947
diff
changeset
|
640 perl_load_file(f); |
3397860c22e9
[gaim-migrate @ 1959]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1947
diff
changeset
|
641 g_free(f); |
1187
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
642 cfdes(config, NULL); |
798
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
643 } |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
644 |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
645 void load_perl_script(GtkWidget *w, gpointer d) |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
646 { |
1240
0daea098b438
[gaim-migrate @ 1250]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1238
diff
changeset
|
647 char *buf, *temp; |
798
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
648 |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
649 if (config) { |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
650 gtk_widget_show(config); |
1187
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
651 gdk_window_raise(config->window); |
798
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
652 return; |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
653 } |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
654 |
1187
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
655 /* Below is basically stolen from plugins.c */ |
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
656 config = gtk_file_selection_new(_("Gaim - Select Perl Script")); |
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
657 |
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
658 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(config)); |
798
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
659 |
1187
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
660 if (!last_dir) { |
1238
78c4f497db2b
[gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1233
diff
changeset
|
661 temp = gaim_user_dir(); |
1241
1881b8c12350
[gaim-migrate @ 1251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1240
diff
changeset
|
662 buf = g_strconcat(temp, G_DIR_SEPARATOR_S, NULL); |
1238
78c4f497db2b
[gaim-migrate @ 1248]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1233
diff
changeset
|
663 g_free(temp); |
1187
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
664 } else { |
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
665 buf = g_strconcat(last_dir, G_DIR_SEPARATOR_S, NULL); |
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
666 } |
798
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
667 |
1187
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
668 gtk_file_selection_set_filename(GTK_FILE_SELECTION(config), buf); |
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
669 gtk_file_selection_complete(GTK_FILE_SELECTION(config), "*.pl"); |
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
670 gtk_signal_connect(GTK_OBJECT(config), "destroy", GTK_SIGNAL_FUNC(cfdes), |
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
671 config); |
798
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
672 |
1187
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
673 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(config)->ok_button), |
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
674 "clicked", GTK_SIGNAL_FUNC(do_load), NULL); |
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
675 |
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
676 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(config)->cancel_button), |
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
677 "clicked", GTK_SIGNAL_FUNC(cfdes), NULL); |
798
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
678 |
1187
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
679 g_free(buf); |
798
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
680 gtk_widget_show(config); |
1187
6a8e8c06baa5
[gaim-migrate @ 1197]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
681 gdk_window_raise(config->window); |
798
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
682 } |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
683 |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
684 extern void unload_perl_scripts(GtkWidget *w, gpointer d) |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
685 { |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
686 perl_end(); |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
687 perl_init(); |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
688 } |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
689 |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
690 extern void list_perl_scripts(GtkWidget *w, gpointer d) |
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
691 { |
799
72f8ac951c11
[gaim-migrate @ 809]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
798
diff
changeset
|
692 GList *s = perl_list; |
72f8ac951c11
[gaim-migrate @ 809]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
798
diff
changeset
|
693 struct perlscript *p; |
72f8ac951c11
[gaim-migrate @ 809]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
798
diff
changeset
|
694 char buf[BUF_LONG * 4]; |
72f8ac951c11
[gaim-migrate @ 809]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
798
diff
changeset
|
695 int at = 0; |
72f8ac951c11
[gaim-migrate @ 809]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
798
diff
changeset
|
696 |
72f8ac951c11
[gaim-migrate @ 809]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
798
diff
changeset
|
697 at += g_snprintf(buf + at, sizeof(buf) - at, "Loaded scripts:\n"); |
72f8ac951c11
[gaim-migrate @ 809]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
798
diff
changeset
|
698 while (s) { |
72f8ac951c11
[gaim-migrate @ 809]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
798
diff
changeset
|
699 p = (struct perlscript *)s->data; |
72f8ac951c11
[gaim-migrate @ 809]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
798
diff
changeset
|
700 at += g_snprintf(buf + at, sizeof(buf) - at, "%s\n", p->name); |
72f8ac951c11
[gaim-migrate @ 809]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
798
diff
changeset
|
701 s = s->next; |
72f8ac951c11
[gaim-migrate @ 809]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
798
diff
changeset
|
702 } |
72f8ac951c11
[gaim-migrate @ 809]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
798
diff
changeset
|
703 |
72f8ac951c11
[gaim-migrate @ 809]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
798
diff
changeset
|
704 do_error_dialog(buf, _("Perl Scripts")); |
798
9dc39872e1f9
[gaim-migrate @ 808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
797
diff
changeset
|
705 } |
799
72f8ac951c11
[gaim-migrate @ 809]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
798
diff
changeset
|
706 |
560 | 707 #endif /* USE_PERL */ |