libpurple/contact.c

Wed, 30 Aug 2017 20:33:01 -0300

author
dx <dx@dxzone.com.ar>
date
Wed, 30 Aug 2017 20:33:01 -0300
changeset 38648
9ff9acf9fa14
parent 37946
4318acee8ac6
child 39352
62bca2fe2e91
permissions
-rw-r--r--

facebook: Fix "Failed to read thrift" with unknown fields in /t_p payload

>Login error: Failed to read thrift: facebook-api.c:1815
>fb_api_cb_publish_pt: assertion 'FALSE' failed

37946
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * purple
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 *
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * source distribution.
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 *
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * (at your option) any later version.
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 *
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * GNU General Public License for more details.
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 *
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 *
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22 */
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24 #include "contact.h"
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 #include "dbus-maybe.h"
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 #include "internal.h" /* TODO: this needs to die */
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 #include "util.h"
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 #define PURPLE_CONTACT_GET_PRIVATE(obj) \
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_CONTACT, PurpleContactPrivate))
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 typedef struct _PurpleContactPrivate PurpleContactPrivate;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 struct _PurpleContactPrivate {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 char *alias; /* The user-set alias of the contact */
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 PurpleBuddy *priority_buddy; /* The "top" buddy for this contact */
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 gboolean priority_valid; /* Is priority valid? */
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 };
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 enum
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 PROP_0,
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 PROP_ALIAS,
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 PROP_PRIORITY_BUDDY,
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 PROP_LAST
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 };
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 /******************************************************************************
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 * Globals
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 *****************************************************************************/
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 static GObjectClass *parent_class = NULL;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 static GParamSpec *properties[PROP_LAST];
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 /******************************************************************************
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 * API
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 *****************************************************************************/
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 static void
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 purple_contact_compute_priority_buddy(PurpleContact *contact) {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 PurpleBlistNode *bnode;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 PurpleBuddy *new_priority = NULL;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 PurpleContactPrivate *priv = PURPLE_CONTACT_GET_PRIVATE(contact);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 g_return_if_fail(priv != NULL);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 priv->priority_buddy = NULL;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 for (bnode = PURPLE_BLIST_NODE(contact)->child;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 bnode != NULL;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 bnode = bnode->next)
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 PurpleBuddy *buddy;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 if (!PURPLE_IS_BUDDY(bnode))
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 continue;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 buddy = PURPLE_BUDDY(bnode);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 if (new_priority == NULL)
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 new_priority = buddy;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 continue;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 if (purple_account_is_connected(purple_buddy_get_account(buddy)))
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 int cmp = 1;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 if (purple_account_is_connected(purple_buddy_get_account(new_priority)))
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 cmp = purple_buddy_presence_compare(
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 PURPLE_BUDDY_PRESENCE(purple_buddy_get_presence(new_priority)),
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 PURPLE_BUDDY_PRESENCE(purple_buddy_get_presence(buddy)));
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 if (cmp > 0 || (cmp == 0 &&
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 purple_prefs_get_bool("/purple/contact/last_match")))
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 new_priority = buddy;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 priv->priority_buddy = new_priority;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 priv->priority_valid = TRUE;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 g_object_notify_by_pspec(G_OBJECT(contact),
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 properties[PROP_PRIORITY_BUDDY]);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 PurpleGroup *
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 purple_contact_get_group(const PurpleContact *contact)
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 g_return_val_if_fail(PURPLE_IS_CONTACT(contact), NULL);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110 return PURPLE_GROUP(PURPLE_BLIST_NODE(contact)->parent);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 void
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114 purple_contact_set_alias(PurpleContact *contact, const char *alias)
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 PurpleBlistUiOps *ops = purple_blist_get_ui_ops();
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 PurpleIMConversation *im;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 PurpleBlistNode *bnode;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 char *old_alias;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 char *new_alias = NULL;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 PurpleContactPrivate *priv = PURPLE_CONTACT_GET_PRIVATE(contact);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 g_return_if_fail(priv != NULL);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 if ((alias != NULL) && (*alias != '\0'))
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 new_alias = purple_utf8_strip_unprintables(alias);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 if (!purple_strequal(priv->alias, new_alias)) {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129 g_free(new_alias);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 return;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133 old_alias = priv->alias;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 if ((new_alias != NULL) && (*new_alias != '\0'))
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136 priv->alias = new_alias;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 else {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138 priv->alias = NULL;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139 g_free(new_alias); /* could be "\0" */
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 g_object_notify_by_pspec(G_OBJECT(contact),
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143 properties[PROP_ALIAS]);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 if (ops) {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146 if (ops->save_node)
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 ops->save_node(PURPLE_BLIST_NODE(contact));
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148 if (ops->update)
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149 ops->update(purple_blist_get_buddy_list(), PURPLE_BLIST_NODE(contact));
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152 for(bnode = PURPLE_BLIST_NODE(contact)->child; bnode != NULL; bnode = bnode->next)
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153 {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154 PurpleBuddy *buddy = PURPLE_BUDDY(bnode);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156 im = purple_conversations_find_im_with_account(purple_buddy_get_name(buddy),
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 purple_buddy_get_account(buddy));
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 if (im)
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159 purple_conversation_autoset_title(PURPLE_CONVERSATION(im));
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 purple_signal_emit(purple_blist_get_handle(), "blist-node-aliased",
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 contact, old_alias);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 g_free(old_alias);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167 const char *purple_contact_get_alias(PurpleContact* contact)
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168 {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169 PurpleContactPrivate *priv = PURPLE_CONTACT_GET_PRIVATE(contact);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171 g_return_val_if_fail(priv != NULL, NULL);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173 if (priv->alias)
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174 return priv->alias;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176 return purple_buddy_get_alias(purple_contact_get_priority_buddy(contact));
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179 gboolean purple_contact_on_account(PurpleContact *c, PurpleAccount *account)
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181 PurpleBlistNode *bnode, *cnode = (PurpleBlistNode *) c;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 g_return_val_if_fail(PURPLE_IS_CONTACT(c), FALSE);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), FALSE);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186 for (bnode = cnode->child; bnode; bnode = bnode->next) {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
187 PurpleBuddy *buddy;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
188
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
189 if (! PURPLE_IS_BUDDY(bnode))
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190 continue;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
191
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192 buddy = (PurpleBuddy *)bnode;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
193 if (purple_buddy_get_account(buddy) == account)
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194 return TRUE;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196 return FALSE;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199 void purple_contact_invalidate_priority_buddy(PurpleContact *contact)
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200 {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201 PurpleContactPrivate *priv = PURPLE_CONTACT_GET_PRIVATE(contact);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203 g_return_if_fail(priv != NULL);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205 priv->priority_valid = FALSE;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208 PurpleBuddy *purple_contact_get_priority_buddy(PurpleContact *contact)
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209 {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
210 PurpleContactPrivate *priv = PURPLE_CONTACT_GET_PRIVATE(contact);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
211
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
212 g_return_val_if_fail(priv != NULL, NULL);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 if (!priv->priority_valid)
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215 purple_contact_compute_priority_buddy(contact);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
216
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217 return priv->priority_buddy;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220 void purple_contact_merge(PurpleContact *source, PurpleBlistNode *node)
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221 {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
222 PurpleBlistNode *sourcenode = (PurpleBlistNode*)source;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223 PurpleBlistNode *prev, *cur, *next;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224 PurpleContact *target;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 g_return_if_fail(PURPLE_IS_CONTACT(source));
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
227 g_return_if_fail(PURPLE_IS_BLIST_NODE(node));
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
229 if (PURPLE_IS_CONTACT(node)) {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
230 target = (PurpleContact *)node;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
231 prev = _purple_blist_get_last_child(node);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
232 } else if (PURPLE_IS_BUDDY(node)) {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
233 target = (PurpleContact *)node->parent;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
234 prev = node;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
235 } else {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
236 return;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
237 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
238
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
239 if (source == target || !target)
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
240 return;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
241
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
242 next = sourcenode->child;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
243
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
244 while (next) {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
245 cur = next;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
246 next = cur->next;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
247 if (PURPLE_IS_BUDDY(cur)) {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
248 purple_blist_add_buddy((PurpleBuddy *)cur, target, NULL, prev);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
249 prev = cur;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
250 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
252 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
253
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
254 /**************************************************************************
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
255 * GObject Stuff
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
256 **************************************************************************/
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
257 /* Set method for GObject properties */
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
258 static void
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
259 purple_contact_set_property(GObject *obj, guint param_id, const GValue *value,
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
260 GParamSpec *pspec)
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
261 {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
262 PurpleContact *contact = PURPLE_CONTACT(obj);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
263
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
264 switch (param_id) {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
265 case PROP_ALIAS:
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
266 purple_contact_set_alias(contact, g_value_get_string(value));
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
267 break;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
268 default:
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
269 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
270 break;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
271 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
272 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
273
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
274 /* Get method for GObject properties */
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
275 static void
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
276 purple_contact_get_property(GObject *obj, guint param_id, GValue *value,
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
277 GParamSpec *pspec)
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
278 {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
279 PurpleContact *contact = PURPLE_CONTACT(obj);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
280 PurpleContactPrivate *priv = PURPLE_CONTACT_GET_PRIVATE(contact);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
281
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
282 switch (param_id) {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
283 case PROP_ALIAS:
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
284 g_value_set_string(value, priv->alias);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
285 break;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
286 case PROP_PRIORITY_BUDDY:
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
287 g_value_set_object(value, purple_contact_get_priority_buddy(contact));
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
288 break;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
289 default:
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
290 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
291 break;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
292 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
293 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
294
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
295 /* GObject initialization function */
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
296 static void
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
297 purple_contact_init(GTypeInstance *instance, gpointer klass)
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
298 {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
299 PurpleContact *contact = PURPLE_CONTACT(instance);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
300 PurpleBlistUiOps *ops = purple_blist_get_ui_ops();
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
301
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
302 if (ops && ops->new_node)
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
303 ops->new_node(PURPLE_BLIST_NODE(contact));
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
304
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
305 PURPLE_DBUS_REGISTER_POINTER(contact, PurpleContact);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
306 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
307
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
308 /* GObject finalize function */
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
309 static void
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
310 purple_contact_finalize(GObject *object)
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
311 {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
312 g_free(PURPLE_CONTACT_GET_PRIVATE(object)->alias);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
313
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
314 PURPLE_DBUS_UNREGISTER_POINTER(object);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
315
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
316 G_OBJECT_CLASS(parent_class)->finalize(object);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
317 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
318
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
319 /* Class initializer function */
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
320 static void purple_contact_class_init(PurpleContactClass *klass)
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
321 {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
322 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
323
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
324 parent_class = g_type_class_peek_parent(klass);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
325
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
326 obj_class->finalize = purple_contact_finalize;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
327
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
328 /* Setup properties */
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
329 obj_class->get_property = purple_contact_get_property;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
330 obj_class->set_property = purple_contact_set_property;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
331
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
332 g_type_class_add_private(klass, sizeof(PurpleContactPrivate));
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
333
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
334 properties[PROP_ALIAS] = g_param_spec_string(
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
335 "alias",
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
336 "Alias",
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
337 "The alias for the contact.",
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
338 NULL,
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
339 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
340 );
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
341
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
342 properties[PROP_PRIORITY_BUDDY] = g_param_spec_object(
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
343 "priority-buddy",
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
344 "Priority buddy",
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
345 "The priority buddy of the contact.",
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
346 PURPLE_TYPE_BUDDY,
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
347 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
348 );
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
349
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
350 g_object_class_install_properties(obj_class, PROP_LAST, properties);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
351 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
352
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
353 GType
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
354 purple_contact_get_type(void)
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
355 {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
356 static GType type = 0;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
357
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
358 if(type == 0) {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
359 static const GTypeInfo info = {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
360 sizeof(PurpleContactClass),
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
361 NULL,
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
362 NULL,
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
363 (GClassInitFunc)purple_contact_class_init,
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
364 NULL,
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
365 NULL,
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
366 sizeof(PurpleContact),
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
367 0,
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
368 (GInstanceInitFunc)purple_contact_init,
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
369 NULL,
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
370 };
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
371
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
372 type = g_type_register_static(
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
373 PURPLE_TYPE_COUNTING_NODE,
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
374 "PurpleContact",
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
375 &info,
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
376 0
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
377 );
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
378 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
379
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
380 return type;
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
381 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
382
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
383 PurpleContact *
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
384 purple_contact_new(void)
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
385 {
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
386 return g_object_new(PURPLE_TYPE_CONTACT, NULL);
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
387 }
4318acee8ac6 Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
388

mercurial