annotate libpurple/protocols/bonjour/mdns_common.c @ 29408:1d58c44c87f4

Oops, that wasn't meant to be left in as a warning, but noting these is probably good.
author Paul Aurich <paul@darkrain42.org>
date Wed, 10 Feb 2010 06:43:51 +0000
parents 9340e1db0f46
children 9c8b28dc6656
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
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:
diff changeset
1 /*
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:
diff changeset
2 * This program is free software; you can redistribute it and/or modify
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:
diff changeset
3 * it under the terms of the GNU General Public License as published by
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:
diff changeset
4 * the Free Software Foundation; either version 2 of the License, or
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:
diff changeset
5 * (at your option) any later version.
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:
diff changeset
6 *
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:
diff changeset
7 * This program is distributed in the hope that it will be useful,
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:
diff changeset
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
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:
diff changeset
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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:
diff changeset
10 * GNU Library General Public License for more details.
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:
diff changeset
11 *
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:
diff changeset
12 * You should have received a copy of the GNU General Public License
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:
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: 19653
diff changeset
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301, USA.
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:
diff changeset
15 */
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:
diff changeset
16
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:
diff changeset
17 #include <string.h>
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:
diff changeset
18
18276
1faa319ab4c3 More compile fixes from rekkanoryo for G_GNUC_NULL_TERMINATED issues
Stu Tomlinson <stu@nosnilmot.com>
parents: 17790
diff changeset
19 #include "internal.h"
18843
7bf6b9a70b41 Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18804
diff changeset
20 #include "debug.h"
7bf6b9a70b41 Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18804
diff changeset
21
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:
diff changeset
22 #include "mdns_common.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
23 #include "mdns_interface.h"
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:
diff changeset
24 #include "bonjour.h"
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:
diff changeset
25 #include "buddy.h"
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:
diff changeset
26
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:
diff changeset
27
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:
diff changeset
28 /**
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:
diff changeset
29 * Allocate space for the dns-sd data.
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:
diff changeset
30 */
18859
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
31 BonjourDnsSd * bonjour_dns_sd_new() {
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:
diff changeset
32 BonjourDnsSd *data = g_new0(BonjourDnsSd, 1);
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:
diff changeset
33 return data;
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:
diff changeset
34 }
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:
diff changeset
35
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:
diff changeset
36 /**
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:
diff changeset
37 * Deallocate the space of the dns-sd data.
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:
diff changeset
38 */
18859
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
39 void bonjour_dns_sd_free(BonjourDnsSd *data) {
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:
diff changeset
40 g_free(data->first);
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:
diff changeset
41 g_free(data->last);
17739
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17733
diff changeset
42 g_free(data->phsh);
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17733
diff changeset
43 g_free(data->status);
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17733
diff changeset
44 g_free(data->vc);
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17733
diff changeset
45 g_free(data->msg);
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:
diff changeset
46 g_free(data);
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:
diff changeset
47 }
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:
diff changeset
48
24140
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
49 #define MAX_TXT_CONSTITUENT_LEN 255
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
50
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
51 /* Make sure that the value isn't longer than it is supposed to be */
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
52 static const char*
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
53 get_max_txt_record_value(const char *key, const char *value)
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
54 {
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
55 /* "each constituent string of a DNS TXT record is limited to 255 bytes"
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
56 * This includes the key and the '='
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
57 */
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
58 static char buffer[MAX_TXT_CONSTITUENT_LEN + 1];
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
59 gchar *end_valid = NULL;
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
60 int len = MIN(strlen(value), MAX_TXT_CONSTITUENT_LEN - (strlen(key) + 2));
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
61
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
62 strncpy(buffer, value, len);
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
63
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
64 buffer[len] = '\0';
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
65
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
66 /* If we've cut part of a utf-8 character, kill it */
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
67 if (!g_utf8_validate(buffer, -1, (const gchar **)&end_valid))
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
68 *end_valid = '\0';
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
69
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
70 return buffer;
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
71 }
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
72
18859
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
73 static GSList *generate_presence_txt_records(BonjourDnsSd *data) {
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
74 GSList *ret = NULL;
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
75 PurpleKeyValuePair *kvp;
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
76 char portstring[6];
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
77 const char *jid, *aim, *email;
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
78
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
79 /* Convert the port to a string */
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
80 snprintf(portstring, sizeof(portstring), "%d", data->port_p2pj);
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
81
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
82 jid = purple_account_get_string(data->account, "jid", NULL);
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
83 aim = purple_account_get_string(data->account, "AIM", NULL);
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
84 email = purple_account_get_string(data->account, "email", NULL);
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
85
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
86 #define _M_ADD_R(k, v) \
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
87 kvp = g_new0(PurpleKeyValuePair, 1); \
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
88 kvp->key = g_strdup(k); \
24140
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
89 kvp->value = g_strdup(get_max_txt_record_value(k, v)); \
18859
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
90 ret = g_slist_prepend(ret, kvp); \
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
91
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
92 /* We should try to follow XEP-0174, but some clients have "issues", so we humor them.
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
93 * See http://telepathy.freedesktop.org/wiki/SalutInteroperability
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
94 */
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
95
24140
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
96 /* Large TXT records are problematic.
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
97 * While it is technically possible for this to exceed a standard 512-byte
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
98 * DNS message, it shouldn't happen unless we get wacky data entered for
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
99 * some of the freeform fields. It is even less likely to exceed the
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
100 * recommended maximum of 1300 bytes.
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
101 */
9340e1db0f46 Prevent DNS-SD TXT record strings from exceeding the maximum length.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19680
diff changeset
102
18859
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
103 /* Needed by iChat */
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
104 _M_ADD_R("txtvers", "1")
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
105 /* Needed by Gaim/Pidgin <= 2.0.1 (remove at some point) */
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
106 _M_ADD_R("1st", data->first)
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
107 /* Needed by Gaim/Pidgin <= 2.0.1 (remove at some point) */
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
108 _M_ADD_R("last", data->last)
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
109 /* Needed by Adium */
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
110 _M_ADD_R("port.p2pj", portstring)
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
111 /* Needed by iChat, Gaim/Pidgin <= 2.0.1 */
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
112 _M_ADD_R("status", data->status)
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
113 _M_ADD_R("node", "libpurple")
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
114 _M_ADD_R("ver", VERSION)
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
115 /* Currently always set to "!" since we don't support AV and wont ever be in a conference */
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
116 _M_ADD_R("vc", data->vc)
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
117 if (email != NULL && *email != '\0') {
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
118 _M_ADD_R("email", email)
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
119 }
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
120 if (jid != NULL && *jid != '\0') {
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
121 _M_ADD_R("jid", jid)
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
122 }
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
123 /* Nonstandard, but used by iChat */
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
124 if (aim != NULL && *aim != '\0') {
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
125 _M_ADD_R("AIM", aim)
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
126 }
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
127 if (data->msg != NULL && *data->msg != '\0') {
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
128 _M_ADD_R("msg", data->msg)
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
129 }
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
130 if (data->phsh != NULL && *data->phsh != '\0') {
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
131 _M_ADD_R("phsh", data->phsh)
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
132 }
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
133
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
134 /* TODO: ext, nick */
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
135 return ret;
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
136 }
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
137
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
138 static void free_presence_txt_records(GSList *lst) {
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
139 PurpleKeyValuePair *kvp;
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
140 while(lst) {
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
141 kvp = lst->data;
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
142 g_free(kvp->key);
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
143 g_free(kvp->value);
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
144 g_free(kvp);
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
145 lst = g_slist_remove(lst, lst->data);
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
146 }
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
147 }
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
148
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
149 static gboolean publish_presence(BonjourDnsSd *data, PublishType type) {
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
150 GSList *txt_records;
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
151 gboolean ret;
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
152
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
153 txt_records = generate_presence_txt_records(data);
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
154 ret = _mdns_publish(data, type, txt_records);
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
155 free_presence_txt_records(txt_records);
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
156
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
157 return ret;
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
158 }
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
159
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:
diff changeset
160 /**
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:
diff changeset
161 * Send a new dns-sd packet updating our status.
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:
diff changeset
162 */
18859
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
163 void bonjour_dns_sd_send_status(BonjourDnsSd *data, const char *status, const char *status_message) {
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:
diff changeset
164 g_free(data->status);
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:
diff changeset
165 g_free(data->msg);
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:
diff changeset
166
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:
diff changeset
167 data->status = g_strdup(status);
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:
diff changeset
168 data->msg = g_strdup(status_message);
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:
diff changeset
169
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:
diff changeset
170 /* Update our text record with the new status */
18859
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
171 publish_presence(data, PUBLISH_UPDATE);
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:
diff changeset
172 }
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:
diff changeset
173
18845
09f52521ff5b Fix bonjour buddy icons to work with iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18843
diff changeset
174 /**
09f52521ff5b Fix bonjour buddy icons to work with iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18843
diff changeset
175 * Retrieve the buddy icon blob
09f52521ff5b Fix bonjour buddy icons to work with iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18843
diff changeset
176 */
09f52521ff5b Fix bonjour buddy icons to work with iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18843
diff changeset
177 void bonjour_dns_sd_retrieve_buddy_icon(BonjourBuddy* buddy) {
18849
1787e601aafc _mdns_retrieve_retrieve_buddy_icon() - what kind of crack am I on anyway?
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18845
diff changeset
178 _mdns_retrieve_buddy_icon(buddy);
18843
7bf6b9a70b41 Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18804
diff changeset
179 }
7bf6b9a70b41 Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18804
diff changeset
180
18859
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
181 void bonjour_dns_sd_update_buddy_icon(BonjourDnsSd *data) {
18843
7bf6b9a70b41 Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18804
diff changeset
182 PurpleStoredImage *img;
7bf6b9a70b41 Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18804
diff changeset
183
7bf6b9a70b41 Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18804
diff changeset
184 if ((img = purple_buddy_icons_find_account_icon(data->account))) {
7bf6b9a70b41 Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18804
diff changeset
185 gconstpointer avatar_data;
7bf6b9a70b41 Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18804
diff changeset
186 gsize avatar_len;
7bf6b9a70b41 Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18804
diff changeset
187
7bf6b9a70b41 Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18804
diff changeset
188 avatar_data = purple_imgstore_get_data(img);
7bf6b9a70b41 Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18804
diff changeset
189 avatar_len = purple_imgstore_get_size(img);
7bf6b9a70b41 Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18804
diff changeset
190
18845
09f52521ff5b Fix bonjour buddy icons to work with iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18843
diff changeset
191 if (_mdns_set_buddy_icon_data(data, avatar_data, avatar_len)) {
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: 18859
diff changeset
192 /* The filename is a SHA-1 hash of the data (conveniently what we need) */
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: 18859
diff changeset
193 const char *p, *filename = purple_imgstore_get_filename(img);
18845
09f52521ff5b Fix bonjour buddy icons to work with iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18843
diff changeset
194
09f52521ff5b Fix bonjour buddy icons to work with iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18843
diff changeset
195 g_free(data->phsh);
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: 18859
diff changeset
196 data->phsh = NULL;
18845
09f52521ff5b Fix bonjour buddy icons to work with iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18843
diff changeset
197
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: 18859
diff changeset
198 /* 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: 18859
diff changeset
199 p = strchr(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: 18859
diff changeset
200 if (p)
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: 18859
diff changeset
201 data->phsh = g_strndup(filename, p - 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: 18859
diff changeset
202 else
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: 18859
diff changeset
203 purple_debug_error("bonjour", "account buddy icon returned unexpected filename (%s)"
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: 18859
diff changeset
204 "; unable to extract hash. Clearing buddy icon\n", filename);
18845
09f52521ff5b Fix bonjour buddy icons to work with iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18843
diff changeset
205
09f52521ff5b Fix bonjour buddy icons to work with iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18843
diff changeset
206 /* Update our TXT record */
18859
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
207 publish_presence(data, PUBLISH_UPDATE);
18845
09f52521ff5b Fix bonjour buddy icons to work with iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18843
diff changeset
208 }
18843
7bf6b9a70b41 Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18804
diff changeset
209
7bf6b9a70b41 Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18804
diff changeset
210 purple_imgstore_unref(img);
7bf6b9a70b41 Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18804
diff changeset
211 } else {
7bf6b9a70b41 Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18804
diff changeset
212 /* We need to do this regardless of whether data->phsh is set so that we
7bf6b9a70b41 Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18804
diff changeset
213 * cancel any icons that are currently in the process of being set */
7bf6b9a70b41 Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18804
diff changeset
214 _mdns_set_buddy_icon_data(data, NULL, 0);
7bf6b9a70b41 Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18804
diff changeset
215 if (data->phsh != NULL) {
7bf6b9a70b41 Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18804
diff changeset
216 /* Clear the buddy icon */
7bf6b9a70b41 Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18804
diff changeset
217 g_free(data->phsh);
7bf6b9a70b41 Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18804
diff changeset
218 data->phsh = NULL;
7bf6b9a70b41 Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18804
diff changeset
219 /* Update our TXT record */
18859
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
220 publish_presence(data, PUBLISH_UPDATE);
18843
7bf6b9a70b41 Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18804
diff changeset
221 }
7bf6b9a70b41 Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18804
diff changeset
222 }
7bf6b9a70b41 Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18804
diff changeset
223 }
7bf6b9a70b41 Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18804
diff changeset
224
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:
diff changeset
225 /**
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:
diff changeset
226 * Advertise our presence within the dns-sd daemon and start browsing
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:
diff changeset
227 * for other bonjour peers.
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:
diff changeset
228 */
18859
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
229 gboolean bonjour_dns_sd_start(BonjourDnsSd *data) {
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:
diff changeset
230
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:
diff changeset
231 /* Initialize the dns-sd data and session */
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
232 if (!_mdns_init_session(data))
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:
diff changeset
233 return FALSE;
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:
diff changeset
234
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:
diff changeset
235 /* Publish our bonjour IM client at the mDNS daemon */
18859
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
236 if (!publish_presence(data, PUBLISH_START))
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:
diff changeset
237 return FALSE;
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:
diff changeset
238
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:
diff changeset
239 /* Advise the daemon that we are waiting for connections */
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
240 if (!_mdns_browse(data)) {
19653
941965d6fd88 Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19285
diff changeset
241 purple_debug_error("bonjour", "Unable to get service.\n");
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:
diff changeset
242 return FALSE;
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:
diff changeset
243 }
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:
diff changeset
244
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:
diff changeset
245 return TRUE;
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:
diff changeset
246 }
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:
diff changeset
247
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:
diff changeset
248 /**
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:
diff changeset
249 * Unregister the "_presence._tcp" service at the mDNS daemon.
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:
diff changeset
250 */
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:
diff changeset
251
18859
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
252 void bonjour_dns_sd_stop(BonjourDnsSd *data) {
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
253 _mdns_stop(data);
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:
diff changeset
254 }