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
	}
Ejemplo n.º 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);
	}
}
Ejemplo n.º 3
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;
	}
Ejemplo n.º 4
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;
    }
}
/**
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;
	}
Ejemplo n.º 6
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();
	}
Ejemplo n.º 7
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);
	}

}
// ----------------------------------------------------------------------------
// CIpsPlgNewChildPartFromFileOperation::PrepareStoreL
// ----------------------------------------------------------------------------
//
void CIpsPlgNewChildPartFromFileOperation::PrepareStoreL()
    {
    CMsvEntry* cAtta = iMsvSession.GetEntryL( iNewAttachmentId );
    CleanupStack::PushL( cAtta );
    TBool parentToMultipartAlternative( EFalse );
    if( cAtta->HasStoreL() )
        {
        CMsvStore* store = cAtta->EditStoreL();
        CleanupStack::PushL( store );
        CImMimeHeader* mimeHeader = CImMimeHeader::NewLC();
        
        if( store->IsPresentL( KUidMsgFileMimeHeader ) )
            {
            mimeHeader->RestoreL( *store );
            CDesC8Array& array = mimeHeader->ContentTypeParams();
            array.AppendL( KMethod );
            parentToMultipartAlternative = ETrue;
            
            if( iContentType->Des().Find( KMimeTextCalRequest ) != KErrNotFound )
                {    
                array.AppendL( KRequest );
                }
            else if( iContentType->Des().Find( KMimeTextCalResponse ) != KErrNotFound )
                {
                array.AppendL( KResponse );
                }
            else if( iContentType->Des().Find( KMimeTextCalCancel ) != KErrNotFound ) 
                {
                array.AppendL( KCancel );
                }
            else
                {
                parentToMultipartAlternative = EFalse;
                }
            mimeHeader->StoreWithoutCommitL( *store );
            store->CommitL();
            }
        
        CleanupStack::PopAndDestroy( 2, store );
        }

    if( parentToMultipartAlternative &&
        iFilePath->Find( KFileExtensionICS ) != KErrNotFound )
        {        
        TMsvEntry tAttaEntry = cAtta->Entry();
        TMsvId id = tAttaEntry.Parent();
        CMsvEntry* cParent = iMsvSession.GetEntryL( id );
        CleanupStack::PushL( cParent );
        
        TMsvEmailEntry tEntry = cParent->Entry();
        tEntry.SetMessageFolderType( EFolderTypeAlternative );
        
        // Do async again if needed

        iOperation = cParent->ChangeL( tEntry, iStatus );
        CleanupStack::PopAndDestroy( cParent );
        CleanupStack::PopAndDestroy( cAtta );
        }
    else
        {
        CleanupStack::PopAndDestroy( cAtta );
        iStatus = KRequestPending;
        TRequestStatus* status = &iStatus;
        User::RequestComplete(status,KErrNone);
        }
    iStep = EStoreMessagePart; // Next step
    SetActive();
    }