Mercurial > pidgin.yaz
changeset 11992:c824e39db0e7
[gaim-migrate @ 14285]
- make Offline a user setable status in MSN
- redo MSN status changing to query the core for the current status instead
of keeping track of it itself, as recommended by Mark on patch #1336338.
- bring back the buddy list synchronization by parsing the buddy list after
signon
committer: Tailor Script <tailor@pidgin.im>
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Sun, 06 Nov 2005 21:52:00 +0000 |
parents | 94ba447a6a5c |
children | aa77da6c7f21 |
files | src/protocols/msn/msn.c src/protocols/msn/notification.c src/protocols/msn/session.c src/protocols/msn/session.h src/protocols/msn/state.c src/protocols/msn/state.h |
diffstat | 6 files changed, 95 insertions(+), 90 deletions(-) [+] |
line wrap: on
line diff
--- a/src/protocols/msn/msn.c Sun Nov 06 19:52:20 2005 +0000 +++ b/src/protocols/msn/msn.c Sun Nov 06 21:52:00 2005 +0000 @@ -566,7 +566,7 @@ GList *types = NULL; status = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, - "offline", _("Offline"), FALSE, FALSE, FALSE); + "offline", _("Offline"), FALSE, TRUE, FALSE); types = g_list_append(types, status); status = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, @@ -873,37 +873,15 @@ msn_set_status(GaimAccount *account, GaimStatus *status) { GaimConnection *gc; - MsnSession *session = NULL; - const char *state; - int msnstatus; + MsnSession *session; gc = gaim_account_get_connection(account); if (gc != NULL) + { session = gc->proto_data; - - state = gaim_status_get_id(status); - - gaim_debug_info("msn", "Set status to %s\n", gaim_status_get_name(status)); - - if (!strcmp(state, "away")) - msnstatus = MSN_AWAY; - else if (!strcmp(state, "brb")) - msnstatus = MSN_BRB; - else if (!strcmp(state, "busy")) - msnstatus = MSN_BUSY; - else if (!strcmp(state, "phone")) - msnstatus = MSN_PHONE; - else if (!strcmp(state, "lunch")) - msnstatus = MSN_LUNCH; - else if (!strcmp(state, "invisible")) - msnstatus = MSN_HIDDEN; - else if (0) /* how do we detect idle with new status? */ - msnstatus = MSN_IDLE; - else - msnstatus = MSN_ONLINE; - if (gc) - msn_change_status(session, msnstatus); + msn_change_status(session); + } } static void @@ -913,9 +891,10 @@ session = gc->proto_data; - msn_change_status(session, (idle ? MSN_IDLE : MSN_ONLINE)); + msn_change_status(session); } +#if 0 static void fake_userlist_add_buddy(MsnUserList *userlist, const char *who, int list_id, @@ -963,6 +942,7 @@ user->list_op |= (1 << list_id); } +#endif static void msn_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) @@ -977,8 +957,12 @@ if (!session->logged_in) { +#if 0 fake_userlist_add_buddy(session->sync_userlist, who, MSN_LIST_FL, group ? group->name : NULL); +#else + gaim_debug_error("msn", "msn_add_buddy called before connected\n"); +#endif return; } @@ -1326,7 +1310,7 @@ msn_user_set_buddy_icon(user, filename); - msn_change_status(session, session->state); + msn_change_status(session); } static void
--- a/src/protocols/msn/notification.c Sun Nov 06 19:52:20 2005 +0000 +++ b/src/protocols/msn/notification.c Sun Nov 06 21:52:00 2005 +0000 @@ -702,6 +702,7 @@ msn_user_update(user); } +#if 0 static void chg_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { @@ -727,6 +728,7 @@ cmdproc->session->state = state_id; } +#endif static void @@ -1379,7 +1381,7 @@ cbs_table = msn_table_new(); /* Synchronous */ - msn_table_add_cmd(cbs_table, "CHG", "CHG", chg_cmd); + msn_table_add_cmd(cbs_table, "CHG", "CHG", NULL); msn_table_add_cmd(cbs_table, "CHG", "ILN", iln_cmd); msn_table_add_cmd(cbs_table, "ADD", "ADD", add_cmd); msn_table_add_cmd(cbs_table, "ADD", "ILN", iln_cmd);
--- a/src/protocols/msn/session.c Sun Nov 06 19:52:20 2005 +0000 +++ b/src/protocols/msn/session.c Sun Nov 06 21:52:00 2005 +0000 @@ -39,7 +39,6 @@ session->account = account; session->notification = msn_notification_new(session); session->userlist = msn_userlist_new(session); - session->sync_userlist = msn_userlist_new(session); session->user = msn_user_new(session->userlist, gaim_account_get_username(account), NULL); @@ -71,9 +70,6 @@ msn_userlist_destroy(session->userlist); - if (session->sync_userlist != NULL) - msn_userlist_destroy(session->sync_userlist); - if (session->passport_info.kv != NULL) g_free(session->passport_info.kv); @@ -231,72 +227,63 @@ static void msn_session_sync_users(MsnSession *session) { - GList *l; - - l = session->sync_userlist->users; - - while (l != NULL) - { - MsnUser *local_user; + GaimBlistNode *gnode, *cnode, *bnode; + GaimConnection *gc = gaim_account_get_connection(session->account); - local_user = (MsnUser *)l->data; + g_return_if_fail(gc != NULL); - if (local_user->passport != NULL) - { - MsnUser *remote_user; - - remote_user = msn_userlist_find_user(session->userlist, - local_user->passport); + /* The core used to use msn_add_buddy to add all buddies before + * being logged in. This no longer happens, so we manually iterate + * over the whole buddy list to identify sync issues. */ - if (remote_user == NULL || - ((local_user->list_op & ( 1 << MSN_LIST_FL)) && - !(remote_user->list_op & ( 1 << MSN_LIST_FL)))) - { - /* The user was not on the server list */ - msn_show_sync_issue(session, local_user->passport, NULL); - } - else - { - GList *l; - - for (l = local_user->group_ids; l != NULL; l = l->next) - { - const char *group_name; - int gid; + for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { + GaimGroup *group = (GaimGroup *)gnode; + const char *group_name = group->name; + if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) + continue; + for(cnode = gnode->child; cnode; cnode = cnode->next) { + if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) + continue; + for(bnode = cnode->child; bnode; bnode = bnode->next) { + GaimBuddy *b; + if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) + continue; + b = (GaimBuddy *)bnode; + if(b->account == gc->account) { + MsnUser *remote_user; gboolean found = FALSE; - GList *l2; + + remote_user = msn_userlist_find_user(session->userlist, b->name); - group_name = - msn_userlist_find_group_name(local_user->userlist, - GPOINTER_TO_INT(l->data)); + if ((remote_user != NULL) && (remote_user->list_op & MSN_LIST_FL_OP)) + { + int group_id; + GList *l; - gid = msn_userlist_find_group_id(remote_user->userlist, - group_name); + group_id = msn_userlist_find_group_id(remote_user->userlist, + group_name); - for (l2 = remote_user->group_ids; l2 != NULL; l2 = l2->next) - { - if (GPOINTER_TO_INT(l2->data) == gid) + for (l = remote_user->group_ids; l != NULL; l = l->next) { - found = TRUE; - break; + if (group_id == GPOINTER_TO_INT(l->data)) + { + found = TRUE; + break; + } } + } if (!found) { - /* The user was not on that group on the server list */ - msn_show_sync_issue(session, local_user->passport, - group_name); + /* The user was not on the server list or not in that group + * on the server list */ + msn_show_sync_issue(session, b->name, group_name); } } } } - - l = l->next; } - - msn_userlist_destroy(session->sync_userlist); - session->sync_userlist = NULL; } void @@ -416,7 +403,7 @@ session->logged_in = TRUE; - msn_change_status(session, session->state == 0 ? MSN_ONLINE : session->state); + msn_change_status(session); gaim_connection_set_state(gc, GAIM_CONNECTED);
--- a/src/protocols/msn/session.h Sun Nov 06 19:52:20 2005 +0000 +++ b/src/protocols/msn/session.h Sun Nov 06 21:52:00 2005 +0000 @@ -80,7 +80,6 @@ { GaimAccount *account; MsnUser *user; - int state; guint protocol_ver; @@ -96,7 +95,6 @@ MsnSync *sync; MsnUserList *userlist; - MsnUserList *sync_userlist; int servconns_count; /**< The count of server connections. */ GList *switches; /**< The list of all the switchboards. */
--- a/src/protocols/msn/state.c Sun Nov 06 19:52:20 2005 +0000 +++ b/src/protocols/msn/state.c Sun Nov 06 21:52:00 2005 +0000 @@ -39,8 +39,9 @@ }; void -msn_change_status(MsnSession *session, MsnAwayType state) +msn_change_status(MsnSession *session) { + GaimAccount *account = session->account; MsnCmdProc *cmdproc; MsnUser *user; MsnObject *msnobj; @@ -51,8 +52,7 @@ cmdproc = session->notification->cmdproc; user = session->user; - state_text = msn_state_get_text(state); - session->state = state; + state_text = msn_state_get_text(msn_state_from_account(account)); /* If we're not logged in yet, don't send the status to the server, * it will be sent when login completes @@ -96,3 +96,36 @@ return status_text[state]; } + +MsnAwayType +msn_state_from_account(GaimAccount *account) +{ + MsnAwayType msnstatus; + GaimPresence *presence; + GaimStatus *status; + const char *status_id; + + presence = gaim_account_get_presence(account); + status = gaim_presence_get_active_status(presence); + status_id = gaim_status_get_id(status); + + if (!strcmp(status_id, "away")) + msnstatus = MSN_AWAY; + else if (!strcmp(status_id, "brb")) + msnstatus = MSN_BRB; + else if (!strcmp(status_id, "busy")) + msnstatus = MSN_BUSY; + else if (!strcmp(status_id, "phone")) + msnstatus = MSN_PHONE; + else if (!strcmp(status_id, "lunch")) + msnstatus = MSN_LUNCH; + else if (!strcmp(status_id, "invisible")) + msnstatus = MSN_HIDDEN; + else + msnstatus = MSN_ONLINE; + + if ((msnstatus == MSN_ONLINE) && gaim_presence_is_idle(presence)) + msnstatus = MSN_IDLE; + + return msnstatus; +}
--- a/src/protocols/msn/state.h Sun Nov 06 19:52:20 2005 +0000 +++ b/src/protocols/msn/state.h Sun Nov 06 21:52:00 2005 +0000 @@ -47,9 +47,8 @@ * Changes the status of the user. * * @param session The MSN session. - * @param state The new state. */ -void msn_change_status(MsnSession *session, MsnAwayType state); +void msn_change_status(MsnSession *session); /** * Returns the string representation of an away type. @@ -62,4 +61,6 @@ const char *msn_state_get_text(MsnAwayType state); +MsnAwayType msn_state_from_account(GaimAccount *account); + #endif /* _MSN_STATE_H_ */