widgets/widgetapp/src/WidgetUiWindowManager.cpp
branchRCL_3
changeset 84 800203832575
parent 71 4bd5176e1bc8
child 91 30342f40acbf
equal deleted inserted replaced
73:a1a5d4e727e8 84:800203832575
    66 const TInt KOOMNotificationDialogIntervalTimeOut = 60000000;
    66 const TInt KOOMNotificationDialogIntervalTimeOut = 60000000;
    67 const TInt KOOMNotificationDialogTimeOut = 2000000;
    67 const TInt KOOMNotificationDialogTimeOut = 2000000;
    68 const TInt KOOMHarvesterNotificationTimeOut = 5000000;
    68 const TInt KOOMHarvesterNotificationTimeOut = 5000000;
    69 const TInt KOOMWidgetCloseTimeOut = 15;//Do not close the widget that was started after OOM within 15 sec
    69 const TInt KOOMWidgetCloseTimeOut = 15;//Do not close the widget that was started after OOM within 15 sec
    70 
    70 
       
    71 #ifdef BRDO_OCC_ENABLED_FF
       
    72 const TInt KRetryConnectivityTimeout( 2*1000*1000 ); // 2 seconds
       
    73 #endif
       
    74 
    71 class CRequestRAM : public CActive
    75 class CRequestRAM : public CActive
    72     {
    76     {
    73 public: 
    77 public: 
    74 
    78 
    75     static CRequestRAM* StartLD(CWidgetUiWindowManager* aWidgetUiWindowManager, const TUid& aUid, TUint32 aOperation);
    79     static CRequestRAM* StartLD(CWidgetUiWindowManager* aWidgetUiWindowManager, const TUid& aUid, TUint32 aOperation);
   185 #ifdef BRDO_WRT_HS_FF    
   189 #ifdef BRDO_WRT_HS_FF    
   186     iCpsPublisher = CCpsPublisher::NewL();
   190     iCpsPublisher = CCpsPublisher::NewL();
   187     iCenrepNotifyHandler = CCenrepNotifyHandler::NewL( *this );
   191     iCenrepNotifyHandler = CCenrepNotifyHandler::NewL( *this );
   188     iNetworkListener = CWidgetUiNetworkListener::NewL( *this );
   192     iNetworkListener = CWidgetUiNetworkListener::NewL( *this );
   189 #endif
   193 #endif
       
   194     
       
   195 #ifdef BRDO_OCC_ENABLED_FF
       
   196     iConnStageNotifier = CConnectionStageNotifierWCB::NewL();
       
   197     iConnStageNotifier->SetPriority(CActive::EPriorityHigh);
       
   198     iRetryConnectivity = CPeriodic::NewL(CActive::EPriorityStandard);
       
   199 #endif
   190     }
   200     }
   191 
   201 
   192 // -----------------------------------------------------------------------------
   202 // -----------------------------------------------------------------------------
   193 // CWidgetUiWindowManager::NewL
   203 // CWidgetUiWindowManager::NewL
   194 // Two-phased constructor
   204 // Two-phased constructor
   244     delete iConnection;
   254     delete iConnection;
   245 #ifdef BRDO_WRT_HS_FF  
   255 #ifdef BRDO_WRT_HS_FF  
   246     delete iCpsPublisher;
   256     delete iCpsPublisher;
   247 #endif
   257 #endif
   248     delete iDb;
   258     delete iDb;
       
   259 #ifdef BRDO_OCC_ENABLED_FF 
       
   260     if ( iRetryConnectivity)
       
   261         {
       
   262         iRetryConnectivity->Cancel();
       
   263         delete iRetryConnectivity;
       
   264         iRetryConnectivity = NULL;
       
   265         }
       
   266 #endif
   249     }
   267     }
   250 
   268 
   251 // -----------------------------------------------------------------------------
   269 // -----------------------------------------------------------------------------
   252 // CWidgetUiWindowManager::DeactivateMiniViewL()
   270 // CWidgetUiWindowManager::DeactivateMiniViewL()
   253 // Stop MiniView. Stops publishing and exits widget
   271 // Stop MiniView. Stops publishing and exits widget
   393        case WidgetOffline:
   411        case WidgetOffline:
   394             {
   412             {
   395             iNetworkMode = EOfflineMode;
   413             iNetworkMode = EOfflineMode;
   396             CWidgetUiWindow* wdgt_window( GetWindow( aUid ) );
   414             CWidgetUiWindow* wdgt_window( GetWindow( aUid ) );
   397             if (wdgt_window)
   415             if (wdgt_window)
   398             	{
   416                 {
   399 #ifdef BRDO_WRT_HS_FF
   417 #ifdef BRDO_WRT_HS_FF
   400                 if ( wdgt_window->NetworkModeWait()->IsStarted() )
   418                  if ( wdgt_window->NetworkModeWait()->IsStarted() )
       
   419                      {
       
   420                      wdgt_window->NetworkModeWait()->AsyncStop();
       
   421                      }
       
   422 #endif
       
   423                  if ( iConnection->Connected())
       
   424                      {
       
   425                      for ( TInt i = 0; i < iWindowList.Count(); i++ )
       
   426                          {
       
   427                          CWidgetUiWindow* window = iWindowList[i];
       
   428                          if ( window && 
       
   429                      	       (window->WidgetMiniViewState() == EPublishStart ||
       
   430                      	       window->WidgetMiniViewState() == EPublishSuspend) 
       
   431                      	      )
       
   432                              //Send cancelFetch to all windows
       
   433                              TRAP_IGNORE( window->Engine()->HandleCommandL( 
       
   434                                 (TInt)TBrCtlDefs::ECommandIdBase +
       
   435                                 (TInt)TBrCtlDefs::ECommandCancelFetch ) );
       
   436                          }
       
   437                      TRAP_IGNORE( wdgt_window->Engine()->HandleCommandL( 
       
   438                         (TInt)TBrCtlDefs::ECommandIdBase +
       
   439                         (TInt)TBrCtlDefs::ECommandDisconnect ) );                     
       
   440                       }
       
   441                 // if no full view widgets open, then close the network connection
       
   442                 if ( !FullViewWidgetsOpen() && iConnection->Connected() )
   401                     {
   443                     {
   402                     wdgt_window->NetworkModeWait()->AsyncStop();
   444 
   403                     }
   445                      iConnection->StopConnectionL();
   404 #endif
       
   405                 // if no full view widgets open, then close the network connection
       
   406                 if ( ( !FullViewWidgetsOpen() ) && ( iConnection->Connected() ) )
       
   407                     {
       
   408                     TRAP_IGNORE( wdgt_window->Engine()->HandleCommandL( 
       
   409                             (TInt)TBrCtlDefs::ECommandIdBase +
       
   410                             (TInt)TBrCtlDefs::ECommandCancelFetch ) );
       
   411                     
       
   412                     wdgt_window->Engine()->HandleCommandL( 
       
   413                             (TInt)TBrCtlDefs::ECommandIdBase +
       
   414                             (TInt)TBrCtlDefs::ECommandDisconnect );
       
   415                     iConnection->CancelConnection();
       
   416                     iConnection->StopConnectionL();
       
   417 #ifdef BRDO_OCC_ENABLED_FF                    
   446 #ifdef BRDO_OCC_ENABLED_FF                    
   418                     for ( TInt i = 0; i < iWindowList.Count(); i++ )
   447                      StopConnectionObserving();
   419         				{
   448 #endif
   420         				CWidgetUiWindow* window = iWindowList[i];
   449                    }
   421         				//send to all windows
       
   422                     	window->StopConnectionObserving();
       
   423                     	}
       
   424 #endif                    	
       
   425                     }
       
   426                 if(wdgt_window->IsWidgetLoaded())
   450                 if(wdgt_window->IsWidgetLoaded())
   427                     wdgt_window->DetermineNetworkState();
   451                     wdgt_window->DetermineNetworkState();
   428                 else
   452                 else
   429                     wdgt_window->NeedToNotifyNetworkState(ETrue);
   453                     wdgt_window->NeedToNotifyNetworkState(ETrue);
   430                 }
   454                 }
   709             (TInt)TBrCtlDefs::ECommandCancelFetch ) );   
   733             (TInt)TBrCtlDefs::ECommandCancelFetch ) );   
   710     if ( lastOne )
   734     if ( lastOne )
   711         {
   735         {
   712         if(aWidgetWindow->CanBeDeleted())
   736         if(aWidgetWindow->CanBeDeleted())
   713             {
   737             {
   714             TRAP_IGNORE( aWidgetWindow->Engine()->HandleCommandL( 
       
   715                     (TInt)TBrCtlDefs::ECommandIdBase +
       
   716                     (TInt)TBrCtlDefs::ECommandDisconnect ) );
       
   717             iConnection->CancelConnection();
       
   718 #ifdef BRDO_OCC_ENABLED_FF            
   738 #ifdef BRDO_OCC_ENABLED_FF            
   719             aWidgetWindow->StopConnectionObserving();
   739             StopConnectionObserving();
   720 #endif
   740 #endif
   721             iConnection->StopConnectionL();
   741             iConnection->StopConnectionL();
   722             delete aWidgetWindow;
   742             delete aWidgetWindow;
   723             return ETrue;
   743             return ETrue;
   724             }
   744             }
   735                     count = ETrue;
   755                     count = ETrue;
   736                     break;
   756                     break;
   737                     }
   757                     }
   738                 }         
   758                 }         
   739             if(!count && iNetworkMode == EOfflineMode){
   759             if(!count && iNetworkMode == EOfflineMode){
   740                 aWidgetWindow->Engine()->HandleCommandL( 
       
   741                 (TInt)TBrCtlDefs::ECommandIdBase +
       
   742                                 (TInt)TBrCtlDefs::ECommandDisconnect );
       
   743 #ifdef BRDO_OCC_ENABLED_FF                                    
   760 #ifdef BRDO_OCC_ENABLED_FF                                    
   744                 aWidgetWindow->StopConnectionObserving();
   761                 StopConnectionObserving();
   745 #endif
   762 #endif
   746                 iConnection->StopConnectionL();
   763                 iConnection->StopConnectionL();
   747                 }             
   764                 }             
   748             delete aWidgetWindow;
   765             delete aWidgetWindow;
   749             }
   766             }
  1439            CWidgetUiWindow* window = iWindowList[i];   
  1456            CWidgetUiWindow* window = iWindowList[i];   
  1440            TRAP_IGNORE( window->Engine()->HandleCommandL( 
  1457            TRAP_IGNORE( window->Engine()->HandleCommandL( 
  1441                    (TInt)TBrCtlDefs::ECommandIdBase +
  1458                    (TInt)TBrCtlDefs::ECommandIdBase +
  1442                    (TInt)TBrCtlDefs::ECommandCancelFetch ) ); 
  1459                    (TInt)TBrCtlDefs::ECommandCancelFetch ) ); 
  1443            if(i == 0)
  1460            if(i == 0)
  1444                TRAP_IGNORE( window->Engine()->HandleCommandL( 
  1461            	    {
  1445                        (TInt)TBrCtlDefs::ECommandIdBase +
       
  1446                        (TInt)TBrCtlDefs::ECommandDisconnect ) );
       
  1447                        iConnection->CancelConnection();
       
  1448 #ifdef BRDO_OCC_ENABLED_FF                       
  1462 #ifdef BRDO_OCC_ENABLED_FF                       
  1449                        window->StopConnectionObserving();
  1463                 StopConnectionObserving();
  1450 #endif                       
  1464 #endif                       
  1451                        iConnection->StopConnectionL();
  1465                 iConnection->StopConnectionL();
       
  1466                 }
  1452            delete window;  
  1467            delete window;  
  1453            }  
  1468            }  
  1454    iWindowList.Reset();
  1469    iWindowList.Reset();
  1455    } 
  1470    } 
  1456 
  1471 
  1484 
  1499 
  1485 void CWidgetUiWindowManager::ExitNow()
  1500 void CWidgetUiWindowManager::ExitNow()
  1486     {
  1501     {
  1487     iAppUi.Exit();
  1502     iAppUi.Exit();
  1488     }
  1503     }
       
  1504 #ifdef BRDO_OCC_ENABLED_FF
       
  1505 // -----------------------------------------------------------------------------
       
  1506 // CWidgetUiWindowManager::ConnectionStageAchievedL()
       
  1507 // -----------------------------------------------------------------------------
       
  1508 //
       
  1509 void CWidgetUiWindowManager::ConnectionStageAchievedL()
       
  1510     {
       
  1511     iConnection->Disconnect();
       
  1512     
       
  1513     TNifProgressBuf buf = iConnStageNotifier->GetProgressBuffer();
       
  1514     CWidgetUiWindow* window( iWindowList[0] );
       
  1515     if( buf().iError == KErrDisconnected )
       
  1516         {
       
  1517         TRAP_IGNORE( window->Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandSetRetryConnectivityFlag + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  1518         SetRetryFlag(ETrue);    
       
  1519     
       
  1520         TRAP_IGNORE( window->Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandCancelQueuedTransactions + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  1521     
       
  1522         if( iRetryConnectivity && iRetryConnectivity->IsActive())
       
  1523             {
       
  1524             iRetryConnectivity->Cancel();
       
  1525             }
       
  1526         iRetryConnectivity->Start(KRetryConnectivityTimeout, 0,TCallBack(RetryConnectivity,this));
       
  1527         }
       
  1528     else
       
  1529         {
       
  1530         TRAP_IGNORE( window->Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandCancelFetch + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  1531         }
       
  1532     }  
       
  1533 
       
  1534 void CWidgetUiWindowManager::ConnNeededStatusL( TInt aErr )
       
  1535     {
       
  1536     StopConnectionObserving(); //Need to stop the connection observer first
       
  1537 
       
  1538 
       
  1539     if ( !iConnStageNotifier->IsActive() )
       
  1540         {
       
  1541         TName* connectionName = iConnection->ConnectionNameL();
       
  1542         CleanupStack::PushL( connectionName );
       
  1543 
       
  1544         iConnStageNotifier->StartNotificationL(connectionName, KLinkLayerClosed, this);
       
  1545 
       
  1546         CleanupStack::PopAndDestroy();  //connectionName
       
  1547         }
       
  1548     } 
       
  1549 void CWidgetUiWindowManager::StopConnectionObserving()
       
  1550     {
       
  1551     
       
  1552     if ( iConnStageNotifier )
       
  1553         {
       
  1554         iConnStageNotifier->Cancel();
       
  1555         }
       
  1556     } 
       
  1557 
       
  1558 // -----------------------------------------------------------------------------
       
  1559 // CWidgetUiWindow::SetRetryFlag
       
  1560 // -----------------------------------------------------------------------------
       
  1561 //
       
  1562 void CWidgetUiWindowManager::SetRetryFlag(TBool flag)
       
  1563      {
       
  1564      reConnectivityFlag = flag;
       
  1565      }
       
  1566 // -----------------------------------------------------------------------------
       
  1567 // CWidgetUiWindow::RetryConnectivity
       
  1568 // -----------------------------------------------------------------------------
       
  1569 //
       
  1570 TInt CWidgetUiWindowManager::RetryConnectivity(TAny* aWindowManager)
       
  1571     {
       
  1572 
       
  1573     TInt err = ((CWidgetUiWindowManager*)aWindowManager)->RetryInternetConnection();
       
  1574     return err;
       
  1575     }
       
  1576 TInt CWidgetUiWindowManager::RetryInternetConnection()
       
  1577     {
       
  1578     //First cancel the timer
       
  1579     if ( iRetryConnectivity && iRetryConnectivity->IsActive() )
       
  1580     {
       
  1581         iRetryConnectivity->Cancel();
       
  1582     }
       
  1583     TInt err = KErrNone;
       
  1584     if ( !iConnection->Connected() )
       
  1585        {
       
  1586        TRAP_IGNORE( err = iConnection->StartConnectionL( ETrue ) );
       
  1587        }
       
  1588     CWidgetUiWindow* window( iWindowList[0] );
       
  1589     if( err == KErrNone )
       
  1590        { 
       
  1591    
       
  1592        TRAP_IGNORE( window->Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandUnSetRetryConnectivityFlag + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  1593        SetRetryFlag(EFalse);
       
  1594        
       
  1595        TRAP_IGNORE(ConnNeededStatusL(err)); //Start the observer again
       
  1596        TRAP_IGNORE( window->Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandRetryTransactions + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  1597        }
       
  1598     else
       
  1599         {
       
  1600         TRAP_IGNORE( window->Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandUnSetRetryConnectivityFlag + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  1601         SetRetryFlag(EFalse);
       
  1602         TRAP_IGNORE(window->Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandClearQuedTransactions + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  1603         }
       
  1604     
       
  1605     return err;
       
  1606     }
       
  1607 // -----------------------------------------------------------------------------
       
  1608 // CWidgetUiWindowManager::GetRetryFlag
       
  1609 // -----------------------------------------------------------------------------
       
  1610 //
       
  1611  TBool CWidgetUiWindowManager::GetRetryFlag()
       
  1612       {
       
  1613       return reConnectivityFlag;
       
  1614       } 
       
  1615 #endif // BRDO_OCC_ENABLED_FF
  1489 
  1616 
  1490 CRequestRAM::CRequestRAM(CWidgetUiWindowManager* aWidgetUiWindowManager, const TUid& aUid, TUint32 aOperation):
  1617 CRequestRAM::CRequestRAM(CWidgetUiWindowManager* aWidgetUiWindowManager, const TUid& aUid, TUint32 aOperation):
  1491     CActive( EPriorityStandard ),
  1618     CActive( EPriorityStandard ),
  1492     iOperation(aOperation),
  1619     iOperation(aOperation),
  1493     iUid(aUid),
  1620     iUid(aUid),
  1574     {
  1701     {
  1575     iOomSession.CancelRequestFreeMemory();
  1702     iOomSession.CancelRequestFreeMemory();
  1576     }    
  1703     }    
  1577 void CWidgetUiWindowManager::CenrepChanged(TInt aHSModeOnline)
  1704 void CWidgetUiWindowManager::CenrepChanged(TInt aHSModeOnline)
  1578     {
  1705     {
  1579     for ( TInt i = 0; i < iWindowList.Count(); i++ )
  1706     if(iWindowList.Count())
  1580         {
  1707         {
  1581         CWidgetUiWindow* window = iWindowList[i];
  1708         CWidgetUiWindow* window = iWindowList[0];
  1582         if( window &&  window->WidgetMiniViewState() == EPublishSuspend )
  1709         if( window &&
  1583             {
  1710         	(window->WidgetMiniViewState() == EPublishStart ||
  1584             if ( window->NetworkModeWait()->IsStarted() )
  1711           window->WidgetMiniViewState() == EPublishSuspend) )
       
  1712             {
       
  1713             if ( window->NetworkModeWait()->IsStarted() &&  window->WidgetMiniViewState() == EPublishSuspend)
  1585                 {
  1714                 {
  1586                 window->NetworkModeWait()->AsyncStop();
  1715                 window->NetworkModeWait()->AsyncStop();
  1587                 }
  1716                 }
  1588 		        if(aHSModeOnline)
  1717 		        if(aHSModeOnline)
  1589 		            {
  1718 		            {
  1590 		  	        iNetworkMode = EOnlineMode;
  1719 		  	        iNetworkMode = EOnlineMode;
  1591 		            }
  1720 		            }
  1592 		        else
  1721 		        else
  1593 		  	        {
  1722 		  	        {
  1594 		  	        iNetworkMode = EOfflineMode;	
  1723 		  	        iNetworkMode = EOfflineMode;
  1595 		  	        if ( ( !FullViewWidgetsOpen() ) && ( iConnection->Connected() ) )
  1724 		  	        
  1596                     {
  1725 		  	        if ( iConnection->Connected() )
  1597                     TRAP_IGNORE( window->Engine()->HandleCommandL( 
  1726 		  	            {
  1598                                 (TInt)TBrCtlDefs::ECommandIdBase +
  1727                         for ( TInt i = 0; i < iWindowList.Count(); i++ )
  1599                                 (TInt)TBrCtlDefs::ECommandCancelFetch ) );
  1728                             {
  1600                     
  1729                             CWidgetUiWindow* wdg_window = iWindowList[i];
  1601                          window->Engine()->HandleCommandL( 
  1730                             //send CancelFetch to all windows
  1602                                 (TInt)TBrCtlDefs::ECommandIdBase +
  1731                             TRAP_IGNORE( window->Engine()->HandleCommandL( 
  1603                                 (TInt)TBrCtlDefs::ECommandDisconnect );
  1732                                     (TInt)TBrCtlDefs::ECommandIdBase +
  1604                     iConnection->CancelConnection();
  1733                                     (TInt)TBrCtlDefs::ECommandCancelFetch ) );
  1605 #ifdef BRDO_OCC_ENABLED_FF                    
  1734                             }                        
  1606 					window->StopConnectionObserving();
  1735                         TRAP_IGNORE( window->Engine()->HandleCommandL( 
  1607 #endif
  1736                                  (TInt)TBrCtlDefs::ECommandIdBase +
  1608                     iConnection->StopConnectionL();
  1737                                  (TInt)TBrCtlDefs::ECommandDisconnect ) );                        
       
  1738                         }
  1609                     }
  1739                     }
  1610 		  	        }
  1740             if(window->IsWidgetLoaded())
  1611 		  	    if(window->IsWidgetLoaded())
       
  1612                 window->DetermineNetworkState();
  1741                 window->DetermineNetworkState();
  1613             else
  1742             else
  1614                 window->NeedToNotifyNetworkState(ETrue);
  1743                 window->NeedToNotifyNetworkState(ETrue);
  1615         
  1744         
  1616             }
  1745             }
  1617         }
  1746         }
       
  1747       if ( ( !FullViewWidgetsOpen() ) && iConnection->Connected() && iNetworkMode == EOfflineMode)
       
  1748           {          
       
  1749 #ifdef BRDO_OCC_ENABLED_FF                    
       
  1750           StopConnectionObserving();
       
  1751 #endif
       
  1752           iConnection->StopConnectionL();
       
  1753           }
  1618   }        
  1754   }        
  1619 
  1755 
  1620 
  1756 
  1621 //cenrep notification handling
  1757 //cenrep notification handling
  1622 
  1758