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