devicediagnostics/diagplugins/diagdatanetworkplugin/src/diagdatanetworktestplugin.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 Data Network Test 
       
    15 *                 plug-in class.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 
       
    22 // Class Declaration
       
    23 #include "diagdatanetworktestplugin.h"      // CDiagDataNetworkTestPlugin
       
    24 
       
    25 // System includes
       
    26 #include <centralrepository.h> 
       
    27 #include <StringLoader.h>                   // StringLoader
       
    28 #include <devdiagdatanetworktestpluginrsc.rsg> // Resources
       
    29 #include <DiagFrameworkDebug.h>             // LOGSTRING
       
    30 #include "diagdatanetworkprivatecrkeys.h"
       
    31 
       
    32 // User includes
       
    33 #include "diagdatanetworktestplugin.hrh"    // UIDs
       
    34 #include "diagdatanetworktestpdpengine.h"   // CDiagDataNetworkTestPDPEngine
       
    35 // ADO & Platformization Changes
       
    36 #include <DiagFrameworkDebug.h>                     // debug macros
       
    37 #include <DiagEngineCommon.h>                       // MDiagEngineCommon
       
    38 #include <DiagCommonDialog.h> 
       
    39 #include <AknDialog.h> // ADO & Platformization Changes
       
    40 #include <aknmessagequerydialog.h>  // ADO & Platformization Changes
       
    41 #include <DiagTestExecParam.h>          // TDiagTestExecParam
       
    42 #include <DiagPluginExecPlan.h>
       
    43 #include <DiagExecPlanEntry.h>
       
    44 
       
    45 // EXTERNAL DATA STRUCTURES
       
    46 
       
    47 // EXTERNAL FUNCTION PROTOTYPES
       
    48 
       
    49 // CONSTANTS
       
    50 const TUid KDiagDataNetworkTestPluginUid = { _IMPLEMENTATION_UID };
       
    51 _LIT( KDiagDataNetworkTestPluginResourceFileName, "z:DevDiagDataNetworkTestPluginRsc.rsc" );
       
    52 
       
    53 // MACROS
       
    54 
       
    55 // LOCAL CONSTANTS AND MACROS
       
    56 
       
    57 // MODULE DATA STRUCTURES
       
    58 
       
    59 // LOCAL FUNCTION PROTOTYPES
       
    60 
       
    61 // FORWARD DECLARATIONS
       
    62 
       
    63 // ============================= LOCAL FUNCTIONS ==============================
       
    64 
       
    65 // ========================= MEMBER FUNCTIONS ================================
       
    66 
       
    67 // ----------------------------------------------------------------------------
       
    68 // CDiagDataNetworkTestPlugin::CDiagDataNetworkTestPlugin()
       
    69 //
       
    70 // Constructor
       
    71 // ----------------------------------------------------------------------------
       
    72 //
       
    73 CDiagDataNetworkTestPlugin::CDiagDataNetworkTestPlugin( CDiagPluginConstructionParam* aParam )
       
    74     :   CDiagTestPluginBase( aParam )
       
    75     {
       
    76     LOGSTRING("CDiagDataNetworkTestPlugin::CDiagDataNetworkTestPlugin()")
       
    77     }
       
    78 
       
    79 
       
    80 // ---------------------------------------------------------------------------
       
    81 // CDiagDataNetworkTestPlugin::NewL()
       
    82 //
       
    83 // Symbian OS default constructor
       
    84 // ---------------------------------------------------------------------------
       
    85 MDiagPlugin* CDiagDataNetworkTestPlugin::NewL( TAny* aInitParams )
       
    86     {
       
    87     LOGSTRING("CDiagDataNetworkTestPlugin::NewL()")
       
    88     
       
    89     /*CRepository  *cRep;
       
    90     TInt val;
       
    91     cRep = CRepository::NewL( KCRUidDiagDataNetworkTestPlugin );    
       
    92     CleanupStack::PushL( cRep );  
       
    93     TInt err = cRep->Get( KDiagDataNetworkTestPluginPrimaryAPN,val );
       
    94     CleanupStack::PopAndDestroy(cRep);
       
    95     
       
    96 
       
    97     return NULL;*/
       
    98     
       
    99     if ( !aInitParams )
       
   100         {
       
   101         User::Leave ( KErrArgument );
       
   102         }
       
   103 
       
   104     CleanupStack::PushL( aInitParams );
       
   105     CDiagPluginConstructionParam* param = 
       
   106             static_cast<CDiagPluginConstructionParam*>(aInitParams);
       
   107                 
       
   108     CDiagDataNetworkTestPlugin* self = new( ELeave ) CDiagDataNetworkTestPlugin (param);
       
   109     CleanupStack::PushL( self );
       
   110     
       
   111     self->ConstructL();
       
   112     
       
   113     CleanupStack::Pop(self);
       
   114     CleanupStack::Pop( aInitParams );
       
   115     return self;
       
   116     }
       
   117 
       
   118 
       
   119 
       
   120 // ---------------------------------------------------------------------------
       
   121 // CDiagDataNetworkTestPlugin::ConstructL()
       
   122 //
       
   123 // Symbian OS two-phased constructor
       
   124 // ---------------------------------------------------------------------------
       
   125 void CDiagDataNetworkTestPlugin::ConstructL()
       
   126     {
       
   127     LOGSTRING("CDiagDataNetworkTestPlugin::ConstructL()")
       
   128     BaseConstructL ( KDiagDataNetworkTestPluginResourceFileName );
       
   129     }
       
   130 
       
   131 
       
   132 // ----------------------------------------------------------------------------
       
   133 // CDiagDataNetworkTestPlugin::~CDiagDataNetworkTestPlugin
       
   134 //
       
   135 // Destructor
       
   136 // ----------------------------------------------------------------------------
       
   137 CDiagDataNetworkTestPlugin::~CDiagDataNetworkTestPlugin()
       
   138     {
       
   139     LOGSTRING("CDiagDataNetworkTestPlugin::~CDiagDataNetworkTestPlugin()")
       
   140     
       
   141     // StopAndCleanupL() called by base class destructor, whcih calls
       
   142     //  Cancel()    -> DoCancel()
       
   143     //  DoStopAndCleanupL()
       
   144     // Not much to do here.
       
   145     }
       
   146 
       
   147 
       
   148 // ---------------------------------------------------------------------------
       
   149 // From MDiagPlugin
       
   150 // CDiagDataNetworkTestPlugin::IsVisible()
       
   151 // ---------------------------------------------------------------------------
       
   152 
       
   153 TBool CDiagDataNetworkTestPlugin::IsVisible() const
       
   154     {
       
   155     return ETrue;
       
   156     }
       
   157    
       
   158 
       
   159 // ---------------------------------------------------------------------------
       
   160 // From MDiagTestPlugin
       
   161 // CDiagDataNetworkTestPlugin::RunMode()
       
   162 // ---------------------------------------------------------------------------
       
   163 MDiagTestPlugin::TRunMode CDiagDataNetworkTestPlugin::RunMode() const
       
   164     {
       
   165     return EAutomatic;
       
   166     }
       
   167 
       
   168 // ---------------------------------------------------------------------------
       
   169 // From MDiagTestPlugin
       
   170 // CDiagDataNetworkTestPlugin::DoStopAndCleanupL()
       
   171 // ---------------------------------------------------------------------------
       
   172 void CDiagDataNetworkTestPlugin::DoStopAndCleanupL() 
       
   173     {
       
   174     delete iPDPEngine;
       
   175     iPDPEngine = NULL;        
       
   176     }
       
   177 
       
   178 // ---------------------------------------------------------------------------
       
   179 // From MDiagTestPlugin
       
   180 // CDiagDataNetworkTestPlugin::TotalSteps()
       
   181 // ---------------------------------------------------------------------------
       
   182 TUint CDiagDataNetworkTestPlugin::TotalSteps() const
       
   183     {
       
   184     return (CDiagDataNetworkTestPDPEngine::TotalSteps());
       
   185     }
       
   186 
       
   187 
       
   188 // ---------------------------------------------------------------------------
       
   189 // From MDiagPlugin
       
   190 // CDiagDataNetworkTestPlugin::GetPluginNameL
       
   191 // ---------------------------------------------------------------------------
       
   192 HBufC* CDiagDataNetworkTestPlugin::GetPluginNameL( TNameLayoutType aLayoutType ) const
       
   193     {
       
   194     switch ( aLayoutType )
       
   195         {
       
   196         case ENameLayoutHeadingPane:
       
   197             return StringLoader::LoadL( R_DIAG_DATA_NETWORK_TEST_HEADING_PANE );
       
   198             
       
   199         case ENameLayoutPopupInfoPane:
       
   200             return StringLoader::LoadL( R_DIAG_DATA_NETWORK_TEST_INFO_PANE );            
       
   201 
       
   202         case ENameLayoutTitlePane:
       
   203             return StringLoader::LoadL( R_DIAG_DATA_NETWORK_TEST_TITLE_PANE );
       
   204             
       
   205         case ENameLayoutListSingleGraphic:
       
   206             return StringLoader::LoadL( R_DIAG_DATA_NETWORK_TEST_SINGLE_GRAPHIC  );  
       
   207                     
       
   208         case ENameLayoutListSingle:
       
   209             return StringLoader::LoadL ( R_DIAG_DATA_NETWORK_TEST_SINGLE );
       
   210 
       
   211         default:
       
   212             LOGSTRING2( "CDiagDataNetworkTestPlugin::GetPluginNameL: "
       
   213                 L"ERROR: Unsupported layout type %d", aLayoutType )
       
   214             __ASSERT_DEBUG( 0, User::Invariant() );
       
   215             return StringLoader::LoadL ( R_DIAG_DATA_NETWORK_TEST_SINGLE );
       
   216         }
       
   217     }
       
   218 
       
   219 
       
   220 // ---------------------------------------------------------------------------
       
   221 // From MDiagPlugin
       
   222 // CDiagDataNetworkTestPlugin::Uid
       
   223 // ---------------------------------------------------------------------------
       
   224 TUid CDiagDataNetworkTestPlugin::Uid() const
       
   225     {
       
   226     return KDiagDataNetworkTestPluginUid;
       
   227     }
       
   228     
       
   229    
       
   230 // ---------------------------------------------------------------------------
       
   231 // From CActive
       
   232 // CDiagDataNetworkTestPlugin::RunL
       
   233 // ---------------------------------------------------------------------------
       
   234 void CDiagDataNetworkTestPlugin::RunL()
       
   235     {
       
   236     // nothing to implement here
       
   237     }    
       
   238 
       
   239 // ---------------------------------------------------------------------------
       
   240 // From CActive
       
   241 // CDiagDataNetworkTestPlugin::DoCancel
       
   242 // ---------------------------------------------------------------------------
       
   243 void CDiagDataNetworkTestPlugin::DoCancel()
       
   244     {
       
   245     // nothing to implement here   
       
   246     }
       
   247 
       
   248 // ---------------------------------------------------------------------------
       
   249 // From CDiagTestPluginBase
       
   250 // CDiagDataNetworkTestPlugin::DoRunTestL()
       
   251 // ---------------------------------------------------------------------------
       
   252 void CDiagDataNetworkTestPlugin::DoRunTestL()
       
   253     {
       
   254     ASSERT( iPDPEngine == NULL );
       
   255 
       
   256     delete iPDPEngine;
       
   257     iPDPEngine = NULL;
       
   258     
       
   259      // ADO & Platformization Changes
       
   260      
       
   261     if(!(ExecutionParam().Engine().ExecutionPlanL().CurrentExecutionItem().AsDependency()))
       
   262     {
       
   263      
       
   264     TInt aButtonId;
       
   265     
       
   266     ShowMessageQueryL(R_DIAG_MESSAGEQUERY_TITLE_DATANETWORK,aButtonId);
       
   267       
       
   268     if(aButtonId == EDataNetworkTestCancel)
       
   269     	{
       
   270     	CompleteTestL( CDiagResultsDatabaseItem::ESkipped );
       
   271         return;
       
   272     	}
       
   273     
       
   274     if(aButtonId == EDataNetworkTestSkip)
       
   275     	{
       
   276 		TInt confirmResult = 0;
       
   277             
       
   278         CAknDialog* dlg = ExecutionParam().Engine().
       
   279         CreateCommonDialogLC( EDiagCommonDialogConfirmSkipAll, NULL );
       
   280     
       
   281         if ( !RunWaitingDialogL( dlg, confirmResult ) )
       
   282             {
       
   283             return;
       
   284             }
       
   285         
       
   286         if (confirmResult)
       
   287             {
       
   288             return;
       
   289             }
       
   290     	}
       
   291     	
       
   292     	}
       
   293     // Changes Ends
       
   294     iPDPEngine = CDiagDataNetworkTestPDPEngine::NewL(*this);
       
   295        
       
   296     // Run the Data Network Test
       
   297     iPDPEngine->RunDataNetworkTestL();
       
   298     }
       
   299     
       
   300 
       
   301 TBool CDiagDataNetworkTestPlugin::DisplayDialog(TInt& aUserResponse)
       
   302 {
       
   303 
       
   304 	// set softkey for single execution
       
   305 	if ( !SinglePluginExecution() )
       
   306 	{
       
   307 		// Create common dialog by invoking Engine
       
   308 		CAknDialog* dlg = ExecutionParam().Engine().
       
   309 		CreateCommonDialogLC( EDiagCommonDialogConfirmCancelAll, NULL );
       
   310 
       
   311 		return RunWaitingDialogL( dlg, aUserResponse );
       
   312 	}	
       
   313 	else 
       
   314 	{
       
   315 		//CompleteTestL( CDiagResultsDatabaseItem::ECancelled );	 //commented for NTEI-7EZ96S
       
   316 		return EFalse;
       
   317 	}
       
   318 
       
   319 }
       
   320 // ---------------------------------------------------------------------------
       
   321 // CDiagDataNetworkTestPlugin::ReportTestResultL()
       
   322 // ---------------------------------------------------------------------------    
       
   323 void CDiagDataNetworkTestPlugin::ReportTestResultL( CDiagResultsDatabaseItem::TResult aResult )
       
   324     {
       
   325     // before returning the test result to the Diagnostics interface,
       
   326     // delete the engine
       
   327     delete iPDPEngine;
       
   328     iPDPEngine = NULL;        
       
   329                    
       
   330     CompleteTestL( aResult );
       
   331     }
       
   332     
       
   333 // ---------------------------------------------------------------------------
       
   334 // CDiagDataNetworkTestPlugin::ReportTestProgL()
       
   335 // ---------------------------------------------------------------------------      
       
   336 void CDiagDataNetworkTestPlugin::ReportTestProgL(TInt aStep)
       
   337     {
       
   338     ReportTestProgressL( aStep );
       
   339     }
       
   340     // ADO & Platformization Changes
       
   341 TBool CDiagDataNetworkTestPlugin::ShowMessageQueryL( TInt aResourceId, TInt &aButtonId  )
       
   342     {
       
   343     LOGSTRING( "CDiagAudioPlugin::ShowMessageQueryL IN" )
       
   344     CAknMessageQueryDialog* dlg    = NULL;
       
   345     TBool                   result = EFalse;
       
   346 
       
   347     // Create CAknMessageQueryDialog instance
       
   348     dlg = new ( ELeave ) CAknMessageQueryDialog();
       
   349 
       
   350     dlg->PrepareLC( aResourceId );
       
   351      
       
   352     CEikButtonGroupContainer& cba = dlg->ButtonGroupContainer();
       
   353 
       
   354         switch ( aResourceId )
       
   355             {
       
   356             case R_DIAG_MESSAGEQUERY_TITLE_DATANETWORK: 
       
   357          	   {
       
   358             	if ( SinglePluginExecution() )
       
   359         			{
       
   360         			cba.SetCommandSetL( R_CBA_DATANETWORK_SINGLE_EXECUTION );		
       
   361         			}
       
   362         	   else 
       
   363         	   		{	
       
   364                 	cba.SetCommandSetL( R_CBA_DATANETWORK_GROUP_EXECUTION );		
       
   365                 	}
       
   366         		}
       
   367                 break;
       
   368 
       
   369             default:
       
   370                 break;
       
   371             }
       
   372         	
       
   373     result = RunWaitingDialogL( dlg, aButtonId );
       
   374 
       
   375     LOGSTRING3( "CDiagAudioPlugin::ShowMessageQueryL() OUT aButtonId=%d result=%d", aButtonId, result );
       
   376     return result;
       
   377     }
       
   378 
       
   379 // End of File
       
   380