3 * Purple is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
22 #include "attention.h"
24 /******************************************************************************
25 * PurpleAttentionType API
26 *****************************************************************************/
27 struct _PurpleAttentionType
{
29 const gchar
*incoming_description
;
30 const gchar
*outgoing_description
;
31 const gchar
*icon_name
;
32 const gchar
*unlocalized_name
;
37 purple_attention_type
,
38 purple_attention_type_copy
,
43 purple_attention_type_new(const gchar
*unlocalized_name
,
45 const gchar
*incoming_description
,
46 const gchar
*outgoing_description
)
48 PurpleAttentionType
*attn
= g_new0(PurpleAttentionType
, 1);
50 attn
->unlocalized_name
= unlocalized_name
;
52 attn
->incoming_description
= incoming_description
;
53 attn
->outgoing_description
= outgoing_description
;
59 purple_attention_type_copy(PurpleAttentionType
*attn
) {
60 PurpleAttentionType
*attn_copy
= NULL
;
62 g_return_val_if_fail(attn
!= NULL
, NULL
);
64 attn_copy
= g_new(PurpleAttentionType
, 1);
71 purple_attention_type_get_name(const PurpleAttentionType
*type
) {
72 g_return_val_if_fail(type
, NULL
);
78 purple_attention_type_set_name(PurpleAttentionType
*type
, const gchar
*name
) {
79 g_return_if_fail(type
);
85 purple_attention_type_get_incoming_desc(const PurpleAttentionType
*type
) {
86 g_return_val_if_fail(type
, NULL
);
88 return type
->incoming_description
;
92 purple_attention_type_set_incoming_desc(PurpleAttentionType
*type
, const gchar
*desc
) {
93 g_return_if_fail(type
);
95 type
->incoming_description
= desc
;
99 purple_attention_type_get_outgoing_desc(const PurpleAttentionType
*type
) {
100 g_return_val_if_fail(type
, NULL
);
102 return type
->outgoing_description
;
106 purple_attention_type_set_outgoing_desc(PurpleAttentionType
*type
, const gchar
*desc
) {
107 g_return_if_fail(type
!= NULL
);
109 type
->outgoing_description
= desc
;
113 purple_attention_type_get_icon_name(const PurpleAttentionType
*type
) {
114 g_return_val_if_fail(type
, NULL
);
116 if(type
->icon_name
== NULL
|| *(type
->icon_name
) == '\0')
119 return type
->icon_name
;
123 purple_attention_type_set_icon_name(PurpleAttentionType
*type
, const gchar
*name
) {
124 g_return_if_fail(type
);
126 type
->icon_name
= name
;
130 purple_attention_type_get_unlocalized_name(const PurpleAttentionType
*type
) {
131 g_return_val_if_fail(type
, NULL
);
133 return type
->unlocalized_name
;
137 purple_attention_type_set_unlocalized_name(PurpleAttentionType
*type
, const gchar
*ulname
) {
138 g_return_if_fail(type
);
140 type
->unlocalized_name
= ulname
;
143 /******************************************************************************
144 * PurpleAttentionType API
145 *****************************************************************************/
146 G_DEFINE_INTERFACE(PurpleProtocolAttention
, purple_protocol_attention
, G_TYPE_INVALID
);
149 purple_protocol_attention_default_init(PurpleProtocolAttentionInterface
*iface
) {
153 purple_protocol_attention_send(PurpleProtocolAttention
*attn
, PurpleConnection
*gc
, const gchar
*username
, guint type
) {
154 PurpleProtocolAttentionInterface
*iface
= NULL
;
156 g_return_val_if_fail(PURPLE_IS_PROTOCOL_ATTENTION(attn
), FALSE
);
158 iface
= PURPLE_PROTOCOL_ATTENTION_GET_IFACE(attn
);
159 if(iface
&& iface
->send
) {
160 return iface
->send(attn
, gc
, username
, type
);
167 purple_protocol_attention_get_types(PurpleProtocolAttention
*attn
, PurpleAccount
*account
) {
168 PurpleProtocolAttentionInterface
*iface
= NULL
;
170 g_return_val_if_fail(PURPLE_IS_PROTOCOL_ATTENTION(attn
), NULL
);
172 iface
= PURPLE_PROTOCOL_ATTENTION_GET_IFACE(attn
);
173 if(iface
&& iface
->get_types
) {
174 return iface
->get_types(attn
, account
);