libreoffice: update to 24.8.4.2
[oi-userland.git] / components / network / avahi / patches / 12-browse.patch
blob858857d675408477bf110c91eba8d7cea83494ba
1 --- /usr/tmp/clean/avahi-0.6.28/avahi-core/browse.c 2010-08-26 01:51:38.983153000 +0100
2 +++ avahi-0.6.28/avahi-core/browse.c 2011-01-20 15:27:33.366236170 +0000
3 @@ -22,6 +22,7 @@
4 #endif
6 #include <stdlib.h>
7 +#include <stdio.h>
9 #include <avahi-common/timeval.h>
10 #include <avahi-common/malloc.h>
11 @@ -519,6 +520,91 @@
15 +#ifdef HAVE_BONJOUR
16 +static void resolve_socket_event(AvahiWatch *w, int fd, AvahiWatchEvent events,
17 +void *userdata) {
18 + AvahiSRecordBrowser *b = userdata;
19 + DNSServiceErrorType ret;
20 + DNSServiceRef client;
22 + assert(w);
23 + assert(fd >= 0);
24 + assert(events & AVAHI_WATCH_IN);
26 + assert (fd == DNSServiceRefSockFD(b->client));
28 + ret = DNSServiceProcessResult(b->client);
29 + if (ret != kDNSServiceErr_NoError) {
30 + if (b->watch) {
31 + b->server->poll_api->watch_free(b->watch);
32 + b->watch = NULL;
33 + }
34 + DNSServiceRefDeallocate(b->client);
35 + b->client = NULL;
36 + avahi_server_set_errno(b->server, AVAHI_ERR_DISCONNECTED);
37 + b->callback(b, b->interface, b->protocol, AVAHI_BROWSER_FAILURE, NULL, 0, b->userdata);
38 + }
41 +static void resolve_error_callback(AvahiTimeEvent *e, void *userdata) {
42 + AvahiSRecordBrowser *b = userdata;
44 + if (b->defer_time_event) {
45 + avahi_time_event_free(b->defer_time_event);
46 + b->defer_time_event = NULL;
47 + }
48 + avahi_server_set_errno(b->server, AVAHI_ERR_FAILURE);
49 + b->callback(
50 + b, b->interface, b->protocol, AVAHI_BROWSER_FAILURE, NULL,
51 + 0,
52 + b->userdata);
55 +static void browse_reply(DNSServiceRef client, DNSServiceFlags flags, uint32_t ifIndex, DNSServiceErrorType errorCode,
56 + const char *fullname, uint16_t rrtype, uint16_t rrclass, uint16_t rdlen, const void *rdata, uint32_t ttl, void *context) {
57 + AvahiSRecordBrowser *b = context;
58 + AvahiRecord *rr;
59 + AvahiKey *k;
61 + k = avahi_key_new(fullname, rrclass, rrtype);
62 + rr = avahi_record_new(k, ttl);
63 + if (avahi_rdata_parse(rr, rdata, rdlen) != 0) {
64 + printf("parse failed\n");
65 + return;
66 + }
67 + b->callback(b, b->interface, b->protocol, AVAHI_BROWSER_NEW, rr, 0, b->userdata);
68 + avahi_record_unref(rr);
71 +static void avahi_browse_record_start(AvahiSRecordBrowser *b) {
72 + DNSServiceErrorType ret;
73 + DNSServiceFlags flags;
75 + if (b->flags != AVAHI_LOOKUP_USE_WIDE_AREA)
76 + flags = kDNSServiceFlagsForceMulticast;
77 + else
78 + flags = 0;
80 + ret = DNSServiceQueryRecord(&b->client,
81 + 0,
82 + b->interface == AVAHI_IF_UNSPEC ?
83 + kDNSServiceInterfaceIndexAny :
84 + b->interface,
85 + b->key->name,
86 + b->key->type,
87 + b->key->clazz,
88 + browse_reply,
89 + b);
90 + if (ret != kDNSServiceErr_NoError || !b->client) {
91 + b->defer_time_event = avahi_time_event_new(b->server->time_event_queue,
92 +NULL, resolve_error_callback, b);
93 + } else {
94 + b->defer_time_event = NULL;
95 + b->watch = b->server->poll_api->watch_new(b->server->poll_api, DNSServiceRefSockFD(b->client), AVAHI_WATCH_IN, resolve_socket_event, b);
96 + }
98 +#endif
100 AvahiSRecordBrowser *avahi_s_record_browser_new(
101 AvahiServer *server,
102 AvahiIfIndex interface,
103 @@ -560,9 +646,15 @@
105 AVAHI_LLIST_PREPEND(AvahiSRecordBrowser, browser, server->record_browsers, b);
107 +#ifdef HAVE_BONJOUR
108 + b->watch = NULL;
109 + b->client = NULL;
110 + avahi_browse_record_start(b);
111 +#else
112 /* The currently cached entries are scanned a bit later, and than we will start querying, too */
113 b->defer_time_event = avahi_time_event_new(server->time_event_queue, NULL, defer_callback, b);
114 assert(b->defer_time_event);
115 +#endif
117 return b;
119 @@ -575,6 +667,13 @@
120 b->server->need_browser_cleanup = 1;
122 browser_cancel(b);
123 +#ifdef HAVE_BONJOUR
124 + if (b->watch)
125 + b->server->poll_api->watch_free(b->watch);
127 + if (b->client)
128 + DNSServiceRefDeallocate(b->client);
129 +#endif
132 void avahi_s_record_browser_destroy(AvahiSRecordBrowser *b) {
133 @@ -608,6 +707,8 @@
135 if (server->wide_area_lookup_engine)
136 avahi_wide_area_cleanup(server->wide_area_lookup_engine);
137 +#ifndef HAVE_BONJOUR
138 avahi_multicast_lookup_engine_cleanup(server->multicast_lookup_engine);
139 +#endif
142 --- /usr/tmp/clean/avahi-0.6.28/avahi-core/browse.h 2010-08-26 01:51:38.983153000 +0100
143 +++ avahi-0.6.28/avahi-core/browse.h 2011-01-21 09:33:14.663164775 +0000
144 @@ -50,6 +50,12 @@
145 unsigned n_lookups;
147 AvahiSRBLookup *root_lookup;
149 +#ifdef HAVE_BONJOUR
150 + DNSServiceRef client;
151 + AvahiWatch *watch;
152 +#endif
156 void avahi_browser_cleanup(AvahiServer *server);