Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Handling delayed dbus method
QtWS25 Last Chance

Handling delayed dbus method

Scheduled Pinned Locked Moved Solved General and Desktop
dbusdelayed methodqvariantqmlextpluginerror
2 Posts 1 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    blacky_i
    wrote on last edited by
    #1

    Hello everyone!

    I am developing dbus api and encontered with this, How to handle delayed dbus call? I have daemon app which is handling dbus requests and share plugin qml extension which is sending dbus method call to daemon app.

    I followed this tutorial to create delayed method. After that I request some data from internet. Here is code:

    //Creating delayed message
    QVariant DBusAdaptor::getChatList(const int offset, const QDBusMessage &message)
    {
        m_delayedList.append(RequestData());
        message.setDelayedReply(true);
        m_delayedList.last().reply = message.createReply();
        QDBusConnection::sessionBus().send(m_delayedList.last().reply);
        tdlibJson->getChats(0,
                            std::numeric_limits<std::int64_t>::max(),
                            5,
                            c_extraName);
    
        return QVariant();
    }
    //Sending delayed message with data
    void DBusAdaptor::sendChatList()
    {
        QDBusMessage reply = m_delayedList.last().reply;
        qDebug() << m_chats[0];
        reply << m_chats[0] << m_chats[1];
        QDBusConnection::sessionBus().send(reply);
        m_delayedList.removeLast();
        m_chatIds.clear();
        m_chats.clear();
    }
    
    //Filling list with data which will be send over dbus.
    void DBusAdaptor::addChatItem(const QJsonObject &chatObject)
    {
        if (chatObject.keys().contains("@extra"))
            if (chatObject["@extra"].toString() == c_extraName)
                m_chats.append(chatObject.toVariantMap());
        qDebug() << m_chats.size() << m_chatIds.size();
        if (m_chats.size() == m_chatIds.size())
            emit sendData();
    }
    

    In etension plugin I use this code:

        QDBusPendingCall async = remoteAppIface->asyncCall(c_dbusMethod, 0);
        dbusWatcher = new QDBusPendingCallWatcher(async, this);
        connect(dbusWatcher, &QDBusPendingCallWatcher::finished,
        [this](QDBusPendingCallWatcher * call) {
            QDBusPendingReply<QString, QByteArray> reply = *call;
            if (reply.isError())
                qDebug() << reply.error();
            else
                qDebug() << reply.argumentAt<0>();
            call->deleteLater();
        });
    

    And I can't get data from method, all I get is emptyness with error message:

    QDBusError("org.freedesktop.DBus.Error.InvalidSignature","Unexpected reply signature: got \"\", expected \"say\"")
    

    I assume that handling delayed methods are different, but can't find any examples. Is there on internet any examples of this? Or There is an error in code?

    Thanks in advance

    1 Reply Last reply
    0
    • B Offline
      B Offline
      blacky_i
      wrote on last edited by
      #2

      I've solved it.

      To handle long I did not have to send immediately reply (even though tutorial said that we have to). And delayed reply will be send.

      Also in extension, QDBusPendingReply<QString, QByteArray> reply = *call; setting expecting signature to \"say\" and not looking to xml interface.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved