PDA

View Full Version : Multi output parameters with DBUS-Method



mecland
29th December 2013, 10:13
Hi all

I have a xml file as bellow:
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.example.chat">
<method name="CalcTime">
<arg name="TimeStamp" direction="out" type="i">
<doc>
<line> TimeStamp: The value of the monotonic system clock (millisecond precision) when this signal was sent out.</line>
</doc>
</arg>
<arg name="IsDaylightSaving" direction="out" type="i">
<doc>
<line> 1 is DST is currently used, 0 otherwise.</line>
</doc>
</arg>
</method>
</interface>
</node>

as the xml file, that have two parameter for output, and I using qtdbusxml2cpp got the interface file as bellow:
class OrgExampleChatInterface: public QDBusAbstractInterface
{
Q_OBJECT
public:
static inline const char *staticInterfaceName()
{ return "org.example.chat"; }

public:
OrgExampleChatInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
~OrgExampleChatInterface();

public Q_SLOTS: // METHODS
inline QDBusPendingReply<int, int> CalcTime()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QLatin1String("CalcTime"), argumentList);
}
inline QDBusReply<int> CalcTime(int &IsDaylightSaving)
{
QList<QVariant> argumentList;
QDBusMessage reply = callWithArgumentList(QDBus::Block, QLatin1String("CalcTime"), argumentList);
if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 2) {
IsDaylightSaving = qdbus_cast<int>(reply.arguments().at(1));
}
return reply;
}

Q_SIGNALS: // SIGNALS
};

namespace org {
namespace example {
typedef ::OrgExampleChatInterface chat;
}
}

I implement the method in server:
int ChatMainWindow::CalcTime(int& val)
{
val = 8;
return 1024;
}

and call it in client:
int v3;
QDBusReply<int> reply = ifc->CalcTime(v3);
qDebug() << "###########: " << reply;
qDebug() << "###########: " << v3;

but the method does'nt run in server, the client output as bellow:
###########: 151468768
###########: 0

That's have any problem? please point it, thank you.
BR,

Mecland

anda_skoa
30th December 2013, 17:23
I would suggest you run qdbusxml2cpp and let it create an Adaptor. Then you know exactly what kind of signature you are expected to implement :)

Cheers,
_

aamer4yu
31st December 2013, 12:41
What is the code in the DBus Adaptor that you created ?
Have you properly set parent for the dbus adaptor ? May be you need to show the adaptor code for the function call.