Namespaces
Variants
Actions
(Difference between revisions)

Message receive notification using Qt Mobility

Jump to: navigation, search
m (Hamishwillee - Update ArticleMetaData)
m (Hamishwillee -)
 
(4 intermediate revisions by one user not shown)
Line 1: Line 1:
[[Category:Qt Mobility]][[Category:Messaging]]
+
[[Category:Qt Mobility]][[Category:Messaging]][[Category:MeeGo Harmattan]][[Category:Symbian]][[Category:Qt]]
 
{{ArticleMetaData
 
{{ArticleMetaData
 
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] -->
 
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] -->
Line 20: Line 20:
 
|author=[[User:Skumar rao]]
 
|author=[[User:Skumar rao]]
 
}}
 
}}
 
== Overview ==
 
 
{{Abstract| This article demonstrates how to query messages from the system, how to get notifications of when messages are added or updated.}} Circle through all messages including SMS, MMS and Email from device
 
{{Abstract| This article demonstrates how to query messages from the system, how to get notifications of when messages are added or updated.}} Circle through all messages including SMS, MMS and Email from device
 
== Keywords ==
 
 
 
== Project configuration file (.Pro file) ==
 
== Project configuration file (.Pro file) ==
 
* Add the Qt Mobility project configuration option in the .Pro file as shown below
 
* Add the Qt Mobility project configuration option in the .Pro file as shown below
Line 34: Line 29:
  
 
== Header File ==
 
== Header File ==
<code cpp>
+
<code cpp-qt>
  
 
#include <qtmessaging.h>
 
#include <qtmessaging.h>
Line 47: Line 42:
  
 
== Source File ==
 
== Source File ==
<code cpp>
+
<code cpp-qt>
 
void send_notification::initialization() {     
 
void send_notification::initialization() {     
 
     msgStore = QMessageStore::instance();
 
     msgStore = QMessageStore::instance();

Latest revision as of 01:59, 18 October 2012

Article Metadata

Tested with
Devices(s): Nokia N97 Mini

Compatibility
Platform(s): S60 5th Edition

Article
Keywords: QMessageStore
Created: skumar_rao (15 Mar 2010)
Last edited: hamishwillee (18 Oct 2012)

This article demonstrates how to query messages from the system, how to get notifications of when messages are added or updated. Circle through all messages including SMS, MMS and Email from device

Contents

Project configuration file (.Pro file)

  • Add the Qt Mobility project configuration option in the .Pro file as shown below
CONFIG += mobility
MOBILITY += messaging

Header File

#include <qtmessaging.h>
 
private slots:
void messageAdded(const QMessageId &id, const QMessageStore::NotificationFilterIdSet &matchingFilterIds);
private:
QMessageStore* msgStore;
QMessageFilter msgFilter;
QMessageStore::NotificationFilterId msgFilterId;

Source File

void send_notification::initialization() {    
msgStore = QMessageStore::instance();
QMessageFolderFilter folderFilter(QMessageFolderFilter::byDisplayName("Inbox"));
msgFilter = QMessageFilter::byParentFolderId(folderFilter);
}
 
void send_notification::register_to_receive_msgs() {
msgFilterId = msgStore->registerNotificationFilter(msgFilter);
connect(msgStore, SIGNAL(messageUpdated(QMessageId, QMessageStore::NotificationFilterIdSet)), this, SLOT(messageAdded(QMessageId, QMessageStore::NotificationFilterIdSet)));
}
 
void send_notification::deregister_to_receive_msgs() {
msgStore->unregisterNotificationFilter(msgFilterId);
disconnect(msgStore, SIGNAL(messageAdded(QMessageId, QMessageStore::NotificationFilterIdSet)), this, SLOT(messageAdded(QMessageId, QMessageStore::NotificationFilterIdSet)));
}
 
void send_notification::messageAdded(const QMessageId &id, const QMessageStore::NotificationFilterIdSet &matchingFilterIds) {
if(id.isValid()) {
QMessage msgReceived(id);
QMessageContentContainer bodyPart = msgReceived.find(msgReceived.bodyId());
// bodyPart.isContentAvailable() : returns true if there is message body
QString bodyText = bodyPart.textContent();
QString msgSender = msgReceived.from().recipient();
}
else {
// Ignore this state
}
}

Classes

  • QMessageStore
  • QMessageFilter
  • QMessageStore::NotificationFilterId
  • QMessage

Reference links

--skumar_rao 02:40, 16 March 2010 (UTC)

This page was last modified on 18 October 2012, at 01:59.
131 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved