dbus_error_init (&error);
- if (client->state == AVAHI_CLIENT_DISCONNECTED) {
+ if (client->state == AVAHI_CLIENT_FAILURE) {
avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE);
goto fail;
}
client = b->client;
- if (b->path && client->state != AVAHI_CLIENT_DISCONNECTED)
+ if (b->path && client->state != AVAHI_CLIENT_FAILURE)
r = avahi_client_simple_method_call(client, b->path, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "Free");
AVAHI_LLIST_REMOVE(AvahiDomainBrowser, domain_browsers, client->domain_browsers, b);
dbus_error_init(&error);
- if (client->state == AVAHI_CLIENT_DISCONNECTED) {
+ if (client->state == AVAHI_CLIENT_FAILURE) {
avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE);
goto fail;
}
assert(b);
client = b->client;
- if (b->path && client->state != AVAHI_CLIENT_DISCONNECTED)
+ if (b->path && client->state != AVAHI_CLIENT_FAILURE)
r = avahi_client_simple_method_call(client, b->path, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "Free");
AVAHI_LLIST_REMOVE(AvahiServiceTypeBrowser, service_type_browsers, b->client->service_type_browsers, b);
dbus_error_init(&error);
- if (client->state == AVAHI_CLIENT_DISCONNECTED) {
+ if (client->state == AVAHI_CLIENT_FAILURE) {
avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE);
goto fail;
}
assert(b);
client = b->client;
- if (b->path && client->state != AVAHI_CLIENT_DISCONNECTED)
+ if (b->path && client->state != AVAHI_CLIENT_FAILURE)
r = avahi_client_simple_method_call(client, b->path, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "Free");
AVAHI_LLIST_REMOVE(AvahiServiceBrowser, service_browsers, b->client->service_browsers, b);
client->state = state;
switch (client->state) {
- case AVAHI_CLIENT_DISCONNECTED:
case AVAHI_CLIENT_FAILURE:
if (client->bus) {
dbus_connection_disconnect(client->bus);
/* dbus_message_get_path (message), */
/* dbus_message_get_member (message)); */
- if (client->state == AVAHI_CLIENT_DISCONNECTED)
+ if (client->state == AVAHI_CLIENT_FAILURE)
goto fail;
if (dbus_message_is_signal(message, DBUS_INTERFACE_LOCAL, "Disconnected")) {
/* The DBUS server died or kicked us */
- client_set_state(client, AVAHI_CLIENT_DISCONNECTED);
+ avahi_client_set_errno(client, AVAHI_ERR_DISCONNECTED);
+ client_set_state(client, AVAHI_CLIENT_FAILURE);
} if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) {
char *name, *old, *new;
goto fail;
}
- if (strcmp(name, AVAHI_DBUS_NAME) == 0)
+ if (strcmp(name, AVAHI_DBUS_NAME) == 0) {
/* Regardless if the server lost or acquired its name or
* if the name was transfered: our services are no longer
* available, so we disconnect ourselves */
-
- client_set_state(client, AVAHI_CLIENT_DISCONNECTED);
+
+ avahi_client_set_errno(client, AVAHI_ERR_DISCONNECTED);
+ client_set_state(client, AVAHI_CLIENT_FAILURE);
+ }
} else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_SERVER, "StateChanged")) {
int32_t state;
client->error = AVAHI_OK;
client->callback = callback;
client->userdata = userdata;
- client->state = AVAHI_CLIENT_DISCONNECTED;
+ client->state = AVAHI_CLIENT_FAILURE;
client->host_name = NULL;
client->host_name_fqdn = NULL;
const char* avahi_client_get_version_string (AvahiClient *client) {
assert(client);
- if (client->state == AVAHI_CLIENT_DISCONNECTED) {
+ if (client->state == AVAHI_CLIENT_FAILURE) {
avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE);
return NULL;
}
const char* avahi_client_get_domain_name (AvahiClient *client) {
assert(client);
- if (client->state == AVAHI_CLIENT_DISCONNECTED) {
+ if (client->state == AVAHI_CLIENT_FAILURE) {
avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE);
return NULL;
}
const char* avahi_client_get_host_name (AvahiClient *client) {
assert(client);
- if (client->state == AVAHI_CLIENT_DISCONNECTED) {
+ if (client->state == AVAHI_CLIENT_FAILURE) {
avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE);
return NULL;
}
const char* avahi_client_get_host_name_fqdn (AvahiClient *client) {
assert(client);
- if (client->state == AVAHI_CLIENT_DISCONNECTED) {
+ if (client->state == AVAHI_CLIENT_FAILURE) {
avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE);
return NULL;
}
DBusError error;
assert(client);
- if (client->state == AVAHI_CLIENT_DISCONNECTED) {
+ if (client->state == AVAHI_CLIENT_FAILURE) {
avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE);
return AVAHI_SERVICE_COOKIE_INVALID;
}
AVAHI_CLIENT_S_REGISTERING = AVAHI_SERVER_REGISTERING, /**< Server state: REGISTERING */
AVAHI_CLIENT_S_RUNNING = AVAHI_SERVER_RUNNING, /**< Server state: RUNNING */
AVAHI_CLIENT_S_COLLISION = AVAHI_SERVER_COLLISION, /**< Server state: COLLISION */
- AVAHI_CLIENT_DISCONNECTED = 100, /**< Lost DBUS connection to the Avahi daemon */
- AVAHI_CLIENT_FAILURE = 101 /**< Some kind of error happened on the client side */
+ AVAHI_CLIENT_FAILURE = 100 /**< Some kind of error happened on the client side */
} AvahiClientState;
/** The function prototype for the callback of an AvahiClient */
dbus_error_init (&error);
- if (client->state == AVAHI_CLIENT_DISCONNECTED) {
+ if (client->state == AVAHI_CLIENT_FAILURE) {
avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE);
goto fail;
}
assert(group);
- if (group->path && client->state != AVAHI_CLIENT_DISCONNECTED)
+ if (group->path && client->state != AVAHI_CLIENT_FAILURE)
r = entry_group_simple_method_call(group, "Free");
AVAHI_LLIST_REMOVE(AvahiEntryGroup, groups, client->groups, group);
int avahi_entry_group_commit(AvahiEntryGroup *group) {
assert(group);
- if (!group->path || group->client->state == AVAHI_CLIENT_DISCONNECTED)
+ if (!group->path || group->client->state == AVAHI_CLIENT_FAILURE)
return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE);
return entry_group_simple_method_call(group, "Commit");
int avahi_entry_group_reset(AvahiEntryGroup *group) {
assert(group);
- if (!group->path || group->client->state == AVAHI_CLIENT_DISCONNECTED)
+ if (!group->path || group->client->state == AVAHI_CLIENT_FAILURE)
return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE);
return entry_group_simple_method_call(group, "Reset");
assert(group);
client = group->client;
- if (!group->path || group->client->state == AVAHI_CLIENT_DISCONNECTED)
+ if (!group->path || group->client->state == AVAHI_CLIENT_FAILURE)
return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE);
dbus_error_init(&error);
client = group->client;
- if (!group->path || group->client->state == AVAHI_CLIENT_DISCONNECTED)
+ if (!group->path || group->client->state == AVAHI_CLIENT_FAILURE)
return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE);
if (!domain)
client = group->client;
- if (!group->path || group->client->state == AVAHI_CLIENT_DISCONNECTED)
+ if (!group->path || group->client->state == AVAHI_CLIENT_FAILURE)
return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE);
if (!domain)
client = group->client;
- if (!group->path || group->client->state == AVAHI_CLIENT_DISCONNECTED)
+ if (!group->path || group->client->state == AVAHI_CLIENT_FAILURE)
return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE);
if (!domain)
client = group->client;
- if (!group->path || group->client->state == AVAHI_CLIENT_DISCONNECTED)
+ if (!group->path || group->client->state == AVAHI_CLIENT_FAILURE)
return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE);
dbus_error_init(&error);
client = group->client;
- if (!group->path || group->client->state == AVAHI_CLIENT_DISCONNECTED)
+ if (!group->path || group->client->state == AVAHI_CLIENT_FAILURE)
return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE);
dbus_error_init(&error);
dbus_error_init (&error);
- if (client->state == AVAHI_CLIENT_DISCONNECTED) {
+ if (client->state == AVAHI_CLIENT_FAILURE) {
avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE);
goto fail;
}
assert(r);
client = r->client;
- if (r->path && client->state != AVAHI_CLIENT_DISCONNECTED)
+ if (r->path && client->state != AVAHI_CLIENT_FAILURE)
ret = avahi_client_simple_method_call(client, r->path, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, "Free");
AVAHI_LLIST_REMOVE(AvahiServiceResolver, service_resolvers, client->service_resolvers, r);
dbus_error_init (&error);
- if (client->state == AVAHI_CLIENT_DISCONNECTED) {
+ if (client->state == AVAHI_CLIENT_FAILURE) {
avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE);
goto fail;
}
assert(r);
client = r->client;
- if (r->path && client->state != AVAHI_CLIENT_DISCONNECTED)
+ if (r->path && client->state != AVAHI_CLIENT_FAILURE)
ret = avahi_client_simple_method_call(client, r->path, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, "Free");
AVAHI_LLIST_REMOVE(AvahiHostNameResolver, host_name_resolvers, client->host_name_resolvers, r);
return NULL;
}
- if (client->state == AVAHI_CLIENT_DISCONNECTED) {
+ if (client->state == AVAHI_CLIENT_FAILURE) {
avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE);
goto fail;
}
assert(r);
client = r->client;
- if (r->path && client->state != AVAHI_CLIENT_DISCONNECTED)
+ if (r->path && client->state != AVAHI_CLIENT_FAILURE)
ret = avahi_client_simple_method_call(client, r->path, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, "Free");
AVAHI_LLIST_REMOVE(AvahiAddressResolver, address_resolvers, client->address_resolvers, r);
AVAHI_DBUS_ERR_ACCESS_DENIED,
AVAHI_DBUS_ERR_INVALID_OPERATION,
AVAHI_DBUS_ERR_DBUS_ERROR,
- AVAHI_DBUS_ERR_NOT_CONNECTED,
+ AVAHI_DBUS_ERR_DISCONNECTED,
AVAHI_DBUS_ERR_NO_MEMORY,
AVAHI_DBUS_ERR_INVALID_OBJECT,
AVAHI_DBUS_ERR_NO_DAEMON,
#define AVAHI_DBUS_ERR_ACCESS_DENIED DBUS_ERROR_ACCESS_DENIED
#define AVAHI_DBUS_ERR_INVALID_OPERATION "org.freedesktop.Avahi.InvalidOperationError"
#define AVAHI_DBUS_ERR_DBUS_ERROR "org.freedesktop.Avahi.DBusError"
-#define AVAHI_DBUS_ERR_NOT_CONNECTED "org.freedesktop.Avahi.NotConnectedError"
+#define AVAHI_DBUS_ERR_DISCONNECTED "org.freedesktop.Avahi.DisconnectedError"
#define AVAHI_DBUS_ERR_NO_MEMORY "org.freedesktop.Avahi.NoMemoryError"
#define AVAHI_DBUS_ERR_INVALID_OBJECT "org.freedesktop.Avahi.InvalidObjectError"
#define AVAHI_DBUS_ERR_NO_DAEMON "org.freedesktop.Avahi.NoDaemonError"
"Access denied",
"Invalid operation",
"An unexpected DBUS error occured",
- "Could not get a connection to the daemon",
+ "Daemon connection failed",
"Memory exhausted",
"The object passed in was not valid",
"Daemon not running",
AVAHI_ERR_ACCESS_DENIED = -20, /**< Access denied */
AVAHI_ERR_INVALID_OPERATION = -21, /**< Invalid operation */
AVAHI_ERR_DBUS_ERROR = -22, /**< An unexpected DBUS error occured */
- AVAHI_ERR_NOT_CONNECTED = -23, /**< Could not get a connection to the daemon */
+ AVAHI_ERR_DISCONNECTED = -23, /**< Daemon connection failed */
AVAHI_ERR_NO_MEMORY = -24, /**< Memory exhausted */
AVAHI_ERR_INVALID_OBJECT = -25, /**< The object passed to this function was invalid */
AVAHI_ERR_NO_DAEMON = -26, /**< Daemon not running */
switch (state) {
case AVAHI_CLIENT_FAILURE:
- case AVAHI_CLIENT_DISCONNECTED:
reg_report_status(data, SW_DISCOVERY_PUBLISH_INVALID);
break;
case AVAHI_ERR_INVALID_CONFIG:
case AVAHI_ERR_TIMEOUT:
case AVAHI_ERR_DBUS_ERROR:
- case AVAHI_ERR_NOT_CONNECTED:
+ case AVAHI_ERR_DISCONNECTED:
case AVAHI_ERR_NO_DAEMON:
break;
switch (state) {
case AVAHI_CLIENT_FAILURE:
- case AVAHI_CLIENT_DISCONNECTED:
if (sdref->service_browser_callback)
sdref->service_browser_callback(sdref, 0, 0, error, NULL, NULL, NULL, sdref->context);
switch (state) {
case AVAHI_CLIENT_FAILURE:
- case AVAHI_CLIENT_DISCONNECTED:
reg_report_error(sdref, kDNSServiceErr_Unknown);
break;
avahi_simple_poll_quit(simple_poll);
break;
- case AVAHI_CLIENT_DISCONNECTED:
- fprintf(stderr, "Client disconnected, exiting.\n");
- avahi_simple_poll_quit(simple_poll);
- break;
-
case AVAHI_CLIENT_S_REGISTERING:
case AVAHI_CLIENT_S_RUNNING:
case AVAHI_CLIENT_S_COLLISION:
avahi_simple_poll_quit(simple_poll);
break;
- case AVAHI_CLIENT_DISCONNECTED:
- fprintf(stderr, "Client disconnected, exiting.\n");
- avahi_simple_poll_quit(simple_poll);
- break;
-
case AVAHI_CLIENT_S_REGISTERING:
case AVAHI_CLIENT_S_RUNNING:
case AVAHI_CLIENT_S_COLLISION:
* update man pages
later:
-* avahi-client: do something about letting the client know if the daemon comes back from a DISCONNECTED state
* add simplification routine for adding services
* implement avahi-utils in C
* support for special domain PTR records based on local IP subnet address
/* Called whenever the client or server state changes */
- if (state == AVAHI_CLIENT_DISCONNECTED) {
- fprintf(stderr, "Server connection terminated.\n");
+ if (state == AVAHI_CLIENT_FAILURE) {
+ fprintf(stderr, "Server connection failre: %s\n", avahi_strerror(avahi_client_errno(c)));
avahi_simple_poll_quit(simple_poll);
}
}
avahi_entry_group_reset(group);
break;
- case AVAHI_CLIENT_DISCONNECTED:
-
- fprintf(stderr, "Server connection terminated.\n");
- avahi_simple_poll_quit(simple_poll);
-
- break;
-
case AVAHI_CLIENT_FAILURE:
fprintf(stderr, "Client failure: %s\n", avahi_strerror(avahi_client_errno(c)));
g_message ("Avahi Client State Change: %d", state);
- if (state == AVAHI_CLIENT_DISCONNECTED)
+ if (state == AVAHI_CLIENT_FAILURE)
{
/* We we're disconnected from the Daemon */
- g_message ("Disconnected from the Avahi Daemon");
+ g_message ("Disconnected from the Avahi Daemon: %s", avahi_strerror(avahi_client_errno(client)));
/* Quit the application */
g_main_loop_quit (loop);