libpurple/group.c

Wed, 07 Aug 2019 01:15:14 -0400

author
Elliott Sales de Andrade <qulogic@pidgin.im>
date
Wed, 07 Aug 2019 01:15:14 -0400
changeset 39782
db027c5e1463
parent 39759
ea1401483849
child 40079
a37a1e349491
permissions
-rw-r--r--

Fix broken `priv != NULL` checks in libpurple.

The `*_get_instance_private` function just returns input value + offset,
so it is impossible for `priv` to be `NULL`.

37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * purple
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 *
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * source distribution.
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 *
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * (at your option) any later version.
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 *
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * GNU General Public License for more details.
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 *
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 *
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22 */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24 #include "group.h"
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 #include "internal.h" /* TODO: we need to kill this */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 typedef struct _PurpleGroupPrivate PurpleGroupPrivate;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 /******************************************************************************
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 * Private Data
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 *****************************************************************************/
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 struct _PurpleGroupPrivate {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 char *name; /* The name of this group. */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 gboolean is_constructed; /* Indicates if the group has finished being
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 constructed. */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 };
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 /* Group property enums */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 enum
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 GROUP_PROP_0,
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 GROUP_PROP_NAME,
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 GROUP_PROP_LAST
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 };
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 /******************************************************************************
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 * Globals
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 *****************************************************************************/
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 static GParamSpec *properties[GROUP_PROP_LAST];
39364
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
50
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
51 G_DEFINE_TYPE_WITH_PRIVATE(PurpleGroup, purple_group,
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
52 PURPLE_TYPE_COUNTING_NODE);
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 /******************************************************************************
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 * Group API
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 *****************************************************************************/
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 GSList *purple_group_get_accounts(PurpleGroup *group) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 GSList *l = NULL;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 PurpleBlistNode *gnode, *cnode, *bnode;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 gnode = (PurpleBlistNode *)group;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 for (cnode = gnode->child; cnode; cnode = cnode->next) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 if (PURPLE_IS_CHAT(cnode)) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 if (!g_slist_find(l, purple_chat_get_account(PURPLE_CHAT(cnode))))
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 l = g_slist_append(l, purple_chat_get_account(PURPLE_CHAT(cnode)));
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 } else if (PURPLE_IS_CONTACT(cnode)) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 for (bnode = cnode->child; bnode; bnode = bnode->next) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 if (PURPLE_IS_BUDDY(bnode)) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 if (!g_slist_find(l, purple_buddy_get_account(PURPLE_BUDDY(bnode))))
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 l = g_slist_append(l, purple_buddy_get_account(PURPLE_BUDDY(bnode)));
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 return l;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 gboolean purple_group_on_account(PurpleGroup *g, PurpleAccount *account) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 PurpleBlistNode *cnode;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 for (cnode = ((PurpleBlistNode *)g)->child; cnode; cnode = cnode->next) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 if (PURPLE_IS_CONTACT(cnode)) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 if(purple_contact_on_account((PurpleContact *) cnode, account))
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 return TRUE;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 } else if (PURPLE_IS_CHAT(cnode)) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 PurpleChat *chat = (PurpleChat *)cnode;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 if ((!account && purple_account_is_connected(purple_chat_get_account(chat)))
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 || purple_chat_get_account(chat) == account)
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 return TRUE;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 return FALSE;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 /*
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 * TODO: If merging, prompt the user if they want to merge.
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 void purple_group_set_name(PurpleGroup *source, const char *name) {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
100 PurpleGroupPrivate *priv = NULL;
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 PurpleGroup *dest;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 gchar *old_name;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 gchar *new_name;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 GList *moved_buddies = NULL;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 GSList *accts;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
107 g_return_if_fail(PURPLE_IS_GROUP(source));
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 g_return_if_fail(name != NULL);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
110 priv = purple_group_get_instance_private(source);
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
111
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112 new_name = purple_utf8_strip_unprintables(name);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114 if (*new_name == '\0' || purple_strequal(new_name, priv->name)) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 g_free(new_name);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 return;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 dest = purple_blist_find_group(new_name);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 if (dest != NULL && purple_utf8_strcasecmp(priv->name,
39364
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
121 purple_group_get_name(dest)) != 0) {
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122 /* We're merging two groups */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 PurpleBlistNode *prev, *child, *next;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 prev = _purple_blist_get_last_child((PurpleBlistNode*)dest);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 child = PURPLE_BLIST_NODE(source)->child;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 /*
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129 * TODO: This seems like a dumb way to do this... why not just
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 * append all children from the old group to the end of the new
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 * one? Protocols might be expecting to receive an add_buddy() for
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132 * each moved buddy...
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133 */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 while (child)
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136 next = child->next;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 if (PURPLE_IS_CONTACT(child)) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138 PurpleBlistNode *bnode;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139 purple_blist_add_contact((PurpleContact *)child, dest, prev);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 for (bnode = child->child; bnode != NULL; bnode = bnode->next) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 purple_blist_add_buddy((PurpleBuddy *)bnode, (PurpleContact *)child,
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 NULL, bnode->prev);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143 moved_buddies = g_list_append(moved_buddies, bnode);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 prev = child;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146 } else if (PURPLE_IS_CHAT(child)) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 purple_blist_add_chat((PurpleChat *)child, dest, prev);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148 prev = child;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149 } else {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 purple_debug(PURPLE_DEBUG_ERROR, "blistnodetypes",
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151 "Unknown child type in group %s\n", priv->name);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153 child = next;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156 /* Make a copy of the old group name and then delete the old group */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 old_name = g_strdup(priv->name);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 purple_blist_remove_group(source);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159 source = dest;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 g_free(new_name);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 } else {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 /* A simple rename */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 PurpleBlistNode *cnode, *bnode;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 /* Build a GList of all buddies in this group */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166 for (cnode = PURPLE_BLIST_NODE(source)->child; cnode != NULL; cnode = cnode->next) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167 if (PURPLE_IS_CONTACT(cnode))
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168 for (bnode = cnode->child; bnode != NULL; bnode = bnode->next)
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169 moved_buddies = g_list_append(moved_buddies, bnode);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172 purple_blist_update_groups_cache(source, new_name);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174 old_name = priv->name;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175 priv->name = new_name;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 g_object_notify_by_pspec(G_OBJECT(source), properties[GROUP_PROP_NAME]);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 /* Save our changes */
39676
1e8394d47205 Add list parameter to all buddy list UI ops.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
181 purple_blist_save_node(purple_blist_get_default(),
1e8394d47205 Add list parameter to all buddy list UI ops.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
182 PURPLE_BLIST_NODE(source));
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 /* Update the UI */
39675
583e2ba6e78e Add wrapper functions for some PurpleBlistUiOps.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39665
diff changeset
185 purple_blist_update_node(purple_blist_get_default(),
583e2ba6e78e Add wrapper functions for some PurpleBlistUiOps.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39665
diff changeset
186 PURPLE_BLIST_NODE(source));
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
187
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
188 /* Notify all protocols */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
189 /* TODO: Is this condition needed? Seems like it would always be TRUE */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190 if(old_name && !purple_strequal(priv->name, old_name)) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
191 for (accts = purple_group_get_accounts(source); accts; accts = g_slist_remove(accts, accts->data)) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192 PurpleAccount *account = accts->data;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
193 PurpleConnection *gc = NULL;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194 PurpleProtocol *protocol = NULL;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 GList *l = NULL, *buddies = NULL;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 gc = purple_account_get_connection(account);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199 if(gc)
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200 protocol = purple_connection_get_protocol(gc);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202 if(!protocol)
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203 continue;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205 for(l = moved_buddies; l; l = l->next) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206 PurpleBuddy *buddy = PURPLE_BUDDY(l->data);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208 if(buddy && purple_buddy_get_account(buddy) == account)
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209 buddies = g_list_append(buddies, (PurpleBlistNode *)buddy);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
210 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
211
39759
ea1401483849 Rename *_GET_*_IFACE to more standard *_GET_IFACE.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39676
diff changeset
212 if(PURPLE_PROTOCOL_IMPLEMENTS(protocol, SERVER, rename_group)) {
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213 purple_protocol_server_iface_rename_group(protocol, gc, old_name, source, buddies);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 } else {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215 GList *cur, *groups = NULL;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
216
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217 /* Make a list of what the groups each buddy is in */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218 for(cur = buddies; cur; cur = cur->next) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219 PurpleBlistNode *node = (PurpleBlistNode *)cur->data;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220 groups = g_list_prepend(groups, node->parent->parent);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
222
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223 purple_account_remove_buddies(account, buddies, groups);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224 g_list_free(groups);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225 purple_account_add_buddies(account, buddies, NULL);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
227
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228 g_list_free(buddies);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
229 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
230 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
231 g_list_free(moved_buddies);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
232 g_free(old_name);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
233
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
234 g_object_notify_by_pspec(G_OBJECT(source), properties[GROUP_PROP_NAME]);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
235 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
236
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
237 const char *purple_group_get_name(PurpleGroup *group) {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
238 PurpleGroupPrivate *priv = NULL;
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
239
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
240 g_return_val_if_fail(PURPLE_IS_GROUP(group), NULL);
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
241
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
242 priv = purple_group_get_instance_private(group);
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
243 return priv->name;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
244 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
245
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
246 /******************************************************************************
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
247 * GObject Stuff
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
248 *****************************************************************************/
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
249 /* Set method for GObject properties */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
250 static void
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251 purple_group_set_property(GObject *obj, guint param_id, const GValue *value,
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
252 GParamSpec *pspec)
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
253 {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
254 PurpleGroup *group = PURPLE_GROUP(obj);
39364
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
255 PurpleGroupPrivate *priv = purple_group_get_instance_private(group);
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
256
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
257 switch (param_id) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
258 case GROUP_PROP_NAME:
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
259 if (priv->is_constructed)
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
260 purple_group_set_name(group, g_value_get_string(value));
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
261 else
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
262 priv->name =
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
263 purple_utf8_strip_unprintables(g_value_get_string(value));
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
264 break;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
265 default:
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
266 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
267 break;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
268 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
269 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
270
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
271 /* Get method for GObject properties */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
272 static void
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
273 purple_group_get_property(GObject *obj, guint param_id, GValue *value,
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
274 GParamSpec *pspec)
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
275 {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
276 PurpleGroup *group = PURPLE_GROUP(obj);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
277
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
278 switch (param_id) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
279 case GROUP_PROP_NAME:
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
280 g_value_set_string(value, purple_group_get_name(group));
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
281 break;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
282 default:
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
283 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
284 break;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
285 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
286 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
287
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
288 /* GObject initialization function */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
289 static void
39364
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
290 purple_group_init(PurpleGroup *group) {
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
291 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
292
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
293 /* Called when done constructing */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
294 static void
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
295 purple_group_constructed(GObject *object) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
296 PurpleGroup *group = PURPLE_GROUP(object);
39364
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
297 PurpleGroupPrivate *priv = purple_group_get_instance_private(group);
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
298
39364
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
299 G_OBJECT_CLASS(purple_group_parent_class)->constructed(object);
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
300
39676
1e8394d47205 Add list parameter to all buddy list UI ops.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
301 purple_blist_new_node(purple_blist_get_default(),
1e8394d47205 Add list parameter to all buddy list UI ops.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
302 PURPLE_BLIST_NODE(group));
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
303
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
304 priv->is_constructed = TRUE;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
305 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
306
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
307 /* GObject finalize function */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
308 static void
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
309 purple_group_finalize(GObject *object) {
39364
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
310 PurpleGroupPrivate *priv = purple_group_get_instance_private(
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
311 PURPLE_GROUP(object));
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
312
39364
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
313 g_free(priv->name);
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
314
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
315 G_OBJECT_CLASS(purple_group_parent_class)->finalize(object);
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
316 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
317
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
318 /* Class initializer function */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
319 static void
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
320 purple_group_class_init(PurpleGroupClass *klass) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
321 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
322
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
323 obj_class->finalize = purple_group_finalize;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
324 obj_class->constructed = purple_group_constructed;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
325
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
326 /* Setup properties */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
327 obj_class->get_property = purple_group_get_property;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
328 obj_class->set_property = purple_group_set_property;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
329
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
330 properties[GROUP_PROP_NAME] = g_param_spec_string(
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
331 "name",
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
332 "Name",
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
333 "Name of the group.",
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
334 NULL,
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
335 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
336 );
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
337
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
338 g_object_class_install_properties(obj_class, GROUP_PROP_LAST, properties);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
339 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
340
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
341 PurpleGroup *
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
342 purple_group_new(const char *name) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
343 PurpleGroup *group;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
344
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
345 if (name == NULL || name[0] == '\0')
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
346 name = PURPLE_BLIST_DEFAULT_GROUP_NAME;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
347 if (g_strcmp0(name, "Buddies") == 0)
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
348 name = PURPLE_BLIST_DEFAULT_GROUP_NAME;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
349 if (g_strcmp0(name, _purple_blist_get_localized_default_group_name()) == 0)
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
350 name = PURPLE_BLIST_DEFAULT_GROUP_NAME;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
351
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
352 group = purple_blist_find_group(name);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
353 if (group != NULL)
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
354 return group;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
355
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
356 return g_object_new(PURPLE_TYPE_GROUP, "name", name, NULL);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
357 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
358

mercurial