meetingrequest/mrgui/mrfieldbuildercommon/src/cmrattachmentui.cpp
branchRCL_3
changeset 12 4ce476e64c59
child 16 b5fbb9b25d57
equal deleted inserted replaced
11:0396474f30f5 12:4ce476e64c59
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: Attachment fetch utility class for event viewers and editors
       
    15 *
       
    16 */
       
    17 
       
    18 #include "cmrattachmentui.h"
       
    19 #include "cmrattachmentprogressinfo.h"
       
    20 #include "mesmrcalentry.h"
       
    21 #include "cmrfilemanager.h"
       
    22 #include "cmrgrid.h"
       
    23 #include "cesmrglobalnote.h"
       
    24 #include "esmrhelper.h"
       
    25 
       
    26 #include <mgfetch.h>
       
    27 #include <aknlistquerydialog.h>
       
    28 #include <sysutil.h>
       
    29 #include <calattachment.h>
       
    30 #include <npdapi.h>
       
    31 #include <akncommondialogsdynmem.h>
       
    32 #include <apparc.h>
       
    33 #include <esmrgui.rsg>
       
    34 #include <apgcli.h>
       
    35 #include <apmrec.h>
       
    36 #include <commoncontentpolicy.h>
       
    37 #include <ct/rcpointerarray.h>
       
    38 #include <aknnotewrappers.h>
       
    39 #include <stringloader.h>
       
    40 
       
    41 #include "emailtrace.h"
       
    42 
       
    43 namespace // codescanner::namespace
       
    44 	{
       
    45 	_LIT8( KUnknownDatatype, "unknown");
       
    46 	
       
    47 	const TInt KTempTextFileNameLength( 20 );
       
    48 	_LIT( KTextFilenameExtension, ".txt" );
       
    49 	
       
    50     /**
       
    51      * Check if the character is illegal for the filename
       
    52      */
       
    53 	TBool IsIllegalChar(const TUint aChar)
       
    54 	    {
       
    55 	    return (
       
    56 	        aChar == '*'  ||
       
    57 	        aChar == '\\' ||
       
    58 	        aChar == '<'  ||
       
    59 	        aChar == '>'  ||
       
    60 	        aChar == ':'  ||
       
    61 	        aChar == '.'  ||
       
    62 	        aChar == '"'  ||
       
    63 	        aChar == '/'  ||
       
    64 	        aChar == '|'  ||
       
    65 	        aChar == '?'  ||
       
    66 	        aChar == CEditableText::EParagraphDelimiter  ||
       
    67 	        aChar == CEditableText::ELineBreak  ||
       
    68 	        aChar <  ' ' );
       
    69 	    }
       
    70 
       
    71 	/**
       
    72 	 * Get the file name by making use of the content
       
    73 	 */
       
    74 	void GetFileNameFromBuffer( TFileName& aFileName,
       
    75 	            const TDesC& aBuffer, TInt aMaxLength, const TDesC* aExt /*= NULL*/ )
       
    76 	    {
       
    77 	    if(aExt!=NULL)
       
    78 	        {
       
    79 	        aMaxLength -= aExt->Length();
       
    80 	        }
       
    81 
       
    82 	    TInt len = aBuffer.Length();
       
    83 	    TInt max = Min( len, aMaxLength );
       
    84 	    aFileName.Zero();
       
    85 
       
    86 	    TInt cc = 0;
       
    87 	    TUint ch;
       
    88 	    TUint ch1 = 0;
       
    89 	    TBool spaces = EFalse;
       
    90 	    for( TInt i = 0; i < len && cc < max; i++ )
       
    91 	        {
       
    92 	        ch = aBuffer[i];
       
    93 
       
    94 	        // ignore spaces from beginning of the buffer until first
       
    95 	        // non-space is encountered.
       
    96 	        if( !spaces && ch != ' ' )
       
    97 	            {
       
    98 	            spaces = ETrue;
       
    99 	            }
       
   100 
       
   101 	        if(i>0)
       
   102 	            {
       
   103 	            ch1 = aBuffer[i-1];
       
   104 	            }
       
   105 
       
   106 	        // strip illegal chars away.
       
   107 	        // checks also if previous and current chars are '.'
       
   108 	        if( spaces && !IsIllegalChar(ch) )
       
   109 	            {
       
   110 	            if( !( i > 0 && ch == '.' && ch1 == '.' ) )
       
   111 	                {
       
   112 	                aFileName.Append( ch );
       
   113 	                cc++;
       
   114 	                }
       
   115 	            }
       
   116 	        }
       
   117 
       
   118 	    aFileName.Trim();
       
   119 
       
   120 	    // If filename is empty at this point, do not append extension either.
       
   121 	    // Instead, empty filename is returned so that caller can use whatever
       
   122 	    // default name
       
   123 	    if( aFileName.Length() > 0 && aExt != NULL )
       
   124 	        {
       
   125 	        aFileName.Append(*aExt);
       
   126 	        }
       
   127 	    }
       
   128 	}
       
   129 
       
   130 // ---------------------------------------------------------------------------
       
   131 // CMRAttachmentUi::AttachmentOperationCompleted
       
   132 // ---------------------------------------------------------------------------
       
   133 //
       
   134 EXPORT_C CMRAttachmentUi* CMRAttachmentUi::NewL()
       
   135 	{
       
   136     FUNC_LOG;
       
   137     
       
   138 	CMRAttachmentUi* self = new ( ELeave ) CMRAttachmentUi();
       
   139 	CleanupStack::PushL( self );
       
   140 	self->ConstructL();
       
   141 	CleanupStack::Pop( self );
       
   142 	return self;
       
   143 	}
       
   144 
       
   145 // ---------------------------------------------------------------------------
       
   146 // CMRAttachmentUi::AttachmentOperationCompleted
       
   147 // ---------------------------------------------------------------------------
       
   148 //
       
   149 EXPORT_C TInt CMRAttachmentUi::LaunchFetchUi( MESMRCalEntry& aEntry )
       
   150 	{
       
   151     FUNC_LOG;
       
   152     
       
   153 	iEntry = &aEntry;
       
   154 
       
   155 	TInt error( KErrNone );
       
   156 	TRAP( error, DoLaunchFetchUiL() );
       
   157 	return error;
       
   158 	}
       
   159 
       
   160 // ---------------------------------------------------------------------------
       
   161 // CMRAttachmentUi::AttachmentOperationCompleted
       
   162 // ---------------------------------------------------------------------------
       
   163 //
       
   164 EXPORT_C TInt CMRAttachmentUi::LaunchViewerUi( MESMRCalEntry& aEntry )
       
   165 	{
       
   166     FUNC_LOG;
       
   167     
       
   168 	iEntry = &aEntry;
       
   169 	TInt error( KErrNone );
       
   170 	TRAP( error, DoLaunchViewerUiL() );
       
   171 	return error;
       
   172 	}
       
   173 
       
   174 // ---------------------------------------------------------------------------
       
   175 // CMRAttachmentUi::AttachmentOperationCompleted
       
   176 // ---------------------------------------------------------------------------
       
   177 //
       
   178 EXPORT_C CMRAttachmentUi::~CMRAttachmentUi()
       
   179 	{
       
   180     FUNC_LOG;
       
   181     
       
   182 	delete iFilesToCopy;
       
   183 	delete iFilesToAdd;
       
   184 	delete iManager;
       
   185 	delete iProgress;
       
   186 	iFsSession.Close();
       
   187 	}
       
   188 
       
   189 // ---------------------------------------------------------------------------
       
   190 // CMRAttachmentUi::AttachmentOperationCompleted
       
   191 // ---------------------------------------------------------------------------
       
   192 //
       
   193 EXPORT_C void CMRAttachmentUi::SetObserver( MMRAttachmentUiObserver& aObserver )
       
   194 	{
       
   195     FUNC_LOG;
       
   196     
       
   197 	iObserver = &aObserver;
       
   198 	}
       
   199 
       
   200 // ---------------------------------------------------------------------------
       
   201 // CMRAttachmentUi::AttachmentOperationCompleted
       
   202 // ---------------------------------------------------------------------------
       
   203 //
       
   204 EXPORT_C TAttachmentOpResult CMRAttachmentUi::LatestOperationResult()
       
   205 	{
       
   206     FUNC_LOG;
       
   207     
       
   208 	TAttachmentOpResult result;
       
   209 	result.iFiles = &(iManager->CopiedFiles());
       
   210 	return result;
       
   211 	}
       
   212 
       
   213 // ---------------------------------------------------------------------------
       
   214 // CMRAttachmentUi::AttachmentOperationCompleted
       
   215 // ---------------------------------------------------------------------------
       
   216 //
       
   217 CMRAttachmentUi::CMRAttachmentUi()
       
   218 	{
       
   219     FUNC_LOG;
       
   220     
       
   221 	}
       
   222 
       
   223 // ---------------------------------------------------------------------------
       
   224 // CMRAttachmentUi::AttachmentOperationCompleted
       
   225 // ---------------------------------------------------------------------------
       
   226 //
       
   227 void CMRAttachmentUi::ConstructL()
       
   228 	{
       
   229     FUNC_LOG;
       
   230     
       
   231 	}
       
   232 
       
   233 // ---------------------------------------------------------------------------
       
   234 // CMRAttachmentUi::AttachmentOperationCompleted
       
   235 // ---------------------------------------------------------------------------
       
   236 //
       
   237 void CMRAttachmentUi::DoLaunchFetchUiL()
       
   238 	{
       
   239     FUNC_LOG;
       
   240     
       
   241 	TMediaFileType type = ResolveAttachmentTypeL();
       
   242 	
       
   243 	if ( ENoMediaFile != type )
       
   244 	    {
       
   245         // Create array of descriptors for the selected files
       
   246         iFilesToCopy = new ( ELeave ) CDesCArrayFlat( 5 );
       
   247         iFilesToAdd = new ( ELeave ) CDesCArrayFlat( 1 );
       
   248         TBool retval( EFalse );
       
   249         HBufC* buf = NULL;
       
   250         // Connect session
       
   251         User::LeaveIfError( iFsSession.Connect() );
       
   252         User::LeaveIfError( iFsSession.ShareProtected() );
       
   253     
       
   254         if( type == EPresentationsFile )
       
   255             {
       
   256             buf = CNotepadApi::FetchMemoL();
       
   257             if( buf )
       
   258                 {
       
   259                 CleanupStack::PushL(buf);
       
   260     
       
   261                 TFileName filename;
       
   262                 TInt max = KTempTextFileNameLength;
       
   263     
       
   264                 // first try to create filename from memo text.
       
   265                 GetFileNameFromBuffer( filename, *buf, max, &KTextFilenameExtension );
       
   266     
       
   267                 TFileName tempPath;
       
   268                 User::LeaveIfError( ESMRHelper::CreateAndAppendPrivateDirToFileName( tempPath ) );
       
   269                 tempPath.Append( filename );
       
   270     
       
   271                 // check the file name for validity and possible name duplicates.
       
   272                 TInt err = CApaApplication::GenerateFileName( iFsSession, tempPath );
       
   273     
       
   274                 if( err == KErrNone )
       
   275                     {
       
   276                     // write buffer to text file
       
   277                     CPlainText* text = CPlainText::NewL();
       
   278                     CleanupStack::PushL( text );
       
   279                     text->InsertL( 0, *buf );
       
   280                     text->ExportAsTextL( tempPath, CPlainText::EOrganiseByParagraph, 0 );
       
   281                     CleanupStack::PopAndDestroy( text );
       
   282                     iFilesToAdd->AppendL( tempPath );
       
   283                     }
       
   284     
       
   285                 CleanupStack::PopAndDestroy( buf );
       
   286                 }
       
   287             }
       
   288         else if( type == EAnyMediaFile )
       
   289             {
       
   290             TInt supportedTypes = AknCommonDialogsDynMem::EMemoryTypePhone |
       
   291                                   AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage |
       
   292                                   AknCommonDialogsDynMem::EMemoryTypeMMCExternal;
       
   293     
       
   294             TFileName filename;
       
   295             retval = AknCommonDialogsDynMem::RunSelectDlgLD( supportedTypes,
       
   296                                                        filename,
       
   297                                                        R_MR_ATTACHMENT_MEMORY_SELECTION_DIALOG,
       
   298                                                        /*aFilter*/NULL,
       
   299                                                        /*aVerifier*/this );
       
   300             if( retval )
       
   301                 {
       
   302                 iFilesToCopy->AppendL( filename );
       
   303                 }
       
   304             }
       
   305         else
       
   306             {
       
   307             // Open the dialog. 
       
   308              retval = MGFetch::RunL(
       
   309                 *iFilesToCopy, // When dialog is closed, fileArray contains selected files
       
   310                 type, // Displays only media files of type aMediaType
       
   311                 ETrue,		// single or multiple file selection
       
   312                 this		// Pointer to class implementing MMGFetchVerifier;
       
   313                         // when user has selected file(s),
       
   314                         // MMGFetchVerifier::VerifySelectionL is called.
       
   315                 );
       
   316             }
       
   317     
       
   318         TInt index(0);
       
   319         while ( index < iFilesToCopy->MdcaCount() )
       
   320             {
       
   321             TPtrC filename( iFilesToCopy->MdcaPoint(index) );
       
   322             if ( IsDuplicateNameL( filename ) )
       
   323                 {
       
   324                 iFilesToCopy->Delete( index );
       
   325                 
       
   326                 //though attachment is aleady attached to this entry, show the info note for this info.
       
   327                 CAknInformationNote* note = new ( ELeave ) CAknInformationNote(ETrue);
       
   328                 HBufC* cannotAttach = StringLoader::LoadLC( 
       
   329                         R_QTN_MEET_REQ_INFO_ALREADY_ATTACHED );
       
   330                 note->ExecuteLD( *cannotAttach );
       
   331                 CleanupStack::PopAndDestroy( cannotAttach );                
       
   332                 }
       
   333             else 
       
   334                 {
       
   335                 ++index;
       
   336                 }
       
   337             }
       
   338         
       
   339         // Start copy
       
   340         if( iFilesToCopy->MdcaCount() > 0 )
       
   341             {
       
   342             // Count files to be copied
       
   343             iFileCount = iFilesToCopy->Count();
       
   344             if( iFileCount > 0 )
       
   345                 {
       
   346                 StartCopyOpL();
       
   347                 }
       
   348             }
       
   349         // Add directly to CCalAttachment, no copy needed
       
   350         else if( iFilesToAdd->MdcaCount() > 0 )
       
   351             {
       
   352             UpdateEntryL();
       
   353             }
       
   354 	    }
       
   355 	}
       
   356 
       
   357 // ---------------------------------------------------------------------------
       
   358 // CMRAttachmentUi::AttachmentOperationCompleted
       
   359 // ---------------------------------------------------------------------------
       
   360 //
       
   361 void CMRAttachmentUi::StartCopyOpL()
       
   362 	{
       
   363     FUNC_LOG;
       
   364     
       
   365 	// Fetch the first filename from the array
       
   366 	TInt size( 0 );
       
   367 	for( TInt i = 0; i < iFileCount; ++i )
       
   368 		{
       
   369 		const TDesC& originalPath = (*iFilesToCopy)[i];
       
   370 		TEntry entry;
       
   371 		User::LeaveIfError( iFsSession.Entry( originalPath,entry ) );
       
   372 		// Count total size for the progressbar
       
   373 		size += entry.iSize;
       
   374 		}
       
   375 
       
   376 	if( !iManager )
       
   377 		{
       
   378 		iManager = CMRFileManager::NewL(iFsSession);
       
   379 		}
       
   380 	if( !iProgress )
       
   381 		{
       
   382 		iProgress = CMRAttachmentProgressInfo::NewL( *iManager, *this );
       
   383 		}
       
   384 	// Give total size to progress bar
       
   385 	// Set progressbar as a observer to copy operation
       
   386 	iProgress->StartProgressNoteL( size );
       
   387 
       
   388     // Check if there is space available
       
   389     if( !SysUtil::FFSSpaceBelowCriticalLevelL( &iFsSession, size ) )
       
   390     	{
       
   391 		iManager->SetObserver( *iProgress );
       
   392 		iManager->CopyFilesL( *iFilesToCopy );
       
   393     	}
       
   394 	}
       
   395 
       
   396 // ---------------------------------------------------------------------------
       
   397 // CMRAttachmentUi::AttachmentOperationCompleted
       
   398 // ---------------------------------------------------------------------------
       
   399 //
       
   400 void CMRAttachmentUi::UpdateEntryL()
       
   401 	{
       
   402     FUNC_LOG;
       
   403     
       
   404 	MDesC16Array* fileArray = NULL;
       
   405 	if( iFilesToAdd->MdcaCount() > 0  )
       
   406 		{
       
   407 		fileArray = iFilesToAdd;
       
   408 		}
       
   409 	else
       
   410 		{
       
   411 		fileArray = &iManager->CopiedFiles();
       
   412 		}
       
   413 
       
   414 	TInt fileCount( fileArray->MdcaCount() );
       
   415 
       
   416 	for( TInt i = 0; i < fileCount; ++i )
       
   417 		{
       
   418 		const TDesC& fileName( fileArray->MdcaPoint(i) );
       
   419 		// When copy done add attachment File handles to calentry
       
   420 		RFile fileHandle;
       
   421 		User::LeaveIfError( fileHandle.Open( 
       
   422 		        iFsSession, fileName, EFileWrite ) );
       
   423 		CleanupClosePushL( fileHandle );
       
   424 		// create attachment and add to calendar entry
       
   425 		CCalAttachment* attachment = CCalAttachment::NewFileL( fileHandle );
       
   426 		
       
   427         RApaLsSession apaSession;
       
   428         TDataRecognitionResult dataType;
       
   429         User::LeaveIfError(apaSession.Connect());
       
   430         apaSession.RecognizeData(fileHandle, dataType);
       
   431         apaSession.Close();
       
   432         
       
   433         TPtrC8 contentType( dataType.iDataType.Des8() );
       
   434         
       
   435         if ( contentType.Length() )
       
   436             {
       
   437             attachment->SetMimeTypeL( contentType );
       
   438             }
       
   439         else
       
   440             {
       
   441             attachment->SetMimeTypeL( KUnknownDatatype );
       
   442             }
       
   443 		
       
   444 		CleanupStack::PopAndDestroy( &fileHandle );
       
   445 		CleanupStack::PushL( attachment );
       
   446 		// set attachment properties
       
   447 		const TDesC& filenameOriginal = iFilesToCopy->MdcaPoint( i );
       
   448 		TFileName label;
       
   449 		TParse parser;
       
   450 		parser.Set( filenameOriginal , NULL, NULL );
       
   451 		label.Append( parser.NameAndExt() );
       
   452 		attachment->SetLabelL( label );
       
   453 			
       
   454 		
       
   455 		
       
   456 		iEntry->Entry().AddAttachmentL( *attachment ); // calEntry takes ownership
       
   457 		CleanupStack::Pop( attachment );
       
   458 		}
       
   459 
       
   460 	if( iObserver )
       
   461 		{
       
   462 		iObserver->AttachmentOperationCompleted( *iFilesToCopy );
       
   463 		}
       
   464 	}
       
   465 
       
   466 // ---------------------------------------------------------------------------
       
   467 // CMRAttachmentUi::AttachmentOperationCompleted
       
   468 // ---------------------------------------------------------------------------
       
   469 //
       
   470 void CMRAttachmentUi::DoLaunchViewerUiL()
       
   471 	{
       
   472     FUNC_LOG;
       
   473     
       
   474 	// TODO: Launch attachment view
       
   475 	// read attachments from calentry and populate the listbox
       
   476 	}
       
   477 
       
   478 // ---------------------------------------------------------------------------
       
   479 // CMRAttachmentUi::AttachmentOperationCompleted
       
   480 // ---------------------------------------------------------------------------
       
   481 //
       
   482 TMediaFileType CMRAttachmentUi::ResolveAttachmentTypeL()
       
   483 	{
       
   484     FUNC_LOG;
       
   485     
       
   486 	TMediaFileType type = ENoMediaFile;
       
   487 	TInt selectedOption( 0 );
       
   488     
       
   489 	if ( CMRGrid::ExecuteL( selectedOption ) )
       
   490         {
       
   491         switch( selectedOption )
       
   492             {
       
   493             case 0:
       
   494                 type = EImageFile;
       
   495                 break;
       
   496             case 1:
       
   497                 type = EVideoFile;
       
   498                 break;
       
   499             case 2:
       
   500                 type = EMusicFile;
       
   501                 break;
       
   502             case 3:
       
   503                 type = EPresentationsFile;
       
   504                 break;
       
   505             case 4:
       
   506                 type = EAnyMediaFile;
       
   507                 break;
       
   508     
       
   509             default:
       
   510                 break;
       
   511             }
       
   512         }
       
   513 	
       
   514 	return type;
       
   515 	}
       
   516 
       
   517 // ---------------------------------------------------------------------------
       
   518 // CMRAttachmentUi::AttachmentOperationCompleted
       
   519 // ---------------------------------------------------------------------------
       
   520 //
       
   521 void CMRAttachmentUi::DialogDismissedL( TInt /*aButtonId*/ )
       
   522 	{
       
   523     FUNC_LOG;
       
   524     
       
   525 	// Called whent the copy process has ended
       
   526 	UpdateEntryL();
       
   527 	}
       
   528 
       
   529 // ---------------------------------------------------------------------------
       
   530 // CMRAttachmentUi::VerifySelectionL
       
   531 // ---------------------------------------------------------------------------
       
   532 //
       
   533 TBool CMRAttachmentUi::VerifySelectionL( const MDesCArray* aSelectedFiles )
       
   534     {
       
   535     FUNC_LOG;
       
   536     
       
   537     TInt fileCount = aSelectedFiles->MdcaCount();
       
   538     TBool isProtected = EFalse;
       
   539     for( TInt i = 0; i < fileCount; ++i )
       
   540         {
       
   541         const TDesC& originalPath = aSelectedFiles->MdcaPoint( i );
       
   542         RFile selected;
       
   543         User::LeaveIfError( selected.Open( 
       
   544                 iFsSession, originalPath, EFileRead ) );
       
   545         CleanupClosePushL( selected );
       
   546         isProtected =  FileDrmProtectedL( selected );
       
   547         CleanupStack::PopAndDestroy();
       
   548         if ( isProtected )
       
   549             {
       
   550             break;
       
   551             }
       
   552         }
       
   553     // Protected file returns verification fail and 
       
   554     // unprotected file returns verification ok
       
   555     return !isProtected;
       
   556     }
       
   557 
       
   558 // ---------------------------------------------------------------------------
       
   559 // CMRAttachmentUi::OkToExitL
       
   560 // ---------------------------------------------------------------------------
       
   561 //
       
   562 TBool CMRAttachmentUi::OkToExitL( 
       
   563         const TDesC& aDriveAndPath, 
       
   564         const TEntry& aEntry )
       
   565     {
       
   566     FUNC_LOG;
       
   567     
       
   568     TFileName path;
       
   569     path = aDriveAndPath;
       
   570     path.Append( aEntry.iName );
       
   571     
       
   572     RFile selected;
       
   573     User::LeaveIfError( selected.Open( iFsSession, path, EFileRead ) );
       
   574     CleanupClosePushL( selected );
       
   575     TBool isProtected = FileDrmProtectedL( selected );
       
   576     CleanupStack::PopAndDestroy();
       
   577 
       
   578     // Protected file returns not ok to exit and 
       
   579     // unprotected file returns ok to exit
       
   580     return !isProtected;
       
   581     }
       
   582 
       
   583 // ---------------------------------------------------------------------------
       
   584 // CMRAttachmentUi::FileDrmProtectedL
       
   585 // ---------------------------------------------------------------------------
       
   586 //
       
   587 TBool CMRAttachmentUi::FileDrmProtectedL( RFile& aFile )
       
   588     {
       
   589     FUNC_LOG;
       
   590     
       
   591     TBool isProtected( EFalse );
       
   592     CCommonContentPolicy* ccp = CCommonContentPolicy::NewLC();      
       
   593     isProtected = ccp->IsClosedFileL( aFile );
       
   594     if ( isProtected )
       
   595             {
       
   596             // TODO: Add suitable note to cesmrglobalnote.cpp
       
   597             CESMRGlobalNote::ExecuteL
       
   598                                 ( CESMRGlobalNote::EESMRAlarmAlreadyPassed );
       
   599             }
       
   600     CleanupStack::PopAndDestroy( ccp );
       
   601     return isProtected;
       
   602     }
       
   603 
       
   604 // ---------------------------------------------------------------------------
       
   605 // CMRAttachmentUi::IsDuplicateNameL
       
   606 // ---------------------------------------------------------------------------
       
   607 //
       
   608 TBool CMRAttachmentUi::IsDuplicateNameL(
       
   609         const TDesC& aSelectedFile )
       
   610     {               
       
   611     FUNC_LOG;
       
   612     
       
   613     CCalEntry& entry( iEntry->Entry() );
       
   614     
       
   615     TInt attachmentCount = entry.AttachmentCountL();
       
   616     
       
   617     TBool matchNotFound( ETrue );
       
   618     if( attachmentCount )
       
   619         {
       
   620         TParsePtrC fileNameParser(aSelectedFile);
       
   621         TPtrC parsedFileName = fileNameParser.NameAndExt();
       
   622 
       
   623         for(TInt index = 0; index < attachmentCount && matchNotFound; ++index)
       
   624             {     
       
   625             CCalAttachment* attachment = entry.AttachmentL(index);
       
   626             matchNotFound = parsedFileName.Compare( attachment->Label() ); 
       
   627             }
       
   628         }
       
   629     
       
   630     return !matchNotFound; 
       
   631     }
       
   632 
       
   633 // End of file
       
   634