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#include <avahi-common/watch.h> 32#include <avahi-common/gccmacro.h> 33 34/** \file client.h Definitions and functions for the client API over D-Bus */ 35 36AVAHI_C_DECL_BEGIN 37 38/** A connection context */ 39typedef struct AvahiClient AvahiClient; 40 41/** States of a client object, a superset of AvahiServerState */ 42typedef enum { 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. */ 48} AvahiClientState; 49 50typedef enum { 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 */ 53} AvahiClientFlags; 54 55/** The function prototype for the callback of an AvahiClient */ 56typedef void (*AvahiClientCallback) ( 57 AvahiClient *s, 58 AvahiClientState state /**< The new state of the client */, 59 void* userdata /**< The user data that was passed to avahi_client_new() */); 60 61/** @{ \name Construction and destruction */ 62 63/** Creates a new client instance */ 64AvahiClient* 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. */); 70 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! */ 74void avahi_client_free(AvahiClient *client); 75 76/** @} */ 77 78/** @{ \name Properties */ 79 80/** Get the version of the server */ 81const char* avahi_client_get_version_string (AvahiClient*); 82 83/** Get host name */ 84const char* avahi_client_get_host_name (AvahiClient*); 85 86/** Set host name. \since 0.6.13 */ 87int avahi_client_set_host_name(AvahiClient*, const char *name); 88 89/** Get domain name */ 90const char* avahi_client_get_domain_name (AvahiClient*); 91 92/** Get FQDN domain name */ 93const char* avahi_client_get_host_name_fqdn (AvahiClient*); 94 95/** Get state */ 96AvahiClientState avahi_client_get_state(AvahiClient *client); 97 98/** @{ \name Error Handling */ 99 100/** Get the last error number. See avahi_strerror() for converting this error code into a human readable string. */ 101int avahi_client_errno (AvahiClient*); 102 103/** @} */ 104 105/** \cond fulldocs */ 106/** Return the local service cookie. returns AVAHI_SERVICE_COOKIE_INVALID on failure. */ 107uint32_t avahi_client_get_local_service_cookie(AvahiClient *client); 108/** \endcond */ 109 110/** @{ \name Libc NSS Support */ 111 112/** Return 1 if gethostbyname() supports mDNS lookups, 0 otherwise. \since 0.6.5 */ 113int avahi_nss_support(void); 114 115/** @} */ 116 117AVAHI_C_DECL_END 118 119#endif 120