Mercurial > pidgin
comparison src/protocols/toc/toc.c @ 5605:4fa8ca4f4259
[gaim-migrate @ 6009]
i'm a search-and-replace machine!
committer: Tailor Script <tailor@pidgin.im>
| author | Nathan Walp <nwalp@pidgin.im> |
|---|---|
| date | Sat, 31 May 2003 15:40:32 +0000 |
| parents | cce2d7868c78 |
| children | 0bdfa28c678e |
comparison
equal
deleted
inserted
replaced
| 5604:92b2c7f461f9 | 5605:4fa8ca4f4259 |
|---|---|
| 52 #include "win32dep.h" | 52 #include "win32dep.h" |
| 53 #endif | 53 #endif |
| 54 | 54 |
| 55 static GaimPlugin *my_protocol = NULL; | 55 static GaimPlugin *my_protocol = NULL; |
| 56 | 56 |
| 57 /* for win32 compatability */ | |
| 58 G_MODULE_IMPORT GSList *connections; | |
| 59 | |
| 60 #define REVISION "penguin" | 57 #define REVISION "penguin" |
| 61 | 58 |
| 62 #define TYPE_SIGNON 1 | 59 #define TYPE_SIGNON 1 |
| 63 #define TYPE_DATA 2 | 60 #define TYPE_DATA 2 |
| 64 #define TYPE_ERROR 3 | 61 #define TYPE_ERROR 3 |
| 93 #define UC_UNCONFIRMED 0x08 | 90 #define UC_UNCONFIRMED 0x08 |
| 94 #define UC_NORMAL 0x10 | 91 #define UC_NORMAL 0x10 |
| 95 #define UC_WIRELESS 0x20 | 92 #define UC_WIRELESS 0x20 |
| 96 | 93 |
| 97 struct ft_request { | 94 struct ft_request { |
| 98 struct gaim_connection *gc; | 95 GaimConnection *gc; |
| 99 char *user; | 96 char *user; |
| 100 char UID[2048]; | 97 char UID[2048]; |
| 101 char *cookie; | 98 char *cookie; |
| 102 char *ip; | 99 char *ip; |
| 103 int port; | 100 int port; |
| 137 | 134 |
| 138 /* constants to identify proto_opts */ | 135 /* constants to identify proto_opts */ |
| 139 #define USEROPT_AUTH 0 | 136 #define USEROPT_AUTH 0 |
| 140 #define USEROPT_AUTHPORT 1 | 137 #define USEROPT_AUTHPORT 1 |
| 141 | 138 |
| 139 #define TOC_CONNECT_STEPS 3 | |
| 140 | |
| 142 static void toc_login_callback(gpointer, gint, GaimInputCondition); | 141 static void toc_login_callback(gpointer, gint, GaimInputCondition); |
| 143 static void toc_callback(gpointer, gint, GaimInputCondition); | 142 static void toc_callback(gpointer, gint, GaimInputCondition); |
| 144 static void accept_file_dialog(struct ft_request *); | 143 static void accept_file_dialog(struct ft_request *); |
| 145 | 144 |
| 146 /* The following were added for win32 port - Herman */ | 145 /* The following were added for win32 port - Herman */ |
| 174 | 173 |
| 175 | 174 |
| 176 /* ok. this function used to take username/password, and return 0 on success. | 175 /* ok. this function used to take username/password, and return 0 on success. |
| 177 * now, it takes username/password, and returns NULL on error or a new gaim_connection | 176 * now, it takes username/password, and returns NULL on error or a new gaim_connection |
| 178 * on success. */ | 177 * on success. */ |
| 179 static void toc_login(struct gaim_account *account) | 178 static void toc_login(GaimAccount *account) |
| 180 { | 179 { |
| 181 struct gaim_connection *gc; | 180 GaimConnection *gc; |
| 182 struct toc_data *tdt; | 181 struct toc_data *tdt; |
| 183 char buf[80]; | 182 char buf[80]; |
| 184 | 183 |
| 185 gc = new_gaim_conn(account); | 184 gc = gaim_account_get_connection(account); |
| 186 gc->proto_data = tdt = g_new0(struct toc_data, 1); | 185 gc->proto_data = tdt = g_new0(struct toc_data, 1); |
| 187 gc->flags |= OPT_CONN_HTML; | 186 gc->flags |= OPT_CONN_HTML; |
| 188 gc->flags |= OPT_CONN_AUTO_RESP; | 187 gc->flags |= OPT_CONN_AUTO_RESP; |
| 189 | 188 |
| 190 g_snprintf(buf, sizeof buf, _("Looking up %s"), | 189 g_snprintf(buf, sizeof buf, _("Looking up %s"), |
| 191 account->proto_opt[USEROPT_AUTH][0] ? account->proto_opt[USEROPT_AUTH] : TOC_HOST); | 190 gaim_account_get_string(account, "server", TOC_HOST)); |
| 192 set_login_progress(gc, 1, buf); | 191 gaim_connection_update_progress(gc, buf, 1, TOC_CONNECT_STEPS); |
| 193 | 192 |
| 194 debug_printf("* Client connects to TOC\n"); | 193 debug_printf("* Client connects to TOC\n"); |
| 195 if (proxy_connect(account, account->proto_opt[USEROPT_AUTH][0] ? | 194 if (proxy_connect(account, |
| 196 account->proto_opt[USEROPT_AUTH] : TOC_HOST, | 195 gaim_account_get_string(account, "server", TOC_HOST), |
| 197 account->proto_opt[USEROPT_AUTHPORT][0] ? | 196 gaim_account_get_int(account, "port", TOC_PORT), |
| 198 atoi(account->proto_opt[USEROPT_AUTHPORT]) : TOC_PORT, | |
| 199 toc_login_callback, gc) != 0 || !account->gc) { | 197 toc_login_callback, gc) != 0 || !account->gc) { |
| 200 g_snprintf(buf, sizeof(buf), "Connect to %s failed", account->proto_opt[USEROPT_AUTH]); | 198 g_snprintf(buf, sizeof(buf), "Connect to %s failed", |
| 201 hide_login_progress(gc, buf); | 199 gaim_account_get_string(account, "server", TOC_HOST)); |
| 202 signoff(gc); | 200 gaim_connection_error(gc, buf); |
| 203 return; | 201 return; |
| 204 } | 202 } |
| 205 } | 203 } |
| 206 | 204 |
| 207 static void toc_login_callback(gpointer data, gint source, GaimInputCondition cond) | 205 static void toc_login_callback(gpointer data, gint source, GaimInputCondition cond) |
| 208 { | 206 { |
| 209 struct gaim_connection *gc = data; | 207 GaimConnection *gc = data; |
| 210 struct toc_data *tdt; | 208 struct toc_data *tdt; |
| 211 char buf[80]; | 209 char buf[80]; |
| 212 struct sockaddr_in name; | 210 struct sockaddr_in name; |
| 213 socklen_t namelen; | 211 socklen_t namelen; |
| 214 | 212 |
| 215 if (!g_slist_find(connections, data)) { | 213 if (!g_list_find(gaim_connections_get_all(), data)) { |
| 216 toc_soc_close(source); | 214 toc_soc_close(source); |
| 217 return; | 215 return; |
| 218 } | 216 } |
| 219 | 217 |
| 220 tdt = gc->proto_data; | 218 tdt = gc->proto_data; |
| 221 | 219 |
| 222 if (source == -1) { | 220 if (source == -1) { |
| 223 /* we didn't successfully connect. tdt->toc_fd is valid here */ | 221 /* we didn't successfully connect. tdt->toc_fd is valid here */ |
| 224 hide_login_progress(gc, "Unable to connect."); | 222 gaim_connection_error(gc, "Unable to connect."); |
| 225 signoff(gc); | |
| 226 return; | 223 return; |
| 227 } | 224 } |
| 228 tdt->toc_fd = source; | 225 tdt->toc_fd = source; |
| 229 | 226 |
| 230 /* | 227 /* |
| 232 * should open on the exact server we're connected to. toc.oscar.aol.com | 229 * should open on the exact server we're connected to. toc.oscar.aol.com |
| 233 * doesn't work because that hostname resolves to multiple IP addresses. | 230 * doesn't work because that hostname resolves to multiple IP addresses. |
| 234 */ | 231 */ |
| 235 if (getpeername(tdt->toc_fd, (struct sockaddr *)&name, &namelen) == 0) | 232 if (getpeername(tdt->toc_fd, (struct sockaddr *)&name, &namelen) == 0) |
| 236 strncpy(tdt->toc_ip, inet_ntoa(name.sin_addr), sizeof(tdt->toc_ip)); | 233 strncpy(tdt->toc_ip, inet_ntoa(name.sin_addr), sizeof(tdt->toc_ip)); |
| 237 else if (gc->account && gc->account->proto_opt[USEROPT_AUTH][0]) | |
| 238 strncpy(tdt->toc_ip, gc->account->proto_opt[USEROPT_AUTH], sizeof(tdt->toc_ip)); | |
| 239 else | 234 else |
| 240 strncpy(tdt->toc_ip, TOC_HOST, sizeof(tdt->toc_ip)); | 235 strncpy(tdt->toc_ip, gaim_account_get_string(gc->account, "server", TOC_HOST), sizeof(tdt->toc_ip)); |
| 241 | 236 |
| 242 debug_printf("* Client sends \"FLAPON\\r\\n\\r\\n\"\n"); | 237 debug_printf("* Client sends \"FLAPON\\r\\n\\r\\n\"\n"); |
| 243 if (toc_write(tdt->toc_fd, FLAPON, strlen(FLAPON)) < 0) { | 238 if (toc_write(tdt->toc_fd, FLAPON, strlen(FLAPON)) < 0) { |
| 244 hide_login_progress(gc, "Disconnected."); | 239 gaim_connection_error(gc, "Disconnected."); |
| 245 signoff(gc); | |
| 246 return; | 240 return; |
| 247 } | 241 } |
| 248 tdt->state = STATE_FLAPON; | 242 tdt->state = STATE_FLAPON; |
| 249 | 243 |
| 250 /* i know a lot of people like to look at gaim to see how TOC works. so i'll comment | 244 /* i know a lot of people like to look at gaim to see how TOC works. so i'll comment |
| 251 * on what this does. it's really simple. when there's data ready to be read from the | 245 * on what this does. it's really simple. when there's data ready to be read from the |
| 252 * toc_fd file descriptor, toc_callback is called, with gc passed as its data arg. */ | 246 * toc_fd file descriptor, toc_callback is called, with gc passed as its data arg. */ |
| 253 gc->inpa = gaim_input_add(tdt->toc_fd, GAIM_INPUT_READ, toc_callback, gc); | 247 gc->inpa = gaim_input_add(tdt->toc_fd, GAIM_INPUT_READ, toc_callback, gc); |
| 254 | 248 |
| 255 g_snprintf(buf, sizeof(buf), _("Signon: %s"), gc->username); | 249 g_snprintf(buf, sizeof(buf), _("Signon: %s"), gaim_account_get_username(gc->account)); |
| 256 set_login_progress(gc, 2, buf); | 250 gaim_connection_update_progress(gc, buf, 2, TOC_CONNECT_STEPS); |
| 257 } | 251 } |
| 258 | 252 |
| 259 static void toc_close(struct gaim_connection *gc) | 253 static void toc_close(GaimConnection *gc) |
| 260 { | 254 { |
| 261 if (gc->inpa > 0) | 255 if (gc->inpa > 0) |
| 262 gaim_input_remove(gc->inpa); | 256 gaim_input_remove(gc->inpa); |
| 263 gc->inpa = 0; | 257 gc->inpa = 0; |
| 264 toc_soc_close(((struct toc_data *)gc->proto_data)->toc_fd); | 258 toc_soc_close(((struct toc_data *)gc->proto_data)->toc_fd); |
| 265 g_free(gc->proto_data); | 259 g_free(gc->proto_data); |
| 266 } | 260 } |
| 267 | 261 |
| 268 static void toc_build_config(struct gaim_account *account, char *s, int len, gboolean show) | 262 static void toc_build_config(GaimAccount *account, char *s, int len, gboolean show) |
| 269 { | 263 { |
| 270 GaimBlistNode *gnode,*bnode; | 264 GaimBlistNode *gnode,*bnode; |
| 271 struct group *g; | 265 struct group *g; |
| 272 struct buddy *b; | 266 struct buddy *b; |
| 273 GSList *plist = account->permit; | 267 GSList *plist = account->permit; |
| 274 GSList *dlist = account->deny; | 268 GSList *dlist = account->deny; |
| 275 | 269 |
| 276 int pos = 0; | 270 int pos = 0; |
| 277 | 271 |
| 278 if (!account->permdeny) | 272 if (!account->perm_deny) |
| 279 account->permdeny = 1; | 273 account->perm_deny = 1; |
| 280 | 274 |
| 281 pos += g_snprintf(&s[pos], len - pos, "m %d\n", account->permdeny); | 275 pos += g_snprintf(&s[pos], len - pos, "m %d\n", account->perm_deny); |
| 282 for(gnode = gaim_get_blist()->root; gnode && len > pos; gnode = gnode->next) { | 276 for(gnode = gaim_get_blist()->root; gnode && len > pos; gnode = gnode->next) { |
| 283 g = (struct group *)gnode; | 277 g = (struct group *)gnode; |
| 284 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | 278 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
| 285 continue; | 279 continue; |
| 286 if(gaim_group_on_account(g, account)) { | 280 if(gaim_group_on_account(g, account)) { |
| 374 msg[cnt] = '\0'; | 368 msg[cnt] = '\0'; |
| 375 g_free(cpy); | 369 g_free(cpy); |
| 376 return cnt; | 370 return cnt; |
| 377 } | 371 } |
| 378 | 372 |
| 379 static int sflap_send(struct gaim_connection *gc, char *buf, int olen, int type) | 373 static int sflap_send(GaimConnection *gc, char *buf, int olen, int type) |
| 380 { | 374 { |
| 381 int len; | 375 int len; |
| 382 int slen = 0; | 376 int slen = 0; |
| 383 struct sflap_hdr hdr; | 377 struct sflap_hdr hdr; |
| 384 char obuf[MSG_LEN]; | 378 char obuf[MSG_LEN]; |
| 422 } | 416 } |
| 423 | 417 |
| 424 return toc_write(tdt->toc_fd, obuf, slen); | 418 return toc_write(tdt->toc_fd, obuf, slen); |
| 425 } | 419 } |
| 426 | 420 |
| 427 static int wait_reply(struct gaim_connection *gc, char *buffer, size_t buflen) | 421 static int wait_reply(GaimConnection *gc, char *buffer, size_t buflen) |
| 428 { | 422 { |
| 429 struct toc_data *tdt = (struct toc_data *)gc->proto_data; | 423 struct toc_data *tdt = (struct toc_data *)gc->proto_data; |
| 430 struct sflap_hdr *hdr; | 424 struct sflap_hdr *hdr; |
| 431 int ret; | 425 int ret; |
| 432 | 426 |
| 455 return ret; | 449 return ret; |
| 456 } else | 450 } else |
| 457 return 0; | 451 return 0; |
| 458 } | 452 } |
| 459 | 453 |
| 460 static unsigned char *roast_password(char *pass) | 454 static unsigned char *roast_password(const char *pass) |
| 461 { | 455 { |
| 462 /* Trivial "encryption" */ | 456 /* Trivial "encryption" */ |
| 463 static unsigned char rp[256]; | 457 static unsigned char rp[256]; |
| 464 static char *roast = ROAST; | 458 static char *roast = ROAST; |
| 465 int pos = 2; | 459 int pos = 2; |
| 568 return buf; | 562 return buf; |
| 569 } | 563 } |
| 570 | 564 |
| 571 static void toc_callback(gpointer data, gint source, GaimInputCondition condition) | 565 static void toc_callback(gpointer data, gint source, GaimInputCondition condition) |
| 572 { | 566 { |
| 573 struct gaim_connection *gc = (struct gaim_connection *)data; | 567 GaimConnection *gc = (GaimConnection *)data; |
| 574 struct toc_data *tdt = (struct toc_data *)gc->proto_data; | 568 struct toc_data *tdt = (struct toc_data *)gc->proto_data; |
| 575 struct sflap_hdr *hdr; | 569 struct sflap_hdr *hdr; |
| 576 struct signon so; | 570 struct signon so; |
| 577 char buf[8 * 1024], *c; | 571 char buf[8 * 1024], *c; |
| 578 char snd[BUF_LEN * 2]; | 572 char snd[BUF_LEN * 2]; |
| 579 | 573 |
| 574 const char *username = gaim_account_get_username(gc->account); | |
| 575 char *password; | |
| 576 | |
| 580 /* there's data waiting to be read, so read it. */ | 577 /* there's data waiting to be read, so read it. */ |
| 581 if (wait_reply(gc, buf, 8 * 1024) <= 0) { | 578 if (wait_reply(gc, buf, 8 * 1024) <= 0) { |
| 582 hide_login_progress_error(gc, _("Connection Closed")); | 579 gaim_connection_error(gc, _("Connection Closed")); |
| 583 signoff(gc); | |
| 584 return; | 580 return; |
| 585 } | 581 } |
| 586 | 582 |
| 587 if (tdt->state == STATE_FLAPON) { | 583 if (tdt->state == STATE_FLAPON) { |
| 588 hdr = (struct sflap_hdr *)buf; | 584 hdr = (struct sflap_hdr *)buf; |
| 592 debug_printf("* TOC sends Client FLAP SIGNON\n"); | 588 debug_printf("* TOC sends Client FLAP SIGNON\n"); |
| 593 tdt->seqno = ntohs(hdr->seqno); | 589 tdt->seqno = ntohs(hdr->seqno); |
| 594 tdt->state = STATE_SIGNON_REQUEST; | 590 tdt->state = STATE_SIGNON_REQUEST; |
| 595 | 591 |
| 596 debug_printf("* Client sends TOC FLAP SIGNON\n"); | 592 debug_printf("* Client sends TOC FLAP SIGNON\n"); |
| 597 g_snprintf(so.username, sizeof(so.username), "%s", gc->username); | 593 g_snprintf(so.username, sizeof(so.username), "%s", username); |
| 598 so.ver = htonl(1); | 594 so.ver = htonl(1); |
| 599 so.tag = htons(1); | 595 so.tag = htons(1); |
| 600 so.namelen = htons(strlen(so.username)); | 596 so.namelen = htons(strlen(so.username)); |
| 601 if (sflap_send(gc, (char *)&so, ntohs(so.namelen) + 8, TYPE_SIGNON) < 0) { | 597 if (sflap_send(gc, (char *)&so, ntohs(so.namelen) + 8, TYPE_SIGNON) < 0) { |
| 602 hide_login_progress(gc, _("Disconnected.")); | 598 gaim_connection_error(gc, _("Disconnected.")); |
| 603 signoff(gc); | |
| 604 return; | 599 return; |
| 605 } | 600 } |
| 606 | 601 |
| 607 debug_printf("* Client sends TOC \"toc_signon\" message\n"); | 602 debug_printf("* Client sends TOC \"toc_signon\" message\n"); |
| 608 /* i hate icq. */ | 603 /* i hate icq. */ |
| 609 if (gc->username[0] >= '0' && gc->username[0] <= '9') | 604 if (username[0] >= '0' && username[0] <= '9') |
| 610 gc->password[9] = '\0'; | 605 password = g_strndup(gaim_account_get_password(gc->account), 8); |
| 606 else | |
| 607 password = g_strdup(gaim_account_get_password(gc->account)); | |
| 611 g_snprintf(snd, sizeof snd, "toc_signon %s %d %s %s %s \"%s\"", | 608 g_snprintf(snd, sizeof snd, "toc_signon %s %d %s %s %s \"%s\"", |
| 612 AUTH_HOST, AUTH_PORT, normalize(gc->username), | 609 AUTH_HOST, AUTH_PORT, normalize(username), |
| 613 roast_password(gc->password), LANGUAGE, REVISION); | 610 roast_password(password), LANGUAGE, REVISION); |
| 611 g_free(password); | |
| 614 if (sflap_send(gc, snd, -1, TYPE_DATA) < 0) { | 612 if (sflap_send(gc, snd, -1, TYPE_DATA) < 0) { |
| 615 hide_login_progress(gc, _("Disconnected.")); | 613 gaim_connection_error(gc, _("Disconnected.")); |
| 616 signoff(gc); | |
| 617 return; | 614 return; |
| 618 } | 615 } |
| 619 | 616 |
| 620 set_login_progress(gc, 3, _("Waiting for reply...")); | 617 gaim_connection_update_progress(gc, _("Waiting for reply..."), 3, TOC_CONNECT_STEPS); |
| 621 return; | 618 return; |
| 622 } | 619 } |
| 623 | 620 |
| 624 if (tdt->state == STATE_SIGNON_REQUEST) { | 621 if (tdt->state == STATE_SIGNON_REQUEST) { |
| 625 debug_printf("* TOC sends client SIGN_ON reply\n"); | 622 debug_printf("* TOC sends client SIGN_ON reply\n"); |
| 626 if (g_ascii_strncasecmp(buf + sizeof(struct sflap_hdr), "SIGN_ON", strlen("SIGN_ON"))) { | 623 if (g_ascii_strncasecmp(buf + sizeof(struct sflap_hdr), "SIGN_ON", strlen("SIGN_ON"))) { |
| 627 debug_printf("Didn't get SIGN_ON! buf was: %s\n", | 624 debug_printf("Didn't get SIGN_ON! buf was: %s\n", |
| 628 buf + sizeof(struct sflap_hdr)); | 625 buf + sizeof(struct sflap_hdr)); |
| 629 if (!g_ascii_strncasecmp(buf + sizeof(struct sflap_hdr), "ERROR", 5)) { | 626 if (!g_ascii_strncasecmp(buf + sizeof(struct sflap_hdr), "ERROR", 5)) { |
| 630 strtok(buf + sizeof(struct sflap_hdr), ":"); | 627 strtok(buf + sizeof(struct sflap_hdr), ":"); |
| 631 hide_login_progress(gc, show_error_message()); | 628 gaim_connection_error(gc, show_error_message()); |
| 632 } else | 629 } else |
| 633 hide_login_progress(gc, _("Authentication Failed")); | 630 gaim_connection_error(gc, _("Authentication Failed")); |
| 634 signoff(gc); | |
| 635 return; | 631 return; |
| 636 } | 632 } |
| 637 /* we're supposed to check that it's really TOC v1 here but we know it is ;) */ | 633 /* we're supposed to check that it's really TOC v1 here but we know it is ;) */ |
| 638 debug_printf("TOC version: %s\n", buf + sizeof(struct sflap_hdr) + 8); | 634 debug_printf("TOC version: %s\n", buf + sizeof(struct sflap_hdr) + 8); |
| 639 | 635 |
| 641 * version of the config and then the toc_init_done message. we'll come back to | 637 * version of the config and then the toc_init_done message. we'll come back to |
| 642 * the callback in a better state if we get CONFIG anyway */ | 638 * the callback in a better state if we get CONFIG anyway */ |
| 643 | 639 |
| 644 tdt->state = STATE_ONLINE; | 640 tdt->state = STATE_ONLINE; |
| 645 | 641 |
| 646 account_online(gc); | 642 gaim_connection_set_state(gc, GAIM_CONNECTED); |
| 647 serv_finish_login(gc); | 643 serv_finish_login(gc); |
| 648 | 644 |
| 649 /* Client sends TOC toc_init_done message */ | 645 /* Client sends TOC toc_init_done message */ |
| 650 debug_printf("* Client sends TOC toc_init_done message\n"); | 646 debug_printf("* Client sends TOC toc_init_done message\n"); |
| 651 g_snprintf(snd, sizeof snd, "toc_init_done"); | 647 g_snprintf(snd, sizeof snd, "toc_init_done"); |
| 670 if (tdt->state != STATE_PAUSE) | 666 if (tdt->state != STATE_PAUSE) |
| 671 debug_printf("got SIGN_ON but not PAUSE!\n"); | 667 debug_printf("got SIGN_ON but not PAUSE!\n"); |
| 672 else { | 668 else { |
| 673 tdt->state = STATE_ONLINE; | 669 tdt->state = STATE_ONLINE; |
| 674 g_snprintf(snd, sizeof snd, "toc_signon %s %d %s %s %s \"%s\"", | 670 g_snprintf(snd, sizeof snd, "toc_signon %s %d %s %s %s \"%s\"", |
| 675 AUTH_HOST, AUTH_PORT, normalize(gc->username), | 671 AUTH_HOST, AUTH_PORT, |
| 676 roast_password(gc->password), LANGUAGE, REVISION); | 672 normalize(gaim_account_get_username(gc->account)), |
| 673 roast_password(gaim_account_get_password(gc->account)), | |
| 674 LANGUAGE, REVISION); | |
| 677 if (sflap_send(gc, snd, -1, TYPE_DATA) < 0) { | 675 if (sflap_send(gc, snd, -1, TYPE_DATA) < 0) { |
| 678 hide_login_progress(gc, _("Disconnected.")); | 676 gaim_connection_error(gc, _("Disconnected.")); |
| 679 signoff(gc); | |
| 680 return; | 677 return; |
| 681 } | 678 } |
| 682 g_snprintf(snd, sizeof snd, "toc_init_done"); | 679 g_snprintf(snd, sizeof snd, "toc_init_done"); |
| 683 sflap_send(gc, snd, -1, TYPE_DATA); | 680 sflap_send(gc, snd, -1, TYPE_DATA); |
| 684 gaim_notify_info(gc, NULL, | 681 gaim_notify_info(gc, NULL, |
| 747 time(&time_idle); | 744 time(&time_idle); |
| 748 time_idle -= idle * 60; | 745 time_idle -= idle * 60; |
| 749 } else | 746 } else |
| 750 time_idle = 0; | 747 time_idle = 0; |
| 751 | 748 |
| 752 tmp = g_strdup(normalize(gc->username)); | 749 tmp = g_strdup(normalize(gaim_account_get_username(gc->account))); |
| 753 if (!strcmp(tmp, normalize(c))) | 750 if (!strcmp(tmp, normalize(c))) |
| 754 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", c); | 751 gaim_connection_set_display_name(gc, c); |
| 755 g_free(tmp); | 752 g_free(tmp); |
| 756 | 753 |
| 757 serv_got_update(gc, c, logged, evil, signon, time_idle, type); | 754 serv_got_update(gc, c, logged, evil, signon, time_idle, type); |
| 758 } else if (!g_ascii_strcasecmp(c, "ERROR")) { | 755 } else if (!g_ascii_strcasecmp(c, "ERROR")) { |
| 759 gaim_notify_error(gc, NULL, show_error_message(), NULL); | 756 gaim_notify_error(gc, NULL, show_error_message(), NULL); |
| 862 | 859 |
| 863 name = strtok(NULL, ":"); | 860 name = strtok(NULL, ":"); |
| 864 url = strtok(NULL, ":"); | 861 url = strtok(NULL, ":"); |
| 865 | 862 |
| 866 g_snprintf(tmp, sizeof(tmp), "http://%s:%d/%s", tdt->toc_ip, | 863 g_snprintf(tmp, sizeof(tmp), "http://%s:%d/%s", tdt->toc_ip, |
| 867 gc->account->proto_opt[USEROPT_AUTHPORT][0] ? | 864 gaim_account_get_int(gc->account, "port", TOC_PORT), |
| 868 atoi(gc->account->proto_opt[USEROPT_AUTHPORT]) : TOC_PORT, | |
| 869 url); | 865 url); |
| 870 grab_url(tmp, FALSE, toc_got_info, NULL); | 866 grab_url(tmp, FALSE, toc_got_info, NULL); |
| 871 } else if (!g_ascii_strcasecmp(c, "DIR_STATUS")) { | 867 } else if (!g_ascii_strcasecmp(c, "DIR_STATUS")) { |
| 872 } else if (!g_ascii_strcasecmp(c, "ADMIN_NICK_STATUS")) { | 868 } else if (!g_ascii_strcasecmp(c, "ADMIN_NICK_STATUS")) { |
| 873 } else if (!g_ascii_strcasecmp(c, "ADMIN_PASSWD_STATUS")) { | 869 } else if (!g_ascii_strcasecmp(c, "ADMIN_PASSWD_STATUS")) { |
| 1020 } else { | 1016 } else { |
| 1021 debug_printf("don't know what to do with %s\n", c); | 1017 debug_printf("don't know what to do with %s\n", c); |
| 1022 } | 1018 } |
| 1023 } | 1019 } |
| 1024 | 1020 |
| 1025 static int toc_send_im(struct gaim_connection *gc, const char *name, const char *message, int len, int flags) | 1021 static int toc_send_im(GaimConnection *gc, const char *name, const char *message, int len, int flags) |
| 1026 { | 1022 { |
| 1027 char buf[BUF_LEN * 2]; | 1023 char buf[BUF_LEN * 2]; |
| 1028 char *tmp = g_malloc(strlen(message) * 4 + 1); /* 4 because \n gets replaced with <BR> */ | 1024 char *tmp = g_malloc(strlen(message) * 4 + 1); /* 4 because \n gets replaced with <BR> */ |
| 1029 | 1025 |
| 1030 strcpy(tmp, message); | 1026 strcpy(tmp, message); |
| 1039 | 1035 |
| 1040 g_free(tmp); | 1036 g_free(tmp); |
| 1041 return 1; | 1037 return 1; |
| 1042 } | 1038 } |
| 1043 | 1039 |
| 1044 static void toc_set_config(struct gaim_connection *gc) | 1040 static void toc_set_config(GaimConnection *gc) |
| 1045 { | 1041 { |
| 1046 char *buf = g_malloc(MSG_LEN), snd[BUF_LEN * 2]; | 1042 char *buf = g_malloc(MSG_LEN), snd[BUF_LEN * 2]; |
| 1047 toc_build_config(gc->account, buf, MSG_LEN - strlen("toc_set_config \\{\\}"), FALSE); | 1043 toc_build_config(gc->account, buf, MSG_LEN - strlen("toc_set_config \\{\\}"), FALSE); |
| 1048 g_snprintf(snd, MSG_LEN, "toc_set_config {%s}", buf); | 1044 g_snprintf(snd, MSG_LEN, "toc_set_config {%s}", buf); |
| 1049 sflap_send(gc, snd, -1, TYPE_DATA); | 1045 sflap_send(gc, snd, -1, TYPE_DATA); |
| 1050 g_free(buf); | 1046 g_free(buf); |
| 1051 } | 1047 } |
| 1052 | 1048 |
| 1053 static void toc_get_info(struct gaim_connection *g, const char *name) | 1049 static void toc_get_info(GaimConnection *g, const char *name) |
| 1054 { | 1050 { |
| 1055 char buf[BUF_LEN * 2]; | 1051 char buf[BUF_LEN * 2]; |
| 1056 g_snprintf(buf, MSG_LEN, "toc_get_info %s", normalize(name)); | 1052 g_snprintf(buf, MSG_LEN, "toc_get_info %s", normalize(name)); |
| 1057 sflap_send(g, buf, -1, TYPE_DATA); | 1053 sflap_send(g, buf, -1, TYPE_DATA); |
| 1058 } | 1054 } |
| 1059 | 1055 |
| 1060 static void toc_get_dir(struct gaim_connection *g, const char *name) | 1056 static void toc_get_dir(GaimConnection *g, const char *name) |
| 1061 { | 1057 { |
| 1062 char buf[BUF_LEN * 2]; | 1058 char buf[BUF_LEN * 2]; |
| 1063 g_snprintf(buf, MSG_LEN, "toc_get_dir %s", normalize(name)); | 1059 g_snprintf(buf, MSG_LEN, "toc_get_dir %s", normalize(name)); |
| 1064 sflap_send(g, buf, -1, TYPE_DATA); | 1060 sflap_send(g, buf, -1, TYPE_DATA); |
| 1065 } | 1061 } |
| 1066 | 1062 |
| 1067 static void toc_set_dir(struct gaim_connection *g, const char *first, const char *middle, const char *last, | 1063 static void toc_set_dir(GaimConnection *g, const char *first, const char *middle, const char *last, |
| 1068 const char *maiden, const char *city, const char *state, const char *country, int web) | 1064 const char *maiden, const char *city, const char *state, const char *country, int web) |
| 1069 { | 1065 { |
| 1070 char buf2[BUF_LEN * 4], buf[BUF_LEN]; | 1066 char buf2[BUF_LEN * 4], buf[BUF_LEN]; |
| 1071 g_snprintf(buf2, sizeof(buf2), "%s:%s:%s:%s:%s:%s:%s:%s", first, | 1067 g_snprintf(buf2, sizeof(buf2), "%s:%s:%s:%s:%s:%s:%s:%s", first, |
| 1072 middle, last, maiden, city, state, country, (web == 1) ? "Y" : ""); | 1068 middle, last, maiden, city, state, country, (web == 1) ? "Y" : ""); |
| 1073 escape_text(buf2); | 1069 escape_text(buf2); |
| 1074 g_snprintf(buf, sizeof(buf), "toc_set_dir %s", buf2); | 1070 g_snprintf(buf, sizeof(buf), "toc_set_dir %s", buf2); |
| 1075 sflap_send(g, buf, -1, TYPE_DATA); | 1071 sflap_send(g, buf, -1, TYPE_DATA); |
| 1076 } | 1072 } |
| 1077 | 1073 |
| 1078 static void toc_dir_search(struct gaim_connection *g, const char *first, const char *middle, const char *last, | 1074 static void toc_dir_search(GaimConnection *g, const char *first, const char *middle, const char *last, |
| 1079 const char *maiden, const char *city, const char *state, const char *country, const char *email) | 1075 const char *maiden, const char *city, const char *state, const char *country, const char *email) |
| 1080 { | 1076 { |
| 1081 char buf[BUF_LONG]; | 1077 char buf[BUF_LONG]; |
| 1082 g_snprintf(buf, sizeof(buf) / 2, "toc_dir_search %s:%s:%s:%s:%s:%s:%s:%s", first, middle, | 1078 g_snprintf(buf, sizeof(buf) / 2, "toc_dir_search %s:%s:%s:%s:%s:%s:%s:%s", first, middle, |
| 1083 last, maiden, city, state, country, email); | 1079 last, maiden, city, state, country, email); |
| 1084 debug_printf("Searching for: %s,%s,%s,%s,%s,%s,%s\n", first, middle, last, maiden, | 1080 debug_printf("Searching for: %s,%s,%s,%s,%s,%s,%s\n", first, middle, last, maiden, |
| 1085 city, state, country); | 1081 city, state, country); |
| 1086 sflap_send(g, buf, -1, TYPE_DATA); | 1082 sflap_send(g, buf, -1, TYPE_DATA); |
| 1087 } | 1083 } |
| 1088 | 1084 |
| 1089 static void toc_set_away(struct gaim_connection *g, char *state, char *message) | 1085 static void toc_set_away(GaimConnection *g, char *state, char *message) |
| 1090 { | 1086 { |
| 1091 char buf[BUF_LEN * 2]; | 1087 char buf[BUF_LEN * 2]; |
| 1092 if (g->away) { | 1088 if (g->away) { |
| 1093 g_free (g->away); | 1089 g_free (g->away); |
| 1094 g->away = NULL; | 1090 g->away = NULL; |
| 1103 } else | 1099 } else |
| 1104 g_snprintf(buf, MSG_LEN, "toc_set_away \"\""); | 1100 g_snprintf(buf, MSG_LEN, "toc_set_away \"\""); |
| 1105 sflap_send(g, buf, -1, TYPE_DATA); | 1101 sflap_send(g, buf, -1, TYPE_DATA); |
| 1106 } | 1102 } |
| 1107 | 1103 |
| 1108 static void toc_set_info(struct gaim_connection *g, char *info) | 1104 static void toc_set_info(GaimConnection *g, char *info) |
| 1109 { | 1105 { |
| 1110 char buf[BUF_LEN * 2], buf2[BUF_LEN * 2]; | 1106 char buf[BUF_LEN * 2], buf2[BUF_LEN * 2]; |
| 1111 g_snprintf(buf2, sizeof buf2, "%s", info); | 1107 g_snprintf(buf2, sizeof buf2, "%s", info); |
| 1112 escape_text(buf2); | 1108 escape_text(buf2); |
| 1113 g_snprintf(buf, sizeof(buf), "toc_set_info \"%s\n\"", buf2); | 1109 g_snprintf(buf, sizeof(buf), "toc_set_info \"%s\n\"", buf2); |
| 1114 sflap_send(g, buf, -1, TYPE_DATA); | 1110 sflap_send(g, buf, -1, TYPE_DATA); |
| 1115 } | 1111 } |
| 1116 | 1112 |
| 1117 static void toc_change_passwd(struct gaim_connection *g, const char *orig, const char *new) | 1113 static void toc_change_passwd(GaimConnection *g, const char *orig, const char *new) |
| 1118 { | 1114 { |
| 1119 char buf[BUF_LEN * 2]; | 1115 char buf[BUF_LEN * 2]; |
| 1120 g_snprintf(buf, BUF_LONG, "toc_change_passwd %s %s", orig, new); | 1116 g_snprintf(buf, BUF_LONG, "toc_change_passwd %s %s", orig, new); |
| 1121 sflap_send(g, buf, strlen(buf), TYPE_DATA); | 1117 sflap_send(g, buf, strlen(buf), TYPE_DATA); |
| 1122 } | 1118 } |
| 1123 | 1119 |
| 1124 static void toc_add_buddy(struct gaim_connection *g, const char *name) | 1120 static void toc_add_buddy(GaimConnection *g, const char *name) |
| 1125 { | 1121 { |
| 1126 char buf[BUF_LEN * 2]; | 1122 char buf[BUF_LEN * 2]; |
| 1127 g_snprintf(buf, sizeof(buf), "toc_add_buddy %s", normalize(name)); | 1123 g_snprintf(buf, sizeof(buf), "toc_add_buddy %s", normalize(name)); |
| 1128 sflap_send(g, buf, -1, TYPE_DATA); | 1124 sflap_send(g, buf, -1, TYPE_DATA); |
| 1129 toc_set_config(g); | 1125 toc_set_config(g); |
| 1130 } | 1126 } |
| 1131 | 1127 |
| 1132 static void toc_add_buddies(struct gaim_connection *g, GList *buddies) | 1128 static void toc_add_buddies(GaimConnection *g, GList *buddies) |
| 1133 { | 1129 { |
| 1134 char buf[BUF_LEN * 2]; | 1130 char buf[BUF_LEN * 2]; |
| 1135 int n; | 1131 int n; |
| 1136 | 1132 |
| 1137 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); | 1133 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); |
| 1144 buddies = buddies->next; | 1140 buddies = buddies->next; |
| 1145 } | 1141 } |
| 1146 sflap_send(g, buf, -1, TYPE_DATA); | 1142 sflap_send(g, buf, -1, TYPE_DATA); |
| 1147 } | 1143 } |
| 1148 | 1144 |
| 1149 static void toc_remove_buddy(struct gaim_connection *g, char *name, char *group) | 1145 static void toc_remove_buddy(GaimConnection *g, char *name, char *group) |
| 1150 { | 1146 { |
| 1151 char buf[BUF_LEN * 2]; | 1147 char buf[BUF_LEN * 2]; |
| 1152 g_snprintf(buf, sizeof(buf), "toc_remove_buddy %s", normalize(name)); | 1148 g_snprintf(buf, sizeof(buf), "toc_remove_buddy %s", normalize(name)); |
| 1153 sflap_send(g, buf, -1, TYPE_DATA); | 1149 sflap_send(g, buf, -1, TYPE_DATA); |
| 1154 toc_set_config(g); | 1150 toc_set_config(g); |
| 1155 } | 1151 } |
| 1156 | 1152 |
| 1157 static void toc_remove_buddies(struct gaim_connection *g, GList *buddies, const char *group) | 1153 static void toc_remove_buddies(GaimConnection *g, GList *buddies, const char *group) |
| 1158 { | 1154 { |
| 1159 char buf[BUF_LEN * 2]; | 1155 char buf[BUF_LEN * 2]; |
| 1160 int n; | 1156 int n; |
| 1161 | 1157 |
| 1162 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); | 1158 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); |
| 1170 } | 1166 } |
| 1171 sflap_send(g, buf, -1, TYPE_DATA); | 1167 sflap_send(g, buf, -1, TYPE_DATA); |
| 1172 toc_set_config(g); | 1168 toc_set_config(g); |
| 1173 } | 1169 } |
| 1174 | 1170 |
| 1175 static void toc_set_idle(struct gaim_connection *g, int time) | 1171 static void toc_set_idle(GaimConnection *g, int time) |
| 1176 { | 1172 { |
| 1177 char buf[BUF_LEN * 2]; | 1173 char buf[BUF_LEN * 2]; |
| 1178 g_snprintf(buf, sizeof(buf), "toc_set_idle %d", time); | 1174 g_snprintf(buf, sizeof(buf), "toc_set_idle %d", time); |
| 1179 sflap_send(g, buf, -1, TYPE_DATA); | 1175 sflap_send(g, buf, -1, TYPE_DATA); |
| 1180 } | 1176 } |
| 1181 | 1177 |
| 1182 static void toc_warn(struct gaim_connection *g, char *name, int anon) | 1178 static void toc_warn(GaimConnection *g, char *name, int anon) |
| 1183 { | 1179 { |
| 1184 char send[BUF_LEN * 2]; | 1180 char send[BUF_LEN * 2]; |
| 1185 g_snprintf(send, 255, "toc_evil %s %s", name, ((anon) ? "anon" : "norm")); | 1181 g_snprintf(send, 255, "toc_evil %s %s", name, ((anon) ? "anon" : "norm")); |
| 1186 sflap_send(g, send, -1, TYPE_DATA); | 1182 sflap_send(g, send, -1, TYPE_DATA); |
| 1187 } | 1183 } |
| 1188 | 1184 |
| 1189 static GList *toc_chat_info(struct gaim_connection *gc) | 1185 static GList *toc_chat_info(GaimConnection *gc) |
| 1190 { | 1186 { |
| 1191 GList *m = NULL; | 1187 GList *m = NULL; |
| 1192 struct proto_chat_entry *pce; | 1188 struct proto_chat_entry *pce; |
| 1193 | 1189 |
| 1194 pce = g_new0(struct proto_chat_entry, 1); | 1190 pce = g_new0(struct proto_chat_entry, 1); |
| 1205 m = g_list_append(m, pce); | 1201 m = g_list_append(m, pce); |
| 1206 | 1202 |
| 1207 return m; | 1203 return m; |
| 1208 } | 1204 } |
| 1209 | 1205 |
| 1210 static void toc_join_chat(struct gaim_connection *g, GHashTable *data) | 1206 static void toc_join_chat(GaimConnection *g, GHashTable *data) |
| 1211 { | 1207 { |
| 1212 char buf[BUF_LONG]; | 1208 char buf[BUF_LONG]; |
| 1213 char *name, *exchange; | 1209 char *name, *exchange; |
| 1214 char *id; | 1210 char *id; |
| 1215 | 1211 |
| 1224 } | 1220 } |
| 1225 | 1221 |
| 1226 sflap_send(g, buf, -1, TYPE_DATA); | 1222 sflap_send(g, buf, -1, TYPE_DATA); |
| 1227 } | 1223 } |
| 1228 | 1224 |
| 1229 static void toc_chat_invite(struct gaim_connection *g, int id, const char *message, const char *name) | 1225 static void toc_chat_invite(GaimConnection *g, int id, const char *message, const char *name) |
| 1230 { | 1226 { |
| 1231 char buf[BUF_LONG]; | 1227 char buf[BUF_LONG]; |
| 1232 g_snprintf(buf, sizeof(buf) / 2, "toc_chat_invite %d \"%s\" %s", id, | 1228 g_snprintf(buf, sizeof(buf) / 2, "toc_chat_invite %d \"%s\" %s", id, |
| 1233 message ? message : "", normalize(name)); | 1229 message ? message : "", normalize(name)); |
| 1234 sflap_send(g, buf, -1, TYPE_DATA); | 1230 sflap_send(g, buf, -1, TYPE_DATA); |
| 1235 } | 1231 } |
| 1236 | 1232 |
| 1237 static void toc_chat_leave(struct gaim_connection *g, int id) | 1233 static void toc_chat_leave(GaimConnection *g, int id) |
| 1238 { | 1234 { |
| 1239 GSList *bcs = g->buddy_chats; | 1235 GSList *bcs = g->buddy_chats; |
| 1240 struct gaim_conversation *b = NULL; | 1236 struct gaim_conversation *b = NULL; |
| 1241 char buf[BUF_LEN * 2]; | 1237 char buf[BUF_LEN * 2]; |
| 1242 | 1238 |
| 1259 g_snprintf(buf, 255, "toc_chat_leave %d", id); | 1255 g_snprintf(buf, 255, "toc_chat_leave %d", id); |
| 1260 sflap_send(g, buf, -1, TYPE_DATA); | 1256 sflap_send(g, buf, -1, TYPE_DATA); |
| 1261 } | 1257 } |
| 1262 } | 1258 } |
| 1263 | 1259 |
| 1264 static void toc_chat_whisper(struct gaim_connection *g, int id, char *who, char *message) | 1260 static void toc_chat_whisper(GaimConnection *g, int id, char *who, char *message) |
| 1265 { | 1261 { |
| 1266 char buf2[BUF_LEN * 2]; | 1262 char buf2[BUF_LEN * 2]; |
| 1267 escape_text(message); | 1263 escape_text(message); |
| 1268 g_snprintf(buf2, sizeof(buf2), "toc_chat_whisper %d %s \"%s\"", id, normalize(who), message); | 1264 g_snprintf(buf2, sizeof(buf2), "toc_chat_whisper %d %s \"%s\"", id, normalize(who), message); |
| 1269 sflap_send(g, buf2, -1, TYPE_DATA); | 1265 sflap_send(g, buf2, -1, TYPE_DATA); |
| 1270 } | 1266 } |
| 1271 | 1267 |
| 1272 static int toc_chat_send(struct gaim_connection *g, int id, char *message) | 1268 static int toc_chat_send(GaimConnection *g, int id, char *message) |
| 1273 { | 1269 { |
| 1274 char buf[BUF_LEN * 2]; | 1270 char buf[BUF_LEN * 2]; |
| 1275 escape_text(message); | 1271 escape_text(message); |
| 1276 if (strlen(message) > 2000) | 1272 if (strlen(message) > 2000) |
| 1277 return -E2BIG; | 1273 return -E2BIG; |
| 1278 g_snprintf(buf, sizeof(buf), "toc_chat_send %d \"%s\"", id, message); | 1274 g_snprintf(buf, sizeof(buf), "toc_chat_send %d \"%s\"", id, message); |
| 1279 sflap_send(g, buf, -1, TYPE_DATA); | 1275 sflap_send(g, buf, -1, TYPE_DATA); |
| 1280 return 0; | 1276 return 0; |
| 1281 } | 1277 } |
| 1282 | 1278 |
| 1283 static void toc_keepalive(struct gaim_connection *gc) | 1279 static void toc_keepalive(GaimConnection *gc) |
| 1284 { | 1280 { |
| 1285 sflap_send(gc, "", 0, TYPE_KEEPALIVE); | 1281 sflap_send(gc, "", 0, TYPE_KEEPALIVE); |
| 1286 } | 1282 } |
| 1287 | 1283 |
| 1288 static const char *toc_list_icon(struct gaim_account *a, struct buddy *b) | 1284 static const char *toc_list_icon(GaimAccount *a, struct buddy *b) |
| 1289 { | 1285 { |
| 1290 return "aim"; | 1286 return "aim"; |
| 1291 } | 1287 } |
| 1292 | 1288 |
| 1293 static void toc_list_emblems(struct buddy *b, char **se, char **sw, char **nw, char **ne) | 1289 static void toc_list_emblems(struct buddy *b, char **se, char **sw, char **nw, char **ne) |
| 1312 *sw = emblems[1]; | 1308 *sw = emblems[1]; |
| 1313 *nw = emblems[2]; | 1309 *nw = emblems[2]; |
| 1314 *ne = emblems[3]; | 1310 *ne = emblems[3]; |
| 1315 } | 1311 } |
| 1316 | 1312 |
| 1317 static GList *toc_buddy_menu(struct gaim_connection *gc, const char *who) | 1313 static GList *toc_buddy_menu(GaimConnection *gc, const char *who) |
| 1318 { | 1314 { |
| 1319 GList *m = NULL; | 1315 GList *m = NULL; |
| 1320 struct proto_buddy_menu *pbm; | 1316 struct proto_buddy_menu *pbm; |
| 1321 | 1317 |
| 1322 pbm = g_new0(struct proto_buddy_menu, 1); | 1318 pbm = g_new0(struct proto_buddy_menu, 1); |
| 1326 m = g_list_append(m, pbm); | 1322 m = g_list_append(m, pbm); |
| 1327 | 1323 |
| 1328 return m; | 1324 return m; |
| 1329 } | 1325 } |
| 1330 | 1326 |
| 1331 static void toc_add_permit(struct gaim_connection *gc, const char *who) | 1327 static void toc_add_permit(GaimConnection *gc, const char *who) |
| 1332 { | 1328 { |
| 1333 char buf2[BUF_LEN * 2]; | 1329 char buf2[BUF_LEN * 2]; |
| 1334 if (gc->account->permdeny != 3) | 1330 if (gc->account->perm_deny != 3) |
| 1335 return; | 1331 return; |
| 1336 g_snprintf(buf2, sizeof(buf2), "toc_add_permit %s", normalize(who)); | 1332 g_snprintf(buf2, sizeof(buf2), "toc_add_permit %s", normalize(who)); |
| 1337 sflap_send(gc, buf2, -1, TYPE_DATA); | 1333 sflap_send(gc, buf2, -1, TYPE_DATA); |
| 1338 toc_set_config(gc); | 1334 toc_set_config(gc); |
| 1339 } | 1335 } |
| 1340 | 1336 |
| 1341 static void toc_add_deny(struct gaim_connection *gc, const char *who) | 1337 static void toc_add_deny(GaimConnection *gc, const char *who) |
| 1342 { | 1338 { |
| 1343 char buf2[BUF_LEN * 2]; | 1339 char buf2[BUF_LEN * 2]; |
| 1344 if (gc->account->permdeny != 4) | 1340 if (gc->account->perm_deny != 4) |
| 1345 return; | 1341 return; |
| 1346 g_snprintf(buf2, sizeof(buf2), "toc_add_deny %s", normalize(who)); | 1342 g_snprintf(buf2, sizeof(buf2), "toc_add_deny %s", normalize(who)); |
| 1347 sflap_send(gc, buf2, -1, TYPE_DATA); | 1343 sflap_send(gc, buf2, -1, TYPE_DATA); |
| 1348 toc_set_config(gc); | 1344 toc_set_config(gc); |
| 1349 } | 1345 } |
| 1350 | 1346 |
| 1351 static void toc_set_permit_deny(struct gaim_connection *gc) | 1347 static void toc_set_permit_deny(GaimConnection *gc) |
| 1352 { | 1348 { |
| 1353 char buf2[BUF_LEN * 2]; | 1349 char buf2[BUF_LEN * 2]; |
| 1354 GSList *list; | 1350 GSList *list; |
| 1355 int at; | 1351 int at; |
| 1356 | 1352 |
| 1357 switch (gc->account->permdeny) { | 1353 switch (gc->account->perm_deny) { |
| 1358 case 1: | 1354 case 1: |
| 1359 /* permit all, deny none. to get here reliably we need to have been in permit | 1355 /* permit all, deny none. to get here reliably we need to have been in permit |
| 1360 * mode, and send an empty toc_add_deny message, which will switch us to deny none */ | 1356 * mode, and send an empty toc_add_deny message, which will switch us to deny none */ |
| 1361 g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | 1357 g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); |
| 1362 sflap_send(gc, buf2, -1, TYPE_DATA); | 1358 sflap_send(gc, buf2, -1, TYPE_DATA); |
| 1411 break; | 1407 break; |
| 1412 } | 1408 } |
| 1413 toc_set_config(gc); | 1409 toc_set_config(gc); |
| 1414 } | 1410 } |
| 1415 | 1411 |
| 1416 static void toc_rem_permit(struct gaim_connection *gc, const char *who) | 1412 static void toc_rem_permit(GaimConnection *gc, const char *who) |
| 1417 { | 1413 { |
| 1418 if (gc->account->permdeny != 3) | 1414 if (gc->account->perm_deny != 3) |
| 1419 return; | 1415 return; |
| 1420 toc_set_permit_deny(gc); | 1416 toc_set_permit_deny(gc); |
| 1421 } | 1417 } |
| 1422 | 1418 |
| 1423 static void toc_rem_deny(struct gaim_connection *gc, const char *who) | 1419 static void toc_rem_deny(GaimConnection *gc, const char *who) |
| 1424 { | 1420 { |
| 1425 if (gc->account->permdeny != 4) | 1421 if (gc->account->perm_deny != 4) |
| 1426 return; | 1422 return; |
| 1427 toc_set_permit_deny(gc); | 1423 toc_set_permit_deny(gc); |
| 1428 } | 1424 } |
| 1429 | 1425 |
| 1430 static GList *toc_away_states(struct gaim_connection *gc) | 1426 static GList *toc_away_states(GaimConnection *gc) |
| 1431 { | 1427 { |
| 1432 return g_list_append(NULL, GAIM_AWAY_CUSTOM); | 1428 return g_list_append(NULL, GAIM_AWAY_CUSTOM); |
| 1433 } | 1429 } |
| 1434 | 1430 |
| 1435 static GList *toc_actions(struct gaim_connection *gc) | 1431 static GList *toc_actions(GaimConnection *gc) |
| 1436 { | 1432 { |
| 1437 GList *m = NULL; | 1433 GList *m = NULL; |
| 1438 struct proto_actions_menu *pam; | 1434 struct proto_actions_menu *pam; |
| 1439 | 1435 |
| 1440 pam = g_new0(struct proto_actions_menu, 1); | 1436 pam = g_new0(struct proto_actions_menu, 1); |
| 1496 }; | 1492 }; |
| 1497 | 1493 |
| 1498 struct file_transfer { | 1494 struct file_transfer { |
| 1499 struct file_header hdr; | 1495 struct file_header hdr; |
| 1500 | 1496 |
| 1501 struct gaim_connection *gc; | 1497 GaimConnection *gc; |
| 1502 | 1498 |
| 1503 char *user; | 1499 char *user; |
| 1504 char *cookie; | 1500 char *cookie; |
| 1505 char *ip; | 1501 char *ip; |
| 1506 int port; | 1502 int port; |
| 1662 | 1658 |
| 1663 static void toc_send_file(gpointer a, struct file_transfer *old_ft) | 1659 static void toc_send_file(gpointer a, struct file_transfer *old_ft) |
| 1664 { | 1660 { |
| 1665 struct file_transfer *ft; | 1661 struct file_transfer *ft; |
| 1666 const char *dirname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(old_ft->window)); | 1662 const char *dirname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(old_ft->window)); |
| 1667 struct gaim_account *account; | 1663 GaimAccount *account; |
| 1668 char buf[BUF_LEN * 2]; | 1664 char buf[BUF_LEN * 2]; |
| 1669 | 1665 |
| 1670 if (file_is_dir(dirname, old_ft->window)) | 1666 if (file_is_dir(dirname, old_ft->window)) |
| 1671 return; | 1667 return; |
| 1672 ft = g_new0(struct file_transfer, 1); | 1668 ft = g_new0(struct file_transfer, 1); |
| 1861 | 1857 |
| 1862 static void toc_get_file(gpointer a, struct file_transfer *old_ft) | 1858 static void toc_get_file(gpointer a, struct file_transfer *old_ft) |
| 1863 { | 1859 { |
| 1864 struct file_transfer *ft; | 1860 struct file_transfer *ft; |
| 1865 const char *dirname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(old_ft->window)); | 1861 const char *dirname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(old_ft->window)); |
| 1866 struct gaim_account *account; | 1862 GaimAccount *account; |
| 1867 char *buf, buf2[BUF_LEN * 2]; | 1863 char *buf, buf2[BUF_LEN * 2]; |
| 1868 | 1864 |
| 1869 if (file_is_dir(dirname, old_ft->window)) | 1865 if (file_is_dir(dirname, old_ft->window)) |
| 1870 return; | 1866 return; |
| 1871 ft = g_new0(struct file_transfer, 1); | 1867 ft = g_new0(struct file_transfer, 1); |
| 1931 g_free(ft); | 1927 g_free(ft); |
| 1932 } | 1928 } |
| 1933 | 1929 |
| 1934 | 1930 |
| 1935 static void toc_accept_ft(struct ft_request *fr) { | 1931 static void toc_accept_ft(struct ft_request *fr) { |
| 1936 if(g_slist_find(connections, fr->gc)) { | 1932 if(g_list_find(gaim_connections_get_all(), fr->gc)) { |
| 1937 GtkWidget *window; | 1933 GtkWidget *window; |
| 1938 char buf[BUF_LEN]; | 1934 char buf[BUF_LEN]; |
| 1939 | 1935 |
| 1940 struct file_transfer *ft = g_new0(struct file_transfer, 1); | 1936 struct file_transfer *ft = g_new0(struct file_transfer, 1); |
| 1941 ft->gc = fr->gc; | 1937 ft->gc = fr->gc; |
| 1980 g_snprintf(buf, sizeof(buf), | 1976 g_snprintf(buf, sizeof(buf), |
| 1981 ngettext( | 1977 ngettext( |
| 1982 "%s requests %s to accept %d file: %s (%.2f %s)%s%s", | 1978 "%s requests %s to accept %d file: %s (%.2f %s)%s%s", |
| 1983 "%s requests %s to accept %d files: %s (%.2f %s)%s%s", | 1979 "%s requests %s to accept %d files: %s (%.2f %s)%s%s", |
| 1984 ft->files), | 1980 ft->files), |
| 1985 ft->user, ft->gc->username, ft->files, | 1981 ft->user, gaim_account_get_username(ft->gc->account), ft->files, |
| 1986 ft->filename, size, sizes[index], (ft->message) ? "\n" : "", | 1982 ft->filename, size, sizes[index], (ft->message) ? "\n" : "", |
| 1987 (ft->message) ? ft->message : ""); | 1983 (ft->message) ? ft->message : ""); |
| 1988 } else { | 1984 } else { |
| 1989 g_snprintf(buf, sizeof(buf), _("%s requests you to send them a file"), ft->user); | 1985 g_snprintf(buf, sizeof(buf), _("%s requests you to send them a file"), ft->user); |
| 1990 } | 1986 } |
