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