| 621 return; |
621 return; |
| 622 } |
622 } |
| 623 |
623 |
| 624 if (tdt->state == STATE_SIGNON_REQUEST) { |
624 if (tdt->state == STATE_SIGNON_REQUEST) { |
| 625 debug_printf("* TOC sends client SIGN_ON reply\n"); |
625 debug_printf("* TOC sends client SIGN_ON reply\n"); |
| 626 if (g_strncasecmp(buf + sizeof(struct sflap_hdr), "SIGN_ON", strlen("SIGN_ON"))) { |
626 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", |
627 debug_printf("Didn't get SIGN_ON! buf was: %s\n", |
| 628 buf + sizeof(struct sflap_hdr)); |
628 buf + sizeof(struct sflap_hdr)); |
| 629 if (!g_strncasecmp(buf + sizeof(struct sflap_hdr), "ERROR", 5)) { |
629 if (!g_ascii_strncasecmp(buf + sizeof(struct sflap_hdr), "ERROR", 5)) { |
| 630 strtok(buf + sizeof(struct sflap_hdr), ":"); |
630 strtok(buf + sizeof(struct sflap_hdr), ":"); |
| 631 hide_login_progress(gc, show_error_message()); |
631 hide_login_progress(gc, show_error_message()); |
| 632 } else |
632 } else |
| 633 hide_login_progress(gc, _("Authentication Failed")); |
633 hide_login_progress(gc, _("Authentication Failed")); |
| 634 signoff(gc); |
634 signoff(gc); |
| 663 |
663 |
| 664 debug_printf("TOC S: %s\n", buf + sizeof(struct sflap_hdr)); |
664 debug_printf("TOC S: %s\n", buf + sizeof(struct sflap_hdr)); |
| 665 |
665 |
| 666 c = strtok(buf + sizeof(struct sflap_hdr), ":"); /* Ditch the first part */ |
666 c = strtok(buf + sizeof(struct sflap_hdr), ":"); /* Ditch the first part */ |
| 667 |
667 |
| 668 if (!g_strcasecmp(c, "SIGN_ON")) { |
668 if (!g_ascii_strcasecmp(c, "SIGN_ON")) { |
| 669 /* we should only get here after a PAUSE */ |
669 /* we should only get here after a PAUSE */ |
| 670 if (tdt->state != STATE_PAUSE) |
670 if (tdt->state != STATE_PAUSE) |
| 671 debug_printf("got SIGN_ON but not PAUSE!\n"); |
671 debug_printf("got SIGN_ON but not PAUSE!\n"); |
| 672 else { |
672 else { |
| 673 tdt->state = STATE_ONLINE; |
673 tdt->state = STATE_ONLINE; |
| 682 g_snprintf(snd, sizeof snd, "toc_init_done"); |
682 g_snprintf(snd, sizeof snd, "toc_init_done"); |
| 683 sflap_send(gc, snd, -1, TYPE_DATA); |
683 sflap_send(gc, snd, -1, TYPE_DATA); |
| 684 do_error_dialog(_("TOC has come back from its pause. You may now send" |
684 do_error_dialog(_("TOC has come back from its pause. You may now send" |
| 685 " messages again."), NULL, GAIM_INFO); |
685 " messages again."), NULL, GAIM_INFO); |
| 686 } |
686 } |
| 687 } else if (!strcasecmp(c, "CONFIG")) { |
687 } else if (!g_ascii_strcasecmp(c, "CONFIG")) { |
| 688 c = strtok(NULL, ":"); |
688 c = strtok(NULL, ":"); |
| 689 parse_toc_buddy_list(gc->account, c); |
689 parse_toc_buddy_list(gc->account, c); |
| 690 } else if (!strcasecmp(c, "NICK")) { |
690 } else if (!g_ascii_strcasecmp(c, "NICK")) { |
| 691 /* ignore NICK so that things get imported/exported properly |
691 /* ignore NICK so that things get imported/exported properly |
| 692 c = strtok(NULL, ":"); |
692 c = strtok(NULL, ":"); |
| 693 g_snprintf(gc->username, sizeof(gc->username), "%s", c); |
693 g_snprintf(gc->username, sizeof(gc->username), "%s", c); |
| 694 */ |
694 */ |
| 695 } else if (!strcasecmp(c, "IM_IN")) { |
695 } else if (!g_ascii_strcasecmp(c, "IM_IN")) { |
| 696 char *away, *message; |
696 char *away, *message; |
| 697 int a = 0; |
697 int a = 0; |
| 698 |
698 |
| 699 c = strtok(NULL, ":"); |
699 c = strtok(NULL, ":"); |
| 700 away = strtok(NULL, ":"); |
700 away = strtok(NULL, ":"); |
| 705 message++; |
705 message++; |
| 706 |
706 |
| 707 a = (away && (*away == 'T')) ? IM_FLAG_AWAY : 0; |
707 a = (away && (*away == 'T')) ? IM_FLAG_AWAY : 0; |
| 708 |
708 |
| 709 serv_got_im(gc, c, message, a, time(NULL), -1); |
709 serv_got_im(gc, c, message, a, time(NULL), -1); |
| 710 } else if (!strcasecmp(c, "UPDATE_BUDDY")) { |
710 } else if (!g_ascii_strcasecmp(c, "UPDATE_BUDDY")) { |
| 711 char *l, *uc, *tmp; |
711 char *l, *uc, *tmp; |
| 712 int logged, evil, idle, type = 0; |
712 int logged, evil, idle, type = 0; |
| 713 time_t signon, time_idle; |
713 time_t signon, time_idle; |
| 714 |
714 |
| 715 c = strtok(NULL, ":"); /* name */ |
715 c = strtok(NULL, ":"); /* name */ |
| 752 if (!strcmp(tmp, normalize(c))) |
752 if (!strcmp(tmp, normalize(c))) |
| 753 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", c); |
753 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", c); |
| 754 g_free(tmp); |
754 g_free(tmp); |
| 755 |
755 |
| 756 serv_got_update(gc, c, logged, evil, signon, time_idle, type); |
756 serv_got_update(gc, c, logged, evil, signon, time_idle, type); |
| 757 } else if (!strcasecmp(c, "ERROR")) { |
757 } else if (!g_ascii_strcasecmp(c, "ERROR")) { |
| 758 do_error_dialog(show_error_message(), NULL, GAIM_ERROR); |
758 do_error_dialog(show_error_message(), NULL, GAIM_ERROR); |
| 759 } else if (!strcasecmp(c, "EVILED")) { |
759 } else if (!g_ascii_strcasecmp(c, "EVILED")) { |
| 760 int lev; |
760 int lev; |
| 761 char *name; |
761 char *name; |
| 762 |
762 |
| 763 sscanf(strtok(NULL, ":"), "%d", &lev); |
763 sscanf(strtok(NULL, ":"), "%d", &lev); |
| 764 name = strtok(NULL, ":"); |
764 name = strtok(NULL, ":"); |
| 765 |
765 |
| 766 serv_got_eviled(gc, name, lev); |
766 serv_got_eviled(gc, name, lev); |
| 767 } else if (!strcasecmp(c, "CHAT_JOIN")) { |
767 } else if (!g_ascii_strcasecmp(c, "CHAT_JOIN")) { |
| 768 char *name; |
768 char *name; |
| 769 int id; |
769 int id; |
| 770 |
770 |
| 771 sscanf(strtok(NULL, ":"), "%d", &id); |
771 sscanf(strtok(NULL, ":"), "%d", &id); |
| 772 name = strtok(NULL, ":"); |
772 name = strtok(NULL, ":"); |
| 773 |
773 |
| 774 serv_got_joined_chat(gc, id, name); |
774 serv_got_joined_chat(gc, id, name); |
| 775 } else if (!strcasecmp(c, "CHAT_IN")) { |
775 } else if (!g_ascii_strcasecmp(c, "CHAT_IN")) { |
| 776 int id, w; |
776 int id, w; |
| 777 char *m, *who, *whisper; |
777 char *m, *who, *whisper; |
| 778 |
778 |
| 779 sscanf(strtok(NULL, ":"), "%d", &id); |
779 sscanf(strtok(NULL, ":"), "%d", &id); |
| 780 who = strtok(NULL, ":"); |
780 who = strtok(NULL, ":"); |
| 785 m++; |
785 m++; |
| 786 |
786 |
| 787 w = (whisper && (*whisper == 'T')) ? 1 : 0; |
787 w = (whisper && (*whisper == 'T')) ? 1 : 0; |
| 788 |
788 |
| 789 serv_got_chat_in(gc, id, who, w, m, time((time_t)NULL)); |
789 serv_got_chat_in(gc, id, who, w, m, time((time_t)NULL)); |
| 790 } else if (!strcasecmp(c, "CHAT_UPDATE_BUDDY")) { |
790 } else if (!g_ascii_strcasecmp(c, "CHAT_UPDATE_BUDDY")) { |
| 791 int id; |
791 int id; |
| 792 char *in, *buddy; |
792 char *in, *buddy; |
| 793 GSList *bcs = gc->buddy_chats; |
793 GSList *bcs = gc->buddy_chats; |
| 794 struct gaim_conversation *b = NULL; |
794 struct gaim_conversation *b = NULL; |
| 795 struct gaim_chat *chat; |
795 struct gaim_chat *chat; |
| 814 while ((buddy = strtok(NULL, ":")) != NULL) |
814 while ((buddy = strtok(NULL, ":")) != NULL) |
| 815 gaim_chat_add_user(chat, buddy, NULL); |
815 gaim_chat_add_user(chat, buddy, NULL); |
| 816 else |
816 else |
| 817 while ((buddy = strtok(NULL, ":")) != NULL) |
817 while ((buddy = strtok(NULL, ":")) != NULL) |
| 818 gaim_chat_remove_user(chat, buddy, NULL); |
818 gaim_chat_remove_user(chat, buddy, NULL); |
| 819 } else if (!strcasecmp(c, "CHAT_INVITE")) { |
819 } else if (!g_ascii_strcasecmp(c, "CHAT_INVITE")) { |
| 820 char *name, *who, *message; |
820 char *name, *who, *message; |
| 821 int *id = g_new0(int, 1); |
821 int *id = g_new0(int, 1); |
| 822 |
822 |
| 823 name = strtok(NULL, ":"); |
823 name = strtok(NULL, ":"); |
| 824 sscanf(strtok(NULL, ":"), "%d", id); |
824 sscanf(strtok(NULL, ":"), "%d", id); |
| 825 who = strtok(NULL, ":"); |
825 who = strtok(NULL, ":"); |
| 826 message = strtok(NULL, ":"); |
826 message = strtok(NULL, ":"); |
| 827 |
827 |
| 828 serv_got_chat_invite(gc, name, who, message, g_list_append(NULL, id)); |
828 serv_got_chat_invite(gc, name, who, message, g_list_append(NULL, id)); |
| 829 } else if (!strcasecmp(c, "CHAT_LEFT")) { |
829 } else if (!g_ascii_strcasecmp(c, "CHAT_LEFT")) { |
| 830 GSList *bcs = gc->buddy_chats; |
830 GSList *bcs = gc->buddy_chats; |
| 831 struct gaim_conversation *b = NULL; |
831 struct gaim_conversation *b = NULL; |
| 832 int id; |
832 int id; |
| 833 |
833 |
| 834 sscanf(strtok(NULL, ":"), "%d", &id); |
834 sscanf(strtok(NULL, ":"), "%d", &id); |
| 850 g_snprintf(error_buf, sizeof error_buf, _("You have been disconnected" |
850 g_snprintf(error_buf, sizeof error_buf, _("You have been disconnected" |
| 851 " from chat room %s."), b->name); |
851 " from chat room %s."), b->name); |
| 852 do_error_dialog(error_buf, NULL, GAIM_ERROR); |
852 do_error_dialog(error_buf, NULL, GAIM_ERROR); |
| 853 } else |
853 } else |
| 854 serv_got_chat_left(gc, id); |
854 serv_got_chat_left(gc, id); |
| 855 } else if (!strcasecmp(c, "GOTO_URL")) { |
855 } else if (!g_ascii_strcasecmp(c, "GOTO_URL")) { |
| 856 char *name, *url, tmp[256]; |
856 char *name, *url, tmp[256]; |
| 857 |
857 |
| 858 name = strtok(NULL, ":"); |
858 name = strtok(NULL, ":"); |
| 859 url = strtok(NULL, ":"); |
859 url = strtok(NULL, ":"); |
| 860 |
860 |
| 861 g_snprintf(tmp, sizeof(tmp), "http://%s:%d/%s", tdt->toc_ip, |
861 g_snprintf(tmp, sizeof(tmp), "http://%s:%d/%s", tdt->toc_ip, |
| 862 gc->account->proto_opt[USEROPT_AUTHPORT][0] ? |
862 gc->account->proto_opt[USEROPT_AUTHPORT][0] ? |
| 863 atoi(gc->account->proto_opt[USEROPT_AUTHPORT]) : TOC_PORT, |
863 atoi(gc->account->proto_opt[USEROPT_AUTHPORT]) : TOC_PORT, |
| 864 url); |
864 url); |
| 865 grab_url(tmp, FALSE, toc_got_info, NULL); |
865 grab_url(tmp, FALSE, toc_got_info, NULL); |
| 866 } else if (!strcasecmp(c, "DIR_STATUS")) { |
866 } else if (!g_ascii_strcasecmp(c, "DIR_STATUS")) { |
| 867 } else if (!strcasecmp(c, "ADMIN_NICK_STATUS")) { |
867 } else if (!g_ascii_strcasecmp(c, "ADMIN_NICK_STATUS")) { |
| 868 } else if (!strcasecmp(c, "ADMIN_PASSWD_STATUS")) { |
868 } else if (!g_ascii_strcasecmp(c, "ADMIN_PASSWD_STATUS")) { |
| 869 do_error_dialog(_("Password Change Successful"), NULL, GAIM_INFO); |
869 do_error_dialog(_("Password Change Successful"), NULL, GAIM_INFO); |
| 870 } else if (!strcasecmp(c, "PAUSE")) { |
870 } else if (!g_ascii_strcasecmp(c, "PAUSE")) { |
| 871 tdt->state = STATE_PAUSE; |
871 tdt->state = STATE_PAUSE; |
| 872 do_error_dialog(_("TOC has sent a PAUSE command."), _("When this happens, TOC ignores" |
872 do_error_dialog(_("TOC has sent a PAUSE command."), _("When this happens, TOC ignores" |
| 873 " any messages sent to it, and may kick you off if you send a" |
873 " any messages sent to it, and may kick you off if you send a" |
| 874 " message. Gaim will prevent anything from going through. This" |
874 " message. Gaim will prevent anything from going through. This" |
| 875 " is only temporary, please be patient."), GAIM_WARNING); |
875 " is only temporary, please be patient."), GAIM_WARNING); |
| 876 } else if (!strcasecmp(c, "RVOUS_PROPOSE")) { |
876 } else if (!g_ascii_strcasecmp(c, "RVOUS_PROPOSE")) { |
| 877 char *user, *uuid, *cookie; |
877 char *user, *uuid, *cookie; |
| 878 int seq; |
878 int seq; |
| 879 char *rip, *pip, *vip, *trillian = NULL; |
879 char *rip, *pip, *vip, *trillian = NULL; |
| 880 int port; |
880 int port; |
| 881 |
881 |
| 1716 return; |
1716 return; |
| 1717 ft = g_new0(struct file_transfer, 1); |
1717 ft = g_new0(struct file_transfer, 1); |
| 1718 if (old_ft->files == 1) |
1718 if (old_ft->files == 1) |
| 1719 ft->filename = g_strdup(dirname); |
1719 ft->filename = g_strdup(dirname); |
| 1720 else |
1720 else |
| 1721 ft->filename = g_dirname(dirname); |
1721 ft->filename = g_path_get_dirname(dirname); |
| 1722 ft->cookie = g_strdup(old_ft->cookie); |
1722 ft->cookie = g_strdup(old_ft->cookie); |
| 1723 ft->user = g_strdup(old_ft->user); |
1723 ft->user = g_strdup(old_ft->user); |
| 1724 ft->ip = g_strdup(old_ft->ip); |
1724 ft->ip = g_strdup(old_ft->ip); |
| 1725 ft->files = old_ft->files; |
1725 ft->files = old_ft->files; |
| 1726 ft->port = old_ft->port; |
1726 ft->port = old_ft->port; |
| 1764 } |
1764 } |
| 1765 |
1765 |
| 1766 if (ft->hdr.hdrtype == htons(0x1108)) { |
1766 if (ft->hdr.hdrtype == htons(0x1108)) { |
| 1767 struct tm *fortime; |
1767 struct tm *fortime; |
| 1768 struct stat st; |
1768 struct stat st; |
| |
1769 char *basename; |
| 1769 |
1770 |
| 1770 toc_read(source, ft, 8); |
1771 toc_read(source, ft, 8); |
| 1771 toc_read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); |
1772 toc_read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); |
| 1772 debug_header(ft); |
1773 debug_header(ft); |
| 1773 |
1774 |
| 1774 stat(ft->filename, &st); |
1775 stat(ft->filename, &st); |
| 1775 fortime = localtime(&st.st_mtime); |
1776 fortime = localtime(&st.st_mtime); |
| |
1777 basename = g_path_get_basename(ft->filename); |
| 1776 g_snprintf(buf, sizeof(buf), "%2d/%2d/%4d %2d:%2d %8ld %s\r\n", |
1778 g_snprintf(buf, sizeof(buf), "%2d/%2d/%4d %2d:%2d %8ld %s\r\n", |
| 1777 fortime->tm_mon + 1, fortime->tm_mday, fortime->tm_year + 1900, |
1779 fortime->tm_mon + 1, fortime->tm_mday, fortime->tm_year + 1900, |
| 1778 fortime->tm_hour + 1, fortime->tm_min + 1, (long)st.st_size, |
1780 fortime->tm_hour + 1, fortime->tm_min + 1, (long)st.st_size, |
| 1779 g_basename(ft->filename)); |
1781 basename); |
| 1780 toc_write(source, buf, ntohl(ft->hdr.size)); |
1782 toc_write(source, buf, ntohl(ft->hdr.size)); |
| |
1783 g_free(basename); |
| 1781 return; |
1784 return; |
| 1782 } |
1785 } |
| 1783 |
1786 |
| 1784 if (ft->hdr.hdrtype == htons(0x1209)) { |
1787 if (ft->hdr.hdrtype == htons(0x1209)) { |
| 1785 toc_read(source, ft, 8); |
1788 toc_read(source, ft, 8); |
| 1870 g_free(buf); |
1874 g_free(buf); |
| 1871 hdr->totfiles = htons(1); hdr->filesleft = htons(1); |
1875 hdr->totfiles = htons(1); hdr->filesleft = htons(1); |
| 1872 hdr->totparts = htons(1); hdr->partsleft = htons(1); |
1876 hdr->totparts = htons(1); hdr->partsleft = htons(1); |
| 1873 hdr->totsize = htonl((long)ft->st.st_size); /* combined size of all files */ |
1877 hdr->totsize = htonl((long)ft->st.st_size); /* combined size of all files */ |
| 1874 /* size = strlen("mm/dd/yyyy hh:mm sizesize 'name'\r\n") */ |
1878 /* size = strlen("mm/dd/yyyy hh:mm sizesize 'name'\r\n") */ |
| 1875 hdr->size = htonl(28 + strlen(g_basename(ft->filename))); /* size of listing.txt */ |
1879 basename = g_path_get_basename(ft->filename); |
| |
1880 hdr->size = htonl(28 + strlen(basename)); /* size of listing.txt */ |
| |
1881 g_free(basename); |
| 1876 hdr->modtime = htonl(ft->st.st_mtime); |
1882 hdr->modtime = htonl(ft->st.st_mtime); |
| 1877 hdr->checksum = htonl(0x89f70000); /* uh... */ |
1883 hdr->checksum = htonl(0x89f70000); /* uh... */ |
| 1878 g_snprintf(hdr->idstring, 32, "OFT_Windows ICBMFT V1.1 32"); |
1884 g_snprintf(hdr->idstring, 32, "OFT_Windows ICBMFT V1.1 32"); |
| 1879 hdr->flags = 0x02; |
1885 hdr->flags = 0x02; |
| 1880 hdr->lnameoffset = 0x1A; |
1886 hdr->lnameoffset = 0x1A; |