875
875
dbus_connection_get_is_connected(client->bus) &&
876
876
(client->state == AVAHI_CLIENT_S_RUNNING || client->state == AVAHI_CLIENT_S_REGISTERING || client->state == AVAHI_CLIENT_S_COLLISION);
879
int avahi_client_set_host_name(AvahiClient* client, const char *name) {
880
DBusMessage *message = NULL, *reply = NULL;
885
if (!avahi_client_is_connected(client))
886
return avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE);
888
dbus_error_init (&error);
890
if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "SetHostName"))) {
891
avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
895
if (!dbus_message_append_args (message, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID)) {
896
avahi_client_set_errno (client, AVAHI_ERR_NO_MEMORY);
900
reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error);
902
if (!reply || dbus_error_is_set (&error))
905
if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) ||
906
dbus_error_is_set (&error))
909
dbus_message_unref(message);
910
dbus_message_unref(reply);
912
avahi_free(client->host_name);
913
client->host_name = NULL;
914
avahi_free(client->host_name_fqdn);
915
client->host_name_fqdn = NULL;
922
dbus_message_unref(message);
924
dbus_message_unref(reply);
926
if (dbus_error_is_set(&error)) {
927
avahi_client_set_dbus_error(client, &error);
928
dbus_error_free(&error);
931
return client->error;