Fri, 12 Aug 2016 16:27:33 -0500
Pull PurpleGroup out into it's own files
|
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 "dbus-maybe.h" |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
25 | #include "group.h" |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
26 | #include "internal.h" /* TODO: we need to kill this */ |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
28 | #define PURPLE_GROUP_GET_PRIVATE(obj) \ |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
29 | (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_GROUP, 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 | 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]; |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
54 | static GObjectClass *parent_class = NULL; |
|
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))); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
69 | } else if (PURPLE_IS_CONTACT(cnode)) { |
|
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) { |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
85 | if (PURPLE_IS_CONTACT(cnode)) { |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
86 | 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
|
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) { |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
102 | PurpleBlistUiOps *ops = purple_blist_get_ui_ops(); |
|
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 | PurpleGroupPrivate *priv = PURPLE_GROUP_GET_PRIVATE(source); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
109 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
110 | g_return_if_fail(priv != NULL); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
111 | g_return_if_fail(name != NULL); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
112 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
113 | new_name = purple_utf8_strip_unprintables(name); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
114 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
115 | 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
|
116 | g_free(new_name); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
117 | return; |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
118 | } |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
119 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
120 | dest = purple_blist_find_group(new_name); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
121 | if (dest != NULL && purple_utf8_strcasecmp(priv->name, |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
122 | PURPLE_GROUP_GET_PRIVATE(dest)->name) != 0) { |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
123 | /* We're merging two groups */ |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
124 | PurpleBlistNode *prev, *child, *next; |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
125 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
126 | 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
|
127 | child = PURPLE_BLIST_NODE(source)->child; |
|
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 | /* |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
130 | * 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
|
131 | * 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
|
132 | * 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
|
133 | * each moved buddy... |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
134 | */ |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
135 | while (child) |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
136 | { |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
137 | next = child->next; |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
138 | if (PURPLE_IS_CONTACT(child)) { |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
139 | PurpleBlistNode *bnode; |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
140 | 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
|
141 | 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
|
142 | 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
|
143 | NULL, bnode->prev); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
144 | 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
|
145 | } |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
146 | prev = child; |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
147 | } else if (PURPLE_IS_CHAT(child)) { |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
148 | 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
|
149 | prev = child; |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
150 | } else { |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
151 | purple_debug(PURPLE_DEBUG_ERROR, "blistnodetypes", |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
152 | "Unknown child type in group %s\n", priv->name); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
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) { |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
168 | if (PURPLE_IS_CONTACT(cnode)) |
|
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 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
178 | 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
|
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 */ |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
182 | if (ops && ops->save_node) |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
183 | ops->save_node(PURPLE_BLIST_NODE(source)); |
|
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 */ |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
186 | if (ops && ops->update) |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
187 | ops->update(purple_blist_get_buddy_list(), PURPLE_BLIST_NODE(source)); |
|
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)) { |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
192 | for (accts = purple_group_get_accounts(source); accts; accts = g_slist_remove(accts, accts->data)) { |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
193 | PurpleAccount *account = accts->data; |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
194 | PurpleConnection *gc = NULL; |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
195 | PurpleProtocol *protocol = NULL; |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
196 | GList *l = NULL, *buddies = NULL; |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
197 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
198 | gc = purple_account_get_connection(account); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
199 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
200 | if(gc) |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
201 | protocol = purple_connection_get_protocol(gc); |
|
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(!protocol) |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
204 | continue; |
|
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 | 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
|
207 | PurpleBuddy *buddy = PURPLE_BUDDY(l->data); |
|
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 | 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
|
210 | buddies = g_list_append(buddies, (PurpleBlistNode *)buddy); |
|
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 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
213 | if(PURPLE_PROTOCOL_IMPLEMENTS(protocol, SERVER_IFACE, rename_group)) { |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
214 | purple_protocol_server_iface_rename_group(protocol, gc, old_name, source, buddies); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
215 | } else { |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
216 | GList *cur, *groups = NULL; |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
217 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
218 | /* 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
|
219 | for(cur = buddies; cur; cur = cur->next) { |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
220 | PurpleBlistNode *node = (PurpleBlistNode *)cur->data; |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
221 | 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
|
222 | } |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
223 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
224 | purple_account_remove_buddies(account, buddies, groups); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
225 | g_list_free(groups); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
226 | purple_account_add_buddies(account, buddies, NULL); |
|
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 | g_list_free(buddies); |
|
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(moved_buddies); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
233 | g_free(old_name); |
|
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_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
|
236 | } |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
237 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
238 | const char *purple_group_get_name(PurpleGroup *group) { |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
239 | PurpleGroupPrivate *priv = PURPLE_GROUP_GET_PRIVATE(group); |
|
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 | g_return_val_if_fail(priv != NULL, NULL); |
|
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 | return priv->name; |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
244 | } |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
245 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
246 | /****************************************************************************** |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
247 | * GObject Stuff |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
248 | *****************************************************************************/ |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
249 | /* Set method for GObject properties */ |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
250 | static void |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
251 | purple_group_set_property(GObject *obj, guint param_id, const GValue *value, |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
252 | GParamSpec *pspec) |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
253 | { |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
254 | PurpleGroup *group = PURPLE_GROUP(obj); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
255 | PurpleGroupPrivate *priv = PURPLE_GROUP_GET_PRIVATE(group); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
256 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
257 | switch (param_id) { |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
258 | case GROUP_PROP_NAME: |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
259 | if (priv->is_constructed) |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
260 | purple_group_set_name(group, g_value_get_string(value)); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
261 | else |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
262 | priv->name = |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
263 | purple_utf8_strip_unprintables(g_value_get_string(value)); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
264 | break; |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
265 | default: |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
266 | G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
267 | break; |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
268 | } |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
269 | } |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
270 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
271 | /* Get method for GObject properties */ |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
272 | static void |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
273 | purple_group_get_property(GObject *obj, guint param_id, GValue *value, |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
274 | GParamSpec *pspec) |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
275 | { |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
276 | PurpleGroup *group = PURPLE_GROUP(obj); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
277 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
278 | switch (param_id) { |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
279 | case GROUP_PROP_NAME: |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
280 | g_value_set_string(value, purple_group_get_name(group)); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
281 | break; |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
282 | default: |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
283 | G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
284 | break; |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
285 | } |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
286 | } |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
287 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
288 | /* GObject initialization function */ |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
289 | static void |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
290 | purple_group_init(GTypeInstance *instance, gpointer klass) { |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
291 | PURPLE_DBUS_REGISTER_POINTER(PURPLE_GROUP(instance), PurpleGroup); |
|
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 | /* Called when done constructing */ |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
295 | static void |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
296 | purple_group_constructed(GObject *object) { |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
297 | PurpleGroup *group = PURPLE_GROUP(object); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
298 | PurpleGroupPrivate *priv = PURPLE_GROUP_GET_PRIVATE(group); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
299 | PurpleBlistUiOps *ops = purple_blist_get_ui_ops(); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
300 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
301 | G_OBJECT_CLASS(parent_class)->constructed(object); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
302 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
303 | if (ops && ops->new_node) |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
304 | ops->new_node(PURPLE_BLIST_NODE(group)); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
305 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
306 | priv->is_constructed = TRUE; |
|
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 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
309 | /* GObject finalize function */ |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
310 | static void |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
311 | purple_group_finalize(GObject *object) { |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
312 | g_free(PURPLE_GROUP_GET_PRIVATE(object)->name); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
313 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
314 | PURPLE_DBUS_UNREGISTER_POINTER(object); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
315 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
316 | G_OBJECT_CLASS(parent_class)->finalize(object); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
317 | } |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
318 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
319 | /* Class initializer function */ |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
320 | static void |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
321 | purple_group_class_init(PurpleGroupClass *klass) { |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
322 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
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 | parent_class = g_type_class_peek_parent(klass); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
325 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
326 | obj_class->finalize = purple_group_finalize; |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
327 | obj_class->constructed = purple_group_constructed; |
|
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 | /* Setup properties */ |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
330 | 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
|
331 | 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
|
332 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
333 | g_type_class_add_private(klass, sizeof(PurpleGroupPrivate)); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
334 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
335 | 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
|
336 | "name", |
|
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 of the group.", |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
339 | NULL, |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
340 | 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
|
341 | ); |
|
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 | 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
|
344 | } |
|
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 | GType |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
347 | purple_group_get_type(void) { |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
348 | static GType type = 0; |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
349 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
350 | if(type == 0) { |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
351 | static const GTypeInfo info = { |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
352 | sizeof(PurpleGroupClass), |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
353 | NULL, |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
354 | NULL, |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
355 | (GClassInitFunc)purple_group_class_init, |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
356 | NULL, |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
357 | NULL, |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
358 | sizeof(PurpleGroup), |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
359 | 0, |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
360 | (GInstanceInitFunc)purple_group_init, |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
361 | NULL, |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
362 | }; |
|
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 | type = g_type_register_static(PURPLE_TYPE_COUNTING_NODE, |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
365 | "PurpleGroup", |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
366 | &info, 0); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
367 | } |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
368 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
369 | return type; |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
370 | } |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
371 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
372 | PurpleGroup * |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
373 | purple_group_new(const char *name) { |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
374 | PurpleGroup *group; |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
375 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
376 | if (name == NULL || name[0] == '\0') |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
377 | name = PURPLE_BLIST_DEFAULT_GROUP_NAME; |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
378 | if (g_strcmp0(name, "Buddies") == 0) |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
379 | name = PURPLE_BLIST_DEFAULT_GROUP_NAME; |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
380 | 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
|
381 | name = PURPLE_BLIST_DEFAULT_GROUP_NAME; |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
382 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
383 | group = purple_blist_find_group(name); |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
384 | if (group != NULL) |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
385 | return group; |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
386 | |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
387 | 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
|
388 | } |
|
e42e19eba593
Pull PurpleGroup out into it's own files
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
389 |