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