×
Namespaces

Variants
Actions
(Difference between revisions)

Archived:Send SMS using Qt Mobility

From Nokia Developer Wiki
Jump to: navigation, search
skumar_rao (Talk | contribs)
hamishwillee (Talk | contribs)
m (moved Send SMS using Qt Mobility to Archived:Send SMS using Qt Mobility: Article no longer works with current SDKs)
 
(30 intermediate revisions by 8 users not shown)
Line 1: Line 1:
[[Category:Qt for Symbian]][[Category:Qt for Symbian]]
+
[[Category:Code Snippet]][[Category:Qt Mobility]][[Category:MeeGo Harmattan]][[Category:Symbian]][[Category:SMS]][[Category:Qt]]
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"
+
{{Archived|This example is outdated and may not compile with new sdks; see this for new examples [[Qt Mobility API Basic Examples Part 1]]'''}}
|-
+
{{Abstract|The following code shows how to send an SMS using Qt Mobility.}}
|'''ID''' ||  
+
{{ArticleMetaData <!-- v1.2 -->
|'''Creation date''' || 15th Mar 2010
+
|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]]) -->
|'''Platform''' || S60 5th Edition  
+
|devices= Nokia N97 Mini, Nokia N900
|'''Tested on devices''' || Nokia N97 Mini
+
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
|-
+
|platform= S60 5th Edition, Maemo 5
|'''Category''' || Qt for Symbian
+
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
|'''Subcategory''' || Qt Mobility API
+
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
|-
+
|signing= DevCert required
|}
+
|capabilities= ReadUserData, WriteUserData, ReadDeviceData, WriteDeviceData
 
+
|keywords= QMessageServiceAction, QMessageId
 
+
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"
+
|translated-by= <!-- [[User:XXXX]] -->
|-
+
|translated-from-title= <!-- Title only -->
|'''Keywords (APIs, classes, methods, functions)''': QMessageServiceAction, QMessageId
+
|translated-from-id= <!-- Id of translated revision -->
|}
+
|review-by= <!-- After re-review: [[User:username]] -->
 
+
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 
+
|update-by= <!-- After significant update: [[User:username]]-->
{{UnderConstruction}}
+
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 
+
|creationdate= July 7 2010
{{Tip| Read this article before moving forward: [[Setting up environment for Qt Mobility API]]}}
+
|author= [[User:Skumar rao]]
 
+
<!-- The following are not in current metadata -->
== Overview ==
+
|id= CS001616
The below code shows how to send a SMS using Qt Mobility
+
}}
 
+
{{SeeAlso|[[Archived:Setting up environment for Qt Mobility API]]}}
== Keywords ==
+
  
 
== Project configuration file (.Pro file) ==
 
== Project configuration file (.Pro file) ==
Line 34: Line 33:
 
CONFIG += mobility
 
CONFIG += mobility
 
MOBILITY += messaging
 
MOBILITY += messaging
 +
</code>
 +
 +
The use of Messaging requires the [[Capabilities (Symbian Signed)/ReadUserData Capability|ReadUserData]] and [[Capabilities (Symbian Signed)/WriteUserData Capability|WriteUserData]] capabilities from the '''user granted''' category.
 +
It also requires the [[Capabilities (Symbian Signed)/ReadDeviceData Capability|ReadDeviceData]] and [[Capabilities (Symbian Signed)/WriteDeviceData Capability|WriteDeviceData]] capabilities from the '''open signed online''' category. Read more about [[Capabilities]].
 +
 +
<code cpp-qt>
 +
symbian {
 +
TARGET.CAPABILITY = ReadUserData \
 +
    WriteUserData \
 +
    ReadDeviceData \
 +
    WriteDeviceData
 +
}
 
</code>
 
</code>
  
 
===Headers===
 
===Headers===
<code>
+
<code cpp-qt>
 
#include <qtmessaging.h>
 
#include <qtmessaging.h>
  
Line 48: Line 59:
  
 
===Source file===
 
===Source file===
<code>
+
<code cpp-qt>
// connect messageseives statechange signal to our slot, to get notification     
+
// connect messages state-change signal to our slot, to get notification     
 
connect(&m_MessageServiceAction, SIGNAL(stateChanged(QMessageServiceAction::State)), this, SLOT(messageStateChanged(QMessageServiceAction::State)));     
 
connect(&m_MessageServiceAction, SIGNAL(stateChanged(QMessageServiceAction::State)), this, SLOT(messageStateChanged(QMessageServiceAction::State)));     
 
      
 
      
Line 69: Line 80:
 
void send_sms::messageStateChanged(QMessageServiceAction::State s) {
 
void send_sms::messageStateChanged(QMessageServiceAction::State s) {
 
     if (s == QMessageServiceAction::Successful) {
 
     if (s == QMessageServiceAction::Successful) {
         // message send successfull
+
         // message send successful
 
         }
 
         }
 
     else {
 
     else {
Line 78: Line 89:
  
 
===Classes===
 
===Classes===
* QMessageServiceAction
+
* [http://doc.qt.nokia.com/qtmobility-1.0-tp/qmessageserviceaction.html QMessageServiceAction]
* QMessageId
+
* [http://doc.qt.nokia.com/qtmobility-1.0/qmessageid.html QMessageId]
  
 
== Reference links==
 
== Reference links==
 
* [http://qt.nokia.com/ Qt - cross-platform application and UI framework]
 
* [http://qt.nokia.com/ Qt - cross-platform application and UI framework]
 
* [http://labs.trolltech.com/page/Projects/QtMobility Qt Mobility API]
 
* [http://labs.trolltech.com/page/Projects/QtMobility Qt Mobility API]
* [http://qt.nokia.com/developer/new-qt-apis New Qt APIs Beta - Mobility Project]
+
* [http://qt.nokia.com/developer/qt-roadmap New Qt APIs Beta - Mobility Project]
 
* SDK help
 
* SDK help

Latest revision as of 01:24, 18 October 2012

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

This example is outdated and may not compile with new sdks; see this for new examples Qt Mobility API Basic Examples Part 1

The following code shows how to send an SMS using Qt Mobility.

Article Metadata
Tested with
Devices(s): Nokia N97 Mini, Nokia N900
Compatibility
Platform(s): S60 5th Edition, Maemo 5
Symbian
Platform Security
Signing Required: DevCert required
Capabilities: ReadUserData, WriteUserData, ReadDeviceData, WriteDeviceData
Article
Keywords: QMessageServiceAction, QMessageId
Created: skumar_rao (07 Jul 2010)
Last edited: hamishwillee (18 Oct 2012)

Contents

[edit] Project configuration file (.Pro file)

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

The use of Messaging requires the ReadUserData and WriteUserData capabilities from the user granted category. It also requires the ReadDeviceData and WriteDeviceData capabilities from the open signed online category. Read more about Capabilities.

symbian {
TARGET.CAPABILITY = ReadUserData \
WriteUserData \
ReadDeviceData \
WriteDeviceData
}

[edit] Headers

#include <qtmessaging.h>
 
private slots:
void messageStateChanged(QMessageServiceAction::State s);
private:
QMessageServiceAction m_MessageServiceAction;
QMessageId m_sendId;

[edit] Source file

// connect messages state-change signal to our slot, to get notification    
connect(&m_MessageServiceAction, SIGNAL(stateChanged(QMessageServiceAction::State)), this, SLOT(messageStateChanged(QMessageServiceAction::State)));
 
void send_sms::QtSendSMSMessage(QString address, QString body) {
// Prepare QMessage with address & body
QMessage message;
message.setType(QMessage::Sms);
message.setTo(QMessageAddress(address, QMessageAddress::Phone));
message.setBody(body);
 
if (iMessageServiceAction.send(message)) {
sendId = message.id();
}
else {
// message sending failed
}
}
 
void send_sms::messageStateChanged(QMessageServiceAction::State s) {
if (s == QMessageServiceAction::Successful) {
// message send successful
}
else {
// message sending failed
}
}

[edit] Classes

[edit] Reference links

This page was last modified on 18 October 2012, at 01:24.
318 page views in the last 30 days.
×