|
1 /* |
|
2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: CSearchSettingsContainer implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 // INCLUDE FILES |
|
24 #include <appmngrgspluginrsc.rsg> |
|
25 #include <aknlists.h> |
|
26 #include <eikfutil.h> |
|
27 #include <stringloader.h> |
|
28 #include <csxhelp/am.hlp.hrh> |
|
29 #include <centralrepository.h> |
|
30 #include <akniconarray.h> |
|
31 #include <featmgr.h> |
|
32 #include <swinstallerinternalcrkeys.h> |
|
33 #include <data_caging_path_literals.hrh> |
|
34 #include <aknsutils.h> |
|
35 #include <appmngr.mbg> |
|
36 #include "SearchSettingsContainer.h" |
|
37 |
|
38 // LOCAL CONSTANTS AND MACROS |
|
39 |
|
40 |
|
41 const TInt KGranularity = 1; |
|
42 _LIT(KAppMngrIconFileName, "AppMngr.mbm"); |
|
43 _LIT(KAppMngrIconFileNameMif, "AppMngr.mif"); |
|
44 _LIT(KZDrive, "z:"); |
|
45 |
|
46 _LIT(KListTextFormat, "\t%S"); |
|
47 const TInt KMaxCharsForSettingsString = 30; |
|
48 |
|
49 // ================= MEMBER FUNCTIONS ======================= |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CAppMngrContainer::NewL |
|
53 // Two-phased constructor. |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 CSearchSettingsContainer* CSearchSettingsContainer::NewL( const TRect& /*aRect*/ ) |
|
57 { |
|
58 CSearchSettingsContainer* self = new ( ELeave ) CSearchSettingsContainer(); |
|
59 CleanupStack::PushL( self ); |
|
60 CleanupStack::Pop(); |
|
61 return self; |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // Destructor |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 CSearchSettingsContainer::~CSearchSettingsContainer() |
|
69 { |
|
70 delete iListbox; |
|
71 delete iItems; |
|
72 delete iOcspCheckValueArray; |
|
73 delete iAllowUntrustedValueArray; |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // CSearchSettingsContainer::UpdateListBoxContentL |
|
78 // |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 void CSearchSettingsContainer::UpdateListBoxContentL() |
|
82 { |
|
83 |
|
84 if(iListbox) |
|
85 { |
|
86 delete iListbox; |
|
87 iListbox = NULL; |
|
88 } |
|
89 |
|
90 iListbox = new( ELeave ) CAknSettingStyleListBox; |
|
91 iListbox->SetContainerWindowL( *this ); |
|
92 iListbox->SetListBoxObserver( this ); |
|
93 iListbox->ConstructL( this, EAknListBoxLoopScrolling ); |
|
94 |
|
95 _LIT(KSearchSettingString,"In-Device Search"); |
|
96 HBufC* cap; // = " IDS" |
|
97 cap = HBufC::NewL(KMaxCharsForSettingsString); |
|
98 cap->Des().Copy(KSearchSettingString); |
|
99 |
|
100 |
|
101 TBuf<50> first; |
|
102 TBuf<50> listText; |
|
103 TInt i = 0; |
|
104 first.Format(*cap); |
|
105 listText.Format(KListTextFormat,&first); |
|
106 iArray.InsertL(i,listText); |
|
107 const TRect rect( Rect() ); |
|
108 |
|
109 // the list rectangle takes the top left of the screen as (0,0), |
|
110 //that would mean that we have to give the co-ordintes relative to top left corner of the screen |
|
111 |
|
112 TRect listRect(rect.iTl.iX, rect.iTl.iY, |
|
113 rect.Width(), rect.Height()); |
|
114 |
|
115 iListbox->SetRect(listRect); |
|
116 |
|
117 iListbox->CreateScrollBarFrameL( ETrue ); |
|
118 iListbox->ScrollBarFrame() |
|
119 ->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); |
|
120 |
|
121 iListbox->Model()->SetItemTextArray( &iArray );// iModel ); |
|
122 iListbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
123 |
|
124 iListbox->ActivateL(); |
|
125 |
|
126 iListbox->SetCurrentItemIndex( 0 ); |
|
127 iListbox->DrawNow(); |
|
128 } |
|
129 |
|
130 // --------------------------------------------------------------------------- |
|
131 // CSearchSettingsContainer::OfferKeyEventL |
|
132 // This handles the scrolling the list by arrows and the clear key and OK key |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 TKeyResponse CSearchSettingsContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
136 TEventCode aType ) |
|
137 { |
|
138 return iListbox->OfferKeyEventL(aKeyEvent, aType); |
|
139 } |
|
140 |
|
141 // --------------------------------------------------------- |
|
142 // CSearchSettingsContainer::HandleListBoxEventL |
|
143 // Called by framework when the ListBox event is fired. |
|
144 // --------------------------------------------------------- |
|
145 // |
|
146 void CSearchSettingsContainer::HandleListBoxEventL( CEikListBox* , |
|
147 TListBoxEvent aEventType ) |
|
148 { |
|
149 switch ( aEventType ) |
|
150 { |
|
151 case EEventEnterKeyPressed: |
|
152 case EEventItemDoubleClicked: |
|
153 HandleListBoxSelectionL(); |
|
154 break; |
|
155 default: |
|
156 break; |
|
157 } |
|
158 |
|
159 } |
|
160 |
|
161 // --------------------------------------------------------- |
|
162 // CSearchSettingsContainer::HandleListBoxSelectionL |
|
163 // Called by framework when the ListBox item is selected. |
|
164 // --------------------------------------------------------- |
|
165 // |
|
166 void CSearchSettingsContainer::HandleListBoxSelectionL() |
|
167 { |
|
168 |
|
169 } |
|
170 // --------------------------------------------------------------------------- |
|
171 // C++ constructor |
|
172 // --------------------------------------------------------------------------- |
|
173 // |
|
174 CSearchSettingsContainer::CSearchSettingsContainer() |
|
175 : iArray(5) |
|
176 { |
|
177 } |
|
178 |
|
179 // --------------------------------------------------------- |
|
180 // CSearchSettingsContainer::ConstructL |
|
181 // Symbian OS two phased constructor |
|
182 // Creates new window and listbox |
|
183 // --------------------------------------------------------- |
|
184 // |
|
185 void CSearchSettingsContainer::ConstructL( const TRect& aRect ) |
|
186 { |
|
187 CreateWindowL(); |
|
188 SetBlank(); |
|
189 |
|
190 iListbox = new( ELeave ) CAknSettingStyleListBox; |
|
191 |
|
192 iListbox->SetContainerWindowL( *this ); |
|
193 iListbox->SetListBoxObserver( this ); |
|
194 iListbox->ConstructL( this, EAknListBoxSelectionList ); |
|
195 |
|
196 // Read the setting items array (contains first lines of the setting items) |
|
197 iItems = iCoeEnv->ReadDesC16ArrayResourceL( R_MIDP_GENERAL_SETTING_ARRAY ); |
|
198 // read the ocsp check value array |
|
199 iOcspCheckValueArray = iCoeEnv->ReadDesC16ArrayResourceL( R_MIDP_OCSP_CHECK_VALUE_ARRAY ); |
|
200 // read the allow untrusted setting value array |
|
201 iAllowUntrustedValueArray = iCoeEnv->ReadDesC16ArrayResourceL(R_MIDP_ALLOW_UNTRUSTED_VALUE_ARRAY); |
|
202 |
|
203 // set up the listbox |
|
204 iListbox->CreateScrollBarFrameL( ETrue ); |
|
205 iListbox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOn, |
|
206 CEikScrollBarFrame::EAuto ); |
|
207 |
|
208 iListbox->SetRect( aRect.Size() ); |
|
209 iListbox->ActivateL(); |
|
210 |
|
211 SetRect( aRect ); |
|
212 ActivateL(); |
|
213 |
|
214 iListbox->SetCurrentItemIndex( 0 ); |
|
215 |
|
216 LoadIconsL(); |
|
217 } |
|
218 |
|
219 // ----------------------------------------------------------------------------- |
|
220 // CSearchSettingsContainer::LoadIconsL |
|
221 // ----------------------------------------------------------------------------- |
|
222 // |
|
223 void CSearchSettingsContainer::LoadIconsL() |
|
224 { |
|
225 HBufC* iconFilePath = HBufC::NewL(5/*this is enough for drive etc*/ + |
|
226 KDC_APP_BITMAP_DIR().Length() + KAppMngrIconFileName().Length() ); |
|
227 CleanupStack::PushL( iconFilePath ); |
|
228 |
|
229 TPtr ptr = iconFilePath->Des(); |
|
230 ptr.Append(KZDrive); |
|
231 ptr.Append(KDC_APP_BITMAP_DIR); |
|
232 |
|
233 #ifdef __SCALABLE_ICONS |
|
234 ptr.Append(KAppMngrIconFileNameMif); |
|
235 #else // !__SCALABLE_ICONS |
|
236 ptr.Append(KAppMngrIconFileName); |
|
237 #endif //__SCALABLE_ICONS |
|
238 |
|
239 CArrayPtr<CGulIcon>* icons = new( ELeave ) CAknIconArray( KGranularity ); |
|
240 CleanupStack::PushL( icons ); |
|
241 |
|
242 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
|
243 CGulIcon* icon = AknsUtils::CreateGulIconL( skinInstance, |
|
244 KAknsIIDQgnIndiSettProtectedAdd, |
|
245 *iconFilePath, |
|
246 EMbmAppmngrQgn_indi_sett_protected_add, |
|
247 EMbmAppmngrQgn_indi_sett_protected_add_mask ); |
|
248 CleanupStack::PushL( icon ); |
|
249 icons->AppendL( icon ); |
|
250 |
|
251 CleanupStack::Pop( 2 ); // icon, icons |
|
252 CleanupStack::PopAndDestroy(); // iconFilePath |
|
253 } |
|
254 |
|
255 // --------------------------------------------------------- |
|
256 // CSearchSettingsContainer::SizeChanged |
|
257 // Called by framework when the view size is changed |
|
258 // --------------------------------------------------------- |
|
259 // |
|
260 void CSearchSettingsContainer::SizeChanged() |
|
261 { |
|
262 iListbox->SetRect( Rect() ); |
|
263 } |
|
264 |
|
265 // --------------------------------------------------------- |
|
266 // CSearchSettingsContainer::CountComponentControls |
|
267 // --------------------------------------------------------- |
|
268 // |
|
269 TInt CSearchSettingsContainer::CountComponentControls() const |
|
270 { |
|
271 return iListbox ? 1 : 0; |
|
272 } |
|
273 |
|
274 // --------------------------------------------------------- |
|
275 // CSearchSettingsContainer::ComponentControl |
|
276 // --------------------------------------------------------- |
|
277 // |
|
278 CCoeControl* CSearchSettingsContainer::ComponentControl( TInt aIndex ) const |
|
279 { |
|
280 switch ( aIndex ) |
|
281 { |
|
282 case 0: |
|
283 return iListbox; |
|
284 default: |
|
285 return NULL; |
|
286 } |
|
287 } |
|
288 // --------------------------------------------------------------------------- |
|
289 // CSearchSettingsContainer::GetHelpContext |
|
290 // Gives the help context to be displayed |
|
291 // --------------------------------------------------------------------------- |
|
292 // |
|
293 void CSearchSettingsContainer::GetHelpContext( TCoeHelpContext& aContext ) const |
|
294 { |
|
295 aContext.iMajor = KUidAppMngr; |
|
296 aContext.iContext = KAM_HLP_GENERAL_SETTINGS; |
|
297 } |
|
298 |
|
299 |
|
300 // --------------------------------------------------------- |
|
301 // CSearchSettingsContainer::HandleResourceChange |
|
302 // Handles a resource relative event |
|
303 // --------------------------------------------------------- |
|
304 // |
|
305 void CSearchSettingsContainer::HandleResourceChange( TInt aType ) |
|
306 { |
|
307 CCoeControl::HandleResourceChange( aType ); |
|
308 |
|
309 if ( aType == KEikDynamicLayoutVariantSwitch ) //Handle change in layout orientation |
|
310 { |
|
311 TRect mainPaneRect; |
|
312 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); |
|
313 SetRect( mainPaneRect ); |
|
314 DrawNow(); |
|
315 } |
|
316 |
|
317 } |
|
318 |
|
319 // ----------------------------------------------------------------------------- |
|
320 // CSearchSettingsContainer::FocusChanged |
|
321 // ----------------------------------------------------------------------------- |
|
322 // |
|
323 void CSearchSettingsContainer::FocusChanged( TDrawNow aDrawNow ) |
|
324 { |
|
325 if ( iListbox ) |
|
326 { |
|
327 iListbox->SetFocus( IsFocused(), aDrawNow ); |
|
328 } |
|
329 } |
|
330 |
|
331 |
|
332 // End of File |