# HG changeset patch
# Node ID 40062bdb5f1e0bf57a8978805aaf80ee9ac334b9
# Parent  5c55680a1a6b5689f7dee66d0aebbb470ac7ffc6
diff --git a/libpurple/accounts.c b/libpurple/accounts.c
--- a/libpurple/accounts.c
+++ b/libpurple/accounts.c
@@ -217,10 +217,9 @@
 			purple_proxy_info_set_proxy_type(proxy_info, PURPLE_PROXY_TYPE_USE_ENVVAR);
 		else
 		{
-			PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
 			purple_debug_error("accounts", "Invalid proxy type found when "
 			                   "loading account information for %s\n",
-			                   purple_contact_info_get_username(info));
+			                   purple_account_get_username(account));
 		}
 		g_free(data);
 	}
@@ -288,13 +287,11 @@
 	g_free(type_str);
 
 	if(type > PURPLE_CONNECTION_ERROR_OTHER_ERROR) {
-		PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
-
 		purple_debug_error("accounts",
 		                   "Invalid PurpleConnectionError value %d found when "
 		                   "loading account information for %s\n",
 		                   type,
-		                   purple_contact_info_get_username(info));
+		                   purple_account_get_username(account));
 		type = PURPLE_CONNECTION_ERROR_OTHER_ERROR;
 	}
 
@@ -384,7 +381,10 @@
 	if ((child != NULL) && ((data = purple_xmlnode_get_data(child)) != NULL))
 	{
 		if (*data != '\0') {
-			purple_contact_info_set_alias(PURPLE_CONTACT_INFO(ret), data);
+			PurpleContactInfo *info = NULL;
+
+			info = purple_account_get_contact_info(ret);
+			purple_contact_info_set_alias(info, data);
 		}
 		g_free(data);
 	}
@@ -458,11 +458,9 @@
 
 	r = purple_credential_manager_clear_password_finish(manager, res, &error);
 	if(r != TRUE) {
-		PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
-
 		purple_debug_warning("accounts",
 		                     "Failed to remove password for account %s: %s",
-		                     purple_contact_info_get_name_for_display(info),
+		                     purple_account_get_username(account),
 		                     (error != NULL) ? error->message : "Unknown error");
 
 		g_clear_error(&error);
diff --git a/libpurple/connection.c b/libpurple/connection.c
--- a/libpurple/connection.c
+++ b/libpurple/connection.c
@@ -773,18 +773,15 @@
 purple_connection_connect(PurpleConnection *connection, GError **error) {
 	PurpleConnectionClass *klass = NULL;
 	PurpleConnectionPrivate *priv = NULL;
-	PurpleContactInfo *info = NULL;
 
 	g_return_val_if_fail(PURPLE_IS_CONNECTION(connection), FALSE);
 
 	priv = purple_connection_get_instance_private(connection);
 
-	info = PURPLE_CONTACT_INFO(priv->account);
-
 	if(!purple_account_is_disconnected(priv->account)) {
 		g_set_error(error, PURPLE_CONNECTION_ERROR, 0,
 		            "account %s is not disconnected",
-		            purple_contact_info_get_username(info));
+		            purple_account_get_username(priv->account));
 
 		return TRUE;
 	}
@@ -795,7 +792,7 @@
 	{
 		g_set_error(error, PURPLE_CONNECTION_ERROR, 0,
 		            "Cannot connect to account %s without a password.",
-		            purple_contact_info_get_username(info));
+		            purple_account_get_username(priv->account));
 
 		return FALSE;
 	}
@@ -810,7 +807,7 @@
 
 	g_set_error(error, PURPLE_CONNECTION_ERROR, 0,
 	            "The connection for %s did not implement the connect method",
-	            purple_contact_info_get_username(info));
+	            purple_account_get_username(priv->account));
 
 	return FALSE;
 }
