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

jinzhili jinzhili 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我用以下代码想在我自己的文件夹创建一条短信,我是在短信的我的文件夹中创建了一个自己的目录,然后要在这个目录中创建短信。
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 ,但是它把短信创建到我的文件夹里了,没有在我自己的目录里,达人帮我看看啊。谢谢了!
...全文

相关推荐

评论 3
收藏 已收藏
分享
返回顶部
jinzhili
Symbian 3,118 成员 9,182 内容