]> git.meshlink.io Git - catta/commitdiff
* hide generate init scripts from SVN
authorLennart Poettering <lennart@poettering.net>
Sat, 30 Jul 2005 14:03:22 +0000 (14:03 +0000)
committerLennart Poettering <lennart@poettering.net>
Sat, 30 Jul 2005 14:03:22 +0000 (14:03 +0000)
* 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
avahi-daemon/Makefile.am
avahi-daemon/Server.introspect [new file with mode: 0644]
avahi-daemon/dbus-protocol.c
avahi-daemon/embedd-file.py [new file with mode: 0644]
avahi-daemon/introspect.dtd [new file with mode: 0644]
avahi-daemon/main.c

index c10a7e31c277ac266f481fe0e01ae3e5e4293eb3..ff3cc7896a98722403e699ec5a86205082f6fee8 100644 (file)
@@ -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)
index ed231a6b76293ad6945271707a64f16cdf50c5d7..f1529840adf62ea649d965c4e9d7a94a3ac45f3a 100644 (file)
@@ -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 (file)
index 0000000..274c1c8
--- /dev/null
@@ -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>
index 4e67281da57c2a14f8e60eb1386184cd77793851..b5c3e9a349bdf06836dfda8a056236d35deb023f 100644 (file)
@@ -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 (file)
index 0000000..eaa250f
--- /dev/null
@@ -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 (file)
index 0000000..4ed0dc0
--- /dev/null
@@ -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>
+
+
index 059ebe5e44fa5bcaa6fe8bfcc8998760d4b022f8..e5f307079b45a71dc2f9155b4d404bf3896f767c 100644 (file)
@@ -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>