widgets/widgetapp/src/WidgetUiWindow.cpp
branchRCL_3
changeset 67 4917f9bf7995
parent 62 c711bdda59f4
child 70 8bfb9186a8b8
equal deleted inserted replaced
64:ac77f89b1d9e 67:4917f9bf7995
    40 #include <AiwGenericParam.h>
    40 #include <AiwGenericParam.h>
    41 #include <ActiveApDb.h>
    41 #include <ActiveApDb.h>
    42 #include <aknsdrawutils.h>
    42 #include <aknsdrawutils.h>
    43 #include "SWInstWidgetUid.h"
    43 #include "SWInstWidgetUid.h"
    44 
    44 
       
    45 #ifdef RD_SCALABLE_UI_V2
       
    46 #include <centralrepository.h>
       
    47 #include <SensorPluginDomainCrKeys.h>
       
    48 #endif //RD_SCALABLE_UI_V2
       
    49 
    45 // EXTERNAL DATA STRUCTURES
    50 // EXTERNAL DATA STRUCTURES
    46 
    51 
    47 // EXTERNAL FUNCTION PROTOTYPES
    52 // EXTERNAL FUNCTION PROTOTYPES
    48 
    53 
    49 // CONSTANTS
    54 // CONSTANTS
    50 static const TUint32 KDummyCommand = 0;
    55 static const TUint32 KDummyCommand = 0;
    51 
    56 
    52 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
    53 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 const TInt KRetryConnectivityTimeout( 2*1000*1000 ); // 2 seconds
    54 
    60 
    55 // MACROS
    61 // MACROS
    56 
    62 
    57 // LOCAL CONSTANTS AND MACROS
    63 // LOCAL CONSTANTS AND MACROS
    58 
    64 
   195 
   201 
   196     iNeedToNotifyNetworkState = EFalse;
   202     iNeedToNotifyNetworkState = EFalse;
   197     // determine initial widget online/offline network state
   203     // determine initial widget online/offline network state
   198     DetermineNetworkState();
   204     DetermineNetworkState();
   199     iAsyncCallBack = new (ELeave) CAsyncCallBack(TCallBack(DeleteItself,this),CActive::EPriorityUserInput);
   205     iAsyncCallBack = new (ELeave) CAsyncCallBack(TCallBack(DeleteItself,this),CActive::EPriorityUserInput);
       
   206 #ifdef BRDO_OCC_ENABLED_FF
       
   207     iConnStageNotifier = CConnectionStageNotifierWCB::NewL();
       
   208     //this is required, browser's connection oberver should be hit first. (incase of netscape plgins, transactions will be closed.)
       
   209     iConnStageNotifier->SetPriority(CActive::EPriorityHigh);
       
   210     iRetryConnectivity = CPeriodic::NewL(CActive::EPriorityStandard);
       
   211 #endif
   200     }
   212     }
   201 
   213 
   202 // -----------------------------------------------------------------------------
   214 // -----------------------------------------------------------------------------
   203 // CWidgetUiWindow::~CWidgetUiWindow()
   215 // CWidgetUiWindow::~CWidgetUiWindow()
   204 // Destructor
   216 // Destructor
   495 
   507 
   496     CleanupStack::PopAndDestroy(3);// filename,bitmap,mask
   508     CleanupStack::PopAndDestroy(3);// filename,bitmap,mask
   497     }
   509     }
   498 
   510 
   499 // -----------------------------------------------------------------------------
   511 // -----------------------------------------------------------------------------
   500 // CWidgetUiWindow::Relayout()
   512 // CWidgetUiWindow::RelayoutL( TInt aType )
   501 // switch the display orientation based on preferred setting
   513 // switch the display orientation based on preferred setting
   502 //
   514 //
   503 // -----------------------------------------------------------------------------
   515 // -----------------------------------------------------------------------------
   504 //
   516 //
   505 void CWidgetUiWindow::Relayout( )
   517 void CWidgetUiWindow::RelayoutL( TInt aType )
   506     {
   518     {
   507     if (iIsCurrent)
   519     if (iIsCurrent)
   508         {
   520         {
       
   521 #ifdef RD_SCALABLE_UI_V2
       
   522         if(aType == KEikDynamicLayoutVariantSwitch)
       
   523             {
       
   524             CRepository* iSensor = CRepository::NewLC(KCRUidSensorSettings);
       
   525             TInt sensorOn = 0;
       
   526             //get sensor is on/off from general settings
       
   527             iSensor->Get(KSenSettingsSensorsOn, sensorOn);
       
   528             if(sensorOn == 0)
       
   529                 {    
       
   530                 TRect rec = iWindowManager.View()->Container()->Rect();
       
   531                 if( rec.Height() < rec.Width())
       
   532                     iPreferredOrientation = TBrCtlDefs::EOrientationLandscape;
       
   533                 else
       
   534                     iPreferredOrientation = TBrCtlDefs::EOrientationPortrait;
       
   535                 }
       
   536             CleanupStack::PopAndDestroy();
       
   537             }
       
   538 #endif // RD_SCALABLE_UI_V2
   509         SetDisplayMode(iPreferredOrientation);
   539         SetDisplayMode(iPreferredOrientation);
   510         SetSoftkeysVisible(iShowSoftkeys);
   540         SetSoftkeysVisible(iShowSoftkeys);
   511         //iWindowManager.View()->Container()->SizeChanged();
   541         //iWindowManager.View()->Container()->SizeChanged();
   512         }
   542         }
   513     }
   543     }
   529         if (aCurrent)
   559         if (aCurrent)
   530             {
   560             {
   531             UpdateCba();
   561             UpdateCba();
   532             Engine()->MakeVisible( iWidgetLoaded );
   562             Engine()->MakeVisible( iWidgetLoaded );
   533             // redraw incase the orientation changed while in the background
   563             // redraw incase the orientation changed while in the background
   534             Relayout();
   564             RelayoutL();
   535             }
   565             }
   536         else
   566         else
   537             {
   567             {
   538             // close the menu
   568             // close the menu
   539             iWindowManager.View()->StopDisplayingMenuBar();
   569             iWindowManager.View()->StopDisplayingMenuBar();
   908                                       TInt* aSockSvrHandle,
   938                                       TInt* aSockSvrHandle,
   909                                       TBool* aNewConn,
   939                                       TBool* aNewConn,
   910                                       TApBearerType* aBearerType )
   940                                       TApBearerType* aBearerType )
   911 
   941 
   912     {
   942     {
       
   943 #ifdef BRDO_OCC_ENABLED_FF
       
   944     TBool retryFlag = GetRetryFlag();
       
   945     if( retryFlag )
       
   946         {
       
   947         return;
       
   948         }
       
   949 #endif
   913     // default in case connection setup fails
   950     // default in case connection setup fails
   914     *aConnectionPtr = 0;
   951     *aConnectionPtr = 0;
   915 
   952 
   916     if( EMiniViewEnabled == WidgetMiniViewState() ||
   953     if( EMiniViewEnabled == WidgetMiniViewState() ||
   917         EMiniViewNotEnabled == WidgetMiniViewState())
   954         EMiniViewNotEnabled == WidgetMiniViewState())
  1270     delete self;
  1307     delete self;
  1271     if(p->WindowListCount() == 0)
  1308     if(p->WindowListCount() == 0)
  1272         p->ExitNow();
  1309         p->ExitNow();
  1273     return 0;
  1310     return 0;
  1274     }
  1311     }
  1275 
  1312     
       
  1313 #ifdef BRDO_OCC_ENABLED_FF
       
  1314 // -----------------------------------------------------------------------------
       
  1315 // CWidgetUiWindow::ConnectionStageAchievedL()
       
  1316 // -----------------------------------------------------------------------------
       
  1317 //
       
  1318 void CWidgetUiWindow::ConnectionStageAchievedL()
       
  1319     {
       
  1320 
       
  1321     iWindowManager.GetConnection()->Disconnect();
       
  1322    
       
  1323     TRAP_IGNORE( Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandSetRetryConnectivityFlag + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  1324     SetRetryFlag(ETrue);    
       
  1325     
       
  1326     if( iRetryConnectivity && iRetryConnectivity->IsActive())
       
  1327        {
       
  1328        iRetryConnectivity->Cancel();
       
  1329        }
       
  1330     iRetryConnectivity->Start(KRetryConnectivityTimeout, 0,TCallBack(RetryConnectivity,this));
       
  1331 
       
  1332     }  
       
  1333 
       
  1334 void CWidgetUiWindow::ConnNeededStatusL( TInt aErr )
       
  1335     {
       
  1336     StopConnectionObserving(); //Need to stop the connection observer first
       
  1337 
       
  1338 
       
  1339     if ( !iConnStageNotifier->IsActive() )
       
  1340         {
       
  1341         TName* connectionName = iWindowManager.GetConnection()->ConnectionNameL();
       
  1342         CleanupStack::PushL( connectionName );
       
  1343 
       
  1344         iConnStageNotifier->StartNotificationL(connectionName, KLinkLayerClosed, this);
       
  1345 
       
  1346         CleanupStack::PopAndDestroy();  //connectionName
       
  1347         }
       
  1348     } 
       
  1349 void CWidgetUiWindow::StopConnectionObserving()
       
  1350     {
       
  1351     
       
  1352     if ( iConnStageNotifier && iConnStageNotifier->IsActive() )
       
  1353         {
       
  1354         iConnStageNotifier->Cancel();
       
  1355         }
       
  1356     } 
       
  1357 
       
  1358 // -----------------------------------------------------------------------------
       
  1359 // CWidgetUiWindow::SetRetryFlag
       
  1360 // -----------------------------------------------------------------------------
       
  1361 //
       
  1362 void CWidgetUiWindow::SetRetryFlag(TBool flag)
       
  1363      {
       
  1364      reConnectivityFlag = flag;
       
  1365      }
       
  1366 // -----------------------------------------------------------------------------
       
  1367 // CWidgetUiWindow::RetryConnectivity
       
  1368 // -----------------------------------------------------------------------------
       
  1369 //
       
  1370 TInt CWidgetUiWindow::RetryConnectivity(TAny* aWidgetUiWindow)
       
  1371     {
       
  1372 
       
  1373     TInt err = ((CWidgetUiWindow*)aWidgetUiWindow)->RetryInternetConnection();
       
  1374     return err;
       
  1375     }
       
  1376 TInt CWidgetUiWindow::RetryInternetConnection()
       
  1377     {
       
  1378     //First cancel the timer
       
  1379     if ( iRetryConnectivity && iRetryConnectivity->IsActive() )
       
  1380     {
       
  1381         iRetryConnectivity->Cancel();
       
  1382     }
       
  1383     TInt err = KErrNone;
       
  1384     if ( !iWindowManager.GetConnection()->Connected() )
       
  1385        {
       
  1386        TRAP_IGNORE( err = iWindowManager.GetConnection()->StartConnectionL( ETrue ) );
       
  1387        }
       
  1388     if( err == KErrNone )
       
  1389        { 
       
  1390    
       
  1391        TRAP_IGNORE( Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandUnSetRetryConnectivityFlag + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  1392        SetRetryFlag(EFalse);
       
  1393        
       
  1394        TRAP_IGNORE(ConnNeededStatusL(err)); //Start the observer again
       
  1395        TRAP_IGNORE( Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandRetryTransactions + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  1396        }
       
  1397     else
       
  1398         {
       
  1399         TRAP_IGNORE( Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandUnSetRetryConnectivityFlag + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  1400         SetRetryFlag(EFalse);
       
  1401         TRAP_IGNORE(Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandClearQuedTransactions + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  1402         }
       
  1403     
       
  1404     return err;
       
  1405     }
       
  1406 // -----------------------------------------------------------------------------
       
  1407 // CWidgetUiWindow::GetRetryFlag
       
  1408 // -----------------------------------------------------------------------------
       
  1409 //
       
  1410  TBool CWidgetUiWindow::GetRetryFlag()
       
  1411       {
       
  1412       return reConnectivityFlag;
       
  1413       } 
       
  1414 #endif 
  1276 // End of file
  1415 // End of file