]> git.meshlink.io Git - catta/blob - avahi-client/client.h
9d57c502d0280feee2f7c202d56960afb137732b
[catta] / avahi-client / client.h
1 #ifndef fooclienthfoo
2 #define fooclienthfoo
3
4 /* $Id$ */
5
6 /***
7   This file is part of avahi.
8  
9   avahi is free software; you can redistribute it and/or modify it
10   under the terms of the GNU Lesser General Public License as
11   published by the Free Software Foundation; either version 2.1 of the
12   License, or (at your option) any later version.
13  
14   avahi is distributed in the hope that it will be useful, but WITHOUT
15   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16   or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
17   Public License for more details.
18  
19   You should have received a copy of the GNU Lesser General Public
20   License along with avahi; if not, write to the Free Software
21   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22   USA.
23 ***/
24
25 #include <inttypes.h>
26
27 #include <avahi-common/cdecl.h>
28 #include <avahi-common/address.h>
29 #include <avahi-common/strlst.h>
30 #include <avahi-common/defs.h>
31 #include <avahi-common/watch.h>
32 #include <avahi-common/gccmacro.h>
33
34 /** \file client.h Definitions and functions for the client API over D-Bus */
35
36 /** \example client-publish-service.c Example how to register a DNS-SD
37  * service using the client interface to avahi-daemon. It behaves like a network
38  * printer registering both an IPP and a BSD LPR service. */
39
40 /** \example client-browse-services.c Example how to browse for DNS-SD
41  * services using the client interface to avahi-daemon. */
42
43 /** \example glib-integration.c Example of how to integrate
44  * avahi use with GLIB/GTK applications */
45  
46
47 #ifndef DOXYGEN_SHOULD_SKIP_THIS
48 AVAHI_C_DECL_BEGIN
49 #endif
50
51 /** A connection context */
52 typedef struct AvahiClient AvahiClient;
53
54 /** An entry group object */
55 typedef struct AvahiEntryGroup AvahiEntryGroup;
56
57 /** A domain browser object */
58 typedef struct AvahiDomainBrowser AvahiDomainBrowser;
59
60 /** A service browser object */
61 typedef struct AvahiServiceBrowser AvahiServiceBrowser;
62
63 /** A service type browser object */
64 typedef struct AvahiServiceTypeBrowser AvahiServiceTypeBrowser;
65
66 /** A service resolver object */
67 typedef struct AvahiServiceResolver AvahiServiceResolver;
68
69 /** A service resolver object */
70 typedef struct AvahiHostNameResolver AvahiHostNameResolver;
71
72 /** An address resolver object */
73 typedef struct AvahiAddressResolver AvahiAddressResolver;
74
75 /** States of a client object, a superset of AvahiServerState */
76 typedef enum {
77     AVAHI_CLIENT_S_INVALID = AVAHI_SERVER_INVALID,
78     AVAHI_CLIENT_S_REGISTERING = AVAHI_SERVER_REGISTERING,
79     AVAHI_CLIENT_S_RUNNING = AVAHI_SERVER_RUNNING,
80     AVAHI_CLIENT_S_COLLISION = AVAHI_SERVER_COLLISION,
81     AVAHI_CLIENT_DISCONNECTED = 100 /**< Lost DBUS connection to the Avahi daemon */
82 } AvahiClientState;
83
84 /** The function prototype for the callback of an AvahiClient */
85 typedef void (*AvahiClientCallback) (AvahiClient *s, AvahiClientState state, void* userdata);
86
87 /** The function prototype for the callback of an AvahiEntryGroup */
88 typedef void (*AvahiEntryGroupCallback) (AvahiEntryGroup *g, AvahiEntryGroupState state, void* userdata);
89
90 /** The function prototype for the callback of an AvahiDomainBrowser */
91 typedef void (*AvahiDomainBrowserCallback) (AvahiDomainBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *domain, void *userdata);
92
93 /** The function prototype for the callback of an AvahiServiceBrowser */
94 typedef void (*AvahiServiceBrowserCallback) (AvahiServiceBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *name, const char *type, const char *domain, void *userdata);
95
96 /** The function prototype for the callback of an AvahiServiceTypeBrowser */
97 typedef void (*AvahiServiceTypeBrowserCallback) (AvahiServiceTypeBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *type, const char *domain, void *userdata);
98
99 /** The function prototype for the callback of an AvahiServiceResolver */
100 typedef void (*AvahiServiceResolverCallback) (
101     AvahiServiceResolver *r,
102     AvahiIfIndex interface,
103     AvahiProtocol protocol,
104     AvahiResolverEvent event,
105     const char *name,
106     const char *type,
107     const char *domain,
108     const char *host_name,
109     const AvahiAddress *a,
110     uint16_t port,
111     AvahiStringList *txt,
112     void *userdata);
113
114 /** The function prototype for the callback of an AvahiHostNameResolver */
115 typedef void (*AvahiHostNameResolverCallback) (
116     AvahiHostNameResolver *r,
117     AvahiIfIndex interface,
118     AvahiProtocol protocol,
119     AvahiResolverEvent event,
120     const char *name,
121     const AvahiAddress *a,
122     void *userdata);
123
124 /** The function prototype for the callback of an AvahiAddressResolver */
125 typedef void (*AvahiAddressResolverCallback) (
126     AvahiAddressResolver *r,
127     AvahiIfIndex interface,
128     AvahiProtocol protocol,
129     AvahiResolverEvent event,
130     AvahiProtocol aprotocol,
131     const AvahiAddress *a,
132     const char *name,
133     void *userdata);
134
135 /** Creates a new client instance */
136 AvahiClient* avahi_client_new (const AvahiPoll *poll_api, AvahiClientCallback callback, void *userdata, int *error);
137
138 /** Free a client instance */
139 void avahi_client_free(AvahiClient *client);
140
141 /** Get the version of the server */
142 const char* avahi_client_get_version_string (AvahiClient*);
143
144 /** Get host name */
145 const char* avahi_client_get_host_name (AvahiClient*);
146
147 /** Get domain name */
148 const char* avahi_client_get_domain_name (AvahiClient*);
149
150 /** Get FQDN domain name */
151 const char* avahi_client_get_host_name_fqdn (AvahiClient*);
152
153 /** Get state */
154 AvahiClientState avahi_client_get_state(AvahiClient *client); 
155
156 /** Get the last error number */
157 int avahi_client_errno (AvahiClient*);
158
159 /** Create a new AvahiEntryGroup object */
160 AvahiEntryGroup* avahi_entry_group_new (AvahiClient*, AvahiEntryGroupCallback callback, void *userdata);
161
162 /** Clean up and free an AvahiEntryGroup object */
163 int avahi_entry_group_free (AvahiEntryGroup *);
164
165 /** Commit an AvahiEntryGroup */
166 int avahi_entry_group_commit (AvahiEntryGroup*);
167
168 /** Reset an AvahiEntryGroup */
169 int avahi_entry_group_reset (AvahiEntryGroup*);
170
171 /** Get an AvahiEntryGroup's state */
172 int avahi_entry_group_get_state (AvahiEntryGroup*);
173
174 /** Check if an AvahiEntryGroup is empty */
175 int avahi_entry_group_is_empty (AvahiEntryGroup*);
176
177 /** Get an AvahiEntryGroup's owning client instance */
178 AvahiClient* avahi_entry_group_get_client (AvahiEntryGroup*);
179
180 /** Add a service, takes a variable NULL terminated list of text records */
181 int avahi_entry_group_add_service(
182     AvahiEntryGroup *group,
183     AvahiIfIndex interface,
184     AvahiProtocol protocol,
185     const char *name,
186     const char *type,
187     const char *domain,
188     const char *host,
189     uint16_t port,
190     ...) AVAHI_GCC_SENTINEL;
191
192 /** Add a service, takes an AvahiStringList for text records */
193 int avahi_entry_group_add_service_strlst(
194     AvahiEntryGroup *group,
195     AvahiIfIndex interface,
196     AvahiProtocol protocol,
197     const char *name,
198     const char *type,
199     const char *domain,
200     const char *host,
201     uint16_t port,
202     AvahiStringList *txt);
203
204 /** Add a service, takes a NULL terminated va_list for text records */
205 int avahi_entry_group_add_service_va(
206     AvahiEntryGroup *group,
207     AvahiIfIndex interface,
208     AvahiProtocol protocol,
209     const char *name,
210     const char *type,
211     const char *domain,
212     const char *host,
213     uint16_t port,
214     va_list va);
215
216 /** Get the D-Bus path of an AvahiEntryGroup object, for debugging purposes only. */
217 const char* avahi_entry_group_get_dbus_path (AvahiEntryGroup *);
218
219 /** Browse for domains on the local network */
220 AvahiDomainBrowser* avahi_domain_browser_new (AvahiClient *client,
221                                               AvahiIfIndex interface,
222                                               AvahiProtocol protocol,
223                                               const char *domain,
224                                               AvahiDomainBrowserType btype,
225                                               AvahiDomainBrowserCallback callback,
226                                               void *userdata);
227
228 /** Get the parent client of an AvahiDomainBrowser object */
229 AvahiClient* avahi_domain_browser_get_client (AvahiDomainBrowser *);
230
231 /** Get the D-Bus path of an AvahiDomainBrowser object, for debugging purposes only. */
232 const char* avahi_domain_browser_get_dbus_path (AvahiDomainBrowser *);
233
234 /** Cleans up and frees an AvahiDomainBrowser object */
235 int avahi_domain_browser_free (AvahiDomainBrowser *);
236
237 /** Browse for service types on the local network */
238 AvahiServiceTypeBrowser* avahi_service_type_browser_new (
239                 AvahiClient *client,
240                 AvahiIfIndex interface,
241                 AvahiProtocol protocol,
242                 const char *domain,
243                 AvahiServiceTypeBrowserCallback callback,
244                 void *userdata);
245
246 /** Get the parent client of an AvahiServiceTypeBrowser object */
247 AvahiClient* avahi_service_type_browser_get_client (AvahiServiceTypeBrowser *);
248
249 /** Get the D-Bus path of an AvahiServiceTypeBrowser object, for debugging purposes only. */
250 const char* avahi_service_type_browser_get_dbus_path(AvahiServiceTypeBrowser *);
251
252 /** Cleans up and frees an AvahiServiceTypeBrowser object */
253 int avahi_service_type_browser_free (AvahiServiceTypeBrowser *);
254
255 /** Browse for services of a type on the local network */
256 AvahiServiceBrowser* avahi_service_browser_new (
257                 AvahiClient *client,
258                 AvahiIfIndex interface,
259                 AvahiProtocol protocol,
260                 const char *type,
261                 const char *domain,
262                 AvahiServiceBrowserCallback callback,
263                 void *userdata);
264
265 /** Get the D-Bus path of an AvahiServiceBrowser object, for debugging purposes only. */
266 const char* avahi_service_browser_get_dbus_path (AvahiServiceBrowser *);
267
268 /** Get the parent client of an AvahiServiceBrowser object */
269 AvahiClient* avahi_service_browser_get_client (AvahiServiceBrowser *);
270
271 /* Cleans up and frees an AvahiServiceBrowser object */
272 int avahi_service_browser_free (AvahiServiceBrowser *);
273
274 /** Create a new service resolver object */
275 AvahiServiceResolver * avahi_service_resolver_new(
276     AvahiClient *client,
277     AvahiIfIndex interface,
278     AvahiProtocol protocol,
279     const char *name,
280     const char *type,
281     const char *domain,
282     AvahiProtocol aprotocol,
283     AvahiServiceResolverCallback callback,
284     void *userdata);
285
286 /** Get the parent client of an AvahiServiceResolver object */
287 AvahiClient* avahi_service_resolver_get_client (AvahiServiceResolver *);
288
289 /** Free a service resolver object */
290 int avahi_service_resolver_free(AvahiServiceResolver *r);
291
292 /** Block until the resolving is complete */
293 int avahi_service_resolver_block(AvahiServiceResolver *r);
294
295 /** Create a new hostname resolver object */
296 AvahiHostNameResolver * avahi_host_name_resolver_new(
297     AvahiClient *client,
298     AvahiIfIndex interface,
299     AvahiProtocol protocol,
300     const char *name,
301     AvahiProtocol aprotocol,
302     AvahiHostNameResolverCallback callback,
303     void *userdata);
304
305 /** Get the parent client of an AvahiHostNameResolver object */
306 AvahiClient* avahi_host_name_resolver_get_client (AvahiHostNameResolver *);
307
308 /** Free a hostname resolver object */
309 int avahi_host_name_resolver_free(AvahiHostNameResolver *r);
310
311 /** Block until the resolving is complete */
312 int avahi_host_name_resolver_block(AvahiHostNameResolver *r);
313
314 /** Create a new address resolver object from an address string.  Set aprotocol to AF_UNSPEC for protocol detection. */
315 AvahiAddressResolver * avahi_address_resolver_new(
316     AvahiClient *client,
317     AvahiIfIndex interface,
318     AvahiProtocol protocol,
319     const char *address,
320     AvahiAddressResolverCallback callback,
321     void *userdata);
322
323 /** Create a new address resolver object from an AvahiAddress object */
324 AvahiAddressResolver* avahi_address_resolver_new_a(
325     AvahiClient *client,
326     AvahiIfIndex interface,
327     AvahiProtocol protocol,
328     const AvahiAddress *a,
329     AvahiAddressResolverCallback callback,
330     void *userdata);
331
332 /** Get the parent client of an AvahiAddressResolver object */
333 AvahiClient* avahi_address_resolver_get_client (AvahiAddressResolver *);
334
335 /** Free a AvahiAddressResolver resolver object */
336 int avahi_address_resolver_free(AvahiAddressResolver *r);
337
338 /** Block until the resolving is complete */
339 int avahi_address_resolver_block(AvahiAddressResolver *r);
340
341 #ifndef DOXYGEN_SHOULD_SKIP_THIS
342 AVAHI_C_DECL_END
343 #endif
344
345 #endif