libpurple/group.c

Thu, 25 Aug 2022 21:34:53 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 25 Aug 2022 21:34:53 -0500
branch
gtk4
changeset 41591
ad6f5ffc2825
parent 40870
e3397381fd35
child 41685
ca22b00972d4
permissions
-rw-r--r--

Port the invite dialog to GTK4

Testing Done:
Opened the dialog via conversations -> invite and made sure it worked as expected.

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

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"
40870
e3397381fd35 Remove includes from protocol.h that weren't used there and deal with the fallout
Gary Kramlich <grim@reaperworld.com>
parents: 40765
diff changeset
25
e3397381fd35 Remove includes from protocol.h that weren't used there and deal with the fallout
Gary Kramlich <grim@reaperworld.com>
parents: 40765
diff changeset
26 #include "debug.h"
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 #include "internal.h" /* TODO: we need to kill this */
40439
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40079
diff changeset
28 #include "purpleprivate.h"
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
29 #include "purpleprotocolserver.h"
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 typedef struct _PurpleGroupPrivate PurpleGroupPrivate;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 /******************************************************************************
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 * Private Data
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 *****************************************************************************/
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 struct _PurpleGroupPrivate {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 char *name; /* The name of this group. */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 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
39 constructed. */
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
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 /* Group property enums */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 enum
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 GROUP_PROP_0,
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 GROUP_PROP_NAME,
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 GROUP_PROP_LAST
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
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 /******************************************************************************
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 * Globals
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 *****************************************************************************/
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 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
54
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
55 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
56 PURPLE_TYPE_COUNTING_NODE);
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 /******************************************************************************
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 * Group API
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 GSList *purple_group_get_accounts(PurpleGroup *group) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 GSList *l = NULL;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 PurpleBlistNode *gnode, *cnode, *bnode;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 gnode = (PurpleBlistNode *)group;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 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
68 if (PURPLE_IS_CHAT(cnode)) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 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
70 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
71 } else if (PURPLE_IS_CONTACT(cnode)) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 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
73 if (PURPLE_IS_BUDDY(bnode)) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 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
75 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
76 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 }
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
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 return l;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 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
85 PurpleBlistNode *cnode;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 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
87 if (PURPLE_IS_CONTACT(cnode)) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 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
89 return TRUE;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 } else if (PURPLE_IS_CHAT(cnode)) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 PurpleChat *chat = (PurpleChat *)cnode;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 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
93 || purple_chat_get_account(chat) == account)
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 return TRUE;
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 return FALSE;
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
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 /*
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 * 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
102 */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 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
104 PurpleGroupPrivate *priv = NULL;
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 PurpleGroup *dest;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 gchar *old_name;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 gchar *new_name;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 GList *moved_buddies = NULL;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 GSList *accts;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
111 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
112 g_return_if_fail(name != NULL);
e42e19eba593 Pull PurpleGroup out into it's own files
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: 39759
diff changeset
114 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
115
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 new_name = purple_utf8_strip_unprintables(name);
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 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
119 g_free(new_name);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 return;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 dest = purple_blist_find_group(new_name);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124 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
125 purple_group_get_name(dest)) != 0) {
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 /* We're merging two groups */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 PurpleBlistNode *prev, *child, *next;
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 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
130 child = PURPLE_BLIST_NODE(source)->child;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132 /*
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133 * 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
134 * 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
135 * 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
136 * each moved buddy...
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138 while (child)
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139 {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 next = child->next;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 if (PURPLE_IS_CONTACT(child)) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 PurpleBlistNode *bnode;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143 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
144 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
145 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
146 NULL, bnode->prev);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 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
148 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149 prev = child;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 } else if (PURPLE_IS_CHAT(child)) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151 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
152 prev = child;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153 } else {
40765
a5381c20e802 Use specific purple_debug_* functions
Arkadiy Illarionov <qarkai@gmail.com>
parents: 40708
diff changeset
154 purple_debug_error("blistnodetypes", "Unknown child type in group %s", priv->name);
37944
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 child = next;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159 /* 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
160 old_name = g_strdup(priv->name);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 purple_blist_remove_group(source);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 source = dest;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 g_free(new_name);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 } else {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 /* A simple rename */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166 PurpleBlistNode *cnode, *bnode;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168 /* 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
169 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
170 if (PURPLE_IS_CONTACT(cnode))
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171 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
172 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
173 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175 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
176
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 old_name = priv->name;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 priv->name = new_name;
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 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
181 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 /* 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
184 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
185 PURPLE_BLIST_NODE(source));
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
187 /* Update the UI */
39675
583e2ba6e78e Add wrapper functions for some PurpleBlistUiOps.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39665
diff changeset
188 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
189 PURPLE_BLIST_NODE(source));
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
191 /* Notify all protocols */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192 /* 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
193 if(old_name && !purple_strequal(priv->name, old_name)) {
40079
a37a1e349491 Replace g_[s]list_remove with g_[s]list_delete_link.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39782
diff changeset
194 for (accts = purple_group_get_accounts(source); accts;
a37a1e349491 Replace g_[s]list_remove with g_[s]list_delete_link.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39782
diff changeset
195 accts = g_slist_delete_link(accts, accts)) {
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196 PurpleAccount *account = accts->data;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 PurpleConnection *gc = NULL;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198 PurpleProtocol *protocol = NULL;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199 GList *l = NULL, *buddies = NULL;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201 gc = purple_account_get_connection(account);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203 if(gc)
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204 protocol = purple_connection_get_protocol(gc);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206 if(!protocol)
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207 continue;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209 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
210 PurpleBuddy *buddy = PURPLE_BUDDY(l->data);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
211
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
212 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
213 buddies = g_list_append(buddies, (PurpleBlistNode *)buddy);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215
39759
ea1401483849 Rename *_GET_*_IFACE to more standard *_GET_IFACE.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39676
diff changeset
216 if(PURPLE_PROTOCOL_IMPLEMENTS(protocol, SERVER, rename_group)) {
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
217 purple_protocol_server_rename_group(PURPLE_PROTOCOL_SERVER(protocol),
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
218 gc, old_name, source,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
219 buddies);
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220 } else {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221 GList *cur, *groups = NULL;
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 /* 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
224 for(cur = buddies; cur; cur = cur->next) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225 PurpleBlistNode *node = (PurpleBlistNode *)cur->data;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 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
227 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
229 purple_account_remove_buddies(account, buddies, groups);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
230 g_list_free(groups);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
231 purple_account_add_buddies(account, buddies, NULL);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
232 }
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_list_free(buddies);
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 g_list_free(moved_buddies);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
238 g_free(old_name);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
239
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
240 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
241 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
242
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
243 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
244 PurpleGroupPrivate *priv = NULL;
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
245
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
246 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
247
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
248 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
249 return priv->name;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
250 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
252 /******************************************************************************
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
253 * GObject Stuff
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
254 *****************************************************************************/
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
255 /* Set method for GObject properties */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
256 static void
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
257 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
258 GParamSpec *pspec)
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
259 {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
260 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
261 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
262
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
263 switch (param_id) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
264 case GROUP_PROP_NAME:
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
265 if (priv->is_constructed)
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
266 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
267 else
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
268 priv->name =
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
269 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
270 break;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
271 default:
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
272 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
273 break;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
274 }
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
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
277 /* Get method for GObject properties */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
278 static void
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
279 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
280 GParamSpec *pspec)
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
281 {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
282 PurpleGroup *group = PURPLE_GROUP(obj);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
283
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
284 switch (param_id) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
285 case GROUP_PROP_NAME:
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
286 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
287 break;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
288 default:
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
289 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
290 break;
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
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
294 /* GObject initialization function */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
295 static void
39364
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
296 purple_group_init(PurpleGroup *group) {
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
297 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
298
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
299 /* Called when done constructing */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
300 static void
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
301 purple_group_constructed(GObject *object) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
302 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
303 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
304
39364
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
305 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
306
39676
1e8394d47205 Add list parameter to all buddy list UI ops.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
307 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
308 PURPLE_BLIST_NODE(group));
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
309
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
310 priv->is_constructed = TRUE;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
311 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
312
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
313 /* GObject finalize function */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
314 static void
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
315 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
316 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
317 PURPLE_GROUP(object));
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
318
39364
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
319 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
320
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
321 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
322 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
323
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
324 /* Class initializer function */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
325 static void
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
326 purple_group_class_init(PurpleGroupClass *klass) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
327 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
328
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
329 obj_class->finalize = purple_group_finalize;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
330 obj_class->constructed = purple_group_constructed;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
331
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
332 /* Setup properties */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
333 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
334 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
335
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
336 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
337 "name",
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
338 "Name",
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
339 "Name of the group.",
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
340 NULL,
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
341 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
342 );
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
343
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
344 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
345 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
346
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
347 PurpleGroup *
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
348 purple_group_new(const char *name) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
349 PurpleGroup *group;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
350
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
351 if (name == NULL || name[0] == '\0')
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
352 name = PURPLE_BLIST_DEFAULT_GROUP_NAME;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
353 if (g_strcmp0(name, "Buddies") == 0)
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
354 name = PURPLE_BLIST_DEFAULT_GROUP_NAME;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
355 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
356 name = PURPLE_BLIST_DEFAULT_GROUP_NAME;
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 group = purple_blist_find_group(name);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
359 if (group != NULL)
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
360 return group;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
361
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
362 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
363 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
364

mercurial