Mercurial > pidgin.yaz
diff libpurple/protocols/myspace/user.c @ 25374:e22bc87b758b
explicit merge of '9a5e549612efd8ca6f60fc57b51a4eee7e32c861'
and 'f398f87ffee8b1b11295a0a0138936074c5dff7a'
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Fri, 02 Jan 2009 22:09:40 +0000 |
parents | 295464ae2d2a f8dbd57cf635 |
children | 138c729f8c9a |
line wrap: on
line diff
--- a/libpurple/protocols/myspace/user.c Tue Dec 16 03:35:22 2008 +0000 +++ b/libpurple/protocols/myspace/user.c Fri Jan 02 22:09:40 2009 +0000 @@ -52,18 +52,15 @@ return NULL; } - if (!buddy->proto_data) { + if (!(user = purple_buddy_get_protocol_data(buddy))) { /* No MsimUser for this buddy; make one. */ /* TODO: where is this freed? */ user = g_new0(MsimUser, 1); user->buddy = buddy; - user->id = purple_blist_node_get_int(&buddy->node, "UserID"); - buddy->proto_data = (gpointer)user; + purple_buddy_set_protocol_data(buddy, user); } - user = (MsimUser *)(buddy->proto_data); - return user; } @@ -95,6 +92,7 @@ { PurplePresence *presence; gchar *str; + guint uid; guint cv; /* Useful to identify the account the tooltip refers to. @@ -103,6 +101,8 @@ purple_notify_user_info_add_pair(user_info, _("User"), user->username); } + uid = purple_blist_node_get_int((PurpleBlistNode *)user->buddy, "UserID"); + /* a/s/l...the vitals */ if (user->age) { char age[16]; @@ -193,9 +193,9 @@ gsize len, const gchar *error_message) { - MsimUser *user; - - user = (MsimUser *)user_data; + MsimUser *user = (MsimUser *)user_data; + const char *name = purple_buddy_get_name(user->buddy); + PurpleAccount *account; purple_debug_info("msim_downloaded_buddy_icon", "Downloaded %" G_GSIZE_FORMAT " bytes\n", len); @@ -203,12 +203,12 @@ if (!url_text) { purple_debug_info("msim_downloaded_buddy_icon", "failed to download icon for %s", - user->buddy->name); + name); return; } - purple_buddy_icons_set_for_user(user->buddy->account, - user->buddy->name, + account = purple_buddy_get_account(user->buddy); + purple_buddy_icons_set_for_user(account, name, g_memdup((gchar *)url_text, len), len, /* Use URL itself as buddy icon "checksum" (TODO: ETag) */ user->image_url); /* checksum */ @@ -231,7 +231,9 @@ static void msim_set_artist_or_title(MsimUser *user, const char *new_artist, const char *new_title) { PurplePresence *presence; + PurpleAccount *account; const char *prev_artist, *prev_title; + const char *name; if (user->buddy == NULL) /* User not on buddy list so nothing to do */ @@ -245,8 +247,11 @@ if (new_title && !*new_title) new_title = NULL; + account = purple_buddy_get_account(user->buddy); + name = purple_buddy_get_name(user->buddy); + if (!new_artist && !new_title) { - purple_prpl_got_user_status_deactive(user->buddy->account, user->buddy->name, "tune"); + purple_prpl_got_user_status_deactive(account, name, "tune"); return; } @@ -266,7 +271,7 @@ if (!new_title) new_title = prev_title; - purple_prpl_got_user_status(user->buddy->account, user->buddy->name, "tune", + purple_prpl_got_user_status(account, name, "tune", PURPLE_TUNE_TITLE, new_title, PURPLE_TUNE_ARTIST, new_artist, NULL); @@ -283,13 +288,15 @@ static void msim_store_user_info_each(const gchar *key_str, gchar *value_str, MsimUser *user) { + const char *name = user->buddy ? purple_buddy_get_name(user->buddy) : NULL; + if (g_str_equal(key_str, "UserID") || g_str_equal(key_str, "ContactID")) { /* Save to buddy list, if it exists, for quick cached uid lookup with msim_uid2username_from_blist(). */ user->id = atol(value_str); if (user->buddy) { - purple_debug_info("msim", "associating uid %s with username %s\n", key_str, user->buddy->name); - purple_blist_node_set_int(&user->buddy->node, "UserID", user->id); + purple_debug_info("msim", "associating uid %s with username %s\n", key_str, name); + purple_blist_node_set_int(PURPLE_BLIST_NODE(user->buddy), "UserID", user->id); } /* Need to store in MsimUser, too? What if not on blist? */ } else if (g_str_equal(key_str, "Age")) { @@ -339,9 +346,8 @@ /* Instead of showing 'no photo' picture, show nothing. */ if (g_str_equal(user->image_url, "http://x.myspace.com/images/no_pic.gif")) { - purple_buddy_icons_set_for_user(user->buddy->account, - user->buddy->name, - NULL, 0, NULL); + purple_buddy_icons_set_for_user(purple_buddy_get_account(user->buddy), + name, NULL, 0, NULL); return; }