annotate libpurple/protocols/bonjour/mdns_win32.c @ 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.
author Daniel Atallah <daniel.atallah@gmail.com>
date Sun, 05 Aug 2007 02:44:53 +0000
parents 316be7e715c6
children 83719d57a8ee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17495
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
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
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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
18276
1faa319ab4c3 More compile fixes from rekkanoryo for G_GNUC_NULL_TERMINATED issues
Stu Tomlinson <stu@nosnilmot.com>
parents: 17552
diff changeset
17 #include "internal.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: 18761
diff changeset
18 #include "debug.h"
17495
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
19
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: 18761
diff changeset
20 #include "buddy.h"
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: 18761
diff changeset
21 #include "mdns_interface.h"
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: 18761
diff changeset
22 #include "dns_sd_proxy.h"
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: 18761
diff changeset
23 #include "dnsquery.h"
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: 18761
diff changeset
24
17495
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
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
26 /* data structure for the resolve callback */
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: 18761
diff changeset
27 typedef struct _ResolveCallbackArgs {
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
28 DNSServiceRef resolver;
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: 18761
diff changeset
29 guint resolver_handler;
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
30
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
31 PurpleDnsQueryData *query;
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
32 gchar *fqn;
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
33
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
34 BonjourBuddy* buddy;
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
35 } ResolveCallbackArgs;
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
36
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: 18761
diff changeset
37 /* data used by win32 bonjour implementation */
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: 18761
diff changeset
38 typedef struct _win32_session_impl_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: 18761
diff changeset
39 DNSServiceRef advertisement;
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: 18761
diff changeset
40 DNSServiceRef browser;
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: 18761
diff changeset
41
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: 18761
diff changeset
42 guint advertisement_handler; /* hack... windows bonjour is broken, so we have to have this */
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: 18761
diff changeset
43 } Win32SessionImplData;
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: 18761
diff changeset
44
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: 18761
diff changeset
45 typedef struct _win32_buddy_impl_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: 18761
diff changeset
46 DNSServiceRef txt_query;
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: 18761
diff changeset
47 guint txt_query_handler;
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: 18761
diff changeset
48 } Win32BuddyImplData;
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: 18761
diff changeset
49
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: 18761
diff changeset
50 static void
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: 18761
diff changeset
51 _mdns_handle_event(gpointer data, gint source, PurpleInputCondition condition) {
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: 18761
diff changeset
52 DNSServiceProcessResult((DNSServiceRef) 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: 18761
diff changeset
53 }
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: 18761
diff changeset
54
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
55 static void
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
56 _mdns_parse_text_record(BonjourBuddy* buddy, const char* record, uint16_t record_len)
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
57 {
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
58 const char *txt_entry;
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
59 uint8_t txt_len;
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
60 int i;
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
61
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
62 for (i = 0; buddy_TXT_records[i] != NULL; i++) {
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
63 txt_entry = TXTRecordGetValuePtr(record_len, record, buddy_TXT_records[i], &txt_len);
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
64 if (txt_entry != NULL)
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
65 set_bonjour_buddy_value(buddy, buddy_TXT_records[i], txt_entry, txt_len);
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
66 }
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
67 }
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
68
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
69 static void DNSSD_API
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
70 _mdns_text_record_query_callback(DNSServiceRef DNSServiceRef, DNSServiceFlags flags,
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
71 uint32_t interfaceIndex, DNSServiceErrorType errorCode, const char *fullname,
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
72 uint16_t rrtype, uint16_t rrclass, uint16_t rdlen, const void *rdata,
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
73 uint32_t ttl, void *context)
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
74 {
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: 18761
diff changeset
75
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
76 if (kDNSServiceErr_NoError != errorCode)
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: 18761
diff changeset
77 purple_debug_error("bonjour", "record query - callback error.\n");
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
78 else if (flags & kDNSServiceFlagsAdd)
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
79 {
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: 18761
diff changeset
80 /* New 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: 18761
diff changeset
81 BonjourBuddy *buddy = (BonjourBuddy*) context;
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
82 _mdns_parse_text_record(buddy, rdata, rdlen);
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
83 bonjour_buddy_add_to_purple(buddy);
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
84 }
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
85 }
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
86
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
87 static void
17495
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
88 _mdns_resolve_host_callback(GSList *hosts, gpointer data, const char *error_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
89 {
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
90 ResolveCallbackArgs* args = (ResolveCallbackArgs*)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
91
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
92 if (!hosts || !hosts->data)
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
93 purple_debug_error("bonjour", "host resolution - callback error.\n");
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: 18761
diff changeset
94 else {
17495
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
95 struct sockaddr_in *addr = (struct sockaddr_in*)g_slist_nth_data(hosts, 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
96 BonjourBuddy* buddy = args->buddy;
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: 18761
diff changeset
97 Win32BuddyImplData *idata = buddy->mdns_impl_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: 18761
diff changeset
98
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: 18761
diff changeset
99 g_return_if_fail(idata != NULL);
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
100
17506
bbe9248337ea Fix network byte order issues with win32 bonjour stuff. Also copy the buddy's ip address so that subsequent calls don't overwrite it (it already is being copied and freed because of the howl implementation).
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17505
diff changeset
101 buddy->ip = g_strdup(inet_ntoa(addr->sin_addr));
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
102
17495
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
103 /* finally, set up the continuous txt record watcher, and add the buddy to purple */
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
104
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: 18761
diff changeset
105 if (kDNSServiceErr_NoError == DNSServiceQueryRecord(&idata->txt_query, 0, 0, buddy->full_service_name,
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: 18761
diff changeset
106 kDNSServiceType_TXT, kDNSServiceClass_IN, _mdns_text_record_query_callback, 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: 18761
diff changeset
107 int fd = DNSServiceRefSockFD(idata->txt_query);
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: 18761
diff changeset
108 idata->txt_query_handler = purple_input_add(fd, PURPLE_INPUT_READ, _mdns_handle_event, idata->txt_query);
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
109
17495
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
110 bonjour_buddy_add_to_purple(buddy);
18761
316be7e715c6 Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18276
diff changeset
111
316be7e715c6 Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18276
diff changeset
112 purple_debug_info("bonjour", "Found buddy %s at %s:%d\n", buddy->name, buddy->ip, buddy->port_p2pj);
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: 18761
diff changeset
113 } else
17495
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
114 bonjour_buddy_delete(buddy);
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
115
17495
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
116 }
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
117
17495
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
118 /* free the hosts list*/
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
119 g_slist_free(hosts);
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
120
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
121 /* free the remaining args memory */
17495
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
122 purple_dnsquery_destroy(args->query);
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
123 g_free(args->fqn);
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
124 g_free(args);
17495
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
125 }
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
126
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
127 static void DNSSD_API
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
128 _mdns_service_resolve_callback(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, DNSServiceErrorType errorCode,
17495
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
129 const char *fullname, const char *hosttarget, uint16_t port, uint16_t txtLen, const char *txtRecord, void *context)
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
130 {
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
131 ResolveCallbackArgs *args = (ResolveCallbackArgs*)context;
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
132
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
133 /* remove the input fd and destroy the service ref */
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: 18761
diff changeset
134 purple_input_remove(args->resolver_handler);
17495
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
135 DNSServiceRefDeallocate(args->resolver);
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
136
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
137 if (kDNSServiceErr_NoError != errorCode)
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
138 {
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
139 purple_debug_error("bonjour", "service resolver - callback error.\n");
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
140 bonjour_buddy_delete(args->buddy);
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
141 g_free(args);
17495
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
142 }
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
143 else
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
144 {
17506
bbe9248337ea Fix network byte order issues with win32 bonjour stuff. Also copy the buddy's ip address so that subsequent calls don't overwrite it (it already is being copied and freed because of the howl implementation).
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17505
diff changeset
145 args->buddy->port_p2pj = ntohs(port);
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
146
17495
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
147 /* parse the text record */
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
148 _mdns_parse_text_record(args->buddy, txtRecord, txtLen);
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
149
17495
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
150 /* set more arguments, and start the host resolver */
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
151 args->fqn = g_strdup(fullname);
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
152
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
153 if (!(args->query =
17495
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
154 purple_dnsquery_a(hosttarget, port, _mdns_resolve_host_callback, args)))
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
155 {
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
156 purple_debug_error("bonjour", "service resolver - host resolution failed.\n");
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
157 bonjour_buddy_delete(args->buddy);
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
158 g_free(args->fqn);
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
159 g_free(args);
17495
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 }
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
162
17495
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
163 }
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
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
165 static void DNSSD_API
17495
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 _mdns_service_register_callback(DNSServiceRef sdRef, DNSServiceFlags flags, DNSServiceErrorType errorCode,
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 const char *name, const char *regtype, const char *domain, void *context)
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 {
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 /* we don't actually care about anything said in this callback - this is only here because Bonjour for windows is broken */
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 if (kDNSServiceErr_NoError != errorCode)
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
171 purple_debug_error("bonjour", "service advertisement - callback error.\n");
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 else
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 purple_debug_info("bonjour", "service advertisement - callback.\n");
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
174 }
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
175
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: 18761
diff changeset
176 static void DNSSD_API
17495
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
177 _mdns_service_browse_callback(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex,
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
178 DNSServiceErrorType errorCode, const char *serviceName, const char *regtype, const char *replyDomain, void *context)
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
179 {
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
180 PurpleAccount *account = (PurpleAccount*)context;
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
181 PurpleBuddy *gb = NULL;
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
182
17495
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
183 if (kDNSServiceErr_NoError != errorCode)
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
184 purple_debug_error("bonjour", "service browser - callback error");
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: 18761
diff changeset
185 else if (flags & kDNSServiceFlagsAdd) {
17495
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
186 /* A presence service instance has been discovered... check it isn't us! */
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: 18761
diff changeset
187 if (g_ascii_strcasecmp(serviceName, account->username) != 0) {
17495
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
188 /* OK, lets go ahead and resolve it to add to the buddy list */
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
189 ResolveCallbackArgs *args = g_new0(ResolveCallbackArgs, 1);
17495
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
190 args->buddy = bonjour_buddy_new(serviceName, account);
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
191
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: 18761
diff changeset
192 if (kDNSServiceErr_NoError != DNSServiceResolve(&args->resolver, 0, 0, serviceName, regtype, replyDomain, _mdns_service_resolve_callback, args)) {
17495
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
193 bonjour_buddy_delete(args->buddy);
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
194 g_free(args);
17495
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
195 purple_debug_error("bonjour", "service browser - failed to resolve service.\n");
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: 18761
diff changeset
196 } else {
17495
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
197 /* get a file descriptor for this service ref, and add it to the input list */
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: 18761
diff changeset
198 gint fd = DNSServiceRefSockFD(args->resolver);
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: 18761
diff changeset
199 args->resolver_handler = purple_input_add(fd, PURPLE_INPUT_READ, _mdns_handle_event, args->resolver);
17495
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
200 }
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
201 }
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: 18761
diff changeset
202 } else {
17495
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
203 /* A peer has sent a goodbye packet, remove them from the buddy list */
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
204 purple_debug_info("bonjour", "service browser - remove notification\n");
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
205 gb = purple_find_buddy(account, serviceName);
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: 18761
diff changeset
206 if (gb != NULL) {
17495
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
207 bonjour_buddy_delete(gb->proto_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
208 purple_blist_remove_buddy(gb);
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
209 }
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
210 }
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
211 }
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
212
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: 18761
diff changeset
213 /****************************
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: 18761
diff changeset
214 * mdns_interface functions *
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: 18761
diff changeset
215 ****************************/
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: 18761
diff changeset
216
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: 18761
diff changeset
217 gboolean _mdns_init_session(BonjourDnsSd *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: 18761
diff changeset
218 data->mdns_impl_data = g_new0(Win32SessionImplData, 1);
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: 18761
diff changeset
219 return TRUE;
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: 18761
diff changeset
220 }
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: 18761
diff changeset
221
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: 18761
diff changeset
222 gboolean _mdns_publish(BonjourDnsSd *data, PublishType type) {
17495
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
223 TXTRecordRef dns_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
224 char portstring[6];
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: 18761
diff changeset
225 gboolean ret = TRUE;
17501
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
226 const char *jid, *aim, *email;
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
227 DNSServiceErrorType set_ret;
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: 18761
diff changeset
228 Win32SessionImplData *idata = data->mdns_impl_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: 18761
diff changeset
229
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: 18761
diff changeset
230 g_return_val_if_fail(idata != NULL, FALSE);
17501
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
231
17495
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
232 TXTRecordCreate(&dns_data, 256, NULL);
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
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 /* Convert the port to a string */
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 snprintf(portstring, sizeof(portstring), "%d", data->port_p2pj);
17501
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
236
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
237 jid = purple_account_get_string(data->account, "jid", NULL);
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
238 aim = purple_account_get_string(data->account, "AIM", NULL);
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
239 email = purple_account_get_string(data->account, "email", NULL);
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
240
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
241 /* We should try to follow XEP-0174, but some clients have "issues", so we humor them.
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
242 * See http://telepathy.freedesktop.org/wiki/SalutInteroperability
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
243 */
17495
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
17501
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
245 /* Needed by iChat */
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
246 set_ret = TXTRecordSetValue(&dns_data, "txtvers", 1, "1");
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
247 /* Needed by Gaim/Pidgin <= 2.0.1 (remove at some point) */
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
248 if (set_ret == kDNSServiceErr_NoError)
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
249 set_ret = TXTRecordSetValue(&dns_data, "1st", strlen(data->first), data->first);
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
250 /* Needed by Gaim/Pidgin <= 2.0.1 (remove at some point) */
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
251 if (set_ret == kDNSServiceErr_NoError)
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
252 set_ret = TXTRecordSetValue(&dns_data, "last", strlen(data->last), data->last);
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
253 /* Needed by Adium */
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
254 if (set_ret == kDNSServiceErr_NoError)
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
255 set_ret = TXTRecordSetValue(&dns_data, "port.p2pj", strlen(portstring), portstring);
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
256 /* Needed by iChat, Gaim/Pidgin <= 2.0.1 */
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
257 if (set_ret == kDNSServiceErr_NoError)
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
258 set_ret = TXTRecordSetValue(&dns_data, "status", strlen(data->status), data->status);
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
259 if (set_ret == kDNSServiceErr_NoError)
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
260 set_ret = TXTRecordSetValue(&dns_data, "ver", strlen(VERSION), VERSION);
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
261 /* Currently always set to "!" since we don't support AV and wont ever be in a conference */
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
262 if (set_ret == kDNSServiceErr_NoError)
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
263 set_ret = TXTRecordSetValue(&dns_data, "vc", strlen(data->vc), data->vc);
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
264 if (set_ret == kDNSServiceErr_NoError && email != NULL && *email != '\0')
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
265 set_ret = TXTRecordSetValue(&dns_data, "email", strlen(email), email);
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
266 if (set_ret == kDNSServiceErr_NoError && jid != NULL && *jid != '\0')
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
267 set_ret = TXTRecordSetValue(&dns_data, "jid", strlen(jid), jid);
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
268 /* Nonstandard, but used by iChat */
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
269 if (set_ret == kDNSServiceErr_NoError && aim != NULL && *aim != '\0')
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
270 set_ret = TXTRecordSetValue(&dns_data, "AIM", strlen(aim), aim);
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
271 if (set_ret == kDNSServiceErr_NoError && data->msg != NULL && *data->msg != '\0')
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
272 set_ret = TXTRecordSetValue(&dns_data, "msg", strlen(data->msg), data->msg);
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
273 if (set_ret == kDNSServiceErr_NoError && data->phsh != NULL && *data->phsh != '\0')
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
274 set_ret = TXTRecordSetValue(&dns_data, "phsh", strlen(data->phsh), data->phsh);
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
275
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
276 /* TODO: ext, nick, node */
c96b085ddf5c Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
277
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: 18761
diff changeset
278 if (set_ret != kDNSServiceErr_NoError) {
17495
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
279 purple_debug_error("bonjour", "Unable to allocate memory for text record.\n");
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: 18761
diff changeset
280 ret = FALSE;
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: 18761
diff changeset
281 } else {
17495
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
282 DNSServiceErrorType err = kDNSServiceErr_NoError;
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
283
17495
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
284 /* OK, we're done constructing the text record, (re)publish the service */
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
285
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: 18761
diff changeset
286 switch (type) {
17495
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
287 case PUBLISH_START:
18761
316be7e715c6 Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18276
diff changeset
288 purple_debug_info("bonjour", "Registering service on port %d\n", data->port_p2pj);
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: 18761
diff changeset
289 err = DNSServiceRegister(&idata->advertisement, 0, 0, purple_account_get_username(data->account), ICHAT_SERVICE,
17506
bbe9248337ea Fix network byte order issues with win32 bonjour stuff. Also copy the buddy's ip address so that subsequent calls don't overwrite it (it already is being copied and freed because of the howl implementation).
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17505
diff changeset
290 NULL, NULL, htons(data->port_p2pj), TXTRecordGetLength(&dns_data), TXTRecordGetBytesPtr(&dns_data),
17495
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
291 _mdns_service_register_callback, NULL);
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
292 break;
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
293
17495
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
294 case PUBLISH_UPDATE:
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: 18761
diff changeset
295 err = DNSServiceUpdateRecord(idata->advertisement, NULL, 0, TXTRecordGetLength(&dns_data), TXTRecordGetBytesPtr(&dns_data), 0);
17495
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
296 break;
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
297 }
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
298
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: 18761
diff changeset
299 if (err != kDNSServiceErr_NoError) {
17495
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
300 purple_debug_error("bonjour", "Failed to publish presence service.\n");
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: 18761
diff changeset
301 ret = FALSE;
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: 18761
diff changeset
302 } else if (type == PUBLISH_START) {
17495
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
303 /* hack: Bonjour on windows is broken. We don't care about the callback but we have to listen anyway */
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: 18761
diff changeset
304 gint fd = DNSServiceRefSockFD(idata->advertisement);
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: 18761
diff changeset
305 idata->advertisement_handler = purple_input_add(fd, PURPLE_INPUT_READ, _mdns_handle_event, idata->advertisement);
17495
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
306 }
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
307 }
17505
9ccec98b8ca9 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
308
17495
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
309 /* Free the memory used by temp 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
310 TXTRecordDeallocate(&dns_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
311 return ret;
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
312 }
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
313
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: 18761
diff changeset
314 gboolean _mdns_browse(BonjourDnsSd *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: 18761
diff changeset
315 Win32SessionImplData *idata = data->mdns_impl_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: 18761
diff changeset
316
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: 18761
diff changeset
317 g_return_val_if_fail(idata != NULL, FALSE);
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: 18761
diff changeset
318
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: 18761
diff changeset
319 return (DNSServiceBrowse(&idata->browser, 0, 0, ICHAT_SERVICE, 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: 18761
diff changeset
320 _mdns_service_browse_callback, data->account)
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: 18761
diff changeset
321 == kDNSServiceErr_NoError);
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: 18761
diff changeset
322 }
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: 18761
diff changeset
323
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: 18761
diff changeset
324 guint _mdns_register_to_mainloop(BonjourDnsSd *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: 18761
diff changeset
325 Win32SessionImplData *idata = data->mdns_impl_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: 18761
diff changeset
326
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: 18761
diff changeset
327 g_return_val_if_fail(idata != NULL, FALSE);
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: 18761
diff changeset
328
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: 18761
diff changeset
329 return purple_input_add(DNSServiceRefSockFD(idata->browser),
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: 18761
diff changeset
330 PURPLE_INPUT_READ, _mdns_handle_event, idata->browser);
17495
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
331 }
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: 18761
diff changeset
332
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: 18761
diff changeset
333 void _mdns_stop(BonjourDnsSd *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: 18761
diff changeset
334 Win32SessionImplData *idata = data->mdns_impl_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: 18761
diff changeset
335
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: 18761
diff changeset
336 if (idata == NULL || idata->advertisement == NULL || idata->browser == 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: 18761
diff changeset
337 return;
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: 18761
diff changeset
338
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: 18761
diff changeset
339 /* hack: for win32, we need to stop listening to the advertisement pipe too */
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: 18761
diff changeset
340 purple_input_remove(idata->advertisement_handler);
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: 18761
diff changeset
341
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: 18761
diff changeset
342 DNSServiceRefDeallocate(idata->advertisement);
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: 18761
diff changeset
343 DNSServiceRefDeallocate(idata->browser);
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: 18761
diff changeset
344
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: 18761
diff changeset
345 g_free(idata);
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: 18761
diff changeset
346
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: 18761
diff changeset
347 data->mdns_impl_data = 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: 18761
diff changeset
348 }
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: 18761
diff changeset
349
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: 18761
diff changeset
350 void _mdns_init_buddy(BonjourBuddy *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: 18761
diff changeset
351 buddy->mdns_impl_data = g_new0(Win32BuddyImplData, 1);
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: 18761
diff changeset
352 }
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: 18761
diff changeset
353
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: 18761
diff changeset
354 void _mdns_delete_buddy(BonjourBuddy *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: 18761
diff changeset
355 Win32BuddyImplData *idata = buddy->mdns_impl_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: 18761
diff changeset
356
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: 18761
diff changeset
357 g_return_if_fail(idata != 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: 18761
diff changeset
358
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: 18761
diff changeset
359 if (idata->txt_query != 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: 18761
diff changeset
360 purple_input_remove(idata->txt_query_handler);
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: 18761
diff changeset
361 DNSServiceRefDeallocate(idata->txt_query);
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: 18761
diff changeset
362 }
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: 18761
diff changeset
363
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: 18761
diff changeset
364 g_free(idata);
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: 18761
diff changeset
365
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: 18761
diff changeset
366 buddy->mdns_impl_data = 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: 18761
diff changeset
367 }
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: 18761
diff changeset
368