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