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