Symbian CreateAndSendMessageL发送彩信

来源:互联网 发布:python init 函数 编辑:程序博客网 时间:2024/06/13 08:38
Symbian CreateAndSendMessageL发送彩信1用程序调用彩信的编辑框进行彩信发生,通常用在好友推荐的场合.程序把彩编辑框调起来.插入相应的内容并把焦点设置到输入号码处.让用户设置号码即可以发送.让我们看看如何实现void CSendMMSTestAppUi::CreateAndSendMessageL(const TDesC& desContent){// create empty messageCMessageData* message = CMessageData::NewLC();CParaFormatLayer* paraFormatLayer = CParaFormatLayer::NewL();CleanupStack::PushL(paraFormatLayer);CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL();CleanupStack::PushL(charFormatLayer);CRichText* messageBodyContent = CRichText::NewL(paraFormatLayer,charFormatLayer);CleanupStack::PushL(messageBodyContent);messageBodyContent->InsertL(0, desContent);message->SetBodyTextL(messageBodyContent);// start message editor through SendUIsendAppUi->CreateAndSendMessageL(KSenduiMtmSmsUid, message, KNullUid);CleanupStack::PopAndDestroy(4);}以上代码在N73/N95/E71上测试通过Symbian MTM发送彩信2上一篇blog文我介绍了用编辑框发彩信,但是可能在某些情况下我们需要暗地里发短信.也就是让用户不知道.这种情况怎么实现呢?让我们来看下面的实现方案void CMMSSender::SendMMSL(const TDesC& aAddress,const TDesC& aContent){CMsvEntry* entry = CMsvEntry::NewL(*iSession,KMsvGlobalOutBoxIndexEntryId,TMsvSelectionOrdering());CleanupStack::PushL(entry);// Set context to the parent folder (Outbox)iMmsMtm->SwitchCurrentEntryL( entry->EntryId() );// Create new message in the parent folder (Outbox) and// set it as the current contextiMmsMtm->CreateMessageL( iMmsMtm->DefaultServiceL() );CleanupStack::PopAndDestroy(); // entry//设置手机号码,发送的手机号码iMmsMtm->AddAddresseeL(aAddress);//发送彩信的标题// Setting message subjectiMmsMtm->SetSubjectL(_L("/x597D/x53CB/x63A8/x8350/x4E50/x79C0"));// Opening storeCMsvStore* store = iMmsMtm->Entry().EditStoreL();CleanupStack::PushL(store);_LIT(KFileName, "mmsexample.txt");TMsvAttachmentId attachId = KMsvNullIndexEntryId;//创建文本类型的附件,彩信也可以发布图像音乐类型的附件iMmsMtm->CreateTextAttachmentL(*store, attachId, aContent, KFileName);store->CommitL();CleanupStack::PopAndDestroy(); // storeTMsvEntry ent = iMmsMtm->Entry().Entry();// Set InPreparation to falseent.SetInPreparation(EFalse);// Mark as visible, after this the message can be seen in Outbox and,// after sending, in Sent folder.ent.SetVisible(ETrue); iMmsMtm->Entry().ChangeL(ent); // Commit changes// Save the changesiMmsMtm->SaveMessageL();// Start sending the message via the Server MTM to the MMS serverCMsvOperationWait* wait = CMsvOperationWait::NewLC();wait->iStatus = KRequestPending;CMsvOperation* op = NULL;//发送信息op = iMmsMtm->SendL(wait->iStatus );wait->Start();CleanupStack::PushL( op );CActiveScheduler::Start();// The following is to ignore the completion of other active objects.// It is not needed if the app has a command absorbing control (usingCCommandAbsorbingControl).while( wait->iStatus == KRequestPending )CActiveScheduler::Start();CleanupStack::PopAndDestroy(2); // op, wait}