appinstaller/AppMngr2/src/appmngr2appui.cpp
branchRCL_3
changeset 26 8b7f4e561641
parent 25 7333d7932ef7
--- a/appinstaller/AppMngr2/src/appmngr2appui.cpp	Tue Aug 31 15:21:33 2010 +0300
+++ b/appinstaller/AppMngr2/src/appmngr2appui.cpp	Wed Sep 01 12:22:02 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2008-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"
@@ -22,6 +22,8 @@
 #include "appmngr2installedview.h"      // CAppMngr2InstalledView
 #include "appmngr2packagesview.h"       // CAppMngr2PackagesView
 #include "appmngr2.hrh"                 // Command IDs
+#include "appmngr2exittimer.h"          // Exit Timer
+
 #include <appmngr2runtime.h>            // CAppMngr2Runtime
 #include <appmngr2driveutils.h>         // TAppMngr2DriveUtils
 #include <appmngr2debugutils.h>         // FLOG macros
@@ -30,6 +32,11 @@
 #include <featmgr.h>                    // FeatureManager
 #include <e32property.h>                // RProperty
 #include <hlplch.h>                     // HlpLauncher
+#include <StringLoader.h>               // StringLoader
+#include <appmngr2.rsg>                 // Resource IDs
+#include <AknGlobalNote.h>              // WaitNote
+#include <avkon.rsg>
+
 
 _LIT( KSWInstCommonUIResourceFileName, "SWInstCommonUI.rsc" );
 
@@ -49,16 +56,25 @@
     wsSession.ComputeMode( RWsSession::EPriorityControlDisabled );
 
     FeatureManager::InitializeLibL();
-    
+
     TFileName* fullName = TAppMngr2DriveUtils::NearestResourceFileLC(
             KSWInstCommonUIResourceFileName, iEikonEnv->FsSession() );
     FLOG( "CAppMngr2AppUi::ConstructL, opening %S", fullName );
     iResourceFileOffset = iEikonEnv->AddResourceFileL( *fullName );
     CleanupStack::PopAndDestroy( fullName );
 
+    // Let's start global wait note so user can see that 
+    // App. Mngr is scanning memory.
+    HBufC* string = StringLoader::LoadLC( R_QTN_AM_SCANNING_MEMORY );  
+    CAknGlobalNote* note = CAknGlobalNote::NewLC();
+    note->SetSoftkeys( R_AVKON_SOFTKEYS_EMPTY );    
+    FLOG( "CAppMngr2AppUi::ConstructL: ShowNoteL EAknGlobalWaitNote " );
+    iNoteId = note->ShowNoteL( EAknGlobalWaitNote, *string );
+    CleanupStack::PopAndDestroy( 2, string );
+                
     FLOG( "CAppMngr2AppUi::ConstructL, creting model" );
     iModel = CAppMngr2Model::NewL( iEikonEnv->FsSession(), *this );
-   
+
     FLOG( "CAppMngr2AppUi::ConstructL, creting views" );
     CAppMngr2InstalledView* installedView = CAppMngr2InstalledView::NewL();
     AddViewL( installedView );  // takes ownership
@@ -92,10 +108,13 @@
         {
         ActivateLocalViewL( KInstalledViewId );
         }
-    
+
     FLOG( "CAppMngr2AppUi::ConstructL, starting delayed construct" );
     iIdle = CIdle::NewL( CActive::EPriorityStandard );
     iIdle->Start( TCallBack( &CAppMngr2AppUi::DelayedConstructL, this ) );
+    
+    FLOG( "CAppMngr2AppUi::ConstructL, iExitTimer = NULL" );
+    iExitTimer = NULL;    
     }
 
 // ---------------------------------------------------------------------------
@@ -105,13 +124,23 @@
 CAppMngr2AppUi::~CAppMngr2AppUi()
     {
     FLOG( "CAppMngr2AppUi::~CAppMngr2AppUi" );
+    
+    if( iNoteId )
+        {
+        // If appmngr is closed for some reason let's make sure 
+        // the note is closed.
+        TRAP_IGNORE( CancelNoteL() );
+        }
+    
     delete iIdle;
     delete iModel;
+    
     if( iResourceFileOffset > 0 )
         {
         iEikonEnv->DeleteResourceFile( iResourceFileOffset );
         }
-    FeatureManager::UnInitializeLib();
+    FeatureManager::UnInitializeLib();    
+    delete iExitTimer;   
     }
 
 // ---------------------------------------------------------------------------
