Wed, 16 Oct 2024 02:24:30 -0500
IRCv3: Finally handle NICK messages
Testing Done:
Connected to my local ergo and changed nicks on registered and unregistered accounts and verified everything was updated properly.
Bugs closed: PIDGIN-17963
Reviewed at https://reviews.imfreedom.org/r/3589/
--- a/im.pidgin.Pidgin3.yml Tue Oct 15 01:48:58 2024 -0500 +++ b/im.pidgin.Pidgin3.yml Wed Oct 16 02:24:30 2024 -0500 @@ -63,8 +63,8 @@ sources: - type: archive archive-type: tar-xz - url: https://sourceforge.net/projects/pidgin/files/ibis/0.8.2/ibis-0.8.2.tar.xz/download - sha256: cd5c5fdfed9912baa56f8219b7839ca165480b993d362cbda4be4c2fdc627c91 + url: https://sourceforge.net/projects/pidgin/files/ibis/0.9.0/ibis-0.9.0.tar.xz/download + sha256: 43251c44fc97205804fd28b79b355ff27659f172a7b542de24aa596cbde3d852 - name: xeme buildsystem: meson config-opts:
--- a/protocols/ircv3/meson.build Tue Oct 15 01:48:58 2024 -0500 +++ b/protocols/ircv3/meson.build Wed Oct 16 02:24:30 2024 -0500 @@ -20,7 +20,7 @@ subdir_done() endif -ibis_dep = dependency('ibis', version : '>= 0.8.2') +ibis_dep = dependency('ibis', version : '>= 0.9.0') ircv3_filebase = f'purple-@purple_api_major_version@-ircv3' ircv3_filebase = f'purple-@purple_api_major_version@-ircv3'
--- a/protocols/ircv3/purpleircv3connection.c Tue Oct 15 01:48:58 2024 -0500 +++ b/protocols/ircv3/purpleircv3connection.c Wed Oct 16 02:24:30 2024 -0500 @@ -476,6 +476,9 @@ g_signal_connect_object(client, "message::" IBIS_MSG_PART, G_CALLBACK(purple_ircv3_message_handler_part), connection, G_CONNECT_DEFAULT); + g_signal_connect_object(client, "message::" IBIS_MSG_NICK, + G_CALLBACK(purple_ircv3_message_handler_nick), + connection, G_CONNECT_DEFAULT); g_signal_connect_object(client, "message::" IBIS_MSG_QUIT, G_CALLBACK(purple_ircv3_message_handler_quit), connection, G_CONNECT_DEFAULT);
--- a/protocols/ircv3/purpleircv3messagehandlers.c Tue Oct 15 01:48:58 2024 -0500 +++ b/protocols/ircv3/purpleircv3messagehandlers.c Wed Oct 16 02:24:30 2024 -0500 @@ -555,3 +555,55 @@ return TRUE; } + +gboolean +purple_ircv3_message_handler_nick(G_GNUC_UNUSED IbisClient *client, + G_GNUC_UNUSED const char *command, + IbisMessage *ibis_message, + gpointer data) +{ + PurpleIRCv3Connection *connection = data; + PurpleContact *contact = NULL; + PurpleContactInfo *info = NULL; + IbisTags *tags = NULL; + GStrv params = NULL; + guint n_params = 0; + char *new_source = NULL; + char *user = NULL; + char *host = NULL; + const char *source = NULL; + const char *nick = NULL; + + params = ibis_message_get_params(ibis_message); + n_params = g_strv_length(params); + + if(n_params != 1) { + g_message("received NICK with %d params, expected 1", n_params); + return FALSE; + } + + nick = params[0]; + source = ibis_message_get_source(ibis_message); + ibis_source_parse(source, NULL, &user, &host); + new_source = ibis_source_serialize(nick, user, host); + g_clear_pointer(&user, g_free); + g_clear_pointer(&host, g_free); + + contact = purple_ircv3_connection_find_or_create_contact(connection, + ibis_message); + info = PURPLE_CONTACT_INFO(contact); + + /* If the account tag doesn't exist, we need to update the id property of + * the contact. + */ + tags = ibis_message_get_tags(ibis_message); + if(!ibis_tags_exists(tags, IBIS_TAG_ACCOUNT)) { + purple_contact_info_set_id(info, nick); + } + + purple_contact_info_set_display_name(info, nick); + purple_contact_info_set_sid(info, new_source); + g_clear_pointer(&new_source, g_free); + + return TRUE; +}
--- a/protocols/ircv3/purpleircv3messagehandlers.h Tue Oct 15 01:48:58 2024 -0500 +++ b/protocols/ircv3/purpleircv3messagehandlers.h Wed Oct 16 02:24:30 2024 -0500 @@ -45,6 +45,7 @@ G_GNUC_INTERNAL gboolean purple_ircv3_message_handler_privmsg(IbisClient *client, const char *command, IbisMessage *message, gpointer data); G_GNUC_INTERNAL gboolean purple_ircv3_message_handler_topic(IbisClient *client, const char *command, IbisMessage *message, gpointer data); G_GNUC_INTERNAL gboolean purple_ircv3_message_handler_quit(IbisClient *client, const char *command, IbisMessage *message, gpointer data); +G_GNUC_INTERNAL gboolean purple_ircv3_message_handler_nick(IbisClient *client, const char *command, IbisMessage *message, gpointer data); G_END_DECLS