コード例 #1
0
void CheckNoAttachmentsL()
	{
	CDummyObserver* ob1 = new(ELeave) CDummyObserver;
	CleanupStack::PushL(ob1);
	
	CMsvSession* session = CMsvSession::OpenSyncL(*ob1);
	CleanupStack::PushL(session);
	
	CMsvEntry* cEntry = CMsvEntry::NewL(*session, KMsvDraftEntryId, 
		TMsvSelectionOrdering(KMsvNoGrouping,EMsvSortByNone,ETrue));
	CleanupStack::PushL(cEntry);
	
	CMsvEntrySelection* selection = cEntry->ChildrenL();
	CleanupStack::PushL(selection);

	test(selection->Count() == 1);
	cEntry->SetEntryL((*selection)[0]);

	if (cEntry->HasStoreL())
		{
		CMsvStore* store = cEntry->ReadStoreL();
		CleanupStack::PushL(store);
	
		MMsvAttachmentManager& attachmentMgr = store->AttachmentManagerL();
		test(attachmentMgr.AttachmentCount() == 0);
		CleanupStack::PopAndDestroy(store);
		}

	CleanupStack::PopAndDestroy(4, ob1); // selection, cEntry, session, ob1
	}
void CMtfTestActionGetAttachmentFileFromIndex::RunTestActionL()
	{
	CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0));
	TMsvId messageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1));
	TInt attachIndex = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(2));
	HBufC* dataFilePath   = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(3), NULL);

	CMsvEntry* entry = paramSession->GetEntryL(messageEntry);
	CleanupStack::PushL(entry);
	
	CMsvStore* store = entry->ReadStoreL();
	CleanupStack::PushL(store);
	
	MMsvAttachmentManager& manager = store->AttachmentManagerL();
	
	RFile fileAttachment = manager.GetAttachmentFileL(attachIndex);
	CleanupClosePushL(fileAttachment);
	
	if( dataFilePath != NULL )
		{
		// check of contents of attachment file is requested
		CompareFileL(fileAttachment, *dataFilePath);
		}
	
	CleanupStack::PopAndDestroy(3, entry); // fileAttachment, store, entry
	}
コード例 #3
0
void CMtfTestActionCompareAttachment::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionCompareAttachment);
	CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0));
	TMsvId messageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1));
	TMsvAttachmentId attachId = ObtainValueParameterL<TMsvAttachmentId>(TestCase(),ActionParameters().Parameter(2));
	HBufC* dataFilePath   = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(3));

	CMsvEntry* entry = paramSession->GetEntryL(messageEntry);
	CleanupStack::PushL(entry);
	
	CMsvStore* store = entry->ReadStoreL();
	CleanupStack::PushL(store);
	
	MMsvAttachmentManager& manager = store->AttachmentManagerL();
	
	RFile fileAttachment = manager.GetAttachmentFileL(attachId);
	CleanupClosePushL(fileAttachment);
	
	CompareFileL(fileAttachment, *dataFilePath);
	
	CleanupStack::PopAndDestroy(&fileAttachment);
	
	CleanupStack::PopAndDestroy(2, entry); // store, entry
	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionCompareAttachment);
	TestCase().ActionCompletedL(*this);
	}
コード例 #4
0
/*
-----------------------------------------------------------------------------
RFile GetAttachmentFileL(TMsvAttachmentId aId)
----------------------------------------------------------------------------
*/
void CMailBoxContainer::OpenFileL(TBool /*aOpenWith*/)
{
	if(iSession && iSelectionBox)
	{	
		TInt CurrItmIndex = iSelectionBox->CurrentItemIndex();
		
		TMsvSelectionOrdering sort;
		sort.SetShowInvisibleEntries(ETrue);
		sort.SetSorting(EMsvSortByDate);
		// Take a handle to the folder entry
		CMsvEntry* parentEntry = CMsvEntry::NewL(*iSession,iCurrentMailBox,sort);
		CleanupStack::PushL(parentEntry);
		
		// A selection of all BT entries
		CMsvEntrySelection* entries = parentEntry->ChildrenL();//ChildrenWithMtmL(KUidMsgTypeBt);
		CleanupStack::PushL(entries);
			
		//Process all entries
		if(CurrItmIndex >= 0 && CurrItmIndex < iIDArray->Count())
		{
			//Get entry
			CMsvEntry* btEntry = iSession->GetEntryL(iIDArray->At(CurrItmIndex).iEnt);
			CleanupStack::PushL(btEntry);
			
			//Then get entrys child
			CMsvEntrySelection* btChildren = btEntry->ChildrenL();
			CleanupStack::PushL(btChildren);
		
			btEntry->SetEntryL(iIDArray->At(CurrItmIndex).iMsg);
									
			if (btEntry->HasStoreL())
			{
				CMsvStore* store = btEntry->ReadStoreL();
				CleanupStack::PushL(store);
				
				MMsvAttachmentManager& attMngr = store->AttachmentManagerL();
				CMsvAttachment* attachment = attMngr.GetAttachmentInfoL(iIDArray->At(CurrItmIndex).iAtt);
				if(attachment)
				{
					RFile SourceFil(attMngr.GetAttachmentFileL(iIDArray->At(CurrItmIndex).iAtt));
					iUtils.GetFileUtils().OpenFileWithHandler(SourceFil);
					SourceFil.Close();
				}
				
				CleanupStack::PopAndDestroy(store);
			}
			
			CleanupStack::PopAndDestroy(2);
		}				
		CleanupStack::PopAndDestroy(2);
	}
}
コード例 #5
0
TBool CT_MsgVerifyHeaders::VerifyMimeHeaderPartsL(CMsvEntrySelection* aEntrySelection)
	{
	TBool status = EPass;
	for(int index = 0; index < aEntrySelection->Count(); ++index)
		{
		CMsvEntry* entry = iSharedDataPOP.iSession->GetEntryL(aEntrySelection->At(index));
		CleanupStack::PushL(entry);
		CMsvStore* store = entry->ReadStoreL();
		CleanupStack::PushL(store);
		if (store->IsPresentL(KUidMsgFileMimeHeader))
			{
			CImMimeHeader* mimeHeader = CImMimeHeader::NewLC();
			mimeHeader->RestoreL(*store);
	
			TBuf<256> param;
			TPtrC contentType;
			param.Format(KContentType, index);
			if(GetStringFromConfig( ConfigSection(), param, contentType))
				{
				TPtrC8 content8 = mimeHeader->ContentType();
				HBufC* content16 = HBufC::NewLC(content8.Length());
				content16->Des().Copy(content8);
				if(contentType.Compare(content16->Des()))
					{
					ERR_PRINTF1(_L("Content Type is not matched"));
					status = EFail;
					}
				CleanupStack::PopAndDestroy(content16);
				}
			TPtrC contentSubType;
			param.Format(KContentSubType, index);
			if(GetStringFromConfig( ConfigSection(), param, contentSubType))
				{
				TPtrC8 content8 = mimeHeader->ContentSubType();
				HBufC* content16 = HBufC::NewLC(content8.Length());
				content16->Des().Copy(content8);
				if(contentSubType.Compare(content16->Des()))
					{
					ERR_PRINTF1(_L("Content Sub Type is not matched"));
					status = EFail;
					}
				CleanupStack::PopAndDestroy(content16);
				}
			CleanupStack::PopAndDestroy(mimeHeader);
			}
		CleanupStack::PopAndDestroy(store);
		CleanupStack::PopAndDestroy(entry);
		}
	return status;
	}
コード例 #6
0
/**
CountLinesOfBodyTextL()
Counts the lines of body text in the email aEntry

@param aEntry
A reference to an object representing the email

@param aFooterExists
Reference to a boolean variable - set to ETrue if the footer string is found in the body text

@param aFooterSize
Expected KB left on server inserted into footer string if present 

@return
Number of lines in the body text 
*/
TInt CT_MsgComparePopEmailMsgs::CountLinesOfBodyTextL(CMsvEntry& aEntry, TBool& aFooterExists, TInt& aFooterSize)
	{
	TInt lines = 0;
	aFooterExists=EFalse;
	aFooterSize=0;
	aEntry.SetEntryL(aEntry.EntryId());
	if(aEntry.HasStoreL())
		{
		CMsvStore*	msvStore1= aEntry.ReadStoreL();
		CleanupStack::PushL(msvStore1);
		CParaFormatLayer*	paraFormatLayer1 = CParaFormatLayer::NewL();
		CleanupStack::PushL(paraFormatLayer1);
		CCharFormatLayer*	charFormatLayer1 = CCharFormatLayer::NewL(); 
		CleanupStack::PushL(charFormatLayer1);
		CRichText*	bodyText1=CRichText::NewL(paraFormatLayer1, charFormatLayer1, CEditableText::EFlatStorage, 256);
		CleanupStack::PushL(bodyText1);

		bodyText1->Reset();
		if (msvStore1->HasBodyTextL())
			{
			msvStore1->RestoreBodyTextL(*bodyText1);
			TUint16 val = CEditableText::ELineBreak;
			TInt n = 0;
			TInt pos = 0;
			for(;;)
				{
				TPtrC bodyText = bodyText1->Read(pos);
				n = bodyText.Find(&val, 1);
				if(n < 0)
					break;
				lines++;
				pos += n+1;
				
				//This Check is needed to delete the extra line introduced by communigate Pro Server
				TInt fpos = CheckIfServerMessageExists(bodyText);
				if (fpos != KErrNotFound)
					{
					lines--;
					}
				}
			TPtrC	pBt = bodyText1->Read(0);
			aFooterExists = CheckIfFooterMessageExistsL(pBt , aFooterSize);
			}		
		CleanupStack::PopAndDestroy(4, msvStore1);  //bodyText1,charFormatLayer1,paraFormatLayer1,msvStore1.
		}
	return lines;
	}
