# HG changeset patch
# Node ID 71872437f569
# Parent  83144d32517f
diff --git a/libpurple/protocols/gg/account.c b/libpurple/protocols/gg/account.c
--- a/libpurple/protocols/gg/account.c
+++ b/libpurple/protocols/gg/account.c
@@ -417,6 +417,7 @@
 {
 	ggp_account_chpass_data *chpass_data = _chpass_data;
 	PurpleAccount *account = purple_connection_get_account(chpass_data->gc);
+	PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
 	PurpleRequestFields *fields;
 	PurpleRequestFieldGroup *main_group, *password_group, *token_group;
 	PurpleRequestField *field, *field_password;
@@ -482,7 +483,7 @@
 	chpass_data->token = token;
 
 	primary = g_strdup_printf(_("Change password for %s"),
-		purple_account_get_username(account));
+	                          purple_contact_info_get_username(info));
 
 	purple_request_fields(gc, GGP_ACCOUNT_CHPASS_TITLE, primary,
 		_("Please enter your current password and your new password."),
@@ -498,6 +499,7 @@
 	ggp_account_chpass_data *chpass_data, PurpleRequestFields *fields)
 {
 	PurpleAccount *account = purple_connection_get_account(chpass_data->gc);
+	PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
 	struct gg_http *h;
 	uin_t uin;
 
@@ -544,7 +546,7 @@
 		return;
 	}
 
-	uin = ggp_str_to_uin(purple_account_get_username(account));
+	uin = ggp_str_to_uin(purple_contact_info_get_username(info));
 	purple_debug_info("gg", "ggp_account_chpass_dialog_ok: validation ok "
 		"[token id=%s, value=%s]\n",
 		chpass_data->token->id, chpass_data->token_value);
