|
1 /* |
|
2 * Copyright (c) 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: View for Power saving query |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "GSPowerSavingQueryPlugin.h" |
|
21 #include "GSPowerSavingQueryPluginContainer.h" |
|
22 #include "GSPowerSavingQueryPluginModel.h" |
|
23 #include "GSPowerSavingQueryPlugin.hrh" |
|
24 #include "GsLogger.h" |
|
25 #include <GSPowerSavingQueryPlugin.mbg> // icons |
|
26 #include <GSPowerSavingQueryPluginRsc.rsg> |
|
27 #include <gsfwviewuids.h> |
|
28 #include <gsprivatepluginproviderids.h> |
|
29 #include <aknradiobuttonsettingpage.h> |
|
30 #include <aknViewAppUi.h> |
|
31 #include <featmgr.h> |
|
32 #include <StringLoader.h> |
|
33 #include <bautils.h> |
|
34 #include <coeaui.h> |
|
35 #include <gulicon.h> |
|
36 #include <hlplch.h> // for hlplauncher |
|
37 #include <gscommon.hrh> |
|
38 |
|
39 // EXTERNAL DATA STRUCTURES |
|
40 |
|
41 // EXTERNAL FUNCTION PROTOTYPES |
|
42 |
|
43 // CONSTANTS |
|
44 const TInt KGSSettingOff = 0; |
|
45 const TInt KGSSettingOn = 1; |
|
46 const TInt KGSIndexOff = 1; |
|
47 const TInt KGSIndexOn = 0; |
|
48 |
|
49 // MACROS |
|
50 |
|
51 // LOCAL CONSTANTS AND MACROS |
|
52 |
|
53 _LIT( KGSPowerSavingQueryPluginResourceFileName, "z:GSPowerSavingQueryPluginRsc.rsc" ); |
|
54 |
|
55 // MODULE DATA STRUCTURES |
|
56 |
|
57 // LOCAL FUNCTION PROTOTYPES |
|
58 |
|
59 // FORWARD DECLARATIONS |
|
60 |
|
61 // ============================= LOCAL FUNCTIONS ============================== |
|
62 |
|
63 // ========================= MEMBER FUNCTIONS ================================ |
|
64 |
|
65 // ---------------------------------------------------------------------------- |
|
66 // CGSPowerSavingQueryPlugin::CGSPowerSavingQueryPlugin() |
|
67 // |
|
68 // Constructor |
|
69 // ---------------------------------------------------------------------------- |
|
70 // |
|
71 CGSPowerSavingQueryPlugin::CGSPowerSavingQueryPlugin() |
|
72 : iResourceLoader( *iCoeEnv ) |
|
73 { |
|
74 } |
|
75 |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // CGSPowerSavingQueryPlugin::NewL() |
|
79 // |
|
80 // Symbian OS default constructor |
|
81 // --------------------------------------------------------------------------- |
|
82 CGSPowerSavingQueryPlugin* CGSPowerSavingQueryPlugin::NewL( TAny* /*aInitParams*/ ) |
|
83 { |
|
84 CGSPowerSavingQueryPlugin* self = new( ELeave ) CGSPowerSavingQueryPlugin(); |
|
85 |
|
86 CleanupStack::PushL( self ); |
|
87 self->ConstructL(); |
|
88 CleanupStack::Pop(); |
|
89 |
|
90 return self; |
|
91 } |
|
92 |
|
93 |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // CGSPowerSavingQueryPlugin::ConstructL() |
|
97 // |
|
98 // Symbian OS two-phased constructor |
|
99 // --------------------------------------------------------------------------- |
|
100 void CGSPowerSavingQueryPlugin::ConstructL() |
|
101 { |
|
102 FeatureManager::InitializeLibL(); |
|
103 // Find the resource file |
|
104 TParse parse; |
|
105 parse.Set( KGSPowerSavingQueryPluginResourceFileName, |
|
106 &KDC_RESOURCE_FILES_DIR, NULL ); |
|
107 TFileName fileName( parse.FullName() ); |
|
108 |
|
109 // Get language of resource file |
|
110 BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), fileName ); |
|
111 |
|
112 // Open resource file |
|
113 iResourceLoader.OpenL( fileName ); |
|
114 |
|
115 BaseConstructL( R_GS_POWER_SAVING_QUERY_VIEW ); |
|
116 } |
|
117 |
|
118 |
|
119 // ---------------------------------------------------------------------------- |
|
120 // CGSPowerSavingQueryPlugin::~CGSPowerSavingQueryPlugin |
|
121 // |
|
122 // Destructor |
|
123 // ---------------------------------------------------------------------------- |
|
124 CGSPowerSavingQueryPlugin::~CGSPowerSavingQueryPlugin() |
|
125 { |
|
126 FeatureManager::UnInitializeLib(); |
|
127 iResourceLoader.Close(); |
|
128 } |
|
129 |
|
130 |
|
131 // --------------------------------------------------------------------------- |
|
132 // TUid CGSPowerSavingQueryPlugin::Id() |
|
133 // |
|
134 // Returns view's ID. |
|
135 // --------------------------------------------------------------------------- |
|
136 TUid CGSPowerSavingQueryPlugin::Id() const |
|
137 { |
|
138 return KGSPowerSavingQueryPluginUid; |
|
139 } |
|
140 |
|
141 |
|
142 // ========================= From CGSPluginInterface ================== |
|
143 |
|
144 // ---------------------------------------------------------------------------- |
|
145 // CGSPowerSavingQueryPlugin::GetCaption |
|
146 // |
|
147 // Return application/view caption. |
|
148 // ---------------------------------------------------------------------------- |
|
149 // |
|
150 void CGSPowerSavingQueryPlugin::GetCaptionL( TDes& aCaption ) const |
|
151 { |
|
152 // the resource file is already opened. |
|
153 HBufC* result = StringLoader::LoadL( R_GS_POWER_SAVING_QUERY_VIEW_CAPTION ); |
|
154 |
|
155 aCaption.Copy( *result ); |
|
156 delete result; |
|
157 } |
|
158 |
|
159 |
|
160 // ---------------------------------------------------------------------------- |
|
161 // CGSPowerSavingQueryPlugin::PluginProviderCategory |
|
162 // |
|
163 // A means to identify the location of this plug-in in the framework. |
|
164 // ---------------------------------------------------------------------------- |
|
165 // |
|
166 TInt CGSPowerSavingQueryPlugin::PluginProviderCategory() const |
|
167 { |
|
168 //To identify internal plug-ins. |
|
169 return KGSPluginProviderInternal; |
|
170 } |
|
171 |
|
172 |
|
173 // ---------------------------------------------------------------------------- |
|
174 // CGSPowerSavingQueryPlugin::Visible |
|
175 // |
|
176 // Provides the visibility status of self to framework. |
|
177 // ---------------------------------------------------------------------------- |
|
178 // |
|
179 TBool CGSPowerSavingQueryPlugin::Visible() const |
|
180 { |
|
181 return ETrue; |
|
182 } |
|
183 |
|
184 |
|
185 // --------------------------------------------------------------------------- |
|
186 // CGSPowerSavingQueryPlugin::HandleCommandL(TInt aCommand) |
|
187 // |
|
188 // Handles commands directed to this class. |
|
189 // --------------------------------------------------------------------------- |
|
190 void CGSPowerSavingQueryPlugin::HandleCommandL( TInt aCommand ) |
|
191 { |
|
192 switch ( aCommand ) |
|
193 { |
|
194 case EGSMSKCmdAppChange: |
|
195 HandleListBoxSelectionL(); |
|
196 break; |
|
197 case EGSCmdAppChange: |
|
198 ShowSettingPageL(); |
|
199 break; |
|
200 case EAknSoftkeyBack: |
|
201 iAppUi->ActivateLocalViewL( KGSDeviceManagementPluginUid ); |
|
202 break; |
|
203 case EAknCmdHelp: |
|
204 { |
|
205 if( FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
206 { |
|
207 HlpLauncher::LaunchHelpApplicationL( |
|
208 iEikonEnv->WsSession(), iAppUi->AppHelpContextL() ); |
|
209 } |
|
210 break; |
|
211 } |
|
212 default: |
|
213 iAppUi->HandleCommandL( aCommand ); |
|
214 break; |
|
215 } |
|
216 } |
|
217 |
|
218 |
|
219 // --------------------------------------------------------------------------- |
|
220 // CGSPowerSavingQueryPlugin::UpdateListBoxL |
|
221 // |
|
222 // Updates listbox items. |
|
223 // --------------------------------------------------------------------------- |
|
224 // |
|
225 void CGSPowerSavingQueryPlugin::UpdateListBoxL( TInt aItemId ) |
|
226 { |
|
227 if( Container() ) |
|
228 { |
|
229 Container()->UpdateListBoxL( aItemId ); |
|
230 } |
|
231 } |
|
232 |
|
233 |
|
234 // ---------------------------------------------------------------------------- |
|
235 // CGSPowerSavingQueryPlugin::Container |
|
236 // |
|
237 // Return handle to container class. |
|
238 // ---------------------------------------------------------------------------- |
|
239 // |
|
240 CGSPowerSavingQueryPluginContainer* CGSPowerSavingQueryPlugin::Container() |
|
241 { |
|
242 return static_cast<CGSPowerSavingQueryPluginContainer*>( iContainer ); |
|
243 } |
|
244 |
|
245 |
|
246 // --------------------------------------------------------------------------- |
|
247 // CGSPowerSavingQueryPlugin::NewContainerL() |
|
248 // |
|
249 // Creates new iContainer. |
|
250 // --------------------------------------------------------------------------- |
|
251 // |
|
252 void CGSPowerSavingQueryPlugin::NewContainerL() |
|
253 { |
|
254 iContainer = new( ELeave ) CGSPowerSavingQueryPluginContainer; |
|
255 } |
|
256 |
|
257 |
|
258 // --------------------------------------------------------------------------- |
|
259 // CGSPowerSavingQueryPlugin::DoActivateL() |
|
260 // |
|
261 // From CAknView |
|
262 // --------------------------------------------------------------------------- |
|
263 // |
|
264 void CGSPowerSavingQueryPlugin::DoActivateL( const TVwsViewId& aPrevViewId, |
|
265 TUid aCustomMessageId, |
|
266 const TDesC8& aCustomMessage ) |
|
267 { |
|
268 __GSLOGSTRING("[CGSPowerSavingQueryPlugin]-->CGSPowerSavingQueryPlugin::DoActivateL"); |
|
269 |
|
270 CGSBaseView::DoActivateL( aPrevViewId, aCustomMessageId, aCustomMessage ); |
|
271 |
|
272 __GSLOGSTRING("[CGSPowerSavingQueryPlugin]<--CGSPowerSavingQueryPlugin::DoActivateL"); |
|
273 } |
|
274 |
|
275 // --------------------------------------------------------------------------- |
|
276 // CGSPowerSavingQueryPlugin::DoActivateL() |
|
277 // |
|
278 // From CAknView |
|
279 // --------------------------------------------------------------------------- |
|
280 // |
|
281 void CGSPowerSavingQueryPlugin::DoDeactivate() |
|
282 { |
|
283 CGSBaseView::DoDeactivate(); |
|
284 } |
|
285 |
|
286 // --------------------------------------------------------------------------- |
|
287 // CGSPowerSavingQueryPlugin::HandleListBoxSelectionL() |
|
288 // |
|
289 // Handles events raised through a rocker key. |
|
290 // --------------------------------------------------------------------------- |
|
291 void CGSPowerSavingQueryPlugin::HandleListBoxSelectionL() |
|
292 { |
|
293 CGSPowerSavingQueryPluginModel* model = Container()->Model(); |
|
294 |
|
295 TInt queryValue( model->PowerSavingQueryEnabled() ); |
|
296 |
|
297 if ( EGSPowerSavingQueryOn == queryValue ) |
|
298 { |
|
299 queryValue = EGSPowerSavingQueryOff; |
|
300 } |
|
301 else |
|
302 { |
|
303 queryValue = EGSPowerSavingQueryOn; |
|
304 } |
|
305 |
|
306 model->EnablePowerSavingQuery( queryValue ); |
|
307 |
|
308 UpdateListBoxL( KGSSettIdPowerSavingQuery ); |
|
309 } |
|
310 |
|
311 |
|
312 |
|
313 // --------------------------------------------------------------------------- |
|
314 // CGSPowerSavingQueryPlugin::ShowDialupAutodisconSettingPageL |
|
315 // |
|
316 // Display dialup auto disconnect setting page. |
|
317 // --------------------------------------------------------------------------- |
|
318 // |
|
319 void CGSPowerSavingQueryPlugin::ShowSettingPageL() |
|
320 { |
|
321 TBool queryValue = Container()->Model()->PowerSavingQueryEnabled(); |
|
322 |
|
323 SwitchOnOffValue( queryValue ); |
|
324 |
|
325 CDesCArrayFlat* items = iCoeEnv->ReadDesC16ArrayResourceL( |
|
326 R_POWER_SAVING_QUERY_SETTING_PAGE_LBX ); |
|
327 CleanupStack::PushL( items ); |
|
328 |
|
329 CAknRadioButtonSettingPage* dlg = new( ELeave ) CAknRadioButtonSettingPage( |
|
330 R_POWER_SAVING_QUERY_SETTING_PAGE, queryValue, items ); |
|
331 |
|
332 if ( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged ) ) |
|
333 { |
|
334 SwitchOnOffValue( queryValue ); |
|
335 Container()->Model()->EnablePowerSavingQuery( queryValue ); |
|
336 UpdateListBoxL( KGSSettIdPowerSavingQuery ); |
|
337 } |
|
338 |
|
339 CleanupStack::PopAndDestroy( items ); |
|
340 } |
|
341 |
|
342 // ----------------------------------------------------------------------------- |
|
343 // CGSPowerSavingQueryPlugin::CreateIconL() |
|
344 // |
|
345 // |
|
346 // ----------------------------------------------------------------------------- |
|
347 // |
|
348 CGulIcon* CGSPowerSavingQueryPlugin::CreateIconL( const TUid aIconType ) |
|
349 { |
|
350 CGulIcon* icon; |
|
351 TParse* fp = new( ELeave ) TParse(); |
|
352 CleanupStack::PushL( fp ); |
|
353 fp->Set( KGSPowerSavingQueryPluginIconDirAndName, &KDC_BITMAP_DIR, NULL ); |
|
354 |
|
355 if( aIconType == KGSIconTypeLbxItem ) |
|
356 { |
|
357 icon = AknsUtils::CreateGulIconL( |
|
358 AknsUtils::SkinInstance(), |
|
359 KAknsIIDQgnPropCpDevPsActivate, |
|
360 fp->FullName(), |
|
361 EMbmGspowersavingquerypluginQgn_prop_cp_dev_ps_activate, |
|
362 EMbmGspowersavingquerypluginQgn_prop_cp_dev_ps_activate_mask ); |
|
363 } |
|
364 else |
|
365 { |
|
366 icon = CGSPluginInterface::CreateIconL( aIconType ); |
|
367 } |
|
368 |
|
369 CleanupStack::PopAndDestroy( fp ); |
|
370 |
|
371 return icon; |
|
372 |
|
373 } |
|
374 |
|
375 |
|
376 // ----------------------------------------------------------------------------- |
|
377 // CGSPowerSavingQueryPlugin::DynInitMenuPaneL() |
|
378 // |
|
379 // dynamically handle help item if not supported |
|
380 // ----------------------------------------------------------------------------- |
|
381 // |
|
382 void CGSPowerSavingQueryPlugin::DynInitMenuPaneL( TInt aResourceId, |
|
383 CEikMenuPane* aMenuPane ) |
|
384 { |
|
385 if( aResourceId == R_GS_MENU_ITEM_HELP ) |
|
386 { |
|
387 User::LeaveIfNull( aMenuPane ); |
|
388 |
|
389 aMenuPane->SetItemDimmed( EAknCmdHelp, |
|
390 !FeatureManager::FeatureSupported( KFeatureIdHelp ) ); |
|
391 } |
|
392 } |
|
393 // ----------------------------------------------------------------------------- |
|
394 // CGSPowerSavingQueryPlugin::SwitchOnOffValue() |
|
395 // |
|
396 // |
|
397 // ----------------------------------------------------------------------------- |
|
398 // |
|
399 void CGSPowerSavingQueryPlugin::SwitchOnOffValue( TInt& aValue ) |
|
400 { |
|
401 if ( aValue == KGSSettingOn ) |
|
402 { |
|
403 aValue = KGSIndexOn; |
|
404 } |
|
405 else if ( aValue == KGSSettingOff ) |
|
406 { |
|
407 aValue = KGSIndexOff; |
|
408 } |
|
409 } |
|
410 |
|
411 // End of File |