/** CheckAttachmentsL() Compares attachments for the email messages aRecvEntry and aSentEntry using expected results in aMailInfo @param aRecvEntry An identifier for the recieved email @param aMailInfo Expected state of recieved email attachments @param aSentEntry An identifier for the original email @return ETrue if attachments match otherwise EFalse */ TBool CT_MsgComparePopEmailMsgs::CheckAttachmentsL(TMsvEntry& aRecvEntry, CExpPop3MailInfo& aMailInfo, TMsvEntry& aSentEntry) { TBool ret = ETrue; CAttachmentItem* recvManager = CAttachmentItem::NewLC(*iSharedDataPOP.iSession, aRecvEntry); CAttachmentItem* sentManager = CAttachmentItem::NewLC(*iSharedDataPOP.iSession, aSentEntry); TInt recvCount = recvManager->MMsvAttachmentManager().AttachmentCount(); TInt sentCount = sentManager->MMsvAttachmentManager().AttachmentCount(); TFileName recvFileName; TFileName sentFileName; if(recvCount == aMailInfo.GetNumAttachments()) { for(TInt i=0;i<recvCount;i++) { for(TInt j=0;j<sentCount;j++) { CMsvAttachment* recvAttInfo = recvManager->MMsvAttachmentManager().GetAttachmentInfoL(i); CleanupStack::PushL(recvAttInfo); CMsvAttachment* sentAttInfo = sentManager->MMsvAttachmentManager().GetAttachmentInfoL(j); CleanupStack::PushL(sentAttInfo); if(recvAttInfo->AttachmentName().Compare(sentAttInfo->AttachmentName()) == 0) { recvFileName = recvAttInfo->FilePath(); sentFileName = sentAttInfo->FilePath(); ret = CompareFilesL(recvFileName, sentFileName); } CleanupStack::PopAndDestroy(2, recvAttInfo); } } } else { INFO_PRINTF3(_L("Warning - Expected attachments mismatch recieved (%d) expected (%d)"), recvCount, aMailInfo.GetNumAttachments()); ret = EFalse; } CleanupStack::PopAndDestroy(2, recvManager); // recvManager,sentManager return ret; }
void CMtfTestActionVerifyAttachmentInfo::ExecuteActionL() { TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionVerifyAttachmentInfo); CMsvAttachment* attachmentInfo = ObtainParameterReferenceL<CMsvAttachment>(TestCase(),ActionParameters().Parameter(0)); HBufC* paramFileName = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(1)); TInt paramFileSize = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(2)); HBufC* paramMimeType = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(3)); TestCase().INFO_PRINTF1(_L("VerifyAttachmentInfo.....")); TestCase().INFO_PRINTF2(_L("Attachment Name - %S"), &attachmentInfo->AttachmentName()); TestCase().INFO_PRINTF2(_L("Size - %d"), attachmentInfo->Size()); TBuf<KMimeTypeLength> mimeType; mimeType.Copy(attachmentInfo->MimeType()); TestCase().INFO_PRINTF2(_L("MimeType - %S"), &mimeType); TestCase().INFO_PRINTF1(_L("With..")); TestCase().INFO_PRINTF2(_L("Attachment Name - %S"), paramFileName); TestCase().INFO_PRINTF2(_L("Size - %d"), paramFileSize); TestCase().INFO_PRINTF2(_L("MimeType - %S"), paramMimeType); if ( (paramFileName->Compare(attachmentInfo->AttachmentName()) == 0) && (paramMimeType->Compare(mimeType) == 0) && (paramFileSize == attachmentInfo->Size()) ) { } else { User::Leave(KErrGeneral); } TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionVerifyAttachmentInfo); TestCase().ActionCompletedL(*this); }
/* ----------------------------------------------------------------------------- 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); } }