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