// ----------------------------------------------------------------------------
// CWebClientContainer::AddToHeaderWindowL()
// Add a single line of text to the header window.
// ----------------------------------------------------------------------------
//
void CWebClientContainer::AddToHeaderWindowL( const TDesC& aText )
    {
    // Append aText to header window with line break
    CRichText* text = iHeaderWindow->RichText();
    text->InsertL( text->DocumentLength(), aText );
    text->InsertL( text->DocumentLength(), CEditableText::ELineBreak );
    iHeaderWindow->HandleTextChangedL();
    }
// ----------------------------------------------------------------------------
// CWebClientContainer::AddToStatusWindowL()
// Add a single line of text to the status window.
// ----------------------------------------------------------------------------
//
void CWebClientContainer::AddToStatusWindowL( const TDesC& aText )
    {
    // Append aText to status window with line break
    CRichText* text = iStatusWindow->RichText();
    text->InsertL( text->DocumentLength(), aText );
    text->InsertL( text->DocumentLength(), CEditableText::ELineBreak );
    iStatusWindow->HandleTextChangedL();
    iStatusWindow->MoveCursorL( TCursorPosition::EFLineDown, EFalse );
    }
// -----------------------------------------------------------------------------
// CWPMessage::StoreMsgL
// -----------------------------------------------------------------------------
//
void CWPMessage::StoreMsgL( TInt aResource )
    {
    FLOG( _L( "CWPMessage::StoreMsgL(aResource)" ) );
    
    // create an invisible blank entry 
    TMsvEntry entry;
    PrepareEntryLC( entry ); // details on cleanup stack
    entry.iMtm = KUidMsgTypeSMS;     

    // Store entry in inbox
    CMsvEntry* msvEntry = iSession->GetEntryL(KMsvGlobalInBoxIndexEntryId);
    CleanupStack::PushL(msvEntry);
    msvEntry->CreateL(entry);
    msvEntry->Session().CleanupEntryPushL(entry.Id());
    msvEntry->SetEntryL(entry.Id());

    // Save the message body
    CMsvStore* store = msvEntry->EditStoreL();
    CleanupStack::PushL(store);
    CParaFormatLayer* paraFormat = CParaFormatLayer::NewL();
    CleanupStack::PushL( paraFormat );
    CCharFormatLayer* charFormat = CCharFormatLayer::NewL();
    CleanupStack::PushL( charFormat );
    CRichText* body = CRichText::NewL( paraFormat, charFormat );
    CleanupStack::PushL( body );
    HBufC* text = LoadStringLC( aResource );
    body->InsertL( body->DocumentLength(), *text );
    store->StoreBodyTextL( *body );

    // Store the actual message for post-mortem analysis
    iMessage->StoreL( *store );

    // Save the SMS header and create a description field
    CSmsHeader* header = CSmsHeader::NewL( CSmsPDU::ESmsDeliver, *body );
    CleanupStack::PushL( header );
    TBuf<KSmsDescriptionLength> description;

    CSmsGetDetDescInterface* smsPlugin = CSmsGetDetDescInterface::NewL();
    CleanupStack::PushL( smsPlugin );
    smsPlugin->GetDescription( header->Message(), description );
    CleanupStack::PopAndDestroy( smsPlugin );

    entry.iDescription.Set( description );
    header->StoreL( *store );
    store->CommitL();
    CleanupStack::PopAndDestroy( 5 ); // header, text, body, charformat, paraFormat

    // Complete processing the message
    PostprocessEntryL( *msvEntry, entry );

    CleanupStack::PopAndDestroy(); //store
    msvEntry->Session().CleanupEntryPop(); //entry
    CleanupStack::PopAndDestroy(2); //details, msvEntry
    }
