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