Help with QDBusPendingCall
Hi!
I tried to call this method with Qt using QDBusPendingCall, but I always receive an error in the reply.
The message I'm trying to call is this:
Code:
method call sender=:1.50 -> dest=org.freedesktop.Tracker serial=5264 path=/org/freedesktop/Tracker/Metadata; interface=org.freedesktop.Tracker.Metadata; member=GetUniqueValuesWithAggregates
string "Music"
array [
string "Audio:Artist"
]
string ""
array [
string "SUM"
string "COUNT"
string "COUNT"
string "CONCAT"
]
array [
string "Audio:Duration"
string "Audio:Album"
string "*"
string "Audio:Album"
]
boolean false
int32 0
int32 10
And this is the reply I should receive:
Code:
method return sender=:1.1317 -> dest=:1.50 reply_serial=5264
array [
array [
string "Affinity"
string "4307"
string "1"
string "15"
string "Affinity"
]
array [
string "Alanis Morissette"
string "3645"
string "1"
string "13"
string "Jagged Little Pill"
]
array [
string "Al Di Meola"
string "2312"
string "1"
string "6"
string "Casino"
]
...
]
I tried to use this code, but as I said I always receive an error (reply.isError() is true):
Code:
void MafwHelper::GetCatalog(QString aggregate, int index, int count)
{
#ifdef Q_WS_MAEMO_5
QDBusConnection conn = QDBusConnection::sessionBus();
QDBusInterface device("org.freedesktop.Tracker",
"/org/freedesktop/Tracker/Metadata", "org.freedesktop.Tracker.Metadata", conn);
QStringList par1 = QStringList() << aggregate;
QStringList par2 = QStringList() << "SUM" << "COUNT" << "COUNT" << "CONCAT";
QStringList par3 = QStringList() << "Audio:Duration" << "Audio:Album" << "*" << "Audio:Album";
qDebug() << "DBusMessage: GetUniqueValuesWithAggregates";
QDBusPendingCall pcall = device.asyncCall("GetUniqueValuesWithAggregates",
"Music", par1, "",
par2, par3, false, index, count);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall, this);
connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
this, SLOT(GetCatalogFinishedSlot(QDBusPendingCallWatcher*)));
#endif
}
#ifdef Q_WS_MAEMO_5
void MafwHelper::GetCatalogFinishedSlot(QDBusPendingCallWatcher* call)
{
QDBusPendingReply<QDBusVariant> reply = *call;
if (reply.isError()) {
qWarning() << "QDBusPendingReply error";
} else {
for(int i=0; i<reply.count(); i++){
QVariant val = qvariant_cast<QDBusVariant>(reply.argumentAt(i)).variant();
qDebug() << val;
}
}
call->deleteLater();
}
#endif
Can someone point me in the right direction? :)
I'm not even sure that a QStringList parameter is correct for the array in dbusmessage...
Many thanks
|