libpurple/protocols/bonjour/buddy.c

Wed, 13 May 2009 20:29:03 +0000

author
Marcus Lundblad <malu@pidgin.im>
date
Wed, 13 May 2009 20:29:03 +0000
changeset 27110
05ca719b901b
parent 25132
3e760a7a5981
child 34697
fde4eb63fab0
child 38258
9a6551eba09c
permissions
-rw-r--r--

Support custom smileys in MUCs (when all participants support BoB and a maximum
of 10 participants are in the chat).
Always announce support for BoB, since disable custom smileys will still turn
off fetching them, and BoB can be used for other purposes further on.

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
18338
d3cb08f27e04 More compile fixes from rekkanoryo for G_GNUC_NULL_TERMINATED issues
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 17663
diff changeset
20 #include "internal.h"
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
21 #include "buddy.h"
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
22 #include "account.h"
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
23 #include "blist.h"
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
24 #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
25 #include "mdns_interface.h"
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
26 #include "debug.h"
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
27
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
28 /**
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
29 * Creates a new buddy.
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
30 */
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
31 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
32 bonjour_buddy_new(const gchar *name, PurpleAccount* account)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
33 {
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
34 BonjourBuddy *buddy = g_new0(BonjourBuddy, 1);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
35
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
36 buddy->account = account;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
37 buddy->name = g_strdup(name);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
38
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
39 _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
40
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
41 return buddy;
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
42 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
43
19220
60d667d6bdc5 Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <datallah@pidgin.im>
parents: 19208
diff changeset
44 #define _B_CLR(x) g_free(x); x = NULL;
60d667d6bdc5 Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <datallah@pidgin.im>
parents: 19208
diff changeset
45
60d667d6bdc5 Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <datallah@pidgin.im>
parents: 19208
diff changeset
46 void clear_bonjour_buddy_values(BonjourBuddy *buddy) {
60d667d6bdc5 Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <datallah@pidgin.im>
parents: 19208
diff changeset
47
60d667d6bdc5 Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <datallah@pidgin.im>
parents: 19208
diff changeset
48 _B_CLR(buddy->first)
60d667d6bdc5 Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <datallah@pidgin.im>
parents: 19208
diff changeset
49 _B_CLR(buddy->email);
60d667d6bdc5 Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <datallah@pidgin.im>
parents: 19208
diff changeset
50 _B_CLR(buddy->ext);
60d667d6bdc5 Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <datallah@pidgin.im>
parents: 19208
diff changeset
51 _B_CLR(buddy->jid);
60d667d6bdc5 Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <datallah@pidgin.im>
parents: 19208
diff changeset
52 _B_CLR(buddy->last);
60d667d6bdc5 Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <datallah@pidgin.im>
parents: 19208
diff changeset
53 _B_CLR(buddy->msg);
60d667d6bdc5 Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <datallah@pidgin.im>
parents: 19208
diff changeset
54 _B_CLR(buddy->nick);
60d667d6bdc5 Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <datallah@pidgin.im>
parents: 19208
diff changeset
55 _B_CLR(buddy->node);
60d667d6bdc5 Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <datallah@pidgin.im>
parents: 19208
diff changeset
56 _B_CLR(buddy->phsh);
60d667d6bdc5 Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <datallah@pidgin.im>
parents: 19208
diff changeset
57 _B_CLR(buddy->status);
60d667d6bdc5 Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <datallah@pidgin.im>
parents: 19208
diff changeset
58 _B_CLR(buddy->vc);
60d667d6bdc5 Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <datallah@pidgin.im>
parents: 19208
diff changeset
59 _B_CLR(buddy->ver);
60d667d6bdc5 Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <datallah@pidgin.im>
parents: 19208
diff changeset
60 _B_CLR(buddy->AIM);
60d667d6bdc5 Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <datallah@pidgin.im>
parents: 19208
diff changeset
61
60d667d6bdc5 Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <datallah@pidgin.im>
parents: 19208
diff changeset
62 }
60d667d6bdc5 Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <datallah@pidgin.im>
parents: 19208
diff changeset
63
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
64 void
20238
e4abd12fb7ec applied changes from e9e74094baa29c6f5589385507221a2502b817fb
Luke Schierer <lschiere@pidgin.im>
parents: 19859
diff changeset
65 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
66 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
67
20238
e4abd12fb7ec applied changes from e9e74094baa29c6f5589385507221a2502b817fb
Luke Schierer <lschiere@pidgin.im>
parents: 19859
diff changeset
68 g_return_if_fail(record_key != NULL);
e4abd12fb7ec applied changes from e9e74094baa29c6f5589385507221a2502b817fb
Luke Schierer <lschiere@pidgin.im>
parents: 19859
diff changeset
69
17611
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
70 if (!strcmp(record_key, "1st"))
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
71 fld = &buddy->first;
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
72 else if(!strcmp(record_key, "email"))
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
73 fld = &buddy->email;
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
74 else if(!strcmp(record_key, "ext"))
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
75 fld = &buddy->ext;
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
76 else if(!strcmp(record_key, "jid"))
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
77 fld = &buddy->jid;
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
78 else if(!strcmp(record_key, "last"))
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
79 fld = &buddy->last;
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
80 else if(!strcmp(record_key, "msg"))
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
81 fld = &buddy->msg;
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
82 else if(!strcmp(record_key, "nick"))
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
83 fld = &buddy->nick;
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
84 else if(!strcmp(record_key, "node"))
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
85 fld = &buddy->node;
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
86 else if(!strcmp(record_key, "phsh"))
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
87 fld = &buddy->phsh;
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
88 else if(!strcmp(record_key, "status"))
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
89 fld = &buddy->status;
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
90 else if(!strcmp(record_key, "vc"))
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
91 fld = &buddy->vc;
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
92 else if(!strcmp(record_key, "ver"))
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
93 fld = &buddy->ver;
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
94 else if(!strcmp(record_key, "AIM"))
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
95 fld = &buddy->AIM;
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
96
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
97 if(fld == NULL)
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
98 return;
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
99
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
100 g_free(*fld);
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
101 *fld = NULL;
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17599
diff changeset
102 *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
103 }
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
104
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
105 /**
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
106 * Check if all the compulsory buddy data is present.
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
107 */
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
108 gboolean
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
109 bonjour_buddy_check(BonjourBuddy *buddy)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
110 {
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
111 if (buddy->account == NULL)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
112 return FALSE;
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
113
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
114 if (buddy->name == NULL)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
115 return FALSE;
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
116
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
117 return TRUE;
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
118 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
119
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 * 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
122 * 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
123 * the buddy.
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
124 */
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
125 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
126 bonjour_buddy_add_to_purple(BonjourBuddy *bonjour_buddy, PurpleBuddy *buddy)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
127 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
128 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
129 PurpleAccount *account = bonjour_buddy->account;
24562
22ed1e1ef32f More Bonjour struct hiding fixes.
Richard Laager <rlaager@pidgin.im>
parents: 23160
diff changeset
130 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
131
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
132 /* 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
133 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
134 status_id = BONJOUR_STATUS_ID_AWAY;
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
135 else
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
136 status_id = BONJOUR_STATUS_ID_AVAILABLE;
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
137
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
138 /*
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
139 * TODO: Figure out the idle time by getting the "away"
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
140 * field from the DNS SD.
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
141 */
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
142
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
143 /* Make sure the Bonjour group exists in our buddy list */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
144 group = purple_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
145 if (group == NULL) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
146 group = purple_group_new(BONJOUR_GROUP_NAME);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
147 purple_blist_add_group(group, NULL);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
148 }
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
149
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
150 /* 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
151 if (buddy == NULL)
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
152 buddy = purple_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
153
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
154 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
155 buddy = purple_buddy_new(account, bonjour_buddy->name, NULL);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
156 purple_blist_node_set_flags((PurpleBlistNode *)buddy, PURPLE_BLIST_NODE_FLAG_NO_SAVE);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
157 purple_blist_add_buddy(buddy, NULL, group, NULL);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
158 }
23160
0aff8f3882f4 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <datallah@pidgin.im>
parents: 23140
diff changeset
159
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23160
diff changeset
160 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
161 purple_buddy_set_protocol_data(buddy, bonjour_buddy);
23160
0aff8f3882f4 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <datallah@pidgin.im>
parents: 23140
diff changeset
162
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
163 /* 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
164 if (bonjour_buddy->nick && *bonjour_buddy->nick)
24562
22ed1e1ef32f More Bonjour struct hiding fixes.
Richard Laager <rlaager@pidgin.im>
parents: 23160
diff changeset
165 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
166 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
167 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
168 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
169 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
170 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
171 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
172 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
173 (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
174 (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
175 (last && *last ? last : ""));
24562
22ed1e1ef32f More Bonjour struct hiding fixes.
Richard Laager <rlaager@pidgin.im>
parents: 23160
diff changeset
176 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
177 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
178 }
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
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
180 /* Set the user's status */
11519
abb61e69b1cf [gaim-migrate @ 13764]
Mark Doliner <markdoliner@pidgin.im>
parents: 11496
diff changeset
181 if (bonjour_buddy->msg != NULL)
24562
22ed1e1ef32f More Bonjour struct hiding fixes.
Richard Laager <rlaager@pidgin.im>
parents: 23160
diff changeset
182 purple_prpl_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
183 "message", bonjour_buddy->msg, NULL);
11519
abb61e69b1cf [gaim-migrate @ 13764]
Mark Doliner <markdoliner@pidgin.im>
parents: 11496
diff changeset
184 else
24562
22ed1e1ef32f More Bonjour struct hiding fixes.
Richard Laager <rlaager@pidgin.im>
parents: 23160
diff changeset
185 purple_prpl_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
186
24562
22ed1e1ef32f More Bonjour struct hiding fixes.
Richard Laager <rlaager@pidgin.im>
parents: 23160
diff changeset
187 purple_prpl_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
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 /* 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
190 * 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
191 * 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
192
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 /* 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
194 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
195 new_hash = (bonjour_buddy->phsh && *(bonjour_buddy->phsh)) ? bonjour_buddy->phsh : NULL;
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 if (new_hash && (!old_hash || strcmp(old_hash, new_hash) != 0)) {
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
197 /* 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
198 /* 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
199 * 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
200 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
201 } else if (!new_hash)
24562
22ed1e1ef32f More Bonjour struct hiding fixes.
Richard Laager <rlaager@pidgin.im>
parents: 23160
diff changeset
202 purple_buddy_icons_set_for_user(account, name, NULL, 0, NULL);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
203 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
204
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
205 /**
23140
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
206 * 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
207 * 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
208 */
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
209 void bonjour_buddy_signed_off(PurpleBuddy *pb) {
23160
0aff8f3882f4 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <datallah@pidgin.im>
parents: 23140
diff changeset
210 if (PURPLE_BLIST_NODE_SHOULD_SAVE(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_prpl_got_user_status(purple_buddy_get_account(pb),
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
212 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
213 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
214 purple_buddy_set_protocol_data(pb, NULL);
23160
0aff8f3882f4 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <datallah@pidgin.im>
parents: 23140
diff changeset
215 } else {
23140
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
216 purple_account_remove_buddy(purple_buddy_get_account(pb), pb, NULL);
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
217 purple_blist_remove_buddy(pb);
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
218 }
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
219 }
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
220
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
221 /**
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
222 * 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
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 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
225 /* Recalculate the hash instead of using the current phsh to make sure it is accurate for the icon. */
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
226 char *p, *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
227
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 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
229 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
230
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
231 /* Take advantage of the fact that we use a SHA-1 hash of the data as the filename. */
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
232 hash = purple_util_get_image_filename(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
233
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
234 /* Get rid of the extension */
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 if (!(p = strchr(hash, '.'))) {
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
236 g_free(hash);
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
237 return;
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
238 }
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
239
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
240 *p = '\0';
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
241
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
242 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
243 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
244
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
245 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
246 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
247
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
248 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
249 }
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
250
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
251 /**
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
252 * Deletes a buddy from memory.
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
253 */
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
254 void
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
255 bonjour_buddy_delete(BonjourBuddy *buddy)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
256 {
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
257 g_free(buddy->name);
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 20238
diff changeset
258 while (buddy->ips != NULL) {
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 20238
diff changeset
259 g_free(buddy->ips->data);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 20238
diff changeset
260 buddy->ips = g_slist_delete_link(buddy->ips, buddy->ips);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 20238
diff changeset
261 }
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
262 g_free(buddy->first);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
263 g_free(buddy->phsh);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
264 g_free(buddy->status);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
265 g_free(buddy->email);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
266 g_free(buddy->last);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
267 g_free(buddy->jid);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
268 g_free(buddy->AIM);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
269 g_free(buddy->vc);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
270 g_free(buddy->msg);
17631
ef6530e6697b Fix leakage.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
271 g_free(buddy->ext);
ef6530e6697b Fix leakage.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
272 g_free(buddy->nick);
ef6530e6697b Fix leakage.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
273 g_free(buddy->node);
ef6530e6697b Fix leakage.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
274 g_free(buddy->ver);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
275
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
276 bonjour_jabber_close_conversation(buddy->conversation);
fd736a4d91a9 Close conversation connections when logging out of the Bonjour account. This also fixes leakage.
Daniel Atallah <datallah@pidgin.im>
parents: 17631
diff changeset
277 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
278
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
279 /* 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
280 _mdns_delete_buddy(buddy);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
281
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
282 g_free(buddy);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
283 }

mercurial