photosgallery/viewframework/uiutilities/src/glxprogressindicator.cpp
branchRCL_3
changeset 17 a60acebbbd9d
parent 14 2dac0fdba72b
child 19 420f6808bf21
--- a/photosgallery/viewframework/uiutilities/src/glxprogressindicator.cpp	Tue Apr 27 16:37:53 2010 +0300
+++ b/photosgallery/viewframework/uiutilities/src/glxprogressindicator.cpp	Tue May 11 16:13:40 2010 +0300
@@ -76,13 +76,10 @@
         {
         iProgressbarTicker->Cancel();
         delete iProgressbarTicker;
-        }
-    if(iProgressDialog)
-        {
-        iProgressDialog->ProcessFinishedL();
+        iProgressbarTicker = NULL;
         }
 
-	// Stop force generation of thumbnails when progress dialog is dismissed
+    // Stop force generation of thumbnails when progress dialog is dismissed
     if (iUiUtility)
         {
         iUiUtility->StopTNMDaemon();
@@ -99,14 +96,13 @@
     TRACER("CGlxProgressIndicator::ConstructL()");
     iUiUtility->StartTNMDaemon();
 
-    if(!iProgressbarTicker)
+    if (!iProgressbarTicker)
         {
         iProgressbarTicker = CPeriodic::NewL(CActive::EPriorityStandard);
         }
 
     iFinalCount = iUiUtility->GetItemsLeftCount();
     GLX_LOG_INFO1("final count in viewactivate = %d",iFinalCount);
-
     }
 
 
@@ -117,7 +113,7 @@
 TInt CGlxProgressIndicator::PeriodicCallbackL(TAny* aPtr )
     {
     TRACER("CGlxProgressIndicator::PeriodicCallbackL");
-    static_cast< CGlxProgressIndicator* >( aPtr )->DisplayProgressBarL();
+    static_cast<CGlxProgressIndicator*> (aPtr)->DisplayProgressBarL();
     return KErrNone;
     }
 
@@ -131,13 +127,13 @@
     TInt itemsLeft = iUiUtility->GetItemsLeftCount();
     GLX_LOG_INFO1("itemsLeft in DisplayProgressBarL = %d",iFinalCount);
     UpdateProgressBar();
-    if(!itemsLeft)
+    if (!itemsLeft)
         {
-        if(iProgressbarTicker->IsActive())
+        if (iProgressbarTicker->IsActive())
             {
             iProgressbarTicker->Cancel();
             }
-        StartProgressNoteL(iFinalCount,EFalse);
+        StartProgressNoteL(iFinalCount, EFalse);
         }
     }
 
@@ -149,39 +145,38 @@
     {
     TRACER("CGlxProgressIndicator::StartProgressNoteL()");
     TInt itemsLeft = iUiUtility->GetItemsLeftCount();
-    if(aShow)
+    if (aShow)
         {
-        if(!iProgressDialog)
+        if (!iProgressDialog)
             {
             iProgressDialog = new (ELeave) CAknProgressDialog(
                     (reinterpret_cast<CEikDialog**> (&iProgressDialog)),
                     ETrue);
             }
         iProgressDialog->PrepareLC(R_PROGRESS_NOTE);
-        
+
         iProgressInfo = iProgressDialog->GetProgressInfoL();
-        
+
         iProgressDialog->SetCallback(this);
-        
-        HBufC* processingInfo = 
-                    StringLoader::LoadLC(R_GLX_MAIN_LIST_VIEW_PROCESSING_DIALOG);
+
+        HBufC* processingInfo = StringLoader::LoadLC(
+                R_GLX_MAIN_LIST_VIEW_PROCESSING_DIALOG);
         iProgressDialog->SetTextL(*processingInfo);
-        CleanupStack::PopAndDestroy(processingInfo );
+        CleanupStack::PopAndDestroy(processingInfo);
         iProgressInfo->SetFinalValue(aFinalValue);
-        iProgressInfo->SetAndDraw(iFinalCount-itemsLeft);
+        iProgressInfo->SetAndDraw(iFinalCount - itemsLeft);
         iProgressDialog->RunLD();
         }
     else
         {
         iProgressDialog->ProcessFinishedL();
         iGlxGridViewNotifyObserver.HandleDialogDismissedL();
-        if(iProgressDialog)
+        if (iProgressDialog)
             {
             iProgressDialog = NULL;
             iProgressInfo = NULL;
             }
         }
-     
     }
     
 // -----------------------------------------------------------------------------
@@ -189,9 +184,9 @@
 // -----------------------------------------------------------------------------
 //
 void CGlxProgressIndicator::UpdateProgressBar()
-    {   
+    {
     TRACER("CGlxProgressIndicator::UpdateProgressBar()");
-    if(iProgressInfo)
+    if (iProgressInfo)
         {
         /*
          * to show a number string in the progress bar use the below code
@@ -208,20 +203,17 @@
 // DialogDismissedL
 // -----------------------------------------------------------------------------
 //  
-void CGlxProgressIndicator::DialogDismissedL(TInt aButtonId)
+void CGlxProgressIndicator::DialogDismissedL(TInt /*aButtonId*/)
     {
     TRACER("CGlxProgressIndicator::DialogDismissedL()");
-    if(iProgressbarTicker)
+    if (iProgressbarTicker)
         {
         iProgressbarTicker->Cancel();
+        delete iProgressbarTicker;
         iProgressbarTicker = NULL;
         }
-
-    if(iProgressDialog)
-        {
-        iProgressDialog = NULL;
-        iProgressInfo = NULL;
-        }
+    iProgressDialog = NULL;
+    iProgressInfo = NULL;
     }
 
 // -----------------------------------------------------------------------------
@@ -283,3 +275,18 @@
         iUiUtility->StopTNMDaemon();
         }
     }
+
+// -----------------------------------------------------------------------------
+// DismissProgressDialog
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CGlxProgressIndicator::DismissProgressDialog()
+    {
+    TRACER("CGlxProgressIndicator::DismissProgressDialog");
+    
+    if(iProgressDialog)
+        {
+        TRAP_IGNORE(iProgressDialog->ProcessFinishedL());
+        }
+    }
+