emailuis/emailui/src/FreestyleEmailUiSendAttachmentsListControl.cpp
branchRCL_3
changeset 35 e64954c2c8e2
parent 34 cd2816114bd1
child 26 67369d1b217f
equal deleted inserted replaced
34:cd2816114bd1 35:e64954c2c8e2
    60 
    60 
    61 // CONSTANTS
    61 // CONSTANTS
    62 
    62 
    63 // CLASS IMPLEMENTATION
    63 // CLASS IMPLEMENTATION
    64 
    64 
    65 TInt KGenericTimerDialogInterval = 1000; // Interval for iDialogTimer
    65 const TInt KBigAttachmentSize = 200000; // in Bytes - Attachment is big when it's over this size
    66 
    66 
    67 // ---------------------------------------------------------------------------
    67 // ---------------------------------------------------------------------------
    68 // Two-phased constructor.
    68 // Two-phased constructor.
    69 // ---------------------------------------------------------------------------
    69 // ---------------------------------------------------------------------------
    70 //
    70 //
   120     FUNC_LOG;
   120     FUNC_LOG;
   121     CAlfControl::ConstructL( aEnv );
   121     CAlfControl::ConstructL( aEnv );
   122 	iService = CFscContactActionService::NewL( iAppUi->GetVPbkManagerL() );
   122 	iService = CFscContactActionService::NewL( iAppUi->GetVPbkManagerL() );
   123     iModel = CFSEmailUiSendAttachmentsListModel::NewL( iAppUi, Env(), this );
   123     iModel = CFSEmailUiSendAttachmentsListModel::NewL( iAppUi, Env(), this );
   124     iAttachmentAddingLocked = EFalse;
   124     iAttachmentAddingLocked = EFalse;
   125     iDialogTimer = CFSEmailUiGenericTimer::NewL( this );
       
   126     }
   125     }
   127 
   126 
   128 // ---------------------------------------------------------------------------
   127 // ---------------------------------------------------------------------------
   129 // Virtual destructor.
   128 // Virtual destructor.
   130 // ---------------------------------------------------------------------------
   129 // ---------------------------------------------------------------------------
   131 //
   130 //
   132 CFreestyleEmailUiSendAttachmentsListControl::~CFreestyleEmailUiSendAttachmentsListControl()
   131 CFreestyleEmailUiSendAttachmentsListControl::~CFreestyleEmailUiSendAttachmentsListControl()
   133     {
   132     {
   134     FUNC_LOG;
   133     FUNC_LOG;
   135 	if(iDialogTimer)
   134     delete iService;
   136 		{
       
   137 	    iDialogTimer->Cancel();
       
   138 	    delete iDialogTimer;
       
   139 		}
       
   140 	delete iService;
       
   141     }
   135     }
   142 
   136 
   143 // <cmail>
   137 // <cmail>
   144 // ---------------------------------------------------------------------------
   138 // ---------------------------------------------------------------------------
   145 // Verify file selection (e.g. DRM)
   139 // Verify file selection (e.g. DRM)
   343 {
   337 {
   344     FUNC_LOG;
   338     FUNC_LOG;
   345 	return iAttachmentAddingLocked;
   339 	return iAttachmentAddingLocked;
   346 }
   340 }
   347 
   341 
   348 
       
   349 // ---------------------------------------------------------------------------
       
   350 // TimerEventL
       
   351 // Timer that delays the dialog will open the dialog here
       
   352 // ---------------------------------------------------------------------------
       
   353 //
       
   354 void CFreestyleEmailUiSendAttachmentsListControl::TimerEventL( CFSEmailUiGenericTimer* /*aTriggeredTimer*/ )
       
   355 	{
       
   356 	TFsEmailUiUtility::ShowWaitNoteL( iWaitNote, R_FSE_WAIT_INSERTING_TEXT, EFalse,ETrue );
       
   357 	iDialogTimer->Cancel();
       
   358 	}
       
   359 
       
   360 // ---------------------------------------------------------------------------
   342 // ---------------------------------------------------------------------------
   361 // AppendAttachmentToListL
   343 // AppendAttachmentToListL
   362 //
   344 //
   363 // Open files selection dialog and append given filename to attachment list
   345 // Open files selection dialog and append given filename to attachment list
   364 // ---------------------------------------------------------------------------
   346 // ---------------------------------------------------------------------------
   411 	    fetchOK = TFsEmailUiUtility::ShowSelectFileDialogL( filePath );
   393 	    fetchOK = TFsEmailUiUtility::ShowSelectFileDialogL( filePath );
   412 	    }
   394 	    }
   413         
   395         
   414 	iAttachmentAddingLocked = ETrue;
   396 	iAttachmentAddingLocked = ETrue;
   415 	
   397 	
       
   398 	if( fetchOK )
       
   399 		{
       
   400 	    TInt size(0);  
       
   401 	    TInt err(KErrNone);
       
   402 	    // check if dialog could be shown if the attachment is not protected and have a propper size
       
   403 	    RFile file; 
       
   404 	    err = file.Open( CCoeEnv::Static()->FsSession(), filePath, EFileShareReadersOnly );
       
   405 	    if( err == KErrNone )
       
   406 	        {
       
   407 	        CleanupClosePushL( file );
       
   408 	        fetchOK = !FileDrmProtectedL( file ); // it's ok if it is NOT protected
       
   409 	   	    file.Size(size); //get size in bytes
       
   410 	        CleanupStack::PopAndDestroy( &file );
       
   411 	    	}
       
   412 	        
       
   413 	    // show dialog for multiple files or 
       
   414 	    // show if file is not protected and it's considered as the Big Attachment
       
   415         if(( fetchOK && size > KBigAttachmentSize )  || err != KErrNone )
       
   416             {
       
   417 		    TFsEmailUiUtility::ShowWaitNoteL( iWaitNote, R_FSE_WAIT_INSERTING_TEXT, EFalse,ETrue );
       
   418 		    iWaitNote->DrawNow();
       
   419 		    iWaitNote->FocusChanged(EDrawNow);
       
   420 		    }
       
   421 	    }
       
   422     
       
   423 	
   416 	if ( fetchOK && filePath.Length() > 0 ) // </cmail>
   424 	if ( fetchOK && filePath.Length() > 0 ) // </cmail>
   417 		{
   425 		{
   418 	    iDialogTimer->Start(KGenericTimerDialogInterval);   
       
   419 	
       
   420         if ( !FileDrmProtectedL( filePath ) )
   426         if ( !FileDrmProtectedL( filePath ) )
   421 			{
   427 			{
   422 			// add file as a email message part
   428 			// add file as a email message part
   423 	    	CFSMailMessagePart* msgPart = NULL;
   429 	    	CFSMailMessagePart* msgPart = NULL;
   424 	    	
   430 	    	
   466 			
   472 			
   467 			ret = ETrue;
   473 			ret = ETrue;
   468 			}
   474 			}
   469 		}
   475 		}
   470 
   476 
   471 	iDialogTimer->Cancel();
   477 	if( iWaitNote ) 
   472 	if(iWaitNote) 
       
   473 	  	{
   478 	  	{
   474 	    iWaitNote->ProcessFinishedL();
   479 	    iWaitNote->ProcessFinishedL();
   475 	   	}
   480 	   	}
   476 	iAttachmentAddingLocked = EFalse;
   481 	iAttachmentAddingLocked = EFalse;
   477 	
   482 	
   509     TBool isProtected( EFalse );
   514     TBool isProtected( EFalse );
   510 		
   515 		
   511     RFile file;
   516     RFile file;
   512     TInt err = file.Open( CCoeEnv::Static()->FsSession(), 
   517     TInt err = file.Open( CCoeEnv::Static()->FsSession(), 
   513                           aFilePath, 
   518                           aFilePath, 
   514                           EFileRead | EFileShareAny );
   519                           EFileShareReadersOnly );
   515     User::LeaveIfError( err );
   520     User::LeaveIfError( err );
   516     CleanupClosePushL( file );
   521     CleanupClosePushL( file );
   517     isProtected = FileDrmProtectedL( file );
   522     isProtected = FileDrmProtectedL( file );
   518     CleanupStack::PopAndDestroy( &file );
   523     CleanupStack::PopAndDestroy( &file );
   519 		
   524