diff --git a/libpurple/plugins/idle/idle.c b/libpurple/plugins/idle/idle.c
--- a/libpurple/plugins/idle/idle.c
+++ b/libpurple/plugins/idle/idle.c
@@ -57,7 +57,6 @@
 static void
 set_idle_time(PurpleAccount *acct, int mins_idle) {
 	PurpleConnection *gc = purple_account_get_connection(acct);
-	PurpleContactInfo *info = PURPLE_CONTACT_INFO(acct);
 	PurplePresence *presence = purple_account_get_presence(acct);
 	GDateTime *idle_since = NULL;
 
@@ -66,7 +65,7 @@
 	}
 
 	purple_debug_info("idle", "setting idle time for %s to %d\n",
-	                  purple_contact_info_get_username(info), mins_idle);
+	                  purple_account_get_username(acct), mins_idle);
 
 	if(mins_idle > 0) {
 		GDateTime *now = g_date_time_new_now_local();
@@ -87,13 +86,12 @@
 static void
 idle_action_ok(G_GNUC_UNUSED gpointer data, PurpleRequestPage *page) {
 	PurpleAccount *acct = purple_request_page_get_account(page, "acct");
-	PurpleContactInfo *info = PURPLE_CONTACT_INFO(acct);
 	int tm = purple_request_page_get_integer(page, "mins");
 
 	/* only add the account to the GList if it's not already been idled */
 	if(!unidle_filter(acct, NULL)) {
 		purple_debug_misc("idle", "%s hasn't been idled yet; adding to list.",
-		                  purple_contact_info_get_username(info));
+		                  purple_account_get_username(acct));
 		idled_accts = g_list_append(idled_accts, acct);
 	}
 
@@ -113,10 +111,8 @@
 		acct = (PurpleAccount *)(iter->data);
 
 		if(acct && idleable_filter(acct, NULL)) {
-			PurpleContactInfo *info = PURPLE_CONTACT_INFO(acct);
-
 			purple_debug_misc("idle", "Idling %s.\n",
-			                  purple_contact_info_get_username(info));
+			                  purple_account_get_username(acct));
 
 			set_idle_time(acct, tm);
 
diff --git a/libpurple/plugins/kwallet/purplekwallet.cpp b/libpurple/plugins/kwallet/purplekwallet.cpp
--- a/libpurple/plugins/kwallet/purplekwallet.cpp
+++ b/libpurple/plugins/kwallet/purplekwallet.cpp
@@ -75,10 +75,8 @@
 
 static QString
 purple_kwallet_provider_account_key(PurpleAccount *account) {
-	PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
-
 	return QString(purple_account_get_protocol_id(account)) + ":" +
-	               purple_contact_info_get_username(info);
+	               purple_account_get_username(account);
 }
 
 static void
diff --git a/libpurple/plugins/libsecret/libsecret.c b/libpurple/plugins/libsecret/libsecret.c
--- a/libpurple/plugins/libsecret/libsecret.c
+++ b/libpurple/plugins/libsecret/libsecret.c
@@ -148,7 +148,6 @@
                                      GAsyncReadyCallback callback,
                                      gpointer data)
 {
-	PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
 	GTask *task = NULL;
 
 	task = g_task_new(provider, cancellable, callback, data);
@@ -156,7 +155,7 @@
 
 	secret_password_lookup(&purple_libsecret_schema, cancellable,
                            purple_libsecret_read_password_callback, task,
-                           "user", purple_contact_info_get_username(info),
+                           "user", purple_account_get_username(account),
                            "protocol", purple_account_get_protocol_id(account),
                            NULL);
 }
@@ -175,19 +174,19 @@
 static void
 purple_libsecret_write_password_async(PurpleCredentialProvider *provider,
                                       PurpleAccount *account,
-                                      const gchar *password,
+                                      const char *password,
                                       GCancellable *cancellable,
                                       GAsyncReadyCallback callback,
                                       gpointer data)
 {
-	PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
 	GTask *task = NULL;
-	gchar *label = NULL;
-	const gchar *username = NULL;
+	char *label = NULL;
+	const char *username = NULL;
 
 	task = g_task_new(provider, cancellable, callback, data);
 	g_task_set_source_tag(task, purple_libsecret_write_password_async);
-	username = purple_contact_info_get_username(info);
+
+	username = purple_account_get_username(account);
 
 	label = g_strdup_printf(_("libpurple password for account %s"), username);
 	secret_password_store(&purple_libsecret_schema,
@@ -218,7 +217,6 @@
                                       GAsyncReadyCallback callback,
                                       gpointer data)
 {
-	PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
 	GTask *task = NULL;
 
 	task = g_task_new(provider, cancellable, callback, data);
@@ -226,7 +224,7 @@
 
 	secret_password_clear(&purple_libsecret_schema, cancellable,
 	                      purple_libsecret_clear_password_callback, task,
-	                      "user", purple_contact_info_get_username(info),
+	                      "user", purple_account_get_username(account),
 	                      "protocol", purple_account_get_protocol_id(account),
 	                      NULL);
 }
diff --git a/libpurple/purpleaccountmanager.c b/libpurple/purpleaccountmanager.c
--- a/libpurple/purpleaccountmanager.c
+++ b/libpurple/purpleaccountmanager.c
@@ -633,10 +633,8 @@
 			new_index--;
 		}
 	} else {
-		PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
-
 		g_critical("Unregistered account (%s) found during reorder!",
-		           purple_contact_info_get_username(info));
+		           purple_account_get_username(account));
 
 		return;
 	}
