comparison libpurple/protocols/yahoo/libymsg.c @ 27464:09772222714a

merge of '599603c54f97d6978ff312a4ff140857302b0033' and '85d6ddccd30dc452a4afcd6adc18d9369901b646'
author Mark Doliner <mark@kingant.net>
date Mon, 06 Jul 2009 09:08:17 +0000
parents 430eb9e9042a
children d46ab8c52cc4 85fa979b08c2 42360009f2e5
comparison
equal deleted inserted replaced
27450:c374d57b3215 27464:09772222714a
157 157
158 if (pkt->service == YAHOO_SERVICE_LOGOFF && pkt->status == -1) { 158 if (pkt->service == YAHOO_SERVICE_LOGOFF && pkt->status == -1) {
159 if (!purple_account_get_remember_password(account)) 159 if (!purple_account_get_remember_password(account))
160 purple_account_set_password(account, NULL); 160 purple_account_set_password(account, NULL);
161 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NAME_IN_USE, 161 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NAME_IN_USE,
162 _("You have signed on from another location.")); 162 _("You have signed on from another location"));
163 return; 163 return;
164 } 164 }
165 165
166 while (l) { 166 while (l) {
167 struct yahoo_pair *pair = l->data; 167 struct yahoo_pair *pair = l->data;
1794 case 1212: 1794 case 1212:
1795 /* Password incorrect */ 1795 /* Password incorrect */
1796 /* Set password to NULL. Avoids account locking. Brings dialog to enter password if clicked on Re-enable account */ 1796 /* Set password to NULL. Avoids account locking. Brings dialog to enter password if clicked on Re-enable account */
1797 if (!purple_account_get_remember_password(purple_connection_get_account(gc))) 1797 if (!purple_account_get_remember_password(purple_connection_get_account(gc)))
1798 purple_account_set_password(purple_connection_get_account(gc), NULL); 1798 purple_account_set_password(purple_connection_get_account(gc), NULL);
1799 error_reason = g_strdup(_("Incorrect Password")); 1799 error_reason = g_strdup(_("Incorrect password"));
1800 error = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED; 1800 error = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED;
1801 break; 1801 break;
1802 case 1213: 1802 case 1213:
1803 /* security lock from too many failed login attempts */ 1803 /* security lock from too many failed login attempts */
1804 error_reason = g_strdup(_("Account locked: Too many failed login attempts.\nLogging into the Yahoo! website may fix this.")); 1804 error_reason = g_strdup(_("Account locked: Too many failed login attempts. Logging into the Yahoo! website may fix this."));
1805 error = PURPLE_CONNECTION_ERROR_OTHER_ERROR; 1805 error = PURPLE_CONNECTION_ERROR_OTHER_ERROR;
1806 break; 1806 break;
1807 case 1235: 1807 case 1235:
1808 /* the username does not exist */ 1808 /* the username does not exist */
1809 error_reason = g_strdup(_("Username does not exist")); 1809 error_reason = g_strdup(_("Username does not exist"));
1810 error = PURPLE_CONNECTION_ERROR_INVALID_USERNAME; 1810 error = PURPLE_CONNECTION_ERROR_INVALID_USERNAME;
1811 break; 1811 break;
1812 case 1214: 1812 case 1214:
1813 case 1236: 1813 case 1236:
1814 /* indicates a lock of some description */ 1814 /* indicates a lock of some description */
1815 error_reason = g_strdup(_("Account locked: Unknown reason.\nLogging into the Yahoo! website may fix this.")); 1815 error_reason = g_strdup(_("Account locked: Unknown reason. Logging into the Yahoo! website may fix this."));
1816 error = PURPLE_CONNECTION_ERROR_OTHER_ERROR; 1816 error = PURPLE_CONNECTION_ERROR_OTHER_ERROR;
1817 break; 1817 break;
1818 case 100: 1818 case 100:
1819 /* username or password missing */ 1819 /* username or password missing */
1820 error_reason = g_strdup(_("Username or password missing")); 1820 error_reason = g_strdup(_("Username or password missing"));
2049 l = l->next; 2049 l = l->next;
2050 } 2050 }
2051 2051
2052 switch (err) { 2052 switch (err) {
2053 case 0: 2053 case 0:
2054 msg = g_strdup(_("Unknown error.")); 2054 msg = g_strdup(_("Unknown error"));
2055 reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; 2055 reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
2056 break; 2056 break;
2057 case 3: 2057 case 3:
2058 msg = g_strdup(_("Invalid username.")); 2058 msg = g_strdup(_("Username does not exist"));
2059 reason = PURPLE_CONNECTION_ERROR_INVALID_USERNAME; 2059 reason = PURPLE_CONNECTION_ERROR_INVALID_USERNAME;
2060 break; 2060 break;
2061 case 13: 2061 case 13:
2062 #ifdef TRY_WEBMESSENGER_LOGIN 2062 #ifdef TRY_WEBMESSENGER_LOGIN
2063 if (!yd->wm) { 2063 if (!yd->wm) {
2075 } 2075 }
2076 #endif /* TRY_WEBMESSENGER_LOGIN */ 2076 #endif /* TRY_WEBMESSENGER_LOGIN */
2077 if (!purple_account_get_remember_password(account)) 2077 if (!purple_account_get_remember_password(account))
2078 purple_account_set_password(account, NULL); 2078 purple_account_set_password(account, NULL);
2079 2079
2080 msg = g_strdup(_("Incorrect password.")); 2080 msg = g_strdup(_("Incorrect password"));
2081 reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED; 2081 reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED;
2082 break; 2082 break;
2083 case 14: 2083 case 14:
2084 msg = g_strdup(_("Your account is locked, please log in to the Yahoo! website.")); 2084 msg = g_strdup(_("Your account is locked, please log in to the Yahoo! website."));
2085 reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED; 2085 reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED;
2165 g_free(who); 2165 g_free(who);
2166 return; 2166 return;
2167 } 2167 }
2168 2168
2169 decoded_group = yahoo_string_decode(gc, group, FALSE); 2169 decoded_group = yahoo_string_decode(gc, group, FALSE);
2170 buf = g_strdup_printf(_("Could not add buddy %s to group %s to the server list on account %s."), 2170 buf = g_strdup_printf(_("Unable to add buddy %s to group %s to the server list on account %s."),
2171 who, decoded_group, purple_connection_get_display_name(gc)); 2171 who, decoded_group, purple_connection_get_display_name(gc));
2172 if (!purple_conv_present_error(who, purple_connection_get_account(gc), buf)) 2172 if (!purple_conv_present_error(who, purple_connection_get_account(gc), buf))
2173 purple_notify_error(gc, NULL, _("Could not add buddy to server list"), buf); 2173 purple_notify_error(gc, NULL, _("Unable to add buddy to server list"), buf);
2174 g_free(buf); 2174 g_free(buf);
2175 g_free(decoded_group); 2175 g_free(decoded_group);
2176 g_free(who); 2176 g_free(who);
2177 } 2177 }
2178 2178
2927 2927
2928 if (errno == EAGAIN) 2928 if (errno == EAGAIN)
2929 /* No worries */ 2929 /* No worries */
2930 return; 2930 return;
2931 2931
2932 tmp = g_strdup_printf(_("Lost connection with server:\n%s"), 2932 tmp = g_strdup_printf(_("Lost connection with server: %s"),
2933 g_strerror(errno)); 2933 g_strerror(errno));
2934 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); 2934 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
2935 g_free(tmp); 2935 g_free(tmp);
2936 return; 2936 return;
2937 } else if (len == 0) { 2937 } else if (len == 0) {
2938 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 2938 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
2939 _("Server closed the connection.")); 2939 _("Server closed the connection"));
2940 return; 2940 return;
2941 } 2941 }
2942 gc->last_received = time(NULL); 2942 gc->last_received = time(NULL);
2943 yd->rxqueue = g_realloc(yd->rxqueue, len + yd->rxlen); 2943 yd->rxqueue = g_realloc(yd->rxqueue, len + yd->rxlen);
2944 memcpy(yd->rxqueue + yd->rxlen, buf, len); 2944 memcpy(yd->rxqueue + yd->rxlen, buf, len);
3016 struct yahoo_data *yd; 3016 struct yahoo_data *yd;
3017 struct yahoo_packet *pkt; 3017 struct yahoo_packet *pkt;
3018 3018
3019 if (source < 0) { 3019 if (source < 0) {
3020 gchar *tmp; 3020 gchar *tmp;
3021 tmp = g_strdup_printf(_("Could not establish a connection with the server:\n%s"), 3021 tmp = g_strdup_printf(_("Unable to connect: %s"), error_message);
3022 error_message);
3023 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); 3022 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
3024 g_free(tmp); 3023 g_free(tmp);
3025 return; 3024 return;
3026 } 3025 }
3027 3026
3043 struct yahoo_data *yd; 3042 struct yahoo_data *yd;
3044 struct yahoo_packet *pkt; 3043 struct yahoo_packet *pkt;
3045 3044
3046 if (source < 0) { 3045 if (source < 0) {
3047 gchar *tmp; 3046 gchar *tmp;
3048 tmp = g_strdup_printf(_("Could not establish a connection with the server:\n%s"), 3047 tmp = g_strdup_printf(_("Unable to connect: %s"), error_message);
3049 error_message);
3050 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); 3048 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
3051 g_free(tmp); 3049 g_free(tmp);
3052 return; 3050 return;
3053 } 3051 }
3054 3052
3083 3081
3084 if (errno == EAGAIN) 3082 if (errno == EAGAIN)
3085 /* No worries */ 3083 /* No worries */
3086 return; 3084 return;
3087 3085
3088 tmp = g_strdup_printf(_("Lost connection with server:\n%s"), 3086 tmp = g_strdup_printf(_("Lost connection with server: %s"),
3089 g_strerror(errno)); 3087 g_strerror(errno));
3090 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); 3088 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
3091 g_free(tmp); 3089 g_free(tmp);
3092 return; 3090 return;
3093 } else if (len == 0) { 3091 } else if (len == 0) {
3094 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 3092 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
3095 _("Server closed the connection.")); 3093 _("Server closed the connection"));
3096 return; 3094 return;
3097 } 3095 }
3098 3096
3099 if (yd->rxlen > 0 || !g_strstr_len(buf, len, "\r\n\r\n")) { 3097 if (yd->rxlen > 0 || !g_strstr_len(buf, len, "\r\n\r\n")) {
3100 yd->rxqueue = g_realloc(yd->rxqueue, yd->rxlen + len + 1); 3098 yd->rxqueue = g_realloc(yd->rxqueue, yd->rxlen + len + 1);
3106 buf[len] = '\0'; 3104 buf[len] = '\0';
3107 3105
3108 if ((strncmp(buf, "HTTP/1.0 302", strlen("HTTP/1.0 302")) && 3106 if ((strncmp(buf, "HTTP/1.0 302", strlen("HTTP/1.0 302")) &&
3109 strncmp(buf, "HTTP/1.1 302", strlen("HTTP/1.1 302")))) { 3107 strncmp(buf, "HTTP/1.1 302", strlen("HTTP/1.1 302")))) {
3110 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 3108 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
3111 _("Received unexpected HTTP response from server.")); 3109 _("Received unexpected HTTP response from server"));
3112 purple_debug_misc("yahoo", "Unexpected HTTP response: %s\n", buf); 3110 purple_debug_misc("yahoo", "Unexpected HTTP response: %s\n", buf);
3113 return; 3111 return;
3114 } 3112 }
3115 3113
3116 s = g_string_sized_new(len); 3114 s = g_string_sized_new(len);
3136 /* Now we have our cookies to login with. I'll go get the milk. */ 3134 /* Now we have our cookies to login with. I'll go get the milk. */
3137 if (purple_proxy_connect(gc, account, "wcs2.msg.dcn.yahoo.com", 3135 if (purple_proxy_connect(gc, account, "wcs2.msg.dcn.yahoo.com",
3138 purple_account_get_int(account, "port", YAHOO_PAGER_PORT), 3136 purple_account_get_int(account, "port", YAHOO_PAGER_PORT),
3139 yahoo_got_web_connected, gc) == NULL) { 3137 yahoo_got_web_connected, gc) == NULL) {
3140 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 3138 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
3141 _("Connection problem")); 3139 _("Unable to connect"));
3142 return; 3140 return;
3143 } 3141 }
3144 } 3142 }
3145 3143
3146 static void yahoo_got_cookies_send_cb(gpointer data, gint source, PurpleInputCondition cond) 3144 static void yahoo_got_cookies_send_cb(gpointer data, gint source, PurpleInputCondition cond)
3162 g_free(yd->auth); 3160 g_free(yd->auth);
3163 yd->auth = NULL; 3161 yd->auth = NULL;
3164 if (gc->inpa) 3162 if (gc->inpa)
3165 purple_input_remove(gc->inpa); 3163 purple_input_remove(gc->inpa);
3166 gc->inpa = 0; 3164 gc->inpa = 0;
3167 tmp = g_strdup_printf(_("Lost connection with %s:\n%s"), 3165 tmp = g_strdup_printf(_("Lost connection with %s: %s"),
3168 "login.yahoo.com:80", g_strerror(errno)); 3166 "login.yahoo.com:80", g_strerror(errno));
3169 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); 3167 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
3170 g_free(tmp); 3168 g_free(tmp);
3171 return; 3169 return;
3172 } 3170 }
3187 { 3185 {
3188 PurpleConnection *gc = data; 3186 PurpleConnection *gc = data;
3189 3187
3190 if (source < 0) { 3188 if (source < 0) {
3191 gchar *tmp; 3189 gchar *tmp;
3192 tmp = g_strdup_printf(_("Could not establish a connection with %s:\n%s"), 3190 tmp = g_strdup_printf(_("Unable to establish a connection with %s: %s"),
3193 "login.yahoo.com:80", error_message); 3191 "login.yahoo.com:80", error_message);
3194 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); 3192 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
3195 g_free(tmp); 3193 g_free(tmp);
3196 return; 3194 return;
3197 } 3195 }
3324 "Host: login.yahoo.com\r\n\r\n"); 3322 "Host: login.yahoo.com\r\n\r\n");
3325 g_hash_table_destroy(hash); 3323 g_hash_table_destroy(hash);
3326 yd->auth = g_string_free(url, FALSE); 3324 yd->auth = g_string_free(url, FALSE);
3327 if (purple_proxy_connect(gc, account, "login.yahoo.com", 80, yahoo_got_cookies, gc) == NULL) { 3325 if (purple_proxy_connect(gc, account, "login.yahoo.com", 80, yahoo_got_cookies, gc) == NULL) {
3328 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 3326 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
3329 _("Connection problem")); 3327 _("Unable to connect"));
3330 return; 3328 return;
3331 } 3329 }
3332 3330
3333 purple_cipher_context_destroy(context); 3331 purple_cipher_context_destroy(context);
3334 } 3332 }
3435 purple_account_get_string(account, "server", YAHOOJP_PAGER_HOST), 3433 purple_account_get_string(account, "server", YAHOOJP_PAGER_HOST),
3436 purple_account_get_int(account, "port", YAHOO_PAGER_PORT), 3434 purple_account_get_int(account, "port", YAHOO_PAGER_PORT),
3437 yahoo_got_connected, gc) == NULL) 3435 yahoo_got_connected, gc) == NULL)
3438 { 3436 {
3439 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 3437 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
3440 _("Connection problem")); 3438 _("Unable to connect"));
3441 return; 3439 return;
3442 } 3440 }
3443 } else { 3441 } else {
3444 yd->jp = FALSE; 3442 yd->jp = FALSE;
3445 if (purple_proxy_connect(gc, account, 3443 if (purple_proxy_connect(gc, account,
3446 purple_account_get_string(account, "server", YAHOO_PAGER_HOST), 3444 purple_account_get_string(account, "server", YAHOO_PAGER_HOST),
3447 purple_account_get_int(account, "port", YAHOO_PAGER_PORT), 3445 purple_account_get_int(account, "port", YAHOO_PAGER_PORT),
3448 yahoo_got_connected, gc) == NULL) 3446 yahoo_got_connected, gc) == NULL)
3449 { 3447 {
3450 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 3448 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
3451 _("Connection problem")); 3449 _("Unable to connect"));
3452 return; 3450 return;
3453 } 3451 }
3454 } 3452 }
3455 } 3453 }
3456 3454