IRCv3: Update the status window title when the user's nick changes

Thu, 06 Feb 2025 20:29:19 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 06 Feb 2025 20:29:19 -0600
changeset 43174
94bf15b8dad0
parent 43173
399e2538f319
child 43175
41ad34b9de13

IRCv3: Update the status window title when the user's nick changes

Testing Done:
Changed my nick on a local ergo server using quote and verified the title of the status window updated correctly. Also built and ran the flatpak without issue.

Bugs closed: PIDGIN-18036

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

im.pidgin.Pidgin3.yml file | annotate | diff | comparison | revisions
protocols/ircv3/meson.build file | annotate | diff | comparison | revisions
protocols/ircv3/purpleircv3connection.c file | annotate | diff | comparison | revisions
subprojects/ibis.wrap file | annotate | diff | comparison | revisions
--- a/im.pidgin.Pidgin3.yml	Mon Feb 03 21:11:44 2025 -0600
+++ b/im.pidgin.Pidgin3.yml	Thu Feb 06 20:29:19 2025 -0600
@@ -71,8 +71,8 @@
     sources:
       - type: archive
         archive-type: tar-xz
-        url: https://sourceforge.net/projects/pidgin/files/ibis/0.11.0/ibis-0.11.0.tar.xz/download
-        sha256: 9f2d4a13229ca5848d1cf3a0f56ffdde4f8decea4b6b0101d5c10421a9ba35dc
+        url: https://sourceforge.net/projects/pidgin/files/ibis/0.11.2/ibis-0.11.2.tar.xz/download
+        sha256: 04ac94c2c564e24a24ef76805ca065451aa76cf9c7b2eb46f0b1e4107f5f7205
   - name: xeme
     buildsystem: meson
     config-opts:
--- a/protocols/ircv3/meson.build	Mon Feb 03 21:11:44 2025 -0600
+++ b/protocols/ircv3/meson.build	Thu Feb 06 20:29:19 2025 -0600
@@ -22,7 +22,7 @@
 	subdir_done()
 endif
 
-ibis_dep = dependency('ibis', version : '>= 0.11.1')
+ibis_dep = dependency('ibis', version : '>= 0.11.2')
 
 ircv3_filebase = f'purple-@purple_api_major_version@-ircv3'
 ircv3_filebase = f'purple-@purple_api_major_version@-ircv3'
--- a/protocols/ircv3/purpleircv3connection.c	Mon Feb 03 21:11:44 2025 -0600
+++ b/protocols/ircv3/purpleircv3connection.c	Thu Feb 06 20:29:19 2025 -0600
@@ -31,6 +31,8 @@
 #include "purpleircv3core.h"
 #include "purpleircv3messagehandlers.h"
 
+#define IRCV3_STATUS_CONVERSATION_ID "@ircv3-status@"
+
 enum {
 	PROP_0,
 	PROP_CLIENT,
@@ -579,6 +581,28 @@
 	                                     IBIS_CAPABILITY_ACCOUNT_TAG);
 }
 
+static void
+purple_ircv3_connection_update_status_title_cb(G_GNUC_UNUSED GObject *obj,
+                                               G_GNUC_UNUSED GParamSpec *pspec,
+                                               gpointer data)
+{
+	PurpleIRCv3Connection *connection = data;
+	char *title = NULL;
+	const char *nick = NULL;
+	const char *network = NULL;
+
+	nick = ibis_client_get_active_nick(connection->client);
+
+	network = ibis_client_get_network(connection->client);
+	if(purple_strempty(network)) {
+		network = connection->server_name;
+	}
+
+	title = g_strdup_printf(_("status %s on %s"), nick, network);
+	purple_conversation_set_title(connection->status_conversation, title);
+	g_free(title);
+}
+
 /******************************************************************************
  * PurpleConnection Implementation
  *****************************************************************************/
@@ -616,6 +640,12 @@
 	g_signal_connect_object(connection->client, "notify::error",
 	                        G_CALLBACK(purple_ircv3_connection_error_cb),
 	                        connection, G_CONNECT_DEFAULT);
+	g_signal_connect_object(connection->client, "notify::active-nick",
+	                        G_CALLBACK(purple_ircv3_connection_update_status_title_cb),
+	                        connection, G_CONNECT_DEFAULT);
+	g_signal_connect_object(connection->client, "notify::network",
+	                        G_CALLBACK(purple_ircv3_connection_update_status_title_cb),
+	                        connection, G_CONNECT_DEFAULT);
 	purple_ircv3_connection_add_message_handlers(connection,
 	                                             connection->client);
 
@@ -734,15 +764,11 @@
 	PurpleConversationManager *conversation_manager = NULL;
 	char **userparts = NULL;
 	const char *username = NULL;
-	char *title = NULL;
 
 	G_OBJECT_CLASS(purple_ircv3_connection_parent_class)->constructed(obj);
 
 	account = purple_connection_get_account(PURPLE_CONNECTION(connection));
 
-	title = g_strdup_printf(_("status for %s"),
-	                        purple_account_get_username(account));
-
 	/* Split the username into nick and server and store the values. */
 	username = purple_account_get_username(account);
 	userparts = g_strsplit(username, "@", 2);
@@ -755,15 +781,14 @@
 	conversation_manager = purple_conversation_manager_get_default();
 	connection->status_conversation = purple_conversation_manager_find_with_id(conversation_manager,
 	                                                                           account,
-	                                                                           connection->server_name);
+	                                                                           IRCV3_STATUS_CONVERSATION_ID);
 
 	if(!PURPLE_IS_CONVERSATION(connection->status_conversation)) {
 		/* Create our status conversation. */
 		connection->status_conversation = g_object_new(
 			PURPLE_TYPE_CONVERSATION,
 			"account", account,
-			"id", connection->server_name,
-			"title", title,
+			"id", IRCV3_STATUS_CONVERSATION_ID,
 			"online", TRUE,
 			NULL);
 
@@ -776,8 +801,6 @@
 		purple_conversation_set_online(connection->status_conversation, TRUE);
 		purple_conversation_set_error(connection->status_conversation, NULL);
 	}
-
-	g_clear_pointer(&title, g_free);
 }
 
 static void
--- a/subprojects/ibis.wrap	Mon Feb 03 21:11:44 2025 -0600
+++ b/subprojects/ibis.wrap	Thu Feb 06 20:29:19 2025 -0600
@@ -1,5 +1,5 @@
 [wrap-file]
-directory = ibis-0.11.1
-source_url = https://sourceforge.net/projects/pidgin/files/ibis/0.11.1/ibis-0.11.1.tar.xz
-source_filename = ibis-0.11.1.tar.xz
-source_hash = c3efb8d77f893fea9f7290f8884e9d00f552e84331ccd5d2b686fe6ce16fc3b7
+directory = ibis-0.11.2
+source_url = https://sourceforge.net/projects/pidgin/files/ibis/0.11.2/ibis-0.11.2.tar.xz
+source_filename = ibis-0.11.2.tar.xz
+source_hash = 04ac94c2c564e24a24ef76805ca065451aa76cf9c7b2eb46f0b1e4107f5f7205

mercurial