Mercurial > pidgin
comparison src/protocols/toc/toc.c @ 5436:ad445074d239
[gaim-migrate @ 5818]
Another big commit. Ugh. I need a very smart regexp.
Core/UI split do_error_dialog(), and soon the mail dialogs! Yay! This
should work without problems at all, but standard disclaimer..
committer: Tailor Script <tailor@pidgin.im>
| author | Christian Hammond <chipx86@chipx86.com> |
|---|---|
| date | Sun, 18 May 2003 19:59:02 +0000 |
| parents | 890b29f00b68 |
| children | cce2d7868c78 |
comparison
equal
deleted
inserted
replaced
| 5435:a2f26666de42 | 5436:ad445074d239 |
|---|---|
| 679 signoff(gc); | 679 signoff(gc); |
| 680 return; | 680 return; |
| 681 } | 681 } |
| 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 gaim_notify_info(gc, NULL, |
| 685 " messages again."), NULL, GAIM_INFO); | 685 _("TOC has come back from its pause. You may " |
| 686 "now send messages again."), NULL); | |
| 686 } | 687 } |
| 687 } else if (!g_ascii_strcasecmp(c, "CONFIG")) { | 688 } else if (!g_ascii_strcasecmp(c, "CONFIG")) { |
| 688 c = strtok(NULL, ":"); | 689 c = strtok(NULL, ":"); |
| 689 parse_toc_buddy_list(gc->account, c); | 690 parse_toc_buddy_list(gc->account, c); |
| 690 } else if (!g_ascii_strcasecmp(c, "NICK")) { | 691 } else if (!g_ascii_strcasecmp(c, "NICK")) { |
| 753 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", c); | 754 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", c); |
| 754 g_free(tmp); | 755 g_free(tmp); |
| 755 | 756 |
| 756 serv_got_update(gc, c, logged, evil, signon, time_idle, type); | 757 serv_got_update(gc, c, logged, evil, signon, time_idle, type); |
| 757 } else if (!g_ascii_strcasecmp(c, "ERROR")) { | 758 } else if (!g_ascii_strcasecmp(c, "ERROR")) { |
| 758 do_error_dialog(show_error_message(), NULL, GAIM_ERROR); | 759 gaim_notify_error(gc, NULL, show_error_message(), NULL); |
| 759 } else if (!g_ascii_strcasecmp(c, "EVILED")) { | 760 } else if (!g_ascii_strcasecmp(c, "EVILED")) { |
| 760 int lev; | 761 int lev; |
| 761 char *name; | 762 char *name; |
| 762 | 763 |
| 763 sscanf(strtok(NULL, ":"), "%d", &lev); | 764 sscanf(strtok(NULL, ":"), "%d", &lev); |
| 851 if (b->window) { | 852 if (b->window) { |
| 852 char error_buf[BUF_LONG]; | 853 char error_buf[BUF_LONG]; |
| 853 gaim_conversation_set_account(b, NULL); | 854 gaim_conversation_set_account(b, NULL); |
| 854 g_snprintf(error_buf, sizeof error_buf, _("You have been disconnected" | 855 g_snprintf(error_buf, sizeof error_buf, _("You have been disconnected" |
| 855 " from chat room %s."), b->name); | 856 " from chat room %s."), b->name); |
| 856 do_error_dialog(error_buf, NULL, GAIM_ERROR); | 857 gaim_notify_error(gc, NULL, error_buf, NULL); |
| 857 } else | 858 } else |
| 858 serv_got_chat_left(gc, id); | 859 serv_got_chat_left(gc, id); |
| 859 } else if (!g_ascii_strcasecmp(c, "GOTO_URL")) { | 860 } else if (!g_ascii_strcasecmp(c, "GOTO_URL")) { |
| 860 char *name, *url, tmp[256]; | 861 char *name, *url, tmp[256]; |
| 861 | 862 |
| 868 url); | 869 url); |
| 869 grab_url(tmp, FALSE, toc_got_info, NULL); | 870 grab_url(tmp, FALSE, toc_got_info, NULL); |
| 870 } else if (!g_ascii_strcasecmp(c, "DIR_STATUS")) { | 871 } else if (!g_ascii_strcasecmp(c, "DIR_STATUS")) { |
| 871 } else if (!g_ascii_strcasecmp(c, "ADMIN_NICK_STATUS")) { | 872 } else if (!g_ascii_strcasecmp(c, "ADMIN_NICK_STATUS")) { |
| 872 } else if (!g_ascii_strcasecmp(c, "ADMIN_PASSWD_STATUS")) { | 873 } else if (!g_ascii_strcasecmp(c, "ADMIN_PASSWD_STATUS")) { |
| 873 do_error_dialog(_("Password Change Successful"), NULL, GAIM_INFO); | 874 gaim_notify_info(gc, NULL, _("Password Change Successful"), NULL); |
| 874 } else if (!g_ascii_strcasecmp(c, "PAUSE")) { | 875 } else if (!g_ascii_strcasecmp(c, "PAUSE")) { |
| 875 tdt->state = STATE_PAUSE; | 876 tdt->state = STATE_PAUSE; |
| 876 do_error_dialog(_("TOC has sent a PAUSE command."), _("When this happens, TOC ignores" | 877 gaim_notify_warning(gc, NULL, |
| 877 " any messages sent to it, and may kick you off if you send a" | 878 _("TOC has sent a PAUSE command."), |
| 878 " message. Gaim will prevent anything from going through. This" | 879 _("When this happens, TOC ignores any messages " |
| 879 " is only temporary, please be patient."), GAIM_WARNING); | 880 "sent to it, and may kick you off if you send a" |
| 881 " message. Gaim will prevent anything from " | |
| 882 "going through. This is only temporary, please " | |
| 883 "be patient.")); | |
| 880 } else if (!g_ascii_strcasecmp(c, "RVOUS_PROPOSE")) { | 884 } else if (!g_ascii_strcasecmp(c, "RVOUS_PROPOSE")) { |
| 881 char *user, *uuid, *cookie; | 885 char *user, *uuid, *cookie; |
| 882 int seq; | 886 int seq; |
| 883 char *rip, *pip, *vip, *trillian = NULL; | 887 char *rip, *pip, *vip, *trillian = NULL; |
| 884 int port; | 888 int port; |
| 1562 | 1566 |
| 1563 if (ft->files == 1) { | 1567 if (ft->files == 1) { |
| 1564 ft->file = fopen(ft->filename, "w"); | 1568 ft->file = fopen(ft->filename, "w"); |
| 1565 if (!ft->file) { | 1569 if (!ft->file) { |
| 1566 buf = g_strdup_printf(_("Could not open %s for writing!"), ft->filename); | 1570 buf = g_strdup_printf(_("Could not open %s for writing!"), ft->filename); |
| 1567 do_error_dialog(buf, strerror(errno), GAIM_ERROR); | 1571 gaim_notify_error(ft->gc, NULL, buf, strerror(errno)); |
| 1568 g_free(buf); | 1572 g_free(buf); |
| 1569 gaim_input_remove(ft->inpa); | 1573 gaim_input_remove(ft->inpa); |
| 1570 toc_soc_close(source); | 1574 toc_soc_close(source); |
| 1571 g_free(ft->filename); | 1575 g_free(ft->filename); |
| 1572 g_free(ft->user); | 1576 g_free(ft->user); |
| 1579 ft->file = fopen(buf, "w"); | 1583 ft->file = fopen(buf, "w"); |
| 1580 g_free(buf); | 1584 g_free(buf); |
| 1581 if (!ft->file) { | 1585 if (!ft->file) { |
| 1582 buf = g_strdup_printf("Could not open %s/%s for writing!", ft->filename, | 1586 buf = g_strdup_printf("Could not open %s/%s for writing!", ft->filename, |
| 1583 ft->hdr.name); | 1587 ft->hdr.name); |
| 1584 do_error_dialog(buf, strerror(errno), GAIM_ERROR); | 1588 gaim_notify_error(ft->gc, NULL, buf, strerror(errno)); |
| 1585 g_free(buf); | 1589 g_free(buf); |
| 1586 gaim_input_remove(ft->inpa); | 1590 gaim_input_remove(ft->inpa); |
| 1587 toc_soc_close(source); | 1591 toc_soc_close(source); |
| 1588 g_free(ft->filename); | 1592 g_free(ft->filename); |
| 1589 g_free(ft->user); | 1593 g_free(ft->user); |
| 1596 return; | 1600 return; |
| 1597 } | 1601 } |
| 1598 | 1602 |
| 1599 rt = toc_read(source, buf, MIN(ntohl(ft->hdr.size) - ft->recvsize, 1024)); | 1603 rt = toc_read(source, buf, MIN(ntohl(ft->hdr.size) - ft->recvsize, 1024)); |
| 1600 if (rt < 0) { | 1604 if (rt < 0) { |
| 1601 do_error_dialog("File transfer failed; other side probably canceled.", NULL, GAIM_ERROR); | 1605 gaim_notify_error(ft->gc, NULL, |
| 1606 _("File transfer failed; other side probably " | |
| 1607 "canceled."), NULL); | |
| 1602 gaim_input_remove(ft->inpa); | 1608 gaim_input_remove(ft->inpa); |
| 1603 toc_soc_close(source); | 1609 toc_soc_close(source); |
| 1604 g_free(ft->user); | 1610 g_free(ft->user); |
| 1605 g_free(ft->ip); | 1611 g_free(ft->ip); |
| 1606 g_free(ft->cookie); | 1612 g_free(ft->cookie); |
| 1639 static void toc_send_file_connect(gpointer data, gint src, GaimInputCondition cond) | 1645 static void toc_send_file_connect(gpointer data, gint src, GaimInputCondition cond) |
| 1640 { | 1646 { |
| 1641 struct file_transfer *ft = data; | 1647 struct file_transfer *ft = data; |
| 1642 | 1648 |
| 1643 if (src == -1) { | 1649 if (src == -1) { |
| 1644 do_error_dialog(_("Could not connect for transfer."), NULL, GAIM_ERROR); | 1650 gaim_notify_error(ft->gc, NULL, |
| 1651 _("Could not connect for transfer."), NULL); | |
| 1645 g_free(ft->filename); | 1652 g_free(ft->filename); |
| 1646 g_free(ft->cookie); | 1653 g_free(ft->cookie); |
| 1647 g_free(ft->user); | 1654 g_free(ft->user); |
| 1648 g_free(ft->ip); | 1655 g_free(ft->ip); |
| 1649 g_free(ft); | 1656 g_free(ft); |
| 1678 | 1685 |
| 1679 g_snprintf(buf, sizeof(buf), "toc_rvous_accept %s %s %s", ft->user, ft->cookie, FILE_SEND_UID); | 1686 g_snprintf(buf, sizeof(buf), "toc_rvous_accept %s %s %s", ft->user, ft->cookie, FILE_SEND_UID); |
| 1680 sflap_send(ft->gc, buf, -1, TYPE_DATA); | 1687 sflap_send(ft->gc, buf, -1, TYPE_DATA); |
| 1681 | 1688 |
| 1682 if (proxy_connect(account, ft->ip, ft->port, toc_send_file_connect, ft) != 0) { | 1689 if (proxy_connect(account, ft->ip, ft->port, toc_send_file_connect, ft) != 0) { |
| 1683 do_error_dialog(_("Could not connect for transfer."), NULL, GAIM_ERROR); | 1690 gaim_notify_error(ft->gc, NULL, |
| 1691 _("Could not connect for transfer."), NULL); | |
| 1684 g_free(ft->filename); | 1692 g_free(ft->filename); |
| 1685 g_free(ft->cookie); | 1693 g_free(ft->cookie); |
| 1686 g_free(ft->user); | 1694 g_free(ft->user); |
| 1687 g_free(ft->ip); | 1695 g_free(ft->ip); |
| 1688 g_free(ft); | 1696 g_free(ft); |
| 1744 toc_read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | 1752 toc_read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); |
| 1745 debug_header(ft); | 1753 debug_header(ft); |
| 1746 | 1754 |
| 1747 if (ft->hdr.hdrtype != htons(0x120c)) { | 1755 if (ft->hdr.hdrtype != htons(0x120c)) { |
| 1748 g_snprintf(buf, sizeof(buf), "%s decided to cancel the transfer", ft->user); | 1756 g_snprintf(buf, sizeof(buf), "%s decided to cancel the transfer", ft->user); |
| 1749 do_error_dialog(buf, NULL, GAIM_ERROR); | 1757 gaim_notify_error(ft->gc, NULL, buf, NULL); |
| 1750 gaim_input_remove(ft->inpa); | 1758 gaim_input_remove(ft->inpa); |
| 1751 toc_soc_close(source); | 1759 toc_soc_close(source); |
| 1752 g_free(ft->filename); | 1760 g_free(ft->filename); |
| 1753 g_free(ft->user); | 1761 g_free(ft->user); |
| 1754 g_free(ft->ip); | 1762 g_free(ft->ip); |
| 1801 struct file_header *hdr; | 1809 struct file_header *hdr; |
| 1802 char *buf; | 1810 char *buf; |
| 1803 char *basename; | 1811 char *basename; |
| 1804 | 1812 |
| 1805 if (src == -1) { | 1813 if (src == -1) { |
| 1806 do_error_dialog(_("Could not connect for transfer!"), NULL, GAIM_ERROR); | 1814 gaim_notify_error(ft->gc, NULL, |
| 1815 _("Could not connect for transfer!"), NULL); | |
| 1807 fclose(ft->file); | 1816 fclose(ft->file); |
| 1808 g_free(ft->filename); | 1817 g_free(ft->filename); |
| 1809 g_free(ft->cookie); | 1818 g_free(ft->cookie); |
| 1810 g_free(ft->user); | 1819 g_free(ft->user); |
| 1811 g_free(ft->ip); | 1820 g_free(ft->ip); |
| 1833 hdr->flags = 0x02; | 1842 hdr->flags = 0x02; |
| 1834 hdr->lnameoffset = 0x1A; | 1843 hdr->lnameoffset = 0x1A; |
| 1835 hdr->lsizeoffset = 0x10; | 1844 hdr->lsizeoffset = 0x10; |
| 1836 g_snprintf(hdr->name, 64, "listing.txt"); | 1845 g_snprintf(hdr->name, 64, "listing.txt"); |
| 1837 if (toc_write(src, hdr, 256) < 0) { | 1846 if (toc_write(src, hdr, 256) < 0) { |
| 1838 do_error_dialog(_("Could not write file header. The file will not be transferred."), NULL, GAIM_ERROR); | 1847 gaim_notify_error(ft->gc, NULL, |
| 1848 _("Could not write file header. The file will " | |
| 1849 "not be transferred."), NULL); | |
| 1839 fclose(ft->file); | 1850 fclose(ft->file); |
| 1840 g_free(ft->filename); | 1851 g_free(ft->filename); |
| 1841 g_free(ft->cookie); | 1852 g_free(ft->cookie); |
| 1842 g_free(ft->user); | 1853 g_free(ft->user); |
| 1843 g_free(ft->ip); | 1854 g_free(ft->ip); |
| 1860 ft = g_new0(struct file_transfer, 1); | 1871 ft = g_new0(struct file_transfer, 1); |
| 1861 ft->filename = g_strdup(dirname); | 1872 ft->filename = g_strdup(dirname); |
| 1862 ft->file = fopen(ft->filename, "r"); | 1873 ft->file = fopen(ft->filename, "r"); |
| 1863 if (!ft->file) { | 1874 if (!ft->file) { |
| 1864 buf = g_strdup_printf("Unable to open %s for transfer.", ft->filename); | 1875 buf = g_strdup_printf("Unable to open %s for transfer.", ft->filename); |
| 1865 do_error_dialog(buf, NULL, GAIM_ERROR); | 1876 gaim_notify_error(ft->gc, NULL, buf, NULL); |
| 1866 g_free(buf); | 1877 g_free(buf); |
| 1867 g_free(ft->filename); | 1878 g_free(ft->filename); |
| 1868 g_free(ft); | 1879 g_free(ft); |
| 1869 return; | 1880 return; |
| 1870 } | 1881 } |
| 1871 if (stat(dirname, &ft->st)) { | 1882 if (stat(dirname, &ft->st)) { |
| 1872 buf = g_strdup_printf("Unable to examine %s.", dirname); | 1883 buf = g_strdup_printf("Unable to examine %s.", dirname); |
| 1873 do_error_dialog(buf, NULL, GAIM_ERROR); | 1884 gaim_notify_error(ft->gc, NULL, buf, NULL); |
| 1874 g_free(buf); | 1885 g_free(buf); |
| 1875 g_free(ft->filename); | 1886 g_free(ft->filename); |
| 1876 g_free(ft); | 1887 g_free(ft); |
| 1877 return; | 1888 return; |
| 1878 } | 1889 } |
| 1886 | 1897 |
| 1887 g_snprintf(buf2, sizeof(buf2), "toc_rvous_accept %s %s %s", ft->user, ft->cookie, FILE_GET_UID); | 1898 g_snprintf(buf2, sizeof(buf2), "toc_rvous_accept %s %s %s", ft->user, ft->cookie, FILE_GET_UID); |
| 1888 sflap_send(ft->gc, buf2, -1, TYPE_DATA); | 1899 sflap_send(ft->gc, buf2, -1, TYPE_DATA); |
| 1889 | 1900 |
| 1890 if (proxy_connect(account, ft->ip, ft->port, toc_get_file_connect, ft) < 0) { | 1901 if (proxy_connect(account, ft->ip, ft->port, toc_get_file_connect, ft) < 0) { |
| 1891 do_error_dialog(_("Could not connect for transfer."), NULL, GAIM_ERROR); | 1902 gaim_notify_error(ft->gc, NULL, |
| 1903 _("Could not connect for transfer."), NULL); | |
| 1892 fclose(ft->file); | 1904 fclose(ft->file); |
| 1893 g_free(ft->filename); | 1905 g_free(ft->filename); |
| 1894 g_free(ft->cookie); | 1906 g_free(ft->cookie); |
| 1895 g_free(ft->user); | 1907 g_free(ft->user); |
| 1896 g_free(ft->ip); | 1908 g_free(ft->ip); |
