summaryrefslogtreecommitdiff
path: root/libpurple/purpleconversation.h
diff options
context:
space:
mode:
authorGary Kramlich <grim@reaperworld.com>2023-03-03 01:24:36 -0600
committerGary Kramlich <grim@reaperworld.com>2023-03-03 01:24:36 -0600
commit0884785f7bd2f15efd5a1631dfdd9ebd7ecbc4db (patch)
tree766925af8616ccc89dd13e783ede3e7993a901fe /libpurple/purpleconversation.h
parent60320e741924bc697d663ae39e8be0b2a6e1ea91 (diff)
downloadpidgin-0884785f7bd2f15efd5a1631dfdd9ebd7ecbc4db.tar.gz
Add membership management to PurpleConversation
This is one of many steps to making PurpleConversation handle all conversation types instead of being an abstract class. In modern chat protocols the only distinction between different types of conversations is an enum property and members can join and leave dms, group dms, and multiple user chats. As such this change is necessary to facilitate that. Testing Done: Ran the unit tests under valgrind and built and verified the docs looked alright. Bugs closed: PIDGIN-17768 Reviewed at https://reviews.imfreedom.org/r/2287/
Diffstat (limited to 'libpurple/purpleconversation.h')
-rw-r--r--libpurple/purpleconversation.h125
1 files changed, 110 insertions, 15 deletions
diff --git a/libpurple/purpleconversation.h b/libpurple/purpleconversation.h
index 2cfd4a80fe..b2cf93adfa 100644
--- a/libpurple/purpleconversation.h
+++ b/libpurple/purpleconversation.h
@@ -1,22 +1,19 @@
-/* purple
+/*
+ * 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 Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
*
- * This program 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 program is distributed in the hope that it will be useful,
+ * 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.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <https://www.gnu.org/licenses/>.
*/
#if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION)
@@ -33,6 +30,8 @@
G_DECLARE_DERIVABLE_TYPE(PurpleConversation, purple_conversation, PURPLE,
CONVERSATION, GObject)
+#include <purplecontactinfo.h>
+#include <purpleconversationmember.h>
#include <purplemessage.h>
/**
@@ -357,6 +356,102 @@ GList * purple_conversation_get_extended_menu(PurpleConversation *conv);
*/
gboolean purple_conversation_present_error(const gchar *who, PurpleAccount *account, const gchar *what);
+/**
+ * purple_conversation_get_members:
+ * @conversation: The instance.
+ *
+ * Gets the members that are in @conversation.
+ *
+ * Returns: (transfer none): The members in @conversation.
+ *
+ * Since: 3.0.0
+ */
+GListModel *purple_conversation_get_members(PurpleConversation *conversation);
+
+/**
+ * purple_conversation_has_member:
+ * @conversation: The instance.
+ * @info: The [class@Purple.ContactInfo] to look for.
+ * @position: (out) (optional): A return address for the position of the member
+ * in the collection.
+ *
+ * Checks if @info is in @conversation. If @info is found, @position is set to
+ * the position of @info in [property@Purple.Conversation:members] if it is not
+ * %NULL.
+ *
+ * Returns: %TRUE if @info is in @conversation otherwise %FALSE.
+ *
+ * Since: 3.0.0
+ */
+gboolean purple_conversation_has_member(PurpleConversation *conversation, PurpleContactInfo *info, guint *position);
+
+/**
+ * purple_conversation_find_member:
+ * @conversation: The instance.
+ * @info: A [class@Purple.ContactInfo instance]
+ *
+ * Finds the [class@Purple.ConversationMember] for @info if they are a member
+ * of @conversation.
+ *
+ * Returns: (transfer none) (nullable): The [class@Purple.ConversationMember]
+ * if found or %NULL.
+ *
+ * Since: 3.0.0
+ */
+PurpleConversationMember *purple_conversation_find_member(PurpleConversation *conversation, PurpleContactInfo *info);
+
+/**
+ * purple_conversation_add_member:
+ * @conversation: The instance.
+ * @info: The [class@Purple.ContactInfo] of the person joining.
+ * @announce: Whether this addition should be announced or not.
+ * @message: (nullable): An optional message to be used with @announce.
+ *
+ * Looks for an existing [class@Purple.ConversationMember] for @info in
+ * @conversation and returns it if found. If not, a new
+ * [class@Purple.ConversationMember] is created.
+ *
+ * > This method is intended to be called by a protocol plugin to directly
+ * > manage the membership state of the @conversation.
+ *
+ * This will also emit the [signal@Purple.Conversation::member-added] signal if
+ * an existing member was not found.
+ *
+ * The @announce and @message parameters will be used when emitting the
+ * [signal@Purple.Conversation::member-added] signal. Announce and message are
+ * meant for protocols to more properly define their behavior. For example, on
+ * IRC you will typically be told when a user joins a chat but on Twitch this
+ * isn't announced.
+ *
+ * Returns: (transfer none): The [class@Purple.ConversationMember] that was
+ * created or found.
+ *
+ * Since: 3.0.0
+ */
+PurpleConversationMember *purple_conversation_add_member(PurpleConversation *conversation, PurpleContactInfo *info, gboolean announce, const char *message);
+
+/**
+ * purple_conversation_remove_member:
+ * @conversation: The instance.
+ * @member: The [class@Purple.ConversationMember] to remove.
+ * @announce: Whether or not this removal should be announced.
+ * @message: (nullable): An optional message for the announcement.
+ *
+ * Attempts to remove @member from the collection of members in @conversation.
+ * If found, @member is removed and the
+ * [signal@Purple.Conversation::member-removed] signal is emitted with
+ * @announce and @message as parameters.
+ *
+ * > This method is intended to be called by a protocol plugin to directly
+ * > manage the membership state of the @conversation.
+ *
+ * Returns: %TRUE if @member was found and removed from @conversation,
+ * otherwise %FALSE.
+ *
+ * Since: 3.0.0
+ */
+gboolean purple_conversation_remove_member(PurpleConversation *conversation, PurpleConversationMember *member, gboolean announce, const char *message);
+
G_END_DECLS
#endif /* PURPLE_CONVERSATION_H */