[Kde-hardware-devel] MMQT API - Asynchronous mode

Lamarque Souza lamarque at kde.org
Thu Jun 2 15:22:58 UTC 2016


Hi,

Jan is right, you have to use Q_OBJECT to use signals/slots in Qt.

An asynchronous pseudo code based on the example provided in MMQt source
code would look like:

SomeQWidget::someMethod()
{
ModemManager::ModemMessaging::Ptr messaging =
modemdevice->messagingInterface();

ModemManager::ModemMessaging::Message msg;
msg.number = "number";
msg.text = "message text";

QDBusReply<QString> sms = messaging->createMessage(msg);
ModemManager::Sms::Ptr tmp = messaging->findMessage(sms.value());
QDBusPendingReply<> reply = tmp->send();

// This is the important part:
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);

// This only works with Qt5:
connect(watcher, &QDBusPendingCallWatcher::finished, [reply, this]() {
    // This code run after the message has been sent.
    if (reply.isError()) {
        qDebug() << reply.error().message();
    }
});
}

Lamarque V. Souza

http://planetkde.org/pt-br

On Thu, Jun 2, 2016 at 4:35 AM, Jan Grulich <jgrulich at redhat.com> wrote:

> Hi,
>
> On pondělí 11. dubna 2016 11:11:52 CEST Charles A wrote:
> > Hi!
> > I have been using the MMQT api in order to send SMS messages.
> > I have been using MMQT version 5.2.2 and it works great! I recently found
> > an issue where the signalQuality (in ModemManager::Modem Interface) would
> > return 0 even though the signal quality returned by dbus was not 0.
> > Since then I decided to upgrade MMQT to a more recent version, I tried
> MMQT
> > 5.18.0 and my old code seem to not work at all with the MMQT 5.18.0
> > version.
>
> The API changed a bit after modemmanager-qt became a KDE framework.
>
> > After reading a bit, I stumbled upon the following bug report (
> > https://bugs.kde.org/show_bug.cgi?id=358261) and I realized I need to
> use
> > to Async mode to make it work since I was using the sync method.
> >
> > I wanted to know if there are any examples on how to use Async mode in
> > order to send an SMS message?
>
> Unfortunately there is no example for that particular case, but if you go
> through plasma-nm, there's a lot of stuff using networkmanager-qt/
> modemmanager-qt code (check src/libs/models/networkmodel.cpp).
>
> > I have been trying to use SIGNAL/SLOT method but I am not sure I am doing
> > it right. I am trying to connect to the signal without being a Q_OBJECT.
>
> I think you need to derive your class from QObject to be able to use Qt's
> signal/slot mechanism.
>
> You can also send us your code so we can take a look and help you more with
> that.
>
> > Thank you!
> > Charles
>
>
> Regards,
> Jan
> --
> Jan Grulich <jgrulich at redhat.com>
> Software Engineer, Desktop team
> Red Hat Czech
> _______________________________________________
> Kde-hardware-devel mailing list
> Kde-hardware-devel at kde.org
> https://mail.kde.org/mailman/listinfo/kde-hardware-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-hardware-devel/attachments/20160602/edc0086f/attachment.html>


More information about the Kde-hardware-devel mailing list