Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

使用RSendAs发送短消息

From Wiki
Jump to: navigation, search
Article Metadata

兼容于
平台: S30 3rd Edition

文章
关键词: RSendAs
User:Davey 2 在 26 Dec 2007 创建
最后由 hamishwillee 在 20 Oct 2011 编辑

适用版本:

Series60 3rd Edition

解决方案:


在OS9.x中发送短消息最方便的方法就是RSendAs了,仅仅需要传入消息的接收者和消息正文,其他的交给RSendAs完成。
但是对于中文短消息应用这个方法却不适用,因为使用RSendAs发送短信,使用的都是默认的设置,并且不能修改,消息正文都会转换成7-bit-sms的格式,所有不是以7-bit-sms格式定义的字符都以问号代替,中文就不是以7-bit-sms格式定义的,因此使用RSendAs发送的短信都显示为问号,这点必须注意。

以下的代码演示了如何使用RSendAs:

CPP文件:

CRSendAsSender* CRSendAsSender::NewL(MRSendSMSObserver& aObserver,const TDesC& aMessage,const TDesC& aRecipients) {
CRSendAsSender* self = new(ELeave)CRSendAsSender(aObserver);
self->ConstructL(aMessage,aRecipients);
return self;
}
 
CRSendAsSender::CRSendAsSender(MRSendSMSObserver& aObserver):CActive(0),iObserver(aObserver) {
}
 
CRSendAsSender::~CRSendAsSender() {
Cancel();
iSendAsMessage.Close();
iSendAs.Close();
}
 
void CRSendAsSender::ConstructL(const TDesC& aMessage,const TDesC& aRecipients) {
CActiveScheduler::Add(this);
 
User::LeaveIfError(iSendAs.Connect());
iSendAsMessage.CreateL(iSendAs, KUidMsgTypeSMS);
 
iSendAsMessage.AddRecipientL(aRecipients, RSendAsMessage::ESendAsRecipientTo);
iSendAsMessage.SetBodyTextL(aMessage);
 
iSendAsMessage.SendMessage(iStatus);
SetActive();
}
 
void CRSendAsSender::DoCancel() {
iSendAsMessage.Cancel();
}
 
void CRSendAsSender::RunL() {
iObserver.MessageSentL(iStatus.Int());
}

头文件:

#include <e32base.h>
#include <F32FILE.H>
#include <BADESCA.H>
 
#include <rsendasmessage.h>
#include <rsendas.h>
#include <MTCLREG.H>
 
class MRSendSMSObserver {
public:
virtual void MessageSentL(TInt aError) = 0;
};
 
class CRSendAsSender : public CActive {
public:
static CRSendAsSender* NewL(MRSendSMSObserver& aObserver,const TDesC& aMessage,const TDesC& aRecipients);
~CRSendAsSender();
protected:
void DoCancel();
void RunL();
private:
CRSendAsSender(MRSendSMSObserver& aObserver);
void ConstructL(const TDesC& aMessage,const TDesC& aRecipients);
private:
MRSendSMSObserver& iObserver;
RSendAs iSendAs;
RSendAsMessage iSendAsMessage;
};
This page was last modified on 20 October 2011, at 05:54.
211 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×