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