libpurple/purpleperson.c

Mon, 30 Jun 2025 14:22:13 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Mon, 30 Jun 2025 14:22:13 -0500
changeset 43269
1523eab3b5a0
parent 43171
914049a55a72
child 43301
0e43dc8462e8
permissions
-rw-r--r--

Update the flatpak to gnome 48 and to the matching birb version

The birb version was missed here when it was updated.

Testing Done:
Built the flatpak with the instructions in the readme.

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

41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Purple - Internet Messaging Library
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
5 * Purple is the legal property of its developers, whose names are too numerous
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
7 * source distribution.
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
9 * This library is free software; you can redistribute it and/or modify it
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
10 * under the terms of the GNU General Public License as published by the Free
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
11 * Software Foundation; either version 2 of the License, or (at your option)
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
12 * any later version.
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
14 * This library is distributed in the hope that it will be useful, but WITHOUT
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
17 * more details.
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
18 *
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
19 * You should have received a copy of the GNU General Public License along with
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
20 * this library; if not, see <https://www.gnu.org/licenses/>.
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include "purpleperson.h"
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
42053
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
25 #include "util.h"
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
26
42059
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
27 #include "util.h"
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
28
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 struct _PurplePerson {
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 GObject parent;
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
32 char *id;
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33
42312
7d6f0b8b6e77 Use PurpleAvatar for PurplePerson and PurpleContactInfo
Gary Kramlich <grim@reaperworld.com>
parents: 42309
diff changeset
34 gchar *alias;
7d6f0b8b6e77 Use PurpleAvatar for PurplePerson and PurpleContactInfo
Gary Kramlich <grim@reaperworld.com>
parents: 42309
diff changeset
35 PurpleAvatar *avatar;
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
36 char *color;
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
37
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 PurpleTags *tags;
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 GPtrArray *contacts;
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 };
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 enum {
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 PROP_0,
42663
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
45 PROP_ITEM_TYPE,
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
46 PROP_N_ITEMS,
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 PROP_ID,
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 PROP_ALIAS,
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 PROP_AVATAR,
42054
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
50 PROP_AVATAR_FOR_DISPLAY,
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
51 PROP_COLOR,
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
52 PROP_COLOR_FOR_DISPLAY,
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 PROP_TAGS,
42053
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
54 PROP_NAME_FOR_DISPLAY,
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
55 PROP_PRIORITY_CONTACT_INFO,
42584
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42576
diff changeset
56 N_PROPERTIES,
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 };
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 static GParamSpec *properties[N_PROPERTIES] = {NULL, };
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
60 static void
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
61 purple_person_priority_contact_info_notify_cb(GObject *obj,
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
62 G_GNUC_UNUSED GParamSpec *pspec,
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
63 gpointer data);
43171
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
64 static void
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
65 purple_person_presence_notify_cb(GObject *obj,
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
66 GParamSpec *pspec,
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
67 gpointer data);
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
68
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 /******************************************************************************
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 * Helpers
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 *****************************************************************************/
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 static void
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
73 purple_person_set_id(PurplePerson *person, const char *id) {
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 g_return_if_fail(PURPLE_IS_PERSON(person));
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 g_free(person->id);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 if(id != NULL) {
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 person->id = g_strdup(id);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 } else {
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 person->id = g_uuid_string_random();
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 g_object_notify_by_pspec(G_OBJECT(person), properties[PROP_ID]);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 static gint
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 purple_person_contact_compare(gconstpointer a, gconstpointer b) {
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
89 PurpleContactInfo *c1 = *(PurpleContactInfo **)a;
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
90 PurpleContactInfo *c2 = *(PurpleContactInfo **)b;
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 PurplePresence *p1 = NULL;
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 PurplePresence *p2 = NULL;
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
94 p1 = purple_contact_info_get_presence(c1);
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
95 p2 = purple_contact_info_get_presence(c2);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 return purple_presence_compare(p1, p2);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 static void
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
101 purple_person_sort_contacts(PurplePerson *person,
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
102 PurpleContactInfo *original_priority)
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
103 {
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
104 PurpleContactInfo *new_priority = NULL;
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 guint n_items = person->contacts->len;
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 g_ptr_array_sort(person->contacts, purple_person_contact_compare);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 /* Tell the list we update our stuff. */
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110 g_list_model_items_changed(G_LIST_MODEL(person), 0, n_items, n_items);
43128
1ce3ad90614c Make sure we notify on the n-items property for all objects that have it
Gary Kramlich <grim@reaperworld.com>
parents: 43071
diff changeset
111 g_object_notify_by_pspec(G_OBJECT(person), properties[PROP_N_ITEMS]);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112
43171
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
113 /* If we have at least 1 contact, it is the new priority. */
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
114 if(person->contacts->len > 0) {
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
115 new_priority = g_ptr_array_index(person->contacts, 0);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
116 }
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
117
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 /* See if the priority contact changed. */
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 if(original_priority != new_priority) {
42314
37eca344465a Fix some issues with PurplePerson->avatar
Gary Kramlich <grim@reaperworld.com>
parents: 42312
diff changeset
120 PurpleAvatar *old_avatar = NULL;
37eca344465a Fix some issues with PurplePerson->avatar
Gary Kramlich <grim@reaperworld.com>
parents: 42312
diff changeset
121 PurpleAvatar *new_avatar = NULL;
42053
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
122 GObject *obj = G_OBJECT(person);
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
123 const char *old_color = NULL;
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
124 const char *new_color = NULL;
42053
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
125
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
126 if(PURPLE_IS_CONTACT_INFO(original_priority)) {
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
127 old_avatar = purple_contact_info_get_avatar(original_priority);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
128 old_color = purple_contact_info_get_color(original_priority);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
129
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
130 g_signal_handlers_disconnect_by_func(original_priority,
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
131 purple_person_priority_contact_info_notify_cb,
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
132 person);
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
133 }
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
134
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
135 if(PURPLE_IS_CONTACT_INFO(new_priority)) {
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
136 new_avatar = purple_contact_info_get_avatar(new_priority);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
137 new_color = purple_contact_info_get_color(new_priority);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
138
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
139 g_signal_connect_object(new_priority, "notify",
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
140 G_CALLBACK(purple_person_priority_contact_info_notify_cb),
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
141 person, 0);
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
142 }
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
143
42053
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
144 g_object_freeze_notify(obj);
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
145 g_object_notify_by_pspec(obj, properties[PROP_NAME_FOR_DISPLAY]);
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
146 g_object_notify_by_pspec(obj, properties[PROP_PRIORITY_CONTACT_INFO]);
42054
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
147
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
148 /* If the color isn't overridden by the person, check if it has
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
149 * changed.
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
150 */
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
151 if(purple_strempty(person->color)) {
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
152 if(!purple_strequal(old_color, new_color)) {
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
153 g_object_notify_by_pspec(obj,
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
154 properties[PROP_COLOR_FOR_DISPLAY]);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
155 }
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
156 }
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
157
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
158 /* If the person doesn't have an avatar set, check if the avatar
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
159 * changed and notify if it has.
42054
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
160 */
42312
7d6f0b8b6e77 Use PurpleAvatar for PurplePerson and PurpleContactInfo
Gary Kramlich <grim@reaperworld.com>
parents: 42309
diff changeset
161 if(!PURPLE_IS_AVATAR(person->avatar)) {
42314
37eca344465a Fix some issues with PurplePerson->avatar
Gary Kramlich <grim@reaperworld.com>
parents: 42312
diff changeset
162 if(old_avatar != new_avatar) {
37eca344465a Fix some issues with PurplePerson->avatar
Gary Kramlich <grim@reaperworld.com>
parents: 42312
diff changeset
163 g_object_notify_by_pspec(obj, properties[PROP_AVATAR_FOR_DISPLAY]);
37eca344465a Fix some issues with PurplePerson->avatar
Gary Kramlich <grim@reaperworld.com>
parents: 42312
diff changeset
164 }
42054
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
165 }
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
166
42053
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
167 g_object_thaw_notify(obj);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170
42059
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
171 /* This function is used by purple_person_matches to determine if a contact info
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
172 * matches the needle.
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
173 */
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
174 static gboolean
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
175 purple_person_matches_find_func(gconstpointer a, gconstpointer b) {
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
176 PurpleContactInfo *info = (gpointer)a;
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
177 const char *needle = b;
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
178
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
179 return purple_contact_info_matches(info, needle);
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
180 }
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
181
43171
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
182 static gboolean
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
183 purple_person_remove_contact_info_internal(PurplePerson *person,
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
184 PurpleContactInfo *info)
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
185 {
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
186 PurplePresence *presence = NULL;
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
187 guint index = 0;
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
188 gboolean found = FALSE;
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
189
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
190 found = g_ptr_array_find(person->contacts, info, &index);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
191 if(!found) {
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
192 return FALSE;
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
193 }
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
194
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
195 presence = purple_contact_info_get_presence(info);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
196 g_signal_handlers_disconnect_by_func(presence,
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
197 purple_person_presence_notify_cb,
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
198 person);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
199
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
200 purple_contact_info_set_person(info, NULL);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
201
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
202 g_ptr_array_remove_index_fast(person->contacts, index);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
203
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
204 return TRUE;
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
205 }
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
206
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207 /******************************************************************************
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208 * Callbacks
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209 *****************************************************************************/
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
210 static void
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
211 purple_person_priority_contact_info_notify_cb(G_GNUC_UNUSED GObject *obj,
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
212 GParamSpec *pspec,
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
213 gpointer data)
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
214 {
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
215 PurplePerson *person = data;
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
216 const char *property = NULL;
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
217
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
218 property = g_param_spec_get_name(pspec);
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
219
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
220 if(purple_strequal(property, "name-for-display")) {
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
221 g_object_notify_by_pspec(G_OBJECT(person),
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
222 properties[PROP_NAME_FOR_DISPLAY]);
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
223 } else if(purple_strequal(property, "avatar")) {
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
224 g_object_notify_by_pspec(G_OBJECT(person),
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
225 properties[PROP_AVATAR_FOR_DISPLAY]);
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
226 } else if(purple_strequal(property, "color")) {
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
227 g_object_notify_by_pspec(G_OBJECT(person),
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
228 properties[PROP_COLOR_FOR_DISPLAY]);
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
229 }
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
230 }
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
231
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
232 static void
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
233 purple_person_presence_notify_cb(G_GNUC_UNUSED GObject *obj,
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
234 G_GNUC_UNUSED GParamSpec *pspec,
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
235 gpointer data)
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
236 {
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
237 PurplePerson *person = data;
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
238 PurpleContactInfo *current_priority = NULL;
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
239
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
240 current_priority = purple_person_get_priority_contact_info(person);
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
241
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
242 purple_person_sort_contacts(person, current_priority);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
243 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
244
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
245 /******************************************************************************
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
246 * GListModel Implementation
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
247 *****************************************************************************/
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
248 static GType
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
249 purple_person_get_item_type(G_GNUC_UNUSED GListModel *list) {
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
250 return PURPLE_TYPE_CONTACT_INFO;
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
252
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
253 static guint
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
254 purple_person_get_n_items(GListModel *list) {
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
255 PurplePerson *person = PURPLE_PERSON(list);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
256
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
257 return person->contacts->len;
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
258 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
259
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
260 static gpointer
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
261 purple_person_get_item(GListModel *list, guint position) {
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
262 PurplePerson *person = PURPLE_PERSON(list);
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
263 PurpleContactInfo *info = NULL;
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
264
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
265 if(position < person->contacts->len) {
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
266 info = g_ptr_array_index(person->contacts, position);
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
267 g_object_ref(info);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
268 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
269
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
270 return info;
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
271 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
272
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
273 static void
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
274 purple_person_list_model_init(GListModelInterface *iface) {
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
275 iface->get_item_type = purple_person_get_item_type;
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
276 iface->get_n_items = purple_person_get_n_items;
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
277 iface->get_item = purple_person_get_item;
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
278 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
279
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
280 /******************************************************************************
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
281 * GObject Implementation
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
282 *****************************************************************************/
42576
ab1ca778ddb2 Make sure all of the final types in libpurple are defined as such
Gary Kramlich <grim@reaperworld.com>
parents: 42314
diff changeset
283 G_DEFINE_FINAL_TYPE_WITH_CODE(PurplePerson, purple_person, G_TYPE_OBJECT,
ab1ca778ddb2 Make sure all of the final types in libpurple are defined as such
Gary Kramlich <grim@reaperworld.com>
parents: 42314
diff changeset
284 G_IMPLEMENT_INTERFACE(G_TYPE_LIST_MODEL,
ab1ca778ddb2 Make sure all of the final types in libpurple are defined as such
Gary Kramlich <grim@reaperworld.com>
parents: 42314
diff changeset
285 purple_person_list_model_init))
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
286
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
287 static void
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
288 purple_person_get_property(GObject *obj, guint param_id, GValue *value,
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
289 GParamSpec *pspec)
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
290 {
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
291 PurplePerson *person = PURPLE_PERSON(obj);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
292
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
293 switch(param_id) {
42663
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
294 case PROP_ITEM_TYPE:
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
295 g_value_set_gtype(value,
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
296 purple_person_get_item_type(G_LIST_MODEL(person)));
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
297 break;
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
298 case PROP_N_ITEMS:
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
299 g_value_set_uint(value,
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
300 purple_person_get_n_items(G_LIST_MODEL(person)));
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
301 break;
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
302 case PROP_ID:
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
303 g_value_set_string(value, purple_person_get_id(person));
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
304 break;
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
305 case PROP_ALIAS:
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
306 g_value_set_string(value, purple_person_get_alias(person));
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
307 break;
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
308 case PROP_AVATAR:
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
309 g_value_set_object(value, purple_person_get_avatar(person));
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
310 break;
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
311 case PROP_AVATAR_FOR_DISPLAY:
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
312 g_value_set_object(value,
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
313 purple_person_get_avatar_for_display(person));
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
314 break;
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
315 case PROP_COLOR:
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
316 g_value_set_string(value, purple_person_get_color(person));
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
317 break;
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
318 case PROP_COLOR_FOR_DISPLAY:
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
319 g_value_set_string(value, purple_person_get_color_for_display(person));
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
320 break;
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
321 case PROP_TAGS:
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
322 g_value_set_object(value, purple_person_get_tags(person));
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
323 break;
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
324 case PROP_NAME_FOR_DISPLAY:
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
325 g_value_set_string(value, purple_person_get_name_for_display(person));
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
326 break;
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
327 case PROP_PRIORITY_CONTACT_INFO:
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
328 g_value_set_object(value,
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
329 purple_person_get_priority_contact_info(person));
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
330 break;
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
331 default:
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
332 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
333 break;
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
334 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
335 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
336
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
337 static void
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
338 purple_person_set_property(GObject *obj, guint param_id, const GValue *value,
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
339 GParamSpec *pspec)
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
340 {
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
341 PurplePerson *person = PURPLE_PERSON(obj);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
342
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
343 switch(param_id) {
42663
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
344 case PROP_ID:
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
345 purple_person_set_id(person, g_value_get_string(value));
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
346 break;
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
347 case PROP_ALIAS:
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
348 purple_person_set_alias(person, g_value_get_string(value));
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
349 break;
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
350 case PROP_AVATAR:
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
351 purple_person_set_avatar(person, g_value_get_object(value));
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
352 break;
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
353 case PROP_COLOR:
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
354 purple_person_set_color(person, g_value_get_string(value));
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
355 break;
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
356 default:
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
357 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
358 break;
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
359 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
360 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
361
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
362 static void
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
363 purple_person_dispose(GObject *obj) {
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
364 PurplePerson *person = PURPLE_PERSON(obj);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
365
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
366 g_clear_object(&person->avatar);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
367 g_clear_object(&person->tags);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
368
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
369 if(person->contacts != NULL) {
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
370 g_ptr_array_free(person->contacts, TRUE);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
371 person->contacts = NULL;
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
372 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
373
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
374 G_OBJECT_CLASS(purple_person_parent_class)->dispose(obj);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
375 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
376
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
377 static void
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
378 purple_person_finalize(GObject *obj) {
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
379 PurplePerson *person = PURPLE_PERSON(obj);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
380
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
381 g_clear_pointer(&person->id, g_free);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
382 g_clear_pointer(&person->alias, g_free);
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
383 g_clear_pointer(&person->color, g_free);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
384
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
385 G_OBJECT_CLASS(purple_person_parent_class)->finalize(obj);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
386 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
387
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
388 static void
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
389 purple_person_constructed(GObject *obj) {
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
390 PurplePerson *person = NULL;
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
391
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
392 G_OBJECT_CLASS(purple_person_parent_class)->constructed(obj);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
393
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
394 person = PURPLE_PERSON(obj);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
395 if(person->id == NULL) {
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
396 purple_person_set_id(person, NULL);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
397 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
398 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
399
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
400 static void
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
401 purple_person_init(PurplePerson *person) {
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
402 person->tags = purple_tags_new();
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
403 person->contacts = g_ptr_array_new_full(0, (GDestroyNotify)g_object_unref);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
404 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
405
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
406 static void
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
407 purple_person_class_init(PurplePersonClass *klass) {
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
408 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
409
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
410 obj_class->get_property = purple_person_get_property;
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
411 obj_class->set_property = purple_person_set_property;
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
412 obj_class->constructed = purple_person_constructed;
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
413 obj_class->dispose = purple_person_dispose;
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
414 obj_class->finalize = purple_person_finalize;
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
415
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
416 /**
42663
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
417 * PurplePerson:item-type:
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
418 *
42984
818220289e67 Update the gi-docgen subproject and fix some new issues it found
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
419 * The type of items. See [vfunc@Gio.ListModel.get_item_type].
42663
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
420 *
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
421 * Since: 3.0
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
422 */
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
423 properties[PROP_ITEM_TYPE] = g_param_spec_gtype(
43071
071588186662 Remove nick and blurb from libpurple properties
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42984
diff changeset
424 "item-type", NULL, NULL,
42663
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
425 G_TYPE_OBJECT,
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
426 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
427
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
428 /**
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
429 * PurplePerson:n-items:
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
430 *
42984
818220289e67 Update the gi-docgen subproject and fix some new issues it found
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
431 * The number of items. See [vfunc@Gio.ListModel.get_n_items].
42663
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
432 *
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
433 * Since: 3.0
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
434 */
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
435 properties[PROP_N_ITEMS] = g_param_spec_uint(
43071
071588186662 Remove nick and blurb from libpurple properties
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42984
diff changeset
436 "n-items", NULL, NULL,
42663
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
437 0, G_MAXUINT, 0,
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
438 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
439
e4e10a90e4a2 Add item-type and n-items properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
440 /**
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
441 * PurplePerson:id:
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
442 *
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
443 * The protocol specific id for the contact.
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
444 *
42615
2f3308794a8f Remove the micro version from since tags for libpurple part 4
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
445 * Since: 3.0
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
446 */
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
447 properties[PROP_ID] = g_param_spec_string(
43071
071588186662 Remove nick and blurb from libpurple properties
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42984
diff changeset
448 "id", NULL, NULL,
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
449 NULL,
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
450 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
451
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
452 /**
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
453 * PurplePerson:alias:
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
454 *
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
455 * The alias for this person. This is controlled by the libpurple user.
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
456 *
42615
2f3308794a8f Remove the micro version from since tags for libpurple part 4
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
457 * Since: 3.0
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
458 */
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
459 properties[PROP_ALIAS] = g_param_spec_string(
43071
071588186662 Remove nick and blurb from libpurple properties
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42984
diff changeset
460 "alias", NULL, NULL,
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
461 NULL,
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
462 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
463
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
464 /**
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
465 * PurplePerson:avatar:
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
466 *
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
467 * The avatar for this person. This is controlled by the libpurple user,
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
468 * which they can use to set a custom avatar.
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
469 *
42615
2f3308794a8f Remove the micro version from since tags for libpurple part 4
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
470 * Since: 3.0
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
471 */
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
472 properties[PROP_AVATAR] = g_param_spec_object(
43071
071588186662 Remove nick and blurb from libpurple properties
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42984
diff changeset
473 "avatar", NULL, NULL,
42312
7d6f0b8b6e77 Use PurpleAvatar for PurplePerson and PurpleContactInfo
Gary Kramlich <grim@reaperworld.com>
parents: 42309
diff changeset
474 PURPLE_TYPE_AVATAR,
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
475 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
476
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
477 /**
42054
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
478 * PurplePerson:avatar-for-display
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
479 *
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
480 * The avatar to show for the person. If [property@Purple.Person:avatar] is
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
481 * set, it will be returned. Otherwise the value of
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
482 * [property@Purple.ContactInfo:avatar] for
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
483 * [property@Purple.Person:priority-contact-info] will be returned.
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
484 *
42615
2f3308794a8f Remove the micro version from since tags for libpurple part 4
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
485 * Since: 3.0
42054
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
486 */
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
487 properties[PROP_AVATAR_FOR_DISPLAY] = g_param_spec_object(
43071
071588186662 Remove nick and blurb from libpurple properties
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42984
diff changeset
488 "avatar-for-display", NULL, NULL,
42312
7d6f0b8b6e77 Use PurpleAvatar for PurplePerson and PurpleContactInfo
Gary Kramlich <grim@reaperworld.com>
parents: 42309
diff changeset
489 PURPLE_TYPE_AVATAR,
42054
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
490 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
491
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
492 /**
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
493 * PurplePerson:color:
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
494 *
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
495 * A custom color to use for this person which will override any colors for
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
496 * the contacts that belong to this person.
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
497 *
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
498 * This is an RGB hex code that user interfaces can use when rendering the
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
499 * person.
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
500 *
42615
2f3308794a8f Remove the micro version from since tags for libpurple part 4
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
501 * Since: 3.0
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
502 */
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
503 properties[PROP_COLOR] = g_param_spec_string(
43071
071588186662 Remove nick and blurb from libpurple properties
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42984
diff changeset
504 "color", NULL, NULL,
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
505 NULL,
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
506 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
507
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
508 /**
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
509 * PurplePerson:color-for-display:
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
510 *
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
511 * The color to use for this person.
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
512 *
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
513 * This will return the value of [property@Person:color] if it is set,
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
514 * otherwise it will return the value of [property@ContactInfo:color] of
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
515 * the priority contact info.
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
516 *
42615
2f3308794a8f Remove the micro version from since tags for libpurple part 4
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
517 * Since: 3.0
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
518 */
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
519 properties[PROP_COLOR_FOR_DISPLAY] = g_param_spec_string(
43071
071588186662 Remove nick and blurb from libpurple properties
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42984
diff changeset
520 "color-for-display", NULL, NULL,
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
521 NULL,
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
522 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
523
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
524 /**
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
525 * PurplePerson:tags:
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
526 *
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
527 * The [class@Purple.Tags] for this person.
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
528 *
42615
2f3308794a8f Remove the micro version from since tags for libpurple part 4
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
529 * Since: 3.0
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
530 */
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
531 properties[PROP_TAGS] = g_param_spec_object(
43071
071588186662 Remove nick and blurb from libpurple properties
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42984
diff changeset
532 "tags", NULL, NULL,
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
533 PURPLE_TYPE_TAGS,
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
534 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
535
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
536 /**
42053
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
537 * PurplePerson:name-for-display:
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
538 *
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
539 * The name that should be displayed for this person.
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
540 *
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
541 * If [property@Purple.Person:alias] is set that will be returned. If not
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
542 * the value of [method@Purple.ContactInfo.get_name_for_display] for
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
543 * [property@Purple.Person:priority-contact-info] will be used. If
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
544 * [property@Purple.Person:priority-contact-info] is %NULL, then %NULL will
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
545 * be returned.
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
546 *
42615
2f3308794a8f Remove the micro version from since tags for libpurple part 4
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
547 * Since: 3.0
42053
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
548 */
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
549 properties[PROP_NAME_FOR_DISPLAY] = g_param_spec_string(
43071
071588186662 Remove nick and blurb from libpurple properties
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42984
diff changeset
550 "name-for-display", NULL, NULL,
42053
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
551 NULL,
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
552 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
553
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
554 /**
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
555 * PurplePerson:priority-contact-info:
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
556 *
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
557 * The [class@Purple.ContactInfo] that currently has the highest priority.
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
558 *
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
559 * This is used by user interfaces to determine which
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
560 * [class@Purple.ContactInfo] to use when messaging and so on.
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
561 *
42615
2f3308794a8f Remove the micro version from since tags for libpurple part 4
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
562 * Since: 3.0
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
563 */
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
564 properties[PROP_PRIORITY_CONTACT_INFO] = g_param_spec_object(
43071
071588186662 Remove nick and blurb from libpurple properties
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42984
diff changeset
565 "priority-contact-info", NULL, NULL,
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
566 PURPLE_TYPE_CONTACT_INFO,
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
567 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
568
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
569 g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
570 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
571
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
572 /******************************************************************************
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
573 * Public API
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
574 *****************************************************************************/
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
575 PurplePerson *
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
576 purple_person_new(void) {
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
577 return g_object_new(PURPLE_TYPE_PERSON, NULL);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
578 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
579
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
580 const char *
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
581 purple_person_get_id(PurplePerson *person) {
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
582 g_return_val_if_fail(PURPLE_IS_PERSON(person), NULL);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
583
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
584 return person->id;
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
585 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
586
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
587 const char *
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
588 purple_person_get_alias(PurplePerson *person) {
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
589 g_return_val_if_fail(PURPLE_IS_PERSON(person), NULL);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
590
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
591 return person->alias;
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
592 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
593
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
594 void
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
595 purple_person_set_alias(PurplePerson *person, const char *alias) {
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
596 g_return_if_fail(PURPLE_IS_PERSON(person));
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
597
42767
8cf1d11b59c1 Use g_set_str everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42663
diff changeset
598 if(g_set_str(&person->alias, alias)) {
42053
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
599 GObject *obj = G_OBJECT(person);
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
600
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
601 g_object_freeze_notify(obj);
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
602 g_object_notify_by_pspec(obj, properties[PROP_ALIAS]);
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
603 g_object_notify_by_pspec(obj, properties[PROP_NAME_FOR_DISPLAY]);
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
604 g_object_thaw_notify(obj);
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
605 }
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
606 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
607
42312
7d6f0b8b6e77 Use PurpleAvatar for PurplePerson and PurpleContactInfo
Gary Kramlich <grim@reaperworld.com>
parents: 42309
diff changeset
608 PurpleAvatar *
42054
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
609 purple_person_get_avatar_for_display(PurplePerson *person) {
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
610 PurpleContactInfo *priority = NULL;
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
611
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
612 g_return_val_if_fail(PURPLE_IS_PERSON(person), NULL);
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
613
42312
7d6f0b8b6e77 Use PurpleAvatar for PurplePerson and PurpleContactInfo
Gary Kramlich <grim@reaperworld.com>
parents: 42309
diff changeset
614 if(PURPLE_IS_AVATAR(person->avatar)) {
42054
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
615 return person->avatar;
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
616 }
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
617
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
618 priority = purple_person_get_priority_contact_info(person);
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
619 if(PURPLE_IS_CONTACT_INFO(priority)) {
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
620 return purple_contact_info_get_avatar(priority);
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
621 }
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
622
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
623 return NULL;
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
624 }
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
625
42312
7d6f0b8b6e77 Use PurpleAvatar for PurplePerson and PurpleContactInfo
Gary Kramlich <grim@reaperworld.com>
parents: 42309
diff changeset
626 PurpleAvatar *
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
627 purple_person_get_avatar(PurplePerson *person) {
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
628 g_return_val_if_fail(PURPLE_IS_PERSON(person), NULL);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
629
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
630 return person->avatar;
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
631 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
632
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
633 void
42312
7d6f0b8b6e77 Use PurpleAvatar for PurplePerson and PurpleContactInfo
Gary Kramlich <grim@reaperworld.com>
parents: 42309
diff changeset
634 purple_person_set_avatar(PurplePerson *person, PurpleAvatar *avatar) {
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
635 g_return_if_fail(PURPLE_IS_PERSON(person));
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
636
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
637 if(g_set_object(&person->avatar, avatar)) {
42054
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
638 GObject *obj = G_OBJECT(person);
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
639
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
640 g_object_freeze_notify(obj);
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
641 g_object_notify_by_pspec(obj, properties[PROP_AVATAR]);
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
642 g_object_notify_by_pspec(obj, properties[PROP_AVATAR_FOR_DISPLAY]);
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
643 g_object_thaw_notify(obj);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
644 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
645 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
646
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
647 const char *
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
648 purple_person_get_color(PurplePerson *person) {
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
649 g_return_val_if_fail(PURPLE_IS_PERSON(person), NULL);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
650
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
651 return person->color;
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
652 }
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
653
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
654 void
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
655 purple_person_set_color(PurplePerson *person, const char *color) {
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
656 g_return_if_fail(PURPLE_IS_PERSON(person));
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
657
42767
8cf1d11b59c1 Use g_set_str everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42663
diff changeset
658 if(g_set_str(&person->color, color)) {
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
659 GObject *obj = G_OBJECT(person);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
660
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
661 g_object_freeze_notify(obj);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
662 g_object_notify_by_pspec(obj, properties[PROP_COLOR]);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
663 g_object_notify_by_pspec(obj, properties[PROP_COLOR_FOR_DISPLAY]);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
664 g_object_thaw_notify(obj);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
665 }
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
666 }
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
667
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
668 const char *
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
669 purple_person_get_color_for_display(PurplePerson *person) {
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
670 PurpleContactInfo *priority = NULL;
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
671
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
672 g_return_val_if_fail(PURPLE_IS_PERSON(person), NULL);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
673
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
674 if(!purple_strempty(person->color)) {
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
675 return person->color;
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
676 }
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
677
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
678 priority = purple_person_get_priority_contact_info(person);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
679 if(PURPLE_IS_CONTACT_INFO(priority)) {
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
680 return purple_contact_info_get_color(priority);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
681 }
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
682
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
683 return NULL;
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
684 }
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
685
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
686 PurpleTags *
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
687 purple_person_get_tags(PurplePerson *person) {
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
688 g_return_val_if_fail(PURPLE_IS_PERSON(person), NULL);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
689
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
690 return person->tags;
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
691 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
692
42053
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
693 const char *
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
694 purple_person_get_name_for_display(PurplePerson *person) {
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
695 PurpleContactInfo *priority = NULL;
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
696
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
697 g_return_val_if_fail(PURPLE_IS_PERSON(person), NULL);
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
698
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
699 if(!purple_strempty(person->alias)) {
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
700 return person->alias;
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
701 }
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
702
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
703 priority = purple_person_get_priority_contact_info(person);
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
704 if(PURPLE_IS_CONTACT_INFO(priority)) {
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
705 return purple_contact_info_get_name_for_display(priority);
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
706 }
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
707
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
708 return NULL;
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
709 }
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41975
diff changeset
710
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
711 void
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
712 purple_person_add_contact_info(PurplePerson *person,
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
713 PurpleContactInfo *info)
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
714 {
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
715 PurplePresence *presence = NULL;
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
716 PurpleContactInfo *current_priority = NULL;
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
717
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
718 g_return_if_fail(PURPLE_IS_PERSON(person));
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
719 g_return_if_fail(PURPLE_IS_CONTACT_INFO(info));
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
720
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
721 current_priority = purple_person_get_priority_contact_info(person);
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
722
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
723 g_ptr_array_add(person->contacts, g_object_ref(info));
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
724
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
725 presence = purple_contact_info_get_presence(info);
41771
c5877e2c93f2 Create and add PurpleContacts to the manager when purple_buddy_new is called
Gary Kramlich <grim@reaperworld.com>
parents: 41761
diff changeset
726 g_signal_connect_object(presence, "notify",
c5877e2c93f2 Create and add PurpleContacts to the manager when purple_buddy_new is called
Gary Kramlich <grim@reaperworld.com>
parents: 41761
diff changeset
727 G_CALLBACK(purple_person_presence_notify_cb),
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
728 person, 0);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
729
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
730 purple_contact_info_set_person(info, person);
41761
9dc5d28fca99 When a Contact is added to a Person set the Contact's Person to that Person.
Gary Kramlich <grim@reaperworld.com>
parents: 41749
diff changeset
731
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
732 purple_person_sort_contacts(person, current_priority);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
733 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
734
43171
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
735 void
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
736 purple_person_remove_all_contact_infos(PurplePerson *person) {
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
737 PurpleContactInfo *current_priority = NULL;
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
738
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
739 g_return_if_fail(PURPLE_IS_PERSON(person));
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
740
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
741 current_priority = purple_person_get_priority_contact_info(person);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
742
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
743 /* This loop is weird because we're removing from the array we are
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
744 * iterating. We could go backwards, but this is fine as we just work on
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
745 * the first item. The length is decremented in the remove function so we
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
746 * don't need to do it ourselves.
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
747 */
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
748 while(person->contacts->len > 0) {
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
749 PurpleContactInfo *info = g_ptr_array_index(person->contacts, 0);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
750
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
751 purple_person_remove_contact_info_internal(person, info);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
752 }
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
753
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
754 purple_person_sort_contacts(person, current_priority);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
755 }
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
756
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
757 gboolean
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
758 purple_person_remove_contact_info(PurplePerson *person,
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
759 PurpleContactInfo *info)
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
760 {
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
761 PurpleContactInfo *current_priority = NULL;
43171
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
762 gboolean found = FALSE;
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
763
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
764 g_return_val_if_fail(PURPLE_IS_PERSON(person), FALSE);
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
765 g_return_val_if_fail(PURPLE_IS_CONTACT_INFO(info), FALSE);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
766
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
767 current_priority = purple_person_get_priority_contact_info(person);
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
768
43171
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
769 found = purple_person_remove_contact_info_internal(person, info);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
770 if(found) {
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42060
diff changeset
771 purple_person_sort_contacts(person, current_priority);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
772 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
773
43171
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 43128
diff changeset
774 return TRUE;
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
775 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
776
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
777 PurpleContactInfo *
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
778 purple_person_get_priority_contact_info(PurplePerson *person) {
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
779 g_return_val_if_fail(PURPLE_IS_PERSON(person), NULL);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
780
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
781 if(person->contacts->len == 0) {
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
782 return NULL;
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
783 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
784
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
785 return g_ptr_array_index(person->contacts, 0);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
786 }
41975
3ef645de21e7 Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
787
3ef645de21e7 Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
788 gboolean
3ef645de21e7 Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
789 purple_person_has_contacts(PurplePerson *person) {
3ef645de21e7 Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
790 g_return_val_if_fail(PURPLE_IS_PERSON(person), FALSE);
3ef645de21e7 Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
791
3ef645de21e7 Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
792 return person->contacts->len > 0;
3ef645de21e7 Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
793 }
42059
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
794
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
795 gboolean
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
796 purple_person_matches(PurplePerson *person, const char *needle) {
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
797 g_return_val_if_fail(PURPLE_IS_PERSON(person), FALSE);
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
798
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
799 if(purple_strempty(needle)) {
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
800 return TRUE;
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
801 }
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
802
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
803 /* Check if the person's alias matches. */
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
804 if(!purple_strempty(person->alias)) {
42060
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 42059
diff changeset
805 if(purple_strmatches(needle, person->alias)) {
42059
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
806 return TRUE;
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
807 }
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
808 }
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
809
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
810 /* See if any of the contact infos match. */
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
811 return g_ptr_array_find_with_equal_func(person->contacts, needle,
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
812 purple_person_matches_find_func,
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
813 NULL);
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
814 }

mercurial