chiark / gitweb /
bus: add support for serializing to gvariant
[elogind.git] / src / libsystemd-bus / bus-introspect.c
index 92deb75..115b3ce 100644 (file)
@@ -24,6 +24,7 @@
 #include "bus-introspect.h"
 #include "bus-signature.h"
 #include "bus-internal.h"
+#include "bus-protocol.h"
 
 int introspect_begin(struct introspect *i) {
         assert(i);
@@ -34,7 +35,7 @@ int introspect_begin(struct introspect *i) {
         if (!i->f)
                 return -ENOMEM;
 
-        fputs(SD_BUS_INTROSPECT_DOCTYPE
+        fputs(BUS_INTROSPECT_DOCTYPE
               "<node>\n", i->f);
 
         return 0;
@@ -43,12 +44,12 @@ int introspect_begin(struct introspect *i) {
 int introspect_write_default_interfaces(struct introspect *i, bool object_manager) {
         assert(i);
 
-        fputs(SD_BUS_INTROSPECT_INTERFACE_PEER
-              SD_BUS_INTROSPECT_INTERFACE_INTROSPECTABLE
-              SD_BUS_INTROSPECT_INTERFACE_PROPERTIES, i->f);
+        fputs(BUS_INTROSPECT_INTERFACE_PEER
+              BUS_INTROSPECT_INTERFACE_INTROSPECTABLE
+              BUS_INTROSPECT_INTERFACE_PROPERTIES, i->f);
 
         if (object_manager)
-                fputs(SD_BUS_INTROSPECT_INTERFACE_OBJECT_MANAGER, i->f);
+                fputs(BUS_INTROSPECT_INTERFACE_OBJECT_MANAGER, i->f);
 
         return 0;
 }
@@ -63,7 +64,7 @@ int introspect_write_child_nodes(struct introspect *i, Set *s, const char *prefi
                 const char *e;
 
                 e = object_path_startswith(node, prefix);
-                if (e)
+                if (e && e[0])
                         fprintf(i->f, " <node name=\"%s\"/>\n", e);
 
                 free(node);
@@ -111,13 +112,10 @@ static int introspect_write_arguments(struct introspect *i, const char *signatur
         }
 }
 
-int introspect_write_interface(struct introspect *i, const char *interface, const sd_bus_vtable *v) {
+int introspect_write_interface(struct introspect *i, const sd_bus_vtable *v) {
         assert(i);
-        assert(interface);
         assert(v);
 
-        fprintf(i->f, " <interface name=\"%s\">\n", interface);
-
         for (; v->type != _SD_BUS_VTABLE_END; v++) {
 
                 switch (v->type) {
@@ -155,7 +153,6 @@ int introspect_write_interface(struct introspect *i, const char *interface, cons
 
         }
 
-        fputs(" </interface>\n", i->f);
         return 0;
 }
 
@@ -173,7 +170,7 @@ int introspect_finish(struct introspect *i, sd_bus *bus, sd_bus_message *m, sd_b
         if (ferror(i->f))
                 return -ENOMEM;
 
-        r = sd_bus_message_new_method_return(bus, m, &q);
+        r = sd_bus_message_new_method_return(m, &q);
         if (r < 0)
                 return r;