×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    4

    How to handle incoming SMS with QtMobility

    Hi all. Can someone tell me how handle incoming SMS?
    For example I want to do something when an SMS, from a specific sender, is arriving.
    In Qt mobility extensions there was a signal called "messageArrived" but now in QtMobility this signal doesn't exist.

    Which signal can I use?

    Thanks
    Last edited by glatorre; 2010-01-22 at 14:01.

  2. #2
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: How to handle incoming SMS with QtMobility

    you can use QMessageStore::registerNotificationFilter

  3. #3
    Registered User
    Join Date
    Nov 2009
    Posts
    4

    Re: How to handle incoming SMS with QtMobility

    Ok thanks

  4. #4
    Registered User
    Join Date
    Mar 2010
    Posts
    15

    Re: How to handle incoming SMS with QtMobility

    Can I get some more details on the Question . ie how to use registerNotificationFilter.

    Also I wanted to know how to copy/move the messages from message store to some specific folder(say some user created folder.)

  5. #5
    Registered User
    Join Date
    Mar 2010
    Posts
    15

    Question Re: How to handle incoming SMS with QtMobility

    Still waiting for some answers. Or my questions are not clear .
    Thanks in advance .

  6. #6
    Registered User
    Join Date
    Mar 2010
    Posts
    7

    Re: How to handle incoming SMS with QtMobility

    Hi,

    I have used code like this (QtMobility-1.0.0-beta1).

    I declare the manager as a class member in the .h file.

    Code:
    QMessageManager m_messageManager;
    In the constructor I setup the manager and connect the messageAdded-signal to my handler-slot.

    Code:
    m_messageManager.registerNotificationFilter(QMessageFilter::byStandardFolder(QMessage::InboxFolder));
    
    connect(&m_messageManager, 
            SIGNAL(messageAdded(const QMessageId&, const QMessageManager::NotificationFilterIdSet&)),
            this, SLOT(receiveMessage(const QMessageId&)));
    and my handler-slot looks like this.

    Code:
    void MainWindow::receiveMessage(const QMessageId& id)
    {
        qDebug() << "Receive message " << id.toString();
    
        // TODO: You must find more sophisticated approach than this while -loop here. 
        while (m_messageManager.message(id).type() == QMessage::NoType);
    
        QMessage message(m_messageManager.message(id));
        QString subject = message.subject();
        if (subject.length() == 0) {
            subject = message.textContent(); // This function was not documented 
                                             // (when I last looked the API documents)
        }
    
        qDebug() << message.type() << message.from().recipient() << subject;
    }
    I hope that this code snippet put you in right path.

  7. #7
    Registered User
    Join Date
    Apr 2010
    Posts
    10

    Re: How to handle incoming SMS with QtMobility

    Code:
    // TODO: You must find more sophisticated approach than this while -loop here. 
    while (m_messageManager.message(id).type() == QMessage::NoType);
    I have a question regarding this little piece of code, is the idea here to wait for the SMS to load completely? Because i am having problems reading the SMS content. Sometimes there is a body and a sender, more often however both fields are empty, and the type of the message is QMessage::NoType. The only explanation i could find is im trying to read the content before it has had time to load, is this correct?

    I've been looking through the documentation and tried the following approach:
    Code:
    msgStore.registerNotificationFilter(QMessageFilter::byStandardFolder(QMessage::InboxFolder) & QMessageFilter::byType(QMessage::Sms));
    This didn't work at all. So is there any working way of checking when the message is ready to be read?

    Thanks in advance!

  8. #8
    Registered User
    Join Date
    Mar 2010
    Posts
    7

    Re: How to handle incoming SMS with QtMobility

    Yes, you've understood correctly. E.g. When you study this (line 349 onward) example code in Qt Mobility Gitorius, you can find that lots of code lines are used to solve this problem.

    Note also the Known Issues in Messaging API. There are some limitations when using the filters in Messaging API. You can find them from Release Notes of the QtMobility Project.

Similar Threads

  1. Turning off incoming SMS notification programmatically
    By juannoguera in forum Symbian User Interface
    Replies: 3
    Last Post: 2009-03-05, 20:49
  2. Retreiving Phone number of incoming SMS
    By kumar_sai123 in forum Symbian Networking & Messaging (Closed)
    Replies: 6
    Last Post: 2009-01-29, 13:01
  3. Replies: 3
    Last Post: 2009-01-08, 04:41
  4. Need urgent help with incoming sms number.
    By Donnieng in forum Symbian
    Replies: 1
    Last Post: 2007-06-16, 05:52

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×