Tue, 17 Jan 2023 01:41:05 -0600
Create new conversation when activating users in the new contact list
I also had to remove an unnecessary g_date_time_unref in the demo protocol
plugin for testing.
Testing Done:
Using the demo protocol plugin, I opened a conversation to `Echo` and sent a message. I then went to the buddy list window and double clicked on `Echo` again. I saw history got loaded, which I'll be removing in the near future, but I was able to send messages correctly.
Reviewed at https://reviews.imfreedom.org/r/2201/
--- a/libpurple/protocols/demo/purpledemoprotocolim.c Tue Jan 17 01:24:38 2023 -0600 +++ b/libpurple/protocols/demo/purpledemoprotocolim.c Tue Jan 17 01:41:05 2023 -0600 @@ -54,8 +54,6 @@ purple_message_get_contents(info->message), flags, g_date_time_to_unix(timestamp)); - g_date_time_unref(timestamp); - return FALSE; }
--- a/pidgin/pidgincontactlist.c Tue Jan 17 01:24:38 2023 -0600 +++ b/pidgin/pidgincontactlist.c Tue Jan 17 01:41:05 2023 -0600 @@ -79,6 +79,40 @@ return texture; } +static void +pidgin_contact_list_activate_cb(GtkListView *self, guint position, + G_GNUC_UNUSED gpointer data) +{ + PurpleAccount *account = NULL; + PurpleContactInfo *info = NULL; + PurpleConversation *conversation = NULL; + PurpleConversationManager *manager = NULL; + PurplePerson *person = NULL; + GtkSelectionModel *model = NULL; + const char *name = NULL; + + model = gtk_list_view_get_model(self); + + person = g_list_model_get_item(G_LIST_MODEL(model), position); + if(!PURPLE_IS_PERSON(person)) { + g_warning("we seem to have activated a zombie.. RUN!!!!!!"); + + return; + } + + info = purple_person_get_priority_contact_info(person); + account = purple_contact_get_account(PURPLE_CONTACT(info)); + name = purple_contact_info_get_username(info); + + manager = purple_conversation_manager_get_default(); + conversation = purple_conversation_manager_find_im(manager, account, name); + + if(!PURPLE_IS_CONVERSATION(conversation)) { + conversation = purple_im_conversation_new(account, name); + purple_conversation_manager_register(manager, conversation); + } +} + /****************************************************************************** * GObject Implementation *****************************************************************************/ @@ -110,6 +144,8 @@ gtk_widget_class_bind_template_callback(widget_class, pidgin_contact_list_avatar_cb); + gtk_widget_class_bind_template_callback(widget_class, + pidgin_contact_list_activate_cb); } /******************************************************************************
--- a/pidgin/resources/ContactList/widget.ui Tue Jan 17 01:24:38 2023 -0600 +++ b/pidgin/resources/ContactList/widget.ui Tue Jan 17 01:41:05 2023 -0600 @@ -70,6 +70,7 @@ </property> </object> </property> + <signal name="activate" handler="pidgin_contact_list_activate_cb" swapped="no"/> </object> </child> </template>