Mon, 30 Jun 2025 14:22:13 -0500
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 | 1 | /* |
| 2 | * Purple - Internet Messaging Library | |
| 3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> | |
| 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 | 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 | 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 | 21 | */ |
| 22 | ||
| 23 | #include "purpleperson.h" | |
| 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 | 29 | struct _PurplePerson { |
| 30 | GObject parent; | |
| 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 | 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 | 38 | PurpleTags *tags; |
| 39 | ||
| 40 | GPtrArray *contacts; | |
| 41 | }; | |
| 42 | ||
| 43 | enum { | |
| 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 | 47 | PROP_ID, |
| 48 | PROP_ALIAS, | |
| 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 | 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 | 57 | }; |
| 58 | static GParamSpec *properties[N_PROPERTIES] = {NULL, }; | |
| 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 | 69 | /****************************************************************************** |
| 70 | * Helpers | |
| 71 | *****************************************************************************/ | |
| 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 | 74 | g_return_if_fail(PURPLE_IS_PERSON(person)); |
| 75 | ||
| 76 | g_free(person->id); | |
| 77 | ||
| 78 | if(id != NULL) { | |
| 79 | person->id = g_strdup(id); | |
| 80 | } else { | |
| 81 | person->id = g_uuid_string_random(); | |
| 82 | } | |
| 83 | ||
| 84 | g_object_notify_by_pspec(G_OBJECT(person), properties[PROP_ID]); | |
| 85 | } | |
| 86 | ||
| 87 | static gint | |
| 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 | 91 | PurplePresence *p1 = NULL; |
| 92 | PurplePresence *p2 = NULL; | |
| 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 | 96 | |
| 97 | return purple_presence_compare(p1, p2); | |
| 98 | } | |
| 99 | ||
| 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 | 105 | guint n_items = person->contacts->len; |
| 106 | ||
| 107 | g_ptr_array_sort(person->contacts, purple_person_contact_compare); | |
| 108 | ||
| 109 | /* Tell the list we update our stuff. */ | |
| 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 | 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 | 118 | /* See if the priority contact changed. */ |
| 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 | 168 | } |
| 169 | } | |
| 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 | 207 | /****************************************************************************** |
| 208 | * Callbacks | |
| 209 | *****************************************************************************/ | |
| 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 | 233 | purple_person_presence_notify_cb(G_GNUC_UNUSED GObject *obj, |
| 234 | G_GNUC_UNUSED GParamSpec *pspec, | |
| 235 | gpointer data) | |
| 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 | 243 | } |
| 244 | ||
| 245 | /****************************************************************************** | |
| 246 | * GListModel Implementation | |
| 247 | *****************************************************************************/ | |
| 248 | static GType | |
| 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 | 251 | } |
| 252 | ||
| 253 | static guint | |
| 254 | purple_person_get_n_items(GListModel *list) { | |
| 255 | PurplePerson *person = PURPLE_PERSON(list); | |
| 256 | ||
| 257 | return person->contacts->len; | |
| 258 | } | |
| 259 | ||
| 260 | static gpointer | |
| 261 | purple_person_get_item(GListModel *list, guint position) { | |
| 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 | 264 | |
| 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 | 268 | } |
| 269 | ||
|
41948
6d844d2faff1
Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents:
41771
diff
changeset
|
270 | return info; |
| 41749 | 271 | } |
| 272 | ||
| 273 | static void | |
| 274 | purple_person_list_model_init(GListModelInterface *iface) { | |
| 275 | iface->get_item_type = purple_person_get_item_type; | |
| 276 | iface->get_n_items = purple_person_get_n_items; | |
| 277 | iface->get_item = purple_person_get_item; | |
| 278 | } | |
| 279 | ||
| 280 | /****************************************************************************** | |
| 281 | * GObject Implementation | |
| 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 | 286 | |
| 287 | static void | |
| 288 | purple_person_get_property(GObject *obj, guint param_id, GValue *value, | |
| 289 | GParamSpec *pspec) | |
| 290 | { | |
| 291 | PurplePerson *person = PURPLE_PERSON(obj); | |
| 292 | ||
| 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 | 334 | } |
| 335 | } | |
| 336 | ||
| 337 | static void | |
| 338 | purple_person_set_property(GObject *obj, guint param_id, const GValue *value, | |
| 339 | GParamSpec *pspec) | |
| 340 | { | |
| 341 | PurplePerson *person = PURPLE_PERSON(obj); | |
| 342 | ||
| 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 | 359 | } |
| 360 | } | |
| 361 | ||
| 362 | static void | |
| 363 | purple_person_dispose(GObject *obj) { | |
| 364 | PurplePerson *person = PURPLE_PERSON(obj); | |
| 365 | ||
| 366 | g_clear_object(&person->avatar); | |
| 367 | g_clear_object(&person->tags); | |
| 368 | ||
| 369 | if(person->contacts != NULL) { | |
| 370 | g_ptr_array_free(person->contacts, TRUE); | |
| 371 | person->contacts = NULL; | |
| 372 | } | |
| 373 | ||
| 374 | G_OBJECT_CLASS(purple_person_parent_class)->dispose(obj); | |
| 375 | } | |
| 376 | ||
| 377 | static void | |
| 378 | purple_person_finalize(GObject *obj) { | |
| 379 | PurplePerson *person = PURPLE_PERSON(obj); | |
| 380 | ||
| 381 | g_clear_pointer(&person->id, g_free); | |
| 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 | 384 | |
| 385 | G_OBJECT_CLASS(purple_person_parent_class)->finalize(obj); | |
| 386 | } | |
| 387 | ||
| 388 | static void | |
| 389 | purple_person_constructed(GObject *obj) { | |
| 390 | PurplePerson *person = NULL; | |
| 391 | ||
| 392 | G_OBJECT_CLASS(purple_person_parent_class)->constructed(obj); | |
| 393 | ||
| 394 | person = PURPLE_PERSON(obj); | |
| 395 | if(person->id == NULL) { | |
| 396 | purple_person_set_id(person, NULL); | |
| 397 | } | |
| 398 | } | |
| 399 | ||
| 400 | static void | |
| 401 | purple_person_init(PurplePerson *person) { | |
| 402 | person->tags = purple_tags_new(); | |
| 403 | person->contacts = g_ptr_array_new_full(0, (GDestroyNotify)g_object_unref); | |
| 404 | } | |
| 405 | ||
| 406 | static void | |
| 407 | purple_person_class_init(PurplePersonClass *klass) { | |
| 408 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); | |
| 409 | ||
| 410 | obj_class->get_property = purple_person_get_property; | |
| 411 | obj_class->set_property = purple_person_set_property; | |
| 412 | obj_class->constructed = purple_person_constructed; | |
| 413 | obj_class->dispose = purple_person_dispose; | |
| 414 | obj_class->finalize = purple_person_finalize; | |
| 415 | ||
| 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 | 441 | * PurplePerson:id: |
| 442 | * | |
| 443 | * The protocol specific id for the contact. | |
| 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 | 446 | */ |
| 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 | 449 | NULL, |
| 450 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); | |
| 451 | ||
| 452 | /** | |
| 453 | * PurplePerson:alias: | |
| 454 | * | |
| 455 | * The alias for this person. This is controlled by the libpurple user. | |
| 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 | 458 | */ |
| 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 | 461 | NULL, |
| 462 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); | |
| 463 | ||
| 464 | /** | |
| 465 | * PurplePerson:avatar: | |
| 466 | * | |
| 467 | * The avatar for this person. This is controlled by the libpurple user, | |
| 468 | * which they can use to set a custom avatar. | |
| 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 | 471 | */ |
| 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 | 475 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
| 476 | ||
| 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 | 525 | * PurplePerson:tags: |
| 526 | * | |
| 527 | * The [class@Purple.Tags] for this person. | |
| 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 | 530 | */ |
| 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 | 533 | PURPLE_TYPE_TAGS, |
| 534 | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); | |
| 535 | ||
| 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 | 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 | 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 | 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 | 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 | 567 | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); |
| 568 | ||
| 569 | g_object_class_install_properties(obj_class, N_PROPERTIES, properties); | |
| 570 | } | |
| 571 | ||
| 572 | /****************************************************************************** | |
| 573 | * Public API | |
| 574 | *****************************************************************************/ | |
| 575 | PurplePerson * | |
| 576 | purple_person_new(void) { | |
| 577 | return g_object_new(PURPLE_TYPE_PERSON, NULL); | |
| 578 | } | |
| 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 | 581 | purple_person_get_id(PurplePerson *person) { |
| 582 | g_return_val_if_fail(PURPLE_IS_PERSON(person), NULL); | |
| 583 | ||
| 584 | return person->id; | |
| 585 | } | |
| 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 | 588 | purple_person_get_alias(PurplePerson *person) { |
| 589 | g_return_val_if_fail(PURPLE_IS_PERSON(person), NULL); | |
| 590 | ||
| 591 | return person->alias; | |
| 592 | } | |
| 593 | ||
| 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 | 596 | g_return_if_fail(PURPLE_IS_PERSON(person)); |
| 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 | 606 | } |
| 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 | 627 | purple_person_get_avatar(PurplePerson *person) { |
| 628 | g_return_val_if_fail(PURPLE_IS_PERSON(person), NULL); | |
| 629 | ||
| 630 | return person->avatar; | |
| 631 | } | |
| 632 | ||
| 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 | 635 | g_return_if_fail(PURPLE_IS_PERSON(person)); |
| 636 | ||
| 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 | 644 | } |
| 645 | } | |
| 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 | 686 | PurpleTags * |
| 687 | purple_person_get_tags(PurplePerson *person) { | |
| 688 | g_return_val_if_fail(PURPLE_IS_PERSON(person), NULL); | |
| 689 | ||
| 690 | return person->tags; | |
| 691 | } | |
| 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 | 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 | 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 | 717 | |
| 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 | 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 | 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 | 728 | person, 0); |
| 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 | 733 | } |
| 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 | 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 | 763 | |
| 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 | 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 | 772 | } |
| 773 | ||
|
43171
914049a55a72
Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents:
43128
diff
changeset
|
774 | return TRUE; |
| 41749 | 775 | } |
| 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 | 779 | g_return_val_if_fail(PURPLE_IS_PERSON(person), NULL); |
| 780 | ||
| 781 | if(person->contacts->len == 0) { | |
| 782 | return NULL; | |
| 783 | } | |
| 784 | ||
| 785 | return g_ptr_array_index(person->contacts, 0); | |
| 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 | } |