7 This file is part of avahi.
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.
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.
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
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 #include <avahi-common/watch.h>
32 #include <avahi-common/gccmacro.h>
34 /** \file client.h Definitions and functions for the client API over D-Bus */
38 /** A connection context */
39 typedef struct AvahiClient AvahiClient;
41 /** States of a client object, a superset of AvahiServerState */
43 AVAHI_CLIENT_S_REGISTERING = AVAHI_SERVER_REGISTERING, /**< Server state: REGISTERING */
44 AVAHI_CLIENT_S_RUNNING = AVAHI_SERVER_RUNNING, /**< Server state: RUNNING */
45 AVAHI_CLIENT_S_COLLISION = AVAHI_SERVER_COLLISION, /**< Server state: COLLISION */
46 AVAHI_CLIENT_FAILURE = 100, /**< Some kind of error happened on the client side */
47 AVAHI_CLIENT_CONNECTING = 101 /**< We're still connecting. This state is only entered when AVAHI_CLIENT_NO_FAIL has been passed to avahi_client_new() and the daemon is not yet available. */
51 AVAHI_CLIENT_IGNORE_USER_CONFIG = 1, /**< Don't read user configuration */
52 AVAHI_CLIENT_NO_FAIL = 2 /**< Don't fail if the daemon is not available when avahi_client_new() is called, instead enter AVAHI_CLIENT_CONNECTING state and wait for the daemon to appear */
55 /** The function prototype for the callback of an AvahiClient */
56 typedef void (*AvahiClientCallback) (
58 AvahiClientState state /**< The new state of the client */,
59 void* userdata /**< The user data that was passed to avahi_client_new() */);
61 /** @{ \name Construction and destruction */
63 /** Creates a new client instance */
64 AvahiClient* avahi_client_new (
65 const AvahiPoll *poll_api /**< The abstract event loop API to use */,
66 AvahiClientFlags flags /**< Some flags to modify the behaviour of the client library */,
67 AvahiClientCallback callback /**< A callback that is called whenever the state of the client changes. This may be NULL. Please note that this function is called for the first time from within the avahi_client_new() context! Thus, in the callback you should not make use of global variables that are initialized only after your call to avahi_client_new(). A common mistake is to store the AvahiClient pointer returned by avahi_client_new() in a global variable and assume that this global variable already contains the valid pointer when the callback is called for the first time. A work-around for this is to always use the AvahiClient pointer passed to the callback function instead of the global pointer. */,
68 void *userdata /**< Some arbitrary user data pointer that will be passed to the callback function */,
69 int *error /**< If creation of the client fails, this integer will contain the error cause. May be NULL if you aren't interested in the reason why avahi_client_new() failed. */);
71 /** Free a client instance. This will automatically free all
72 * associated browser, resolve and entry group objects. All pointers
73 * to such objects become invalid! */
74 void avahi_client_free(AvahiClient *client);
78 /** @{ \name Properties */
80 /** Get the version of the server */
81 const char* avahi_client_get_version_string (AvahiClient*);
84 const char* avahi_client_get_host_name (AvahiClient*);
86 /** Set host name. \since 0.6.13 */
87 int avahi_client_set_host_name(AvahiClient*, const char *name);
89 /** Get domain name */
90 const char* avahi_client_get_domain_name (AvahiClient*);
92 /** Get FQDN domain name */
93 const char* avahi_client_get_host_name_fqdn (AvahiClient*);
96 AvahiClientState avahi_client_get_state(AvahiClient *client);
98 /** @{ \name Error Handling */
100 /** Get the last error number. See avahi_strerror() for converting this error code into a human readable string. */
101 int avahi_client_errno (AvahiClient*);
105 /** \cond fulldocs */
106 /** Return the local service cookie. returns AVAHI_SERVICE_COOKIE_INVALID on failure. */
107 uint32_t avahi_client_get_local_service_cookie(AvahiClient *client);
110 /** @{ \name Libc NSS Support */
112 /** Return 1 if gethostbyname() supports mDNS lookups, 0 otherwise. \since 0.6.5 */
113 int avahi_nss_support(void);