Mercurial > pidgin
annotate src/protocols/toc/toc.c @ 10744:1b927566fcc4
[gaim-migrate @ 12346]
Some lovin' for stuff that isn't compiled by default.
committer: Tailor Script <tailor@pidgin.im>
| author | Mark Doliner <mark@kingant.net> |
|---|---|
| date | Sun, 27 Mar 2005 01:14:41 +0000 |
| parents | 94cc67130789 |
| children | bf5e48215158 |
| 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: | |
| 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.")); | |
| 553 break; | |
| 554 g_snprintf(buf, sizeof(buf), _("An unknown signon error has occurred: %s."), w); | |
| 555 break; | |
| 556 default: | |
| 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 serv_finish_login(gc); |
| 737 | |
| 9058 | 738 /* |
| 739 * Add me to my buddy list so that we know the time when | |
| 740 * the server thinks I signed on. | |
| 741 */ | |
| 9285 | 742 buddy = gaim_buddy_new(account, username, NULL); |
| 743 /* XXX - Pick a group to add to */ | |
| 744 /* gaim_blist_add(buddy, NULL, g, NULL); */ | |
| 745 serv_add_buddy(gc, buddy); | |
| 9058 | 746 |
| 2086 | 747 /* Client sends TOC toc_init_done message */ |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
748 gaim_debug(GAIM_DEBUG_INFO, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
749 "Client sends TOC toc_init_done message\n"); |
| 2086 | 750 g_snprintf(snd, sizeof snd, "toc_init_done"); |
| 751 sflap_send(gc, snd, -1, TYPE_DATA); | |
| 752 | |
| 753 /* | |
| 754 g_snprintf(snd, sizeof snd, "toc_set_caps %s %s %s", | |
| 755 FILE_SEND_UID, FILE_GET_UID, B_ICON_UID); | |
| 756 */ | |
| 757 g_snprintf(snd, sizeof snd, "toc_set_caps %s %s", FILE_SEND_UID, FILE_GET_UID); | |
| 758 sflap_send(gc, snd, -1, TYPE_DATA); | |
| 759 | |
| 760 return; | |
| 761 } | |
| 762 | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
763 gaim_debug(GAIM_DEBUG_INFO, "toc", "S: %s\n", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
764 buf + sizeof(struct sflap_hdr)); |
| 2086 | 765 |
| 766 c = strtok(buf + sizeof(struct sflap_hdr), ":"); /* Ditch the first part */ | |
| 767 | |
| 4793 | 768 if (!g_ascii_strcasecmp(c, "SIGN_ON")) { |
| 2086 | 769 /* we should only get here after a PAUSE */ |
| 770 if (tdt->state != STATE_PAUSE) | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
771 gaim_debug(GAIM_DEBUG_ERROR, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
772 "got SIGN_ON but not PAUSE!\n"); |
| 2086 | 773 else { |
| 774 tdt->state = STATE_ONLINE; | |
| 775 g_snprintf(snd, sizeof snd, "toc_signon %s %d %s %s %s \"%s\"", | |
| 5605 | 776 AUTH_HOST, AUTH_PORT, |
| 10011 | 777 gaim_normalize(account, gaim_account_get_username(account)), |
| 10744 | 778 roast_password(gaim_connection_get_password(gc)), |
| 5605 | 779 LANGUAGE, REVISION); |
| 2086 | 780 if (sflap_send(gc, snd, -1, TYPE_DATA) < 0) { |
| 5605 | 781 gaim_connection_error(gc, _("Disconnected.")); |
| 2086 | 782 return; |
| 783 } | |
| 784 g_snprintf(snd, sizeof snd, "toc_init_done"); | |
| 785 sflap_send(gc, snd, -1, TYPE_DATA); | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
786 gaim_notify_info(gc, NULL, |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
787 _("TOC has come back from its pause. You may " |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
788 "now send messages again."), NULL); |
| 2086 | 789 } |
| 4793 | 790 } else if (!g_ascii_strcasecmp(c, "CONFIG")) { |
| 2086 | 791 c = strtok(NULL, ":"); |
| 10744 | 792 parse_toc_buddy_list(account, c); |
| 4793 | 793 } else if (!g_ascii_strcasecmp(c, "NICK")) { |
| 2086 | 794 /* ignore NICK so that things get imported/exported properly |
| 795 c = strtok(NULL, ":"); | |
| 796 g_snprintf(gc->username, sizeof(gc->username), "%s", c); | |
| 797 */ | |
| 4793 | 798 } else if (!g_ascii_strcasecmp(c, "IM_IN")) { |
| 2086 | 799 char *away, *message; |
| 800 int a = 0; | |
| 801 | |
| 802 c = strtok(NULL, ":"); | |
| 803 away = strtok(NULL, ":"); | |
| 804 | |
| 805 message = away; | |
| 806 while (*message && (*message != ':')) | |
| 807 message++; | |
| 808 message++; | |
| 809 | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
810 a = (away && (*away == 'T')) ? GAIM_CONV_IM_AUTO_RESP : 0; |
| 2086 | 811 |
| 6982 | 812 serv_got_im(gc, c, message, a, time(NULL)); |
| 4793 | 813 } else if (!g_ascii_strcasecmp(c, "UPDATE_BUDDY")) { |
|
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
814 char *l, *uc, *tmp; |
| 9927 | 815 gboolean logged_in; |
| 816 int evil, idle, type = 0; | |
| 2086 | 817 time_t signon, time_idle; |
| 818 | |
| 819 c = strtok(NULL, ":"); /* name */ | |
| 820 l = strtok(NULL, ":"); /* online */ | |
| 821 sscanf(strtok(NULL, ":"), "%d", &evil); | |
| 822 sscanf(strtok(NULL, ":"), "%ld", &signon); | |
| 823 sscanf(strtok(NULL, ":"), "%d", &idle); | |
| 824 uc = strtok(NULL, ":"); | |
| 825 | |
| 9927 | 826 logged_in = (l && (*l == 'T')) ? TRUE : FALSE; |
| 2086 | 827 |
| 828 if (uc[0] == 'A') | |
| 829 type |= UC_AOL; | |
| 830 switch (uc[1]) { | |
| 831 case 'A': | |
| 832 type |= UC_ADMIN; | |
| 833 break; | |
| 834 case 'U': | |
| 835 type |= UC_UNCONFIRMED; | |
| 836 break; | |
| 837 case 'O': | |
| 838 type |= UC_NORMAL; | |
| 839 break; | |
| 3083 | 840 case 'C': |
| 841 type |= UC_WIRELESS; | |
| 842 break; | |
| 2086 | 843 default: |
| 844 break; | |
| 845 } | |
| 846 if (uc[2] == 'U') | |
| 847 type |= UC_UNAVAILABLE; | |
| 848 | |
| 849 if (idle) { | |
| 850 time(&time_idle); | |
| 851 time_idle -= idle * 60; | |
| 852 } else | |
| 853 time_idle = 0; | |
| 854 | |
| 9058 | 855 /* |
| 856 * If we have info for ourselves then set our display name, warning | |
| 857 * level and official time of login. | |
| 858 */ | |
| 10011 | 859 tmp = g_strdup(gaim_normalize(account, gaim_account_get_username(gc->account))); |
| 860 if (!strcmp(tmp, gaim_normalize(account, c))) { | |
| 5605 | 861 gaim_connection_set_display_name(gc, c); |
| 10011 | 862 /* XXX - What should the second parameter be here? */ |
| 863 gaim_prpl_got_account_warning_level(account, NULL, evil); | |
| 864 gaim_prpl_got_account_login_time(account, NULL, signon); | |
| 9058 | 865 } |
|
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
866 g_free(tmp); |
|
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
867 |
| 10011 | 868 gaim_prpl_got_user_status(account, c, (logged_in ? "online" : "offline"), NULL); |
| 869 gaim_prpl_got_user_login_time(account, c, signon); | |
| 870 if (time_idle > 0) | |
| 871 gaim_prpl_got_user_idle(account, c, TRUE, time_idle); | |
| 872 else | |
| 873 gaim_prpl_got_user_idle(account, c, FALSE, 0); | |
| 4793 | 874 } else if (!g_ascii_strcasecmp(c, "ERROR")) { |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
875 gaim_notify_error(gc, NULL, show_error_message(), NULL); |
| 4793 | 876 } else if (!g_ascii_strcasecmp(c, "EVILED")) { |
| 2086 | 877 int lev; |
| 878 char *name; | |
| 879 | |
| 880 sscanf(strtok(NULL, ":"), "%d", &lev); | |
| 881 name = strtok(NULL, ":"); | |
| 882 | |
| 10011 | 883 gaim_prpl_got_account_warning_level(account, name, lev); |
| 4793 | 884 } else if (!g_ascii_strcasecmp(c, "CHAT_JOIN")) { |
| 2086 | 885 char *name; |
| 886 int id; | |
| 887 | |
| 888 sscanf(strtok(NULL, ":"), "%d", &id); | |
| 889 name = strtok(NULL, ":"); | |
| 890 | |
| 891 serv_got_joined_chat(gc, id, name); | |
| 4793 | 892 } else if (!g_ascii_strcasecmp(c, "CHAT_IN")) { |
| 9584 | 893 int id; |
| 894 GaimConvChatFlags flags; | |
| 2086 | 895 char *m, *who, *whisper; |
| 896 | |
| 897 sscanf(strtok(NULL, ":"), "%d", &id); | |
| 898 who = strtok(NULL, ":"); | |
| 899 whisper = strtok(NULL, ":"); | |
| 900 m = whisper; | |
| 901 while (*m && (*m != ':')) | |
| 902 m++; | |
| 903 m++; | |
| 904 | |
| 9584 | 905 flags = (whisper && (*whisper == 'T')) ? GAIM_CONV_CHAT_WHISPER : 0; |
| 2086 | 906 |
| 9584 | 907 serv_got_chat_in(gc, id, who, flags, m, time((time_t)NULL)); |
| 4793 | 908 } else if (!g_ascii_strcasecmp(c, "CHAT_UPDATE_BUDDY")) { |
| 2086 | 909 int id; |
| 910 char *in, *buddy; | |
| 911 GSList *bcs = gc->buddy_chats; | |
| 5679 | 912 GaimConversation *b = NULL; |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
913 GaimConvChat *chat; |
| 2086 | 914 |
| 915 sscanf(strtok(NULL, ":"), "%d", &id); | |
| 916 in = strtok(NULL, ":"); | |
| 917 | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
918 chat = GAIM_CONV_CHAT(b); |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
919 |
| 2086 | 920 while (bcs) { |
| 5679 | 921 b = (GaimConversation *)bcs->data; |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
922 if (id == gaim_conv_chat_get_id(chat)) |
| 2086 | 923 break; |
| 924 bcs = bcs->next; | |
| 925 b = NULL; | |
| 926 } | |
| 927 | |
| 928 if (!b) | |
| 929 return; | |
| 930 | |
| 931 if (in && (*in == 'T')) | |
| 932 while ((buddy = strtok(NULL, ":")) != NULL) | |
| 9846 | 933 gaim_conv_chat_add_user(chat, buddy, NULL, GAIM_CBFLAGS_NONE, TRUE); |
| 2086 | 934 else |
| 935 while ((buddy = strtok(NULL, ":")) != NULL) | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
936 gaim_conv_chat_remove_user(chat, buddy, NULL); |
| 4793 | 937 } else if (!g_ascii_strcasecmp(c, "CHAT_INVITE")) { |
| 2086 | 938 char *name, *who, *message; |
| 5234 | 939 int id; |
| 940 GHashTable *components = g_hash_table_new_full(g_str_hash, g_str_equal, | |
| 941 g_free, g_free); | |
| 2086 | 942 |
| 943 name = strtok(NULL, ":"); | |
| 5234 | 944 sscanf(strtok(NULL, ":"), "%d", &id); |
| 2086 | 945 who = strtok(NULL, ":"); |
| 946 message = strtok(NULL, ":"); | |
| 947 | |
| 5234 | 948 g_hash_table_replace(components, g_strdup("id"), g_strdup_printf("%d", id)); |
| 949 | |
| 950 serv_got_chat_invite(gc, name, who, message, components); | |
| 4793 | 951 } else if (!g_ascii_strcasecmp(c, "CHAT_LEFT")) { |
| 2086 | 952 GSList *bcs = gc->buddy_chats; |
| 5679 | 953 GaimConversation *b = NULL; |
| 2086 | 954 int id; |
| 955 | |
| 956 sscanf(strtok(NULL, ":"), "%d", &id); | |
| 957 | |
| 958 while (bcs) { | |
| 5679 | 959 b = (GaimConversation *)bcs->data; |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
960 if (id == gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))) |
| 2086 | 961 break; |
| 962 b = NULL; | |
| 963 bcs = bcs->next; | |
| 964 } | |
| 965 | |
| 966 if (!b) | |
| 967 return; | |
| 968 | |
| 969 if (b->window) { | |
| 970 char error_buf[BUF_LONG]; | |
| 4491 | 971 gaim_conversation_set_account(b, NULL); |
| 2086 | 972 g_snprintf(error_buf, sizeof error_buf, _("You have been disconnected" |
| 973 " from chat room %s."), b->name); | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
974 gaim_notify_error(gc, NULL, error_buf, NULL); |
| 2086 | 975 } else |
| 976 serv_got_chat_left(gc, id); | |
| 4793 | 977 } else if (!g_ascii_strcasecmp(c, "GOTO_URL")) { |
| 2086 | 978 char *name, *url, tmp[256]; |
| 979 | |
| 980 name = strtok(NULL, ":"); | |
| 981 url = strtok(NULL, ":"); | |
| 982 | |
| 4597 | 983 g_snprintf(tmp, sizeof(tmp), "http://%s:%d/%s", tdt->toc_ip, |
| 5605 | 984 gaim_account_get_int(gc->account, "port", TOC_PORT), |
| 2086 | 985 url); |
|
7094
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
7084
diff
changeset
|
986 gaim_url_fetch(tmp, FALSE, NULL, FALSE, toc_got_info, gc); |
| 4793 | 987 } else if (!g_ascii_strcasecmp(c, "DIR_STATUS")) { |
| 988 } else if (!g_ascii_strcasecmp(c, "ADMIN_NICK_STATUS")) { | |
| 989 } else if (!g_ascii_strcasecmp(c, "ADMIN_PASSWD_STATUS")) { | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
990 gaim_notify_info(gc, NULL, _("Password Change Successful"), NULL); |
| 4793 | 991 } else if (!g_ascii_strcasecmp(c, "PAUSE")) { |
| 2086 | 992 tdt->state = STATE_PAUSE; |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
993 gaim_notify_warning(gc, NULL, |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
994 _("TOC has sent a PAUSE command."), |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
995 _("When this happens, TOC ignores any messages " |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
996 "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
|
997 " message. Gaim will prevent anything from " |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
998 "going through. This is only temporary, please " |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
999 "be patient.")); |
| 4793 | 1000 } else if (!g_ascii_strcasecmp(c, "RVOUS_PROPOSE")) { |
| 6867 | 1001 #if 0 |
| 2086 | 1002 char *user, *uuid, *cookie; |
| 1003 int seq; | |
| 3159 | 1004 char *rip, *pip, *vip, *trillian = NULL; |
| 2086 | 1005 int port; |
| 3126 | 1006 |
| 2086 | 1007 user = strtok(NULL, ":"); |
| 1008 uuid = strtok(NULL, ":"); | |
| 1009 cookie = strtok(NULL, ":"); | |
| 1010 sscanf(strtok(NULL, ":"), "%d", &seq); | |
| 1011 rip = strtok(NULL, ":"); | |
| 1012 pip = strtok(NULL, ":"); | |
| 1013 vip = strtok(NULL, ":"); | |
| 1014 sscanf(strtok(NULL, ":"), "%d", &port); | |
| 1015 | |
| 1016 if (!strcmp(uuid, FILE_SEND_UID)) { | |
| 1017 /* they want us to get a file */ | |
| 1018 int unk[4], i; | |
| 1019 char *messages[4], *tmp, *name; | |
| 1020 int subtype, files, totalsize = 0; | |
| 1021 struct ft_request *ft; | |
| 1022 | |
| 1023 for (i = 0; i < 4; i++) { | |
| 3126 | 1024 trillian = strtok(NULL, ":"); |
| 1025 sscanf(trillian, "%d", &unk[i]); | |
| 2086 | 1026 if (unk[i] == 10001) |
| 1027 break; | |
| 3126 | 1028 /* Trillian likes to send an empty token as a message, rather than |
| 1029 no message at all. */ | |
| 1030 if (*(trillian + strlen(trillian) +1) != ':') | |
| 1031 frombase64(strtok(NULL, ":"), &messages[i], NULL); | |
| 2086 | 1032 } |
| 3126 | 1033 |
| 2086 | 1034 frombase64(strtok(NULL, ":"), &tmp, NULL); |
| 1035 | |
| 1036 subtype = tmp[1]; | |
| 1037 files = tmp[3]; | |
| 1038 | |
| 1039 totalsize |= (tmp[4] << 24) & 0xff000000; | |
| 1040 totalsize |= (tmp[5] << 16) & 0x00ff0000; | |
| 1041 totalsize |= (tmp[6] << 8) & 0x0000ff00; | |
| 1042 totalsize |= (tmp[7] << 0) & 0x000000ff; | |
| 1043 | |
| 1044 if (!totalsize) { | |
| 1045 g_free(tmp); | |
| 1046 for (i--; i >= 0; i--) | |
| 1047 g_free(messages[i]); | |
| 1048 return; | |
| 1049 } | |
| 1050 | |
| 1051 name = tmp + 8; | |
| 1052 | |
| 1053 ft = g_new0(struct ft_request, 1); | |
| 1054 ft->cookie = g_strdup(cookie); | |
| 1055 ft->ip = g_strdup(pip); | |
| 1056 ft->port = port; | |
| 1057 if (i) | |
| 1058 ft->message = g_strdup(messages[0]); | |
| 1059 else | |
| 1060 ft->message = NULL; | |
| 1061 ft->filename = g_strdup(name); | |
| 1062 ft->user = g_strdup(user); | |
| 1063 ft->size = totalsize; | |
| 1064 ft->files = files; | |
| 1065 g_snprintf(ft->UID, sizeof(ft->UID), "%s", FILE_SEND_UID); | |
| 1066 ft->gc = gc; | |
| 1067 | |
| 1068 g_free(tmp); | |
| 1069 for (i--; i >= 0; i--) | |
| 1070 g_free(messages[i]); | |
| 1071 | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1072 gaim_debug(GAIM_DEBUG_MISC, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1073 "English translation of RVOUS_PROPOSE: %s requests " |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1074 "Send File (i.e. send a file to you); %s:%d " |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1075 "(verified_ip:port), %d files at total size of " |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1076 "%d bytes.\n", user, vip, port, files, totalsize); |
| 2086 | 1077 accept_file_dialog(ft); |
| 1078 } else if (!strcmp(uuid, FILE_GET_UID)) { | |
| 1079 /* they want us to send a file */ | |
| 1080 int unk[4], i; | |
| 1081 char *messages[4], *tmp; | |
| 1082 struct ft_request *ft; | |
| 1083 | |
| 1084 for (i = 0; i < 4; i++) { | |
| 1085 sscanf(strtok(NULL, ":"), "%d", unk + i); | |
| 1086 if (unk[i] == 10001) | |
| 1087 break; | |
| 3126 | 1088 /* Trillian likes to send an empty token as a message, rather than |
| 1089 no message at all. */ | |
| 1090 if (*(trillian + strlen(trillian) +1) != ':') | |
| 1091 frombase64(strtok(NULL, ":"), &messages[i], NULL); | |
| 2086 | 1092 } |
| 1093 frombase64(strtok(NULL, ":"), &tmp, NULL); | |
| 1094 | |
| 1095 ft = g_new0(struct ft_request, 1); | |
| 1096 ft->cookie = g_strdup(cookie); | |
| 1097 ft->ip = g_strdup(pip); | |
| 1098 ft->port = port; | |
| 1099 if (i) | |
| 1100 ft->message = g_strdup(messages[0]); | |
| 1101 else | |
| 1102 ft->message = NULL; | |
| 1103 ft->user = g_strdup(user); | |
| 1104 g_snprintf(ft->UID, sizeof(ft->UID), "%s", FILE_GET_UID); | |
| 1105 ft->gc = gc; | |
| 1106 | |
| 1107 g_free(tmp); | |
| 1108 for (i--; i >= 0; i--) | |
| 1109 g_free(messages[i]); | |
| 1110 | |
| 1111 accept_file_dialog(ft); | |
| 1112 } else if (!strcmp(uuid, VOICE_UID)) { | |
| 1113 /* oh goody. voice over ip. fun stuff. */ | |
| 1114 } else if (!strcmp(uuid, B_ICON_UID)) { | |
| 1115 int unk[4], i; | |
| 1116 char *messages[4]; | |
| 1117 struct buddy_icon *icon; | |
| 1118 | |
| 1119 for (i = 0; i < 4; i++) { | |
| 1120 sscanf(strtok(NULL, ":"), "%d", unk + i); | |
| 1121 if (unk[i] == 10001) | |
| 1122 break; | |
| 1123 frombase64(strtok(NULL, ":"), &messages[i], NULL); | |
| 1124 } | |
| 1125 frombase64(strtok(NULL, ":"), (char **)&icon, NULL); | |
| 1126 | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1127 gaim_debug(GAIM_DEBUG_MISC, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1128 "received icon of length %d\n", icon->len); |
| 2086 | 1129 g_free(icon); |
| 1130 for (i--; i >= 0; i--) | |
| 1131 g_free(messages[i]); | |
| 1132 } else if (!strcmp(uuid, IMAGE_UID)) { | |
| 1133 /* aka Direct IM */ | |
| 1134 } else { | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1135 gaim_debug(GAIM_DEBUG_ERROR, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1136 "Don't know what to do with RVOUS UUID %s\n", uuid); |
| 2086 | 1137 /* do we have to do anything here? i think it just times out */ |
| 1138 } | |
| 6867 | 1139 #endif |
| 2086 | 1140 } else { |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1141 gaim_debug(GAIM_DEBUG_ERROR, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1142 "don't know what to do with %s\n", c); |
| 2086 | 1143 } |
| 1144 } | |
| 1145 | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
1146 static int toc_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags flags) |
| 2086 | 1147 { |
| 6061 | 1148 char *buf1, *buf2; |
| 2086 | 1149 |
| 6855 | 1150 #if 1 |
| 1151 /* This is the old, non-i18n way */ | |
| 6061 | 1152 buf1 = escape_text(message); |
| 1153 if (strlen(buf1) + 52 > MSG_LEN) { | |
| 1154 g_free(buf1); | |
|
2123
56c4382f2909
[gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
1155 return -E2BIG; |
|
2136
73253b36c3cb
[gaim-migrate @ 2146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2130
diff
changeset
|
1156 } |
| 7261 | 1157 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
|
1158 ((flags & GAIM_CONV_IM_AUTO_RESP) ? " auto" : "")); |
| 6061 | 1159 g_free(buf1); |
| 6855 | 1160 #else |
| 1161 /* This doesn't work yet. See the comments below for details */ | |
| 1162 buf1 = gaim_strreplace(message, "\"", "\\\""); | |
| 1163 | |
| 1164 /* | |
| 1165 * We still need to determine what encoding should be used and send the | |
| 1166 * message in that encoding. This should be done the same as in | |
| 1167 * oscar_encoding_check() in oscar.c. There is no encoding flag sent | |
| 1168 * along with the message--the TOC to OSCAR proxy server must just | |
| 1169 * use a lil' algorithm to determine what the actual encoding is. | |
| 1170 * | |
| 1171 * After that, you need to convert buf1 to that encoding, and keep track | |
| 1172 * of the length of the resulting string. Then you need to make sure | |
| 1173 * that length is passed to sflap_send(). | |
| 1174 */ | |
| 1175 | |
| 6982 | 1176 if (strlen(buf1) + 52 > MSG_LEN) { |
| 6855 | 1177 g_free(buf1); |
| 1178 return -E2BIG; | |
| 1179 } | |
| 1180 | |
| 7261 | 1181 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
|
1182 ((flags & GAIM_CONV_IM_AUTO_RESP) ? "auto" : "")); |
| 6855 | 1183 g_free(buf1); |
| 1184 #endif | |
| 1185 | |
| 6061 | 1186 sflap_send(gc, buf2, -1, TYPE_DATA); |
| 1187 g_free(buf2); | |
| 1188 | |
|
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2281
diff
changeset
|
1189 return 1; |
| 2086 | 1190 } |
| 1191 | |
| 5605 | 1192 static void toc_set_config(GaimConnection *gc) |
| 2086 | 1193 { |
|
2281
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1194 char *buf = g_malloc(MSG_LEN), snd[BUF_LEN * 2]; |
| 4491 | 1195 toc_build_config(gc->account, buf, MSG_LEN - strlen("toc_set_config \\{\\}"), FALSE); |
| 2086 | 1196 g_snprintf(snd, MSG_LEN, "toc_set_config {%s}", buf); |
| 1197 sflap_send(gc, snd, -1, TYPE_DATA); | |
|
2281
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1198 g_free(buf); |
| 2086 | 1199 } |
| 1200 | |
| 7261 | 1201 static void toc_get_info(GaimConnection *gc, const char *name) |
| 2086 | 1202 { |
| 1203 char buf[BUF_LEN * 2]; | |
| 7261 | 1204 g_snprintf(buf, MSG_LEN, "toc_get_info %s", gaim_normalize(gc->account, name)); |
| 1205 sflap_send(gc, buf, -1, TYPE_DATA); | |
| 2086 | 1206 } |
| 1207 | |
| 8950 | 1208 /* Should be implemented as an Account Action? */ |
| 9030 | 1209 static void toc_get_dir(GaimBlistNode *node, gpointer data) |
| 2086 | 1210 { |
| 9030 | 1211 GaimBuddy *buddy; |
| 1212 GaimConnection *gc; | |
| 2086 | 1213 char buf[BUF_LEN * 2]; |
| 9030 | 1214 |
| 1215 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
| 1216 | |
| 1217 buddy = (GaimBuddy *) node; | |
| 9058 | 1218 gc = gaim_account_get_connection(buddy->account); |
| 9030 | 1219 |
| 1220 g_snprintf(buf, MSG_LEN, "toc_get_dir %s", | |
| 1221 gaim_normalize(buddy->account, buddy->name)); | |
| 7261 | 1222 sflap_send(gc, buf, -1, TYPE_DATA); |
| 2086 | 1223 } |
| 1224 | |
| 8950 | 1225 #if 0 |
| 1226 /* Should be implemented as an Account Action */ | |
| 5605 | 1227 static void toc_set_dir(GaimConnection *g, const char *first, const char *middle, const char *last, |
| 3466 | 1228 const char *maiden, const char *city, const char *state, const char *country, int web) |
| 2086 | 1229 { |
| 6059 | 1230 char *buf3, buf2[BUF_LEN * 4], buf[BUF_LEN]; |
| 2086 | 1231 g_snprintf(buf2, sizeof(buf2), "%s:%s:%s:%s:%s:%s:%s:%s", first, |
| 1232 middle, last, maiden, city, state, country, (web == 1) ? "Y" : ""); | |
| 6059 | 1233 buf3 = escape_text(buf2); |
| 1234 g_snprintf(buf, sizeof(buf), "toc_set_dir %s", buf3); | |
| 1235 g_free(buf3); | |
| 2086 | 1236 sflap_send(g, buf, -1, TYPE_DATA); |
| 1237 } | |
| 8950 | 1238 #endif |
| 2086 | 1239 |
| 8950 | 1240 #if 0 |
| 1241 /* Should be implemented as an Account Action */ | |
| 5605 | 1242 static void toc_dir_search(GaimConnection *g, const char *first, const char *middle, const char *last, |
| 3466 | 1243 const char *maiden, const char *city, const char *state, const char *country, const char *email) |
| 2086 | 1244 { |
| 1245 char buf[BUF_LONG]; | |
| 1246 g_snprintf(buf, sizeof(buf) / 2, "toc_dir_search %s:%s:%s:%s:%s:%s:%s:%s", first, middle, | |
| 1247 last, maiden, city, state, country, email); | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1248 gaim_debug(GAIM_DEBUG_INFO, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1249 "Searching for: %s,%s,%s,%s,%s,%s,%s\n", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1250 first, middle, last, maiden, |
| 2086 | 1251 city, state, country); |
| 1252 sflap_send(g, buf, -1, TYPE_DATA); | |
| 1253 } | |
| 8950 | 1254 #endif |
| 2086 | 1255 |
| 10401 | 1256 static void toc_set_status(GaimAccount *account, GaimStatus *status) |
| 2086 | 1257 { |
| 10401 | 1258 #if 0 /* do we care about TOC any more? */ |
| 2086 | 1259 char buf[BUF_LEN * 2]; |
| 10011 | 1260 if (gc->away) { |
| 1261 g_free(gc->away); | |
| 1262 gc->away = NULL; | |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
1263 } |
| 2086 | 1264 if (message) { |
| 6059 | 1265 char *tmp; |
| 10011 | 1266 gc->away = g_strdup(message); |
| 6059 | 1267 tmp = escape_text(message); |
| 3188 | 1268 g_snprintf(buf, MSG_LEN, "toc_set_away \"%s\"", tmp); |
| 1269 g_free(tmp); | |
| 2086 | 1270 } else |
| 1271 g_snprintf(buf, MSG_LEN, "toc_set_away \"\""); | |
| 1272 sflap_send(g, buf, -1, TYPE_DATA); | |
| 10401 | 1273 #endif |
| 2086 | 1274 } |
| 1275 | |
| 5954 | 1276 static void toc_set_info(GaimConnection *g, const char *info) |
| 2086 | 1277 { |
| 6059 | 1278 char buf[BUF_LEN * 2], *buf2; |
| 1279 buf2 = escape_text(info); | |
| 2086 | 1280 g_snprintf(buf, sizeof(buf), "toc_set_info \"%s\n\"", buf2); |
| 6059 | 1281 g_free(buf2); |
| 2086 | 1282 sflap_send(g, buf, -1, TYPE_DATA); |
| 1283 } | |
| 1284 | |
| 5605 | 1285 static void toc_change_passwd(GaimConnection *g, const char *orig, const char *new) |
| 2086 | 1286 { |
| 1287 char buf[BUF_LEN * 2]; | |
| 1288 g_snprintf(buf, BUF_LONG, "toc_change_passwd %s %s", orig, new); | |
| 6306 | 1289 sflap_send(g, buf, -1, TYPE_DATA); |
| 2086 | 1290 } |
| 1291 | |
| 7261 | 1292 static void |
| 9285 | 1293 toc_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) |
| 2086 | 1294 { |
| 1295 char buf[BUF_LEN * 2]; | |
| 9285 | 1296 g_snprintf(buf, sizeof(buf), "toc_add_buddy %s", gaim_normalize(gc->account, buddy->name)); |
| 7261 | 1297 sflap_send(gc, buf, -1, TYPE_DATA); |
| 1298 toc_set_config(gc); | |
| 2086 | 1299 } |
| 1300 | |
| 9285 | 1301 static void toc_add_buddies(GaimConnection *gc, GList *buddies, GList *groups) |
| 2086 | 1302 { |
| 1303 char buf[BUF_LEN * 2]; | |
| 1304 int n; | |
| 9285 | 1305 GList *cur; |
| 2086 | 1306 |
| 1307 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); | |
| 9285 | 1308 for (cur = buddies; cur != NULL; cur = cur->next) { |
| 1309 GaimBuddy *buddy = cur->data; | |
| 1310 | |
| 1311 if (strlen(gaim_normalize(gc->account, buddy->name)) + n + 32 > MSG_LEN) { | |
| 7261 | 1312 sflap_send(gc, buf, -1, TYPE_DATA); |
| 2086 | 1313 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); |
| 1314 } | |
| 9285 | 1315 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", gaim_normalize(gc->account, buddy->name)); |
| 2086 | 1316 } |
| 7261 | 1317 sflap_send(gc, buf, -1, TYPE_DATA); |
| 2086 | 1318 } |
| 1319 | |
| 9285 | 1320 static void toc_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) |
| 2086 | 1321 { |
| 1322 char buf[BUF_LEN * 2]; | |
| 9285 | 1323 g_snprintf(buf, sizeof(buf), "toc_remove_buddy %s", gaim_normalize(gc->account, buddy->name)); |
| 7261 | 1324 sflap_send(gc, buf, -1, TYPE_DATA); |
| 1325 toc_set_config(gc); | |
| 2086 | 1326 } |
| 1327 | |
| 9285 | 1328 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
|
1329 { |
|
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1330 char buf[BUF_LEN * 2]; |
|
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1331 int n; |
| 9285 | 1332 GList *cur; |
|
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1333 |
|
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1334 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); |
| 9285 | 1335 for (cur = buddies; cur != NULL; cur = cur->next) { |
| 1336 GaimBuddy *buddy = cur->data; | |
| 1337 | |
| 1338 if (strlen(gaim_normalize(gc->account, buddy->name)) + n + 32 > MSG_LEN) { | |
| 7261 | 1339 sflap_send(gc, buf, -1, TYPE_DATA); |
|
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1340 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); |
|
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1341 } |
| 9285 | 1342 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
|
1343 } |
| 7261 | 1344 sflap_send(gc, buf, -1, TYPE_DATA); |
| 1345 toc_set_config(gc); | |
|
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1346 } |
|
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1347 |
| 5605 | 1348 static void toc_set_idle(GaimConnection *g, int time) |
| 2086 | 1349 { |
| 1350 char buf[BUF_LEN * 2]; | |
| 1351 g_snprintf(buf, sizeof(buf), "toc_set_idle %d", time); | |
| 1352 sflap_send(g, buf, -1, TYPE_DATA); | |
| 1353 } | |
| 1354 | |
| 6059 | 1355 static void toc_warn(GaimConnection *g, const char *name, int anon) |
| 2086 | 1356 { |
| 1357 char send[BUF_LEN * 2]; | |
| 1358 g_snprintf(send, 255, "toc_evil %s %s", name, ((anon) ? "anon" : "norm")); | |
| 1359 sflap_send(g, send, -1, TYPE_DATA); | |
| 1360 } | |
| 1361 | |
| 5605 | 1362 static GList *toc_chat_info(GaimConnection *gc) |
| 2086 | 1363 { |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1364 GList *m = NULL; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1365 struct proto_chat_entry *pce; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1366 |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1367 pce = g_new0(struct proto_chat_entry, 1); |
| 7841 | 1368 pce->label = _("_Group:"); |
| 5234 | 1369 pce->identifier = "room"; |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1370 m = g_list_append(m, pce); |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1371 |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1372 pce = g_new0(struct proto_chat_entry, 1); |
| 7841 | 1373 pce->label = _("_Exchange:"); |
| 5234 | 1374 pce->identifier = "exchange"; |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1375 pce->is_int = TRUE; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1376 pce->min = 4; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1377 pce->max = 20; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1378 m = g_list_append(m, pce); |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1379 |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1380 return m; |
| 2086 | 1381 } |
| 1382 | |
| 9754 | 1383 GHashTable *toc_chat_info_defaults(GaimConnection *gc, const char *chat_name) |
| 1384 { | |
| 1385 GHashTable *defaults; | |
| 1386 | |
| 1387 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
| 1388 | |
| 1389 if (chat_name != NULL) | |
| 1390 g_hash_table_insert(defaults, "room", g_strdup(chat_name)); | |
| 1391 | |
| 1392 return defaults; | |
| 1393 } | |
| 1394 | |
| 5605 | 1395 static void toc_join_chat(GaimConnection *g, GHashTable *data) |
| 2086 | 1396 { |
| 1397 char buf[BUF_LONG]; | |
| 5234 | 1398 char *name, *exchange; |
| 1399 char *id; | |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1400 |
| 5234 | 1401 name = g_hash_table_lookup(data, "room"); |
| 1402 exchange = g_hash_table_lookup(data, "exchange"); | |
| 1403 id = g_hash_table_lookup(data, "id"); | |
| 1404 | |
| 1405 if (id) { | |
| 1406 g_snprintf(buf, 255, "toc_chat_accept %d", atoi(id)); | |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1407 } else { |
| 5234 | 1408 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
|
1409 } |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1410 |
| 2086 | 1411 sflap_send(g, buf, -1, TYPE_DATA); |
| 1412 } | |
| 1413 | |
| 7261 | 1414 static void toc_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) |
| 2086 | 1415 { |
| 1416 char buf[BUF_LONG]; | |
|
2719
9747583279d1
[gaim-migrate @ 2732]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2706
diff
changeset
|
1417 g_snprintf(buf, sizeof(buf) / 2, "toc_chat_invite %d \"%s\" %s", id, |
| 7261 | 1418 message ? message : "", gaim_normalize(gc->account, name)); |
| 1419 sflap_send(gc, buf, -1, TYPE_DATA); | |
| 2086 | 1420 } |
| 1421 | |
| 5605 | 1422 static void toc_chat_leave(GaimConnection *g, int id) |
| 2086 | 1423 { |
| 1424 GSList *bcs = g->buddy_chats; | |
| 5679 | 1425 GaimConversation *b = NULL; |
| 2086 | 1426 char buf[BUF_LEN * 2]; |
| 1427 | |
| 1428 while (bcs) { | |
| 5679 | 1429 b = (GaimConversation *)bcs->data; |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
1430 if (id == gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))) |
| 2086 | 1431 break; |
| 1432 b = NULL; | |
| 1433 bcs = bcs->next; | |
| 1434 } | |
| 1435 | |
| 1436 if (!b) | |
| 1437 return; /* can this happen? */ | |
| 1438 | |
| 4491 | 1439 if (gaim_conversation_get_account(b) == NULL) { |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1440 /* TOC already kicked us out of this room */ |
| 2086 | 1441 serv_got_chat_left(g, id); |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1442 } |
| 2086 | 1443 else { |
| 1444 g_snprintf(buf, 255, "toc_chat_leave %d", id); | |
| 1445 sflap_send(g, buf, -1, TYPE_DATA); | |
| 1446 } | |
| 1447 } | |
| 1448 | |
| 7261 | 1449 static void toc_chat_whisper(GaimConnection *gc, int id, const char *who, const char *message) |
| 2086 | 1450 { |
| 6059 | 1451 char *buf1, *buf2; |
| 1452 buf1 = escape_text(message); | |
| 7261 | 1453 buf2 = g_strdup_printf("toc_chat_whisper %d %s \"%s\"", id, gaim_normalize(gc->account, who), buf1); |
| 6059 | 1454 g_free(buf1); |
| 7261 | 1455 sflap_send(gc, buf2, -1, TYPE_DATA); |
| 6059 | 1456 g_free(buf2); |
| 2086 | 1457 } |
| 1458 | |
| 6059 | 1459 static int toc_chat_send(GaimConnection *g, int id, const char *message) |
| 2086 | 1460 { |
| 6059 | 1461 char *buf1, *buf2; |
| 1462 buf1 = escape_text(message); | |
| 1463 if (strlen(buf1) > 2000) { | |
| 1464 g_free(buf1); | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1465 return -E2BIG; |
| 6059 | 1466 } |
| 1467 buf2 = g_strdup_printf("toc_chat_send %d \"%s\"", id, buf1); | |
| 1468 g_free(buf1); | |
| 1469 sflap_send(g, buf2, -1, TYPE_DATA); | |
| 1470 g_free(buf2); | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1471 return 0; |
| 2086 | 1472 } |
| 1473 | |
| 5605 | 1474 static void toc_keepalive(GaimConnection *gc) |
| 2086 | 1475 { |
| 1476 sflap_send(gc, "", 0, TYPE_KEEPALIVE); | |
| 1477 } | |
| 1478 | |
| 6695 | 1479 static const char *toc_list_icon(GaimAccount *a, GaimBuddy *b) |
| 2086 | 1480 { |
| 5971 | 1481 if (!b || (b && b->name && b->name[0] == '+')) { |
| 6695 | 1482 if (a != NULL && isdigit(*gaim_account_get_username(a))) |
| 5971 | 1483 return "icq"; |
| 1484 else | |
| 1485 return "aim"; | |
| 1486 } | |
| 1487 | |
| 1488 if (b && b->name && isdigit(b->name[0])) | |
| 1489 return "icq"; | |
| 4687 | 1490 return "aim"; |
| 1491 } | |
| 4916 | 1492 |
| 9972 | 1493 static void toc_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) |
| 4916 | 1494 { |
| 1495 char *emblems[4] = {NULL,NULL,NULL,NULL}; | |
| 1496 int i = 0; | |
| 1497 | |
| 5971 | 1498 if (!GAIM_BUDDY_IS_ONLINE(b)) { |
| 4916 | 1499 *se = "offline"; |
| 1500 return; | |
| 1501 } else { | |
| 1502 if (b->uc & UC_UNAVAILABLE) | |
| 1503 emblems[i++] = "away"; | |
| 1504 if (b->uc & UC_AOL) | |
| 1505 emblems[i++] = "aol"; | |
| 1506 if (b->uc & UC_ADMIN) | |
| 1507 emblems[i++] = "admin"; | |
| 1508 if (b->uc & UC_WIRELESS) | |
| 1509 emblems[i++] = "wireless"; | |
| 1510 } | |
| 1511 *se = emblems[0]; | |
| 1512 *sw = emblems[1]; | |
| 1513 *nw = emblems[2]; | |
| 1514 *ne = emblems[3]; | |
| 1515 } | |
| 2086 | 1516 |
| 9030 | 1517 static GList *toc_blist_node_menu(GaimBlistNode *node) |
| 2086 | 1518 { |
|
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1519 GList *m = NULL; |
| 9030 | 1520 GaimBlistNodeAction *act; |
| 2086 | 1521 |
| 9030 | 1522 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { |
| 1523 act = gaim_blist_node_action_new(_("Get Dir Info"), | |
|
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10589
diff
changeset
|
1524 toc_get_dir, NULL, NULL); |
| 9030 | 1525 m = g_list_append(m, act); |
| 1526 } | |
|
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1527 |
|
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1528 return m; |
| 2086 | 1529 } |
| 1530 | |
| 5605 | 1531 static void toc_add_permit(GaimConnection *gc, const char *who) |
| 2086 | 1532 { |
| 1533 char buf2[BUF_LEN * 2]; | |
| 5605 | 1534 if (gc->account->perm_deny != 3) |
| 2086 | 1535 return; |
| 7261 | 1536 g_snprintf(buf2, sizeof(buf2), "toc_add_permit %s", gaim_normalize(gc->account, who)); |
| 2086 | 1537 sflap_send(gc, buf2, -1, TYPE_DATA); |
| 1538 toc_set_config(gc); | |
| 1539 } | |
| 1540 | |
| 5605 | 1541 static void toc_add_deny(GaimConnection *gc, const char *who) |
| 2086 | 1542 { |
| 1543 char buf2[BUF_LEN * 2]; | |
| 5605 | 1544 if (gc->account->perm_deny != 4) |
| 2086 | 1545 return; |
| 7261 | 1546 g_snprintf(buf2, sizeof(buf2), "toc_add_deny %s", gaim_normalize(gc->account, who)); |
| 2086 | 1547 sflap_send(gc, buf2, -1, TYPE_DATA); |
| 1548 toc_set_config(gc); | |
| 1549 } | |
| 1550 | |
| 5605 | 1551 static void toc_set_permit_deny(GaimConnection *gc) |
| 2086 | 1552 { |
| 1553 char buf2[BUF_LEN * 2]; | |
| 1554 GSList *list; | |
| 1555 int at; | |
| 1556 | |
| 5605 | 1557 switch (gc->account->perm_deny) { |
| 2086 | 1558 case 1: |
| 1559 /* permit all, deny none. to get here reliably we need to have been in permit | |
| 1560 * mode, and send an empty toc_add_deny message, which will switch us to deny none */ | |
| 1561 g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | |
| 1562 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1563 g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | |
| 1564 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1565 break; | |
| 1566 case 2: | |
| 1567 /* deny all, permit none. to get here reliably we need to have been in deny | |
| 1568 * mode, and send an empty toc_add_permit message, which will switch us to permit none */ | |
| 1569 g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | |
| 1570 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1571 g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | |
| 1572 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1573 break; | |
| 1574 case 3: | |
| 1575 /* permit some. we want to switch to deny mode first, then send the toc_add_permit | |
| 1576 * message, which will clear and set our permit list. toc sucks. */ | |
| 1577 g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | |
| 1578 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1579 | |
| 1580 at = g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | |
| 4491 | 1581 list = gc->account->permit; |
| 2086 | 1582 while (list) { |
| 7261 | 1583 at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", gaim_normalize(gc->account, list->data)); |
| 2086 | 1584 if (at > MSG_LEN + 32) { /* from out my ass comes greatness */ |
| 1585 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1586 at = g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | |
| 1587 } | |
| 1588 list = list->next; | |
| 1589 } | |
| 1590 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1591 break; | |
| 1592 case 4: | |
| 1593 /* deny some. we want to switch to permit mode first, then send the toc_add_deny | |
| 1594 * message, which will clear and set our deny list. toc sucks. */ | |
| 1595 g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | |
| 1596 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1597 | |
| 1598 at = g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | |
| 4491 | 1599 list = gc->account->deny; |
| 2086 | 1600 while (list) { |
| 7261 | 1601 at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", gaim_normalize(gc->account, list->data)); |
| 2086 | 1602 if (at > MSG_LEN + 32) { /* from out my ass comes greatness */ |
| 1603 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1604 at = g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | |
| 1605 } | |
| 1606 list = list->next; | |
| 1607 } | |
| 1608 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1609 break; | |
| 1610 default: | |
| 1611 break; | |
| 1612 } | |
| 1613 toc_set_config(gc); | |
| 1614 } | |
| 1615 | |
| 5605 | 1616 static void toc_rem_permit(GaimConnection *gc, const char *who) |
| 2086 | 1617 { |
| 5605 | 1618 if (gc->account->perm_deny != 3) |
| 2086 | 1619 return; |
| 1620 toc_set_permit_deny(gc); | |
| 1621 } | |
| 1622 | |
| 5605 | 1623 static void toc_rem_deny(GaimConnection *gc, const char *who) |
| 2086 | 1624 { |
| 5605 | 1625 if (gc->account->perm_deny != 4) |
| 2086 | 1626 return; |
| 1627 toc_set_permit_deny(gc); | |
| 1628 } | |
| 1629 | |
| 10401 | 1630 static GList *toc_away_states(GaimAccount *account) |
| 2086 | 1631 { |
| 10401 | 1632 #if 0 /* do we care about TOC any more? */ |
| 2086 | 1633 return g_list_append(NULL, GAIM_AWAY_CUSTOM); |
| 10401 | 1634 #else |
| 1635 return NULL; | |
| 1636 #endif | |
| 2086 | 1637 } |
| 1638 | |
|
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7062
diff
changeset
|
1639 static void |
| 9015 | 1640 show_set_info(GaimPluginAction *action) |
|
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1641 { |
| 9015 | 1642 GaimConnection *gc = (GaimConnection *) action->context; |
|
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1643 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
|
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 |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1646 static void |
| 9015 | 1647 change_pass(GaimPluginAction *action) |
|
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7062
diff
changeset
|
1648 { |
| 9015 | 1649 GaimConnection *gc = (GaimConnection *) action->context; |
|
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7062
diff
changeset
|
1650 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7062
diff
changeset
|
1651 } |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7062
diff
changeset
|
1652 |
| 9015 | 1653 static GList *toc_actions(GaimPlugin *plugin, gpointer context) |
| 2086 | 1654 { |
| 1655 GList *m = NULL; | |
| 9015 | 1656 GaimPluginAction *act; |
| 2086 | 1657 |
| 9015 | 1658 act = gaim_plugin_action_new(_("Set User Info"), |
| 1659 show_set_info); | |
| 1660 m = g_list_append(m, act); | |
| 4333 | 1661 |
|
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
1662 #if 0 |
| 9015 | 1663 act = gaim_plugin_action_new(_("Set Dir Info"), |
| 1664 show_set_dir); | |
| 1665 m = g_list_append(m, act); | |
|
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
1666 #endif |
| 4333 | 1667 |
| 9015 | 1668 act = gaim_plugin_action_new(_("Change Password"), |
| 1669 change_pass); | |
| 1670 m = g_list_append(m, act); | |
| 2086 | 1671 |
| 1672 return m; | |
| 1673 } | |
| 1674 | |
| 6867 | 1675 #if 0 |
| 2086 | 1676 /********* |
| 1677 * RVOUS ACTIONS | |
| 1678 ********/ | |
| 1679 | |
| 1680 struct file_header { | |
| 1681 char magic[4]; /* 0 */ | |
| 1682 short hdrlen; /* 4 */ | |
| 1683 short hdrtype; /* 6 */ | |
| 1684 char bcookie[8]; /* 8 */ | |
| 1685 short encrypt; /* 16 */ | |
| 1686 short compress; /* 18 */ | |
| 1687 short totfiles; /* 20 */ | |
| 1688 short filesleft; /* 22 */ | |
| 1689 short totparts; /* 24 */ | |
| 1690 short partsleft; /* 26 */ | |
| 1691 long totsize; /* 28 */ | |
| 1692 long size; /* 32 */ | |
| 1693 long modtime; /* 36 */ | |
| 1694 long checksum; /* 40 */ | |
| 1695 long rfrcsum; /* 44 */ | |
| 1696 long rfsize; /* 48 */ | |
| 1697 long cretime; /* 52 */ | |
| 1698 long rfcsum; /* 56 */ | |
| 1699 long nrecvd; /* 60 */ | |
| 1700 long recvcsum; /* 64 */ | |
| 1701 char idstring[32]; /* 68 */ | |
| 1702 char flags; /* 100 */ | |
| 1703 char lnameoffset; /* 101 */ | |
| 1704 char lsizeoffset; /* 102 */ | |
| 1705 char dummy[69]; /* 103 */ | |
| 1706 char macfileinfo[16]; /* 172 */ | |
| 1707 short nencode; /* 188 */ | |
| 1708 short nlanguage; /* 190 */ | |
| 1709 char name[64]; /* 192 */ | |
| 1710 /* 256 */ | |
| 1711 }; | |
| 1712 | |
| 1713 struct file_transfer { | |
| 1714 struct file_header hdr; | |
| 1715 | |
| 5605 | 1716 GaimConnection *gc; |
| 2086 | 1717 |
| 1718 char *user; | |
| 1719 char *cookie; | |
| 1720 char *ip; | |
| 1721 int port; | |
| 1722 long size; | |
| 1723 struct stat st; | |
| 1724 | |
| 1725 GtkWidget *window; | |
| 1726 int files; | |
| 1727 char *filename; | |
| 1728 FILE *file; | |
| 1729 int recvsize; | |
| 1730 | |
| 1731 gint inpa; | |
| 1732 }; | |
| 1733 | |
| 1734 static void debug_header(struct file_transfer *ft) { | |
| 1735 struct file_header *f = (struct file_header *)ft; | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1736 gaim_debug(GAIM_DEBUG_MISC, "toc", "FT HEADER:\n" |
| 2086 | 1737 "\t%s %d 0x%04x\n" |
| 1738 "\t%s %d %d\n" | |
|
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1739 "\t%d %d %d %d %d %d\n" |
|
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1740 "\t%d %d %d %d %d %d %d %d\n" |
| 2086 | 1741 "\t%s\n" |
| 1742 "\t0x%02x, 0x%02x, 0x%02x\n" | |
| 1743 "\t%s %s\n" | |
| 1744 "\t%d %d\n" | |
| 1745 "\t%s\n", | |
| 1746 f->magic, ntohs(f->hdrlen), f->hdrtype, | |
| 1747 f->bcookie, ntohs(f->encrypt), ntohs(f->compress), | |
| 1748 ntohs(f->totfiles), ntohs(f->filesleft), ntohs(f->totparts), | |
| 1749 ntohs(f->partsleft), ntohl(f->totsize), ntohl(f->size), | |
| 1750 ntohl(f->modtime), ntohl(f->checksum), ntohl(f->rfrcsum), ntohl(f->rfsize), | |
| 1751 ntohl(f->cretime), ntohl(f->rfcsum), ntohl(f->nrecvd), | |
| 1752 ntohl(f->recvcsum), | |
| 1753 f->idstring, | |
| 1754 f->flags, f->lnameoffset, f->lsizeoffset, | |
| 1755 f->dummy, f->macfileinfo, | |
| 1756 ntohs(f->nencode), ntohs(f->nlanguage), | |
| 1757 f->name); | |
| 1758 } | |
| 1759 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1760 static void toc_send_file_callback(gpointer data, gint source, GaimInputCondition cond) |
| 2086 | 1761 { |
| 1762 char buf[BUF_LONG]; | |
| 1763 int rt, i; | |
| 1764 | |
| 1765 struct file_transfer *ft = data; | |
| 1766 | |
| 1767 if (ft->hdr.hdrtype != 0x202) { | |
| 1768 char *buf; | |
| 1769 frombase64(ft->cookie, &buf, NULL); | |
| 1770 | |
| 9134 | 1771 read(source, ft, 8); |
| 1772 read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | |
| 2086 | 1773 debug_header(ft); |
| 1774 | |
| 1775 ft->hdr.hdrtype = 0x202; | |
| 1776 memcpy(ft->hdr.bcookie, buf, 8); | |
| 1777 g_free(buf); | |
| 1778 ft->hdr.encrypt = 0; ft->hdr.compress = 0; | |
| 1779 debug_header(ft); | |
| 9134 | 1780 write(source, ft, 256); |
| 2086 | 1781 |
| 1782 if (ft->files == 1) { | |
|
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10401
diff
changeset
|
1783 ft->file = g_fopen(ft->filename, "w"); |
| 2086 | 1784 if (!ft->file) { |
| 4115 | 1785 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
|
1786 gaim_notify_error(ft->gc, NULL, buf, strerror(errno)); |
| 2086 | 1787 g_free(buf); |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1788 gaim_input_remove(ft->inpa); |
| 9134 | 1789 close(source); |
| 2086 | 1790 g_free(ft->filename); |
| 1791 g_free(ft->user); | |
| 1792 g_free(ft->ip); | |
| 1793 g_free(ft->cookie); | |
| 1794 g_free(ft); | |
| 1795 } | |
| 1796 } else { | |
| 1797 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
|
1798 ft->file = g_fopen(buf, "w"); |
| 2086 | 1799 g_free(buf); |
| 1800 if (!ft->file) { | |
| 1801 buf = g_strdup_printf("Could not open %s/%s for writing!", ft->filename, | |
| 1802 ft->hdr.name); | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1803 gaim_notify_error(ft->gc, NULL, buf, strerror(errno)); |
| 2086 | 1804 g_free(buf); |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1805 gaim_input_remove(ft->inpa); |
| 9134 | 1806 close(source); |
| 2086 | 1807 g_free(ft->filename); |
| 1808 g_free(ft->user); | |
| 1809 g_free(ft->ip); | |
| 1810 g_free(ft->cookie); | |
| 1811 g_free(ft); | |
| 1812 } | |
| 1813 } | |
| 1814 | |
| 1815 return; | |
| 1816 } | |
| 1817 | |
| 9134 | 1818 rt = read(source, buf, MIN(ntohl(ft->hdr.size) - ft->recvsize, 1024)); |
| 2086 | 1819 if (rt < 0) { |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1820 gaim_notify_error(ft->gc, NULL, |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1821 _("File transfer failed; other side probably " |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1822 "canceled."), NULL); |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1823 gaim_input_remove(ft->inpa); |
| 9134 | 1824 close(source); |
| 2086 | 1825 g_free(ft->user); |
| 1826 g_free(ft->ip); | |
| 1827 g_free(ft->cookie); | |
| 1828 if (ft->file) | |
| 1829 fclose(ft->file); | |
| 1830 g_free(ft); | |
| 1831 return; | |
| 1832 } | |
| 1833 ft->recvsize += rt; | |
| 1834 for (i = 0; i < rt; i++) | |
| 1835 fprintf(ft->file, "%c", buf[i]); | |
| 1836 | |
| 1837 if (ft->recvsize == ntohl(ft->hdr.size)) { | |
| 1838 ft->hdr.hdrtype = htons(0x0204); | |
| 1839 ft->hdr.filesleft = htons(ntohs(ft->hdr.filesleft) - 1); | |
| 1840 ft->hdr.partsleft = htons(ntohs(ft->hdr.partsleft) - 1); | |
| 1841 ft->hdr.recvcsum = ft->hdr.checksum; /* uh... */ | |
| 1842 ft->hdr.nrecvd = htons(ntohs(ft->hdr.nrecvd) + 1); | |
| 1843 ft->hdr.flags = 0; | |
| 9134 | 1844 write(source, ft, 256); |
| 2086 | 1845 debug_header(ft); |
| 1846 ft->recvsize = 0; | |
| 1847 fclose(ft->file); | |
| 1848 if (ft->hdr.filesleft == 0) { | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1849 gaim_input_remove(ft->inpa); |
| 9134 | 1850 close(source); |
| 2086 | 1851 g_free(ft->filename); |
| 1852 g_free(ft->user); | |
| 1853 g_free(ft->ip); | |
| 1854 g_free(ft->cookie); | |
| 1855 g_free(ft); | |
| 1856 } | |
| 1857 } | |
| 1858 } | |
| 1859 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1860 static void toc_send_file_connect(gpointer data, gint src, GaimInputCondition cond) |
| 2086 | 1861 { |
| 1862 struct file_transfer *ft = data; | |
| 1863 | |
| 1864 if (src == -1) { | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1865 gaim_notify_error(ft->gc, NULL, |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1866 _("Could not connect for transfer."), NULL); |
| 2086 | 1867 g_free(ft->filename); |
| 1868 g_free(ft->cookie); | |
| 1869 g_free(ft->user); | |
| 1870 g_free(ft->ip); | |
| 1871 g_free(ft); | |
| 1872 return; | |
| 1873 } | |
| 1874 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1875 ft->inpa = gaim_input_add(src, GAIM_INPUT_READ, toc_send_file_callback, ft); |
| 2086 | 1876 } |
| 1877 | |
| 1878 static void toc_send_file(gpointer a, struct file_transfer *old_ft) | |
| 1879 { | |
| 1880 struct file_transfer *ft; | |
| 1881 const char *dirname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(old_ft->window)); | |
| 5605 | 1882 GaimAccount *account; |
| 2086 | 1883 char buf[BUF_LEN * 2]; |
| 1884 | |
| 5966 | 1885 if (gaim_gtk_check_if_dir(dirname, GTK_FILE_SELECTION(old_ft->window))) |
| 2086 | 1886 return; |
| 1887 ft = g_new0(struct file_transfer, 1); | |
| 1888 if (old_ft->files == 1) | |
| 1889 ft->filename = g_strdup(dirname); | |
| 1890 else | |
| 4793 | 1891 ft->filename = g_path_get_dirname(dirname); |
| 2086 | 1892 ft->cookie = g_strdup(old_ft->cookie); |
| 1893 ft->user = g_strdup(old_ft->user); | |
| 1894 ft->ip = g_strdup(old_ft->ip); | |
| 1895 ft->files = old_ft->files; | |
| 1896 ft->port = old_ft->port; | |
| 1897 ft->gc = old_ft->gc; | |
| 4491 | 1898 account = ft->gc->account; |
| 2086 | 1899 gtk_widget_destroy(old_ft->window); |
| 1900 | |
| 1901 g_snprintf(buf, sizeof(buf), "toc_rvous_accept %s %s %s", ft->user, ft->cookie, FILE_SEND_UID); | |
| 1902 sflap_send(ft->gc, buf, -1, TYPE_DATA); | |
| 1903 | |
|
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1904 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
|
1905 gaim_notify_error(ft->gc, NULL, |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1906 _("Could not connect for transfer."), NULL); |
| 2086 | 1907 g_free(ft->filename); |
| 1908 g_free(ft->cookie); | |
| 1909 g_free(ft->user); | |
| 1910 g_free(ft->ip); | |
| 1911 g_free(ft); | |
| 1912 return; | |
| 1913 } | |
| 1914 } | |
| 1915 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1916 static void toc_get_file_callback(gpointer data, gint source, GaimInputCondition cond) |
| 2086 | 1917 { |
| 1918 char buf[BUF_LONG]; | |
| 1919 | |
| 1920 struct file_transfer *ft = data; | |
| 1921 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1922 if (cond & GAIM_INPUT_WRITE) { |
| 2086 | 1923 int remain = MIN(ntohl(ft->hdr.totsize) - ft->recvsize, 1024); |
| 1924 int i; | |
| 1925 for (i = 0; i < remain; i++) | |
| 1926 fscanf(ft->file, "%c", &buf[i]); | |
| 9134 | 1927 write(source, buf, remain); |
| 2086 | 1928 ft->recvsize += remain; |
| 1929 if (ft->recvsize == ntohl(ft->hdr.totsize)) { | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1930 gaim_input_remove(ft->inpa); |
|
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1931 ft->inpa = gaim_input_add(source, GAIM_INPUT_READ, |
| 2086 | 1932 toc_get_file_callback, ft); |
| 1933 } | |
| 1934 return; | |
| 1935 } | |
| 1936 | |
| 1937 if (ft->hdr.hdrtype == htons(0x1108)) { | |
| 1938 struct tm *fortime; | |
| 1939 struct stat st; | |
| 4793 | 1940 char *basename; |
| 2086 | 1941 |
| 9134 | 1942 read(source, ft, 8); |
| 1943 read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | |
| 2086 | 1944 debug_header(ft); |
| 1945 | |
|
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10401
diff
changeset
|
1946 g_stat(ft->filename, &st); |
| 2086 | 1947 fortime = localtime(&st.st_mtime); |
| 4793 | 1948 basename = g_path_get_basename(ft->filename); |
| 2086 | 1949 g_snprintf(buf, sizeof(buf), "%2d/%2d/%4d %2d:%2d %8ld %s\r\n", |
| 1950 fortime->tm_mon + 1, fortime->tm_mday, fortime->tm_year + 1900, | |
| 1951 fortime->tm_hour + 1, fortime->tm_min + 1, (long)st.st_size, | |
| 4793 | 1952 basename); |
| 9134 | 1953 write(source, buf, ntohl(ft->hdr.size)); |
| 4793 | 1954 g_free(basename); |
| 2086 | 1955 return; |
| 1956 } | |
| 1957 | |
| 1958 if (ft->hdr.hdrtype == htons(0x1209)) { | |
| 9134 | 1959 read(source, ft, 8); |
| 1960 read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | |
| 2086 | 1961 debug_header(ft); |
| 1962 return; | |
| 1963 } | |
| 1964 | |
| 1965 if (ft->hdr.hdrtype == htons(0x120b)) { | |
| 9134 | 1966 read(source, ft, 8); |
| 1967 read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | |
| 2086 | 1968 debug_header(ft); |
| 1969 | |
| 1970 if (ft->hdr.hdrtype != htons(0x120c)) { | |
| 1971 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
|
1972 gaim_notify_error(ft->gc, NULL, buf, NULL); |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1973 gaim_input_remove(ft->inpa); |
| 9134 | 1974 close(source); |
| 2086 | 1975 g_free(ft->filename); |
| 1976 g_free(ft->user); | |
| 1977 g_free(ft->ip); | |
| 1978 g_free(ft->cookie); | |
| 1979 if (ft->file) | |
| 1980 fclose(ft->file); | |
| 1981 g_free(ft); | |
| 1982 return; | |
| 1983 } | |
| 1984 | |
| 1985 ft->hdr.hdrtype = 0x0101; | |
| 1986 ft->hdr.totfiles = htons(1); ft->hdr.filesleft = htons(1); | |
| 1987 ft->hdr.flags = 0x20; | |
| 9134 | 1988 write(source, ft, 256); |
| 2086 | 1989 return; |
| 1990 } | |
| 1991 | |
| 1992 if (ft->hdr.hdrtype == 0x0101) { | |
| 9134 | 1993 read(source, ft, 8); |
| 1994 read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | |
| 2086 | 1995 debug_header(ft); |
| 1996 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1997 gaim_input_remove(ft->inpa); |
|
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1998 ft->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, |
| 2086 | 1999 toc_get_file_callback, ft); |
| 2000 return; | |
| 2001 } | |
| 2002 | |
| 2003 if (ft->hdr.hdrtype == 0x0202) { | |
| 9134 | 2004 read(source, ft, 8); |
| 2005 read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | |
| 2086 | 2006 debug_header(ft); |
| 2007 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2008 gaim_input_remove(ft->inpa); |
| 9134 | 2009 close(source); |
| 2086 | 2010 g_free(ft->filename); |
| 2011 g_free(ft->user); | |
| 2012 g_free(ft->ip); | |
| 2013 g_free(ft->cookie); | |
| 2014 if (ft->file) | |
| 2015 fclose(ft->file); | |
| 2016 g_free(ft); | |
| 2017 return; | |
| 2018 } | |
| 2019 } | |
| 2020 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2021 static void toc_get_file_connect(gpointer data, gint src, GaimInputCondition cond) |
| 2086 | 2022 { |
| 2023 struct file_transfer *ft = data; | |
| 2024 struct file_header *hdr; | |
| 2025 char *buf; | |
| 4793 | 2026 char *basename; |
| 2086 | 2027 |
| 2028 if (src == -1) { | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
2029 gaim_notify_error(ft->gc, NULL, |
| 7981 | 2030 _("Could not connect for transfer."), NULL); |
| 2086 | 2031 fclose(ft->file); |
| 2032 g_free(ft->filename); | |
| 2033 g_free(ft->cookie); | |
| 2034 g_free(ft->user); | |
| 2035 g_free(ft->ip); | |
| 2036 g_free(ft); | |
| 2037 return; | |
| 2038 } | |
| 2039 | |
| 2040 hdr = (struct file_header *)ft; | |
| 2041 hdr->magic[0] = 'O'; hdr->magic[1] = 'F'; hdr->magic[2] = 'T'; hdr->magic[3] = '2'; | |
| 2042 hdr->hdrlen = htons(256); | |
| 2043 hdr->hdrtype = htons(0x1108); | |
| 2044 frombase64(ft->cookie, &buf, NULL); | |
| 2045 g_snprintf(hdr->bcookie, 8, "%s", buf); | |
| 2046 g_free(buf); | |
| 2047 hdr->totfiles = htons(1); hdr->filesleft = htons(1); | |
| 2048 hdr->totparts = htons(1); hdr->partsleft = htons(1); | |
| 2049 hdr->totsize = htonl((long)ft->st.st_size); /* combined size of all files */ | |
| 2050 /* size = strlen("mm/dd/yyyy hh:mm sizesize 'name'\r\n") */ | |
| 4793 | 2051 basename = g_path_get_basename(ft->filename); |
| 2052 hdr->size = htonl(28 + strlen(basename)); /* size of listing.txt */ | |
| 2053 g_free(basename); | |
| 2086 | 2054 hdr->modtime = htonl(ft->st.st_mtime); |
| 2055 hdr->checksum = htonl(0x89f70000); /* uh... */ | |
| 2056 g_snprintf(hdr->idstring, 32, "OFT_Windows ICBMFT V1.1 32"); | |
| 2057 hdr->flags = 0x02; | |
| 2058 hdr->lnameoffset = 0x1A; | |
| 2059 hdr->lsizeoffset = 0x10; | |
| 2060 g_snprintf(hdr->name, 64, "listing.txt"); | |
| 9134 | 2061 if (write(src, hdr, 256) < 0) { |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
2062 gaim_notify_error(ft->gc, NULL, |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
2063 _("Could not write file header. The file will " |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
2064 "not be transferred."), NULL); |
| 2086 | 2065 fclose(ft->file); |
| 2066 g_free(ft->filename); | |
| 2067 g_free(ft->cookie); | |
| 2068 g_free(ft->user); | |
| 2069 g_free(ft->ip); | |
| 2070 g_free(ft); | |
| 2071 return; | |
| 2072 } | |
| 2073 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2074 ft->inpa = gaim_input_add(src, GAIM_INPUT_READ, toc_get_file_callback, ft); |
| 2086 | 2075 } |
| 2076 | |
| 2077 static void toc_get_file(gpointer a, struct file_transfer *old_ft) | |
| 2078 { | |
| 2079 struct file_transfer *ft; | |
| 2080 const char *dirname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(old_ft->window)); | |
| 5605 | 2081 GaimAccount *account; |
| 2086 | 2082 char *buf, buf2[BUF_LEN * 2]; |
| 2083 | |
| 5966 | 2084 if (gaim_gtk_check_if_dir(dirname, GTK_FILE_SELECTION(old_ft->window))) |
| 2086 | 2085 return; |
| 2086 ft = g_new0(struct file_transfer, 1); | |
| 2087 ft->filename = g_strdup(dirname); | |
|
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10401
diff
changeset
|
2088 ft->file = g_fopen(ft->filename, "r"); |
| 2086 | 2089 if (!ft->file) { |
| 3427 | 2090 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
|
2091 gaim_notify_error(ft->gc, NULL, buf, NULL); |
| 2086 | 2092 g_free(buf); |
| 2093 g_free(ft->filename); | |
| 2094 g_free(ft); | |
| 2095 return; | |
| 2096 } | |
|
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10401
diff
changeset
|
2097 if (g_stat(dirname, &ft->st)) { |
| 3427 | 2098 buf = g_strdup_printf("Unable to examine %s.", dirname); |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
2099 gaim_notify_error(ft->gc, NULL, buf, NULL); |
| 2086 | 2100 g_free(buf); |
| 2101 g_free(ft->filename); | |
| 2102 g_free(ft); | |
| 2103 return; | |
| 2104 } | |
| 2105 ft->cookie = g_strdup(old_ft->cookie); | |
| 2106 ft->user = g_strdup(old_ft->user); | |
| 2107 ft->ip = g_strdup(old_ft->ip); | |
| 2108 ft->port = old_ft->port; | |
| 2109 ft->gc = old_ft->gc; | |
| 4491 | 2110 account = ft->gc->account; |
| 2086 | 2111 gtk_widget_destroy(old_ft->window); |
| 2112 | |
| 2113 g_snprintf(buf2, sizeof(buf2), "toc_rvous_accept %s %s %s", ft->user, ft->cookie, FILE_GET_UID); | |
| 2114 sflap_send(ft->gc, buf2, -1, TYPE_DATA); | |
| 2115 | |
|
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2116 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
|
2117 gaim_notify_error(ft->gc, NULL, |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
2118 _("Could not connect for transfer."), NULL); |
| 2086 | 2119 fclose(ft->file); |
| 2120 g_free(ft->filename); | |
| 2121 g_free(ft->cookie); | |
| 2122 g_free(ft->user); | |
| 2123 g_free(ft->ip); | |
| 2124 g_free(ft); | |
| 2125 return; | |
| 2126 } | |
| 2127 } | |
| 2128 | |
| 2129 static void cancel_callback(gpointer a, struct file_transfer *ft) { | |
| 2130 gtk_widget_destroy(ft->window); | |
| 2131 if (a == ft->window) { | |
| 2132 g_free(ft->cookie); | |
| 2133 g_free(ft->user); | |
| 2134 g_free(ft->ip); | |
| 2135 g_free(ft); | |
| 2136 } | |
| 2137 } | |
| 2138 | |
| 3867 | 2139 static void toc_reject_ft(struct ft_request *ft) { |
| 2140 g_free(ft->user); | |
| 2141 g_free(ft->filename); | |
| 2142 g_free(ft->ip); | |
| 2143 g_free(ft->cookie); | |
| 2144 if (ft->message) | |
| 2145 g_free(ft->message); | |
| 2146 g_free(ft); | |
| 2147 } | |
| 2148 | |
| 2149 | |
| 3730 | 2150 static void toc_accept_ft(struct ft_request *fr) { |
| 5605 | 2151 if(g_list_find(gaim_connections_get_all(), fr->gc)) { |
| 4249 | 2152 GtkWidget *window; |
| 2153 char buf[BUF_LEN]; | |
| 2086 | 2154 |
| 4249 | 2155 struct file_transfer *ft = g_new0(struct file_transfer, 1); |
| 2156 ft->gc = fr->gc; | |
| 2157 ft->user = g_strdup(fr->user); | |
| 2158 ft->cookie = g_strdup(fr->cookie); | |
| 2159 ft->ip = g_strdup(fr->ip); | |
| 2160 ft->port = fr->port; | |
| 2161 ft->files = fr->files; | |
| 2086 | 2162 |
| 4249 | 2163 ft->window = window = gtk_file_selection_new(_("Gaim - Save As...")); |
| 2164 g_snprintf(buf, sizeof(buf), "%s/%s", gaim_home_dir(), fr->filename ? fr->filename : ""); | |
| 2165 gtk_file_selection_set_filename(GTK_FILE_SELECTION(window), buf); | |
| 4635 | 2166 g_signal_connect(G_OBJECT(window), "destroy", |
| 2167 G_CALLBACK(cancel_callback), ft); | |
| 2168 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(ft->window)->cancel_button), | |
| 2169 "clicked", G_CALLBACK(cancel_callback), ft); | |
| 2086 | 2170 |
| 4249 | 2171 if (!strcmp(fr->UID, FILE_SEND_UID)) |
| 4635 | 2172 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(window)->ok_button), |
| 2173 "clicked", G_CALLBACK(toc_send_file), ft); | |
| 4249 | 2174 else |
| 4635 | 2175 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(window)->ok_button), |
| 2176 "clicked", G_CALLBACK(toc_get_file), ft); | |
| 2086 | 2177 |
| 4249 | 2178 gtk_widget_show(window); |
| 2179 } | |
| 2180 | |
| 3867 | 2181 toc_reject_ft(fr); |
| 2086 | 2182 } |
| 2183 | |
| 2184 static void accept_file_dialog(struct ft_request *ft) { | |
| 2185 char buf[BUF_LONG]; | |
| 2186 if (!strcmp(ft->UID, FILE_SEND_UID)) { | |
| 2187 /* holy crap. who the fuck would transfer gigabytes through AIM?! */ | |
| 2188 static char *sizes[4] = { "bytes", "KB", "MB", "GB" }; | |
| 2189 float size = ft->size; | |
| 2190 int index = 0; | |
| 2191 while ((index < 4) && (size > 1024)) { | |
| 2192 size /= 1024; | |
| 2193 index++; | |
| 2194 } | |
| 6500 | 2195 g_snprintf(buf, sizeof(buf), |
| 4276 | 2196 ngettext( |
| 2197 "%s requests %s to accept %d file: %s (%.2f %s)%s%s", | |
| 2198 "%s requests %s to accept %d files: %s (%.2f %s)%s%s", | |
| 2199 ft->files), | |
| 5605 | 2200 ft->user, gaim_account_get_username(ft->gc->account), ft->files, |
| 2086 | 2201 ft->filename, size, sizes[index], (ft->message) ? "\n" : "", |
| 2202 (ft->message) ? ft->message : ""); | |
| 2203 } else { | |
| 2204 g_snprintf(buf, sizeof(buf), _("%s requests you to send them a file"), ft->user); | |
| 2205 } | |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2206 |
| 9948 | 2207 gaim_request_accept_cancel(ft->gc, NULL, buf, NULL, |
| 9970 | 2208 GAIM_DEFAULT_ACTION_NONE, ft, |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2209 G_CALLBACK(toc_accept_ft), |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2210 G_CALLBACK(toc_reject_ft)); |
| 2086 | 2211 } |
| 6867 | 2212 #endif |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2213 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2214 static GaimPluginProtocolInfo prpl_info = |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2215 { |
| 9058 | 2216 0, |
| 9475 | 2217 NULL, /* user_splits */ |
| 2218 NULL, /* protocol_options */ | |
| 2219 NO_BUDDY_ICONS, /* icon_spec */ | |
| 2220 toc_list_icon, /* list_icon */ | |
| 2221 toc_list_emblems, /* list_emblems */ | |
| 2222 NULL, /* status_text */ | |
| 2223 NULL, /* tooltip_text */ | |
| 2224 toc_away_states, /* away_states */ | |
| 2225 toc_blist_node_menu, /* blist_node_menu */ | |
| 2226 toc_chat_info, /* chat_info */ | |
| 9754 | 2227 toc_chat_info_defaults, /* chat_info_defaults */ |
| 9475 | 2228 toc_login, /* login */ |
| 2229 toc_close, /* close */ | |
| 2230 toc_send_im, /* send_im */ | |
| 2231 toc_set_info, /* set_info */ | |
| 2232 NULL, /* send_typing */ | |
| 2233 toc_get_info, /* get_info */ | |
| 10401 | 2234 toc_set_status, /* set_away */ |
| 9475 | 2235 toc_set_idle, /* set_idle */ |
| 2236 toc_change_passwd, /* change_passwd */ | |
| 2237 toc_add_buddy, /* add_buddy */ | |
| 2238 toc_add_buddies, /* add_buddies */ | |
| 2239 toc_remove_buddy, /* remove_buddy */ | |
| 2240 toc_remove_buddies, /* remove_buddies */ | |
| 2241 toc_add_permit, /* add_permit */ | |
| 2242 toc_add_deny, /* add_deny */ | |
| 2243 toc_rem_permit, /* rem_permit */ | |
| 2244 toc_rem_deny, /* rem_deny */ | |
| 2245 toc_set_permit_deny, /* set_permit_deny */ | |
| 2246 toc_warn, /* warn */ | |
| 2247 toc_join_chat, /* join_chat */ | |
| 2248 NULL, /* reject_chat */ | |
| 9917 | 2249 NULL, /* get_chat_name */ |
| 9475 | 2250 toc_chat_invite, /* chat_invite */ |
| 2251 toc_chat_leave, /* chat_leave */ | |
| 2252 toc_chat_whisper, /* chat_whisper */ | |
| 2253 toc_chat_send, /* chat_send */ | |
| 2254 toc_keepalive, /* keepalive */ | |
| 2255 NULL, /* register_user */ | |
| 2256 NULL, /* get_cb_info */ | |
| 2257 NULL, /* get_cb_away */ | |
| 2258 NULL, /* alias_buddy */ | |
| 2259 NULL, /* group_buddy */ | |
| 2260 NULL, /* rename_group */ | |
| 2261 NULL, /* buddy_free */ | |
| 2262 NULL, /* convo_closed */ | |
| 2263 NULL, /* normalize */ | |
| 2264 NULL, /* set_buddy_icon */ | |
| 2265 NULL, /* remove_group */ | |
| 2266 NULL, /* get_cb_real_name */ | |
| 2267 NULL, /* set_chat_topic */ | |
| 2268 NULL, /* find_blist_chat */ | |
| 2269 NULL, /* roomlist_get_list */ | |
| 2270 NULL, /* roomlist_cancel */ | |
| 2271 NULL, /* roomlist_expand_category */ | |
| 2272 NULL, /* can_receive_file */ | |
| 2273 NULL /* send_file */ | |
|
5205
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 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2276 static GaimPluginInfo info = |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2277 { |
| 9954 | 2278 GAIM_PLUGIN_MAGIC, |
| 2279 GAIM_MAJOR_VERSION, | |
| 2280 GAIM_MINOR_VERSION, | |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2281 GAIM_PLUGIN_PROTOCOL, /**< type */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2282 NULL, /**< ui_requirement */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2283 0, /**< flags */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2284 NULL, /**< dependencies */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2285 GAIM_PRIORITY_DEFAULT, /**< priority */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2286 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2287 "prpl-toc", /**< id */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2288 "TOC", /**< name */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2289 VERSION, /**< version */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2290 /** summary */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2291 N_("TOC Protocol Plugin"), |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2292 /** description */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2293 N_("TOC Protocol Plugin"), |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2294 NULL, /**< author */ |
|
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6321
diff
changeset
|
2295 GAIM_WEBSITE, /**< homepage */ |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2296 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2297 NULL, /**< load */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2298 NULL, /**< unload */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2299 NULL, /**< destroy */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2300 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2301 NULL, /**< ui_info */ |
| 8993 | 2302 &prpl_info, /**< extra_info */ |
| 2303 NULL, | |
| 9015 | 2304 toc_actions |
|
5205
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 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2307 static void |
|
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
2308 init_plugin(GaimPlugin *plugin) |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2309 { |
|
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5605
diff
changeset
|
2310 GaimAccountOption *option; |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2311 |
|
5685
43ea75092684
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
2312 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
|
2313 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
|
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5605
diff
changeset
|
2314 option); |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2315 |
|
5685
43ea75092684
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
2316 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
|
2317 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
|
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5605
diff
changeset
|
2318 option); |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2319 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2320 my_protocol = plugin; |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2321 } |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2322 |
|
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
2323 GAIM_INIT_PLUGIN(toc, init_plugin, info); |
