pkiutilities/CertmanUi/SRC/Certmanuidialogs.cpp
changeset 1 d5423fbb4f29
parent 0 164170e6151a
child 8 ece4bbb094df
--- a/pkiutilities/CertmanUi/SRC/Certmanuidialogs.cpp	Tue Jan 26 15:20:08 2010 +0200
+++ b/pkiutilities/CertmanUi/SRC/Certmanuidialogs.cpp	Tue Feb 02 00:44:34 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2003-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -15,127 +15,98 @@
 *
 */
 
-
-// INCLUDE FILES
-
 #include <AknWaitDialog.h>
 #include <certmanui.rsg>
 #include "Certmanuidialogs.h"
 #include "CertManUILogger.h"
 #include "CertmanuiCommon.h"
 
-
 #ifdef _DEBUG
 _LIT( KDesCertmanUiFault, "CertmanUi" );
 #endif
 
+
 // ================= MEMBER FUNCTIONS =======================
 
 // ---------------------------------------------------------
 // CCertManUiDialog::CCertManUiDialogs()
-// Default c++ constructor
 // ---------------------------------------------------------
+//
 CCertManUIWaitDialog::CCertManUIWaitDialog()
     {
-    iDialog = NULL;
     }
 
 // ---------------------------------------------------------
 // CCertManUiDialog::~CCertManUiDialogs()
-// Destructor
 // ---------------------------------------------------------
+//
 CCertManUIWaitDialog::~CCertManUIWaitDialog()
     {
-    if ( iDialog )
+    if( iDialog )
         {
         delete iDialog;
+        iDialog = NULL;
         }
     }
 
 //---------------------------------------------------------------
-// CCertManUiDialog::StartWaitDialogL
-// Displays wait dialog
+// CCertManUiDialog::StartWaitDialogL()
 //---------------------------------------------------------------
+//
 void CCertManUIWaitDialog::StartWaitDialogL( TInt aDialogSelector )
     {
     CERTMANUILOGGER_ENTERFN( "CCertManUIWaitDialog::StartWaitDialogL" );
-    TInt dialog = 0;
 
-    // If iDisplayed flag is true, but iDialog is NULL we have had leave.
-    // Reset iDisplayed to normalize situation
-    if(iDisplayed && iDialog == NULL)
-        {
-        iDisplayed = EFalse;
-        }
-
-    if(!iDisplayed)
+    if( !iDialog )
         {
-        if( !iDialog )
-           {
-            iDialog = new ( ELeave )CAknWaitDialog( REINTERPRET_CAST(CEikDialog**,
-                &iDialog), ETrue );	
-           } 
+        iDialog = new( ELeave ) CAknWaitDialog( reinterpret_cast< CEikDialog** >( &iDialog ) );
 
-
-        //CleanupStack::PushL(TCleanupItem(CleanupWaitDialog, (TAny**)&iDialog));
-
-        switch(aDialogSelector)
+        TInt dialog = 0;
+        switch( aDialogSelector )
             {
             case ECertmanUiDeleteDialog:
-                LOG_WRITE("Show delete note");
+                LOG_WRITE( "Show delete note" );
                 dialog = R_CERTMANUI_DELETE_WAIT_NOTE;
                 break;
 
             case ECertmanUiWaitDialog:
-                LOG_WRITE("Show wait note");
+                LOG_WRITE( "Show wait note" );
                 dialog = R_CERTMANUI_WAIT_NOTE;
                 break;
+
             default:
-                __ASSERT_DEBUG( EFalse, User::Panic(KDesCertmanUiFault,
-                    EBadDialogSelector));
+                __ASSERT_DEBUG( EFalse, User::Panic( KDesCertmanUiFault, EBadDialogSelector ) );
                 break;
             }
 
-        iDialog->ExecuteLD(dialog);
-        iDisplayed = ETrue;
+        iDialog->ExecuteLD( dialog );
         }
 
+    ++iOpenCount;
+
     CERTMANUILOGGER_LEAVEFN( "CCertManUIWaitDialog::StartWaitDialogL" );
     }
 
 //---------------------------------------------------------------
 // CCertManUiDialog::CloseWaitDialogL
-// Close wait dialog
 //---------------------------------------------------------------
+//
 void CCertManUIWaitDialog::CloseWaitDialogL()
     {
     CERTMANUILOGGER_ENTERFN( "CCertManUIWaitDialog::CloseWaitDialogL" );
 
-    if( iDialog )
+    --iOpenCount;
+
+    if( iDialog && !iOpenCount )
         {
-        iDialog->ProcessFinishedL();
-        //CleanupStack::PopAndDestroy();
+        TRAPD( err, iDialog->ProcessFinishedL() );
+        if( !err )
+            {
+            delete iDialog;
+            iDialog = NULL;
+            }
         }
 
-    iDisplayed = EFalse;
     CERTMANUILOGGER_LEAVEFN( "CCertManUIWaitDialog::CloseWaitDialogL" );
     }
 
-// ---------------------------------------------------------
-// CCertManUIWaitDialog::CleanupWaitDialog
-//
-// ---------------------------------------------------------
-void CCertManUIWaitDialog::CleanupWaitDialog(TAny* aAny)
-    {
-    CERTMANUILOGGER_ENTERFN( "CCertManUIWaitDialog::CleanupWaitDialog" );
-
-    CAknWaitDialog** dialog = (CAknWaitDialog**) aAny;
-    if ( dialog && *dialog )
-        {
-        delete *dialog;
-        }
-    CERTMANUILOGGER_LEAVEFN( "CCertManUIWaitDialog::CleanupWaitDialog" );
-    }
-
-
-// End of file