TInt CPartialDownloadStep::GetEntryCountL()
	{
	
	TImapAccount imapAccount=iImapClient->GetImapAccount();
	
	TMsvSelectionOrdering ordering;	

	//open the imap service entry
	CMsvEntry* imapService = CMsvEntry::NewL(*iSession,imapAccount.iImapService,ordering);
	CleanupStack::PushL(imapService);
	//get its children
	CMsvEntrySelection* msvEntrySelection;
	msvEntrySelection=imapService->ChildrenL();
	//open its child inbox entry
	CMsvEntry* inboxEntry = CMsvEntry::NewL(*iSession, (*msvEntrySelection)[0],ordering);
    CleanupStack::PushL(inboxEntry);
    
    //get the childeren of the inbox
    delete msvEntrySelection;
    msvEntrySelection=NULL;
    msvEntrySelection=inboxEntry->ChildrenL();
    //the count should be 2
    TInt count=msvEntrySelection->Count();
    
    delete msvEntrySelection;
    msvEntrySelection=NULL;	
	CleanupStack::PopAndDestroy(2,imapService);
	
	return count;
	}
示例#2
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);
	}
}
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 CMtfTestActionSetUserResponse::ExecuteActionL()
	{	
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSetUserResponse);
	CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession> (TestCase(),ActionParameters().Parameter(0));	
	TInt paramUserResponse = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(1),EFalse);
	
	CMsvEntry* cEntry = CMsvEntry::NewL(*paramSession, KMsvDraftEntryId, 
						TMsvSelectionOrdering(KMsvNoGrouping,EMsvSortByNone,ETrue));
	CleanupStack::PushL(cEntry);
	
	CMsvEntrySelection* selection = cEntry->ChildrenL();
	CleanupStack::PushL(selection);

	TestCase().INFO_PRINTF2(_L("Count of Draft Folder's selection is %d"),selection->Count());
	
	if (selection->Count() == 0)
	{	
	User::Leave(KErrNotFound);
	}
	
	cEntry->SetEntryL((*selection)[0]);

	if (!paramUserResponse)
	{	
	TMsvEntry entry = cEntry->Entry();
	entry.iError = KErrCancel;
	cEntry->ChangeL(entry);
	}
	
	CleanupStack::PopAndDestroy(2);
	
	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSetUserResponse);
	TestCase().ActionCompletedL(*this);
	}
// -----------------------------------------------------------------------------
// CMmsAdapterMsvApi::FindUserFolderL
// -----------------------------------------------------------------------------
//    
TBool CMmsAdapterMsvApi::FindUserFolderL( const TDesC& aName, TMsvId& aFolder )
    {
    CMsvEntry* entry = iSession.GetEntryL( KMsvMyFoldersEntryIdValue );
    CleanupStack::PushL( entry );
     
    CMsvEntrySelection* selection = entry->ChildrenL();
    CleanupStack::PushL( selection );
    
    TBool found( EFalse );
    TMsvId serviceId;
    TMsvEntry entryT;

    for ( TInt i = 0; i < selection->Count(); i++ )
        {
        User::LeaveIfError( iSession.GetEntry( selection->At( i ), serviceId, entryT ) );
        
        if ( !entryT.Deleted() && entryT.iType == KUidMsvFolderEntry && 
            aName.Compare(entryT.iDescription) == 0 )
            {
            found = ETrue;
            aFolder = entryT.Id();
            break;
            }
        }
    
    CleanupStack::PopAndDestroy( selection );
    CleanupStack::PopAndDestroy( entry );
    
    return found;           
    }
// -----------------------------------------------------------------------------
// CMmsAdapterMsvApi::FindUserFolderL
// -----------------------------------------------------------------------------
//    
TBool CMmsAdapterMsvApi::FindUserFolderL( TMsvId aFolder, TPtrC& aName, TTime& aDate )
    {
    TBool found( EFalse );
    
    CMsvEntry* entry = iSession.GetEntryL( KMsvMyFoldersEntryIdValue );
    CleanupStack::PushL( entry );
     
    CMsvEntrySelection* selection = entry->ChildrenL();
    CleanupStack::PushL( selection );
    
    TMsvId serviceId;
    TMsvEntry entryT;

    for ( TInt i = 0; i < selection->Count(); i++ )
        {
        User::LeaveIfError( iSession.GetEntry( selection->At( i ), serviceId, entryT ) );
        
        if ( !entryT.Deleted() && entryT.iType == KUidMsvFolderEntry && entryT.Id() == aFolder )
            {
            found = ETrue;
            aDate = entryT.iDate;
            aName.Set( entryT.iDetails );
            break;
            }
        }
    
    CleanupStack::PopAndDestroy( selection );
    CleanupStack::PopAndDestroy( entry ); 
    
    return found;        
    }
