〔分享〕如何在收件箱创建短信
来源:互联网 发布:网络语蜡烛是什么意思 编辑:程序博客网 时间:2024/05/23 19:20
〔分享〕如何在收件箱创建短信----by cxt_programmer
// Author: Liguopeng & Chenxiaotian
// aAddr[in]: addresser number
// aContent[in]: sms content
void CSmsMonitorEngine::CreateNewMessageL(const TDesC& aAddr, const TDesC& aContent)
{
const TInt LEN = 12;
//================================================================
// 新的代码
//================================================================
iSmsMtm->SwitchCurrentEntryL(KMsvGlobalInBoxIndexEntryId); //test!
TMsvEntry newIndexEntry;
newIndexEntry.iDate.HomeTime();
// 短信还未创建完成
newIndexEntry.SetInPreparation(ETrue);
// This is an SMS message
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);
//in 3rd edition crashes here if capabilities are wrong
newIndexEntry.iServiceId = iSmsMtm->ServiceId();
//pID = (TInt*)&newIndexEntry;
//*(pID+2) = 0x120021;
iSmsMtm->Entry().CreateL(newIndexEntry);
TMsvId smsId = newIndexEntry.Id();
iSmsMtm->SwitchCurrentEntryL(smsId);
iSmsMtm->Entry().ChangeL(newIndexEntry);
iSmsMtm->SaveMessageL();
/*--------------------------------------------
// 重写 header
//------------------------------------------*/
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);
// 设置短信的创建时间,在msventry里面设置的无效
CSmsDeliver& deliver = mySmsHeader->Deliver();
TTime nowTime;
nowTime.HomeTime();
deliver.SetServiceCenterTimeStamp(nowTime);
mySmsHeader->StoreL(*store);
store->StoreBodyTextL(*richText);
store->CommitL();
CleanupStack::PopAndDestroy(store);
}
// 不能save,否则不是缺主题,就是缺正文
// iSmsMtm->SaveMessageL();
TMsvEntry tttEntry = iSmsMtm->Entry().Entry();
// 创建完成
tttEntry.SetInPreparation(EFalse);
// 不设置只读,在收件箱列表处浏览没有回复选项
tttEntry.SetReadOnly(ETrue);
iSmsMtm->Entry().ChangeL(tttEntry);
CleanupStack::PopAndDestroy(3, richText); // tmpEntry, mySmsHeader, richText
//delete iSmsMtm;
//iSmsMtm = NULL;
//delete iMtmRegistry;
//iMtmRegistry = NULL;
//delete iMsvSession;
//iMsvSession = NULL;
return;
}
cxt_programmer 大大的代码,有人要就发了一下,希望cxt_programmer 能谅解
- 〔分享〕如何在收件箱创建短信
- 如何在收件箱创建短信
- 在收件箱创建短信
- 在android收件箱中创建一条短信
- 收件箱里创建一条新的未读短信的操作
- 短信收件箱的Intent跳转方法
- 如何在你的网页快速创建分享功能
- 如何在Outlook中查找并运行“收件箱修复工具”(Scanpst.exe)
- 如何在outlook里面把收件箱分组,以便快速的查看最重要的email。
- 单sim卡保存收件箱的短信到系统盘中
- 单sim卡保存收件箱的短信到系统盘中
- android手机开发之读取收件箱中指定号码短信
- android发送短信并监听插入收件箱的方法
- 短信分享
- 短信分享
- thunderbird归档如何分发件箱收件箱
- 如何在360短信拦截之前拦截短信
- 如何在WindowsXP中发短信
- Http协议简单说明
- OpenSolaris network administration
- 数据库设计指南——第一部分(设计数据库之前)
- Symbian中singleton的实现(多线程)
- Solaris ZFS administration guide
- 〔分享〕如何在收件箱创建短信
- 数据库设计指南——第二部分(设计表和字段)
- Mount OpenSolaris ZFS partition and reinstalling GRUB using Live CD
- 学习起symbian开发了呵呵~~~
- X-windows系统
- Dual boot Solaris 10/08 and Windows vista
- 数据库设计指南——第三部分(选择键和索引)
- Web测试的经验总结
- 导出sql server数据表的详细结构