コード例 #7
0
ファイル: T_CLT0.CPP プロジェクト: kuailexs/symbiandump-mw2
LOCAL_C void TestEntryStream(CMsvEntry& aEntry, TMsvId aId, TMsvId aService, TBool aAllDescendents)
{
    // get the store
    aEntry.SetEntryL(aId);
    CMsvStore* store=NULL;
    if(aEntry.HasStoreL()) store = aEntry.ReadStoreL();
    test(store==NULL || store->IsPresentL(KUidMsvHiddenEntryStream)==EFalse);
    delete store;
    // recurse into the children
    if (aAllDescendents)
    {
        CMsvEntrySelection* selection = aEntry.ChildrenL();
        TInt count=selection->Count();
        while (count--)
            TestEntryStream(aEntry, selection->At(count), aService, EFalse);
        delete selection;
    }
}
コード例 #8
0
TBool CSmsReplyToStep::CheckMessageL()
	{

	INFO_PRINTF1(_L("Received new message in Inbox - should be status report..."));
		
	TMsvSelectionOrdering ordering;	
	ordering.ShowInvisibleEntries();
	CMsvEntry* entry = CMsvEntry::NewL(*iSession, KMsvGlobalInBoxIndexEntryId,ordering);
	CleanupStack::PushL(entry);
	
	CMsvEntrySelection* msvEntrySelection;
	msvEntrySelection=entry->ChildrenL();
	CleanupStack::PushL(msvEntrySelection);
	
	// Check how many mesasges there are - should be just 1
	TInt count = msvEntrySelection->Count();
	INFO_PRINTF3(_L("Number of new messages: %d, should be: %d"), count, 1);

	// Restore the message
	CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsDeliver, *iTestUtils->iRichText);
	CleanupStack::PushL(header);
	entry->SetEntryL((*msvEntrySelection)[0]);

	CMsvStore* store = entry->ReadStoreL();
	CleanupStack::PushL(store);	
	header->RestoreL(*store);
	
	if(store->HasBodyTextL())
		{
		store->RestoreBodyTextL(*iTestUtils->iRichText);	
		}
		
	TBuf<KSmsDescriptionLength> desc;
	User::LeaveIfError(TSmsUtilities::GetDescription(header->Message(), desc));
	
	//Check for a reply address field
	CSmsReplyAddressOperations& operations = STATIC_CAST(CSmsReplyAddressOperations&,header->Message().GetOperationsForIEL(CSmsInformationElement::ESmsReplyAddressFormat));
	TBool result=operations.ContainsReplyAddressIEL();

	CleanupStack::PopAndDestroy(4,entry);	
	return result;	
	}
コード例 #9
0
/**
CountLinesOfHtmlL()
Counts the number of lines of HTML

@param aEntry
A reference to an object representing the email

@return
Number of lines of HTML
*/
TInt CT_MsgComparePopEmailMsgs::CountLinesOfHtmlL(CMsvEntry& aEntry)
	{ 
	TInt lines = 0;
	aEntry.SetEntryL(aEntry.EntryId());
	
	
	CMsvStore* store = aEntry.ReadStoreL();
	CleanupStack::PushL(store);
	
	MMsvAttachmentManager& attManager = store->AttachmentManagerL();
	
	RFile htmlFile = attManager.GetAttachmentFileL(0);
	CleanupClosePushL(htmlFile);
	
	_LIT8(KFindData, "\r\n");
	TInt htmlSize = 0;
	User::LeaveIfError(htmlFile.Size(htmlSize));
	HBufC8* fBuf = HBufC8::NewLC(htmlSize);
	TPtr8 p = fBuf->Des();
	htmlFile.Read(p);
	TInt pos = 0;
	for(;;)
		{
		pos = p.Find(KFindData);
		if(pos < 0)
			{
			break;
			}
		p = p.Mid(pos+2);
		lines++;
		}
		
	CleanupStack::PopAndDestroy(fBuf);
	CleanupStack::PopAndDestroy(); // htmlFile
	CleanupStack::PopAndDestroy(store);
	
	return lines;
	}
コード例 #10
0
ファイル: saex.cpp プロジェクト: Bathla/SMS_Encryptor
void CSAEXAppUi::CreateNewSMSMessageL()
    {
    
   	TMsvSelectionOrdering order( KMsvNoGrouping, EMsvSortByDate, ETrue );
    CMsvEntry* folderEntry = CMsvEntry::NewL( *iSession,KMsvDraftEntryId, order );
    CleanupStack::PushL( folderEntry );    
    CMsvEntrySelection* folderSelection = folderEntry->ChildrenWithTypeL(
        KUidMsvMessageEntry );
    CleanupStack::PushL( folderSelection );

	const TInt count( folderSelection->Count() );
	 for ( TInt i( 0 ); i < count; i++ )
	 {
		CMsvEntry *msgEntry; 		
       TMsvId msgEntryId = ( *folderSelection )[ i ];	  
		msgEntry=iSession->GetEntryL( msgEntryId);
		CleanupStack::PushL(msgEntry);

		if( msgEntry!= KErrNone )
		{

				if(true)//msgEntry->Entry().iType)//KUidMsvMessageEntry)
				{				
					CParaFormatLayer* paraLayer = CParaFormatLayer::NewL();
					CleanupStack::PushL(paraLayer); 
					CCharFormatLayer* charLayer = CCharFormatLayer::NewL(); 
					CleanupStack::PushL(charLayer); 
					CRichText* cipherBody = CRichText::NewL(paraLayer, charLayer); 
					CRichText * plainBody=CRichText::NewL(paraLayer, charLayer); 

					CleanupStack::PushL(cipherBody); 
					CleanupStack::PushL(plainBody); 

					CMsvStore* store= msgEntry->ReadStoreL();
					CleanupStack::PushL(store);

					store->RestoreBodyTextL(*cipherBody);

					CSendAs* iSendAs=NULL;   
					iSendAs = CSendAs::NewL(*this);				

					if(iSendAs)
						{
								CleanupStack::PushL(iSendAs);        
								iSendAs->SetMtmL(KUidMsgTypeSMS);        

								if(iSendAs->AvailableServices().Count()<1)
									{
										CEikonEnv::Static()->InfoMsg(_L("No SMS services available."));
										User::Leave(KErrNotFound);
									}
        
								iSendAs->SetService(0); 
        
								User::LeaveIfError(iSendAs->QueryMessageCapability(KUidMtmQueryCanSendMsg, EFalse));
								User::LeaveIfError(iSendAs->QueryMessageCapability(KUidMtmQueryMaxBodySize, ETrue));

        
								iSendAs->CreateMessageL();

								iSendAs->AddRecipientL( iRecipient->Des() );
								//iSendAs->SetSubjectL( KIGainTag ); 
								
								decryptBody(cipherBody,plainBody);								
								iSendAs->SetBodyL(*plainBody);									
								

								User::LeaveIfError(iSendAs->ValidateMessage());
								iSendAs->SaveMessageL(ETrue); // message is saved into Outbox(drafts)

								CleanupStack::PopAndDestroy(1,iSendAs);//plainBody and iSendAs

								
						}		

							CleanupStack::PopAndDestroy(5, paraLayer);	

					}
					else
					{
								CEikonEnv::Static()->AlertWin(_L("No SMS found."));
								User::Leave(KErrNotFound);
					
					}
						CleanupStack::PopAndDestroy(1, msgEntry);	
		}


	 }	 
	 	CleanupStack::PopAndDestroy( 2 ); 	

    }
コード例 #11
0
/**
 Function : doTestStepL
 Description : Verify if message part(s) of the message entries returned by sort mechanism are
			   in the intended order.
 @return : TVerdict - Test step result
 */
