libpurple/countingnode.c

Sun, 11 Dec 2022 22:56:34 -0600

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Sun, 11 Dec 2022 22:56:34 -0600
changeset 41960
c8a4853205e3
parent 41685
ca22b00972d4
child 42584
687260353985
permissions
-rw-r--r--

Bump C standard to C99 for libpurple files and fix warnings

Testing Done:
Touched all source files and compiled; saw no new warnings.

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

37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * purple
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 *
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * source distribution.
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 *
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * (at your option) any later version.
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 *
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * GNU General Public License for more details.
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 *
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 *
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22 */
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include "countingnode.h"
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 typedef struct _PurpleCountingNodePrivate PurpleCountingNodePrivate;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 /* Private data of a counting node */
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 struct _PurpleCountingNodePrivate {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 int totalsize; /* The number of children under this node */
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 int currentsize; /* The number of children under this node
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 corresponding to online accounts */
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 int onlinecount; /* The number of children under this contact who are
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 currently online */
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 };
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 /* Counting node property enums */
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 enum
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 PROP_0,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 PROP_TOTAL_SIZE,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 PROP_CURRENT_SIZE,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 PROP_ONLINE_COUNT,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 PROP_LAST
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 };
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 static GParamSpec *properties[PROP_LAST];
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47
39364
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37945
diff changeset
48 G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(PurpleCountingNode, purple_counting_node,
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37945
diff changeset
49 PURPLE_TYPE_BLIST_NODE);
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37945
diff changeset
50
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 /******************************************************************************
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 * API
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 *****************************************************************************/
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 int
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 purple_counting_node_get_total_size(PurpleCountingNode *counter)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
57 PurpleCountingNodePrivate *priv = NULL;
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
59 g_return_val_if_fail(PURPLE_IS_COUNTING_NODE(counter), -1);
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
61 priv = purple_counting_node_get_instance_private(counter);
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 return priv->totalsize;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 int
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 purple_counting_node_get_current_size(PurpleCountingNode *counter)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
68 PurpleCountingNodePrivate *priv = NULL;
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
70 g_return_val_if_fail(PURPLE_IS_COUNTING_NODE(counter), -1);
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
72 priv = purple_counting_node_get_instance_private(counter);
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 return priv->currentsize;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 int
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 purple_counting_node_get_online_count(PurpleCountingNode *counter)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
79 PurpleCountingNodePrivate *priv = NULL;
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
81 g_return_val_if_fail(PURPLE_IS_COUNTING_NODE(counter), -1);
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
83 priv = purple_counting_node_get_instance_private(counter);
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 return priv->onlinecount;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 void
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 purple_counting_node_change_total_size(PurpleCountingNode *counter, int delta)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
90 PurpleCountingNodePrivate *priv = NULL;
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
92 g_return_if_fail(PURPLE_IS_COUNTING_NODE(counter));
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
94 priv = purple_counting_node_get_instance_private(counter);
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 purple_counting_node_set_total_size(counter, priv->totalsize + delta);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 void
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 purple_counting_node_change_current_size(PurpleCountingNode *counter, int delta)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
101 PurpleCountingNodePrivate *priv = NULL;
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
103 g_return_if_fail(PURPLE_IS_COUNTING_NODE(counter));
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
105 priv = purple_counting_node_get_instance_private(counter);
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 purple_counting_node_set_current_size(counter, priv->currentsize + delta);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 void
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110 purple_counting_node_change_online_count(PurpleCountingNode *counter, int delta)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
112 PurpleCountingNodePrivate *priv = NULL;
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
114 g_return_if_fail(PURPLE_IS_COUNTING_NODE(counter));
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
116 priv = purple_counting_node_get_instance_private(counter);
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 purple_counting_node_set_online_count(counter, priv->onlinecount + delta);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 void
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 purple_counting_node_set_total_size(PurpleCountingNode *counter, int totalsize)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
123 PurpleCountingNodePrivate *priv = NULL;
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
125 g_return_if_fail(PURPLE_IS_COUNTING_NODE(counter));
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
127 priv = purple_counting_node_get_instance_private(counter);
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 priv->totalsize = totalsize;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 g_object_notify_by_pspec(G_OBJECT(counter), properties[PROP_TOTAL_SIZE]);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133 void
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 purple_counting_node_set_current_size(PurpleCountingNode *counter, int currentsize)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
136 PurpleCountingNodePrivate *priv = NULL;
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
138 g_return_if_fail(PURPLE_IS_COUNTING_NODE(counter));
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
140 priv = purple_counting_node_get_instance_private(counter);
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 priv->currentsize = currentsize;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143 g_object_notify_by_pspec(G_OBJECT(counter), properties[PROP_CURRENT_SIZE]);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146 void
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 purple_counting_node_set_online_count(PurpleCountingNode *counter, int onlinecount)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
149 PurpleCountingNodePrivate *priv = NULL;
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
151 g_return_if_fail(PURPLE_IS_COUNTING_NODE(counter));
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
153 priv = purple_counting_node_get_instance_private(counter);
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154 priv->onlinecount = onlinecount;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156 g_object_notify_by_pspec(G_OBJECT(counter), properties[PROP_ONLINE_COUNT]);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159 /**************************************************************************
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 * GObject Stuff
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 **************************************************************************/
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 /* Set method for GObject properties */
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 static void
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 purple_counting_node_set_property(GObject *obj, guint param_id, const GValue *value,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 GParamSpec *pspec)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166 {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167 PurpleCountingNode *node = PURPLE_COUNTING_NODE(obj);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169 switch (param_id) {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170 case PROP_TOTAL_SIZE:
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171 purple_counting_node_set_total_size(node, g_value_get_int(value));
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172 break;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173 case PROP_CURRENT_SIZE:
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174 purple_counting_node_set_current_size(node, g_value_get_int(value));
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175 break;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176 case PROP_ONLINE_COUNT:
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 purple_counting_node_set_online_count(node, g_value_get_int(value));
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 break;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179 default:
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181 break;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185 /* Get method for GObject properties */
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186 static void
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
187 purple_counting_node_get_property(GObject *obj, guint param_id, GValue *value,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
188 GParamSpec *pspec)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
189 {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190 PurpleCountingNode *node = PURPLE_COUNTING_NODE(obj);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
191
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192 switch (param_id) {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
193 case PROP_TOTAL_SIZE:
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194 g_value_set_int(value, purple_counting_node_get_total_size(node));
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 break;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196 case PROP_CURRENT_SIZE:
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 g_value_set_int(value, purple_counting_node_get_current_size(node));
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198 break;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199 case PROP_ONLINE_COUNT:
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200 g_value_set_int(value, purple_counting_node_get_online_count(node));
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201 break;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202 default:
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204 break;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207
39364
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37945
diff changeset
208 static void
41960
c8a4853205e3 Bump C standard to C99 for libpurple files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41685
diff changeset
209 purple_counting_node_init(G_GNUC_UNUSED PurpleCountingNode *counter)
39364
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37945
diff changeset
210 {
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37945
diff changeset
211 }
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37945
diff changeset
212
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213 /* Class initializer function */
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 static void
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215 purple_counting_node_class_init(PurpleCountingNodeClass *klass)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
216 {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219 /* Setup properties */
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220 obj_class->get_property = purple_counting_node_get_property;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221 obj_class->set_property = purple_counting_node_set_property;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
222
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223 properties[PROP_TOTAL_SIZE] = g_param_spec_int(
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224 "total-size",
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225 "Total size",
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 "The number of children under this node.",
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
227 G_MININT, G_MAXINT, 0,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
229 );
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
230
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
231 properties[PROP_CURRENT_SIZE] = g_param_spec_int(
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
232 "current-size",
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
233 "Current size",
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
234 "The number of children with online accounts.",
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
235 G_MININT, G_MAXINT, 0,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
236 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
237 );
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
238
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
239 properties[PROP_ONLINE_COUNT] = g_param_spec_int(
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
240 "online-count",
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
241 "Online count",
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
242 "The number of children that are online.",
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
243 G_MININT, G_MAXINT, 0,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
244 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
245 );
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
246
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
247 g_object_class_install_properties(obj_class, PROP_LAST, properties);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
248 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
249

mercurial