示例#7
0
/*
-----------------------------------------------------------------------------
----------------------------------------------------------------------------
*/
void CMailBoxContainer::AddEmailFoldersL(CMsvSession* aSession)
{
	if(aSession)
	{	
		CMsvEntry *localServiceEntry = aSession->GetEntryL(KMsvRootIndexEntryId);//KMsvLocalServiceIndexEntryId);
		CleanupStack::PushL(localServiceEntry);
		CMsvEntrySelection *folders = localServiceEntry->ChildrenL();
		CleanupStack::PushL(folders);

		if(folders->Count() > 1) // first is local folder
		{
			for (TInt i = 1;i <  folders->Count();i++)
			{
				TMsvEntry ExtraFolder = localServiceEntry->ChildDataL((*folders)[i]);
				
				CMailFldItem* NewIttem = new(ELeave)CMailFldItem();
				CleanupStack::PushL(NewIttem);
					
				NewIttem->iTitle = ExtraFolder.iDetails.AllocL();
				NewIttem->iMscId = 	ExtraFolder.Id();
			
				CleanupStack::Pop();//NewIttem
				iFolderArray.Append(NewIttem);
			}
		}
		
		CleanupStack::PopAndDestroy(2); // localServiceEntry, folders
	}
}
// methods from CSendAsEditUtils
void CSendAsTestEditUtils::LaunchEditorL(TMsvId /*aId*/, TRequestStatus& aStatus)
	{

	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);

	CMsvEntry* cEntry2 = session->GetEntryL(selection->At(0));
	CleanupStack::PushL(cEntry2);

	TMsvEntry entry = cEntry2->Entry();
	entry.SetMtmData3(234567890); // Show we've been called by touching the TMsvEntry.
	cEntry2->ChangeL(entry);
	
	CleanupStack::PopAndDestroy(5, ob1); // cEntry2, selection, cEntry, session, ob1

	iUserStatus = &aStatus;
	aStatus = KRequestPending;
	// wait a few seconds before completing
	iEditTimer->After(KSendAsTestEditWaitTime);
	}
/**
GetMessagePartIndexL()
Retrieves the part index id for the email identified by aEntry

@param aEntry
A valid email identifier

@param aUid
An identifier tfor the type of message part to be retrieved

@return
TMsvId - message part identifier
*/
TMsvId CT_MsgComparePopEmailMsgs::GetMessagePartIndexL(TMsvEntry& aEntry, TUid aUid)
	{
	static TBool msgPartFound = EFalse;	
	TMsvId msgPartId = 0;
	CMsvEntry*	baseEntry  = iSharedDataPOP.iSession->GetEntryL(aEntry.Id());
	CleanupStack::PushL(baseEntry);
	CMsvEntrySelection*	selection =  baseEntry->ChildrenL();
	CleanupStack::PushL(selection);
	TInt count = selection->Count();
	TInt ind1;
	CMsvEntry* entry = iSharedDataPOP.iSession->GetEntryL(KMsvRootIndexEntryId);
	CleanupStack::PushL(entry);
	for (ind1=0, msgPartFound=EFalse; ind1 < count; ind1++)
		{
		if(msgPartFound)
			{
			break;
			}		
		TMsvId	childId  = selection->At(ind1);
		entry->SetEntryL(childId);

		if (entry->Entry().iType  == aUid)
			{
			msgPartId = childId;
			break;
			}
		else if (entry->Entry().iType  == KUidMsvFolderEntry)
			{
			TMsvEntry ent = entry->Entry();
			msgPartId = GetMessagePartIndexL(ent, aUid);
			}
		}
	CleanupStack::PopAndDestroy(3, baseEntry);  // entry,selection,baseEntry
	return msgPartId;
	}
TInt CMtfTestActionCheckChildrenCountWithFlagBase::CountChildrenL(TMsvId aParent, CMsvSession& aSession)
	{
	TInt children = 0;
	// Get children at this level

	CMsvEntry* entryContext = CMsvEntry::NewL(aSession, aParent, 
	    	TMsvSelectionOrdering(KMsvNoGrouping, EMsvSortByNone, ETrue));
	CleanupStack::PushL(entryContext);
	
	entryContext->SetEntryL(aParent);
	TMsvSelectionOrdering order;
	order.SetShowInvisibleEntries(ETrue);
	entryContext->SetSortTypeL(order);
	
	CMsvEntrySelection* selection = entryContext->ChildrenL();
	CleanupStack::PushL(selection);
	
	// for each child
	TInt count=selection->Count();
	for(TInt child=0;child<count;child++)
		{
		entryContext->SetEntryL((*selection)[child]);
		TMsvEntry entry=entryContext->Entry();
		if (entry.iType==KUidMsvMessageEntry && FlagIsSet(entry) )
			{
			++children;
			}
		// if this is a folder then recurse
		if (entry.iType==KUidMsvFolderEntry)
			children +=CountChildrenL((*selection)[child], aSession);
		}
	CleanupStack::PopAndDestroy(2); // selection,entryContext
	return children;
	}