TVerdict CT_MsgVerifySortResult::doTestStepL()
	{
	INFO_PRINTF1(_L("Test Step : VerifySortResult"));
	TPtrC fieldName;
	TBuf<1> buf;
	TBool sortedByTo = ETrue;
	TBool sortedByFrom = ETrue;
	TBool sortedByCc = ETrue;
	TBool sortedByBcc = ETrue;
	TBool sortedBySubject = ETrue;
	TBool sortedByUnRead = ETrue;
	TBool sortedByDetails = ETrue;
	TBool sortedByDescription = ETrue;
	TBool sortedByDate = ETrue;
	TBool sortedBySize = ETrue;
	TBool sortedByAttachment = ETrue;
	TBool sortedByPriority = ETrue;
	TBool sortedById = ETrue;
	TBool sortedByNewFlag = ETrue;

	TInt expectedSearchResultCount = 0;
	GetIntFromConfig(ConfigSection(), KExpectedResultCount, expectedSearchResultCount); // Read search result count

	TInt resultCount = 0;
	GetIntFromConfig(ConfigSection(), KCountOfResult, resultCount); // Read search result count

	if(expectedSearchResultCount > 0 && resultCount == 0)
		{
		ERR_PRINTF2(_L("Expected SORT Result Count > 0 and Actual SORT result count = %d"), resultCount);		
		SetTestStepResult(EFail);
		}
	else if(expectedSearchResultCount == 0 && resultCount == 0)
		{
		SetTestStepResult(EPass);
		}
	else
		{
		RArray<TMsvEntry> messageEntries = iSharedDataCommon.iSearchSortResultArray;
		INFO_PRINTF2(_L("Number of entries to be verified = %d"), messageEntries.Count());
		DisplayMsgEntryList(messageEntries); // Log the message entry details
		if ( !GetStringFromConfig( ConfigSection(), KSortMsgPart, fieldName))
			{
			ERR_PRINTF1(_L("Message part to be verified for is not specified"));
			SetTestStepResult (EFail);
			}
		TMsvMessagePart msgPartValue = CT_MsgUtilsEnumConverter::ConvertDesToMessagePart(fieldName);		

		TPtrC sortOrder;
		GetStringFromConfig(ConfigSection(), KSortOrder, sortOrder);
		TMsvSortOrder sortOption = CT_MsgUtilsEnumConverter::ConvertDesToSortOrder(sortOrder);

		CMsvEntry *entry = CMsvEntry::NewL(*iSharedDataCommon.iSession, KMsvRootIndexEntryId, TMsvSelectionOrdering());
		CleanupStack::PushL(entry);

		switch(msgPartValue)
			{
		case EMsvTo:
			switch(sortOption)
				{
			case EMsvSortAscending:
				for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByTo; ++j)
					{
					entry->SetEntryL(messageEntries[j].Id());
					CMsvStore* store1 = entry->ReadStoreL();
					CleanupStack::PushL(store1);
					CImHeader* header1 = CImHeader::NewLC(); 
					header1->RestoreL(*store1); // Retrieves the email message header
					
					HBufC* address1=HBufC::NewL(50); 
					if(header1->ToRecipients().Count())
						{
						address1 = (header1->ToRecipients()[0]).AllocL();					
						}
	
					CleanupStack::PopAndDestroy(2,store1);
					
					entry->SetEntryL(messageEntries[j+1].Id());
					CMsvStore* store2 = entry->ReadStoreL();
					CleanupStack::PushL(store2);
					CImHeader* header2 = CImHeader::NewLC(); 
					header2->RestoreL(*store2); // Retrieves the email message header
					
					HBufC* address2=HBufC::NewL(50); 
					//  FIx when no fields are there
					if(header2->ToRecipients().Count())
						{
						 address2 = (header2->ToRecipients()[0]).AllocL();
						}
					CleanupStack::PopAndDestroy(2,store2);	

					if(address1->CompareF(*address2) > 0)// Checks if any messages is not in Ascending order   w.r.t to TO field
						{
						ERR_PRINTF1(_L("Sorting by TO: Not in Ascending order"));
						sortedByTo = EFalse;
						SetTestStepResult(EFail);
						}
					delete address2;
					delete address1;	
					}
				break;
			case EMsvSortDescending:
				for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByTo; ++j)
					{
					entry->SetEntryL(messageEntries[j].Id());
					CMsvStore* store1 = entry->ReadStoreL();
					CleanupStack::PushL(store1);
					CImHeader* header1 = CImHeader::NewLC(); 
					header1->RestoreL(*store1); // Retrieves the email message header
					HBufC* address1=HBufC::NewL(50); 
					if(header1->ToRecipients().Count())
						{
						address1 = (header1->ToRecipients()[0]).AllocL();					
						}
					CleanupStack::PopAndDestroy(2,store1);
					
					entry->SetEntryL(messageEntries[j+1].Id());
					CMsvStore* store2 = entry->ReadStoreL();
					CleanupStack::PushL(store2);
					CImHeader* header2 = CImHeader::NewLC(); 
					header2->RestoreL(*store2); // Retrieves the email message header
					HBufC* address2=HBufC::NewL(50); 
					//  FIx when no fields are there
					if(header2->ToRecipients().Count())
						{
						 address2 = (header2->ToRecipients()[0]).AllocL();
						}
					CleanupStack::PopAndDestroy(2,store2);	

					if(address1->CompareF(*address2) < 0)// Checks if any messages is not in Descending order  w.r.t to TO field
						{
						ERR_PRINTF1(_L("Sorting by TO: Not in Descending order"));
						sortedByTo = EFalse;
						SetTestStepResult(EFail);
						}
					delete address2;
					delete address1;	
					}
				break;
				}
			break;
		case EMsvFrom:
			switch(sortOption)
				{
			case EMsvSortAscending:
				for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByFrom; ++j)
					{
					entry->SetEntryL(messageEntries[j].Id());
					CMsvStore* store1 = entry->ReadStoreL();
					CleanupStack::PushL(store1);
					CImHeader* header1 = CImHeader::NewLC(); 
					header1->RestoreL(*store1); // Retrieves the email message header
					HBufC* address1 = header1->From().AllocL();
					CleanupStack::PopAndDestroy(2,store1);

					entry->SetEntryL(messageEntries[j+1].Id());
					CMsvStore* store2 = entry->ReadStoreL();
					CleanupStack::PushL(store2);
					CImHeader* header2 = CImHeader::NewLC(); 
					header2->RestoreL(*store2); // Retrieves the email message header
					HBufC* address2 = header2->From().AllocL();
					CleanupStack::PopAndDestroy(2,store2);	

					if(address1->CompareF(*address2) > 0)// Checks if any messages is not in Ascending order w.r.t to FROM field
						{
						ERR_PRINTF1(_L("Sorting by From: Not in Ascending order"));
						sortedByFrom = EFalse;
						SetTestStepResult(EFail);
						}
					delete address2;
					delete address1;	
					}
				break;
			case EMsvSortDescending:
				for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByFrom; ++j)
					{
					entry->SetEntryL(messageEntries[j].Id());
					CMsvStore* store1 = entry->ReadStoreL();
					CleanupStack::PushL(store1);
					CImHeader* header1 = CImHeader::NewLC(); 
					header1->RestoreL(*store1); // Retrieves the email message header
					HBufC* address1 = header1->From().AllocL();
					CleanupStack::PopAndDestroy(2,store1);
					
					entry->SetEntryL(messageEntries[j+1].Id());
					CMsvStore* store2 = entry->ReadStoreL();
					CleanupStack::PushL(store2);
					CImHeader* header2 = CImHeader::NewLC(); 
					header2->RestoreL(*store2); // Retrieves the email message header
					HBufC* address2 = header2->From().AllocL();
					CleanupStack::PopAndDestroy(2,store2);	

					if(address1->CompareF(*address2) < 0)// Checks if any messages is not in Descending order w.r.t to FROM field
						{
						ERR_PRINTF1(_L("Sorting by From: Not in Descending order"));
						sortedByFrom = EFalse;
						SetTestStepResult(EFail);
						}
					delete address2;
					delete address1;	
					}
				break;
				}
			break;
		case EMsvCc:
			switch(sortOption)
				{
			case EMsvSortAscending:
				for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByCc; ++j)
					{
					HBufC* address1 = HBufC::NewL(50); 
					entry->SetEntryL(messageEntries[j].Id());
					CMsvStore* store1 = entry->ReadStoreL();
					CleanupStack::PushL(store1);
					CImHeader* header1 = CImHeader::NewLC(); 
					header1->RestoreL(*store1); // Retrieves the email message header
					
					if(header1->CcRecipients().Count())
						{
						address1 = (header1->CcRecipients()[0]).AllocL();					
						}
					CleanupStack::PopAndDestroy(2,store1);
					
					HBufC* address2 = HBufC::NewL(50); 
					entry->SetEntryL(messageEntries[j+1].Id());
					CMsvStore* store2 = entry->ReadStoreL();
					CleanupStack::PushL(store2);
					CImHeader* header2 = CImHeader::NewLC(); 
					header2->RestoreL(*store2); // Retrieves the email message header
				
					if(header2->CcRecipients().Count())
						{
						address2 = (header2->CcRecipients()[0]).AllocL();					
						}
					CleanupStack::PopAndDestroy(2,store2);
				
					if(address1->CompareF(*address2) > 0)// Checks if any messages is not in Ascending order w.r.t to CC field
						{
						ERR_PRINTF1(_L("Sorting by CC: Not in Ascending order"));
						sortedByCc = EFalse;
						SetTestStepResult(EFail);
						}
					delete address2;
					delete address1;	
					}
				break;
			case EMsvSortDescending:
				for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByCc; ++j)
					{
					HBufC* address1 = HBufC::NewL(50); 
					entry->SetEntryL(messageEntries[j].Id());
					CMsvStore* store1 = entry->ReadStoreL();
					CleanupStack::PushL(store1);
					CImHeader* header1 = CImHeader::NewLC(); 
					header1->RestoreL(*store1); // Retrieves the email message header
					
					if(header1->CcRecipients().Count())
						{
						address1 = (header1->CcRecipients()[0]).AllocL();					
						}
					CleanupStack::PopAndDestroy(2,store1);
					
					
					HBufC* address2 = HBufC::NewL(50); 
					entry->SetEntryL(messageEntries[j+1].Id());
					CMsvStore* store2 = entry->ReadStoreL();
					CleanupStack::PushL(store2);
					CImHeader* header2 = CImHeader::NewLC(); 
					header2->RestoreL(*store2); // Retrieves the email message header
				
					if(header2->CcRecipients().Count())
						{
						address2 = (header2->CcRecipients()[0]).AllocL();					
						}
					CleanupStack::PopAndDestroy(2,store2);
				
									
					if(address1->CompareF(*address2) < 0)// Checks if any messages is not in Descending order w.r.t to CC field
						{
						ERR_PRINTF1(_L("Sorting by CC: Not in Descending order"));
						sortedByCc = EFalse;
						SetTestStepResult(EFail);
						}
					delete address2;
					delete address1;	
					}
				break;
				}
			break;
		case EMsvBcc:
			switch(sortOption)
				{
			case EMsvSortAscending:
				for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByBcc; ++j)
					{
					HBufC* address1 = HBufC::NewL(50); 
					if(messageEntries[j].iMtm != KUidMsgTypeSMS)
						{
						entry->SetEntryL(messageEntries[j].Id());
						CMsvStore* store1 = entry->ReadStoreL();
						CleanupStack::PushL(store1);
						CImHeader* header1 = CImHeader::NewLC(); 
						header1->RestoreL(*store1); // Retrieves the email message header
						if(header1->BccRecipients().Count())
							{
							address1 = (header1->BccRecipients()[0]).AllocL();					
							}
						CleanupStack::PopAndDestroy(2,store1);
						}
					else
						{
						buf.Copy(_L(""));
						address1 = buf.AllocL();
						}
					
					HBufC* address2 = HBufC::NewL(50); 
					if(messageEntries[j+1].iMtm != KUidMsgTypeSMS)
						{
						entry->SetEntryL(messageEntries[j+1].Id());
						CMsvStore* store2 = entry->ReadStoreL();
						CleanupStack::PushL(store2);
						CImHeader* header2 = CImHeader::NewLC(); 
						header2->RestoreL(*store2); // Retrieves the email message header
						if(header2->BccRecipients().Count())
							{
							address2 = (header2->BccRecipients()[0]).AllocL();					
							}
						CleanupStack::PopAndDestroy(2,store2);
						}
					else
						{
						buf.Copy(_L(""));
						address2 = buf.AllocL();
						}

					if(address1->CompareF(*address2) > 0)// Checks if any messages is not in Ascending order w.r.t to BCC field
						{
						ERR_PRINTF1(_L("Sorting by BCC: Not in Ascending order"));
						sortedByBcc = EFalse;
						SetTestStepResult(EFail);
						}
					delete address2;
					delete address1;	
					}
				break;
				
			case EMsvSortDescending:
				for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByBcc; ++j)
					{
					HBufC* address1 = HBufC::NewL(50); 
					if(messageEntries[j].iMtm != KUidMsgTypeSMS)
						{
						entry->SetEntryL(messageEntries[j].Id());
						CMsvStore* store1 = entry->ReadStoreL();
						CleanupStack::PushL(store1);
						CImHeader* header1 = CImHeader::NewLC(); 
						header1->RestoreL(*store1); // Retrieves the email message header
						if(header1->BccRecipients().Count())
							{
							address1 = (header1->BccRecipients()[0]).AllocL();					
							}
						CleanupStack::PopAndDestroy(2,store1);
						}
					else
						{
						buf.Copy(_L(""));
						address1 = buf.AllocL();
						}
					HBufC* address2 = HBufC::NewL(50); 
					if(messageEntries[j].iMtm != KUidMsgTypeSMS)
						{
						entry->SetEntryL(messageEntries[j+1].Id());
						CMsvStore* store2 = entry->ReadStoreL();
						CleanupStack::PushL(store2);
						CImHeader* header2 = CImHeader::NewLC(); 
						header2->RestoreL(*store2); // Retrieves the email message header
						if(header2->BccRecipients().Count())
							{
							address2 = (header2->BccRecipients()[0]).AllocL();					
							}
						CleanupStack::PopAndDestroy(2,store2);
						}
					else
						{
						buf.Copy(_L(""));
						address2 = buf.AllocL();
						}

					if(address1->CompareF(*address2) < 0)// Checks if any messages is not in Descending order w.r.t to BCC field
						{
						ERR_PRINTF1(_L("Sorting by BCC: Not in Descending order"));
						sortedByBcc = EFalse;
						SetTestStepResult(EFail);
						}
					delete address2;
					delete address1;	
					}
				break;
				}
			break;
		case EMsvSubject:
			switch(sortOption)
				{
			case EMsvSortAscending:
				for(TInt j = 0; j < messageEntries.Count() - 1 && sortedBySubject; ++j)
					{
					entry->SetEntryL(messageEntries[j].Id());
					CMsvStore* store1 = entry->ReadStoreL();
					CleanupStack::PushL(store1);
					CImHeader* header1 = CImHeader::NewLC(); 
					header1->RestoreL(*store1); // Retrieves the email message header
					HBufC* subject1 = header1->Subject().AllocL();
					CleanupStack::PopAndDestroy(2,store1);

					entry->SetEntryL(messageEntries[j+1].Id());
					CMsvStore* store2 = entry->ReadStoreL();
					CleanupStack::PushL(store2);
					CImHeader* header2 = CImHeader::NewLC(); 
					header2->RestoreL(*store2); // Retrieves the email message header
					HBufC* subject2 = header2->Subject().AllocL();
					CleanupStack::PopAndDestroy(2,store2);

					if(subject1->CompareF(*subject2) > 0)// Checks if any messages is not in Ascending order w.r.t to SUBJECT field
						{
						ERR_PRINTF1(_L("Sorting by Subject: Not in Ascending order"));
						sortedBySubject = EFalse;
						SetTestStepResult(EFail);
						}
					delete subject2;
					delete subject1;	
					}
				break;
			case EMsvSortDescending:
				for(TInt j = 0; j < messageEntries.Count() - 1 && sortedBySubject; ++j)
					{
					entry->SetEntryL(messageEntries[j].Id());
					CMsvStore* store1 = entry->ReadStoreL();
					CleanupStack::PushL(store1);
					CImHeader* header1 = CImHeader::NewLC(); 
					header1->RestoreL(*store1); // Retrieves the email message header
					
					entry->SetEntryL(messageEntries[j+1].Id());
					CMsvStore* store2 = entry->ReadStoreL();
					CleanupStack::PushL(store2);
					CImHeader* header2 = CImHeader::NewLC(); 
					header2->RestoreL(*store2); // Retrieves the email message header

					if(header1->Subject().CompareF(header2->Subject()) < 0)// Checks if any messages is not in Descending order w.r.t to SUBJECT field
						{
						ERR_PRINTF1(_L("Sorting by Subject: Not in Descending order"));
						sortedBySubject = EFalse;
						SetTestStepResult(EFail);
						}
					CleanupStack::PopAndDestroy(4, store1);	
					}
				break;
				}
			break;
		case EMsvUnreadMessages:
			switch(sortOption)
				{
			case EMsvSortAscending:
				for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByUnRead; ++j)
					{
					if(messageEntries[j].Unread() > messageEntries[j+1].Unread()) // Checks if any messages is not in Ascending order
						{
						ERR_PRINTF1(_L("Sorting by UnReadFlag: Not in Ascending order"));
						sortedByUnRead = EFalse;
						SetTestStepResult(EFail);
						}
					}
				break;
			case EMsvSortDescending:
				for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByUnRead; ++j)
					{
					if(messageEntries[j].Unread() < messageEntries[j+1].Unread()) // Checks if any messages is not in Descending order
						{
						ERR_PRINTF1(_L("Sorting by UnReadFlag: Not in Descending order"));
						sortedByUnRead = EFalse;
						SetTestStepResult(EFail);
						}
					}
				}
			break;
		case EMsvDetails:
			switch(sortOption)
				{
			case EMsvSortAscending:
				for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByDetails; ++j)
					{
					if(messageEntries[j].iDetails.CompareF(messageEntries[j+1].iDetails) > 0)// Checks if any messages is not in Ascending order
						{
						ERR_PRINTF1(_L("Sorting by Details: Not in Ascending order"));
						sortedByDetails = EFalse;
						SetTestStepResult(EFail);
						}
					}
				break;
			case EMsvSortDescending:
				for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByDetails; ++j)
					{
					if(messageEntries[j].iDetails.CompareF(messageEntries[j+1].iDetails) < 0) // Checks if any messages is not in Descending order
						{
						ERR_PRINTF1(_L("Sorting by Details: Not in Descending order"));
						sortedByDetails = EFalse;
						SetTestStepResult(EFail);
						}
					}
				}
			break;
		case EMsvDescription:
			switch(sortOption)
				{
			case EMsvSortAscending:
				for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByDescription; ++j)
					{
					if(messageEntries[j].iDescription.CompareF(messageEntries[j+1].iDescription) > 0)// Checks if any messages is not in Ascending order
						{
						ERR_PRINTF1(_L("Sorting by Description: Not in Ascending order"));
						sortedByDescription = EFalse;
						SetTestStepResult(EFail);
						}
					}
				break;
			case EMsvSortDescending:
				for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByDescription; ++j)
					{
					if(messageEntries[j].iDescription.CompareF(messageEntries[j+1].iDescription) < 0) // Checks if any messages is not in Descending order
						{
						ERR_PRINTF1(_L("Sorting by Description: Not in Descending order"));
						sortedByDescription = EFalse;
						SetTestStepResult(EFail);
						}
					}
				}
			break;
		case EMsvDate:
			switch(sortOption)
				{
			case EMsvSortAscending:
				for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByDate; ++j)
					{
					if(messageEntries[j].iDate > messageEntries[j+1].iDate) // Checks if any messages is not in Ascending order
						{
						ERR_PRINTF1(_L("Sorting by Date: Not in Ascending order"));
						sortedByDate = EFalse;
						SetTestStepResult(EFail);
						}
					}
				break;
			case EMsvSortDescending:
				for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByDate; ++j)
					{
					if(messageEntries[j].iDate < messageEntries[j+1].iDate) // Checks if any messages is not in Descending order
						{
						ERR_PRINTF1(_L("Sorting by Date: Not in Descending order"));
						sortedByDate = EFalse;
						SetTestStepResult(EFail);
						}
					}
				}
			break;
		case EMsvSize:
			switch(sortOption)
				{
			case EMsvSortAscending:
				for(TInt j = 0; j < messageEntries.Count() - 1 && sortedBySize; ++j)
					{
					if(messageEntries[j].iSize > messageEntries[j+1].iSize) // Checks if any messages is not in Ascending order
						{
						ERR_PRINTF1(_L("Sorting by Size: Not in Ascending order"));
						sortedBySize = EFalse;
						SetTestStepResult(EFail);
						}
					}
				break;
			case EMsvSortDescending:
				for(TInt j = 0; j < messageEntries.Count() - 1 && sortedBySize; ++j)
					{
					if(messageEntries[j].iSize < messageEntries[j+1].iSize) // Checks if any messages is not in Descending order
						{
						ERR_PRINTF1(_L("Sorting by Size: Not in Descending order"));
						sortedBySize = EFalse;
						SetTestStepResult(EFail);
						}
					}
				}
			break;
		case EMsvAttachment:
			switch(sortOption)
				{
			case EMsvSortAscending:
				for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByAttachment; ++j)
					{
					if(messageEntries[j].Attachment() > messageEntries[j+1].Attachment()) // Checks if any messages is not in Ascending order
						{
						ERR_PRINTF1(_L("Sorting by AttachmentFlag: Not in Ascending order"));
						sortedByAttachment = EFalse;
						SetTestStepResult(EFail);
						}
					}
				break;
			case EMsvSortDescending:
				for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByAttachment; ++j)
					{
					if(messageEntries[j].Attachment() < messageEntries[j+1].Attachment()) // Checks if any messages is not in Descending order
						{
						ERR_PRINTF1(_L("Sorting by AttachmentFlag: Not in Descending order"));
						sortedByAttachment = EFalse;
						SetTestStepResult(EFail);
						}
					}
				}
			break;
		case EMsvNew:
			switch(sortOption)
				{
			case EMsvSortAscending:
				for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByNewFlag; ++j)
					{
					if(messageEntries[j].New() < messageEntries[j+1].New()) // Checks if any messages is not in Ascending order
						{
						ERR_PRINTF1(_L("Sorting by NewFlag: Not in Ascending order"));
						sortedByNewFlag = EFalse;
						SetTestStepResult(EFail);
						}
					}
				break;
			case EMsvSortDescending:
				for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByNewFlag; ++j)
					{
					if(messageEntries[j].New() > messageEntries[j+1].New()) // Checks if any messages is not in Descending order
						{
						ERR_PRINTF1(_L("Sorting by NewFlag: Not in Descending order"));
						sortedByNewFlag = EFalse;
						SetTestStepResult(EFail);
						}
					}
				}
			break;
		case EMsvBody:
			SetTestStepError(KErrNotSupported);
			break;
		case EMsvPriority:
			switch(sortOption)
				{
			case EMsvSortAscending:
				for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByPriority; ++j)
					{
					if(messageEntries[j].Priority() < messageEntries[j+1].Priority()) // Checks if any messages is not in Ascending order
						{
						ERR_PRINTF1(_L("Sorting by AttachmentFlag: Not in Ascending order"));
						sortedByPriority = EFalse;
						SetTestStepResult(EFail);
						}
					}
				break;
			case EMsvSortDescending:
				for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByPriority; ++j)
					{
					if(messageEntries[j].Priority() > messageEntries[j+1].Priority()) // Checks if any messages is not in Descending order
						{
						ERR_PRINTF1(_L("Sorting by AttachmentFlag: Not in Descending order"));
						sortedByPriority = EFalse;
						SetTestStepResult(EFail);
						}
					}
				}
			break;
		case EMsvMtmTypeUID:
			break;
			}
		CleanupStack::PopAndDestroy(1, entry);
		}
	return TestStepResult();	
	}
