pidgin/pidgin

ed15916ec9ed
Parents 79e613af04c4
Children 4af13de1fee2
First pass at moving attention to it's own files
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/attention.c Thu Jan 18 23:46:05 2018 -0600
@@ -0,0 +1,179 @@
+/* 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
+ */
+
+#include "attention.h"
+
+/******************************************************************************
+ * PurpleAttentionType API
+ *****************************************************************************/
+struct _PurpleAttentionType {
+ const gchar *name;
+ const gchar *incoming_description;
+ const gchar *outgoing_description;
+ const gchar *icon_name;
+ const gchar *unlocalized_name;
+};
+
+G_DEFINE_BOXED_TYPE(
+ PurpleAttentionType,
+ purple_attention_type,
+ purple_attention_type_copy,
+ g_free
+);
+
+PurpleAttentionType *
+purple_attention_type_new(const gchar *unlocalized_name,
+ const gchar *name,
+ const gchar *incoming_description,
+ const gchar *outgoing_description)
+{
+ PurpleAttentionType *attn = g_new0(PurpleAttentionType, 1);
+
+ attn->unlocalized_name = unlocalized_name;
+ attn->name = name;
+ attn->incoming_description = incoming_description;
+ attn->outgoing_description = outgoing_description;
+
+ return attn;
+}
+
+PurpleAttentionType *
+purple_attention_type_copy(PurpleAttentionType *attn) {
+ PurpleAttentionType *attn_copy = NULL;
+
+ g_return_val_if_fail(attn != NULL, NULL);
+
+ attn_copy = g_new(PurpleAttentionType, 1);
+ *attn_copy = *attn;
+
+ return attn_copy;
+}
+
+const gchar *
+purple_attention_type_get_name(const PurpleAttentionType *type) {
+ g_return_val_if_fail(type, NULL);
+
+ return type->name;
+}
+
+void
+purple_attention_type_set_name(PurpleAttentionType *type, const gchar *name) {
+ g_return_if_fail(type);
+
+ type->name = name;
+}
+
+const gchar *
+purple_attention_type_get_incoming_desc(const PurpleAttentionType *type) {
+ g_return_val_if_fail(type, NULL);
+
+ return type->incoming_description;
+}
+
+void
+purple_attention_type_set_incoming_desc(PurpleAttentionType *type, const gchar *desc) {
+ g_return_if_fail(type);
+
+ type->incoming_description = desc;
+}
+
+const gchar *
+purple_attention_type_get_outgoing_desc(const PurpleAttentionType *type) {
+ g_return_val_if_fail(type, NULL);
+
+ return type->outgoing_description;
+}
+
+void
+purple_attention_type_set_outgoing_desc(PurpleAttentionType *type, const gchar *desc) {
+ g_return_if_fail(type != NULL);
+
+ type->outgoing_description = desc;
+}
+
+const gchar *
+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 NULL;
+
+ return type->icon_name;
+}
+
+void
+purple_attention_type_set_icon_name(PurpleAttentionType *type, const gchar *name) {
+ g_return_if_fail(type);
+
+ type->icon_name = name;
+}
+
+const gchar *
+purple_attention_type_get_unlocalized_name(const PurpleAttentionType *type) {
+ g_return_val_if_fail(type, NULL);
+
+ return type->unlocalized_name;
+}
+
+void
+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);
+
+static void
+purple_protocol_attention_default_init(PurpleProtocolAttentionInterface *iface) {
+}
+
+gboolean
+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);
+ }
+
+ return FALSE;
+}
+
+GList *
+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);
+ }
+
+ return NULL;
+}
+
--- a/libpurple/attention.h Thu Nov 23 22:28:09 2017 -0600
+++ b/libpurple/attention.h Thu Jan 18 23:46:05 2018 -0600
@@ -22,6 +22,9 @@
#ifndef PURPLE_ATTENTION_H
#define PURPLE_ATTENTION_H
+#include <glib.h>
+#include <glib-object.h>
+
/**
* SECTION:attention
* @section_id: libpurple-attention
@@ -29,32 +32,212 @@
* @title: Attention Object and Interfaces
*/
-#define PURPLE_TYPE_PROTOCOL_ATTENTION_IFACE (purple_protocol_attention_iface_get_type())
-
-typedef struct _PurpleProtocolAttentionIface PurpleProtocolAttentionIface;
+#define PURPLE_TYPE_ATTENTION_TYPE (purple_attention_type_get_type())
/**
- * PurpleProtocolAttentionIface:
+ * PurpleAttentionType:
+ * @name: The name to show in GUI elements.
+ * @incoming_description: Shown when received.
+ * @outgoing_description: Shown when sent.
+ * @icon_name: Optional name of the icon to display.
+ * @unlocalized_name: An unlocalized name for UIs that would rather use that.
+ *
+ * Represents "nudges" and "buzzes" that you may send to a buddy to attract
+ * their attention (or vice-versa).
+ */
+typedef struct _PurpleAttentionType PurpleAttentionType;
+
+#define PURPLE_TYPE_PROTOCOL_ATTENTION (purple_protocol_attention_get_type())
+#define PURPLE_PROTOCOL_ATTENTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_PROTOCOL_ATTENTION, PurpleProtocolAttention))
+#define PURPLE_IS_PROTOCOL_ATTENTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PROTOCOL_ATTENTION))
+#define PURPLE_PROTOCOL_ATTENTION_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), PURPLE_TYPE_PROTOCOL_ATTENTION, PurpleProtocolAttentionInterface))
+
+typedef struct _PurpleProtocolAttention PurpleProtocolAttention;
+typedef struct _PurpleProtocolAttentionInterface PurpleProtocolAttentionInterface;
+
+#include "account.h"
+#include "connection.h"
+
+/**
+ * PurpleProtocolAttentionInterface:
*
* The protocol attention interface.
*
* This interface provides attention API for sending and receiving
* zaps/nudges/buzzes etc.
*/
-struct _PurpleProtocolAttentionIface
+struct _PurpleProtocolAttentionInterface
{
/*< private >*/
- GTypeInterface parent_iface;
+ GTypeInterface parent;
/*< public >*/
- gboolean (*send)(PurpleConnection *gc, const char *username,
- guint type);
+ gboolean (*send)(PurpleProtocolAttention *attn, PurpleConnection *gc, const gchar *username, guint type);
- GList *(*get_types)(PurpleAccount *acct);
+ GList *(*get_types)(PurpleProtocolAttention *attn, PurpleAccount *acct);
};
-#define PURPLE_PROTOCOL_HAS_ATTENTION_IFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PROTOCOL_ATTENTION_IFACE))
-#define PURPLE_PROTOCOL_GET_ATTENTION_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), PURPLE_TYPE_PROTOCOL_ATTENTION_IFACE, \
- PurpleProtocolAttentionIface))
+G_BEGIN_DECLS
+
+/******************************************************************************
+ * AttentionType API
+ *****************************************************************************/
+
+/**
+ * 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.
+ *
+ * Returns: The name.
+ */
+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
+ * localization.
+ *
+ * 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,
+ * thus it is required.
+ */
+void purple_attention_type_set_unlocalized_name(PurpleAttentionType *type, const gchar *ulname);
+
+/******************************************************************************
+ * Protocol Interface
+ *****************************************************************************/
+
+/**
+ * purple_protocol_attention_get_type:
+ *
+ * Returns: The #GType for the protocol attention interface.
+ */
+GType purple_protocol_attention_get_type(void);
+
+/**
+ * purple_protocol_attention_get_types:
+ * @protocol: The #PurpleProtocol.
+ * @account: The #PurpleAccount whose attention types to get.
+ *
+ * Returns a list of
+ */
+GList *purple_protocol_attention_get_types(PurpleProtocolAttention *attn,
+ PurpleAccount *acct);
+
+gboolean purple_protocol_attention_send(PurpleProtocolAttention *attn,
+ PurpleConnection *gc, const char *username, guint type);
+
+G_END_DECLS
#endif /* PURPLE_ATTENTION_H */
--- a/libpurple/meson.build Thu Nov 23 22:28:09 2017 -0600
+++ b/libpurple/meson.build Thu Jan 18 23:46:05 2018 -0600
@@ -2,6 +2,7 @@
'account.c',
'accounts.c',
'accountopt.c',
+ 'attention.c',
'blistnode.c',
'buddy.c',
'buddylist.c',
@@ -86,6 +87,7 @@
'account.h',
'accounts.h',
'accountopt.h',
+ 'attention.h',
'blistnode.h',
'buddy.h',
'buddylist.h',
--- a/libpurple/protocol.c Thu Nov 23 22:28:09 2017 -0600
+++ b/libpurple/protocol.c Thu Jan 18 23:46:05 2018 -0600
@@ -864,56 +864,6 @@
#undef DEFINE_PROTOCOL_FUNC
/**************************************************************************
- * Protocol Attention Interface API
- **************************************************************************/
-#define DEFINE_PROTOCOL_FUNC(protocol,funcname,...) \
- PurpleProtocolAttentionIface *attention_iface = \
- PURPLE_PROTOCOL_GET_ATTENTION_IFACE(protocol); \
- if (attention_iface && attention_iface->funcname) \
- attention_iface->funcname(__VA_ARGS__);
-
-#define DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol,defaultreturn,funcname,...) \
- PurpleProtocolAttentionIface *attention_iface = \
- PURPLE_PROTOCOL_GET_ATTENTION_IFACE(protocol); \
- if (attention_iface && attention_iface->funcname) \
- return attention_iface->funcname(__VA_ARGS__); \
- else \
- return defaultreturn;
-
-GType
-purple_protocol_attention_iface_get_type(void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY(type == 0)) {
- static const GTypeInfo info = {
- .class_size = sizeof(PurpleProtocolAttentionIface),
- };
-
- type = g_type_register_static(G_TYPE_INTERFACE,
- "PurpleProtocolAttentionIface", &info, 0);
- }
- return type;
-}
-
-gboolean
-purple_protocol_attention_iface_send(PurpleProtocol *protocol,
- PurpleConnection *gc, const char *username, guint type)
-{
- DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol, FALSE, send, gc, username, type);
-}
-
-GList *
-purple_protocol_attention_iface_get_types(PurpleProtocol *protocol,
- PurpleAccount *account)
-{
- DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol, NULL, get_types, account);
-}
-
-#undef DEFINE_PROTOCOL_FUNC_WITH_RETURN
-#undef DEFINE_PROTOCOL_FUNC
-
-/**************************************************************************
* Protocol Media Interface API
**************************************************************************/
#define DEFINE_PROTOCOL_FUNC(protocol,funcname,...) \
--- a/libpurple/protocol.h Thu Nov 23 22:28:09 2017 -0600
+++ b/libpurple/protocol.h Thu Jan 18 23:46:05 2018 -0600
@@ -1050,29 +1050,6 @@
PurpleRoomlistRoom *room);
/**************************************************************************/
-/* Protocol Attention Interface API */
-/**************************************************************************/
-
-/**
- * purple_protocol_attention_iface_get_type:
- *
- * Returns: The #GType for the protocol attention interface.
- */
-GType purple_protocol_attention_iface_get_type(void);
-
-gboolean purple_protocol_attention_iface_send(PurpleProtocol *protocol,
- PurpleConnection *gc, const char *username, guint type);
-
-/**
- * purple_protocol_attention_iface_get_types:
- * @protocol: The #PurpleProtocol.
- * @account: The #PurpleAccount whose attention types to get.
- *
- * Returns a list of
-GList *purple_protocol_attention_iface_get_types(PurpleProtocol *protocol,
- PurpleAccount *acct);
-
-/**************************************************************************/
/* Protocol Media Interface API */
/**************************************************************************/
--- a/libpurple/protocols.c Thu Nov 23 22:28:09 2017 -0600
+++ b/libpurple/protocols.c Thu Jan 18 23:46:05 2018 -0600
@@ -32,149 +32,6 @@
static GHashTable *protocols = NULL;
-/**************************************************************************/
-/* Attention Type API */
-/**************************************************************************/
-
-struct _PurpleAttentionType
-{
- const char *name; /* Shown in GUI elements */
- const char *incoming_description; /* Shown when sent */
- const char *outgoing_description; /* Shown when receied */
- const char *icon_name; /* Icon to display (optional) */
- const char *unlocalized_name; /* Unlocalized name for UIs needing it */
-};
-
-
-PurpleAttentionType *
-purple_attention_type_new(const char *ulname, const char *name,
- const char *inc_desc, const char *out_desc)
-{
- PurpleAttentionType *attn = g_new0(PurpleAttentionType, 1);
-
- purple_attention_type_set_name(attn, name);
- purple_attention_type_set_incoming_desc(attn, inc_desc);
- purple_attention_type_set_outgoing_desc(attn, out_desc);
- purple_attention_type_set_unlocalized_name(attn, ulname);
-
- return attn;
-}
-
-
-void
-purple_attention_type_set_name(PurpleAttentionType *type, const char *name)
-{
- g_return_if_fail(type != NULL);
-
- type->name = name;
-}
-
-void
-purple_attention_type_set_incoming_desc(PurpleAttentionType *type, const char *desc)
-{
- g_return_if_fail(type != NULL);
-
- type->incoming_description = desc;
-}
-
-void
-purple_attention_type_set_outgoing_desc(PurpleAttentionType *type, const char *desc)
-{
- g_return_if_fail(type != NULL);
-
- type->outgoing_description = desc;
-}
-
-void
-purple_attention_type_set_icon_name(PurpleAttentionType *type, const char *name)
-{
- g_return_if_fail(type != NULL);
-
- type->icon_name = name;
-}
-
-void
-purple_attention_type_set_unlocalized_name(PurpleAttentionType *type, const char *ulname)
-{
- g_return_if_fail(type != NULL);
-
- type->unlocalized_name = ulname;
-}
-
-const char *
-purple_attention_type_get_name(const PurpleAttentionType *type)
-{
- g_return_val_if_fail(type != NULL, NULL);
-
- return type->name;
-}
-
-const char *
-purple_attention_type_get_incoming_desc(const PurpleAttentionType *type)
-{
- g_return_val_if_fail(type != NULL, NULL);
-
- return type->incoming_description;
-}
-
-const char *
-purple_attention_type_get_outgoing_desc(const PurpleAttentionType *type)
-{
- g_return_val_if_fail(type != NULL, NULL);
-
- return type->outgoing_description;
-}
-
-const char *
-purple_attention_type_get_icon_name(const PurpleAttentionType *type)
-{
- g_return_val_if_fail(type != NULL, NULL);
-
- if(type->icon_name == NULL || *(type->icon_name) == '\0')
- return NULL;
-
- return type->icon_name;
-}
-
-const char *
-purple_attention_type_get_unlocalized_name(const PurpleAttentionType *type)
-{
- g_return_val_if_fail(type != NULL, NULL);
-
- return type->unlocalized_name;
-}
-
-/**************************************************************************
- * GBoxed code for PurpleAttentionType
- **************************************************************************/
-
-static PurpleAttentionType *
-purple_attention_type_copy(PurpleAttentionType *attn)
-{
- PurpleAttentionType *attn_copy;
-
- g_return_val_if_fail(attn != NULL, NULL);
-
- attn_copy = g_new(PurpleAttentionType, 1);
- *attn_copy = *attn;
-
- return attn_copy;
-}
-
-GType
-purple_attention_type_get_type(void)
-{
- static GType type = 0;
-
- if (type == 0) {
- type = g_boxed_type_register_static("PurpleAttentionType",
- (GBoxedCopyFunc)purple_attention_type_copy,
- (GBoxedFreeFunc)g_free);
- }
-
- return type;
-}
-
/**************************************************************************
* GBoxed code for PurpleProtocolChatEntry
**************************************************************************/
@@ -508,7 +365,7 @@
g_return_if_fail(who != NULL);
protocol = purple_protocols_find(purple_account_get_protocol_id(purple_connection_get_account(gc)));
- g_return_if_fail(PURPLE_PROTOCOL_IMPLEMENTS(protocol, ATTENTION_IFACE, send));
+ g_return_if_fail(PURPLE_IS_PROTOCOL_ATTENTION(protocol));
attn = purple_get_attention_type_from_code(purple_connection_get_account(gc), type_code);
@@ -526,7 +383,7 @@
purple_debug_info("server", "serv_send_attention: sending '%s' to %s\n",
description, who);
- if (!purple_protocol_attention_iface_send(protocol, gc, who, type_code))
+ if (!purple_protocol_attention_send(PURPLE_PROTOCOL_ATTENTION(protocol), gc, who, type_code))
return;
im = purple_im_conversation_new(purple_connection_get_account(gc), who);
--- a/libpurple/protocols.h Thu Nov 23 22:28:09 2017 -0600
+++ b/libpurple/protocols.h Thu Jan 18 23:46:05 2018 -0600
@@ -36,16 +36,6 @@
typedef struct _PurpleProtocolAction PurpleProtocolAction;
typedef void (*PurpleProtocolActionCallback)(PurpleProtocolAction *action);
-#define PURPLE_TYPE_ATTENTION_TYPE (purple_attention_type_get_type())
-
-/**
- * PurpleAttentionType:
- *
- * Represents "nudges" and "buzzes" that you may send to a buddy to attract
- * their attention (or vice-versa).
- */
-typedef struct _PurpleAttentionType PurpleAttentionType;
-
/**************************************************************************/
/* Basic Protocol Information */
/**************************************************************************/
@@ -157,135 +147,6 @@
/* Attention Type API */
/**************************************************************************/
-/**
- * purple_attention_type_get_type:
- *
- * Returns: The #GType for the #PurpleAttentionType boxed structure.
- */
-GType purple_attention_type_get_type(void);
-
-/**
- * purple_attention_type_new:
- * @ulname: 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 @ulname, with localization.
- * @inc_desc: A localized description shown when the event is received.
- * @out_desc: 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 char *ulname, const char *name,
- const char *inc_desc, const char *out_desc);
-
-/**
- * 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
- * localization.
- *
- * Sets the displayed name of the attention-demanding event.
- */
-void purple_attention_type_set_name(PurpleAttentionType *type, const char *name);
-
-/**
- * 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 char *desc);
-
-/**
- * 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 char *desc);
-
-/**
- * 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 char *name);
-
-/**
- * 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,
- * thus it is required.
- */
-void purple_attention_type_set_unlocalized_name(PurpleAttentionType *type, const char *ulname);
-
-/**
- * purple_attention_type_get_name:
- * @type: The attention type.
- *
- * Get the attention type's name as displayed by the UI.
- *
- * Returns: The name.
- */
-const char *purple_attention_type_get_name(const PurpleAttentionType *type);
-
-/**
- * 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 char *purple_attention_type_get_incoming_desc(const PurpleAttentionType *type);
-
-/**
- * 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 char *purple_attention_type_get_outgoing_desc(const PurpleAttentionType *type);
-
-/**
- * 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 char *purple_attention_type_get_icon_name(const PurpleAttentionType *type);
-
-/**
- * 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 char *purple_attention_type_get_unlocalized_name(const PurpleAttentionType *type);
-
/**************************************************************************/
/* Protocol Action API */
/**************************************************************************/
--- a/libpurple/protocols/jabber/jabber.c Thu Nov 23 22:28:09 2017 -0600
+++ b/libpurple/protocols/jabber/jabber.c Thu Jan 18 23:46:05 2018 -0600
@@ -3211,7 +3211,7 @@
return _jabber_send_buzz(js, who, error) ? PURPLE_CMD_RET_OK : PURPLE_CMD_RET_FAILED;
}
-GList *jabber_attention_types(PurpleAccount *account)
+GList *jabber_attention_types(PurpleProtocolAttention *attn, PurpleAccount *account)
{
static GList *types = NULL;
@@ -3223,7 +3223,7 @@
return types;
}
-gboolean jabber_send_attention(PurpleConnection *gc, const char *username, guint code)
+gboolean jabber_send_attention(PurpleProtocolAttention *attn, PurpleConnection *gc, const char *username, guint code)
{
JabberStream *js = purple_connection_get_protocol_data(gc);
gchar *error = NULL;
@@ -4249,10 +4249,10 @@
}
static void
-jabber_protocol_attention_iface_init(PurpleProtocolAttentionIface *attention_iface)
+jabber_protocol_attention_iface_init(PurpleProtocolAttentionInterface *iface)
{
- attention_iface->send = jabber_send_attention;
- attention_iface->get_types = jabber_attention_types;
+ iface->send = jabber_send_attention;
+ iface->get_types = jabber_attention_types;
}
static void
@@ -4291,7 +4291,7 @@
PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_ROOMLIST_IFACE,
jabber_protocol_roomlist_iface_init)
- PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_ATTENTION_IFACE,
+ PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_ATTENTION,
jabber_protocol_attention_iface_init)
PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_MEDIA_IFACE,
--- a/libpurple/protocols/jabber/jabber.h Thu Nov 23 22:28:09 2017 -0600
+++ b/libpurple/protocols/jabber/jabber.h Thu Jan 18 23:46:05 2018 -0600
@@ -59,6 +59,7 @@
#include <gmodule.h>
#include <gio/gio.h>
+#include "attention.h"
#include "circularbuffer.h"
#include "connection.h"
#include "http.h"
@@ -418,8 +419,8 @@
void jabber_register_gateway(JabberStream *js, const char *gateway);
void jabber_register_account(PurpleAccount *account);
void jabber_unregister_account(PurpleAccount *account, PurpleAccountUnregistrationCb cb, void *user_data);
-gboolean jabber_send_attention(PurpleConnection *gc, const char *username, guint code);
-GList *jabber_attention_types(PurpleAccount *account);
+gboolean jabber_send_attention(PurpleProtocolAttention *attn, PurpleConnection *gc, const char *username, guint code);
+GList *jabber_attention_types(PurpleProtocolAttention *attn, PurpleAccount *account);
void jabber_convo_closed(PurpleConnection *gc, const char *who);
PurpleChat *jabber_find_blist_chat(PurpleAccount *account, const char *name);
gboolean jabber_offline_message(const PurpleBuddy *buddy);
--- a/libpurple/server.c Thu Nov 23 22:28:09 2017 -0600
+++ b/libpurple/server.c Thu Jan 18 23:46:05 2018 -0600
@@ -295,10 +295,10 @@
protocol = purple_protocols_find(purple_account_get_protocol_id(account));
/* Lookup the attention type in the protocol's attention_types list, if any. */
- if (PURPLE_PROTOCOL_IMPLEMENTS(protocol, ATTENTION_IFACE, get_types)) {
+ if (PURPLE_IS_PROTOCOL_ATTENTION(protocol)) {
GList *attention_types;
- attention_types = purple_protocol_attention_iface_get_types(protocol, account);
+ attention_types = purple_protocol_attention_get_types(protocol, account);
attn = (PurpleAttentionType *)g_list_nth_data(attention_types, type_code);
} else {
attn = NULL;
--- a/libpurple/server.h Thu Nov 23 22:28:09 2017 -0600
+++ b/libpurple/server.h Thu Jan 18 23:46:05 2018 -0600
@@ -29,6 +29,7 @@
*/
#include "accounts.h"
+#include "attention.h"
#include "conversations.h"
#include "group.h"
#include "message.h"
--- a/pidgin/gtkconv.c Thu Nov 23 22:28:09 2017 -0600
+++ b/pidgin/gtkconv.c Thu Jan 18 23:46:05 2018 -0600
@@ -31,6 +31,7 @@
#include <gdk/gdkkeysyms.h>
#include "account.h"
+#include "attention.h"
#include "cmds.h"
#include "core.h"
#include "debug.h"
@@ -3444,8 +3445,8 @@
if (pc != NULL)
protocol = purple_connection_get_protocol(pc);
- if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, ATTENTION_IFACE, get_types)) {
- list = purple_protocol_attention_iface_get_types(protocol, purple_connection_get_account(pc));
+ if (protocol && PURPLE_IS_PROTOCOL_ATTENTION(protocol)) {
+ list = purple_protocol_attention_get_types(PURPLE_PROTOCOL_ATTENTION(protocol), purple_connection_get_account(pc));
/* Multiple attention types */
if (list && list->next) {
@@ -7432,7 +7433,7 @@
gtk_action_set_sensitive(win->menu->add, (PURPLE_PROTOCOL_IMPLEMENTS(protocol, SERVER_IFACE, add_buddy)));
gtk_action_set_sensitive(win->menu->remove, (PURPLE_PROTOCOL_IMPLEMENTS(protocol, SERVER_IFACE, remove_buddy)));
gtk_action_set_sensitive(win->menu->send_file, can_send_file);
- gtk_action_set_sensitive(win->menu->get_attention, (PURPLE_PROTOCOL_IMPLEMENTS(protocol, ATTENTION_IFACE, send)));
+ gtk_action_set_sensitive(win->menu->get_attention, (PURPLE_IS_PROTOCOL_ATTENTION(protocol)));
gtk_action_set_sensitive(win->menu->alias,
(account != NULL) &&
(purple_blist_find_buddy(account, purple_conversation_get_name(conv)) != NULL));
--- a/pidgin/gtkwebviewtoolbar.c Thu Nov 23 22:28:09 2017 -0600
+++ b/pidgin/gtkwebviewtoolbar.c Thu Jan 18 23:46:05 2018 -0600
@@ -1682,7 +1682,7 @@
for the time being it is always disabled for chats */
gtk_action_set_sensitive(priv->attention,
conv && protocol && PURPLE_IS_IM_CONVERSATION(conv) &&
- PURPLE_PROTOCOL_IMPLEMENTS(protocol, ATTENTION_IFACE, send));
+ PURPLE_IS_PROTOCOL_ATTENTION(protocol));
update_smiley_button(toolbar);
}