Sat, 13 Apr 2024 23:08:29 -0500
Remove PurpleChat
This has been on the chopping block for awhile, and we're finally chopping it.
Testing Done:
Checked in with the turtles.
Reviewed at https://reviews.imfreedom.org/r/3120/
| ChangeLog.API | file | annotate | diff | comparison | revisions | |
| libpurple/accounts.c | file | annotate | diff | comparison | revisions | |
| libpurple/buddy.h | file | annotate | diff | comparison | revisions | |
| libpurple/buddyicon.c | file | annotate | diff | comparison | revisions | |
| libpurple/buddylist.c | file | annotate | diff | comparison | revisions | |
| libpurple/buddylist.h | file | annotate | diff | comparison | revisions | |
| libpurple/chat.c | file | annotate | diff | comparison | revisions | |
| libpurple/chat.h | file | annotate | diff | comparison | revisions | |
| libpurple/group.c | file | annotate | diff | comparison | revisions | |
| libpurple/meson.build | file | annotate | diff | comparison | revisions | |
| libpurple/purpleprotocolclient.c | file | annotate | diff | comparison | revisions | |
| libpurple/purpleprotocolclient.h | file | annotate | diff | comparison | revisions | |
| po/POTFILES.in | file | annotate | diff | comparison | revisions |
--- a/ChangeLog.API Sat Apr 13 23:01:11 2024 -0500 +++ b/ChangeLog.API Sat Apr 13 23:08:29 2024 -0500 @@ -367,12 +367,15 @@ * purple_attention_type_get_unlocalized_name * purple_base16_* * purple_base64_*. Use g_base64_* instead + * purple_blist_add_chat * purple_blist_find_chat * purple_blist_get_ui_data * purple_blist_load * purple_blist_new * purple_blist_node_get_ui_data * purple_blist_node_set_ui_data + * purple_blist_remove_chat + * purple_blist_request_add_chat * purple_blist_set_ui_data * purple_set_blist * purple_blist_update_buddy_icon
--- a/libpurple/accounts.c Sat Apr 13 23:01:11 2024 -0500 +++ b/libpurple/accounts.c Sat Apr 13 23:08:29 2024 -0500 @@ -540,12 +540,6 @@ } bnode = bnode_next; } - } else if(PURPLE_IS_CHAT(cnode)) { - PurpleChat *c = (PurpleChat *)cnode; - - if(purple_chat_get_account(c) == account) { - purple_blist_remove_chat(c); - } } cnode = cnode_next; }
--- a/libpurple/buddy.h Sat Apr 13 23:01:11 2024 -0500 +++ b/libpurple/buddy.h Sat Apr 13 23:08:29 2024 -0500 @@ -39,7 +39,6 @@ #include "blistnode.h" #include "buddyicon.h" -#include "chat.h" #include "contact.h" #include "group.h" #include "media.h" @@ -65,8 +64,7 @@ * Gets the name of @n. */ #define PURPLE_BLIST_NODE_NAME(n) \ - (PURPLE_IS_CHAT(n) ? purple_chat_get_name(PURPLE_CHAT(n)) : \ - PURPLE_IS_BUDDY(n) ? purple_buddy_get_name(PURPLE_BUDDY(n)) : NULL) + (PURPLE_IS_BUDDY(n) ? purple_buddy_get_name(PURPLE_BUDDY(n)) : NULL) /**************************************************************************/ /* Data Structures */
--- a/libpurple/buddyicon.c Sat Apr 13 23:01:11 2024 -0500 +++ b/libpurple/buddyicon.c Sat Apr 13 23:08:29 2024 -0500 @@ -878,7 +878,6 @@ g_return_val_if_fail(node != NULL, NULL); if (!PURPLE_IS_META_CONTACT(node) && - !PURPLE_IS_CHAT(node) && !PURPLE_IS_GROUP(node)) { return NULL; } @@ -945,7 +944,6 @@ g_return_val_if_fail(node != NULL, NULL); if (!PURPLE_IS_META_CONTACT(node) && - !PURPLE_IS_CHAT(node) && !PURPLE_IS_GROUP(node)) { return NULL; } @@ -1031,7 +1029,6 @@ } } else if (PURPLE_IS_META_CONTACT(node) || - PURPLE_IS_CHAT(node) || PURPLE_IS_GROUP(node)) { const char *filename;
--- a/libpurple/buddylist.c Sat Apr 13 23:01:11 2024 -0500 +++ b/libpurple/buddylist.c Sat Apr 13 23:08:29 2024 -0500 @@ -199,24 +199,6 @@ } } -static void -chat_component_to_xmlnode(gpointer key, gpointer value, gpointer user_data) -{ - const char *name; - const char *data; - PurpleXmlNode *node, *child; - - name = (const char *)key; - data = (const char *)value; - node = (PurpleXmlNode *)user_data; - - g_return_if_fail(data != NULL); - - child = purple_xmlnode_new_child(node, "component"); - purple_xmlnode_set_attrib(child, "name", name); - purple_xmlnode_insert_data(child, data, -1); -} - static PurpleXmlNode * buddy_to_xmlnode(PurpleBuddy *buddy) { @@ -282,40 +264,6 @@ } static PurpleXmlNode * -chat_to_xmlnode(PurpleChat *chat) -{ - PurpleXmlNode *node, *child; - PurpleAccount *account = purple_chat_get_account(chat); - PurpleContactInfo *info = PURPLE_CONTACT_INFO(account); - gchar *alias; - - g_object_get(chat, "alias", &alias, NULL); - - node = purple_xmlnode_new("chat"); - purple_xmlnode_set_attrib(node, "proto", - purple_account_get_protocol_id(account)); - purple_xmlnode_set_attrib(node, "account", - purple_contact_info_get_username(info)); - - if (alias != NULL) - { - child = purple_xmlnode_new_child(node, "alias"); - purple_xmlnode_insert_data(child, alias, -1); - } - - /* Write chat components */ - g_hash_table_foreach(purple_chat_get_components(chat), - chat_component_to_xmlnode, node); - - /* Write chat settings */ - g_hash_table_foreach(purple_blist_node_get_settings(PURPLE_BLIST_NODE(chat)), - value_to_xmlnode, node); - - g_free(alias); - return node; -} - -static PurpleXmlNode * group_to_xmlnode(PurpleGroup *group) { PurpleXmlNode *node, *child; @@ -339,11 +287,6 @@ child = contact_to_xmlnode(PURPLE_META_CONTACT(cnode)); purple_xmlnode_insert_child(node, child); } - else if (PURPLE_IS_CHAT(cnode)) - { - child = chat_to_xmlnode(PURPLE_CHAT(cnode)); - purple_xmlnode_insert_child(node, child); - } } return node; @@ -556,57 +499,6 @@ } static void -parse_chat(PurpleGroup *group, PurpleXmlNode *cnode) -{ - PurpleAccount *account; - PurpleAccountManager *manager = purple_account_manager_get_default(); - PurpleChat *chat; - const char *acct_name, *proto; - PurpleXmlNode *x; - char *alias = NULL; - GHashTable *components; - - acct_name = purple_xmlnode_get_attrib(cnode, "account"); - proto = purple_xmlnode_get_attrib(cnode, "proto"); - - if(!acct_name || !proto) { - return; - } - - account = purple_account_manager_find(manager, acct_name, proto); - - if(!account) { - return; - } - - if((x = purple_xmlnode_get_child(cnode, "alias"))) { - alias = purple_xmlnode_get_data(x); - } - - components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); - - for(x = purple_xmlnode_get_child(cnode, "component"); x; x = purple_xmlnode_get_next_twin(x)) { - const char *name; - char *value; - - name = purple_xmlnode_get_attrib(x, "name"); - value = purple_xmlnode_get_data(x); - g_hash_table_replace(components, g_strdup(name), value); - } - - chat = purple_chat_new(account, alias, components); - purple_blist_add_chat(chat, group, - _purple_blist_get_last_child((PurpleBlistNode*)group)); - - for(x = purple_xmlnode_get_child(cnode, "setting"); x; x = purple_xmlnode_get_next_twin(x)) { - parse_setting((PurpleBlistNode*)chat, x); - } - - g_clear_object(&account); - g_free(alias); -} - -static void parse_group(PurpleXmlNode *groupnode) { const char *name = purple_xmlnode_get_attrib(groupnode, "name"); @@ -625,8 +517,6 @@ else if (purple_strequal(cnode->name, "contact") || purple_strequal(cnode->name, "person")) parse_contact(group, cnode); - else if (purple_strequal(cnode->name, "chat")) - parse_chat(group, cnode); } } @@ -823,104 +713,6 @@ purple_blist_fold_name(new_name), group); } -void purple_blist_add_chat(PurpleChat *chat, PurpleGroup *group, PurpleBlistNode *node) -{ - PurpleBlistNode *cnode = PURPLE_BLIST_NODE(chat); - PurpleBuddyListClass *klass = NULL; - PurpleCountingNode *group_counter; - - g_return_if_fail(PURPLE_IS_CHAT(chat)); - g_return_if_fail(PURPLE_IS_BUDDY_LIST(purplebuddylist)); - klass = PURPLE_BUDDY_LIST_GET_CLASS(purplebuddylist); - - if (node == NULL) { - if (group == NULL) - group = purple_group_new(_("Chats")); - - /* Add group to blist if isn't already on it. Fixes #2752. */ - if (!purple_blist_find_group(purple_group_get_name(group))) { - purple_blist_add_group( - group, - purple_blist_get_last_sibling( - purple_blist_get_default_root())); - } - } else { - group = PURPLE_GROUP(node->parent); - } - - /* if we're moving to overtop of ourselves, do nothing */ - if (cnode == node) - return; - - if (cnode->parent) { - /* This chat was already in the list and is - * being moved. - */ - group_counter = PURPLE_COUNTING_NODE(cnode->parent); - purple_counting_node_change_total_size(group_counter, -1); - if (purple_account_is_connected(purple_chat_get_account(chat))) { - purple_counting_node_change_online_count(group_counter, -1); - purple_counting_node_change_current_size(group_counter, -1); - } - if (cnode->next) - cnode->next->prev = cnode->prev; - if (cnode->prev) - cnode->prev->next = cnode->next; - if (cnode->parent->child == cnode) - cnode->parent->child = cnode->next; - - if (klass && klass->remove) { - klass->remove(purplebuddylist, cnode); - } - /* ops->remove() cleaned up the cnode's ui_data, so we need to - * reinitialize it */ - if (klass && klass->new_node) { - klass->new_node(purplebuddylist, cnode); - } - } - - if (node != NULL) { - if (node->next) - node->next->prev = cnode; - cnode->next = node->next; - cnode->prev = node; - cnode->parent = node->parent; - node->next = cnode; - group_counter = PURPLE_COUNTING_NODE(node->parent); - purple_counting_node_change_total_size(group_counter, +1); - if (purple_account_is_connected(purple_chat_get_account(chat))) { - purple_counting_node_change_online_count(group_counter, +1); - purple_counting_node_change_current_size(group_counter, +1); - } - } else { - if (((PurpleBlistNode *)group)->child) - ((PurpleBlistNode *)group)->child->prev = cnode; - cnode->next = ((PurpleBlistNode *)group)->child; - cnode->prev = NULL; - ((PurpleBlistNode *)group)->child = cnode; - cnode->parent = PURPLE_BLIST_NODE(group); - group_counter = PURPLE_COUNTING_NODE(group); - purple_counting_node_change_total_size(group_counter, +1); - if (purple_account_is_connected(purple_chat_get_account(chat))) { - purple_counting_node_change_online_count(group_counter, +1); - purple_counting_node_change_current_size(group_counter, +1); - } - } - - if (klass) { - if (klass->save_node) { - klass->save_node(purplebuddylist, cnode); - } - if (klass->update) { - klass->update(purplebuddylist, - PURPLE_BLIST_NODE(cnode)); - } - } - - purple_signal_emit(purple_blist_get_handle(), "blist-node-added", - cnode); -} - void purple_blist_add_buddy(PurpleBuddy *buddy, PurpleMetaContact *contact, PurpleGroup *group, PurpleBlistNode *node) { PurpleBuddyListClass *klass = NULL; @@ -1106,8 +898,7 @@ klass = PURPLE_BUDDY_LIST_GET_CLASS(purplebuddylist); priv = purple_buddy_list_get_instance_private(purplebuddylist); - if (node && (PURPLE_IS_META_CONTACT(node) || - PURPLE_IS_CHAT(node))) + if (node && (PURPLE_IS_META_CONTACT(node))) g = PURPLE_GROUP(node->parent); else if (group) g = group; @@ -1197,8 +988,7 @@ } } - if (node && (PURPLE_IS_META_CONTACT(node) || - PURPLE_IS_CHAT(node))) { + if (node && (PURPLE_IS_META_CONTACT(node))) { if (node->next) node->next->prev = cnode; cnode->next = node->next; @@ -1462,56 +1252,6 @@ purple_blist_remove_contact(contact); } -void purple_blist_remove_chat(PurpleChat *chat) -{ - PurpleBuddyListClass *klass = NULL; - PurpleBlistNode *node, *gnode; - PurpleGroup *group; - PurpleCountingNode *group_counter; - - g_return_if_fail(PURPLE_IS_BUDDY_LIST(purplebuddylist)); - g_return_if_fail(PURPLE_IS_CHAT(chat)); - - klass = PURPLE_BUDDY_LIST_GET_CLASS(purplebuddylist); - node = (PurpleBlistNode *)chat; - gnode = node->parent; - group = (PurpleGroup *)gnode; - - if (gnode != NULL) - { - /* Remove the node from its parent */ - if (gnode->child == node) - gnode->child = node->next; - if (node->prev) - node->prev->next = node->next; - if (node->next) - node->next->prev = node->prev; - - /* Adjust size counts */ - group_counter = PURPLE_COUNTING_NODE(group); - if (purple_account_is_connected(purple_chat_get_account(chat))) { - purple_counting_node_change_online_count(group_counter, -1); - purple_counting_node_change_current_size(group_counter, -1); - } - purple_counting_node_change_total_size(group_counter, -1); - } - - /* Update the UI */ - if (klass && klass->remove) { - klass->remove(purplebuddylist, node); - } - - if (klass && klass->remove_node) { - klass->remove_node(purplebuddylist, node); - } - - purple_signal_emit(purple_blist_get_handle(), "blist-node-removed", - PURPLE_BLIST_NODE(chat)); - - /* Delete the node */ - g_object_unref(chat); -} - void purple_blist_remove_group(PurpleGroup *group) { PurpleAccountManager *manager = NULL; @@ -1741,12 +1481,6 @@ klass->update(purplebuddylist, cnode); } - } else if (PURPLE_IS_CHAT(cnode) && - purple_chat_get_account(PURPLE_CHAT(cnode)) == account) { - group_counter = PURPLE_COUNTING_NODE(gnode); - purple_counting_node_change_online_count(group_counter, +1); - purple_counting_node_change_current_size(group_counter, +1); - klass->update(purplebuddylist, cnode); } } klass->update(purplebuddylist, gnode); @@ -1759,7 +1493,6 @@ PurpleBlistNode *gnode, *cnode, *bnode; PurpleCountingNode *contact_counter, *group_counter; PurpleBuddy *buddy; - PurpleChat *chat; PurpleMetaContact *contact; PurpleGroup *group; GList *list = NULL, *iter = NULL; @@ -1827,19 +1560,6 @@ cnode); } } - } else if (PURPLE_IS_CHAT(cnode)) { - chat = PURPLE_CHAT(cnode); - - if(purple_chat_get_account(chat) == account) { - group_counter = PURPLE_COUNTING_NODE(group); - purple_counting_node_change_current_size(group_counter, -1); - purple_counting_node_change_online_count(group_counter, -1); - - if (klass && klass->remove) { - klass->remove(purplebuddylist, - cnode); - } - } } } } @@ -1854,7 +1574,6 @@ void purple_blist_walk(PurpleBlistWalkFunc group_func, - PurpleBlistWalkFunc chat_func, PurpleBlistWalkFunc meta_contact_func, PurpleBlistWalkFunc contact_func, gpointer data) @@ -1878,10 +1597,6 @@ contact_func(contact, data); } } - } else { - if(PURPLE_IS_CHAT(meta_contact) && chat_func != NULL) { - chat_func(meta_contact, data); - } } } } @@ -1909,21 +1624,6 @@ } void -purple_blist_request_add_chat(PurpleAccount *account, PurpleGroup *group, - const char *alias, const char *name) -{ - PurpleBuddyListClass *klass = NULL; - - g_return_if_fail(PURPLE_IS_BUDDY_LIST(purplebuddylist)); - - klass = PURPLE_BUDDY_LIST_GET_CLASS(purplebuddylist); - if (klass != NULL && klass->request_add_chat != NULL) { - klass->request_add_chat(purplebuddylist, account, group, alias, - name); - } -} - -void purple_blist_request_add_group(void) { PurpleBuddyListClass *klass = NULL;
--- a/libpurple/buddylist.h Sat Apr 13 23:01:11 2024 -0500 +++ b/libpurple/buddylist.h Sat Apr 13 23:08:29 2024 -0500 @@ -43,7 +43,6 @@ */ #define PURPLE_BLIST_DEFAULT_GROUP_NAME (purple_blist_get_default_group_name()) -#include "chat.h" #include "contact.h" /** @@ -95,8 +94,6 @@ * @set_visible: Hides or unhides the buddy list. * @request_add_buddy: Called when information is needed to add a buddy to the * buddy list. See purple_blist_request_add_buddy(). - * @request_add_chat: Called when information is needed to add a chat to the - * buddy list. See purple_blist_request_add_chat(). * @request_add_group: Called when information is needed to add a group to the * buddy list. See purple_blist_request_add_group(). * @save_node: This is called when a node has been modified and should be @@ -150,10 +147,6 @@ const char *username, const char *group, const char *alias); - void (*request_add_chat)(PurpleBuddyList *list, PurpleAccount *account, - PurpleGroup *group, const char *alias, - const char *name); - void (*request_add_group)(PurpleBuddyList *list); void (*save_node)(PurpleBuddyList *list, PurpleBlistNode *node); @@ -286,23 +279,6 @@ void purple_blist_update_groups_cache(PurpleGroup *group, const char *new_name); /** - * purple_blist_add_chat: - * @chat: The new chat who gets added - * @group: The group to add the new chat to. - * @node: The insertion point - * - * Adds a new chat to the buddy list. - * - * The chat will be inserted right after node or appended to the end - * of group if node is NULL. If both are NULL, the buddy will be added to - * the "Chats" group. - * - * Since: 2.0 - */ -PURPLE_AVAILABLE_IN_ALL -void purple_blist_add_chat(PurpleChat *chat, PurpleGroup *group, PurpleBlistNode *node); - -/** * purple_blist_add_buddy: * @buddy: The new buddy who gets added * @contact: The optional contact to place the buddy in. @@ -382,17 +358,6 @@ void purple_blist_remove_contact(PurpleMetaContact *contact); /** - * purple_blist_remove_chat: - * @chat: The chat to be removed - * - * Removes a chat from the buddy list and frees the memory allocated to it. - * - * Since: 2.0 - */ -PURPLE_AVAILABLE_IN_ALL -void purple_blist_remove_chat(PurpleChat *chat); - -/** * purple_blist_remove_group: * @group: The group to be removed * @@ -502,7 +467,6 @@ /** * purple_blist_walk: * @group_func: (scope call): The callback for groups - * @chat_func: (scope call): The callback for chats * @meta_contact_func: (scope call): The callback for meta-contacts * @contact_func: (scope call): The callback for contacts * @data: User supplied data. @@ -513,7 +477,7 @@ * Since: 3.0 */ PURPLE_AVAILABLE_IN_3_0 -void purple_blist_walk(PurpleBlistWalkFunc group_func, PurpleBlistWalkFunc chat_func, PurpleBlistWalkFunc meta_contact_func, PurpleBlistWalkFunc contact_func, gpointer data); +void purple_blist_walk(PurpleBlistWalkFunc group_func, PurpleBlistWalkFunc meta_contact_func, PurpleBlistWalkFunc contact_func, gpointer data); /** * purple_blist_get_default_group_name: @@ -562,22 +526,6 @@ const char *group, const char *alias); /** - * purple_blist_request_add_chat: - * @account: The account the buddy is added to. - * @group: The optional group to add the chat to. - * @alias: The optional alias for the chat. - * @name: The required chat name. - * - * Requests from the user information needed to add a chat to the - * buddy list. - * - * Since: 2.0 - */ -PURPLE_AVAILABLE_IN_ALL -void purple_blist_request_add_chat(PurpleAccount *account, PurpleGroup *group, - const char *alias, const char *name); - -/** * purple_blist_request_add_group: * * Requests from the user information needed to add a group to the
--- a/libpurple/chat.c Sat Apr 13 23:01:11 2024 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,301 +0,0 @@ -/* - * Purple - Internet Messaging Library - * Copyright (C) Pidgin Developers <devel@pidgin.im> - * - * Purple is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this library; if not, see <https://www.gnu.org/licenses/>. - */ - -#include "chat.h" -#include "util.h" - -typedef struct _PurpleChatPrivate PurpleChatPrivate; - -/* Private data for a chat node */ -struct _PurpleChatPrivate { - char *alias; /* The display name of this chat. */ - PurpleAccount *account; /* The account this chat is attached to */ - GHashTable *components; /* the stuff the protocol needs to know to - join the chat */ - - gboolean is_constructed; /* Indicates if the chat has finished being - constructed. */ -}; - -/* Chat property enums */ -enum -{ - PROP_0, - PROP_ALIAS, - PROP_ACCOUNT, - PROP_COMPONENTS, - N_PROPERTIES, -}; - -/****************************************************************************** - * Globals - *****************************************************************************/ -static GParamSpec *properties[N_PROPERTIES] = {NULL, }; - -G_DEFINE_TYPE_WITH_PRIVATE(PurpleChat, purple_chat, PURPLE_TYPE_BLIST_NODE); - -/****************************************************************************** - * API - *****************************************************************************/ - -const char *purple_chat_get_name(PurpleChat *chat) -{ - PurpleChatPrivate *priv = NULL; - - g_return_val_if_fail(PURPLE_IS_CHAT(chat), NULL); - - priv = purple_chat_get_instance_private(chat); - - if ((priv->alias != NULL) && (*priv->alias != '\0')) - return priv->alias; - - return NULL; -} - -void -purple_chat_set_alias(PurpleChat *chat, const char *alias) -{ - PurpleChatPrivate *priv = NULL; - char *old_alias; - char *new_alias = NULL; - - g_return_if_fail(PURPLE_IS_CHAT(chat)); - - priv = purple_chat_get_instance_private(chat); - - if ((alias != NULL) && (*alias != '\0')) - new_alias = purple_utf8_strip_unprintables(alias); - - if (!purple_strequal(priv->alias, new_alias)) { - g_free(new_alias); - return; - } - - old_alias = priv->alias; - - if ((new_alias != NULL) && (*new_alias != '\0')) - priv->alias = new_alias; - else { - priv->alias = NULL; - g_free(new_alias); /* could be "\0" */ - } - - g_object_notify_by_pspec(G_OBJECT(chat), properties[PROP_ALIAS]); - - purple_blist_save_node(purple_blist_get_default(), - PURPLE_BLIST_NODE(chat)); - purple_blist_update_node(purple_blist_get_default(), - PURPLE_BLIST_NODE(chat)); - - purple_signal_emit(purple_blist_get_handle(), "blist-node-aliased", - chat, old_alias); - g_free(old_alias); -} - -PurpleGroup * -purple_chat_get_group(PurpleChat *chat) -{ - g_return_val_if_fail(PURPLE_IS_CHAT(chat), NULL); - - return PURPLE_GROUP(PURPLE_BLIST_NODE(chat)->parent); -} - -PurpleAccount * -purple_chat_get_account(PurpleChat *chat) -{ - PurpleChatPrivate *priv = NULL; - - g_return_val_if_fail(PURPLE_IS_CHAT(chat), NULL); - - priv = purple_chat_get_instance_private(chat); - return priv->account; -} - -GHashTable * -purple_chat_get_components(PurpleChat *chat) -{ - PurpleChatPrivate *priv = NULL; - - g_return_val_if_fail(PURPLE_IS_CHAT(chat), NULL); - - priv = purple_chat_get_instance_private(chat); - return priv->components; -} - -/****************************************************************************** - * GObject Stuff - *****************************************************************************/ -static void -purple_chat_set_property(GObject *obj, guint param_id, const GValue *value, - GParamSpec *pspec) -{ - PurpleChat *chat = PURPLE_CHAT(obj); - PurpleChatPrivate *priv = purple_chat_get_instance_private(chat); - - switch (param_id) { - case PROP_ALIAS: - if (priv->is_constructed) - purple_chat_set_alias(chat, g_value_get_string(value)); - else - priv->alias = - purple_utf8_strip_unprintables(g_value_get_string(value)); - break; - case PROP_ACCOUNT: - priv->account = g_value_get_object(value); - break; - case PROP_COMPONENTS: - priv->components = g_value_get_pointer(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); - break; - } -} - -static void -purple_chat_get_property(GObject *obj, guint param_id, GValue *value, - GParamSpec *pspec) -{ - PurpleChat *chat = PURPLE_CHAT(obj); - PurpleChatPrivate *priv = purple_chat_get_instance_private(chat); - - switch (param_id) { - case PROP_ALIAS: - g_value_set_string(value, priv->alias); - break; - case PROP_ACCOUNT: - g_value_set_object(value, purple_chat_get_account(chat)); - break; - case PROP_COMPONENTS: - g_value_set_pointer(value, purple_chat_get_components(chat)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); - break; - } -} - -/* GObject initialization function */ -static void -purple_chat_init(G_GNUC_UNUSED PurpleChat *chat) -{ -} - -/* Called when done constructing */ -static void -purple_chat_constructed(GObject *object) -{ - PurpleChat *chat = PURPLE_CHAT(object); - PurpleChatPrivate *priv = purple_chat_get_instance_private(chat); - - G_OBJECT_CLASS(purple_chat_parent_class)->constructed(object); - - purple_blist_new_node(purple_blist_get_default(), - PURPLE_BLIST_NODE(chat)); - - priv->is_constructed = TRUE; -} - -/* GObject finalize function */ -static void -purple_chat_finalize(GObject *object) -{ - PurpleChatPrivate *priv = - purple_chat_get_instance_private(PURPLE_CHAT(object)); - - g_free(priv->alias); - g_hash_table_destroy(priv->components); - - G_OBJECT_CLASS(purple_chat_parent_class)->finalize(object); -} - -/* Class initializer function */ -static void purple_chat_class_init(PurpleChatClass *klass) -{ - GObjectClass *obj_class = G_OBJECT_CLASS(klass); - - obj_class->finalize = purple_chat_finalize; - - /* Setup properties */ - obj_class->get_property = purple_chat_get_property; - obj_class->set_property = purple_chat_set_property; - obj_class->constructed = purple_chat_constructed; - - /** - * PurpleChat:alias: - * - * The alias of the chat. - * - * Since: 3.0 - */ - properties[PROP_ALIAS] = g_param_spec_string( - "alias", - "Alias", - "The alias for the chat.", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS - ); - - /** - * PurpleChat:account: - * - * The account that the chat belongs to. - * - * Since: 3.0 - */ - properties[PROP_ACCOUNT] = g_param_spec_object( - "account", - "Account", - "The account that the chat belongs to.", - PURPLE_TYPE_ACCOUNT, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS - ); - - /** - * PurpleChat:components: - * - * The components for the chat. - * - * Since: 3.0 - */ - properties[PROP_COMPONENTS] = g_param_spec_pointer( - "components", - "Components", - "The protocol components of the chat.", - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS - ); - - g_object_class_install_properties(obj_class, N_PROPERTIES, properties); -} - -PurpleChat * -purple_chat_new(PurpleAccount *account, const char *alias, GHashTable *components) -{ - g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL); - g_return_val_if_fail(components != NULL, NULL); - - return g_object_new(PURPLE_TYPE_CHAT, - "account", account, - "alias", alias, - "components", components, - NULL); -}
--- a/libpurple/chat.h Sat Apr 13 23:01:11 2024 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,162 +0,0 @@ -/* - * Purple - Internet Messaging Library - * Copyright (C) Pidgin Developers <devel@pidgin.im> - * - * Purple is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this library; if not, see <https://www.gnu.org/licenses/>. - */ - -#if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION) -# error "only <purple.h> may be included directly" -#endif - -#ifndef PURPLE_CHAT_H -#define PURPLE_CHAT_H - -#define PURPLE_TYPE_CHAT (purple_chat_get_type()) -#define PURPLE_CHAT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_CHAT, PurpleChat)) -#define PURPLE_CHAT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_CHAT, PurpleChatClass)) -#define PURPLE_IS_CHAT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_CHAT)) -#define PURPLE_IS_CHAT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_CHAT)) -#define PURPLE_CHAT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_CHAT, PurpleChatClass)) - -typedef struct _PurpleChat PurpleChat; -typedef struct _PurpleChatClass PurpleChatClass; - -#include "blistnode.h" -#include "group.h" -#include "purpleaccount.h" -#include "purpleversion.h" - -/** - * PurpleChat: - * - * A chat on the buddy list. - * - * Since: 2.0 - */ -struct _PurpleChat { - PurpleBlistNode node; -}; - -struct _PurpleChatClass { - PurpleBlistNodeClass node_class; - - /*< private >*/ - void (*_purple_reserved1)(void); - void (*_purple_reserved2)(void); - void (*_purple_reserved3)(void); - void (*_purple_reserved4)(void); -}; - -G_BEGIN_DECLS - -/** - * purple_chat_get_type: - * - * Returns: The #GType for the #PurpleChat object. - * - * Since: 3.0 - */ -PURPLE_AVAILABLE_IN_3_0 -GType purple_chat_get_type(void); - -/** - * purple_chat_new: - * @account: The account this chat will get added to - * @alias: The alias of the new chat - * @components: The info the protocol needs to join the chat. The - * hash function should be g_str_hash() and the - * equal function should be g_str_equal(). - * - * Creates a new chat for the buddy list - * - * Returns: A newly allocated chat - * - * Since: 2.0 - */ -PURPLE_AVAILABLE_IN_ALL -PurpleChat *purple_chat_new(PurpleAccount *account, const char *alias, GHashTable *components); - -/** - * purple_chat_get_name: - * @chat: The chat whose name will be returned. - * - * Returns the correct name to display for a blist chat. - * - * Returns: The alias (if set), or first component value. - * - * Since: 2.0 - */ -PURPLE_AVAILABLE_IN_ALL -const char *purple_chat_get_name(PurpleChat *chat); - -/** - * purple_chat_set_alias: - * @chat: The chat - * @alias: The alias - * - * Sets the alias for a blist chat. - * - * Since: 3.0 - */ -PURPLE_AVAILABLE_IN_3_0 -void purple_chat_set_alias(PurpleChat *chat, const char *alias); - -/** - * purple_chat_get_group: - * @chat: The chat. - * - * Returns the group of which the chat is a member. - * - * Returns: (transfer none): The parent group, or %NULL if the chat is not in a - * group. - * - * Since: 2.0 - */ -PURPLE_AVAILABLE_IN_ALL -PurpleGroup *purple_chat_get_group(PurpleChat *chat); - -/** - * purple_chat_get_account: - * @chat: The chat. - * - * Returns the account the chat belongs to. - * - * Returns: (transfer none): The account the chat belongs to. - * - * Since: 2.4 - */ -PURPLE_AVAILABLE_IN_2_4 -PurpleAccount *purple_chat_get_account(PurpleChat *chat); - -/** - * purple_chat_get_components: - * @chat: The chat. - * - * Get a hashtable containing information about a chat. - * - * Returns: (transfer none): The hashtable. - * - * Since: 2.4 - */ -PURPLE_AVAILABLE_IN_2_4 -GHashTable *purple_chat_get_components(PurpleChat *chat); - -G_END_DECLS - -#endif /* PURPLE_CHAT_H */
--- a/libpurple/group.c Sat Apr 13 23:01:11 2024 -0500 +++ b/libpurple/group.c Sat Apr 13 23:08:29 2024 -0500 @@ -63,10 +63,7 @@ gnode = (PurpleBlistNode *)group; for (cnode = gnode->child; cnode; cnode = cnode->next) { - if (PURPLE_IS_CHAT(cnode)) { - if (!g_slist_find(l, purple_chat_get_account(PURPLE_CHAT(cnode)))) - l = g_slist_append(l, purple_chat_get_account(PURPLE_CHAT(cnode))); - } else if (PURPLE_IS_META_CONTACT(cnode)) { + if (PURPLE_IS_META_CONTACT(cnode)) { for (bnode = cnode->child; bnode; bnode = bnode->next) { if (PURPLE_IS_BUDDY(bnode)) { if (!g_slist_find(l, purple_buddy_get_account(PURPLE_BUDDY(bnode)))) @@ -85,11 +82,6 @@ if (PURPLE_IS_META_CONTACT(cnode)) { if(purple_meta_contact_on_account((PurpleMetaContact *) cnode, account)) return TRUE; - } else if (PURPLE_IS_CHAT(cnode)) { - PurpleChat *chat = (PurpleChat *)cnode; - if ((!account && purple_account_is_connected(purple_chat_get_account(chat))) - || purple_chat_get_account(chat) == account) - return TRUE; } } return FALSE; @@ -145,9 +137,6 @@ moved_buddies = g_list_append(moved_buddies, bnode); } prev = child; - } else if (PURPLE_IS_CHAT(child)) { - purple_blist_add_chat((PurpleChat *)child, dest, prev); - prev = child; } else { purple_debug_error("blistnodetypes", "Unknown child type in group %s", priv->name); }
--- a/libpurple/meson.build Sat Apr 13 23:01:11 2024 -0500 +++ b/libpurple/meson.build Sat Apr 13 23:08:29 2024 -0500 @@ -5,7 +5,6 @@ 'buddy.c', 'buddylist.c', 'buddyicon.c', - 'chat.c', 'circularbuffer.c', 'cmds.c', 'connection.c', @@ -115,7 +114,6 @@ 'buddy.h', 'buddylist.h', 'buddyicon.h', - 'chat.h', 'circularbuffer.h', 'cmds.h', 'connection.h',
--- a/libpurple/purpleprotocolclient.c Sat Apr 13 23:01:11 2024 -0500 +++ b/libpurple/purpleprotocolclient.c Sat Apr 13 23:08:29 2024 -0500 @@ -87,25 +87,6 @@ return NULL; } -PurpleChat * -purple_protocol_client_find_blist_chat(PurpleProtocolClient *client, - PurpleAccount *account, - const gchar *name) -{ - PurpleProtocolClientInterface *iface = NULL; - - g_return_val_if_fail(PURPLE_IS_PROTOCOL_CLIENT(client), NULL); - g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL); - g_return_val_if_fail(name != NULL, NULL); - - iface = PURPLE_PROTOCOL_CLIENT_GET_IFACE(client); - if(iface != NULL && iface->find_blist_chat != NULL) { - return iface->find_blist_chat(client, account, name); - } - - return NULL; -} - gboolean purple_protocol_client_offline_message(PurpleProtocolClient *client, PurpleBuddy *buddy)
--- a/libpurple/purpleprotocolclient.h Sat Apr 13 23:01:11 2024 -0500 +++ b/libpurple/purpleprotocolclient.h Sat Apr 13 23:08:29 2024 -0500 @@ -62,8 +62,6 @@ const gchar *(*normalize)(PurpleProtocolClient *client, PurpleAccount *account, const gchar *who); - PurpleChat *(*find_blist_chat)(PurpleProtocolClient *client, PurpleAccount *account, const gchar *name); - gboolean (*offline_message)(PurpleProtocolClient *client, PurpleBuddy *buddy); /*< private >*/ @@ -118,22 +116,6 @@ const gchar *purple_protocol_client_normalize(PurpleProtocolClient *client, PurpleAccount *account, const gchar *who); /** - * purple_protocol_client_find_blist_chat: - * @client: The #PurpleProtocolClient instance. - * @account: A #PurpleAccount instance. - * @name: The name of the chat to find. - * - * Looks for a chat named @name in the contact list of @account. - * - * Returns: (transfer none): The #PurpleChat instance or %NULL if no chat could - * be found. - * - * Since: 3.0 - */ -PURPLE_AVAILABLE_IN_3_0 -PurpleChat *purple_protocol_client_find_blist_chat(PurpleProtocolClient *client, PurpleAccount *account, const gchar *name); - -/** * purple_protocol_client_offline_message: * @client: The #PurpleProtocolClient instance. * @buddy: A #PurpleBuddy instance.