示例#11
0
TVerdict CTestUTCSort::TestSortingL()
	{
	
	TVerdict result=EPass;
	//create ordering objects
	TMsvSelectionOrdering ordering;	
	ordering.SetSorting(EMsvSortByDate);
	
	//sort the gloabl inbox by date
	CMsvEntry* inboxEntry = CMsvEntry::NewL(*iSession, KMsvDraftEntryIdValue,ordering);
	CleanupStack::PushL(inboxEntry);
	
	//retrieve the children of the inbox
	CMsvEntrySelection* msvEntrySelection;
	msvEntrySelection=inboxEntry->ChildrenL();
	CleanupStack::PushL(msvEntrySelection);
	
	CMsvEntry* child;
	TMsvEntry childDetails;
	TBuf<45> dateTimeString;
	
	//look at the id of each child and test its id, these should
	//be in the order the entries were created.
	for(TInt i=0;i<KNumEmailMessages;++i)
		{
		child=iSession->GetEntryL((*msvEntrySelection)[i]);
		childDetails=child->Entry();
		delete child;

		//print the time of the entry to the log file		
		dateTimeString.Zero();
		FormatDateTime(dateTimeString,childDetails.iDate); 
		INFO_PRINTF2(_L("%S"),&dateTimeString);
				
		if(childDetails.Id()!=iTMsvIdList->At(i))
			{
			ERR_PRINTF1(_L("Entries in wrong order"));	
			result=EFail;
			break;
			}
		}

	CleanupStack::PopAndDestroy(msvEntrySelection);
	CleanupStack::PopAndDestroy(inboxEntry);

	return result;
	
	}
示例#12
0
/*
-----------------------------------------------------------------------------
----------------------------------------------------------------------------
*/
void CSMSMonitor::CheckInboxL(void)
{	
	TInt smsCount(0),mmsCount(0);

	CMsvEntry* Entrie = iSession->GetEntryL(KMsvGlobalInBoxIndexEntryId);
	if(Entrie)
	{
		CleanupStack::PushL(Entrie);
		
		if(Entrie->Count())
		{
			TMsvSelectionOrdering MySortType;
			
			MySortType.SetSorting(EMsvSortByDate);
			
			Entrie->SetSortTypeL(MySortType);
			
			CMsvEntrySelection* entries = Entrie->ChildrenL();
			if(entries)
			{
				CleanupStack::PushL(entries);
		 
				for(TInt i = (entries->Count() - 1); i >= 0; i--)
				{
					if(Entrie->ChildDataL(entries->At(i)).Unread())
					{	
						if(Entrie->ChildDataL(entries->At(i)).iMtm == KUidMsgTypeSMS)
						{
							smsCount++;
						}
						else if(Entrie->ChildDataL(entries->At(i)).iMtm == KUidMsgTypeMultimedia)
						{
							mmsCount++;
						}
					}
				} 
			
				CleanupStack::PopAndDestroy(entries);
			}
		}
		
		CleanupStack::PopAndDestroy(1);//Entrie
	}
	
	if(iObserver){
		iObserver->InboxChangedL(smsCount,mmsCount);
	}
}
示例#13
0
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;
    }
}
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;	
	}
void CTestUTCParse::TraverseL(const TMsvId aTMsvId)
	{
	//open the entry, dont sort
	TMsvSelectionOrdering ordering;	
	ordering.SetSorting(EMsvSortByNone);
	CMsvEntry* entry = CMsvEntry::NewL(*iSession, aTMsvId,ordering);
	CleanupStack::PushL(entry);
	
	//retrieve the entries children
	CMsvEntrySelection* msvEntrySelection;
	msvEntrySelection=entry->ChildrenL();
	CleanupStack::PushL(msvEntrySelection);
	TInt count = entry->Count();
	
	CMsvEntry* child;
	TMsvEntry childDetails;

	//for each child test if its a message entry
	for(TInt i=0;i<count;i++)
		{
		child=iSession->GetEntryL((*msvEntrySelection)[i]);
		childDetails=child->Entry();
		
		if(childDetails.iType==KUidMsvMessageEntry)
			{
			iMessageEntryCount++;
			iTimeList->AppendL(childDetails.iDate);
			PrintEntryTime(&childDetails.iDate);
			}
		//recursive call
		TraverseL(childDetails.Id());
		if(child)
			{
			delete child;
			}
		}
			
	CleanupStack::PopAndDestroy(msvEntrySelection);
	CleanupStack::PopAndDestroy(entry);
		
	}
