[xpcom] Add support for sending variants (no autoconversion, just by signature)
[browser-dbus-bridge.git] / xpcom-dbusservice / DBusMarshaling.cpp
index c95a41d39b1d07bd93368e34af3ddbf2c457f2cc..ae0f13313b66b3f5ecc8f0abccb349b479966d2f 100644 (file)
@@ -596,6 +596,25 @@ addVariantToIter(JSContext* cx, nsIVariant *aVariant, DBusMessageIter *aIter, DB
 
         }
     }
+    else if (element_type == DBUS_TYPE_VARIANT)
+    {
+        BDBLOG(("  add variant from variant\n"));
+
+        nsCAutoString variantSignature;
+        getSignatureFromVariant(cx, aVariant, variantSignature);
+
+        BDBLOG(("  variant sig: %s\n", variantSignature.get()));
+
+        DBusSignatureIter aChildSigIter;
+        dbus_signature_iter_init(&aChildSigIter, variantSignature.get());
+
+        DBusMessageIter variantIter;
+        dbus_message_iter_open_container(aIter, DBUS_TYPE_VARIANT,
+                                         variantSignature.get(), &variantIter);
+        addVariantToIter(cx, aVariant, &variantIter, &aChildSigIter);
+        dbus_message_iter_close_container(aIter, &variantIter);
+
+    }
     else if (element_type == DBUS_TYPE_STRUCT)
     {
         BDBLOG(("  add struct from variant\n"));