libpurple/protocols/bonjour/buddy.c

Sat, 27 Sep 2008 06:33:42 +0000

author
Sadrul Habib Chowdhury <sadrul@pidgin.im>
date
Sat, 27 Sep 2008 06:33:42 +0000
branch
sadrul.struct.hiding
changeset 24398
4865c2ee6ea8
parent 23160
0aff8f3882f4
child 24571
77c103347d66
permissions
-rw-r--r--

Start hiding blist.h internals in prpls.

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;
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
130 const char *status_id, *old_hash, *new_hash;
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23160
diff changeset
131 const char *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
132
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
133 /* 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
134 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
135 status_id = BONJOUR_STATUS_ID_AWAY;
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
136 else
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
137 status_id = BONJOUR_STATUS_ID_AVAILABLE;
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 /*
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
140 * TODO: Figure out the idle time by getting the "away"
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
141 * field from the DNS SD.
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
142 */
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
143
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
144 /* 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
145 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
146 if (group == NULL) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
147 group = purple_group_new(BONJOUR_GROUP_NAME);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
148 purple_blist_add_group(group, NULL);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
149 }
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
150
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
151 /* 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
152 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
153 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
154
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
155 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
156 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
157 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
158 purple_blist_add_buddy(buddy, NULL, group, NULL);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
159 }
23160
0aff8f3882f4 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <datallah@pidgin.im>
parents: 23140
diff changeset
160
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23160
diff changeset
161 name = purple_buddy_get_name(buddy);
23140
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
162 buddy->proto_data = bonjour_buddy;
23160
0aff8f3882f4 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <datallah@pidgin.im>
parents: 23140
diff changeset
163
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
164 /* Create the alias for the buddy using the first and the last name */
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
165 if (bonjour_buddy->nick)
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23160
diff changeset
166 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
167 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
168 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
169 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
170 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
171 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
172 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
173 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
174 (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
175 (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
176 (last && *last ? last : ""));
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23160
diff changeset
177 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
178 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
179 }
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
180
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
181 /* Set the user's status */
11519
abb61e69b1cf [gaim-migrate @ 13764]
Mark Doliner <markdoliner@pidgin.im>
parents: 11496
diff changeset
182 if (bonjour_buddy->msg != NULL)
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23160
diff changeset
183 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
184 "message", bonjour_buddy->msg, NULL);
11519
abb61e69b1cf [gaim-migrate @ 13764]
Mark Doliner <markdoliner@pidgin.im>
parents: 11496
diff changeset
185 else
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23160
diff changeset
186 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
187
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23160
diff changeset
188 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
189
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 /* 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
191 * 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
192 * 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
193
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 /* 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
195 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
196 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
197 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
198 /* 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
199 /* 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
200 * 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
201 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
202 } else if (!new_hash)
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23160
diff changeset
203 purple_buddy_icons_set_for_user(account, name, NULL, 0, NULL);
11477
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
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
206 /**
23140
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
207 * 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
208 * 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
209 */
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
210 void bonjour_buddy_signed_off(PurpleBuddy *pb) {
23160
0aff8f3882f4 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <datallah@pidgin.im>
parents: 23140
diff changeset
211 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
212 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
213 purple_buddy_get_name(pb), "offline", NULL);
23160
0aff8f3882f4 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <datallah@pidgin.im>
parents: 23140
diff changeset
214 bonjour_buddy_delete(pb->proto_data);
0aff8f3882f4 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <datallah@pidgin.im>
parents: 23140
diff changeset
215 pb->proto_data = NULL;
0aff8f3882f4 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <datallah@pidgin.im>
parents: 23140
diff changeset
216 } 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
217 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
218 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
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
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
222 /**
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 * 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
224 */
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 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
226 /* 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
227 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
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 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
230 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
231
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
232 /* 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
233 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
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 /* 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
236 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
237 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
238 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
239 }
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
240
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
241 *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
242
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 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
244 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
245
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 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
247 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
248
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
249 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
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
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
252 /**
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
253 * Deletes a buddy from memory.
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
254 */
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
255 void
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
256 bonjour_buddy_delete(BonjourBuddy *buddy)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
257 {
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
258 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
259 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
260 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
261 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
262 }
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
263 g_free(buddy->first);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
264 g_free(buddy->phsh);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
265 g_free(buddy->status);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
266 g_free(buddy->email);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
267 g_free(buddy->last);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
268 g_free(buddy->jid);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
269 g_free(buddy->AIM);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
270 g_free(buddy->vc);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
271 g_free(buddy->msg);
17631
ef6530e6697b Fix leakage.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
272 g_free(buddy->ext);
ef6530e6697b Fix leakage.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
273 g_free(buddy->nick);
ef6530e6697b Fix leakage.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
274 g_free(buddy->node);
ef6530e6697b Fix leakage.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
275 g_free(buddy->ver);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
276
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
277 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
278 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
279
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
280 /* 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
281 _mdns_delete_buddy(buddy);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
282
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
283 g_free(buddy);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
284 }

mercurial