summaryrefslogtreecommitdiffstats
path: root/avahi-daemon
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2006-08-22 01:49:25 +0000
committerLennart Poettering <lennart@poettering.net>2006-08-22 01:49:25 +0000
commit8f02a455414a986c3616c37df103d586b888708c (patch)
treecc86d1ea11b684403ab603c97afc09f47621408c /avahi-daemon
parent5622a8298f55b77a7bd202f6f2d7cd6d9a622eef (diff)
add new D-Bus API function SetHostName to change the host name of the running avahi daemon
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1260 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-daemon')
-rw-r--r--avahi-daemon/Server.introspect3
-rw-r--r--avahi-daemon/dbus-protocol.c17
2 files changed, 19 insertions, 1 deletions
diff --git a/avahi-daemon/Server.introspect b/avahi-daemon/Server.introspect
index 6635618..9d743ba 100644
--- a/avahi-daemon/Server.introspect
+++ b/avahi-daemon/Server.introspect
@@ -44,6 +44,9 @@
<method name="GetHostName">
<arg name="name" type="s" direction="out"/>
</method>
+ <method name="SetHostName">
+ <arg name="name" type="s" direction="in"/>
+ </method>
<method name="GetHostNameFqdn">
<arg name="name" type="s" direction="out"/>
</method>
diff --git a/avahi-daemon/dbus-protocol.c b/avahi-daemon/dbus-protocol.c
index 55fe3e4..4fb58d2 100644
--- a/avahi-daemon/dbus-protocol.c
+++ b/avahi-daemon/dbus-protocol.c
@@ -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)) {