我正在尝试使用Qt的QDBus类库调用WPA请求者的DBus接口.特别是,我正在尝试使用"Get"属性调用来检索"Interfaces"属性值.
"获取"的DBus规范(通过内省)是:
<interface name="org.freedesktop.DBus.Properties">
<method name="Get">
<arg name="interface" type="s" direction="in"/>
<arg name="propname" type="s" direction="in"/>
<arg name="value" type="v" direction="out"/>
</method>
...
</interface>
Run Code Online (Sandbox Code Playgroud)
看起来很简单.输入两个字符串,输出是变量(这些是DBus类型).对于"Interfaces"属性,我期望变量是一个对象路径数组(DBus类型"ao").
我QDBusInterface::call()用来调用DBus方法,它返回一个QDBusMessage,但我无法弄清楚如何从中提取数据.
QDBusMessage::arguments()返回一个QList<QVariant>.为了找到我的对象路径数组,我尝试了对此列表中项目的各种转换,但我似乎最终得到了一个空字符串.
QVariant::type()看起来它应该有所帮助,但它似乎只返回类型QDBusMessage,这显然是错误的.例如:
// 'message' is of type QDBusMessage
qDebug() << "Argument 0 type is" << message.arguments().at(0).type();
Run Code Online (Sandbox Code Playgroud)
打印:
Argument 0 type is QVariant::QDBusMessage
Run Code Online (Sandbox Code Playgroud)
如何提取实际的消息数据?