Mercurial > pidgin
comparison src/protocols/oscar/oscar.c @ 4121:69c049c48a96
[gaim-migrate @ 4338]
Matt's patch is more thorough
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Mon, 23 Dec 2002 20:32:52 +0000 |
parents | 697217b52ebd |
children | 1a5dcfa1823e |
comparison
equal
deleted
inserted
replaced
4120:697217b52ebd | 4121:69c049c48a96 |
---|---|
218 g_free(n); | 218 g_free(n); |
219 return m; | 219 return m; |
220 } | 220 } |
221 | 221 |
222 static char *extract_name(const char *name) { | 222 static char *extract_name(const char *name) { |
223 char *tmp; | 223 char *tmp, *x; |
224 int i, j; | 224 int i, j; |
225 char *x; | |
226 | 225 |
227 if (!name) | 226 if (!name) |
228 return NULL; | 227 return NULL; |
229 | 228 |
230 x = strchr(name, '-'); | 229 x = strchr(name, '-'); |
230 | |
231 if (!x) return NULL; | 231 if (!x) return NULL; |
232 x = strchr(++x, '-'); | 232 x = strchr(++x, '-'); |
233 if (!x) return NULL; | 233 if (!x) return NULL; |
234 tmp = g_strdup(++x); | 234 tmp = g_strdup(++x); |
235 | 235 |
1762 | 1762 |
1763 if (args->icbmflags & AIM_IMFLAGS_HASICON) { | 1763 if (args->icbmflags & AIM_IMFLAGS_HASICON) { |
1764 struct icon_req *ir = NULL; | 1764 struct icon_req *ir = NULL; |
1765 GSList *h = od->hasicons; | 1765 GSList *h = od->hasicons; |
1766 char *who = normalize(userinfo->sn); | 1766 char *who = normalize(userinfo->sn); |
1767 | |
1768 if (!args->iconlen || !args->iconsum || !args->iconstamp) | |
1769 return 1; | |
1770 | |
1767 debug_printf("%s has an icon\n", userinfo->sn); | 1771 debug_printf("%s has an icon\n", userinfo->sn); |
1768 while (h) { | 1772 while (h) { |
1769 ir = h->data; | 1773 ir = h->data; |
1770 if (!strcmp(ir->user, who)) | 1774 if (!strcmp(ir->user, who)) |
1771 break; | 1775 break; |
1811 * convert it to utf-8 before handing it to the gaim core. | 1815 * convert it to utf-8 before handing it to the gaim core. |
1812 * This conversion should *never* fail, if it does it | 1816 * This conversion should *never* fail, if it does it |
1813 * means that either the incoming ICBM is corrupted or | 1817 * means that either the incoming ICBM is corrupted or |
1814 * there is something we don't understand about it. */ | 1818 * there is something we don't understand about it. */ |
1815 /* For the record, AIM Unicode is big-endian UCS-2 */ | 1819 /* For the record, AIM Unicode is big-endian UCS-2 */ |
1820 | |
1821 if (!args->msg || !args->msglen) | |
1822 return 1; | |
1823 | |
1816 tmp = g_convert(args->msg, args->msglen, "UTF-8", "UCS-2BE", NULL, &convlen, &err); | 1824 tmp = g_convert(args->msg, args->msglen, "UTF-8", "UCS-2BE", NULL, &convlen, &err); |
1817 if (err) { | 1825 if (err) { |
1818 debug_printf("Unicode IM conversion: %s\n", err->message); | 1826 debug_printf("Unicode IM conversion: %s\n", err->message); |
1819 tmp = strdup(_("(There was an error receiving this message)")); | 1827 tmp = strdup(_("(There was an error receiving this message)")); |
1820 } | 1828 } |
1827 * that will happily send ISO-8859-1 without marking it as | 1835 * that will happily send ISO-8859-1 without marking it as |
1828 * such */ | 1836 * such */ |
1829 if (args->icbmflags & AIM_IMFLAGS_ISO_8859_1) { | 1837 if (args->icbmflags & AIM_IMFLAGS_ISO_8859_1) { |
1830 debug_printf ("Received ISO-8859-1 IM\n"); | 1838 debug_printf ("Received ISO-8859-1 IM\n"); |
1831 } | 1839 } |
1840 | |
1841 if (!args->msg || !args->msglen) | |
1842 return 1; | |
1843 | |
1832 tmp = g_convert(args->msg, args->msglen, "UTF-8", "ISO-8859-1", NULL, &convlen, &err); | 1844 tmp = g_convert(args->msg, args->msglen, "UTF-8", "ISO-8859-1", NULL, &convlen, &err); |
1833 if (err) { | 1845 if (err) { |
1834 debug_printf("ISO-8859-1 IM conversion: %s\n", err->message); | 1846 debug_printf("ISO-8859-1 IM conversion: %s\n", err->message); |
1835 tmp = strdup(_("(There was an error receiving this message)")); | 1847 tmp = strdup(_("(There was an error receiving this message)")); |
1836 } | 1848 } |
1854 } | 1866 } |
1855 | 1867 |
1856 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { | 1868 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
1857 struct gaim_connection *gc = sess->aux_data; | 1869 struct gaim_connection *gc = sess->aux_data; |
1858 | 1870 |
1871 if (!args) | |
1872 return 0; | |
1873 | |
1859 debug_printf("rendezvous status %d (%s)\n", args->status, userinfo->sn); | 1874 debug_printf("rendezvous status %d (%s)\n", args->status, userinfo->sn); |
1860 | 1875 |
1861 | 1876 |
1862 if (args->status == AIM_RENDEZVOUS_CANCEL) { | 1877 if (args->status == AIM_RENDEZVOUS_CANCEL) { |
1863 struct oscar_file_transfer *oft; | 1878 struct oscar_file_transfer *oft; |
1879 if (!args->cookie) | |
1880 return 1; | |
1864 oft = find_oft_by_cookie(gc, args->cookie); | 1881 oft = find_oft_by_cookie(gc, args->cookie); |
1865 if (oft) { | 1882 if (oft) { |
1866 transfer_abort(oft->xfer, _("Buddy canceled transfer")); | 1883 transfer_abort(oft->xfer, _("Buddy canceled transfer")); |
1867 oscar_file_transfer_disconnect(sess, oft->conn); | 1884 oscar_file_transfer_disconnect(sess, oft->conn); |
1868 } | 1885 } |
1879 debug_printf("unknown rendezvous status\n"); | 1896 debug_printf("unknown rendezvous status\n"); |
1880 return 1; | 1897 return 1; |
1881 } | 1898 } |
1882 | 1899 |
1883 if (args->reqclass & AIM_CAPS_CHAT) { | 1900 if (args->reqclass & AIM_CAPS_CHAT) { |
1884 char *name = extract_name(args->info.chat.roominfo.name); | 1901 char *name; |
1885 int *exch; | 1902 int *exch; |
1886 | 1903 GList *m = NULL; |
1887 if (!name) { | |
1888 /* Well, something weird must've happened here, let's run to church */ | |
1889 debug_printf("somebody tried to kick you in the balls.\n"); | |
1890 return 0; | |
1891 } | |
1892 | 1904 |
1905 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange || !args->msg) | |
1906 return 1; | |
1907 name = extract_name(args->info.chat.roominfo.name); | |
1893 exch = g_new0(int, 1); | 1908 exch = g_new0(int, 1); |
1894 GList *m = NULL; | |
1895 m = g_list_append(m, g_strdup(name ? name : args->info.chat.roominfo.name)); | 1909 m = g_list_append(m, g_strdup(name ? name : args->info.chat.roominfo.name)); |
1896 *exch = args->info.chat.roominfo.exchange; | 1910 *exch = args->info.chat.roominfo.exchange; |
1897 m = g_list_append(m, exch); | 1911 m = g_list_append(m, exch); |
1898 serv_got_chat_invite(gc, | 1912 serv_got_chat_invite(gc, |
1899 name ? name : args->info.chat.roominfo.name, | 1913 name ? name : args->info.chat.roominfo.name, |
1904 g_free(name); | 1918 g_free(name); |
1905 } else if (args->reqclass & AIM_CAPS_SENDFILE) { | 1919 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
1906 struct oscar_file_transfer *oft; | 1920 struct oscar_file_transfer *oft; |
1907 struct oscar_data *od = gc->proto_data; | 1921 struct oscar_data *od = gc->proto_data; |
1908 | 1922 |
1923 if (!args->cookie || !args->verifiedip || !args->port || | |
1924 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
1925 !args->info.sendfile.totfiles || !args->msg || !args->reqclass) | |
1926 return 1; | |
1909 if ((oft = find_oft_by_cookie(sess->aux_data, args->cookie))) | 1927 if ((oft = find_oft_by_cookie(sess->aux_data, args->cookie))) |
1910 { | 1928 { |
1911 /* This is a request for a reverse connection, | 1929 /* This is a request for a reverse connection, |
1912 * which is used by newer clients when for some | 1930 * which is used by newer clients when for some |
1913 * reason they are unable to connect to our listener | 1931 * reason they are unable to connect to our listener |
2047 struct gaim_connection *gc = sess->aux_data; | 2065 struct gaim_connection *gc = sess->aux_data; |
2048 gchar **msg1, **msg2; | 2066 gchar **msg1, **msg2; |
2049 GError *err = NULL; | 2067 GError *err = NULL; |
2050 int i; | 2068 int i; |
2051 | 2069 |
2070 if (!args->type || !args->msg || !args->uin) | |
2071 return 1; | |
2072 | |
2052 debug_printf("Received a channel 4 message of type %d.\n", args->type); | 2073 debug_printf("Received a channel 4 message of type %d.\n", args->type); |
2053 | 2074 |
2054 /* Split up the message at the delimeter character, then convert each string to UTF-8 */ | 2075 /* Split up the message at the delimeter character, then convert each string to UTF-8 */ |
2055 msg1 = g_strsplit(args->msg, "þ", 0); | 2076 msg1 = g_strsplit(args->msg, "þ", 0); |
2056 msg2 = (gchar **)g_malloc(10*sizeof(gchar *)); /* AAA */ | 2077 msg2 = (gchar **)g_malloc(10*sizeof(gchar *)); /* AAA */ |