comparison libpurple/protocols/myspace/myspace.c @ 32827:4a34689eeb33 default tip

merged from im.pidgin.pidgin
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Sat, 19 Nov 2011 14:42:54 +0900
parents a5f50581b7c0
children
comparison
equal deleted inserted replaced
32692:0f94ec89f0bc 32827:4a34689eeb33
252 const gchar *from_username; 252 const gchar *from_username;
253 253
254 g_return_val_if_fail(who != NULL, FALSE); 254 g_return_val_if_fail(who != NULL, FALSE);
255 g_return_val_if_fail(text != NULL, FALSE); 255 g_return_val_if_fail(text != NULL, FALSE);
256 256
257 from_username = session->account->username; 257 from_username = purple_account_get_username(session->account);
258 258
259 g_return_val_if_fail(from_username != NULL, FALSE); 259 g_return_val_if_fail(from_username != NULL, FALSE);
260 260
261 purple_debug_info("msim", "sending %d message from %s to %s: %s\n", 261 purple_debug_info("msim", "sending %d message from %s to %s: %s\n",
262 type, from_username, who, text); 262 type, from_username, who, text);
703 } 703 }
704 704
705 purple_connection_update_progress(session->gc, _("Logging in"), 2, 4); 705 purple_connection_update_progress(session->gc, _("Logging in"), 2, 4);
706 706
707 response_len = 0; 707 response_len = 0;
708 response = msim_compute_login_response(nc, account->username, account->password, &response_len); 708 response = msim_compute_login_response(nc, purple_account_get_username(account), purple_account_get_password(account), &response_len);
709 709
710 g_free(nc); 710 g_free(nc);
711 711
712 ret = msim_send(session, 712 ret = msim_send(session,
713 "login2", MSIM_TYPE_INTEGER, MSIM_AUTH_ALGORITHM, 713 "login2", MSIM_TYPE_INTEGER, MSIM_AUTH_ALGORITHM,
714 /* This is actually user's email address. */ 714 /* This is actually user's email address. */
715 "username", MSIM_TYPE_STRING, g_strdup(account->username), 715 "username", MSIM_TYPE_STRING, g_strdup(purple_account_get_username(account)),
716 /* GString will be freed in msim_msg_free() in msim_send(). */ 716 /* GString will be freed in msim_msg_free() in msim_send(). */
717 "response", MSIM_TYPE_BINARY, g_string_new_len(response, response_len), 717 "response", MSIM_TYPE_BINARY, g_string_new_len(response, response_len),
718 "clientver", MSIM_TYPE_INTEGER, MSIM_CLIENT_VERSION, 718 "clientver", MSIM_TYPE_INTEGER, MSIM_CLIENT_VERSION,
719 "langid", MSIM_TYPE_INTEGER, MSIM_LANGUAGE_ID_ENGLISH, 719 "langid", MSIM_TYPE_INTEGER, MSIM_LANGUAGE_ID_ENGLISH,
720 "imlang", MSIM_TYPE_STRING, g_strdup(MSIM_LANGUAGE_NAME_ENGLISH), 720 "imlang", MSIM_TYPE_STRING, g_strdup(MSIM_LANGUAGE_NAME_ENGLISH),
750 * 750 *
751 * Filed enhancement ticket for libpurple as #4688. 751 * Filed enhancement ticket for libpurple as #4688.
752 */ 752 */
753 753
754 purple_debug_info("msim", "Unrecognized data on account for %s\n", 754 purple_debug_info("msim", "Unrecognized data on account for %s\n",
755 (session && session->account && session->account->username) ? 755 (session && session->account && purple_account_get_username(session->account)) ?
756 session->account->username : "(NULL)"); 756 purple_account_get_username(session->account) : "(NULL)");
757 if (note) { 757 if (note) {
758 purple_debug_info("msim", "(Note: %s)\n", note); 758 purple_debug_info("msim", "(Note: %s)\n", note);
759 } 759 }
760 760
761 if (msg) { 761 if (msg) {
1836 case MSIM_ERROR_INCORRECT_PASSWORD: /* Incorrect password */ 1836 case MSIM_ERROR_INCORRECT_PASSWORD: /* Incorrect password */
1837 reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED; 1837 reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED;
1838 if (!purple_account_get_remember_password(session->account)) 1838 if (!purple_account_get_remember_password(session->account))
1839 purple_account_set_password(session->account, NULL); 1839 purple_account_set_password(session->account, NULL);
1840 #ifdef MSIM_MAX_PASSWORD_LENGTH 1840 #ifdef MSIM_MAX_PASSWORD_LENGTH
1841 if (session->account->password && (strlen(session->account->password) > MSIM_MAX_PASSWORD_LENGTH)) { 1841 if (purple_account_get_password(session->account) && (strlen(purple_account_get_password(session->account)) > MSIM_MAX_PASSWORD_LENGTH)) {
1842 gchar *suggestion; 1842 gchar *suggestion;
1843 1843
1844 suggestion = g_strdup_printf(_("%s Your password is " 1844 suggestion = g_strdup_printf(_("%s Your password is "
1845 "%zu characters, which is longer than the " 1845 "%zu characters, which is longer than the "
1846 "maximum length of %d. Please shorten your " 1846 "maximum length of %d. Please shorten your "
1847 "password at http://profileedit.myspace.com/index.cfm?fuseaction=accountSettings.changePassword and try again."), 1847 "password at http://profileedit.myspace.com/index.cfm?fuseaction=accountSettings.changePassword and try again."),
1848 full_errmsg, 1848 full_errmsg,
1849 strlen(session->account->password), 1849 strlen(purple_account_get_password(session->account)),
1850 MSIM_MAX_PASSWORD_LENGTH); 1850 MSIM_MAX_PASSWORD_LENGTH);
1851 1851
1852 /* Replace full_errmsg. */ 1852 /* Replace full_errmsg. */
1853 g_free(full_errmsg); 1853 g_free(full_errmsg);
1854 full_errmsg = suggestion; 1854 full_errmsg = suggestion;
2165 g_free(tmp); 2165 g_free(tmp);
2166 return; 2166 return;
2167 } 2167 }
2168 2168
2169 session->fd = source; 2169 session->fd = source;
2170 2170 session->inpa = purple_input_add(source, PURPLE_INPUT_READ, msim_input_cb, gc);
2171 gc->inpa = purple_input_add(source, PURPLE_INPUT_READ, msim_input_cb, gc);
2172 } 2171 }
2173 2172
2174 /** 2173 /**
2175 * Start logging in to the MSIM servers. 2174 * Start logging in to the MSIM servers.
2176 * 2175 *
2182 PurpleConnection *gc; 2181 PurpleConnection *gc;
2183 const gchar *host; 2182 const gchar *host;
2184 int port; 2183 int port;
2185 2184
2186 g_return_if_fail(acct != NULL); 2185 g_return_if_fail(acct != NULL);
2187 g_return_if_fail(acct->username != NULL); 2186 g_return_if_fail(purple_account_get_username(acct) != NULL);
2188 2187
2189 purple_debug_info("msim", "logging in %s\n", acct->username); 2188 purple_debug_info("msim", "logging in %s\n", purple_account_get_username(acct));
2190 2189
2191 gc = purple_account_get_connection(acct); 2190 gc = purple_account_get_connection(acct);
2192 purple_connection_set_protocol_data(gc, msim_session_new(acct)); 2191 purple_connection_set_protocol_data(gc, msim_session_new(acct));
2193 gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_URLDESC; 2192 purple_connection_set_flags(gc, PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_URLDESC);
2194 2193
2195 /* 2194 /*
2196 * Lets wipe out our local list of blocked buddies. We'll get a 2195 * Lets wipe out our local list of blocked buddies. We'll get a
2197 * list of all blocked buddies from the server, and we shouldn't 2196 * list of all blocked buddies from the server, and we shouldn't
2198 * have stuff in the local list that isn't on the server list. 2197 * have stuff in the local list that isn't on the server list.
2261 if (session == NULL) 2260 if (session == NULL)
2262 return; 2261 return;
2263 2262
2264 purple_connection_set_protocol_data(gc, NULL); 2263 purple_connection_set_protocol_data(gc, NULL);
2265 2264
2266 if (session->gc->inpa) { 2265 if (session->inpa) {
2267 purple_input_remove(session->gc->inpa); 2266 purple_input_remove(session->inpa);
2267 session->inpa = 0;
2268 } 2268 }
2269 if (session->fd >= 0) { 2269 if (session->fd >= 0) {
2270 close(session->fd); 2270 close(session->fd);
2271 session->fd = -1; 2271 session->fd = -1;
2272 } 2272 }
2541 2541
2542 msim_set_status_code(session, status_code, stripped); 2542 msim_set_status_code(session, status_code, stripped);
2543 2543
2544 /* If we should be idle, set that status. Time is irrelevant here. */ 2544 /* If we should be idle, set that status. Time is irrelevant here. */
2545 if (purple_presence_is_idle(pres) && status_code != MSIM_STATUS_CODE_OFFLINE_OR_HIDDEN) 2545 if (purple_presence_is_idle(pres) && status_code != MSIM_STATUS_CODE_OFFLINE_OR_HIDDEN)
2546 msim_set_idle(account->gc, 1); 2546 msim_set_idle(purple_account_get_connection(account), 1);
2547 } 2547 }
2548 2548
2549 /** 2549 /**
2550 * Go idle. 2550 * Go idle.
2551 */ 2551 */
2862 if (msim_is_userid(str)) { 2862 if (msim_is_userid(str)) {
2863 /* Have user ID, we need to get their username first :) */ 2863 /* Have user ID, we need to get their username first :) */
2864 const char *username; 2864 const char *username;
2865 2865
2866 /* If the account does not exist, we can't look up the user. */ 2866 /* If the account does not exist, we can't look up the user. */
2867 if (!account || !account->gc) 2867 if (!account || !purple_account_get_connection(account))
2868 return str; 2868 return str;
2869 2869
2870 id = atol(str); 2870 id = atol(str);
2871 username = msim_uid2username_from_blist((PurpleAccount *)account, id); 2871 username = msim_uid2username_from_blist((PurpleAccount *)account, id);
2872 if (!username) { 2872 if (!username) {