コード例 #12
0
/**
CountLinesOfBodyTextL()
Counts the lines of body text in the email aEntry

@param aEntry
A reference to an object representing the email

@param aFooterExists
Reference to a boolean variable - set to ETrue if the footer string is found in the body text

@param aFooterSize
Expected KB left on server inserted into footer string if present 

@return
Number of lines in the body text 
*/
TInt CT_MsgComparePopEmailMsgs::CountLinesOfBodyTextL(CMsvEntry& aEntry, TBool& aFooterExists, TInt& aFooterSize)
	{
	TInt lines = 0;
	TInt count =0;
	aFooterExists=EFalse;
	aFooterSize=0;
	aEntry.SetEntryL(aEntry.EntryId());
	if(aEntry.HasStoreL())
		{
		CMsvStore*	msvStore1= aEntry.ReadStoreL();
		CleanupStack::PushL(msvStore1);
		CParaFormatLayer*	paraFormatLayer1 = CParaFormatLayer::NewL();
		CleanupStack::PushL(paraFormatLayer1);
		CCharFormatLayer*	charFormatLayer1 = CCharFormatLayer::NewL(); 
		CleanupStack::PushL(charFormatLayer1);
		CRichText*	bodyText1=CRichText::NewL(paraFormatLayer1, charFormatLayer1, CEditableText::EFlatStorage, 256);
		CleanupStack::PushL(bodyText1);

		bodyText1->Reset();
		if (msvStore1->HasBodyTextL())
			{
			msvStore1->RestoreBodyTextL(*bodyText1);
			TUint16 val = CEditableText::ELineBreak;
			TUint16 val1 = CEditableText::EParagraphDelimiter;
			TUint16 val2 = KUnicodeValue;
			
			TInt n = 0;
			TInt pos = 0;
			for(;;)
				{
				TPtrC bodyText = bodyText1->Read(pos);
				n = bodyText.Find(&val, 1);
								
				// if iStore8BitData flag is set, the line is terminated by "CEditableText::EParagraphDelimiter"			
				if(msvStore1->IsPresentL(KMsvPlainBodyText8))
					{
					if ( 0 == count )
						{
						TPtrC buffer = bodyText.Mid(0,n+2);
						// eg for 8bit the body look as : This is a simple email message.\x2028\x2029\x2029
						// eg for 16bit the body look as: This is a simple email message.\x2028\x2028\x2029
						if((bodyText.Right(2).Compare(KParagraphDelimiter)==KErrNone) && \
									 buffer.Find(&val2,1) != 75)
							{
							lines++;	
							count++;
							}				
							// Increment the line if EParagraphDelimiter or 0x0046 is found sequence as eg:1. \x2028\x2029
							// 2. \x2028\x2029\x2028\x2029\x0046 3. \x2028\x2029\x2028\x2029\x2028\x2029
						else if ( (buffer.Find(&val1,1)==0 && n==-1) || (buffer.Find(&val2,1)==1) \
										|| (buffer.Find(&val1,1)>0) )
							{
							lines++;		
							}
						}
					}
				if(n < 0)
					break;
				lines++;
				pos += n+1;
								
				//This Check is needed to delete the extra line introduced by communigate Pro Server
				TInt fpos = CheckIfServerMessageExists(bodyText);
				if (fpos != KErrNotFound)
					{
					lines--;
					}
				}
			TPtrC	pBt = bodyText1->Read(0);
			aFooterExists = CheckIfFooterMessageExistsL(pBt , aFooterSize);
			}		
		CleanupStack::PopAndDestroy(4, msvStore1);  //bodyText1,charFormatLayer1,paraFormatLayer1,msvStore1.
		}
	return lines;
	}
