widgets/widgetapp/src/WidgetUiWindow.cpp
branchRCL_3
changeset 44 800203832575
parent 42 a1a5d4e727e8
child 46 30342f40acbf
equal deleted inserted replaced
42:a1a5d4e727e8 44:800203832575
    54 // CONSTANTS
    54 // CONSTANTS
    55 static const TUint32 KDummyCommand = 0;
    55 static const TUint32 KDummyCommand = 0;
    56 
    56 
    57 const TUint KWmlNoDefaultAccessPoint = KMaxTUint; // see cenrep setting default -1 as int, here as uint
    57 const TUint KWmlNoDefaultAccessPoint = KMaxTUint; // see cenrep setting default -1 as int, here as uint
    58 const TUint KWmlNoDefaultSnapId = KMaxTUint; // see cenrep setting default -1 as int, here as uint
    58 const TUint KWmlNoDefaultSnapId = KMaxTUint; // see cenrep setting default -1 as int, here as uint
    59 #ifdef BRDO_OCC_ENABLED_FF
    59 
    60 const TInt KRetryConnectivityTimeout( 2*1000*1000 ); // 2 seconds
       
    61 #endif
       
    62 
    60 
    63 // MACROS
    61 // MACROS
    64 
    62 
    65 // LOCAL CONSTANTS AND MACROS
    63 // LOCAL CONSTANTS AND MACROS
    66 
    64 
   204 
   202 
   205     iNeedToNotifyNetworkState = EFalse;
   203     iNeedToNotifyNetworkState = EFalse;
   206     // determine initial widget online/offline network state
   204     // determine initial widget online/offline network state
   207     DetermineNetworkState();
   205     DetermineNetworkState();
   208     iAsyncCallBack = new (ELeave) CAsyncCallBack(TCallBack(DeleteItself,this),CActive::EPriorityUserInput);
   206     iAsyncCallBack = new (ELeave) CAsyncCallBack(TCallBack(DeleteItself,this),CActive::EPriorityUserInput);
   209 #ifdef BRDO_OCC_ENABLED_FF
       
   210     iConnStageNotifier = CConnectionStageNotifierWCB::NewL();
       
   211     //this is required, browser's connection oberver should be hit first. (incase of netscape plgins, transactions will be closed.)
       
   212     iConnStageNotifier->SetPriority(CActive::EPriorityHigh);
       
   213     iRetryConnectivity = CPeriodic::NewL(CActive::EPriorityStandard);
       
   214 #endif
       
   215     }
   207     }
   216 
   208 
   217 // -----------------------------------------------------------------------------
   209 // -----------------------------------------------------------------------------
   218 // CWidgetUiWindow::~CWidgetUiWindow()
   210 // CWidgetUiWindow::~CWidgetUiWindow()
   219 // Destructor
   211 // Destructor
   229     if (iEngine && iWidgetUiObserver)
   221     if (iEngine && iWidgetUiObserver)
   230         {
   222         {
   231         iEngine->RemoveLoadEventObserver( iWidgetUiObserver );
   223         iEngine->RemoveLoadEventObserver( iWidgetUiObserver );
   232         iEngine->RemoveStateChangeObserver( iWindowManager.View() );
   224         iEngine->RemoveStateChangeObserver( iWindowManager.View() );
   233         }
   225         }
   234 #ifdef BRDO_OCC_ENABLED_FF 
       
   235     if ( iRetryConnectivity)
       
   236         {
       
   237         iRetryConnectivity->Cancel();
       
   238         delete iRetryConnectivity;
       
   239         iRetryConnectivity = NULL;
       
   240         }
       
   241 #endif
       
   242     delete iEngine;
   226     delete iEngine;
   243     delete iWidgetUiObserver;
   227     delete iWidgetUiObserver;
   244     delete iUrl;
   228     delete iUrl;
   245     delete iWidgetPath;
   229     delete iWidgetPath;
   246     delete iWidgetBundleId;
   230     delete iWidgetBundleId;
   940             }
   924             }
   941         *aNewConn = ETrue;
   925         *aNewConn = ETrue;
   942         if(iWindowManager.GetNetworkMode() == EOfflineMode)
   926         if(iWindowManager.GetNetworkMode() == EOfflineMode)
   943         	{
   927         	{
   944             iWindowManager.GetConnection()->CancelConnection();
   928             iWindowManager.GetConnection()->CancelConnection();
   945             iWindowManager.GetConnection()->StopConnectionL();        		
   929             iWindowManager.GetConnection()->StopConnectionL();
       
   930             User::Leave( KErrAccessDenied );
   946         	}      
   931         	}      
   947 #ifdef BRDO_OCC_ENABLED_FF        
   932 #ifdef BRDO_OCC_ENABLED_FF        
   948 		else
   933 		else
   949         	TRAP_IGNORE(ConnNeededStatusL(KErrNone)); 
   934         	TRAP_IGNORE(iWindowManager.ConnNeededStatusL(KErrNone)); 
   950 #endif        
   935 #endif        
   951         }
   936         }
   952     }
   937     }
   953 
   938 
   954 // -----------------------------------------------------------------------------
   939 // -----------------------------------------------------------------------------
   961                                       TBool* aNewConn,
   946                                       TBool* aNewConn,
   962                                       TApBearerType* aBearerType )
   947                                       TApBearerType* aBearerType )
   963 
   948 
   964     {
   949     {
   965 #ifdef BRDO_OCC_ENABLED_FF
   950 #ifdef BRDO_OCC_ENABLED_FF
   966     TBool retryFlag = GetRetryFlag();
   951     TBool retryFlag = iWindowManager.GetRetryFlag();
   967     if( retryFlag )
   952     if( retryFlag )
   968         {
   953         {
   969         return;
   954         return;
   970         }
   955         }
   971 #endif
   956 #endif
  1333         User::Exit(KErrNone);
  1318         User::Exit(KErrNone);
  1334     return 0;
  1319     return 0;
  1335     }
  1320     }
  1336     
  1321     
  1337 #ifdef BRDO_OCC_ENABLED_FF
  1322 #ifdef BRDO_OCC_ENABLED_FF
  1338 // -----------------------------------------------------------------------------
       
  1339 // CWidgetUiWindow::ConnectionStageAchievedL()
       
  1340 // -----------------------------------------------------------------------------
       
  1341 //
       
  1342 void CWidgetUiWindow::ConnectionStageAchievedL()
       
  1343     {
       
  1344     iWindowManager.GetConnection()->Disconnect();
       
  1345     
       
  1346     TNifProgressBuf buf = iConnStageNotifier->GetProgressBuffer();
       
  1347     if( buf().iError == KErrDisconnected )
       
  1348         {
       
  1349         TRAP_IGNORE( Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandSetRetryConnectivityFlag + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  1350         SetRetryFlag(ETrue);    
       
  1351     
       
  1352         TRAP_IGNORE( Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandCancelQueuedTransactions + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  1353     
       
  1354         if( iRetryConnectivity && iRetryConnectivity->IsActive())
       
  1355             {
       
  1356             iRetryConnectivity->Cancel();
       
  1357             }
       
  1358         iRetryConnectivity->Start(KRetryConnectivityTimeout, 0,TCallBack(RetryConnectivity,this));
       
  1359         }
       
  1360     else
       
  1361         {
       
  1362         TRAP_IGNORE( Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandCancelFetch + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  1363         }
       
  1364     }  
       
  1365 
       
  1366 void CWidgetUiWindow::ConnNeededStatusL( TInt aErr )
       
  1367     {
       
  1368     StopConnectionObserving(); //Need to stop the connection observer first
       
  1369 
       
  1370 
       
  1371     if ( !iConnStageNotifier->IsActive() )
       
  1372         {
       
  1373         TName* connectionName = iWindowManager.GetConnection()->ConnectionNameL();
       
  1374         CleanupStack::PushL( connectionName );
       
  1375 
       
  1376         iConnStageNotifier->StartNotificationL(connectionName, KLinkLayerClosed, this);
       
  1377 
       
  1378         CleanupStack::PopAndDestroy();  //connectionName
       
  1379         }
       
  1380     } 
       
  1381 void CWidgetUiWindow::StopConnectionObserving()
       
  1382     {
       
  1383     
       
  1384     if ( iConnStageNotifier )
       
  1385         {
       
  1386         iConnStageNotifier->Cancel();
       
  1387         }
       
  1388     } 
       
  1389 
       
  1390 // -----------------------------------------------------------------------------
       
  1391 // CWidgetUiWindow::SetRetryFlag
       
  1392 // -----------------------------------------------------------------------------
       
  1393 //
       
  1394 void CWidgetUiWindow::SetRetryFlag(TBool flag)
       
  1395      {
       
  1396      reConnectivityFlag = flag;
       
  1397      }
       
  1398 // -----------------------------------------------------------------------------
       
  1399 // CWidgetUiWindow::RetryConnectivity
       
  1400 // -----------------------------------------------------------------------------
       
  1401 //
       
  1402 TInt CWidgetUiWindow::RetryConnectivity(TAny* aWidgetUiWindow)
       
  1403     {
       
  1404 
       
  1405     TInt err = ((CWidgetUiWindow*)aWidgetUiWindow)->RetryInternetConnection();
       
  1406     return err;
       
  1407     }
       
  1408 TInt CWidgetUiWindow::RetryInternetConnection()
       
  1409     {
       
  1410     //First cancel the timer
       
  1411     if ( iRetryConnectivity && iRetryConnectivity->IsActive() )
       
  1412     {
       
  1413         iRetryConnectivity->Cancel();
       
  1414     }
       
  1415     TInt err = KErrNone;
       
  1416     if ( !iWindowManager.GetConnection()->Connected() )
       
  1417        {
       
  1418        TRAP_IGNORE( err = iWindowManager.GetConnection()->StartConnectionL( ETrue ) );
       
  1419        }
       
  1420     if( err == KErrNone )
       
  1421        { 
       
  1422    
       
  1423        TRAP_IGNORE( Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandUnSetRetryConnectivityFlag + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  1424        SetRetryFlag(EFalse);
       
  1425        
       
  1426        TRAP_IGNORE(ConnNeededStatusL(err)); //Start the observer again
       
  1427        TRAP_IGNORE( Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandRetryTransactions + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  1428        }
       
  1429     else
       
  1430         {
       
  1431         TRAP_IGNORE( Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandUnSetRetryConnectivityFlag + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  1432         SetRetryFlag(EFalse);
       
  1433         TRAP_IGNORE(Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandClearQuedTransactions + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  1434         }
       
  1435     
       
  1436     return err;
       
  1437     }
       
  1438 // -----------------------------------------------------------------------------
       
  1439 // CWidgetUiWindow::GetRetryFlag
       
  1440 // -----------------------------------------------------------------------------
       
  1441 //
       
  1442  TBool CWidgetUiWindow::GetRetryFlag()
       
  1443       {
       
  1444       return reConnectivityFlag;
       
  1445       } 
       
  1446  
       
  1447  void CWidgetUiWindow::CancelAllDialogs()
  1323  void CWidgetUiWindow::CancelAllDialogs()
  1448      {
  1324      {
  1449      if( iDialogsProvider)
  1325      if( iDialogsProvider)
  1450          {
  1326          {
  1451           iDialogsProvider->CancelAll();
  1327           iDialogsProvider->CancelAll();