@@ -657,9 +655,8 @@
 
 	for(guint index = 0; index < manager->accounts->len; index++) {
 		PurpleAccount *account = g_ptr_array_index(manager->accounts, index);
-		PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
 
-		if(purple_strequal(purple_contact_info_get_id(info), id)) {
+		if(purple_strequal(purple_account_get_id(account), id)) {
 			return g_object_ref(account);
 		}
 	}
@@ -669,7 +666,7 @@
 
 PurpleAccount *
 purple_account_manager_find(PurpleAccountManager *manager,
-                            const gchar *username, const gchar *protocol_id)
+                            const char *username, const char *protocol_id)
 {
 	g_return_val_if_fail(PURPLE_IS_ACCOUNT_MANAGER(manager), NULL);
 	g_return_val_if_fail(username != NULL, NULL);
@@ -677,11 +674,10 @@
 
 	for(guint index = 0; index < manager->accounts->len; index++) {
 		PurpleAccount *account = g_ptr_array_index(manager->accounts, index);
-		PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
-		gchar *normalized = NULL;
-		const gchar *existing_protocol_id = NULL;
-		const gchar *existing_username = NULL;
-		const gchar *existing_normalized = NULL;
+		char *normalized = NULL;
+		const char *existing_protocol_id = NULL;
+		const char *existing_username = NULL;
+		const char *existing_normalized = NULL;
 
 		/* Check if the protocol id matches what the user asked for. */
 		existing_protocol_id = purple_account_get_protocol_id(account);
@@ -690,7 +686,7 @@
 		}
 
 		/* Finally verify the username. */
-		existing_username = purple_contact_info_get_username(info);
+		existing_username = purple_account_get_username(account);
 		normalized = g_strdup(purple_normalize(account, username));
 		existing_normalized = purple_normalize(account, existing_username);
 
diff --git a/libpurple/purpleauthorizationrequestnotification.c b/libpurple/purpleauthorizationrequestnotification.c
--- a/libpurple/purpleauthorizationrequestnotification.c
+++ b/libpurple/purpleauthorizationrequestnotification.c
@@ -52,7 +52,6 @@
 {
 	PurpleAccount *account = NULL;
 	PurpleAuthorizationRequest *request = NULL;
-	PurpleContactInfo *info = NULL;
 	PurpleNotification *notification = PURPLE_NOTIFICATION(auth_notification);
 	char *title = NULL;
 	const char *alias = NULL;
@@ -60,7 +59,6 @@
 
 	request = auth_notification->authorization_request;
 	account = purple_authorization_request_get_account(request);
-	info = PURPLE_CONTACT_INFO(account);
 	username = purple_authorization_request_get_username(request);
 	alias = purple_authorization_request_get_alias(request);
 
@@ -68,12 +66,12 @@
 		title = g_strdup_printf(_("%s (%s) would like to add %s to their"
 		                          " contact list"),
 		                        alias, username,
-		                        purple_contact_info_get_username(info));
+		                        purple_account_get_username(account));
 	} else {
 		title = g_strdup_printf(_("%s would like to add %s to their contact"
 		                          " list"),
 		                        username,
-		                        purple_contact_info_get_username(info));
+		                        purple_account_get_username(account));
 	}
 
 	purple_notification_set_title(notification, title);
diff --git a/libpurple/purpleconversation.c b/libpurple/purpleconversation.c
--- a/libpurple/purpleconversation.c
+++ b/libpurple/purpleconversation.c
@@ -177,9 +177,10 @@
 	/* Remove the account from the conversation if it's a member. */
 	if(PURPLE_IS_ACCOUNT(conversation->account)) {
 		if(PURPLE_IS_CONVERSATION_MEMBER(member)) {
-			purple_conversation_remove_member(conversation,
-			                                  PURPLE_CONTACT_INFO(conversation->account),
-			                                  FALSE, NULL);
+			PurpleContactInfo *info = NULL;
+
+			info = purple_account_get_contact_info(conversation->account);
+			purple_conversation_remove_member(conversation, info, FALSE, NULL);
 		}
 	}
 
