[html] Add conversion methods using carriers to XPCOM wrapper
authorKalle Vahlman <kalle.vahlman@movial.com>
Wed, 29 Apr 2009 10:26:59 +0000 (13:26 +0300)
committerKalle Vahlman <kalle.vahlman@movial.com>
Wed, 29 Apr 2009 10:26:59 +0000 (13:26 +0300)
html/dbus.js

index 35fcf136fd208b8baddd6c4e81476b4fb14f5e79..f2021840d7b4b35cfe6240a1d6b1467de99eed05 100644 (file)
@@ -98,13 +98,40 @@ if (!window.DBus)
             }
         }
 
-        /* TODO: These need their own XPCOM types/handling:
-       - ObjectPath
-       - Signature
-       - Variant?
-       - Struct?
-         */
+    };
+
+    // Methods for non-variant and non-automatic type conversions
+    window.DBus.prototype.Signature = function(val) {
+      ep("UniversalXPConnect");
+      var carrier = cc["@movial.fi/dbus/datacarrier;1"].createInstance(ci.IDBusDataCarrier);
+      carrier.type = "g";
+      carrier.value = val;
+      return carrier;
+    };
+
+    window.DBus.prototype.ObjectPath = function(val) {
+      ep("UniversalXPConnect");
+      var carrier = cc["@movial.fi/dbus/datacarrier;1"].createInstance(ci.IDBusDataCarrier);
+      carrier.type = "o";
+      carrier.value = val;
+      return carrier;
+    };
+
+    window.DBus.prototype.Variant = function(sig, val) {
+      ep("UniversalXPConnect");
+      var carrier = cc["@movial.fi/dbus/datacarrier;1"].createInstance(ci.IDBusDataCarrier);
+      carrier.type = "v";
+      carrier.signature = sig;
+      carrier.value = val;
+      return carrier;
+    };
 
+    window.DBus.prototype.Struct = function(val) {
+      ep("UniversalXPConnect");
+      var carrier = cc["@movial.fi/dbus/datacarrier;1"].createInstance(ci.IDBusDataCarrier);
+      carrier.type = "r";
+      carrier.value = val;
+      return carrier;
     };
 
     // Bridge API: dbus.getMethod()