browserui/browser/SettingsSrc/SettingsContainer.cpp
changeset 10 57d5b8e231c4
parent 0 84ad3b177aa3
child 18 4530440261a8
--- a/browserui/browser/SettingsSrc/SettingsContainer.cpp	Mon Mar 30 12:49:49 2009 +0300
+++ b/browserui/browser/SettingsSrc/SettingsContainer.cpp	Fri May 08 08:18:43 2009 +0300
@@ -81,6 +81,7 @@
 _LIT( KSettingsCategoryListBoxItemNoIcon, " " );
 const TInt KDoesntExist = -1;
 const TInt KGranularity = 1;
+const TInt KMaxTitleLength = 512;
 
 
 _LIT( KWmlSettingsListBoxItemPrefix, " \t" );
@@ -418,6 +419,11 @@
     	{
     	AppendDownloadsOpenL( itemArray, itemText );
     	}
+    
+    if( ApiProvider().Preferences().SearchFeature() )
+    	{
+    	AppendSearchProviderL( itemArray, itemText );
+    	}
 
     RestoreListBoxIndexL();
     iSettingListBox->DrawNow();
@@ -686,7 +692,7 @@
         	{
 		    CreateItemFromTwoStringsL( 
 		    R_WMLBROWSER_SETTINGS_DEFAULT_AP, 
-		    R_WML_SETTINGS_ACCESS_POINT_ALWAYS_ASK, 
+		    R_WML_SETTINGS_ACCESS_POINT_ASK_WHEN_NEEDED, 
 		    aItemText );
 		        
 		    break;	
@@ -722,7 +728,7 @@
                     }   
                 }
             
-            HBufC* name = iCoeEnv->AllocReadResourceLC( R_WML_SETTINGS_ACCESS_POINT_ALWAYS_ASK );
+            HBufC* name = iCoeEnv->AllocReadResourceLC( R_WML_SETTINGS_ACCESS_POINT_ASK_WHEN_NEEDED );
             aItemText.Append( *name );
             CleanupStack::PopAndDestroy(); // name
                 
@@ -754,7 +760,7 @@
                 }
             else
                 {
-                HBufC* name = iCoeEnv->AllocReadResourceLC( R_WML_SETTINGS_ACCESS_POINT_ALWAYS_ASK );
+                HBufC* name = iCoeEnv->AllocReadResourceLC( R_WML_SETTINGS_ACCESS_POINT_ASK_WHEN_NEEDED );
                 aItemText.Append( *name );
                 CleanupStack::PopAndDestroy(); // name
                 
@@ -1088,6 +1094,40 @@
     }
 
 
+
+// -----------------------------------------------------------------------------
+// CSettingsContainer::AppendSearchProviderL
+// -----------------------------------------------------------------------------
+void CSettingsContainer::AppendSearchProviderL(
+                                                      CDesCArray*& aItemArray,
+                                                      TBuf<KWmlSettingsItemMaxLength>& aItemText)
+	{
+	aItemText.Zero();
+    aItemText.Append( KWmlSettingsListBoxItemPrefix );
+    HBufC* settingTitle = iCoeEnv->AllocReadResourceLC( R_BROWSERS_SETT_WEB_SEARCH_PROVIDER );
+    aItemText.Append( *settingTitle );
+    CleanupStack::PopAndDestroy(); // settingTitle
+    aItemText.Append( KWmlSettingsListBoxItemPostfix );
+    
+    HBufC* searchProvider = HBufC::NewLC( KMaxTitleLength );
+    TPtr searchProviderPtr = searchProvider->Des();
+    
+    ApiProvider().Preferences().GetStringValueL( KBrowserSearchProviderTitle,
+            KMaxTitleLength , searchProviderPtr);
+    
+    if(searchProvider->Compare(KNullDesC()) == 0)
+    	{
+    	CleanupStack::PopAndDestroy(searchProvider);
+    	searchProvider = iCoeEnv->AllocReadResourceLC( R_IS_LABEL_NOT_SELECTED );
+    	}
+    
+    aItemText.Append( *searchProvider );
+    CleanupStack::PopAndDestroy( searchProvider );
+    
+    aItemArray->AppendL( aItemText );
+    iSettingIndex->AppendL( EWmlSettingsSearchProvider );
+	}
+
 // -----------------------------------------------------------------------------
 // CSettingsContainer::AppendAutoLoadContentL
 // -----------------------------------------------------------------------------
@@ -2515,6 +2555,12 @@
             DisplayGeneralSettingsL();
             break;
     		}
+    		
+        case EWmlSettingsSearchProvider:
+        	{
+ 			RunSearchSettingsL();
+        	break;
+        	}
 
 
 
@@ -3252,6 +3298,7 @@
             	case EWmlSettingsShortCutKey0Cmd:
             	case EWmlSettingsShortCutKeyStarCmd:
             	case EWmlSettingsShortCutKeyHashCmd:
+            	case EWmlSettingsSearchProvider:
                 {
                 	ChangeItemL( ETrue );
                     ret = EKeyWasConsumed;
@@ -3281,6 +3328,11 @@
     return ret;
     }
 
+
+// -----------------------------------------------------------------------------
+// CSettingsContainer::HandleListBoxEventL
+// -----------------------------------------------------------------------------
+//
 void CSettingsContainer::HandleListBoxEventL(CEikListBox* aListBox,TListBoxEvent aEventType)
     {
     if (iPenEnabled)
@@ -3311,6 +3363,22 @@
 
 
 // -----------------------------------------------------------------------------
+// CSettingsContainer::HandleGainingForegroundL
+// -----------------------------------------------------------------------------
+//
+void CSettingsContainer::HandleGainingForegroundL()
+	{
+	switch(iCurrentSettingCategory)
+		{
+		case EGeneral:
+			DisplayGeneralSettingsL();
+			break;
+		default: // do nothing
+			break;
+		}
+	}
+
+// -----------------------------------------------------------------------------
 // CSettingsContainer::CreateItemFromTwoStringsL
 // -----------------------------------------------------------------------------
 //
@@ -3644,4 +3712,19 @@
         }
     }
 
+// -----------------------------------------------------------------------------
+// CSettingsContainer::RunSearchSettingsL
+// -----------------------------------------------------------------------------
+//
+void CSettingsContainer::RunSearchSettingsL()
+    {
+    // Get Search application UID from CenRep 
+    TInt id = ApiProvider().Preferences().GetIntValue( KBrowserSearchAppUid );
+    TUid searchAppId( TUid::Uid( id ) );
+    id = ApiProvider().Preferences().GetIntValue( KBrowserSearchProviderSettingViewId );
+    TUid settingViewId( TUid::Uid( id ) );
+    TVwsViewId viewToOpen(searchAppId, settingViewId);
+    CBrowserAppUi::Static()->ActivateViewL(viewToOpen);
+    } 
+
 // End of File