comparison libpurple/protocols/myspace/user.c @ 22306:7d0e93198c39

If the user sets a username (because they don't have one), and it succeeds, then set MsimSession.username as well and update the server alias, so that outgoing messages correctly appear as from their username instead of uid. Based on patch from Jaywalker. Closes #4857.
author Jeffrey Connelly <jaconnel@calpoly.edu>
date Mon, 18 Feb 2008 19:20:39 +0000
parents bf4902fce6e4
children 3225c99785b8
comparison
equal deleted inserted replaced
22305:bf4902fce6e4 22306:7d0e93198c39
562 /*** 562 /***
563 * If they hit cancel or no at any point in the Setting Username process, we come here. * 563 * If they hit cancel or no at any point in the Setting Username process, we come here. *
564 * Currently.. We're safe letting them get by without setting it.. Unless we hear otherwise.. * 564 * Currently.. We're safe letting them get by without setting it.. Unless we hear otherwise.. *
565 * So for now, give them a menu.. If this becomes an issue with the Official client.. boot them here */ 565 * So for now, give them a menu.. If this becomes an issue with the Official client.. boot them here */
566 void msim_do_not_set_username_cb(PurpleConnection *gc) { 566 void msim_do_not_set_username_cb(PurpleConnection *gc) {
567 purple_debug_info("msim", "Dont set username"); 567 purple_debug_info("msim", "Don't set username");
568 568
569 /* Protocol won't log in now without a username set.. Disconnect */ 569 /* Protocol won't log in now without a username set.. Disconnect */
570 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, _("No username set")); 570 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, _("No username set"));
571 } 571 }
572 572
801 && lid == MC_SET_USERNAME_LID) { 801 && lid == MC_SET_USERNAME_LID) {
802 purple_debug_info("msim_username_is_set_cb", "Proper cmd,dsn,lid for username_is_set!\n"); 802 purple_debug_info("msim_username_is_set_cb", "Proper cmd,dsn,lid for username_is_set!\n");
803 purple_debug_info("msim_username_is_set_cb", "Username Set with return code %d\n",code); 803 purple_debug_info("msim_username_is_set_cb", "Username Set with return code %d\n",code);
804 if (code == 0) { 804 if (code == 0) {
805 /* Good! */ 805 /* Good! */
806 session->username = username;
806 msim_we_are_logged_on(session); 807 msim_we_are_logged_on(session);
807 } else { 808 } else {
808 purple_debug_info("msim_username_is_set", "code is %d",code); 809 purple_debug_info("msim_username_is_set", "code is %d",code);
809 /* TODO: what to do here? */ 810 /* TODO: what to do here? */
810 } 811 }
811 } else if (cmd == (MSIM_CMD_BIT_REPLY | MSIM_CMD_GET) 812 } else if (cmd == (MSIM_CMD_BIT_REPLY | MSIM_CMD_GET)
812 && dsn == MG_MYSPACE_INFO_BY_STRING_DSN 813 && dsn == MG_MYSPACE_INFO_BY_STRING_DSN
813 && lid == MG_MYSPACE_INFO_BY_STRING_LID) { 814 && lid == MG_MYSPACE_INFO_BY_STRING_LID) {
814 /* Not quite done... ONE MORE STEP :) */ 815 /* Not quite done... ONE MORE STEP :) */
815 rid = msim_new_reply_callback(session, msim_username_is_set_cb, data); 816 rid = msim_new_reply_callback(session, msim_username_is_set_cb, data);
816 body = msim_msg_new("UserName", MSIM_TYPE_STRING, g_strdup(username),NULL); 817 body = msim_msg_new("UserName", MSIM_TYPE_STRING, g_strdup(username), NULL);
817 if (!msim_send(session, "persist", MSIM_TYPE_INTEGER, 1, 818 if (!msim_send(session, "persist", MSIM_TYPE_INTEGER, 1,
818 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, 819 "sesskey", MSIM_TYPE_INTEGER, session->sesskey,
819 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_PUT, 820 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_PUT,
820 "dsn", MSIM_TYPE_INTEGER, MC_SET_USERNAME_DSN, 821 "dsn", MSIM_TYPE_INTEGER, MC_SET_USERNAME_DSN,
821 "uid", MSIM_TYPE_INTEGER, session->userid, 822 "uid", MSIM_TYPE_INTEGER, session->userid,