Split PurpleAttentionType and PurpleProtocolAttention into their own files
Testing Done:
Compiled and ran, I sent an XMPP buzz, but we don't currently render it with talkatu nor is there a toolbar action associated with attention so I couldn't really test.
Reviewed at https://reviews.imfreedom.org/r/176/
--- a/doc/reference/libpurple/libpurple-docs.xml Mon Nov 02 00:48:14 2020 -0600
+++ b/doc/reference/libpurple/libpurple-docs.xml Wed Nov 04 02:35:18 2020 -0600
@@ -31,7 +31,6 @@
<xi:include href="xml/account.xml" />
<xi:include href="xml/accounts.xml" />
<xi:include href="xml/action.xml" />
- <xi:include href="xml/attention.xml" />
<xi:include href="xml/blistnode.xml" />
<xi:include href="xml/buddy.xml" />
<xi:include href="xml/buddylist.xml" />
@@ -66,6 +65,7 @@
<xi:include href="xml/purpleaccountoption.xml" />
<xi:include href="xml/purpleaccountpresence.xml" />
<xi:include href="xml/purpleaccountusersplit.xml" />
+ <xi:include href="xml/purpleattentiontype.xml" /> <xi:include href="xml/purplebuddypresence.xml" />
<xi:include href="xml/purplechatuser.xml" />
<xi:include href="xml/purplecredentialprovider.xml" />
@@ -73,6 +73,7 @@
<xi:include href="xml/purplekeyvaluepair.xml" />
<xi:include href="xml/purplemarkup.xml" />
<xi:include href="xml/purplepresence.xml" />
+ <xi:include href="xml/purpleprotocolattention.xml" /> <xi:include href="xml/purpleprotocolfactory.xml" />
<xi:include href="xml/purpleprotocolim.xml" />
<xi:include href="xml/purpleprotocolmedia.xml" />
--- a/libpurple/attention.c Mon Nov 02 00:48:14 2020 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,184 +0,0 @@
- * 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
- * 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
-/******************************************************************************
- * PurpleAttentionType API
- *****************************************************************************/
-struct _PurpleAttentionType {
- /* The name to show in GUI elements. */
- /* Shown when received. */
- const gchar *incoming_description;
- const gchar *outgoing_description;
- /* Optional name of the icon to display. */
- const gchar *icon_name;
- /* An unlocalized name for UIs that would rather use that. */
- const gchar *unlocalized_name;
- purple_attention_type_copy,
-purple_attention_type_new(const gchar *unlocalized_name,
- const gchar *incoming_description,
- const gchar *outgoing_description)
- PurpleAttentionType *attn = g_new0(PurpleAttentionType, 1);
- attn->unlocalized_name = unlocalized_name;
- attn->incoming_description = incoming_description;
- attn->outgoing_description = outgoing_description;
-purple_attention_type_copy(PurpleAttentionType *attn) {
- PurpleAttentionType *attn_copy = NULL;
- g_return_val_if_fail(attn != NULL, NULL);
- attn_copy = g_new(PurpleAttentionType, 1);
-purple_attention_type_get_name(const PurpleAttentionType *type) {
- g_return_val_if_fail(type, NULL);
-purple_attention_type_set_name(PurpleAttentionType *type, const gchar *name) {
- g_return_if_fail(type);
-purple_attention_type_get_incoming_desc(const PurpleAttentionType *type) {
- g_return_val_if_fail(type, NULL);
- return type->incoming_description;
-purple_attention_type_set_incoming_desc(PurpleAttentionType *type, const gchar *desc) {
- g_return_if_fail(type);
- type->incoming_description = desc;
-purple_attention_type_get_outgoing_desc(const PurpleAttentionType *type) {
- g_return_val_if_fail(type, NULL);
- return type->outgoing_description;
-purple_attention_type_set_outgoing_desc(PurpleAttentionType *type, const gchar *desc) {
- g_return_if_fail(type != NULL);
- type->outgoing_description = desc;
-purple_attention_type_get_icon_name(const PurpleAttentionType *type) {
- g_return_val_if_fail(type, NULL);
- if(type->icon_name == NULL || *(type->icon_name) == '\0')
- return type->icon_name;
-purple_attention_type_set_icon_name(PurpleAttentionType *type, const gchar *name) {
- g_return_if_fail(type);
- type->icon_name = name;
-purple_attention_type_get_unlocalized_name(const PurpleAttentionType *type) {
- g_return_val_if_fail(type, NULL);
- return type->unlocalized_name;
-purple_attention_type_set_unlocalized_name(PurpleAttentionType *type, const gchar *ulname) {
- g_return_if_fail(type);
- type->unlocalized_name = ulname;
-/******************************************************************************
- * PurpleAttentionType API
- *****************************************************************************/
-G_DEFINE_INTERFACE(PurpleProtocolAttention, purple_protocol_attention, G_TYPE_INVALID);
-purple_protocol_attention_default_init(PurpleProtocolAttentionInterface *iface) {
-purple_protocol_attention_send(PurpleProtocolAttention *attn, PurpleConnection *gc, const gchar *username, guint type) {
- PurpleProtocolAttentionInterface *iface = NULL;
- g_return_val_if_fail(PURPLE_IS_PROTOCOL_ATTENTION(attn), FALSE);
- iface = PURPLE_PROTOCOL_ATTENTION_GET_IFACE(attn);
- if(iface && iface->send) {
- return iface->send(attn, gc, username, type);
-purple_protocol_attention_get_types(PurpleProtocolAttention *attn, PurpleAccount *account) {
- PurpleProtocolAttentionInterface *iface = NULL;
- g_return_val_if_fail(PURPLE_IS_PROTOCOL_ATTENTION(attn), NULL);
- iface = PURPLE_PROTOCOL_ATTENTION_GET_IFACE(attn);
- if(iface && iface->get_types) {
- return iface->get_types(attn, account);
--- a/libpurple/attention.h Mon Nov 02 00:48:14 2020 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,257 +0,0 @@
- * 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
- * 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
-#if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION)
-# error "only <purple.h> may be included directly"
-#ifndef PURPLE_ATTENTION_H
-#define PURPLE_ATTENTION_H
-#include <glib-object.h>
- * @section_id: libpurple-attention
- * @short_description: <filename>attention.h</filename>
- * @title: Attention Object and Interfaces
-#define PURPLE_TYPE_ATTENTION_TYPE (purple_attention_type_get_type())
- * Represents "nudges" and "buzzes" that you may send to a buddy to attract
- * their attention (or vice-versa).
-typedef struct _PurpleAttentionType PurpleAttentionType;
- * PURPLE_TYPE_PROTOCOL_ATTENTION:
- * The standard _get_type macro for #PurpleProtocolAttention.
-#define PURPLE_TYPE_PROTOCOL_ATTENTION (purple_protocol_attention_get_type())
-/******************************************************************************
- *****************************************************************************/
- * purple_attention_type_get_type:
- * Returns: The #GType for the #PurpleAttentionType boxed structure.
-GType purple_attention_type_get_type(void);
-PurpleAttentionType *purple_attention_type_copy(PurpleAttentionType *attn);
- * purple_attention_type_new:
- * @unlocalized_name: A non-localized string that can be used by UIs in need of such
- * non-localized strings. This should be the same as @name,
- * without localization.
- * @name: A localized string that the UI may display for the event. This
- * should be the same string as @unlocalized_name, with localization.
- * @incoming_description: A localized description shown when the event is received.
- * @outgoing_description: A localized description shown when the event is sent.
- * Creates a new #PurpleAttentionType object and sets its mandatory parameters.
- * Returns: A pointer to the new object.
-PurpleAttentionType *purple_attention_type_new(const gchar *unlocalized_name, const gchar *name,
- const gchar *incoming_description, const gchar *outgoing_description);
- * purple_attention_type_get_name:
- * @type: The attention type.
- * Get the attention type's name as displayed by the UI.
-const gchar *purple_attention_type_get_name(const PurpleAttentionType *type);
- * purple_attention_type_set_name:
- * @type: The attention type.
- * @name: The localized name that will be displayed by UIs. This should be
- * the same string given as the unlocalized name, but with
- * Sets the displayed name of the attention-demanding event.
-void purple_attention_type_set_name(PurpleAttentionType *type, const gchar *name);
- * purple_attention_type_get_incoming_desc:
- * @type: The attention type.
- * Get the attention type's description shown when the event is received.
- * Returns: The description.
-const gchar *purple_attention_type_get_incoming_desc(const PurpleAttentionType *type);
- * purple_attention_type_set_incoming_desc:
- * @type: The attention type.
- * @desc: The localized description for incoming events.
- * Sets the description of the attention-demanding event shown in conversations
- * when the event is received.
-void purple_attention_type_set_incoming_desc(PurpleAttentionType *type, const gchar *desc);
- * purple_attention_type_get_outgoing_desc:
- * @type: The attention type.
- * Get the attention type's description shown when the event is sent.
- * Returns: The description.
-const gchar *purple_attention_type_get_outgoing_desc(const PurpleAttentionType *type);
- * purple_attention_type_set_outgoing_desc:
- * @type: The attention type.
- * @desc: The localized description for outgoing events.
- * Sets the description of the attention-demanding event shown in conversations
- * when the event is sent.
-void purple_attention_type_set_outgoing_desc(PurpleAttentionType *type, const gchar *desc);
- * purple_attention_type_get_icon_name:
- * @type: The attention type.
- * Get the attention type's icon name.
- * Note: Icons are optional for attention events.
- * Returns: The icon name or %NULL if unset/empty.
-const gchar *purple_attention_type_get_icon_name(const PurpleAttentionType *type);
- * purple_attention_type_set_icon_name:
- * @type: The attention type.
- * @name: The icon's name.
- * Sets the name of the icon to display for the attention event; this is optional.
- * Note: Icons are optional for attention events.
-void purple_attention_type_set_icon_name(PurpleAttentionType *type, const gchar *name);
- * purple_attention_type_get_unlocalized_name:
- * @type: The attention type
- * Get the attention type's unlocalized name; this is useful for some UIs.
- * Returns: The unlocalized name.
-const gchar *purple_attention_type_get_unlocalized_name(const PurpleAttentionType *type);
- * purple_attention_type_set_unlocalized_name:
- * @type: The attention type.
- * @ulname: The unlocalized name. This should be the same string given as
- * the localized name, but without localization.
- * Sets the unlocalized name of the attention event; some UIs may need this,
-void purple_attention_type_set_unlocalized_name(PurpleAttentionType *type, const gchar *ulname);
-/******************************************************************************
- *****************************************************************************/
- * purple_protocol_attention_get_type:
- * Returns: The #GType for the protocol attention interface.
-G_DECLARE_INTERFACE(PurpleProtocolAttention, purple_protocol_attention, PURPLE,
- PROTOCOL_ATTENTION, GObject)
- * PurpleProtocolAttentionInterface:
- * @send: Called to send an attention message. See
- * purple_protocol_attention_send().
- * @get_types: Called to list the protocol's attention types. See
- * purple_protocol_attention_get_types().
- * The protocol attention interface.
- * This interface provides attention API for sending and receiving
- * zaps/nudges/buzzes etc.
-struct _PurpleProtocolAttentionInterface {
- gboolean (*send)(PurpleProtocolAttention *attn, PurpleConnection *gc,
- const gchar *username, guint type);
- GList *(*get_types)(PurpleProtocolAttention *attn, PurpleAccount *acct);
- * purple_protocol_attention_get_types:
- * @attn: The #PurpleProtocolAttention.
- * @acct: The #PurpleAccount whose attention types to get.
- * Returns a list of #PurpleAttentionType's for @attn.
- * Returns: (transfer container) (element-type PurpleAttentionType): The list of #PurpleAttentionType's.
-GList *purple_protocol_attention_get_types(PurpleProtocolAttention *attn, PurpleAccount *acct);
- * purple_protocol_attention_send:
- * @attn: The #PurpleProtocolAttention instance.
- * @gc: The #PurpleConnection to send on
- * @username: The name of the user to send the attention to.
- * @type: The type of attention to send.
- * Sends an attention message of @type to @username.
- * Returns: TRUE on success, FALSE otherwise.
-gboolean purple_protocol_attention_send(PurpleProtocolAttention *attn, PurpleConnection *gc, const gchar *username, guint type);
-#endif /* PURPLE_ATTENTION_H */
--- a/libpurple/meson.build Mon Nov 02 00:48:14 2020 -0600
+++ b/libpurple/meson.build Wed Nov 04 02:35:18 2020 -0600
@@ -2,7 +2,6 @@
@@ -51,6 +50,7 @@
'purpleaccountpresence.c',
'purpleaccountusersplit.c',
+ 'purpleattentiontype.c', 'purplecredentialprovider.c',
@@ -58,6 +58,7 @@
+ 'purpleprotocolattention.c', 'purpleprotocolfactory.c',
@@ -93,7 +94,6 @@
@@ -135,6 +135,7 @@
'purpleaccountpresence.h',
'purpleaccountusersplit.h',
+ 'purpleattentiontype.h', 'purplecredentialprovider.h',
@@ -143,6 +144,7 @@
+ 'purpleprotocolattention.h', 'purpleprotocolfactory.h',
--- a/libpurple/protocols.c Mon Nov 02 00:48:14 2020 -0600
+++ b/libpurple/protocols.c Wed Nov 04 02:35:18 2020 -0600
@@ -30,6 +30,7 @@
#include "purpleaccountoption.h"
+#include "purpleprotocolattention.h" #include "purpleprotocolmedia.h"
@@ -373,10 +374,11 @@
attn = purple_get_attention_type_from_code(purple_connection_get_account(gc), type_code);
- if ((buddy = purple_blist_find_buddy(purple_connection_get_account(gc), who)) != NULL)
+ if ((buddy = purple_blist_find_buddy(purple_connection_get_account(gc), who)) != NULL) { alias = purple_buddy_get_contact_alias(buddy);
if (attn && purple_attention_type_get_outgoing_desc(attn)) {
description = g_strdup_printf(purple_attention_type_get_outgoing_desc(attn), alias);
@@ -387,8 +389,9 @@
purple_debug_info("server", "serv_send_attention: sending '%s' to %s\n",
- if (!purple_protocol_attention_send(PURPLE_PROTOCOL_ATTENTION(protocol), gc, who, type_code))
+ if (!purple_protocol_attention_send_attention(PURPLE_PROTOCOL_ATTENTION(protocol), gc, who, type_code)) { im = purple_im_conversation_new(purple_connection_get_account(gc), who);
purple_conversation_write_system_message(PURPLE_CONVERSATION(im), description, 0);
--- a/libpurple/protocols/jabber/jabber.c Mon Nov 02 00:48:14 2020 -0600
+++ b/libpurple/protocols/jabber/jabber.c Wed Nov 04 02:35:18 2020 -0600
@@ -4188,7 +4188,7 @@
jabber_protocol_attention_iface_init(PurpleProtocolAttentionInterface *iface)
- iface->send = jabber_send_attention;
+ iface->send_attention = jabber_send_attention; iface->get_types = jabber_attention_types;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/purpleattentiontype.c Wed Nov 04 02:35:18 2020 -0600
@@ -0,0 +1,147 @@
+ * 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 + * 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 <https://www.gnu.org/licenses/>. +#include "purpleattentiontype.h" +struct _PurpleAttentionType { + /* The name to show in GUI elements. */ + /* Shown when received. */ + const gchar *incoming_description; + const gchar *outgoing_description; + /* Optional name of the icon to display. */ + const gchar *icon_name; + /* An unlocalized name for UIs that would rather use that. */ + const gchar *unlocalized_name; + purple_attention_type_copy, +/****************************************************************************** + *****************************************************************************/ +purple_attention_type_new(const gchar *unlocalized_name, + const gchar *incoming_description, + const gchar *outgoing_description) + PurpleAttentionType *attn = g_new0(PurpleAttentionType, 1); + attn->unlocalized_name = unlocalized_name; + attn->incoming_description = incoming_description; + attn->outgoing_description = outgoing_description; +purple_attention_type_copy(PurpleAttentionType *attn) { + PurpleAttentionType *attn_copy = NULL; + g_return_val_if_fail(attn != NULL, NULL); + attn_copy = g_new(PurpleAttentionType, 1); +purple_attention_type_get_name(const PurpleAttentionType *type) { + g_return_val_if_fail(type, NULL); +purple_attention_type_set_name(PurpleAttentionType *type, const gchar *name) { + g_return_if_fail(type); +purple_attention_type_get_incoming_desc(const PurpleAttentionType *type) { + g_return_val_if_fail(type, NULL); + return type->incoming_description; +purple_attention_type_set_incoming_desc(PurpleAttentionType *type, const gchar *desc) { + g_return_if_fail(type); + type->incoming_description = desc; +purple_attention_type_get_outgoing_desc(const PurpleAttentionType *type) { + g_return_val_if_fail(type, NULL); + return type->outgoing_description; +purple_attention_type_set_outgoing_desc(PurpleAttentionType *type, const gchar *desc) { + g_return_if_fail(type != NULL); + type->outgoing_description = desc; +purple_attention_type_get_icon_name(const PurpleAttentionType *type) { + g_return_val_if_fail(type, NULL); + if(type->icon_name == NULL || *(type->icon_name) == '\0') + return type->icon_name; +purple_attention_type_set_icon_name(PurpleAttentionType *type, const gchar *name) { + g_return_if_fail(type); + type->icon_name = name; +purple_attention_type_get_unlocalized_name(const PurpleAttentionType *type) { + g_return_val_if_fail(type, NULL); + return type->unlocalized_name; +purple_attention_type_set_unlocalized_name(PurpleAttentionType *type, const gchar *ulname) { + g_return_if_fail(type); + type->unlocalized_name = ulname; --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/purpleattentiontype.h Wed Nov 04 02:35:18 2020 -0600
@@ -0,0 +1,191 @@
+ * 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 + * 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 <https://www.gnu.org/licenses/>. +#if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION) +# error "only <purple.h> may be included directly" +#ifndef PURPLE_ATTENTION_TYPE_H +#define PURPLE_ATTENTION_TYPE_H +#include <glib-object.h> + * SECTION:purpleattentiontype + * @section_id: libpurple-purpleattentiontype + * @title: Attention Types +#define PURPLE_TYPE_ATTENTION_TYPE (purple_attention_type_get_type()) + * Represents "nudges" and "buzzes" that you may send to a buddy to attract + * their attention (or vice-versa). +typedef struct _PurpleAttentionType PurpleAttentionType; + * PURPLE_TYPE_PROTOCOL_ATTENTION: + * The standard _get_type macro for #PurpleProtocolAttention. +#define PURPLE_TYPE_PROTOCOL_ATTENTION (purple_protocol_attention_get_type()) + * purple_attention_type_get_type: + * Returns: The #GType for the #PurpleAttentionType boxed structure. +GType purple_attention_type_get_type(void); +PurpleAttentionType *purple_attention_type_copy(PurpleAttentionType *attn); + * purple_attention_type_new: + * @unlocalized_name: A non-localized string that can be used by UIs in need of such + * non-localized strings. This should be the same as @name, + * without localization. + * @name: A localized string that the UI may display for the event. This + * should be the same string as @unlocalized_name, with localization. + * @incoming_description: A localized description shown when the event is received. + * @outgoing_description: A localized description shown when the event is sent. + * Creates a new #PurpleAttentionType object and sets its mandatory parameters. + * Returns: A pointer to the new object. +PurpleAttentionType *purple_attention_type_new(const gchar *unlocalized_name, const gchar *name, + const gchar *incoming_description, const gchar *outgoing_description); + * purple_attention_type_get_name: + * @type: The attention type. + * Get the attention type's name as displayed by the UI. +const gchar *purple_attention_type_get_name(const PurpleAttentionType *type); + * purple_attention_type_set_name: + * @type: The attention type. + * @name: The localized name that will be displayed by UIs. This should be + * the same string given as the unlocalized name, but with + * Sets the displayed name of the attention-demanding event. +void purple_attention_type_set_name(PurpleAttentionType *type, const gchar *name); + * purple_attention_type_get_incoming_desc: + * @type: The attention type. + * Get the attention type's description shown when the event is received. + * Returns: The description. +const gchar *purple_attention_type_get_incoming_desc(const PurpleAttentionType *type); + * purple_attention_type_set_incoming_desc: + * @type: The attention type. + * @desc: The localized description for incoming events. + * Sets the description of the attention-demanding event shown in conversations + * when the event is received. +void purple_attention_type_set_incoming_desc(PurpleAttentionType *type, const gchar *desc); + * purple_attention_type_get_outgoing_desc: + * @type: The attention type. + * Get the attention type's description shown when the event is sent. + * Returns: The description. +const gchar *purple_attention_type_get_outgoing_desc(const PurpleAttentionType *type); + * purple_attention_type_set_outgoing_desc: + * @type: The attention type. + * @desc: The localized description for outgoing events. + * Sets the description of the attention-demanding event shown in conversations + * when the event is sent. +void purple_attention_type_set_outgoing_desc(PurpleAttentionType *type, const gchar *desc); + * purple_attention_type_get_icon_name: + * @type: The attention type. + * Get the attention type's icon name. + * Note: Icons are optional for attention events. + * Returns: The icon name or %NULL if unset/empty. +const gchar *purple_attention_type_get_icon_name(const PurpleAttentionType *type); + * purple_attention_type_set_icon_name: + * @type: The attention type. + * @name: The icon's name. + * Sets the name of the icon to display for the attention event; this is optional. + * Note: Icons are optional for attention events. +void purple_attention_type_set_icon_name(PurpleAttentionType *type, const gchar *name); + * purple_attention_type_get_unlocalized_name: + * @type: The attention type + * Get the attention type's unlocalized name; this is useful for some UIs. + * Returns: The unlocalized name. +const gchar *purple_attention_type_get_unlocalized_name(const PurpleAttentionType *type); + * purple_attention_type_set_unlocalized_name: + * @type: The attention type. + * @ulname: The unlocalized name. This should be the same string given as + * the localized name, but without localization. + * Sets the unlocalized name of the attention event; some UIs may need this, +void purple_attention_type_set_unlocalized_name(PurpleAttentionType *type, const gchar *ulname); +#endif /* PURPLE_ATTENTION_TYPE_H */ --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/purpleprotocolattention.c Wed Nov 04 02:35:18 2020 -0600
@@ -0,0 +1,70 @@
+ * 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 + * 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 <https://www.gnu.org/licenses/>. +#include "purpleprotocolattention.h" +G_DEFINE_INTERFACE(PurpleProtocolAttention, purple_protocol_attention, +/****************************************************************************** + * GInterface Implementation + *****************************************************************************/ +purple_protocol_attention_default_init(PurpleProtocolAttentionInterface *iface) { +/****************************************************************************** + *****************************************************************************/ +purple_protocol_attention_send_attention(PurpleProtocolAttention *attention, + const gchar *username, guint type) + PurpleProtocolAttentionInterface *iface = NULL; + g_return_val_if_fail(PURPLE_IS_PROTOCOL_ATTENTION(attention), FALSE); + iface = PURPLE_PROTOCOL_ATTENTION_GET_IFACE(attention); + if(iface && iface->send_attention) { + return iface->send_attention(attention, gc, username, type); +purple_protocol_attention_get_types(PurpleProtocolAttention *attention, + PurpleAccount *account) + PurpleProtocolAttentionInterface *iface = NULL; + g_return_val_if_fail(PURPLE_IS_PROTOCOL_ATTENTION(attention), NULL); + iface = PURPLE_PROTOCOL_ATTENTION_GET_IFACE(attention); + if(iface && iface->get_types) { + return iface->get_types(attention, account); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/purpleprotocolattention.h Wed Nov 04 02:35:18 2020 -0600
@@ -0,0 +1,118 @@
+ * 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 + * 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 <https://www.gnu.org/licenses/>. +#if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION) +# error "only <purple.h> may be included directly" +#ifndef PURPLE_ATTENTION_H +#define PURPLE_ATTENTION_H +#include <glib-object.h> + * SECTION:purpleprotocolattention + * @section_id: libpurple-purpleprotocolattention + * @title: Protocol Attention Interface + * PURPLE_TYPE_PROTOCOL_ATTENTION: + * The standard _get_type macro for #PurpleProtocolAttention. +#define PURPLE_TYPE_PROTOCOL_ATTENTION (purple_protocol_attention_get_type()) + * purple_protocol_attention_get_type: + * Returns: The #GType for the protocol attention interface. +G_DECLARE_INTERFACE(PurpleProtocolAttention, purple_protocol_attention, PURPLE, + PROTOCOL_ATTENTION, GObject) + * PurpleProtocolAttentionInterface: + * @send_attention: Called to send an attention message. See + * purple_protocol_attention_send_attention(). + * @get_types: Called to list the protocol's attention types. See + * purple_protocol_attention_get_types(). + * The protocol attention interface. + * This interface provides attention API for sending and receiving + * zaps/nudges/buzzes etc. +struct _PurpleProtocolAttentionInterface { + gboolean (*send_attention)(PurpleProtocolAttention *attention, + PurpleConnection *pc, const gchar *username, + GList *(*get_types)(PurpleProtocolAttention *attention, + PurpleAccount *account); + * purple_protocol_attention_get_types: + * @attention: The #PurpleProtocolAttention. + * @account: The #PurpleAccount whose attention types to get. + * Returns a list of #PurpleAttentionType's for @attention. + * Returns: (transfer container) (element-type PurpleAttentionType): The list of + * #PurpleAttentionType's. +GList *purple_protocol_attention_get_types(PurpleProtocolAttention *attention, PurpleAccount *account); + * purple_protocol_attention_send_attention: + * @attention: The #PurpleProtocolAttention instance. + * @gc: The #PurpleConnection to send on + * @username: The name of the user to send the attention to. + * @type: The type of attention to send. + * Sends an attention message of @type to @username. + * Returns: %TRUE on success, %FALSE otherwise. +gboolean purple_protocol_attention_send_attention(PurpleProtocolAttention *attention, PurpleConnection *pc, const gchar *username, guint type); +#endif /* PURPLE_PROTOCOL_ATTENTION_H */ --- a/libpurple/server.c Mon Nov 02 00:48:14 2020 -0600
+++ b/libpurple/server.c Wed Nov 04 02:35:18 2020 -0600
@@ -34,6 +34,7 @@
#include "purpleprivate.h"
+#include "purpleprotocolattention.h" #include "purpleprotocolim.h"
#include "purpleprotocolprivacy.h"
--- a/libpurple/server.h Mon Nov 02 00:48:14 2020 -0600
+++ b/libpurple/server.h Wed Nov 04 02:35:18 2020 -0600
@@ -33,11 +33,11 @@
#include "conversations.h"
+#include "purpleattentiontype.h" --- a/libpurple/tests/test_attention_type.c Mon Nov 02 00:48:14 2020 -0600
+++ b/libpurple/tests/test_attention_type.c Wed Nov 04 02:35:18 2020 -0600
@@ -1,23 +1,23 @@
+ * 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
+ * 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 * 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.
+ * 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.
+ * 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
+ * along with this program; if not, see <https://www.gnu.org/licenses/>. --- a/libpurple/tests/test_protocol_attention.c Mon Nov 02 00:48:14 2020 -0600
+++ b/libpurple/tests/test_protocol_attention.c Wed Nov 04 02:35:18 2020 -0600
@@ -1,23 +1,23 @@
+ * 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
+ * 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 * 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.
+ * 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.
+ * 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
+ * along with this program; if not, see <https://www.gnu.org/licenses/>. @@ -63,7 +63,7 @@
test_purple_protocol_attention_iface_init(PurpleProtocolAttentionInterface *iface) {
- iface->send = test_purple_protocol_attention_send;
+ iface->send_attention = test_purple_protocol_attention_send; iface->get_types = test_purple_protocol_attention_get_types;
@@ -99,7 +99,7 @@
attn->send_called = FALSE;
- actual = purple_protocol_attention_send(PURPLE_PROTOCOL_ATTENTION(attn), c, "someguy", 0);
+ actual = purple_protocol_attention_send_attention(PURPLE_PROTOCOL_ATTENTION(attn), c, "someguy", 0); g_assert_true(attn->send_called);
--- a/po/POTFILES.in Mon Nov 02 00:48:14 2020 -0600
+++ b/po/POTFILES.in Wed Nov 04 02:35:18 2020 -0600
@@ -27,7 +27,6 @@
@@ -264,12 +263,14 @@
libpurple/purpleaccountpresence.c
libpurple/purpleattachment.c
+libpurple/purpleattentiontype.c libpurple/purplebuddypresence.c
libpurple/purplechatuser.c
libpurple/purplecredentialprovider.c
libpurple/purpleimconversation.c
libpurple/purplepresence.c
+libpurple/purpleprotocolattention.c libpurple/purpleprotocolim.c
libpurple/purpleprotocolmedia.c
libpurple/purpleprotocolprivacy.c