libpurple/protocols/bonjour/mdns_win32.c

Mon, 04 Oct 2010 00:48:25 +0000

author
Daniel Atallah <datallah@pidgin.im>
date
Mon, 04 Oct 2010 00:48:25 +0000
changeset 30825
87a79bbdc985
parent 30824
5cdb0deaaa9b
child 32157
39ba2e2492ee
permissions
-rw-r--r--

The hostname used for a bonjour account should always be the current machine
name. This fixes our behavior so the previous statement is always the case.
Unfortunately, this means that if the hostname was previously not the current
machine name, the bonjour jid ends up looking like "username\40otherhost@hostname".

Fixes #12674

20842
d9b06f761ec8 rlaager noticed that these comments shouldn't be processed by doxygen.
Daniel Atallah <datallah@pidgin.im>
parents: 20200
diff changeset
1 /*
20200
21898c919046 applied changes from fbb7ffaf4075cf690cc3ff9d171e56320e9af8da
Luke Schierer <lschiere@pidgin.im>
parents: 19859
diff changeset
2 *
21898c919046 applied changes from fbb7ffaf4075cf690cc3ff9d171e56320e9af8da
Luke Schierer <lschiere@pidgin.im>
parents: 19859
diff changeset
3 * Purple is the legal property of its developers, whose names are too numerous
21898c919046 applied changes from fbb7ffaf4075cf690cc3ff9d171e56320e9af8da
Luke Schierer <lschiere@pidgin.im>
parents: 19859
diff changeset
4 * to list here. Please refer to the COPYRIGHT file distributed with this
21898c919046 applied changes from fbb7ffaf4075cf690cc3ff9d171e56320e9af8da
Luke Schierer <lschiere@pidgin.im>
parents: 19859
diff changeset
5 * source distribution.
21898c919046 applied changes from fbb7ffaf4075cf690cc3ff9d171e56320e9af8da
Luke Schierer <lschiere@pidgin.im>
parents: 19859
diff changeset
6 *
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
7 * 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
8 * 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
9 * 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
10 * (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
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 * 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
13 * 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
14 * 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
15 * 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
16 *
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
17 * 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
18 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19832
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301, USA.
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
20 */
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
21
18338
d3cb08f27e04 More compile fixes from rekkanoryo for G_GNUC_NULL_TERMINATED issues
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 17659
diff changeset
22 #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
23 #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
24
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
25 #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
26 #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
27 #include "dns_sd_proxy.h"
19204
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 19099
diff changeset
28 #include "mdns_common.h"
30825
87a79bbdc985 The hostname used for a bonjour account should always be the current machine
Daniel Atallah <datallah@pidgin.im>
parents: 30824
diff changeset
29 #include "bonjour.h"
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
30
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
31 static GSList *pending_buddies = 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
32
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
33 typedef struct _dnssd_service_ref_handler {
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
34 DNSServiceRef sdRef;
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
35 PurpleAccount *account;
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
36 guint input_handler;
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
37 } DnsSDServiceRefHandlerData;
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
38
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
39 /* 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
40 typedef struct _win32_session_impl_data {
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
41 DnsSDServiceRefHandlerData *presence_query;
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
42 DnsSDServiceRefHandlerData *browser_query;
19204
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 19099
diff changeset
43 DNSRecordRef buddy_icon_rec;
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
44 } 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
45
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
46 typedef struct _win32_buddy_service_resolver_data {
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
47 DnsSDServiceRefHandlerData *txt_query;
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
48 uint32_t if_idx;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
49 gchar *name;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
50 gchar *type;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
51 gchar *domain;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
52 /* This is a reference to the entry in BonjourBuddy->ips */
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
53 const char *ip;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
54 } Win32SvcResolverData;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
55
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
56 typedef struct _win32_buddy_impl_data {
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
57 GSList *resolvers;
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
58 DnsSDServiceRefHandlerData *null_query;
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
59 } 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
60
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
61 /* data structure for the resolve callback */
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
62 typedef struct _ResolveCallbackArgs {
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
63 DnsSDServiceRefHandlerData *resolver_query;
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
64 PurpleAccount *account;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
65 BonjourBuddy *bb;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
66 Win32SvcResolverData *res_data;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
67 gchar *full_service_name;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
68 } ResolveCallbackArgs;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
69
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
70
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
71 static gint
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
72 _find_resolver_data(gconstpointer a, gconstpointer b) {
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
73 const Win32SvcResolverData *rd_a = a;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
74 const Win32SvcResolverData *rd_b = b;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
75 gint ret = 1;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
76
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
77 if(rd_a->if_idx == rd_b->if_idx
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
78 && !strcmp(rd_a->name, rd_b->name)
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
79 && !strcmp(rd_a->type, rd_b->type)
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
80 && !strcmp(rd_a->domain, rd_b->domain)) {
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
81 ret = 0;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
82 }
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
83
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
84 return ret;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
85 }
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
86
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
87 static void
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
88 _cleanup_resolver_data(Win32SvcResolverData *rd) {
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
89 if (rd->txt_query != NULL) {
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
90 purple_input_remove(rd->txt_query->input_handler);
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
91 DNSServiceRefDeallocate(rd->txt_query->sdRef);
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
92 g_free(rd->txt_query);
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
93 }
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
94 g_free(rd->name);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
95 g_free(rd->type);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
96 g_free(rd->domain);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
97 g_free(rd);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
98 }
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
99
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
100 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
101 _mdns_handle_event(gpointer data, gint source, PurpleInputCondition condition) {
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
102 DnsSDServiceRefHandlerData *srh = data;
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
103 DNSServiceErrorType errorCode = DNSServiceProcessResult(srh->sdRef);
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
104 if (errorCode != kDNSServiceErr_NoError) {
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
105 purple_debug_error("bonjour", "Error (%d) handling mDNS response.\n", errorCode);
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
106 /* This happens when the mDNSResponder goes down, I haven't seen it happen any other time (in my limited testing) */
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
107 if (errorCode == kDNSServiceErr_Unknown) {
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
108 purple_connection_error_reason(srh->account->gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
109 _("Error communicating with local mDNSResponder."));
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
110 }
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
111 }
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
112 }
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
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
114 static void
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
115 _mdns_parse_text_record(BonjourBuddy *buddy, const char *record, uint16_t record_len)
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
116 {
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 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
118 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
119 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
120
19220
60d667d6bdc5 Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
121 clear_bonjour_buddy_values(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
122 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
123 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
124 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
125 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
126 }
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 }
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
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
129 static void DNSSD_API
19218
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19210
diff changeset
130 _mdns_record_query_callback(DNSServiceRef DNSServiceRef, DNSServiceFlags flags,
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
131 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
132 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
133 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
134 {
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
135
22113
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
136 if (errorCode != kDNSServiceErr_NoError) {
30824
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
137 purple_debug_error("bonjour", "record query - callback error (%d).\n", errorCode);
19748
ae5eab65f8de Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <datallah@pidgin.im>
parents: 19579
diff changeset
138 /* TODO: Probably should remove the buddy when this happens */
ae5eab65f8de Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <datallah@pidgin.im>
parents: 19579
diff changeset
139 } else if (flags & kDNSServiceFlagsAdd) {
19094
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
140 if (rrtype == kDNSServiceType_TXT) {
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
141 /* New Buddy */
19748
ae5eab65f8de Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <datallah@pidgin.im>
parents: 19579
diff changeset
142 BonjourBuddy *bb = (BonjourBuddy*) context;
ae5eab65f8de Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <datallah@pidgin.im>
parents: 19579
diff changeset
143 _mdns_parse_text_record(bb, rdata, rdlen);
ae5eab65f8de Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <datallah@pidgin.im>
parents: 19579
diff changeset
144 bonjour_buddy_add_to_purple(bb, NULL);
19094
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
145 } else if (rrtype == kDNSServiceType_NULL) {
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
146 /* Buddy Icon response */
19748
ae5eab65f8de Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <datallah@pidgin.im>
parents: 19579
diff changeset
147 BonjourBuddy *bb = (BonjourBuddy*) context;
ae5eab65f8de Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <datallah@pidgin.im>
parents: 19579
diff changeset
148 Win32BuddyImplData *idata = bb->mdns_impl_data;
19094
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
149
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
150 g_return_if_fail(idata != NULL);
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
151
19748
ae5eab65f8de Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <datallah@pidgin.im>
parents: 19579
diff changeset
152 bonjour_buddy_got_buddy_icon(bb, rdata, rdlen);
19094
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
153
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
154 /* We've got what we need; stop listening */
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
155 purple_input_remove(idata->null_query->input_handler);
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
156 DNSServiceRefDeallocate(idata->null_query->sdRef);
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
157 g_free(idata->null_query);
19094
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
158 idata->null_query = NULL;
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
159 }
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
160 }
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
161 }
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
30824
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
163 static void DNSSD_API
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
164 _mdns_resolve_host_callback(DNSServiceRef sdRef, DNSServiceFlags flags,
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
165 uint32_t interfaceIndex, DNSServiceErrorType errorCode,
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
166 const char *hostname, const struct sockaddr *address,
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
167 uint32_t ttl, void *context)
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
168 {
30824
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
169 ResolveCallbackArgs *args = (ResolveCallbackArgs*) context;
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
170 Win32BuddyImplData *idata = args->bb->mdns_impl_data;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
171 gboolean delete_buddy = FALSE;
25331
70fe9413ca87 Fix a race condition that can result in a NULL ptr deref. Fixes #7920.
Daniel Atallah <datallah@pidgin.im>
parents: 23140
diff changeset
172 PurpleBuddy *pb = NULL;
70fe9413ca87 Fix a race condition that can result in a NULL ptr deref. Fixes #7920.
Daniel Atallah <datallah@pidgin.im>
parents: 23140
diff changeset
173
30824
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
174 purple_input_remove(args->resolver_query->input_handler);
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
175 DNSServiceRefDeallocate(args->resolver_query->sdRef);
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
176 g_free(args->resolver_query);
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
177 args->resolver_query = NULL;
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
178
25729
7ef1f61c876e Backport ab47b66449b213d6fbfc728cc1e8c161bed87755 (#8782 - Fix persistent Bonjour buddies.)
Daniel Atallah <datallah@pidgin.im>
parents: 25331
diff changeset
179 if ((pb = purple_find_buddy(args->account, args->res_data->name))) {
7ef1f61c876e Backport ab47b66449b213d6fbfc728cc1e8c161bed87755 (#8782 - Fix persistent Bonjour buddies.)
Daniel Atallah <datallah@pidgin.im>
parents: 25331
diff changeset
180 if (pb->proto_data != args->bb) {
7ef1f61c876e Backport ab47b66449b213d6fbfc728cc1e8c161bed87755 (#8782 - Fix persistent Bonjour buddies.)
Daniel Atallah <datallah@pidgin.im>
parents: 25331
diff changeset
181 purple_debug_error("bonjour", "Found purple buddy for %s not matching bonjour buddy record.",
7ef1f61c876e Backport ab47b66449b213d6fbfc728cc1e8c161bed87755 (#8782 - Fix persistent Bonjour buddies.)
Daniel Atallah <datallah@pidgin.im>
parents: 25331
diff changeset
182 args->res_data->name);
7ef1f61c876e Backport ab47b66449b213d6fbfc728cc1e8c161bed87755 (#8782 - Fix persistent Bonjour buddies.)
Daniel Atallah <datallah@pidgin.im>
parents: 25331
diff changeset
183 goto cleanup;
7ef1f61c876e Backport ab47b66449b213d6fbfc728cc1e8c161bed87755 (#8782 - Fix persistent Bonjour buddies.)
Daniel Atallah <datallah@pidgin.im>
parents: 25331
diff changeset
184 }
25331
70fe9413ca87 Fix a race condition that can result in a NULL ptr deref. Fixes #7920.
Daniel Atallah <datallah@pidgin.im>
parents: 23140
diff changeset
185 /* Make sure that the BonjourBuddy associated with this request is still around */
25729
7ef1f61c876e Backport ab47b66449b213d6fbfc728cc1e8c161bed87755 (#8782 - Fix persistent Bonjour buddies.)
Daniel Atallah <datallah@pidgin.im>
parents: 25331
diff changeset
186 } else if (g_slist_find(pending_buddies, args->bb) == NULL) {
7ef1f61c876e Backport ab47b66449b213d6fbfc728cc1e8c161bed87755 (#8782 - Fix persistent Bonjour buddies.)
Daniel Atallah <datallah@pidgin.im>
parents: 25331
diff changeset
187 purple_debug_error("bonjour", "host resolution - complete, but buddy no longer pending.\n");
25331
70fe9413ca87 Fix a race condition that can result in a NULL ptr deref. Fixes #7920.
Daniel Atallah <datallah@pidgin.im>
parents: 23140
diff changeset
188 goto cleanup;
25729
7ef1f61c876e Backport ab47b66449b213d6fbfc728cc1e8c161bed87755 (#8782 - Fix persistent Bonjour buddies.)
Daniel Atallah <datallah@pidgin.im>
parents: 25331
diff changeset
189 }
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
30824
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
191 if (errorCode != kDNSServiceErr_NoError) {
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
192 purple_debug_error("bonjour", "host resolution - callback error (%d).\n", errorCode);
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
193 delete_buddy = TRUE;
19748
ae5eab65f8de Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <datallah@pidgin.im>
parents: 19579
diff changeset
194 } else {
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
195 DNSServiceRef txt_query_sr;
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
196
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 /* finally, set up the continuous txt record watcher, and add the buddy to purple */
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
198 errorCode = DNSServiceQueryRecord(&txt_query_sr, kDNSServiceFlagsLongLivedQuery,
19207
e63cbb092381 Fix recieving status updates for bonjour (win32 implementation).
Daniel Atallah <datallah@pidgin.im>
parents: 19206
diff changeset
199 kDNSServiceInterfaceIndexAny, args->full_service_name, kDNSServiceType_TXT,
22113
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
200 kDNSServiceClass_IN, _mdns_record_query_callback, args->bb);
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
201 if (errorCode == kDNSServiceErr_NoError) {
30824
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
202 const char *ip = inet_ntoa(((struct sockaddr_in *) address)->sin_addr);
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
203
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
204 purple_debug_info("bonjour", "Found buddy %s at %s:%d\n", args->bb->name, ip, args->bb->port_p2pj);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
205
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
206 args->bb->ips = g_slist_prepend(args->bb->ips, g_strdup(ip));
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
207 args->res_data->ip = args->bb->ips->data;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
208
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
209 args->res_data->txt_query = g_new(DnsSDServiceRefHandlerData, 1);
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
210 args->res_data->txt_query->sdRef = txt_query_sr;
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
211 args->res_data->txt_query->account = args->account;
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
212
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
213 args->res_data->txt_query->input_handler = purple_input_add(DNSServiceRefSockFD(txt_query_sr),
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
214 PURPLE_INPUT_READ, _mdns_handle_event, args->res_data->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
215
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
216 bonjour_buddy_add_to_purple(args->bb, NULL);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
217 } else {
22113
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
218 purple_debug_error("bonjour", "Unable to set up record watcher for buddy %s (%d)\n", args->bb->name, errorCode);
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
219 delete_buddy = TRUE;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
220 }
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
221
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
222 }
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
223
25331
70fe9413ca87 Fix a race condition that can result in a NULL ptr deref. Fixes #7920.
Daniel Atallah <datallah@pidgin.im>
parents: 23140
diff changeset
224 cleanup:
70fe9413ca87 Fix a race condition that can result in a NULL ptr deref. Fixes #7920.
Daniel Atallah <datallah@pidgin.im>
parents: 23140
diff changeset
225
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
226 if (delete_buddy) {
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
227 idata->resolvers = g_slist_remove(idata->resolvers, args->res_data);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
228 _cleanup_resolver_data(args->res_data);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
229
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
230 /* If this was the last resolver, remove the buddy */
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
231 if (idata->resolvers == NULL) {
23140
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 22175
diff changeset
232 if (pb)
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 22175
diff changeset
233 bonjour_buddy_signed_off(pb);
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 22175
diff changeset
234 else
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
235 bonjour_buddy_delete(args->bb);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
236
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
237 /* Remove from the pending list */
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
238 pending_buddies = g_slist_remove(pending_buddies, args->bb);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
239 }
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
240 } else {
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
241 /* Remove from the pending list */
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
242 pending_buddies = g_slist_remove(pending_buddies, args->bb);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
243 }
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
244
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
245 /* free the remaining args memory */
19204
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 19099
diff changeset
246 g_free(args->full_service_name);
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
247 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
248 }
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
249
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
250 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
251 _mdns_service_resolve_callback(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, DNSServiceErrorType errorCode,
29796
919370cb1540 Warning fix for latest Bonjour SDK
Daniel Atallah <datallah@pidgin.im>
parents: 25729
diff changeset
252 const char *fullname, const char *hosttarget, uint16_t port, uint16_t txtLen, const unsigned char *txtRecord, void *context)
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
253 {
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
254 ResolveCallbackArgs *args = (ResolveCallbackArgs*) context;
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
255 Win32BuddyImplData *idata = args->bb->mdns_impl_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
256
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
257 /* remove the input fd and destroy the service ref */
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
258 purple_input_remove(args->resolver_query->input_handler);
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
259 DNSServiceRefDeallocate(args->resolver_query->sdRef);
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
260
22113
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
261 if (errorCode != kDNSServiceErr_NoError)
30824
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
262 purple_debug_error("bonjour", "service resolver - callback error. (%d)\n", errorCode);
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
263 else {
30824
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
264 DNSServiceRef getaddrinfo_sr;
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
265 /* set more arguments, and start the host resolver */
30824
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
266 errorCode = DNSServiceGetAddrInfo(&getaddrinfo_sr, 0, interfaceIndex,
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
267 kDNSServiceProtocol_IPv4, hosttarget, _mdns_resolve_host_callback, args);
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
268 if (errorCode != kDNSServiceErr_NoError)
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
269 purple_debug_error("bonjour", "service resolver - host resolution failed.\n");
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
270 else {
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
271 args->resolver_query->sdRef = getaddrinfo_sr;
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
272 args->resolver_query->input_handler = purple_input_add(DNSServiceRefSockFD(getaddrinfo_sr),
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
273 PURPLE_INPUT_READ, _mdns_handle_event, args->resolver_query);
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
274 args->full_service_name = g_strdup(fullname);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
275
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
276 /* TODO: Should this be per resolver? */
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
277 args->bb->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
278
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
279 /* We don't want to hit the cleanup code */
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
280 return;
30824
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
281 }
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
282 }
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
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
284 /* If we get this far, clean up */
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
285
30824
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
286 g_free(args->resolver_query);
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
287 args->resolver_query = NULL;
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
288
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
289 idata->resolvers = g_slist_remove(idata->resolvers, args->res_data);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
290 _cleanup_resolver_data(args->res_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
291
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
292 /* If this was the last resolver, remove the buddy */
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
293 if (idata->resolvers == NULL) {
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
294 PurpleBuddy *pb;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
295 /* See if this is now attached to a PurpleBuddy */
23140
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 22175
diff changeset
296 if ((pb = purple_find_buddy(args->account, args->bb->name)))
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 22175
diff changeset
297 bonjour_buddy_signed_off(pb);
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 22175
diff changeset
298 else {
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
299 /* Remove from the pending list */
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
300 pending_buddies = g_slist_remove(pending_buddies, args->bb);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
301 bonjour_buddy_delete(args->bb);
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
302 }
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 }
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
304
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
305 g_free(args);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
306
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
307 }
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
308
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
309 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
310 _mdns_service_register_callback(DNSServiceRef sdRef, DNSServiceFlags flags, DNSServiceErrorType errorCode,
19204
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 19099
diff changeset
311 const char *name, const char *regtype, const char *domain, void *context) {
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 19099
diff changeset
312
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 19099
diff changeset
313 /* TODO: deal with collision */
22113
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
314 if (errorCode != kDNSServiceErr_NoError)
19204
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 19099
diff changeset
315 purple_debug_error("bonjour", "service advertisement - callback error (%d).\n", 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
316 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
317 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
318 }
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
319
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
320 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
321 _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
322 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
323 {
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
324 PurpleAccount *account = (PurpleAccount*)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
325
22113
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
326 if (errorCode != kDNSServiceErr_NoError)
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
327 purple_debug_error("bonjour", "service browser - callback error (%d)\n", 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
328 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
329 /* A presence service instance has been discovered... check it isn't us! */
30825
87a79bbdc985 The hostname used for a bonjour account should always be the current machine
Daniel Atallah <datallah@pidgin.im>
parents: 30824
diff changeset
330 if (purple_utf8_strcasecmp(serviceName, bonjour_get_jid(account)) != 0) {
22113
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
331 DNSServiceErrorType resErrorCode;
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
332 /* 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
333 ResolveCallbackArgs *args = g_new0(ResolveCallbackArgs, 1);
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
334 DNSServiceRef resolver_sr;
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
335
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
336 purple_debug_info("bonjour", "Received new record for '%s' on iface %u (%s, %s)\n",
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
337 serviceName, interfaceIndex, regtype ? regtype : "",
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
338 replyDomain ? replyDomain : "");
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
339
30824
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
340 resErrorCode = DNSServiceResolve(&resolver_sr, 0, interfaceIndex, serviceName, regtype,
22113
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
341 replyDomain, _mdns_service_resolve_callback, args);
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
342 if (resErrorCode == kDNSServiceErr_NoError) {
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
343 GSList *tmp = pending_buddies;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
344 PurpleBuddy *pb;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
345 BonjourBuddy* bb = NULL;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
346 Win32SvcResolverData *rd;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
347 Win32BuddyImplData *idata;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
348
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
349 /* Is there an existing buddy? */
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
350 if ((pb = purple_find_buddy(account, serviceName)))
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
351 bb = pb->proto_data;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
352 /* Is there a pending buddy? */
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
353 else {
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
354 while (tmp) {
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
355 BonjourBuddy *bb_tmp = tmp->data;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
356 if (!strcmp(bb_tmp->name, serviceName)) {
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
357 bb = bb_tmp;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
358 break;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
359 }
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
360 tmp = tmp->next;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
361 }
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
362 }
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
363
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
364 if (bb == NULL) {
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
365 bb = bonjour_buddy_new(serviceName, account);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
366
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
367 /* This is only necessary for the wacky case where someone previously manually added a buddy. */
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
368 if (pb == NULL)
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
369 pending_buddies = g_slist_prepend(pending_buddies, bb);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
370 else
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
371 pb->proto_data = bb;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
372 }
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
373
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
374 rd = g_new0(Win32SvcResolverData, 1);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
375 rd->if_idx = interfaceIndex;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
376 rd->name = g_strdup(serviceName);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
377 rd->type = g_strdup(regtype);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
378 rd->domain = g_strdup(replyDomain);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
379
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
380 idata = bb->mdns_impl_data;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
381 idata->resolvers = g_slist_prepend(idata->resolvers, rd);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
382
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
383 args->bb = bb;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
384 args->res_data = rd;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
385 args->account = account;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
386
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
387 args->resolver_query = g_new(DnsSDServiceRefHandlerData, 1);
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
388 args->resolver_query->sdRef = resolver_sr;
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
389 args->resolver_query->account = account;
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
390 /* get a file descriptor for this service ref, and add it to the input list */
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
391 args->resolver_query->input_handler = purple_input_add(DNSServiceRefSockFD(resolver_sr),
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
392 PURPLE_INPUT_READ, _mdns_handle_event, args->resolver_query);
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
393 } else {
22113
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
394 purple_debug_error("bonjour", "service browser - failed to resolve service. (%d)\n", resErrorCode);
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
395 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
396 }
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
397 }
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
398 } else {
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
399 PurpleBuddy *pb = NULL;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
400
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
401 /* A peer has sent a goodbye packet, remove them from the buddy list */
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
402 purple_debug_info("bonjour", "Received remove notification for '%s' on iface %u (%s, %s)\n",
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
403 serviceName, interfaceIndex, regtype ? regtype : "",
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
404 replyDomain ? replyDomain : "");
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
405
19748
ae5eab65f8de Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <datallah@pidgin.im>
parents: 19579
diff changeset
406 pb = purple_find_buddy(account, serviceName);
21612
9fce536735e3 Various bugfixes including using purple_account_remove_buddy() in addition to purple_blist_remove_buddy() to make sure that the buddy gets cleaned up fully when logging out or we go offline.
Daniel Atallah <datallah@pidgin.im>
parents: 21095
diff changeset
407 if (pb != NULL) {
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
408 GSList *l;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
409 /* There may be multiple presences, we should only get rid of this one */
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
410 Win32SvcResolverData *rd_search;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
411 BonjourBuddy *bb = pb->proto_data;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
412 Win32BuddyImplData *idata;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
413
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
414 g_return_if_fail(bb != NULL);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
415
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
416 idata = bb->mdns_impl_data;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
417
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
418 rd_search = g_new0(Win32SvcResolverData, 1);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
419 rd_search->if_idx = interfaceIndex;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
420 rd_search->name = (gchar *) serviceName;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
421 rd_search->type = (gchar *) regtype;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
422 rd_search->domain = (gchar *) replyDomain;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
423
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
424 l = g_slist_find_custom(idata->resolvers, rd_search, _find_resolver_data);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
425
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
426 g_free(rd_search);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
427
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
428 if (l != NULL) {
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
429 Win32SvcResolverData *rd = l->data;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
430 idata->resolvers = g_slist_delete_link(idata->resolvers, l);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
431 /* This IP is no longer available */
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
432 if (rd->ip != NULL) {
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
433 bb->ips = g_slist_remove(bb->ips, rd->ip);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
434 g_free((gchar *) rd->ip);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
435 }
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
436 _cleanup_resolver_data(rd);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
437
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
438 /* If this was the last resolver, remove the buddy */
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
439 if (idata->resolvers == NULL) {
23140
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 22175
diff changeset
440 purple_debug_info("bonjour", "Removed last presence for buddy '%s'; signing off buddy.\n",
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 22175
diff changeset
441 serviceName);
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 22175
diff changeset
442 bonjour_buddy_signed_off(pb);
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
443 }
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
444 }
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
445 } else {
21612
9fce536735e3 Various bugfixes including using purple_account_remove_buddy() in addition to purple_blist_remove_buddy() to make sure that the buddy gets cleaned up fully when logging out or we go offline.
Daniel Atallah <datallah@pidgin.im>
parents: 21095
diff changeset
446 purple_debug_warning("bonjour", "Unable to find buddy (%s) to remove\n", serviceName ? serviceName : "(null)");
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
447 /* TODO: Should we look in the pending buddies list? */
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
448 }
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
449 }
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
450 }
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
451
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
452 /****************************
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
453 * 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
454 ****************************/
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
455
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
456 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
457 data->mdns_impl_data = g_new0(Win32SessionImplData, 1);
30825
87a79bbdc985 The hostname used for a bonjour account should always be the current machine
Daniel Atallah <datallah@pidgin.im>
parents: 30824
diff changeset
458
87a79bbdc985 The hostname used for a bonjour account should always be the current machine
Daniel Atallah <datallah@pidgin.im>
parents: 30824
diff changeset
459 bonjour_dns_sd_set_jid(data->account, purple_get_host_name());
87a79bbdc985 The hostname used for a bonjour account should always be the current machine
Daniel Atallah <datallah@pidgin.im>
parents: 30824
diff changeset
460
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
461 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
462 }
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
463
19221
29e6dd223bc5 Yay for code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 19220
diff changeset
464 gboolean _mdns_publish(BonjourDnsSd *data, PublishType type, GSList *records) {
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
465 TXTRecordRef dns_data;
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
466 gboolean ret = TRUE;
22113
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
467 DNSServiceErrorType errorCode = kDNSServiceErr_NoError;
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
468 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
469
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
470 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
471
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
472 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
473
19221
29e6dd223bc5 Yay for code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 19220
diff changeset
474 while (records) {
29e6dd223bc5 Yay for code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 19220
diff changeset
475 PurpleKeyValuePair *kvp = records->data;
22113
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
476 errorCode = TXTRecordSetValue(&dns_data, kvp->key, strlen(kvp->value), kvp->value);
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
477 if (errorCode != kDNSServiceErr_NoError)
19221
29e6dd223bc5 Yay for code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 19220
diff changeset
478 break;
29e6dd223bc5 Yay for code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 19220
diff changeset
479 records = records->next;
29e6dd223bc5 Yay for code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 19220
diff changeset
480 }
17608
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
481
22113
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
482 if (errorCode != kDNSServiceErr_NoError) {
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
483 purple_debug_error("bonjour", "Unable to allocate memory for text record.(%d)\n", 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
484 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
485 } 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
486 /* OK, we're done constructing the text record, (re)publish the service */
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
487 DNSServiceRef presence_sr;
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
488
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
489 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
490 case PUBLISH_START:
19206
ed0343b92c15 Fix bonjour buddy icons to work with iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
491 purple_debug_info("bonjour", "Registering presence on port %d\n", data->port_p2pj);
30824
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
492 errorCode = DNSServiceRegister(&presence_sr, kDNSServiceInterfaceIndexAny,
30825
87a79bbdc985 The hostname used for a bonjour account should always be the current machine
Daniel Atallah <datallah@pidgin.im>
parents: 30824
diff changeset
493 0, bonjour_get_jid(data->account), LINK_LOCAL_RECORD_NAME,
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
494 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
495 _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
496 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
497
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
498 case PUBLISH_UPDATE:
19206
ed0343b92c15 Fix bonjour buddy icons to work with iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
499 purple_debug_info("bonjour", "Updating presence.\n");
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
500 errorCode = DNSServiceUpdateRecord(idata->presence_query->sdRef, 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
501 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
502 }
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
503
22113
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
504 if (errorCode != kDNSServiceErr_NoError) {
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
505 purple_debug_error("bonjour", "Failed to publish presence service.(%d)\n", 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
506 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
507 } else if (type == PUBLISH_START) {
19207
e63cbb092381 Fix recieving status updates for bonjour (win32 implementation).
Daniel Atallah <datallah@pidgin.im>
parents: 19206
diff changeset
508 /* We need to do this because according to the Apple docs:
e63cbb092381 Fix recieving status updates for bonjour (win32 implementation).
Daniel Atallah <datallah@pidgin.im>
parents: 19206
diff changeset
509 * "the client is responsible for ensuring that DNSServiceProcessResult() is called
e63cbb092381 Fix recieving status updates for bonjour (win32 implementation).
Daniel Atallah <datallah@pidgin.im>
parents: 19206
diff changeset
510 * whenever there is a reply from the daemon - the daemon may terminate its connection
e63cbb092381 Fix recieving status updates for bonjour (win32 implementation).
Daniel Atallah <datallah@pidgin.im>
parents: 19206
diff changeset
511 * with a client that does not process the daemon's responses */
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
512 idata->presence_query = g_new(DnsSDServiceRefHandlerData, 1);
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
513 idata->presence_query->sdRef = presence_sr;
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
514 idata->presence_query->account = data->account;
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
515 idata->presence_query->input_handler = purple_input_add(DNSServiceRefSockFD(presence_sr),
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
516 PURPLE_INPUT_READ, _mdns_handle_event, idata->presence_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
517 }
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
518 }
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
519
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
520 /* 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
521 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
522 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
523 }
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
524
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
525 gboolean _mdns_browse(BonjourDnsSd *data) {
22113
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
526 DNSServiceErrorType 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
527 Win32SessionImplData *idata = data->mdns_impl_data;
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
528 DNSServiceRef browser_sr;
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
529
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
530 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
531
30824
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
532 errorCode = DNSServiceBrowse(&browser_sr, 0, kDNSServiceInterfaceIndexAny,
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
533 LINK_LOCAL_RECORD_NAME, NULL,_mdns_service_browse_callback,
5cdb0deaaa9b Use DNSServiceGetAddrInfo() from dns_sd.h to resolve the IP for remote bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 29796
diff changeset
534 data->account);
22113
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
535 if (errorCode == kDNSServiceErr_NoError) {
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
536 idata->browser_query = g_new(DnsSDServiceRefHandlerData, 1);
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
537 idata->browser_query->sdRef = browser_sr;
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
538 idata->browser_query->account = data->account;
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
539 idata->browser_query->input_handler = purple_input_add(DNSServiceRefSockFD(browser_sr),
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
540 PURPLE_INPUT_READ, _mdns_handle_event, idata->browser_query);
19204
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 19099
diff changeset
541 return TRUE;
22113
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
542 } else
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
543 purple_debug_error("bonjour", "Error registering Local Link presence browser. (%d)\n", errorCode);
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
544
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
545
19204
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 19099
diff changeset
546 return FALSE;
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
547 }
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
548
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
549 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
550 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
551
19204
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 19099
diff changeset
552 if (idata == NULL)
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
553 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
554
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
555 if (idata->presence_query != NULL) {
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
556 purple_input_remove(idata->presence_query->input_handler);
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
557 DNSServiceRefDeallocate(idata->presence_query->sdRef);
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
558 g_free(idata->presence_query);
19204
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 19099
diff changeset
559 }
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
560
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
561 if (idata->browser_query != NULL) {
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
562 purple_input_remove(idata->browser_query->input_handler);
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
563 DNSServiceRefDeallocate(idata->browser_query->sdRef);
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
564 g_free(idata->browser_query);
19204
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 19099
diff changeset
565 }
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 19099
diff changeset
566
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
567 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
568
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
569 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
570 }
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
571
19206
ed0343b92c15 Fix bonjour buddy icons to work with iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
572 gboolean _mdns_set_buddy_icon_data(BonjourDnsSd *data, gconstpointer avatar_data, gsize avatar_len) {
19204
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 19099
diff changeset
573 Win32SessionImplData *idata = data->mdns_impl_data;
22113
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
574 DNSServiceErrorType errorCode = kDNSServiceErr_NoError;
19204
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 19099
diff changeset
575
19206
ed0343b92c15 Fix bonjour buddy icons to work with iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
576 g_return_val_if_fail(idata != NULL, FALSE);
19204
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 19099
diff changeset
577
19206
ed0343b92c15 Fix bonjour buddy icons to work with iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
578 if (avatar_data != NULL && idata->buddy_icon_rec == NULL) {
ed0343b92c15 Fix bonjour buddy icons to work with iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
579 purple_debug_info("bonjour", "Setting new buddy icon.\n");
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
580 errorCode = DNSServiceAddRecord(idata->presence_query->sdRef, &idata->buddy_icon_rec,
19206
ed0343b92c15 Fix bonjour buddy icons to work with iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
581 0, kDNSServiceType_NULL, avatar_len, avatar_data, 0);
19204
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 19099
diff changeset
582 } else if (avatar_data != NULL) {
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 19099
diff changeset
583 purple_debug_info("bonjour", "Updating existing buddy icon.\n");
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
584 errorCode = DNSServiceUpdateRecord(idata->presence_query->sdRef, idata->buddy_icon_rec,
19206
ed0343b92c15 Fix bonjour buddy icons to work with iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
585 0, avatar_len, avatar_data, 0);
ed0343b92c15 Fix bonjour buddy icons to work with iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
586 } else if (idata->buddy_icon_rec != NULL) {
19204
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 19099
diff changeset
587 purple_debug_info("bonjour", "Removing existing buddy icon.\n");
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
588 errorCode = DNSServiceRemoveRecord(idata->presence_query->sdRef, idata->buddy_icon_rec, 0);
19204
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 19099
diff changeset
589 idata->buddy_icon_rec = NULL;
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 19099
diff changeset
590 }
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 19099
diff changeset
591
22113
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
592 if (errorCode != kDNSServiceErr_NoError) {
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
593 purple_debug_error("bonjour", "Error (%d) setting buddy icon record.\n", errorCode);
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
594 return FALSE;
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
595 }
19206
ed0343b92c15 Fix bonjour buddy icons to work with iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
596
22113
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
597 return TRUE;
19204
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 19099
diff changeset
598 }
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 19099
diff changeset
599
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
600 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
601 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
602 }
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
603
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
604 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
605 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
606
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
607 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
608
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
609 while (idata->resolvers) {
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
610 Win32SvcResolverData *rd = idata->resolvers->data;
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
611 _cleanup_resolver_data(rd);
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21612
diff changeset
612 idata->resolvers = g_slist_delete_link(idata->resolvers, idata->resolvers);
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
613 }
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
614
19094
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
615 if (idata->null_query != NULL) {
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
616 purple_input_remove(idata->null_query->input_handler);
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
617 DNSServiceRefDeallocate(idata->null_query->sdRef);
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
618 g_free(idata->null_query);
19094
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
619 }
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
620
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
621 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
622
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
623 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
624 }
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
625
19210
4dcb230b1dbd _mdns_retrieve_retrieve_buddy_icon() - what kind of crack am I on anyway?
Daniel Atallah <datallah@pidgin.im>
parents: 19208
diff changeset
626 void _mdns_retrieve_buddy_icon(BonjourBuddy* buddy) {
19094
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
627 Win32BuddyImplData *idata = buddy->mdns_impl_data;
19206
ed0343b92c15 Fix bonjour buddy icons to work with iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
628 char svc_name[kDNSServiceMaxDomainName];
19094
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
629
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
630 g_return_if_fail(idata != NULL);
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
631
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
632 /* Cancel any existing query */
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
633 if (idata->null_query != NULL) {
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
634 purple_input_remove(idata->null_query->input_handler);
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
635 DNSServiceRefDeallocate(idata->null_query->sdRef);
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
636 g_free(idata->null_query);
19094
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
637 idata->null_query = NULL;
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
638 }
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
639
22175
fe24624d2a07 Fix the _presence._tcp. record not to be referred to as the ICHAT_PRESENCE, that has been bothering me for a while.
Daniel Atallah <datallah@pidgin.im>
parents: 22119
diff changeset
640 if (DNSServiceConstructFullName(svc_name, buddy->name, LINK_LOCAL_RECORD_NAME, "local") != 0)
22113
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
641 purple_debug_error("bonjour", "Unable to construct full name to retrieve buddy icon for %s.\n", buddy->name);
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
642 else {
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
643 DNSServiceRef null_query_sr;
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
644
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
645 DNSServiceErrorType errorCode = DNSServiceQueryRecord(&null_query_sr, 0, kDNSServiceInterfaceIndexAny,
22113
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
646 svc_name, kDNSServiceType_NULL, kDNSServiceClass_IN, _mdns_record_query_callback, buddy);
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
647
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
648 if (errorCode == kDNSServiceErr_NoError) {
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
649 idata->null_query = g_new(DnsSDServiceRefHandlerData, 1);
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
650
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
651 idata->null_query->sdRef = null_query_sr;
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
652 idata->null_query->account = buddy->account;
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
653
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
654 idata->null_query->input_handler = purple_input_add(DNSServiceRefSockFD(null_query_sr),
22113
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
655 PURPLE_INPUT_READ, _mdns_handle_event, idata->null_query);
22119
01e560600e2e Detect the mdnsresponder crashing in the DnsSD implementation and disconnect the account instead of pegging the CPU.
Daniel Atallah <datallah@pidgin.im>
parents: 22113
diff changeset
656 } else
22113
d729dc2a1075 Improve error handling, particularly the debug output. I was hoping that this would provide some debug output that could be used to figure out how to detect and disconnect when the mdnsResponder crashes, but that doesn't appear to be the case.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
657 purple_debug_error("bonjour", "Unable to query buddy icon record for %s. (%d)\n", buddy->name, errorCode);
19094
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
658 }
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
659
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
660 }
b4d0fe1a515a Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents: 19093
diff changeset
661

mercurial