如何在自己的文件夹中创建短信

jinzhili 2009-08-21 09:34:34
我用以下代码想在我自己的文件夹创建一条短信,我是在短信的我的文件夹中创建了一个自己的目录,然后要在这个目录中创建短信。
void CSmsSocketEngine::CreateNewMessageToMyFolderL(const TDesC& aAddr,
const TDesC& aContent)
{
const TInt LEN = 12;

iSmsMtm->SwitchCurrentEntryL(KMsvMyFoldersEntryIdValue); //test!
TTime bTime;
bTime.UniversalTime();

TMsvEntry newIndexEntry;
newIndexEntry.iDate = bTime;

//newIndexEntry.iDate.HomeTime();

newIndexEntry.SetInPreparation(ETrue);

newIndexEntry.iMtm = KUidMsgTypeSMS;
newIndexEntry.iType = KUidMsvMessageEntry;
newIndexEntry.iDetails.Set(aAddr);
newIndexEntry.iDescription.Set(aContent.Left(LEN));

newIndexEntry.SetSendingState(KMsvSendStateNotApplicable);
//以下两行创建到收件箱,会有声音提示
newIndexEntry.SetUnread(ETrue);
newIndexEntry.SetNew(ETrue);

//以下两行创建到收件箱,短信的状态已改为已读,不会有声音提示
/* newIndexEntry.SetUnread(EFalse);
newIndexEntry.SetNew(EFalse);*/

//in 3rd edition crashes here if capabilities are wrong
newIndexEntry.iServiceId = iSmsMtm->ServiceId();

iSmsMtm->Entry().CreateL(newIndexEntry);

TMsvId smsId = newIndexEntry.Id();
iSmsMtm->SwitchCurrentEntryL(smsId);
iSmsMtm->Entry().ChangeL(newIndexEntry);
iSmsMtm->SaveMessageL();

CRichText* richText = CRichText::NewL(
CEikonEnv::Static()->SystemParaFormatLayerL(),
CEikonEnv::Static()->SystemCharFormatLayerL());
CleanupStack::PushL(richText);
richText->InsertL(0, aContent);

CSmsHeader* mySmsHeader = CSmsHeader::NewL(CSmsPDU::ESmsDeliver, *richText);
CleanupStack::PushL(mySmsHeader);

CMsvEntry* tmpEntry = iMsvSession->GetEntryL(newIndexEntry.Id());
CleanupStack::PushL(tmpEntry);
if (tmpEntry->HasStoreL())
{
mySmsHeader->SetFromAddressL(aAddr);

CMsvStore* store = tmpEntry->EditStoreL();
CleanupStack::PushL(store);

TLocale locale;
TTimeIntervalSeconds universalTimeOffSet(locale.UniversalTimeOffset());
TInt tempTime = universalTimeOffSet.Int();

TInt numQuarterHours = universalTimeOffSet.Int() / 3600;

CSmsPDU *pdu = &mySmsHeader->Message().SmsPDU();
CSmsDeliver *dpdu = STATIC_CAST(CSmsDeliver*,pdu);

TTime aTime;
aTime.UniversalTime();
dpdu->SetServiceCenterTimeStamp(aTime,numQuarterHours);

mySmsHeader->StoreL(*store);
store->StoreBodyTextL(*richText);

store->CommitL();
CleanupStack::PopAndDestroy(store);
}

TMsvEntry tttEntry = iSmsMtm->Entry().Entry();
tttEntry.SetInPreparation(EFalse);
// 不设置只读,在收件箱列表处浏览没有回复选项
tttEntry.SetReadOnly(ETrue);

iSmsMtm->Entry().ChangeL(tttEntry);
CleanupStack::PopAndDestroy(3, richText); // tmpEntry, mySmsHeader, richText

return;
}

目录已经创建了,在创建 短信时我指定了 KMsvMyFoldersEntryIdValue ,但是它把短信创建到我的文件夹里了,没有在我自己的目录里,达人帮我看看啊。谢谢了!
...全文
93 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
jinzhili 2009-08-31
  • 打赏
  • 举报
回复
问题已解决了!
jinzhili 2009-08-21
  • 打赏
  • 举报
回复
自己顶一下
yijianxiangde100 2009-08-21
  • 打赏
  • 举报
回复
我也不会,给lz顶一下,看来高手不多啊?

3,120

社区成员

发帖
与我相关
我的任务
社区描述
塞班系统(Symbian系统)是塞班公司为手机而设计的操作系统,它的前身是英国宝意昂公司的 EP ( Electronic Piece of cheese)操作系统。
社区管理员
  • Symbian社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