diff options
author | Lennart Poettering <lennart@poettering.net> | 2005-07-30 14:03:22 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2005-07-30 14:03:22 +0000 |
commit | 3c4e0db3a35b851398eac7c598009e42e3ea7843 (patch) | |
tree | 07c39a10d0e53a46437b71fda31331af5c369f88 | |
parent | 5b5d01cabfcca8cd50d053aa56714cb0eb2f611e (diff) |
* 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
-rw-r--r-- | avahi-daemon/DBUS-API | 4 | ||||
-rw-r--r-- | avahi-daemon/Makefile.am | 7 | ||||
-rw-r--r-- | avahi-daemon/Server.introspect | 115 | ||||
-rw-r--r-- | avahi-daemon/dbus-protocol.c | 14 | ||||
-rw-r--r-- | avahi-daemon/embedd-file.py | 56 | ||||
-rw-r--r-- | avahi-daemon/introspect.dtd | 37 | ||||
-rw-r--r-- | avahi-daemon/main.c | 1 |
7 files changed, 230 insertions, 4 deletions
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 @@ +<?xml version="1.0" standalone='no'?><!--*-nxml-*--> +<!DOCTYPE node SYSTEM "introspect.dtd"> +<node> + + <!-- $Id$ --> + + <interface name="org.freedesktop.Avahi.Server"> + + <method name="GetVersionString"> + <arg name="version" type="s" direction="out"/> + </method> + + <method name="GetHostName"> + <arg name="name" type="s" direction="out"/> + </method> + <method name="GetHostNameFqdn"> + <arg name="name" type="s" direction="out"/> + </method> + <method name="GetDomainName"> + <arg name="name" type="s" direction="out"/> + </method> + + <method name="GetState"> + <arg name="state" type="i" direction="out"/> + </method> + <signal name="StateChanged"> + <arg name="state" type="i"/> + </signal> + + <method name="GetAlternativeHostName"> + <arg name="name" type="s" direction="in"/> + <arg name="name" type="s" direction="out"/> + </method> + <method name="GetAlternativeServiceName"> + <arg name="name" type="s" direction="in"/> + <arg name="name" type="s" direction="out"/> + </method> + + <method name="ResolveHostName"> + <arg name="interface" type="i" direction="in"/> + <arg name="protocol" type="i" direction="in"/> + <arg name="name" type="s" direction="in"/> + <arg name="aprotocol" type="i" direction="in"/> + + <arg name="interface" type="i" direction="out"/> + <arg name="protocol" type="i" direction="out"/> + <arg name="name" type="s" direction="out"/> + <arg name="aprotocol" type="i" direction="out"/> + <arg name="address" type="s" direction="out"/> + </method> + + <method name="ResolveAddress"> + <arg name="interface" type="i" direction="in"/> + <arg name="protocol" type="i" direction="in"/> + <arg name="address" type="s" direction="in"/> + + <arg name="interface" type="i" direction="out"/> + <arg name="protocol" type="i" direction="out"/> + <arg name="aprotocol" type="i" direction="out"/> + <arg name="address" type="s" direction="out"/> + <arg name="name" type="s" direction="out"/> + </method> + + <method name="ResolveService"> + <arg name="interface" type="i" direction="in"/> + <arg name="protocol" type="i" direction="in"/> + <arg name="name" type="s" direction="in"/> + <arg name="type" type="s" direction="in"/> + <arg name="domain" type="s" direction="in"/> + <arg name="aprotocol" type="i" direction="in"/> + + <arg name="interface" type="i" direction="out"/> + <arg name="protocol" type="i" direction="out"/> + <arg name="name" type="s" direction="out"/> + <arg name="type" type="s" direction="out"/> + <arg name="domain" type="s" direction="out"/> + <arg name="host" type="s" direction="out"/> + <arg name="aprotocol" type="i" direction="out"/> + <arg name="address" type="s" direction="out"/> + <arg name="port" type="q" direction="out"/> + <arg name="txt" type="as" direction="out"/> + </method> + + <method name="EntryGroupNew"> + <arg name="path" type="o" direction="out"/> + </method> + + <method name="DomainBrowserNew"> + <arg name="interface" type="i" direction="in"/> + <arg name="protocol" type="i" direction="in"/> + <arg name="domain" type="s" direction="in"/> + <arg name="btype" type="i" direction="in"/> + + <arg name="path" type="o" direction="out"/> + </method> + + <method name="ServiceTypeBrowserNew"> + <arg name="interface" type="i" direction="in"/> + <arg name="protocol" type="i" direction="in"/> + <arg name="domain" type="s" direction="in"/> + + <arg name="path" type="o" direction="out"/> + </method> + + <method name="ServiceBrowserNew"> + <arg name="interface" type="i" direction="in"/> + <arg name="protocol" type="i" direction="in"/> + <arg name="type" type="s" direction="in"/> + <arg name="domain" type="s" direction="in"/> + + <arg name="path" type="o" direction="out"/> + </method> + + </interface> +</node> 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] <file> <symbol>" % 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 @@ +<!-- DTD for D-BUS Introspection data --> +<!-- (C) 2005-02-02 David A. Wheeler; released under the D-BUS licenses, + GNU GPL version 2 (or greater) and AFL 1.1 (or greater) --> + +<!-- see D-BUS specification for documentation --> + +<!ELEMENT node (node*,interface,(node|interface)*)> +<!ATTLIST node name CDATA #IMPLIED> + +<!ELEMENT interface (method|signal|property|annotation)*> +<!ATTLIST interface name CDATA #REQUIRED> + +<!ELEMENT method (arg|annotation)*> +<!ATTLIST method name CDATA #REQUIRED> + +<!ELEMENT signal (arg|annotation)*> +<!ATTLIST signal name CDATA #REQUIRED> + +<!ELEMENT arg EMPTY> +<!ATTLIST arg name CDATA #IMPLIED> +<!ATTLIST arg type CDATA #REQUIRED> +<!-- Method arguments SHOULD include "direction", + while signal and error arguments SHOULD not (since there's no point). + The DTD format can't express that subtlety. --> +<!ATTLIST arg direction (in|out) "in"> + +<!-- AKA "attribute" --> +<!ELEMENT property (annotation)*> +<!ATTLIST property name CDATA #REQUIRED> +<!ATTLIST property type CDATA #REQUIRED> +<!ATTLIST property access (read|write|readwrite) #REQUIRED> + +<!ELEMENT annotation EMPTY> <!-- Generic metadata --> +<!ATTLIST annotation name CDATA #REQUIRED> +<!ATTLIST annotation value CDATA #REQUIRED> + + 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 <grp.h> #include <pwd.h> #include <sys/stat.h> +#include <stdio.h> #include <libdaemon/dfork.h> #include <libdaemon/dsignal.h> |