| 1016 void |
1016 void |
| 1017 msim_get_info(PurpleConnection *gc, const gchar *username) |
1017 msim_get_info(PurpleConnection *gc, const gchar *username) |
| 1018 { |
1018 { |
| 1019 MsimSession *session; |
1019 MsimSession *session; |
| 1020 MsimUser *user; |
1020 MsimUser *user; |
| 1021 guint uid; |
|
| 1022 gchar *user_to_lookup; |
1021 gchar *user_to_lookup; |
| 1023 MsimMessage *user_msg; |
1022 MsimMessage *user_msg; |
| 1024 |
1023 |
| 1025 g_return_if_fail(gc != NULL); |
1024 g_return_if_fail(gc != NULL); |
| 1026 g_return_if_fail(username != NULL); |
1025 g_return_if_fail(username != NULL); |
| 1031 |
1030 |
| 1032 /* Obtain uid of buddy. */ |
1031 /* Obtain uid of buddy. */ |
| 1033 user = msim_find_user(session, username); |
1032 user = msim_find_user(session, username); |
| 1034 |
1033 |
| 1035 /* If is on buddy list, lookup by uid since it is faster. */ |
1034 /* If is on buddy list, lookup by uid since it is faster. */ |
| 1036 if (user && (uid = purple_blist_node_get_int(&user->buddy->node, "UserID"))) { |
1035 if (user && user->id) { |
| 1037 user_to_lookup = g_strdup_printf("%d", uid); |
1036 user_to_lookup = g_strdup_printf("%d", user->id); |
| 1038 } else { |
1037 } else { |
| 1039 /* Looking up buddy not on blist. Lookup by whatever user entered. */ |
1038 /* Looking up buddy not on blist. Lookup by whatever user entered. */ |
| 1040 user_to_lookup = g_strdup(username); |
1039 user_to_lookup = g_strdup(username); |
| 1041 } |
1040 } |
| 1042 |
1041 |
| 1968 "msim_status: making new buddy for %s\n", username); |
1967 "msim_status: making new buddy for %s\n", username); |
| 1969 buddy = purple_buddy_new(session->account, username, NULL); |
1968 buddy = purple_buddy_new(session->account, username, NULL); |
| 1970 purple_blist_add_buddy(buddy, NULL, NULL, NULL); |
1969 purple_blist_add_buddy(buddy, NULL, NULL, NULL); |
| 1971 |
1970 |
| 1972 user = msim_get_user_from_buddy(buddy); |
1971 user = msim_get_user_from_buddy(buddy); |
| 1973 |
1972 user->id = msim_msg_get_integer(msg, "f"); |
| 1974 /* All buddies on list should have a UserID integer associated with them. */ |
1973 |
| 1975 purple_blist_node_set_int(&buddy->node, "UserID", msim_msg_get_integer(msg, "f")); |
1974 /* Keep track of the user ID across sessions */ |
| 1976 |
1975 purple_blist_node_set_int(&buddy->node, "UserID", user->id); |
| |
1976 |
| 1977 msim_store_user_info(session, msg, NULL); |
1977 msim_store_user_info(session, msg, NULL); |
| 1978 } else { |
1978 } else { |
| 1979 purple_debug_info("msim", "msim_status: found buddy %s\n", username); |
1979 purple_debug_info("msim", "msim_status: found buddy %s\n", username); |
| 1980 } |
1980 } |
| 1981 |
1981 |
| 2864 purple_blist_add_buddy(buddy, NULL, group, NULL /* insertion point */); |
2864 purple_blist_add_buddy(buddy, NULL, group, NULL /* insertion point */); |
| 2865 |
2865 |
| 2866 /* 3. Update buddy information */ |
2866 /* 3. Update buddy information */ |
| 2867 user = msim_get_user_from_buddy(buddy); |
2867 user = msim_get_user_from_buddy(buddy); |
| 2868 |
2868 |
| 2869 /* All buddies on list should have 'uid' integer associated with them. */ |
2869 user->id = uid; |
| |
2870 /* Keep track of the user ID across sessions */ |
| 2870 purple_blist_node_set_int(&buddy->node, "UserID", uid); |
2871 purple_blist_node_set_int(&buddy->node, "UserID", uid); |
| 2871 |
2872 |
| 2872 /* Stores a few fields in the MsimUser, relevant to the buddy itself. |
2873 /* Stores a few fields in the MsimUser, relevant to the buddy itself. |
| 2873 * AvatarURL, Headline, ContactID. */ |
2874 * AvatarURL, Headline, ContactID. */ |
| 2874 msim_store_user_info(session, contact_info, NULL); |
2875 msim_store_user_info(session, contact_info, NULL); |