widgets/widgetapp/src/WidgetUiWindow.cpp
changeset 15 60c5402cb945
parent 11 c8a366e56285
child 25 0ed94ceaa377
equal deleted inserted replaced
11:c8a366e56285 15:60c5402cb945
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description: 
    14 * Description:
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include "WidgetUi.hrh"
    18 #include "WidgetUi.hrh"
    19 #include "WidgetUiWindow.h"
    19 #include "WidgetUiWindow.h"
   119     RWidgetRegistryClientSession clientSession = iWindowManager.WidgetUIClientSession();
   119     RWidgetRegistryClientSession clientSession = iWindowManager.WidgetUIClientSession();
   120     iUrl = GetUlrL( clientSession, aUid );
   120     iUrl = GetUlrL( clientSession, aUid );
   121     iWidgetUiObserver = CWidgetUiObserver::NewL( *this );
   121     iWidgetUiObserver = CWidgetUiObserver::NewL( *this );
   122 
   122 
   123     iWidgetUiDialogsProviderProxy = CWidgetUiDialogsProviderProxy::NewL(*(iWindowManager.DialogsProvider()), NULL, *this);
   123     iWidgetUiDialogsProviderProxy = CWidgetUiDialogsProviderProxy::NewL(*(iWindowManager.DialogsProvider()), NULL, *this);
   124     
   124 
   125 #ifdef BRDO_WRT_HS_FF
   125 #ifdef BRDO_WRT_HS_FF
   126     iNetworkModeWait = new(ELeave) CActiveSchedulerWait();
   126     iNetworkModeWait = new(ELeave) CActiveSchedulerWait();
   127 #endif
   127 #endif
   128 
   128 
   129     unsigned int capabilities;
   129     unsigned int capabilities;
   155         iWidgetUiDialogsProviderProxy,
   155         iWidgetUiDialogsProviderProxy,
   156         iWidgetUiObserver, /* window observer */
   156         iWidgetUiObserver, /* window observer */
   157         iWidgetUiObserver /* download observer */);
   157         iWidgetUiObserver /* download observer */);
   158     //Set the cursor mode inside Widget
   158     //Set the cursor mode inside Widget
   159     iEngine->SetBrowserSettingL(TBrCtlDefs::ESettingsCursorShowMode, iWindowManager.CursorShowMode());
   159     iEngine->SetBrowserSettingL(TBrCtlDefs::ESettingsCursorShowMode, iWindowManager.CursorShowMode());
       
   160     iEngine->SetBrowserSettingL(TBrCtlDefs::ESettingsEnterKeyMode, iWindowManager.EnterKeyMode());
   160 
   161 
   161     iEngine->AddLoadEventObserverL( iWidgetUiObserver );
   162     iEngine->AddLoadEventObserverL( iWidgetUiObserver );
   162     iEngine->AddStateChangeObserverL( view );
   163     iEngine->AddStateChangeObserverL( view );
   163     iEngine->SetComponentsToInheritVisibility();
   164     iEngine->SetComponentsToInheritVisibility();
   164 
   165 
   188         }
   189         }
   189     else
   190     else
   190         {
   191         {
   191         SetWindowStateMiniViewL( EMiniViewNotEnabled );
   192         SetWindowStateMiniViewL( EMiniViewNotEnabled );
   192         }
   193         }
   193      
   194 
   194     iDlId = 0;
   195     iDlId = 0;
   195     
   196 
   196     // determine initial widget online/offline network state
   197     // determine initial widget online/offline network state
   197     DetermineNetworkState();
   198     DetermineNetworkState();
   198     }
   199     }
   199 
   200 
   200 // -----------------------------------------------------------------------------
   201 // -----------------------------------------------------------------------------
   271 //
   272 //
   272 /*void CWidgetUiWindow::SetWindowStateMiniView( TInt widgetMiniViewState )
   273 /*void CWidgetUiWindow::SetWindowStateMiniView( TInt widgetMiniViewState )
   273     {
   274     {
   274 
   275 
   275     switch(widgetMiniViewState)
   276     switch(widgetMiniViewState)
   276     	{
   277         {
   277         case 0: iWidgetWindowState.miniViewState = EMiniViewNotEnabled;
   278         case 0: iWidgetWindowState.miniViewState = EMiniViewNotEnabled;
   278                 break;
   279                 break;
   279         case 1: iWidgetWindowState.miniViewState = EMiniViewEnabled;
   280         case 1: iWidgetWindowState.miniViewState = EMiniViewEnabled;
   280                 break;
   281                 break;
   281         case 2: iWidgetWindowState.miniViewState = EPublishStart;
   282         case 2: iWidgetWindowState.miniViewState = EPublishStart;
   528             //deactivate optionsmenu flag
   529             //deactivate optionsmenu flag
   529             iWindowManager.View()->DeActivateOptionsMenu();
   530             iWindowManager.View()->DeActivateOptionsMenu();
   530             Engine()->MakeVisible(EFalse);// hide the active widget
   531             Engine()->MakeVisible(EFalse);// hide the active widget
   531             }
   532             }
   532         if ( !aCurrent &&  (EPublishStart != WidgetMiniViewState()) )
   533         if ( !aCurrent &&  (EPublishStart != WidgetMiniViewState()) )
   533             {			
   534             {
   534             iWidgetExtension->HandleCommandL ( (TInt)TBrCtlDefs::ECommandAppBackground + (TInt)TBrCtlDefs::ECommandIdBase );
   535             iWidgetExtension->HandleCommandL ( (TInt)TBrCtlDefs::ECommandAppBackground + (TInt)TBrCtlDefs::ECommandIdBase );
   535             if( iWindowManager.AnyWidgetOnHs() )
   536             if( iWindowManager.AnyWidgetOnHs() )
   536                 {
   537                 {
   537                 //If there is no widget on HS then we should not stop the JS timers
   538                 //If there is no widget on HS then we should not stop the JS timers
   538                 Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandAppBackground + (TInt)TBrCtlDefs::ECommandIdBase);
   539                 Engine()->HandleCommandL( (TInt)TBrCtlDefs::ECommandAppBackground + (TInt)TBrCtlDefs::ECommandIdBase);
   628 
   629 
   629         if ( !iMiniviewBitmap )
   630         if ( !iMiniviewBitmap )
   630             {
   631             {
   631             iMiniviewBitmap = new CFbsBitmap();
   632             iMiniviewBitmap = new CFbsBitmap();
   632             }
   633             }
   633             
   634 
   634         if ( iMiniviewBitmap && iCpsPublisher)
   635         if ( iMiniviewBitmap && iCpsPublisher)
   635             {
   636             {
   636             TRAP_IGNORE(
   637             TRAP_IGNORE(
   637                (iEngine->TakeSnapshotL( *iMiniviewBitmap ));
   638                (iEngine->TakeSnapshotL( *iMiniviewBitmap ));
   638                 iCpsPublisher->PublishBitmapL( *iMiniviewBitmap, *iWidgetBundleId );
   639                 iCpsPublisher->PublishBitmapL( *iMiniviewBitmap, *iWidgetBundleId );
   666 // -----------------------------------------------------------------------------
   667 // -----------------------------------------------------------------------------
   667 //
   668 //
   668 TBool CWidgetUiWindow::CheckNetworkAccessL()
   669 TBool CWidgetUiWindow::CheckNetworkAccessL()
   669     {
   670     {
   670     // if widgets in offline mode, deny network access
   671     // if widgets in offline mode, deny network access
   671     if (iWindowManager.GetNetworkMode() == EOfflineMode)
   672     if (iWindowManager.GetNetworkMode() == EOfflineMode && !( EMiniViewEnabled == WidgetMiniViewState() ||
   672         {
   673         EMiniViewNotEnabled == WidgetMiniViewState() ))
   673         // if widget is in full view, offer user the option to go to online mode
   674         {
       
   675         // if widget is in full view, offer user the option to go to online mode.The widget should be in HS else dont ask HS for prompt.
   674 #ifdef BRDO_WRT_HS_FF
   676 #ifdef BRDO_WRT_HS_FF
   675         if ( WidgetFullViewState() && WidgetMiniViewState() != EPublishStart )
   677         if ( WidgetFullViewState() && WidgetMiniViewState() != EPublishStart )
   676             {
   678             {
   677             iCpsPublisher->NetworkConnectionAllowedL();
   679             iCpsPublisher->NetworkConnectionAllowedL();
   678             }
   680             iNetworkModeWait->Start();
   679         iNetworkModeWait->Start();
   681             }
   680 #endif
   682 #endif
   681         if (iWindowManager.GetNetworkMode() == EOfflineMode)
   683         if (iWindowManager.GetNetworkMode() == EOfflineMode)
   682             {
   684             {
   683             SetNetworkAccessGrant( EDeny );
   685             SetNetworkAccessGrant( EDeny );
   684             User::Leave( KErrAccessDenied );
   686             User::Leave( KErrAccessDenied );
   685             }
   687             }
   686         }
   688         }
   687     
   689 
   688     // begin info.plist (declare EAllowNetworkAccess or EAllowFullAccess ?)
   690     // begin info.plist (declare EAllowNetworkAccess or EAllowFullAccess ?)
   689     RWidgetRegistryClientSession& widgetRegistry
   691     RWidgetRegistryClientSession& widgetRegistry
   690                 = iWindowManager.WidgetUIClientSession();
   692                 = iWindowManager.WidgetUIClientSession();
   691 
   693 
   692     CWidgetPropertyValue* propValue = widgetRegistry.GetWidgetPropertyValueL(iUid, EAllowNetworkAccess ); 
   694     CWidgetPropertyValue* propValue = widgetRegistry.GetWidgetPropertyValueL(iUid, EAllowNetworkAccess );
   693     TInt networkAccess = *propValue;
   695     TInt networkAccess = *propValue;
   694     delete propValue;
   696     delete propValue;
   695     propValue = widgetRegistry.GetWidgetPropertyValueL(iUid, EAllowFullAccess );
   697     propValue = widgetRegistry.GetWidgetPropertyValueL(iUid, EAllowFullAccess );
   696     TInt fullAccess = *propValue;
   698     TInt fullAccess = *propValue;
   697     delete propValue;
   699     delete propValue;
   698  
   700 
   699     if ( !( networkAccess || fullAccess ) )
   701     if ( !( networkAccess || fullAccess ) )
   700         {
   702         {
   701         SetNetworkAccessGrant( EDeny );
   703         SetNetworkAccessGrant( EDeny );
   702         User::Leave( KErrAccessDenied );
   704         User::Leave( KErrAccessDenied );
   703         }
   705         }
   731                 {
   733                 {
   732                     prompt = 1; // got error, force prompt
   734                     prompt = 1; // got error, force prompt
   733                 }
   735                 }
   734                 delete rep;
   736                 delete rep;
   735             }
   737             }
   736         
   738 
   737             if ( prompt )
   739             if ( prompt )
   738                 {
   740                 {
   739                 CBrowserDialogsProvider* dialogProvider
   741                 CBrowserDialogsProvider* dialogProvider
   740                             = iWindowManager.DialogsProvider();
   742                             = iWindowManager.DialogsProvider();
   741                 TBool grant = EFalse;
   743                 TBool grant = EFalse;
   744                 HBufC* no = StringLoader::LoadLC( R_WIDGETUI_SOFTKEY_NO );
   746                 HBufC* no = StringLoader::LoadLC( R_WIDGETUI_SOFTKEY_NO );
   745                 grant = dialogProvider->DialogConfirmL( _L(""), *message, *yes, *no );
   747                 grant = dialogProvider->DialogConfirmL( _L(""), *message, *yes, *no );
   746                 CleanupStack::PopAndDestroy( 3 );
   748                 CleanupStack::PopAndDestroy( 3 );
   747                 // save prompt result for session
   749                 // save prompt result for session
   748                 SetNetworkAccessGrant( grant? EAllow : EDeny );
   750                 SetNetworkAccessGrant( grant? EAllow : EDeny );
   749                 
   751 
   750                 CheckUserPermissionChanged( grant );
   752                 CheckUserPermissionChanged( grant );
   751                 }
   753                 }
   752             else
   754             else
   753                 {
   755                 {
   754                 // cenrep setting is no prompt for session
   756                 // cenrep setting is no prompt for session
   777         // setup a new connection depending on browser settings
   779         // setup a new connection depending on browser settings
   778 
   780 
   779         // 2.1. deal with access point settings
   781         // 2.1. deal with access point settings
   780         TInt ask( 1 );
   782         TInt ask( 1 );
   781         TInt wmlId( KWmlNoDefaultAccessPoint );
   783         TInt wmlId( KWmlNoDefaultAccessPoint );
   782         TInt snapId( KWmlNoDefaultSnapId ); 
   784         TInt snapId( KWmlNoDefaultSnapId );
   783         CRepository* rep( NULL );
   785         CRepository* rep( NULL );
   784         TRAPD( cenrepError, rep = CRepository::NewL( KCRUidBrowser ) );
   786         TRAPD( cenrepError, rep = CRepository::NewL( KCRUidBrowser ) );
   785         if ( KErrNone == cenrepError )
   787         if ( KErrNone == cenrepError )
   786             {
   788             {
   787             (void)rep->Get( KBrowserAccessPointSelectionMode, ask );
   789             (void)rep->Get( KBrowserAccessPointSelectionMode, ask );
   788             (void)rep->Get( KBrowserDefaultAccessPoint, wmlId );
   790             (void)rep->Get( KBrowserDefaultAccessPoint, wmlId );
   789             (void)rep->Get( KBrowserNGDefaultSnapId, snapId );
   791             (void)rep->Get( KBrowserNGDefaultSnapId, snapId );
   790             }
   792             }
   791         delete rep;
   793         delete rep;
   792         if ( ask == EBrowserCenRepApSelModeDestination &&  
   794         if ( ask == EBrowserCenRepApSelModeDestination &&
   793            ( snapId != KWmlNoDefaultSnapId) )  
   795            ( snapId != KWmlNoDefaultSnapId) )
   794             {  
   796             {
   795             iWindowManager.GetConnection()->SetRequestedSnap( snapId );  
   797             iWindowManager.GetConnection()->SetRequestedSnap( snapId );
   796             iWindowManager.GetConnection()->SetConnectionType( CMManager::EDestination );  
   798             iWindowManager.GetConnection()->SetConnectionType( CMManager::EDestination );
   797             }  
   799             }
   798 
   800 
   799         if ( !ask && (KWmlNoDefaultAccessPoint != wmlId) )
   801         if ( !ask && (KWmlNoDefaultAccessPoint != wmlId) )
   800             {
   802             {
   801             // set the access point (ap)
   803             // set the access point (ap)
   802             CApUtils* apUtils( NULL );
   804             CApUtils* apUtils( NULL );
   838             // least evil option, because they can pick another connection,
   840             // least evil option, because they can pick another connection,
   839             // or hit cancel altogether in which case the KErrCancel block above
   841             // or hit cancel altogether in which case the KErrCancel block above
   840             // kicks in and sets a EDeny.
   842             // kicks in and sets a EDeny.
   841             User::Leave( connFailure );
   843             User::Leave( connFailure );
   842             }
   844             }
   843 		*aNewConn = ETrue;
   845         *aNewConn = ETrue;
   844 
   846 
   845         }
   847         }
   846     }
   848     }
   847 
   849 
   848 // -----------------------------------------------------------------------------
   850 // -----------------------------------------------------------------------------
   931     TPtrC contentType = ExtractBrCtlParam(
   933     TPtrC contentType = ExtractBrCtlParam(
   932                             EParamReceivedContentType,
   934                             EParamReceivedContentType,
   933                             aTypeArray,
   935                             aTypeArray,
   934                             aDesArray,
   936                             aDesArray,
   935                             paramFound );
   937                             paramFound );
   936                             
   938 
   937     HBufC8* contentType8 = 0;
   939     HBufC8* contentType8 = 0;
   938     if ( !paramFound )
   940     if ( !paramFound )
   939         {
   941         {
   940         contentType8 = KNullDesC8().AllocLC();
   942         contentType8 = KNullDesC8().AllocLC();
   941         }
   943         }
   943         {
   945         {
   944         contentType8 = HBufC8::NewLC( contentType.Length() );
   946         contentType8 = HBufC8::NewLC( contentType.Length() );
   945         // 16 bit buffer copied into 8 bit buffer.
   947         // 16 bit buffer copied into 8 bit buffer.
   946         contentType8->Des().Copy( contentType );
   948         contentType8->Des().Copy( contentType );
   947         }
   949         }
   948         
   950 
   949     //Get the download Id of the transaction.
   951     //Get the download Id of the transaction.
   950     //Because, resource loader will not delete the download
   952     //Because, resource loader will not delete the download
   951     //So after handling the download, it will be cleared.
   953     //So after handling the download, it will be cleared.
   952     TPtrC dlId = ExtractBrCtlParam(
   954     TPtrC dlId = ExtractBrCtlParam(
   953                             EParamTransactionId,
   955                             EParamTransactionId,
   954                             aTypeArray,
   956                             aTypeArray,
   955                             aDesArray,
   957                             aDesArray,
   956                             paramFound );
   958                             paramFound );
   957     
   959 
   958     TLex lex(dlId);
   960     TLex lex(dlId);
   959     User::LeaveIfError(lex.Val(iDlId));                        
   961     User::LeaveIfError(lex.Val(iDlId));
   960                             
   962 
   961     TDataType dataType( *contentType8 );
   963     TDataType dataType( *contentType8 );
   962     CAiwGenericParamList* genericParamList =
   964     CAiwGenericParamList* genericParamList =
   963         BrCtlParamList2GenericParamListL( aTypeArray, aDesArray );
   965         BrCtlParamList2GenericParamListL( aTypeArray, aDesArray );
   964     CleanupStack::PushL( genericParamList );
   966     CleanupStack::PushL( genericParamList );
   965     RFile tempFile;
   967     RFile tempFile;
   966     
   968 
   967     iWindowManager.DocHandler().SetExitObserver(this);
   969     iWindowManager.DocHandler().SetExitObserver(this);
   968     iWindowManager.DocHandler().OpenTempFileL( fileName, tempFile );
   970     iWindowManager.DocHandler().OpenTempFileL( fileName, tempFile );
   969     CleanupClosePushL( tempFile );
   971     CleanupClosePushL( tempFile );
   970     iWindowManager.DocHandler().OpenFileEmbeddedL( tempFile,
   972     iWindowManager.DocHandler().OpenFileEmbeddedL( tempFile,
   971                                  dataType,
   973                                  dataType,
  1118 void CWidgetUiWindow::DetermineNetworkState()
  1120 void CWidgetUiWindow::DetermineNetworkState()
  1119     {
  1121     {
  1120     TNetworkState currNetState;
  1122     TNetworkState currNetState;
  1121     RWidgetRegistryClientSession& widgetRegistry = iWindowManager.WidgetUIClientSession();
  1123     RWidgetRegistryClientSession& widgetRegistry = iWindowManager.WidgetUIClientSession();
  1122     TInt inMiniView = widgetRegistry.IsWidgetInMiniView( iUid);
  1124     TInt inMiniView = widgetRegistry.IsWidgetInMiniView( iUid);
  1123     CWidgetPropertyValue* propValue = widgetRegistry.GetWidgetPropertyValueL( iUid, EAllowNetworkAccess ); 
  1125     CWidgetPropertyValue* propValue = widgetRegistry.GetWidgetPropertyValueL( iUid, EAllowNetworkAccess );
  1124     TInt netAccessWdgtProp = *propValue;    // AllowNetworkAccess in the info.plist file
  1126     TInt netAccessWdgtProp = *propValue;    // AllowNetworkAccess in the info.plist file
  1125     
  1127 
  1126     if ( netAccessWdgtProp && ((inMiniView && (iWindowManager.GetNetworkMode() == (TInt)EOnlineMode)) 
  1128     if ( netAccessWdgtProp && ((inMiniView && (iWindowManager.GetNetworkMode() == (TInt)EOnlineMode))
  1127                                     || (!inMiniView && iUserPermission)) )
  1129                                     || (!inMiniView && iUserPermission)) )
  1128         {
  1130         {
  1129         if ( iWindowManager.GetNetworkConn() )
  1131         if ( iWindowManager.GetNetworkConn() )
  1130             {
  1132             {
  1131             currNetState = ENetworkAccessible;
  1133             currNetState = ENetworkAccessible;
  1137         }
  1139         }
  1138     else
  1140     else
  1139         {
  1141         {
  1140         currNetState = ENetworkNotAllowed;
  1142         currNetState = ENetworkNotAllowed;
  1141         }
  1143         }
  1142     
  1144 
  1143     if ( iNetworkState != currNetState )
  1145     if ( iNetworkState != currNetState )
  1144         {
  1146         {
  1145         iNetworkState = currNetState;
  1147         iNetworkState = currNetState;
  1146         // send the new widget network state to widget engine
  1148         // send the new widget network state to widget engine
  1147         iWidgetExtension->SetParamL( TBrCtlDefs::EWidgetNetworkState, (TInt)iNetworkState );
  1149         iWidgetExtension->SetParamL( TBrCtlDefs::EWidgetNetworkState, (TInt)iNetworkState );
  1171             CbaGroup()->ReduceRect(clientRect);
  1173             CbaGroup()->ReduceRect(clientRect);
  1172             }
  1174             }
  1173         //Check if the container rect needs change and then call setRect
  1175         //Check if the container rect needs change and then call setRect
  1174         if(clientRect != iWindowManager.View()->Container()->Rect())
  1176         if(clientRect != iWindowManager.View()->Container()->Rect())
  1175            iWindowManager.View()->Container()->SetRect(clientRect);
  1177            iWindowManager.View()->Container()->SetRect(clientRect);
  1176         
  1178 
  1177         if (!aTextBoxUpdate)
  1179         if (!aTextBoxUpdate)
  1178             {
  1180             {
  1179             // status pane always off unless in text box
  1181             // status pane always off unless in text box
  1180             iWindowManager.View()->UpdateStatusPane(EFalse);
  1182             iWindowManager.View()->UpdateStatusPane(EFalse);
  1181             }
  1183             }