// ---------------------------------------------------------
// GetOutboxEntries()
// Outgoing Pending message/messages
// ---------------------------------------------------------
TInt MsgStoreHandler::GetOutboxEntriesL(MsgInfo& aFailedIndicatorData,
    MsgInfo& aPendingIndicatorData)
{
    CMsvEntry* rootEntry = iMsvSession->GetEntryL(KMsvGlobalOutBoxIndexEntryId);
    CMsvEntrySelection* messages = rootEntry->ChildrenL();

    TInt failedMessageCount = 0;
    TInt pendingMessageCount = 0;

    for (TInt i = 0; i < messages->Count(); ++i) {
        TMsvEntry entry = rootEntry->ChildDataL(messages->At(i));
        if ((entry.iMtm != KSenduiMtmSmsUid) && (entry.iMtm != KSenduiMtmMmsUid)) {
            continue;
        }

        if (entry.SendingState() == KMsvSendStateFailed) {
            ++failedMessageCount;
        }
        else {
            ++pendingMessageCount;
        }

        if (entry.SendingState() == KMsvSendStateFailed) {
            ProcessIndicatorDataL(entry.Id(), aFailedIndicatorData);
        }
        else {
            ProcessIndicatorDataL(entry.Id(), aPendingIndicatorData);
        }
       
    }

    aFailedIndicatorData.mFromSingle = (failedMessageCount > 1) ? false : true;
    aPendingIndicatorData.mFromSingle = (pendingMessageCount > 1) ? false : true;
    aFailedIndicatorData.mIndicatorType = FailedIndicatorPlugin;
    aPendingIndicatorData.mIndicatorType = PendingIndicatorPlugin;
    aFailedIndicatorData.mMsgCount = failedMessageCount;
    aPendingIndicatorData.mMsgCount = pendingMessageCount;

    return KErrNone;
}
// -----------------------------------------------------------------------------
// CMmsAdapterMsvApi::DeleteUserFolderL
// -----------------------------------------------------------------------------
//
 TInt CMmsAdapterMsvApi::DeleteUserFolderL( TMsvId aUid )
    {
    TRACE_FUNC_ENTRY;
    
    CMsvEntry* entry = iSession.GetEntryL(aUid);
    CleanupStack::PushL(entry);
    
    TMsvEntry tEntry = entry->Entry();
    TMsvId parent = tEntry.Parent();        
    
    if ( tEntry.iType != KUidMsvFolderEntry || parent != KMsvMyFoldersEntryIdValue )
        {
        LOGGER_WRITE( "Not correct folder" );
        CleanupStack::PopAndDestroy(entry);
        LOGGER_LEAVEFN( "MsvApi::DeleteUserFolderL" );
        return KErrNotSupported;
        }
        
    CMsvEntrySelection* children = entry->ChildrenL();
    TInt count = children->Count();
    delete children;
    
    if ( count > 0 )
        {
        LOGGER_WRITE( "Folder not empty" );
        CleanupStack::PopAndDestroy( entry );
        LOGGER_LEAVEFN( "MsvApi::DeleteUserFolderL" );
        return KErrInUse;
        }
        
    tEntry.SetReadOnly( EFalse );
    entry->ChangeL( tEntry );
    
    entry->SetEntryL( parent );
    entry->DeleteL( aUid );
    
    CleanupStack::PopAndDestroy( entry );
    TRACE_FUNC_EXIT;
    return KErrNone;
    }   
LOCAL_C void CleanMailFolder(TMsvId aFolderId)
	{
	CDummyObserver* ob1 = new(ELeave) CDummyObserver;
	CleanupStack::PushL(ob1);

	CMsvSession* session = CMsvSession::OpenSyncL(*ob1);
	CleanupStack::PushL(session);
	
	CMsvEntry* cEntry = CMsvEntry::NewL(*session, aFolderId, 
		TMsvSelectionOrdering(KMsvNoGrouping,EMsvSortByNone,ETrue));
	CleanupStack::PushL(cEntry);
	
	CMsvEntrySelection* selection = cEntry->ChildrenL();
	CleanupStack::PushL(selection);

	TMsvLocalOperationProgress progress;
	if (selection->Count() > 0)
		{
		cEntry->DeleteL(*selection, progress);
		}

	CleanupStack::PopAndDestroy(4); // selection, cEntry, session, ob1
	}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
void CIpsPlgImap4ConnectOp::CreateInboxMessagesSelectionL()
    {
    FUNC_LOG;
    // get children of service entry 
    CMsvEntry* cEntry = iMsvSession.GetEntryL( iService );
    CleanupStack::PushL( cEntry );
    CMsvEntrySelection* childrenSelection = cEntry->ChildrenL();
    CleanupStack::PopAndDestroy( cEntry );
    cEntry = NULL;
    CleanupStack::PushL( childrenSelection );

    if ( childrenSelection->Count() )
        {
        TMsvId id = (*childrenSelection)[0]; // index 0 == inbox
        cEntry = iMsvSession.GetEntryL( id ); // reusing cEntry pointer for Inbox entry
        CleanupStack::PushL( cEntry );
        delete iSelection;
        iSelection = NULL;
        // get message-type children of inbox
        iSelection = cEntry->ChildrenWithTypeL( KUidMsvMessageEntry );
        CleanupStack::PopAndDestroy( cEntry );
        }
    CleanupStack::PopAndDestroy( childrenSelection );
    }