@@ -134,6 +163,9 @@
         {
         CAppMngr2ListView* view = static_cast<CAppMngr2ListView*>( iView );
         TRAP_IGNORE( view->RefreshL( aMoreRefreshesExpected ) );
+        
+        // Let's close global wait note since memory scanning is ready.      
+        TRAP_IGNORE( CancelNoteL() );
         }
     }
 
@@ -148,6 +180,9 @@
         {
         CAppMngr2ListView* view = static_cast<CAppMngr2ListView*>( iView );
         TRAP_IGNORE( view->RefreshL( aMoreRefreshesExpected ) );
+        
+        // Let's close global wait note since memory scanning is ready. 
+        TRAP_IGNORE( CancelNoteL() );
         }
     }
 
@@ -180,35 +215,20 @@
         CAppMngr2AppUi* self = static_cast<CAppMngr2AppUi*>( aSelf );
         FLOG( "CAppMngr2AppUi::DelayedConstructL, step %d",
                 self->iDelayedConstructionStep );
-        switch( self->iDelayedConstructionStep )
-            {
-            case EFirstStep:
-                if( self->iConstructInstallationFilesFirst )
-                    {
-                    self->iModel->StartFetchingInstallationFilesL();
-                    }
-                else
-                    {
-                    self->iModel->StartFetchingInstalledAppsL();
-                    }
-                self->iDelayedConstructionStep = ESecondStep;
-                return ETrue; // call DelayedConstruct again
 
-            case ESecondStep:
-                if( self->iConstructInstallationFilesFirst )
-                    {
-                    self->iModel->StartFetchingInstalledAppsL();
-                    }
-                else
-                    {
-                    self->iModel->StartFetchingInstallationFilesL();
-                    }
-                self->iDelayedConstructionStep = EAllDone;
-                break;
-                
-            default:
-                break;
+        // Only necessary part of the model is constructed. AppMngr2 runs
+        // as embedded application in Control panel. It is started either
+        // to display installed applications, or installation files.
+        if( self->iConstructInstallationFilesFirst )
+            {
+            self->iModel->StartFetchingInstallationFilesL();
             }
+        else
+            {
+            self->iModel->StartFetchingInstalledAppsL();
+            }
+
+        self->iDelayedConstructionStep = EAllDone;
         }
     return EFalse; // all done
     }
@@ -223,6 +243,28 @@
     switch ( aCommand )
         {
         case EEikCmdExit:
+            if ( iModel->IsUninstall() && iModel->IsActive() )
+                {
+                // In case we have uninstall process ongoing we need to
+                // start delay timer for Exit. This is because in some cases 
+                // like VPN plug-in the GS is closed and app.mngr exit may come 
+                // just when SWInstLauncer is completing req. in RunL (long 
+                // running task). CActive do not return from Cancel and 
+                // AppMngr2Model's destructor jams.                             
+                if ( !iExitTimer )
+                    {
+                    // If there is not exit timer already let's make one.                    
+                    iExitTimer = CAppMngr2ExitTimer::NewL( this );                       
+                    iExitTimer->StartExitTimer();                    
+                    } 
+                }
+            else
+                {
+                // if we do not have uninstall request let's do Exit now.
+                Exit();
+                }
+            break;
+            
         case EAknCmdExit:
         case EAknSoftkeyExit:
             Exit();
@@ -242,3 +284,20 @@
         }
     }
 
+// ---------------------------------------------------------------------------
+// CAppMngr2AppUi::CancelNoteL()
+// ---------------------------------------------------------------------------
+//
+void CAppMngr2AppUi::CancelNoteL()
+    {
+    FLOG( "CAppMngr2AppUi::CancelNoteL: iNoteId = %d", iNoteId );
+     if ( iNoteId )
+         {         
+         CAknGlobalNote* note = CAknGlobalNote::NewLC();
+         FLOG( "CAppMngr2AppUi::CancelNoteL: note->CancelNoteL" );
+         note->CancelNoteL( iNoteId );         
+         CleanupStack::PopAndDestroy();       
+         iNoteId = 0;
+         }        
+    }
+