summaryrefslogtreecommitdiffstats
path: root/avahi-client/client.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2008-10-26 15:10:35 +0100
committerLennart Poettering <lennart@poettering.net>2008-10-26 15:10:35 +0100
commit955155213febc535caf48d0c4107162f93a58863 (patch)
tree39684506b3bc99b17533182cea9572c3f645132c /avahi-client/client.c
parentb7d12d0d6e81c9c9d657dfe082563ca558179426 (diff)
initialize i18n automatically
Diffstat (limited to 'avahi-client/client.c')
-rw-r--r--avahi-client/client.c204
1 files changed, 103 insertions, 101 deletions
diff --git a/avahi-client/client.c b/avahi-client/client.c
index f665613..389a3d1 100644
--- a/avahi-client/client.c
+++ b/avahi-client/client.c
@@ -2,17 +2,17 @@
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@@ -75,9 +75,9 @@ static void client_set_state (AvahiClient *client, AvahiServerState state) {
dbus_connection_unref(client->bus);
client->bus = NULL;
}
-
+
/* Fall through */
-
+
case AVAHI_CLIENT_S_COLLISION:
case AVAHI_CLIENT_S_REGISTERING:
@@ -94,9 +94,9 @@ static void client_set_state (AvahiClient *client, AvahiServerState state) {
case AVAHI_CLIENT_S_RUNNING:
case AVAHI_CLIENT_CONNECTING:
break;
-
+
}
-
+
if (client->callback)
client->callback (client, state, client->userdata);
}
@@ -107,7 +107,7 @@ static DBusHandlerResult filter_func(DBusConnection *bus, DBusMessage *message,
assert(bus);
assert(message);
-
+
dbus_error_init(&error);
/* fprintf(stderr, "dbus: interface=%s, path=%s, member=%s\n", */
@@ -124,10 +124,10 @@ static DBusHandlerResult filter_func(DBusConnection *bus, DBusMessage *message,
} else if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS, "NameAcquired")) {
/* Ignore this message */
-
+
} else if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) {
char *name, *old, *new;
-
+
if (!dbus_message_get_args(
message, &error,
DBUS_TYPE_STRING, &name,
@@ -149,12 +149,12 @@ static DBusHandlerResult filter_func(DBusConnection *bus, DBusMessage *message,
* available, so we disconnect ourselves */
avahi_client_set_errno(client, AVAHI_ERR_DISCONNECTED);
goto fail;
-
+
} else if (client->state == AVAHI_CLIENT_CONNECTING && (!old || *old == 0)) {
int ret;
-
+
/* Server appeared */
-
+
if ((ret = init_server(client, NULL)) < 0) {
avahi_client_set_errno(client, ret);
goto fail;
@@ -163,14 +163,14 @@ static DBusHandlerResult filter_func(DBusConnection *bus, DBusMessage *message,
}
} else if (!avahi_client_is_connected(client)) {
-
+
/* Ignore messages we get in unconnected state */
-
+
} else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_SERVER, "StateChanged")) {
int32_t state;
char *e = NULL;
int c;
-
+
if (!dbus_message_get_args(
message, &error,
DBUS_TYPE_INT32, &state,
@@ -184,7 +184,7 @@ static DBusHandlerResult filter_func(DBusConnection *bus, DBusMessage *message,
if ((c = avahi_error_dbus_to_number(e)) != AVAHI_OK)
avahi_client_set_errno(client, c);
-
+
client_set_state(client, (AvahiClientState) state);
} else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "StateChanged")) {
@@ -195,12 +195,12 @@ static DBusHandlerResult filter_func(DBusConnection *bus, DBusMessage *message,
for (g = client->groups; g; g = g->groups_next)
if (strcmp(g->path, path) == 0)
break;
-
+
if (g) {
int32_t state;
char *e;
int c;
-
+
if (!dbus_message_get_args(
message, &error,
DBUS_TYPE_INT32, &state,
@@ -215,79 +215,79 @@ static DBusHandlerResult filter_func(DBusConnection *bus, DBusMessage *message,
if ((c = avahi_error_dbus_to_number(e)) != AVAHI_OK)
avahi_client_set_errno(client, c);
-
+
avahi_entry_group_set_state(g, state);
}
-
+
} else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "ItemNew"))
return avahi_domain_browser_event(client, AVAHI_BROWSER_NEW, message);
- else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "ItemRemove"))
+ else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "ItemRemove"))
return avahi_domain_browser_event(client, AVAHI_BROWSER_REMOVE, message);
- else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "CacheExhausted"))
+ else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "CacheExhausted"))
return avahi_domain_browser_event(client, AVAHI_BROWSER_CACHE_EXHAUSTED, message);
- else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "AllForNow"))
+ else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "AllForNow"))
return avahi_domain_browser_event(client, AVAHI_BROWSER_ALL_FOR_NOW, message);
- else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "Failure"))
+ else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "Failure"))
return avahi_domain_browser_event(client, AVAHI_BROWSER_FAILURE, message);
- else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "ItemNew"))
+ else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "ItemNew"))
return avahi_service_type_browser_event (client, AVAHI_BROWSER_NEW, message);
- else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "ItemRemove"))
+ else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "ItemRemove"))
return avahi_service_type_browser_event (client, AVAHI_BROWSER_REMOVE, message);
- else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "CacheExhausted"))
+ else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "CacheExhausted"))
return avahi_service_type_browser_event (client, AVAHI_BROWSER_CACHE_EXHAUSTED, message);
- else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "AllForNow"))
+ else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "AllForNow"))
return avahi_service_type_browser_event (client, AVAHI_BROWSER_ALL_FOR_NOW, message);
- else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "Failure"))
+ else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "Failure"))
return avahi_service_type_browser_event (client, AVAHI_BROWSER_FAILURE, message);
- else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "ItemNew"))
+ else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "ItemNew"))
return avahi_service_browser_event (client, AVAHI_BROWSER_NEW, message);
- else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "ItemRemove"))
+ else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "ItemRemove"))
return avahi_service_browser_event (client, AVAHI_BROWSER_REMOVE, message);
- else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "CacheExhausted"))
+ else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "CacheExhausted"))
return avahi_service_browser_event (client, AVAHI_BROWSER_CACHE_EXHAUSTED, message);
- else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "AllForNow"))
+ else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "AllForNow"))
return avahi_service_browser_event (client, AVAHI_BROWSER_ALL_FOR_NOW, message);
- else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "Failure"))
+ else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "Failure"))
return avahi_service_browser_event (client, AVAHI_BROWSER_FAILURE, message);
- else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, "Found"))
+ else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, "Found"))
return avahi_service_resolver_event (client, AVAHI_RESOLVER_FOUND, message);
- else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, "Failure"))
+ else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, "Failure"))
return avahi_service_resolver_event (client, AVAHI_RESOLVER_FAILURE, message);
- else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, "Found"))
+ else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, "Found"))
return avahi_host_name_resolver_event (client, AVAHI_RESOLVER_FOUND, message);
- else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, "Failure"))
+ else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, "Failure"))
return avahi_host_name_resolver_event (client, AVAHI_RESOLVER_FAILURE, message);
- else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, "Found"))
+ else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, "Found"))
return avahi_address_resolver_event (client, AVAHI_RESOLVER_FOUND, message);
- else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, "Failure"))
+ else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, "Failure"))
return avahi_address_resolver_event (client, AVAHI_RESOLVER_FAILURE, message);
- else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "ItemNew"))
+ else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "ItemNew"))
return avahi_record_browser_event (client, AVAHI_BROWSER_NEW, message);
- else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "ItemRemove"))
+ else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "ItemRemove"))
return avahi_record_browser_event (client, AVAHI_BROWSER_REMOVE, message);
- else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "CacheExhausted"))
+ else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "CacheExhausted"))
return avahi_record_browser_event (client, AVAHI_BROWSER_CACHE_EXHAUSTED, message);
- else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "AllForNow"))
+ else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "AllForNow"))
return avahi_record_browser_event (client, AVAHI_BROWSER_ALL_FOR_NOW, message);
- else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "Failure"))
+ else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "Failure"))
return avahi_record_browser_event (client, AVAHI_BROWSER_FAILURE, message);
else {
fprintf(stderr, "WARNING: Unhandled message: interface=%s, path=%s, member=%s\n",
- dbus_message_get_interface(message),
+ dbus_message_get_interface(message),
dbus_message_get_path(message),
dbus_message_get_member(message));
-
+
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
-
+
return DBUS_HANDLER_RESULT_HANDLED;
fail:
@@ -298,7 +298,7 @@ fail:
}
client_set_state(client, AVAHI_CLIENT_FAILURE);
-
+
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
@@ -307,7 +307,7 @@ static int get_server_state(AvahiClient *client, int *ret_error) {
DBusError error;
int32_t state;
int e = AVAHI_ERR_NO_MEMORY;
-
+
assert(client);
dbus_error_init(&error);
@@ -328,15 +328,15 @@ static int get_server_state(AvahiClient *client, int *ret_error) {
dbus_message_unref(message);
dbus_message_unref(reply);
-
+
return AVAHI_OK;
fail:
if (dbus_error_is_set(&error)) {
e = avahi_error_dbus_to_number (error.name);
dbus_error_free(&error);
- }
-
+ }
+
if (ret_error)
*ret_error = e;
@@ -344,7 +344,7 @@ fail:
dbus_message_unref(message);
if (reply)
dbus_message_unref(reply);
-
+
return e;
}
@@ -353,7 +353,7 @@ static int check_version(AvahiClient *client, int *ret_error) {
DBusError error;
uint32_t version;
int e = AVAHI_ERR_NO_MEMORY;
-
+
assert(client);
dbus_error_init(&error);
@@ -372,7 +372,7 @@ static int check_version(AvahiClient *client, int *ret_error) {
/* If the method GetAPIVersion is not known, we look if
* GetVersionString matches "avahi 0.6" which is the only
* version we support which doesn't have GetAPIVersion() .*/
-
+
dbus_message_unref(message);
if (reply) dbus_message_unref(reply);
dbus_error_free(&error);
@@ -381,25 +381,25 @@ static int check_version(AvahiClient *client, int *ret_error) {
goto fail;
reply = dbus_connection_send_with_reply_and_block (client->bus, message, -1, &error);
-
+
if (!reply || dbus_error_is_set (&error))
goto fail;
-
+
if (!dbus_message_get_args (reply, &error, DBUS_TYPE_STRING, &version_str, DBUS_TYPE_INVALID) ||
dbus_error_is_set (&error))
goto fail;
version = strcmp(version_str, "avahi 0.6") == 0 ? 0x0201 : 0x0000;
-
+
} else {
-
+
if (!dbus_message_get_args (reply, &error, DBUS_TYPE_UINT32, &version, DBUS_TYPE_INVALID) ||
dbus_error_is_set(&error))
goto fail;
}
/*fprintf(stderr, "API Version 0x%04x\n", version);*/
-
+
if ((version & 0xFF00) != (AVAHI_CLIENT_DBUS_API_SUPPORTED & 0xFF00) ||
(version & 0x00FF) < (AVAHI_CLIENT_DBUS_API_SUPPORTED & 0x00FF)) {
e = AVAHI_ERR_VERSION_MISMATCH;
@@ -408,14 +408,14 @@ static int check_version(AvahiClient *client, int *ret_error) {
dbus_message_unref(message);
dbus_message_unref(reply);
-
+
return AVAHI_OK;
fail:
if (dbus_error_is_set(&error)) {
e = avahi_error_dbus_to_number (error.name);
dbus_error_free(&error);
- }
+ }
if (ret_error)
*ret_error = e;
@@ -424,13 +424,13 @@ fail:
dbus_message_unref(message);
if (reply)
dbus_message_unref(reply);
-
+
return e;
}
static int init_server(AvahiClient *client, int *ret_error) {
int r;
-
+
if ((r = check_version(client, ret_error)) < 0)
return r;
@@ -448,14 +448,14 @@ static DBusConnection* avahi_dbus_bus_get(DBusError *error) {
#ifdef HAVE_DBUS_BUS_GET_PRIVATE
if (!(c = dbus_bus_get_private(DBUS_BUS_SYSTEM, error)))
return NULL;
-
+
dbus_connection_set_exit_on_disconnect(c, FALSE);
#else
const char *a;
-
+
if (!(a = getenv("DBUS_SYSTEM_BUS_ADDRESS")) || !*a)
a = DBUS_SYSTEM_BUS_DEFAULT_ADDRESS;
-
+
if (!(c = dbus_connection_open_private(a, error)))
return NULL;
@@ -479,6 +479,8 @@ AvahiClient *avahi_client_new(const AvahiPoll *poll_api, AvahiClientFlags flags,
AvahiClient *client = NULL;
DBusError error;
+ avahi_init_i18n();
+
dbus_error_init(&error);
if (!(client = avahi_new(AvahiClient, 1))) {
@@ -493,13 +495,13 @@ AvahiClient *avahi_client_new(const AvahiPoll *poll_api, AvahiClientFlags flags,
client->userdata = userdata;
client->state = (AvahiClientState) -1;
client->flags = flags;
-
+
client->host_name = NULL;
client->host_name_fqdn = NULL;
client->domain_name = NULL;
client->version_string = NULL;
client->local_service_cookie_valid = 0;
-
+
AVAHI_LLIST_HEAD_INIT(AvahiEntryGroup, client->groups);
AVAHI_LLIST_HEAD_INIT(AvahiDomainBrowser, client->domain_browsers);
AVAHI_LLIST_HEAD_INIT(AvahiServiceBrowser, client->service_browsers);
@@ -523,10 +525,10 @@ AvahiClient *avahi_client_new(const AvahiPoll *poll_api, AvahiClientFlags flags,
if (!dbus_connection_add_filter (client->bus, filter_func, client, NULL)) {
if (ret_error)
- *ret_error = AVAHI_ERR_NO_MEMORY;
+ *ret_error = AVAHI_ERR_NO_MEMORY;
goto fail;
}
-
+
dbus_bus_add_match(
client->bus,
"type='signal', "
@@ -567,17 +569,17 @@ AvahiClient *avahi_client_new(const AvahiPoll *poll_api, AvahiClientFlags flags,
dbus_error_free(&error);
if (!(flags & AVAHI_CLIENT_NO_FAIL)) {
-
+
if (ret_error)
*ret_error = AVAHI_ERR_NO_DAEMON;
-
+
goto fail;
}
/* The user doesn't want this call to fail if the daemon is not
* available, so let's return succesfully */
client_set_state(client, AVAHI_CLIENT_CONNECTING);
-
+
} else {
if (init_server(client, ret_error) < 0)
@@ -600,10 +602,10 @@ fail:
else
*ret_error = avahi_error_dbus_to_number(error.name);
}
-
+
dbus_error_free(&error);
}
-
+
return NULL;
}
@@ -618,7 +620,7 @@ void avahi_client_free(AvahiClient *client) {
#else
dbus_connection_disconnect(client->bus);
#endif
-
+
while (client->groups)
avahi_entry_group_free(client->groups);
@@ -642,7 +644,7 @@ void avahi_client_free(AvahiClient *client) {
while (client->record_browsers)
avahi_record_browser_free(client->record_browsers);
-
+
if (client->bus)
dbus_connection_unref(client->bus);
@@ -650,7 +652,7 @@ void avahi_client_free(AvahiClient *client) {
avahi_free(client->host_name);
avahi_free(client->host_name_fqdn);
avahi_free(client->domain_name);
-
+
avahi_free(client);
}
@@ -675,7 +677,7 @@ static char* avahi_client_get_string_reply_and_block (AvahiClient *client, const
goto fail;
}
}
-
+
reply = dbus_connection_send_with_reply_and_block (client->bus, message, -1, &error);
if (!reply || dbus_error_is_set (&error))
@@ -684,7 +686,7 @@ static char* avahi_client_get_string_reply_and_block (AvahiClient *client, const
if (!dbus_message_get_args (reply, &error, DBUS_TYPE_STRING, &ret, DBUS_TYPE_INVALID) ||
dbus_error_is_set (&error))
goto fail;
-
+
if (!(n = avahi_strdup(ret))) {
avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
@@ -692,7 +694,7 @@ static char* avahi_client_get_string_reply_and_block (AvahiClient *client, const
dbus_message_unref(message);
dbus_message_unref(reply);
-
+
return n;
fail:
@@ -701,7 +703,7 @@ fail:
dbus_message_unref(message);
if (reply)
dbus_message_unref(reply);
-
+
if (dbus_error_is_set(&error)) {
avahi_client_set_dbus_error(client, &error);
dbus_error_free(&error);
@@ -734,13 +736,13 @@ const char* avahi_client_get_domain_name(AvahiClient *client) {
if (!client->domain_name)
client->domain_name = avahi_client_get_string_reply_and_block(client, "GetDomainName", NULL);
-
+
return client->domain_name;
}
const char* avahi_client_get_host_name(AvahiClient *client) {
assert(client);
-
+
if (!avahi_client_is_connected(client)) {
avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE);
return NULL;
@@ -748,7 +750,7 @@ const char* avahi_client_get_host_name(AvahiClient *client) {
if (!client->host_name)
client->host_name = avahi_client_get_string_reply_and_block(client, "GetHostName", NULL);
-
+
return client->host_name;
}
@@ -759,7 +761,7 @@ const char* avahi_client_get_host_name_fqdn (AvahiClient *client) {
avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE);
return NULL;
}
-
+
if (!client->host_name_fqdn)
client->host_name_fqdn = avahi_client_get_string_reply_and_block(client, "GetHostNameFqdn", NULL);
@@ -774,7 +776,7 @@ AvahiClientState avahi_client_get_state(AvahiClient *client) {
int avahi_client_errno(AvahiClient *client) {
assert(client);
-
+
return client->error;
}
@@ -783,25 +785,25 @@ int avahi_client_simple_method_call(AvahiClient *client, const char *path, const
DBusMessage *message = NULL, *reply = NULL;
DBusError error;
int r = AVAHI_OK;
-
+
dbus_error_init(&error);
assert(client);
assert(path);
assert(interface);
assert(method);
-
+
if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, path, interface, method))) {
r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
}
-
+
if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) ||
dbus_error_is_set (&error)) {
r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR);
goto fail;
}
-
+
if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) ||
dbus_error_is_set (&error)) {
r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR);
@@ -812,7 +814,7 @@ int avahi_client_simple_method_call(AvahiClient *client, const char *path, const
dbus_message_unref(reply);
return AVAHI_OK;
-
+
fail:
if (dbus_error_is_set(&error)) {
r = avahi_client_set_dbus_error(client, &error);
@@ -856,7 +858,7 @@ uint32_t avahi_client_get_local_service_cookie(AvahiClient *client) {
if (!dbus_message_get_args (reply, &error, DBUS_TYPE_UINT32, &client->local_service_cookie, DBUS_TYPE_INVALID) ||
dbus_error_is_set (&error))
goto fail;
-
+
dbus_message_unref(message);
dbus_message_unref(reply);
@@ -869,7 +871,7 @@ fail:
dbus_message_unref(message);
if (reply)
dbus_message_unref(reply);
-
+
if (dbus_error_is_set(&error)) {
avahi_client_set_dbus_error(client, &error);
dbus_error_free(&error);
@@ -892,7 +894,7 @@ int avahi_client_set_host_name(AvahiClient* client, const char *name) {
DBusError error;
assert(client);
-
+
if (!avahi_client_is_connected(client))
return avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE);
@@ -907,7 +909,7 @@ int avahi_client_set_host_name(AvahiClient* client, const char *name) {
avahi_client_set_errno (client, AVAHI_ERR_NO_MEMORY);
goto fail;
}
-
+
reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error);
if (!reply || dbus_error_is_set (&error))
@@ -924,7 +926,7 @@ int avahi_client_set_host_name(AvahiClient* client, const char *name) {
client->host_name = NULL;
avahi_free(client->host_name_fqdn);
client->host_name_fqdn = NULL;
-
+
return 0;
fail:
@@ -933,7 +935,7 @@ fail:
dbus_message_unref(message);
if (reply)
dbus_message_unref(reply);
-
+
if (dbus_error_is_set(&error)) {
avahi_client_set_dbus_error(client, &error);
dbus_error_free(&error);