示例#20
0
void CTestUTCSort::RemoveDefaultEntryL()
	{
	
	TMsvSelectionOrdering ordering;	
	
		//sort the gloabl inbox by date
	CMsvEntry* inboxEntry = CMsvEntry::NewL(*iSession, KMsvDraftEntryIdValue,ordering);
	CleanupStack::PushL(inboxEntry);
	
	if(inboxEntry->Count()==1)
		{
		CMsvEntrySelection* mvEntrySelection;
		mvEntrySelection=inboxEntry->ChildrenL();
		CleanupStack::PushL(mvEntrySelection);
		CMsvEntry* child;		
		child=iSession->GetEntryL((*mvEntrySelection)[0]);
		iSession->RemoveEntry(child->EntryId());
		delete child;
		CleanupStack::PopAndDestroy(mvEntrySelection);
		}
	
	CleanupStack::PopAndDestroy(inboxEntry);
		
	}
void CMtfTestActionUtilsSmsScripts::ReadSmsSettingsFromConfigurationFileL(CMtfTestCase& aTestCase, const TDesC& aSettingsFile, CSmsSettings& aSmsSettings)
	{
	CMtfTestActionUtilsConfigFileParser* scriptFileParser = CMtfTestActionUtilsConfigFileParser::NewL(aSettingsFile);
	CleanupStack::PushL(scriptFileParser);

	TPtrC stringPtr;
	TInt intValue;

	// Service Centre
	if(scriptFileParser->GetFieldAsString(KScriptItemSC, stringPtr) == KErrNone)
		{
		// get the addresses from the config file
		TLex detailsToParse(stringPtr);
		TPtrC scName;
		TPtrC scNumber;
		
		detailsToParse.SkipSpaceAndMark();
		while(!detailsToParse.Eos())
			{
			scName.Set(_L("Unknown")); // default SC name
			
			while(detailsToParse.Peek() != ';' && !detailsToParse.Eos()) // SCs' details separated by semi-colon
				{
				if(detailsToParse.Peek() == ',')  // name and number separated by comma
					{ // has a name specified
					scName.Set(detailsToParse.MarkedToken());
					detailsToParse.Inc();
					detailsToParse.SkipSpaceAndMark();
					}
				else
					detailsToParse.Inc();
				}
			
			scNumber.Set(detailsToParse.MarkedToken());
			
			// add the address to the SCs list
		
			aSmsSettings.AddServiceCenterL(scName, scNumber);
		
		
			detailsToParse.Inc();
			detailsToParse.SkipSpaceAndMark();
			}
		}
	
	// Default Service Centre
	if(scriptFileParser->GetFieldAsInteger(KScriptItemDefaultSC, intValue) == KErrNone)
		{
	
		aSmsSettings.SetDefaultServiceCenter(intValue);
	
		}
		
	// Bearer
	if(scriptFileParser->GetFieldAsString(KScriptItemBearer, stringPtr) == KErrNone)
		{
		CSmsSettings::TMobileSmsBearer smsBearer = ObtainValueParameterL<CSmsSettings::TMobileSmsBearer>(aTestCase, stringPtr);
		aSmsSettings.SetSmsBearer(smsBearer);
		}

	// Encoding
	if(scriptFileParser->GetFieldAsString(KScriptItemEncoding, stringPtr) == KErrNone)
		{
		TSmsDataCodingScheme::TSmsAlphabet characterSet = ObtainValueParameterL<TSmsDataCodingScheme::TSmsAlphabet>(aTestCase, stringPtr);
		aSmsSettings.SetCharacterSet(characterSet);
		}
		
	// Delivery Report
	if(scriptFileParser->GetFieldAsString(KScriptItemDeliveryReport, stringPtr) == KErrNone)
		{
		if (stringPtr.CompareF(_L("NO")) == 0)
			{
			aSmsSettings.SetDeliveryReport(EFalse);
			}
		else if (stringPtr.CompareF(_L("YES")) == 0)
			{
			aSmsSettings.SetDeliveryReport(ETrue);
			}
		}
		
	// Reply quoted
	if(scriptFileParser->GetFieldAsString(KScriptItemReplyQuoted, stringPtr) == KErrNone)
		{
		if (stringPtr.CompareF(_L("NO")) == 0)
			{
			aSmsSettings.SetReplyQuoted(EFalse);
			}
		else if (stringPtr.CompareF(_L("YES")) == 0)
			{
			aSmsSettings.SetReplyQuoted(ETrue);
			}
		}
	
	// Description length
	if(scriptFileParser->GetFieldAsInteger(KScriptItemDescriptionLength, intValue) == KErrNone)
		{
		aSmsSettings.SetDescriptionLength(intValue);
		}
		
		
	// Can Concatenate
	if(scriptFileParser->GetFieldAsString(KScriptItemCanConcatenate, stringPtr) == KErrNone)
		{
		if (stringPtr.CompareF(_L("NO")) == 0)
			{
			aSmsSettings.SetCanConcatenate(EFalse);
			}
		else if (stringPtr.CompareF(_L("YES")) == 0)
			{
			aSmsSettings.SetCanConcatenate(ETrue);
			}
		}
	
	// Reply path
	if(scriptFileParser->GetFieldAsString(KScriptItemReplyPath, stringPtr) == KErrNone)
		{
		if (stringPtr.CompareF(_L("NO")) == 0)
			{
			aSmsSettings.SetReplyPath(EFalse);
			}
		else if (stringPtr.CompareF(_L("YES")) == 0)
			{
			aSmsSettings.SetReplyPath(ETrue);
			}
		}
		
	// Reject duplicate
	if(scriptFileParser->GetFieldAsString(KScriptItemRejectDuplicate, stringPtr) == KErrNone)
		{
		if (stringPtr.CompareF(_L("NO")) == 0)
			{
			aSmsSettings.SetRejectDuplicate(EFalse);
			}
		else if (stringPtr.CompareF(_L("YES")) == 0)
			{
			aSmsSettings.SetRejectDuplicate(ETrue);
			}
		}
		
	// Validity period, value is read in minutes
	if(scriptFileParser->GetFieldAsInteger(KScriptItemValidityPeriod, intValue) == KErrNone)
		{
		aSmsSettings.SetValidityPeriod(TTimeIntervalMinutes(intValue));
		}
		
	// Delivery
	if(scriptFileParser->GetFieldAsString(KScriptItemDelivery, stringPtr) == KErrNone)
		{
		TSmsDelivery delivery = ObtainValueParameterL<TSmsDelivery>(aTestCase, stringPtr);
		aSmsSettings.SetDelivery(delivery);
		}
	
	// Status Report Handling
	if(scriptFileParser->GetFieldAsString(KScriptItemStatusReportHandling, stringPtr) == KErrNone)
		{
		CSmsSettings::TSmsReportHandling statusReportHandling = ObtainValueParameterL<CSmsSettings::TSmsReportHandling>(aTestCase, stringPtr);
		aSmsSettings.SetStatusReportHandling(statusReportHandling);
		}

	// Special Message Handling
	if(scriptFileParser->GetFieldAsString(KScriptItemSpecialMessageHandling, stringPtr) == KErrNone)
		{
		CSmsSettings::TSmsReportHandling specialMessageHandling = ObtainValueParameterL<CSmsSettings::TSmsReportHandling>(aTestCase, stringPtr);
		aSmsSettings.SetSpecialMessageHandling(specialMessageHandling);
		}

	// Commdb action
	if(scriptFileParser->GetFieldAsString(KScriptItemSmsCommdbAction, stringPtr) == KErrNone)
		{
		CSmsSettings::TSmsSettingsCommDbAction commdbAction = ObtainValueParameterL<CSmsSettings::TSmsSettingsCommDbAction>(aTestCase, stringPtr);
		aSmsSettings.SetCommDbAction(commdbAction);
		}
		
	// Sms Bearer Action
	if(scriptFileParser->GetFieldAsString(KScriptItemSmsBearerAction, stringPtr) == KErrNone)
		{
		CSmsSettings::TSmsSettingsCommDbAction smsBearerAction = ObtainValueParameterL<CSmsSettings::TSmsSettingsCommDbAction>(aTestCase, stringPtr);
		aSmsSettings.SetSmsBearerAction(smsBearerAction);
		}

	// Message Conversion
	if(scriptFileParser->GetFieldAsString(KScriptItemSmsMessageConversion, stringPtr) == KErrNone)
		{
		TSmsPIDConversion messageConversion = ObtainValueParameterL<TSmsPIDConversion>(aTestCase, stringPtr);
		aSmsSettings.SetMessageConversion(messageConversion);
		}
	
	// Vailidity Period Format
	if(scriptFileParser->GetFieldAsString(KScriptItemSmsValidityPeriodFormat, stringPtr) == KErrNone)
		{
		TSmsFirstOctet::TSmsValidityPeriodFormat valPeriodFormat = ObtainValueParameterL<TSmsFirstOctet::TSmsValidityPeriodFormat>(aTestCase, stringPtr);
		aSmsSettings.SetValidityPeriodFormat(valPeriodFormat);
		}
	
	// Class2 Folder
	if(scriptFileParser->GetFieldAsString(KScriptItemClass2Folder, stringPtr) == KErrNone)
		{
		// Try to find a folder with that name
		MDummySessionObserver obser;
		CMsvSession* session = CMsvSession::OpenSyncL(obser);
		CleanupStack::PushL(session);
		
		CMsvEntry* entry = CMsvEntry::NewL(*session, KMsvLocalServiceIndexEntryId, TMsvSelectionOrdering(KMsvGroupByStandardFolders||KMsvGroupByType,EMsvSortByNone));
		CleanupStack::PushL(entry);
		entry->SetEntryL(KMsvLocalServiceIndexEntryId); // Search only the local folders

		TMsvSelectionOrdering order;
		order.SetShowInvisibleEntries(ETrue);
		entry->SetSortTypeL(order);

		CMsvEntrySelection* selection = entry->ChildrenL();
		CleanupStack::PushL(selection);

		TBool found = EFalse;
		TInt count = selection->Count();
		for (TInt i=0; i<count; i++) 
			{	
			entry->SetEntryL((*selection)[i]);
			if ((stringPtr.CompareF(entry->Entry().iDescription) == 0) ||
			    (stringPtr.CompareF(entry->Entry().iDetails) == 0))
				{
				found = ETrue;
				break;
				}
			}

		TMsvId entryId = KMsvGlobalInBoxIndexEntryId;
		if (found)
			entryId = entry->Entry().Id();
		else
			User::Leave(KErrNotFound);

		aSmsSettings.SetClass2Folder(entryId); 
		
		CleanupStack::PopAndDestroy(3, session); // selection, entry, session
		}

	//Last Segment Delivery Report
	if(scriptFileParser->GetFieldAsString(KLastSegmentDeliveryReport, stringPtr) == KErrNone)
		{
		if (stringPtr.CompareF(_L("NO")) == 0)
			{
			aSmsSettings.SetLastSegmentDeliveryReport(EFalse);
			}
		else if (stringPtr.CompareF(_L("YES")) == 0)
			{
			aSmsSettings.SetLastSegmentDeliveryReport(ETrue);
			}
		}
	
	CleanupStack::PopAndDestroy(scriptFileParser);
	}