/**
  ExecuteActionL
  Parse the Email file and creates an email in the specified local folder.  Creates
  simple emails, emails with HTML, attachments, multipart and embedded emails.
  @internalTechnology 
  @pre    None
  @post   None
  @leave  System wide errors
*/
void CMtfTestActionCreateSmtpMessageFromEmailFile::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionCreateSmtpMessageFromEmailFile);
	CMsvSession* paramSession	= ObtainParameterReferenceL<CMsvSession>(TestCase(),
									ActionParameters().Parameter(0));
								 
	TMsvId paramServiceId 		= ObtainValueParameterL<TMsvId>(TestCase(),
									ActionParameters().Parameter(1));
								 
	TMsvId paramFolderId 		= ObtainValueParameterL<TMsvId>(TestCase(),
								    ActionParameters().Parameter(2));
								 
	TInt paramConfigIndexMailFile = ObtainValueParameterL<TInt>(TestCase(),
								 ActionParameters().Parameter(3),0);
	
	TInt overrideAddress=0;
	if(ActionParameters().Count()>5)
		{
		overrideAddress=ObtainValueParameterL<TInt>(TestCase(),
								 ActionParameters().Parameter(5));		
		}

	TPtrC fileName = TestCase().GetConfigurationFileL(CMtfConfigurationType::EMtfEmailFile,
														paramConfigIndexMailFile);

	/************************************************************************************
	Get the name of the Email file save at the Configuration file index, open the  file, 
	read one line of text from the file, parse the line and set the fields of the email 
	message based on the contents of the parsed line.
	************************************************************************************/
	
	// Set the context ot the folder in which emails have to be created
	CMsvEntry* entry = CMsvEntry::NewL(*paramSession,paramFolderId,TMsvSelectionOrdering());
	CleanupStack::PushL(entry);
	entry->SetEntryL(paramFolderId);

	RFs fs;
	fs.Connect();

	CImCltRecvConvert* recvConvert = CImCltRecvConvert::NewLC(fs,entry,KUidMsgTypeSMTP,
															   paramServiceId);
	recvConvert->SetMsvId(paramFolderId);

	// Open the Email file
	RFile file;
	User::LeaveIfError(file.Open(fs,fileName,EFileRead));

	TestCase().INFO_PRINTF2(_L("Email Data file: %S"), &fileName);
	
	TBuf8<KMaxLenghtOfLine> line;
	TBuf8<1> aChar;				// To read one character from the file
	TBool finished = FALSE;

	recvConvert->ResetL();

	// Parse each line from the 

	do {
		line.FillZ();
		line.SetLength(0);
		// Read one line from email file
		do {
			file.Read(aChar, 1);
			if(aChar.Length())
				{
				line.Append(aChar);
				}
			else
				{
				finished = TRUE;
				}
			} while(aChar.Length() && aChar[0] != 0x0A);
			
			if(!line.Length())
				{
				break;
				}
			// Parse the line for the fields of the email and store them
			recvConvert->ParseNextFieldL(line);
		} while(!finished);


	/****************************************************************************
	 Complete the message creation by setting all the required fields and 
	 storing the email on to the message store.
	 The created email's ID is returned by MessageCompelteL function
	****************************************************************************/
	TMsvId paramMessageId;
	paramMessageId = recvConvert->MessageCompleteL();

	if(paramMessageId == 0)
		{
		User::Leave(KErrUnknown);
		}

	file.Close();
	CleanupStack::PopAndDestroy(recvConvert);
	
	if(overrideAddress)
		{
#ifndef __MESSAGING_API_V2__		
		entry->SetEntryL(paramServiceId);
		CMsvStore* store=entry->ReadStoreL();
		CleanupStack::PushL(store);
#endif		
		CImSmtpSettings* settings= new(ELeave) CImSmtpSettings();
		CleanupStack::PushL(settings);
#ifdef __MESSAGING_API_V2__
 		CEmailAccounts* accounts = CEmailAccounts::NewLC();
 		TSmtpAccount smtpAccount;
 		accounts->GetSmtpAccountL(paramServiceId, smtpAccount);
		accounts->LoadSmtpSettingsL(smtpAccount, *settings);
		CleanupStack::PopAndDestroy();
#else		
		settings->RestoreL(*store);
		CleanupStack::PopAndDestroy();
#endif		
		HBufC* emailAddress=settings->EmailAddress().AllocL();
		CleanupStack::PopAndDestroy();
		CleanupStack::PushL(emailAddress);
		entry->SetEntryL(paramMessageId);
#ifdef __MESSAGING_API_V2__
		CMsvStore* store=entry->EditStoreL();
#else
		
		store=entry->EditStoreL();
#endif
		CleanupStack::PushL(store);
		
		CImHeader* header= CImHeader::NewLC();
		header->RestoreL(*store);
		
		header->ToRecipients().Reset();
		header->ToRecipients().AppendL(*emailAddress);
		
		header->StoreL(*store);
		store->CommitL();
		
		CleanupStack::PopAndDestroy(3,emailAddress);
		}
	
	CleanupStack::PopAndDestroy(entry);

	TestCase().INFO_PRINTF2(_L("Created a email from file %S"),&fileName);

	StoreParameterL<TMsvId>(TestCase(),paramMessageId,ActionParameters().Parameter(4));
	fs.Close();
	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionCreateSmtpMessageFromEmailFile);
	TestCase().ActionCompletedL(*this);
	}
