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