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 typedef struct AvahiClient AvahiClient;
41 typedef struct AvahiEntryGroup AvahiEntryGroup;
42 typedef struct AvahiDomainBrowser AvahiDomainBrowser;
43 typedef struct AvahiServiceBrowser AvahiServiceBrowser;
44 typedef struct AvahiServiceTypeBrowser AvahiServiceTypeBrowser;
46 /** States of a client object, note that AvahiServerStates are also emitted */
48 AVAHI_CLIENT_S_INVALID = AVAHI_SERVER_INVALID,
49 AVAHI_CLIENT_S_REGISTERING = AVAHI_SERVER_REGISTERING,
50 AVAHI_CLIENT_S_RUNNING = AVAHI_SERVER_RUNNING,
51 AVAHI_CLIENT_S_COLLISION = AVAHI_SERVER_COLLISION,
52 AVAHI_CLIENT_DISCONNECTED = 100 /**< Lost DBUS connection to the Avahi daemon */
55 /** The function prototype for the callback of an AvahiClient */
56 typedef void (*AvahiClientCallback) (AvahiClient *s, AvahiClientState state, void* userdata);
58 /** The function prototype for the callback of an AvahiEntryGroup */
59 typedef void (*AvahiEntryGroupCallback) (AvahiEntryGroup *g, AvahiEntryGroupState state, void* userdata);
61 /** The function prototype for the callback of an AvahiDomainBrowser */
62 typedef void (*AvahiDomainBrowserCallback) (AvahiDomainBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *domain, void *userdata);
64 /** The function prototype for the callback of an AvahiServiceBrowser */
65 typedef void (*AvahiServiceBrowserCallback) (AvahiServiceBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *name, const char *type, const char *domain, void *userdata);
67 /** The function prototype for the callback of an AvahiServiceTypeBrowser */
68 typedef void (*AvahiServiceTypeBrowserCallback) (AvahiServiceTypeBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *type, const char *domain, void *userdata);
70 /** Creates a new client instance */
71 AvahiClient* avahi_client_new (const AvahiPoll *poll_api, AvahiClientCallback callback, void *userdata, int *error);
73 /** Free a client instance */
74 void avahi_client_free(AvahiClient *client);
76 /** Get the version of the server */
77 const char* avahi_client_get_version_string (AvahiClient*);
80 const char* avahi_client_get_host_name (AvahiClient*);
82 /** Get domain name */
83 const char* avahi_client_get_domain_name (AvahiClient*);
85 /** Get FQDN domain name */
86 const char* avahi_client_get_host_name_fqdn (AvahiClient*);
89 AvahiClientState avahi_client_get_state(AvahiClient *client);
91 /** Get the last error number */
92 int avahi_client_errno (AvahiClient*);
94 /** Create a new AvahiEntryGroup object */
95 AvahiEntryGroup* avahi_entry_group_new (AvahiClient*, AvahiEntryGroupCallback callback, void *userdata);
97 /** Clean up and free an AvahiEntryGroup object */
98 int avahi_entry_group_free (AvahiEntryGroup *);
100 /** Commit an AvahiEntryGroup */
101 int avahi_entry_group_commit (AvahiEntryGroup*);
103 /** Reset an AvahiEntryGroup */
104 int avahi_entry_group_reset (AvahiEntryGroup*);
106 /** Get an AvahiEntryGroup's state */
107 int avahi_entry_group_get_state (AvahiEntryGroup*);
109 /** Check if an AvahiEntryGroup is empty */
110 int avahi_entry_group_is_empty (AvahiEntryGroup*);
112 /** Get an AvahiEntryGroup's owning client instance */
113 AvahiClient* avahi_entry_group_get_client (AvahiEntryGroup*);
115 /** Add a service, takes a variable NULL terminated list of text records */
116 int avahi_entry_group_add_service(
117 AvahiEntryGroup *group,
118 AvahiIfIndex interface,
119 AvahiProtocol protocol,
125 ...) AVAHI_GCC_SENTINEL;
127 /** Add a service, takes an AvahiStringList for text records */
128 int avahi_entry_group_add_service_strlst(
129 AvahiEntryGroup *group,
130 AvahiIfIndex interface,
131 AvahiProtocol protocol,
137 AvahiStringList *txt);
139 /** Add a service, takes a NULL terminated va_list for text records */
140 int avahi_entry_group_add_service_va(
141 AvahiEntryGroup *group,
142 AvahiIfIndex interface,
143 AvahiProtocol protocol,
151 /** Get the D-Bus path of an AvahiEntryGroup object, for debugging purposes only. */
152 const char* avahi_entry_group_get_dbus_path (AvahiEntryGroup *);
154 /** Browse for domains on the local network */
155 AvahiDomainBrowser* avahi_domain_browser_new (AvahiClient *client,
156 AvahiIfIndex interface,
157 AvahiProtocol protocol,
159 AvahiDomainBrowserType btype,
160 AvahiDomainBrowserCallback callback,
163 /** Get the D-Bus path of an AvahiDomainBrowser object, for debugging purposes only. */
164 const char* avahi_domain_browser_path (AvahiDomainBrowser *);
166 /** Cleans up and frees an AvahiDomainBrowser object */
167 int avahi_domain_browser_free (AvahiDomainBrowser *);
169 /** Browse for service types on the local network */
170 AvahiServiceTypeBrowser* avahi_service_type_browser_new (
172 AvahiIfIndex interface,
173 AvahiProtocol protocol,
175 AvahiServiceTypeBrowserCallback callback,
178 /** Get the D-Bus path of an AvahiServiceTypeBrowser object, for debugging purposes only. */
179 const char* avahi_service_type_browser_path (AvahiServiceTypeBrowser *);
181 /** Cleans up and frees an AvahiServiceTypeBrowser object */
182 int avahi_service_type_browser_free (AvahiServiceTypeBrowser *);
184 /** Browse for services of a type on the local network */
185 AvahiServiceBrowser* avahi_service_browser_new (
187 AvahiIfIndex interface,
188 AvahiProtocol protocol,
191 AvahiServiceBrowserCallback callback,
194 /** Get the D-Bus path of an AvahiServiceBrowser object, for debugging purposes only. */
195 const char* avahi_service_browser_path (AvahiServiceBrowser *);
197 /* Cleans up and frees an AvahiServiceBrowser object */
198 int avahi_service_browser_free (AvahiServiceBrowser *);
200 #ifndef DOXYGEN_SHOULD_SKIP_THIS