Reply
Thread Tools
nicolai's Avatar
Posts: 1,637 | Thanked: 4,424 times | Joined on Apr 2009 @ Germany
#1
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's Avatar
Posts: 275 | Thanked: 389 times | Joined on Feb 2010 @ Sydney
#2
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?
__________________
Quick Widgets - http://wiki.maemo.org/Quick_Widgets
 

The Following 2 Users Say Thank You to GreatGonzo For This Useful Post:
GreatGonzo's Avatar
Posts: 275 | Thanked: 389 times | Joined on Feb 2010 @ Sydney
#3
I forgot to mention that this is on Harmattan. I Haven't tested this under maemo5.
__________________
Quick Widgets - http://wiki.maemo.org/Quick_Widgets
 
nicolai's Avatar
Posts: 1,637 | Thanked: 4,424 times | Joined on Apr 2009 @ Germany
#4
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's Avatar
Posts: 275 | Thanked: 389 times | Joined on Feb 2010 @ Sydney
#5
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?
__________________
Quick Widgets - http://wiki.maemo.org/Quick_Widgets
 

The Following User Says Thank You to GreatGonzo For This Useful Post:
nicolai's Avatar
Posts: 1,637 | Thanked: 4,424 times | Joined on Apr 2009 @ Germany
#6
Originally Posted by GreatGonzo View Post
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 ...)

Originally Posted by GreatGonzo View Post
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's Avatar
Posts: 275 | Thanked: 389 times | Joined on Feb 2010 @ Sydney
#7
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 ;-)
__________________
Quick Widgets - http://wiki.maemo.org/Quick_Widgets
 
GreatGonzo's Avatar
Posts: 275 | Thanked: 389 times | Joined on Feb 2010 @ Sydney
#8
As a developer competition price they should offer fixing a bug of choice instead of devices.
__________________
Quick Widgets - http://wiki.maemo.org/Quick_Widgets
 

The Following User Says Thank You to GreatGonzo For This Useful Post:
Posts: 304 | Thanked: 235 times | Joined on May 2010 @ Manila
#9
Originally Posted by GreatGonzo View Post
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.
 
Reply


 
Forum Jump


All times are GMT. The time now is 01:32.