comparison src/protocols/yahoo/yahoo.c @ 8045:cd3a2cef5112

[gaim-migrate @ 8729] Yahoo works. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Sat, 10 Jan 2004 03:26:09 +0000
parents 802e341aa8c7
children fa6395637e2c
comparison
equal deleted inserted replaced
8044:34b086e2619d 8045:cd3a2cef5112
1848 close(source); 1848 close(source);
1849 return; 1849 return;
1850 } 1850 }
1851 1851
1852 if (source < 0) { 1852 if (source < 0) {
1853 gaim_connection_error(gc, _("Unable to connect.")); 1853 gaim_connection_error(gc, _("Unable to connect"));
1854 return; 1854 return;
1855 } 1855 }
1856 1856
1857 yd = gc->proto_data; 1857 yd = gc->proto_data;
1858 yd->fd = source; 1858 yd->fd = source;
1879 close(source); 1879 close(source);
1880 return; 1880 return;
1881 } 1881 }
1882 1882
1883 if (source < 0) { 1883 if (source < 0) {
1884 gaim_connection_error(gc, _("Unable to connect.")); 1884 gaim_connection_error(gc, _("Unable to connect"));
1885 return; 1885 return;
1886 } 1886 }
1887 1887
1888 yd = gc->proto_data; 1888 yd = gc->proto_data;
1889 yd->fd = source; 1889 yd->fd = source;
1907 struct yahoo_data *yd = gc->proto_data; 1907 struct yahoo_data *yd = gc->proto_data;
1908 char buf[1024], buf2[256], *i = buf, *r = buf2; 1908 char buf[1024], buf2[256], *i = buf, *r = buf2;
1909 int len, o = 0; 1909 int len, o = 0;
1910 1910
1911 len = read(source, buf, sizeof(buf)); 1911 len = read(source, buf, sizeof(buf));
1912
1913 if (len <= 0 || strncmp(buf, "HTTP/1.0 302", strlen("HTTP/1.0 302"))) { 1912 if (len <= 0 || strncmp(buf, "HTTP/1.0 302", strlen("HTTP/1.0 302"))) {
1914 gaim_connection_error(gc, _("Unable to read")); 1913 gaim_connection_error(gc, _("Unable to read"));
1915 return; 1914 return;
1916 } 1915 }
1917 1916
1929 /* Get rid of that "; " */ 1928 /* Get rid of that "; " */
1930 *(r-2) = '\0'; 1929 *(r-2) = '\0';
1931 yd->auth = g_strdup(buf2); 1930 yd->auth = g_strdup(buf2);
1932 gaim_input_remove(gc->inpa); 1931 gaim_input_remove(gc->inpa);
1933 close(source); 1932 close(source);
1934
1935 /* Now we have our cookies to login with. I'll go get the milk. */ 1933 /* Now we have our cookies to login with. I'll go get the milk. */
1936 if (gaim_proxy_connect(account, "wcs1.msg.sc5.yahoo.com", 1934 if (gaim_proxy_connect(account, "wcs2.msg.dcn.yahoo.com",
1937 gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), 1935 gaim_account_get_int(account, "port", YAHOO_PAGER_PORT),
1938 yahoo_got_web_connected, gc) != 0) { 1936 yahoo_got_web_connected, gc) != 0) {
1939 gaim_connection_error(gc, _("Connection problem")); 1937 gaim_connection_error(gc, _("Connection problem"));
1940 return; 1938 return;
1941 } 1939 }
1944 static void yahoo_got_cookies(gpointer data, gint source, GaimInputCondition cond) 1942 static void yahoo_got_cookies(gpointer data, gint source, GaimInputCondition cond)
1945 { 1943 {
1946 GaimConnection *gc = data; 1944 GaimConnection *gc = data;
1947 struct yahoo_data *yd = gc->proto_data; 1945 struct yahoo_data *yd = gc->proto_data;
1948 if (source < 0) { 1946 if (source < 0) {
1949 gaim_connection_error(gc, _("Unable to connect.")); 1947 gaim_connection_error(gc, _("Unable to connect"));
1950 return; 1948 return;
1951 } 1949 }
1952 write(source, yd->auth, strlen(yd->auth)); 1950 write(source, yd->auth, strlen(yd->auth));
1953 g_free(yd->auth); 1951 g_free(yd->auth);
1954 gc->inpa = gaim_input_add(source, GAIM_INPUT_READ, yahoo_web_pending, gc); 1952 gc->inpa = gaim_input_add(source, GAIM_INPUT_READ, yahoo_web_pending, gc);
2040 g_hash_table_foreach(hash, (GHFunc)yahoo_login_page_hash_iter, url); 2038 g_hash_table_foreach(hash, (GHFunc)yahoo_login_page_hash_iter, url);
2041 2039
2042 url = g_string_append(url, "&.hash=1&.md5=1 HTTP/1.1\r\n" 2040 url = g_string_append(url, "&.hash=1&.md5=1 HTTP/1.1\r\n"
2043 "Host: login.yahoo.com\r\n\r\n"); 2041 "Host: login.yahoo.com\r\n\r\n");
2044 g_hash_table_destroy(hash); 2042 g_hash_table_destroy(hash);
2045
2046 yd->auth = g_string_free(url, FALSE); 2043 yd->auth = g_string_free(url, FALSE);
2047 if (gaim_proxy_connect(account, "login.yahoo.com", 80, yahoo_got_cookies, gc) != 0) { 2044 if (gaim_proxy_connect(account, "login.yahoo.com", 80, yahoo_got_cookies, gc) != 0) {
2048 gaim_connection_error(gc, _("Connection problem")); 2045 gaim_connection_error(gc, _("Connection problem"));
2049 return; 2046 return;
2050 } 2047 }
2703 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; 2700 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
2704 struct yahoo_packet *pkt; 2701 struct yahoo_packet *pkt;
2705 2702
2706 if (!yd->logged_in) 2703 if (!yd->logged_in)
2707 return; 2704 return;
2708 2705
2709 /* It seems to work better without this */ 2706 if (gc->account->perm_deny != 4)
2710 /* if (gc->account->perm_deny != 4) */ 2707 return;
2711 /* return; */
2712 2708
2713 if (!who || who[0] == '\0') 2709 if (!who || who[0] == '\0')
2714 return; 2710 return;
2715 2711
2716 pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, 0); 2712 pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, 0);