Sun, 14 Apr 2024 01:14:59 -0500
Remove PurpleBuddy
PurpleContactInfo was created long ago to replace this, it is now its time!
Testing Done:
Ran the turtles.
Reviewed at https://reviews.imfreedom.org/r/3123/
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
1 | /* |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
2 | * Purple - Internet Messaging Library |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
4 | * |
|
42594
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42583
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:
42583
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:
42583
diff
changeset
|
7 | * source distribution. |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
8 | * |
|
42594
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42583
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:
42583
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:
42583
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:
42583
diff
changeset
|
12 | * any later version. |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * |
|
42594
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42583
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:
42583
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:
42583
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:
42583
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:
42583
diff
changeset
|
18 | * |
|
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42583
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:
42583
diff
changeset
|
20 | * this library; if not, see <https://www.gnu.org/licenses/>. |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | */ |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
23 | #include <glib/gi18n-lib.h> |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | |
|
42583
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
25 | #include <birb.h> |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
26 | |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | #include "purplecontactmanager.h" |
|
41771
c5877e2c93f2
Create and add PurpleContacts to the manager when purple_buddy_new is called
Gary Kramlich <grim@reaperworld.com>
parents:
41759
diff
changeset
|
28 | |
|
c5877e2c93f2
Create and add PurpleContacts to the manager when purple_buddy_new is called
Gary Kramlich <grim@reaperworld.com>
parents:
41759
diff
changeset
|
29 | #include "purplegdkpixbuf.h" |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
30 | #include "purpleprivate.h" |
|
42245
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
31 | #include "purpleprotocolroster.h" |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
32 | #include "util.h" |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
33 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
34 | enum { |
|
42660
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
35 | PROP_0, |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
36 | PROP_ITEM_TYPE, |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
37 | PROP_N_ITEMS, |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
38 | N_PROPERTIES, |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
39 | }; |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
40 | static GParamSpec *properties[N_PROPERTIES] = {NULL, }; |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
41 | |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
42 | enum { |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
43 | SIG_ADDED, |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
44 | SIG_REMOVED, |
|
41975
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
45 | SIG_PERSON_ADDED, |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
46 | SIG_PERSON_REMOVED, |
|
42583
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
47 | SIG_POPULATE_MENU, |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
48 | N_SIGNALS, |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
49 | }; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
50 | static guint signals[N_SIGNALS] = {0, }; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
51 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
52 | struct _PurpleContactManager { |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
53 | GObject parent; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
54 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
55 | GHashTable *accounts; |
|
41975
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
56 | |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
57 | GPtrArray *people; |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
58 | }; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
59 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
60 | static PurpleContactManager *default_manager = NULL; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
61 | |
|
41975
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
62 | /* Necessary prototype. */ |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
63 | static void purple_contact_manager_contact_person_changed_cb(GObject *obj, |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
64 | GParamSpec *pspec, |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
65 | gpointer data); |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
66 | |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
67 | /****************************************************************************** |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
68 | * Helpers |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
69 | *****************************************************************************/ |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
70 | static gboolean |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
71 | purple_contact_manager_find_with_username_helper(gconstpointer a, |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
72 | gconstpointer b) |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
73 | { |
|
41956
ba714f65be70
Silence some warning in PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41948
diff
changeset
|
74 | PurpleContactInfo *info_a = PURPLE_CONTACT_INFO((gpointer)a); |
|
ba714f65be70
Silence some warning in PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41948
diff
changeset
|
75 | PurpleContactInfo *info_b = PURPLE_CONTACT_INFO((gpointer)b); |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
76 | const gchar *username_a = NULL; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
77 | const gchar *username_b = NULL; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
78 | |
|
41948
6d844d2faff1
Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents:
41771
diff
changeset
|
79 | username_a = purple_contact_info_get_username(info_a); |
|
6d844d2faff1
Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents:
41771
diff
changeset
|
80 | username_b = purple_contact_info_get_username(info_b); |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
81 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
82 | return purple_strequal(username_a, username_b); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
83 | } |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
84 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
85 | static gboolean |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
86 | purple_contact_manager_find_with_id_helper(gconstpointer a, gconstpointer b) { |
|
41956
ba714f65be70
Silence some warning in PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41948
diff
changeset
|
87 | PurpleContactInfo *info_a = PURPLE_CONTACT_INFO((gpointer)a); |
|
ba714f65be70
Silence some warning in PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41948
diff
changeset
|
88 | PurpleContactInfo *info_b = PURPLE_CONTACT_INFO((gpointer)b); |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
89 | const gchar *id_a = NULL; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
90 | const gchar *id_b = NULL; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
91 | |
|
41948
6d844d2faff1
Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents:
41771
diff
changeset
|
92 | id_a = purple_contact_info_get_id(info_a); |
|
6d844d2faff1
Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents:
41771
diff
changeset
|
93 | id_b = purple_contact_info_get_id(info_b); |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
94 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
95 | return purple_strequal(id_a, id_b); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
96 | } |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
97 | |
|
42245
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
98 | static void |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
99 | purple_contact_manager_protocol_roster_update(PurpleContact *contact) { |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
100 | PurpleAccount *account = NULL; |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
101 | |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
102 | account = purple_contact_get_account(contact); |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
103 | if(PURPLE_IS_ACCOUNT(account)) { |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
104 | PurpleProtocol *protocol = NULL; |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
105 | |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
106 | protocol = purple_account_get_protocol(account); |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
107 | if(PURPLE_IS_PROTOCOL_ROSTER(protocol)) { |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
108 | purple_protocol_roster_update_async(PURPLE_PROTOCOL_ROSTER(protocol), |
|
42256
829e76c73ed1
Add an account parameter to all async methods for PurpleProtocolRoster
Gary Kramlich <grim@reaperworld.com>
parents:
42245
diff
changeset
|
109 | account, contact, NULL, NULL, |
|
829e76c73ed1
Add an account parameter to all async methods for PurpleProtocolRoster
Gary Kramlich <grim@reaperworld.com>
parents:
42245
diff
changeset
|
110 | NULL); |
|
42245
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
111 | } |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
112 | } |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
113 | } |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
114 | |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
115 | /****************************************************************************** |
|
41975
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
116 | * Callbacks |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
117 | *****************************************************************************/ |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
118 | static void |
|
42245
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
119 | purple_contact_manager_contact_update_cb(GObject *obj, |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
120 | G_GNUC_UNUSED GParamSpec *pspec, |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
121 | G_GNUC_UNUSED gpointer data) |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
122 | { |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
123 | purple_contact_manager_protocol_roster_update(PURPLE_CONTACT(obj)); |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
124 | } |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
125 | |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
126 | static void |
|
41975
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
127 | purple_contact_manager_contact_person_changed_cb(GObject *obj, |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
128 | G_GNUC_UNUSED GParamSpec *pspec, |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
129 | gpointer data) |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
130 | { |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
131 | PurpleContact *contact = PURPLE_CONTACT(obj); |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
132 | PurpleContactManager *manager = data; |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
133 | PurplePerson *person = NULL; |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
134 | |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
135 | person = purple_contact_info_get_person(PURPLE_CONTACT_INFO(contact)); |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
136 | /* If the person is now NULL, we leaving the existing person in place as |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
137 | * we don't want to potentially delete user data. |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
138 | */ |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
139 | if(!PURPLE_IS_PERSON(person)) { |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
140 | return; |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
141 | } |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
142 | |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
143 | /* At this point the person changed or is new so we need to add the new |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
144 | * person. |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
145 | */ |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
146 | purple_contact_manager_add_person(manager, person); |
|
42245
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
147 | |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
148 | /* Finally tell the ProtocolRoster about this change. */ |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
149 | purple_contact_manager_protocol_roster_update(contact); |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
150 | } |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
151 | |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
152 | static void |
|
42583
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
153 | purple_contact_manager_contact_populate_menu_cb(PurpleContactInfo *info, |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
154 | GMenu *menu, |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
155 | gpointer data) |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
156 | { |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
157 | g_signal_emit(data, signals[SIG_POPULATE_MENU], 0, info, menu); |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
158 | } |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
159 | |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
160 | static void |
|
42245
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
161 | purple_contact_manager_tags_changed_cb(G_GNUC_UNUSED PurpleTags *tags, |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
162 | G_GNUC_UNUSED const char *tag, |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
163 | G_GNUC_UNUSED const char *name, |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
164 | G_GNUC_UNUSED const char *value, |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
165 | gpointer data) |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
166 | { |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
167 | purple_contact_manager_protocol_roster_update(data); |
|
41975
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
168 | } |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
169 | |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
170 | /****************************************************************************** |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
171 | * GListModel Implementation |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
172 | *****************************************************************************/ |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
173 | static GType |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
174 | purple_contact_manager_get_item_type(G_GNUC_UNUSED GListModel *list) { |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
175 | return PURPLE_TYPE_PERSON; |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
176 | } |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
177 | |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
178 | static guint |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
179 | purple_contact_manager_get_n_items(GListModel *list) { |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
180 | PurpleContactManager *manager = PURPLE_CONTACT_MANAGER(list); |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
181 | |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
182 | return manager->people->len; |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
183 | } |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
184 | |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
185 | static gpointer |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
186 | purple_contact_manager_get_item(GListModel *list, guint position) { |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
187 | PurpleContactManager *manager = PURPLE_CONTACT_MANAGER(list); |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
188 | PurpleContact *contact = NULL; |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
189 | |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
190 | if(position < manager->people->len) { |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
191 | contact = g_object_ref(g_ptr_array_index(manager->people, position)); |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
192 | } |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
193 | |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
194 | return contact; |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
195 | } |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
196 | |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
197 | static void |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
198 | pidgin_contact_manager_list_model_iface_init(GListModelInterface *iface) { |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
199 | iface->get_item_type = purple_contact_manager_get_item_type; |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
200 | iface->get_n_items = purple_contact_manager_get_n_items; |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
201 | iface->get_item = purple_contact_manager_get_item; |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
202 | } |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
203 | |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
204 | /****************************************************************************** |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
205 | * GObject Implementation |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
206 | *****************************************************************************/ |
|
41975
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
207 | G_DEFINE_FINAL_TYPE_WITH_CODE(PurpleContactManager, purple_contact_manager, |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
208 | G_TYPE_OBJECT, |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
209 | G_IMPLEMENT_INTERFACE(G_TYPE_LIST_MODEL, |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
210 | pidgin_contact_manager_list_model_iface_init)) |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
211 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
212 | static void |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
213 | purple_contact_manager_dispose(GObject *obj) { |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
214 | PurpleContactManager *manager = NULL; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
215 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
216 | manager = PURPLE_CONTACT_MANAGER(obj); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
217 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
218 | g_hash_table_remove_all(manager->accounts); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
219 | |
|
41975
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
220 | if(manager->people != NULL) { |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
221 | g_ptr_array_free(manager->people, TRUE); |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
222 | manager->people = NULL; |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
223 | } |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
224 | |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
225 | G_OBJECT_CLASS(purple_contact_manager_parent_class)->dispose(obj); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
226 | } |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
227 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
228 | static void |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
229 | purple_contact_manager_finalize(GObject *obj) { |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
230 | PurpleContactManager *manager = NULL; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
231 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
232 | manager = PURPLE_CONTACT_MANAGER(obj); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
233 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
234 | g_clear_pointer(&manager->accounts, g_hash_table_destroy); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
235 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
236 | G_OBJECT_CLASS(purple_contact_manager_parent_class)->finalize(obj); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
237 | } |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
238 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
239 | static void |
|
42660
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
240 | purple_contact_manager_get_property(GObject *obj, guint param_id, |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
241 | GValue *value, GParamSpec *pspec) |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
242 | { |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
243 | PurpleContactManager *manager = PURPLE_CONTACT_MANAGER(obj); |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
244 | |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
245 | switch(param_id) { |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
246 | case PROP_ITEM_TYPE: |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
247 | g_value_set_gtype(value, |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
248 | purple_contact_manager_get_item_type(G_LIST_MODEL(manager))); |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
249 | break; |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
250 | case PROP_N_ITEMS: |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
251 | g_value_set_uint(value, |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
252 | purple_contact_manager_get_n_items(G_LIST_MODEL(manager))); |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
253 | break; |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
254 | default: |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
255 | G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
256 | break; |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
257 | } |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
258 | } |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
259 | |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
260 | static void |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
261 | purple_contact_manager_init(PurpleContactManager *manager) { |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
262 | manager->accounts = g_hash_table_new_full(g_direct_hash, g_direct_equal, |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
263 | g_object_unref, g_object_unref); |
|
41975
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
264 | |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
265 | /* 100 Seems like a reasonable default of the number people on your contact |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
266 | * list. - gk 20221109 |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
267 | */ |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
268 | manager->people = g_ptr_array_new_full(100, |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
269 | (GDestroyNotify)g_object_unref); |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
270 | } |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
271 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
272 | static void |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
273 | purple_contact_manager_class_init(PurpleContactManagerClass *klass) { |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
274 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
275 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
276 | obj_class->dispose = purple_contact_manager_dispose; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
277 | obj_class->finalize = purple_contact_manager_finalize; |
|
42660
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
278 | obj_class->get_property = purple_contact_manager_get_property; |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
279 | |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
280 | /** |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
281 | * PurpleContactManager:item-type: |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
282 | * |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
283 | * The type of items. See [iface@Gio.ListModel.get_item_type]. |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
284 | * |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
285 | * Since: 3.0 |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
286 | */ |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
287 | properties[PROP_ITEM_TYPE] = g_param_spec_gtype( |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
288 | "item-type", "item-type", |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
289 | "The type of the contained items.", |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
290 | G_TYPE_OBJECT, |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
291 | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
292 | |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
293 | /** |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
294 | * PurpleContactManager:n-items: |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
295 | * |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
296 | * The number of items. See [iface@Gio.ListModel.get_n_items]. |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
297 | * |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
298 | * Since: 3.0 |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
299 | */ |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
300 | properties[PROP_N_ITEMS] = g_param_spec_uint( |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
301 | "n-items", "n-items", |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
302 | "The number of contained items.", |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
303 | 0, G_MAXUINT, 0, |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
304 | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
305 | |
|
22d709f9f47b
Add item-type and n-items properties to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
306 | g_object_class_install_properties(obj_class, N_PROPERTIES, properties); |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
307 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
308 | /** |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
309 | * PurpleContactManager::added: |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
310 | * @manager: The instance. |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
311 | * @contact: The [class@Purple.Contact] that was registered. |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
312 | * |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
313 | * Emitted after @contact has been added to @manager. |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
314 | * |
|
42583
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
315 | * Since: 3.0 |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
316 | */ |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
317 | signals[SIG_ADDED] = g_signal_new_class_handler( |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
318 | "added", |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
319 | G_OBJECT_CLASS_TYPE(klass), |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
320 | G_SIGNAL_RUN_LAST, |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
321 | NULL, |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
322 | NULL, |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
323 | NULL, |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
324 | NULL, |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
325 | G_TYPE_NONE, |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
326 | 1, |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
327 | PURPLE_TYPE_CONTACT); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
328 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
329 | /** |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
330 | * PurpleContactManager::removed: |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
331 | * @manager: The instance. |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
332 | * @contact: The [class@Purple.Contact] that was removed. |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
333 | * |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
334 | * Emitted after @contact has been removed from @manager. |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
335 | * |
|
42583
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
336 | * Since: 3.0 |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
337 | */ |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
338 | signals[SIG_REMOVED] = g_signal_new_class_handler( |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
339 | "removed", |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
340 | G_OBJECT_CLASS_TYPE(klass), |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
341 | G_SIGNAL_RUN_LAST, |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
342 | NULL, |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
343 | NULL, |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
344 | NULL, |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
345 | NULL, |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
346 | G_TYPE_NONE, |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
347 | 1, |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
348 | PURPLE_TYPE_CONTACT); |
|
41975
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
349 | |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
350 | /** |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
351 | * PurpleContactManager::person-added: |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
352 | * @manager: The instance. |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
353 | * @person: The [class@Purple.Person] that was added. |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
354 | * |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
355 | * Emitted after @person has been added to @manager. This is typically done |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
356 | * when a contact is added via [method@Purple.ContactManager.add] but can |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
357 | * also happen if [method@Purple.ContactManager.add_person] is called. |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
358 | * |
|
42583
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
359 | * Since: 3.0 |
|
41975
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
360 | */ |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
361 | signals[SIG_PERSON_ADDED] = g_signal_new_class_handler( |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
362 | "person-added", |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
363 | G_OBJECT_CLASS_TYPE(klass), |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
364 | G_SIGNAL_RUN_LAST, |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
365 | NULL, |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
366 | NULL, |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
367 | NULL, |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
368 | NULL, |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
369 | G_TYPE_NONE, |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
370 | 1, |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
371 | PURPLE_TYPE_PERSON); |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
372 | |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
373 | /** |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
374 | * PurpleContactManager::person-removed: |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
375 | * @manager: The instance. |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
376 | * @person: The [class@Purple.Person] that was removed. |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
377 | * |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
378 | * Emitted after @person has been removed from @manager. This typically |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
379 | * happens when [method@Purple.ContactManager.remove_person] is called. |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
380 | * |
|
42583
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
381 | * Since: 3.0 |
|
41975
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
382 | */ |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
383 | signals[SIG_PERSON_REMOVED] = g_signal_new_class_handler( |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
384 | "person-removed", |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
385 | G_OBJECT_CLASS_TYPE(klass), |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
386 | G_SIGNAL_RUN_LAST, |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
387 | NULL, |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
388 | NULL, |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
389 | NULL, |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
390 | NULL, |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
391 | G_TYPE_NONE, |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
392 | 1, |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
393 | PURPLE_TYPE_PERSON); |
|
42583
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
394 | |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
395 | /** |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
396 | * PurpleContactManager::populate-menu: |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
397 | * @manager: The instance. |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
398 | * @info: The [class@ContactInfo] instance. |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
399 | * @menu: The [class@Gio.Menu] to populate. |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
400 | * |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
401 | * This is a propagation of [signal@ContactInfo::populate-menu]. This means |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
402 | * that your callback will be called for any contact info to populate its |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
403 | * context menu. |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
404 | * |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
405 | * Since: 3.0 |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
406 | */ |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
407 | signals[SIG_POPULATE_MENU] = g_signal_new_class_handler( |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
408 | "populate-menu", |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
409 | G_OBJECT_CLASS_TYPE(klass), |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
410 | G_SIGNAL_RUN_LAST, |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
411 | NULL, |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
412 | NULL, |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
413 | NULL, |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
414 | NULL, |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
415 | G_TYPE_NONE, |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
416 | 2, |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
417 | PURPLE_TYPE_CONTACT_INFO, |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
418 | BIRB_TYPE_ACTION_MENU); |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
419 | } |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
420 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
421 | /****************************************************************************** |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
422 | * Private API |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
423 | *****************************************************************************/ |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
424 | void |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
425 | purple_contact_manager_startup(void) { |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
426 | if(default_manager == NULL) { |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
427 | default_manager = g_object_new(PURPLE_TYPE_CONTACT_MANAGER, NULL); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
428 | g_object_add_weak_pointer(G_OBJECT(default_manager), |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
429 | (gpointer)&default_manager); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
430 | } |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
431 | } |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
432 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
433 | void |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
434 | purple_contact_manager_shutdown(void) { |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
435 | g_clear_object(&default_manager); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
436 | } |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
437 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
438 | /****************************************************************************** |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
439 | * Public API |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
440 | *****************************************************************************/ |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
441 | PurpleContactManager * |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
442 | purple_contact_manager_get_default(void) { |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
443 | if(G_UNLIKELY(!PURPLE_IS_CONTACT_MANAGER(default_manager))) { |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
444 | g_warning("The default contact manager was unexpectedly NULL"); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
445 | } |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
446 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
447 | return default_manager; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
448 | } |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
449 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
450 | void |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
451 | purple_contact_manager_add(PurpleContactManager *manager, |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
452 | PurpleContact *contact) |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
453 | { |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
454 | PurpleAccount *account = NULL; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
455 | GListStore *contacts = NULL; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
456 | gboolean added = FALSE; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
457 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
458 | g_return_if_fail(PURPLE_IS_CONTACT_MANAGER(manager)); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
459 | g_return_if_fail(PURPLE_IS_CONTACT(contact)); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
460 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
461 | account = purple_contact_get_account(contact); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
462 | contacts = g_hash_table_lookup(manager->accounts, account); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
463 | if(!G_IS_LIST_STORE(contacts)) { |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
464 | contacts = g_list_store_new(PURPLE_TYPE_CONTACT); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
465 | g_hash_table_insert(manager->accounts, g_object_ref(account), contacts); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
466 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
467 | g_list_store_append(contacts, contact); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
468 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
469 | added = TRUE; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
470 | } else { |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
471 | if(g_list_store_find(contacts, contact, NULL)) { |
|
41948
6d844d2faff1
Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents:
41771
diff
changeset
|
472 | PurpleContactInfo *info = PURPLE_CONTACT_INFO(contact); |
|
6d844d2faff1
Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents:
41771
diff
changeset
|
473 | const gchar *username = purple_contact_info_get_username(info); |
|
6d844d2faff1
Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents:
41771
diff
changeset
|
474 | const gchar *id = purple_contact_info_get_id(info); |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
475 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
476 | g_warning("double add detected for contact %s:%s", id, username); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
477 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
478 | return; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
479 | } |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
480 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
481 | g_list_store_append(contacts, contact); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
482 | added = TRUE; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
483 | } |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
484 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
485 | if(added) { |
|
41975
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
486 | PurpleContactInfo *info = PURPLE_CONTACT_INFO(contact); |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
487 | PurplePerson *person = purple_contact_info_get_person(info); |
|
42245
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
488 | PurpleTags *tags = NULL; |
|
41975
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
489 | |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
490 | /* If the contact already has a person, add the person to our list of |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
491 | * people. |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
492 | */ |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
493 | if(PURPLE_IS_PERSON(person)) { |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
494 | purple_contact_manager_add_person(manager, person); |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
495 | } |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
496 | |
|
42245
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
497 | tags = purple_contact_info_get_tags(info); |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
498 | |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
499 | /* Add some notify signals to track changes. */ |
|
42583
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
500 | g_signal_connect_object(info, "notify::alias", |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
501 | G_CALLBACK(purple_contact_manager_contact_update_cb), |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
502 | manager, 0); |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
503 | g_signal_connect_object(info, "notify::permission", |
|
42245
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
504 | G_CALLBACK(purple_contact_manager_contact_update_cb), |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
505 | manager, 0); |
|
42583
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
506 | g_signal_connect_object(info, "notify::person", |
|
41975
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
507 | G_CALLBACK(purple_contact_manager_contact_person_changed_cb), |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
508 | manager, 0); |
|
42583
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
509 | g_signal_connect_object(info, "populate-menu", |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
510 | G_CALLBACK(purple_contact_manager_contact_populate_menu_cb), |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
511 | manager, 0); |
|
8a8c571eb98c
Add a propagation signal for populate-menu to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
42256
diff
changeset
|
512 | |
|
42245
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
513 | g_signal_connect_object(tags, "added", |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
514 | G_CALLBACK(purple_contact_manager_tags_changed_cb), |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
515 | contact, 0); |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
516 | g_signal_connect_object(tags, "removed", |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
517 | G_CALLBACK(purple_contact_manager_tags_changed_cb), |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
518 | contact, 0); |
|
41975
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
519 | |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
520 | g_signal_emit(manager, signals[SIG_ADDED], 0, contact); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
521 | } |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
522 | } |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
523 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
524 | gboolean |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
525 | purple_contact_manager_remove(PurpleContactManager *manager, |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
526 | PurpleContact *contact) |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
527 | { |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
528 | PurpleAccount *account = NULL; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
529 | GListStore *contacts = NULL; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
530 | guint position = 0; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
531 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
532 | g_return_val_if_fail(PURPLE_IS_CONTACT_MANAGER(manager), FALSE); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
533 | g_return_val_if_fail(PURPLE_IS_CONTACT(contact), FALSE); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
534 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
535 | account = purple_contact_get_account(contact); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
536 | contacts = g_hash_table_lookup(manager->accounts, account); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
537 | if(!G_IS_LIST_STORE(contacts)) { |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
538 | return FALSE; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
539 | } |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
540 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
541 | if(g_list_store_find(contacts, contact, &position)) { |
|
42245
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
542 | PurpleTags *tags = NULL; |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
543 | gboolean removed = FALSE; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
544 | guint len = 0; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
545 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
546 | /* Ref the contact to make sure that the instance is valid when we emit |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
547 | * the removed signal. |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
548 | */ |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
549 | g_object_ref(contact); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
550 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
551 | len = g_list_model_get_n_items(G_LIST_MODEL(contacts)); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
552 | g_list_store_remove(contacts, position); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
553 | if(g_list_model_get_n_items(G_LIST_MODEL(contacts)) < len) { |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
554 | removed = TRUE; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
555 | } |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
556 | |
|
42245
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
557 | /* Remove the signals for the contact's tags changing as we're no |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
558 | * longer tracking the contact they belong to. |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
559 | */ |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
560 | tags = purple_contact_info_get_tags(PURPLE_CONTACT_INFO(contact)); |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
561 | g_signal_handlers_disconnect_by_func(tags, |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
562 | purple_contact_manager_tags_changed_cb, |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
563 | contact); |
|
57a4955beaf3
Update ContactManager to call ProtocolRoster.update_async when necessary
Gary Kramlich <grim@reaperworld.com>
parents:
42201
diff
changeset
|
564 | |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
565 | if(removed) { |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
566 | g_signal_emit(manager, signals[SIG_REMOVED], 0, contact); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
567 | } |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
568 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
569 | g_object_unref(contact); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
570 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
571 | return removed; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
572 | } |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
573 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
574 | return FALSE; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
575 | } |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
576 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
577 | gboolean |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
578 | purple_contact_manager_remove_all(PurpleContactManager *manager, |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
579 | PurpleAccount *account) |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
580 | { |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
581 | GListStore *contacts = NULL; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
582 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
583 | g_return_val_if_fail(PURPLE_IS_CONTACT_MANAGER(manager), FALSE); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
584 | g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), FALSE); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
585 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
586 | /* If there are any contacts for this account, manually iterate them and |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
587 | * emit the removed signal. This is more efficient than calling remove on |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
588 | * each one individually as that would require updating the backing |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
589 | * GListStore for each individual removal. |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
590 | */ |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
591 | contacts = g_hash_table_lookup(manager->accounts, account); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
592 | if(G_IS_LIST_STORE(contacts)) { |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
593 | guint n_items = g_list_model_get_n_items(G_LIST_MODEL(contacts)); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
594 | for(guint i = 0; i < n_items; i++) { |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
595 | PurpleContact *contact = NULL; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
596 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
597 | contact = g_list_model_get_item(G_LIST_MODEL(contacts), i); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
598 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
599 | g_signal_emit(manager, signals[SIG_REMOVED], 0, contact); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
600 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
601 | g_clear_object(&contact); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
602 | } |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
603 | } |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
604 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
605 | return g_hash_table_remove(manager->accounts, account); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
606 | } |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
607 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
608 | GListModel * |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
609 | purple_contact_manager_get_all(PurpleContactManager *manager, |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
610 | PurpleAccount *account) |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
611 | { |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
612 | g_return_val_if_fail(PURPLE_IS_CONTACT_MANAGER(manager), FALSE); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
613 | g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), FALSE); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
614 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
615 | return g_hash_table_lookup(manager->accounts, account); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
616 | } |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
617 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
618 | PurpleContact * |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
619 | purple_contact_manager_find_with_username(PurpleContactManager *manager, |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
620 | PurpleAccount *account, |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
621 | const gchar *username) |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
622 | { |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
623 | PurpleContact *needle = NULL; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
624 | GListStore *contacts = NULL; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
625 | guint position = 0; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
626 | gboolean found = FALSE; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
627 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
628 | g_return_val_if_fail(PURPLE_IS_CONTACT_MANAGER(manager), FALSE); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
629 | g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), FALSE); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
630 | g_return_val_if_fail(username != NULL, FALSE); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
631 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
632 | contacts = g_hash_table_lookup(manager->accounts, account); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
633 | if(!G_IS_LIST_STORE(contacts)) { |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
634 | return NULL; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
635 | } |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
636 | |
|
41759
1ecc0512e714
Make purple_contact_new take the id instead of the username.
Gary Kramlich <grim@reaperworld.com>
parents:
41754
diff
changeset
|
637 | needle = purple_contact_new(account, NULL); |
|
41948
6d844d2faff1
Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents:
41771
diff
changeset
|
638 | purple_contact_info_set_username(PURPLE_CONTACT_INFO(needle), username); |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
639 | found = g_list_store_find_with_equal_func(contacts, needle, |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
640 | purple_contact_manager_find_with_username_helper, |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
641 | &position); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
642 | g_clear_object(&needle); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
643 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
644 | if(found) { |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
645 | return g_list_model_get_item(G_LIST_MODEL(contacts), position); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
646 | } |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
647 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
648 | return NULL; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
649 | } |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
650 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
651 | PurpleContact * |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
652 | purple_contact_manager_find_with_id(PurpleContactManager *manager, |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
653 | PurpleAccount *account, const gchar *id) |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
654 | { |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
655 | PurpleContact *needle = NULL; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
656 | GListStore *contacts = NULL; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
657 | guint position = 0; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
658 | gboolean found = FALSE; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
659 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
660 | g_return_val_if_fail(PURPLE_IS_CONTACT_MANAGER(manager), FALSE); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
661 | g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), FALSE); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
662 | g_return_val_if_fail(id != NULL, FALSE); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
663 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
664 | contacts = g_hash_table_lookup(manager->accounts, account); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
665 | if(!G_IS_LIST_STORE(contacts)) { |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
666 | return NULL; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
667 | } |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
668 | |
|
41759
1ecc0512e714
Make purple_contact_new take the id instead of the username.
Gary Kramlich <grim@reaperworld.com>
parents:
41754
diff
changeset
|
669 | needle = purple_contact_new(account, id); |
|
41754
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
670 | found = g_list_store_find_with_equal_func(contacts, needle, |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
671 | purple_contact_manager_find_with_id_helper, |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
672 | &position); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
673 | g_clear_object(&needle); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
674 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
675 | if(found) { |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
676 | return g_list_model_get_item(G_LIST_MODEL(contacts), position); |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
677 | } |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
678 | |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
679 | return NULL; |
|
abf413211063
Create the new PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
680 | } |
|
41771
c5877e2c93f2
Create and add PurpleContacts to the manager when purple_buddy_new is called
Gary Kramlich <grim@reaperworld.com>
parents:
41759
diff
changeset
|
681 | |
|
41975
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
682 | void |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
683 | purple_contact_manager_add_person(PurpleContactManager *manager, |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
684 | PurplePerson *person) |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
685 | { |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
686 | g_return_if_fail(PURPLE_IS_CONTACT_MANAGER(manager)); |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
687 | g_return_if_fail(PURPLE_IS_PERSON(person)); |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
688 | |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
689 | /* If the person is already known, bail. */ |
|
42201
f4c0e44c3e20
Fix the issue where the contact list would sometimes duplicate everyone
Gary Kramlich <grim@reaperworld.com>
parents:
42178
diff
changeset
|
690 | if(g_ptr_array_find(manager->people, person, NULL)) { |
|
41975
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
691 | return; |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
692 | } |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
693 | |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
694 | /* Add the person and emit our signals. */ |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
695 | g_ptr_array_add(manager->people, g_object_ref(person)); |
|
42201
f4c0e44c3e20
Fix the issue where the contact list would sometimes duplicate everyone
Gary Kramlich <grim@reaperworld.com>
parents:
42178
diff
changeset
|
696 | g_list_model_items_changed(G_LIST_MODEL(manager), manager->people->len - 1, |
|
f4c0e44c3e20
Fix the issue where the contact list would sometimes duplicate everyone
Gary Kramlich <grim@reaperworld.com>
parents:
42178
diff
changeset
|
697 | 0, 1); |
|
41975
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
698 | g_signal_emit(manager, signals[SIG_PERSON_ADDED], 0, person); |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
699 | } |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
700 | |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
701 | void |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
702 | purple_contact_manager_remove_person(PurpleContactManager *manager, |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
703 | PurplePerson *person, |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
704 | gboolean remove_contacts) |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
705 | { |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
706 | guint index = 0; |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
707 | |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
708 | g_return_if_fail(PURPLE_IS_CONTACT_MANAGER(manager)); |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
709 | g_return_if_fail(PURPLE_IS_PERSON(person)); |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
710 | |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
711 | if(!g_ptr_array_find(manager->people, person, &index)) { |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
712 | return; |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
713 | } |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
714 | |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
715 | if(remove_contacts) { |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
716 | guint n = g_list_model_get_n_items(G_LIST_MODEL(person)); |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
717 | |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
718 | for(guint i = 0; i < n; i++) { |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
719 | PurpleContact *contact = NULL; |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
720 | |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
721 | contact = g_list_model_get_item(G_LIST_MODEL(person), i); |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
722 | if(PURPLE_IS_CONTACT(contact)) { |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
723 | purple_contact_manager_remove(manager, contact); |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
724 | g_object_unref(contact); |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
725 | } |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
726 | } |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
727 | } |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
728 | |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
729 | /* Add a ref to the person, so we can emit the removed signal after it |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
730 | * was actually removed, as our GPtrArray may be holding the last |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
731 | * reference. |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
732 | */ |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
733 | g_object_ref(person); |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
734 | |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
735 | g_ptr_array_remove_index(manager->people, index); |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
736 | |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
737 | g_list_model_items_changed(G_LIST_MODEL(manager), index, 1, 0); |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
738 | |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
739 | /* Emit the removed signal and clear our temporary reference. */ |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
740 | g_signal_emit(manager, signals[SIG_PERSON_REMOVED], 0, person); |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
741 | g_object_unref(person); |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
742 | } |
|
3ef645de21e7
Add tracking of PurplePerson's to PurpleContactManager
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
743 |