idlehomescreen/widgetmanager/src/wmwidgetloaderao.cpp
branchRCL_3
changeset 54 1b758917cafc
parent 16 9674c1a575e9
child 59 d721605b30d0
equal deleted inserted replaced
50:137ebc85284b 54:1b758917cafc
    53 // ---------------------------------------------------------------------------
    53 // ---------------------------------------------------------------------------
    54 //
    54 //
    55 CWmWidgetLoaderAo::CWmWidgetLoaderAo(
    55 CWmWidgetLoaderAo::CWmWidgetLoaderAo(
    56         CWmPlugin& aWmPlugin,
    56         CWmPlugin& aWmPlugin,
    57         CWmListBox& aTargetList )
    57         CWmListBox& aTargetList )
    58     : CAsyncOneShot( EPriorityHigh )
    58     : CActive( EPriorityNormal )
    59     , iWmPlugin( aWmPlugin )
    59     , iWmPlugin( aWmPlugin )
    60     , iWidgetsList( aTargetList )
    60     , iWidgetsList( aTargetList )
    61     {
    61     {
    62     iWidgetRegistry = NULL;
    62     iWidgetRegistry = NULL;
    63     iWidgetOrder = NULL;
    63     iWidgetOrder = NULL;
    68 // CWmWidgetLoaderAo::ConstructL
    68 // CWmWidgetLoaderAo::ConstructL
    69 // ---------------------------------------------------------------------------
    69 // ---------------------------------------------------------------------------
    70 //
    70 //
    71 void CWmWidgetLoaderAo::ConstructL()
    71 void CWmWidgetLoaderAo::ConstructL()
    72     {
    72     {
       
    73     CActiveScheduler::Add( this );
    73     }
    74     }
    74 
    75 
    75 // ---------------------------------------------------------------------------
    76 // ---------------------------------------------------------------------------
    76 // CWmWidgetLoaderAo::~CWmWidgetLoaderAo
    77 // CWmWidgetLoaderAo::~CWmWidgetLoaderAo
    77 // ---------------------------------------------------------------------------
    78 // ---------------------------------------------------------------------------
    79 CWmWidgetLoaderAo::~CWmWidgetLoaderAo()
    80 CWmWidgetLoaderAo::~CWmWidgetLoaderAo()
    80     {
    81     {
    81     // cancel ongoing operation
    82     // cancel ongoing operation
    82     Cancel();
    83     Cancel();
    83 
    84 
    84     // cleanup run data
    85     // cleanup and close session
    85     Cleanup();
    86     Cleanup();
    86     
    87     CloseSession();
    87     }
    88     }
    88 
    89 
    89 // ---------------------------------------------------------------------------
    90 // ---------------------------------------------------------------------------
    90 // CWmWidgetLoaderAo::StartLoading
    91 // CWmWidgetLoaderAo::StartLoading
    91 // ---------------------------------------------------------------------------
    92 // ---------------------------------------------------------------------------
    92 //
    93 //
    93 void CWmWidgetLoaderAo::StartLoading()
    94 void CWmWidgetLoaderAo::StartLoading()
    94     {
    95     {
    95     if ( IsActive() )
    96     if ( IsActive() )
    96         {
    97         {
    97         // cancel ongoing process
    98         return; // already active                
    98         Cancel();
    99         }
    99         }
   100 
   100     Call();
   101     // call itself
       
   102     iStatus = KRequestPending;
       
   103     TRequestStatus *pS = (&iStatus);
       
   104     User::RequestComplete( pS, KErrNone );
       
   105     SetActive();
   101     }
   106     }
   102 
   107 
   103 // ---------------------------------------------------------------------------
   108 // ---------------------------------------------------------------------------
   104 // CWmWidgetLoaderAo::RunL
   109 // CWmWidgetLoaderAo::RunL
   105 // ---------------------------------------------------------------------------
   110 // ---------------------------------------------------------------------------
   106 //
   111 //
   107 void CWmWidgetLoaderAo::RunL()
   112 void CWmWidgetLoaderAo::RunL()
   108     {
   113     {
   109     DoLoadWidgetsL();
   114     DoLoadWidgetsL();
   110     Cleanup();
   115     Cleanup();
       
   116     CloseSession();
   111     }
   117     }
   112 
   118 
   113 // ---------------------------------------------------------------------------
   119 // ---------------------------------------------------------------------------
   114 // CWmWidgetLoaderAo::RunError
   120 // CWmWidgetLoaderAo::RunError
   115 // ---------------------------------------------------------------------------
   121 // ---------------------------------------------------------------------------
   116 //
   122 //
   117 TInt CWmWidgetLoaderAo::RunError( TInt /*aError*/ )
   123 TInt CWmWidgetLoaderAo::RunError( TInt /*aError*/ )
   118     {
   124     {
   119     Cleanup();
   125     Cleanup();
       
   126     CloseSession();
   120     return KErrNone;
   127     return KErrNone;
       
   128     }
       
   129 
       
   130 // ---------------------------------------------------------
       
   131 // CWmWidgetLoaderAo::DoCancel
       
   132 // ---------------------------------------------------------
       
   133 //
       
   134 void CWmWidgetLoaderAo::DoCancel()
       
   135     {
   121     }
   136     }
   122 
   137 
   123 // ---------------------------------------------------------
   138 // ---------------------------------------------------------
   124 // CWmWidgetLoaderAo::DoLoadWidgetsL
   139 // CWmWidgetLoaderAo::DoLoadWidgetsL
   125 // ---------------------------------------------------------
   140 // ---------------------------------------------------------
   278             }
   293             }
   279         }
   294         }
   280     }
   295     }
   281 
   296 
   282 // ---------------------------------------------------------
   297 // ---------------------------------------------------------
       
   298 // CWmWidgetLoaderAo::CloseSession
       
   299 // ---------------------------------------------------------
       
   300 //
       
   301 void CWmWidgetLoaderAo::CloseSession()
       
   302     {
       
   303     // disconnect widget registry
       
   304     if ( iWidgetRegistry )
       
   305         {
       
   306         iWidgetRegistry->Disconnect();
       
   307         iWidgetRegistry->Close();
       
   308         delete iWidgetRegistry;
       
   309         iWidgetRegistry = NULL;
       
   310         }
       
   311     }
       
   312 
       
   313 // ---------------------------------------------------------
   283 // CWmWidgetLoaderAo::AddWidgetDataL
   314 // CWmWidgetLoaderAo::AddWidgetDataL
   284 // ---------------------------------------------------------
   315 // ---------------------------------------------------------
   285 //
   316 //
   286 void CWmWidgetLoaderAo::AddWidgetDataL(
   317 void CWmWidgetLoaderAo::AddWidgetDataL(
   287         CHsContentInfo* aContentInfo, TInt& aCount )
   318         CHsContentInfo* aContentInfo, TInt& aCount )
   343 //
   374 //
   344 void CWmWidgetLoaderAo::Cleanup()
   375 void CWmWidgetLoaderAo::Cleanup()
   345     {
   376     {
   346     iLoading = EFalse;
   377     iLoading = EFalse;
   347     
   378     
   348     // disconnect widget registry
       
   349     if ( iWidgetRegistry )
       
   350         {
       
   351         iWidgetRegistry->Disconnect();
       
   352         iWidgetRegistry->Close();
       
   353         delete iWidgetRegistry;
       
   354         iWidgetRegistry = NULL;
       
   355         }
       
   356     
       
   357     // delete widget order and references to it
   379     // delete widget order and references to it
   358     for( TInt i=0; i<iWidgetsList.WidgetDataCount(); ++i )
   380     for( TInt i=0; i<iWidgetsList.WidgetDataCount(); ++i )
   359         {
   381         {
   360         iWidgetsList.WidgetData(i).SetPersistentWidgetOrder( NULL );
   382         iWidgetsList.WidgetData(i).SetPersistentWidgetOrder( NULL );
   361         }
   383         }