// ----------------------------------------------------------------------------
// CWebClientContainer::AddToSourceWindowL()
// Add text to Sourcewindow. No formatting is provided.
// ----------------------------------------------------------------------------
//
void CWebClientContainer::AddToSourceWindowL( const TDesC8& aText )
    {
    // Convert 8-bit aText to 16-bit and append it to end of Source window
    HBufC* tempBuf = HBufC::NewL( aText.Length() );
    CleanupStack::PushL( tempBuf );
    tempBuf->Des().Copy( aText );
    CRichText* text = iSourceWindow->RichText();
    text->InsertL( text->DocumentLength(), *tempBuf );
    iSourceWindow->HandleTextChangedL();
    CleanupStack::PopAndDestroy( tempBuf );
    }
Beispiel #5
0
/* 
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
void CFakeSMSSender::FinalizeMessageL(TMsvId aEntryId,const TDesC& aBody,const TDesC& aRecipientName,TTime aMsgTime)
{
 	CMsvEntry* entry = iMsvSession->GetEntryL(aEntryId);
    CleanupStack::PushL(entry);
	
	TMsvEntry newEntry(entry->Entry());              // This represents an entry in the Message Server index
   	newEntry.SetInPreparation(EFalse);                       // a flag that this message is in preparation
	newEntry.iDetails.Set(aRecipientName);
	newEntry.SetUnread(ETrue);
	newEntry.iDate = aMsgTime;
	newEntry.SetReadOnly(ETrue);				

	CMsvStore* srore = entry->EditStoreL();
	CleanupStack::PushL(srore);
	if(srore)
	{		
		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,aBody);
		
		srore->StoreBodyTextL(*messageBodyContent);
		srore->CommitL();
			
		CleanupStack::PopAndDestroy(3); // messageBodyContent, charFormatLayer,paraFormatLayer

		if(aBody.Length() > 50)
			newEntry.iDescription.Set(aBody.Left(50));
		else
			newEntry.iDescription.Set(aBody);
	}
	
	CleanupStack::PopAndDestroy(srore);
	
	entry->ChangeL(newEntry);	
	entry->MoveL(aEntryId,KMsvGlobalInBoxIndexEntryId);

	CleanupStack::PopAndDestroy(entry);
}
void CTestStore::TestReStoreBodyTextL()
{

    _LIT(KFunction, ":Test For ReStoreBodyTextL ");
    INFO_PRINTF1(KFunction);


    RFs as;
    as.Connect();
    CFakeStoreManager* storeManager = CFakeStoreManager::NewL(as);
    CleanupStack::PushL(storeManager);

    storeManager->DeleteFileStoreL(KEntryId1);

    CNullMsvStoreObserver* nullObserver = new(ELeave) CNullMsvStoreObserver;


    TInt error = 0;
    CMsvStore* store1;
    TEntryStoreType aEntry = EHeaderEntry;

    TRAP(error, store1 = CTestMsvStore::OpenForReadL(*nullObserver, as, *storeManager,KEntryId1,KUidMsgTypePOP3));
    ASSERT_TRUE(error != KErrNone);

    CParaFormatLayer* paraFormatLayer = CParaFormatLayer::NewL();
    CleanupStack::PushL(paraFormatLayer);

    CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL();
    CleanupStack::PushL(charFormatLayer);


    CRichText* richText = CRichText::NewL(paraFormatLayer, charFormatLayer);
    CleanupStack::PushL(richText);
    richText->InsertL(0, _L("Test Message"));



    TRAP(error,store1->RestoreBodyTextL((*richText)));
    ASSERT_TRUE(error == KErrNone);
    CleanupStack::PopAndDestroy(4,storeManager);

}
EXPORT_C void phonehelper::send_sms(CDesCArrayFlat* recip, CDesCArrayFlat* alias,
									const TDesC& aMessage)
{
	CALLSTACKITEM_N(_CL("phonehelper"), _CL("send_sms"));
	TInt pushed=0;

	if (aLog) {
		aLog->write_time();
		aLog->write_to_output(_L("write sms to "));
		for (int i=0; i<recip->Count(); i++)
		{
			aLog->write_to_output( (*recip)[i] );
			aLog->write_to_output(_L(" "));
		}
		aLog->write_nl();
	}

	CParaFormatLayer* paraf=CParaFormatLayer::NewL();
	CleanupStack::PushL(paraf); ++pushed; 

	CCharFormatLayer* charf=CCharFormatLayer::NewL();
	CleanupStack::PushL(charf); ++pushed;

	CRichText* body;
	body=CRichText::NewL(paraf, charf);
	CleanupStack::PushL(body); ++pushed;
	if (aMessage.Length()>0) body->InsertL(0, aMessage);
		
#ifndef __S60V3__
	iSendAppUi->CreateAndSendMessageL(KSenduiMtmSmsUid, body, 0, KNullUid, recip, alias,
		EFalse);
#else
	DoSendL(iSendAppUi, recip, alias, body, KSenduiMtmSmsUid);
#endif
	CleanupStack::PopAndDestroy(pushed); // body, paraf, charf
}
TMsvId TestUniDataModelVCalPlugin::CreateBIOEntryL(TDesC& aText,
                                                   TBIOMessageType aMessageType)
{
		// Ensure that we have a valid service ID to work with:
		TMsvId iBioServiceId;

		iBioServiceId = SetBIOServiceIdL();

		HBufC* localBuffer = aText.AllocL();
		CleanupStack::PushL(localBuffer);

		TPtr messDes = localBuffer->Des();

		if (aMessageType != EBiovCardMessage && aMessageType
            != EBiovCalenderMessage)
			{
				// convert \r\n to \n since this is what is expected from SMS when not vCard data
				for (TInt i = 0; i < messDes.Length(); i++)
					{
						if (messDes[i] == (TText) '\r' && i < messDes.Length() - 1
								&& messDes[i + 1] == (TText) '\n')
							messDes.Delete(i, 1);
					}
			}

		//  Create and fill a CRichText object for the jobbie:
		CParaFormatLayer* paraFormatLayer = CParaFormatLayer::NewL();
		CleanupStack::PushL(paraFormatLayer);
		CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL();
		CleanupStack::PushL(charFormatLayer);
		CRichText* richText = CRichText::NewL(paraFormatLayer, charFormatLayer);
		CleanupStack::PushL(richText);

		TInt pos = richText->DocumentLength();
		richText->InsertL(pos, messDes);

		TMsvEntry newBioEntry;
		newBioEntry.SetNew(ETrue);
		newBioEntry.SetComplete(EFalse);
		newBioEntry.SetUnread(ETrue);
		newBioEntry.SetVisible(ETrue);
		newBioEntry.SetReadOnly(EFalse);
		newBioEntry.SetFailed(EFalse);
		newBioEntry.SetOperation(EFalse);
		newBioEntry.SetMultipleRecipients(EFalse);
		newBioEntry.SetAttachment(EFalse);
		newBioEntry.iMtm = KUidBIOMessageTypeMtm;
		newBioEntry.iType = KUidMsvMessageEntry;
		newBioEntry.iServiceId = iBioServiceId;
		TTime now;
		now.UniversalTime();
		newBioEntry.iDate = now;

		TTime unixEpoch(KUnixEpoch);
		TTimeIntervalSeconds seconds;
		TTime timeStamp = newBioEntry.iDate;
		timeStamp.SecondsFrom(unixEpoch, seconds);
		retTimeStamp.setTime_t(seconds.Int());

		newBioEntry.iDescription.Set(richText->Read(0, richText->DocumentLength()));
		TBufC<KTelephoneNumberMaxLength> telNumber;

		QString recepient(TEST_MSG_FROM1);
		tempNumber = XQConversions::qStringToS60Desc(recepient);

		telNumber = tempNumber->Des();
		newBioEntry.iDetails.Set(telNumber);

		SetForMtmTypeL(newBioEntry, aMessageType);

		newBioEntry.iSize = richText->DocumentLength();// msgSize;
		CreateBioEntryClientSideL(newBioEntry, *richText);

		CleanupStack::PopAndDestroy(4); // richText, charFormatLayer, paraFormatLayer, localBuffer
		return newBioEntry.Id();
}
/**
@SYMTestCaseID SYSLIB-FORMA-UT-1900
@SYMTestCaseDesc This function will run tests to check if the bidirectional state is being
maintained correctly. Documents containing a mix of different directionality are created and
specific edits which are of interest for each document are performed. These edits are location
specific and will depend on the bidirectional state of surrounding text.
@SYMTestPriority High
@SYMTestActions Edits are performed:
changing the base directionality of a paragraph
changing the directionality of text above the edit position
changing the directionality of neutral characters before and after edit position
changing the directionality of mirrored characters such as parenthesis
changing text directinality by adding explicit embedding
@SYMTestExpectedResults The test must not fail or panic .
@SYMDEF DEF092140, DEF092139
*/
void RunBidirectionalTestL(CRichText& aRichText, CBandMaintainer& aMaintainer, CBandValidator& aValidator)
	{

	aRichText.Reset();
	aMaintainer.InitialiseViewL();

//set up paragraph of just LTR text
	aRichText.InsertL(0, KBleak2);
	aMaintainer.InitialiseViewL();
	User::After(3000000);

//change paragraph base directionality by inserting a RLM marker at the beginning of the paragraph
	TInsertText insertRLM(aMaintainer, aRichText, aValidator, KRLM());
	insertRLM.ExecuteL(0, 1);
	User::After(3000000);

	aRichText.Reset();
	aMaintainer.InitialiseViewL();

//set up paragraph of LLL-RRR-LLL-NNN-RRR-LLL
	aRichText.InsertL(0, KEnglishLongWords_1);
	aRichText.InsertL(aRichText.DocumentLength(), KArabicLessThanALine);
	aRichText.InsertL(aRichText.DocumentLength(), KEnglishLessThanALine_1);
	aRichText.InsertL(aRichText.DocumentLength(), KPuncs);
	aRichText.InsertL(aRichText.DocumentLength(), KArabicLessThanALine);
	aRichText.InsertL(aRichText.DocumentLength(), KBleak2);
	aRichText.InsertL(aRichText.DocumentLength(), KParagraphDelimiter);
	aMaintainer.InitialiseViewL();
	User::After(1000000);

//delete the second run of LTR changing the directionality of the neutrals
	TDeleteText deleteText(aMaintainer, aRichText, aValidator);
	TInt editPos = KEnglishLongWords_1().Length()+KArabicLessThanALine().Length();
	deleteText.ExecuteL(editPos,KEnglishLessThanALine_1().Length());
	User::After(1000000);

//delete the second run of RTL characters to check if neutral directionality is maintained
	editPos = KEnglishLongWords_1().Length()+KArabicLessThanALine().Length()+KPuncs().Length();
	deleteText.ExecuteL(editPos,KArabicLessThanALine().Length());
	User::After(1000000);

	aRichText.Reset();
	aMaintainer.InitialiseViewL();

//set up band to be a paragraph of numbers followed by LTR i.e. EN-EN-EN-LLL
	aRichText.InsertL(aRichText.DocumentLength(), KNumbers);
	aRichText.InsertL(aRichText.DocumentLength(), KBleak2);
	aMaintainer.InitialiseViewL();
	User::After(3000000);

//edit to change directionality of numbers above the edit by inserting RTL text before the LTR
//This RLM works perfectly
	TInsertText insertArabic(aMaintainer, aRichText, aValidator, KArabicMoreThanALine());
	insertArabic.ExecuteL(KNumbers().Length(), KArabicMoreThanALine().Length());
	User::After(3000000);

//undo previous edit text will return to previous directionality
	deleteText.ExecuteL(KNumbers().Length(),KArabicMoreThanALine().Length());
	User::After(10000000);

	aRichText.Reset();
	aMaintainer.InitialiseViewL();

// Document containing RRRRR ( LLLL ) LLLL
	aRichText.InsertL(0, KArabicMoreThanALine);
	aRichText.InsertL(aRichText.DocumentLength(), KOpenBracket);
	aRichText.InsertL(aRichText.DocumentLength(), KEnglishLessThanALine_1);
	aRichText.InsertL(aRichText.DocumentLength(), KCloseBracket);
	aRichText.InsertL(aRichText.DocumentLength(), KEnglishLessThanALine_2);
	aRichText.InsertL(aRichText.DocumentLength(), KOpenBracket);
	aRichText.InsertL(aRichText.DocumentLength(), KEnglishLessThanALine_4);
	aRichText.InsertL(aRichText.DocumentLength(), KCloseBracket);
	aRichText.InsertL(aRichText.DocumentLength(), KParagraphDelimiter);
	aMaintainer.InitialiseViewL();

// Insert LTR after RTL test Doc should now be RRRR LLLL ( LLLL ) LLLL
	TInsertText insertEnglish(aMaintainer, aRichText, aValidator, KEnglishLessThanALine_3());
	insertEnglish.ExecuteL(KArabicMoreThanALine().Length(), KEnglishLessThanALine_3().Length());
// The brackets are now being displayed correctly
// BUT is the neutral English text meant to be displayed as RTL as initially inserted (no RLM)??
	User::After(10000000);

	aRichText.Reset();
	aMaintainer.InitialiseViewL();

// Just an arabic RTL sentence.
	aRichText.InsertL(0, KArabicMoreThanALine);
	aRichText.InsertL(aRichText.DocumentLength(), KParagraphDelimiter);
	aMaintainer.InitialiseViewL();

// Test formatting when inserting RTL enclosed in parenthesis
	TInsertText insertArabBrackets(aMaintainer, aRichText, aValidator, KArabicInParenthesis());
	insertArabBrackets.ExecuteL(KArabicMoreThanALine().Length(), KArabicInParenthesis().Length());
	User::After(1000000);

	aRichText.Reset();
	aMaintainer.InitialiseViewL();

// Just an arabic RTL sentence.
	aRichText.InsertL(0, KArabicMoreThanALine);
	aRichText.InsertL(aRichText.DocumentLength(), KParagraphDelimiter);
	aMaintainer.InitialiseViewL();

// Test formatting when inserting open parenthesis
	TInsertText insertOpen(aMaintainer, aRichText, aValidator, KOpenBracket());
	insertOpen.ExecuteL(KArabicMoreThanALine().Length(), KOpenBracket().Length());
	User::After(1000000);

// Test formatting when inserting RTL after opening parenthesis
	TInsertText insertArabicLessLine(aMaintainer, aRichText, aValidator, KArabicLessThanALine());
	insertArabicLessLine.ExecuteL(aRichText.DocumentLength()-1, KArabicLessThanALine().Length());
	User::After(1000000);

// Test formatting when inserting closing parenthesis after RTL text
	TInsertText insertClose(aMaintainer, aRichText, aValidator, KCloseBracket());
	insertClose.ExecuteL(aRichText.DocumentLength()-1, KOpenBracket().Length());
// This is now being displayed correctly
	User::After(10000000);

// Insert RTL text after parenthesis
	insertArabicLessLine.ExecuteL(aRichText.DocumentLength()-1, KArabicLessThanALine().Length());
// This is now being displayed correctly
	User::After(10000000);

	aRichText.Reset();
	aMaintainer.InitialiseViewL();

//Explicit Embedding testing
	aRichText.InsertL(0, KEnglishShortParagraph);
	aRichText.InsertL(aRichText.DocumentLength(), KRLE);
	aRichText.InsertL(aRichText.DocumentLength(), KFirstWordArabic);
	aRichText.InsertL(aRichText.DocumentLength(), KFirstWord);
	aRichText.InsertL(aRichText.DocumentLength(), KSecondWordArabic);
	aRichText.InsertL(aRichText.DocumentLength(), KSecondWord);
	aRichText.InsertL(aRichText.DocumentLength(), KThirdWordArabic);
	aRichText.InsertL(aRichText.DocumentLength(), KPDF);
	aRichText.InsertL(aRichText.DocumentLength(), KEnglishMoreThanALine_1);
	aRichText.InsertL(aRichText.DocumentLength(), KParagraphDelimiter);
	aMaintainer.InitialiseViewL();

	User::After(1000000);
	editPos=KEnglishShortParagraph().Length()+1;
//	TInsertText insertText2(aMaintainer, aRichText, aValidator, KEnglishLessThanALine_1());
	insertEnglish.ExecuteL(editPos,KEnglishLessThanALine_3().Length());
	User::After(1000000);
	}
