annotate libpurple/protocols/bonjour/buddy.c @ 24120:16734635febf

Start hiding blist.h internals in prpls.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 27 Sep 2008 06:33:42 +0000
parents ef0bcbe33689
children 5ace6c024230
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /*
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * This program is free software; you can redistribute it and/or modify
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 * it under the terms of the GNU General Public License as published by
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 * the Free Software Foundation; either version 2 of the License, or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * This program is distributed in the hope that it will be useful,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * GNU Library General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * along with this program; if not, write to the Free Software
19680
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19573
diff changeset
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301, USA.
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 #include <glib.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 #include <stdlib.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19
18276
1faa319ab4c3 More compile fixes from rekkanoryo for G_GNUC_NULL_TERMINATED issues
Stu Tomlinson <stu@nosnilmot.com>
parents: 17794
diff changeset
20 #include "internal.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 #include "buddy.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 #include "account.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 #include "blist.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 #include "bonjour.h"
18798
ed1def07d86e 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 <daniel.atallah@gmail.com>
parents: 18276
diff changeset
25 #include "mdns_interface.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 #include "debug.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 /**
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 * Creates a new buddy.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 BonjourBuddy *
17733
d7b50cac1c7a 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 <daniel.atallah@gmail.com>
parents: 15823
diff changeset
32 bonjour_buddy_new(const gchar *name, PurpleAccount* account)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 {
17736
e165d1ba8844 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 <daniel.atallah@gmail.com>
parents: 17733
diff changeset
34 BonjourBuddy *buddy = g_new0(BonjourBuddy, 1);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35
17733
d7b50cac1c7a 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 <daniel.atallah@gmail.com>
parents: 15823
diff changeset
36 buddy->account = account;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 buddy->name = g_strdup(name);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38
18798
ed1def07d86e 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 <daniel.atallah@gmail.com>
parents: 18276
diff changeset
39 _mdns_init_buddy(buddy);
ed1def07d86e 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 <daniel.atallah@gmail.com>
parents: 18276
diff changeset
40
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 return buddy;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43
18858
f773aa054dca Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18847
diff changeset
44 #define _B_CLR(x) g_free(x); x = NULL;
f773aa054dca Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18847
diff changeset
45
f773aa054dca Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18847
diff changeset
46 void clear_bonjour_buddy_values(BonjourBuddy *buddy) {
f773aa054dca Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18847
diff changeset
47
f773aa054dca Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18847
diff changeset
48 _B_CLR(buddy->first)
f773aa054dca Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18847
diff changeset
49 _B_CLR(buddy->email);
f773aa054dca Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18847
diff changeset
50 _B_CLR(buddy->ext);
f773aa054dca Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18847
diff changeset
51 _B_CLR(buddy->jid);
f773aa054dca Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18847
diff changeset
52 _B_CLR(buddy->last);
f773aa054dca Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18847
diff changeset
53 _B_CLR(buddy->msg);
f773aa054dca Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18847
diff changeset
54 _B_CLR(buddy->nick);
f773aa054dca Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18847
diff changeset
55 _B_CLR(buddy->node);
f773aa054dca Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18847
diff changeset
56 _B_CLR(buddy->phsh);
f773aa054dca Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18847
diff changeset
57 _B_CLR(buddy->status);
f773aa054dca Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18847
diff changeset
58 _B_CLR(buddy->vc);
f773aa054dca Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18847
diff changeset
59 _B_CLR(buddy->ver);
f773aa054dca Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18847
diff changeset
60 _B_CLR(buddy->AIM);
f773aa054dca Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18847
diff changeset
61
f773aa054dca Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18847
diff changeset
62 }
f773aa054dca Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18847
diff changeset
63
17736
e165d1ba8844 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 <daniel.atallah@gmail.com>
parents: 17733
diff changeset
64 void
20346
07c2e60026da applied changes from e9e74094baa29c6f5589385507221a2502b817fb
Luke Schierer <lschiere@pidgin.im>
parents: 19680
diff changeset
65 set_bonjour_buddy_value(BonjourBuddy* buddy, const char *record_key, const char *value, guint32 len){
17742
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
66 gchar **fld = NULL;
17736
e165d1ba8844 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 <daniel.atallah@gmail.com>
parents: 17733
diff changeset
67
20346
07c2e60026da applied changes from e9e74094baa29c6f5589385507221a2502b817fb
Luke Schierer <lschiere@pidgin.im>
parents: 19680
diff changeset
68 g_return_if_fail(record_key != NULL);
07c2e60026da applied changes from e9e74094baa29c6f5589385507221a2502b817fb
Luke Schierer <lschiere@pidgin.im>
parents: 19680
diff changeset
69
17742
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
70 if (!strcmp(record_key, "1st"))
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
71 fld = &buddy->first;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
72 else if(!strcmp(record_key, "email"))
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
73 fld = &buddy->email;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
74 else if(!strcmp(record_key, "ext"))
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
75 fld = &buddy->ext;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
76 else if(!strcmp(record_key, "jid"))
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
77 fld = &buddy->jid;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
78 else if(!strcmp(record_key, "last"))
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
79 fld = &buddy->last;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
80 else if(!strcmp(record_key, "msg"))
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
81 fld = &buddy->msg;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
82 else if(!strcmp(record_key, "nick"))
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
83 fld = &buddy->nick;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
84 else if(!strcmp(record_key, "node"))
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
85 fld = &buddy->node;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
86 else if(!strcmp(record_key, "phsh"))
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
87 fld = &buddy->phsh;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
88 else if(!strcmp(record_key, "status"))
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
89 fld = &buddy->status;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
90 else if(!strcmp(record_key, "vc"))
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
91 fld = &buddy->vc;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
92 else if(!strcmp(record_key, "ver"))
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
93 fld = &buddy->ver;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
94 else if(!strcmp(record_key, "AIM"))
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
95 fld = &buddy->AIM;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
96
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
97 if(fld == NULL)
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
98 return;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
99
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
100 g_free(*fld);
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
101 *fld = NULL;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17736
diff changeset
102 *fld = g_strndup(value, len);
17733
d7b50cac1c7a 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 <daniel.atallah@gmail.com>
parents: 15823
diff changeset
103 }
d7b50cac1c7a 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 <daniel.atallah@gmail.com>
parents: 15823
diff changeset
104
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105 /**
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 * Check if all the compulsory buddy data is present.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 gboolean
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 bonjour_buddy_check(BonjourBuddy *buddy)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 {
17733
d7b50cac1c7a 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 <daniel.atallah@gmail.com>
parents: 15823
diff changeset
111 if (buddy->account == NULL)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 return FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113
17736
e165d1ba8844 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 <daniel.atallah@gmail.com>
parents: 17733
diff changeset
114 if (buddy->name == NULL)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 return FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 return TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 /**
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 * If the buddy does not yet exist, then create it and add it to
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 * our buddy list. In either case we set the correct status for
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123 * the buddy.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125 void
19573
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19285
diff changeset
126 bonjour_buddy_add_to_purple(BonjourBuddy *bonjour_buddy, PurpleBuddy *buddy)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
128 PurpleGroup *group;
18798
ed1def07d86e 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 <daniel.atallah@gmail.com>
parents: 18276
diff changeset
129 PurpleAccount *account = bonjour_buddy->account;
18847
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
130 const char *status_id, *old_hash, *new_hash;
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23020
diff changeset
131 const char *name;
17736
e165d1ba8844 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 <daniel.atallah@gmail.com>
parents: 17733
diff changeset
132
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
133 /* Translate between the Bonjour status and the Purple status */
18847
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
134 if (bonjour_buddy->status != NULL && g_ascii_strcasecmp("dnd", bonjour_buddy->status) == 0)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 status_id = BONJOUR_STATUS_ID_AWAY;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 status_id = BONJOUR_STATUS_ID_AVAILABLE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 /*
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 * TODO: Figure out the idle time by getting the "away"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 * field from the DNS SD.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 /* Make sure the Bonjour group exists in our buddy list */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
145 group = purple_find_group(BONJOUR_GROUP_NAME); /* Use the buddy's domain, instead? */
18798
ed1def07d86e 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 <daniel.atallah@gmail.com>
parents: 18276
diff changeset
146 if (group == NULL) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
147 group = purple_group_new(BONJOUR_GROUP_NAME);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
148 purple_blist_add_group(group, NULL);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 /* Make sure the buddy exists in our buddy list */
19573
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19285
diff changeset
152 if (buddy == NULL)
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19285
diff changeset
153 buddy = purple_find_buddy(account, bonjour_buddy->name);
17736
e165d1ba8844 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 <daniel.atallah@gmail.com>
parents: 17733
diff changeset
154
18798
ed1def07d86e 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 <daniel.atallah@gmail.com>
parents: 18276
diff changeset
155 if (buddy == NULL) {
ed1def07d86e 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 <daniel.atallah@gmail.com>
parents: 18276
diff changeset
156 buddy = purple_buddy_new(account, bonjour_buddy->name, NULL);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
157 purple_blist_node_set_flags((PurpleBlistNode *)buddy, PURPLE_BLIST_NODE_FLAG_NO_SAVE);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
158 purple_blist_add_buddy(buddy, NULL, group, NULL);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 }
23020
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22977
diff changeset
160
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23020
diff changeset
161 name = purple_buddy_get_name(buddy);
22977
d50194ab3016 Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21806
diff changeset
162 buddy->proto_data = bonjour_buddy;
23020
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22977
diff changeset
163
18798
ed1def07d86e 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 <daniel.atallah@gmail.com>
parents: 18276
diff changeset
164 /* Create the alias for the buddy using the first and the last name */
18847
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
165 if (bonjour_buddy->nick)
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23020
diff changeset
166 serv_got_alias(purple_account_get_connection(account), name, bonjour_buddy->nick);
18847
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
167 else {
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
168 gchar *alias = NULL;
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
169 const char *first, *last;
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
170 first = bonjour_buddy->first;
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
171 last = bonjour_buddy->last;
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
172 if ((first && *first) || (last && *last))
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
173 alias = g_strdup_printf("%s%s%s",
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
174 (first && *first ? first : ""),
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
175 (first && *first && last && *last ? " " : ""),
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
176 (last && *last ? last : ""));
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23020
diff changeset
177 serv_got_alias(purple_account_get_connection(account), name, alias);
18847
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
178 g_free(alias);
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
179 }
18798
ed1def07d86e 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 <daniel.atallah@gmail.com>
parents: 18276
diff changeset
180
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 /* Set the user's status */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 if (bonjour_buddy->msg != NULL)
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23020
diff changeset
183 purple_prpl_got_user_status(account, name, status_id,
18798
ed1def07d86e 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 <daniel.atallah@gmail.com>
parents: 18276
diff changeset
184 "message", bonjour_buddy->msg, NULL);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 else
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23020
diff changeset
186 purple_prpl_got_user_status(account, name, status_id, NULL);
17733
d7b50cac1c7a 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 <daniel.atallah@gmail.com>
parents: 15823
diff changeset
187
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23020
diff changeset
188 purple_prpl_got_user_idle(account, name, FALSE, 0);
18799
83719d57a8ee 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 <daniel.atallah@gmail.com>
parents: 18798
diff changeset
189
83719d57a8ee 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 <daniel.atallah@gmail.com>
parents: 18798
diff changeset
190 /* TODO: Because we don't save Bonjour buddies in blist.xml,
83719d57a8ee 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 <daniel.atallah@gmail.com>
parents: 18798
diff changeset
191 * we will always have to look up the buddy icon at login time.
83719d57a8ee 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 <daniel.atallah@gmail.com>
parents: 18798
diff changeset
192 * I think we should figure out a way to do something about this. */
83719d57a8ee 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 <daniel.atallah@gmail.com>
parents: 18798
diff changeset
193
83719d57a8ee 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 <daniel.atallah@gmail.com>
parents: 18798
diff changeset
194 /* Deal with the buddy icon */
83719d57a8ee 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 <daniel.atallah@gmail.com>
parents: 18798
diff changeset
195 old_hash = purple_buddy_icons_get_checksum_for_user(buddy);
83719d57a8ee 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 <daniel.atallah@gmail.com>
parents: 18798
diff changeset
196 new_hash = (bonjour_buddy->phsh && *(bonjour_buddy->phsh)) ? bonjour_buddy->phsh : NULL;
83719d57a8ee 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 <daniel.atallah@gmail.com>
parents: 18798
diff changeset
197 if (new_hash && (!old_hash || strcmp(old_hash, new_hash) != 0)) {
83719d57a8ee 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 <daniel.atallah@gmail.com>
parents: 18798
diff changeset
198 /* Look up the new icon data */
18847
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
199 /* TODO: Make sure the hash assigned to the retrieved buddy icon is the same
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
200 * as what we looked up. */
18799
83719d57a8ee 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 <daniel.atallah@gmail.com>
parents: 18798
diff changeset
201 bonjour_dns_sd_retrieve_buddy_icon(bonjour_buddy);
18847
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
202 } else if (!new_hash)
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23020
diff changeset
203 purple_buddy_icons_set_for_user(account, name, NULL, 0, NULL);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 /**
22977
d50194ab3016 Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21806
diff changeset
207 * The buddy has signed off Bonjour.
d50194ab3016 Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21806
diff changeset
208 * If the buddy is being saved, mark as offline, otherwise delete
d50194ab3016 Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21806
diff changeset
209 */
d50194ab3016 Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21806
diff changeset
210 void bonjour_buddy_signed_off(PurpleBuddy *pb) {
23020
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22977
diff changeset
211 if (PURPLE_BLIST_NODE_SHOULD_SAVE(pb)) {
22977
d50194ab3016 Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21806
diff changeset
212 purple_prpl_got_user_status(purple_buddy_get_account(pb),
d50194ab3016 Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21806
diff changeset
213 purple_buddy_get_name(pb), "offline", NULL);
23020
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22977
diff changeset
214 bonjour_buddy_delete(pb->proto_data);
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22977
diff changeset
215 pb->proto_data = NULL;
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22977
diff changeset
216 } else {
22977
d50194ab3016 Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21806
diff changeset
217 purple_account_remove_buddy(purple_buddy_get_account(pb), pb, NULL);
d50194ab3016 Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21806
diff changeset
218 purple_blist_remove_buddy(pb);
d50194ab3016 Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21806
diff changeset
219 }
d50194ab3016 Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21806
diff changeset
220 }
d50194ab3016 Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21806
diff changeset
221
d50194ab3016 Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21806
diff changeset
222 /**
18847
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
223 * We got the buddy icon data; deal with it
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
224 */
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
225 void bonjour_buddy_got_buddy_icon(BonjourBuddy *buddy, gconstpointer data, gsize len) {
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
226 /* Recalculate the hash instead of using the current phsh to make sure it is accurate for the icon. */
19285
2d6d936867bc 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 <daniel.atallah@gmail.com>
parents: 18858
diff changeset
227 char *p, *hash;
18847
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
228
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
229 if (data == NULL || len == 0)
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
230 return;
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
231
19285
2d6d936867bc 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 <daniel.atallah@gmail.com>
parents: 18858
diff changeset
232 /* Take advantage of the fact that we use a SHA-1 hash of the data as the filename. */
2d6d936867bc 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 <daniel.atallah@gmail.com>
parents: 18858
diff changeset
233 hash = purple_util_get_image_filename(data, len);
18847
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
234
19285
2d6d936867bc 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 <daniel.atallah@gmail.com>
parents: 18858
diff changeset
235 /* Get rid of the extension */
2d6d936867bc 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 <daniel.atallah@gmail.com>
parents: 18858
diff changeset
236 if (!(p = strchr(hash, '.'))) {
2d6d936867bc 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 <daniel.atallah@gmail.com>
parents: 18858
diff changeset
237 g_free(hash);
2d6d936867bc 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 <daniel.atallah@gmail.com>
parents: 18858
diff changeset
238 return;
2d6d936867bc 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 <daniel.atallah@gmail.com>
parents: 18858
diff changeset
239 }
18847
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
240
19285
2d6d936867bc 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 <daniel.atallah@gmail.com>
parents: 18858
diff changeset
241 *p = '\0';
18847
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
242
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
243 purple_debug_info("bonjour", "Got buddy icon for %s icon hash='%s' phsh='%s'.\n", buddy->name,
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
244 hash, buddy->phsh ? buddy->phsh : "(null)");
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
245
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
246 purple_buddy_icons_set_for_user(buddy->account, buddy->name,
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
247 g_memdup(data, len), len, hash);
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
248
19285
2d6d936867bc 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 <daniel.atallah@gmail.com>
parents: 18858
diff changeset
249 g_free(hash);
18847
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
250 }
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
251
2bf2bd713955 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 <daniel.atallah@gmail.com>
parents: 18843
diff changeset
252 /**
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 * Deletes a buddy from memory.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
255 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256 bonjour_buddy_delete(BonjourBuddy *buddy)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258 g_free(buddy->name);
21806
41959f031322 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 <daniel.atallah@gmail.com>
parents: 20346
diff changeset
259 while (buddy->ips != NULL) {
41959f031322 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 <daniel.atallah@gmail.com>
parents: 20346
diff changeset
260 g_free(buddy->ips->data);
41959f031322 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 <daniel.atallah@gmail.com>
parents: 20346
diff changeset
261 buddy->ips = g_slist_delete_link(buddy->ips, buddy->ips);
41959f031322 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 <daniel.atallah@gmail.com>
parents: 20346
diff changeset
262 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263 g_free(buddy->first);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264 g_free(buddy->phsh);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
265 g_free(buddy->status);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266 g_free(buddy->email);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267 g_free(buddy->last);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268 g_free(buddy->jid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269 g_free(buddy->AIM);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270 g_free(buddy->vc);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
271 g_free(buddy->msg);
17778
eae7a411e3a1 Fix leakage.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17742
diff changeset
272 g_free(buddy->ext);
eae7a411e3a1 Fix leakage.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17742
diff changeset
273 g_free(buddy->nick);
eae7a411e3a1 Fix leakage.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17742
diff changeset
274 g_free(buddy->node);
eae7a411e3a1 Fix leakage.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17742
diff changeset
275 g_free(buddy->ver);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276
17794
612dc5149964 Close conversation connections when logging out of the Bonjour account. This also fixes leakage.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17778
diff changeset
277 bonjour_jabber_close_conversation(buddy->conversation);
612dc5149964 Close conversation connections when logging out of the Bonjour account. This also fixes leakage.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17778
diff changeset
278 buddy->conversation = NULL;
17736
e165d1ba8844 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 <daniel.atallah@gmail.com>
parents: 17733
diff changeset
279
18798
ed1def07d86e 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 <daniel.atallah@gmail.com>
parents: 18276
diff changeset
280 /* Clean up any mdns implementation data */
ed1def07d86e 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 <daniel.atallah@gmail.com>
parents: 18276
diff changeset
281 _mdns_delete_buddy(buddy);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282
17736
e165d1ba8844 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 <daniel.atallah@gmail.com>
parents: 17733
diff changeset
283 g_free(buddy);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284 }