libpurple/group.c

Thu, 22 Feb 2024 06:03:16 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 22 Feb 2024 06:03:16 -0600
changeset 42596
b64b96f3b781
parent 42594
eddde70cedd8
child 42656
df9aafbae930
permissions
-rw-r--r--

Add a favorite property to PurpleContactInfo

This will be used in the future for toggling whether or not contacts are
favorited or starred.

Testing Done:
Ran the unit tests under valgrind.

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

37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
2 * Purple - Internet Messaging Library
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * Purple is the legal property of its developers, whose names are too numerous
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * source distribution.
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
9 * This library is free software; you can redistribute it and/or modify it
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
10 * under the terms of the GNU General Public License as published by the Free
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
11 * Software Foundation; either version 2 of the License, or (at your option)
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
12 * any later version.
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
14 * This library is distributed in the hope that it will be useful, but WITHOUT
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
17 * more details.
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
19 * You should have received a copy of the GNU General Public License along with
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
20 * this library; if not, see <https://www.gnu.org/licenses/>.
37944
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 #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
24
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 #include "debug.h"
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
26 #include "purpleprivate.h"
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
27 #include "purpleprotocolserver.h"
37944
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 typedef struct _PurpleGroupPrivate PurpleGroupPrivate;
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 /******************************************************************************
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 * Private Data
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 struct _PurpleGroupPrivate {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 char *name; /* The name of this group. */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 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
37 constructed. */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 };
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 /* Group property enums */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 enum
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 {
42584
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41960
diff changeset
43 PROP_0,
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41960
diff changeset
44 PROP_NAME,
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41960
diff changeset
45 N_PROPERTIES,
37944
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
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 * Globals
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 *****************************************************************************/
42584
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41960
diff changeset
51 static GParamSpec *properties[N_PROPERTIES] = {NULL, };
39364
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
52
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
53 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
54 PURPLE_TYPE_COUNTING_NODE);
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55
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 * Group API
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 GSList *purple_group_get_accounts(PurpleGroup *group) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 GSList *l = NULL;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 PurpleBlistNode *gnode, *cnode, *bnode;
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 gnode = (PurpleBlistNode *)group;
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 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
66 if (PURPLE_IS_CHAT(cnode)) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 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
68 l = g_slist_append(l, purple_chat_get_account(PURPLE_CHAT(cnode)));
41733
a9085b52de8b Rename PurpleContact to PurpleMetaContact.
Gary Kramlich <grim@reaperworld.com>
parents: 41685
diff changeset
69 } else if (PURPLE_IS_META_CONTACT(cnode)) {
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 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
71 if (PURPLE_IS_BUDDY(bnode)) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 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
73 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
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 }
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 return l;
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
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 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
83 PurpleBlistNode *cnode;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 for (cnode = ((PurpleBlistNode *)g)->child; cnode; cnode = cnode->next) {
41733
a9085b52de8b Rename PurpleContact to PurpleMetaContact.
Gary Kramlich <grim@reaperworld.com>
parents: 41685
diff changeset
85 if (PURPLE_IS_META_CONTACT(cnode)) {
a9085b52de8b Rename PurpleContact to PurpleMetaContact.
Gary Kramlich <grim@reaperworld.com>
parents: 41685
diff changeset
86 if(purple_meta_contact_on_account((PurpleMetaContact *) cnode, account))
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 return TRUE;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 } else if (PURPLE_IS_CHAT(cnode)) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 PurpleChat *chat = (PurpleChat *)cnode;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 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
91 || purple_chat_get_account(chat) == account)
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 return TRUE;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 }
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 return FALSE;
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
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 * 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
100 */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 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
102 PurpleGroupPrivate *priv = NULL;
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 PurpleGroup *dest;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 gchar *old_name;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 gchar *new_name;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 GList *moved_buddies = NULL;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 GSList *accts;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
109 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
110 g_return_if_fail(name != NULL);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
112 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
113
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114 new_name = purple_utf8_strip_unprintables(name);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 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
117 g_free(new_name);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 return;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 dest = purple_blist_find_group(new_name);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122 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
123 purple_group_get_name(dest)) != 0) {
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124 /* We're merging two groups */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 PurpleBlistNode *prev, *child, *next;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 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
128 child = PURPLE_BLIST_NODE(source)->child;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 /*
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 * 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
132 * 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
133 * 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
134 * each moved buddy...
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 while (child)
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 next = child->next;
41733
a9085b52de8b Rename PurpleContact to PurpleMetaContact.
Gary Kramlich <grim@reaperworld.com>
parents: 41685
diff changeset
139 if (PURPLE_IS_META_CONTACT(child)) {
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 PurpleBlistNode *bnode;
41733
a9085b52de8b Rename PurpleContact to PurpleMetaContact.
Gary Kramlich <grim@reaperworld.com>
parents: 41685
diff changeset
141 purple_blist_add_contact((PurpleMetaContact *)child, dest, prev);
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 for (bnode = child->child; bnode != NULL; bnode = bnode->next) {
41733
a9085b52de8b Rename PurpleContact to PurpleMetaContact.
Gary Kramlich <grim@reaperworld.com>
parents: 41685
diff changeset
143 purple_blist_add_buddy((PurpleBuddy *)bnode, (PurpleMetaContact *)child,
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 NULL, bnode->prev);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 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
146 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 prev = child;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148 } else if (PURPLE_IS_CHAT(child)) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149 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
150 prev = child;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151 } else {
40765
a5381c20e802 Use specific purple_debug_* functions
Arkadiy Illarionov <qarkai@gmail.com>
parents: 40708
diff changeset
152 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
153 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154 child = next;
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
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 /* 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
158 old_name = g_strdup(priv->name);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159 purple_blist_remove_group(source);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 source = dest;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 g_free(new_name);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 } else {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 /* A simple rename */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 PurpleBlistNode *cnode, *bnode;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166 /* 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
167 for (cnode = PURPLE_BLIST_NODE(source)->child; cnode != NULL; cnode = cnode->next) {
41733
a9085b52de8b Rename PurpleContact to PurpleMetaContact.
Gary Kramlich <grim@reaperworld.com>
parents: 41685
diff changeset
168 if (PURPLE_IS_META_CONTACT(cnode))
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169 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
170 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
171 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173 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
174
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175 old_name = priv->name;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176 priv->name = new_name;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177
42584
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41960
diff changeset
178 g_object_notify_by_pspec(G_OBJECT(source), properties[PROP_NAME]);
37944
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
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181 /* 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
182 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
183 PURPLE_BLIST_NODE(source));
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185 /* Update the UI */
39675
583e2ba6e78e Add wrapper functions for some PurpleBlistUiOps.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39665
diff changeset
186 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
187 PURPLE_BLIST_NODE(source));
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
188
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
189 /* Notify all protocols */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190 /* 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
191 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
192 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
193 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
194 PurpleAccount *account = accts->data;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 PurpleConnection *gc = NULL;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196 PurpleProtocol *protocol = NULL;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 GList *l = NULL, *buddies = NULL;
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 gc = purple_account_get_connection(account);
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 if(gc)
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202 protocol = purple_connection_get_protocol(gc);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204 if(!protocol)
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205 continue;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207 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
208 PurpleBuddy *buddy = PURPLE_BUDDY(l->data);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
210 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
211 buddies = g_list_append(buddies, (PurpleBlistNode *)buddy);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
212 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213
39759
ea1401483849 Rename *_GET_*_IFACE to more standard *_GET_IFACE.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39676
diff changeset
214 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
215 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
216 gc, old_name, source,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
217 buddies);
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218 } else {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219 GList *cur, *groups = NULL;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221 /* 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
222 for(cur = buddies; cur; cur = cur->next) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223 PurpleBlistNode *node = (PurpleBlistNode *)cur->data;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224 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
225 }
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 purple_account_remove_buddies(account, buddies, groups);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228 g_list_free(groups);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
229 purple_account_add_buddies(account, buddies, NULL);
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
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
232 g_list_free(buddies);
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 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
235 g_list_free(moved_buddies);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
236 g_free(old_name);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
237
42584
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41960
diff changeset
238 g_object_notify_by_pspec(G_OBJECT(source), properties[PROP_NAME]);
37944
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
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
241 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
242 PurpleGroupPrivate *priv = NULL;
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
243
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
244 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
245
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39759
diff changeset
246 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
247 return priv->name;
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
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 * GObject Stuff
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 /* Set method for GObject properties */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
254 static void
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
255 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
256 GParamSpec *pspec)
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
257 {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
258 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
259 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
260
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
261 switch (param_id) {
42584
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41960
diff changeset
262 case PROP_NAME:
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
263 if (priv->is_constructed)
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
264 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
265 else
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
266 priv->name =
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
267 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
268 break;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
269 default:
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
270 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
271 break;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
272 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
273 }
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 /* Get method for GObject properties */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
276 static void
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
277 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
278 GParamSpec *pspec)
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
279 {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
280 PurpleGroup *group = PURPLE_GROUP(obj);
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 switch (param_id) {
42584
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41960
diff changeset
283 case PROP_NAME:
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
284 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
285 break;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
286 default:
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
287 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
288 break;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
289 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
290 }
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 /* GObject initialization function */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
293 static void
41960
c8a4853205e3 Bump C standard to C99 for libpurple files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41733
diff changeset
294 purple_group_init(G_GNUC_UNUSED PurpleGroup *group) {
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
295 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
296
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
297 /* Called when done constructing */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
298 static void
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
299 purple_group_constructed(GObject *object) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
300 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
301 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
302
39364
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
303 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
304
39676
1e8394d47205 Add list parameter to all buddy list UI ops.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
305 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
306 PURPLE_BLIST_NODE(group));
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
307
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
308 priv->is_constructed = TRUE;
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
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
311 /* GObject finalize function */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
312 static void
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
313 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
314 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
315 PURPLE_GROUP(object));
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
316
39364
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
317 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
318
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
319 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
320 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
321
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
322 /* Class initializer function */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
323 static void
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
324 purple_group_class_init(PurpleGroupClass *klass) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
325 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
326
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
327 obj_class->finalize = purple_group_finalize;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
328 obj_class->constructed = purple_group_constructed;
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 /* Setup properties */
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
331 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
332 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
333
42584
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41960
diff changeset
334 properties[PROP_NAME] = g_param_spec_string(
37944
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
335 "name",
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
336 "Name",
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
337 "Name of the group.",
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
338 NULL,
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
339 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
340 );
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
341
42584
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41960
diff changeset
342 g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
37944
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
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
345 PurpleGroup *
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
346 purple_group_new(const char *name) {
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
347 PurpleGroup *group;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
348
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
349 if (name == NULL || name[0] == '\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 if (g_strcmp0(name, "Buddies") == 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, _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
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
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
356 group = purple_blist_find_group(name);
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
357 if (group != NULL)
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
358 return group;
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
359
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
360 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
361 }
e42e19eba593 Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
362

mercurial