×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    10

    Question QMessage::setStatus(QMessage::Read,true); does not work

    Hello, i have been trying to figure out whats wrong for hours, so basically when the application starts on my Symbian phone, i check the inbox for unread SMS messages, then i parse through them and send a reply message to each sender, what i would want to achieve is to mark the parsed messages as read so that they aren't parsed on the next application launch, but for some reason it doesn't seem to be doing what i want it to, ill include some parts of the code for reference:

    Code:
    smsHandler::smsHandler(QObject *parent,database *theDb) :
        QObject(parent)
    {
        this->theDatabase = theDb;
        foreach(const QMessageAccountId &id, manager.queryAccounts()){
            QMessage::Type type(QMessage::NoType);
            QMessageAccount account(id);
            QString name(account.name());
            if (account.messageTypes() & QMessage::Sms) {
                type = QMessage::Sms;
      
            }
            accountDetails.insert(name, qMakePair(type, account.id()));
            manager.registerNotificationFilter(QMessageFilter::byStandardFolder(QMessage::InboxFolder));
            connect(&manager, SIGNAL(messageUpdated(QMessageId,QMessageManager::NotificationFilterIdSet)), this, SLOT(messageUpdatedMethod(QMessageId,QMessageManager::NotificationFilterIdSet)));        connect(&theService,SIGNAL(messagesFound(QMessageIdList)),this,SLOT(messagesFound(QMessageIdList)));
    QMessageFilter folderFilter(QMessageFilter::byStandardFolder(QMessage::InboxFolder,QMessageDataComparator::Equal));
            QMessageFilter typeFilter(QMessageFilter::byType(QMessage::Sms));
            QMessageFilter excludeRead(QMessageFilter::byStatus(QMessage::Read,QMessageDataComparator::NotEqual));
            theService.queryMessages(folderFilter&typeFilter&excludeRead);
        }
    }

    Code:
    void smsHandler::messagesFound(const QMessageIdList &ids){
        foreach(const QMessageId& id, ids)
              {
    
            if(id.isValid()) {
              QMessage msgReceived(manager.message(id));
              manager.message(id).setStatus(QMessage::Read);
              qDebug()<< "read is" << QMessage::Read << manager.message(id).status(); // returns "read is 1 0"
              msgReceived.setStatus(QMessage::Read,true);
              QMessageContentContainer bodyPart = msgReceived.find(msgReceived.bodyId());
              QString bodyText = bodyPart.textContent();
              QMessageAddress msgSender(QMessageAddress::Phone,msgReceived.from().addressee());
              QStringList splittedMessage = bodyText.split(",",QString::SkipEmptyParts);
              QStringList wantList;
              for(int i= 0;i < splittedMessage.length();i++){
                  QString want = splittedMessage.at(i);
                  wantList.append(want.trimmed());
              }
              if(wantList.length() > 0){
                
                  msgReceived.setStatus(QMessage::Read,true);
                
                  QString welcomeText = this->theDatabase->addPhoneNumber(wantList,msgSender.addressee());
                  if(welcomeText.length() > 0){
                      QStringList senders;
                      senders.append(msgSender.addressee());
                      this->sendMessage(senders,welcomeText);
                  }
            
              }
              }
            else{
                    qDebug() << "id is not valid";
                }
        }
    }

    and the header just in case:
    Code:
    #ifndef SMSHANDLER_H
    #define SMSHANDLER_H
    
    #include <QObject>
    #include "qmessageaccountid.h"
    #include "qmessageaccount.h"
    #include "qmessagemanager.h"
    #include "qmessageservice.h"
    
    #include <QMap>
    #include <QPair>
    #include "database.h"
    QTM_USE_NAMESPACE
    
    class smsHandler : public QObject
    {
        Q_OBJECT
    public:
        explicit smsHandler(QObject *parent = 0,database *theDb = 0);
        void sendMessage(QStringList recievers, QString message);
    signals:
    
    private:
        database *theDatabase;
        QMessageService theService;
        QMessageManager manager;
        QMap<QString, QPair<QMessage::Type, QMessageAccountId> > accountDetails;
    private slots:
        void messageUpdatedMethod(const QMessageId &id, const QMessageManager::NotificationFilterIdSet &matchingFilterIds);
        void messagesFound(const QMessageIdList &ids);
    };
    
    #endif // SMSHANDLER_H
    also the capabilities in the .pro file:
    Code:
    TARGET.CAPABILITY = NetworkServices \
        LocalServices \
        ReadUserData \
        WriteUserData \
        UserEnvironment
    Everything else is working fine as far as the messaging is concerned, i can send messages and recieve them, read the content, but i cannot set the status.

    Hope somebody has encountered this situation before, i did not find anything related on the forums though.

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

    Re: QMessage::setStatus(QMessage::Read,true); does not work

    and i just tested to set the body of the message, that didn't seem to work either.

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

    Re: QMessage::setStatus(QMessage::Read,true); does not work

    I seem to have found the solution, you have to do manually update the message using
    http://doc.qt.nokia.com/qtmobility-1...#updateMessage

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    13

    Angry Re: QMessage::setStatus(QMessage::Read,true); does not work

    The solution is quite obvious (use updateMessage function) but it doesn't work in my project.

    First I read the message with QMessageManager::message, then set it as read with QMessage::setStatus.
    Then I try to store the new status with QMessageManager::update but it return always false.

    Even the update returns false, status for SMS messages are updated. But for email (no matter if POP/IMAP/MFE) nothing happens. QMessageManager::error() return just no error so there is something badly wrong in Qt Mobility.

Similar Threads

  1. Qmessage of type sms, receiver number returns ring/tel/ring
    By bassejepsen in forum [Archived] Qt Mobility Project
    Replies: 0
    Last Post: 2010-08-09, 11:37
  2. How to put scrollbar in Qmessage box
    By shaktiqt123 in forum Qt
    Replies: 1
    Last Post: 2010-05-25, 16:22
  3. WebService and SetStatus()
    By SimonJudge in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2007-08-14, 13:34
  4. destroyApp(true) doesn't work?
    By Stephie in forum Mobile Java General
    Replies: 2
    Last Post: 2006-10-15, 12:32

Posting Permissions

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