Mercurial > pidgin.yaz
comparison libpurple/protocols/myspace/myspace.c @ 22302:0e2207b46080
In msimprpl, if the user signs in without any username set (this will happen
the first time they login to MySpaceIM if they haven't set a short URL),
have them pick a username and use it. Patch from Jaywalker.
Closes #2844.
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Sat, 16 Feb 2008 20:20:12 +0000 |
parents | 5aabf4e24188 |
children | 1097406c8f6c |
comparison
equal
deleted
inserted
replaced
22301:3ed2c259f656 | 22302:0e2207b46080 |
---|---|
71 | 71 |
72 #ifdef MSIM_USE_KEEPALIVE | 72 #ifdef MSIM_USE_KEEPALIVE |
73 static gboolean msim_check_alive(gpointer data); | 73 static gboolean msim_check_alive(gpointer data); |
74 #endif | 74 #endif |
75 | 75 |
76 static gboolean msim_we_are_logged_on(MsimSession *session, MsimMessage *msg); | 76 static gboolean msim_is_username_set(MsimSession *session, MsimMessage *msg); |
77 | 77 |
78 static gboolean msim_process(MsimSession *session, MsimMessage *msg); | 78 static gboolean msim_process(MsimSession *session, MsimMessage *msg); |
79 | 79 |
80 static MsimMessage *msim_do_postprocessing(MsimMessage *msg, const gchar *uid_field_name, const gchar *uid_before, guint uid); | 80 static MsimMessage *msim_do_postprocessing(MsimMessage *msg, const gchar *uid_field_name, const gchar *uid_before, guint uid); |
81 static void msim_postprocess_outgoing_cb(MsimSession *session, MsimMessage *userinfo, gpointer data); | 81 static void msim_postprocess_outgoing_cb(MsimSession *session, MsimMessage *userinfo, gpointer data); |
1546 } | 1546 } |
1547 #endif | 1547 #endif |
1548 | 1548 |
1549 /** Called when the session key arrives. */ | 1549 /** Called when the session key arrives. */ |
1550 static gboolean | 1550 static gboolean |
1551 msim_we_are_logged_on(MsimSession *session, MsimMessage *msg) | 1551 msim_is_username_set(MsimSession *session, MsimMessage *msg) { |
1552 { | 1552 /*MsimMessage *body;*/ |
1553 MsimMessage *body; | |
1554 | 1553 |
1555 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); | 1554 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
1556 g_return_val_if_fail(msg != NULL, FALSE); | 1555 g_return_val_if_fail(msg != NULL, FALSE); |
1557 | 1556 |
1558 session->sesskey = msim_msg_get_integer(msg, "sesskey"); | 1557 session->sesskey = msim_msg_get_integer(msg, "sesskey"); |
1578 * address and not username. Will be freed in msim_session_destroy(). */ | 1577 * address and not username. Will be freed in msim_session_destroy(). */ |
1579 session->username = msim_msg_get_string(msg, "uniquenick"); | 1578 session->username = msim_msg_get_string(msg, "uniquenick"); |
1580 | 1579 |
1581 /* Set display name to username (otherwise will show email address) */ | 1580 /* Set display name to username (otherwise will show email address) */ |
1582 purple_connection_set_display_name(session->gc, session->username); | 1581 purple_connection_set_display_name(session->gc, session->username); |
1582 | |
1583 | |
1584 /* Additional post-connect operations */ | |
1585 | |
1586 | |
1587 if (msim_msg_get_integer(msg, "uniquenick") == session->userid) { | |
1588 purple_debug_info("msim_we_are_logged_on", "TODO: pick username\n"); | |
1589 g_return_val_if_fail(session->gc != NULL, FALSE); | |
1590 purple_request_yes_no(session->gc, | |
1591 _("MySpaceIM - No Username Set"), | |
1592 _("You appear to have no MySpace username."), | |
1593 _("Would you like to set one now? (Note: THIS CANNOT BE CHANGED!)"), | |
1594 0, | |
1595 session->account, | |
1596 NULL, | |
1597 NULL, | |
1598 session->gc, G_CALLBACK(msim_set_username_cb), G_CALLBACK(msim_do_not_set_username_cb)); | |
1599 purple_debug_info("msim","Username Not Set Alert Prompted\n"); | |
1600 return FALSE; | |
1601 } | |
1602 return TRUE; | |
1603 } | |
1604 | |
1605 /** Called after username is set. */ | |
1606 gboolean msim_we_are_logged_on(MsimSession *session) { | |
1607 MsimMessage *body; | |
1608 | |
1609 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); | |
1583 | 1610 |
1584 /* The session is now set up, ready to be connected. This emits the | 1611 /* The session is now set up, ready to be connected. This emits the |
1585 * signedOn signal, so clients can now do anything with msimprpl, and | 1612 * signedOn signal, so clients can now do anything with msimprpl, and |
1586 * we're ready for it (session key, userid, username all setup). */ | 1613 * we're ready for it (session key, userid, username all setup). */ |
1587 purple_connection_update_progress(session->gc, _("Connected"), 3, 4); | 1614 purple_connection_update_progress(session->gc, _("Connected"), 3, 4); |
1588 purple_connection_set_state(session->gc, PURPLE_CONNECTED); | 1615 purple_connection_set_state(session->gc, PURPLE_CONNECTED); |
1589 | |
1590 | |
1591 /* Additional post-connect operations */ | |
1592 | |
1593 | |
1594 if (msim_msg_get_integer(msg, "uniquenick") == session->userid) { | |
1595 purple_debug_info("msim_we_are_logged_on", "TODO: pick username\n"); | |
1596 /* No username is set. */ | |
1597 purple_notify_error(session->account, | |
1598 _("No username set"), | |
1599 _("Please go to http://editprofile.myspace.com/index.cfm?fuseaction=profile.username and choose a username and try to login again."), NULL); | |
1600 purple_connection_error_reason (session->gc, | |
1601 PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, _("No username set")); | |
1602 return FALSE; | |
1603 } | |
1604 | 1616 |
1605 body = msim_msg_new( | 1617 body = msim_msg_new( |
1606 "UserID", MSIM_TYPE_INTEGER, session->userid, | 1618 "UserID", MSIM_TYPE_INTEGER, session->userid, |
1607 NULL); | 1619 NULL); |
1608 | 1620 |
1685 #endif | 1697 #endif |
1686 | 1698 |
1687 if (msim_msg_get_integer(msg, "lc") == 1) { | 1699 if (msim_msg_get_integer(msg, "lc") == 1) { |
1688 return msim_login_challenge(session, msg); | 1700 return msim_login_challenge(session, msg); |
1689 } else if (msim_msg_get_integer(msg, "lc") == 2) { | 1701 } else if (msim_msg_get_integer(msg, "lc") == 2) { |
1690 return msim_we_are_logged_on(session, msg); | 1702 /* return msim_we_are_logged_on(session, msg); */ |
1703 if (msim_is_username_set(session, msg)) { | |
1704 return msim_we_are_logged_on(session); | |
1705 } else { | |
1706 /* No username is set... We'll wait for the callbacks to do their work */ | |
1707 /* When they're all done, the last one will call msim_we_are_logged_on() and pick up where we left off */ | |
1708 return FALSE; | |
1709 } | |
1691 } else if (msim_msg_get(msg, "bm")) { | 1710 } else if (msim_msg_get(msg, "bm")) { |
1692 return msim_incoming_bm(session, msg); | 1711 return msim_incoming_bm(session, msg); |
1693 } else if (msim_msg_get(msg, "rid")) { | 1712 } else if (msim_msg_get(msg, "rid")) { |
1694 return msim_process_reply(session, msg); | 1713 return msim_process_reply(session, msg); |
1695 } else if (msim_msg_get(msg, "error")) { | 1714 } else if (msim_msg_get(msg, "error")) { |