devicediagnostics/devdiagapp/src/devdiagcommoncanceldialogs.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 implementation of the common dialogs, which are
       
    15 *                used by both the Device Diagnostics Application and plugins.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // System Include Files
       
    21 #include <DiagFrameworkDebug.h>     // Debugging Macros
       
    22 #include <devdiagapp.rsg>        // Resource defintions
       
    23 
       
    24 // User Include Files
       
    25 #include "devdiagcommoncanceldialogs.h"        // CDevDiagCommonCancelDialogs
       
    26 #include "devdiagengine.h"            // CDevDiagEngine
       
    27 
       
    28 
       
    29 // ============================ MEMBER FUNCTIONS =============================
       
    30 
       
    31 // ---------------------------------------------------------------------------
       
    32 // Two-phased constructor.
       
    33 // ---------------------------------------------------------------------------
       
    34 //
       
    35 CDevDiagCommonCancelDialogs* CDevDiagCommonCancelDialogs::NewLC(
       
    36     CDevDiagEngine& aEngine,
       
    37     TBool aSuspendTestsOnExecute )
       
    38     {
       
    39     LOGSTRING2( "CDevDiagCommonCancelDialogs::NewLC( %d )",
       
    40                 aSuspendTestsOnExecute )
       
    41 
       
    42     CDevDiagCommonCancelDialogs* self =
       
    43         new ( ELeave ) CDevDiagCommonCancelDialogs( aEngine,
       
    44                                                  aSuspendTestsOnExecute );
       
    45     CleanupStack::PushL( self );
       
    46     self->ConstructL();
       
    47     return self;
       
    48     }
       
    49 
       
    50 // ---------------------------------------------------------------------------
       
    51 // From CAknQueryDialog.
       
    52 // Runs the dialog, and returns the ID of the button used to dismiss it.
       
    53 // ---------------------------------------------------------------------------
       
    54 //
       
    55 TInt CDevDiagCommonCancelDialogs::RunLD()
       
    56     {
       
    57     LOGSTRING( "CDevDiagCommonCancelDialogs::RunLD()" )
       
    58 
       
    59     // Tell the engine to suspend execution while we're asking the user if
       
    60     // they really want to cancel tests.
       
    61     if ( iSuspendTestsOnExecute )
       
    62         {
       
    63         iEngine.ExecutionStopL( CDevDiagEngine::EStopModeSuspend );
       
    64         }
       
    65 
       
    66     // Only stop the watchdog timer.
       
    67     else
       
    68         {
       
    69         iEngine.ExecutionStopL( CDevDiagEngine::EStopModeWatchdog );
       
    70         }
       
    71 
       
    72     // Ask the user if they really want to cancel all.  Note: We cannot cancel
       
    73     // or resume after this call, because it deletes the dialog, so that
       
    74     // handling is done in OkToExitL.
       
    75     return CAknListQueryDialog::RunLD();
       
    76     }
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // The default constructor.
       
    80 // ---------------------------------------------------------------------------
       
    81 //
       
    82 CDevDiagCommonCancelDialogs::CDevDiagCommonCancelDialogs(
       
    83     CDevDiagEngine& aEngine,
       
    84     TBool aSuspendTestsOnExecute )
       
    85 :   CAknListQueryDialog( &iIndex ),
       
    86     iEngine( aEngine ),
       
    87     iSuspendTestsOnExecute( aSuspendTestsOnExecute )
       
    88     {
       
    89     LOGSTRING( "CDevDiagCommonCancelDialogs::CDevDiagCommonCancelDialogs()" )
       
    90 
       
    91     // Nothing to do.
       
    92     }
       
    93 
       
    94 // ---------------------------------------------------------------------------
       
    95 // Two-phased constructor.
       
    96 // ---------------------------------------------------------------------------
       
    97 //
       
    98 void CDevDiagCommonCancelDialogs::ConstructL()
       
    99     {
       
   100     LOGSTRING( "CDevDiagCommonCancelDialogs::ConstructL()" )
       
   101 
       
   102     PrepareLC( R_DEVDIAG_CANCEL_LIST_QUERY );
       
   103     CleanupStack::Pop( this );
       
   104     }
       
   105 
       
   106 // ---------------------------------------------------------------------------
       
   107 // From CAknQueryDialog.
       
   108 // This function is called for a button press on the dialog.  It is used to
       
   109 // determine if the dialog may be exited.
       
   110 // ---------------------------------------------------------------------------
       
   111 //
       
   112 TBool CDevDiagCommonCancelDialogs::OkToExitL( TInt aButtonId )
       
   113     {
       
   114     LOGSTRING2( "CDevDiagCommonCancelDialogs::OkToExitL( %d )", aButtonId )
       
   115 
       
   116     //This must be called to update iIndex to right value.
       
   117     TBool exit = CAknListQueryDialog::OkToExitL ( aButtonId );
       
   118   
       
   119     if ( aButtonId == EAknSoftkeyOk )
       
   120         {
       
   121         if ( iIndex == 0 ) //cancel this test
       
   122             {                        
       
   123             iEngine.ExecutionStopL( CDevDiagEngine::EStopModeSkip );
       
   124             }
       
   125         else if ( iIndex == 1 ) //cancel rest of the test
       
   126             {
       
   127             // Cancel all execution, as the user requested.
       
   128             iEngine.ExecutionStopL( CDevDiagEngine::EStopModeCancel );
       
   129             }
       
   130         else
       
   131             {
       
   132             //Error
       
   133             }
       
   134         
       
   135         }
       
   136     else
       
   137         {
       
   138         // Resume execution because the user decided not to cancel.
       
   139         if ( iSuspendTestsOnExecute )
       
   140             {
       
   141             iEngine.ExecutionResumeL( CDevDiagEngine::EResumeModeResume );
       
   142             }
       
   143         // Restart the watchdog timer.
       
   144         else
       
   145             {
       
   146             iEngine.ExecutionResumeL( CDevDiagEngine::EResumeModeWatchdog );
       
   147             }
       
   148         }
       
   149 
       
   150     return ETrue;
       
   151     }
       
   152 
       
   153 // End of File