]> git.meshlink.io Git - catta/blob - avahi-client/client.h
056adfbe7fe00274f1bdedc702bbbb7bf39b9912
[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 typedef struct AvahiClient AvahiClient;
41 typedef struct AvahiEntryGroup AvahiEntryGroup;
42 typedef struct AvahiDomainBrowser AvahiDomainBrowser;
43 typedef struct AvahiServiceBrowser AvahiServiceBrowser;
44 typedef struct AvahiServiceTypeBrowser AvahiServiceTypeBrowser;
45
46 /** States of a client object, note that AvahiServerStates are also emitted */
47 typedef enum {
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 */
53 } AvahiClientState;
54
55 /** The function prototype for the callback of an AvahiClient */
56 typedef void (*AvahiClientCallback) (AvahiClient *s, AvahiClientState state, void* userdata);
57
58 /** The function prototype for the callback of an AvahiEntryGroup */
59 typedef void (*AvahiEntryGroupCallback) (AvahiEntryGroup *g, AvahiEntryGroupState state, void* userdata);
60
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);
63
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);
66
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);
69
70 /** Creates a new client instance */
71 AvahiClient* avahi_client_new (const AvahiPoll *poll_api, AvahiClientCallback callback, void *userdata, int *error);
72
73 /** Free a client instance */
74 void avahi_client_free(AvahiClient *client);
75
76 /** Get the version of the server */
77 const char* avahi_client_get_version_string (AvahiClient*);
78
79 /** Get host name */
80 const char* avahi_client_get_host_name (AvahiClient*);
81
82 /** Get domain name */
83 const char* avahi_client_get_domain_name (AvahiClient*);
84
85 /** Get FQDN domain name */
86 const char* avahi_client_get_host_name_fqdn (AvahiClient*);
87
88 /** Get state */
89 AvahiClientState avahi_client_get_state(AvahiClient *client); 
90
91 /** Get the last error number */
92 int avahi_client_errno (AvahiClient*);
93
94 /** Create a new AvahiEntryGroup object */
95 AvahiEntryGroup* avahi_entry_group_new (AvahiClient*, AvahiEntryGroupCallback callback, void *userdata);
96
97 /** Clean up and free an AvahiEntryGroup object */
98 int avahi_entry_group_free (AvahiEntryGroup *);
99
100 /** Commit an AvahiEntryGroup */
101 int avahi_entry_group_commit (AvahiEntryGroup*);
102
103 /** Reset an AvahiEntryGroup */
104 int avahi_entry_group_reset (AvahiEntryGroup*);
105
106 /** Get an AvahiEntryGroup's state */
107 int avahi_entry_group_get_state (AvahiEntryGroup*);
108
109 /** Check if an AvahiEntryGroup is empty */
110 int avahi_entry_group_is_empty (AvahiEntryGroup*);
111
112 /** Get an AvahiEntryGroup's owning client instance */
113 AvahiClient* avahi_entry_group_get_client (AvahiEntryGroup*);
114
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,
120     const char *name,
121     const char *type,
122     const char *domain,
123     const char *host,
124     uint16_t port,
125     ...) AVAHI_GCC_SENTINEL;
126
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,
132     const char *name,
133     const char *type,
134     const char *domain,
135     const char *host,
136     uint16_t port,
137     AvahiStringList *txt);
138
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,
144     const char *name,
145     const char *type,
146     const char *domain,
147     const char *host,
148     uint16_t port,
149     va_list va);
150
151 /** Get the D-Bus path of an AvahiEntryGroup object, for debugging purposes only. */
152 const char* avahi_entry_group_get_dbus_path (AvahiEntryGroup *);
153
154 /** Browse for domains on the local network */
155 AvahiDomainBrowser* avahi_domain_browser_new (AvahiClient *client,
156                                               AvahiIfIndex interface,
157                                               AvahiProtocol protocol,
158                                               const char *domain,
159                                               AvahiDomainBrowserType btype,
160                                               AvahiDomainBrowserCallback callback,
161                                               void *userdata);
162
163 /** Get the D-Bus path of an AvahiDomainBrowser object, for debugging purposes only. */
164 const char* avahi_domain_browser_get_dbus_path (AvahiDomainBrowser *);
165
166 /** Cleans up and frees an AvahiDomainBrowser object */
167 int avahi_domain_browser_free (AvahiDomainBrowser *);
168
169 /** Browse for service types on the local network */
170 AvahiServiceTypeBrowser* avahi_service_type_browser_new (
171                 AvahiClient *client,
172                 AvahiIfIndex interface,
173                 AvahiProtocol protocol,
174                 const char *domain,
175                 AvahiServiceTypeBrowserCallback callback,
176                 void *userdata);
177
178 /** Get the D-Bus path of an AvahiServiceTypeBrowser object, for debugging purposes only. */
179 const char* avahi_service_type_browser_get_dbus_path(AvahiServiceTypeBrowser *);
180
181 /** Cleans up and frees an AvahiServiceTypeBrowser object */
182 int avahi_service_type_browser_free (AvahiServiceTypeBrowser *);
183
184 /** Browse for services of a type on the local network */
185 AvahiServiceBrowser* avahi_service_browser_new (
186                 AvahiClient *client,
187                 AvahiIfIndex interface,
188                 AvahiProtocol protocol,
189                 const char *type,
190                 const char *domain,
191                 AvahiServiceBrowserCallback callback,
192                 void *userdata);
193
194 /** Get the D-Bus path of an AvahiServiceBrowser object, for debugging purposes only. */
195 const char* avahi_service_browser_get_dbus_path (AvahiServiceBrowser *);
196
197 /* Cleans up and frees an AvahiServiceBrowser object */
198 int avahi_service_browser_free (AvahiServiceBrowser *);
199
200 #ifndef DOXYGEN_SHOULD_SKIP_THIS
201 AVAHI_C_DECL_END
202 #endif
203
204 #endif