widgets/widgetapp/src/WidgetUiWindowManager.cpp
branchRCL_3
changeset 48 79859ed3eea9
parent 47 e1bea15f9a39
child 49 919f36ff910f
equal deleted inserted replaced
47:e1bea15f9a39 48:79859ed3eea9
    23 #include "WidgetUiAppUi.h"
    23 #include "WidgetUiAppUi.h"
    24 #include "WidgetUiNetworkListener.h"
    24 #include "WidgetUiNetworkListener.h"
    25 #include "WidgetInstallerInternalCRKeys.h"
    25 #include "WidgetInstallerInternalCRKeys.h"
    26 #include "SWInstWidgetUid.h"
    26 #include "SWInstWidgetUid.h"
    27 #include "widgetappdefs.rh"
    27 #include "widgetappdefs.rh"
    28 #include "browser_platform_variant.hrh"
    28 #include "Browser_platform_variant.hrh"
    29 #include "WidgetUiPSNotifier.h"
       
    30 #ifdef BRDO_WRT_HS_FF
    29 #ifdef BRDO_WRT_HS_FF
    31 #include "cpspublisher.h"
    30 #include "cpspublisher.h"
    32 #endif
    31 #endif
    33 
    32 
    34 #include <WidgetUi.rsg>
    33 #include <WidgetUi.rsg>
    35 #include <brctlinterface.h>
    34 #include <brctlinterface.h>
    36 #include <widgetregistryconstants.h>
    35 #include <WidgetRegistryConstants.h>
    37 #include <centralrepository.h>
    36 #include <centralrepository.h>
    38 #include <StringLoader.h>
    37 #include <StringLoader.h>
    39 #include <AknNoteDialog.h>
    38 #include <aknnotedialog.h>
    40 #include <S32FILE.H>
    39 #include <BrowserDialogsProvider.h>
       
    40 #include <s32file.h>
    41 #include <aknnotewrappers.h>
    41 #include <aknnotewrappers.h>
    42 #include "cpglobals.h" // CPS string definitions.
    42 #include "cpglobals.h" // CPS string definitions.
    43 
    43 
    44 #include <internetconnectionmanager.h>
    44 #include <InternetConnectionManager.h>
    45 #include <ActiveApDb.h>
    45 #include <ActiveApDb.h>
    46 #include <oommonitorsession.h>
    46 #include <oommonitorsession.h>
    47 #include <aknglobalnote.h>
    47 #include <AknGlobalNote.h>
    48 
       
    49 #ifdef BRDO_MULTITOUCH_ENABLED_FF  
       
    50 #include<akntranseffect.h>
       
    51 #include<gfxtranseffect/GfxTransEffect.h>
       
    52 #endif
       
    53 
       
    54 #ifdef BRDO_OCC_ENABLED_FF
       
    55 #include <extendedconnpref.h>
       
    56 #endif
       
    57 
    48 
    58 // LOCAL FUNCTION PROTOTYPES
    49 // LOCAL FUNCTION PROTOTYPES
    59 TInt doDestructOOMNotifyTimer( TAny* ptr );
    50 TInt doDestructOOMNotifyTimer( TAny* ptr );
    60 TInt doNotifyHarvester( TAny* ptr );
    51 TInt doNotifyHarvester( TAny* ptr );
    61 
    52 
    66 const TInt KMemoryToCreateWidgetWindow = 10*1024*1024;
    57 const TInt KMemoryToCreateWidgetWindow = 10*1024*1024;
    67 const TInt KOOMNotificationDialogIntervalTimeOut = 60000000;
    58 const TInt KOOMNotificationDialogIntervalTimeOut = 60000000;
    68 const TInt KOOMNotificationDialogTimeOut = 2000000;
    59 const TInt KOOMNotificationDialogTimeOut = 2000000;
    69 const TInt KOOMHarvesterNotificationTimeOut = 5000000;
    60 const TInt KOOMHarvesterNotificationTimeOut = 5000000;
    70 const TInt KOOMWidgetCloseTimeOut = 15;//Do not close the widget that was started after OOM within 15 sec
    61 const TInt KOOMWidgetCloseTimeOut = 15;//Do not close the widget that was started after OOM within 15 sec
    71 
       
    72 #ifdef BRDO_OCC_ENABLED_FF
       
    73 const TInt KRetryConnectivityTimeout( 2*1000*1000 ); // 2 seconds
       
    74 #endif
       
    75 
    62 
    76 class CRequestRAM : public CActive
    63 class CRequestRAM : public CActive
    77     {
    64     {
    78 public: 
    65 public: 
    79 
    66 
   176             }
   163             }
   177         
   164         
   178         delete cenRep;
   165         delete cenRep;
   179         }
   166         }
   180         
   167         
       
   168     iDialogsProvider = CBrowserDialogsProvider::NewL( NULL );
   181     iHandler = CDocumentHandler::NewL(CEikonEnv::Static()->Process());
   169     iHandler = CDocumentHandler::NewL(CEikonEnv::Static()->Process());
   182 
   170 
   183     iDb = CActiveApDb::NewL( EDatabaseTypeIAP );
   171     iDb = CActiveApDb::NewL( EDatabaseTypeIAP );
   184     #ifdef BRDO_OCC_ENABLED_FF
       
   185     iConnection = CInternetConnectionManager::NewL( iDb->Database(), ETrue );
       
   186     #else
       
   187     iConnection = CInternetConnectionManager::NewL( iDb->Database(), EFalse );
   172     iConnection = CInternetConnectionManager::NewL( iDb->Database(), EFalse );
   188     #endif
       
   189     
       
   190 #ifdef BRDO_WRT_HS_FF    
   173 #ifdef BRDO_WRT_HS_FF    
   191     iCpsPublisher = CCpsPublisher::NewL();
   174     iCpsPublisher = CCpsPublisher::NewL();
   192     iCenrepNotifyHandler = CCenrepNotifyHandler::NewL( *this );
   175 #endif
       
   176     
   193     iNetworkListener = CWidgetUiNetworkListener::NewL( *this );
   177     iNetworkListener = CWidgetUiNetworkListener::NewL( *this );
   194 #endif
       
   195     
       
   196 #ifdef BRDO_OCC_ENABLED_FF
       
   197     iConnStageNotifier = CConnectionStageNotifierWCB::NewL();
       
   198     iConnStageNotifier->SetPriority(CActive::EPriorityHigh);
       
   199     iRetryConnectivity = CPeriodic::NewL(CActive::EPriorityStandard);
       
   200 #endif
       
   201     
       
   202         //Creating observer WidgetWindowsObeserver
       
   203     iWidgetNotifier = CWidgetUiPSNotifier::NewL(*this, EWidgetRegAltered);
       
   204     	
       
   205 #ifdef BRDO_SAPINTFN_ENABLED_FF
       
   206     iWidgetSapiNotifier = CWidgetUiPSNotifier::NewL(*this, ESapiPrompt);
       
   207     iWidgetSapiClearNotifier = CWidgetUiPSNotifier::NewL(*this, ESapiPromptCleared);
       
   208 #endif
       
   209     }
   178     }
   210 
   179 
   211 // -----------------------------------------------------------------------------
   180 // -----------------------------------------------------------------------------
   212 // CWidgetUiWindowManager::NewL
   181 // CWidgetUiWindowManager::NewL
   213 // Two-phased constructor
   182 // Two-phased constructor
   231 //
   200 //
   232 // -----------------------------------------------------------------------------
   201 // -----------------------------------------------------------------------------
   233 //
   202 //
   234 CWidgetUiWindowManager::~CWidgetUiWindowManager()
   203 CWidgetUiWindowManager::~CWidgetUiWindowManager()
   235     {
   204     {
   236 #ifdef BRDO_WRT_HS_FF 
   205     iWindowList.ResetAndDestroy();
   237     iCenrepNotifyHandler->DoCancel();
   206     
   238     delete iCenrepNotifyHandler;
       
   239 #endif
       
   240    
       
   241     iActiveFsWindow = NULL;
       
   242     
       
   243 #ifdef BRDO_OCC_ENABLED_FF 
       
   244     if ( iRetryConnectivity)
       
   245         {
       
   246         iRetryConnectivity->Cancel();
       
   247         delete iRetryConnectivity;
       
   248         iRetryConnectivity = NULL;
       
   249         }
       
   250 #endif
       
   251 	 
       
   252 	  iWindowList.ResetAndDestroy();
       
   253   
       
   254 #ifdef BRDO_WRT_HS_FF   
       
   255     delete iNetworkListener;
   207     delete iNetworkListener;
   256 #endif
       
   257 
   208 
   258     // TODO Why there is a "Disconnect" method in the first place...
   209     // TODO Why there is a "Disconnect" method in the first place...
   259     // RHandleBase::Close() should be enough?
   210     // RHandleBase::Close() should be enough?
   260     if ( iServerConnected )
   211     if ( iServerConnected )
   261         {
   212         {
   263         }
   214         }
   264         
   215         
   265     iClientSession.Close();
   216     iClientSession.Close();
   266     
   217     
   267     delete iHandler;
   218     delete iHandler;
       
   219     delete iDialogsProvider;
       
   220 
   268     if ( iConnection )
   221     if ( iConnection )
   269         {
   222         {
   270         TRAP_IGNORE( iConnection->StopConnectionL() );
   223         TRAP_IGNORE( iConnection->StopConnectionL() );
   271         }
   224         }
   272 
   225 
   273     delete iConnection;
   226     delete iConnection;
   274 #ifdef BRDO_WRT_HS_FF  
   227 #ifdef BRDO_WRT_HS_FF  
   275     delete iCpsPublisher;
   228     delete iCpsPublisher;
   276 #endif
   229 #endif
   277     delete iDb;
   230     delete iDb;
   278     delete iWidgetNotifier;
       
   279     
       
   280 #ifdef BRDO_SAPINTFN_ENABLED_FF
       
   281     delete iWidgetSapiNotifier;
       
   282     delete iWidgetSapiClearNotifier;
       
   283 #endif
       
   284     }
   231     }
   285 
   232 
   286 // -----------------------------------------------------------------------------
   233 // -----------------------------------------------------------------------------
   287 // CWidgetUiWindowManager::DeactivateMiniViewL()
   234 // CWidgetUiWindowManager::DeactivateMiniViewL()
   288 // Stop MiniView. Stops publishing and exits widget
   235 // Stop MiniView. Stops publishing and exits widget
   296     if(!wdgt_window)
   243     if(!wdgt_window)
   297         return EFalse;
   244         return EFalse;
   298     wdgt_window->SetWindowStateMiniViewL( EMiniViewEnabled );
   245     wdgt_window->SetWindowStateMiniViewL( EMiniViewEnabled );
   299 
   246 
   300     // TODO also other states are possible when we should react?
   247     // TODO also other states are possible when we should react?
   301     
   248 
   302     // Removing . Miniview, shall remove full view as well. For blanket permissions
   249     // Removing . Miniview, shall remove full view as well. For blanket permissions
   303     // will be revoked for miniview
   250     // will be revoked for miniview
   304 
   251 
   305  
   252     iClientSession.SetBlanketPermissionL( aUid, EBlanketUnknown );
   306     iClientSession.SetMiniViewL( aUid, EFalse );
   253     iClientSession.SetMiniViewL( aUid, EFalse );
   307 #ifdef BRDO_OCC_ENABLED_FF
       
   308     wdgt_window->CancelAllDialogs();
       
   309         
       
   310      if ( wdgt_window->IsDialogsLaunched() )
       
   311         {
       
   312         return EFalse;
       
   313         }
       
   314 #endif    
       
   315     return CloseWindow( wdgt_window );
   254     return CloseWindow( wdgt_window );
   316     }
   255     }
   317 
   256 
   318 // -----------------------------------------------------------------------------
   257 // -----------------------------------------------------------------------------
   319 // CWidgetUiWindowManager::ActivateMiniView()
   258 // CWidgetUiWindowManager::ActivateMiniView()
   387             break;
   326             break;
   388         case WidgetSelect:
   327         case WidgetSelect:
   389             {            	
   328             {            	
   390             // If we don't have window we know that WidgetUI has died
   329             // If we don't have window we know that WidgetUI has died
   391             // We must enable miniview state
   330             // We must enable miniview state
   392 #ifdef BRDO_MULTITOUCH_ENABLED_FF
       
   393             GfxTransEffect::BeginFullScreen(AknTransEffect::EApplicationStart,TRect(0,0,0,0),AknTransEffect::EParameterType,AknTransEffect::GfxTransParam(TUid::Uid(KWidgetAppUid)));
       
   394 #endif
       
   395             if( !GetWindow(aUid))
   331             if( !GetWindow(aUid))
   396                 {        
   332                 {        
   397                 needToNotify = EFalse;
   333                 needToNotify = EFalse;
   398                 CanWindowBeCreated( aUid, aOperation );
   334                 CanWindowBeCreated( aUid, aOperation );
   399                 break;
   335                 break;
   400                 }
   336                 }
   401             //WidgetLauncher modified to bring app to foreground
   337             //WidgetLauncher modified to bring app to foreground
   402             GetWindow( aUid)->IncrementClickCount();
   338             GetWindow( aUid)->IncrementClickCount();
   403             OpenOrCreateWindowL( aUid, LaunchFullscreen );            
   339             OpenOrCreateWindowL( aUid, LaunchFullscreen );            
   404 #ifdef BRDO_MULTITOUCH_ENABLED_FF            
       
   405             GfxTransEffect::EndFullScreen();
       
   406 #endif            
       
   407             }
   340             }
   408             break;
   341             break;
   409         case WidgetOnline:
   342         case WidgetOnline:
   410             {
   343             {
   411             iNetworkMode = EOnlineMode;
   344             iNetworkMode = EOnlineMode;
   412             CWidgetUiWindow* wdgt_window( GetWindow( aUid ) );
   345             CWidgetUiWindow* wdgt_window( GetWindow( aUid ) );
   413             if (wdgt_window)
   346 #ifdef BRDO_WRT_HS_FF
       
   347             if ( wdgt_window->NetworkModeWait()->IsStarted() )
   414                 {
   348                 {
   415 #ifdef BRDO_WRT_HS_FF
   349                 wdgt_window->NetworkModeWait()->AsyncStop();
   416                 if ( wdgt_window->NetworkModeWait()->IsStarted() )
   350                 }
   417                     {
       
   418                     wdgt_window->NetworkModeWait()->AsyncStop();
       
   419                     }
       
   420 #endif
   351 #endif
   421                 if(wdgt_window->IsWidgetLoaded())
   352             wdgt_window->DetermineNetworkState();
   422                     wdgt_window->DetermineNetworkState();
       
   423                 else
       
   424                     wdgt_window->NeedToNotifyNetworkState(ETrue);
       
   425                 }
       
   426             }
   353             }
   427             break;
   354             break;
   428        case WidgetOffline:
   355        case WidgetOffline:
   429             {
   356             {
   430             iNetworkMode = EOfflineMode;
   357             iNetworkMode = EOfflineMode;
   431             CWidgetUiWindow* wdgt_window( GetWindow( aUid ) );
   358             CWidgetUiWindow* wdgt_window( GetWindow( aUid ) );
   432             if (wdgt_window)
   359 #ifdef BRDO_WRT_HS_FF
       
   360             if ( wdgt_window->NetworkModeWait()->IsStarted() )
   433                 {
   361                 {
   434 #ifdef BRDO_WRT_HS_FF
   362                 wdgt_window->NetworkModeWait()->AsyncStop();
   435                  if ( wdgt_window->NetworkModeWait()->IsStarted() )
   363                 }
   436                      {
       
   437                      wdgt_window->NetworkModeWait()->AsyncStop();
       
   438                      }
       
   439 #endif
   364 #endif
   440                  if ( iConnection->Connected())
   365             // if no full view widgets open, then close the network connection
   441                      {
   366             if ( ( !FullViewWidgetsOpen() ) && ( iConnection->Connected() ) )
   442                      for ( TInt i = 0; i < iWindowList.Count(); i++ )
   367                 {
   443                          {
   368                 wdgt_window->Engine()->HandleCommandL( 
   444                          CWidgetUiWindow* window = iWindowList[i];
       
   445                          if ( window && 
       
   446                      	       (window->WidgetMiniViewState() == EPublishStart ||
       
   447                      	       window->WidgetMiniViewState() == EPublishSuspend) 
       
   448                      	      )
       
   449                              //Send cancelFetch to all windows
       
   450                              TRAP_IGNORE( window->Engine()->HandleCommandL( 
       
   451                                 (TInt)TBrCtlDefs::ECommandIdBase +
       
   452                                 (TInt)TBrCtlDefs::ECommandCancelFetch ) );
       
   453                          }
       
   454                      TRAP_IGNORE( wdgt_window->Engine()->HandleCommandL( 
       
   455                         (TInt)TBrCtlDefs::ECommandIdBase +
   369                         (TInt)TBrCtlDefs::ECommandIdBase +
   456                         (TInt)TBrCtlDefs::ECommandDisconnect ) );                     
   370                         (TInt)TBrCtlDefs::ECommandDisconnect );
   457                       }
   371                 iConnection->StopConnectionL();
   458                 // if no full view widgets open, then close the network connection
       
   459                 if ( !FullViewWidgetsOpen() && iConnection->Connected() )
       
   460                     {
       
   461 
       
   462                      iConnection->StopConnectionL();
       
   463 #ifdef BRDO_OCC_ENABLED_FF                    
       
   464                      StopConnectionObserving();
       
   465 #endif
       
   466                    }
       
   467                 if(wdgt_window->IsWidgetLoaded())
       
   468                     wdgt_window->DetermineNetworkState();
       
   469                 else
       
   470                     wdgt_window->NeedToNotifyNetworkState(ETrue);
       
   471                 }
   372                 }
   472             }
   373             wdgt_window->DetermineNetworkState();
   473             break; 
   374             }
   474         case WidgetFullViewClose:
   375             break;
   475         	{
   376        case WidgetRestart:
   476         	needToNotify = EFalse ;
   377            {
   477 #ifdef BRDO_OCC_ENABLED_FF 
   378            OpenOrCreateWindowL( aUid, LaunchMiniview );
   478         	CWidgetUiWindow* window( GetWindow( aUid ) );
   379            ResumeWidgetL( aUid );
   479             if( !window )
   380            }
   480                 return;
   381            break;
   481             else if ( window->IsDialogsLaunched() )
       
   482                 {
       
   483           	    iActiveFsWindow = window;
       
   484           	    // Bring app to foreground
       
   485           	    iAppUi.SendAppToForeground(); 
       
   486           	    if ( iActiveFsWindow->Engine()->Rect() != View()->ClientRect())
       
   487                     {
       
   488                     iActiveFsWindow->Engine()->SetRect( View()->ClientRect() );
       
   489                     }
       
   490                 iActiveFsWindow->SetCurrentWindow( ETrue ); 
       
   491           	   
       
   492                 }
       
   493             else if (window->getSapiPromptCleared())
       
   494                 {
       
   495                 Exit( EEikCmdExit, aUid );
       
   496                 }
       
   497                        
       
   498          	    
       
   499 #else
       
   500                 Exit( EEikCmdExit, aUid );
       
   501 #endif
       
   502         	}
       
   503         	break;
       
   504         }
   382         }
   505     if(needToNotify)
   383     if(needToNotify)
   506     // Widget is up and running, notify that next one can be launched    
   384     // Widget is up and running, notify that next one can be launched    
   507     	NotifyCommandHandled();
   385     	NotifyCommandHandled();
   508     
   386     
   726 // =============================================================================
   604 // =============================================================================
   727 //
   605 //
   728 TBool CWidgetUiWindowManager::RemoveFromWindowList( CWidgetUiWindow* aWidgetWindow )
   606 TBool CWidgetUiWindowManager::RemoveFromWindowList( CWidgetUiWindow* aWidgetWindow )
   729     {
   607     {
   730     __ASSERT_DEBUG( aWidgetWindow, User::Invariant() );
   608     __ASSERT_DEBUG( aWidgetWindow, User::Invariant() );
   731     TBool count(EFalse);
   609     if ( iDialogsProvider->IsDialogLaunched() )
   732   
   610         {
       
   611         return EFalse;
       
   612         }
       
   613 
   733     if ( iClientSession.IsWidgetInFullView ( aWidgetWindow->Uid()))
   614     if ( iClientSession.IsWidgetInFullView ( aWidgetWindow->Uid()))
   734         {
   615         {
   735 #ifdef BRDO_WRT_HS_FF
       
   736           iCpsPublisher->ClearScreenshotL(*(aWidgetWindow->WidgetBundleId()), aWidgetWindow->Uid().iUid);
       
   737 #endif
       
   738         HideWindow( aWidgetWindow );
   616         HideWindow( aWidgetWindow );
   739         if (aWidgetWindow == iActiveFsWindow)
   617         if (aWidgetWindow == iActiveFsWindow)
   740             iActiveFsWindow = NULL;
   618             iActiveFsWindow = NULL;
   741         // make widgets act like separate applications by pushing to background
   619         // make widgets act like separate applications by pushing to background
   742         // when widget is in fullview , this way user is sent back to app shell or idle 
   620         // when widget is in fullview , this way user is sent back to app shell or idle 
   753     TRAP_IGNORE( aWidgetWindow->Engine()->HandleCommandL( 
   631     TRAP_IGNORE( aWidgetWindow->Engine()->HandleCommandL( 
   754             (TInt)TBrCtlDefs::ECommandIdBase +
   632             (TInt)TBrCtlDefs::ECommandIdBase +
   755             (TInt)TBrCtlDefs::ECommandCancelFetch ) );   
   633             (TInt)TBrCtlDefs::ECommandCancelFetch ) );   
   756     if ( lastOne )
   634     if ( lastOne )
   757         {
   635         {
   758         if(aWidgetWindow->CanBeDeleted())
   636         TRAP_IGNORE( aWidgetWindow->Engine()->HandleCommandL( 
   759             {
   637                 (TInt)TBrCtlDefs::ECommandIdBase +
   760 #ifdef BRDO_OCC_ENABLED_FF            
   638                 (TInt)TBrCtlDefs::ECommandDisconnect ) );
   761             StopConnectionObserving();
   639 
   762 #endif
   640         delete aWidgetWindow;
   763             iConnection->StopConnectionL();
   641         return ETrue;
   764             delete aWidgetWindow;
       
   765             return ETrue;
       
   766             }
       
   767         }
   642         }
   768     else
   643     else
   769         {
   644         {
   770         if(aWidgetWindow->CanBeDeleted())
   645         delete aWidgetWindow;
   771             {
       
   772             for ( TInt i = 0; i < iWindowList.Count(); ++i )
       
   773                 {
       
   774                 CWidgetUiWindow* window( iWindowList[i] );
       
   775                 if(window->WidgetMiniViewState() == EMiniViewEnabled || window->WidgetMiniViewState() == EMiniViewNotEnabled)
       
   776                     {
       
   777                     count = ETrue;
       
   778                     break;
       
   779                     }
       
   780                 }         
       
   781             if(!count && iNetworkMode == EOfflineMode){
       
   782 #ifdef BRDO_OCC_ENABLED_FF                                    
       
   783                 StopConnectionObserving();
       
   784 #endif
       
   785                 iConnection->StopConnectionL();
       
   786                 }             
       
   787             if(!aWidgetWindow->Engine()->IsSynchRequestPending())
       
   788             	delete aWidgetWindow;
       
   789 			else
       
   790 				{
       
   791 				//Let sync request complete and then delete					
       
   792 				aWidgetWindow->DeleteItself();
       
   793 				}
       
   794             }
       
   795         }
   646         }
   796     return EFalse;
   647     return EFalse;
   797     }
   648     }
   798 
   649 
   799 // =============================================================================
   650 // =============================================================================
   882 void CWidgetUiWindowManager::SendWidgetToBackground( const TUid& aUid )
   733 void CWidgetUiWindowManager::SendWidgetToBackground( const TUid& aUid )
   883     {
   734     {
   884     CWidgetUiWindow* window( GetWindow( aUid ) );
   735     CWidgetUiWindow* window( GetWindow( aUid ) );
   885     if( !window )
   736     if( !window )
   886         return;
   737         return;
   887         
   738 
   888 #ifdef BRDO_WRT_HS_FF
       
   889           iCpsPublisher->ClearScreenshotL(*(GetWindow(aUid )->WidgetBundleId()), aUid.iUid);
       
   890 #endif
       
   891 #ifdef BRDO_MULTITOUCH_ENABLED_FF      
       
   892     GfxTransEffect::BeginFullScreen(AknTransEffect::EApplicationExit,TRect(0,0,0,0),AknTransEffect::EParameterType,AknTransEffect::GfxTransParam(TUid::Uid(KWidgetAppUid)));
       
   893 #endif    
       
   894     // make widgets act like separate applications by pushing to background
   739     // make widgets act like separate applications by pushing to background
   895     // this way user is sent back to app shell or idle to run another widget
   740     // this way user is sent back to app shell or idle to run another widget
   896     iAppUi.SendAppToBackground();
   741     iAppUi.SendAppToBackground();
   897     if ( window == iActiveFsWindow )
   742     if ( window == iActiveFsWindow )
   898         {
   743         {
   899         //make the active window NULL and also CurrentWindow as False
   744         //make the active window NULL and also CurrentWindow as False
   900         iActiveFsWindow->SetCurrentWindow(EFalse);
       
   901         iActiveFsWindow->SetIsCurrentWindow(EFalse);
   745         iActiveFsWindow->SetIsCurrentWindow(EFalse);
   902         iActiveFsWindow = NULL;        
   746         iActiveFsWindow = NULL;        
   903         }        
   747         }        
   904 
   748 
   905     window->Engine()->MakeVisible( EFalse );
   749     window->Engine()->MakeVisible( EFalse );
  1010         {
   854         {
  1011         ShowWindow( iActiveFsWindow );
   855         ShowWindow( iActiveFsWindow );
  1012         }
   856         }
  1013     else
   857     else
  1014         {
   858         {
  1015 #ifdef BRDO_OCC_ENABLED_FF
       
  1016         if(iActiveFsWindow)
       
  1017             iActiveFsWindow->CancelAllDialogs();
       
  1018 #endif    
       
  1019         
       
  1020 #ifdef BRDO_WRT_HS_FF  
       
  1021         CFbsBitmap* bitmap( new CFbsBitmap() );
       
  1022         if ( bitmap && iCpsPublisher)
       
  1023             {
       
  1024             if(iActiveFsWindow)
       
  1025                 {
       
  1026                 TRAP_IGNORE(iActiveFsWindow->Engine()->TakeSnapshotL( *bitmap ));
       
  1027                 TRAP_IGNORE(iCpsPublisher->PublishScreenshotL(*iActiveFsWindow->WidgetBundleId(),iActiveFsWindow->Uid().iUid, bitmap));
       
  1028                 }
       
  1029              }
       
  1030 #endif
       
  1031         HideWindow( iActiveFsWindow );
   859         HideWindow( iActiveFsWindow );
  1032         }
   860         }
  1033     }
   861     }
  1034 
   862 
  1035 // -----------------------------------------------------------------------------
   863 // -----------------------------------------------------------------------------
  1153 		
   981 		
  1154     if( (wdgt_window ->WidgetMiniViewState() == EMiniViewEnabled) ||
   982     if( (wdgt_window ->WidgetMiniViewState() == EMiniViewEnabled) ||
  1155         (wdgt_window->WidgetMiniViewState() == EPublishSuspend) )
   983         (wdgt_window->WidgetMiniViewState() == EPublishSuspend) )
  1156         {
   984         {
  1157         //Widgets on HS cannnot be active
   985         //Widgets on HS cannnot be active
  1158         if (iActiveFsWindow )
       
  1159             {
       
  1160             iActiveFsWindow->Engine()->MakeVisible( EFalse );
       
  1161             iActiveFsWindow->SetIsCurrentWindow( EFalse );
       
  1162             iActiveFsWindow->Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandAppBackground + (TInt)TBrCtlDefs::ECommandIdBase);
       
  1163             }
       
  1164         iActiveFsWindow = NULL;
   986         iActiveFsWindow = NULL;
  1165         // Publish should start only after widget is resumed.
   987         // Publish should start only after widget is resumed.
  1166         wdgt_window->SetWindowStateMiniViewL(EPublishStart);
   988         wdgt_window->SetWindowStateMiniViewL(EPublishStart);
  1167 
   989 
  1168         wdgt_window->Engine()->HandleCommandL( 
   990         wdgt_window->Engine()->HandleCommandL( 
  1172         wdgt_window->WidgetExtension()->HandleCommandL(
   994         wdgt_window->WidgetExtension()->HandleCommandL(
  1173             (TInt)TBrCtlDefs::ECommandAppForeground + 
   995             (TInt)TBrCtlDefs::ECommandAppForeground + 
  1174             (TInt)TBrCtlDefs::ECommandIdBase);
   996             (TInt)TBrCtlDefs::ECommandIdBase);
  1175 #ifdef BRDO_WRT_HS_FF 
   997 #ifdef BRDO_WRT_HS_FF 
  1176         wdgt_window->Engine()->MakeVisible( EFalse );
   998         wdgt_window->Engine()->MakeVisible( EFalse );
  1177         wdgt_window->SetIsCurrentWindow( EFalse );
       
  1178         wdgt_window->Engine()->SetRect( iCpsPublisher->BitmapSize());
   999         wdgt_window->Engine()->SetRect( iCpsPublisher->BitmapSize());
  1179         //When HS comes to foreground show the latest updatd content on HS.
       
  1180         //Relayout can sometimes happen only when widget in FullView.
       
  1181         wdgt_window->PublishSnapShot();
       
  1182 #endif
  1000 #endif
  1183         }
  1001         }
  1184     }
  1002     }
  1185 
  1003 
  1186 // -----------------------------------------------------------------------------
  1004 // -----------------------------------------------------------------------------
  1438 //
  1256 //
  1439 // In case of OOM closes all widgets. 
  1257 // In case of OOM closes all widgets. 
  1440 // ------------------------------------------------------------------------
  1258 // ------------------------------------------------------------------------
  1441 TBool  CWidgetUiWindowManager::CloseAllWidgetsUnderOOM()
  1259 TBool  CWidgetUiWindowManager::CloseAllWidgetsUnderOOM()
  1442     {
  1260     {
       
  1261     TInt temp(0);
  1443     TInt err(KErrNone);
  1262     TInt err(KErrNone);
  1444     CWidgetUiWindow* windowToBeClosed(NULL);
  1263     CWidgetUiWindow* windowToBeClosed(NULL);
  1445     TTime currentTime;
  1264     TTime currentTime;
  1446     currentTime.HomeTime();    
  1265     currentTime.HomeTime();    
  1447     TTimeIntervalSeconds  seconds;
  1266     TTimeIntervalSeconds  seconds;
  1448     TInt nCountWidgetClosed = 0;
  1267     TInt nCountWidgetClosed = 0;
  1449     TBool bAllWindowsClosed = ETrue;
  1268     TBool bAllWindowsClosed = ETrue;
  1450       
  1269       
  1451     TInt nWidgetsCount = iWindowList.Count();
  1270     TInt nWidgetsCount = iWindowList.Count();
  1452     if(nWidgetsCount > 0)
       
  1453         { 
       
  1454         CWidgetUiWindow* window = iWindowList[0];
       
  1455         TRAP_IGNORE( window->Engine()->HandleCommandL( 
       
  1456                     (TInt)TBrCtlDefs::ECommandIdBase +
       
  1457                     (TInt)TBrCtlDefs::ECommandOOMExit ) );
       
  1458         } 
       
  1459     for ( TInt i = (nWidgetsCount-1); i >= 0; i-- )
  1271     for ( TInt i = (nWidgetsCount-1); i >= 0; i-- )
  1460         {
  1272         {
  1461         CWidgetUiWindow* window = iWindowList[i];        
  1273         CWidgetUiWindow* window = iWindowList[i];        
  1462         err = currentTime.SecondsFrom(iTimeLastWidgetOpen,seconds);
  1274         err = currentTime.SecondsFrom(iTimeLastWidgetOpen,seconds);
  1463         if ( err == KErrOverflow || seconds.Int() > KOOMWidgetCloseTimeOut)
  1275         if ( err == KErrOverflow || seconds.Int() > KOOMWidgetCloseTimeOut)
  1485 void CWidgetUiWindowManager::CloseAllWidgets()  
  1297 void CWidgetUiWindowManager::CloseAllWidgets()  
  1486    {   
  1298    {   
  1487    TInt nWidgetsCount = iWindowList.Count();  
  1299    TInt nWidgetsCount = iWindowList.Count();  
  1488        for ( TInt i = (nWidgetsCount-1); i >= 0; i-- )  
  1300        for ( TInt i = (nWidgetsCount-1); i >= 0; i-- )  
  1489            {  
  1301            {  
  1490            CWidgetUiWindow* window = iWindowList[i];   
  1302            CWidgetUiWindow* window = iWindowList[i];    
  1491            TRAP_IGNORE( window->Engine()->HandleCommandL( 
       
  1492                    (TInt)TBrCtlDefs::ECommandIdBase +
       
  1493                    (TInt)TBrCtlDefs::ECommandCancelFetch ) ); 
       
  1494            if(i == 0)
       
  1495            	    {
       
  1496 #ifdef BRDO_OCC_ENABLED_FF                       
       
  1497                 StopConnectionObserving();
       
  1498 #endif                       
       
  1499                 iConnection->StopConnectionL();
       
  1500                 }
       
  1501            delete window;  
  1303            delete window;  
  1502            }  
  1304            }  
  1503    iWindowList.Reset();
  1305    iWindowList.Reset();
  1504    } 
  1306    } 
  1505 
  1307 
  1528             return ETrue;
  1330             return ETrue;
  1529         }
  1331         }
  1530     return EFalse;
  1332     return EFalse;
  1531     }
  1333     }
  1532 
  1334 
  1533 
       
  1534 void CWidgetUiWindowManager::ExitNow()
       
  1535     {
       
  1536     iAppUi.Exit();
       
  1537     }
       
  1538 #ifdef BRDO_OCC_ENABLED_FF
       
  1539 // -----------------------------------------------------------------------------
       
  1540 // CWidgetUiWindowManager::ConnectionStageAchievedL()
       
  1541 // -----------------------------------------------------------------------------
       
  1542 //
       
  1543 void CWidgetUiWindowManager::ConnectionStageAchievedL()
       
  1544     {
       
  1545     iConnection->Disconnect();
       
  1546     
       
  1547     TNifProgressBuf buf = iConnStageNotifier->GetProgressBuffer();
       
  1548     CWidgetUiWindow* window( iWindowList[0] );
       
  1549     if( buf().iError == KErrDisconnected )
       
  1550         {
       
  1551         TRAP_IGNORE( window->Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandSetRetryConnectivityFlag + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  1552         SetRetryFlag(ETrue);    
       
  1553     
       
  1554         TRAP_IGNORE( window->Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandCancelQueuedTransactions + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  1555     
       
  1556         if( iRetryConnectivity && iRetryConnectivity->IsActive())
       
  1557             {
       
  1558             iRetryConnectivity->Cancel();
       
  1559             }
       
  1560         iRetryConnectivity->Start(KRetryConnectivityTimeout, 0,TCallBack(RetryConnectivity,this));
       
  1561         }
       
  1562     else
       
  1563         {
       
  1564         TRAP_IGNORE( window->Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandCancelFetch + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  1565         }
       
  1566     }  
       
  1567 
       
  1568 void CWidgetUiWindowManager::ConnNeededStatusL( TInt aErr )
       
  1569     {
       
  1570     StopConnectionObserving(); //Need to stop the connection observer first
       
  1571 
       
  1572 
       
  1573     if ( !iConnStageNotifier->IsActive() )
       
  1574         {
       
  1575         TName* connectionName = iConnection->ConnectionNameL();
       
  1576         CleanupStack::PushL( connectionName );
       
  1577 
       
  1578         iConnStageNotifier->StartNotificationL(connectionName, KLinkLayerClosed, this);
       
  1579 
       
  1580         CleanupStack::PopAndDestroy();  //connectionName
       
  1581         }
       
  1582     } 
       
  1583 void CWidgetUiWindowManager::StopConnectionObserving()
       
  1584     {
       
  1585     
       
  1586     if ( iConnStageNotifier )
       
  1587         {
       
  1588         iConnStageNotifier->Cancel();
       
  1589         }
       
  1590     } 
       
  1591 
       
  1592 // -----------------------------------------------------------------------------
       
  1593 // CWidgetUiWindow::SetRetryFlag
       
  1594 // -----------------------------------------------------------------------------
       
  1595 //
       
  1596 void CWidgetUiWindowManager::SetRetryFlag(TBool flag)
       
  1597      {
       
  1598      reConnectivityFlag = flag;
       
  1599      }
       
  1600 // -----------------------------------------------------------------------------
       
  1601 // CWidgetUiWindow::RetryConnectivity
       
  1602 // -----------------------------------------------------------------------------
       
  1603 //
       
  1604 TInt CWidgetUiWindowManager::RetryConnectivity(TAny* aWindowManager)
       
  1605     {
       
  1606 
       
  1607     TInt err = ((CWidgetUiWindowManager*)aWindowManager)->RetryInternetConnection();
       
  1608     return err;
       
  1609     }
       
  1610 TInt CWidgetUiWindowManager::RetryInternetConnection()
       
  1611     {
       
  1612     //First cancel the timer
       
  1613     if ( iRetryConnectivity && iRetryConnectivity->IsActive() )
       
  1614     {
       
  1615         iRetryConnectivity->Cancel();
       
  1616     }
       
  1617     TInt err = KErrNone;
       
  1618     if ( !iConnection->Connected() )
       
  1619        {
       
  1620        TRAP_IGNORE( err = iConnection->StartConnectionL( ETrue ) );
       
  1621        }
       
  1622     
       
  1623     //Root cause needs to be identified..
       
  1624     //Fix for Array out of bound crash..
       
  1625     if(!iWindowList.Count())   
       
  1626     	return err;
       
  1627     	
       
  1628     CWidgetUiWindow* window( iWindowList[0] );
       
  1629     if( err == KErrNone )
       
  1630        { 
       
  1631    
       
  1632        TRAP_IGNORE( window->Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandUnSetRetryConnectivityFlag + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  1633        SetRetryFlag(EFalse);
       
  1634        
       
  1635        TRAP_IGNORE(ConnNeededStatusL(err)); //Start the observer again
       
  1636        TRAP_IGNORE( window->Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandRetryTransactions + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  1637        }
       
  1638     else
       
  1639         {
       
  1640         TRAP_IGNORE( window->Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandUnSetRetryConnectivityFlag + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  1641         SetRetryFlag(EFalse);
       
  1642         TRAP_IGNORE(window->Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandClearQuedTransactions + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  1643         }
       
  1644     
       
  1645     return err;
       
  1646     }
       
  1647 // -----------------------------------------------------------------------------
       
  1648 // CWidgetUiWindowManager::GetRetryFlag
       
  1649 // -----------------------------------------------------------------------------
       
  1650 //
       
  1651  TBool CWidgetUiWindowManager::GetRetryFlag()
       
  1652       {
       
  1653       return reConnectivityFlag;
       
  1654       } 
       
  1655 #endif // BRDO_OCC_ENABLED_FF
       
  1656 
       
  1657 CRequestRAM::CRequestRAM(CWidgetUiWindowManager* aWidgetUiWindowManager, const TUid& aUid, TUint32 aOperation):
  1335 CRequestRAM::CRequestRAM(CWidgetUiWindowManager* aWidgetUiWindowManager, const TUid& aUid, TUint32 aOperation):
  1658     CActive( EPriorityStandard ),
  1336     CActive( EPriorityStandard ),
  1659     iWidgetUiWindowManager(aWidgetUiWindowManager),
  1337     iOperation(aOperation),
  1660     iUid(aUid),
  1338     iUid(aUid),
  1661     iOperation(aOperation)
  1339     iWidgetUiWindowManager(aWidgetUiWindowManager)
  1662     {
  1340     {
  1663 	}
  1341 	}
  1664 	
  1342 	
  1665 CRequestRAM* CRequestRAM::StartLD(CWidgetUiWindowManager* aWidgetUiWindowManager, const TUid& aUid, TUint32 aOperation)
  1343 CRequestRAM* CRequestRAM::StartLD(CWidgetUiWindowManager* aWidgetUiWindowManager, const TUid& aUid, TUint32 aOperation)
  1666     {
  1344     {
  1673     
  1351     
  1674 void CRequestRAM::ConstructL()
  1352 void CRequestRAM::ConstructL()
  1675     {
  1353     {
  1676     User::LeaveIfError(iOomSession.Connect());
  1354     User::LeaveIfError(iOomSession.Connect());
  1677     CActiveScheduler::Add( this );
  1355     CActiveScheduler::Add( this );
  1678 #ifdef BRDO_OOM_MONITOR2_COMPONENT_FF
  1356 #ifdef FF_OOM_MONITOR2_COMPONENT
  1679     iOomSession.RequestOptionalRam(KMemoryToCreateWidgetWindow, KMemoryToCreateWidgetWindow, KUidWidgetOOMPlugin, iStatus);
  1357     iOomSession.RequestOptionalRam(KMemoryToCreateWidgetWindow, KMemoryToCreateWidgetWindow, KUidWidgetOOMPlugin, iStatus);
  1680     SetActive();
  1358     SetActive();
  1681 #else
  1359 #else
  1682     TMemoryInfoV1Buf  info;
  1360     TMemoryInfoV1Buf  info;
  1683     UserHal::MemoryInfo (info);                
  1361     UserHal::MemoryInfo (info);                
  1691 void CRequestRAM::RunL()
  1369 void CRequestRAM::RunL()
  1692     {    
  1370     {    
  1693     if(iStatus >= 0)
  1371     if(iStatus >= 0)
  1694         {        
  1372         {        
  1695         iWidgetUiWindowManager->OpenOrCreateWindowL( iUid, LaunchMiniview );
  1373         iWidgetUiWindowManager->OpenOrCreateWindowL( iUid, LaunchMiniview );
  1696         iWidgetUiWindowManager->GetWindow(iUid)->NeedToNotifyNetworkState(ETrue);
       
  1697         iWidgetUiWindowManager->ResumeWidgetL( iUid );
  1374         iWidgetUiWindowManager->ResumeWidgetL( iUid );
  1698         iWidgetUiWindowManager->GetWindow(iUid)->SetTime();
  1375         iWidgetUiWindowManager->GetWindow(iUid)->SetTime();
  1699 #ifdef OOM_WIDGET_CLOSEALL        
  1376 #ifdef OOM_WIDGET_CLOSEALL        
  1700         iWidgetUiWindowManager->SetLastWidgetRestartTime( iWidgetUiWindowManager->GetWindow(iUid)->GetTime());
  1377         iWidgetUiWindowManager->SetLastWidgetRestartTime( iWidgetUiWindowManager->GetWindow(iUid)->GetTime());
  1701 #endif //OOM_WIDGET_CLOSEALL
  1378 #endif //OOM_WIDGET_CLOSEALL
  1718         iWidgetUiWindowManager->StartHarvesterNotifyTimer();            
  1395         iWidgetUiWindowManager->StartHarvesterNotifyTimer();            
  1719         }
  1396         }
  1720     else
  1397     else
  1721         {
  1398         {
  1722         NotifyCommandHandled();
  1399         NotifyCommandHandled();
  1723         TBool lastOne( iWidgetUiWindowManager->WindowListCount() == 0 );
       
  1724         if( lastOne )
       
  1725             {
       
  1726             iWidgetUiWindowManager->AppUi().Exit();
       
  1727             }
       
  1728         iWidgetUiWindowManager->SendAppToBackground();  
  1400         iWidgetUiWindowManager->SendAppToBackground();  
  1729         iWidgetUiWindowManager->WidgetUIClientSession().SetActive( iUid, EFalse );
  1401         iWidgetUiWindowManager->WidgetUIClientSession().SetActive( iUid, EFalse );
  1730         }        
  1402         }        
  1731     delete this;    
  1403     delete this;    
  1732     }
  1404     }
  1739     }
  1411     }
  1740 void CRequestRAM::DoCancel()
  1412 void CRequestRAM::DoCancel()
  1741     {
  1413     {
  1742     iOomSession.CancelRequestFreeMemory();
  1414     iOomSession.CancelRequestFreeMemory();
  1743     }    
  1415     }    
  1744 void CWidgetUiWindowManager::CenrepChanged(TInt aHSModeOnline)
  1416 
  1745     {
       
  1746     if(iWindowList.Count())
       
  1747         {
       
  1748         CWidgetUiWindow* window = iWindowList[0];
       
  1749         if( window &&
       
  1750         	(window->WidgetMiniViewState() == EPublishStart ||
       
  1751           window->WidgetMiniViewState() == EPublishSuspend) )
       
  1752             {
       
  1753             if ( window->NetworkModeWait()->IsStarted() &&  window->WidgetMiniViewState() == EPublishSuspend)
       
  1754                 {
       
  1755                 window->NetworkModeWait()->AsyncStop();
       
  1756                 }
       
  1757 		        if(aHSModeOnline)
       
  1758 		            {
       
  1759 		  	        iNetworkMode = EOnlineMode;
       
  1760 		            }
       
  1761 		        else
       
  1762 		  	        {
       
  1763 		  	        iNetworkMode = EOfflineMode;
       
  1764 		  	        
       
  1765 		  	        if ( iConnection->Connected() )
       
  1766 		  	            {
       
  1767                         for ( TInt i = 0; i < iWindowList.Count(); i++ )
       
  1768                             {
       
  1769                             CWidgetUiWindow* wdg_window = iWindowList[i];
       
  1770                             //send CancelFetch to all windows
       
  1771                             TRAP_IGNORE( window->Engine()->HandleCommandL( 
       
  1772                                     (TInt)TBrCtlDefs::ECommandIdBase +
       
  1773                                     (TInt)TBrCtlDefs::ECommandCancelFetch ) );
       
  1774                             }                        
       
  1775                         TRAP_IGNORE( window->Engine()->HandleCommandL( 
       
  1776                                  (TInt)TBrCtlDefs::ECommandIdBase +
       
  1777                                  (TInt)TBrCtlDefs::ECommandDisconnect ) );                        
       
  1778                         }
       
  1779                     }
       
  1780             if(window->IsWidgetLoaded())
       
  1781                 window->DetermineNetworkState();
       
  1782             else
       
  1783                 window->NeedToNotifyNetworkState(ETrue);
       
  1784         
       
  1785             }
       
  1786         }
       
  1787       if ( ( !FullViewWidgetsOpen() ) && iConnection->Connected() && iNetworkMode == EOfflineMode)
       
  1788           {          
       
  1789 #ifdef BRDO_OCC_ENABLED_FF                    
       
  1790           StopConnectionObserving();
       
  1791 #endif
       
  1792           iConnection->StopConnectionL();
       
  1793           }
       
  1794   }        
       
  1795 
       
  1796 
       
  1797 //cenrep notification handling
       
  1798 
       
  1799 CCenrepNotifyHandler * CCenrepNotifyHandler::NewL(
       
  1800     MCenrepWatcher& aObserver)
       
  1801     {
       
  1802     CCenrepNotifyHandler* o =  CCenrepNotifyHandler::NewLC(aObserver);
       
  1803     CleanupStack:: Pop(o);
       
  1804     return o;
       
  1805     }
       
  1806 CCenrepNotifyHandler*  CCenrepNotifyHandler::NewLC(
       
  1807     MCenrepWatcher& aObserver) 
       
  1808     {
       
  1809     CCenrepNotifyHandler* self( new( ELeave ) CCenrepNotifyHandler( aObserver) );
       
  1810     CleanupStack:: PushL(self);
       
  1811     self->ConstructL();
       
  1812     return self;
       
  1813     }    
       
  1814 void CCenrepNotifyHandler::ConstructL()
       
  1815     {
       
  1816     iUid = TUid::Uid( KCRUidActiveIdleLV ); 
       
  1817     iKey = KAIWebStatus;
       
  1818     iRepository = CRepository::NewL( iUid );
       
  1819     CActiveScheduler::Add(this);
       
  1820     StartObservingL();
       
  1821     }
       
  1822          
       
  1823 CCenrepNotifyHandler::CCenrepNotifyHandler(MCenrepWatcher& aObserver) : CActive (EPriorityLow),iObserver(aObserver) 
       
  1824    {
       
  1825          
       
  1826    }
       
  1827      
       
  1828 CCenrepNotifyHandler::~CCenrepNotifyHandler()
       
  1829     {
       
  1830     Cancel(); //first cancel because iRepository is used there
       
  1831     delete iRepository;
       
  1832     iRepository=NULL;
       
  1833     }
       
  1834     
       
  1835 void CCenrepNotifyHandler::StartObservingL()
       
  1836     {
       
  1837     if( IsActive() )
       
  1838         {
       
  1839         return; //do nothing if allready observing
       
  1840         }
       
  1841     User::LeaveIfError(
       
  1842                    iRepository->NotifyRequest( iKey, iStatus ) );
       
  1843     SetActive();
       
  1844     }
       
  1845     
       
  1846 void CCenrepNotifyHandler::StopObserving()
       
  1847     {
       
  1848     Cancel();
       
  1849     }
       
  1850     
       
  1851 void CCenrepNotifyHandler::DoCancel()
       
  1852     {
       
  1853     iRepository->NotifyCancel(iKey);
       
  1854     }
       
  1855 
       
  1856 void CCenrepNotifyHandler::RunL()
       
  1857     {
       
  1858     TInt value = 0;
       
  1859     TInt error = iRepository->Get( iKey, value);
       
  1860     if( error == KErrNone )
       
  1861         {
       
  1862         iObserver.CenrepChanged(value);
       
  1863         }
       
  1864     // Re-subscribe
       
  1865    error = iRepository->NotifyRequest( iKey, iStatus );
       
  1866    if( error == KErrNone )
       
  1867        {
       
  1868        SetActive();
       
  1869        }
       
  1870     }
       
  1871 // End of file
  1417 // End of file