devicediagnostics/diagplugins/diagexternalmediacardplugin/src/diagexternalmediacardplugin.cpp
branchRCL_3
changeset 58 5b858729772b
equal deleted inserted replaced
57:6757f1e2efd2 58:5b858729772b
       
     1 /*
       
     2 * Copyright (c) 2007 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:  External Media Card Test Plugin
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // CLASS DECLARATION
       
    20 #include "diagexternalmediacardplugin.hrh" // ADO & Platformization Changes
       
    21 #include "diagexternalmediacardplugin.h"
       
    22 
       
    23 // SYSTME INCLUDE FILES
       
    24 #include <featmgr.h>                    // feature manager for MMC support checking
       
    25 #include <features.hrh>
       
    26 //#ifndef RD_MULTIPLE_DRIVE
       
    27 #include <pathinfo.h>                   //PathInfo
       
    28 //#endif // RD_MULTIPLE_DRIVE
       
    29 #include <sysutil.h>                    //SysUtil
       
    30 #include <StringLoader.h>               // StringLoader
       
    31 
       
    32 #include <DiagTestObserver.h>           // MDiagTestObserver
       
    33 #include <DiagTestExecParam.h>          // TDiagTestExecParam
       
    34 #include <DiagResultsDbItemBuilder.h>   // CDiagResultsDbItemBuilder
       
    35 #include <DiagResultDetailBasic.h>      // CDiagResultDetailBasic
       
    36 #include <DiagFrameworkDebug.h>         // LOGSTRING
       
    37 #include <devdiagexternalmediacardpluginrsc.rsg>
       
    38 #include <AknDialog.h> // ADO & Platformization Changes
       
    39 #include <aknmessagequerydialog.h>  // ADO & Platformization Changes
       
    40 #include <DiagCommonDialog.h>          // for EDiagCommonDialogConfirmCancelAll 
       
    41 #include <DiagEngineCommon.h> 
       
    42 
       
    43 
       
    44 #include <AknQueryDialog.h>
       
    45 #include <avkon.hrh>
       
    46 // EXTERNAL DATA STRUCTURES
       
    47 
       
    48 // EXTERNAL FUNCTION PROTOTYPES
       
    49 
       
    50 // CONSTANTS 
       
    51 const TInt KDiagExternalMediaCardStepsMaxCount = 2;   //total test steps
       
    52 _LIT( KText1, "PhoneDoctor External Memory Test" );
       
    53 
       
    54 // MACROS
       
    55 
       
    56 // LOCAL CONSTANTS AND MACROS
       
    57 
       
    58 // MODULE DATA STRUCTURES
       
    59 
       
    60 // LOCAL FUNCTION PROTOTYPES
       
    61 
       
    62 // FORWARD DECLARATIONS
       
    63 
       
    64 // ============================= LOCAL FUNCTIONS ==============================
       
    65 
       
    66 // ========================= MEMBER FUNCTIONS ================================
       
    67 
       
    68 // ----------------------------------------------------------------------------
       
    69 // CDiagExternalMediaCardPlugin::CDiagExternalMediaCardPlugin()
       
    70 //
       
    71 // Constructor
       
    72 // ----------------------------------------------------------------------------
       
    73 //
       
    74 CDiagExternalMediaCardPlugin::CDiagExternalMediaCardPlugin( 
       
    75         CDiagPluginConstructionParam* aParam )
       
    76     :   CDiagTestPluginBase( aParam )
       
    77     {
       
    78     }
       
    79 
       
    80 
       
    81 // ---------------------------------------------------------------------------
       
    82 // CDiagExternalMediaCardPlugin::NewL()
       
    83 //
       
    84 // Symbian OS default constructor
       
    85 // ---------------------------------------------------------------------------
       
    86 MDiagPlugin* CDiagExternalMediaCardPlugin::NewL( TAny* aInitParams )
       
    87     {
       
    88     ASSERT( aInitParams );
       
    89     LOGSTRING( "CDiagExternalMediaCard::NewL" );
       
    90     
       
    91     CDiagPluginConstructionParam* param = 
       
    92             static_cast<CDiagPluginConstructionParam*>( aInitParams );    
       
    93 
       
    94     CleanupStack::PushL( param );    
       
    95     CDiagExternalMediaCardPlugin* self = new( ELeave ) CDiagExternalMediaCardPlugin (param);
       
    96     CleanupStack::Pop( param );
       
    97     
       
    98     CleanupStack::PushL( self );
       
    99     self->ConstructL();
       
   100     CleanupStack::Pop( self ); // self    
       
   101 
       
   102     return self;
       
   103     }
       
   104 
       
   105 
       
   106 // ---------------------------------------------------------------------------
       
   107 // CDiagExternalMediaCardPlugin::ConstructL()
       
   108 //
       
   109 // Symbian OS two-phased constructor
       
   110 // ---------------------------------------------------------------------------
       
   111 void CDiagExternalMediaCardPlugin::ConstructL()
       
   112     {
       
   113     LOGSTRING("CDiagExternalMediaCardPlugin::ConstructL: Plugin created.");
       
   114     BaseConstructL ( KDiagExternalMediaCardPluginResourceFileName );
       
   115     
       
   116     FeatureManager::InitializeLibL();
       
   117 	idialogOn = EFalse;
       
   118 	idialogDismissed = EFalse;
       
   119     }
       
   120 
       
   121 
       
   122 // ----------------------------------------------------------------------------
       
   123 // CDiagExternalMediaCardPlugin::~CDiagExternalMediaCardPlugin
       
   124 //
       
   125 // Destructor
       
   126 // ----------------------------------------------------------------------------
       
   127 CDiagExternalMediaCardPlugin::~CDiagExternalMediaCardPlugin()
       
   128     {
       
   129     FeatureManager::UnInitializeLib();    
       
   130     }
       
   131 
       
   132 
       
   133 // ---------------------------------------------------------------------------
       
   134 // From MDiagPlugin
       
   135 // CDiagExternalMediaCardPlugin::IsVisible()
       
   136 // ---------------------------------------------------------------------------
       
   137 TBool CDiagExternalMediaCardPlugin::IsVisible() const
       
   138     {
       
   139     return ( FeatureManager::FeatureSupported( KFeatureIdMmc ) );
       
   140     }
       
   141 
       
   142 
       
   143 // ---------------------------------------------------------------------------
       
   144 // From MDiagPlugin
       
   145 // CDiagExternalMediaCardPlugin::IsSupported()
       
   146 // ---------------------------------------------------------------------------
       
   147 TBool CDiagExternalMediaCardPlugin::IsSupported() const
       
   148     {
       
   149     return ( FeatureManager::FeatureSupported( KFeatureIdMmc ) );
       
   150     }    
       
   151 
       
   152         
       
   153 // ---------------------------------------------------------------------------
       
   154 // From MDiagTestPlugin
       
   155 // CDiagExternalMediaCardPlugin::RunMode()
       
   156 // ---------------------------------------------------------------------------
       
   157 MDiagTestPlugin::TRunMode CDiagExternalMediaCardPlugin::RunMode() const
       
   158     {
       
   159     return EAutomatic;
       
   160     }
       
   161 
       
   162 
       
   163 // ---------------------------------------------------------------------------
       
   164 // From MDiagTestPlugin
       
   165 // CDiagExternalMediaCardPlugin::TotalSteps()
       
   166 // ---------------------------------------------------------------------------
       
   167 TUint CDiagExternalMediaCardPlugin::TotalSteps() const
       
   168     {
       
   169     return KDiagExternalMediaCardStepsMaxCount;
       
   170     }
       
   171 
       
   172 
       
   173 // ---------------------------------------------------------------------------
       
   174 // From MDiagPlugin
       
   175 // CDiagExternalMediaCardPlugin::GetPluginNameL
       
   176 // ---------------------------------------------------------------------------
       
   177 HBufC* CDiagExternalMediaCardPlugin::GetPluginNameL( TNameLayoutType aLayoutType ) const
       
   178     {
       
   179     switch ( aLayoutType )
       
   180         {
       
   181         case ENameLayoutListSingle:
       
   182             return StringLoader::LoadL ( R_DIAG_EXTERNAL_MEDIA_CARD_PLUGIN_NAME );
       
   183                         
       
   184         case ENameLayoutHeadingPane:
       
   185              return StringLoader::LoadL ( R_QTN_DIAG_MSG_TITLE_MMC );
       
   186         
       
   187         case ENameLayoutPopupInfoPane:
       
   188               //return StringLoader::LoadL ( R_QTN_DIAG_MSG_INFO_MMC );
       
   189               //Return test name for dispalyin TEST REsults in case of Perform All test
       
   190               //Ravi
       
   191               return StringLoader::LoadL ( R_DIAG_EXTERNAL_MEDIA_CARD_PLUGIN_NAME );
       
   192         
       
   193         case ENameLayoutTitlePane:
       
   194              return StringLoader::LoadL ( R_QTN_DIAG_TITLE_TEST_EXTERNAL_MEMORY );
       
   195         
       
   196         case ENameLayoutListSingleGraphic:
       
   197              return StringLoader::LoadL ( R_QTN_DIAG_LST_TEST_MMC );            
       
   198             
       
   199 
       
   200         default:
       
   201             LOGSTRING2( "CDiagExternalMediaCardPlugin::GetPluginNameL: "
       
   202                 L"ERROR: Unsupported layout type %d", aLayoutType )
       
   203             __ASSERT_DEBUG( 0, User::Invariant() );
       
   204             return StringLoader::LoadL ( R_DIAG_EXTERNAL_MEDIA_CARD_PLUGIN_NAME );
       
   205         }
       
   206     }
       
   207 
       
   208 // ---------------------------------------------------------------------------
       
   209 // From MDiagPlugin
       
   210 // CDiagExternalMediaCardPlugin::Uid
       
   211 // ---------------------------------------------------------------------------
       
   212 TUid CDiagExternalMediaCardPlugin::Uid() const
       
   213     {
       
   214     return KDiagExternalMediaCardPluginUid;
       
   215     }
       
   216 
       
   217     
       
   218 // ---------------------------------------------------------------------------
       
   219 // From CActive
       
   220 // CDiagExternalMediaCardPlugin::RunL
       
   221 // ---------------------------------------------------------------------------
       
   222 void CDiagExternalMediaCardPlugin::RunL()
       
   223     {    	
       
   224     switch ( iState )
       
   225         {
       
   226         case EWriting:
       
   227             //report test progress     	
       
   228             iCounter--;    
       
   229             if ( iCounter > 0 )
       
   230                 {
       
   231                 ReportTestProgressL( KDiagExternalMediaCardStepsMaxCount - iCounter );
       
   232                 }
       
   233     		
       
   234     		if (idialogDismissed)
       
   235 	    		{
       
   236 	    		ReportResultToPluginL( CDiagResultsDatabaseItem::ESkipped );
       
   237 	    		LOGSTRING("CDiagExternalMediaCardPlugin::RunL dialogDismissed=EWriting");
       
   238 	    		return;
       
   239 	    		}
       
   240             //check if write is okay
       
   241             if ( iStatus == KErrNone )
       
   242                 {
       
   243                 LOGSTRING( "CDiagExternalMediaCard::RunL, write ok" );
       
   244                 iFile.Close();
       
   245 					
       
   246                 // read test			
       
   247                 TInt errorCodeOpen = iFile2.Open( iFs, iFileName, EFileRead );				
       
   248                 if ( errorCodeOpen!=KErrNone )
       
   249                     {
       
   250                     LOGSTRING( "CDiagExternalMediaCard::RunL,iFile2 open fail" );				
       
   251                     ReportResultToPluginL( CDiagResultsDatabaseItem::EFailed );	
       
   252                     return;
       
   253                     }			    
       
   254                 LOGSTRING( "CDiagExternalMediaCard::RunL, iFile2 open okay" );
       
   255 				
       
   256                 // Start read test
       
   257                 SetState( EReading ); 
       
   258                 iBufr.Zero();
       
   259                 iFile2.Read( iBufr, iStatus );
       
   260          				
       
   261                 SetActive();                                
       
   262                 }
       
   263             else   //write fail
       
   264                 {
       
   265                 LOGSTRING( "CDiagExternalMediaCard::RunL, write fail" );	
       
   266                 //set test result fail
       
   267                 ReportResultToPluginL( CDiagResultsDatabaseItem::EFailed );       			
       
   268                 }
       
   269             break;
       
   270     			
       
   271         case EReading:
       
   272         
       
   273         	if (idialogDismissed)
       
   274 	    		{
       
   275 	    		ReportResultToPluginL( CDiagResultsDatabaseItem::ESkipped );
       
   276 	    		LOGSTRING("CDiagExternalMediaCardPlugin::RunL dialogDismissed=EReading");
       
   277 	    		return;
       
   278 	    		}
       
   279             //check if read is okay
       
   280             if( iStatus == KErrNone )
       
   281                 {
       
   282                 LOGSTRING( "CDiagExternalMediaCard::RunL, read okay" );
       
   283 								
       
   284                 //compare data and set test result				
       
   285                 CDiagResultsDatabaseItem::TResult result = ( iBufr == iBufw )? 
       
   286                                                             CDiagResultsDatabaseItem::ESuccess
       
   287 				                                            : CDiagResultsDatabaseItem::EFailed;
       
   288                 ReportResultToPluginL( result );
       
   289                 LOGSTRING2( "CDiagExternalMediaCard::RunL,test result %d", result );
       
   290                 }
       
   291             else  //read fail
       
   292                 {
       
   293                 LOGSTRING( "CDiagExternalMediaCard::RunL, read fail" );  		
       
   294                 //set result fail
       
   295                 ReportResultToPluginL( CDiagResultsDatabaseItem::EFailed );
       
   296                 }
       
   297             break;
       
   298     		
       
   299         default:
       
   300             LOGSTRING( "CDiagExternalMediaCard::RunL, default case" );
       
   301             //set result fail
       
   302             ReportResultToPluginL( CDiagResultsDatabaseItem::EFailed );       			
       
   303             break;
       
   304         }
       
   305     }    
       
   306 
       
   307 // ---------------------------------------------------------------------------
       
   308 // CDiagExternalMediaCardPlugin::RunError
       
   309 // ---------------------------------------------------------------------------
       
   310 //
       
   311 TInt CDiagExternalMediaCardPlugin::RunError( TInt aError )
       
   312 	{
       
   313 		LOGSTRING2( "CDiagExternalMediaCardPlugin::RunError( %d )", aError )    
       
   314 		return KErrNone;
       
   315 	}
       
   316 	
       
   317 // ---------------------------------------------------------------------------
       
   318 // From CActive
       
   319 // CDiagExternalMediaCardPlugin::DoCancel
       
   320 // ---------------------------------------------------------------------------
       
   321 void CDiagExternalMediaCardPlugin::DoCancel()
       
   322     { 
       
   323     switch ( iState )
       
   324         {
       
   325         case EReading:
       
   326             iFile.ReadCancel(iStatus);
       
   327             break;
       
   328             
       
   329         default:
       
   330             // No action needed
       
   331             break;
       
   332         }    
       
   333     // RFile.Write() does not support cancel. 
       
   334     // See Symbian FAQ 1409 at
       
   335     // http://www3.symbian.com/faq.nsf/0/C3248753E9B33398802571C3006037CA?OpenDocument
       
   336     // So no cancel is necessary for EWriting
       
   337     
       
   338     }    
       
   339 
       
   340 
       
   341 // ---------------------------------------------------------------------------
       
   342 // From CDiagTestPluginBase
       
   343 // CDiagExternalMediaCardPlugin::ShowTitleMessageL()
       
   344 // ---------------------------------------------------------------------------
       
   345 TBool CDiagExternalMediaCardPlugin::ShowTitleMessageL()
       
   346     {
       
   347     TInt aButtonId;
       
   348     ShowMessageQueryL(R_MESSAGEQUERY_TITLE_EXTERNALMEMORY,aButtonId);
       
   349     
       
   350     if(aButtonId == ECBACmdCancel)
       
   351         {
       
   352         ReportResultToPluginL( CDiagResultsDatabaseItem::ESkipped );
       
   353         return EFalse;
       
   354         }
       
   355     
       
   356     if(aButtonId == ECBACmdSkip)
       
   357         {
       
   358         TInt confirmResult = 0;
       
   359             
       
   360         CAknDialog* dlg = ExecutionParam().Engine().
       
   361         CreateCommonDialogLC( EDiagCommonDialogConfirmSkipAll, NULL );
       
   362     
       
   363         if ( !RunWaitingDialogL( dlg, confirmResult ) )
       
   364             {
       
   365             return EFalse;
       
   366             }
       
   367         
       
   368         if ( confirmResult)
       
   369             {
       
   370             return EFalse;
       
   371             }
       
   372         }
       
   373     return ETrue;
       
   374     }
       
   375 
       
   376 // ---------------------------------------------------------------------------
       
   377 // From CDiagTestPluginBase
       
   378 // CDiagExternalMediaCardPlugin::DoRunTestL()
       
   379 // ---------------------------------------------------------------------------
       
   380 void CDiagExternalMediaCardPlugin::DoRunTestL()
       
   381     {
       
   382     //TInt aButtonId; // ADO & Platformization Changes
       
   383     iCounter = KDiagExternalMediaCardStepsMaxCount;
       
   384     // ADO & Platformization Changes
       
   385     if(!ShowTitleMessageL())
       
   386         return;
       
   387     // Changes Ends
       
   388     
       
   389     //Start my test
       
   390     ShowProgressNoteL();
       
   391         
       
   392     SetState( EIdle );
       
   393     
       
   394     //test should not be performed if external media card is not supported
       
   395     ASSERT( FeatureManager::FeatureSupported( KFeatureIdMmc ) );
       
   396     
       
   397     TInt errorCode( KErrNotFound );
       
   398     
       
   399         //check the drive number for external card
       
   400     TInt mmcDriveNum( 0 );
       
   401     
       
   402         // If path length is zero, driveLetterBuf will be empty.
       
   403     TBuf<1> driveLetterBuf;
       
   404     
       
   405     
       
   406     
       
   407 
       
   408         
       
   409  	driveLetterBuf = PathInfo::MemoryCardRootPath().Left( 1 );
       
   410 
       
   411     if ( driveLetterBuf.Length() > 0 )
       
   412         {
       
   413         LOGSTRING( "CDiagExternalMediaCard::DoRunTestL, driveLetterBuf ok" );
       
   414         TChar driveLetter = driveLetterBuf[0];
       
   415         errorCode = RFs::CharToDrive( driveLetter, mmcDriveNum );
       
   416         }
       
   417     else
       
   418         {
       
   419         LOGSTRING( "CDiagExternalMediaCard::DoRunTestL, driveLetterBuf empty" );
       
   420         }
       
   421             
       
   422     if ( errorCode != KErrNone )
       
   423         {
       
   424         //no such drive exists,act as feature not supported
       
   425         LOGSTRING( "CDiagExternalMediaCard::DoRunTestL, no drive" );               	
       
   426         ReportResultToPluginL( CDiagResultsDatabaseItem::EFailed );
       
   427         return;       			
       
   428        	}
       
   429        	
       
   430        	
       
   431     TVolumeInfo volumeinfo;
       
   432     TDriveInfo driveInfo;
       
   433     TInt errorCode2;
       
   434         	
       
   435     do
       
   436     {
       
   437     User::LeaveIfError( iFs.Connect() );  // Connects a client process to the fileserver
       
   438     LOGSTRING( "CDiagExternalMediaCard::DoRunTestL, iFs connect" );
       
   439     
       
   440     errorCode = iFs.Volume( volumeinfo, mmcDriveNum );
       
   441     LOGSTRING( "CDiagExternalMediaCard::DoRunTestL, Volume" );
       
   442     
       
   443     errorCode2 = iFs.Drive( driveInfo, mmcDriveNum );
       
   444     LOGSTRING( "CDiagExternalMediaCard::DoRunTestL, Drive" );
       
   445     
       
   446     if ( errorCode != KErrNone || errorCode2 != KErrNone )
       
   447         {
       
   448         //no such drive exists,act as feature not supported
       
   449         LOGSTRING( "CDiagExternalMediaCard::DoRunTestL, no drive" );               		
       
   450 	        TInt  buttonId;
       
   451 		    TBool result = EFalse;
       
   452 		    result = ShowMessageQueryL( R_MESSAGEQUERY_NO_EXTERNALMEMORY, buttonId );
       
   453 
       
   454 		    // Check session is valid after dialog dismissed
       
   455 		    if ( !result )
       
   456 		        {
       
   457 		        LOGSTRING( "CDiagExternalMediaCardPlugin::AfterPlayL - !iSessionValid 1.2" )
       
   458 		        return;
       
   459 		        }
       
   460 
       
   461 		    // Report Success on Yes
       
   462 		    if ( (buttonId == EAknSoftkeyYes) ||  (buttonId == EAknSoftkeyOk))
       
   463 		        {
       
   464 		        LOGSTRING( "CDiagExternalMediaCardPlugin::EAknSoftkeyOk has pressed - return ESuccess" )
       
   465 		        }
       
   466 		    else if ( buttonId == ECBACmdSkip )
       
   467 		        {
       
   468        			ReportResultToPluginL( CDiagResultsDatabaseItem::ESkipped );
       
   469 		        return;
       
   470 		        }
       
   471 	    	else if ( (buttonId == EAknSoftkeyNo) || (buttonId == ECBACmdNo) )
       
   472 		        {
       
   473 		        		if(SinglePluginExecution())
       
   474 		        		{	
       
   475 		        		ReportResultToPluginL( CDiagResultsDatabaseItem::EFailed);
       
   476 		        		return;
       
   477 		        		}
       
   478 		        		else
       
   479 		        		{
       
   480 		            TInt confirmResult = 0;
       
   481                 
       
   482                     CAknDialog* dlg = ExecutionParam().Engine().
       
   483                     CreateCommonDialogLC( EDiagCommonDialogConfirmCancelAll, NULL );
       
   484                 
       
   485                     if ( !RunWaitingDialogL( dlg, confirmResult ) )
       
   486                         {
       
   487                         return;
       
   488                         }
       
   489                     
       
   490                     if ( confirmResult)
       
   491                         {
       
   492                         //CompleteTestL( CDiagResultsDatabaseItem::ECancelled );	
       
   493                         return;
       
   494                         }
       
   495                  }
       
   496 
       
   497 		        }		   
       
   498         }
       
   499     
       
   500       } while(errorCode != KErrNone || errorCode2 != KErrNone);
       
   501         
       
   502         	                  
       
   503     //check status of external media card
       
   504         
       
   505     if ( ( driveInfo.iMediaAtt & KMediaAttLocked ) ||
       
   506          ( driveInfo.iMediaAtt & KMediaAttWriteProtected ) )
       
   507         {
       
   508         //card is locked or read only
       
   509         LOGSTRING( "CDiagExternalMediaCard::DoRunTestL, card locked or read only" );		     		
       
   510         ReportResultToPluginL( CDiagResultsDatabaseItem::EFailed ); 
       
   511         return;       		       		    			
       
   512         }
       
   513             		       		
       
   514     if ( SysUtil::DiskSpaceBelowCriticalLevelL( &iFs, iBufw.MaxLength(), mmcDriveNum ) )
       
   515         {
       
   516         //card is out of memory
       
   517         LOGSTRING( "CDiagExternalMediaCard::DoRunTestL, out of memory" );
       
   518         ReportResultToPluginL( CDiagResultsDatabaseItem::EFailed );	
       
   519         return;	
       
   520         }
       
   521     	 
       
   522     //Try to create a temp file for test	    		
       
   523     TFileName FilePath;
       
   524     TDriveUnit unit( mmcDriveNum );
       
   525     errorCode = iFs.CreatePrivatePath( unit );
       
   526 		
       
   527     if ( ( errorCode != KErrNone ) && ( errorCode != KErrAlreadyExists ) )
       
   528         {
       
   529         LOGSTRING( "CDiagExternalMediaCard::DoRunTestL, CreatePrivatePath fail" );
       
   530         ReportResultToPluginL( CDiagResultsDatabaseItem::EFailed );	
       
   531         return;
       
   532         }
       
   533 			
       
   534     iFs.PrivatePath( FilePath );
       
   535     FilePath.Insert( 0, unit.Name() );
       
   536 								    		
       
   537     errorCode = iFile.Temp( iFs, FilePath, iFileName, EFileWrite );
       
   538     LOGSTRING2( "CDiagExternalMediaCard::DoRunTestL, Temp err = %d", errorCode );
       
   539 											
       
   540     if ( errorCode != KErrNone )
       
   541         {
       
   542         //Temp file creation failed
       
   543         ReportResultToPluginL( CDiagResultsDatabaseItem::EFailed );
       
   544         return;
       
   545         }
       
   546     		
       
   547     // Temp file created, start the write test					
       
   548 							
       
   549     iBufw.Zero();
       
   550     iBufw.Copy( KText1 );
       
   551 			
       
   552     SetState( EWriting ); 
       
   553 		
       
   554     iFile.Write( iBufw, iStatus );
       
   555     SetActive();    
       
   556     }
       
   557 
       
   558 // ----------------------------------------------------------------------------
       
   559 // CDiagExternalMediaCardPlugin::ShowProgressNoteL
       
   560 //
       
   561 // Progress Note
       
   562 // ----------------------------------------------------------------------------
       
   563 
       
   564 void CDiagExternalMediaCardPlugin::ShowProgressNoteL()
       
   565     {
       
   566 		if ( iWaitDialog )
       
   567 		    {
       
   568 		    delete iWaitDialog;
       
   569 		    iWaitDialog = NULL;
       
   570 		    }
       
   571 
       
   572 		                    
       
   573 		// WAIT NOTE DIALOG
       
   574 		iWaitDialog = new (ELeave) CAknWaitDialog(
       
   575 									(REINTERPRET_CAST(CEikDialog**, &iWaitDialog)), 
       
   576 									ETrue);
       
   577 
       
   578 		iWaitDialog->PrepareLC(R_EXTMEM_PLUGIN_WAIT_NOTE);
       
   579 		iWaitDialog->SetCallback(this);
       
   580 		iWaitDialog->RunLD();
       
   581 		idialogOn = ETrue;
       
   582 		LOGSTRING("CDiagExternalMediaCardPlugin::ShowProgressNoteL()");
       
   583 
       
   584     }
       
   585 
       
   586 //*********************************************************
       
   587 // CallBack from AKnWaitDialog when Cancel is pressed
       
   588 //*********************************************************
       
   589 
       
   590 void CDiagExternalMediaCardPlugin::DialogDismissedL( TInt aButtonId )
       
   591 	{
       
   592 		 LOGSTRING2("CDiagExternalMediaCardPlugin::DialogDismissedL() = %d",aButtonId);
       
   593 		 
       
   594 		 if (aButtonId == ECBACmdCancel && idialogOn) 
       
   595 		 {
       
   596 		 // cancel the tests based on which point the dialog is dismissed
       
   597 		 LOGSTRING2("CDiagExternalMediaCardPlugin::DialogDismissed @ iState= %d",iState);
       
   598 		 if (iState == EReading)
       
   599 	     iFile.ReadCancel(iStatus);
       
   600 		
       
   601 	     iWaitDialog = NULL;
       
   602 	     idialogOn = EFalse;
       
   603 	     idialogDismissed = ETrue;      
       
   604 		 }
       
   605 	}    
       
   606 
       
   607 void CDiagExternalMediaCardPlugin::ReportResultToPluginL(CDiagResultsDatabaseItem::TResult aResult)
       
   608 	{
       
   609 		// clear the dialogue only if dialog is running.    
       
   610 		if(idialogOn)    
       
   611 		iWaitDialog->ProcessFinishedL();
       
   612 
       
   613 		CompleteTestL( aResult );
       
   614 	}
       
   615 	
       
   616 //---------------------------------------------------------------------------
       
   617 // CDiagExternalMediaCardPlugin::DoStopAndCleanupL
       
   618 //---------------------------------------------------------------------------
       
   619 void CDiagExternalMediaCardPlugin::DoStopAndCleanupL()
       
   620     {
       
   621     switch ( iState )
       
   622         {
       
   623         case EWriting: 
       
   624             iFile.Close();
       
   625             iFs.Delete( iFileName ); // delete the file created by Temp									
       
   626             iFs.Close();
       
   627             break;
       
   628     		
       
   629         case EReading:
       
   630             iFile2.Close();	
       
   631             iFs.Delete( iFileName ); // delete the file created by Temp						
       
   632             iFs.Close();   		
       
   633             break;
       
   634     		 
       
   635         case EIdle:
       
   636             iFs.Close();
       
   637             break;
       
   638     	    
       
   639         default:
       
   640             ASSERT ( EFalse );      //this should never happen
       
   641             break;
       
   642         }
       
   643 	if ( iWaitDialog )
       
   644 	delete iWaitDialog;   
       
   645 	idialogOn = EFalse;
       
   646 	idialogDismissed = EFalse;
       
   647     SetState( EIdle );
       
   648     }
       
   649 
       
   650     
       
   651 //---------------------------------------------------------------------------
       
   652 // CDiagExternalMediaCardPlugin::SetState()
       
   653 //---------------------------------------------------------------------------
       
   654 void CDiagExternalMediaCardPlugin::SetState( TStates aState )
       
   655     {
       
   656     iState = aState;
       
   657     }
       
   658     
       
   659 // ADO & Platformization Changes
       
   660 TBool CDiagExternalMediaCardPlugin::ShowMessageQueryL( TInt aResourceId, TInt &aButtonId  )
       
   661     {
       
   662     LOGSTRING( "CDiagAudioPlugin::ShowMessageQueryL IN" )
       
   663     CAknMessageQueryDialog* dlg    = NULL;
       
   664     TBool                   result = EFalse;
       
   665 
       
   666     // Create CAknMessageQueryDialog instance
       
   667     dlg = new ( ELeave ) CAknMessageQueryDialog();
       
   668 
       
   669     dlg->PrepareLC( aResourceId );
       
   670      
       
   671     CEikButtonGroupContainer& cba = dlg->ButtonGroupContainer();
       
   672 
       
   673         switch ( aResourceId )
       
   674             {
       
   675             case R_MESSAGEQUERY_TITLE_EXTERNALMEMORY: 
       
   676          	   {
       
   677             	if ( SinglePluginExecution() )
       
   678         			{
       
   679         			cba.SetCommandSetL( R_EXT_MEMORY_SOFTKEYS_OK_CANCEL );		
       
   680         			}
       
   681         	   else 
       
   682         	   		{	
       
   683                 	cba.SetCommandSetL( R_EXT_MEMORY_SOFTKEYS_OK_SKIP );		
       
   684                 	}
       
   685         		}
       
   686                 break;
       
   687 
       
   688             default:
       
   689                 break;
       
   690             }
       
   691         	
       
   692     result = RunWaitingDialogL( dlg, aButtonId );
       
   693 
       
   694     LOGSTRING3( "CDiagAudioPlugin::ShowMessageQueryL() OUT aButtonId=%d result=%d", aButtonId, result );
       
   695     return result;
       
   696     }
       
   697     
       
   698 // End of File
       
   699