7 This file is part of avahi.
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.
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.
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
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>
34 /** \file client.h Definitions and functions for the client API over D-Bus */
36 #ifndef DOXYGEN_SHOULD_SKIP_THIS
40 /** A connection context */
41 typedef struct AvahiClient AvahiClient;
43 /** An entry group object */
44 typedef struct AvahiEntryGroup AvahiEntryGroup;
46 /** A domain browser object */
47 typedef struct AvahiDomainBrowser AvahiDomainBrowser;
49 /** A service browser object */
50 typedef struct AvahiServiceBrowser AvahiServiceBrowser;
52 /** A service type browser object */
53 typedef struct AvahiServiceTypeBrowser AvahiServiceTypeBrowser;
55 /** A service resolver object */
56 typedef struct AvahiServiceResolver AvahiServiceResolver;
58 /** States of a client object, note that AvahiServerStates are also emitted */
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 */
67 /** The function prototype for the callback of an AvahiClient */
68 typedef void (*AvahiClientCallback) (AvahiClient *s, AvahiClientState state, void* userdata);
70 /** The function prototype for the callback of an AvahiEntryGroup */
71 typedef void (*AvahiEntryGroupCallback) (AvahiEntryGroup *g, AvahiEntryGroupState state, void* userdata);
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);
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);
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);
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,
91 const char *host_name,
92 const AvahiAddress *a,
97 /** Creates a new client instance */
98 AvahiClient* avahi_client_new (const AvahiPoll *poll_api, AvahiClientCallback callback, void *userdata, int *error);
100 /** Free a client instance */
101 void avahi_client_free(AvahiClient *client);
103 /** Get the version of the server */
104 const char* avahi_client_get_version_string (AvahiClient*);
107 const char* avahi_client_get_host_name (AvahiClient*);
109 /** Get domain name */
110 const char* avahi_client_get_domain_name (AvahiClient*);
112 /** Get FQDN domain name */
113 const char* avahi_client_get_host_name_fqdn (AvahiClient*);
116 AvahiClientState avahi_client_get_state(AvahiClient *client);
118 /** Get the last error number */
119 int avahi_client_errno (AvahiClient*);
121 /** Create a new AvahiEntryGroup object */
122 AvahiEntryGroup* avahi_entry_group_new (AvahiClient*, AvahiEntryGroupCallback callback, void *userdata);
124 /** Clean up and free an AvahiEntryGroup object */
125 int avahi_entry_group_free (AvahiEntryGroup *);
127 /** Commit an AvahiEntryGroup */
128 int avahi_entry_group_commit (AvahiEntryGroup*);
130 /** Reset an AvahiEntryGroup */
131 int avahi_entry_group_reset (AvahiEntryGroup*);
133 /** Get an AvahiEntryGroup's state */
134 int avahi_entry_group_get_state (AvahiEntryGroup*);
136 /** Check if an AvahiEntryGroup is empty */
137 int avahi_entry_group_is_empty (AvahiEntryGroup*);
139 /** Get an AvahiEntryGroup's owning client instance */
140 AvahiClient* avahi_entry_group_get_client (AvahiEntryGroup*);
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,
152 ...) AVAHI_GCC_SENTINEL;
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,
164 AvahiStringList *txt);
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,
178 /** Get the D-Bus path of an AvahiEntryGroup object, for debugging purposes only. */
179 const char* avahi_entry_group_get_dbus_path (AvahiEntryGroup *);
181 /** Browse for domains on the local network */
182 AvahiDomainBrowser* avahi_domain_browser_new (AvahiClient *client,
183 AvahiIfIndex interface,
184 AvahiProtocol protocol,
186 AvahiDomainBrowserType btype,
187 AvahiDomainBrowserCallback callback,
190 /** Get the D-Bus path of an AvahiDomainBrowser object, for debugging purposes only. */
191 const char* avahi_domain_browser_get_dbus_path (AvahiDomainBrowser *);
193 /** Cleans up and frees an AvahiDomainBrowser object */
194 int avahi_domain_browser_free (AvahiDomainBrowser *);
196 /** Browse for service types on the local network */
197 AvahiServiceTypeBrowser* avahi_service_type_browser_new (
199 AvahiIfIndex interface,
200 AvahiProtocol protocol,
202 AvahiServiceTypeBrowserCallback callback,
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 *);
208 /** Cleans up and frees an AvahiServiceTypeBrowser object */
209 int avahi_service_type_browser_free (AvahiServiceTypeBrowser *);
211 /** Browse for services of a type on the local network */
212 AvahiServiceBrowser* avahi_service_browser_new (
214 AvahiIfIndex interface,
215 AvahiProtocol protocol,
218 AvahiServiceBrowserCallback callback,
221 /** Get the D-Bus path of an AvahiServiceBrowser object, for debugging purposes only. */
222 const char* avahi_service_browser_get_dbus_path (AvahiServiceBrowser *);
224 /* Cleans up and frees an AvahiServiceBrowser object */
225 int avahi_service_browser_free (AvahiServiceBrowser *);
227 /** Create a new service resolver object */
228 AvahiServiceResolver * avahi_service_resolver_new(
230 AvahiIfIndex interface,
231 AvahiProtocol protocol,
235 AvahiProtocol aprotocol,
236 AvahiServiceResolverCallback callback,
239 /** Free a service resolver object */
240 int avahi_service_resolver_free(AvahiServiceResolver *r);
242 /** Block until the resolving is complete */
243 int avahi_service_resolver_block(AvahiServiceResolver *r);
245 #ifndef DOXYGEN_SHOULD_SKIP_THIS