devicediagnosticsfw/diagpluginbase/src/diagpluginwaitingdialogwrapper.cpp
branchRCL_3
changeset 61 b183ec05bd8c
parent 59 13d7c31c74e0
child 62 19bba8228ff0
equal deleted inserted replaced
59:13d7c31c74e0 61:b183ec05bd8c
     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:  Class definition of CDiagPluginWaitingDialogWrapper
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // CLASS DECLARATION
       
    20 #include "diagpluginwaitingdialogwrapper.h"
       
    21 
       
    22 // SYSTEM INCLUDE FILES
       
    23 #include <AknDialog.h>                      // CAknDialog
       
    24 
       
    25 // USER INCLUDE FILES
       
    26 #include "diagpluginbase.pan"               // Panic Codes
       
    27 
       
    28 // LOCAL TYPES
       
    29 
       
    30 // ======== LOCAL FUNCTIONS ========
       
    31 
       
    32 // ======== MEMBER FUNCTIONS ========
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 // CDiagPluginWaitingDialogWrapper::NewL
       
    36 // ---------------------------------------------------------------------------
       
    37 //
       
    38 EXPORT_C CDiagPluginWaitingDialogWrapper* CDiagPluginWaitingDialogWrapper::NewL( 
       
    39         CAknDialog* aWaitingDialog )
       
    40     {
       
    41     CleanupStack::PushL( aWaitingDialog );
       
    42     CDiagPluginWaitingDialogWrapper* self = new ( ELeave ) 
       
    43         CDiagPluginWaitingDialogWrapper( aWaitingDialog );
       
    44     CleanupStack::Pop( aWaitingDialog );
       
    45 
       
    46     return self;
       
    47     }
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // CDiagPluginWaitingDialogWrapper::CDiagPluginWaitingDialogWrapper
       
    51 // ---------------------------------------------------------------------------
       
    52 //
       
    53 CDiagPluginWaitingDialogWrapper::CDiagPluginWaitingDialogWrapper( 
       
    54         CAknDialog* aWaitingDialog )
       
    55     :   iWaitingDialog( aWaitingDialog ),
       
    56         iIsObjectDeletedPtr( NULL )
       
    57     {
       
    58     // Dialog must not be NULL
       
    59     __ASSERT_ALWAYS( iWaitingDialog, Panic( EDiagPluginBasePanicBadArgument ) );
       
    60 
       
    61     // Coverity Change .....  Dialog must have EEikDialogFlagWait flag set
       
    62     __ASSERT_ALWAYS( (iWaitingDialog->DialogFlags() & EEikDialogFlagWait),
       
    63                      Panic( EDiagPluginBasePanicBadArgument ) );
       
    64     }
       
    65 
       
    66 // ---------------------------------------------------------------------------
       
    67 // CDiagPluginWaitingDialogWrapper::~CDiagPluginWaitingDialogWrapper
       
    68 // ---------------------------------------------------------------------------
       
    69 //
       
    70 EXPORT_C CDiagPluginWaitingDialogWrapper::~CDiagPluginWaitingDialogWrapper()
       
    71     {
       
    72     if( iIsObjectDeletedPtr )
       
    73         {
       
    74         // If this pointer is set, we are still in RunLD().
       
    75         __ASSERT_DEBUG( iWaitingDialog, Panic( EDiagPluginBasePanicInternal ) );
       
    76         
       
    77         *iIsObjectDeletedPtr = ETrue;
       
    78         iIsObjectDeletedPtr = NULL;
       
    79 
       
    80         delete iWaitingDialog;
       
    81         iWaitingDialog = NULL;
       
    82         }
       
    83     }
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // CDiagPluginWaitingDialogWrapper::RunLD
       
    87 // ---------------------------------------------------------------------------
       
    88 EXPORT_C TBool CDiagPluginWaitingDialogWrapper::RunLD( TInt& aDialogResponse )
       
    89     {
       
    90     // Make sure that this function is not called twice.
       
    91     __ASSERT_ALWAYS( iIsObjectDeletedPtr == NULL,
       
    92         Panic( EDiagPluginBasePanicInvalidState ) );
       
    93 
       
    94     TBool isObjectDeleted = EFalse;
       
    95     
       
    96     iIsObjectDeletedPtr = &isObjectDeleted;
       
    97 
       
    98     aDialogResponse = iWaitingDialog->RunLD();
       
    99     // Do not access local variable until isObjectDeleted
       
   100     // value is checked first. "this" pointer may be invalid at this pointer.
       
   101 
       
   102     if ( isObjectDeleted )
       
   103         {
       
   104         // this class is already deleted. Exit immediately.
       
   105         return EFalse;
       
   106         }
       
   107     else
       
   108         {
       
   109         // iWaitingDialog->RunLD() returned with user response.
       
   110         iIsObjectDeletedPtr = NULL;
       
   111         iWaitingDialog = NULL;
       
   112 
       
   113         // Self-destruct as it is a "D" function.
       
   114         delete this;
       
   115         return ETrue;
       
   116         }
       
   117     }
       
   118 
       
   119 // End of File
       
   120