symbian mtm操作
2010-08-20 01:50:00 来源:WEB开发网// 得到sms内容
CRichText& mtmBody = iMtm->Body();
mtmBody.Reset();
mtmBody.InsertL(0, KGDSMSTag); //插入我们的短信内容
// 使用CSmsClientMtm类处理sms
CSmsClientMtm* smsMtm = STATIC_CAST(CSmsClientMtm*, iMtm);
smsMtm->RestoreServiceAndSettingsL();
//CSmsHeader封装sms消息的参数,像服务中心号码和发送设定
CSmsHeader& header = smsMtm->SmsHeader();
//CSmsSettings类用来详细设定sms Header
CSmsSettings* sendOptions = CSmsSettings::NewL();
CleanupStack::PushL(sendOptions);
sendOptions->CopyL(smsMtm->ServiceSettings());
sendOptions->SetDelivery(ESmsDeliveryImmediately);//设定立即发送
header.SetSmsSettingsL(*sendOptions);
//检查服务中心号码有效性
if(header.Message().ServiceCenterAddress().Length() == 0)
{
// 如果没有设定,则查找默认中心号码
CSmsSettings* serviceSettings = &(smsMtm->ServiceSettings());
//中心号码列表为空
if(!serviceSettings->NumSCAddresses())
{
// 错误消息
iEikonEnv->InfoWinL(_L("No service center number"),_L("cannot send this one."));
}
else
{
// 设定为默认服务中心号码
CSmsNumber* sc = 0;
sc = &(serviceSettings->SCAddress(serviceSettings->DefaultSC()));
header.Message().SetServiceCenterAddressL(sc->Address());
}
}
CleanupStack::PopAndDestroy();
... ...
CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
CleanupStack::PushL(selection);
selection->AppendL(movedId); // 添加我们要发送的sms,movedId在省略部分有定义,是TMsvId型变量
// 调用的这个函数是用于发送的,具体的代码后面介绍
SetScheduledSendingStateL(selection);
更多精彩
赞助商链接