]> git.meshlink.io Git - catta/blob - avahi-client/client.h
56672e3820074a0b0e07df1b47864c6991060c3c
[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
44 #ifndef DOXYGEN_SHOULD_SKIP_THIS
45 AVAHI_C_DECL_BEGIN
46 #endif
47
48 /** A connection context */
49 typedef struct AvahiClient AvahiClient;
50
51 /** An entry group object */
52 typedef struct AvahiEntryGroup AvahiEntryGroup;
53
54 /** A domain browser object */
55 typedef struct AvahiDomainBrowser AvahiDomainBrowser;
56
57 /** A service browser object */
58 typedef struct AvahiServiceBrowser AvahiServiceBrowser;
59
60 /** A service type browser object */
61 typedef struct AvahiServiceTypeBrowser AvahiServiceTypeBrowser;
62
63 /** A service resolver object */
64 typedef struct AvahiServiceResolver AvahiServiceResolver;
65
66 /** States of a client object, a superset of AvahiServerState */
67 typedef enum {
68     AVAHI_CLIENT_S_INVALID = AVAHI_SERVER_INVALID,
69     AVAHI_CLIENT_S_REGISTERING = AVAHI_SERVER_REGISTERING,
70     AVAHI_CLIENT_S_RUNNING = AVAHI_SERVER_RUNNING,
71     AVAHI_CLIENT_S_COLLISION = AVAHI_SERVER_COLLISION,
72     AVAHI_CLIENT_DISCONNECTED = 100 /**< Lost DBUS connection to the Avahi daemon */
73 } AvahiClientState;
74
75 /** The function prototype for the callback of an AvahiClient */
76 typedef void (*AvahiClientCallback) (AvahiClient *s, AvahiClientState state, void* userdata);
77
78 /** The function prototype for the callback of an AvahiEntryGroup */
79 typedef void (*AvahiEntryGroupCallback) (AvahiEntryGroup *g, AvahiEntryGroupState state, void* userdata);
80
81 /** The function prototype for the callback of an AvahiDomainBrowser */
82 typedef void (*AvahiDomainBrowserCallback) (AvahiDomainBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *domain, void *userdata);
83
84 /** The function prototype for the callback of an AvahiServiceBrowser */
85 typedef void (*AvahiServiceBrowserCallback) (AvahiServiceBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *name, const char *type, const char *domain, void *userdata);
86
87 /** The function prototype for the callback of an AvahiServiceTypeBrowser */
88 typedef void (*AvahiServiceTypeBrowserCallback) (AvahiServiceTypeBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *type, const char *domain, void *userdata);
89
90 /** The function prototype for the callback of an AvahiServiceResolver */
91 typedef void (*AvahiServiceResolverCallback) (
92     AvahiServiceResolver *r,
93     AvahiIfIndex interface,
94     AvahiProtocol protocol,
95     AvahiResolverEvent event,
96     const char *name,
97     const char *type,
98     const char *domain,
99     const char *host_name,
100     const AvahiAddress *a,
101     uint16_t port,
102     AvahiStringList *txt,
103     void *userdata);
104
105 /** Creates a new client instance */
106 AvahiClient* avahi_client_new (const AvahiPoll *poll_api, AvahiClientCallback callback, void *userdata, int *error);
107
108 /** Free a client instance */
109 void avahi_client_free(AvahiClient *client);
110
111 /** Get the version of the server */
112 const char* avahi_client_get_version_string (AvahiClient*);
113
114 /** Get host name */
115 const char* avahi_client_get_host_name (AvahiClient*);
116
117 /** Get domain name */
118 const char* avahi_client_get_domain_name (AvahiClient*);
119
120 /** Get FQDN domain name */
121 const char* avahi_client_get_host_name_fqdn (AvahiClient*);
122
123 /** Get state */
124 AvahiClientState avahi_client_get_state(AvahiClient *client); 
125
126 /** Get the last error number */
127 int avahi_client_errno (AvahiClient*);
128
129 /** Create a new AvahiEntryGroup object */
130 AvahiEntryGroup* avahi_entry_group_new (AvahiClient*, AvahiEntryGroupCallback callback, void *userdata);
131
132 /** Clean up and free an AvahiEntryGroup object */
133 int avahi_entry_group_free (AvahiEntryGroup *);
134
135 /** Commit an AvahiEntryGroup */
136 int avahi_entry_group_commit (AvahiEntryGroup*);
137
138 /** Reset an AvahiEntryGroup */
139 int avahi_entry_group_reset (AvahiEntryGroup*);
140
141 /** Get an AvahiEntryGroup's state */
142 int avahi_entry_group_get_state (AvahiEntryGroup*);
143
144 /** Check if an AvahiEntryGroup is empty */
145 int avahi_entry_group_is_empty (AvahiEntryGroup*);
146
147 /** Get an AvahiEntryGroup's owning client instance */
148 AvahiClient* avahi_entry_group_get_client (AvahiEntryGroup*);
149
150 /** Add a service, takes a variable NULL terminated list of text records */
151 int avahi_entry_group_add_service(
152     AvahiEntryGroup *group,
153     AvahiIfIndex interface,
154     AvahiProtocol protocol,
155     const char *name,
156     const char *type,
157     const char *domain,
158     const char *host,
159     uint16_t port,
160     ...) AVAHI_GCC_SENTINEL;
161
162 /** Add a service, takes an AvahiStringList for text records */
163 int avahi_entry_group_add_service_strlst(
164     AvahiEntryGroup *group,
165     AvahiIfIndex interface,
166     AvahiProtocol protocol,
167     const char *name,
168     const char *type,
169     const char *domain,
170     const char *host,
171     uint16_t port,
172     AvahiStringList *txt);
173
174 /** Add a service, takes a NULL terminated va_list for text records */
175 int avahi_entry_group_add_service_va(
176     AvahiEntryGroup *group,
177     AvahiIfIndex interface,
178     AvahiProtocol protocol,
179     const char *name,
180     const char *type,
181     const char *domain,
182     const char *host,
183     uint16_t port,
184     va_list va);
185
186 /** Get the D-Bus path of an AvahiEntryGroup object, for debugging purposes only. */
187 const char* avahi_entry_group_get_dbus_path (AvahiEntryGroup *);
188
189 /** Browse for domains on the local network */
190 AvahiDomainBrowser* avahi_domain_browser_new (AvahiClient *client,
191                                               AvahiIfIndex interface,
192                                               AvahiProtocol protocol,
193                                               const char *domain,
194                                               AvahiDomainBrowserType btype,
195                                               AvahiDomainBrowserCallback callback,
196                                               void *userdata);
197
198 /** Get the D-Bus path of an AvahiDomainBrowser object, for debugging purposes only. */
199 const char* avahi_domain_browser_get_dbus_path (AvahiDomainBrowser *);
200
201 /** Cleans up and frees an AvahiDomainBrowser object */
202 int avahi_domain_browser_free (AvahiDomainBrowser *);
203
204 /** Browse for service types on the local network */
205 AvahiServiceTypeBrowser* avahi_service_type_browser_new (
206                 AvahiClient *client,
207                 AvahiIfIndex interface,
208                 AvahiProtocol protocol,
209                 const char *domain,
210                 AvahiServiceTypeBrowserCallback callback,
211                 void *userdata);
212
213 /** Get the D-Bus path of an AvahiServiceTypeBrowser object, for debugging purposes only. */
214 const char* avahi_service_type_browser_get_dbus_path(AvahiServiceTypeBrowser *);
215
216 /** Cleans up and frees an AvahiServiceTypeBrowser object */
217 int avahi_service_type_browser_free (AvahiServiceTypeBrowser *);
218
219 /** Browse for services of a type on the local network */
220 AvahiServiceBrowser* avahi_service_browser_new (
221                 AvahiClient *client,
222                 AvahiIfIndex interface,
223                 AvahiProtocol protocol,
224                 const char *type,
225                 const char *domain,
226                 AvahiServiceBrowserCallback callback,
227                 void *userdata);
228
229 /** Get the D-Bus path of an AvahiServiceBrowser object, for debugging purposes only. */
230 const char* avahi_service_browser_get_dbus_path (AvahiServiceBrowser *);
231
232 /* Cleans up and frees an AvahiServiceBrowser object */
233 int avahi_service_browser_free (AvahiServiceBrowser *);
234
235 /** Create a new service resolver object */
236 AvahiServiceResolver * avahi_service_resolver_new(
237     AvahiClient *client,
238     AvahiIfIndex interface,
239     AvahiProtocol protocol,
240     const char *name,
241     const char *type,
242     const char *domain,
243     AvahiProtocol aprotocol,
244     AvahiServiceResolverCallback callback,
245     void *userdata);
246
247 /** Free a service resolver object */
248 int avahi_service_resolver_free(AvahiServiceResolver *r);
249
250 /** Block until the resolving is complete */
251 int avahi_service_resolver_block(AvahiServiceResolver *r);
252
253 #ifndef DOXYGEN_SHOULD_SKIP_THIS
254 AVAHI_C_DECL_END
255 #endif
256
257 #endif