示例#22
0
LOCAL_C void TestMultipleNotifsL()
{
    CMultipleSessionObserver* ob = new(ELeave) CMultipleSessionObserver;
    CleanupStack::PushL(ob);

    CMsvSession* session = CMsvSession::OpenSyncL(*ob);
    CleanupStack::PushL(session);

    CMsvEntry* cEntry = CMsvEntry::NewL(*session, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering());
    CleanupStack::PushL(cEntry);

    CEntryObserver* entryOb1=new (ELeave) CEntryObserver;
    CleanupStack::PushL(entryOb1);
    cEntry->AddObserverL(*entryOb1);

    CTestActive* active = new (ELeave) CTestActive;
    CleanupStack::PushL(active);

    CMsvOperation* operation;
    CMsvEntrySelection* selection;

    // create folders to work under
    TMsvEntry folder1;
    folder1.iDescription.Set(KShortDescription);
    folder1.iDetails.Set(KShortDetails);
    folder1.iType = KUidMsvFolderEntry;
    folder1.iMtm = KUidMsvLocalServiceMtm;
    folder1.iServiceId = KMsvLocalServiceIndexEntryId;

    TMsvEntry folder2;
    folder2.iDescription.Set(KShortDescription);
    folder2.iDetails.Set(KShortDetails);
    folder2.iType = KUidMsvFolderEntry;
    folder2.iMtm = KUidMsvLocalServiceMtm;
    folder2.iServiceId = KMsvLocalServiceIndexEntryId;

    TMsvEntry folder3;
    folder3.iDescription.Set(KShortDescription);
    folder3.iDetails.Set(KShortDetails);
    folder3.iType = KUidMsvFolderEntry;
    folder3.iMtm = KUidMsvLocalServiceMtm;
    folder3.iServiceId = KMsvLocalServiceIndexEntryId;

    // create all th entries
    TMsvEntry entry;
    entry.iDescription.Set(KShortDescription);
    entry.iDetails.Set(KShortDetails);
    entry.iType = KUidMsvFolderEntry;
    entry.iMtm = KUidMsvLocalServiceMtm;
    entry.iServiceId = KMsvLocalServiceIndexEntryId;

    // create folder 2 & 3
    cEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);
    CreateEntry(folder2, *cEntry, KErrNone, *entryOb1);
    CreateEntry(folder3, *cEntry, KErrNone, *entryOb1);

    TMsvLocalOperationProgress prog;

    TInt max = 2*TMsvPackedChangeNotification::KMsvPackedChangeLimit+4;
    for (TInt count=1; count<=max; count++)
    {
        test.Printf(_L("."));

        // create another entry under folder 2
        cEntry->SetEntryL(folder2.Id());
        CreateEntry(entry, *cEntry, KErrNone, *entryOb1);

        // create folder1
        cEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);
        CreateEntry(folder1, *cEntry, KErrNone, *entryOb1);

        // test
        cEntry->SetEntryL(folder3.Id());
        selection = cEntry->ChildrenL();
        test(selection->Count()==0);
        delete selection;

        // copy all entries to folder 3
        ob->Start(MMsvSessionObserver::EMsvEntriesCreated, folder3.Id());
        cEntry->SetEntryL(folder2.Id());
        selection = cEntry->ChildrenL();
        test(selection->Count()==count);
        active->StartL();
        operation = cEntry->CopyL(*selection, folder3.Id(), active->iStatus);
        delete selection;
        CActiveScheduler::Start(); // operation complete
        test(operation->iStatus.Int()==KErrNone);
        test(operation->Mtm()==KUidMsvLocalServiceMtm);
        test(operation->Service()==KMsvLocalServiceIndexEntryId);
        prog = McliUtils::GetLocalProgressL(*operation);
        test(prog.iTotalNumberOfEntries==count);
        test(prog.iNumberCompleted==count);
        test(prog.iNumberFailed==0);
        test(prog.iError==KErrNone);
        delete operation;
        operation=NULL;
        // test
        cEntry->SetEntryL(folder3.Id());
        selection = cEntry->ChildrenL();
        test(selection->Count()==count);
        delete selection;
        if (ob->iEvents>1)
            test(ob->iSelection.Count()>TMsvPackedChangeNotification::KMsvPackedChangeLimit);
        else if (count>TMsvPackedChangeNotification::KMsvPackedChangeLimit)
        {
            ob->Wait();
            CActiveScheduler::Start();
        }
        // test
        selection = cEntry->ChildrenL();
        test(selection->Count()==count);
        delete selection;
        if (ob->iEvents>2)
            test(ob->iSelection.Count()>2*TMsvPackedChangeNotification::KMsvPackedChangeLimit);
        else if (count>2*TMsvPackedChangeNotification::KMsvPackedChangeLimit)
        {
            ob->Wait();
            CActiveScheduler::Start();
        }
        test(ob->iSelection.Count()==count);
        ob->Finish();

        // move all entries to folder 1
        selection = cEntry->ChildrenL();
        test(selection->Count()==count);
        ob->Start(MMsvSessionObserver::EMsvEntriesMoved, folder1.Id(), folder3.Id());
        active->StartL();
        operation = cEntry->MoveL(*selection, folder1.Id(), active->iStatus);
        delete selection;
        CActiveScheduler::Start(); // operation complete
        test(operation->iStatus.Int()==KErrNone);
        test(operation->Mtm()==KUidMsvLocalServiceMtm);
        test(operation->Service()==KMsvLocalServiceIndexEntryId);
        prog = McliUtils::GetLocalProgressL(*operation);
        test(prog.iTotalNumberOfEntries==count);
        test(prog.iNumberCompleted==count);
        test(prog.iNumberFailed==0);
        test(prog.iError==KErrNone);
        delete operation;
        operation=NULL;
        cEntry->SetEntryL(folder1.Id());
        selection = cEntry->ChildrenL();
        test(selection->Count()==count);
        delete selection;
        if (ob->iEvents>1)
            test(ob->iSelection.Count()>TMsvPackedChangeNotification::KMsvPackedChangeLimit);
        else if (count>TMsvPackedChangeNotification::KMsvPackedChangeLimit)
        {
            test(ob->iEvents==1);
            ob->Wait();
            CActiveScheduler::Start();
            test(ob->iEvents==2);
        }
        if (ob->iEvents>2)
            test(ob->iSelection.Count()>2*TMsvPackedChangeNotification::KMsvPackedChangeLimit);
        else if (count>2*TMsvPackedChangeNotification::KMsvPackedChangeLimit)
        {
            test(ob->iEvents==2);
            ob->Wait();
            CActiveScheduler::Start();
            test(ob->iEvents==3);
        }
        test(ob->iSelection.Count()==count);
        ob->Finish();


        // delete them
        ob->Start(MMsvSessionObserver::EMsvEntriesDeleted, KMsvGlobalInBoxIndexEntryId);
        cEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);
        active->StartL();
        operation = cEntry->DeleteL(folder1.Id(), active->iStatus);
        CActiveScheduler::Start(); // operation complete
        test(operation->iStatus.Int()==KErrNone);
        test(operation->Mtm()==KUidMsvLocalServiceMtm);
        test(operation->Service()==KMsvLocalServiceIndexEntryId);
        prog = McliUtils::GetLocalProgressL(*operation);
        test(prog.iTotalNumberOfEntries==1);
        test(prog.iNumberFailed==0);
        test(prog.iError==KErrNone);
        delete operation;
        operation=NULL;
        if (count+1>TMsvPackedChangeNotification::KMsvPackedChangeLimit && ob->iEvents==1)
        {
            ob->Wait();
            CActiveScheduler::Start();
        }
        if (count+1>2*TMsvPackedChangeNotification::KMsvPackedChangeLimit && ob->iEvents==2)
        {
            ob->Wait();
            CActiveScheduler::Start();
        }
        test(ob->iSelection.Count()==count+1);
        ob->Finish();
    }

    test.Printf(_L("\n"));
    CleanupStack::PopAndDestroy(5);
}
示例#23
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();
	}
示例#24
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);
	}

}
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
	}