1 /* |
|
2 * Copyright (c) 2003-2009 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: AppMngr2 GS (General Settings) Settings plug-in Container |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "appmngr2gssettingscontainer.h" // CAppMngr2GSSettingsContainer |
|
20 #include <aknlists.h> // CAknSettingStyleListBox |
|
21 #include <centralrepository.h> // CRepository |
|
22 #include <AknIconArray.h> // CAknIconArray |
|
23 #include <featmgr.h> // FeatureManager |
|
24 #include <SWInstallerInternalCRKeys.h> // KCRUidSWInstallerSettings |
|
25 #include <data_caging_path_literals.hrh> // KDC_RESOURCE_FILES_DIR |
|
26 #include <appmngr2gssettingspluginrsc.rsg> // Resource IDs |
|
27 #include <appmngr2.mbg> // Bitmap IDs |
|
28 #include <csxhelp/am.hlp.hrh> // Help IDs |
|
29 |
|
30 const TInt KNumStrSize = 1; // Buffer size for string which has one number |
|
31 const TInt KGranularity = 1; |
|
32 const TInt KMaxSettingsItemLength = 128 + NCentralRepositoryConstants::KMaxUnicodeStringLength; |
|
33 |
|
34 _LIT( KAppMngrTab, "\t"); |
|
35 _LIT( KAppMngr2IconFileNameMif, "appmngr2.mif" ); |
|
36 _LIT( KDriveZ, "z:" ); |
|
37 |
|
38 // ======== MEMBER FUNCTIONS ======== |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // CAppMngr2GSSettingsContainer::NewL() |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 CAppMngr2GSSettingsContainer* CAppMngr2GSSettingsContainer::NewL( const TRect& aRect ) |
|
45 { |
|
46 CAppMngr2GSSettingsContainer* self = new ( ELeave ) CAppMngr2GSSettingsContainer(); |
|
47 CleanupStack::PushL( self ); |
|
48 self->ConstructL( aRect ); |
|
49 CleanupStack::Pop( self ); |
|
50 return self; |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // CAppMngr2GSSettingsContainer::~CAppMngr2GSSettingsContainer() |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 CAppMngr2GSSettingsContainer::~CAppMngr2GSSettingsContainer() |
|
58 { |
|
59 delete iListbox; |
|
60 delete iItems; |
|
61 delete iOcspCheckValueArray; |
|
62 delete iAllowUntrustedValueArray; |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // CAppMngr2GSSettingsContainer::ListBox() |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 CAknSettingStyleListBox* CAppMngr2GSSettingsContainer::ListBox() const |
|
70 { |
|
71 return iListbox; |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // CAppMngr2GSSettingsContainer::UpdateListBoxContentL() |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 void CAppMngr2GSSettingsContainer::UpdateListBoxContentL() |
|
79 { |
|
80 TInt ocsp_check_value = 0; |
|
81 HBufC* ocsp_url = HBufC::NewLC( NCentralRepositoryConstants::KMaxUnicodeStringLength ); |
|
82 TPtr ocsp_url_value( ocsp_url->Des() ); |
|
83 ocsp_url_value.Zero(); |
|
84 TInt allowUntrustedValue( 0 ); |
|
85 |
|
86 // Must save listbox indexes because content will be deleted |
|
87 TInt lastListBoxPos = iListbox->CurrentItemIndex(); |
|
88 TInt lastListBoxTopPos = iListbox->TopItemIndex(); |
|
89 |
|
90 MDesCArray* itemList = iListbox->Model()->ItemTextArray(); |
|
91 CDesCArray* itemArray = static_cast<CDesCArray*>( itemList ); |
|
92 itemArray->Reset(); |
|
93 |
|
94 // Get data from Central repository |
|
95 CRepository* repDB = CRepository::NewLC( KCRUidSWInstallerSettings ); |
|
96 repDB->Get( KSWInstallerOcspProcedure, ocsp_check_value ); |
|
97 repDB->Get( KSWInstallerOcspDefaultURL, ocsp_url_value ); |
|
98 if( ocsp_url_value.Length() == 0 ) |
|
99 { |
|
100 // If OCSP URL is empty string add the default text "none" |
|
101 iCoeEnv->ReadResourceAsDes16L( ocsp_url_value, R_AM_SET_OCSP_NONE ); |
|
102 } |
|
103 repDB->Get( KSWInstallerAllowUntrusted, allowUntrustedValue ); |
|
104 if( allowUntrustedValue ) |
|
105 { |
|
106 allowUntrustedValue = 1; |
|
107 } |
|
108 CleanupStack::PopAndDestroy( repDB ); |
|
109 |
|
110 switch( ocsp_check_value ) |
|
111 { |
|
112 case ESWInstallerOcspProcedureOff: |
|
113 ocsp_check_value = EAppMngr2OcspCheckValueArrayOff; |
|
114 break; |
|
115 case ESWInstallerOcspProcedureOn: |
|
116 ocsp_check_value = EAppMngr2OcspCheckValueArrayOn; |
|
117 break; |
|
118 case ESWInstallerOcspProcedureMust: |
|
119 ocsp_check_value = EAppMngr2OcspCheckValueArrayMustPass; |
|
120 break; |
|
121 default: |
|
122 break; |
|
123 } |
|
124 |
|
125 HBufC* itemValue = HBufC::NewLC( KMaxSettingsItemLength ); |
|
126 TPtr itemPtr = itemValue->Des(); |
|
127 itemPtr = ( *iItems )[ EAppMngr2SettingSwInstall ]; |
|
128 |
|
129 // Check variation |
|
130 TInt hideAllowUntrusted( 1 ); |
|
131 CRepository* variationDB = CRepository::NewLC( KCRUidSWInstallerLV ); |
|
132 variationDB->Get( KSWInstallerHideUntrustedIns, hideAllowUntrusted ); |
|
133 CleanupStack::PopAndDestroy( variationDB ); |
|
134 |
|
135 if( !hideAllowUntrusted ) |
|
136 { |
|
137 itemPtr.Zero(); |
|
138 itemPtr = ( *iItems )[ EAppMngr2SettingSwInstall ]; |
|
139 itemPtr += ( *iAllowUntrustedValueArray )[ allowUntrustedValue ]; |
|
140 itemArray->AppendL( itemPtr ); |
|
141 } |
|
142 |
|
143 if( !FeatureManager::FeatureSupported( KFeatureIdOCSP ) ) |
|
144 { |
|
145 // If OCSP feature is not supported, OCSP settings can not be changed |
|
146 // --> lock icon is added |
|
147 TBuf<KNumStrSize> strNum; |
|
148 strNum.Num( 0 ); |
|
149 |
|
150 // If lock icon is wanted to be shown, the string format must be: |
|
151 // " \tSetting label\t\tSetting value\t\t\t0" |
|
152 |
|
153 itemPtr.Zero(); |
|
154 itemPtr = ( *iItems )[ EAppMngr2SettingOcsp ]; |
|
155 itemPtr += ( *iOcspCheckValueArray )[ ocsp_check_value ]; |
|
156 itemPtr += KAppMngrTab; |
|
157 itemPtr += KAppMngrTab; |
|
158 itemPtr += KAppMngrTab; |
|
159 itemPtr.Append( strNum ); |
|
160 itemArray->AppendL( itemPtr ); |
|
161 |
|
162 itemPtr.Zero(); |
|
163 itemPtr = ( *iItems )[ EAppMngr2SettingOcspUrl ]; |
|
164 itemPtr += ocsp_url_value; |
|
165 itemPtr += KAppMngrTab; |
|
166 itemPtr += KAppMngrTab; |
|
167 itemPtr += KAppMngrTab; |
|
168 itemPtr.Append( strNum ); |
|
169 itemArray->AppendL( itemPtr ); |
|
170 } |
|
171 else |
|
172 { |
|
173 itemPtr.Zero(); |
|
174 itemPtr = ( *iItems )[ EAppMngr2SettingOcsp ]; |
|
175 itemPtr += ( *iOcspCheckValueArray )[ ocsp_check_value ]; |
|
176 itemArray->AppendL( itemPtr ); |
|
177 |
|
178 itemPtr.Zero(); |
|
179 itemPtr = ( *iItems )[ EAppMngr2SettingOcspUrl ]; |
|
180 itemPtr += ocsp_url_value; |
|
181 itemArray->AppendL( itemPtr ); |
|
182 } |
|
183 |
|
184 CleanupStack::PopAndDestroy( itemValue ); |
|
185 // Handle content changes |
|
186 iListbox->Reset(); |
|
187 // Listbox might not have index |
|
188 if( lastListBoxPos != -1 ) |
|
189 { |
|
190 iListbox->SetCurrentItemIndex( lastListBoxPos ); |
|
191 iListbox->SetTopItemIndex( lastListBoxTopPos ); |
|
192 } |
|
193 |
|
194 CleanupStack::PopAndDestroy( ocsp_url ); |
|
195 |
|
196 // Call after addition to ensure that the list dialog is updated correctly. |
|
197 iListbox->HandleItemAdditionL(); |
|
198 } |
|
199 |
|
200 // --------------------------------------------------------------------------- |
|
201 // CAppMngr2GSSettingsContainer::OfferKeyEventL() |
|
202 // --------------------------------------------------------------------------- |
|
203 // |
|
204 TKeyResponse CAppMngr2GSSettingsContainer::OfferKeyEventL( |
|
205 const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
206 { |
|
207 return iListbox->OfferKeyEventL(aKeyEvent, aType); |
|
208 } |
|
209 |
|
210 // --------------------------------------------------------------------------- |
|
211 // CAppMngr2GSSettingsContainer::CAppMngr2GSSettingsContainer() |
|
212 // --------------------------------------------------------------------------- |
|
213 // |
|
214 CAppMngr2GSSettingsContainer::CAppMngr2GSSettingsContainer() |
|
215 { |
|
216 } |
|
217 |
|
218 // --------------------------------------------------------------------------- |
|
219 // CAppMngr2GSSettingsContainer::ConstructL() |
|
220 // --------------------------------------------------------------------------- |
|
221 // |
|
222 void CAppMngr2GSSettingsContainer::ConstructL( const TRect& aRect ) |
|
223 { |
|
224 CreateWindowL(); |
|
225 |
|
226 iListbox = new( ELeave ) CAknSettingStyleListBox; |
|
227 |
|
228 iListbox->SetContainerWindowL( *this ); |
|
229 iListbox->ConstructL( this, EAknListBoxSelectionList ); |
|
230 |
|
231 // Read the setting items array (contains first lines of the setting items) |
|
232 iItems = iCoeEnv->ReadDesC16ArrayResourceL( R_APPMNGR2_SETTING_ARRAY ); |
|
233 iOcspCheckValueArray = iCoeEnv->ReadDesC16ArrayResourceL( |
|
234 R_APPMNGR2_OCSP_CHECK_VALUE_ARRAY ); |
|
235 iAllowUntrustedValueArray = iCoeEnv->ReadDesC16ArrayResourceL( |
|
236 R_APPMNGR2_ALLOW_UNTRUSTED_VALUE_ARRAY ); |
|
237 |
|
238 iListbox->CreateScrollBarFrameL( ETrue ); |
|
239 iListbox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOn, |
|
240 CEikScrollBarFrame::EAuto ); |
|
241 iListbox->SetRect( aRect.Size() ); |
|
242 iListbox->ActivateL(); |
|
243 SetRect( aRect ); |
|
244 ActivateL(); |
|
245 |
|
246 iListbox->SetCurrentItemIndex( EAppMngr2SettingSwInstall ); |
|
247 if( !FeatureManager::FeatureSupported( KFeatureIdOCSP ) ) |
|
248 { |
|
249 LoadIconsL(); |
|
250 } |
|
251 } |
|
252 |
|
253 // --------------------------------------------------------------------------- |
|
254 // CAppMngr2GSSettingsContainer::LoadIconsL() |
|
255 // --------------------------------------------------------------------------- |
|
256 // |
|
257 void CAppMngr2GSSettingsContainer::LoadIconsL() |
|
258 { |
|
259 HBufC* iconFilePath = HBufC::NewL( KDriveZ().Length() + |
|
260 KDC_APP_BITMAP_DIR().Length() + KAppMngr2IconFileNameMif().Length() ); |
|
261 CleanupStack::PushL( iconFilePath ); |
|
262 |
|
263 TPtr ptr = iconFilePath->Des(); |
|
264 ptr.Append( KDriveZ ); |
|
265 ptr.Append( KDC_APP_BITMAP_DIR ); |
|
266 ptr.Append( KAppMngr2IconFileNameMif ); |
|
267 |
|
268 CArrayPtr<CGulIcon>* icons = new ( ELeave ) CAknIconArray( KGranularity ); |
|
269 CleanupStack::PushL( icons ); |
|
270 |
|
271 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
|
272 CGulIcon* icon = AknsUtils::CreateGulIconL( skinInstance, |
|
273 KAknsIIDQgnIndiSettProtectedAdd, *iconFilePath, |
|
274 EMbmAppmngr2Qgn_indi_sett_protected_add, |
|
275 EMbmAppmngr2Qgn_indi_sett_protected_add_mask ); |
|
276 CleanupStack::PushL( icon ); |
|
277 icons->AppendL( icon ); |
|
278 |
|
279 iListbox->ItemDrawer()->FormattedCellData()->SetIconArrayL( icons ); |
|
280 |
|
281 CleanupStack::Pop( icon ); |
|
282 CleanupStack::Pop( icons ); |
|
283 CleanupStack::PopAndDestroy( iconFilePath ); |
|
284 } |
|
285 |
|
286 // --------------------------------------------------------------------------- |
|
287 // CAppMngr2GSSettingsContainer::SizeChanged() |
|
288 // --------------------------------------------------------------------------- |
|
289 // |
|
290 void CAppMngr2GSSettingsContainer::SizeChanged() |
|
291 { |
|
292 iListbox->SetRect( Rect() ); |
|
293 } |
|
294 |
|
295 // --------------------------------------------------------------------------- |
|
296 // CAppMngr2GSSettingsContainer::FocusChanged() |
|
297 // --------------------------------------------------------------------------- |
|
298 // |
|
299 void CAppMngr2GSSettingsContainer::FocusChanged( TDrawNow aDrawNow ) |
|
300 { |
|
301 if( iListbox ) |
|
302 { |
|
303 iListbox->SetFocus( IsFocused(), aDrawNow ); |
|
304 } |
|
305 } |
|
306 // --------------------------------------------------------------------------- |
|
307 // CAppMngr2GSSettingsContainer::CountComponentControls() |
|
308 // --------------------------------------------------------------------------- |
|
309 // |
|
310 TInt CAppMngr2GSSettingsContainer::CountComponentControls() const |
|
311 { |
|
312 return iListbox ? 1 : 0; |
|
313 } |
|
314 |
|
315 // --------------------------------------------------------------------------- |
|
316 // CAppMngr2GSSettingsContainer::ComponentControl() |
|
317 // --------------------------------------------------------------------------- |
|
318 // |
|
319 CCoeControl* CAppMngr2GSSettingsContainer::ComponentControl( TInt aIndex ) const |
|
320 { |
|
321 switch ( aIndex ) |
|
322 { |
|
323 case 0: |
|
324 return iListbox; |
|
325 default: |
|
326 return NULL; |
|
327 } |
|
328 } |
|
329 |
|
330 // --------------------------------------------------------------------------- |
|
331 // CAppMngr2GSSettingsContainer::GetHelpContext() |
|
332 // --------------------------------------------------------------------------- |
|
333 // |
|
334 void CAppMngr2GSSettingsContainer::GetHelpContext( TCoeHelpContext& aContext ) const |
|
335 { |
|
336 aContext.iMajor = KAppMngr2AppUid; |
|
337 aContext.iContext = KAM_HLP_GENERAL_SETTINGS; |
|
338 } |
|
339 |
|
340 // --------------------------------------------------------------------------- |
|
341 // CAppMngr2GSSettingsContainer::HandleResourceChange() |
|
342 // --------------------------------------------------------------------------- |
|
343 // |
|
344 void CAppMngr2GSSettingsContainer::HandleResourceChange( TInt aType ) |
|
345 { |
|
346 CCoeControl::HandleResourceChange( aType ); |
|
347 |
|
348 if( aType == KEikDynamicLayoutVariantSwitch ) //Handle change in layout orientation |
|
349 { |
|
350 TRect mainPaneRect; |
|
351 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); |
|
352 SetRect( mainPaneRect ); |
|
353 DrawNow(); |
|
354 } |
|
355 } |
|
356 |
|