Mercurial > pidgin.yaz
annotate src/protocols/toc/toc.c @ 5605:4fa8ca4f4259
[gaim-migrate @ 6009]
i'm a search-and-replace machine!
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Sat, 31 May 2003 15:40:32 +0000 |
parents | cce2d7868c78 |
children | 0bdfa28c678e |
rev | line source |
---|---|
2086 | 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 */ | |
21 | |
22 | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
25 #include <config.h> |
2086 | 26 #endif |
3630 | 27 |
28 #ifndef _WIN32 | |
2086 | 29 #include <netdb.h> |
30 #include <unistd.h> | |
31 #include <netinet/in.h> | |
32 #include <arpa/inet.h> | |
3630 | 33 #include <sys/socket.h> |
34 #else | |
35 #include <winsock.h> | |
36 #endif | |
37 | |
38 #include <gtk/gtk.h> | |
39 #include <errno.h> | |
2086 | 40 #include <string.h> |
41 #include <stdlib.h> | |
42 #include <stdio.h> | |
43 #include <time.h> | |
44 #include <sys/types.h> | |
45 #include <sys/stat.h> | |
46 #include "prpl.h" | |
47 #include "multi.h" | |
48 #include "gaim.h" | |
49 #include "proxy.h" | |
50 | |
3630 | 51 #ifdef _WIN32 |
52 #include "win32dep.h" | |
53 #endif | |
54 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
55 static GaimPlugin *my_protocol = NULL; |
4249 | 56 |
2086 | 57 #define REVISION "penguin" |
58 | |
59 #define TYPE_SIGNON 1 | |
60 #define TYPE_DATA 2 | |
61 #define TYPE_ERROR 3 | |
62 #define TYPE_SIGNOFF 4 | |
63 #define TYPE_KEEPALIVE 5 | |
64 | |
65 #define FLAPON "FLAPON\r\n\r\n" | |
66 #define ROAST "Tic/Toc" | |
67 | |
68 #define TOC_HOST "toc.oscar.aol.com" | |
69 #define TOC_PORT 9898 | |
70 #define AUTH_HOST "login.oscar.aol.com" | |
71 #define AUTH_PORT 5190 | |
72 #define LANGUAGE "english" | |
73 | |
74 #define STATE_OFFLINE 0 | |
75 #define STATE_FLAPON 1 | |
76 #define STATE_SIGNON_REQUEST 2 | |
77 #define STATE_ONLINE 3 | |
78 #define STATE_PAUSE 4 | |
79 | |
80 #define VOICE_UID "09461341-4C7F-11D1-8222-444553540000" | |
81 #define FILE_SEND_UID "09461343-4C7F-11D1-8222-444553540000" | |
82 #define IMAGE_UID "09461345-4C7F-11D1-8222-444553540000" | |
83 #define B_ICON_UID "09461346-4C7F-11D1-8222-444553540000" | |
84 #define STOCKS_UID "09461347-4C7F-11D1-8222-444553540000" | |
85 #define FILE_GET_UID "09461348-4C7F-11D1-8222-444553540000" | |
86 #define GAMES_UID "0946134a-4C7F-11D1-8222-444553540000" | |
87 | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2453
diff
changeset
|
88 #define UC_AOL 0x02 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2453
diff
changeset
|
89 #define UC_ADMIN 0x04 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2453
diff
changeset
|
90 #define UC_UNCONFIRMED 0x08 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2453
diff
changeset
|
91 #define UC_NORMAL 0x10 |
3083 | 92 #define UC_WIRELESS 0x20 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2453
diff
changeset
|
93 |
2086 | 94 struct ft_request { |
5605 | 95 GaimConnection *gc; |
2086 | 96 char *user; |
97 char UID[2048]; | |
98 char *cookie; | |
99 char *ip; | |
100 int port; | |
101 char *message; | |
102 char *filename; | |
103 int files; | |
104 int size; | |
105 }; | |
106 | |
107 struct buddy_icon { | |
108 guint32 hash; | |
109 guint32 len; | |
110 time_t time; | |
111 void *data; | |
112 }; | |
113 | |
114 struct toc_data { | |
115 int toc_fd; | |
4597 | 116 char toc_ip[20]; |
2086 | 117 int seqno; |
118 int state; | |
119 }; | |
120 | |
121 struct sflap_hdr { | |
122 unsigned char ast; | |
123 unsigned char type; | |
124 unsigned short seqno; | |
125 unsigned short len; | |
126 }; | |
127 | |
128 struct signon { | |
129 unsigned int ver; | |
130 unsigned short tag; | |
131 unsigned short namelen; | |
132 char username[80]; | |
133 }; | |
134 | |
135 /* constants to identify proto_opts */ | |
136 #define USEROPT_AUTH 0 | |
137 #define USEROPT_AUTHPORT 1 | |
138 | |
5605 | 139 #define TOC_CONNECT_STEPS 3 |
140 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
141 static void toc_login_callback(gpointer, gint, GaimInputCondition); |
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
142 static void toc_callback(gpointer, gint, GaimInputCondition); |
2086 | 143 static void accept_file_dialog(struct ft_request *); |
144 | |
3630 | 145 /* The following were added for win32 port - Herman */ |
146 | |
147 int toc_write(int fd, const void *buffer, int len) | |
148 { | |
149 #ifndef _WIN32 | |
150 return write(fd, buffer, len); | |
151 #else | |
152 return send(fd, buffer, len, 0); | |
153 #endif | |
154 } | |
155 | |
156 int toc_read(int fd, void *buffer, int size) | |
157 { | |
158 #ifndef _WIN32 | |
159 return read(fd, buffer, size); | |
160 #else | |
161 return recv(fd, buffer, size, 0); | |
162 #endif | |
163 } | |
164 | |
165 int toc_soc_close( int fd ) | |
166 { | |
167 #ifndef _WIN32 | |
168 return close(fd); | |
169 #else | |
170 return closesocket(fd); | |
171 #endif | |
172 } | |
173 | |
174 | |
2086 | 175 /* ok. this function used to take username/password, and return 0 on success. |
176 * now, it takes username/password, and returns NULL on error or a new gaim_connection | |
177 * on success. */ | |
5605 | 178 static void toc_login(GaimAccount *account) |
2086 | 179 { |
5605 | 180 GaimConnection *gc; |
2086 | 181 struct toc_data *tdt; |
182 char buf[80]; | |
183 | |
5605 | 184 gc = gaim_account_get_connection(account); |
2086 | 185 gc->proto_data = tdt = g_new0(struct toc_data, 1); |
2918
4df759d607f3
[gaim-migrate @ 2931]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2916
diff
changeset
|
186 gc->flags |= OPT_CONN_HTML; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
187 gc->flags |= OPT_CONN_AUTO_RESP; |
2086 | 188 |
4834 | 189 g_snprintf(buf, sizeof buf, _("Looking up %s"), |
5605 | 190 gaim_account_get_string(account, "server", TOC_HOST)); |
191 gaim_connection_update_progress(gc, buf, 1, TOC_CONNECT_STEPS); | |
2086 | 192 |
193 debug_printf("* Client connects to TOC\n"); | |
5605 | 194 if (proxy_connect(account, |
195 gaim_account_get_string(account, "server", TOC_HOST), | |
196 gaim_account_get_int(account, "port", TOC_PORT), | |
4491 | 197 toc_login_callback, gc) != 0 || !account->gc) { |
5605 | 198 g_snprintf(buf, sizeof(buf), "Connect to %s failed", |
199 gaim_account_get_string(account, "server", TOC_HOST)); | |
200 gaim_connection_error(gc, buf); | |
2086 | 201 return; |
202 } | |
203 } | |
204 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
205 static void toc_login_callback(gpointer data, gint source, GaimInputCondition cond) |
2086 | 206 { |
5605 | 207 GaimConnection *gc = data; |
2086 | 208 struct toc_data *tdt; |
209 char buf[80]; | |
4597 | 210 struct sockaddr_in name; |
211 socklen_t namelen; | |
2086 | 212 |
5605 | 213 if (!g_list_find(gaim_connections_get_all(), data)) { |
3630 | 214 toc_soc_close(source); |
2086 | 215 return; |
216 } | |
217 | |
218 tdt = gc->proto_data; | |
219 | |
220 if (source == -1) { | |
221 /* we didn't successfully connect. tdt->toc_fd is valid here */ | |
5605 | 222 gaim_connection_error(gc, "Unable to connect."); |
2086 | 223 return; |
224 } | |
4452 | 225 tdt->toc_fd = source; |
2086 | 226 |
4597 | 227 /* |
228 * Copy the IP that we're connected to. We need this because "GOTO_URL"'s | |
229 * should open on the exact server we're connected to. toc.oscar.aol.com | |
230 * doesn't work because that hostname resolves to multiple IP addresses. | |
231 */ | |
232 if (getpeername(tdt->toc_fd, (struct sockaddr *)&name, &namelen) == 0) | |
233 strncpy(tdt->toc_ip, inet_ntoa(name.sin_addr), sizeof(tdt->toc_ip)); | |
234 else | |
5605 | 235 strncpy(tdt->toc_ip, gaim_account_get_string(gc->account, "server", TOC_HOST), sizeof(tdt->toc_ip)); |
4597 | 236 |
2086 | 237 debug_printf("* Client sends \"FLAPON\\r\\n\\r\\n\"\n"); |
3630 | 238 if (toc_write(tdt->toc_fd, FLAPON, strlen(FLAPON)) < 0) { |
5605 | 239 gaim_connection_error(gc, "Disconnected."); |
2086 | 240 return; |
241 } | |
242 tdt->state = STATE_FLAPON; | |
243 | |
244 /* i know a lot of people like to look at gaim to see how TOC works. so i'll comment | |
245 * on what this does. it's really simple. when there's data ready to be read from the | |
246 * toc_fd file descriptor, toc_callback is called, with gc passed as its data arg. */ | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
247 gc->inpa = gaim_input_add(tdt->toc_fd, GAIM_INPUT_READ, toc_callback, gc); |
2086 | 248 |
5605 | 249 g_snprintf(buf, sizeof(buf), _("Signon: %s"), gaim_account_get_username(gc->account)); |
250 gaim_connection_update_progress(gc, buf, 2, TOC_CONNECT_STEPS); | |
2086 | 251 } |
252 | |
5605 | 253 static void toc_close(GaimConnection *gc) |
2086 | 254 { |
255 if (gc->inpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
256 gaim_input_remove(gc->inpa); |
2086 | 257 gc->inpa = 0; |
3630 | 258 toc_soc_close(((struct toc_data *)gc->proto_data)->toc_fd); |
2086 | 259 g_free(gc->proto_data); |
260 } | |
261 | |
5605 | 262 static void toc_build_config(GaimAccount *account, char *s, int len, gboolean show) |
4687 | 263 { |
4785 | 264 GaimBlistNode *gnode,*bnode; |
4687 | 265 struct group *g; |
266 struct buddy *b; | |
267 GSList *plist = account->permit; | |
268 GSList *dlist = account->deny; | |
269 | |
270 int pos = 0; | |
271 | |
5605 | 272 if (!account->perm_deny) |
273 account->perm_deny = 1; | |
4687 | 274 |
5605 | 275 pos += g_snprintf(&s[pos], len - pos, "m %d\n", account->perm_deny); |
4785 | 276 for(gnode = gaim_get_blist()->root; gnode && len > pos; gnode = gnode->next) { |
277 g = (struct group *)gnode; | |
278 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
279 continue; | |
4687 | 280 if(gaim_group_on_account(g, account)) { |
281 pos += g_snprintf(&s[pos], len - pos, "g %s\n", g->name); | |
4785 | 282 for(bnode = gnode->child; bnode && len > pos; bnode = bnode->next) { |
283 b = (struct buddy *)bnode; | |
284 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
285 continue; | |
4687 | 286 if(b->account == account) { |
287 pos += g_snprintf(&s[pos], len - pos, "b %s%s%s\n", b->name, | |
4705 | 288 (show && b->alias) ? ":" : "", |
289 (show && b->alias) ? b->alias : ""); | |
4687 | 290 } |
291 } | |
292 } | |
293 } | |
294 | |
295 while (len > pos && plist) { | |
296 pos += g_snprintf(&s[pos], len - pos, "p %s\n", (char *)plist->data); | |
297 plist = plist->next; | |
298 } | |
299 | |
300 while (len > pos && dlist) { | |
301 pos += g_snprintf(&s[pos], len - pos, "d %s\n", (char *)dlist->data); | |
302 dlist = dlist->next; | |
303 } | |
304 } | |
305 | |
2371
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
306 static int escape_message(char *msg) |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
307 { |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
308 char *c, *cpy; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
309 int cnt = 0; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
310 /* Assumes you have a buffer able to cary at least BUF_LEN * 2 bytes */ |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
311 if (strlen(msg) > BUF_LEN) { |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
312 debug_printf("Warning: truncating message to 2048 bytes\n"); |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
313 msg[2047] = '\0'; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
314 } |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
315 |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
316 cpy = g_strdup(msg); |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
317 c = cpy; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
318 while (*c) { |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
319 switch (*c) { |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
320 case '$': |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
321 case '[': |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
322 case ']': |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
323 case '(': |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
324 case ')': |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
325 msg[cnt++] = '\\'; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
326 /* Fall through */ |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
327 default: |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
328 msg[cnt++] = *c; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
329 } |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
330 c++; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
331 } |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
332 msg[cnt] = '\0'; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
333 g_free(cpy); |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
334 return cnt; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
335 } |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
336 |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
337 static int escape_text(char *msg) |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
338 { |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
339 char *c, *cpy; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
340 int cnt = 0; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
341 /* Assumes you have a buffer able to cary at least BUF_LEN * 4 bytes */ |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
342 if (strlen(msg) > BUF_LEN) { |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
343 fprintf(stderr, "Warning: truncating message to 2048 bytes\n"); |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
344 msg[2047] = '\0'; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
345 } |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
346 |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
347 cpy = g_strdup(msg); |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
348 c = cpy; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
349 while (*c) { |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
350 switch (*c) { |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
351 case '\n': |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
352 msg[cnt++] = '<'; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
353 msg[cnt++] = 'B'; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
354 msg[cnt++] = 'R'; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
355 msg[cnt++] = '>'; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
356 break; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
357 case '{': |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
358 case '}': |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
359 case '\\': |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
360 case '"': |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
361 msg[cnt++] = '\\'; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
362 /* Fall through */ |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
363 default: |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
364 msg[cnt++] = *c; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
365 } |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
366 c++; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
367 } |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
368 msg[cnt] = '\0'; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
369 g_free(cpy); |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
370 return cnt; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
371 } |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
372 |
5605 | 373 static int sflap_send(GaimConnection *gc, char *buf, int olen, int type) |
2086 | 374 { |
375 int len; | |
376 int slen = 0; | |
377 struct sflap_hdr hdr; | |
378 char obuf[MSG_LEN]; | |
379 struct toc_data *tdt = (struct toc_data *)gc->proto_data; | |
380 | |
381 if (tdt->state == STATE_PAUSE) | |
382 /* TOC has given us the PAUSE message; sending could cause a disconnect | |
383 * so we just return here like everything went through fine */ | |
384 return 0; | |
385 | |
2281
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
386 if (olen < 0) |
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
387 len = escape_message(buf); |
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
388 else |
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
389 len = olen; |
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
390 |
2086 | 391 /* One _last_ 2048 check here! This shouldn't ever |
392 * get hit though, hopefully. If it gets hit on an IM | |
393 * It'll lose the last " and the message won't go through, | |
394 * but this'll stop a segfault. */ | |
2281
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
395 if (len > MSG_LEN) { |
2086 | 396 debug_printf("message too long, truncating\n"); |
2281
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
397 buf[MSG_LEN - 1] = '\0'; |
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
398 len = MSG_LEN; |
2086 | 399 } |
400 | |
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
401 if (olen < 0) |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
402 debug_printf("TOC C: %s\n", buf); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
403 |
2086 | 404 hdr.ast = '*'; |
405 hdr.type = type; | |
406 hdr.seqno = htons(tdt->seqno++ & 0xffff); | |
407 hdr.len = htons(len + (type == TYPE_SIGNON ? 0 : 1)); | |
408 | |
409 memcpy(obuf, &hdr, sizeof(hdr)); | |
410 slen += sizeof(hdr); | |
411 memcpy(&obuf[slen], buf, len); | |
412 slen += len; | |
413 if (type != TYPE_SIGNON) { | |
414 obuf[slen] = '\0'; | |
415 slen += 1; | |
416 } | |
417 | |
3630 | 418 return toc_write(tdt->toc_fd, obuf, slen); |
2086 | 419 } |
420 | |
5605 | 421 static int wait_reply(GaimConnection *gc, char *buffer, size_t buflen) |
2086 | 422 { |
423 struct toc_data *tdt = (struct toc_data *)gc->proto_data; | |
424 struct sflap_hdr *hdr; | |
425 int ret; | |
426 | |
3630 | 427 if (toc_read(tdt->toc_fd, buffer, sizeof(struct sflap_hdr)) < 0) { |
2086 | 428 debug_printf("error, couldn't read flap header\n"); |
429 return -1; | |
430 } | |
431 | |
432 hdr = (struct sflap_hdr *)buffer; | |
433 | |
434 if (buflen < ntohs(hdr->len)) { | |
435 /* fake like there's a read error */ | |
436 debug_printf("buffer too small (have %d, need %d)\n", buflen, ntohs(hdr->len)); | |
437 return -1; | |
438 } | |
439 | |
440 if (ntohs(hdr->len) > 0) { | |
441 int count = 0; | |
442 ret = 0; | |
443 do { | |
444 count += ret; | |
3630 | 445 ret = toc_read(tdt->toc_fd, |
2086 | 446 buffer + sizeof(struct sflap_hdr) + count, ntohs(hdr->len) - count); |
447 } while (count + ret < ntohs(hdr->len) && ret > 0); | |
448 buffer[sizeof(struct sflap_hdr) + count + ret] = '\0'; | |
449 return ret; | |
450 } else | |
451 return 0; | |
452 } | |
453 | |
5605 | 454 static unsigned char *roast_password(const char *pass) |
2086 | 455 { |
456 /* Trivial "encryption" */ | |
457 static unsigned char rp[256]; | |
458 static char *roast = ROAST; | |
459 int pos = 2; | |
460 int x; | |
461 strcpy(rp, "0x"); | |
462 for (x = 0; (x < 150) && pass[x]; x++) | |
463 pos += sprintf(&rp[pos], "%02x", pass[x] ^ roast[x % strlen(roast)]); | |
464 rp[pos] = '\0'; | |
465 return rp; | |
466 } | |
467 | |
4322 | 468 static void toc_got_info(gpointer data, char *url_text, unsigned long len) |
2086 | 469 { |
470 if (!url_text) | |
471 return; | |
472 | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
473 g_show_info_text(NULL, NULL, 2, url_text, NULL); |
2086 | 474 } |
475 | |
2453
b72143059ad4
[gaim-migrate @ 2466]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2382
diff
changeset
|
476 static char *show_error_message() |
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
477 { |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
478 int no = atoi(strtok(NULL, ":")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
479 char *w = strtok(NULL, ":"); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
480 static char buf[256]; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
481 |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
482 switch(no) { |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
483 case 69: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
484 g_snprintf(buf, sizeof(buf), _("Unable to write file %s."), w); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
485 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
486 case 169: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
487 g_snprintf(buf, sizeof(buf), _("Unable to read file %s."), w); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
488 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
489 case 269: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
490 g_snprintf(buf, sizeof(buf), _("Message too long, last %s bytes truncated."), w); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
491 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
492 case 901: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
493 g_snprintf(buf, sizeof(buf), _("%s not currently logged in."), w); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
494 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
495 case 902: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
496 g_snprintf(buf, sizeof(buf), _("Warning of %s not allowed."), w); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
497 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
498 case 903: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
499 g_snprintf(buf, sizeof(buf), _("A message has been dropped, you are exceeding the server speed limit.")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
500 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
501 case 950: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
502 g_snprintf(buf, sizeof(buf), _("Chat in %s is not available."), w); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
503 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
504 case 960: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
505 g_snprintf(buf, sizeof(buf), _("You are sending messages too fast to %s."), w); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
506 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
507 case 961: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
508 g_snprintf(buf, sizeof(buf), _("You missed an IM from %s because it was too big."), w); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
509 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
510 case 962: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
511 g_snprintf(buf, sizeof(buf), _("You missed an IM from %s because it was sent too fast."), w); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
512 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
513 case 970: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
514 g_snprintf(buf, sizeof(buf), _("Failure.")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
515 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
516 case 971: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
517 g_snprintf(buf, sizeof(buf), _("Too many matches.")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
518 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
519 case 972: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
520 g_snprintf(buf, sizeof(buf), _("Need more qualifiers.")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
521 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
522 case 973: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
523 g_snprintf(buf, sizeof(buf), _("Dir service temporarily unavailable.")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
524 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
525 case 974: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
526 g_snprintf(buf, sizeof(buf), _("Email lookup restricted.")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
527 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
528 case 975: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
529 g_snprintf(buf, sizeof(buf), _("Keyword ignored.")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
530 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
531 case 976: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
532 g_snprintf(buf, sizeof(buf), _("No keywords.")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
533 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
534 case 977: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
535 g_snprintf(buf, sizeof(buf), _("User has no directory information.")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
536 /* g_snprintf(buf, sizeof(buf), "Language not supported."); */ |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
537 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
538 case 978: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
539 g_snprintf(buf, sizeof(buf), _("Country not supported.")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
540 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
541 case 979: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
542 g_snprintf(buf, sizeof(buf), _("Failure unknown: %s."), w); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
543 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
544 case 980: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
545 g_snprintf(buf, sizeof(buf), _("Incorrect nickname or password.")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
546 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
547 case 981: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
548 g_snprintf(buf, sizeof(buf), _("The service is temporarily unavailable.")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
549 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
550 case 982: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
551 g_snprintf(buf, sizeof(buf), _("Your warning level is currently too high to log in.")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
552 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
553 case 983: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
554 g_snprintf(buf, sizeof(buf), _("You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer.")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
555 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
556 g_snprintf(buf, sizeof(buf), _("An unknown signon error has occurred: %s."), w); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
557 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
558 default: |
3100 | 559 g_snprintf(buf, sizeof(buf), _("An unknown error, %d, has occurred. Info: %s"), no, w); |
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
560 } |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
561 |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
562 return buf; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
563 } |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
564 |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
565 static void toc_callback(gpointer data, gint source, GaimInputCondition condition) |
2086 | 566 { |
5605 | 567 GaimConnection *gc = (GaimConnection *)data; |
2086 | 568 struct toc_data *tdt = (struct toc_data *)gc->proto_data; |
569 struct sflap_hdr *hdr; | |
570 struct signon so; | |
571 char buf[8 * 1024], *c; | |
572 char snd[BUF_LEN * 2]; | |
573 | |
5605 | 574 const char *username = gaim_account_get_username(gc->account); |
575 char *password; | |
576 | |
2086 | 577 /* there's data waiting to be read, so read it. */ |
578 if (wait_reply(gc, buf, 8 * 1024) <= 0) { | |
5605 | 579 gaim_connection_error(gc, _("Connection Closed")); |
2086 | 580 return; |
581 } | |
582 | |
583 if (tdt->state == STATE_FLAPON) { | |
584 hdr = (struct sflap_hdr *)buf; | |
585 if (hdr->type != TYPE_SIGNON) | |
586 debug_printf("problem, hdr->type != TYPE_SIGNON\n"); | |
587 else | |
588 debug_printf("* TOC sends Client FLAP SIGNON\n"); | |
589 tdt->seqno = ntohs(hdr->seqno); | |
590 tdt->state = STATE_SIGNON_REQUEST; | |
591 | |
592 debug_printf("* Client sends TOC FLAP SIGNON\n"); | |
5605 | 593 g_snprintf(so.username, sizeof(so.username), "%s", username); |
2086 | 594 so.ver = htonl(1); |
595 so.tag = htons(1); | |
596 so.namelen = htons(strlen(so.username)); | |
597 if (sflap_send(gc, (char *)&so, ntohs(so.namelen) + 8, TYPE_SIGNON) < 0) { | |
5605 | 598 gaim_connection_error(gc, _("Disconnected.")); |
2086 | 599 return; |
600 } | |
601 | |
602 debug_printf("* Client sends TOC \"toc_signon\" message\n"); | |
2853
f0633f458a1c
[gaim-migrate @ 2866]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
603 /* i hate icq. */ |
5605 | 604 if (username[0] >= '0' && username[0] <= '9') |
605 password = g_strndup(gaim_account_get_password(gc->account), 8); | |
606 else | |
607 password = g_strdup(gaim_account_get_password(gc->account)); | |
2086 | 608 g_snprintf(snd, sizeof snd, "toc_signon %s %d %s %s %s \"%s\"", |
5605 | 609 AUTH_HOST, AUTH_PORT, normalize(username), |
610 roast_password(password), LANGUAGE, REVISION); | |
611 g_free(password); | |
2086 | 612 if (sflap_send(gc, snd, -1, TYPE_DATA) < 0) { |
5605 | 613 gaim_connection_error(gc, _("Disconnected.")); |
2086 | 614 return; |
615 } | |
616 | |
5605 | 617 gaim_connection_update_progress(gc, _("Waiting for reply..."), 3, TOC_CONNECT_STEPS); |
2086 | 618 return; |
619 } | |
620 | |
621 if (tdt->state == STATE_SIGNON_REQUEST) { | |
622 debug_printf("* TOC sends client SIGN_ON reply\n"); | |
4793 | 623 if (g_ascii_strncasecmp(buf + sizeof(struct sflap_hdr), "SIGN_ON", strlen("SIGN_ON"))) { |
2086 | 624 debug_printf("Didn't get SIGN_ON! buf was: %s\n", |
625 buf + sizeof(struct sflap_hdr)); | |
4793 | 626 if (!g_ascii_strncasecmp(buf + sizeof(struct sflap_hdr), "ERROR", 5)) { |
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
627 strtok(buf + sizeof(struct sflap_hdr), ":"); |
5605 | 628 gaim_connection_error(gc, show_error_message()); |
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
629 } else |
5605 | 630 gaim_connection_error(gc, _("Authentication Failed")); |
2086 | 631 return; |
632 } | |
633 /* we're supposed to check that it's really TOC v1 here but we know it is ;) */ | |
2128
bc79be34eb73
[gaim-migrate @ 2138]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2123
diff
changeset
|
634 debug_printf("TOC version: %s\n", buf + sizeof(struct sflap_hdr) + 8); |
2086 | 635 |
636 /* we used to check for the CONFIG here, but we'll wait until we've sent our | |
637 * version of the config and then the toc_init_done message. we'll come back to | |
638 * the callback in a better state if we get CONFIG anyway */ | |
639 | |
640 tdt->state = STATE_ONLINE; | |
641 | |
5605 | 642 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2086 | 643 serv_finish_login(gc); |
644 | |
645 /* Client sends TOC toc_init_done message */ | |
646 debug_printf("* Client sends TOC toc_init_done message\n"); | |
647 g_snprintf(snd, sizeof snd, "toc_init_done"); | |
648 sflap_send(gc, snd, -1, TYPE_DATA); | |
649 | |
650 /* | |
651 g_snprintf(snd, sizeof snd, "toc_set_caps %s %s %s", | |
652 FILE_SEND_UID, FILE_GET_UID, B_ICON_UID); | |
653 */ | |
654 g_snprintf(snd, sizeof snd, "toc_set_caps %s %s", FILE_SEND_UID, FILE_GET_UID); | |
655 sflap_send(gc, snd, -1, TYPE_DATA); | |
656 | |
657 return; | |
658 } | |
659 | |
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
660 debug_printf("TOC S: %s\n", buf + sizeof(struct sflap_hdr)); |
2086 | 661 |
662 c = strtok(buf + sizeof(struct sflap_hdr), ":"); /* Ditch the first part */ | |
663 | |
4793 | 664 if (!g_ascii_strcasecmp(c, "SIGN_ON")) { |
2086 | 665 /* we should only get here after a PAUSE */ |
666 if (tdt->state != STATE_PAUSE) | |
667 debug_printf("got SIGN_ON but not PAUSE!\n"); | |
668 else { | |
669 tdt->state = STATE_ONLINE; | |
670 g_snprintf(snd, sizeof snd, "toc_signon %s %d %s %s %s \"%s\"", | |
5605 | 671 AUTH_HOST, AUTH_PORT, |
672 normalize(gaim_account_get_username(gc->account)), | |
673 roast_password(gaim_account_get_password(gc->account)), | |
674 LANGUAGE, REVISION); | |
2086 | 675 if (sflap_send(gc, snd, -1, TYPE_DATA) < 0) { |
5605 | 676 gaim_connection_error(gc, _("Disconnected.")); |
2086 | 677 return; |
678 } | |
679 g_snprintf(snd, sizeof snd, "toc_init_done"); | |
680 sflap_send(gc, snd, -1, TYPE_DATA); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
681 gaim_notify_info(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
682 _("TOC has come back from its pause. You may " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
683 "now send messages again."), NULL); |
2086 | 684 } |
4793 | 685 } else if (!g_ascii_strcasecmp(c, "CONFIG")) { |
2086 | 686 c = strtok(NULL, ":"); |
4491 | 687 parse_toc_buddy_list(gc->account, c); |
4793 | 688 } else if (!g_ascii_strcasecmp(c, "NICK")) { |
2086 | 689 /* ignore NICK so that things get imported/exported properly |
690 c = strtok(NULL, ":"); | |
691 g_snprintf(gc->username, sizeof(gc->username), "%s", c); | |
692 */ | |
4793 | 693 } else if (!g_ascii_strcasecmp(c, "IM_IN")) { |
2086 | 694 char *away, *message; |
695 int a = 0; | |
696 | |
697 c = strtok(NULL, ":"); | |
698 away = strtok(NULL, ":"); | |
699 | |
700 message = away; | |
701 while (*message && (*message != ':')) | |
702 message++; | |
703 message++; | |
704 | |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2232
diff
changeset
|
705 a = (away && (*away == 'T')) ? IM_FLAG_AWAY : 0; |
2086 | 706 |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2853
diff
changeset
|
707 serv_got_im(gc, c, message, a, time(NULL), -1); |
4793 | 708 } else if (!g_ascii_strcasecmp(c, "UPDATE_BUDDY")) { |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
709 char *l, *uc, *tmp; |
2086 | 710 int logged, evil, idle, type = 0; |
711 time_t signon, time_idle; | |
712 | |
713 c = strtok(NULL, ":"); /* name */ | |
714 l = strtok(NULL, ":"); /* online */ | |
715 sscanf(strtok(NULL, ":"), "%d", &evil); | |
716 sscanf(strtok(NULL, ":"), "%ld", &signon); | |
717 sscanf(strtok(NULL, ":"), "%d", &idle); | |
718 uc = strtok(NULL, ":"); | |
719 | |
720 logged = (l && (*l == 'T')) ? 1 : 0; | |
721 | |
722 if (uc[0] == 'A') | |
723 type |= UC_AOL; | |
724 switch (uc[1]) { | |
725 case 'A': | |
726 type |= UC_ADMIN; | |
727 break; | |
728 case 'U': | |
729 type |= UC_UNCONFIRMED; | |
730 break; | |
731 case 'O': | |
732 type |= UC_NORMAL; | |
733 break; | |
3083 | 734 case 'C': |
735 type |= UC_WIRELESS; | |
736 break; | |
2086 | 737 default: |
738 break; | |
739 } | |
740 if (uc[2] == 'U') | |
741 type |= UC_UNAVAILABLE; | |
742 | |
743 if (idle) { | |
744 time(&time_idle); | |
745 time_idle -= idle * 60; | |
746 } else | |
747 time_idle = 0; | |
748 | |
5605 | 749 tmp = g_strdup(normalize(gaim_account_get_username(gc->account))); |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
750 if (!strcmp(tmp, normalize(c))) |
5605 | 751 gaim_connection_set_display_name(gc, c); |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
752 g_free(tmp); |
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
753 |
4732 | 754 serv_got_update(gc, c, logged, evil, signon, time_idle, type); |
4793 | 755 } else if (!g_ascii_strcasecmp(c, "ERROR")) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
756 gaim_notify_error(gc, NULL, show_error_message(), NULL); |
4793 | 757 } else if (!g_ascii_strcasecmp(c, "EVILED")) { |
2086 | 758 int lev; |
759 char *name; | |
760 | |
761 sscanf(strtok(NULL, ":"), "%d", &lev); | |
762 name = strtok(NULL, ":"); | |
763 | |
764 serv_got_eviled(gc, name, lev); | |
4793 | 765 } else if (!g_ascii_strcasecmp(c, "CHAT_JOIN")) { |
2086 | 766 char *name; |
767 int id; | |
768 | |
769 sscanf(strtok(NULL, ":"), "%d", &id); | |
770 name = strtok(NULL, ":"); | |
771 | |
772 serv_got_joined_chat(gc, id, name); | |
4793 | 773 } else if (!g_ascii_strcasecmp(c, "CHAT_IN")) { |
2086 | 774 int id, w; |
775 char *m, *who, *whisper; | |
776 | |
777 sscanf(strtok(NULL, ":"), "%d", &id); | |
778 who = strtok(NULL, ":"); | |
779 whisper = strtok(NULL, ":"); | |
780 m = whisper; | |
781 while (*m && (*m != ':')) | |
782 m++; | |
783 m++; | |
784 | |
785 w = (whisper && (*whisper == 'T')) ? 1 : 0; | |
786 | |
787 serv_got_chat_in(gc, id, who, w, m, time((time_t)NULL)); | |
4793 | 788 } else if (!g_ascii_strcasecmp(c, "CHAT_UPDATE_BUDDY")) { |
2086 | 789 int id; |
790 char *in, *buddy; | |
791 GSList *bcs = gc->buddy_chats; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
792 struct gaim_conversation *b = NULL; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
793 struct gaim_chat *chat; |
2086 | 794 |
795 sscanf(strtok(NULL, ":"), "%d", &id); | |
796 in = strtok(NULL, ":"); | |
797 | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
798 chat = GAIM_CHAT(b); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
799 |
2086 | 800 while (bcs) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
801 b = (struct gaim_conversation *)bcs->data; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
802 if (id == gaim_chat_get_id(chat)) |
2086 | 803 break; |
804 bcs = bcs->next; | |
805 b = NULL; | |
806 } | |
807 | |
808 if (!b) | |
809 return; | |
810 | |
811 if (in && (*in == 'T')) | |
812 while ((buddy = strtok(NULL, ":")) != NULL) | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
813 gaim_chat_add_user(chat, buddy, NULL); |
2086 | 814 else |
815 while ((buddy = strtok(NULL, ":")) != NULL) | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
816 gaim_chat_remove_user(chat, buddy, NULL); |
4793 | 817 } else if (!g_ascii_strcasecmp(c, "CHAT_INVITE")) { |
2086 | 818 char *name, *who, *message; |
5234 | 819 int id; |
820 GHashTable *components = g_hash_table_new_full(g_str_hash, g_str_equal, | |
821 g_free, g_free); | |
2086 | 822 |
823 name = strtok(NULL, ":"); | |
5234 | 824 sscanf(strtok(NULL, ":"), "%d", &id); |
2086 | 825 who = strtok(NULL, ":"); |
826 message = strtok(NULL, ":"); | |
827 | |
5234 | 828 g_hash_table_replace(components, g_strdup("id"), g_strdup_printf("%d", id)); |
829 | |
830 serv_got_chat_invite(gc, name, who, message, components); | |
4793 | 831 } else if (!g_ascii_strcasecmp(c, "CHAT_LEFT")) { |
2086 | 832 GSList *bcs = gc->buddy_chats; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
833 struct gaim_conversation *b = NULL; |
2086 | 834 int id; |
835 | |
836 sscanf(strtok(NULL, ":"), "%d", &id); | |
837 | |
838 while (bcs) { | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
839 b = (struct gaim_conversation *)bcs->data; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
840 if (id == gaim_chat_get_id(GAIM_CHAT(b))) |
2086 | 841 break; |
842 b = NULL; | |
843 bcs = bcs->next; | |
844 } | |
845 | |
846 if (!b) | |
847 return; | |
848 | |
849 if (b->window) { | |
850 char error_buf[BUF_LONG]; | |
4491 | 851 gaim_conversation_set_account(b, NULL); |
2086 | 852 g_snprintf(error_buf, sizeof error_buf, _("You have been disconnected" |
853 " from chat room %s."), b->name); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
854 gaim_notify_error(gc, NULL, error_buf, NULL); |
2086 | 855 } else |
856 serv_got_chat_left(gc, id); | |
4793 | 857 } else if (!g_ascii_strcasecmp(c, "GOTO_URL")) { |
2086 | 858 char *name, *url, tmp[256]; |
859 | |
860 name = strtok(NULL, ":"); | |
861 url = strtok(NULL, ":"); | |
862 | |
4597 | 863 g_snprintf(tmp, sizeof(tmp), "http://%s:%d/%s", tdt->toc_ip, |
5605 | 864 gaim_account_get_int(gc->account, "port", TOC_PORT), |
2086 | 865 url); |
2584
34812d648f72
[gaim-migrate @ 2597]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2526
diff
changeset
|
866 grab_url(tmp, FALSE, toc_got_info, NULL); |
4793 | 867 } else if (!g_ascii_strcasecmp(c, "DIR_STATUS")) { |
868 } else if (!g_ascii_strcasecmp(c, "ADMIN_NICK_STATUS")) { | |
869 } else if (!g_ascii_strcasecmp(c, "ADMIN_PASSWD_STATUS")) { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
870 gaim_notify_info(gc, NULL, _("Password Change Successful"), NULL); |
4793 | 871 } else if (!g_ascii_strcasecmp(c, "PAUSE")) { |
2086 | 872 tdt->state = STATE_PAUSE; |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
873 gaim_notify_warning(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
874 _("TOC has sent a PAUSE command."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
875 _("When this happens, TOC ignores any messages " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
876 "sent to it, and may kick you off if you send a" |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
877 " message. Gaim will prevent anything from " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
878 "going through. This is only temporary, please " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
879 "be patient.")); |
4793 | 880 } else if (!g_ascii_strcasecmp(c, "RVOUS_PROPOSE")) { |
2086 | 881 char *user, *uuid, *cookie; |
882 int seq; | |
3159 | 883 char *rip, *pip, *vip, *trillian = NULL; |
2086 | 884 int port; |
3126 | 885 |
2086 | 886 user = strtok(NULL, ":"); |
887 uuid = strtok(NULL, ":"); | |
888 cookie = strtok(NULL, ":"); | |
889 sscanf(strtok(NULL, ":"), "%d", &seq); | |
890 rip = strtok(NULL, ":"); | |
891 pip = strtok(NULL, ":"); | |
892 vip = strtok(NULL, ":"); | |
893 sscanf(strtok(NULL, ":"), "%d", &port); | |
894 | |
895 if (!strcmp(uuid, FILE_SEND_UID)) { | |
896 /* they want us to get a file */ | |
897 int unk[4], i; | |
898 char *messages[4], *tmp, *name; | |
899 int subtype, files, totalsize = 0; | |
900 struct ft_request *ft; | |
901 | |
902 for (i = 0; i < 4; i++) { | |
3126 | 903 trillian = strtok(NULL, ":"); |
904 sscanf(trillian, "%d", &unk[i]); | |
2086 | 905 if (unk[i] == 10001) |
906 break; | |
3126 | 907 /* Trillian likes to send an empty token as a message, rather than |
908 no message at all. */ | |
909 if (*(trillian + strlen(trillian) +1) != ':') | |
910 frombase64(strtok(NULL, ":"), &messages[i], NULL); | |
2086 | 911 } |
3126 | 912 |
2086 | 913 frombase64(strtok(NULL, ":"), &tmp, NULL); |
914 | |
915 subtype = tmp[1]; | |
916 files = tmp[3]; | |
917 | |
918 totalsize |= (tmp[4] << 24) & 0xff000000; | |
919 totalsize |= (tmp[5] << 16) & 0x00ff0000; | |
920 totalsize |= (tmp[6] << 8) & 0x0000ff00; | |
921 totalsize |= (tmp[7] << 0) & 0x000000ff; | |
922 | |
923 if (!totalsize) { | |
924 g_free(tmp); | |
925 for (i--; i >= 0; i--) | |
926 g_free(messages[i]); | |
927 return; | |
928 } | |
929 | |
930 name = tmp + 8; | |
931 | |
932 ft = g_new0(struct ft_request, 1); | |
933 ft->cookie = g_strdup(cookie); | |
934 ft->ip = g_strdup(pip); | |
935 ft->port = port; | |
936 if (i) | |
937 ft->message = g_strdup(messages[0]); | |
938 else | |
939 ft->message = NULL; | |
940 ft->filename = g_strdup(name); | |
941 ft->user = g_strdup(user); | |
942 ft->size = totalsize; | |
943 ft->files = files; | |
944 g_snprintf(ft->UID, sizeof(ft->UID), "%s", FILE_SEND_UID); | |
945 ft->gc = gc; | |
946 | |
947 g_free(tmp); | |
948 for (i--; i >= 0; i--) | |
949 g_free(messages[i]); | |
950 | |
951 debug_printf("English translation of RVOUS_PROPOSE: %s requests Send File (i.e." | |
952 " send a file to you); %s:%d (verified_ip:port), %d files at" | |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
953 " total size of %d bytes.\n", user, vip, port, files, totalsize); |
2086 | 954 accept_file_dialog(ft); |
955 } else if (!strcmp(uuid, FILE_GET_UID)) { | |
956 /* they want us to send a file */ | |
957 int unk[4], i; | |
958 char *messages[4], *tmp; | |
959 struct ft_request *ft; | |
960 | |
961 for (i = 0; i < 4; i++) { | |
962 sscanf(strtok(NULL, ":"), "%d", unk + i); | |
963 if (unk[i] == 10001) | |
964 break; | |
3126 | 965 /* Trillian likes to send an empty token as a message, rather than |
966 no message at all. */ | |
967 if (*(trillian + strlen(trillian) +1) != ':') | |
968 frombase64(strtok(NULL, ":"), &messages[i], NULL); | |
2086 | 969 } |
970 frombase64(strtok(NULL, ":"), &tmp, NULL); | |
971 | |
972 ft = g_new0(struct ft_request, 1); | |
973 ft->cookie = g_strdup(cookie); | |
974 ft->ip = g_strdup(pip); | |
975 ft->port = port; | |
976 if (i) | |
977 ft->message = g_strdup(messages[0]); | |
978 else | |
979 ft->message = NULL; | |
980 ft->user = g_strdup(user); | |
981 g_snprintf(ft->UID, sizeof(ft->UID), "%s", FILE_GET_UID); | |
982 ft->gc = gc; | |
983 | |
984 g_free(tmp); | |
985 for (i--; i >= 0; i--) | |
986 g_free(messages[i]); | |
987 | |
988 accept_file_dialog(ft); | |
989 } else if (!strcmp(uuid, VOICE_UID)) { | |
990 /* oh goody. voice over ip. fun stuff. */ | |
991 } else if (!strcmp(uuid, B_ICON_UID)) { | |
992 /* | |
993 int unk[4], i; | |
994 char *messages[4]; | |
995 struct buddy_icon *icon; | |
996 | |
997 for (i = 0; i < 4; i++) { | |
998 sscanf(strtok(NULL, ":"), "%d", unk + i); | |
999 if (unk[i] == 10001) | |
1000 break; | |
1001 frombase64(strtok(NULL, ":"), &messages[i], NULL); | |
1002 } | |
1003 frombase64(strtok(NULL, ":"), (char **)&icon, NULL); | |
1004 | |
1005 debug_printf("received icon of length %d\n", icon->len); | |
1006 g_free(icon); | |
1007 for (i--; i >= 0; i--) | |
1008 g_free(messages[i]); | |
1009 */ | |
1010 } else if (!strcmp(uuid, IMAGE_UID)) { | |
1011 /* aka Direct IM */ | |
1012 } else { | |
1013 debug_printf("Don't know what to do with RVOUS UUID %s\n", uuid); | |
1014 /* do we have to do anything here? i think it just times out */ | |
1015 } | |
1016 } else { | |
1017 debug_printf("don't know what to do with %s\n", c); | |
1018 } | |
1019 } | |
1020 | |
5605 | 1021 static int toc_send_im(GaimConnection *gc, const char *name, const char *message, int len, int flags) |
2086 | 1022 { |
1023 char buf[BUF_LEN * 2]; | |
2343
29449a6b79e6
[gaim-migrate @ 2356]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2334
diff
changeset
|
1024 char *tmp = g_malloc(strlen(message) * 4 + 1); /* 4 because \n gets replaced with <BR> */ |
2086 | 1025 |
2136
73253b36c3cb
[gaim-migrate @ 2146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2130
diff
changeset
|
1026 strcpy(tmp, message); |
73253b36c3cb
[gaim-migrate @ 2146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2130
diff
changeset
|
1027 escape_text(tmp); |
73253b36c3cb
[gaim-migrate @ 2146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2130
diff
changeset
|
1028 if (strlen(tmp) + 52 > MSG_LEN) { |
73253b36c3cb
[gaim-migrate @ 2146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2130
diff
changeset
|
1029 g_free(tmp); |
2123
56c4382f2909
[gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
1030 return -E2BIG; |
2136
73253b36c3cb
[gaim-migrate @ 2146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2130
diff
changeset
|
1031 } |
2086 | 1032 g_snprintf(buf, MSG_LEN - 8, "toc_send_im %s \"%s\"%s", normalize(name), |
2231
8c4ff1a368bd
[gaim-migrate @ 2241]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2205
diff
changeset
|
1033 tmp, ((flags & IM_FLAG_AWAY) ? " auto" : "")); |
2086 | 1034 sflap_send(gc, buf, -1, TYPE_DATA); |
2123
56c4382f2909
[gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
1035 |
2136
73253b36c3cb
[gaim-migrate @ 2146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2130
diff
changeset
|
1036 g_free(tmp); |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2281
diff
changeset
|
1037 return 1; |
2086 | 1038 } |
1039 | |
5605 | 1040 static void toc_set_config(GaimConnection *gc) |
2086 | 1041 { |
2281
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1042 char *buf = g_malloc(MSG_LEN), snd[BUF_LEN * 2]; |
4491 | 1043 toc_build_config(gc->account, buf, MSG_LEN - strlen("toc_set_config \\{\\}"), FALSE); |
2086 | 1044 g_snprintf(snd, MSG_LEN, "toc_set_config {%s}", buf); |
1045 sflap_send(gc, snd, -1, TYPE_DATA); | |
2281
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1046 g_free(buf); |
2086 | 1047 } |
1048 | |
5605 | 1049 static void toc_get_info(GaimConnection *g, const char *name) |
2086 | 1050 { |
1051 char buf[BUF_LEN * 2]; | |
1052 g_snprintf(buf, MSG_LEN, "toc_get_info %s", normalize(name)); | |
1053 sflap_send(g, buf, -1, TYPE_DATA); | |
1054 } | |
1055 | |
5605 | 1056 static void toc_get_dir(GaimConnection *g, const char *name) |
2086 | 1057 { |
1058 char buf[BUF_LEN * 2]; | |
1059 g_snprintf(buf, MSG_LEN, "toc_get_dir %s", normalize(name)); | |
1060 sflap_send(g, buf, -1, TYPE_DATA); | |
1061 } | |
1062 | |
5605 | 1063 static void toc_set_dir(GaimConnection *g, const char *first, const char *middle, const char *last, |
3466 | 1064 const char *maiden, const char *city, const char *state, const char *country, int web) |
2086 | 1065 { |
1066 char buf2[BUF_LEN * 4], buf[BUF_LEN]; | |
1067 g_snprintf(buf2, sizeof(buf2), "%s:%s:%s:%s:%s:%s:%s:%s", first, | |
1068 middle, last, maiden, city, state, country, (web == 1) ? "Y" : ""); | |
1069 escape_text(buf2); | |
1070 g_snprintf(buf, sizeof(buf), "toc_set_dir %s", buf2); | |
1071 sflap_send(g, buf, -1, TYPE_DATA); | |
1072 } | |
1073 | |
5605 | 1074 static void toc_dir_search(GaimConnection *g, const char *first, const char *middle, const char *last, |
3466 | 1075 const char *maiden, const char *city, const char *state, const char *country, const char *email) |
2086 | 1076 { |
1077 char buf[BUF_LONG]; | |
1078 g_snprintf(buf, sizeof(buf) / 2, "toc_dir_search %s:%s:%s:%s:%s:%s:%s:%s", first, middle, | |
1079 last, maiden, city, state, country, email); | |
1080 debug_printf("Searching for: %s,%s,%s,%s,%s,%s,%s\n", first, middle, last, maiden, | |
1081 city, state, country); | |
1082 sflap_send(g, buf, -1, TYPE_DATA); | |
1083 } | |
1084 | |
5605 | 1085 static void toc_set_away(GaimConnection *g, char *state, char *message) |
2086 | 1086 { |
1087 char buf[BUF_LEN * 2]; | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
1088 if (g->away) { |
2086 | 1089 g_free (g->away); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
1090 g->away = NULL; |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
1091 } |
2086 | 1092 if (message) { |
3188 | 1093 char *tmp = g_malloc(strlen(message) * 4 + 1); |
1094 strcpy(tmp, message); | |
2086 | 1095 g->away = g_strdup (message); |
3188 | 1096 escape_text(tmp); |
1097 g_snprintf(buf, MSG_LEN, "toc_set_away \"%s\"", tmp); | |
1098 g_free(tmp); | |
2086 | 1099 } else |
1100 g_snprintf(buf, MSG_LEN, "toc_set_away \"\""); | |
1101 sflap_send(g, buf, -1, TYPE_DATA); | |
1102 } | |
1103 | |
5605 | 1104 static void toc_set_info(GaimConnection *g, char *info) |
2086 | 1105 { |
1106 char buf[BUF_LEN * 2], buf2[BUF_LEN * 2]; | |
1107 g_snprintf(buf2, sizeof buf2, "%s", info); | |
1108 escape_text(buf2); | |
1109 g_snprintf(buf, sizeof(buf), "toc_set_info \"%s\n\"", buf2); | |
1110 sflap_send(g, buf, -1, TYPE_DATA); | |
1111 } | |
1112 | |
5605 | 1113 static void toc_change_passwd(GaimConnection *g, const char *orig, const char *new) |
2086 | 1114 { |
1115 char buf[BUF_LEN * 2]; | |
1116 g_snprintf(buf, BUF_LONG, "toc_change_passwd %s %s", orig, new); | |
1117 sflap_send(g, buf, strlen(buf), TYPE_DATA); | |
1118 } | |
1119 | |
5605 | 1120 static void toc_add_buddy(GaimConnection *g, const char *name) |
2086 | 1121 { |
1122 char buf[BUF_LEN * 2]; | |
1123 g_snprintf(buf, sizeof(buf), "toc_add_buddy %s", normalize(name)); | |
1124 sflap_send(g, buf, -1, TYPE_DATA); | |
1125 toc_set_config(g); | |
1126 } | |
1127 | |
5605 | 1128 static void toc_add_buddies(GaimConnection *g, GList *buddies) |
2086 | 1129 { |
1130 char buf[BUF_LEN * 2]; | |
1131 int n; | |
1132 | |
1133 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); | |
1134 while (buddies) { | |
2130
50c7a704ee56
[gaim-migrate @ 2140]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2128
diff
changeset
|
1135 if (strlen(normalize(buddies->data)) + n + 32 > MSG_LEN) { |
2086 | 1136 sflap_send(g, buf, -1, TYPE_DATA); |
1137 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); | |
1138 } | |
1139 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", normalize(buddies->data)); | |
1140 buddies = buddies->next; | |
1141 } | |
1142 sflap_send(g, buf, -1, TYPE_DATA); | |
1143 } | |
1144 | |
5605 | 1145 static void toc_remove_buddy(GaimConnection *g, char *name, char *group) |
2086 | 1146 { |
1147 char buf[BUF_LEN * 2]; | |
1148 g_snprintf(buf, sizeof(buf), "toc_remove_buddy %s", normalize(name)); | |
1149 sflap_send(g, buf, -1, TYPE_DATA); | |
1150 toc_set_config(g); | |
1151 } | |
1152 | |
5605 | 1153 static void toc_remove_buddies(GaimConnection *g, GList *buddies, const char *group) |
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1154 { |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1155 char buf[BUF_LEN * 2]; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1156 int n; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1157 |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1158 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1159 while (buddies) { |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1160 if (strlen(normalize(buddies->data)) + n + 32 > MSG_LEN) { |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1161 sflap_send(g, buf, -1, TYPE_DATA); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1162 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1163 } |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1164 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", normalize(buddies->data)); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1165 buddies = buddies->next; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1166 } |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1167 sflap_send(g, buf, -1, TYPE_DATA); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1168 toc_set_config(g); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1169 } |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1170 |
5605 | 1171 static void toc_set_idle(GaimConnection *g, int time) |
2086 | 1172 { |
1173 char buf[BUF_LEN * 2]; | |
1174 g_snprintf(buf, sizeof(buf), "toc_set_idle %d", time); | |
1175 sflap_send(g, buf, -1, TYPE_DATA); | |
1176 } | |
1177 | |
5605 | 1178 static void toc_warn(GaimConnection *g, char *name, int anon) |
2086 | 1179 { |
1180 char send[BUF_LEN * 2]; | |
1181 g_snprintf(send, 255, "toc_evil %s %s", name, ((anon) ? "anon" : "norm")); | |
1182 sflap_send(g, send, -1, TYPE_DATA); | |
1183 } | |
1184 | |
5605 | 1185 static GList *toc_chat_info(GaimConnection *gc) |
2086 | 1186 { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1187 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1188 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1189 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1190 pce = g_new0(struct proto_chat_entry, 1); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1191 pce->label = _("Join what group:"); |
5234 | 1192 pce->identifier = "room"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1193 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1194 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1195 pce = g_new0(struct proto_chat_entry, 1); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1196 pce->label = _("Exchange:"); |
5234 | 1197 pce->identifier = "exchange"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1198 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1199 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1200 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1201 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1202 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1203 return m; |
2086 | 1204 } |
1205 | |
5605 | 1206 static void toc_join_chat(GaimConnection *g, GHashTable *data) |
2086 | 1207 { |
1208 char buf[BUF_LONG]; | |
5234 | 1209 char *name, *exchange; |
1210 char *id; | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1211 |
5234 | 1212 name = g_hash_table_lookup(data, "room"); |
1213 exchange = g_hash_table_lookup(data, "exchange"); | |
1214 id = g_hash_table_lookup(data, "id"); | |
1215 | |
1216 if (id) { | |
1217 g_snprintf(buf, 255, "toc_chat_accept %d", atoi(id)); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1218 } else { |
5234 | 1219 g_snprintf(buf, sizeof(buf) / 2, "toc_chat_join %d \"%s\"", atoi(exchange), name); |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1220 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1221 |
2086 | 1222 sflap_send(g, buf, -1, TYPE_DATA); |
1223 } | |
1224 | |
5605 | 1225 static void toc_chat_invite(GaimConnection *g, int id, const char *message, const char *name) |
2086 | 1226 { |
1227 char buf[BUF_LONG]; | |
2719
9747583279d1
[gaim-migrate @ 2732]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2706
diff
changeset
|
1228 g_snprintf(buf, sizeof(buf) / 2, "toc_chat_invite %d \"%s\" %s", id, |
9747583279d1
[gaim-migrate @ 2732]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2706
diff
changeset
|
1229 message ? message : "", normalize(name)); |
2086 | 1230 sflap_send(g, buf, -1, TYPE_DATA); |
1231 } | |
1232 | |
5605 | 1233 static void toc_chat_leave(GaimConnection *g, int id) |
2086 | 1234 { |
1235 GSList *bcs = g->buddy_chats; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1236 struct gaim_conversation *b = NULL; |
2086 | 1237 char buf[BUF_LEN * 2]; |
1238 | |
1239 while (bcs) { | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1240 b = (struct gaim_conversation *)bcs->data; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1241 if (id == gaim_chat_get_id(GAIM_CHAT(b))) |
2086 | 1242 break; |
1243 b = NULL; | |
1244 bcs = bcs->next; | |
1245 } | |
1246 | |
1247 if (!b) | |
1248 return; /* can this happen? */ | |
1249 | |
4491 | 1250 if (gaim_conversation_get_account(b) == NULL) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1251 /* TOC already kicked us out of this room */ |
2086 | 1252 serv_got_chat_left(g, id); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1253 } |
2086 | 1254 else { |
1255 g_snprintf(buf, 255, "toc_chat_leave %d", id); | |
1256 sflap_send(g, buf, -1, TYPE_DATA); | |
1257 } | |
1258 } | |
1259 | |
5605 | 1260 static void toc_chat_whisper(GaimConnection *g, int id, char *who, char *message) |
2086 | 1261 { |
1262 char buf2[BUF_LEN * 2]; | |
2371
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
1263 escape_text(message); |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
1264 g_snprintf(buf2, sizeof(buf2), "toc_chat_whisper %d %s \"%s\"", id, normalize(who), message); |
2086 | 1265 sflap_send(g, buf2, -1, TYPE_DATA); |
1266 } | |
1267 | |
5605 | 1268 static int toc_chat_send(GaimConnection *g, int id, char *message) |
2086 | 1269 { |
1270 char buf[BUF_LEN * 2]; | |
1271 escape_text(message); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1272 if (strlen(message) > 2000) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1273 return -E2BIG; |
2086 | 1274 g_snprintf(buf, sizeof(buf), "toc_chat_send %d \"%s\"", id, message); |
1275 sflap_send(g, buf, -1, TYPE_DATA); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1276 return 0; |
2086 | 1277 } |
1278 | |
5605 | 1279 static void toc_keepalive(GaimConnection *gc) |
2086 | 1280 { |
1281 sflap_send(gc, "", 0, TYPE_KEEPALIVE); | |
1282 } | |
1283 | |
5605 | 1284 static const char *toc_list_icon(GaimAccount *a, struct buddy *b) |
2086 | 1285 { |
4687 | 1286 return "aim"; |
1287 } | |
4916 | 1288 |
4921 | 1289 static void toc_list_emblems(struct buddy *b, char **se, char **sw, char **nw, char **ne) |
4916 | 1290 { |
1291 char *emblems[4] = {NULL,NULL,NULL,NULL}; | |
1292 int i = 0; | |
1293 | |
5068 | 1294 if (b->present == GAIM_BUDDY_OFFLINE) { |
4916 | 1295 *se = "offline"; |
1296 return; | |
1297 } else { | |
1298 if (b->uc & UC_UNAVAILABLE) | |
1299 emblems[i++] = "away"; | |
1300 if (b->uc & UC_AOL) | |
1301 emblems[i++] = "aol"; | |
1302 if (b->uc & UC_ADMIN) | |
1303 emblems[i++] = "admin"; | |
1304 if (b->uc & UC_WIRELESS) | |
1305 emblems[i++] = "wireless"; | |
1306 } | |
1307 *se = emblems[0]; | |
1308 *sw = emblems[1]; | |
1309 *nw = emblems[2]; | |
1310 *ne = emblems[3]; | |
1311 } | |
2086 | 1312 |
5605 | 1313 static GList *toc_buddy_menu(GaimConnection *gc, const char *who) |
2086 | 1314 { |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1315 GList *m = NULL; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1316 struct proto_buddy_menu *pbm; |
2086 | 1317 |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1318 pbm = g_new0(struct proto_buddy_menu, 1); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1319 pbm->label = _("Get Dir Info"); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1320 pbm->callback = toc_get_dir; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1321 pbm->gc = gc; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1322 m = g_list_append(m, pbm); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1323 |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1324 return m; |
2086 | 1325 } |
1326 | |
5605 | 1327 static void toc_add_permit(GaimConnection *gc, const char *who) |
2086 | 1328 { |
1329 char buf2[BUF_LEN * 2]; | |
5605 | 1330 if (gc->account->perm_deny != 3) |
2086 | 1331 return; |
1332 g_snprintf(buf2, sizeof(buf2), "toc_add_permit %s", normalize(who)); | |
1333 sflap_send(gc, buf2, -1, TYPE_DATA); | |
1334 toc_set_config(gc); | |
1335 } | |
1336 | |
5605 | 1337 static void toc_add_deny(GaimConnection *gc, const char *who) |
2086 | 1338 { |
1339 char buf2[BUF_LEN * 2]; | |
5605 | 1340 if (gc->account->perm_deny != 4) |
2086 | 1341 return; |
1342 g_snprintf(buf2, sizeof(buf2), "toc_add_deny %s", normalize(who)); | |
1343 sflap_send(gc, buf2, -1, TYPE_DATA); | |
1344 toc_set_config(gc); | |
1345 } | |
1346 | |
5605 | 1347 static void toc_set_permit_deny(GaimConnection *gc) |
2086 | 1348 { |
1349 char buf2[BUF_LEN * 2]; | |
1350 GSList *list; | |
1351 int at; | |
1352 | |
5605 | 1353 switch (gc->account->perm_deny) { |
2086 | 1354 case 1: |
1355 /* permit all, deny none. to get here reliably we need to have been in permit | |
1356 * mode, and send an empty toc_add_deny message, which will switch us to deny none */ | |
1357 g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | |
1358 sflap_send(gc, buf2, -1, TYPE_DATA); | |
1359 g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | |
1360 sflap_send(gc, buf2, -1, TYPE_DATA); | |
1361 break; | |
1362 case 2: | |
1363 /* deny all, permit none. to get here reliably we need to have been in deny | |
1364 * mode, and send an empty toc_add_permit message, which will switch us to permit none */ | |
1365 g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | |
1366 sflap_send(gc, buf2, -1, TYPE_DATA); | |
1367 g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | |
1368 sflap_send(gc, buf2, -1, TYPE_DATA); | |
1369 break; | |
1370 case 3: | |
1371 /* permit some. we want to switch to deny mode first, then send the toc_add_permit | |
1372 * message, which will clear and set our permit list. toc sucks. */ | |
1373 g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | |
1374 sflap_send(gc, buf2, -1, TYPE_DATA); | |
1375 | |
1376 at = g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | |
4491 | 1377 list = gc->account->permit; |
2086 | 1378 while (list) { |
1379 at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", normalize(list->data)); | |
1380 if (at > MSG_LEN + 32) { /* from out my ass comes greatness */ | |
1381 sflap_send(gc, buf2, -1, TYPE_DATA); | |
1382 at = g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | |
1383 } | |
1384 list = list->next; | |
1385 } | |
1386 sflap_send(gc, buf2, -1, TYPE_DATA); | |
1387 break; | |
1388 case 4: | |
1389 /* deny some. we want to switch to permit mode first, then send the toc_add_deny | |
1390 * message, which will clear and set our deny list. toc sucks. */ | |
1391 g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | |
1392 sflap_send(gc, buf2, -1, TYPE_DATA); | |
1393 | |
1394 at = g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | |
4491 | 1395 list = gc->account->deny; |
2086 | 1396 while (list) { |
1397 at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", normalize(list->data)); | |
1398 if (at > MSG_LEN + 32) { /* from out my ass comes greatness */ | |
1399 sflap_send(gc, buf2, -1, TYPE_DATA); | |
1400 at = g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | |
1401 } | |
1402 list = list->next; | |
1403 } | |
1404 sflap_send(gc, buf2, -1, TYPE_DATA); | |
1405 break; | |
1406 default: | |
1407 break; | |
1408 } | |
1409 toc_set_config(gc); | |
1410 } | |
1411 | |
5605 | 1412 static void toc_rem_permit(GaimConnection *gc, const char *who) |
2086 | 1413 { |
5605 | 1414 if (gc->account->perm_deny != 3) |
2086 | 1415 return; |
1416 toc_set_permit_deny(gc); | |
1417 } | |
1418 | |
5605 | 1419 static void toc_rem_deny(GaimConnection *gc, const char *who) |
2086 | 1420 { |
5605 | 1421 if (gc->account->perm_deny != 4) |
2086 | 1422 return; |
1423 toc_set_permit_deny(gc); | |
1424 } | |
1425 | |
5605 | 1426 static GList *toc_away_states(GaimConnection *gc) |
2086 | 1427 { |
1428 return g_list_append(NULL, GAIM_AWAY_CUSTOM); | |
1429 } | |
1430 | |
5605 | 1431 static GList *toc_actions(GaimConnection *gc) |
2086 | 1432 { |
1433 GList *m = NULL; | |
4333 | 1434 struct proto_actions_menu *pam; |
2086 | 1435 |
4333 | 1436 pam = g_new0(struct proto_actions_menu, 1); |
1437 pam->label = _("Set User Info"); | |
1438 pam->callback = show_set_info; | |
1439 pam->gc = gc; | |
1440 m = g_list_append(m, pam); | |
1441 | |
1442 pam = g_new0(struct proto_actions_menu, 1); | |
1443 pam->label = _("Set Dir Info"); | |
1444 pam->callback = show_set_dir; | |
1445 pam->gc = gc; | |
1446 m = g_list_append(m, pam); | |
1447 | |
1448 pam = g_new0(struct proto_actions_menu, 1); | |
1449 pam->label = _("Change Password"); | |
1450 pam->callback = show_change_passwd; | |
1451 pam->gc = gc; | |
1452 m = g_list_append(m, pam); | |
2086 | 1453 |
1454 return m; | |
1455 } | |
1456 | |
1457 /********* | |
1458 * RVOUS ACTIONS | |
1459 ********/ | |
1460 | |
1461 struct file_header { | |
1462 char magic[4]; /* 0 */ | |
1463 short hdrlen; /* 4 */ | |
1464 short hdrtype; /* 6 */ | |
1465 char bcookie[8]; /* 8 */ | |
1466 short encrypt; /* 16 */ | |
1467 short compress; /* 18 */ | |
1468 short totfiles; /* 20 */ | |
1469 short filesleft; /* 22 */ | |
1470 short totparts; /* 24 */ | |
1471 short partsleft; /* 26 */ | |
1472 long totsize; /* 28 */ | |
1473 long size; /* 32 */ | |
1474 long modtime; /* 36 */ | |
1475 long checksum; /* 40 */ | |
1476 long rfrcsum; /* 44 */ | |
1477 long rfsize; /* 48 */ | |
1478 long cretime; /* 52 */ | |
1479 long rfcsum; /* 56 */ | |
1480 long nrecvd; /* 60 */ | |
1481 long recvcsum; /* 64 */ | |
1482 char idstring[32]; /* 68 */ | |
1483 char flags; /* 100 */ | |
1484 char lnameoffset; /* 101 */ | |
1485 char lsizeoffset; /* 102 */ | |
1486 char dummy[69]; /* 103 */ | |
1487 char macfileinfo[16]; /* 172 */ | |
1488 short nencode; /* 188 */ | |
1489 short nlanguage; /* 190 */ | |
1490 char name[64]; /* 192 */ | |
1491 /* 256 */ | |
1492 }; | |
1493 | |
1494 struct file_transfer { | |
1495 struct file_header hdr; | |
1496 | |
5605 | 1497 GaimConnection *gc; |
2086 | 1498 |
1499 char *user; | |
1500 char *cookie; | |
1501 char *ip; | |
1502 int port; | |
1503 long size; | |
1504 struct stat st; | |
1505 | |
1506 GtkWidget *window; | |
1507 int files; | |
1508 char *filename; | |
1509 FILE *file; | |
1510 int recvsize; | |
1511 | |
1512 gint inpa; | |
1513 }; | |
1514 | |
1515 static void debug_header(struct file_transfer *ft) { | |
1516 struct file_header *f = (struct file_header *)ft; | |
1517 debug_printf("TOC FT HEADER:\n" | |
1518 "\t%s %d 0x%04x\n" | |
1519 "\t%s %d %d\n" | |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1520 "\t%d %d %d %d %d %d\n" |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1521 "\t%d %d %d %d %d %d %d %d\n" |
2086 | 1522 "\t%s\n" |
1523 "\t0x%02x, 0x%02x, 0x%02x\n" | |
1524 "\t%s %s\n" | |
1525 "\t%d %d\n" | |
1526 "\t%s\n", | |
1527 f->magic, ntohs(f->hdrlen), f->hdrtype, | |
1528 f->bcookie, ntohs(f->encrypt), ntohs(f->compress), | |
1529 ntohs(f->totfiles), ntohs(f->filesleft), ntohs(f->totparts), | |
1530 ntohs(f->partsleft), ntohl(f->totsize), ntohl(f->size), | |
1531 ntohl(f->modtime), ntohl(f->checksum), ntohl(f->rfrcsum), ntohl(f->rfsize), | |
1532 ntohl(f->cretime), ntohl(f->rfcsum), ntohl(f->nrecvd), | |
1533 ntohl(f->recvcsum), | |
1534 f->idstring, | |
1535 f->flags, f->lnameoffset, f->lsizeoffset, | |
1536 f->dummy, f->macfileinfo, | |
1537 ntohs(f->nencode), ntohs(f->nlanguage), | |
1538 f->name); | |
1539 } | |
1540 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1541 static void toc_send_file_callback(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1542 { |
1543 char buf[BUF_LONG]; | |
1544 int rt, i; | |
1545 | |
1546 struct file_transfer *ft = data; | |
1547 | |
1548 if (ft->hdr.hdrtype != 0x202) { | |
1549 char *buf; | |
1550 frombase64(ft->cookie, &buf, NULL); | |
1551 | |
3630 | 1552 toc_read(source, ft, 8); |
1553 toc_read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | |
2086 | 1554 debug_header(ft); |
1555 | |
1556 ft->hdr.hdrtype = 0x202; | |
1557 memcpy(ft->hdr.bcookie, buf, 8); | |
1558 g_free(buf); | |
1559 ft->hdr.encrypt = 0; ft->hdr.compress = 0; | |
1560 debug_header(ft); | |
3630 | 1561 toc_write(source, ft, 256); |
2086 | 1562 |
1563 if (ft->files == 1) { | |
1564 ft->file = fopen(ft->filename, "w"); | |
1565 if (!ft->file) { | |
4115 | 1566 buf = g_strdup_printf(_("Could not open %s for writing!"), ft->filename); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1567 gaim_notify_error(ft->gc, NULL, buf, strerror(errno)); |
2086 | 1568 g_free(buf); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1569 gaim_input_remove(ft->inpa); |
3630 | 1570 toc_soc_close(source); |
2086 | 1571 g_free(ft->filename); |
1572 g_free(ft->user); | |
1573 g_free(ft->ip); | |
1574 g_free(ft->cookie); | |
1575 g_free(ft); | |
1576 } | |
1577 } else { | |
1578 buf = g_strdup_printf("%s/%s", ft->filename, ft->hdr.name); | |
1579 ft->file = fopen(buf, "w"); | |
1580 g_free(buf); | |
1581 if (!ft->file) { | |
1582 buf = g_strdup_printf("Could not open %s/%s for writing!", ft->filename, | |
1583 ft->hdr.name); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1584 gaim_notify_error(ft->gc, NULL, buf, strerror(errno)); |
2086 | 1585 g_free(buf); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1586 gaim_input_remove(ft->inpa); |
3630 | 1587 toc_soc_close(source); |
2086 | 1588 g_free(ft->filename); |
1589 g_free(ft->user); | |
1590 g_free(ft->ip); | |
1591 g_free(ft->cookie); | |
1592 g_free(ft); | |
1593 } | |
1594 } | |
1595 | |
1596 return; | |
1597 } | |
1598 | |
3630 | 1599 rt = toc_read(source, buf, MIN(ntohl(ft->hdr.size) - ft->recvsize, 1024)); |
2086 | 1600 if (rt < 0) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1601 gaim_notify_error(ft->gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1602 _("File transfer failed; other side probably " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1603 "canceled."), NULL); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1604 gaim_input_remove(ft->inpa); |
3630 | 1605 toc_soc_close(source); |
2086 | 1606 g_free(ft->user); |
1607 g_free(ft->ip); | |
1608 g_free(ft->cookie); | |
1609 if (ft->file) | |
1610 fclose(ft->file); | |
1611 g_free(ft); | |
1612 return; | |
1613 } | |
1614 ft->recvsize += rt; | |
1615 for (i = 0; i < rt; i++) | |
1616 fprintf(ft->file, "%c", buf[i]); | |
1617 | |
1618 if (ft->recvsize == ntohl(ft->hdr.size)) { | |
1619 ft->hdr.hdrtype = htons(0x0204); | |
1620 ft->hdr.filesleft = htons(ntohs(ft->hdr.filesleft) - 1); | |
1621 ft->hdr.partsleft = htons(ntohs(ft->hdr.partsleft) - 1); | |
1622 ft->hdr.recvcsum = ft->hdr.checksum; /* uh... */ | |
1623 ft->hdr.nrecvd = htons(ntohs(ft->hdr.nrecvd) + 1); | |
1624 ft->hdr.flags = 0; | |
3630 | 1625 toc_write(source, ft, 256); |
2086 | 1626 debug_header(ft); |
1627 ft->recvsize = 0; | |
1628 fclose(ft->file); | |
1629 if (ft->hdr.filesleft == 0) { | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1630 gaim_input_remove(ft->inpa); |
3630 | 1631 toc_soc_close(source); |
2086 | 1632 g_free(ft->filename); |
1633 g_free(ft->user); | |
1634 g_free(ft->ip); | |
1635 g_free(ft->cookie); | |
1636 g_free(ft); | |
1637 } | |
1638 } | |
1639 } | |
1640 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1641 static void toc_send_file_connect(gpointer data, gint src, GaimInputCondition cond) |
2086 | 1642 { |
1643 struct file_transfer *ft = data; | |
1644 | |
1645 if (src == -1) { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1646 gaim_notify_error(ft->gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1647 _("Could not connect for transfer."), NULL); |
2086 | 1648 g_free(ft->filename); |
1649 g_free(ft->cookie); | |
1650 g_free(ft->user); | |
1651 g_free(ft->ip); | |
1652 g_free(ft); | |
1653 return; | |
1654 } | |
1655 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1656 ft->inpa = gaim_input_add(src, GAIM_INPUT_READ, toc_send_file_callback, ft); |
2086 | 1657 } |
1658 | |
1659 static void toc_send_file(gpointer a, struct file_transfer *old_ft) | |
1660 { | |
1661 struct file_transfer *ft; | |
1662 const char *dirname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(old_ft->window)); | |
5605 | 1663 GaimAccount *account; |
2086 | 1664 char buf[BUF_LEN * 2]; |
1665 | |
1666 if (file_is_dir(dirname, old_ft->window)) | |
1667 return; | |
1668 ft = g_new0(struct file_transfer, 1); | |
1669 if (old_ft->files == 1) | |
1670 ft->filename = g_strdup(dirname); | |
1671 else | |
4793 | 1672 ft->filename = g_path_get_dirname(dirname); |
2086 | 1673 ft->cookie = g_strdup(old_ft->cookie); |
1674 ft->user = g_strdup(old_ft->user); | |
1675 ft->ip = g_strdup(old_ft->ip); | |
1676 ft->files = old_ft->files; | |
1677 ft->port = old_ft->port; | |
1678 ft->gc = old_ft->gc; | |
4491 | 1679 account = ft->gc->account; |
2086 | 1680 gtk_widget_destroy(old_ft->window); |
1681 | |
1682 g_snprintf(buf, sizeof(buf), "toc_rvous_accept %s %s %s", ft->user, ft->cookie, FILE_SEND_UID); | |
1683 sflap_send(ft->gc, buf, -1, TYPE_DATA); | |
1684 | |
4634 | 1685 if (proxy_connect(account, ft->ip, ft->port, toc_send_file_connect, ft) != 0) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1686 gaim_notify_error(ft->gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1687 _("Could not connect for transfer."), NULL); |
2086 | 1688 g_free(ft->filename); |
1689 g_free(ft->cookie); | |
1690 g_free(ft->user); | |
1691 g_free(ft->ip); | |
1692 g_free(ft); | |
1693 return; | |
1694 } | |
1695 } | |
1696 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1697 static void toc_get_file_callback(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1698 { |
1699 char buf[BUF_LONG]; | |
1700 | |
1701 struct file_transfer *ft = data; | |
1702 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1703 if (cond & GAIM_INPUT_WRITE) { |
2086 | 1704 int remain = MIN(ntohl(ft->hdr.totsize) - ft->recvsize, 1024); |
1705 int i; | |
1706 for (i = 0; i < remain; i++) | |
1707 fscanf(ft->file, "%c", &buf[i]); | |
3630 | 1708 toc_write(source, buf, remain); |
2086 | 1709 ft->recvsize += remain; |
1710 if (ft->recvsize == ntohl(ft->hdr.totsize)) { | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1711 gaim_input_remove(ft->inpa); |
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1712 ft->inpa = gaim_input_add(source, GAIM_INPUT_READ, |
2086 | 1713 toc_get_file_callback, ft); |
1714 } | |
1715 return; | |
1716 } | |
1717 | |
1718 if (ft->hdr.hdrtype == htons(0x1108)) { | |
1719 struct tm *fortime; | |
1720 struct stat st; | |
4793 | 1721 char *basename; |
2086 | 1722 |
3630 | 1723 toc_read(source, ft, 8); |
1724 toc_read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | |
2086 | 1725 debug_header(ft); |
1726 | |
1727 stat(ft->filename, &st); | |
1728 fortime = localtime(&st.st_mtime); | |
4793 | 1729 basename = g_path_get_basename(ft->filename); |
2086 | 1730 g_snprintf(buf, sizeof(buf), "%2d/%2d/%4d %2d:%2d %8ld %s\r\n", |
1731 fortime->tm_mon + 1, fortime->tm_mday, fortime->tm_year + 1900, | |
1732 fortime->tm_hour + 1, fortime->tm_min + 1, (long)st.st_size, | |
4793 | 1733 basename); |
3630 | 1734 toc_write(source, buf, ntohl(ft->hdr.size)); |
4793 | 1735 g_free(basename); |
2086 | 1736 return; |
1737 } | |
1738 | |
1739 if (ft->hdr.hdrtype == htons(0x1209)) { | |
3630 | 1740 toc_read(source, ft, 8); |
1741 toc_read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | |
2086 | 1742 debug_header(ft); |
1743 return; | |
1744 } | |
1745 | |
1746 if (ft->hdr.hdrtype == htons(0x120b)) { | |
3630 | 1747 toc_read(source, ft, 8); |
1748 toc_read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | |
2086 | 1749 debug_header(ft); |
1750 | |
1751 if (ft->hdr.hdrtype != htons(0x120c)) { | |
1752 g_snprintf(buf, sizeof(buf), "%s decided to cancel the transfer", ft->user); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1753 gaim_notify_error(ft->gc, NULL, buf, NULL); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1754 gaim_input_remove(ft->inpa); |
3630 | 1755 toc_soc_close(source); |
2086 | 1756 g_free(ft->filename); |
1757 g_free(ft->user); | |
1758 g_free(ft->ip); | |
1759 g_free(ft->cookie); | |
1760 if (ft->file) | |
1761 fclose(ft->file); | |
1762 g_free(ft); | |
1763 return; | |
1764 } | |
1765 | |
1766 ft->hdr.hdrtype = 0x0101; | |
1767 ft->hdr.totfiles = htons(1); ft->hdr.filesleft = htons(1); | |
1768 ft->hdr.flags = 0x20; | |
3630 | 1769 toc_write(source, ft, 256); |
2086 | 1770 return; |
1771 } | |
1772 | |
1773 if (ft->hdr.hdrtype == 0x0101) { | |
3630 | 1774 toc_read(source, ft, 8); |
1775 toc_read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | |
2086 | 1776 debug_header(ft); |
1777 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1778 gaim_input_remove(ft->inpa); |
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1779 ft->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, |
2086 | 1780 toc_get_file_callback, ft); |
1781 return; | |
1782 } | |
1783 | |
1784 if (ft->hdr.hdrtype == 0x0202) { | |
3630 | 1785 toc_read(source, ft, 8); |
1786 toc_read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | |
2086 | 1787 debug_header(ft); |
1788 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1789 gaim_input_remove(ft->inpa); |
3630 | 1790 toc_soc_close(source); |
2086 | 1791 g_free(ft->filename); |
1792 g_free(ft->user); | |
1793 g_free(ft->ip); | |
1794 g_free(ft->cookie); | |
1795 if (ft->file) | |
1796 fclose(ft->file); | |
1797 g_free(ft); | |
1798 return; | |
1799 } | |
1800 } | |
1801 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1802 static void toc_get_file_connect(gpointer data, gint src, GaimInputCondition cond) |
2086 | 1803 { |
1804 struct file_transfer *ft = data; | |
1805 struct file_header *hdr; | |
1806 char *buf; | |
4793 | 1807 char *basename; |
2086 | 1808 |
1809 if (src == -1) { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1810 gaim_notify_error(ft->gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1811 _("Could not connect for transfer!"), NULL); |
2086 | 1812 fclose(ft->file); |
1813 g_free(ft->filename); | |
1814 g_free(ft->cookie); | |
1815 g_free(ft->user); | |
1816 g_free(ft->ip); | |
1817 g_free(ft); | |
1818 return; | |
1819 } | |
1820 | |
1821 hdr = (struct file_header *)ft; | |
1822 hdr->magic[0] = 'O'; hdr->magic[1] = 'F'; hdr->magic[2] = 'T'; hdr->magic[3] = '2'; | |
1823 hdr->hdrlen = htons(256); | |
1824 hdr->hdrtype = htons(0x1108); | |
1825 frombase64(ft->cookie, &buf, NULL); | |
1826 g_snprintf(hdr->bcookie, 8, "%s", buf); | |
1827 g_free(buf); | |
1828 hdr->totfiles = htons(1); hdr->filesleft = htons(1); | |
1829 hdr->totparts = htons(1); hdr->partsleft = htons(1); | |
1830 hdr->totsize = htonl((long)ft->st.st_size); /* combined size of all files */ | |
1831 /* size = strlen("mm/dd/yyyy hh:mm sizesize 'name'\r\n") */ | |
4793 | 1832 basename = g_path_get_basename(ft->filename); |
1833 hdr->size = htonl(28 + strlen(basename)); /* size of listing.txt */ | |
1834 g_free(basename); | |
2086 | 1835 hdr->modtime = htonl(ft->st.st_mtime); |
1836 hdr->checksum = htonl(0x89f70000); /* uh... */ | |
1837 g_snprintf(hdr->idstring, 32, "OFT_Windows ICBMFT V1.1 32"); | |
1838 hdr->flags = 0x02; | |
1839 hdr->lnameoffset = 0x1A; | |
1840 hdr->lsizeoffset = 0x10; | |
1841 g_snprintf(hdr->name, 64, "listing.txt"); | |
3630 | 1842 if (toc_write(src, hdr, 256) < 0) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1843 gaim_notify_error(ft->gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1844 _("Could not write file header. The file will " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1845 "not be transferred."), NULL); |
2086 | 1846 fclose(ft->file); |
1847 g_free(ft->filename); | |
1848 g_free(ft->cookie); | |
1849 g_free(ft->user); | |
1850 g_free(ft->ip); | |
1851 g_free(ft); | |
1852 return; | |
1853 } | |
1854 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1855 ft->inpa = gaim_input_add(src, GAIM_INPUT_READ, toc_get_file_callback, ft); |
2086 | 1856 } |
1857 | |
1858 static void toc_get_file(gpointer a, struct file_transfer *old_ft) | |
1859 { | |
1860 struct file_transfer *ft; | |
1861 const char *dirname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(old_ft->window)); | |
5605 | 1862 GaimAccount *account; |
2086 | 1863 char *buf, buf2[BUF_LEN * 2]; |
1864 | |
1865 if (file_is_dir(dirname, old_ft->window)) | |
1866 return; | |
1867 ft = g_new0(struct file_transfer, 1); | |
1868 ft->filename = g_strdup(dirname); | |
1869 ft->file = fopen(ft->filename, "r"); | |
1870 if (!ft->file) { | |
3427 | 1871 buf = g_strdup_printf("Unable to open %s for transfer.", ft->filename); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1872 gaim_notify_error(ft->gc, NULL, buf, NULL); |
2086 | 1873 g_free(buf); |
1874 g_free(ft->filename); | |
1875 g_free(ft); | |
1876 return; | |
1877 } | |
1878 if (stat(dirname, &ft->st)) { | |
3427 | 1879 buf = g_strdup_printf("Unable to examine %s.", dirname); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1880 gaim_notify_error(ft->gc, NULL, buf, NULL); |
2086 | 1881 g_free(buf); |
1882 g_free(ft->filename); | |
1883 g_free(ft); | |
1884 return; | |
1885 } | |
1886 ft->cookie = g_strdup(old_ft->cookie); | |
1887 ft->user = g_strdup(old_ft->user); | |
1888 ft->ip = g_strdup(old_ft->ip); | |
1889 ft->port = old_ft->port; | |
1890 ft->gc = old_ft->gc; | |
4491 | 1891 account = ft->gc->account; |
2086 | 1892 gtk_widget_destroy(old_ft->window); |
1893 | |
1894 g_snprintf(buf2, sizeof(buf2), "toc_rvous_accept %s %s %s", ft->user, ft->cookie, FILE_GET_UID); | |
1895 sflap_send(ft->gc, buf2, -1, TYPE_DATA); | |
1896 | |
4634 | 1897 if (proxy_connect(account, ft->ip, ft->port, toc_get_file_connect, ft) < 0) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1898 gaim_notify_error(ft->gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1899 _("Could not connect for transfer."), NULL); |
2086 | 1900 fclose(ft->file); |
1901 g_free(ft->filename); | |
1902 g_free(ft->cookie); | |
1903 g_free(ft->user); | |
1904 g_free(ft->ip); | |
1905 g_free(ft); | |
1906 return; | |
1907 } | |
1908 } | |
1909 | |
1910 static void cancel_callback(gpointer a, struct file_transfer *ft) { | |
1911 gtk_widget_destroy(ft->window); | |
1912 if (a == ft->window) { | |
1913 g_free(ft->cookie); | |
1914 g_free(ft->user); | |
1915 g_free(ft->ip); | |
1916 g_free(ft); | |
1917 } | |
1918 } | |
1919 | |
3867 | 1920 static void toc_reject_ft(struct ft_request *ft) { |
1921 g_free(ft->user); | |
1922 g_free(ft->filename); | |
1923 g_free(ft->ip); | |
1924 g_free(ft->cookie); | |
1925 if (ft->message) | |
1926 g_free(ft->message); | |
1927 g_free(ft); | |
1928 } | |
1929 | |
1930 | |
3730 | 1931 static void toc_accept_ft(struct ft_request *fr) { |
5605 | 1932 if(g_list_find(gaim_connections_get_all(), fr->gc)) { |
4249 | 1933 GtkWidget *window; |
1934 char buf[BUF_LEN]; | |
2086 | 1935 |
4249 | 1936 struct file_transfer *ft = g_new0(struct file_transfer, 1); |
1937 ft->gc = fr->gc; | |
1938 ft->user = g_strdup(fr->user); | |
1939 ft->cookie = g_strdup(fr->cookie); | |
1940 ft->ip = g_strdup(fr->ip); | |
1941 ft->port = fr->port; | |
1942 ft->files = fr->files; | |
2086 | 1943 |
4249 | 1944 ft->window = window = gtk_file_selection_new(_("Gaim - Save As...")); |
1945 g_snprintf(buf, sizeof(buf), "%s/%s", gaim_home_dir(), fr->filename ? fr->filename : ""); | |
1946 gtk_file_selection_set_filename(GTK_FILE_SELECTION(window), buf); | |
4635 | 1947 g_signal_connect(G_OBJECT(window), "destroy", |
1948 G_CALLBACK(cancel_callback), ft); | |
1949 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(ft->window)->cancel_button), | |
1950 "clicked", G_CALLBACK(cancel_callback), ft); | |
2086 | 1951 |
4249 | 1952 if (!strcmp(fr->UID, FILE_SEND_UID)) |
4635 | 1953 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(window)->ok_button), |
1954 "clicked", G_CALLBACK(toc_send_file), ft); | |
4249 | 1955 else |
4635 | 1956 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(window)->ok_button), |
1957 "clicked", G_CALLBACK(toc_get_file), ft); | |
2086 | 1958 |
4249 | 1959 gtk_widget_show(window); |
1960 } | |
1961 | |
3867 | 1962 toc_reject_ft(fr); |
2086 | 1963 } |
1964 | |
1965 static void accept_file_dialog(struct ft_request *ft) { | |
1966 char buf[BUF_LONG]; | |
1967 if (!strcmp(ft->UID, FILE_SEND_UID)) { | |
1968 /* holy crap. who the fuck would transfer gigabytes through AIM?! */ | |
1969 static char *sizes[4] = { "bytes", "KB", "MB", "GB" }; | |
1970 float size = ft->size; | |
1971 int index = 0; | |
1972 while ((index < 4) && (size > 1024)) { | |
1973 size /= 1024; | |
1974 index++; | |
1975 } | |
2943 | 1976 g_snprintf(buf, sizeof(buf), |
4276 | 1977 ngettext( |
1978 "%s requests %s to accept %d file: %s (%.2f %s)%s%s", | |
1979 "%s requests %s to accept %d files: %s (%.2f %s)%s%s", | |
1980 ft->files), | |
5605 | 1981 ft->user, gaim_account_get_username(ft->gc->account), ft->files, |
2086 | 1982 ft->filename, size, sizes[index], (ft->message) ? "\n" : "", |
1983 (ft->message) ? ft->message : ""); | |
1984 } else { | |
1985 g_snprintf(buf, sizeof(buf), _("%s requests you to send them a file"), ft->user); | |
1986 } | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1987 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1988 gaim_request_accept_cancel(ft->gc, NULL, buf, NULL, 0, ft, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1989 G_CALLBACK(toc_accept_ft), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1990 G_CALLBACK(toc_reject_ft)); |
2086 | 1991 } |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1992 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1993 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1994 { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1995 GAIM_PROTO_TOC, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1996 OPT_PROTO_CORRECT_TIME, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1997 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1998 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1999 toc_list_icon, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2000 toc_list_emblems, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2001 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2002 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2003 toc_away_states, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2004 toc_actions, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2005 toc_buddy_menu, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2006 toc_chat_info, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2007 toc_login, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2008 toc_close, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2009 toc_send_im, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2010 toc_set_info, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2011 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2012 toc_get_info, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2013 toc_set_away, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2014 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2015 toc_set_dir, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2016 toc_get_dir, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2017 toc_dir_search, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2018 toc_set_idle, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2019 toc_change_passwd, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2020 toc_add_buddy, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2021 toc_add_buddies, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2022 toc_remove_buddy, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2023 toc_remove_buddies, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2024 toc_add_permit, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2025 toc_add_deny, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2026 toc_rem_permit, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2027 toc_rem_deny, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2028 toc_set_permit_deny, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2029 toc_warn, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2030 toc_join_chat, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2031 toc_chat_invite, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2032 toc_chat_leave, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2033 toc_chat_whisper, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2034 toc_chat_send, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2035 toc_keepalive, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2036 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2037 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2038 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2039 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2040 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2041 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2042 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2043 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2044 NULL |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2045 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2046 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2047 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2048 { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2049 2, /**< api_version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2050 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2051 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2052 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2053 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2054 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2055 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2056 "prpl-toc", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2057 "TOC", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2058 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2059 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2060 N_("TOC Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2061 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2062 N_("TOC Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2063 NULL, /**< author */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2064 WEBSITE, /**< homepage */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2065 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2066 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2067 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2068 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2069 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2070 NULL, /**< ui_info */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2071 &prpl_info /**< extra_info */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2072 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2073 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2074 static void |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2075 __init_plugin(GaimPlugin *plugin) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2076 { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2077 struct proto_user_opt *puo; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2078 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2079 puo = g_new0(struct proto_user_opt, 1); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2080 puo->label = g_strdup(_("TOC Host:")); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2081 puo->def = g_strdup("toc.oscar.aol.com"); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2082 puo->pos = USEROPT_AUTH; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2083 prpl_info.user_opts = g_list_append(prpl_info.user_opts, puo); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2084 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2085 puo = g_new0(struct proto_user_opt, 1); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2086 puo->label = g_strdup(_("TOC Port:")); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2087 puo->def = g_strdup("9898"); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2088 puo->pos = USEROPT_AUTHPORT; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2089 prpl_info.user_opts = g_list_append(prpl_info.user_opts, puo); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2090 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2091 my_protocol = plugin; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2092 } |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2093 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2094 GAIM_INIT_PLUGIN(toc, __init_plugin, info); |