]> git.meshlink.io Git - catta/blob - avahi-daemon/dbus-internal.h
* Implement client API for arbitrary record browsing
[catta] / avahi-daemon / dbus-internal.h
1 #ifndef foodbusinternalhfoo
2 #define foodbusinternalhfoo
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
26 #include <dbus/dbus.h>
27
28 #include <avahi-core/core.h>
29 #include <avahi-core/publish.h>
30 #include <avahi-core/lookup.h>
31
32 #include <avahi-common/llist.h>
33
34 typedef struct Server Server;
35 typedef struct Client Client;
36 typedef struct EntryGroupInfo EntryGroupInfo;
37 typedef struct SyncHostNameResolverInfo SyncHostNameResolverInfo;
38 typedef struct AsyncHostNameResolverInfo AsyncHostNameResolverInfo;
39 typedef struct SyncAddressResolverInfo SyncAddressResolverInfo;
40 typedef struct AsyncAddressResolverInfo AsyncAddressResolverInfo;
41 typedef struct DomainBrowserInfo DomainBrowserInfo;
42 typedef struct ServiceTypeBrowserInfo ServiceTypeBrowserInfo;
43 typedef struct ServiceBrowserInfo ServiceBrowserInfo;
44 typedef struct SyncServiceResolverInfo SyncServiceResolverInfo;
45 typedef struct AsyncServiceResolverInfo AsyncServiceResolverInfo;
46 typedef struct RecordBrowserInfo RecordBrowserInfo;
47
48 #define CLIENTS_MAX 256
49 #define OBJECTS_PER_CLIENT_MAX 50
50 #define ENTRIES_PER_ENTRY_GROUP_MAX 20
51
52 struct EntryGroupInfo {
53     unsigned id;
54     Client *client;
55     AvahiSEntryGroup *entry_group;
56     char *path;
57
58     int n_entries;
59     
60     AVAHI_LLIST_FIELDS(EntryGroupInfo, entry_groups);
61 };
62
63 struct SyncHostNameResolverInfo {
64     Client *client;
65     AvahiSHostNameResolver *host_name_resolver;
66     DBusMessage *message;
67
68     AVAHI_LLIST_FIELDS(SyncHostNameResolverInfo, sync_host_name_resolvers);
69 };
70
71 struct AsyncHostNameResolverInfo {
72     unsigned id;
73     Client *client;
74     AvahiSHostNameResolver *host_name_resolver;
75     char *path;
76
77     AVAHI_LLIST_FIELDS(AsyncHostNameResolverInfo, async_host_name_resolvers);
78 };
79
80 struct SyncAddressResolverInfo {
81     Client *client;
82     AvahiSAddressResolver *address_resolver;
83     DBusMessage *message;
84
85     AVAHI_LLIST_FIELDS(SyncAddressResolverInfo, sync_address_resolvers);
86 };
87
88 struct AsyncAddressResolverInfo {
89     unsigned id;
90     Client *client;
91     AvahiSAddressResolver *address_resolver;
92     char *path;
93
94     AVAHI_LLIST_FIELDS(AsyncAddressResolverInfo, async_address_resolvers);
95 };
96
97 struct DomainBrowserInfo {
98     unsigned id;
99     Client *client;
100     AvahiSDomainBrowser *domain_browser;
101     char *path;
102
103     AVAHI_LLIST_FIELDS(DomainBrowserInfo, domain_browsers);
104 };
105
106 struct ServiceTypeBrowserInfo {
107     unsigned id;
108     Client *client;
109     AvahiSServiceTypeBrowser *service_type_browser;
110     char *path;
111
112     AVAHI_LLIST_FIELDS(ServiceTypeBrowserInfo, service_type_browsers);
113 };
114
115 struct ServiceBrowserInfo {
116     unsigned id;
117     Client *client;
118     AvahiSServiceBrowser *service_browser;
119     char *path;
120
121     AVAHI_LLIST_FIELDS(ServiceBrowserInfo, service_browsers);
122 };
123
124 struct SyncServiceResolverInfo {
125     Client *client;
126     AvahiSServiceResolver *service_resolver;
127     DBusMessage *message;
128
129     AVAHI_LLIST_FIELDS(SyncServiceResolverInfo, sync_service_resolvers);
130 };
131
132 struct AsyncServiceResolverInfo {
133     unsigned id;
134     Client *client;
135     AvahiSServiceResolver *service_resolver;
136     char *path;
137
138     AVAHI_LLIST_FIELDS(AsyncServiceResolverInfo, async_service_resolvers);
139 };
140
141 struct RecordBrowserInfo {
142     unsigned id;
143     Client *client;
144     AvahiSRecordBrowser *record_browser;
145     char *path;
146
147     AVAHI_LLIST_FIELDS(RecordBrowserInfo, record_browsers);
148 };
149
150 struct Client {
151     unsigned id;
152     char *name;
153     unsigned current_id;
154     int n_objects;
155     
156     AVAHI_LLIST_FIELDS(Client, clients);
157     AVAHI_LLIST_HEAD(EntryGroupInfo, entry_groups);
158     AVAHI_LLIST_HEAD(SyncHostNameResolverInfo, sync_host_name_resolvers);
159     AVAHI_LLIST_HEAD(AsyncHostNameResolverInfo, async_host_name_resolvers);
160     AVAHI_LLIST_HEAD(SyncAddressResolverInfo, sync_address_resolvers);
161     AVAHI_LLIST_HEAD(AsyncAddressResolverInfo, async_address_resolvers);
162     AVAHI_LLIST_HEAD(DomainBrowserInfo, domain_browsers);
163     AVAHI_LLIST_HEAD(ServiceTypeBrowserInfo, service_type_browsers);
164     AVAHI_LLIST_HEAD(ServiceBrowserInfo, service_browsers);
165     AVAHI_LLIST_HEAD(SyncServiceResolverInfo, sync_service_resolvers);
166     AVAHI_LLIST_HEAD(AsyncServiceResolverInfo, async_service_resolvers);
167     AVAHI_LLIST_HEAD(RecordBrowserInfo, record_browsers);
168 };
169
170 struct Server {
171     DBusConnection *bus;
172     AVAHI_LLIST_HEAD(Client, clients);
173     int n_clients;
174     unsigned current_id;
175 };
176
177 extern Server *server;
178
179 void avahi_dbus_entry_group_free(EntryGroupInfo *i);
180 void avahi_dbus_entry_group_callback(AvahiServer *s, AvahiSEntryGroup *g, AvahiEntryGroupState state, void* userdata);
181 DBusHandlerResult avahi_dbus_msg_entry_group_impl(DBusConnection *c, DBusMessage *m, void *userdata);
182
183 void avahi_dbus_sync_host_name_resolver_free(SyncHostNameResolverInfo *i);
184 void avahi_dbus_sync_host_name_resolver_callback(AvahiSHostNameResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const char *host_name, const AvahiAddress *a, AvahiLookupResultFlags flags, void* userdata);
185
186 void avahi_dbus_async_host_name_resolver_free(AsyncHostNameResolverInfo *i);
187 void avahi_dbus_async_host_name_resolver_callback(AvahiSHostNameResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const char *host_name, const AvahiAddress *a, AvahiLookupResultFlags flags, void* userdata);
188 DBusHandlerResult avahi_dbus_msg_async_host_name_resolver_impl(DBusConnection *c, DBusMessage *m, void *userdata);
189
190 void avahi_dbus_sync_address_resolver_free(SyncAddressResolverInfo *i);
191 void avahi_dbus_sync_address_resolver_callback(AvahiSAddressResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const AvahiAddress *address, const char *host_name, AvahiLookupResultFlags flags, void* userdata);
192
193 void avahi_dbus_async_address_resolver_free(AsyncAddressResolverInfo *i);
194 void avahi_dbus_async_address_resolver_callback(AvahiSAddressResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const AvahiAddress *address, const char *host_name, AvahiLookupResultFlags flags, void* userdata);
195 DBusHandlerResult avahi_dbus_msg_async_address_resolver_impl(DBusConnection *c, DBusMessage *m, void *userdata);
196
197 void avahi_dbus_domain_browser_free(DomainBrowserInfo *i);
198 DBusHandlerResult avahi_dbus_msg_domain_browser_impl(DBusConnection *c, DBusMessage *m, void *userdata);
199 void avahi_dbus_domain_browser_callback(AvahiSDomainBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *domain, AvahiLookupResultFlags flags,  void* userdata);
200
201 void avahi_dbus_service_type_browser_free(ServiceTypeBrowserInfo *i);
202 DBusHandlerResult avahi_dbus_msg_service_type_browser_impl(DBusConnection *c, DBusMessage *m, void *userdata);
203 void avahi_dbus_service_type_browser_callback(AvahiSServiceTypeBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *type, const char *domain, AvahiLookupResultFlags flags, void* userdata);
204
205 void avahi_dbus_service_browser_free(ServiceBrowserInfo *i);
206 DBusHandlerResult avahi_dbus_msg_service_browser_impl(DBusConnection *c, DBusMessage *m, void *userdata);
207 void avahi_dbus_service_browser_callback(AvahiSServiceBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *name, const char *type, const char *domain, AvahiLookupResultFlags flags, void* userdata);
208
209 void avahi_dbus_sync_service_resolver_free(SyncServiceResolverInfo *i);
210
211 void avahi_dbus_sync_service_resolver_callback(
212     AvahiSServiceResolver *r,
213     AvahiIfIndex interface,
214     AvahiProtocol protocol,
215     AvahiResolverEvent event,
216     const char *name,
217     const char *type,
218     const char *domain,
219     const char *host_name,
220     const AvahiAddress *a,
221     uint16_t port,
222     AvahiStringList *txt,
223     AvahiLookupResultFlags flags, 
224     void* userdata);
225
226 void avahi_dbus_async_service_resolver_free(AsyncServiceResolverInfo *i);
227 void avahi_dbus_async_service_resolver_callback(
228     AvahiSServiceResolver *r,
229     AvahiIfIndex interface,
230     AvahiProtocol protocol,
231     AvahiResolverEvent event,
232     const char *name,
233     const char *type,
234     const char *domain,
235     const char *host_name,
236     const AvahiAddress *a,
237     uint16_t port,
238     AvahiStringList *txt,
239     AvahiLookupResultFlags flags, 
240     void* userdata);
241
242 DBusHandlerResult avahi_dbus_msg_async_service_resolver_impl(DBusConnection *c, DBusMessage *m, void *userdata);
243
244 void avahi_dbus_record_browser_free(RecordBrowserInfo *i);
245 DBusHandlerResult avahi_dbus_msg_record_browser_impl(DBusConnection *c, DBusMessage *m, void *userdata);
246 void avahi_dbus_record_browser_callback(AvahiSRecordBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, AvahiRecord *record, AvahiLookupResultFlags flags, void* userdata);
247
248 #endif