maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   QMessageFilter and listening for incoming SMS doesn't work (https://talk.maemo.org/showthread.php?t=84511)

nicolai 2012-05-26 20:59

QMessageFilter and listening for incoming SMS doesn't work
 
Hi,

I try to use QMessageManager to listen for incoming
messages (SMS/InstantMessage). But I only got it
working for E-Mail. This is my code
Code:

m_manager = new QMessageManager(this);
    QObject::connect(m_manager,
        SIGNAL(messageAdded(const QMessageId&,
            const QMessageManager::NotificationFilterIdSet&)),
        this,
        SLOT(messageAdded(const QMessageId&,
            const QMessageManager::NotificationFilterIdSet&)));

    m_manager->registerNotificationFilter(
                QMessageFilter::byType(QMessage::Sms));

The messageAdded signal is never called on new messages.
I tried different filters, empty filters, filter for InstantMessage,
SMS and InstantMessage. But only the empty filter or
a filter which includes QMessage::EMail works, and only for
new emails.
Anyone got this working or any idea what I could have
missed?

nicolai

GreatGonzo 2012-05-27 12:02

Re: QMessageFilter and listening for incoming SMS doesn't work
 
This works from me.

Code:

  connect(&m_manager,
            SIGNAL(messageAdded(const QMessageId&,
                                const QMessageManager::NotificationFilterIdSet&)),
            this,
            SLOT(messageReceived(const QMessageId&,
                                const QMessageManager::NotificationFilterIdSet&)));

    m_notifFilterSet.insert(m_manager.registerNotificationFilter(
        QMessageFilter::byType(QMessage::Sms) &
        QMessageFilter::bySender(SMS_NUMBER)));

and
Code:

void MessageHandler::messageReceived(const QMessageId& id,
          const QMessageManager::NotificationFilterIdSet& matchingFilterIds) {
    if (matchingFilterIds.contains(m_notifFilterSet)) {
        QMessage message = m_manager.message(id);
        QString messageString = message.textContent();
        qDebug() << "message received" << messageString;
        if (messageString.startsWith(m_stop)) {
            m_message = messageString;
            emit messageChanged(messageString);
        }
        if (m_deleteMessage) {
            deleteSent();
            m_manager.removeMessage(id);
        }
    }
}

I have problems with sending though. Do you have any idea regarding
my question?

GreatGonzo 2012-05-27 12:54

Re: QMessageFilter and listening for incoming SMS doesn't work
 
I forgot to mention that this is on Harmattan. I Haven't tested this under maemo5.

nicolai 2012-05-28 08:57

Re: QMessageFilter and listening for incoming SMS doesn't work
 
You are right, it does work for SMS, too.
But it doesn't work for QMessageType InstantMessage,
this is strange, as both message types are signaled
by CommHistory with a dbus signal "eventsAdded" and
the Qt MessageManager should listen on this signal.

As for sending SMS, you could try to use telepathy instead
of QMessageService.

GreatGonzo 2012-05-28 09:34

Re: QMessageFilter and listening for incoming SMS doesn't work
 
I was thinking to connect to dbus directly. I can see a slight difference between the messages sent from conversation and from my application. It is only a message type identifier which is missing from the conversations dbus message. It might just be a problem with vodafone. I'll try another carrier and see if it is the same. This is quite frustrating development. qtmobility is fragile at best and I am sitting on an almost finished application.
I will try instant messages when I get the time and get back to you.
Do you know anybody who has used qml location/landmark?

nicolai 2012-05-28 10:12

Re: QMessageFilter and listening for incoming SMS doesn't work
 
Quote:

Originally Posted by GreatGonzo (Post 1213684)
This is quite frustrating development. qtmobility is fragile at best and I am sitting on an almost finished application.

+1
Had a handful applications in mind or work, but for every
application there was missing or buggy part in qtmobility.
(Contacts, alarms, messaging ...)

Quote:

Originally Posted by GreatGonzo (Post 1213684)
Do you know anybody who has used qml location/landmark?

I tried once working on an application with landmarks, don't
remember where it fails, at the moment.
What do you want to do? Have some code that doesn't work?

GreatGonzo 2012-05-28 10:43

Re: QMessageFilter and listening for incoming SMS doesn't work
 
I am creating landmarks on demand in c++, and using LandmarkModel in qml. The ProximityFilter works in the qt simulator but on the device it works some time but not others for no obvious reason. The CategoryFilter doesn't work at all.
So I think I have to revert to creating a custom geomap qml c=+ plugin...
And a custom dbus SMS send work around.
Enough to drive me to java ;-)

GreatGonzo 2012-05-28 10:46

Re: QMessageFilter and listening for incoming SMS doesn't work
 
As a developer competition price they should offer fixing a bug of choice instead of devices.

kent_autistic 2012-05-28 12:39

Re: QMessageFilter and listening for incoming SMS doesn't work
 
Quote:

Originally Posted by GreatGonzo (Post 1213734)
As a developer competition price they should offer fixing a bug of choice instead of devices.

awesome idea! i think you should bring this up with the council.


All times are GMT. The time now is 08:13.

vBulletin® Version 3.8.8