| 1761 char *crypt = NULL; |
1761 char *crypt = NULL; |
| 1762 PurpleHttpCookieJar *cookiejar; |
1762 PurpleHttpCookieJar *cookiejar; |
| 1763 |
1763 |
| 1764 purple_debug_info("yahoo","Authentication: In yahoo_auth16_stage2\n"); |
1764 purple_debug_info("yahoo","Authentication: In yahoo_auth16_stage2\n"); |
| 1765 |
1765 |
| 1766 yd->http_reqs = g_slist_remove(yd->http_reqs, http_conn); |
|
| 1767 |
|
| 1768 if (!purple_http_response_is_successfull(response)) { |
1766 if (!purple_http_response_is_successfull(response)) { |
| 1769 const gchar *error_message = purple_http_response_get_error(response); |
1767 const gchar *error_message = purple_http_response_get_error(response); |
| 1770 purple_debug_error("yahoo", "Login Failed, unable to retrieve stage 2 url: %s\n", error_message); |
1768 purple_debug_error("yahoo", "Login Failed, unable to retrieve stage 2 url: %s\n", error_message); |
| 1771 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_message); |
1769 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_message); |
| 1772 g_free(auth_data->seed); |
1770 g_free(auth_data->seed); |
| 1859 struct yahoo_auth_data *auth_data = _auth_data; |
1857 struct yahoo_auth_data *auth_data = _auth_data; |
| 1860 PurpleConnection *gc = auth_data->gc; |
1858 PurpleConnection *gc = auth_data->gc; |
| 1861 YahooData *yd = purple_connection_get_protocol_data(gc); |
1859 YahooData *yd = purple_connection_get_protocol_data(gc); |
| 1862 |
1860 |
| 1863 purple_debug_info("yahoo","Authentication: In yahoo_auth16_stage1_cb\n"); |
1861 purple_debug_info("yahoo","Authentication: In yahoo_auth16_stage1_cb\n"); |
| 1864 |
|
| 1865 yd->http_reqs = g_slist_remove(yd->http_reqs, http_conn); |
|
| 1866 |
1862 |
| 1867 if (!purple_http_response_is_successfull(response)) { |
1863 if (!purple_http_response_is_successfull(response)) { |
| 1868 const gchar *error_message = purple_http_response_get_error(response); |
1864 const gchar *error_message = purple_http_response_get_error(response); |
| 1869 purple_debug_error("yahoo", "Login Failed, unable to retrieve login url: %s\n", error_message); |
1865 purple_debug_error("yahoo", "Login Failed, unable to retrieve login url: %s\n", error_message); |
| 1870 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_message); |
1866 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_message); |
| 1956 } |
1952 } |
| 1957 else { |
1953 else { |
| 1958 /* OK to login, correct information provided */ |
1954 /* OK to login, correct information provided */ |
| 1959 gboolean yahoojp = yahoo_is_japan(account); |
1955 gboolean yahoojp = yahoo_is_japan(account); |
| 1960 PurpleHttpRequest *req; |
1956 PurpleHttpRequest *req; |
| 1961 PurpleHttpConnection *hc; |
|
| 1962 |
1957 |
| 1963 req = purple_http_request_new(NULL); |
1958 req = purple_http_request_new(NULL); |
| 1964 purple_http_request_set_url_printf(req, |
1959 purple_http_request_set_url_printf(req, |
| 1965 yahoojp ? YAHOOJP_LOGIN_URL : YAHOO_LOGIN_URL, |
1960 yahoojp ? YAHOOJP_LOGIN_URL : YAHOO_LOGIN_URL, |
| 1966 token); |
1961 token); |
| 1967 purple_http_request_header_set(req, "User-Agent", |
1962 purple_http_request_header_set(req, "User-Agent", |
| 1968 YAHOO_CLIENT_USERAGENT); |
1963 YAHOO_CLIENT_USERAGENT); |
| 1969 hc = purple_http_request(gc, req, yahoo_auth16_stage2, |
1964 purple_http_connection_set_add(yd->http_reqs, |
| 1970 auth_data); |
1965 purple_http_request(gc, req, |
| |
1966 yahoo_auth16_stage2, auth_data)); |
| 1971 purple_http_request_unref(req); |
1967 purple_http_request_unref(req); |
| 1972 yd->http_reqs = g_slist_prepend(yd->http_reqs, hc); |
|
| 1973 |
1968 |
| 1974 g_free(token); |
1969 g_free(token); |
| 1975 } |
1970 } |
| 1976 } |
1971 } |
| 1977 } |
1972 } |
| 1979 static void yahoo_auth16_stage1(PurpleConnection *gc, const char *seed) |
1974 static void yahoo_auth16_stage1(PurpleConnection *gc, const char *seed) |
| 1980 { |
1975 { |
| 1981 YahooData *yd = purple_connection_get_protocol_data(gc); |
1976 YahooData *yd = purple_connection_get_protocol_data(gc); |
| 1982 PurpleAccount *account = purple_connection_get_account(gc); |
1977 PurpleAccount *account = purple_connection_get_account(gc); |
| 1983 PurpleHttpRequest *req; |
1978 PurpleHttpRequest *req; |
| 1984 PurpleHttpConnection *hc; |
|
| 1985 struct yahoo_auth_data *auth_data = NULL; |
1979 struct yahoo_auth_data *auth_data = NULL; |
| 1986 char *encoded_username; |
1980 char *encoded_username; |
| 1987 char *encoded_password; |
1981 char *encoded_password; |
| 1988 gboolean yahoojp = yahoo_is_japan(account); |
1982 gboolean yahoojp = yahoo_is_japan(account); |
| 1989 |
1983 |
| 2004 req = purple_http_request_new(NULL); |
1998 req = purple_http_request_new(NULL); |
| 2005 purple_http_request_set_url_printf(req, |
1999 purple_http_request_set_url_printf(req, |
| 2006 yahoojp ? YAHOOJP_TOKEN_URL : YAHOO_TOKEN_URL, |
2000 yahoojp ? YAHOOJP_TOKEN_URL : YAHOO_TOKEN_URL, |
| 2007 encoded_username, encoded_password, purple_url_encode(seed)); |
2001 encoded_username, encoded_password, purple_url_encode(seed)); |
| 2008 purple_http_request_header_set(req, "User-Agent", YAHOO_CLIENT_USERAGENT); |
2002 purple_http_request_header_set(req, "User-Agent", YAHOO_CLIENT_USERAGENT); |
| 2009 hc = purple_http_request(gc, req, yahoo_auth16_stage1_cb, auth_data); |
2003 purple_http_connection_set_add(yd->http_reqs, purple_http_request(gc, |
| |
2004 req, yahoo_auth16_stage1_cb, auth_data)); |
| 2010 purple_http_request_unref(req); |
2005 purple_http_request_unref(req); |
| 2011 yd->http_reqs = g_slist_prepend(yd->http_reqs, hc); |
|
| 2012 |
2006 |
| 2013 purple_str_wipe(encoded_password); |
2007 purple_str_wipe(encoded_password); |
| 2014 g_free(encoded_username); |
2008 g_free(encoded_username); |
| 2015 } |
2009 } |
| 2016 |
2010 |
| 3563 gchar **strings = NULL, *cs_server = NULL; |
3557 gchar **strings = NULL, *cs_server = NULL; |
| 3564 int port = purple_account_get_int(a, "port", YAHOO_PAGER_PORT); |
3558 int port = purple_account_get_int(a, "port", YAHOO_PAGER_PORT); |
| 3565 int stringslen = 0; |
3559 int stringslen = 0; |
| 3566 const gchar *got_data; |
3560 const gchar *got_data; |
| 3567 |
3561 |
| 3568 yd->http_reqs = g_slist_remove(yd->http_reqs, http_conn); |
|
| 3569 |
|
| 3570 if (!purple_http_response_is_successfull(response)) { |
3562 if (!purple_http_response_is_successfull(response)) { |
| 3571 purple_debug_error("yahoo", "Unable to retrieve server info: %s\n", |
3563 purple_debug_error("yahoo", "Unable to retrieve server info: %s\n", |
| 3572 purple_http_response_get_error(response)); |
3564 purple_http_response_get_error(response)); |
| 3573 |
3565 |
| 3574 if(yahoo_is_japan(a)) { /* We don't know fallback hosts for Yahoo Japan :( */ |
3566 if(yahoo_is_japan(a)) { /* We don't know fallback hosts for Yahoo Japan :( */ |
| 3624 } |
3616 } |
| 3625 |
3617 |
| 3626 void yahoo_login(PurpleAccount *account) { |
3618 void yahoo_login(PurpleAccount *account) { |
| 3627 PurpleConnection *gc = purple_account_get_connection(account); |
3619 PurpleConnection *gc = purple_account_get_connection(account); |
| 3628 PurpleHttpRequest *req; |
3620 PurpleHttpRequest *req; |
| 3629 PurpleHttpConnection *hc; |
|
| 3630 YahooData *yd = g_new0(YahooData, 1); |
3621 YahooData *yd = g_new0(YahooData, 1); |
| 3631 PurpleStatus *status = purple_account_get_active_status(account); |
3622 PurpleStatus *status = purple_account_get_active_status(account); |
| 3632 |
3623 |
| 3633 purple_connection_set_protocol_data(gc, yd); |
3624 purple_connection_set_protocol_data(gc, yd); |
| 3634 purple_connection_set_flags(gc, PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_BGCOLOR | PURPLE_CONNECTION_NO_URLDESC); |
3625 purple_connection_set_flags(gc, PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_BGCOLOR | PURPLE_CONNECTION_NO_URLDESC); |
| 3642 yd->yahoo_local_p2p_server_fd = -1; |
3633 yd->yahoo_local_p2p_server_fd = -1; |
| 3643 yd->fd = -1; |
3634 yd->fd = -1; |
| 3644 yd->txhandler = 0; |
3635 yd->txhandler = 0; |
| 3645 /* TODO: Is there a good grow size for the buffer? */ |
3636 /* TODO: Is there a good grow size for the buffer? */ |
| 3646 yd->txbuf = purple_circ_buffer_new(0); |
3637 yd->txbuf = purple_circ_buffer_new(0); |
| |
3638 yd->http_reqs = purple_http_connection_set_new(); |
| 3647 yd->friends = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, yahoo_friend_free); |
3639 yd->friends = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, yahoo_friend_free); |
| 3648 yd->imvironments = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
3640 yd->imvironments = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
| 3649 yd->xfer_peer_idstring_map = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL); |
3641 yd->xfer_peer_idstring_map = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL); |
| 3650 yd->peers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
3642 yd->peers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
| 3651 yahoo_p2p_disconnect_destroy_data); |
3643 yahoo_p2p_disconnect_destroy_data); |
| 3663 /* Get the pager server. Actually start connecting in the callback since we |
3655 /* Get the pager server. Actually start connecting in the callback since we |
| 3664 * must have the contents of the HTTP response to proceed. */ |
3656 * must have the contents of the HTTP response to proceed. */ |
| 3665 req = purple_http_request_new(yd->jp ? YAHOOJP_PAGER_HOST_REQ_URL : |
3657 req = purple_http_request_new(yd->jp ? YAHOOJP_PAGER_HOST_REQ_URL : |
| 3666 YAHOO_PAGER_HOST_REQ_URL); |
3658 YAHOO_PAGER_HOST_REQ_URL); |
| 3667 purple_http_request_header_set(req, "User-Agent", YAHOO_CLIENT_USERAGENT); |
3659 purple_http_request_header_set(req, "User-Agent", YAHOO_CLIENT_USERAGENT); |
| 3668 hc = purple_http_request(gc, req, yahoo_got_pager_server, yd); |
3660 purple_http_connection_set_add(yd->http_reqs, purple_http_request(gc, |
| |
3661 req, yahoo_got_pager_server, yd)); |
| 3669 purple_http_request_unref(req); |
3662 purple_http_request_unref(req); |
| 3670 yd->http_reqs = g_slist_prepend(yd->http_reqs, hc); |
|
| 3671 |
3663 |
| 3672 return; |
3664 return; |
| 3673 } |
3665 } |
| 3674 |
3666 |
| 3675 void yahoo_close(PurpleConnection *gc) { |
3667 void yahoo_close(PurpleConnection *gc) { |
| 3679 if (yd->inpa) { |
3671 if (yd->inpa) { |
| 3680 purple_input_remove(yd->inpa); |
3672 purple_input_remove(yd->inpa); |
| 3681 yd->inpa = 0; |
3673 yd->inpa = 0; |
| 3682 } |
3674 } |
| 3683 |
3675 |
| 3684 while (yd->http_reqs) { |
3676 purple_http_connection_set_destroy(yd->http_reqs); |
| 3685 purple_http_conn_cancel(yd->http_reqs->data); |
3677 yd->http_reqs = NULL; |
| 3686 yd->http_reqs = g_slist_delete_link(yd->http_reqs, yd->http_reqs); |
|
| 3687 } |
|
| 3688 |
3678 |
| 3689 for (l = yd->confs; l; l = l->next) { |
3679 for (l = yd->confs; l; l = l->next) { |
| 3690 PurpleConversation *conv = l->data; |
3680 PurpleConversation *conv = l->data; |
| 3691 |
3681 |
| 3692 yahoo_conf_leave(yd, purple_conversation_get_name(conv), |
3682 yahoo_conf_leave(yd, purple_conversation_get_name(conv), |
| 4197 gchar *url; |
4187 gchar *url; |
| 4198 YahooData *yd = purple_connection_get_protocol_data(gc); |
4188 YahooData *yd = purple_connection_get_protocol_data(gc); |
| 4199 |
4189 |
| 4200 g_return_if_fail(PURPLE_CONNECTION_IS_VALID(gc)); |
4190 g_return_if_fail(PURPLE_CONNECTION_IS_VALID(gc)); |
| 4201 |
4191 |
| 4202 yd->http_reqs = g_slist_remove(yd->http_reqs, http_conn); |
|
| 4203 |
|
| 4204 if (!purple_http_response_is_successfull(response)) { |
4192 if (!purple_http_response_is_successfull(response)) { |
| 4205 purple_debug_error("yahoo", |
4193 purple_debug_error("yahoo", |
| 4206 "Requesting mail login token failed: %s\n", |
4194 "Requesting mail login token failed: %s\n", |
| 4207 purple_http_response_get_error(response)); |
4195 purple_http_response_get_error(response)); |
| 4208 url = g_strdup(yd->jp ? YAHOOJP_MAIL_URL : YAHOO_MAIL_URL); |
4196 url = g_strdup(yd->jp ? YAHOOJP_MAIL_URL : YAHOO_MAIL_URL); |
| 4233 |
4221 |
| 4234 PurpleConnection *gc = action->context; |
4222 PurpleConnection *gc = action->context; |
| 4235 YahooData *yd = purple_connection_get_protocol_data(gc); |
4223 YahooData *yd = purple_connection_get_protocol_data(gc); |
| 4236 PurpleHttpRequest *req; |
4224 PurpleHttpRequest *req; |
| 4237 PurpleHttpCookieJar *cookiejar; |
4225 PurpleHttpCookieJar *cookiejar; |
| 4238 PurpleHttpConnection *hc; |
|
| 4239 |
4226 |
| 4240 req = purple_http_request_new( |
4227 req = purple_http_request_new( |
| 4241 "https://login.yahoo.com/config/cookie_token"); |
4228 "https://login.yahoo.com/config/cookie_token"); |
| 4242 purple_http_request_set_method(req, "POST"); |
4229 purple_http_request_set_method(req, "POST"); |
| 4243 purple_http_request_header_set(req, "User-Agent", |
4230 purple_http_request_header_set(req, "User-Agent", |
| 4244 YAHOO_CLIENT_USERAGENT); |
4231 YAHOO_CLIENT_USERAGENT); |
| 4245 cookiejar = purple_http_request_get_cookie_jar(req); |
4232 cookiejar = purple_http_request_get_cookie_jar(req); |
| 4246 purple_http_cookie_jar_set(cookiejar, "T", yd->cookie_t); |
4233 purple_http_cookie_jar_set(cookiejar, "T", yd->cookie_t); |
| 4247 purple_http_cookie_jar_set(cookiejar, "Y", yd->cookie_y); |
4234 purple_http_cookie_jar_set(cookiejar, "Y", yd->cookie_y); |
| 4248 hc = purple_http_request(gc, req, yahoo_get_inbox_token_cb, NULL); |
4235 purple_http_connection_set_add(yd->http_reqs, purple_http_request(gc, |
| |
4236 req, yahoo_get_inbox_token_cb, NULL)); |
| 4249 purple_http_request_unref(req); |
4237 purple_http_request_unref(req); |
| 4250 |
|
| 4251 yd->http_reqs = g_slist_prepend(yd->http_reqs, hc); |
|
| 4252 } |
4238 } |
| 4253 |
4239 |
| 4254 #if 0 |
4240 #if 0 |
| 4255 /* XXX: it doesn't seems to work */ |
4241 /* XXX: it doesn't seems to work */ |
| 4256 static void |
4242 static void |
| 4342 YahooData *yd = purple_connection_get_protocol_data(gc); |
4328 YahooData *yd = purple_connection_get_protocol_data(gc); |
| 4343 char *status = NULL; |
4329 char *status = NULL; |
| 4344 char *carrier = NULL; |
4330 char *carrier = NULL; |
| 4345 PurpleAccount *account = purple_connection_get_account(gc); |
4331 PurpleAccount *account = purple_connection_get_account(gc); |
| 4346 PurpleConversation *conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, sms_cb_data->who, account); |
4332 PurpleConversation *conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, sms_cb_data->who, account); |
| 4347 |
|
| 4348 yd->http_reqs = g_slist_remove(yd->http_reqs, http_conn); |
|
| 4349 |
4333 |
| 4350 if (!purple_http_response_is_successfull(response)) { |
4334 if (!purple_http_response_is_successfull(response)) { |
| 4351 purple_conversation_write(conv, NULL, _("Can't send SMS. Unable to obtain mobile carrier."), PURPLE_MESSAGE_SYSTEM, time(NULL)); |
4335 purple_conversation_write(conv, NULL, _("Can't send SMS. Unable to obtain mobile carrier."), PURPLE_MESSAGE_SYSTEM, time(NULL)); |
| 4352 |
4336 |
| 4353 g_free(sms_cb_data->who); |
4337 g_free(sms_cb_data->who); |
| 4395 static void yahoo_get_sms_carrier(PurpleConnection *gc, gpointer data) |
4379 static void yahoo_get_sms_carrier(PurpleConnection *gc, gpointer data) |
| 4396 { |
4380 { |
| 4397 YahooData *yd = purple_connection_get_protocol_data(gc); |
4381 YahooData *yd = purple_connection_get_protocol_data(gc); |
| 4398 PurpleHttpRequest *req; |
4382 PurpleHttpRequest *req; |
| 4399 PurpleHttpCookieJar *cookiejar; |
4383 PurpleHttpCookieJar *cookiejar; |
| 4400 PurpleHttpConnection *hc; |
|
| 4401 struct yahoo_sms_carrier_cb_data *sms_cb_data; |
4384 struct yahoo_sms_carrier_cb_data *sms_cb_data; |
| 4402 char *validate_request_str = NULL; |
4385 char *validate_request_str = NULL; |
| 4403 xmlnode *validate_request_root = NULL; |
4386 xmlnode *validate_request_root = NULL; |
| 4404 xmlnode *validate_request_child = NULL; |
4387 xmlnode *validate_request_child = NULL; |
| 4405 |
4388 |
| 4427 YAHOO_CLIENT_USERAGENT); |
4410 YAHOO_CLIENT_USERAGENT); |
| 4428 cookiejar = purple_http_request_get_cookie_jar(req); |
4411 cookiejar = purple_http_request_get_cookie_jar(req); |
| 4429 purple_http_cookie_jar_set(cookiejar, "T", yd->cookie_t); |
4412 purple_http_cookie_jar_set(cookiejar, "T", yd->cookie_t); |
| 4430 purple_http_cookie_jar_set(cookiejar, "Y", yd->cookie_y); |
4413 purple_http_cookie_jar_set(cookiejar, "Y", yd->cookie_y); |
| 4431 purple_http_request_set_contents(req, validate_request_str, -1); |
4414 purple_http_request_set_contents(req, validate_request_str, -1); |
| 4432 hc = purple_http_request(gc, req, yahoo_get_sms_carrier_cb, data); |
4415 purple_http_connection_set_add(yd->http_reqs, purple_http_request(gc, |
| |
4416 req, yahoo_get_sms_carrier_cb, data)); |
| 4433 purple_http_request_unref(req); |
4417 purple_http_request_unref(req); |
| 4434 |
|
| 4435 yd->http_reqs = g_slist_prepend(yd->http_reqs, hc); |
|
| 4436 |
4418 |
| 4437 g_free(validate_request_str); |
4419 g_free(validate_request_str); |
| 4438 } |
4420 } |
| 4439 |
4421 |
| 4440 int yahoo_send_im(PurpleConnection *gc, const char *who, const char *what, PurpleMessageFlags flags) |
4422 int yahoo_send_im(PurpleConnection *gc, const char *who, const char *what, PurpleMessageFlags flags) |