From 3c4e0db3a35b851398eac7c598009e42e3ea7843 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 30 Jul 2005 14:03:22 +0000 Subject: [PATCH] * hide generate init scripts from SVN * DBUS: implement introspection for Server object * fix avahi-daemon build (missing stdio.h inclusion) git-svn-id: file:///home/lennart/svn/public/avahi/trunk@199 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- avahi-daemon/DBUS-API | 4 +- avahi-daemon/Makefile.am | 7 +- avahi-daemon/Server.introspect | 115 +++++++++++++++++++++++++++++++++ avahi-daemon/dbus-protocol.c | 14 +++- avahi-daemon/embedd-file.py | 56 ++++++++++++++++ avahi-daemon/introspect.dtd | 37 +++++++++++ avahi-daemon/main.c | 1 + 7 files changed, 230 insertions(+), 4 deletions(-) create mode 100644 avahi-daemon/Server.introspect create mode 100644 avahi-daemon/embedd-file.py create mode 100644 avahi-daemon/introspect.dtd diff --git a/avahi-daemon/DBUS-API b/avahi-daemon/DBUS-API index c10a7e3..ff3cc78 100644 --- a/avahi-daemon/DBUS-API +++ b/avahi-daemon/DBUS-API @@ -8,8 +8,8 @@ org.freedesktop.Avahi.Server -- Accessible through /org/freedeskto 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, int32 aprotocol, string address] ResolveHostName(int32 interface, int32 protocol, string name, int32 aprotocol) + [int32 interface, int32 protocol, int32 aprotocol, string address, string 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) path EntryGroupNew() -- Creates a new org.freedesktop.Avahi.EntryGroup object path DomainBrowserNew(int32 interface, int32 protocol, string domain, int32 btype) diff --git a/avahi-daemon/Makefile.am b/avahi-daemon/Makefile.am index ed231a6..f152984 100644 --- a/avahi-daemon/Makefile.am +++ b/avahi-daemon/Makefile.am @@ -63,7 +63,8 @@ service_DATA = \ pkgdata_DATA = \ avahi-service.dtd -EXTRA_DIST = avahi-service.dtd avahi-daemon.conf example.service dbus-test.py +EXTRA_DIST = avahi-service.dtd avahi-daemon.conf example.service dbus-test.py Server.introspect server-introspect-xml.c +BUILT_SOURCES = server-introspect-xml.c if ENABLE_DBUS avahi_daemon_SOURCES += dbus-protocol.c dbus-protocol.h @@ -80,3 +81,7 @@ avahi_daemon_LDADD = $(AM_LDADD) ../avahi-core/libavahi-core.la ../avahi-common/ xmllint: xmllint --noout --valid example.service xmllint --noout --valid Server.introspect + xmllint --noout --valid EntryGroup.introspect + +server-introspect-xml.c: Server.introspect + python embedd-file.py -s $< server_introspect_xml > $@ diff --git a/avahi-daemon/Server.introspect b/avahi-daemon/Server.introspect new file mode 100644 index 0000000..274c1c8 --- /dev/null +++ b/avahi-daemon/Server.introspect @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/avahi-daemon/dbus-protocol.c b/avahi-daemon/dbus-protocol.c index 4e67281..b5c3e9a 100644 --- a/avahi-daemon/dbus-protocol.c +++ b/avahi-daemon/dbus-protocol.c @@ -38,6 +38,9 @@ #include "dbus-protocol.h" #include "main.h" +/* Include generated introspection data */ +#include "server-introspect-xml.c" + typedef struct Server Server; typedef struct Client Client; typedef struct EntryGroupInfo EntryGroupInfo; @@ -873,7 +876,16 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void dbus_message_get_path(m), dbus_message_get_member(m)); - if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetHostName")) { + if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) { + + if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { + avahi_log_warn("Error parsing Introspect message"); + goto fail; + } + + return respond_string(c, m, server_introspect_xml); + + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetHostName")) { if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { avahi_log_warn("Error parsing Server::GetHostName message"); diff --git a/avahi-daemon/embedd-file.py b/avahi-daemon/embedd-file.py new file mode 100644 index 0000000..eaa250f --- /dev/null +++ b/avahi-daemon/embedd-file.py @@ -0,0 +1,56 @@ +#!/usr/bin/python + +import os, sys + +def usage(ret = 0): + print "%s [-s] " % sys.argv[0] + sys.exit(ret) + +args = sys.argv[1:] + +use_static = False + +if len(args) >= 1 and args[0] == '-s': + use_static = True + args = args[1:] + +if len(args) >= 1 and args[0] == '-h': + usage() + +if len(args) != 2: + sys.stderr("Wrong number of arguments") + usage(1) + +f = file(args[0]) +t = f.read() +f.close() + +out = sys.stdout + +if use_static: + out.write("static ") + +out.write('const char %s[] = \n"' % args[1]); + +n = 0 + +for c in t: + if c == '\n': + out.write('\\n"\n"') + n = 0 + elif c == '"': + out.write('\\"') + n += 2 + elif ord(c) < 32 or ord(c) >= 127: + out.write('\\x%02x' % ord(c)) + n += 4 + else: + out.write(c) + n += 1 + + if n >= 76: + out.write('"\n"') + n = 0 + +out.write('";\n'); + diff --git a/avahi-daemon/introspect.dtd b/avahi-daemon/introspect.dtd new file mode 100644 index 0000000..4ed0dc0 --- /dev/null +++ b/avahi-daemon/introspect.dtd @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/avahi-daemon/main.c b/avahi-daemon/main.c index 059ebe5..e5f3070 100644 --- a/avahi-daemon/main.c +++ b/avahi-daemon/main.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include -- 2.39.5