@@ -187,9 +188,10 @@
 		GObject *obj = NULL;
 
 		if(PURPLE_IS_ACCOUNT(conversation->account)) {
-			purple_conversation_add_member(conversation,
-			                               PURPLE_CONTACT_INFO(account),
-			                               FALSE, NULL);
+			PurpleContactInfo *info = NULL;
+
+			info = purple_account_get_contact_info(account);
+			purple_conversation_add_member(conversation, info, FALSE, NULL);
 
 			g_signal_connect_object(account, "notify::connected",
 			                        G_CALLBACK(purple_conversation_account_connected_cb),
@@ -338,7 +340,7 @@
 
 	protocol = purple_account_get_protocol(account);
 
-	me = purple_contact_info_get_name_for_display(PURPLE_CONTACT_INFO(account));
+	me = purple_account_get_username(account);
 
 	/* Always linkify the text for display, unless we're explicitly asked to do
 	 * otherwise. */
@@ -1343,7 +1345,7 @@
 	}
 
 	account = purple_conversation_get_account(conversation);
-	account_info = PURPLE_CONTACT_INFO(account);
+	account_info = purple_account_get_contact_info(account);
 
 	str = g_string_new("");
 
diff --git a/libpurple/purplecredentialmanager.c b/libpurple/purplecredentialmanager.c
--- a/libpurple/purplecredentialmanager.c
+++ b/libpurple/purplecredentialmanager.c
@@ -531,7 +531,7 @@
 	if(!purple_account_get_remember_password(account)) {
 		const char *name = NULL;
 
-		name = purple_contact_info_get_username(PURPLE_CONTACT_INFO(account));
+		name = purple_account_get_username(account);
 
 		g_task_return_new_error(task, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
 		                        _("account \"%s\" is not marked to be stored"),
diff --git a/libpurple/purplefiletransfer.c b/libpurple/purplefiletransfer.c
--- a/libpurple/purplefiletransfer.c
+++ b/libpurple/purplefiletransfer.c
@@ -504,7 +504,7 @@
 		PURPLE_TYPE_FILE_TRANSFER,
 		"account", account,
 		"remote", remote,
-		"initiator", PURPLE_CONTACT_INFO(account),
+		"initiator", purple_account_get_contact_info(account),
 		"local-file", local_file,
 		"filename", filename,
 		"file-size", file_size,
diff --git a/libpurple/purplenotification.c b/libpurple/purplenotification.c
--- a/libpurple/purplenotification.c
+++ b/libpurple/purplenotification.c
@@ -501,7 +501,6 @@
 purple_notification_new_from_add_contact_request(PurpleAddContactRequest *request)
 {
 	PurpleAccount *account = NULL;
-	PurpleContactInfo *info = NULL;
 	PurpleNotification *notification = NULL;
 	char *title = NULL;
 	const char *alias = NULL;
@@ -510,7 +509,6 @@
 	g_return_val_if_fail(PURPLE_IS_ADD_CONTACT_REQUEST(request), NULL);
 
 	account = purple_add_contact_request_get_account(request);
-	info = PURPLE_CONTACT_INFO(account);
 	notification = purple_notification_new(PURPLE_NOTIFICATION_TYPE_ADD_CONTACT,
 	                                       account, request, g_object_unref);
 
@@ -520,11 +518,11 @@
 	if(alias != NULL && *alias != '\0') {
 		title = g_strdup_printf(_("%s (%s) added %s to their contact list"),
 		                        alias, username,
-		                        purple_contact_info_get_username(info));
+		                        purple_account_get_username(account));
 	} else {
 		title = g_strdup_printf(_("%s added %s to their contact list"),
 		                        username,
-		                        purple_contact_info_get_username(info));
+		                        purple_account_get_username(account));
 	}
 
 	purple_notification_set_title(notification, title);
@@ -537,7 +535,6 @@
 purple_notification_new_from_authorization_request(PurpleAuthorizationRequest *authorization_request)
 {
 	PurpleAccount *account = NULL;
-	PurpleContactInfo *info = NULL;
 	PurpleNotification *notification = NULL;
 	char *title = NULL;
 	const char *alias = NULL;
@@ -547,7 +544,6 @@
 	                     NULL);
 
 	account = purple_authorization_request_get_account(authorization_request);
-	info = PURPLE_CONTACT_INFO(account);
 	notification = purple_notification_new(PURPLE_NOTIFICATION_TYPE_AUTHORIZATION_REQUEST,
 	                                       account, authorization_request,
 	                                       g_object_unref);
@@ -559,12 +555,12 @@
 		title = g_strdup_printf(_("%s (%s) would like to add %s to their"
 		                          " contact list"),
 		                        alias, username,
-		                        purple_contact_info_get_username(info));
+		                        purple_account_get_username(account));
 	} else {
 		title = g_strdup_printf(_("%s would like to add %s to their contact"
 		                          " list"),
 		                        username,
-		                        purple_contact_info_get_username(info));
+		                        purple_account_get_username(account));
 	}
 
 	purple_notification_set_title(notification, title);
