Archived:How to send and receive SMS in Qt for Symbian

From Qt Wiki
Jump to navigation Jump to search

Template:Archived Template:ArticleMetaData

Overview[edit | edit source]

Template:Abstract. How to use Mobile Extension APIs in Qt for Symbian contains class 76ytuiytuityutyutututyutyutyu and 76ytuiytuityutyutututyutyutyu which provide a way to send and receive messages.

This snippet requires ReadUserData, NetworkServices, WriteUserData, UserEnvironment and LocalServices. Self-signing is not possible because a Developer certificate is needed.

Preconditions[edit | edit source]

Headers required[edit | edit source]

#include "XQMessaging.h"
#include "XQMessage.h"

.pro file[edit | edit source]

Add following lines to your .pro file. symbian:LIBS += -lsendas2 \

   -lmsgs \
   -letext \
   -lefsrv \
   -lcharconv \
   -lgsmu

symbian:TARGET.CAPABILITY = NetworkServices \

   LocalServices \
   ReadUserData \
   WriteUserData \
   UserEnvironment

Send SMS[edit | edit source]

For sending SMS we need to create message with 76ytuiytuityutyutututyutyutyu class. After creating message, send it using 76ytuiytuityutyutututyutyutyu method of 76ytuiytuityutyutututyutyutyu class. The following source code demostrate how to send SMS.

Source code[edit | edit source]

void QtSMSOperation::sendSMS() {

   XQMessaging messaging;
   XQMessage message(QStringList("98433487876"),QString("Testing"));
   
   if (messaging.send(message) == XQMessaging::NoError)
   {
       QMessageBox msgBox;
       msgBox.setText(tr("SMS was sent successfully"));
       msgBox.exec();
   }

}

Receive SMS[edit | edit source]

76ytuiytuityutyutututyutyutyu class emitt a signal 76ytuiytuityutyutututyutyutyu when SMS is received, with reference of 76ytuiytuityutyutututyutyutyu class which has message body and sender information. so we need to catch that signal in your slots. The following source code demostrate how to receive SMS.


/* implement signal ans slots to listen all incoming message */ QtSMSOperation::QtSMSOperation(QWidget *parent)

   : QMainWindow(parent)

{

   ui.setupUi(this);
   /* messaging is declared of type XQMessaging in header file.
   * the slot receiveSMS() will get called on al incomming message */
   connect(&messaging, SIGNAL(messageReceived(const XQMessage&)), this, SLOT(receiveSMS(const XQMessage&)));
   messaging.startReceiving(XQMessaging::MsgTypeSMS);

}

/* receive incomming message */ void QtSMSOperation::receiveSMS(const XQMessage& message) {

   /* message.sender() contains the cell number of sender 
   * and message.body contain body part of message */
   QMessageBox::information(0,message.sender(),message.body());

}

Code Example[edit | edit source]

  • The Code Example will show how to send and receive messages in Qt and is tested on Nokia 5800 XpressMusic.
pt:Archived:Como enviar e receber mensagens, em Qt para Symbian