comparison libpurple/protocols/yahoo/libymsg.c @ 30383:2a19f7385ba5

merged from im.pidgin.pidgin
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Tue, 18 May 2010 02:29:24 +0900
parents bd0ce3844104 04c84a3f9553
children 81ffeb069847
comparison
equal deleted inserted replaced
30361:46275cca345e 30383:2a19f7385ba5
1791 1791
1792 g_strfreev(splits); 1792 g_strfreev(splits);
1793 return tmp2; 1793 return tmp2;
1794 } 1794 }
1795 1795
1796 static void yahoo_auth16_stage2(PurpleUtilFetchUrlData *unused, gpointer user_data, const gchar *ret_data, size_t len, const gchar *error_message) 1796 static void yahoo_auth16_stage2(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *ret_data, size_t len, const gchar *error_message)
1797 { 1797 {
1798 struct yahoo_auth_data *auth_data = user_data; 1798 struct yahoo_auth_data *auth_data = user_data;
1799 PurpleConnection *gc = auth_data->gc; 1799 PurpleConnection *gc = auth_data->gc;
1800 YahooData *yd; 1800 YahooData *yd = purple_connection_get_protocol_data(gc);
1801 gboolean try_login_on_error = FALSE; 1801 gboolean try_login_on_error = FALSE;
1802 1802
1803 purple_debug_info("yahoo","Authentication: In yahoo_auth16_stage2\n"); 1803 purple_debug_info("yahoo","Authentication: In yahoo_auth16_stage2\n");
1804 1804
1805 if (!PURPLE_CONNECTION_IS_VALID(gc)) { 1805 yd->url_datas = g_slist_remove(yd->url_datas, url_data);
1806 g_free(auth_data->seed); 1806
1807 g_free(auth_data);
1808 g_return_if_reached();
1809 }
1810
1811 yd = (YahooData *)gc->proto_data;
1812
1813 if (error_message != NULL) { 1807 if (error_message != NULL) {
1814 purple_debug_error("yahoo", "Login Failed, unable to retrieve stage 2 url: %s\n", error_message); 1808 purple_debug_error("yahoo", "Login Failed, unable to retrieve stage 2 url: %s\n", error_message);
1815 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_message); 1809 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_message);
1816 g_free(auth_data->seed); 1810 g_free(auth_data->seed);
1817 g_free(auth_data); 1811 g_free(auth_data);
1914 } 1908 }
1915 g_free(auth_data->seed); 1909 g_free(auth_data->seed);
1916 g_free(auth_data); 1910 g_free(auth_data);
1917 } 1911 }
1918 1912
1919 static void yahoo_auth16_stage1_cb(PurpleUtilFetchUrlData *unused, gpointer user_data, const gchar *ret_data, size_t len, const gchar *error_message) 1913 static void yahoo_auth16_stage1_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *ret_data, size_t len, const gchar *error_message)
1920 { 1914 {
1921 struct yahoo_auth_data *auth_data = user_data; 1915 struct yahoo_auth_data *auth_data = user_data;
1922 PurpleConnection *gc = auth_data->gc; 1916 PurpleConnection *gc = auth_data->gc;
1917 YahooData *yd = purple_connection_get_protocol_data(gc);
1923 1918
1924 purple_debug_info("yahoo","Authentication: In yahoo_auth16_stage1_cb\n"); 1919 purple_debug_info("yahoo","Authentication: In yahoo_auth16_stage1_cb\n");
1925 1920
1926 if (!PURPLE_CONNECTION_IS_VALID(gc)) { 1921 yd->url_datas = g_slist_remove(yd->url_datas, url_data);
1927 g_free(auth_data->seed);
1928 g_free(auth_data);
1929 g_return_if_reached();
1930 }
1931 1922
1932 if (error_message != NULL) { 1923 if (error_message != NULL) {
1933 purple_debug_error("yahoo", "Login Failed, unable to retrieve login url: %s\n", error_message); 1924 purple_debug_error("yahoo", "Login Failed, unable to retrieve login url: %s\n", error_message);
1934 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_message); 1925 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_message);
1935 g_free(auth_data->seed); 1926 g_free(auth_data->seed);
2027 2018
2028 url = g_strdup_printf(yahoojp ? YAHOOJP_LOGIN_URL : YAHOO_LOGIN_URL, token); 2019 url = g_strdup_printf(yahoojp ? YAHOOJP_LOGIN_URL : YAHOO_LOGIN_URL, token);
2029 url_data = purple_util_fetch_url_request_len_with_account( 2020 url_data = purple_util_fetch_url_request_len_with_account(
2030 proxy_ssl ? account : NULL, url, TRUE, YAHOO_CLIENT_USERAGENT, 2021 proxy_ssl ? account : NULL, url, TRUE, YAHOO_CLIENT_USERAGENT,
2031 TRUE, NULL, TRUE, -1, yahoo_auth16_stage2, auth_data); 2022 TRUE, NULL, TRUE, -1, yahoo_auth16_stage2, auth_data);
2023 if (url_data)
2024 yd->url_datas = g_slist_prepend(yd->url_datas, url_data);
2032 g_free(url); 2025 g_free(url);
2033 g_free(token); 2026 g_free(token);
2034 } 2027 }
2035 } 2028 }
2036 } 2029 }
2037 2030
2038 static void yahoo_auth16_stage1(PurpleConnection *gc, const char *seed) 2031 static void yahoo_auth16_stage1(PurpleConnection *gc, const char *seed)
2039 { 2032 {
2033 YahooData *yd = purple_connection_get_protocol_data(gc);
2040 PurpleAccount *account = purple_connection_get_account(gc); 2034 PurpleAccount *account = purple_connection_get_account(gc);
2041 PurpleUtilFetchUrlData *url_data = NULL; 2035 PurpleUtilFetchUrlData *url_data = NULL;
2042 struct yahoo_auth_data *auth_data = NULL; 2036 struct yahoo_auth_data *auth_data = NULL;
2043 char *url = NULL; 2037 char *url = NULL;
2044 char *encoded_username; 2038 char *encoded_username;
2066 2060
2067 url_data = purple_util_fetch_url_request_len_with_account( 2061 url_data = purple_util_fetch_url_request_len_with_account(
2068 proxy_ssl ? account : NULL, url, TRUE, 2062 proxy_ssl ? account : NULL, url, TRUE,
2069 YAHOO_CLIENT_USERAGENT, TRUE, NULL, FALSE, -1, 2063 YAHOO_CLIENT_USERAGENT, TRUE, NULL, FALSE, -1,
2070 yahoo_auth16_stage1_cb, auth_data); 2064 yahoo_auth16_stage1_cb, auth_data);
2065 if (url_data)
2066 yd->url_datas = g_slist_prepend(yd->url_datas, url_data);
2071 2067
2072 g_free(url); 2068 g_free(url);
2073 } 2069 }
2074 2070
2075 static void yahoo_process_auth(PurpleConnection *gc, struct yahoo_packet *pkt) 2071 static void yahoo_process_auth(PurpleConnection *gc, struct yahoo_packet *pkt)
3604 PurpleConnection *gc = yd->gc; 3600 PurpleConnection *gc = yd->gc;
3605 PurpleAccount *a = purple_connection_get_account(gc); 3601 PurpleAccount *a = purple_connection_get_account(gc);
3606 gchar **strings = NULL, *cs_server = NULL; 3602 gchar **strings = NULL, *cs_server = NULL;
3607 int port = 0, stringslen = 0; 3603 int port = 0, stringslen = 0;
3608 3604
3605 yd->url_datas = g_slist_remove(yd->url_datas, url_data);
3606
3609 if(error_message != NULL || len == 0) { 3607 if(error_message != NULL || len == 0) {
3610 purple_debug_error("yahoo", "Unable to retrieve server info. %" 3608 purple_debug_error("yahoo", "Unable to retrieve server info. %"
3611 G_GSIZE_FORMAT " bytes retrieved with error message: %s\n", len, 3609 G_GSIZE_FORMAT " bytes retrieved with error message: %s\n", len,
3612 error_message ? error_message : "(null)"); 3610 error_message ? error_message : "(null)");
3613 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 3611 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
3650 void yahoo_login(PurpleAccount *account) { 3648 void yahoo_login(PurpleAccount *account) {
3651 PurpleConnection *gc = purple_account_get_connection(account); 3649 PurpleConnection *gc = purple_account_get_connection(account);
3652 YahooData *yd = gc->proto_data = g_new0(YahooData, 1); 3650 YahooData *yd = gc->proto_data = g_new0(YahooData, 1);
3653 PurpleStatus *status = purple_account_get_active_status(account); 3651 PurpleStatus *status = purple_account_get_active_status(account);
3654 gboolean use_whole_url = yahoo_account_use_http_proxy(gc); 3652 gboolean use_whole_url = yahoo_account_use_http_proxy(gc);
3653 PurpleUtilFetchUrlData *url_data;
3655 3654
3656 gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_BGCOLOR | PURPLE_CONNECTION_NO_URLDESC; 3655 gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_BGCOLOR | PURPLE_CONNECTION_NO_URLDESC;
3657 3656
3658 purple_connection_update_progress(gc, _("Connecting"), 1, 2); 3657 purple_connection_update_progress(gc, _("Connecting"), 1, 2);
3659 3658
3682 3681
3683 yahoo_picture_check(account); 3682 yahoo_picture_check(account);
3684 3683
3685 /* Get the pager server. Actually start connecting in the callback since we 3684 /* Get the pager server. Actually start connecting in the callback since we
3686 * must have the contents of the HTTP response to proceed. */ 3685 * must have the contents of the HTTP response to proceed. */
3687 purple_util_fetch_url_request_len_with_account( 3686 url_data = purple_util_fetch_url_request_len_with_account(
3688 purple_connection_get_account(gc), 3687 purple_connection_get_account(gc),
3689 yd->jp ? YAHOOJP_PAGER_HOST_REQ_URL : YAHOO_PAGER_HOST_REQ_URL, 3688 yd->jp ? YAHOOJP_PAGER_HOST_REQ_URL : YAHOO_PAGER_HOST_REQ_URL,
3690 use_whole_url ? TRUE : FALSE, 3689 use_whole_url ? TRUE : FALSE,
3691 YAHOO_CLIENT_USERAGENT, TRUE, NULL, FALSE, -1, 3690 YAHOO_CLIENT_USERAGENT, TRUE, NULL, FALSE, -1,
3692 yahoo_got_pager_server, yd); 3691 yahoo_got_pager_server, yd);
3692 if (url_data)
3693 yd->url_datas = g_slist_prepend(yd->url_datas, url_data);
3693 3694
3694 return; 3695 return;
3695 } 3696 }
3696 3697
3697 void yahoo_close(PurpleConnection *gc) { 3698 void yahoo_close(PurpleConnection *gc) {
4377 char *status = NULL; 4378 char *status = NULL;
4378 char *carrier = NULL; 4379 char *carrier = NULL;
4379 PurpleAccount *account = purple_connection_get_account(gc); 4380 PurpleAccount *account = purple_connection_get_account(gc);
4380 PurpleConversation *conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, sms_cb_data->who, account); 4381 PurpleConversation *conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, sms_cb_data->who, account);
4381 4382
4383 yd->url_datas = g_slist_remove(yd->url_datas, url_data);
4384
4382 if (error_message != NULL) { 4385 if (error_message != NULL) {
4383 purple_conversation_write(conv, NULL, _("Can't send SMS. Unable to obtain mobile carrier."), PURPLE_MESSAGE_SYSTEM, time(NULL)); 4386 purple_conversation_write(conv, NULL, _("Can't send SMS. Unable to obtain mobile carrier."), PURPLE_MESSAGE_SYSTEM, time(NULL));
4384 4387
4385 g_free(sms_cb_data->who); 4388 g_free(sms_cb_data->who);
4386 g_free(sms_cb_data->what); 4389 g_free(sms_cb_data->what);
4470 yahoo_get_sms_carrier_cb, data); 4473 yahoo_get_sms_carrier_cb, data);
4471 4474
4472 g_free(request); 4475 g_free(request);
4473 g_free(validate_request_str); 4476 g_free(validate_request_str);
4474 4477
4475 if (!url_data) { 4478 if (url_data)
4479 yd->url_datas = g_slist_prepend(yd->url_datas, url_data);
4480 else {
4476 PurpleAccount *account = purple_connection_get_account(gc); 4481 PurpleAccount *account = purple_connection_get_account(gc);
4477 PurpleConversation *conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, sms_cb_data->who, account); 4482 PurpleConversation *conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, sms_cb_data->who, account);
4478 purple_conversation_write(conv, NULL, _("Can't send SMS. Unable to obtain mobile carrier."), PURPLE_MESSAGE_SYSTEM, time(NULL)); 4483 purple_conversation_write(conv, NULL, _("Can't send SMS. Unable to obtain mobile carrier."), PURPLE_MESSAGE_SYSTEM, time(NULL));
4479 g_free(sms_cb_data->who); 4484 g_free(sms_cb_data->who);
4480 g_free(sms_cb_data->what); 4485 g_free(sms_cb_data->what);