devicediagnostics/diagplugins/diagusbcableplugin/src/diagusbcabletestplugin.cpp
changeset 0 3ce708148e4d
equal deleted inserted replaced
-1:000000000000 0:3ce708148e4d
       
     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:  This is the class module for the Diagnostics USB Cable Test plugin
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 // Class Declaration
       
    22 #include "diagusbcabletestplugin.h"
       
    23 
       
    24 // System includes
       
    25 #include <avkon.hrh>                        // command definitions
       
    26 #include <StringLoader.h>                   // StringLoader
       
    27 #include <aknmessagequerydialog.h>     		// CAknMessageQueryDialog
       
    28 #include <DiagFrameworkDebug.h>             // Debug macros
       
    29 #include <DiagTestExecParam.h>              // TDiagTestExecParam
       
    30 #include <DiagEngineCommon.h>               // MDiagEngineCommon
       
    31 #include <devdiagusbcabletestpluginrsc.rsg>    // resources
       
    32 
       
    33 // User includes
       
    34 #include "diagusbcabletestengine.h"         // CDiagUSBCableTestEngine
       
    35 #include "diagusbcabletestplugin.hrh"       // UIDs and command ids
       
    36 
       
    37 // EXTERNAL DATA STRUCTURES
       
    38 
       
    39 // EXTERNAL FUNCTION PROTOTYPES
       
    40 
       
    41 // CONSTANTS
       
    42 const TUint KTotalNumOfSteps = 2;
       
    43 const TUid KDiagUSBCableTestPluginUid = { _IMPLEMENTATION_UID };
       
    44 _LIT( KDiagUSBCableTestPluginResourceFileName, "z:DevDiagUSBCableTestPluginRsc.rsc" );
       
    45 
       
    46 // MACROS
       
    47 
       
    48 // LOCAL CONSTANTS AND MACROS
       
    49 
       
    50 // MODULE DATA STRUCTURES
       
    51 
       
    52 // LOCAL FUNCTION PROTOTYPES
       
    53 
       
    54 // FORWARD DECLARATIONS
       
    55 
       
    56 // ============================= LOCAL FUNCTIONS ==============================
       
    57 
       
    58 // ========================= MEMBER FUNCTIONS ================================
       
    59 
       
    60 // ----------------------------------------------------------------------------
       
    61 // Constructor
       
    62 // ----------------------------------------------------------------------------
       
    63 //
       
    64 CDiagUSBCableTestPlugin::CDiagUSBCableTestPlugin
       
    65                                   ( CDiagPluginConstructionParam* aParam )
       
    66     : CDiagTestPluginBase( aParam )
       
    67     {
       
    68     LOGSTRING( "CDiagUSBCableTestPlugin::CDiagUSBCableTestPlugin()" )
       
    69     }
       
    70 
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // Symbian OS default constructor
       
    74 // ---------------------------------------------------------------------------
       
    75 MDiagPlugin* CDiagUSBCableTestPlugin::NewL( TAny* aInitParams )
       
    76     {
       
    77     LOGSTRING( "CDiagUSBCableTestPlugin::NewL()" )
       
    78     CDiagPluginConstructionParam* param = 
       
    79             static_cast<CDiagPluginConstructionParam*>(aInitParams);
       
    80 
       
    81     CleanupStack::PushL( param );
       
    82     CDiagUSBCableTestPlugin* self = 
       
    83             new( ELeave ) CDiagUSBCableTestPlugin (param);
       
    84     CleanupStack::Pop( param );
       
    85 
       
    86     CleanupStack::PushL( self );
       
    87     self->ConstructL();
       
    88     CleanupStack::Pop(self);
       
    89 
       
    90     return self;
       
    91     }
       
    92 
       
    93 
       
    94 
       
    95 // ---------------------------------------------------------------------------
       
    96 // Symbian OS second phase constructor
       
    97 // ---------------------------------------------------------------------------
       
    98 void CDiagUSBCableTestPlugin::ConstructL()
       
    99     {
       
   100     LOGSTRING( "CDiagUSBCableTestPlugin::ConstructL()" )
       
   101     BaseConstructL ( KDiagUSBCableTestPluginResourceFileName );
       
   102     }
       
   103 
       
   104 
       
   105 // ----------------------------------------------------------------------------
       
   106 // Destructor
       
   107 // ----------------------------------------------------------------------------
       
   108 CDiagUSBCableTestPlugin::~CDiagUSBCableTestPlugin()
       
   109     {
       
   110     LOGSTRING( "CDiagUSBCableTestPlugin::~CDiagUSBCableTestPlugin()" )
       
   111     // StopAndCleanupL() called by base class, whcih calls
       
   112     //  Cancel()    -> DoCancel()
       
   113     //  DoStopAndCleanupL()
       
   114     // Not much to do here.
       
   115     }
       
   116 
       
   117 
       
   118 // ---------------------------------------------------------------------------
       
   119 // From MDiagPlugin
       
   120 // CDiagUSBCableTestPlugin::IsVisible()
       
   121 // ---------------------------------------------------------------------------
       
   122 
       
   123 TBool CDiagUSBCableTestPlugin::IsVisible() const
       
   124     {
       
   125     return ETrue;
       
   126     }
       
   127    
       
   128 
       
   129 // ---------------------------------------------------------------------------
       
   130 // From MDiagTestPlugin
       
   131 // CDiagUSBCableTestPlugin::RunMode()
       
   132 // ---------------------------------------------------------------------------
       
   133 MDiagTestPlugin::TRunMode CDiagUSBCableTestPlugin::RunMode() const
       
   134     {
       
   135     return EInteractiveDialog;
       
   136     }
       
   137 
       
   138 // ---------------------------------------------------------------------------
       
   139 // From MDiagTestPlugin
       
   140 // CDiagUSBCableTestPlugin::TotalSteps()
       
   141 // ---------------------------------------------------------------------------
       
   142 TUint CDiagUSBCableTestPlugin::TotalSteps() const
       
   143     {
       
   144     return KTotalNumOfSteps;
       
   145     }
       
   146 
       
   147 // ---------------------------------------------------------------------------
       
   148 // From MDiagPlugin
       
   149 // CDiagUSBCableTestPlugin::GetPluginName
       
   150 // ---------------------------------------------------------------------------
       
   151 HBufC* CDiagUSBCableTestPlugin::GetPluginNameL( TNameLayoutType aLayoutType ) const
       
   152     {
       
   153     switch ( aLayoutType )
       
   154         {
       
   155         
       
   156         case ENameLayoutHeadingPane:
       
   157             return StringLoader::LoadL( R_DIAG_USB_CABLE_TEST_HEADING_PANE );
       
   158 
       
   159         case ENameLayoutPopupInfoPane:
       
   160             return StringLoader::LoadL( R_DIAG_USB_CABLE_TEST_POPUP_INFO_PANE );
       
   161 
       
   162         case ENameLayoutTitlePane:
       
   163             return StringLoader::LoadL( R_DIAG_USB_CABLE_TEST_TITLE_PANE );
       
   164                                                                            
       
   165         case ENameLayoutListSingleGraphic:
       
   166             return StringLoader::LoadL( R_DIAG_USB_CABLE_TEST_SINGLE_GRAPHIC  );        
       
   167         
       
   168         case ENameLayoutListSingle:
       
   169             return StringLoader::LoadL ( R_DIAG_USB_CABLE_TEST_SINGLE ); 
       
   170 
       
   171         default:
       
   172             LOGSTRING2( "CDiagUSBCableTestPlugin::GetPluginNameL: "
       
   173                 L"ERROR: Unsupported layout type %d", aLayoutType )
       
   174             __ASSERT_DEBUG( 0, User::Invariant() );
       
   175             return StringLoader::LoadL ( R_DIAG_USB_CABLE_TEST_SINGLE );
       
   176         }
       
   177     }
       
   178     
       
   179 
       
   180 
       
   181 
       
   182 // ---------------------------------------------------------------------------
       
   183 // From MDiagPlugin
       
   184 // CDiagUSBCableTestPlugin::Uid
       
   185 // ---------------------------------------------------------------------------
       
   186 TUid CDiagUSBCableTestPlugin::Uid() const
       
   187     {
       
   188     return KDiagUSBCableTestPluginUid;
       
   189     }
       
   190     
       
   191    
       
   192 // ---------------------------------------------------------------------------
       
   193 // From CActive
       
   194 // CDiagUSBCableTestPlugin::RunL
       
   195 // ---------------------------------------------------------------------------
       
   196 void CDiagUSBCableTestPlugin::RunL()
       
   197     {
       
   198     // nothing to do here
       
   199     }
       
   200 
       
   201 // ---------------------------------------------------------------------------
       
   202 // From CActive
       
   203 // CDiagUSBCableTestPlugin::DoCancel
       
   204 // ---------------------------------------------------------------------------
       
   205 void CDiagUSBCableTestPlugin::DoCancel()
       
   206     {
       
   207     // nothing to do here
       
   208     }
       
   209 
       
   210 // ---------------------------------------------------------------------------
       
   211 // From CDiagTestPluginBase
       
   212 // CDiagUSBCableTestPlugin::DoRunTestL()
       
   213 // ---------------------------------------------------------------------------
       
   214 void CDiagUSBCableTestPlugin::DoRunTestL()
       
   215     {
       
   216     LOGSTRING( "CDiagUSBCableTestPlugin::DoRunTestL() Test execution begins here." )
       
   217     // ADO & Platformization Changes
       
   218     CAknMessageQueryDialog* dlg    = NULL;
       
   219     TInt aButtonId,result;
       
   220     // code ends
       
   221 
       
   222     // Run USB Cable Test
       
   223     ASSERT( iEngine == NULL );
       
   224     
       
   225     // ADO & Platformization Changes
       
   226 	dlg = new ( ELeave ) CAknMessageQueryDialog();
       
   227 
       
   228     dlg->PrepareLC(R_MESSAGEQUERY_TITLE );
       
   229     
       
   230     if(SinglePluginExecution())
       
   231         {
       
   232         CEikButtonGroupContainer& cba = dlg->ButtonGroupContainer();
       
   233         cba.SetCommandSetL(R_DIAG_USB_SOFTKEYS_CANCEL__OK);
       
   234         }
       
   235 
       
   236 	result = RunWaitingDialogL( dlg, aButtonId );
       
   237 	
       
   238 	if (result == KErrNone)
       
   239 	{
       
   240 	LOGSTRING("RunWaitingDialogL return = true");
       
   241 	}
       
   242 	
       
   243 	if(aButtonId == EUsbTestConnectUSBCancel )
       
   244 		{
       
   245 		CompleteTestL( CDiagResultsDatabaseItem::ECancelled );
       
   246 		return;	
       
   247 		}
       
   248 	
       
   249    if(aButtonId == EUsbTestConnectUSBSkip )
       
   250         {
       
   251         TInt aUserResponse;
       
   252         TInt aResponseType;
       
   253         TInt aOption = 0;
       
   254         aResponseType = AskCancelExecutionL(aUserResponse,aOption);
       
   255         
       
   256         if(!aResponseType)
       
   257             return;
       
   258         
       
   259         if (aUserResponse)
       
   260                { 
       
   261                return;
       
   262                }
       
   263         }
       
   264 		
       
   265 	// ADO & Platformization Changes
       
   266 
       
   267     iEngine = CDiagUSBCableTestEngine::NewL(*this, SinglePluginExecution() );
       
   268     iEngine->RunUSBCableTestL();
       
   269     }
       
   270 
       
   271 // ---------------------------------------------------------------------------
       
   272 // From CDiagTestPluginBase
       
   273 // CDiagUSBCableTestPlugin::DoStopAndCleanupL()
       
   274 // ---------------------------------------------------------------------------
       
   275 void CDiagUSBCableTestPlugin::DoStopAndCleanupL()
       
   276     {
       
   277     LOGSTRING( "CDiagUSBCableTestPlugin::DoStopAndCleanupL()." )
       
   278     delete iEngine;
       
   279     iEngine = NULL;
       
   280     }
       
   281 
       
   282 // ---------------------------------------------------------------------------
       
   283 // From MDiagUSBTestReportResultInterface
       
   284 // CDiagUSBCableTestPlugin::ReportTestResultL()
       
   285 // ---------------------------------------------------------------------------
       
   286 void CDiagUSBCableTestPlugin::ReportTestResultL(
       
   287                                     CDiagResultsDatabaseItem::TResult aResult)
       
   288     {
       
   289     CompleteTestL( aResult );
       
   290     }
       
   291 
       
   292 // ---------------------------------------------------------------------------
       
   293 // The engine class uses this callback on the plugin class to ask the user if 
       
   294 // the entire test execution needs to be cancelled.
       
   295 // ---------------------------------------------------------------------------
       
   296 TBool CDiagUSBCableTestPlugin::AskCancelExecutionL(TInt& aUserResponse, TInt aOption)
       
   297     {
       
   298     CAknDialog* cancelDialog = NULL;
       
   299     if(aOption == 0)
       
   300         {
       
   301         cancelDialog = ExecutionParam().Engine().
       
   302                    CreateCommonDialogLC( EDiagCommonDialogConfirmSkipAll, NULL );
       
   303         }
       
   304     else
       
   305         {
       
   306         cancelDialog = ExecutionParam().Engine().
       
   307                            CreateCommonDialogLC( EDiagCommonDialogConfirmCancelAll, NULL);
       
   308         }
       
   309           
       
   310     return RunWaitingDialogL( cancelDialog, aUserResponse );
       
   311     }    
       
   312 
       
   313 // End of File
       
   314