Tue, 02 Oct 2018 16:01:52 -0500
libpurple: Remove pointer registration for DBus API
|
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 "internal.h" /* TODO: this needs to die */ |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
26 | #include "util.h" |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
28 | #define PURPLE_CONTACT_GET_PRIVATE(obj) \ |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
29 | (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
|
30 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
31 | typedef struct _PurpleContactPrivate PurpleContactPrivate; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
32 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
33 | struct _PurpleContactPrivate { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
34 | 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
|
35 | 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
|
36 | gboolean priority_valid; /* Is priority valid? */ |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
37 | }; |
|
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 | enum |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
40 | { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
41 | PROP_0, |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
42 | PROP_ALIAS, |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
43 | PROP_PRIORITY_BUDDY, |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
44 | PROP_LAST |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
45 | }; |
|
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 | * Globals |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
49 | *****************************************************************************/ |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
50 | static GObjectClass *parent_class = NULL; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
51 | static GParamSpec *properties[PROP_LAST]; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
52 | |
|
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 | * API |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
55 | *****************************************************************************/ |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
56 | static void |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
57 | purple_contact_compute_priority_buddy(PurpleContact *contact) { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
58 | PurpleBlistNode *bnode; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
59 | PurpleBuddy *new_priority = NULL; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
60 | PurpleContactPrivate *priv = PURPLE_CONTACT_GET_PRIVATE(contact); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
61 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
62 | g_return_if_fail(priv != NULL); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
63 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
64 | priv->priority_buddy = NULL; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
65 | for (bnode = PURPLE_BLIST_NODE(contact)->child; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
66 | bnode != NULL; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
67 | bnode = bnode->next) |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
68 | { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
69 | PurpleBuddy *buddy; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
70 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
71 | if (!PURPLE_IS_BUDDY(bnode)) |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
72 | continue; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
73 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
74 | buddy = PURPLE_BUDDY(bnode); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
75 | if (new_priority == NULL) |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
76 | { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
77 | new_priority = buddy; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
78 | continue; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
79 | } |
|
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 | 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
|
82 | { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
83 | int cmp = 1; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
84 | 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
|
85 | cmp = purple_buddy_presence_compare( |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
86 | 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
|
87 | 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
|
88 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
89 | if (cmp > 0 || (cmp == 0 && |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
90 | 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
|
91 | { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
92 | new_priority = buddy; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
93 | } |
|
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 | priv->priority_buddy = new_priority; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
98 | priv->priority_valid = TRUE; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
99 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
100 | 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
|
101 | properties[PROP_PRIORITY_BUDDY]); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
102 | } |
|
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 | PurpleGroup * |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
105 | purple_contact_get_group(const PurpleContact *contact) |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
106 | { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
107 | 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
|
108 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
109 | 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
|
110 | } |
|
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 | void |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
113 | 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
|
114 | { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
115 | PurpleBlistUiOps *ops = purple_blist_get_ui_ops(); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
116 | PurpleIMConversation *im; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
117 | PurpleBlistNode *bnode; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
118 | char *old_alias; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
119 | char *new_alias = NULL; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
120 | PurpleContactPrivate *priv = PURPLE_CONTACT_GET_PRIVATE(contact); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
121 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
122 | g_return_if_fail(priv != NULL); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
123 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
124 | if ((alias != NULL) && (*alias != '\0')) |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
125 | new_alias = purple_utf8_strip_unprintables(alias); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
126 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
127 | if (!purple_strequal(priv->alias, new_alias)) { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
128 | g_free(new_alias); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
129 | return; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
130 | } |
|
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 | old_alias = priv->alias; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
133 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
134 | if ((new_alias != NULL) && (*new_alias != '\0')) |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
135 | priv->alias = new_alias; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
136 | else { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
137 | priv->alias = NULL; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
138 | g_free(new_alias); /* could be "\0" */ |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
139 | } |
|
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 | 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
|
142 | properties[PROP_ALIAS]); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
143 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
144 | if (ops) { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
145 | if (ops->save_node) |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
146 | ops->save_node(PURPLE_BLIST_NODE(contact)); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
147 | if (ops->update) |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
148 | 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
|
149 | } |
|
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 | 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
|
152 | { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
153 | PurpleBuddy *buddy = PURPLE_BUDDY(bnode); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
154 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
155 | 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
|
156 | purple_buddy_get_account(buddy)); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
157 | if (im) |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
158 | purple_conversation_autoset_title(PURPLE_CONVERSATION(im)); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
159 | } |
|
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 | 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
|
162 | contact, old_alias); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
163 | g_free(old_alias); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
164 | } |
|
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 | 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
|
167 | { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
168 | PurpleContactPrivate *priv = PURPLE_CONTACT_GET_PRIVATE(contact); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
169 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
170 | 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
|
171 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
172 | if (priv->alias) |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
173 | return priv->alias; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
174 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
175 | 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
|
176 | } |
|
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 | 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
|
179 | { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
180 | PurpleBlistNode *bnode, *cnode = (PurpleBlistNode *) c; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
181 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
182 | 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
|
183 | 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
|
184 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
185 | 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
|
186 | PurpleBuddy *buddy; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
187 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
188 | if (! PURPLE_IS_BUDDY(bnode)) |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
189 | continue; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
190 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
191 | buddy = (PurpleBuddy *)bnode; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
192 | if (purple_buddy_get_account(buddy) == account) |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
193 | return TRUE; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
194 | } |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
195 | return FALSE; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
196 | } |
|
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 | 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
|
199 | { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
200 | PurpleContactPrivate *priv = PURPLE_CONTACT_GET_PRIVATE(contact); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
201 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
202 | g_return_if_fail(priv != NULL); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
203 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
204 | priv->priority_valid = FALSE; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
205 | } |
|
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 | 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
|
208 | { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
209 | PurpleContactPrivate *priv = PURPLE_CONTACT_GET_PRIVATE(contact); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
210 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
211 | 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
|
212 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
213 | if (!priv->priority_valid) |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
214 | purple_contact_compute_priority_buddy(contact); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
215 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
216 | return priv->priority_buddy; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
217 | } |
|
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 | 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
|
220 | { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
221 | PurpleBlistNode *sourcenode = (PurpleBlistNode*)source; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
222 | PurpleBlistNode *prev, *cur, *next; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
223 | PurpleContact *target; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
224 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
225 | 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
|
226 | 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
|
227 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
228 | if (PURPLE_IS_CONTACT(node)) { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
229 | target = (PurpleContact *)node; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
230 | prev = _purple_blist_get_last_child(node); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
231 | } else if (PURPLE_IS_BUDDY(node)) { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
232 | target = (PurpleContact *)node->parent; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
233 | prev = node; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
234 | } else { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
235 | return; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
236 | } |
|
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 | if (source == target || !target) |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
239 | return; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
240 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
241 | next = sourcenode->child; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
242 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
243 | while (next) { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
244 | cur = next; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
245 | next = cur->next; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
246 | if (PURPLE_IS_BUDDY(cur)) { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
247 | 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
|
248 | prev = cur; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
249 | } |
|
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 | * GObject Stuff |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
255 | **************************************************************************/ |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
256 | /* Set method for GObject properties */ |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
257 | static void |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
258 | 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
|
259 | GParamSpec *pspec) |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
260 | { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
261 | PurpleContact *contact = PURPLE_CONTACT(obj); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
262 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
263 | switch (param_id) { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
264 | case PROP_ALIAS: |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
265 | 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
|
266 | break; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
267 | default: |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
268 | 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
|
269 | break; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
270 | } |
|
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 | /* Get method for GObject properties */ |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
274 | static void |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
275 | 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
|
276 | GParamSpec *pspec) |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
277 | { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
278 | PurpleContact *contact = PURPLE_CONTACT(obj); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
279 | PurpleContactPrivate *priv = PURPLE_CONTACT_GET_PRIVATE(contact); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
280 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
281 | switch (param_id) { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
282 | case PROP_ALIAS: |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
283 | g_value_set_string(value, priv->alias); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
284 | break; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
285 | case PROP_PRIORITY_BUDDY: |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
286 | 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
|
287 | break; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
288 | default: |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
289 | 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
|
290 | break; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
291 | } |
|
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 | /* GObject initialization function */ |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
295 | static void |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
296 | purple_contact_init(GTypeInstance *instance, gpointer klass) |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
297 | { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
298 | PurpleContact *contact = PURPLE_CONTACT(instance); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
299 | PurpleBlistUiOps *ops = purple_blist_get_ui_ops(); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
300 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
301 | if (ops && ops->new_node) |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
302 | ops->new_node(PURPLE_BLIST_NODE(contact)); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
303 | } |
|
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 | /* GObject finalize function */ |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
306 | static void |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
307 | purple_contact_finalize(GObject *object) |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
308 | { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
309 | 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
|
310 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
311 | G_OBJECT_CLASS(parent_class)->finalize(object); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
312 | } |
|
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 | /* Class initializer function */ |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
315 | 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
|
316 | { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
317 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
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 | 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
|
320 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
321 | obj_class->finalize = purple_contact_finalize; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
322 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
323 | /* Setup properties */ |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
324 | 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
|
325 | 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
|
326 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
327 | 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
|
328 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
329 | properties[PROP_ALIAS] = g_param_spec_string( |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
330 | "alias", |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
331 | "Alias", |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
332 | "The alias for the contact.", |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
333 | NULL, |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
334 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
335 | ); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
336 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
337 | 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
|
338 | "priority-buddy", |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
339 | "Priority buddy", |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
340 | "The priority buddy of the contact.", |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
341 | PURPLE_TYPE_BUDDY, |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
342 | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
343 | ); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
344 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
345 | 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
|
346 | } |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
347 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
348 | GType |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
349 | purple_contact_get_type(void) |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
350 | { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
351 | static GType type = 0; |
|
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 | if(type == 0) { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
354 | static const GTypeInfo info = { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
355 | sizeof(PurpleContactClass), |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
356 | NULL, |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
357 | NULL, |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
358 | (GClassInitFunc)purple_contact_class_init, |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
359 | NULL, |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
360 | NULL, |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
361 | sizeof(PurpleContact), |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
362 | 0, |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
363 | (GInstanceInitFunc)purple_contact_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 | }; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
366 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
367 | type = g_type_register_static( |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
368 | PURPLE_TYPE_COUNTING_NODE, |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
369 | "PurpleContact", |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
370 | &info, |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
371 | 0 |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
372 | ); |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
373 | } |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
374 | |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
375 | return type; |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
376 | } |
|
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 | PurpleContact * |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
379 | purple_contact_new(void) |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
380 | { |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
381 | 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
|
382 | } |
|
4318acee8ac6
Pulled PurpleContact out to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
383 |