stefano-m / lua-dbus_proxy

Simple API around GLib's GIO:GDBusProxy built on top of lgi
https://stefano-m.github.io/lua-dbus_proxy/
Apache License 2.0
17 stars 7 forks source link

can't call method declared as a{sv} #10

Closed telent closed 2 years ago

telent commented 2 years ago

This may well just be my lack of understanding of DBus. I'm trying to make a voice call using ModemManager, but not getting very far. I pass it {Number = "+15005550002"} and it reports an error

/nix/store/q7h8zgwc4zc59351gzjyj8hcik81w1bs-lua-5.3.6/bin/lua: ...ua-5.3.6-env/share/lua/5.3/lgi/override/GLib-Variant.lua:111: bad argument #2 to 'new_variant' (GLib.Variant expected, got string).

I also tried voice():CreateCall({Number = GV("s","+15005550002")}) but that gives me (GLib.Variant expected, got userdata)

What am I doing wrong? All help gratefully received

Here's the full script, though I don't know if you'll need a modem installed to replicate it.

local lgi = require("lgi")
local dbus = require("dbus_proxy")
local GLib = lgi.GLib
local GV = lgi.GLib.VariantType
local modem_manager = (dbus.Proxy):new({bus = dbus.Bus.SYSTEM, name = "org.freedesktop.ModemManager1", interface = "org.freedesktop.DBus.ObjectManager", path = "/org/freedesktop/ModemManager1"})

local function voice()
  return (dbus.Proxy):new({bus = dbus.Bus.SYSTEM, name = "org.freedesktop.ModemManager1", interface = "org.freedesktop.ModemManager1.Modem.Voice", path = next(modem_manager:GetManagedObjects())})
end

voice():CreateCall({Number = "+15005550002"})

PS not a real phone number, it comes from https://www.twilio.com/docs/iam/test-credentials#test-calls

telent commented 2 years ago

local GV = lgi.GLib.VariantType

This is wrong, should be lgi.GLib.Variant

stefano-m commented 2 years ago

Hi there, I'm not familiar with ModemManager, but you should be able to pass a value with the correct signature.

AFAICS CreateCall's signature is

CreateCall (IN  a{sv} properties,  OUT o     path);

So doing something like

local GLib = require("lgi").GLib
local GVariant = GLib.Variant

local properties = {Number = GVariant("s", "123")}

as you seem to be doing. Should work.

Having the full stack trace might help.