1#ifndef foointernalhfoo
2#define foointernalhfoo
3
4/***
5  This file is part of avahi.
6
7  avahi is free software; you can redistribute it and/or modify it
8  under the terms of the GNU Lesser General Public License as
9  published by the Free Software Foundation; either version 2.1 of the
10  License, or (at your option) any later version.
11
12  avahi is distributed in the hope that it will be useful, but WITHOUT
13  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
15  Public License for more details.
16
17  You should have received a copy of the GNU Lesser General Public
18  License along with avahi; if not, write to the Free Software
19  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20  USA.
21***/
22
23#include <dbus/dbus.h>
24
25#include "client.h"
26#include "lookup.h"
27#include "publish.h"
28
29struct AvahiClient {
30    const AvahiPoll *poll_api;
31    DBusConnection *bus;
32    int error;
33    AvahiClientState state;
34    AvahiClientFlags flags;
35
36    /* Cache for some seldom changing server data */
37    char *version_string, *host_name, *host_name_fqdn, *domain_name;
38    uint32_t local_service_cookie;
39    int local_service_cookie_valid;
40
41    AvahiClientCallback callback;
42    void *userdata;
43
44    AVAHI_LLIST_HEAD(AvahiEntryGroup, groups);
45    AVAHI_LLIST_HEAD(AvahiDomainBrowser, domain_browsers);
46    AVAHI_LLIST_HEAD(AvahiServiceBrowser, service_browsers);
47    AVAHI_LLIST_HEAD(AvahiServiceTypeBrowser, service_type_browsers);
48    AVAHI_LLIST_HEAD(AvahiServiceResolver, service_resolvers);
49    AVAHI_LLIST_HEAD(AvahiHostNameResolver, host_name_resolvers);
50    AVAHI_LLIST_HEAD(AvahiAddressResolver, address_resolvers);
51    AVAHI_LLIST_HEAD(AvahiRecordBrowser, record_browsers);
52};
53
54struct AvahiEntryGroup {
55    char *path;
56    AvahiEntryGroupState state;
57    int state_valid;
58    AvahiClient *client;
59    AvahiEntryGroupCallback callback;
60    void *userdata;
61    AVAHI_LLIST_FIELDS(AvahiEntryGroup, groups);
62};
63
64struct AvahiDomainBrowser {
65    int ref;
66
67    char *path;
68    AvahiClient *client;
69    AvahiDomainBrowserCallback callback;
70    void *userdata;
71    AVAHI_LLIST_FIELDS(AvahiDomainBrowser, domain_browsers);
72
73    AvahiIfIndex interface;
74    AvahiProtocol protocol;
75
76    AvahiTimeout *defer_timeout;
77
78    AvahiStringList *static_browse_domains;
79};
80
81struct AvahiServiceBrowser {
82    char *path;
83    AvahiClient *client;
84    AvahiServiceBrowserCallback callback;
85    void *userdata;
86    AVAHI_LLIST_FIELDS(AvahiServiceBrowser, service_browsers);
87
88    char *type, *domain;
89    AvahiIfIndex interface;
90    AvahiProtocol protocol;
91};
92
93struct AvahiServiceTypeBrowser {
94    char *path;
95    AvahiClient *client;
96    AvahiServiceTypeBrowserCallback callback;
97    void *userdata;
98    AVAHI_LLIST_FIELDS(AvahiServiceTypeBrowser, service_type_browsers);
99
100    char *domain;
101    AvahiIfIndex interface;
102    AvahiProtocol protocol;
103};
104
105struct AvahiServiceResolver {
106    char *path;
107    AvahiClient *client;
108    AvahiServiceResolverCallback callback;
109    void *userdata;
110    AVAHI_LLIST_FIELDS(AvahiServiceResolver, service_resolvers);
111
112    char *name, *type, *domain;
113    AvahiIfIndex interface;
114    AvahiProtocol protocol;
115};
116
117struct AvahiHostNameResolver {
118    char *path;
119    AvahiClient *client;
120    AvahiHostNameResolverCallback callback;
121    void *userdata;
122    AVAHI_LLIST_FIELDS(AvahiHostNameResolver, host_name_resolvers);
123
124    char *host_name;
125    AvahiIfIndex interface;
126    AvahiProtocol protocol;
127};
128
129struct AvahiAddressResolver {
130    char *path;
131    AvahiClient *client;
132    AvahiAddressResolverCallback callback;
133    void *userdata;
134    AVAHI_LLIST_FIELDS(AvahiAddressResolver, address_resolvers);
135
136    AvahiAddress address;
137    AvahiIfIndex interface;
138    AvahiProtocol protocol;
139};
140
141struct AvahiRecordBrowser {
142    char *path;
143    AvahiClient *client;
144    AvahiRecordBrowserCallback callback;
145    void *userdata;
146    AVAHI_LLIST_FIELDS(AvahiRecordBrowser, record_browsers);
147
148    char *name;
149    uint16_t clazz, type;
150    AvahiIfIndex interface;
151    AvahiProtocol protocol;
152};
153
154int avahi_client_set_errno (AvahiClient *client, int error);
155int avahi_client_set_dbus_error(AvahiClient *client, DBusError *error);
156
157void avahi_entry_group_set_state(AvahiEntryGroup *group, AvahiEntryGroupState state);
158
159DBusHandlerResult avahi_domain_browser_event (AvahiClient *client, AvahiBrowserEvent event, DBusMessage *message);
160DBusHandlerResult avahi_service_type_browser_event (AvahiClient *client, AvahiBrowserEvent event, DBusMessage *message);
161DBusHandlerResult avahi_service_browser_event (AvahiClient *client, AvahiBrowserEvent event, DBusMessage *message);
162DBusHandlerResult avahi_record_browser_event(AvahiClient *client, AvahiBrowserEvent event, DBusMessage *message);
163
164DBusHandlerResult avahi_service_resolver_event (AvahiClient *client, AvahiResolverEvent event, DBusMessage *message);
165DBusHandlerResult avahi_host_name_resolver_event (AvahiClient *client, AvahiResolverEvent event, DBusMessage *message);
166DBusHandlerResult avahi_address_resolver_event (AvahiClient *client, AvahiResolverEvent event, DBusMessage *message);
167
168int avahi_client_simple_method_call(AvahiClient *client, const char *path, const char *interface, const char *method);
169
170int avahi_client_is_connected(AvahiClient *client);
171
172#endif
173