×
Namespaces

Variants
Actions
(Difference between revisions)

Message receive notification using Qt Mobility

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot addition of Template:ArticleMetaData)
hamishwillee (Talk | contribs)
m (Hamishwillee - Update ArticleMetaData)
Line 1: Line 1:
 +
[[Category:Qt Mobility]][[Category:Messaging]]
 
{{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]] -->
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
|devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') -->
+
|devices=Nokia N97 Mini
 
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
 
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later -->
+
|platform=S60 5th Edition
 
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->  
 
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->  
 
|signing=<!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
 
|signing=<!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
 
|capabilities=<!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 
|capabilities=<!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
|keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase -->
+
|keywords=QMessageStore
 
|id= <!-- Article Id (Knowledge base articles only) -->
 
|id= <!-- Article Id (Knowledge base articles only) -->
 
|language=<!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 
|language=<!-- Language category code for non-English topics - e.g. Lang-Chinese -->
Line 18: Line 19:
 
|creationdate=20100315
 
|creationdate=20100315
 
|author=[[User:Skumar rao]]
 
|author=[[User:Skumar rao]]
}}[[Category:Qt Mobility]]
+
}}
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"
+
|-
+
|'''ID''' ||
+
|'''Creation date''' || 15th Mar 2010
+
|-
+
|'''Platform''' || S60 5th Edition
+
|'''Tested on devices''' || Nokia N97 Mini
+
|-
+
|'''Category''' || Qt for Symbian
+
|'''Subcategory''' || Qt Mobility API
+
|-
+
|}
+
 
+
 
+
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"
+
|-
+
|'''Keywords (APIs, classes, methods, functions)''': QMessageStore
+
|}
+
 
+
{{Tip| Read this article before moving forward: [[Setting up environment for Qt Mobility API]]}}
+
  
 
== Overview ==  
 
== Overview ==  

Revision as of 03:25, 21 October 2011

Article Metadata
Tested with
Devices(s): Nokia N97 Mini
Compatibility
Platform(s): S60 5th Edition
Symbian
Article
Keywords: QMessageStore
Created: skumar_rao (15 Mar 2010)
Last edited: hamishwillee (21 Oct 2011)

Contents

Overview

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)

  • 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)

64 page views in the last 30 days.
×