| 1544 |
1544 |
| 1545 exit(0); |
1545 exit(0); |
| 1546 } |
1546 } |
| 1547 #endif |
1547 #endif |
| 1548 |
1548 |
| 1549 /** Called when the session key arrives. */ |
1549 /** Called when the session key arrives to check whether the user |
| |
1550 * has a username, and set one if desired. */ |
| 1550 static gboolean |
1551 static gboolean |
| 1551 msim_is_username_set(MsimSession *session, MsimMessage *msg) { |
1552 msim_is_username_set(MsimSession *session, MsimMessage *msg) |
| 1552 /*MsimMessage *body;*/ |
1553 { |
| 1553 |
|
| 1554 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
1554 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
| 1555 g_return_val_if_fail(msg != NULL, FALSE); |
1555 g_return_val_if_fail(msg != NULL, FALSE); |
| |
1556 g_return_val_if_fail(session->gc != NULL, FALSE); |
| 1556 |
1557 |
| 1557 session->sesskey = msim_msg_get_integer(msg, "sesskey"); |
1558 session->sesskey = msim_msg_get_integer(msg, "sesskey"); |
| 1558 purple_debug_info("msim", "SESSKEY=<%d>\n", session->sesskey); |
1559 purple_debug_info("msim", "SESSKEY=<%d>\n", session->sesskey); |
| 1559 |
1560 |
| 1560 /* What is proof? Used to be uid, but now is 52 base64'd bytes... */ |
1561 /* What is proof? Used to be uid, but now is 52 base64'd bytes... */ |
| 1578 session->username = msim_msg_get_string(msg, "uniquenick"); |
1579 session->username = msim_msg_get_string(msg, "uniquenick"); |
| 1579 |
1580 |
| 1580 /* Set display name to username (otherwise will show email address) */ |
1581 /* Set display name to username (otherwise will show email address) */ |
| 1581 purple_connection_set_display_name(session->gc, session->username); |
1582 purple_connection_set_display_name(session->gc, session->username); |
| 1582 |
1583 |
| 1583 |
1584 /* If user lacks a username, help them get one. */ |
| 1584 /* Additional post-connect operations */ |
|
| 1585 |
|
| 1586 |
|
| 1587 if (msim_msg_get_integer(msg, "uniquenick") == session->userid) { |
1585 if (msim_msg_get_integer(msg, "uniquenick") == session->userid) { |
| 1588 purple_debug_info("msim_we_are_logged_on", "TODO: pick username\n"); |
1586 purple_debug_info("msim_is_username_set", "no username is set\n"); |
| 1589 g_return_val_if_fail(session->gc != NULL, FALSE); |
|
| 1590 purple_request_yes_no(session->gc, |
1587 purple_request_yes_no(session->gc, |
| 1591 _("MySpaceIM - No Username Set"), |
1588 _("MySpaceIM - No Username Set"), |
| 1592 _("You appear to have no MySpace username."), |
1589 _("You appear to have no MySpace username."), |
| 1593 _("Would you like to set one now? (Note: THIS CANNOT BE CHANGED!)"), |
1590 _("Would you like to set one now? (Note: THIS CANNOT BE CHANGED!)"), |
| 1594 0, |
1591 0, |
| 1595 session->account, |
1592 session->account, |
| 1596 NULL, |
1593 NULL, |
| 1597 NULL, |
1594 NULL, |
| 1598 session->gc, G_CALLBACK(msim_set_username_cb), G_CALLBACK(msim_do_not_set_username_cb)); |
1595 session->gc, |
| 1599 purple_debug_info("msim","Username Not Set Alert Prompted\n"); |
1596 G_CALLBACK(msim_set_username_cb), |
| |
1597 G_CALLBACK(msim_do_not_set_username_cb)); |
| |
1598 purple_debug_info("msim_is_username_set","'username not set' alert prompted\n"); |
| 1600 return FALSE; |
1599 return FALSE; |
| 1601 } |
1600 } |
| 1602 return TRUE; |
1601 return TRUE; |
| 1603 } |
1602 } |
| 1604 |
1603 |
| 1605 /** Called after username is set. */ |
1604 /** Called after username is set, if necessary and we're open for business. */ |
| 1606 gboolean msim_we_are_logged_on(MsimSession *session) { |
1605 gboolean msim_we_are_logged_on(MsimSession *session) |
| |
1606 { |
| 1607 MsimMessage *body; |
1607 MsimMessage *body; |
| 1608 |
1608 |
| 1609 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
1609 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
| 1610 |
1610 |
| 1611 /* 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 |