diff libpurple/protocols/myspace/user.c @ 29471:d83ee160ffb6

propagate from branch 'im.pidgin.pidgin' (head eb9385f349a20856b9d3f9911dbc8024caa44052) to branch 'im.pidgin.pidgin.next.minor' (head 439fb2dd7a285d9ca645f65f36ef0f037abe7311)
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Wed, 19 Aug 2009 00:46:04 +0000
parents f541583e31bd
children 57612c4d495b a7f5aa182400 ca106d1e3d6d
line wrap: on
line diff
--- a/libpurple/protocols/myspace/user.c	Mon Mar 02 06:51:50 2009 +0000
+++ b/libpurple/protocols/myspace/user.c	Wed Aug 19 00:46:04 2009 +0000
@@ -41,10 +41,10 @@
 }
 
 /**
- * Get the MsimUser from a PurpleBuddy, creating it if needed.
+ * Get the MsimUser from a PurpleBuddy, optionally creating it if needed.
  */
 MsimUser *
-msim_get_user_from_buddy(PurpleBuddy *buddy)
+msim_get_user_from_buddy(PurpleBuddy *buddy, gboolean create)
 {
 	MsimUser *user;
 
@@ -52,11 +52,13 @@
 		return NULL;
 	}
 
-	if (!(user = purple_buddy_get_protocol_data(buddy))) {
+	user = purple_buddy_get_protocol_data(buddy);
+	if (create && !user) {
 		/* No MsimUser for this buddy; make one. */
 
 		user = g_new0(MsimUser, 1);
 		user->buddy = buddy;
+		user->id = purple_blist_node_get_int(&buddy->node, "UserID");
 		purple_buddy_set_protocol_data(buddy, user);
 	}
 
@@ -94,7 +96,7 @@
 		return NULL;
 	}
 
-	user = msim_get_user_from_buddy(buddy);
+	user = msim_get_user_from_buddy(buddy, TRUE);
 
 	return user;
 }
@@ -108,7 +110,6 @@
 {
 	PurplePresence *presence;
 	gchar *str;
-	guint uid;
 	guint cv;
 
 	/* Useful to identify the account the tooltip refers to.
@@ -117,8 +118,6 @@
 		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];
@@ -638,8 +637,7 @@
 	uid = msim_msg_get_integer(userinfo, "uid");
 	lid = msim_msg_get_integer(userinfo, "lid");
 	body = msim_msg_get_dictionary(userinfo, "body");
-	/* XXX: Mark for translation */
-	errmsg = ("An error occurred while trying to set the username.\n"
+	errmsg = _("An error occurred while trying to set the username.  "
 			"Please try again, or visit http://editprofile.myspace.com/index.cfm?"
 			"fuseaction=profile.username to set your username.");
 
@@ -798,9 +796,9 @@
 	if (!body) {
 		purple_debug_info("msim_username_is_available_cb", "No body for %s?!\n", username);
 		purple_connection_error_reason(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR,
-				"An error occurred while trying to set the username.\n"
+				_("An error occurred while trying to set the username.  "
 				"Please try again, or visit http://editprofile.myspace.com/index.cfm?"
-				"fuseaction=profile.username to set your username.");
+				"fuseaction=profile.username to set your username."));
 		return;
 	}