libpurple/protocols/bonjour/buddy.c

Fri, 01 May 2020 12:13:35 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Fri, 01 May 2020 12:13:35 -0500
changeset 40439
e9838d634d5e
parent 40080
a58c06469198
child 40674
6777a9b23fd0
permissions
-rw-r--r--

Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h

11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1 /*
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
2 * This program is free software; you can redistribute it and/or modify
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
3 * it under the terms of the GNU General Public License as published by
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
4 * the Free Software Foundation; either version 2 of the License, or
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
5 * (at your option) any later version.
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
6 *
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
7 * This program is distributed in the hope that it will be useful,
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
10 * GNU Library General Public License for more details.
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
11 *
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
12 * You should have received a copy of the GNU General Public License
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
13 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19748
diff changeset
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301, USA.
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
15 */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
16
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
17 #include <glib.h>
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
18 #include <stdlib.h>
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
19
39960
4a5610d858ef update bonjour to just use purple.h
Gary Kramlich <grim@reaperworld.com>
parents: 39815
diff changeset
20 #include <purple.h>
4a5610d858ef update bonjour to just use purple.h
Gary Kramlich <grim@reaperworld.com>
parents: 39815
diff changeset
21
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
22 #include "buddy.h"
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
23 #include "bonjour.h"
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 18338
diff changeset
24 #include "mdns_interface.h"
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
25
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
26 /**
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
27 * Creates a new buddy.
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
28 */
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
29 BonjourBuddy *
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents: 15884
diff changeset
30 bonjour_buddy_new(const gchar *name, PurpleAccount* account)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
31 {
17599
8b0aa6917c6d Don't force Bonjour buddies to have firstname, lastname and status TXT records - they are optional. Also, minor cleanup and use glib to allocate memory instead of the crt.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
32 BonjourBuddy *buddy = g_new0(BonjourBuddy, 1);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
33
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents: 15884
diff changeset
34 buddy->account = account;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
35 buddy->name = g_strdup(name);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
36
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 18338
diff changeset
37 _mdns_init_buddy(buddy);
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 18338
diff changeset
38
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
39 return buddy;
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
40 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
41
39815
77cda76aa2cd Replace _B_CLR with g_clear_pointer.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
42 void
77cda76aa2cd Replace _B_CLR with g_clear_pointer.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
43 clear_bonjour_buddy_values(BonjourBuddy *buddy)
77cda76aa2cd Replace _B_CLR with g_clear_pointer.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
44 {
77cda76aa2cd Replace _B_CLR with g_clear_pointer.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
45 g_clear_pointer(&buddy->first, g_free);
77cda76aa2cd Replace _B_CLR with g_clear_pointer.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
46 g_clear_pointer(&buddy->email, g_free);
77cda76aa2cd Replace _B_CLR with g_clear_pointer.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
47 g_clear_pointer(&buddy->ext, g_free);
77cda76aa2cd Replace _B_CLR with g_clear_pointer.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
48 g_clear_pointer(&buddy->jid, g_free);
77cda76aa2cd Replace _B_CLR with g_clear_pointer.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
49 g_clear_pointer(&buddy->last, g_free);
77cda76aa2cd Replace _B_CLR with g_clear_pointer.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
50 g_clear_pointer(&buddy->msg, g_free);
77cda76aa2cd Replace _B_CLR with g_clear_pointer.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
51 g_clear_pointer(&buddy->nick, g_free);
77cda76aa2cd Replace _B_CLR with g_clear_pointer.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
52 g_clear_pointer(&buddy->node, g_free);
77cda76aa2cd Replace _B_CLR with g_clear_pointer.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
53 g_clear_pointer(&buddy->phsh, g_free);
77cda76aa2cd Replace _B_CLR with g_clear_pointer.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
54 g_clear_pointer(&buddy->status, g_free);
77cda76aa2cd Replace _B_CLR with g_clear_pointer.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
55 g_clear_pointer(&buddy->vc, g_free);
77cda76aa2cd Replace _B_CLR with g_clear_pointer.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
56 g_clear_pointer(&buddy->ver, g_free);
77cda76aa2cd Replace _B_CLR with g_clear_pointer.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
57 g_clear_pointer(&buddy->AIM, g_free);
19220
60d667d6bdc5 Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <datallah@pidgin.im>
parents: 19208
diff changeset
58 }
60d667d6bdc5 Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <datallah@pidgin.im>
parents: 19208
diff changeset
59
17599
8b0aa6917c6d Don't force Bonjour buddies to have firstname, lastname and status TXT records - they are optional. Also, minor cleanup and use glib to allocate memory instead of the crt.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
60 void
20238
e4abd12fb7ec applied changes from e9e74094baa29c6f5589385507221a2502b817fb
Luke Schierer <lschiere@pidgin.im>
parents: 19859
diff changeset
61 set_bonjour_buddy_value(BonjourBuddy* buddy, const char *record_key, const char *value, guint32 len){
17611
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
62 gchar **fld = NULL;
17599
8b0aa6917c6d Don't force Bonjour buddies to have firstname, lastname and status TXT records - they are optional. Also, minor cleanup and use glib to allocate memory instead of the crt.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
63
20238
e4abd12fb7ec applied changes from e9e74094baa29c6f5589385507221a2502b817fb
Luke Schierer <lschiere@pidgin.im>
parents: 19859
diff changeset
64 g_return_if_fail(record_key != NULL);
e4abd12fb7ec applied changes from e9e74094baa29c6f5589385507221a2502b817fb
Luke Schierer <lschiere@pidgin.im>
parents: 19859
diff changeset
65
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 25132
diff changeset
66 if (purple_strequal(record_key, "1st"))
17611
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
67 fld = &buddy->first;
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 25132
diff changeset
68 else if(purple_strequal(record_key, "email"))
17611
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
69 fld = &buddy->email;
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 25132
diff changeset
70 else if(purple_strequal(record_key, "ext"))
17611
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
71 fld = &buddy->ext;
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 25132
diff changeset
72 else if(purple_strequal(record_key, "jid"))
17611
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
73 fld = &buddy->jid;
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 25132
diff changeset
74 else if(purple_strequal(record_key, "last"))
17611
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
75 fld = &buddy->last;
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 25132
diff changeset
76 else if(purple_strequal(record_key, "msg"))
17611
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
77 fld = &buddy->msg;
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 25132
diff changeset
78 else if(purple_strequal(record_key, "nick"))
17611
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
79 fld = &buddy->nick;
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 25132
diff changeset
80 else if(purple_strequal(record_key, "node"))
17611
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
81 fld = &buddy->node;
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 25132
diff changeset
82 else if(purple_strequal(record_key, "phsh"))
17611
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
83 fld = &buddy->phsh;
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 25132
diff changeset
84 else if(purple_strequal(record_key, "status"))
17611
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
85 fld = &buddy->status;
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 25132
diff changeset
86 else if(purple_strequal(record_key, "vc"))
17611
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
87 fld = &buddy->vc;
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 25132
diff changeset
88 else if(purple_strequal(record_key, "ver"))
17611
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
89 fld = &buddy->ver;
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 25132
diff changeset
90 else if(purple_strequal(record_key, "AIM"))
17611
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
91 fld = &buddy->AIM;
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
92
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
93 if(fld == NULL)
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
94 return;
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
95
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
96 g_free(*fld);
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
97 *fld = NULL;
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
98 *fld = g_strndup(value, len);
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents: 15884
diff changeset
99 }
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents: 15884
diff changeset
100
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
101 /**
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
102 * Check if all the compulsory buddy data is present.
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
103 */
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
104 gboolean
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
105 bonjour_buddy_check(BonjourBuddy *buddy)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
106 {
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents: 15884
diff changeset
107 if (buddy->account == NULL)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
108 return FALSE;
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
109
17599
8b0aa6917c6d Don't force Bonjour buddies to have firstname, lastname and status TXT records - they are optional. Also, minor cleanup and use glib to allocate memory instead of the crt.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
110 if (buddy->name == NULL)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
111 return FALSE;
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
112
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
113 return TRUE;
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
114 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
115
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
116 /**
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
117 * If the buddy does not yet exist, then create it and add it to
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
118 * our buddy list. In either case we set the correct status for
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
119 * the buddy.
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
120 */
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
121 void
19748
ae5eab65f8de Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <datallah@pidgin.im>
parents: 19397
diff changeset
122 bonjour_buddy_add_to_purple(BonjourBuddy *bonjour_buddy, PurpleBuddy *buddy)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
123 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
124 PurpleGroup *group;
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 18338
diff changeset
125 PurpleAccount *account = bonjour_buddy->account;
24562
22ed1e1ef32f More Bonjour struct hiding fixes.
Richard Laager <rlaager@pidgin.im>
parents: 23160
diff changeset
126 const char *status_id, *old_hash, *new_hash, *name;
17599
8b0aa6917c6d Don't force Bonjour buddies to have firstname, lastname and status TXT records - they are optional. Also, minor cleanup and use glib to allocate memory instead of the crt.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
127
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
128 /* Translate between the Bonjour status and the Purple status */
19208
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
129 if (bonjour_buddy->status != NULL && g_ascii_strcasecmp("dnd", bonjour_buddy->status) == 0)
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
130 status_id = BONJOUR_STATUS_ID_AWAY;
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
131 else
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
132 status_id = BONJOUR_STATUS_ID_AVAILABLE;
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
133
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
134 /*
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
135 * TODO: Figure out the idle time by getting the "away"
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
136 * field from the DNS SD.
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
137 */
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
138
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
139 /* Make sure the Bonjour group exists in our buddy list */
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
140 group = purple_blist_find_group(BONJOUR_GROUP_NAME); /* Use the buddy's domain, instead? */
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 18338
diff changeset
141 if (group == NULL) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
142 group = purple_group_new(BONJOUR_GROUP_NAME);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
143 purple_blist_add_group(group, NULL);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
144 }
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
145
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
146 /* Make sure the buddy exists in our buddy list */
19748
ae5eab65f8de Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <datallah@pidgin.im>
parents: 19397
diff changeset
147 if (buddy == NULL)
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
148 buddy = purple_blist_find_buddy(account, bonjour_buddy->name);
17599
8b0aa6917c6d Don't force Bonjour buddies to have firstname, lastname and status TXT records - they are optional. Also, minor cleanup and use glib to allocate memory instead of the crt.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
149
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 18338
diff changeset
150 if (buddy == NULL) {
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 18338
diff changeset
151 buddy = purple_buddy_new(account, bonjour_buddy->name, NULL);
34865
764a33b41ac7 Renamed blist node's dont_save to transient.
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
152 purple_blist_node_set_transient(PURPLE_BLIST_NODE(buddy), TRUE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
153 purple_blist_add_buddy(buddy, NULL, group, NULL);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
154 }
23160
0aff8f3882f4 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <datallah@pidgin.im>
parents: 23140
diff changeset
155
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23160
diff changeset
156 name = purple_buddy_get_name(buddy);
24935
b9a3603e84c0 Use purple_buddy_get_protocol_data() and purple_buddy_set_protocol_data()
Richard Laager <rlaager@pidgin.im>
parents: 24562
diff changeset
157 purple_buddy_set_protocol_data(buddy, bonjour_buddy);
23160
0aff8f3882f4 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <datallah@pidgin.im>
parents: 23140
diff changeset
158
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 18338
diff changeset
159 /* Create the alias for the buddy using the first and the last name */
25129
476e928f6127 Fix Bonjour to better deal with buddy values set to the empty string.
Richard Laager <rlaager@pidgin.im>
parents: 24562
diff changeset
160 if (bonjour_buddy->nick && *bonjour_buddy->nick)
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 34865
diff changeset
161 purple_serv_got_alias(purple_account_get_connection(account), name, bonjour_buddy->nick);
19208
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
162 else {
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
163 gchar *alias = NULL;
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
164 const char *first, *last;
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
165 first = bonjour_buddy->first;
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
166 last = bonjour_buddy->last;
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
167 if ((first && *first) || (last && *last))
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
168 alias = g_strdup_printf("%s%s%s",
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
169 (first && *first ? first : ""),
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
170 (first && *first && last && *last ? " " : ""),
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
171 (last && *last ? last : ""));
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 34865
diff changeset
172 purple_serv_got_alias(purple_account_get_connection(account), name, alias);
19208
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
173 g_free(alias);
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
174 }
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 18338
diff changeset
175
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
176 /* Set the user's status */
11519
abb61e69b1cf [gaim-migrate @ 13764]
Mark Doliner <markdoliner@pidgin.im>
parents: 11496
diff changeset
177 if (bonjour_buddy->msg != NULL)
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 34865
diff changeset
178 purple_protocol_got_user_status(account, name, status_id,
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 18338
diff changeset
179 "message", bonjour_buddy->msg, NULL);
11519
abb61e69b1cf [gaim-migrate @ 13764]
Mark Doliner <markdoliner@pidgin.im>
parents: 11496
diff changeset
180 else
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 34865
diff changeset
181 purple_protocol_got_user_status(account, name, status_id, NULL);
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents: 15884
diff changeset
182
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 34865
diff changeset
183 purple_protocol_got_user_idle(account, name, FALSE, 0);
19094
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
184
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
185 /* TODO: Because we don't save Bonjour buddies in blist.xml,
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
186 * we will always have to look up the buddy icon at login time.
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
187 * I think we should figure out a way to do something about this. */
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
188
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
189 /* Deal with the buddy icon */
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
190 old_hash = purple_buddy_icons_get_checksum_for_user(buddy);
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
191 new_hash = (bonjour_buddy->phsh && *(bonjour_buddy->phsh)) ? bonjour_buddy->phsh : NULL;
38260
dcada91c0912 Remove redundant NULL checks
qarkai <qarkai@gmail.com>
parents: 38259
diff changeset
192 if (new_hash && !purple_strequal(old_hash, new_hash)) {
19094
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
193 /* Look up the new icon data */
19208
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
194 /* TODO: Make sure the hash assigned to the retrieved buddy icon is the same
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
195 * as what we looked up. */
19094
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
196 bonjour_dns_sd_retrieve_buddy_icon(bonjour_buddy);
19208
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
197 } else if (!new_hash)
24562
22ed1e1ef32f More Bonjour struct hiding fixes.
Richard Laager <rlaager@pidgin.im>
parents: 23160
diff changeset
198 purple_buddy_icons_set_for_user(account, name, NULL, 0, NULL);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
199 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
200
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
201 /**
23140
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
202 * The buddy has signed off Bonjour.
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
203 * If the buddy is being saved, mark as offline, otherwise delete
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
204 */
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
205 void bonjour_buddy_signed_off(PurpleBuddy *pb) {
34865
764a33b41ac7 Renamed blist node's dont_save to transient.
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
206 if (purple_blist_node_is_transient(PURPLE_BLIST_NODE(pb))) {
34697
fde4eb63fab0 Refactored protocols with initial GObject blist API
Ankit Vani <a@nevitus.org>
parents: 25132
diff changeset
207 purple_account_remove_buddy(purple_buddy_get_account(pb), pb, NULL);
fde4eb63fab0 Refactored protocols with initial GObject blist API
Ankit Vani <a@nevitus.org>
parents: 25132
diff changeset
208 purple_blist_remove_buddy(pb);
fde4eb63fab0 Refactored protocols with initial GObject blist API
Ankit Vani <a@nevitus.org>
parents: 25132
diff changeset
209 } else {
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 34865
diff changeset
210 purple_protocol_got_user_status(purple_buddy_get_account(pb),
23140
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
211 purple_buddy_get_name(pb), "offline", NULL);
24935
b9a3603e84c0 Use purple_buddy_get_protocol_data() and purple_buddy_set_protocol_data()
Richard Laager <rlaager@pidgin.im>
parents: 24562
diff changeset
212 bonjour_buddy_delete(purple_buddy_get_protocol_data(pb));
b9a3603e84c0 Use purple_buddy_get_protocol_data() and purple_buddy_set_protocol_data()
Richard Laager <rlaager@pidgin.im>
parents: 24562
diff changeset
213 purple_buddy_set_protocol_data(pb, NULL);
23140
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
214 }
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
215 }
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
216
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
217 /**
19208
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
218 * We got the buddy icon data; deal with it
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
219 */
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
220 void bonjour_buddy_got_buddy_icon(BonjourBuddy *buddy, gconstpointer data, gsize len) {
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
221 /* Recalculate the hash instead of using the current phsh to make sure it is accurate for the icon. */
35837
528ddb11791c Drop purple_util_get_image_extension and purple_util_get_image_filename
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35499
diff changeset
222 gchar *hash;
19208
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
223
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
224 if (data == NULL || len == 0)
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
225 return;
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
226
35837
528ddb11791c Drop purple_util_get_image_extension and purple_util_get_image_filename
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35499
diff changeset
227 hash = g_compute_checksum_for_data(G_CHECKSUM_SHA1, data, len);
19208
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
228
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
229 purple_debug_info("bonjour", "Got buddy icon for %s icon hash='%s' phsh='%s'.\n", buddy->name,
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
230 hash, buddy->phsh ? buddy->phsh : "(null)");
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
231
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
232 purple_buddy_icons_set_for_user(buddy->account, buddy->name,
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
233 g_memdup(data, len), len, hash);
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
234
19397
b1befd204757 Take advantage of the fact that our buddy icon filenames are SHA-1 hashes to avoid recalculating them in the bonjour protocol. I noticed that it wasn't calculating the hash correctly anyway while doing this.
Daniel Atallah <datallah@pidgin.im>
parents: 19220
diff changeset
235 g_free(hash);
19208
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
236 }
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
237
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
238 /**
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
239 * Deletes a buddy from memory.
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
240 */
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
241 void
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
242 bonjour_buddy_delete(BonjourBuddy *buddy)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
243 {
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
244 g_free(buddy->name);
40052
cc03b5af25ea Use GSList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents: 39960
diff changeset
245 g_slist_free_full(buddy->ips, g_free);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
246 g_free(buddy->first);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
247 g_free(buddy->phsh);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
248 g_free(buddy->status);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
249 g_free(buddy->email);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
250 g_free(buddy->last);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
251 g_free(buddy->jid);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
252 g_free(buddy->AIM);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
253 g_free(buddy->vc);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
254 g_free(buddy->msg);
17631
ef6530e6697b Fix leakage.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
255 g_free(buddy->ext);
ef6530e6697b Fix leakage.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
256 g_free(buddy->nick);
ef6530e6697b Fix leakage.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
257 g_free(buddy->node);
ef6530e6697b Fix leakage.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
258 g_free(buddy->ver);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
259
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
260 bonjour_xmpp_close_conversation(buddy->conversation);
17663
fd736a4d91a9 Close conversation connections when logging out of the Bonjour account. This also fixes leakage.
Daniel Atallah <datallah@pidgin.im>
parents: 17631
diff changeset
261 buddy->conversation = NULL;
17599
8b0aa6917c6d Don't force Bonjour buddies to have firstname, lastname and status TXT records - they are optional. Also, minor cleanup and use glib to allocate memory instead of the crt.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
262
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 18338
diff changeset
263 /* Clean up any mdns implementation data */
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 18338
diff changeset
264 _mdns_delete_buddy(buddy);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
265
17599
8b0aa6917c6d Don't force Bonjour buddies to have firstname, lastname and status TXT records - they are optional. Also, minor cleanup and use glib to allocate memory instead of the crt.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
266 g_free(buddy);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
267 }

mercurial