libpurple/protocols/bonjour/mdns_win32.c

Sun, 05 Aug 2007 02:44:53 +0000

author
Daniel Atallah <datallah@pidgin.im>
date
Sun, 05 Aug 2007 02:44:53 +0000
changeset 19093
b2657106df0e
parent 19056
05cd9ab28312
child 19094
b4d0fe1a515a
permissions
-rw-r--r--

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.

17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
1 /*
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
2 * This program is free software; you can redistribute it and/or modify
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
3 * it under the terms of the GNU General Public License as published by
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
4 * the Free Software Foundation; either version 2 of the License, or
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
5 * (at your option) any later version.
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
6 *
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
7 * This program is distributed in the hope that it will be useful,
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
10 * GNU Library General Public License for more details.
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
11 *
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
12 * You should have received a copy of the GNU General Public License
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
13 * along with this program; if not, write to the Free Software
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
15 */
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
16
18338
d3cb08f27e04 More compile fixes from rekkanoryo for G_GNUC_NULL_TERMINATED issues
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 17659
diff changeset
17 #include "internal.h"
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
18 #include "debug.h"
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
19
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
20 #include "buddy.h"
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
21 #include "mdns_interface.h"
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
22 #include "dns_sd_proxy.h"
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
23 #include "dnsquery.h"
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
24
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
25
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
26 /* data structure for the resolve callback */
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
27 typedef struct _ResolveCallbackArgs {
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
28 DNSServiceRef resolver;
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
29 guint resolver_handler;
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
30
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
31 PurpleDnsQueryData *query;
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
32 gchar *fqn;
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
33
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
34 BonjourBuddy* buddy;
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
35 } ResolveCallbackArgs;
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
36
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
37 /* data used by win32 bonjour implementation */
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
38 typedef struct _win32_session_impl_data {
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
39 DNSServiceRef advertisement;
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
40 DNSServiceRef browser;
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
41
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
42 guint advertisement_handler; /* hack... windows bonjour is broken, so we have to have this */
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
43 } Win32SessionImplData;
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
44
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
45 typedef struct _win32_buddy_impl_data {
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
46 DNSServiceRef txt_query;
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
47 guint txt_query_handler;
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
48 } Win32BuddyImplData;
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
49
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
50 static void
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
51 _mdns_handle_event(gpointer data, gint source, PurpleInputCondition condition) {
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
52 DNSServiceProcessResult((DNSServiceRef) data);
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
53 }
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
54
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
55 static void
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
56 _mdns_parse_text_record(BonjourBuddy* buddy, const char* record, uint16_t record_len)
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
57 {
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
58 const char *txt_entry;
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
59 uint8_t txt_len;
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
60 int i;
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
61
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
62 for (i = 0; buddy_TXT_records[i] != NULL; i++) {
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
63 txt_entry = TXTRecordGetValuePtr(record_len, record, buddy_TXT_records[i], &txt_len);
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
64 if (txt_entry != NULL)
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
65 set_bonjour_buddy_value(buddy, buddy_TXT_records[i], txt_entry, txt_len);
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
66 }
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
67 }
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
68
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
69 static void DNSSD_API
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
70 _mdns_text_record_query_callback(DNSServiceRef DNSServiceRef, DNSServiceFlags flags,
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
71 uint32_t interfaceIndex, DNSServiceErrorType errorCode, const char *fullname,
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
72 uint16_t rrtype, uint16_t rrclass, uint16_t rdlen, const void *rdata,
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
73 uint32_t ttl, void *context)
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
74 {
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
75
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
76 if (kDNSServiceErr_NoError != errorCode)
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
77 purple_debug_error("bonjour", "record query - callback error.\n");
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
78 else if (flags & kDNSServiceFlagsAdd)
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
79 {
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
80 /* New Buddy */
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
81 BonjourBuddy *buddy = (BonjourBuddy*) context;
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
82 _mdns_parse_text_record(buddy, rdata, rdlen);
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
83 bonjour_buddy_add_to_purple(buddy);
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
84 }
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
85 }
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
86
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
87 static void
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
88 _mdns_resolve_host_callback(GSList *hosts, gpointer data, const char *error_message)
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
89 {
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
90 ResolveCallbackArgs* args = (ResolveCallbackArgs*)data;
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
91
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
92 if (!hosts || !hosts->data)
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
93 purple_debug_error("bonjour", "host resolution - callback error.\n");
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
94 else {
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
95 struct sockaddr_in *addr = (struct sockaddr_in*)g_slist_nth_data(hosts, 1);
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
96 BonjourBuddy* buddy = args->buddy;
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
97 Win32BuddyImplData *idata = buddy->mdns_impl_data;
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
98
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
99 g_return_if_fail(idata != NULL);
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
100
17613
1a64916f979a 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 <datallah@pidgin.im>
parents: 17612
diff changeset
101 buddy->ip = g_strdup(inet_ntoa(addr->sin_addr));
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
102
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
103 /* finally, set up the continuous txt record watcher, and add the buddy to purple */
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
104
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
105 if (kDNSServiceErr_NoError == DNSServiceQueryRecord(&idata->txt_query, 0, 0, buddy->full_service_name,
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
106 kDNSServiceType_TXT, kDNSServiceClass_IN, _mdns_text_record_query_callback, buddy)) {
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
107 int fd = DNSServiceRefSockFD(idata->txt_query);
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
108 idata->txt_query_handler = purple_input_add(fd, PURPLE_INPUT_READ, _mdns_handle_event, idata->txt_query);
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
109
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
110 bonjour_buddy_add_to_purple(buddy);
19056
05cd9ab28312 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 <datallah@pidgin.im>
parents: 18338
diff changeset
111
05cd9ab28312 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 <datallah@pidgin.im>
parents: 18338
diff changeset
112 purple_debug_info("bonjour", "Found buddy %s at %s:%d\n", buddy->name, buddy->ip, buddy->port_p2pj);
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
113 } else
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
114 bonjour_buddy_delete(buddy);
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
115
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
116 }
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
117
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
118 /* free the hosts list*/
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
119 g_slist_free(hosts);
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
120
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
121 /* free the remaining args memory */
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
122 purple_dnsquery_destroy(args->query);
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
123 g_free(args->fqn);
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
124 g_free(args);
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
125 }
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
126
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
127 static void DNSSD_API
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
128 _mdns_service_resolve_callback(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, DNSServiceErrorType errorCode,
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
129 const char *fullname, const char *hosttarget, uint16_t port, uint16_t txtLen, const char *txtRecord, void *context)
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
130 {
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
131 ResolveCallbackArgs *args = (ResolveCallbackArgs*)context;
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
132
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
133 /* remove the input fd and destroy the service ref */
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
134 purple_input_remove(args->resolver_handler);
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
135 DNSServiceRefDeallocate(args->resolver);
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
136
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
137 if (kDNSServiceErr_NoError != errorCode)
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
138 {
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
139 purple_debug_error("bonjour", "service resolver - callback error.\n");
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
140 bonjour_buddy_delete(args->buddy);
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
141 g_free(args);
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
142 }
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
143 else
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
144 {
17613
1a64916f979a 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 <datallah@pidgin.im>
parents: 17612
diff changeset
145 args->buddy->port_p2pj = ntohs(port);
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
146
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
147 /* parse the text record */
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
148 _mdns_parse_text_record(args->buddy, txtRecord, txtLen);
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
149
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
150 /* set more arguments, and start the host resolver */
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
151 args->fqn = g_strdup(fullname);
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
152
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
153 if (!(args->query =
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
154 purple_dnsquery_a(hosttarget, port, _mdns_resolve_host_callback, args)))
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
155 {
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
156 purple_debug_error("bonjour", "service resolver - host resolution failed.\n");
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
157 bonjour_buddy_delete(args->buddy);
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
158 g_free(args->fqn);
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
159 g_free(args);
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
160 }
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
161 }
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
162
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
163 }
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
164
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
165 static void DNSSD_API
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
166 _mdns_service_register_callback(DNSServiceRef sdRef, DNSServiceFlags flags, DNSServiceErrorType errorCode,
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
167 const char *name, const char *regtype, const char *domain, void *context)
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
168 {
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
169 /* we don't actually care about anything said in this callback - this is only here because Bonjour for windows is broken */
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
170 if (kDNSServiceErr_NoError != errorCode)
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
171 purple_debug_error("bonjour", "service advertisement - callback error.\n");
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
172 else
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
173 purple_debug_info("bonjour", "service advertisement - callback.\n");
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
174 }
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
175
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
176 static void DNSSD_API
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
177 _mdns_service_browse_callback(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex,
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
178 DNSServiceErrorType errorCode, const char *serviceName, const char *regtype, const char *replyDomain, void *context)
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
179 {
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
180 PurpleAccount *account = (PurpleAccount*)context;
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
181 PurpleBuddy *gb = NULL;
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
182
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
183 if (kDNSServiceErr_NoError != errorCode)
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
184 purple_debug_error("bonjour", "service browser - callback error");
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
185 else if (flags & kDNSServiceFlagsAdd) {
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
186 /* A presence service instance has been discovered... check it isn't us! */
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
187 if (g_ascii_strcasecmp(serviceName, account->username) != 0) {
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
188 /* OK, lets go ahead and resolve it to add to the buddy list */
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
189 ResolveCallbackArgs *args = g_new0(ResolveCallbackArgs, 1);
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
190 args->buddy = bonjour_buddy_new(serviceName, account);
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
191
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
192 if (kDNSServiceErr_NoError != DNSServiceResolve(&args->resolver, 0, 0, serviceName, regtype, replyDomain, _mdns_service_resolve_callback, args)) {
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
193 bonjour_buddy_delete(args->buddy);
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
194 g_free(args);
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
195 purple_debug_error("bonjour", "service browser - failed to resolve service.\n");
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
196 } else {
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
197 /* get a file descriptor for this service ref, and add it to the input list */
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
198 gint fd = DNSServiceRefSockFD(args->resolver);
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
199 args->resolver_handler = purple_input_add(fd, PURPLE_INPUT_READ, _mdns_handle_event, args->resolver);
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
200 }
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
201 }
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
202 } else {
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
203 /* A peer has sent a goodbye packet, remove them from the buddy list */
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
204 purple_debug_info("bonjour", "service browser - remove notification\n");
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
205 gb = purple_find_buddy(account, serviceName);
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
206 if (gb != NULL) {
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
207 bonjour_buddy_delete(gb->proto_data);
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
208 purple_blist_remove_buddy(gb);
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
209 }
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
210 }
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
211 }
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
212
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
213 /****************************
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
214 * mdns_interface functions *
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
215 ****************************/
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
216
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
217 gboolean _mdns_init_session(BonjourDnsSd *data) {
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
218 data->mdns_impl_data = g_new0(Win32SessionImplData, 1);
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
219 return TRUE;
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
220 }
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
221
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
222 gboolean _mdns_publish(BonjourDnsSd *data, PublishType type) {
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
223 TXTRecordRef dns_data;
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
224 char portstring[6];
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
225 gboolean ret = TRUE;
17608
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
226 const char *jid, *aim, *email;
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
227 DNSServiceErrorType set_ret;
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
228 Win32SessionImplData *idata = data->mdns_impl_data;
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
229
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
230 g_return_val_if_fail(idata != NULL, FALSE);
17608
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
231
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
232 TXTRecordCreate(&dns_data, 256, NULL);
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
233
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
234 /* Convert the port to a string */
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
235 snprintf(portstring, sizeof(portstring), "%d", data->port_p2pj);
17608
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
236
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
237 jid = purple_account_get_string(data->account, "jid", NULL);
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
238 aim = purple_account_get_string(data->account, "AIM", NULL);
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
239 email = purple_account_get_string(data->account, "email", NULL);
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
240
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
241 /* We should try to follow XEP-0174, but some clients have "issues", so we humor them.
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
242 * See http://telepathy.freedesktop.org/wiki/SalutInteroperability
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
243 */
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
244
17608
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
245 /* Needed by iChat */
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
246 set_ret = TXTRecordSetValue(&dns_data, "txtvers", 1, "1");
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
247 /* Needed by Gaim/Pidgin <= 2.0.1 (remove at some point) */
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
248 if (set_ret == kDNSServiceErr_NoError)
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
249 set_ret = TXTRecordSetValue(&dns_data, "1st", strlen(data->first), data->first);
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
250 /* Needed by Gaim/Pidgin <= 2.0.1 (remove at some point) */
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
251 if (set_ret == kDNSServiceErr_NoError)
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
252 set_ret = TXTRecordSetValue(&dns_data, "last", strlen(data->last), data->last);
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
253 /* Needed by Adium */
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
254 if (set_ret == kDNSServiceErr_NoError)
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
255 set_ret = TXTRecordSetValue(&dns_data, "port.p2pj", strlen(portstring), portstring);
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
256 /* Needed by iChat, Gaim/Pidgin <= 2.0.1 */
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
257 if (set_ret == kDNSServiceErr_NoError)
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
258 set_ret = TXTRecordSetValue(&dns_data, "status", strlen(data->status), data->status);
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
259 if (set_ret == kDNSServiceErr_NoError)
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
260 set_ret = TXTRecordSetValue(&dns_data, "ver", strlen(VERSION), VERSION);
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
261 /* Currently always set to "!" since we don't support AV and wont ever be in a conference */
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
262 if (set_ret == kDNSServiceErr_NoError)
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
263 set_ret = TXTRecordSetValue(&dns_data, "vc", strlen(data->vc), data->vc);
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
264 if (set_ret == kDNSServiceErr_NoError && email != NULL && *email != '\0')
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
265 set_ret = TXTRecordSetValue(&dns_data, "email", strlen(email), email);
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
266 if (set_ret == kDNSServiceErr_NoError && jid != NULL && *jid != '\0')
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
267 set_ret = TXTRecordSetValue(&dns_data, "jid", strlen(jid), jid);
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
268 /* Nonstandard, but used by iChat */
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
269 if (set_ret == kDNSServiceErr_NoError && aim != NULL && *aim != '\0')
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
270 set_ret = TXTRecordSetValue(&dns_data, "AIM", strlen(aim), aim);
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
271 if (set_ret == kDNSServiceErr_NoError && data->msg != NULL && *data->msg != '\0')
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
272 set_ret = TXTRecordSetValue(&dns_data, "msg", strlen(data->msg), data->msg);
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
273 if (set_ret == kDNSServiceErr_NoError && data->phsh != NULL && *data->phsh != '\0')
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
274 set_ret = TXTRecordSetValue(&dns_data, "phsh", strlen(data->phsh), data->phsh);
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
275
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
276 /* TODO: ext, nick, node */
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
277
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
278 if (set_ret != kDNSServiceErr_NoError) {
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
279 purple_debug_error("bonjour", "Unable to allocate memory for text record.\n");
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
280 ret = FALSE;
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
281 } else {
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
282 DNSServiceErrorType err = kDNSServiceErr_NoError;
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
283
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
284 /* OK, we're done constructing the text record, (re)publish the service */
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
285
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
286 switch (type) {
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
287 case PUBLISH_START:
19056
05cd9ab28312 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 <datallah@pidgin.im>
parents: 18338
diff changeset
288 purple_debug_info("bonjour", "Registering service on port %d\n", data->port_p2pj);
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
289 err = DNSServiceRegister(&idata->advertisement, 0, 0, purple_account_get_username(data->account), ICHAT_SERVICE,
17613
1a64916f979a 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 <datallah@pidgin.im>
parents: 17612
diff changeset
290 NULL, NULL, htons(data->port_p2pj), TXTRecordGetLength(&dns_data), TXTRecordGetBytesPtr(&dns_data),
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
291 _mdns_service_register_callback, NULL);
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
292 break;
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
293
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
294 case PUBLISH_UPDATE:
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
295 err = DNSServiceUpdateRecord(idata->advertisement, NULL, 0, TXTRecordGetLength(&dns_data), TXTRecordGetBytesPtr(&dns_data), 0);
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
296 break;
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
297 }
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
298
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
299 if (err != kDNSServiceErr_NoError) {
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
300 purple_debug_error("bonjour", "Failed to publish presence service.\n");
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
301 ret = FALSE;
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
302 } else if (type == PUBLISH_START) {
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
303 /* hack: Bonjour on windows is broken. We don't care about the callback but we have to listen anyway */
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
304 gint fd = DNSServiceRefSockFD(idata->advertisement);
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
305 idata->advertisement_handler = purple_input_add(fd, PURPLE_INPUT_READ, _mdns_handle_event, idata->advertisement);
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
306 }
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
307 }
17612
72b49b54ee39 Cleanup win32 of bonjour stuff - fix to only use glib to allocate and free memory to avoid confusion later.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
308
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
309 /* Free the memory used by temp data */
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
310 TXTRecordDeallocate(&dns_data);
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
311 return ret;
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
312 }
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
313
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
314 gboolean _mdns_browse(BonjourDnsSd *data) {
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
315 Win32SessionImplData *idata = data->mdns_impl_data;
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
316
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
317 g_return_val_if_fail(idata != NULL, FALSE);
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
318
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
319 return (DNSServiceBrowse(&idata->browser, 0, 0, ICHAT_SERVICE, NULL,
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
320 _mdns_service_browse_callback, data->account)
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
321 == kDNSServiceErr_NoError);
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
322 }
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
323
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
324 guint _mdns_register_to_mainloop(BonjourDnsSd *data) {
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
325 Win32SessionImplData *idata = data->mdns_impl_data;
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
326
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
327 g_return_val_if_fail(idata != NULL, FALSE);
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
328
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
329 return purple_input_add(DNSServiceRefSockFD(idata->browser),
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
330 PURPLE_INPUT_READ, _mdns_handle_event, idata->browser);
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
331 }
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
332
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
333 void _mdns_stop(BonjourDnsSd *data) {
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
334 Win32SessionImplData *idata = data->mdns_impl_data;
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
335
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
336 if (idata == NULL || idata->advertisement == NULL || idata->browser == NULL)
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
337 return;
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
338
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
339 /* hack: for win32, we need to stop listening to the advertisement pipe too */
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
340 purple_input_remove(idata->advertisement_handler);
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
341
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
342 DNSServiceRefDeallocate(idata->advertisement);
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
343 DNSServiceRefDeallocate(idata->browser);
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
344
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
345 g_free(idata);
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
346
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
347 data->mdns_impl_data = NULL;
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
348 }
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
349
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
350 void _mdns_init_buddy(BonjourBuddy *buddy) {
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
351 buddy->mdns_impl_data = g_new0(Win32BuddyImplData, 1);
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
352 }
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
353
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
354 void _mdns_delete_buddy(BonjourBuddy *buddy) {
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
355 Win32BuddyImplData *idata = buddy->mdns_impl_data;
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
356
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
357 g_return_if_fail(idata != NULL);
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
358
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
359 if (idata->txt_query != NULL) {
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
360 purple_input_remove(idata->txt_query_handler);
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
361 DNSServiceRefDeallocate(idata->txt_query);
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
362 }
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
363
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
364 g_free(idata);
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
365
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
366 buddy->mdns_impl_data = NULL;
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
367 }
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
368

mercurial