![]() |
QDBusConnection: receive/send message
Hi!
I'm working on OTR integration for Harmattans conversations UI. It should be fine by using D-Bus but I have a problem with D-Bus objects converting to Qt-Classes. But let me explain. I would like to connect to the interface "org.freedesktop.Telepathy.Channel.Interface.Messa ges" and method "MessageReceived". dbus-monitor shows this structure: Code:
signal sender=:1.606 -> dest=(null destination) serial=333 path=/org/freedesktop/Telepathy/Connection/gabble/jabber/XXX_2fnokiaN9/ImChannel33; interface=org.freedesktop.Telepathy.Channel.Interface.Messages; member=MessageReceived Code:
QDBusConnection::sessionBus().connect(QString(), Code:
void ImControlThread::telepathyMessageReceived(QList<QVariant> _content) But now, I'm out of idea. I'm just not able to parse the D-Bus structure from QList<QVariant>. The debug output in my SLOT shows for _content.size() == 2. But for _content.at(0).typeName() == "void*". No chance to cast it in something I can extract the data from. Do you have an idea? Thank you very much for any hint! |
Re: QDBusConnection: receive message
I think you will need to use QDBusMessage and QDBusArgument in order to convert the reply arguments:
Code:
void ImControlThread::telepathyMessageReceived(const QDBusMessage &reply) { |
Re: QDBusConnection: receive message
Perfect! Thank you very much!
|
Re: QDBusConnection: receive message
Dear marxian,
it works well expect for mapTypeToVariant(). Im able to extract the key name, but value is always empty. QDBusMessage &reply includes all the data (qDebug() shows everything), but Code:
map[basicTypeToVariant(arg).toString()] = busArgumentToVariant(arg); Any idea? |
Re: QDBusConnection: receive message
It could be that the QDBusArgument::currentType() of the map values is not handled in dbusArgumentToVariant(), therfore an null QVariant is returned. Try adding a qDebug() statement in that function to check the reported type:
Code:
QVariant dbusArgumentToVariant(const QDBusArgument &arg) { |
Re: QDBusConnection: receive message
Hi!
Thank you a lot! Handling for QDBusArgument::MapEntryType is needed. But now it works fine. The next step is to insert the decrypted message back in tracker so it appears in the conversations UI. Do you have any experience with the Tracker on N9? I thing, using tracker-sparql to modify the message is the right way. Thank you for any hint. |
Re: QDBusConnection: receive message
Ok, got it. I'm able to remove messages from tracker.
The next step is to insert a new message, the decrypted one. |
Re: QDBusConnection: receive/send message
Dear Marxian,
Reading received messages and changing them in tracker works fine. But I spent the last week trying to send a DBus message to Telepathy - without success :( I have to implement this method: http://telepathy.freedesktop.org/spe...Messages1.html So this is my code: Code:
QList<QVariant> args; Code:
QDBusMessage(type=Error, service="", error name="org.freedesktop.DBus.Error.UnknownMethod", error message="Method "SendMessage" with signature "osa{sv}u" on interface "org.freedesktop.Telepathy.ChannelDispatcher.Interface.Messages1" doesn't exist" I know, there are heavy libs like TelepathyQt, but i want just to send only one message and hope, this could be done with a simple code... Thank you for any hint. |
Re: QDBusConnection: receive/send message
Finally, it works!
If someone wants to know, how to send an XMMP-Message using Qt and DBus on Harmattan, here it is: First declare needed typedefs Code:
typedef QMap<QString, QVariant> KeyVarPair; Code:
qDBusRegisterMetaType<KeyVarPair>(); Code:
bool MyClass::telepathySendDBusMessage(QString _receiver, QString _account, QString _content) Code:
myClassObj->telepathySendDBusMessage( |
Re: QDBusConnection: receive/send message
Quote:
Will be your final project opensource? Wish you success! |
All times are GMT. The time now is 22:22. |
vBulletin® Version 3.8.8