Update pidgin to use get id and username directly on PurpleAccount

Thu, 27 Jun 2024 00:46:27 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 27 Jun 2024 00:46:27 -0500
changeset 42804
be8c8b5471ca
parent 42803
984f8dfabb47
child 42805
3e77e81168a5

Update pidgin to use get id and username directly on PurpleAccount

This is part of making PurpleAccount have a PurpleContactInfo instead of being
one.

Testing Done:
Ran the turtles, connected some accounts, disabled one via the menu and re-enabled it.

Reviewed at https://reviews.imfreedom.org/r/3273/

pidgin/gtknotify.c file | annotate | diff | comparison | revisions
pidgin/pidginaccountdisplay.c file | annotate | diff | comparison | revisions
pidgin/pidginaccounteditor.c file | annotate | diff | comparison | revisions
pidgin/pidginaccountmanagerrow.c file | annotate | diff | comparison | revisions
pidgin/pidginaccountsdisabledmenu.c file | annotate | diff | comparison | revisions
pidgin/pidginaccountsenabledmenu.c file | annotate | diff | comparison | revisions
pidgin/pidgincontactinfomenu.c file | annotate | diff | comparison | revisions
pidgin/pidgindisplaywindow.c file | annotate | diff | comparison | revisions
pidgin/pidginnotificationaddcontact.c file | annotate | diff | comparison | revisions
pidgin/pidginnotificationauthorizationrequest.c file | annotate | diff | comparison | revisions
pidgin/pidginnotificationconnectionerror.c file | annotate | diff | comparison | revisions
pidgin/plugins/disco/gtkdisco.c file | annotate | diff | comparison | revisions
pidgin/plugins/unity/unity.c file | annotate | diff | comparison | revisions
--- a/pidgin/gtknotify.c	Thu Jun 27 00:44:54 2024 -0500
+++ b/pidgin/gtknotify.c	Thu Jun 27 00:46:27 2024 -0500
@@ -113,7 +113,6 @@
 static void
 pidgin_widget_decorate_account(GtkWidget *cont, PurpleAccount *account)
 {
-	PurpleContactInfo *info = NULL;
 	PurpleProtocol *protocol = NULL;
 	GtkWidget *image;
 	const gchar *icon_name = NULL;
@@ -121,13 +120,12 @@
 	if (!account)
 		return;
 
-	info = PURPLE_CONTACT_INFO(account);
 	protocol = purple_account_get_protocol(account);
 	icon_name = purple_protocol_get_icon_name(protocol);
 
 	image = gtk_image_new_from_icon_name(icon_name);
 
-	gtk_widget_set_tooltip_text(image, purple_contact_info_get_username(info));
+	gtk_widget_set_tooltip_text(image, purple_account_get_username(account));
 
 	if (GTK_IS_BOX(cont)) {
 		gtk_widget_set_halign(image, GTK_ALIGN_START);
@@ -530,7 +528,7 @@
 {
 	char key[256];
 	g_snprintf(key, sizeof(key), "%s - %s",
-	           purple_contact_info_get_username(PURPLE_CONTACT_INFO(account)),
+	           purple_account_get_username(account),
 	           purple_normalize(account, who));
 	return g_utf8_strup(key, -1);
 }
--- a/pidgin/pidginaccountdisplay.c	Thu Jun 27 00:44:54 2024 -0500
+++ b/pidgin/pidginaccountdisplay.c	Thu Jun 27 00:46:27 2024 -0500
@@ -61,7 +61,7 @@
 		protocol = purple_account_get_protocol(account);
 		icon_name = purple_protocol_get_icon_name(protocol);
 
-		info = PURPLE_CONTACT_INFO(account);
+		info = purple_account_get_contact_info(account);
 		alias = purple_contact_info_get_alias(info);
 		protocol_name = purple_account_get_protocol_name(account);
 		username = purple_contact_info_get_username(info);
--- a/pidgin/pidginaccounteditor.c	Thu Jun 27 00:44:54 2024 -0500
+++ b/pidgin/pidginaccounteditor.c	Thu Jun 27 00:46:27 2024 -0500
@@ -147,12 +147,10 @@
 
 	/* If we have an account, populate its values. */
 	if(PURPLE_IS_ACCOUNT(editor->account)) {
-		/* The username will be split apart below and eventually set as the text
-		 * in the username entry.
+		/* The username will be split apart below and eventually set as the
+		 * text in the username entry.
 		 */
-		PurpleContactInfo *info = PURPLE_CONTACT_INFO(editor->account);
-
-		username = g_strdup(purple_contact_info_get_username(info));
+		username = g_strdup(purple_account_get_username(editor->account));
 		require_password = purple_account_get_require_password(editor->account);
 
 		if(purple_account_is_connected(editor->account)) {
@@ -257,8 +255,9 @@
 
 	/* Determine our values. */
 	if(editor->account != NULL) {
-		PurpleContactInfo *info = PURPLE_CONTACT_INFO(editor->account);
+		PurpleContactInfo *info = NULL;
 
+		info = purple_account_get_contact_info(editor->account);
 		svalue = purple_contact_info_get_alias(info);
 		use_global = purple_account_get_bool(editor->account,
 		                                     "use-global-buddyicon", TRUE);
@@ -783,9 +782,7 @@
 		editor->account = purple_account_new(username->str, protocol_id);
 		new_account = TRUE;
 	} else {
-		PurpleContactInfo *info = PURPLE_CONTACT_INFO(editor->account);
-
-		purple_contact_info_set_username(info, username->str);
+		purple_account_set_username(editor->account, username->str);
 		purple_account_set_protocol_id(editor->account, protocol_id);
 	}
 
@@ -799,12 +796,14 @@
 
 static void
 pidgin_account_editor_save_user_options(PidginAccountEditor *editor) {
-	PurpleContactInfo *info = PURPLE_CONTACT_INFO(editor->account);
+	PurpleContactInfo *info = NULL;
 	const gchar *svalue = NULL;
 	gboolean bvalue = FALSE;
 
 	purple_account_freeze_notify_settings(editor->account);
 
+	info = purple_account_get_contact_info(editor->account);
+
 	/* Set the alias. */
 	svalue = gtk_editable_get_text(GTK_EDITABLE(editor->alias));
 	if(*svalue == '\0') {
--- a/pidgin/pidginaccountmanagerrow.c	Thu Jun 27 00:44:54 2024 -0500
+++ b/pidgin/pidginaccountmanagerrow.c	Thu Jun 27 00:46:27 2024 -0500
@@ -228,7 +228,7 @@
 	const char *name = NULL;
 	char *protocol_name = NULL;
 
-	info = PURPLE_CONTACT_INFO(row->account);
+	info = purple_account_get_contact_info(row->account);
 	name = purple_contact_info_get_name_for_display(info);
 	protocol_name = pidgin_account_manager_row_protocol_name_cb(NULL,
 	                                                            row->account,
--- a/pidgin/pidginaccountsdisabledmenu.c	Thu Jun 27 00:44:54 2024 -0500
+++ b/pidgin/pidginaccountsdisabledmenu.c	Thu Jun 27 00:46:27 2024 -0500
@@ -100,7 +100,6 @@
 {
 	PidginAccountsDisabledMenu *menu = NULL;
 	PurpleAccount *account = NULL;
-	PurpleContactInfo *info = NULL;
 	PurpleProtocol *protocol = NULL;
 	GVariant *value = NULL;
 	const gchar *account_name = NULL, *protocol_name = NULL;
@@ -131,8 +130,7 @@
 		return;
 	}
 
-	info = PURPLE_CONTACT_INFO(account);
-	account_name = purple_contact_info_get_username(info);
+	account_name = purple_account_get_username(account);
 	protocol_name = purple_account_get_protocol_name(account);
 
 	/* translators: This format string is intended to contain the account
@@ -147,7 +145,7 @@
 	g_hash_table_insert(*attributes, G_MENU_ATTRIBUTE_ACTION,
 	                    g_variant_ref_sink(value));
 
-	value = g_variant_new_printf("%s", purple_contact_info_get_id(info));
+	value = g_variant_new_printf("%s", purple_account_get_id(account));
 	g_hash_table_insert(*attributes, G_MENU_ATTRIBUTE_TARGET,
 	                    g_variant_ref_sink(value));
 
--- a/pidgin/pidginaccountsenabledmenu.c	Thu Jun 27 00:44:54 2024 -0500
+++ b/pidgin/pidginaccountsenabledmenu.c	Thu Jun 27 00:46:27 2024 -0500
@@ -211,7 +211,7 @@
 		return;
 	}
 
-	account_name = purple_contact_info_get_username(PURPLE_CONTACT_INFO(account));
+	account_name = purple_account_get_username(account);
 
 	/* Get the protocol from the account. */
 	protocol = purple_account_get_protocol(account);
@@ -261,7 +261,7 @@
 		return;
 	}
 
-	account_id = purple_contact_info_get_id(PURPLE_CONTACT_INFO(account));
+	account_id = purple_account_get_id(account);
 
 	connection = purple_account_get_connection(account);
 	if(PURPLE_IS_CONNECTION(connection)) {
--- a/pidgin/pidgincontactinfomenu.c	Thu Jun 27 00:44:54 2024 -0500
+++ b/pidgin/pidgincontactinfomenu.c	Thu Jun 27 00:46:27 2024 -0500
@@ -87,7 +87,7 @@
 	const char *account_id = NULL;
 	const char *contact_id = NULL;
 
-	account_id = purple_contact_info_get_id(PURPLE_CONTACT_INFO(account));
+	account_id = purple_account_get_id(account);
 	contact_id = purple_contact_info_get_id(info);
 
 	menu = g_menu_new();
--- a/pidgin/pidgindisplaywindow.c	Thu Jun 27 00:44:54 2024 -0500
+++ b/pidgin/pidgindisplaywindow.c	Thu Jun 27 00:46:27 2024 -0500
@@ -522,7 +522,6 @@
 	if(PIDGIN_IS_CONVERSATION(pidgin_conversation)) {
 		PidginDisplayItem *item = NULL;
 		PurpleAccount *account = purple_conversation_get_account(purple_conversation);
-		PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
 		const char *account_id = NULL;
 		char *id = NULL;
 		gboolean item_exists = FALSE;
@@ -534,7 +533,7 @@
 			gtk_widget_unparent(pidgin_conversation);
 		}
 
-		account_id = purple_contact_info_get_id(info);
+		account_id = purple_account_get_id(account);
 		id = g_strdup_printf("%s-%s", account_id, conversation_id);
 		item_exists =
 			g_list_store_find_with_equal_func_full(window->conversation_model,
--- a/pidgin/pidginnotificationaddcontact.c	Thu Jun 27 00:44:54 2024 -0500
+++ b/pidgin/pidginnotificationaddcontact.c	Thu Jun 27 00:46:27 2024 -0500
@@ -176,7 +176,7 @@
 	if(!PURPLE_IS_CONTACT(contact)) {
 		g_warning("failed to find a user named '%s' on account %s",
 		          username,
-		          purple_contact_info_get_username(PURPLE_CONTACT_INFO(account)));
+		          purple_account_get_username(account));
 
 		return;
 	}
--- a/pidgin/pidginnotificationauthorizationrequest.c	Thu Jun 27 00:44:54 2024 -0500
+++ b/pidgin/pidginnotificationauthorizationrequest.c	Thu Jun 27 00:46:27 2024 -0500
@@ -204,7 +204,7 @@
 	if(!PURPLE_IS_CONTACT(contact)) {
 		g_warning("failed to find a user named '%s' on account %s",
 		          username,
-		          purple_contact_info_get_username(PURPLE_CONTACT_INFO(account)));
+		          purple_account_get_username(account));
 
 		return;
 	}
--- a/pidgin/pidginnotificationconnectionerror.c	Thu Jun 27 00:44:54 2024 -0500
+++ b/pidgin/pidginnotificationconnectionerror.c	Thu Jun 27 00:46:27 2024 -0500
@@ -89,7 +89,7 @@
 	}
 
 	/* Set the target for our actions. */
-	account_id = purple_contact_info_get_id(PURPLE_CONTACT_INFO(account));
+	account_id = purple_account_get_id(account);
 	gtk_actionable_set_action_target(GTK_ACTIONABLE(error->reconnect), "s",
 	                                 account_id);
 	gtk_actionable_set_action_target(GTK_ACTIONABLE(error->reenable), "s",
--- a/pidgin/plugins/disco/gtkdisco.c	Thu Jun 27 00:44:54 2024 -0500
+++ b/pidgin/plugins/disco/gtkdisco.c	Thu Jun 27 00:46:27 2024 -0500
@@ -162,7 +162,6 @@
 {
 	PidginDiscoDialog *dialog = data;
 	PurpleConnection *pc;
-	PurpleContactInfo *info = NULL;
 	PidginDiscoList *pdl;
 	const char *username;
 	const char *at, *slash;
@@ -189,8 +188,7 @@
 
 	gtk_widget_set_sensitive(dialog->account_chooser, FALSE);
 
-	info = PURPLE_CONTACT_INFO(dialog->account);
-	username = purple_contact_info_get_username(info);
+	username = purple_account_get_username(dialog->account);
 	at = strchr(username, '@');
 	slash = strchr(username, '/');
 	if (at && !slash) {
--- a/pidgin/plugins/unity/unity.c	Thu Jun 27 00:44:54 2024 -0500
+++ b/pidgin/plugins/unity/unity.c	Thu Jun 27 00:46:27 2024 -0500
@@ -88,7 +88,6 @@
 conversation_id(PurpleConversation *conv)
 {
 	PurpleAccount *account = purple_conversation_get_account(conv);
-	PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
 	const char *type = "misc";
 
 	if(PURPLE_IS_IM_CONVERSATION(conv)) {
@@ -100,7 +99,7 @@
 	return g_strdup_printf("%s:%s:%s:%s",
 	                       type,
 	                       purple_conversation_get_name(conv),
-	                       purple_contact_info_get_username(info),
+	                       purple_account_get_username(account),
 	                       purple_account_get_protocol_id(account));
 }
 

mercurial