/**
@SYMTestCaseID SYSLIB-FORMA-UT-1899
@SYMTestCaseDesc This function runs the scrolling tests. It sets up the documents then calls the ScrollTestL function
to scroll through them.
@SYMTestPriority High
@SYMTestActions The following paragraphs are tested by scrolling up and down through them:
A LTR paragraph containing a few lines of RTL text
A LTR paragraph containing less than a line of RTL text
A LTR paragraph containing a portion of RTL text which is greater than the band
A RTL paragraph containing a few lines of LTR text
A RTL paragraph containing less than a line of LTR text
A RTL paragraph containing a portion of LTR text which is greater than the band
@SYMTestExpectedResults The test must not fail or panic .
@SYMDEF DEF092140, DEF092139
*/
void RunScrollingTestsL(CRichText& aRichText, CBandMaintainer& aMaintainer, CBandValidator& aValidator)
	{
// set up 3 paragraphs of LTR with runs of RTL embedded in each paragraph
	aRichText.Reset();
	test.Start(_L("Scrolling LTR document with embedded RTL"));
	aMaintainer.InitialiseViewL();
//LTR paragraph containing a few lines of RTL text
	aRichText.InsertL(aRichText.DocumentLength(), KLTRWithRTL);
	aRichText.InsertL(aRichText.DocumentLength(), KParagraphDelimiter);
//LTR paragraph containing less than a line of RTL text
	aRichText.InsertL(aRichText.DocumentLength(), KLTRWithSmallRTL);
	aRichText.InsertL(aRichText.DocumentLength(), KParagraphDelimiter);
//LTR paragraph containing a portion of RTL text which is greater than the band
	aRichText.InsertL(aRichText.DocumentLength(), KLTRWithLargeRTL);
	aRichText.InsertL(aRichText.DocumentLength(), KParagraphDelimiter);
	ScrollingTestL(aMaintainer, aValidator);

// 3 paragraphs of RTL with runs of LTR embedded in each paragraph
	aRichText.Reset();
	test.Next(_L("Scrolling RTL document with embedded LTR"));
	aMaintainer.InitialiseViewL();
//RTL paragraph containing a few lines of LTR text
	aRichText.InsertL(aRichText.DocumentLength(), KRTLWithLTR);
	aRichText.InsertL(aRichText.DocumentLength(), KParagraphDelimiter);
//RTL paragraph containing less than a line of LTR text
	aRichText.InsertL(aRichText.DocumentLength(), KRTLWithSmallLTR);
	aRichText.InsertL(aRichText.DocumentLength(), KParagraphDelimiter);
//RTL paragraph containing a portion of LTR text which is greater than the band
	aRichText.InsertL(aRichText.DocumentLength(), KRTLWithLargeLTR);
	aRichText.InsertL(aRichText.DocumentLength(), KParagraphDelimiter);
	ScrollingTestL(aMaintainer, aValidator);
	test.End();
	}