widgets/widgetapp/src/WidgetUiWindow.cpp
changeset 65 5bfc169077b2
parent 38 6297cdf66332
child 68 92a765b5b3e7
equal deleted inserted replaced
42:d39add9822e2 65:5bfc169077b2
    19 #include "WidgetUiWindow.h"
    19 #include "WidgetUiWindow.h"
    20 #include "WidgetUiWindowView.h"
    20 #include "WidgetUiWindowView.h"
    21 #include "WidgetUiWindowContainer.h"
    21 #include "WidgetUiWindowContainer.h"
    22 #include "WidgetUiWindowManager.h"
    22 #include "WidgetUiWindowManager.h"
    23 #include "WidgetUiDialogsProviderProxy.h"
    23 #include "WidgetUiDialogsProviderProxy.h"
    24 #include <widgetregistryconstants.h>
    24 #include "WidgetRegistryConstants.h"
    25 #include "browser_platform_variant.hrh"
    25 #include "Browser_platform_variant.hrh"
    26 #ifdef BRDO_WRT_HS_FF
    26 #ifdef BRDO_WRT_HS_FF
    27 #include "cpspublisher.h"
    27 #include "cpspublisher.h"
    28 #endif
    28 #endif
    29 #include <AknUtils.h>
    29 #include <AknUtils.h>
    30 #include <ImageConversion.h>
    30 #include <ImageConversion.h>
    31 #include <WidgetUi.rsg>
    31 #include <WidgetUi.rsg>
    32 
    32 
    33 #include <schemehandler.h>
    33 #include <schemehandler.h>
    34 #include <internetconnectionmanager.h>
    34 #include <InternetConnectionManager.h>
    35 #include "WidgetInstallerInternalCRKeys.h"
    35 #include "WidgetInstallerInternalCRKeys.h"
    36 #include <browseruisdkcrkeys.h>
    36 #include <BrowserUiSDKCRKeys.h>
    37 #include <StringLoader.h>
    37 #include <StringLoader.h>
    38 #include <centralrepository.h>
    38 #include <centralrepository.h>
    39 #include <ApUtils.h>
    39 #include <ApUtils.h>
    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 
    45 // EXTERNAL DATA STRUCTURES
    46 // EXTERNAL DATA STRUCTURES
    46 
    47 
    47 // EXTERNAL FUNCTION PROTOTYPES
    48 // EXTERNAL FUNCTION PROTOTYPES
    48 
    49 
   191         SetWindowStateMiniViewL( EMiniViewNotEnabled );
   192         SetWindowStateMiniViewL( EMiniViewNotEnabled );
   192         }
   193         }
   193 
   194 
   194     iDlId = 0;
   195     iDlId = 0;
   195 
   196 
   196     iNeedToNotifyNetworkState = EFalse;
       
   197     // determine initial widget online/offline network state
   197     // determine initial widget online/offline network state
   198     DetermineNetworkState();
   198     DetermineNetworkState();
   199     iAsyncCallBack = new (ELeave) CAsyncCallBack(TCallBack(DeleteItself,this),CActive::EPriorityUserInput);
       
   200     }
   199     }
   201 
   200 
   202 // -----------------------------------------------------------------------------
   201 // -----------------------------------------------------------------------------
   203 // CWidgetUiWindow::~CWidgetUiWindow()
   202 // CWidgetUiWindow::~CWidgetUiWindow()
   204 // Destructor
   203 // Destructor
   219     delete iWidgetBundleId;
   218     delete iWidgetBundleId;
   220     delete iRightSoftKeyLabel;
   219     delete iRightSoftKeyLabel;
   221     delete iLeftSoftKeyLabel;
   220     delete iLeftSoftKeyLabel;
   222     delete iWidgetUiDialogsProviderProxy;
   221     delete iWidgetUiDialogsProviderProxy;
   223     delete iSchemeHandler;
   222     delete iSchemeHandler;
   224     
   223     delete iMiniviewBitmap;
   225     iActiveMiniviewBitmap = 0;
       
   226     iMiniviewBitmap1.Reset();
       
   227     iMiniviewBitmap2.Reset();
       
   228     
       
   229 #ifdef BRDO_WRT_HS_FF
   224 #ifdef BRDO_WRT_HS_FF
   230     delete iNetworkModeWait;
   225     delete iNetworkModeWait;
   231 #endif
   226 #endif
   232     if(iAsyncCallBack)
       
   233         {
       
   234         iAsyncCallBack->Cancel();
       
   235         }
       
   236     delete iAsyncCallBack;
       
   237     iAsyncCallBack=NULL;    
       
   238     }
   227     }
   239 
   228 
   240 // -----------------------------------------------------------------------------
   229 // -----------------------------------------------------------------------------
   241 // CWidgetUiWindow::CbaGroup()
   230 // CWidgetUiWindow::CbaGroup()
   242 // returns cba group
   231 // returns cba group
   579         else
   568         else
   580             {
   569             {
   581             // reset the Right Softkey
   570             // reset the Right Softkey
   582             TRAP_IGNORE(iWidgetUiObserver->UpdateSoftkeyL(EKeyRight,KNullDesC,KDummyCommand,EChangeReasonLoad));
   571             TRAP_IGNORE(iWidgetUiObserver->UpdateSoftkeyL(EKeyRight,KNullDesC,KDummyCommand,EChangeReasonLoad));
   583             }
   572             }
   584         if (iLeftSoftKeyLabel)
   573 
   585             {
       
   586             // restore the Left Softkey
       
   587             TRAP_IGNORE(iWidgetUiObserver->UpdateSoftkeyL(EKeyLeft,*iLeftSoftKeyLabel,KDummyCommand,EChangeReasonLoad));
       
   588             }
       
   589         else
       
   590             {
       
   591             // reset the Left Softkey
       
   592             TRAP_IGNORE(iWidgetUiObserver->UpdateSoftkeyL(EKeyLeft,KNullDesC,KDummyCommand,EChangeReasonLoad));
       
   593             }
       
   594         
       
   595         // restore state
   574         // restore state
   596         if ( !showSoftkeys )
   575         if ( !showSoftkeys )
   597             {
   576             {
   598             CbaGroup()->MakeVisible( EFalse );
   577             CbaGroup()->MakeVisible( EFalse );
   599             }
   578             }
   632 
   611 
   633     if (iWidgetLoaded && iIsCurrent && fullView )
   612     if (iWidgetLoaded && iIsCurrent && fullView )
   634         {
   613         {
   635         Engine()->MakeVisible( ETrue );
   614         Engine()->MakeVisible( ETrue );
   636         }
   615         }
   637     PublishSnapShot();
       
   638     if(iWidgetLoaded && iNeedToNotifyNetworkState)
       
   639         DetermineNetworkState();
       
   640     }
   616     }
   641 
   617 
   642 // -----------------------------------------------------------------------------
   618 // -----------------------------------------------------------------------------
   643 // CWidgetUiWindow::PublishSnapShot()
   619 // CWidgetUiWindow::PublishSnapShot()
   644 // pubish offscreen bitmap to CPSpublisger
   620 // pubish offscreen bitmap to CPSpublisger
   649     {
   625     {
   650     if( iWidgetLoaded && (WidgetMiniViewState() == EPublishStart ) )
   626     if( iWidgetLoaded && (WidgetMiniViewState() == EPublishStart ) )
   651         {
   627         {
   652 #ifdef BRDO_WRT_HS_FF
   628 #ifdef BRDO_WRT_HS_FF
   653 
   629 
   654         if ( iCpsPublisher)
   630         if ( !iMiniviewBitmap )
   655             {
   631             {
   656             // Swap bitmaps
   632             iMiniviewBitmap = new CFbsBitmap();
   657             if(iActiveMiniviewBitmap == &iMiniviewBitmap1)
   633             }
   658             	iActiveMiniviewBitmap = &iMiniviewBitmap2;
   634 
   659             else
   635         if ( iMiniviewBitmap && iCpsPublisher)
   660             	iActiveMiniviewBitmap = &iMiniviewBitmap1;
   636             {
   661             
       
   662             // Take snapshot and publish	
       
   663             TRAP_IGNORE(
   637             TRAP_IGNORE(
   664                (iEngine->TakeSnapshotL( *iActiveMiniviewBitmap ));
   638                (iEngine->TakeSnapshotL( *iMiniviewBitmap ));
   665                 iCpsPublisher->PublishBitmapL( *iActiveMiniviewBitmap, *iWidgetBundleId );
   639                 iCpsPublisher->PublishBitmapL( *iMiniviewBitmap, *iWidgetBundleId );
   666                 );
   640                 );
   667             }
   641             }
   668 #endif
   642 #endif
   669         }
   643         }
   670     }
   644     }
   834                     TUint32 iap = apUtils->IapIdFromWapIdL( wmlId );
   808                     TUint32 iap = apUtils->IapIdFromWapIdL( wmlId );
   835                     CleanupStack::PopAndDestroy();
   809                     CleanupStack::PopAndDestroy();
   836                     iWindowManager.GetConnection()->SetRequestedAP( iap );
   810                     iWindowManager.GetConnection()->SetRequestedAP( iap );
   837                 );
   811                 );
   838             }
   812             }
   839 
       
   840         if ( EBrowserCenRepApSelModeAlwaysAsk == ask )
       
   841             {
       
   842               //Always ask case
       
   843               TUint32 ap( 0 );
       
   844               iWindowManager.GetConnection()->SetRequestedAP( ap );
       
   845             }
       
   846         }
   813         }
   847     }
   814     }
   848 
   815 
   849 // -----------------------------------------------------------------------------
   816 // -----------------------------------------------------------------------------
   850 // CWidgetUiWindow::StartNetworkConnection()
   817 // CWidgetUiWindow::StartNetworkConnection()
   856     {
   823     {
   857     *aNewConn = EFalse;
   824     *aNewConn = EFalse;
   858     if ( !iWindowManager.GetConnection()->Connected() )
   825     if ( !iWindowManager.GetConnection()->Connected() )
   859         {
   826         {
   860         // 2.2. make a connection
   827         // 2.2. make a connection
   861         iConnecting=ETrue;
   828         TInt connFailure = iWindowManager.GetConnection()->StartConnectionL( ETrue );
   862         TInt connFailure = 0;
       
   863         TRAPD(err, connFailure=iWindowManager.GetConnection()->StartConnectionL( ETrue ));
       
   864         iConnecting=EFalse;
       
   865         User::LeaveIfError(err);
       
   866         if(iDeleteItself)
       
   867             iAsyncCallBack->CallBack();
       
   868         if (KErrCancel == connFailure)
   829         if (KErrCancel == connFailure)
   869             {
   830             {
   870 #ifdef BRDO_WRT_HS_FF
   831 #ifdef BRDO_WRT_HS_FF
   871             if(! (EMiniViewEnabled == WidgetMiniViewState() || 
   832             iCpsPublisher->NetworkConnectionCancelledL();
   872                   EMiniViewNotEnabled == WidgetMiniViewState()) )
       
   873                 {        
       
   874                 iCpsPublisher->NetworkConnectionCancelledL();
       
   875                 }
       
   876 #endif
   833 #endif
   877             User::Leave( connFailure );
   834             User::Leave( connFailure );
   878             }
   835             }
   879         else if ( KErrNone != connFailure )
   836         else if ( KErrNone != connFailure )
   880             {
   837             {
  1162 //
  1119 //
  1163 void CWidgetUiWindow::DetermineNetworkState()
  1120 void CWidgetUiWindow::DetermineNetworkState()
  1164     {
  1121     {
  1165     TNetworkState currNetState;
  1122     TNetworkState currNetState;
  1166     RWidgetRegistryClientSession& widgetRegistry = iWindowManager.WidgetUIClientSession();
  1123     RWidgetRegistryClientSession& widgetRegistry = iWindowManager.WidgetUIClientSession();
  1167     TInt inMiniView = !(WidgetMiniViewState()==EMiniViewEnabled || WidgetMiniViewState()==EMiniViewNotEnabled);//widgetRegistry.IsWidgetInMiniView( iUid);
  1124     TInt inMiniView = widgetRegistry.IsWidgetInMiniView( iUid);
  1168     CWidgetPropertyValue* propValue = widgetRegistry.GetWidgetPropertyValueL( iUid, EAllowNetworkAccess );
  1125     CWidgetPropertyValue* propValue = widgetRegistry.GetWidgetPropertyValueL( iUid, EAllowNetworkAccess );
  1169     TInt netAccessWdgtProp = *propValue;    // AllowNetworkAccess in the info.plist file
  1126     TInt netAccessWdgtProp = *propValue;    // AllowNetworkAccess in the info.plist file
  1170 
  1127 
  1171     if ( netAccessWdgtProp && ((inMiniView && (iWindowManager.GetNetworkMode() == (TInt)EOnlineMode))
  1128     if ( netAccessWdgtProp && ((inMiniView && (iWindowManager.GetNetworkMode() == (TInt)EOnlineMode))
  1172                                     || (!inMiniView && iUserPermission)) )
  1129                                     || (!inMiniView && iUserPermission)) )
  1224             // status pane always off unless in text box
  1181             // status pane always off unless in text box
  1225             iWindowManager.View()->UpdateStatusPane(EFalse);
  1182             iWindowManager.View()->UpdateStatusPane(EFalse);
  1226             }
  1183             }
  1227         }
  1184         }
  1228     }
  1185     }
  1229 
       
  1230 // -----------------------------------------------------------------------------
       
  1231 // CWidgetUiWindow::NeedToNotifyNetworkState()
       
  1232 // -----------------------------------------------------------------------------
       
  1233 //
       
  1234 void CWidgetUiWindow::NeedToNotifyNetworkState(TBool aNetworkState)
       
  1235     {
       
  1236     iNeedToNotifyNetworkState = aNetworkState;
       
  1237     }
       
  1238 
       
  1239 // -----------------------------------------------------------------------------
       
  1240 // CWidgetUiWindow::CanBeDeleted()
       
  1241 // -----------------------------------------------------------------------------
       
  1242 //
       
  1243 TBool CWidgetUiWindow::CanBeDeleted()
       
  1244     {
       
  1245     iDeleteItself = iConnecting;
       
  1246     return !iConnecting;
       
  1247     }
       
  1248     
       
  1249 // -----------------------------------------------------------------------------
       
  1250 // CWidgetUiWindow::DeleteItself()
       
  1251 // -----------------------------------------------------------------------------
       
  1252 //
       
  1253 TInt CWidgetUiWindow::DeleteItself(TAny* aPtr)
       
  1254     {
       
  1255     CWidgetUiWindow* self = (CWidgetUiWindow*)aPtr;
       
  1256     CWidgetUiWindowManager* p = &self->iWindowManager;
       
  1257     delete self;
       
  1258     if(p->WindowListCount() == 0)
       
  1259         p->ExitNow();
       
  1260     return 0;
       
  1261     }
       
  1262 
       
  1263 // End of file
  1186 // End of file