コード例 #14
0
/*
-----------------------------------------------------------------------------
----------------------------------------------------------------------------
*/
void CMailBoxContainer::ReadMailFolderL(TMsvId aSelected)
{
	iCurrentMailBox = aSelected;

	delete iIDArray;
	iIDArray = NULL;
	
	if(iSession && iSelectionBox)
	{
		TInt OrgCount = iSelectionBox->Model()->ItemTextArray()->MdcaCount();
		STATIC_CAST(CDesCArray*,iSelectionBox->Model()->ItemTextArray())->Reset();
		
		RPointerArray<CFFileTypeItem> ItemTypeArray  = iUtils.GetFileUtils().GetItemTypeArray();

		iIDArray = new(ELeave)CArrayFixFlat<TMyMailEntry>(10);
	
		TMsvSelectionOrdering sort;
		sort.SetShowInvisibleEntries(ETrue);
		sort.SetSorting(EMsvSortByDate);
		// Take a handle to the folder entry
		CMsvEntry* parentEntry = CMsvEntry::NewL(*iSession,aSelected,sort);
		CleanupStack::PushL(parentEntry);
		
		// A selection of all BT entries
		CMsvEntrySelection* entries = parentEntry->ChildrenL();//ChildrenWithMtmL(KUidMsgTypeBt);
		CleanupStack::PushL(entries);
			
	
		//Process all entries
		for(TInt ii = 0; ii < entries->Count(); ii++)
		{
			//Get entry
			CMsvEntry* btEntry = iSession->GetEntryL((*entries)[ii]);
			CleanupStack::PushL(btEntry);
			
			//Then get entrys child
			CMsvEntrySelection* btChildren = btEntry->ChildrenL();
			CleanupStack::PushL(btChildren);
			
			TInt childc = btChildren->Count();
			if (childc>0)
			{
				for(TInt i=0; i<childc; i++)
				{
					TMsvId btAtt = (*btChildren)[i];
					btEntry->SetEntryL(btAtt);
				
					if(btEntry->Entry().iMtm == KUidMsgTypePOP3)
					{
						CImEmailMessage* emailMessage = CImEmailMessage::NewL(*btEntry);
						CleanupStack::PushL(emailMessage);
						
						MMsvAttachmentManager& attMngr = emailMessage->AttachmentManager(); 
						GetAttachmentsL(attMngr,*btEntry,(*entries)[ii],btAtt);
						
						CleanupStack::PopAndDestroy(emailMessage);
					}
					else if (btEntry->HasStoreL())
					{
						CMsvStore* store = btEntry->ReadStoreL();
						CleanupStack::PushL(store);
						
						MMsvAttachmentManager& attMngr = store->AttachmentManagerL();
						GetAttachmentsL(attMngr,*btEntry,(*entries)[ii],btAtt);
						
						CleanupStack::PopAndDestroy(store);
					}

				}
				
			}
			
			CleanupStack::PopAndDestroy(2);
		}	
					
		CleanupStack::PopAndDestroy(2);

		CDesCArray* itemArray = STATIC_CAST( CDesCArray* ,iSelectionBox->Model()->ItemTextArray());		
		if(itemArray->Count() > OrgCount)
		{
			iSelectionBox->HandleItemAdditionL();
			iSelectionBox->SetCurrentItemIndex(0); 
		}
		else
		{
			iSelectionBox->HandleItemRemovalL();
			
			if(itemArray->Count())
			{
				iSelectionBox->SetCurrentItemIndex(0); 
			}
		}
		
		UpdateScrollBar(iSelectionBox);
		DrawNow();
	}
コード例 #15
0
/*
-----------------------------------------------------------------------------
RFile GetAttachmentFileL(TMsvAttachmentId aId)
----------------------------------------------------------------------------
*/
void CMailBoxContainer::CopyFileL(const TDesC& aFolderName)
{

	TFileName fileName,FullFilName;

	if(iSession && iSelectionBox && iListArray)
	{	
		TInt CurrItmIndex = iSelCopyItemIndex;
		iSelCopyItemIndex = -1;
		
		if(CurrItmIndex < 0 || CurrItmIndex >= iIDArray->Count())
		{
			CurrItmIndex = iSelectionBox->CurrentItemIndex();
		}
		
		TMsvSelectionOrdering sort;
		sort.SetShowInvisibleEntries(ETrue);
		sort.SetSorting(EMsvSortByDate);
		// Take a handle to the folder entry
		CMsvEntry* parentEntry = CMsvEntry::NewL(*iSession,iCurrentMailBox,sort);
		CleanupStack::PushL(parentEntry);
		
		// A selection of all BT entries
		CMsvEntrySelection* entries = parentEntry->ChildrenL();//ChildrenWithMtmL(KUidMsgTypeBt);
		CleanupStack::PushL(entries);
			
		//Process all entries
		if(CurrItmIndex >= 0 && CurrItmIndex < iIDArray->Count())
		{
			//Get entry
			CMsvEntry* btEntry = iSession->GetEntryL(iIDArray->At(CurrItmIndex).iEnt);
			CleanupStack::PushL(btEntry);
			
			//Then get entrys child
			CMsvEntrySelection* btChildren = btEntry->ChildrenL();
			CleanupStack::PushL(btChildren);
		
			btEntry->SetEntryL(iIDArray->At(CurrItmIndex).iMsg);
									
	
			if (btEntry->HasStoreL())
			{
				CMsvStore* store = btEntry->ReadStoreL();
				CleanupStack::PushL(store);
				
				MMsvAttachmentManager& attMngr = store->AttachmentManagerL();
				CMsvAttachment* attachment = attMngr.GetAttachmentInfoL(iIDArray->At(CurrItmIndex).iAtt);
				if(attachment)
				{
					fileName.Copy(attachment->AttachmentName());
					
					delete attachment;
					attachment = NULL;
				
					TBool OkToSave(EFalse),SkipMe(EFalse);
				
					do
					{
						FullFilName.Zero();
						StringLoader::Load(FullFilName,R_SH_STR_FILENAME);
					
						CAknTextQueryDialog* Dialog = CAknTextQueryDialog::NewL(fileName,CAknQueryDialog::ENoTone);
						Dialog->PrepareLC(R_ASK_NAME_DIALOG);
						Dialog->SetPromptL(FullFilName);
						if(Dialog->RunLD())
						{
							FullFilName.Copy(aFolderName);
							FullFilName.Append(fileName);
			
							if(BaflUtils::FileExists(CEikonEnv::Static()->FsSession(),FullFilName))
							{
								HBufC* TmpText = StringLoader::LoadLC(R_SH_STR_FILOVERRT);
								
								CAknQueryDialog* dlg = CAknQueryDialog::NewL();
								if(dlg->ExecuteLD(R_QUERY,*TmpText))
								{
									TInt Err = CEikonEnv::Static()->FsSession().Delete(FullFilName);
									if(Err == KErrNone)
									{
										OkToSave = ETrue;
									}
									else
									{
										iUtils.GetFileUtils().ShowFileErrorNoteL(FullFilName,Err);
									}
								}
								
								CleanupStack::PopAndDestroy(TmpText);
							}
							else
							{
								OkToSave = ETrue;
							}
						}
						else
						{
							SkipMe = ETrue;
						}
						
					}while(!SkipMe && !OkToSave);
					
					if(OkToSave)
					{
						
						delete iRFileCopier;
						iRFileCopier = NULL;
						
						iRFileCopier = CRFileCopier::NewL(*this,CEikonEnv::Static()->FsSession(),ETrue);
						
						RFile SourceFil(attMngr.GetAttachmentFileL(iIDArray->At(CurrItmIndex).iAtt));
						iRFileCopier->StartCopyL(SourceFil,FullFilName);
						SourceFil.Close();
					}
				}
				
				CleanupStack::PopAndDestroy(store);
			}
			
			CleanupStack::PopAndDestroy(2);
		}				
		CleanupStack::PopAndDestroy(2);
	}

}
コード例 #16
0
void CBtMsgViewerUtils::GetMessagePathL(TPtr aMsgPath, const TInt aMessageId )
    {
    CMsvEntry* messageEntry = iMsvSession->GetEntryL(aMessageId);
    CleanupStack::PushL(messageEntry);
    
    TMsvEntry entry = messageEntry->Entry();
    if(entry.MtmData1() == KUidMsgTypeBtTInt32)
        {
        CMsvStore* store = messageEntry->ReadStoreL();
        CleanupStack::PushL(store);
        
        TInt attachmentCount = store->AttachmentManagerL().AttachmentCount();
        RFile attachmentFile;
        if(attachmentCount != 0)
            {
            //get file handle for the attachment & the complete path of the file
            attachmentFile = store->AttachmentManagerL().GetAttachmentFileL(0);
            CleanupClosePushL(attachmentFile);
            User::LeaveIfError(attachmentFile.FullName(aMsgPath));
            CleanupStack::PopAndDestroy(&attachmentFile);
            StoreMessageMimeTypeL(aMsgPath);
            
            //mark attachment as Read
            TMsvEntry attachEntry = messageEntry->Entry();
            attachEntry.SetUnread(EFalse);
            messageEntry->ChangeL(attachEntry);
            }
        else
            {
            CClientMtmRegistry* mtmReg = CClientMtmRegistry::NewL(*iMsvSession);
            CleanupStack::PushL(mtmReg); //1st Push
            
            CBIOClientMtm* bioClientMtm = (CBIOClientMtm*) mtmReg->NewMtmL(KBioUidValueUid);
            CleanupStack::PushL(bioClientMtm); //2nd Push
            
            bioClientMtm->SwitchCurrentEntryL(aMessageId);
            
            CMsvEntry* attachmentEntry = CMsvEntry::NewL(bioClientMtm->Session(),
                                        aMessageId,
                                        TMsvSelectionOrdering());
            CleanupStack::PushL(attachmentEntry); //3rd Push
            
            bioClientMtm->LoadMessageL();
    
            CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
            CleanupStack::PushL(selection); //4th Push
    
            selection->AppendL(aMessageId);
    
            TBuf8<1> aParameter;
            CMsvOperationActiveSchedulerWait* wait = CMsvOperationActiveSchedulerWait::NewLC();
            //5th Push
    
            CMsvOperation* operation = bioClientMtm->InvokeAsyncFunctionL(KBiosMtmParse, *selection,
                aParameter, wait->iStatus);
    
            wait->Start();
    
            CMsvStore* store = attachmentEntry->ReadStoreL();
            CleanupStack::PushL(store); //6th Push
            MMsvAttachmentManager& attachMan = store->AttachmentManagerL();
            
            attachmentFile = attachMan.GetAttachmentFileL(0);
            CleanupClosePushL(attachmentFile); //7th Push
            User::LeaveIfError(attachmentFile.FullName(aMsgPath));
            CleanupStack::PopAndDestroy(&attachmentFile);
            StoreMessageMimeTypeL(aMsgPath);
            
            //mark attachment as Read
            TMsvEntry attachEntry = attachmentEntry->Entry();
            attachEntry.SetUnread(EFalse);
            attachmentEntry->ChangeL(attachEntry);
            
            delete operation;
            CleanupStack::PopAndDestroy(6);
            }
        CleanupStack::PopAndDestroy(store);
        }
    else
        {
        CMsvEntry* attachmentEntry = iMsvSession->GetEntryL((*messageEntry)[0].Id());
        CleanupStack::PushL(attachmentEntry); //1st push
            
        CMsvStore* store = attachmentEntry->ReadStoreL();
        CleanupStack::PushL(store);  //2nd push
        
        TBuf<KMaxPath> attachmentName(store->AttachmentManagerL().GetAttachmentInfoL(0)->AttachmentName());
        RFs fs;
        User::LeaveIfError(fs.Connect());
        CleanupClosePushL(fs);
        TEntry entry;
        User::LeaveIfError(fs.Entry(attachmentName, entry));
        CleanupStack::PopAndDestroy(&fs);
        
        //get file handle for the attachment & the complete path of the file
        RFile attachmentFile;
        attachmentFile = store->AttachmentManagerL().GetAttachmentFileL(0);
        CleanupClosePushL(attachmentFile); //3rd Push
        User::LeaveIfError(attachmentFile.FullName(aMsgPath));
        CleanupStack::PopAndDestroy(&attachmentFile);
        StoreMessageMimeTypeL(aMsgPath);
        
        //mark attachment as Read
        TMsvEntry attachEntry = attachmentEntry->Entry();
        attachEntry.SetUnread(EFalse);
        attachmentEntry->ChangeL(attachEntry);
        
        CleanupStack::PopAndDestroy(store);
        CleanupStack::PopAndDestroy(attachmentEntry);
        }
    CleanupStack::PopAndDestroy(messageEntry);
    }
コード例 #17
0
TBool CT_MsgVerifyHeaders::VerifyImHeaderPartsL(CMsvEntrySelection* aEntrySelection)
	{
	TBool status = EPass;
	for(int index = 0; index < aEntrySelection->Count(); ++index)
		{
		CMsvEntry* entry = iSharedDataPOP.iSession->GetEntryL(aEntrySelection->At(index));
		CleanupStack::PushL(entry);
		CMsvStore* store = entry->ReadStoreL();
		CleanupStack::PushL(store);
		CImHeader* header = CImHeader::NewLC();
		// Retrieve the email message header part from the message store
		header->RestoreL(*store);

		// Validate the header fields
		TBuf<256> param;

		for(int indexTo = 0; indexTo < header->ToRecipients().Count(); ++indexTo)
			{
			TPtrC toAddress;
			param.Format(KToAddress, index, indexTo);
			if(GetStringFromConfig( ConfigSection(), param, toAddress))
				{
				TPtrC toAdd = header->ToRecipients()[indexTo];
				if(toAddress.Compare(header->ToRecipients()[indexTo]))
					{
					ERR_PRINTF1(_L(" To Address is not matched"));
					status = EFail;
					}
				}
			}
		for(int indexCc = 0; indexCc < header->CcRecipients().Count(); ++indexCc)
			{
			TPtrC ccAddress;
			param.Format(KCcAddress, index, indexCc);
			if(GetStringFromConfig( ConfigSection(), param, ccAddress))
				{
				TPtrC ccAdd = header->CcRecipients()[indexCc];
				if(ccAddress.Compare(header->CcRecipients()[indexCc]))
					{
					ERR_PRINTF1(_L("CC Address is not matched"));
					status = EFail;
					}
				}
			}
		for(int indexBcc = 0; indexBcc < header->BccRecipients().Count(); ++indexBcc)
			{
			TPtrC bccAddress;
			param.Format(KBccAddress, index, indexBcc);
			if(GetStringFromConfig( ConfigSection(), param, bccAddress))
				{
				TPtrC bccAdd = header->BccRecipients()[indexBcc];
				if(bccAddress.Compare(header->BccRecipients()[indexBcc]))
					{
					ERR_PRINTF1(_L("BCC Address is not matched"));
					status = EFail;
					}
				}
			}
		TPtrC fromAddress;
		param.Format(KFromAddress, index);
		if(GetStringFromConfig( ConfigSection(), param, fromAddress))
			{
			TPtrC fromAdd = header->From();
			if(fromAddress.Compare(header->From()))
				{
				ERR_PRINTF1(_L("From Address is not matched"));
				status = EFail;
				}
			}
		TPtrC subject;
		param.Format(KSubject, index);
		if(GetStringFromConfig( ConfigSection(), param, subject))
			{
			TPtrC tsub = header->Subject();
			if(subject.Compare(header->Subject()))
				{
				ERR_PRINTF1(_L("Subject is not matched"));
				status = EFail;
				}
			}
		CleanupStack::PopAndDestroy(header);
		CleanupStack::PopAndDestroy(store);
		CleanupStack::PopAndDestroy(entry);
		}
	return status;
	}
コード例 #18
0
void CSMSSender::CreateSMSMessageL(const TDesC& aText, const TDesC& aAddress)
/**
	Prepare SMS specific objects ready to send via ESOCK
	@param aText buffer containing ascii contents of message to send
	@param aAddress buffer with telephone number of SMS receiver 
*/
	{
#ifndef __WINS__
	TSmsAddr smsAddr;
    smsAddr.SetSmsAddrFamily(ESmsAddrSendOnly);
    smsAddr.SetPort(smsAddr.Port() + 1);//ycf
    __LOGSTR_TOFILE("sockent bind");
	iSocket.Bind(smsAddr);

	CSmsBuffer* smsBuffer = CSmsBuffer::NewL();
	//CleanupStack::PushL(smsBuffer) is NOT used because CSmsMessage takes ownership of our buffer :-)
	CSmsMessage* smsMsg = CSmsMessage::NewL(iFs, CSmsPDU::ESmsSubmit, smsBuffer);
	CleanupStack::PushL(smsMsg);
	
	TSmsUserDataSettings smsSettings;
    smsSettings.SetAlphabet(TSmsDataCodingScheme::ESmsAlphabetUCS2);
	smsSettings.SetTextCompressed(EFalse);
	smsMsg->SetUserDataSettingsL(smsSettings);
	
	TBuf<KMaxAddressSize> toAddress;
	toAddress.Copy(aAddress);
	smsMsg->SetToFromAddressL(toAddress);

	//Get service centre address.
	// The method used here assumes the SMS settings are provisioned, which is true in known cases.
	// There are alternative partner-only APIs, however this allow this source to be kept public
	#ifdef EKA2
		CSmsSettings* smsSCSettings = CSmsSettings::NewL();
		CleanupStack::PushL(smsSCSettings);
    	CSmsAccount* smsAccount=CSmsAccount::NewLC();
    	smsAccount->LoadSettingsL(*smsSCSettings);
 		// index of the default service centre address for this service
 		TInt defIndex;
		User::LeaveIfError(defIndex = smsSCSettings->DefaultServiceCenter());
 		// Get the service center address
		CSmsServiceCenter&  scAddr = smsSCSettings->GetServiceCenter(defIndex);
	
		TPtrC theAddress=scAddr.Address();
		HBufC* serviceCentreAddress=HBufC::NewLC(theAddress.Length());
		*serviceCentreAddress=theAddress;
		smsMsg->SmsPDU().SetServiceCenterAddressL(*serviceCentreAddress);
		CleanupStack::PopAndDestroy(serviceCentreAddress);//
		CleanupStack::PopAndDestroy(smsAccount);
		CleanupStack::PopAndDestroy(smsSCSettings);	
				
	#else
		TMsvId		serviceId;
		CObserver* pObserver = new (ELeave) CObserver();
		CleanupStack::PushL(pObserver);
		CMsvSession* pSession = CMsvSession::OpenSyncL(*pObserver);
		CleanupStack::PushL(pSession);
		TSmsUtilities::ServiceIdL(*pSession, serviceId, KUidMsgTypeSMS);
		CMsvEntry* service = pSession->GetEntryL(serviceId);
		CleanupStack::PushL(service);
		CMsvStore* msvstore = service->ReadStoreL();
		CleanupStack::PushL(msvstore);
		CSmsSettings* smsSCSettings = CSmsSettings::NewL();
		CleanupStack::PushL(smsSCSettings);
		smsSCSettings->RestoreL(*msvstore);
		TInt defIndex;
		User::LeaveIfError(defIndex = smsSCSettings->DefaultSC());
		defIndex = smsSCSettings->DefaultSC();
 		// Get the default service center address
		CSmsNumber&  scAddr = smsSCSettings->SCAddress(defIndex);
		TPtrC theAddress=scAddr.Address();
		HBufC* serviceCentreAddress=HBufC::NewLC(theAddress.Length());
		*serviceCentreAddress=theAddress;
		smsMsg->SmsPDU().SetServiceCenterAddressL(*serviceCentreAddress);
		CleanupStack::PopAndDestroy(serviceCentreAddress);//
		CleanupStack::PopAndDestroy(smsSCSettings); //smsSettings
		CleanupStack::PopAndDestroy(msvstore);
		CleanupStack::PopAndDestroy(service);
		CleanupStack::PopAndDestroy(pSession);
		CleanupStack::PopAndDestroy(pObserver);		
	#endif
	
	//convert to wide
	HBufC* payload = HBufC::NewL(aText.Length());
	CleanupStack::PushL(payload);
	TPtr pPayload=payload->Des();
	pPayload.Copy(aText); //copy from narrow to wide and convert
	smsBuffer->InsertL(0, pPayload); //copies payload
	RSmsSocketWriteStream writeStream(iSocket);
	CleanupClosePushL(writeStream);
	writeStream << *smsMsg; // remember << operator _CAN_ leave
	__LOGSTR_TOFILE("write stream commit");
	writeStream.CommitL();
	CleanupStack::PopAndDestroy(&writeStream);
	CleanupStack::PopAndDestroy(2);//smsMsg, payload	
#endif
	}
コード例 #19
0
void CheckNewAttachmentL(const TDesC& aFileName, TInt aFileSize, const TDesC8& aMimeType, TUint aCharset, TBool aLinkedAttachment)
	{
	// Check that file exists in the store and it matches our control file.
	CDummyObserver* ob1 = new(ELeave) CDummyObserver;
	CleanupStack::PushL(ob1);
	CMsvSession* session = CMsvSession::OpenSyncL(*ob1);
	CleanupStack::PushL(session);
	CMsvEntry* cEntry = CMsvEntry::NewL(*session, KMsvDraftEntryId, 
		TMsvSelectionOrdering(KMsvNoGrouping,EMsvSortByNone,ETrue));
	CleanupStack::PushL(cEntry);
	CMsvEntrySelection* selection = cEntry->ChildrenL();
	CleanupStack::PushL(selection);

	test(selection->Count() == 1);
	cEntry->SetEntryL((*selection)[0]);
	
	CMsvStore* store = cEntry->ReadStoreL();
	CleanupStack::PushL(store);
	
	MMsvAttachmentManager& attachmentMgr = store->AttachmentManagerL();
	TInt count = attachmentMgr.AttachmentCount();
	test(count > 0);
	
	TBool found = EFalse;
	
	while( count-- > 0 && !found )
		{
		CMsvAttachment* attachmentInfo = attachmentMgr.GetAttachmentInfoL(count);
		CleanupStack::PushL(attachmentInfo);

		// Check the attachment info is what we expect.
		TParse parser1;
		TParse parser2;
		parser1.Set(attachmentInfo->FilePath(), NULL, NULL);
		parser2.Set(aFileName, NULL, NULL);

		found = ETrue;
		if (aLinkedAttachment)
			{
			found = found && (attachmentInfo->Type() == CMsvAttachment::EMsvLinkedFile);  // Check it's a linked file.
			found = found && (parser1.DriveAndPath() == parser2.DriveAndPath());
			}
		else
			{
			found = found && (attachmentInfo->Type() == CMsvAttachment::EMsvFile);  // Check it's a file.
			found = found && (parser1.DriveAndPath() != parser2.DriveAndPath());
			}
			
		found = found && (attachmentInfo->MimeType().Match(aMimeType) == 0);  // Check mime type matches.
		found = found && (parser1.NameAndExt() == parser2.NameAndExt()); // This necessarily correct?
		found = found && (attachmentInfo->Size() == aFileSize); // Check size matches.
		
		// check charset matches
		CMsvMimeHeaders* mimeHeaders = CMsvMimeHeaders::NewLC();
		mimeHeaders->RestoreL(*attachmentInfo);
		found = found && (mimeHeaders->MimeCharset() == aCharset);
		
		CleanupStack::PopAndDestroy(2, attachmentInfo); // mimeHeaders, attachmentInfo
		}
	test(found);

	CleanupStack::PopAndDestroy(5, ob1); // store, selection, cEntry, sesion, ob1
	}