Thread: [SailfishOS+Harmattan] QDBusConnection: receive/send message
View Single Post
Posts: 133 | Thanked: 405 times | Joined on Mar 2012 @ Europe
#1
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
   array [
      array [
         dict entry(            string "pending-message-id"
            variant                uint32 0
         )
         dict entry(
            string "message-sender-id"            
            variant                string "XXX@jabberes.org"
         )
         dict entry(
            string "message-received"
            variant                int64 1440523701    
         )
         dict entry(
            string "message-sender"
            variant                uint32 33
         )      ]
      array [
         dict entry(
            string "content"
            variant                string "Message content" 
          )
         dict entry(
            string "content-type"
            variant                string "text/plain"
         )      ]
   ]
So I wrote the following Qt-Code to connect to this event:

Code:
QDBusConnection::sessionBus().connect(QString(), 
    QString(),
     "org.freedesktop.Telepathy.Channel.Interface.Messages",
     "MessageReceived", this, 
     SLOT(telepathyMessageReceived(QList<QVariant>)));
It works fine and my SLOT will be called on incoming messages:

Code:
void ImControlThread::telepathyMessageReceived(QList<QVariant> _content)
{
    qDebug() << "ImControlThread::telepathyMessageReceived(): size=" << _content.size() << ". Variant=" << _content.at(0).typeName();
}
I have there a QList<QVariant>. The QVariant-Objects must be a QList again with some QVariantMap entries.
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!

Last edited by chrm; 2015-09-05 at 19:15.
 

The Following User Says Thank You to chrm For This Useful Post: