idlehomescreen/widgetmanager/src/wmwidgetloaderao.cpp
branchRCL_3
changeset 54 1b758917cafc
parent 16 9674c1a575e9
child 59 d721605b30d0
--- a/idlehomescreen/widgetmanager/src/wmwidgetloaderao.cpp	Tue May 25 12:29:32 2010 +0300
+++ b/idlehomescreen/widgetmanager/src/wmwidgetloaderao.cpp	Wed Jun 09 09:29:04 2010 +0300
@@ -55,7 +55,7 @@
 CWmWidgetLoaderAo::CWmWidgetLoaderAo(
         CWmPlugin& aWmPlugin,
         CWmListBox& aTargetList )
-    : CAsyncOneShot( EPriorityHigh )
+    : CActive( EPriorityNormal )
     , iWmPlugin( aWmPlugin )
     , iWidgetsList( aTargetList )
     {
@@ -70,6 +70,7 @@
 //
 void CWmWidgetLoaderAo::ConstructL()
     {
+    CActiveScheduler::Add( this );
     }
 
 // ---------------------------------------------------------------------------
@@ -81,9 +82,9 @@
     // cancel ongoing operation
     Cancel();
 
-    // cleanup run data
+    // cleanup and close session
     Cleanup();
-    
+    CloseSession();
     }
 
 // ---------------------------------------------------------------------------
@@ -94,10 +95,14 @@
     {
     if ( IsActive() )
         {
-        // cancel ongoing process
-        Cancel();
+        return; // already active                
         }
-    Call();
+
+    // call itself
+    iStatus = KRequestPending;
+    TRequestStatus *pS = (&iStatus);
+    User::RequestComplete( pS, KErrNone );
+    SetActive();
     }
 
 // ---------------------------------------------------------------------------
@@ -108,6 +113,7 @@
     {
     DoLoadWidgetsL();
     Cleanup();
+    CloseSession();
     }
 
 // ---------------------------------------------------------------------------
@@ -117,10 +123,19 @@
 TInt CWmWidgetLoaderAo::RunError( TInt /*aError*/ )
     {
     Cleanup();
+    CloseSession();
     return KErrNone;
     }
 
 // ---------------------------------------------------------
+// CWmWidgetLoaderAo::DoCancel
+// ---------------------------------------------------------
+//
+void CWmWidgetLoaderAo::DoCancel()
+    {
+    }
+
+// ---------------------------------------------------------
 // CWmWidgetLoaderAo::DoLoadWidgetsL
 // ---------------------------------------------------------
 //
@@ -280,6 +295,22 @@
     }
 
 // ---------------------------------------------------------
+// CWmWidgetLoaderAo::CloseSession
+// ---------------------------------------------------------
+//
+void CWmWidgetLoaderAo::CloseSession()
+    {
+    // disconnect widget registry
+    if ( iWidgetRegistry )
+        {
+        iWidgetRegistry->Disconnect();
+        iWidgetRegistry->Close();
+        delete iWidgetRegistry;
+        iWidgetRegistry = NULL;
+        }
+    }
+
+// ---------------------------------------------------------
 // CWmWidgetLoaderAo::AddWidgetDataL
 // ---------------------------------------------------------
 //
@@ -345,15 +376,6 @@
     {
     iLoading = EFalse;
     
-    // disconnect widget registry
-    if ( iWidgetRegistry )
-        {
-        iWidgetRegistry->Disconnect();
-        iWidgetRegistry->Close();
-        delete iWidgetRegistry;
-        iWidgetRegistry = NULL;
-        }
-    
     // delete widget order and references to it
     for( TInt i=0; i<iWidgetsList.WidgetDataCount(); ++i )
         {