Tue, 15 Apr 2025 00:04:58 -0500
IRCv3: Set the presence to offline when we receive a quit message
If the user specified a quit message, it will be used as the presence message.
Testing Done:
Used a temporary `g_warning` to verify that the presence was changed and the message was set. Also, called in the turtles.
Bugs closed: PIDGIN-18089
Reviewed at https://reviews.imfreedom.org/r/3969/
| protocols/ircv3/purpleircv3messagehandlers.c | file | annotate | diff | comparison | revisions |
--- a/protocols/ircv3/purpleircv3messagehandlers.c Tue Apr 08 23:20:52 2025 -0500 +++ b/protocols/ircv3/purpleircv3messagehandlers.c Tue Apr 15 00:04:58 2025 -0500 @@ -706,10 +706,12 @@ PurpleContact *contact = NULL; PurpleContactInfo *info = NULL; PurpleConversationManager *manager = NULL; + PurplePresence *presence = NULL; GList *conversations = NULL; GStrv params = NULL; guint n_params = 0; char *message = NULL; + char *reason = NULL; params = ibis_message_get_params(ibis_message); n_params = g_strv_length(params); @@ -719,18 +721,22 @@ info = PURPLE_CONTACT_INFO(contact); if(n_params > 0) { - char *reason = NULL; - reason = g_strjoinv(" ", params); message = g_strdup_printf("%s has quit (%s)", purple_contact_info_get_sid(info), reason); - g_free(reason); } else { message = g_strdup_printf("%s has quit", purple_contact_info_get_sid(info)); } + /* Update the presence to offline and if they provided a quit message, set + * it as the presence message. + */ + presence = purple_contact_info_get_presence(PURPLE_CONTACT_INFO(contact)); + purple_presence_set_message(presence, reason); + purple_presence_set_primitive(presence, PURPLE_PRESENCE_PRIMITIVE_OFFLINE); + manager = purple_conversation_manager_get_default(); conversations = purple_conversation_manager_get_all(manager); while(conversations != NULL) { @@ -744,7 +750,8 @@ conversations = g_list_delete_link(conversations, conversations); } - g_free(message); + g_clear_pointer(&message, g_free); + g_clear_pointer(&reason, g_free); return TRUE; }