@@ -589,7 +585,7 @@
 	                                       account, info, NULL);
 
 	/* Set the title of the notification. */
-	username = purple_contact_info_get_username(PURPLE_CONTACT_INFO(account));
+	username = purple_account_get_username(account);
 	if(purple_account_get_enabled(account)) {
 		title = g_strdup_printf(_("%s disconnected"), username);
 	} else {
diff --git a/libpurple/purplesqlitehistoryadapter.c b/libpurple/purplesqlitehistoryadapter.c
--- a/libpurple/purplesqlitehistoryadapter.c
+++ b/libpurple/purplesqlitehistoryadapter.c
@@ -380,7 +380,6 @@
                                     PurpleMessage *message, GError **error)
 {
 	PurpleAccount *account = NULL;
-	PurpleContactInfo *info = NULL;
 	PurpleSqliteHistoryAdapter *sqlite_adapter = NULL;
 	sqlite3_stmt *prepared_statement = NULL;
 	gchar *timestamp = NULL;
@@ -412,13 +411,12 @@
 	}
 
 	account = purple_conversation_get_account(conversation);
-	info = PURPLE_CONTACT_INFO(account);
 
 	sqlite3_bind_text(prepared_statement,
 	                  1, purple_account_get_protocol_name(account), -1,
 	                  SQLITE_STATIC);
 	sqlite3_bind_text(prepared_statement,
-	                  2, purple_contact_info_get_username(info), -1,
+	                  2, purple_account_get_username(account), -1,
 	                  SQLITE_STATIC);
 	sqlite3_bind_text(prepared_statement,
 	                  3, purple_conversation_get_name(conversation), -1,
diff --git a/libpurple/tests/test_account_manager.c b/libpurple/tests/test_account_manager.c
--- a/libpurple/tests/test_account_manager.c
+++ b/libpurple/tests/test_account_manager.c
@@ -100,7 +100,6 @@
 static gboolean
 test_purple_account_manager_find_func(gconstpointer a, gconstpointer b) {
 	PurpleAccount *account = PURPLE_ACCOUNT((gpointer)a);
-	PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
 	const gchar *desired_username = b;
 	const gchar *protocol_id = NULL;
 	const gchar *username = NULL;
@@ -112,7 +111,7 @@
 	}
 
 	/* Finally verify the username. */
-	username = purple_contact_info_get_username(info);
+	username = purple_account_get_username(account);
 	if(!purple_strequal(username, desired_username)) {
 		return FALSE;
 	}
diff --git a/libpurple/tests/test_conversation.c b/libpurple/tests/test_conversation.c
--- a/libpurple/tests/test_conversation.c
+++ b/libpurple/tests/test_conversation.c
@@ -447,7 +447,7 @@
 
 	/* Make sure the account got added as a member. */
 	test_member = purple_conversation_find_member(conversation,
-	                                              PURPLE_CONTACT_INFO(account));
+	                                              purple_account_get_contact_info(account));
 	g_assert_nonnull(test_member);
 
 	/* Connect our signals. */
diff --git a/libpurple/tests/test_conversation_manager.c b/libpurple/tests/test_conversation_manager.c
--- a/libpurple/tests/test_conversation_manager.c
+++ b/libpurple/tests/test_conversation_manager.c
@@ -336,7 +336,7 @@
 		"account", account2,
 		"type", PURPLE_CONVERSATION_TYPE_CHANNEL,
 		NULL);
-	purple_conversation_manager_register(manager, conversation2);
+	purple_conversation_manager_register(manager, conversation3);
 
 	conversation4 = purple_conversation_manager_find_dm(manager, contact);
 	g_assert_null(conversation4);
diff --git a/libpurple/tests/test_file_transfer.c b/libpurple/tests/test_file_transfer.c
--- a/libpurple/tests/test_file_transfer.c
+++ b/libpurple/tests/test_file_transfer.c
@@ -46,7 +46,7 @@
 	g_assert_true(PURPLE_IS_FILE_TRANSFER(transfer));
 
 	initiator = purple_file_transfer_get_initiator(transfer);
-	g_assert_true(initiator == PURPLE_CONTACT_INFO(account));
+	g_assert_true(initiator == purple_account_get_contact_info(account));
 
 	filename = purple_file_transfer_get_filename(transfer);
 	basename = g_path_get_basename(executable);
