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