comparison libpurple/protocols/myspace/myspace.c @ 19429:5e2a2fc55631

Lookup a user's information when their status changes to anything but offline. Now their information (including buddy icon, if any) will be available without explicitly requesting it with Get Info. Closes #2724.
author Jeffrey Connelly <jaconnel@calpoly.edu>
date Sun, 26 Aug 2007 01:08:39 +0000
parents 1fa10842eb83
children 0104035fd510
comparison
equal deleted inserted replaced
19428:1fa10842eb83 19429:5e2a2fc55631
2710 purple_buddy_icons_set_for_user(user->buddy->account, 2710 purple_buddy_icons_set_for_user(user->buddy->account,
2711 user->buddy->name, 2711 user->buddy->name,
2712 NULL, 0, NULL); 2712 NULL, 0, NULL);
2713 return; 2713 return;
2714 } 2714 }
2715 2715
2716 /* TODO: use ETag for checksum */
2716 previous_url = purple_buddy_icons_get_checksum_for_user(user->buddy); 2717 previous_url = purple_buddy_icons_get_checksum_for_user(user->buddy);
2717 2718
2718 /* Only download if URL changed */ 2719 /* Only download if URL changed */
2719 if (!previous_url || !g_str_equal(previous_url, user->image_url)) { 2720 if (!previous_url || !g_str_equal(previous_url, user->image_url)) {
2720 purple_util_fetch_url(user->image_url, TRUE, NULL, TRUE, msim_downloaded_buddy_icon, (gpointer)user); 2721 purple_util_fetch_url(user->image_url, TRUE, NULL, TRUE, msim_downloaded_buddy_icon, (gpointer)user);
3051 /* will be handled below */ 3052 /* will be handled below */
3052 purple_status_code = -1; 3053 purple_status_code = -1;
3053 break; 3054 break;
3054 3055
3055 default: 3056 default:
3056 purple_debug_info("msim", "msim_status for %s, unknown status code %d, treating as available\n", 3057 purple_debug_info("msim", "msim_status for %s, unknown status code %d, treating as available\n",
3057 username, status_code); 3058 username, status_code);
3058 purple_status_code = PURPLE_STATUS_AVAILABLE; 3059 purple_status_code = PURPLE_STATUS_AVAILABLE;
3059 } 3060 }
3060 3061
3061 purple_prpl_got_user_status(session->account, username, purple_primitive_get_id_from_type(purple_status_code), NULL); 3062 purple_prpl_got_user_status(session->account, username, purple_primitive_get_id_from_type(purple_status_code), NULL);
3062 3063
3063 if (status_code == MSIM_STATUS_CODE_IDLE) { 3064 if (status_code == MSIM_STATUS_CODE_IDLE) {
3072 if (status_code == MSIM_STATUS_CODE_ONLINE) { 3073 if (status_code == MSIM_STATUS_CODE_ONLINE) {
3073 /* Secretly whisper to unofficial clients our own version as they come online */ 3074 /* Secretly whisper to unofficial clients our own version as they come online */
3074 msim_send_unofficial_client(session, username); 3075 msim_send_unofficial_client(session, username);
3075 } 3076 }
3076 #endif 3077 #endif
3078
3079 if (status_code != MSIM_STATUS_CODE_OFFLINE_OR_HIDDEN) {
3080 /* Get information when they come online.
3081 * TODO: periodically refresh?
3082 */
3083 purple_debug_info("msim_incoming_status", "%s came online, looking up\n", username);
3084 msim_lookup_user(session, username, NULL, NULL);
3085 }
3077 3086
3078 g_free(username); 3087 g_free(username);
3079 msim_msg_list_free(list); 3088 msim_msg_list_free(list);
3080 3089
3081 return TRUE; 3090 return TRUE;
3762 * @param cb Callback, called with user information when available. 3771 * @param cb Callback, called with user information when available.
3763 * @param data An arbitray data pointer passed to the callback. 3772 * @param data An arbitray data pointer passed to the callback.
3764 */ 3773 */
3765 /* TODO: change to not use callbacks */ 3774 /* TODO: change to not use callbacks */
3766 static void 3775 static void
3767 msim_lookup_user(MsimSession *session, const gchar *user, 3776 msim_lookup_user(MsimSession *session, const gchar *user, MSIM_USER_LOOKUP_CB cb, gpointer data)
3768 MSIM_USER_LOOKUP_CB cb, gpointer data)
3769 { 3777 {
3770 MsimMessage *body; 3778 MsimMessage *body;
3771 gchar *field_name; 3779 gchar *field_name;
3772 guint rid, cmd, dsn, lid; 3780 guint rid, cmd, dsn, lid;
3773 3781
3774 g_return_if_fail(MSIM_SESSION_VALID(session)); 3782 g_return_if_fail(MSIM_SESSION_VALID(session));
3775 g_return_if_fail(user != NULL); 3783 g_return_if_fail(user != NULL);
3776 g_return_if_fail(cb != NULL); 3784 /* Callback can be null to not call anything, just lookup & store information. */
3785 /*g_return_if_fail(cb != NULL);*/
3777 3786
3778 purple_debug_info("msim", "msim_lookup_userid: " 3787 purple_debug_info("msim", "msim_lookup_userid: "
3779 "asynchronously looking up <%s>\n", user); 3788 "asynchronously looking up <%s>\n", user);
3780 3789
3781 msim_msg_dump("msim_lookup_user: data=%s\n", (MsimMessage *)data); 3790 msim_msg_dump("msim_lookup_user: data=%s\n", (MsimMessage *)data);