Mercurial > pidgin
comparison src/protocols/msn/session.c @ 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 | 10066662176a |
| children | 8872789902a1 |
comparison
equal
deleted
inserted
replaced
| 11991:94ba447a6a5c | 11992:c824e39db0e7 |
|---|---|
| 37 session = g_new0(MsnSession, 1); | 37 session = g_new0(MsnSession, 1); |
| 38 | 38 |
| 39 session->account = account; | 39 session->account = account; |
| 40 session->notification = msn_notification_new(session); | 40 session->notification = msn_notification_new(session); |
| 41 session->userlist = msn_userlist_new(session); | 41 session->userlist = msn_userlist_new(session); |
| 42 session->sync_userlist = msn_userlist_new(session); | |
| 43 | 42 |
| 44 session->user = msn_user_new(session->userlist, | 43 session->user = msn_user_new(session->userlist, |
| 45 gaim_account_get_username(account), NULL); | 44 gaim_account_get_username(account), NULL); |
| 46 | 45 |
| 47 session->protocol_ver = 9; | 46 session->protocol_ver = 9; |
| 68 | 67 |
| 69 while (session->slplinks != NULL) | 68 while (session->slplinks != NULL) |
| 70 msn_slplink_destroy(session->slplinks->data); | 69 msn_slplink_destroy(session->slplinks->data); |
| 71 | 70 |
| 72 msn_userlist_destroy(session->userlist); | 71 msn_userlist_destroy(session->userlist); |
| 73 | |
| 74 if (session->sync_userlist != NULL) | |
| 75 msn_userlist_destroy(session->sync_userlist); | |
| 76 | 72 |
| 77 if (session->passport_info.kv != NULL) | 73 if (session->passport_info.kv != NULL) |
| 78 g_free(session->passport_info.kv); | 74 g_free(session->passport_info.kv); |
| 79 | 75 |
| 80 if (session->passport_info.sid != NULL) | 76 if (session->passport_info.sid != NULL) |
| 229 } | 225 } |
| 230 | 226 |
| 231 static void | 227 static void |
| 232 msn_session_sync_users(MsnSession *session) | 228 msn_session_sync_users(MsnSession *session) |
| 233 { | 229 { |
| 234 GList *l; | 230 GaimBlistNode *gnode, *cnode, *bnode; |
| 235 | 231 GaimConnection *gc = gaim_account_get_connection(session->account); |
| 236 l = session->sync_userlist->users; | 232 |
| 237 | 233 g_return_if_fail(gc != NULL); |
| 238 while (l != NULL) | 234 |
| 239 { | 235 /* The core used to use msn_add_buddy to add all buddies before |
| 240 MsnUser *local_user; | 236 * being logged in. This no longer happens, so we manually iterate |
| 241 | 237 * over the whole buddy list to identify sync issues. */ |
| 242 local_user = (MsnUser *)l->data; | 238 |
| 243 | 239 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
| 244 if (local_user->passport != NULL) | 240 GaimGroup *group = (GaimGroup *)gnode; |
| 245 { | 241 const char *group_name = group->name; |
| 246 MsnUser *remote_user; | 242 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
| 247 | 243 continue; |
| 248 remote_user = msn_userlist_find_user(session->userlist, | 244 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
| 249 local_user->passport); | 245 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) |
| 250 | 246 continue; |
| 251 if (remote_user == NULL || | 247 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
| 252 ((local_user->list_op & ( 1 << MSN_LIST_FL)) && | 248 GaimBuddy *b; |
| 253 !(remote_user->list_op & ( 1 << MSN_LIST_FL)))) | 249 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
| 254 { | 250 continue; |
| 255 /* The user was not on the server list */ | 251 b = (GaimBuddy *)bnode; |
| 256 msn_show_sync_issue(session, local_user->passport, NULL); | 252 if(b->account == gc->account) { |
| 257 } | 253 MsnUser *remote_user; |
| 258 else | |
| 259 { | |
| 260 GList *l; | |
| 261 | |
| 262 for (l = local_user->group_ids; l != NULL; l = l->next) | |
| 263 { | |
| 264 const char *group_name; | |
| 265 int gid; | |
| 266 gboolean found = FALSE; | 254 gboolean found = FALSE; |
| 267 GList *l2; | 255 |
| 268 | 256 remote_user = msn_userlist_find_user(session->userlist, b->name); |
| 269 group_name = | 257 |
| 270 msn_userlist_find_group_name(local_user->userlist, | 258 if ((remote_user != NULL) && (remote_user->list_op & MSN_LIST_FL_OP)) |
| 271 GPOINTER_TO_INT(l->data)); | |
| 272 | |
| 273 gid = msn_userlist_find_group_id(remote_user->userlist, | |
| 274 group_name); | |
| 275 | |
| 276 for (l2 = remote_user->group_ids; l2 != NULL; l2 = l2->next) | |
| 277 { | 259 { |
| 278 if (GPOINTER_TO_INT(l2->data) == gid) | 260 int group_id; |
| 261 GList *l; | |
| 262 | |
| 263 group_id = msn_userlist_find_group_id(remote_user->userlist, | |
| 264 group_name); | |
| 265 | |
| 266 for (l = remote_user->group_ids; l != NULL; l = l->next) | |
| 279 { | 267 { |
| 280 found = TRUE; | 268 if (group_id == GPOINTER_TO_INT(l->data)) |
| 281 break; | 269 { |
| 270 found = TRUE; | |
| 271 break; | |
| 272 } | |
| 282 } | 273 } |
| 274 | |
| 283 } | 275 } |
| 284 | 276 |
| 285 if (!found) | 277 if (!found) |
| 286 { | 278 { |
| 287 /* The user was not on that group on the server list */ | 279 /* The user was not on the server list or not in that group |
| 288 msn_show_sync_issue(session, local_user->passport, | 280 * on the server list */ |
| 289 group_name); | 281 msn_show_sync_issue(session, b->name, group_name); |
| 290 } | 282 } |
| 291 } | 283 } |
| 292 } | 284 } |
| 293 } | 285 } |
| 294 | 286 } |
| 295 l = l->next; | |
| 296 } | |
| 297 | |
| 298 msn_userlist_destroy(session->sync_userlist); | |
| 299 session->sync_userlist = NULL; | |
| 300 } | 287 } |
| 301 | 288 |
| 302 void | 289 void |
| 303 msn_session_set_error(MsnSession *session, MsnErrorType error, | 290 msn_session_set_error(MsnSession *session, MsnErrorType error, |
| 304 const char *info) | 291 const char *info) |
| 414 msn_user_set_buddy_icon(session->user, icon); | 401 msn_user_set_buddy_icon(session->user, icon); |
| 415 g_free(icon); | 402 g_free(icon); |
| 416 | 403 |
| 417 session->logged_in = TRUE; | 404 session->logged_in = TRUE; |
| 418 | 405 |
| 419 msn_change_status(session, session->state == 0 ? MSN_ONLINE : session->state); | 406 msn_change_status(session); |
| 420 | 407 |
| 421 gaim_connection_set_state(gc, GAIM_CONNECTED); | 408 gaim_connection_set_state(gc, GAIM_CONNECTED); |
| 422 | 409 |
| 423 /* Sync users */ | 410 /* Sync users */ |
| 424 msn_session_sync_users(session); | 411 msn_session_sync_users(session); |
