libpurple/purpleattentiontype.c

Sat, 30 Jan 2021 02:26:08 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Sat, 30 Jan 2021 02:26:08 -0600
changeset 40745
1b0fa96b5ca3
parent 40579
882884b9bc97
permissions
-rw-r--r--

Make PurpleWhiteboard derivable and remove purple_whiteboard_[gs]et_ui data.

Testing Done:
Compiled

Reviewed at https://reviews.imfreedom.org/r/461/

40579
882884b9bc97 Split PurpleAttentionType and PurpleProtocolAttention into their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40244
diff changeset
1 /*
882884b9bc97 Split PurpleAttentionType and PurpleProtocolAttention into their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40244
diff changeset
2 * purple
882884b9bc97 Split PurpleAttentionType and PurpleProtocolAttention into their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40244
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
38859
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * Purple is the legal property of its developers, whose names are too numerous
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * source distribution.
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * (at your option) any later version.
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * GNU General Public License for more details.
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
40579
882884b9bc97 Split PurpleAttentionType and PurpleProtocolAttention into their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40244
diff changeset
20 * along with this program; if not, see <https://www.gnu.org/licenses/>.
38859
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
40579
882884b9bc97 Split PurpleAttentionType and PurpleProtocolAttention into their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40244
diff changeset
23 #include "purpleattentiontype.h"
38859
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 struct _PurpleAttentionType {
40244
7a330cab3546 Remove documentation for non-public struct fields.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38861
diff changeset
26 /* The name to show in GUI elements. */
38859
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 const gchar *name;
40244
7a330cab3546 Remove documentation for non-public struct fields.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38861
diff changeset
28 /* Shown when received. */
38859
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 const gchar *incoming_description;
40244
7a330cab3546 Remove documentation for non-public struct fields.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38861
diff changeset
30 /* Shown when sent. */
38859
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 const gchar *outgoing_description;
40244
7a330cab3546 Remove documentation for non-public struct fields.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38861
diff changeset
32 /* Optional name of the icon to display. */
38859
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 const gchar *icon_name;
40244
7a330cab3546 Remove documentation for non-public struct fields.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38861
diff changeset
34 /* An unlocalized name for UIs that would rather use that. */
38859
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 const gchar *unlocalized_name;
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 };
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 G_DEFINE_BOXED_TYPE(
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 PurpleAttentionType,
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 purple_attention_type,
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 purple_attention_type_copy,
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 g_free
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 );
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44
40579
882884b9bc97 Split PurpleAttentionType and PurpleProtocolAttention into their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40244
diff changeset
45 /******************************************************************************
882884b9bc97 Split PurpleAttentionType and PurpleProtocolAttention into their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40244
diff changeset
46 * Public API
882884b9bc97 Split PurpleAttentionType and PurpleProtocolAttention into their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40244
diff changeset
47 *****************************************************************************/
38859
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 PurpleAttentionType *
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 purple_attention_type_new(const gchar *unlocalized_name,
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 const gchar *name,
38861
21858f98040c Address the issues that Qulogic found
Gary Kramlich <grim@reaperworld.com>
parents: 38859
diff changeset
51 const gchar *incoming_description,
21858f98040c Address the issues that Qulogic found
Gary Kramlich <grim@reaperworld.com>
parents: 38859
diff changeset
52 const gchar *outgoing_description)
38859
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 {
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 PurpleAttentionType *attn = g_new0(PurpleAttentionType, 1);
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 attn->unlocalized_name = unlocalized_name;
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 attn->name = name;
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 attn->incoming_description = incoming_description;
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 attn->outgoing_description = outgoing_description;
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 return attn;
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 }
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 PurpleAttentionType *
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 purple_attention_type_copy(PurpleAttentionType *attn) {
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 PurpleAttentionType *attn_copy = NULL;
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 g_return_val_if_fail(attn != NULL, NULL);
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 attn_copy = g_new(PurpleAttentionType, 1);
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 *attn_copy = *attn;
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 return attn_copy;
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 }
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 const gchar *
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 purple_attention_type_get_name(const PurpleAttentionType *type) {
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 g_return_val_if_fail(type, NULL);
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 return type->name;
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 }
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 void
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 purple_attention_type_set_name(PurpleAttentionType *type, const gchar *name) {
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 g_return_if_fail(type);
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 type->name = name;
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 }
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 const gchar *
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 purple_attention_type_get_incoming_desc(const PurpleAttentionType *type) {
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 g_return_val_if_fail(type, NULL);
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 return type->incoming_description;
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 }
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 void
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 purple_attention_type_set_incoming_desc(PurpleAttentionType *type, const gchar *desc) {
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 g_return_if_fail(type);
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 type->incoming_description = desc;
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 }
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 const gchar *
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 purple_attention_type_get_outgoing_desc(const PurpleAttentionType *type) {
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 g_return_val_if_fail(type, NULL);
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 return type->outgoing_description;
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 }
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 void
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112 purple_attention_type_set_outgoing_desc(PurpleAttentionType *type, const gchar *desc) {
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 g_return_if_fail(type != NULL);
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 type->outgoing_description = desc;
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 }
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 const gchar *
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 purple_attention_type_get_icon_name(const PurpleAttentionType *type) {
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 g_return_val_if_fail(type, NULL);
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122 if(type->icon_name == NULL || *(type->icon_name) == '\0')
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 return NULL;
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 return type->icon_name;
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 }
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 void
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129 purple_attention_type_set_icon_name(PurpleAttentionType *type, const gchar *name) {
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 g_return_if_fail(type);
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132 type->icon_name = name;
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133 }
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 const gchar *
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136 purple_attention_type_get_unlocalized_name(const PurpleAttentionType *type) {
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 g_return_val_if_fail(type, NULL);
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139 return type->unlocalized_name;
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 }
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 void
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143 purple_attention_type_set_unlocalized_name(PurpleAttentionType *type, const gchar *ulname) {
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 g_return_if_fail(type);
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146 type->unlocalized_name = ulname;
ed15916ec9ed First pass at moving attention to it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 }

mercurial