Created
April 13, 2011 15:53
-
-
Save dio/917807 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void XQMessaging::CreateAndSendMessageL( int aType, TBool aEmbedded, QString aSubject, QStringList aAddressList, QString aBody ){ | |
| TUid serviceUid; | |
| if (aType == 1) | |
| serviceUid = KSenduiMtmSmsUid; | |
| else if (aType == 2) | |
| serviceUid = KSenduiMtmSmtpUid; | |
| CMessageData* message = CMessageData::NewLC(); | |
| if (aSubject.length() != 0){ | |
| TBufC<256> subject(aSubject.utf16()); | |
| message->SetSubjectL(&subject); | |
| } | |
| for (TInt i=0; i<aAddressList.length(); i++) { | |
| if (aAddressList.at(i).length() != 0) { | |
| TBufC<256> address(aAddressList.at(i).utf16()); | |
| message->AppendToAddressL(address); | |
| } | |
| } | |
| CRichText* richText; | |
| CParaFormatLayer* paraFormatLayer; | |
| CCharFormatLayer* charFormatLayer; | |
| paraFormatLayer=CParaFormatLayer::NewL(); | |
| charFormatLayer=CCharFormatLayer::NewL(); | |
| CleanupStack::PushL(paraFormatLayer); | |
| CleanupStack::PushL(charFormatLayer); | |
| TRAPD(err, richText = CRichText::NewL(paraFormatLayer, charFormatLayer)) | |
| if (err == KErrNone) { | |
| if (aBody.length() != 0) { | |
| HBufC * buf = HBufC::NewLC(aBody.length()); | |
| buf->Des().Copy(aBody.utf16()); | |
| richText->InsertL(0, buf->Des()); | |
| message->SetBodyTextL(richText); | |
| CleanupStack::PopAndDestroy(buf); | |
| } | |
| } | |
| else { | |
| // handle error and return | |
| CleanupStack::PopAndDestroy(3); | |
| return; | |
| } | |
| if (iSendUi) { | |
| // start message editor through SendUI | |
| iSendUi->CreateAndSendMessageL( serviceUid, message, KNullUid, aEmbedded ); | |
| } | |
| delete richText; | |
| CleanupStack::PopAndDestroy( 3 ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment