pidgin/pidgin

Parents eae11ccb1bef
Children 6f735120e998
Make PurpleProtocolPrivacy a proper GInterface and move it to it's own file

Move PurpleProtocolPrivacy to its own interface and make it match a typical GInterface implementation

Testing Done:
Compiled and ran with bonjour. Verified no errors in the output. Build and checked the docs as well.

Reviewed at https://reviews.imfreedom.org/r/80/
--- a/ChangeLog.API Sat Aug 22 13:03:30 2020 -0500
+++ b/ChangeLog.API Sat Aug 22 22:15:25 2020 -0500
@@ -33,9 +33,7 @@
* PurpleProtocolOverrideFlags
* PurpleProtocolClientIface
* PurpleProtocolServerIface
- * PurpleProtocolIMIface
* PurpleProtocolChatIface
- * PurpleProtocolPrivacyIface
* PurpleProtocolXferIface
* PurpleProtocolRoomlistIface
* PurpleProtocolAttentionIface
@@ -44,10 +42,6 @@
* purple_protocol_get_* for PurpleProtocol members
* purple_protocol_class_* for class methods
* purple_protocol_server_iface_* for server interface methods
- * purple_protocol_im_iface_* for IM interface methods
- * purple_protocol_privacy_iface_* for privacy interface methods
- * purple_protocol_xfer_iface_* for xfer interface methods
- * purple_protocol_attention_iface_* for attention interface methods
* purple_protocol_factory_iface_* for factory interface methods
* purple_protocol_action_new
* purple_protocol_action_free
--- a/doc/reference/libpurple/libpurple-docs.xml Sat Aug 22 13:03:30 2020 -0500
+++ b/doc/reference/libpurple/libpurple-docs.xml Sat Aug 22 22:15:25 2020 -0500
@@ -71,6 +71,7 @@
<xi:include href="xml/purplekeyvaluepair.xml" />
<xi:include href="xml/purpleprotocolfactory.xml" />
<xi:include href="xml/purpleprotocolim.xml" />
+ <xi:include href="xml/purpleprotocolprivacy.xml" />
<xi:include href="xml/purpleuiinfo.xml" />
<xi:include href="xml/queuedoutputstream.xml" />
<xi:include href="xml/signals.xml" />
--- a/libpurple/account.c Sat Aug 22 13:03:30 2020 -0500
+++ b/libpurple/account.c Sat Aug 22 22:15:25 2020 -0500
@@ -2335,9 +2335,10 @@
name = purple_normalize(account, who);
l = g_slist_find_custom(priv->permit, name, (GCompareFunc)g_strcmp0);
- if (l == NULL)
+ if (l == NULL) {
/* We didn't find the buddy we were looking for, so bail out */
return FALSE;
+ }
/* We should not free l->data just yet. There can be occasions where
* l->data == who. In such cases, freeing l->data here can cause crashes
@@ -2345,11 +2346,13 @@
del = l->data;
priv->permit = g_slist_delete_link(priv->permit, l);
- if (!local_only && purple_account_is_connected(account))
- purple_serv_rem_permit(purple_account_get_connection(account), who);
-
- if (ui_ops != NULL && ui_ops->permit_removed != NULL)
+ if (!local_only && purple_account_is_connected(account)) {
+ purple_serv_remove_permit(purple_account_get_connection(account), who);
+ }
+
+ if (ui_ops != NULL && ui_ops->permit_removed != NULL) {
ui_ops->permit_removed(account, who);
+ }
purple_blist_save_account(purple_blist_get_default(), account);
@@ -2419,20 +2422,23 @@
normalized = purple_normalize(account, who);
l = g_slist_find_custom(priv->deny, normalized, (GCompareFunc)g_strcmp0);
- if (l == NULL)
+ if (l == NULL) {
/* We didn't find the buddy we were looking for, so bail out */
return FALSE;
+ }
buddy = purple_blist_find_buddy(account, normalized);
name = l->data;
priv->deny = g_slist_delete_link(priv->deny, l);
- if (!local_only && purple_account_is_connected(account))
- purple_serv_rem_deny(purple_account_get_connection(account), name);
-
- if (ui_ops != NULL && ui_ops->deny_removed != NULL)
+ if (!local_only && purple_account_is_connected(account)) {
+ purple_serv_remove_deny(purple_account_get_connection(account), name);
+ }
+
+ if (ui_ops != NULL && ui_ops->deny_removed != NULL) {
ui_ops->deny_removed(account, who);
+ }
if (buddy != NULL) {
purple_signal_emit(purple_blist_get_handle(),
--- a/libpurple/meson.build Sat Aug 22 13:03:30 2020 -0500
+++ b/libpurple/meson.build Sat Aug 22 22:15:25 2020 -0500
@@ -54,6 +54,7 @@
'purplekeyvaluepair.c',
'purpleprotocolfactory.c',
'purpleprotocolim.c',
+ 'purpleprotocolprivacy.c',
'purpleuiinfo.c',
'queuedoutputstream.c',
'request.c',
@@ -133,6 +134,7 @@
'purplekeyvaluepair.h',
'purpleprotocolfactory.h',
'purpleprotocolim.h',
+ 'purpleprotocolprivacy.h',
'purpleuiinfo.h',
'queuedoutputstream.h',
'request.h',
--- a/libpurple/protocol.c Sat Aug 22 13:03:30 2020 -0500
+++ b/libpurple/protocol.c Sat Aug 22 22:15:25 2020 -0500
@@ -640,77 +640,6 @@
#undef DEFINE_PROTOCOL_FUNC
/**************************************************************************
- * Protocol Privacy Interface API
- **************************************************************************/
-#define DEFINE_PROTOCOL_FUNC(protocol,funcname,...) \
- PurpleProtocolPrivacyInterface *privacy_iface = \
- PURPLE_PROTOCOL_PRIVACY_GET_IFACE(protocol); \
- if (privacy_iface && privacy_iface->funcname) \
- privacy_iface->funcname(__VA_ARGS__);
-
-#define DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol,defaultreturn,funcname,...) \
- PurpleProtocolPrivacyInterface *privacy_iface = \
- PURPLE_PROTOCOL_PRIVACY_GET_IFACE(protocol); \
- if (privacy_iface && privacy_iface->funcname) \
- return privacy_iface->funcname(__VA_ARGS__); \
- else \
- return defaultreturn;
-
-GType
-purple_protocol_privacy_iface_get_type(void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY(type == 0)) {
- static const GTypeInfo info = {
- .class_size = sizeof(PurpleProtocolPrivacyInterface),
- };
-
- type = g_type_register_static(G_TYPE_INTERFACE,
- "PurpleProtocolPrivacyInterface", &info, 0);
- }
- return type;
-}
-
-void
-purple_protocol_privacy_iface_add_permit(PurpleProtocol *protocol,
- PurpleConnection *gc, const char *name)
-{
- DEFINE_PROTOCOL_FUNC(protocol, add_permit, gc, name);
-}
-
-void
-purple_protocol_privacy_iface_add_deny(PurpleProtocol *protocol,
- PurpleConnection *gc, const char *name)
-{
- DEFINE_PROTOCOL_FUNC(protocol, add_deny, gc, name);
-}
-
-void
-purple_protocol_privacy_iface_rem_permit(PurpleProtocol *protocol,
- PurpleConnection *gc, const char *name)
-{
- DEFINE_PROTOCOL_FUNC(protocol, rem_permit, gc, name);
-}
-
-void
-purple_protocol_privacy_iface_rem_deny(PurpleProtocol *protocol,
- PurpleConnection *gc, const char *name)
-{
- DEFINE_PROTOCOL_FUNC(protocol, rem_deny, gc, name);
-}
-
-void
-purple_protocol_privacy_iface_set_permit_deny(PurpleProtocol *protocol,
- PurpleConnection *gc)
-{
- DEFINE_PROTOCOL_FUNC(protocol, set_permit_deny, gc);
-}
-
-#undef DEFINE_PROTOCOL_FUNC_WITH_RETURN
-#undef DEFINE_PROTOCOL_FUNC
-
-/**************************************************************************
* Protocol Media Interface API
**************************************************************************/
#define DEFINE_PROTOCOL_FUNC(protocol,funcname,...) \
--- a/libpurple/protocol.h Sat Aug 22 13:03:30 2020 -0500
+++ b/libpurple/protocol.h Sat Aug 22 22:15:25 2020 -0500
@@ -474,42 +474,6 @@
#define PURPLE_PROTOCOL_CHAT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), PURPLE_TYPE_PROTOCOL_CHAT, \
PurpleProtocolChatInterface))
-#define PURPLE_TYPE_PROTOCOL_PRIVACY (purple_protocol_privacy_iface_get_type())
-
-typedef struct _PurpleProtocolPrivacyInterface PurpleProtocolPrivacyInterface;
-
-/**
- * PurpleProtocolPrivacyInterface:
- * @add_permit: Add the buddy on the required authorized list.
- * @add_deny: Add the buddy on the required blocked list.
- * @rem_permit: Remove the buddy from the requried authorized list.
- * @rem_deny: Remove the buddy from the required blocked list.
- * @set_permit_deny:Update the server with the privacy information on the permit and deny lists.
- *
- * The protocol privacy interface.
- *
- * This interface provides privacy callbacks such as to permit/deny users.
- */
-struct _PurpleProtocolPrivacyInterface
-{
- /*< private >*/
- GTypeInterface parent_iface;
-
- /*< public >*/
- void (*add_permit)(PurpleConnection *gc, const char *name);
-
- void (*add_deny)(PurpleConnection *gc, const char *name);
-
- void (*rem_permit)(PurpleConnection *gc, const char *name);
-
- void (*rem_deny)(PurpleConnection *gc, const char *name);
-
- void (*set_permit_deny)(PurpleConnection *gc);
-};
-
-#define PURPLE_IS_PROTOCOL_PRIVACY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PROTOCOL_PRIVACY))
-#define PURPLE_PROTOCOL_PRIVACY_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), PURPLE_TYPE_PROTOCOL_PRIVACY, \
- PurpleProtocolPrivacyInterface))
#define PURPLE_TYPE_PROTOCOL_MEDIA (purple_protocol_media_iface_get_type())
@@ -1025,85 +989,6 @@
PurpleConnection *gc, int id, const char *topic);
/**************************************************************************/
-/* Protocol Privacy Interface API */
-/**************************************************************************/
-
-/**
- * purple_protocol_privacy_iface_get_type:
- *
- * Returns: The #GType for the protocol privacy interface.
- *
- * Since: 3.0.0
- */
-GType purple_protocol_privacy_iface_get_type(void);
-
-/**
- * purple_protocol_privacy_iface_add_permit:
- * @protocol: The #PurpleProtocol instance.
- * @connection: The #PurpleConnection instance.
- * @name: The username to permit.
- *
- * Adds a permit to the privacy settings for @connection to allow @name to
- * contact the user.
- *
- * Since: 3.0.0
- */
-void purple_protocol_privacy_iface_add_permit(PurpleProtocol *protocol,
- PurpleConnection *connection, const char *name);
-
-/**
- * purple_protocol_privacy_iface_add_deny:
- * @protocol: The #PurpleProtocol instance.
- * @connection: The #PurpleConnection instance.
- * @name: The username to deny.
- *
- * Adds a deny to the privacy settings for @connection to deny @name from
- * contacting the user.
- *
- * Since: 3.0.0
- */
-void purple_protocol_privacy_iface_add_deny(PurpleProtocol *protocol,
- PurpleConnection *connection, const char *name);
-
-/**
- * purple_protocol_privacy_iface_rem_permit:
- * @protocol: The #PurpleProtocol instance.
- * @connection: The #PurpleConnection instance.
- * @name: The username to remove from the permit privacy settings.
- *
- * Removes an existing permit for @name.
- *
- * Since: 3.0.0
- */
-void purple_protocol_privacy_iface_rem_permit(PurpleProtocol *protocol,
- PurpleConnection *connection, const char *name);
-
-/**
- * purple_protocol_privacy_iface_rem_deny:
- * @protocol: The #PurpleProtocol instance.
- * @connection: The #PurpleConnection instance.
- * @name: The username to remove from the deny privacy settings.
- *
- * Removes an existing deny for @name.
- *
- * Since: 3.0.0
- */
-void purple_protocol_privacy_iface_rem_deny(PurpleProtocol *protocol,
- PurpleConnection *connection, const char *name);
-
-/**
- * purple_protocol_privacy_iface_set_permit_deny:
- * @protocol: The #PurpleProtocol instance.
- * @connection: The #PurpleConnection instance.
- *
- * Forces a sync of the privacy settings with server.
- *
- * Since: 3.0.0
- */
-void purple_protocol_privacy_iface_set_permit_deny(PurpleProtocol *protocol,
- PurpleConnection *connection);
-
-/**************************************************************************/
/* Protocol Media Interface API */
/**************************************************************************/
--- a/libpurple/protocols/gg/gg.c Sat Aug 22 13:03:30 2020 -0500
+++ b/libpurple/protocols/gg/gg.c Sat Aug 22 22:15:25 2020 -0500
@@ -190,7 +190,8 @@
/* ----- BLOCK BUDDIES -------------------------------------------------- */
-static void ggp_add_deny(PurpleConnection *gc, const char *who)
+static void ggp_add_deny(PurpleProtocolPrivacy *privacy, PurpleConnection *gc,
+ const char *who)
{
GGPInfo *info = purple_connection_get_protocol_data(gc);
uin_t uin = ggp_str_to_uin(who);
@@ -201,7 +202,8 @@
gg_add_notify_ex(info->session, uin, GG_USER_BLOCKED);
}
-static void ggp_rem_deny(PurpleConnection *gc, const char *who)
+static void ggp_remove_deny(PurpleProtocolPrivacy *privacy,
+ PurpleConnection *gc, const char *who)
{
GGPInfo *info = purple_connection_get_protocol_data(gc);
uin_t uin = ggp_str_to_uin(who);
@@ -1134,7 +1136,7 @@
ggp_protocol_privacy_iface_init(PurpleProtocolPrivacyInterface *privacy_iface)
{
privacy_iface->add_deny = ggp_add_deny;
- privacy_iface->rem_deny = ggp_rem_deny;
+ privacy_iface->remove_deny = ggp_remove_deny;
}
static void
--- a/libpurple/protocols/jabber/jabber.c Sat Aug 22 13:03:30 2020 -0500
+++ b/libpurple/protocols/jabber/jabber.c Sat Aug 22 22:15:25 2020 -0500
@@ -1886,7 +1886,8 @@
jabber_iq_send(iq);
}
-void jabber_add_deny(PurpleConnection *gc, const char *who)
+void jabber_add_deny(PurpleProtocolPrivacy *privacy, PurpleConnection *gc,
+ const char *who)
{
JabberStream *js;
JabberIq *iq;
@@ -1923,7 +1924,8 @@
jabber_iq_send(iq);
}
-void jabber_rem_deny(PurpleConnection *gc, const char *who)
+void jabber_remove_deny(PurpleProtocolPrivacy *privacy, PurpleConnection *gc,
+ const char *who)
{
JabberStream *js;
JabberIq *iq;
@@ -4163,7 +4165,7 @@
jabber_protocol_privacy_iface_init(PurpleProtocolPrivacyInterface *privacy_iface)
{
privacy_iface->add_deny = jabber_add_deny;
- privacy_iface->rem_deny = jabber_rem_deny;
+ privacy_iface->remove_deny = jabber_remove_deny;
}
static void
--- a/libpurple/protocols/jabber/jabber.h Sat Aug 22 13:03:30 2020 -0500
+++ b/libpurple/protocols/jabber/jabber.h Sat Aug 22 22:15:25 2020 -0500
@@ -407,8 +407,8 @@
JabberIqType type, const char *id,
PurpleXmlNode *child);
void jabber_request_block_list(JabberStream *js);
-void jabber_add_deny(PurpleConnection *gc, const char *who);
-void jabber_rem_deny(PurpleConnection *gc, const char *who);
+void jabber_add_deny(PurpleProtocolPrivacy *privacy, PurpleConnection *gc, const char *who);
+void jabber_remove_deny(PurpleProtocolPrivacy *privacy, PurpleConnection *gc, const char *who);
void jabber_keepalive(PurpleConnection *gc);
void jabber_register_gateway(JabberStream *js, const char *gateway);
void jabber_register_account(PurpleAccount *account);
--- a/libpurple/protocols/novell/novell.c Sat Aug 22 13:03:30 2020 -0500
+++ b/libpurple/protocols/novell/novell.c Sat Aug 22 22:15:25 2020 -0500
@@ -3067,7 +3067,8 @@
}
static void
-novell_add_permit(PurpleConnection *gc, const char *who)
+novell_add_permit(PurpleProtocolPrivacy *privacy, PurpleConnection *gc,
+ const char *who)
{
NMUser *user;
NMERR_T rc = NM_OK;
@@ -3112,7 +3113,8 @@
}
static void
-novell_add_deny(PurpleConnection *gc, const char *who)
+novell_add_deny(PurpleProtocolPrivacy *privacy, PurpleConnection *gc,
+ const char *who)
{
NMUser *user;
NMERR_T rc = NM_OK;
@@ -3157,7 +3159,8 @@
}
static void
-novell_rem_permit(PurpleConnection *gc, const char *who)
+novell_remove_permit(PurpleProtocolPrivacy *privacy, PurpleConnection *gc,
+ const char *who)
{
NMUser *user;
NMERR_T rc = NM_OK;
@@ -3187,7 +3190,8 @@
}
static void
-novell_rem_deny(PurpleConnection *gc, const char *who)
+novell_remove_deny(PurpleProtocolPrivacy *privacy, PurpleConnection *gc,
+ const char *who)
{
NMUser *user;
NMERR_T rc = NM_OK;
@@ -3217,7 +3221,7 @@
}
static void
-novell_set_permit_deny(PurpleConnection *gc)
+novell_set_permit_deny(PurpleProtocolPrivacy *privacy, PurpleConnection *gc)
{
NMERR_T rc = NM_OK;
const char *dn, *name = NULL;
@@ -3556,8 +3560,8 @@
{
privacy_iface->add_permit = novell_add_permit;
privacy_iface->add_deny = novell_add_deny;
- privacy_iface->rem_permit = novell_rem_permit;
- privacy_iface->rem_deny = novell_rem_deny;
+ privacy_iface->remove_permit = novell_remove_permit;
+ privacy_iface->remove_deny = novell_remove_deny;
privacy_iface->set_permit_deny = novell_set_permit_deny;
}
--- a/libpurple/protocols/null/nullprpl.c Sat Aug 22 13:03:30 2020 -0500
+++ b/libpurple/protocols/null/nullprpl.c Sat Aug 22 22:15:25 2020 -0500
@@ -616,27 +616,35 @@
* purple_privacy_check(), from privacy.h), to determine whether messages are
* allowed or blocked.
*/
-static void null_add_permit(PurpleConnection *gc, const char *name) {
+static void null_add_permit(PurpleProtocolPrivacy *privacy,
+ PurpleConnection *gc, const char *name)
+{
purple_debug_info("nullprpl", "%s adds %s to their allowed list\n",
purple_account_get_username(purple_connection_get_account(gc)), name);
}
-static void null_add_deny(PurpleConnection *gc, const char *name) {
+static void null_add_deny(PurpleProtocolPrivacy *privacy,
+ PurpleConnection *gc, const char *name)
+{
purple_debug_info("nullprpl", "%s adds %s to their blocked list\n",
purple_account_get_username(purple_connection_get_account(gc)), name);
}
-static void null_rem_permit(PurpleConnection *gc, const char *name) {
+static void null_remove_permit(PurpleProtocolPrivacy *privacy,
+ PurpleConnection *gc, const char *name)
+{
purple_debug_info("nullprpl", "%s removes %s from their allowed list\n",
purple_account_get_username(purple_connection_get_account(gc)), name);
}
-static void null_rem_deny(PurpleConnection *gc, const char *name) {
+static void null_remove_deny(PurpleProtocolPrivacy *privacy,
+ PurpleConnection *gc, const char *name)
+{
purple_debug_info("nullprpl", "%s removes %s from their blocked list\n",
purple_account_get_username(purple_connection_get_account(gc)), name);
}
-static void null_set_permit_deny(PurpleConnection *gc) {
+static void null_set_permit_deny(PurpleProtocolPrivacy *privacy, PurpleConnection *gc) {
/* this is for synchronizing the local black/whitelist with the server.
* for nullprotocol, it's a noop.
*/
@@ -1090,8 +1098,8 @@
{
privacy_iface->add_permit = null_add_permit;
privacy_iface->add_deny = null_add_deny;
- privacy_iface->rem_permit = null_rem_permit;
- privacy_iface->rem_deny = null_rem_deny;
+ privacy_iface->remove_permit = null_remove_permit;
+ privacy_iface->remove_deny = null_remove_deny;
privacy_iface->set_permit_deny = null_set_permit_deny;
}
--- a/libpurple/protocols/sametime/sametime.c Sat Aug 22 13:03:30 2020 -0500
+++ b/libpurple/protocols/sametime/sametime.c Sat Aug 22 22:15:25 2020 -0500
@@ -4278,7 +4278,9 @@
}
-static void mw_protocol_set_permit_deny(PurpleConnection *gc) {
+static void mw_protocol_set_permit_deny(PurpleProtocolPrivacy *priv,
+ PurpleConnection *gc)
+{
PurpleAccount *acct;
struct mwPurpleProtocolData *pd;
struct mwSession *session;
@@ -4333,23 +4335,31 @@
}
-static void mw_protocol_add_permit(PurpleConnection *gc, const char *name) {
- mw_protocol_set_permit_deny(gc);
-}
-
-
-static void mw_protocol_add_deny(PurpleConnection *gc, const char *name) {
- mw_protocol_set_permit_deny(gc);
-}
-
-
-static void mw_protocol_rem_permit(PurpleConnection *gc, const char *name) {
- mw_protocol_set_permit_deny(gc);
-}
-
-
-static void mw_protocol_rem_deny(PurpleConnection *gc, const char *name) {
- mw_protocol_set_permit_deny(gc);
+static void mw_protocol_add_permit(PurpleProtocolPrivacy *privacy,
+ PurpleConnection *gc, const char *name)
+{
+ mw_protocol_set_permit_deny(privacy, gc);
+}
+
+
+static void mw_protocol_add_deny(PurpleProtocolPrivacy *privacy,
+ PurpleConnection *gc, const char *name)
+{
+ mw_protocol_set_permit_deny(privacy, gc);
+}
+
+
+static void mw_protocol_remove_permit(PurpleProtocolPrivacy *privacy,
+ PurpleConnection *gc, const char *name)
+{
+ mw_protocol_set_permit_deny(privacy, gc);
+}
+
+
+static void mw_protocol_remove_deny(PurpleProtocolPrivacy *privacy,
+ PurpleConnection *gc, const char *name)
+{
+ mw_protocol_set_permit_deny(privacy, gc);
}
@@ -5302,8 +5312,8 @@
{
privacy_iface->add_permit = mw_protocol_add_permit;
privacy_iface->add_deny = mw_protocol_add_deny;
- privacy_iface->rem_permit = mw_protocol_rem_permit;
- privacy_iface->rem_deny = mw_protocol_rem_deny;
+ privacy_iface->remove_permit = mw_protocol_remove_permit;
+ privacy_iface->remove_deny = mw_protocol_remove_deny;
privacy_iface->set_permit_deny = mw_protocol_set_permit_deny;
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/purpleprotocolprivacy.c Sat Aug 22 22:15:25 2020 -0500
@@ -0,0 +1,114 @@
+/*
+ * purple
+ *
+ * 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 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,
+ * 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 program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "purpleprotocolprivacy.h"
+
+/******************************************************************************
+ * GObject Implementation
+ *****************************************************************************/
+G_DEFINE_INTERFACE(PurpleProtocolPrivacy, purple_protocol_privacy,
+ G_TYPE_INVALID)
+
+static void
+purple_protocol_privacy_default_init(PurpleProtocolPrivacyInterface *iface) {
+}
+
+/******************************************************************************
+ * Public API
+ *****************************************************************************/
+void
+purple_protocol_privacy_add_permit(PurpleProtocolPrivacy *privacy,
+ PurpleConnection *connection,
+ const gchar *name)
+{
+ PurpleProtocolPrivacyInterface *iface = NULL;
+
+ g_return_if_fail(PURPLE_IS_PROTOCOL_PRIVACY(privacy));
+ g_return_if_fail(PURPLE_IS_CONNECTION(connection));
+
+ iface = PURPLE_PROTOCOL_PRIVACY_GET_IFACE(privacy);
+ if(iface && iface->add_permit) {
+ iface->add_permit(privacy, connection, name);
+ }
+}
+
+void
+purple_protocol_privacy_add_deny(PurpleProtocolPrivacy *privacy,
+ PurpleConnection *connection,
+ const gchar *name)
+{
+ PurpleProtocolPrivacyInterface *iface = NULL;
+
+ g_return_if_fail(PURPLE_IS_PROTOCOL_PRIVACY(privacy));
+ g_return_if_fail(PURPLE_IS_CONNECTION(connection));
+
+ iface = PURPLE_PROTOCOL_PRIVACY_GET_IFACE(privacy);
+ if(iface && iface->add_deny) {
+ iface->add_deny(privacy, connection, name);
+ }
+}
+
+void
+purple_protocol_privacy_remove_permit(PurpleProtocolPrivacy *privacy,
+ PurpleConnection *connection,
+ const gchar *name)
+{
+ PurpleProtocolPrivacyInterface *iface = NULL;
+
+ g_return_if_fail(PURPLE_IS_PROTOCOL_PRIVACY(privacy));
+ g_return_if_fail(PURPLE_IS_CONNECTION(connection));
+
+ iface = PURPLE_PROTOCOL_PRIVACY_GET_IFACE(privacy);
+ if(iface && iface->remove_permit) {
+ iface->remove_permit(privacy, connection, name);
+ }
+}
+
+void
+purple_protocol_privacy_remove_deny(PurpleProtocolPrivacy *privacy,
+ PurpleConnection *connection,
+ const gchar *name)
+{
+ PurpleProtocolPrivacyInterface *iface = NULL;
+
+ g_return_if_fail(PURPLE_IS_PROTOCOL_PRIVACY(privacy));
+ g_return_if_fail(PURPLE_IS_CONNECTION(connection));
+
+ iface = PURPLE_PROTOCOL_PRIVACY_GET_IFACE(privacy);
+ if(iface && iface->remove_deny) {
+ iface->remove_deny(privacy, connection, name);
+ }
+}
+
+void
+purple_protocol_privacy_set_permit_deny(PurpleProtocolPrivacy *privacy,
+ PurpleConnection *connection)
+{
+ PurpleProtocolPrivacyInterface *iface = NULL;
+
+ g_return_if_fail(PURPLE_IS_PROTOCOL_PRIVACY(privacy));
+ g_return_if_fail(PURPLE_IS_CONNECTION(connection));
+
+ iface = PURPLE_PROTOCOL_PRIVACY_GET_IFACE(privacy);
+ if(iface && iface->set_permit_deny) {
+ iface->set_permit_deny(privacy, connection);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/purpleprotocolprivacy.h Sat Aug 22 22:15:25 2020 -0500
@@ -0,0 +1,147 @@
+/*
+ * purple
+ *
+ * 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 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,
+ * 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 program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION)
+# error "only <purple.h> may be included directly"
+#endif
+
+#ifndef PURPLE_PROTOCOL_PRIVACY_H
+#define PURPLE_PROTOCOL_PRIVACY_H
+
+/**
+ * SECTION:purpleprotocolprivacy
+ * @section_id: libpurple-purpleprotocolprivacy
+ * @short_description: Protocol Privacy Interface
+ * @title: ProtocolPrivacy Interface
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <libpurple/connection.h>
+
+/**
+ * PURPLE_TYPE_PROTOCOL_PRIVACY:
+ *
+ * The standard _get_type method for #PurpleProtocolPrivacy.
+ */
+#define PURPLE_TYPE_PROTOCOL_PRIVACY (purple_protocol_privacy_get_type())
+G_DECLARE_INTERFACE(PurpleProtocolPrivacy, purple_protocol_privacy, PURPLE,
+ PROTOCOL_PRIVACY, GObject)
+
+/**
+ * PurpleProtocolPrivacyInterface:
+ * @add_permit: Add the buddy on the required authorized list.
+ * @add_deny: Add the buddy on the required blocked list.
+ * @remove_permit: Remove the buddy from the required authorized list.
+ * @remove_deny: Remove the buddy from the required blocked list.
+ * @set_permit_deny: Update the server with the privacy information on the
+ * permit and deny lists.
+ *
+ * The protocol privacy interface.
+ *
+ * This interface provides privacy callbacks such as to permit/deny users.
+ */
+struct _PurpleProtocolPrivacyInterface {
+ /*< private >*/
+ GTypeInterface parent;
+
+ /*< public >*/
+ void (*add_permit)(PurpleProtocolPrivacy *privacy, PurpleConnection *connection, const gchar *name);
+
+ void (*add_deny)(PurpleProtocolPrivacy *privacy, PurpleConnection *connection, const gchar *name);
+
+ void (*remove_permit)(PurpleProtocolPrivacy *privacy, PurpleConnection *connection, const gchar *name);
+
+ void (*remove_deny)(PurpleProtocolPrivacy *privacy, PurpleConnection *connection, const gchar *name);
+
+ void (*set_permit_deny)(PurpleProtocolPrivacy *privacy, PurpleConnection *connection);
+
+ /*< private >*/
+ gpointer reserved[4];
+};
+
+G_BEGIN_DECLS
+
+/**
+ * purple_protocol_privacy_add_permit:
+ * @privacy: The #PurpleProtocolPrivacy instance.
+ * @connection: The #PurpleConnection instance.
+ * @name: The username to permit.
+ *
+ * Adds a permit to the privacy settings for @connection to allow @name to
+ * contact the user.
+ *
+ * Since: 3.0.0
+ */
+void purple_protocol_privacy_add_permit(PurpleProtocolPrivacy *privacy, PurpleConnection *connection, const gchar *name);
+
+/**
+ * purple_protocol_privacy_add_deny:
+ * @privacy: The #PurpleProtocolPrivacy instance.
+ * @connection: The #PurpleConnection instance.
+ * @name: The username to deny.
+ *
+ * Adds a deny to the privacy settings for @connection to deny @name from
+ * contacting the user.
+ *
+ * Since: 3.0.0
+ */
+void purple_protocol_privacy_add_deny(PurpleProtocolPrivacy *privacy, PurpleConnection *connection, const gchar *name);
+
+/**
+ * purple_protocol_privacy_remove_permit:
+ * @privacy: The #PurpleProtocolPrivacy instance.
+ * @connection: The #PurpleConnection instance.
+ * @name: The username to remove from the permit privacy settings.
+ *
+ * Removes an existing permit for @name.
+ *
+ * Since: 3.0.0
+ */
+void purple_protocol_privacy_remove_permit(PurpleProtocolPrivacy *privacy, PurpleConnection *connection, const gchar *name);
+
+/**
+ * purple_protocol_privacy_remove_deny:
+ * @privacy: The #PurpleProtocolPrivacy instance.
+ * @connection: The #PurpleConnection instance.
+ * @name: The username to remove from the deny privacy settings.
+ *
+ * Removes an existing deny for @name.
+ *
+ * Since: 3.0.0
+ */
+void purple_protocol_privacy_remove_deny(PurpleProtocolPrivacy *privacy, PurpleConnection *connection, const gchar *name);
+
+/**
+ * purple_protocol_privacy_set_permit_deny:
+ * @privacy: The #PurpleProtocolPrivacy instance.
+ * @connection: The #PurpleConnection instance.
+ *
+ * Forces a sync of the privacy settings with server.
+ *
+ * Since: 3.0.0
+ */
+void purple_protocol_privacy_set_permit_deny(PurpleProtocolPrivacy *privacy, PurpleConnection *connection);
+
+G_END_DECLS
+
+#endif /* PURPLE_PROTOCOL_PRIVACY_H */
\ No newline at end of file
--- a/libpurple/server.c Sat Aug 22 13:03:30 2020 -0500
+++ b/libpurple/server.c Sat Aug 22 22:15:25 2020 -0500
@@ -35,6 +35,7 @@
#include "protocol.h"
#include "purpleprivate.h"
#include "purpleprotocolim.h"
+#include "purpleprotocolprivacy.h"
#include "request.h"
#include "signals.h"
#include "server.h"
@@ -350,50 +351,49 @@
void purple_serv_add_permit(PurpleConnection *gc, const char *name)
{
- PurpleProtocol *protocol;
+ if (gc) {
+ PurpleProtocol *protocol = purple_connection_get_protocol(gc);
+ PurpleProtocolPrivacy *privacy = PURPLE_PROTOCOL_PRIVACY(protocol);
- if (gc) {
- protocol = purple_connection_get_protocol(gc);
- purple_protocol_privacy_iface_add_permit(protocol, gc, name);
+ purple_protocol_privacy_add_permit(privacy, gc, name);
}
}
void purple_serv_add_deny(PurpleConnection *gc, const char *name)
{
- PurpleProtocol *protocol;
+ if (gc) {
+ PurpleProtocol *protocol = purple_connection_get_protocol(gc);
+ PurpleProtocolPrivacy *privacy = PURPLE_PROTOCOL_PRIVACY(protocol);
- if (gc) {
- protocol = purple_connection_get_protocol(gc);
- purple_protocol_privacy_iface_add_deny(protocol, gc, name);
+ purple_protocol_privacy_add_deny(privacy, gc, name);
}
}
-void purple_serv_rem_permit(PurpleConnection *gc, const char *name)
+void purple_serv_remove_permit(PurpleConnection *gc, const char *name)
{
- PurpleProtocol *protocol;
+ if (gc) {
+ PurpleProtocol *protocol = purple_connection_get_protocol(gc);
+ PurpleProtocolPrivacy *privacy = PURPLE_PROTOCOL_PRIVACY(protocol);
- if (gc) {
- protocol = purple_connection_get_protocol(gc);
- purple_protocol_privacy_iface_rem_permit(protocol, gc, name);
+ purple_protocol_privacy_remove_permit(privacy, gc, name);
}
}
-void purple_serv_rem_deny(PurpleConnection *gc, const char *name)
+void purple_serv_remove_deny(PurpleConnection *gc, const char *name)
{
- PurpleProtocol *protocol;
+ if (gc) {
+ PurpleProtocol *protocol = purple_connection_get_protocol(gc);
+ PurpleProtocolPrivacy *privacy = PURPLE_PROTOCOL_PRIVACY(protocol);
- if (gc) {
- protocol = purple_connection_get_protocol(gc);
- purple_protocol_privacy_iface_rem_deny(protocol, gc, name);
+ purple_protocol_privacy_remove_deny(privacy, gc, name);
}
}
void purple_serv_set_permit_deny(PurpleConnection *gc)
{
- PurpleProtocol *protocol;
-
if (gc) {
- protocol = purple_connection_get_protocol(gc);
+ PurpleProtocol *protocol = purple_connection_get_protocol(gc);
+ PurpleProtocolPrivacy *privacy = PURPLE_PROTOCOL_PRIVACY(protocol);
/*
* this is called when either you import a buddy list, and make lots
@@ -401,7 +401,7 @@
* in the prefs. In either case you should probably be resetting and
* resending the permit/deny info when you get this.
*/
- purple_protocol_privacy_iface_set_permit_deny(protocol, gc);
+ purple_protocol_privacy_set_permit_deny(privacy, gc);
}
}
--- a/libpurple/server.h Sat Aug 22 13:03:30 2020 -0500
+++ b/libpurple/server.h Sat Aug 22 22:15:25 2020 -0500
@@ -133,22 +133,22 @@
void purple_serv_add_deny(PurpleConnection *gc, const char *name);
/**
- * purple_serv_rem_permit:
+ * purple_serv_remove_permit:
* @gc: The connection over which to send the typing notification.
* @name: The name of the remote user.
*
* Remove the buddy from the required authorized list.
*/
-void purple_serv_rem_permit(PurpleConnection *gc, const char *name);
+void purple_serv_remove_permit(PurpleConnection *gc, const char *name);
/**
- * purple_serv_rem_deny:
+ * purple_serv_remove_deny:
* @gc: The connection over which to send the typing notification.
* @name: The name of the remote user.
*
* Remove the buddy from the required blocked list.
*/
-void purple_serv_rem_deny(PurpleConnection *gc, const char *name);
+void purple_serv_remove_deny(PurpleConnection *gc, const char *name);
/**
* purple_serv_set_permit_deny:
--- a/po/POTFILES.in Sat Aug 22 13:03:30 2020 -0500
+++ b/po/POTFILES.in Sat Aug 22 22:15:25 2020 -0500
@@ -268,6 +268,7 @@
libpurple/purple-gio.c
libpurple/purplechatuser.c
libpurple/purpleimconversation.c
+libpurple/purpleprotocolprivacy.c
libpurple/queuedoutputstream.c
libpurple/request.c
libpurple/request-datasheet.c