diff --git a/libpurple/protocols/gg/avatar.c b/libpurple/protocols/gg/avatar.c
--- a/libpurple/protocols/gg/avatar.c
+++ b/libpurple/protocols/gg/avatar.c
@@ -181,7 +181,9 @@
 	buddy = purple_blist_find_buddy(account, ggp_uin_to_str(uin));
 
 	if (!buddy) {
-		if (ggp_str_to_uin(purple_account_get_username(account)) == uin) {
+		PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
+
+		if (ggp_str_to_uin(purple_contact_info_get_username(info)) == uin) {
 			purple_debug_misc(
 			        "gg",
 			        "ggp_avatar_buddy_update(%p): own avatar update requested, "
@@ -288,7 +290,8 @@
 	PurpleImage *img = _img;
 	gchar *img_data, *uin_str;
 	PurpleAccount *account = purple_connection_get_account(gc);
-	uin_t uin = ggp_str_to_uin(purple_account_get_username(account));
+	PurpleContactInfo *contact_info = PURPLE_CONTACT_INFO(account);
+	uin_t uin = ggp_str_to_uin(purple_contact_info_get_username(contact_info));
 
 	if (img != avdata->own_img) {
 		purple_debug_warning("gg", "ggp_avatar_own_got_token: "
diff --git a/libpurple/protocols/gg/chat.c b/libpurple/protocols/gg/chat.c
--- a/libpurple/protocols/gg/chat.c
+++ b/libpurple/protocols/gg/chat.c
@@ -217,10 +217,11 @@
 			purple_debug_warning("gg", "ggp_chat_got_event: "
 				"unknown update type - %d", eciu->type);
 	} else if (ev->type == GG_EVENT_CHAT_CREATED) {
-		const struct gg_event_chat_created *ecc =
-			&ev->event.chat_created;
-		uin_t me = ggp_str_to_uin(purple_account_get_username(
-			purple_connection_get_account(gc)));
+		PurpleAccount *account = purple_connection_get_account(gc);
+		PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
+		const struct gg_event_chat_created *ecc = &ev->event.chat_created;
+
+		uin_t me = ggp_str_to_uin(purple_contact_info_get_username(info));
 		chat = ggp_chat_new(gc, ecc->id);
 		ggp_chat_joined(chat, me);
 		ggp_chat_open_conv(chat);
@@ -263,6 +264,8 @@
 
 static void ggp_chat_left(ggp_chat_local_info *chat, uin_t uin)
 {
+	PurpleAccount *account = NULL;
+	PurpleContactInfo *info = NULL;
 	uin_t me;
 	int idx = ggp_chat_participant_find(chat, uin);
 
@@ -281,8 +284,9 @@
 	if (chat->conv == NULL)
 		return;
 
-	me = ggp_str_to_uin(purple_account_get_username(
-		purple_connection_get_account(chat->gc)));
+	account = purple_connection_get_account(chat->gc);
+	info = PURPLE_CONTACT_INFO(account);
+	me = ggp_str_to_uin(purple_contact_info_get_username(info));
 
 	if (me == uin) {
 		purple_conversation_write_system_message(
@@ -434,6 +438,8 @@
 ggp_chat_leave(PurpleProtocolChat *protocol_chat, PurpleConnection *gc,
                gint local_id)
 {
+	PurpleAccount *account = NULL;
+	PurpleContactInfo *contact_info = NULL;
 	GGPInfo *info = purple_connection_get_protocol_data(gc);
 	ggp_chat_local_info *chat;
 	uin_t me;
@@ -452,8 +458,9 @@
 	}
 	chat->conv = NULL;
 
-	me = ggp_str_to_uin(purple_account_get_username(
-		purple_connection_get_account(chat->gc)));
+	account = purple_connection_get_account(chat->gc);
+	contact_info = PURPLE_CONTACT_INFO(account);
+	me = ggp_str_to_uin(purple_contact_info_get_username(contact_info));
 
 	ggp_chat_left(chat, me);
 	chat->left = TRUE;
@@ -486,6 +493,8 @@
 ggp_chat_send(PurpleProtocolChat *protocol_chat, PurpleConnection *gc,
               gint local_id, PurpleMessage *msg)
 {
+	PurpleAccount *account = NULL;
+	PurpleContactInfo *contact_info = NULL;
 	GGPInfo *info = purple_connection_get_protocol_data(gc);
 	GDateTime *dt = NULL;
 	PurpleConversation *conv;
@@ -514,7 +523,9 @@
 		succ = FALSE;
 	g_free(gg_msg);
 
-	me = purple_account_get_username(purple_connection_get_account(gc));
+	account = purple_connection_get_account(gc);
+	contact_info = PURPLE_CONTACT_INFO(account);
+	me = purple_contact_info_get_username(contact_info);
 	dt = purple_message_get_timestamp(msg);
 	purple_serv_got_chat_in(gc, chat->local_id, me,
 		purple_message_get_flags(msg),
@@ -528,11 +539,13 @@
 	const char *message, time_t time, uin_t who)
 {
 	PurpleAccount *account = NULL;
+	PurpleContactInfo *info = NULL;
 	ggp_chat_local_info *chat;
 	uin_t me;
 
 	account = purple_connection_get_account(gc);
-	me = ggp_str_to_uin(purple_account_get_username(account));
+	info = PURPLE_CONTACT_INFO(account);
+	me = ggp_str_to_uin(purple_contact_info_get_username(info));
 
 	chat = ggp_chat_get(gc, chat_id);
 	if (!chat) {
@@ -544,11 +557,14 @@
 	ggp_chat_open_conv(chat);
 	if (who == me) {
 		GDateTime *dt = NULL;
+		PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
 		PurpleMessage *pmsg;
+		const char *username = NULL;
 
-		pmsg = purple_message_new_outgoing(
-			purple_account_get_name_for_display(account),
-			ggp_uin_to_str(who), message, 0);
+		username = purple_contact_info_get_name_for_display(info);
+
+		pmsg = purple_message_new_outgoing(username, ggp_uin_to_str(who),
+		                                   message, 0);
 
 		dt = g_date_time_new_from_unix_local((gint64)time);
 		purple_message_set_timestamp(pmsg, dt);
diff --git a/libpurple/protocols/gg/gg.c b/libpurple/protocols/gg/gg.c
--- a/libpurple/protocols/gg/gg.c
+++ b/libpurple/protocols/gg/gg.c
@@ -102,10 +102,12 @@
 	return NULL;
 }
 
-uin_t ggp_own_uin(PurpleConnection *gc)
-{
-	return ggp_str_to_uin(purple_account_get_username(
-		purple_connection_get_account(gc)));
+uin_t
+ggp_own_uin(PurpleConnection *gc) {
+	PurpleAccount *account = purple_connection_get_account(gc);
+	PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
+
+	return ggp_str_to_uin(purple_contact_info_get_username(info));
 }
 
 /* ---------------------------------------------------------------------- */
@@ -132,9 +134,12 @@
 			_("Buddylist saved successfully!"), NULL,
 			purple_request_cpar_from_connection(gc));
 	} else {
-		gchar *primary = g_strdup_printf(
-			_("Couldn't write buddy list for %s to %s"),
-			purple_account_get_username(account), filename);
+		PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
+		gchar *primary = NULL;
+
+		primary = g_strdup_printf(_("Couldn't write buddy list for %s to %s"),
+		                          purple_contact_info_get_username(info),
+		                          filename);
 		purple_notify_error(account, _("Save Buddylist..."),
 			primary, NULL, purple_request_cpar_from_connection(gc));
 		g_free(primary);
@@ -786,6 +791,7 @@
 static void
 ggp_login(G_GNUC_UNUSED PurpleProtocol *protocol, PurpleAccount *account) {
 	PurpleConnection *gc = purple_account_get_connection(account);
+	PurpleContactInfo *contact_info = PURPLE_CONTACT_INFO(account);
 	struct gg_login_params *glp;
 	GGPInfo *info;
 	const char *address;
@@ -825,7 +831,7 @@
 	ggp_edisc_setup(gc, resolver);
 	g_object_unref(resolver);
 
-	glp->uin = ggp_str_to_uin(purple_account_get_username(account));
+	glp->uin = ggp_str_to_uin(purple_contact_info_get_username(contact_info));
 	glp->password =
 		ggp_convert_to_cp1250(purple_connection_get_password(gc));
 
@@ -977,14 +983,16 @@
               PurpleBuddy *buddy, PurpleGroup *group, const gchar *message)
 {
 	PurpleAccount *account = purple_connection_get_account(gc);
+	PurpleContactInfo *contact_info = PURPLE_CONTACT_INFO(account);
 	GGPInfo *info = purple_connection_get_protocol_data(gc);
 	const gchar *name = purple_buddy_get_name(buddy);
 
 	gg_add_notify(info->session, ggp_str_to_uin(name));
 
 	/* gg server won't tell us our status here */
-	if (purple_strequal(purple_account_get_username(account), name))
+	if(purple_strequal(purple_contact_info_get_username(contact_info), name)) {
 		ggp_status_fake_to_self(gc);
+	}
 
 	ggp_roster_add_buddy(protocol_server, gc, buddy, group, message);
 	ggp_pubdir_request_buddy_alias(gc, buddy);
diff --git a/libpurple/protocols/gg/image-prpl.c b/libpurple/protocols/gg/image-prpl.c
--- a/libpurple/protocols/gg/image-prpl.c
+++ b/libpurple/protocols/gg/image-prpl.c
@@ -164,12 +164,15 @@
 void ggp_image_send(PurpleConnection *gc,
 	const struct gg_event_image_request *image_request)
 {
+	PurpleAccount *account = purple_connection_get_account(gc);
+	PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
 	GGPInfo *accdata = purple_connection_get_protocol_data(gc);
 	ggp_image_session_data *sdata = ggp_image_get_sdata(gc);
 	ggp_image_sent *sent_image;
 	PurpleConversation *conv;
 	PurpleConversationManager *manager;
 	uint64_t id;
+	uint64_t sender;
 	gchar *gg_filename;
 
 	purple_debug_info("gg", "ggp_image_send: got image request "
@@ -182,9 +185,8 @@
 
 	sent_image = g_hash_table_lookup(sdata->sent_images, &id);
 
-	if (sent_image == NULL && image_request->sender == ggp_str_to_uin(
-		purple_account_get_username(purple_connection_get_account(gc))))
-	{
+	sender = ggp_str_to_uin(purple_contact_info_get_username(info));
+	if (sent_image == NULL && image_request->sender == sender) {
 		purple_debug_misc("gg", "ggp_image_send: requested image "
 			"not found, but this may be another session request\n");
 		return;
diff --git a/libpurple/protocols/gg/message-prpl.c b/libpurple/protocols/gg/message-prpl.c
--- a/libpurple/protocols/gg/message-prpl.c
+++ b/libpurple/protocols/gg/message-prpl.c
@@ -240,12 +240,14 @@
 	} else if (msg->type == GGP_MESSAGE_GOT_TYPE_MULTILOGON) {
 		GDateTime *dt = NULL;
 		PurpleAccount *account = NULL;
+		PurpleContactInfo *info = NULL;
 		PurpleConversation *im = ggp_message_get_conv(gc, msg->user);
 		PurpleMessage *pmsg;
 		const gchar *me = NULL;
 
 		account = purple_connection_get_account(gc);
-		me = purple_account_get_name_for_display(account);
+		info = PURPLE_CONTACT_INFO(account);
+		me = purple_contact_info_get_name_for_display(info);
 
 		pmsg = purple_message_new_outgoing(me, NULL, msg->text, 0);
 
diff --git a/libpurple/protocols/gg/oauth/oauth-purple.c b/libpurple/protocols/gg/oauth/oauth-purple.c
--- a/libpurple/protocols/gg/oauth/oauth-purple.c
+++ b/libpurple/protocols/gg/oauth/oauth-purple.c
@@ -107,15 +107,17 @@
 
 	if (data->sign_url) {
 		PurpleAccount *account;
+		PurpleContactInfo *info = NULL;
 		gchar *auth;
 
 		purple_debug_misc("gg", "ggp_oauth_access_token_got: got access token, "
 		                        "returning signed url");
 
 		account = purple_connection_get_account(data->gc);
+		info = PURPLE_CONTACT_INFO(account);
 		auth = gg_oauth_generate_header(
 		        data->sign_method, data->sign_url,
-		        purple_account_get_username(account),
+		        purple_contact_info_get_username(info),
 		        purple_connection_get_password(data->gc), token, token_secret);
 		data->callback(data->gc, auth, data->user_data);
 	} else {
@@ -136,6 +138,7 @@
 {
 	ggp_oauth_data *data = user_data;
 	PurpleAccount *account;
+	PurpleContactInfo *info = NULL;
 	SoupStatus status_code;
 	char *auth;
 	SoupMessage *msg = NULL;
@@ -145,6 +148,7 @@
 	PURPLE_ASSERT_CONNECTION_IS_VALID(data->gc);
 
 	account = purple_connection_get_account(data->gc);
+	info = PURPLE_CONTACT_INFO(account);
 
 	status_code = soup_message_get_status(data->msg);
 	if (status_code != 302) {
@@ -159,7 +163,7 @@
 	                        "requesting access token...");
 
 	auth = gg_oauth_generate_header(method, url,
-	                                purple_account_get_username(account),
+	                                purple_contact_info_get_username(info),
 	                                purple_connection_get_password(data->gc),
 	                                data->token, data->token_secret);
 
@@ -240,7 +244,7 @@
 	request_data = g_strdup_printf(
 		"callback_url=http://www.mojageneracja.pl&request_token=%s&"
 		"uin=%s&password=%s", data->token,
-		purple_account_get_username(account),
+		purple_contact_info_get_username(PURPLE_CONTACT_INFO(account)),
 		purple_connection_get_password(data->gc));
 
 	g_clear_object(&data->msg);
@@ -274,7 +278,8 @@
 	purple_debug_misc("gg", "ggp_oauth_request: requesting token...\n");
 
 	auth = gg_oauth_generate_header(
-	        method, url, purple_account_get_username(account),
+	        method, url,
+	        purple_contact_info_get_username(PURPLE_CONTACT_INFO(account)),
 	        purple_connection_get_password(gc), NULL, NULL);
 
 	data = g_new0(ggp_oauth_data, 1);
diff --git a/libpurple/protocols/gg/pubdir-prpl.c b/libpurple/protocols/gg/pubdir-prpl.c
--- a/libpurple/protocols/gg/pubdir-prpl.c
+++ b/libpurple/protocols/gg/pubdir-prpl.c
@@ -886,9 +886,10 @@
 static void
 ggp_pubdir_set_info_request(PurpleConnection *gc, PurpleRequestFields *fields)
 {
+	PurpleAccount *account = purple_connection_get_account(gc);
+	PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
 	gchar *url;
-	uin_t uin = ggp_str_to_uin(
-	        purple_account_get_username(purple_connection_get_account(gc)));
+	uin_t uin = ggp_str_to_uin(purple_contact_info_get_username(info));
 	ggp_pubdir_record *record = g_new0(ggp_pubdir_record, 1);
 	gchar *birth_s;
 
@@ -1003,8 +1004,10 @@
 void
 ggp_pubdir_set_info(PurpleConnection *gc)
 {
+	PurpleAccount *account = purple_connection_get_account(gc);
+	PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
+
 	ggp_pubdir_get_info(gc,
-	                    ggp_str_to_uin(purple_account_get_username(
-	                            purple_connection_get_account(gc))),
+	                    ggp_str_to_uin(purple_contact_info_get_username(info)),
 	                    ggp_pubdir_set_info_dialog, NULL);
 }
diff --git a/libpurple/protocols/gg/status.c b/libpurple/protocols/gg/status.c
--- a/libpurple/protocols/gg/status.c
+++ b/libpurple/protocols/gg/status.c
@@ -302,6 +302,7 @@
 void ggp_status_fake_to_self(PurpleConnection *gc)
 {
 	PurpleAccount *account = purple_connection_get_account(gc);
+	PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
 	PurpleStatus *status = purple_presence_get_active_status(
 		purple_account_get_presence(account));
 	const char *status_msg = purple_status_get_attr_string(status,
@@ -315,7 +316,7 @@
 	}
 
 	purple_protocol_got_user_status(account,
-		purple_account_get_username(account),
+		purple_contact_info_get_username(info),
 		purple_status_get_id(status),
 		status_msg_gg ? "message" : NULL, status_msg_gg, NULL);
 
@@ -401,13 +402,14 @@
 	const char *descr)
 {
 	PurpleAccount *account = purple_connection_get_account(gc);
+	PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
 	PurpleBuddy *buddy = purple_blist_find_buddy(account, ggp_uin_to_str(uin));
 	const gchar *purple_status = ggp_status_to_purplestatus(status);
 	gchar *status_message = NULL;
 	gboolean is_own;
 
 	is_own = (!g_strcmp0(ggp_uin_to_str(uin),
-		purple_account_get_username(account)));
+	                     purple_contact_info_get_username(info)));
 
 	if (!buddy) {
 		if (!is_own) {
@@ -429,7 +431,7 @@
 		}
 	}
 
-	if (uin == ggp_str_to_uin(purple_account_get_username(account))) {
+	if (uin == ggp_str_to_uin(purple_contact_info_get_username(info))) {
 		purple_debug_info("gg", "ggp_status_got_others_buddy: "
 			"own status changed to %s [%s]\n",
 			purple_status, status_message ? status_message : "");
diff --git a/libpurple/protocols/gg/utils.c b/libpurple/protocols/gg/utils.c
--- a/libpurple/protocols/gg/utils.c
+++ b/libpurple/protocols/gg/utils.c
@@ -61,12 +61,14 @@
 	return buff;
 }
 
-uin_t ggp_get_my_uin(PurpleConnection *gc)
-{
+uin_t
+ggp_get_my_uin(PurpleConnection *gc) {
+	PurpleAccount *account = purple_connection_get_account(gc);
+	PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
+
 	g_return_val_if_fail(gc != NULL, 0);
 
-	return ggp_str_to_uin(purple_account_get_username(
-		purple_connection_get_account(gc)));
+	return ggp_str_to_uin(purple_contact_info_get_username(info));
 }
 
 static gchar * ggp_convert(const gchar *src, const char *srcenc,
