]> git.meshlink.io Git - catta/blob - avahi-client/client.h
824f1e905cf32b1e7d11107e5cc06089b202a1b7
[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
32 /** \file client.h Definitions and functions for the client API over D-Bus */
33
34 #ifndef DOXYGEN_SHOULD_SKIP_THIS
35 AVAHI_C_DECL_BEGIN
36 #endif
37
38 typedef struct _AvahiClient AvahiClient;
39
40 typedef struct _AvahiEntryGroup AvahiEntryGroup;
41
42 typedef struct _AvahiDomainBrowser AvahiDomainBrowser;
43
44 typedef struct _AvahiServiceBrowser AvahiServiceBrowser;
45
46 typedef struct _AvahiServiceTypeBrowser AvahiServiceTypeBrowser;
47
48 /** States of a client object, note that AvahiServerStates are also emitted */
49 typedef enum {
50     AVAHI_CLIENT_DISCONNECTED = 100, /**< Lost DBUS connection to the Avahi daemon */
51     AVAHI_CLIENT_RECONNECTED  = 101  /**< Regained connection to the daemon, all records need to be re-added */
52 } AvahiClientState;
53
54 /** The function prototype for the callback of an AvahiClient */
55 typedef void (*AvahiClientCallback) (AvahiClient *s, AvahiClientState state, void* userdata);
56
57 /** The function prototype for the callback of an AvahiEntryGroup */
58 typedef void (*AvahiEntryGroupCallback) (AvahiEntryGroup *g, AvahiEntryGroupState state, void* userdata);
59
60 /** The function prototype for the callback of an AvahiDomainBrowser */
61 typedef void (*AvahiDomainBrowserCallback) (AvahiDomainBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, char *domain, void *user_data);
62
63 /** The function prototype for the callback of an AvahiServiceBrowser */
64 typedef void (*AvahiServiceBrowserCallback) (AvahiServiceBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, char *name, char *type, char *domain, void *user_data);
65
66 /** The function prototype for the callback of an AvahiServiceTypeBrowser */
67 typedef void (*AvahiServiceTypeBrowserCallback) (AvahiServiceTypeBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, char *type, char *domain, void *user_data);
68
69 /** Creates a new client instance */
70 AvahiClient* avahi_client_new (AvahiClientCallback callback, void *user_data);
71
72 /** Get the version of the server */
73 char* avahi_client_get_version_string (AvahiClient*);
74
75 /** Get host name */
76 char* avahi_client_get_host_name (AvahiClient*);
77
78 /** Get domain name */
79 char* avahi_client_get_domain_name (AvahiClient*);
80
81 /** Get FQDN domain name */
82 char* avahi_client_get_host_name_fqdn (AvahiClient*);
83
84 /** Create a new AvahiEntryGroup object */
85 AvahiEntryGroup* avahi_entry_group_new (AvahiClient*, AvahiEntryGroupCallback callback, void *user_data);
86
87 /** Commit an AvahiEntryGroup */
88 int avahi_entry_group_commit (AvahiEntryGroup*);
89
90 /** Reset an AvahiEntryGroup */
91 int avahi_entry_group_reset (AvahiEntryGroup*);
92
93 /** Get an AvahiEntryGroup's state */
94 int avahi_entry_group_get_state (AvahiEntryGroup*);
95
96 /** Check if an AvahiEntryGroup is empty */
97 int avahi_entry_group_is_empty (AvahiEntryGroup*);
98
99 /** Get the last error number */
100 int avahi_client_errno (AvahiClient*);
101
102 /** Get an AvahiEntryGroup's owning client instance */
103 AvahiClient* avahi_entry_group_get_client (AvahiEntryGroup*);
104
105 /** Add a service, takes an AvahiStringList for text records */
106 int
107 avahi_entry_group_add_service (AvahiEntryGroup *group,
108                                AvahiIfIndex interface,
109                                AvahiProtocol protocol,
110                                const char *name,
111                                const char *type,
112                                const char *domain,
113                                const char *host,
114                                uint16_t port,
115                                AvahiStringList *txt);
116
117 /** Get the D-Bus path of an AvahiEntryGroup object, for debugging purposes only. */
118 char* avahi_entry_group_path (AvahiEntryGroup *);
119
120 /** Browse for domains on the local network */
121 AvahiDomainBrowser* avahi_domain_browser_new (AvahiClient *client,
122                                               AvahiIfIndex interface,
123                                               AvahiProtocol protocol,
124                                               char *domain,
125                                               AvahiDomainBrowserType btype,
126                                               AvahiDomainBrowserCallback callback,
127                                               void *user_data);
128
129 /** Get the D-Bus path of an AvahiDomainBrowser object, for debugging purposes only. */
130 char* avahi_domain_browser_path (AvahiDomainBrowser *);
131
132 /** Cleans up and frees an AvahiDomainBrowser object */
133 void avahi_domain_browser_free (AvahiDomainBrowser *);
134
135 /** Browse for service types on the local network */
136 AvahiServiceTypeBrowser* avahi_service_type_browser_new (
137                 AvahiClient *client,
138                 AvahiIfIndex interface,
139                 AvahiProtocol protocol,
140                 char *domain,
141                 AvahiServiceTypeBrowserCallback callback,
142                 void *user_data);
143
144 /** Get the D-Bus path of an AvahiServiceTypeBrowser object, for debugging purposes only. */
145 char* avahi_service_type_browser_path (AvahiServiceTypeBrowser *);
146
147 /** Cleans up and frees an AvahiServiceTypeBrowser object */
148 void avahi_service_type_browser_free (AvahiServiceTypeBrowser *);
149
150 /** Browse for services of a type on the local network */
151 AvahiServiceBrowser* avahi_service_browser_new (
152                 AvahiClient *client,
153                 AvahiIfIndex interface,
154                 AvahiProtocol protocol,
155                 char *type,
156                 char *domain,
157                 AvahiServiceBrowserCallback callback,
158                 void *user_data);
159
160 /** Get the D-Bus path of an AvahiServiceBrowser object, for debugging purposes only. */
161 char* avahi_service_browser_path (AvahiServiceBrowser *);
162
163 /* Cleans up and frees an AvahiServiceBrowser object */
164 void avahi_service_browser_free (AvahiServiceBrowser *);
165
166 #ifndef DOXYGEN_SHOULD_SKIP_THIS
167 AVAHI_C_DECL_END
168 #endif
169
170 #endif