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.

S60第三版中访问SMS设置的新API

From Wiki
Jump to: navigation, search
Article Metadata

文章
huwell 在 28 Jun 2007 创建
最后由 hamishwillee 在 15 Dec 2011 编辑
  • 设备, 软件 版本:

S60 3rd Edition


  • 说明:

因为S60第三版中出于平台安全的考虑,所有信息设置已经被转移到Central Repository数据存储中。这样的转变导致老的SMS设置API(如CSmsSettings存储和输出函数)无法使用,当需要在S60第三版上发送一个短信时再使用它们会引发KErrGsmSMSUnspecifiedProtocol和KErrGsmSMSInvalidMandatoryInformation错误。


  • 详细描述:

现在在CSmsAccount中有一个新的API,下面这段代码就展示了如何使用该类去设置SMSC地址以便发送消息。

// ----------------------------------------
 
//
 
// Sets the message center to the message
 
//
 
// ----------------------------------------
 
TInt CFW3MsgEngine::SetSMSCL()
{
 
TInt err = 0;
// CSmsHeader encapsulates data specific for sms messages,
// like service center number and options for sending.
CSmsHeader& header = iMtm->SmsHeader();
CSmsSettings* settings = CSmsSettings::NewL();
CleanupStack::PushL(settings);
CSmsNumber* sc = CSmsNumber::NewL(); //CSmsNumber* sc = 0;
CleanupStack::PushL(sc);
//--------- SMSC & header set-up
settings->CopyL(iMtm->ServiceSettings()); // restore existing settings
// set send options
settings->SetDelivery(ESmsDeliveryImmediately); // set to be delivered immediately
header.SetSmsSettingsL(*settings);
// Set SMSC address
 
if (header.Message().ServiceCenterAddress().Length() == 0)
{
// No smsc set. We assume there is at least one sc number defined and use
// the default SC number.
CSmsSettings* serviceSettings = &(iMtm->ServiceSettings());
// if number of scaddresses in the list is null
if (!serviceSettings->ServiceCenterCount()) // New messaging API uses new methods
{
// here there should be a dialog in which user can add sc number
_LIT(KNotSet,"SMSC not set");
// Display a Note
CAknGlobalNote* globalNote = CAknGlobalNote::NewLC();
globalNote->ShowNoteL(EAknGlobalInformationNote , KNotSet);
CleanupStack::PopAndDestroy(); // globalNote
}
else
{
// set sc address to default.
sc->SetAddressL((serviceSettings->GetServiceCenter(serviceSettings->DefaultServiceCenter())).Address());
// New messaging API uses new methods
header.Message().SetServiceCenterAddressL(sc->Address());
}
}
//--------- SMSC & header set-up
CleanupStack::PopAndDestroy(2); // sc, settings
return err;
}
This page was last modified on 15 December 2011, at 10:43.
152 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.

×