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