]> git.meshlink.io Git - catta/blobdiff - avahi-daemon/dbus-protocol.c
autoconf love:
[catta] / avahi-daemon / dbus-protocol.c
index 19e956b6c214145900abf78a759c6885efe619ab..e74caa328ec7213c056b76de994d168351550dd2 100644 (file)
@@ -43,7 +43,6 @@
 #include <avahi-common/dbus.h>
 #include <avahi-common/llist.h>
 #include <avahi-common/malloc.h>
-#include <avahi-common/dbus.h>
 #include <avahi-common/dbus-watch-glue.h>
 #include <avahi-common/alternative.h>
 #include <avahi-common/error.h>
@@ -265,6 +264,22 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH
 
         return avahi_dbus_respond_string(c, m, avahi_server_get_host_name(avahi_server));
         
+    } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "SetHostName")) {
+
+        char *name;
+        
+        if (!dbus_message_get_args(m, &error, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID)) {
+            avahi_log_warn("Error parsing Server::SetHostName message");
+            goto fail;
+        }
+        
+        if (avahi_server_set_host_name(avahi_server, name) < 0) 
+            return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL);
+
+        avahi_log_info("Changing host name to '%s'.", name);
+        
+        return avahi_dbus_respond_ok(c, m);
+        
     } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetDomainName")) {
 
         if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) {
@@ -1115,7 +1130,11 @@ fail:
         dbus_error_free(&error);
 
     if (server->bus) {
+#ifdef HAVE_DBUS_CONNECTION_CLOSE
+        dbus_connection_close(server->bus);
+#else
         dbus_connection_disconnect(server->bus);
+#endif
         dbus_connection_unref(server->bus);
         server->bus = NULL;
     }
@@ -1132,7 +1151,11 @@ static void dbus_disconnect(void) {
     assert(server->n_clients == 0);
 
     if (server->bus) {
+#ifdef HAVE_DBUS_CONNECTION_CLOSE
+        dbus_connection_close(server->bus);
+#else
         dbus_connection_disconnect(server->bus);
+#endif
         dbus_connection_unref(server->bus);
         server->bus = NULL;
     }
@@ -1157,7 +1180,7 @@ int dbus_protocol_setup(const AvahiPoll *poll_api, int _disable_user_service_pub
         if (!force)
             goto fail;
 
-        avahi_log_warn("WARNING: Failed to contact D-BUS daemon, retrying in %ims.", RECONNECT_MSEC);
+        avahi_log_warn("WARNING: Failed to contact D-Bus daemon, retrying in %ims.", RECONNECT_MSEC);
         
         avahi_elapse_time(&tv, RECONNECT_MSEC, 0);
         server->reconnect_timeout = server->poll_api->timeout_new(server->poll_api, &tv, reconnect_callback, NULL);
@@ -1167,7 +1190,11 @@ int dbus_protocol_setup(const AvahiPoll *poll_api, int _disable_user_service_pub
 
 fail:
     if (server->bus) {
+#ifdef HAVE_DBUS_CONNECTION_CLOSE
+        dbus_connection_close(server->bus);
+#else
         dbus_connection_disconnect(server->bus);
+#endif
         dbus_connection_unref(server->bus);
     }