pidgin: ce75e981: Keep track of the user ID in the MsimUse...
markdoliner at pidgin.im
markdoliner at pidgin.im
Thu Dec 11 23:05:36 EST 2008
-----------------------------------------------------------------
Revision: ce75e981fb02f075fc398b19d6ad5d2805046d0c
Ancestor: 7e2bf94f266d33384815fb9d3128f997c7df6b97
Author: markdoliner at pidgin.im
Date: 2008-12-12T04:01:39
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/ce75e981fb02f075fc398b19d6ad5d2805046d0c
Modified files:
libpurple/protocols/myspace/myspace.c
libpurple/protocols/myspace/user.c
libpurple/protocols/myspace/user.h
ChangeLog:
Keep track of the user ID in the MsimUser struct so that we have a copy
even for people who aren't in our buddy list. This fixes the "View web
profile" link when getting info for people not in our buddy list.
-------------- next part --------------
============================================================
--- libpurple/protocols/myspace/myspace.c 092128494d76c42d7b21e5bf322d99d15d72ea64
+++ libpurple/protocols/myspace/myspace.c cf98578d19f7b7c86eff33653ff276b8108a7141
@@ -1018,7 +1018,6 @@ msim_get_info(PurpleConnection *gc, cons
{
MsimSession *session;
MsimUser *user;
- guint uid;
gchar *user_to_lookup;
MsimMessage *user_msg;
@@ -1033,8 +1032,8 @@ msim_get_info(PurpleConnection *gc, cons
user = msim_find_user(session, username);
/* If is on buddy list, lookup by uid since it is faster. */
- if (user && (uid = purple_blist_node_get_int(&user->buddy->node, "UserID"))) {
- user_to_lookup = g_strdup_printf("%d", uid);
+ if (user && user->id) {
+ user_to_lookup = g_strdup_printf("%d", user->id);
} else {
/* Looking up buddy not on blist. Lookup by whatever user entered. */
user_to_lookup = g_strdup(username);
@@ -1970,10 +1969,11 @@ msim_incoming_status(MsimSession *sessio
purple_blist_add_buddy(buddy, NULL, NULL, NULL);
user = msim_get_user_from_buddy(buddy);
+ user->id = msim_msg_get_integer(msg, "f");
- /* All buddies on list should have a UserID integer associated with them. */
- purple_blist_node_set_int(&buddy->node, "UserID", msim_msg_get_integer(msg, "f"));
-
+ /* Keep track of the user ID across sessions */
+ purple_blist_node_set_int(&buddy->node, "UserID", user->id);
+
msim_store_user_info(session, msg, NULL);
} else {
purple_debug_info("msim", "msim_status: found buddy %s\n", username);
@@ -2866,7 +2866,8 @@ msim_add_contact_from_server_cb(MsimSess
/* 3. Update buddy information */
user = msim_get_user_from_buddy(buddy);
- /* All buddies on list should have 'uid' integer associated with them. */
+ user->id = uid;
+ /* Keep track of the user ID across sessions */
purple_blist_node_set_int(&buddy->node, "UserID", uid);
/* Stores a few fields in the MsimUser, relevant to the buddy itself.
============================================================
--- libpurple/protocols/myspace/user.c 33a9e05ef8de35a7d658fda2e4761f614ebf523f
+++ libpurple/protocols/myspace/user.c 40005b3121e9d4145488978c1c53c297f38c4574
@@ -63,6 +63,7 @@ msim_get_user_from_buddy(PurpleBuddy *bu
/* 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;
}
@@ -96,7 +97,6 @@ msim_append_user_info(MsimSession *sessi
{
PurplePresence *presence;
gchar *str;
- guint uid;
guint cv;
/* Useful to identify the account the tooltip refers to.
@@ -170,13 +170,12 @@ msim_append_user_info(MsimSession *sessi
g_free(client);
}
- uid = user->buddy ? purple_blist_node_get_int(&user->buddy->node, "UserID") : 0;
- if (full && uid) {
+ if (full && user->id) {
/* TODO: link to username, if available */
char *profile;
purple_notify_user_info_add_section_break(user_info);
profile = g_strdup_printf("<a href=\"http://myspace.com/%d\">%s</a>",
- uid, _("View web profile"));
+ user->id, _("View web profile"));
purple_notify_user_info_add_pair(user_info, NULL, profile);
g_free(profile);
}
@@ -251,10 +250,11 @@ msim_store_user_info_each(const gchar *k
{
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", atol(value_str));
+ purple_blist_node_set_int(&user->buddy->node, "UserID", user->id);
}
/* Need to store in MsimUser, too? What if not on blist? */
} else if (g_str_equal(key_str, "Age")) {
============================================================
--- libpurple/protocols/myspace/user.h e630e48e95179f76d169f70dc8ceb53c8c8b7994
+++ libpurple/protocols/myspace/user.h 7e2ccaebb860d58b5b7345b65f33998dc6f1c04b
@@ -25,6 +25,7 @@ typedef struct _MsimUser
typedef struct _MsimUser
{
PurpleBuddy *buddy;
+ int id;
guint client_cv;
gchar *client_info;
guint age;
More information about the Commits
mailing list