From 522fb5c25acf2af440e5203e41d07f5fc97ad0a6 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 29 Jul 2005 20:32:07 +0000 Subject: * add avahi-publish * avahi-dump-all: allow user to specify domain to browse * DBUS: implement new methods Server.GetState(), Server.GetAlternativeHostName(), Server.GetAlternativeServiceName() * Add dbust-test.py to EXTRA_DIST * doc fix for alternative.h git-svn-id: file:///home/lennart/svn/public/avahi/trunk@192 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- avahi-daemon/DBUS-API | 3 +++ avahi-daemon/Makefile.am | 3 +-- avahi-daemon/dbus-protocol.c | 52 +++++++++++++++++++++++++++++++++++++++++--- avahi-daemon/dbus-test.py | 4 ++++ 4 files changed, 57 insertions(+), 5 deletions(-) (limited to 'avahi-daemon') diff --git a/avahi-daemon/DBUS-API b/avahi-daemon/DBUS-API index 5acee5f..c10a7e3 100644 --- a/avahi-daemon/DBUS-API +++ b/avahi-daemon/DBUS-API @@ -5,6 +5,9 @@ org.freedesktop.Avahi.Server -- Accessible through /org/freedeskto string GetHostNameFqdn() string GetDomainName() string GetVersionString() + int32 GetState() + string GetAlternativeHostName(string name) + string GetAlternativeServiceName(string name) [int32 interface, int32 protocol, string host_name, int32 aprotocol, string address] ResolveHostName(int32 interface, int32 protocol, string name, int32 aprotocol) [int32 interface, int32 protocol, int32 aprotocol, string address, string host_name] ResolveAddress(int32 interface, int32 protocol, string address) [int32 interface, int32 protocol, string name, string type, string domain, string host, int32 aprotocol, string address, uint16 port, string txt[]] ResolveService(int32 interface, int32 protocol, string name, string type, string domain, int32 aprotocol) diff --git a/avahi-daemon/Makefile.am b/avahi-daemon/Makefile.am index f746a49..a1b2dcb 100644 --- a/avahi-daemon/Makefile.am +++ b/avahi-daemon/Makefile.am @@ -27,7 +27,6 @@ AM_CFLAGS= \ -DAVAHI_SERVICE_DIRECTORY=\"$(servicedir)\" \ -DAVAHI_CONFIG_FILE=\"$(pkgsysconfdir)/avahi-daemon.conf\" - AM_LDADD=-lexpat # GLIB 2.0 @@ -64,7 +63,7 @@ service_DATA = \ pkgdata_DATA = \ avahi-service.dtd -EXTRA_DIST = avahi-service.dtd avahi-daemon.conf example.service +EXTRA_DIST = avahi-service.dtd avahi-daemon.conf example.service dbus-test.py if ENABLE_DBUS avahi_daemon_SOURCES += dbus-protocol.c dbus-protocol.h diff --git a/avahi-daemon/dbus-protocol.c b/avahi-daemon/dbus-protocol.c index f2d34d1..4e67281 100644 --- a/avahi-daemon/dbus-protocol.c +++ b/avahi-daemon/dbus-protocol.c @@ -882,7 +882,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void return respond_string(c, m, avahi_server_get_host_name(avahi_server)); - } if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetDomainName")) { + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetDomainName")) { if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { avahi_log_warn("Error parsing Server::GetDomainName message"); @@ -891,7 +891,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void return respond_string(c, m, avahi_server_get_domain_name(avahi_server)); - } if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetHostNameFqdn")) { + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetHostNameFqdn")) { if (!(dbus_message_get_args(m, &error, DBUS_TYPE_INVALID))) { avahi_log_warn("Error parsing Server::GetHostNameFqdn message"); @@ -900,7 +900,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void return respond_string(c, m, avahi_server_get_host_name_fqdn(avahi_server)); - } if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetVersionString")) { + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetVersionString")) { if (!(dbus_message_get_args(m, &error, DBUS_TYPE_INVALID))) { avahi_log_warn("Error parsing Server::GetVersionString message"); @@ -908,6 +908,52 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void } return respond_string(c, m, PACKAGE_STRING); + + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetState")) { + DBusMessage *reply; + gint32 s; + + if (!(dbus_message_get_args(m, &error, DBUS_TYPE_INVALID))) { + avahi_log_warn("Error parsing Server::GetState message"); + goto fail; + } + + s = (gint32) avahi_server_get_state(avahi_server); + + reply = dbus_message_new_method_return(m); + dbus_message_append_args(reply, DBUS_TYPE_INT32, &s, DBUS_TYPE_INVALID); + dbus_connection_send(c, reply, NULL); + dbus_message_unref(reply); + + return DBUS_HANDLER_RESULT_HANDLED; + + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetAlternativeHostName")) { + gchar *n, * t; + + if (!(dbus_message_get_args(m, &error, DBUS_TYPE_STRING, &n, DBUS_TYPE_INVALID)) || !n || !*n) { + avahi_log_warn("Error parsing Server::GetAlternativeHostName message"); + goto fail; + } + + t = avahi_alternative_host_name(n); + respond_string(c, m, t); + g_free(t); + + return DBUS_HANDLER_RESULT_HANDLED; + + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetAlternativeServiceName")) { + gchar *n, *t; + + if (!(dbus_message_get_args(m, &error, DBUS_TYPE_STRING, &n, DBUS_TYPE_INVALID)) || !n || !*n) { + avahi_log_warn("Error parsing Server::GetAlternativeServiceName message"); + goto fail; + } + + t = avahi_alternative_service_name(n); + respond_string(c, m, t); + g_free(t); + + return DBUS_HANDLER_RESULT_HANDLED; } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "EntryGroupNew")) { Client *client; diff --git a/avahi-daemon/dbus-test.py b/avahi-daemon/dbus-test.py index 3cbe19c..baebf40 100755 --- a/avahi-daemon/dbus-test.py +++ b/avahi-daemon/dbus-test.py @@ -22,6 +22,10 @@ print server.ResolveAddress(0, 0, "192.168.50.4") print "Host name: %s" % server.GetHostName() print "Domain name: %s" % server.GetDomainName() print "FQDN: %s" % server.GetHostNameFqdn() +print "State: %i" % server.GetState() + +print server.GetAlternativeHostName("gurkiman10") +print server.GetAlternativeServiceName("Ahuga Service") def entry_group_state_changed_callback(t): print "EntryGroup::StateChanged: ", t -- cgit