widgets/widgetapp/src/WidgetUiWindowManager.cpp
changeset 26 cb62a4f66ebe
parent 25 0ed94ceaa377
child 27 6297cdf66332
equal deleted inserted replaced
25:0ed94ceaa377 26:cb62a4f66ebe
   200 //
   200 //
   201 // -----------------------------------------------------------------------------
   201 // -----------------------------------------------------------------------------
   202 //
   202 //
   203 CWidgetUiWindowManager::~CWidgetUiWindowManager()
   203 CWidgetUiWindowManager::~CWidgetUiWindowManager()
   204     {
   204     {
       
   205     if( iDialogsProvider)
       
   206         iDialogsProvider->CancelAll();
       
   207     iActiveFsWindow = NULL;
   205     iWindowList.ResetAndDestroy();
   208     iWindowList.ResetAndDestroy();
   206     
   209     
   207     delete iNetworkListener;
   210     delete iNetworkListener;
   208 
   211 
   209     // TODO Why there is a "Disconnect" method in the first place...
   212     // TODO Why there is a "Disconnect" method in the first place...
   349                 if ( wdgt_window->NetworkModeWait()->IsStarted() )
   352                 if ( wdgt_window->NetworkModeWait()->IsStarted() )
   350                     {
   353                     {
   351                     wdgt_window->NetworkModeWait()->AsyncStop();
   354                     wdgt_window->NetworkModeWait()->AsyncStop();
   352                     }
   355                     }
   353 #endif
   356 #endif
   354                 wdgt_window->DetermineNetworkState();
   357                 if(wdgt_window->IsWidgetLoaded())
       
   358                     wdgt_window->DetermineNetworkState();
       
   359                 else
       
   360                     wdgt_window->NeedToNotifyNetworkState(ETrue);
   355                 }
   361                 }
   356             }
   362             }
   357             break;
   363             break;
   358        case WidgetOffline:
   364        case WidgetOffline:
   359             {
   365             {
   368                     }
   374                     }
   369 #endif
   375 #endif
   370                 // if no full view widgets open, then close the network connection
   376                 // if no full view widgets open, then close the network connection
   371                 if ( ( !FullViewWidgetsOpen() ) && ( iConnection->Connected() ) )
   377                 if ( ( !FullViewWidgetsOpen() ) && ( iConnection->Connected() ) )
   372                     {
   378                     {
       
   379                     TRAP_IGNORE( wdgt_window->Engine()->HandleCommandL( 
       
   380                             (TInt)TBrCtlDefs::ECommandIdBase +
       
   381                             (TInt)TBrCtlDefs::ECommandCancelFetch ) );
       
   382                     
   373                     wdgt_window->Engine()->HandleCommandL( 
   383                     wdgt_window->Engine()->HandleCommandL( 
   374                             (TInt)TBrCtlDefs::ECommandIdBase +
   384                             (TInt)TBrCtlDefs::ECommandIdBase +
   375                             (TInt)TBrCtlDefs::ECommandDisconnect );
   385                             (TInt)TBrCtlDefs::ECommandDisconnect );
       
   386                     iConnection->CancelConnection();
   376                     iConnection->StopConnectionL();
   387                     iConnection->StopConnectionL();
   377                     }
   388                     }
   378                 wdgt_window->DetermineNetworkState();
   389                 if(wdgt_window->IsWidgetLoaded())
       
   390                     wdgt_window->DetermineNetworkState();
       
   391                 else
       
   392                     wdgt_window->NeedToNotifyNetworkState(ETrue);
   379                 }
   393                 }
   380             }
   394             }
   381             break;
   395             break; 
   382        case WidgetRestart:
       
   383            {
       
   384            OpenOrCreateWindowL( aUid, LaunchMiniview );
       
   385            ResumeWidgetL( aUid );
       
   386            }
       
   387            break;
       
   388         }
   396         }
   389     if(needToNotify)
   397     if(needToNotify)
   390     // Widget is up and running, notify that next one can be launched    
   398     // Widget is up and running, notify that next one can be launched    
   391     	NotifyCommandHandled();
   399     	NotifyCommandHandled();
   392     
   400     
   637     TRAP_IGNORE( aWidgetWindow->Engine()->HandleCommandL( 
   645     TRAP_IGNORE( aWidgetWindow->Engine()->HandleCommandL( 
   638             (TInt)TBrCtlDefs::ECommandIdBase +
   646             (TInt)TBrCtlDefs::ECommandIdBase +
   639             (TInt)TBrCtlDefs::ECommandCancelFetch ) );   
   647             (TInt)TBrCtlDefs::ECommandCancelFetch ) );   
   640     if ( lastOne )
   648     if ( lastOne )
   641         {
   649         {
   642         TRAP_IGNORE( aWidgetWindow->Engine()->HandleCommandL( 
   650         if(aWidgetWindow->CanBeDeleted())
   643                 (TInt)TBrCtlDefs::ECommandIdBase +
   651             {
   644                 (TInt)TBrCtlDefs::ECommandDisconnect ) );
   652             TRAP_IGNORE( aWidgetWindow->Engine()->HandleCommandL( 
   645 
   653                     (TInt)TBrCtlDefs::ECommandIdBase +
   646         delete aWidgetWindow;
   654                     (TInt)TBrCtlDefs::ECommandDisconnect ) );
   647         return ETrue;
   655             iConnection->CancelConnection(); 
       
   656             iConnection->StopConnectionL();
       
   657             delete aWidgetWindow;
       
   658             return ETrue;
       
   659             }
   648         }
   660         }
   649     else
   661     else
   650         {
   662         {
   651         delete aWidgetWindow;
   663         if(aWidgetWindow->CanBeDeleted())
       
   664             delete aWidgetWindow;
   652         }
   665         }
   653     return EFalse;
   666     return EFalse;
   654     }
   667     }
   655 
   668 
   656 // =============================================================================
   669 // =============================================================================
   746     // this way user is sent back to app shell or idle to run another widget
   759     // this way user is sent back to app shell or idle to run another widget
   747     iAppUi.SendAppToBackground();
   760     iAppUi.SendAppToBackground();
   748     if ( window == iActiveFsWindow )
   761     if ( window == iActiveFsWindow )
   749         {
   762         {
   750         //make the active window NULL and also CurrentWindow as False
   763         //make the active window NULL and also CurrentWindow as False
       
   764         iActiveFsWindow->SetCurrentWindow(EFalse);
   751         iActiveFsWindow->SetIsCurrentWindow(EFalse);
   765         iActiveFsWindow->SetIsCurrentWindow(EFalse);
   752         iActiveFsWindow = NULL;        
   766         iActiveFsWindow = NULL;        
   753         }        
   767         }        
   754 
   768 
   755     window->Engine()->MakeVisible( EFalse );
   769     window->Engine()->MakeVisible( EFalse );
   860         {
   874         {
   861         ShowWindow( iActiveFsWindow );
   875         ShowWindow( iActiveFsWindow );
   862         }
   876         }
   863     else
   877     else
   864         {
   878         {
       
   879         if(iDialogsProvider)
       
   880             iDialogsProvider->CancelAll();
   865         HideWindow( iActiveFsWindow );
   881         HideWindow( iActiveFsWindow );
   866         }
   882         }
   867     }
   883     }
   868 
   884 
   869 // -----------------------------------------------------------------------------
   885 // -----------------------------------------------------------------------------
  1306 void CWidgetUiWindowManager::CloseAllWidgets()  
  1322 void CWidgetUiWindowManager::CloseAllWidgets()  
  1307    {   
  1323    {   
  1308    TInt nWidgetsCount = iWindowList.Count();  
  1324    TInt nWidgetsCount = iWindowList.Count();  
  1309        for ( TInt i = (nWidgetsCount-1); i >= 0; i-- )  
  1325        for ( TInt i = (nWidgetsCount-1); i >= 0; i-- )  
  1310            {  
  1326            {  
  1311            CWidgetUiWindow* window = iWindowList[i];    
  1327            CWidgetUiWindow* window = iWindowList[i];   
       
  1328            TRAP_IGNORE( window->Engine()->HandleCommandL( 
       
  1329                    (TInt)TBrCtlDefs::ECommandIdBase +
       
  1330                    (TInt)TBrCtlDefs::ECommandCancelFetch ) ); 
       
  1331            if(i == 0)
       
  1332                TRAP_IGNORE( window->Engine()->HandleCommandL( 
       
  1333                        (TInt)TBrCtlDefs::ECommandIdBase +
       
  1334                        (TInt)TBrCtlDefs::ECommandDisconnect ) );
       
  1335                        iConnection->CancelConnection();
       
  1336                        iConnection->StopConnectionL();
  1312            delete window;  
  1337            delete window;  
  1313            }  
  1338            }  
  1314    iWindowList.Reset();
  1339    iWindowList.Reset();
  1315    } 
  1340    } 
  1316 
  1341 
  1337         CWidgetUiWindow* window( iWindowList[i] );
  1362         CWidgetUiWindow* window( iWindowList[i] );
  1338         if( window->WidgetMiniViewState() == EPublishStart )
  1363         if( window->WidgetMiniViewState() == EPublishStart )
  1339             return ETrue;
  1364             return ETrue;
  1340         }
  1365         }
  1341     return EFalse;
  1366     return EFalse;
       
  1367     }
       
  1368 
       
  1369 
       
  1370 void CWidgetUiWindowManager::ExitNow()
       
  1371     {
       
  1372     iAppUi.Exit();
  1342     }
  1373     }
  1343 
  1374 
  1344 CRequestRAM::CRequestRAM(CWidgetUiWindowManager* aWidgetUiWindowManager, const TUid& aUid, TUint32 aOperation):
  1375 CRequestRAM::CRequestRAM(CWidgetUiWindowManager* aWidgetUiWindowManager, const TUid& aUid, TUint32 aOperation):
  1345     CActive( EPriorityStandard ),
  1376     CActive( EPriorityStandard ),
  1346     iOperation(aOperation),
  1377     iOperation(aOperation),
  1378 void CRequestRAM::RunL()
  1409 void CRequestRAM::RunL()
  1379     {    
  1410     {    
  1380     if(iStatus >= 0)
  1411     if(iStatus >= 0)
  1381         {        
  1412         {        
  1382         iWidgetUiWindowManager->OpenOrCreateWindowL( iUid, LaunchMiniview );
  1413         iWidgetUiWindowManager->OpenOrCreateWindowL( iUid, LaunchMiniview );
       
  1414         iWidgetUiWindowManager->GetWindow(iUid)->NeedToNotifyNetworkState(ETrue);
  1383         iWidgetUiWindowManager->ResumeWidgetL( iUid );
  1415         iWidgetUiWindowManager->ResumeWidgetL( iUid );
  1384         iWidgetUiWindowManager->GetWindow(iUid)->SetTime();
  1416         iWidgetUiWindowManager->GetWindow(iUid)->SetTime();
  1385 #ifdef OOM_WIDGET_CLOSEALL        
  1417 #ifdef OOM_WIDGET_CLOSEALL        
  1386         iWidgetUiWindowManager->SetLastWidgetRestartTime( iWidgetUiWindowManager->GetWindow(iUid)->GetTime());
  1418         iWidgetUiWindowManager->SetLastWidgetRestartTime( iWidgetUiWindowManager->GetWindow(iUid)->GetTime());
  1387 #endif //OOM_WIDGET_CLOSEALL
  1419 #endif //OOM_WIDGET_CLOSEALL