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 default: |
|
204 iAppUi->HandleCommandL( aCommand ); |
|
205 break; |
|
206 } |
|
207 } |
|
208 |
|
209 |
|
210 // --------------------------------------------------------------------------- |
|
211 // CGSPowerSavingQueryPlugin::UpdateListBoxL |
|
212 // |
|
213 // Updates listbox items. |
|
214 // --------------------------------------------------------------------------- |
|
215 // |
|
216 void CGSPowerSavingQueryPlugin::UpdateListBoxL( TInt aItemId ) |
|
217 { |
|
218 if( Container() ) |
|
219 { |
|
220 Container()->UpdateListBoxL( aItemId ); |
|
221 } |
|
222 } |
|
223 |
|
224 |
|
225 // ---------------------------------------------------------------------------- |
|
226 // CGSPowerSavingQueryPlugin::Container |
|
227 // |
|
228 // Return handle to container class. |
|
229 // ---------------------------------------------------------------------------- |
|
230 // |
|
231 CGSPowerSavingQueryPluginContainer* CGSPowerSavingQueryPlugin::Container() |
|
232 { |
|
233 return static_cast<CGSPowerSavingQueryPluginContainer*>( iContainer ); |
|
234 } |
|
235 |
|
236 |
|
237 // --------------------------------------------------------------------------- |
|
238 // CGSPowerSavingQueryPlugin::NewContainerL() |
|
239 // |
|
240 // Creates new iContainer. |
|
241 // --------------------------------------------------------------------------- |
|
242 // |
|
243 void CGSPowerSavingQueryPlugin::NewContainerL() |
|
244 { |
|
245 iContainer = new( ELeave ) CGSPowerSavingQueryPluginContainer; |
|
246 } |
|
247 |
|
248 |
|
249 // --------------------------------------------------------------------------- |
|
250 // CGSPowerSavingQueryPlugin::DoActivateL() |
|
251 // |
|
252 // From CAknView |
|
253 // --------------------------------------------------------------------------- |
|
254 // |
|
255 void CGSPowerSavingQueryPlugin::DoActivateL( const TVwsViewId& aPrevViewId, |
|
256 TUid aCustomMessageId, |
|
257 const TDesC8& aCustomMessage ) |
|
258 { |
|
259 __GSLOGSTRING("[CGSPowerSavingQueryPlugin]-->CGSPowerSavingQueryPlugin::DoActivateL"); |
|
260 |
|
261 CGSBaseView::DoActivateL( aPrevViewId, aCustomMessageId, aCustomMessage ); |
|
262 |
|
263 __GSLOGSTRING("[CGSPowerSavingQueryPlugin]<--CGSPowerSavingQueryPlugin::DoActivateL"); |
|
264 } |
|
265 |
|
266 // --------------------------------------------------------------------------- |
|
267 // CGSPowerSavingQueryPlugin::DoActivateL() |
|
268 // |
|
269 // From CAknView |
|
270 // --------------------------------------------------------------------------- |
|
271 // |
|
272 void CGSPowerSavingQueryPlugin::DoDeactivate() |
|
273 { |
|
274 CGSBaseView::DoDeactivate(); |
|
275 } |
|
276 |
|
277 // --------------------------------------------------------------------------- |
|
278 // CGSPowerSavingQueryPlugin::HandleListBoxSelectionL() |
|
279 // |
|
280 // Handles events raised through a rocker key. |
|
281 // --------------------------------------------------------------------------- |
|
282 void CGSPowerSavingQueryPlugin::HandleListBoxSelectionL() |
|
283 { |
|
284 CGSPowerSavingQueryPluginModel* model = Container()->Model(); |
|
285 |
|
286 TInt queryValue( model->PowerSavingQueryEnabled() ); |
|
287 |
|
288 if ( EGSPowerSavingQueryOn == queryValue ) |
|
289 { |
|
290 queryValue = EGSPowerSavingQueryOff; |
|
291 } |
|
292 else |
|
293 { |
|
294 queryValue = EGSPowerSavingQueryOn; |
|
295 } |
|
296 |
|
297 model->EnablePowerSavingQuery( queryValue ); |
|
298 |
|
299 UpdateListBoxL( KGSSettIdPowerSavingQuery ); |
|
300 } |
|
301 |
|
302 |
|
303 |
|
304 // --------------------------------------------------------------------------- |
|
305 // CGSPowerSavingQueryPlugin::ShowDialupAutodisconSettingPageL |
|
306 // |
|
307 // Display dialup auto disconnect setting page. |
|
308 // --------------------------------------------------------------------------- |
|
309 // |
|
310 void CGSPowerSavingQueryPlugin::ShowSettingPageL() |
|
311 { |
|
312 TBool queryValue = Container()->Model()->PowerSavingQueryEnabled(); |
|
313 |
|
314 SwitchOnOffValue( queryValue ); |
|
315 |
|
316 CDesCArrayFlat* items = iCoeEnv->ReadDesC16ArrayResourceL( |
|
317 R_POWER_SAVING_QUERY_SETTING_PAGE_LBX ); |
|
318 CleanupStack::PushL( items ); |
|
319 |
|
320 CAknRadioButtonSettingPage* dlg = new( ELeave ) CAknRadioButtonSettingPage( |
|
321 R_POWER_SAVING_QUERY_SETTING_PAGE, queryValue, items ); |
|
322 |
|
323 if ( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged ) ) |
|
324 { |
|
325 SwitchOnOffValue( queryValue ); |
|
326 Container()->Model()->EnablePowerSavingQuery( queryValue ); |
|
327 UpdateListBoxL( KGSSettIdPowerSavingQuery ); |
|
328 } |
|
329 |
|
330 CleanupStack::PopAndDestroy( items ); |
|
331 } |
|
332 |
|
333 // ----------------------------------------------------------------------------- |
|
334 // CGSPowerSavingQueryPlugin::CreateIconL() |
|
335 // |
|
336 // |
|
337 // ----------------------------------------------------------------------------- |
|
338 // |
|
339 CGulIcon* CGSPowerSavingQueryPlugin::CreateIconL( const TUid aIconType ) |
|
340 { |
|
341 CGulIcon* icon; |
|
342 TParse* fp = new( ELeave ) TParse(); |
|
343 CleanupStack::PushL( fp ); |
|
344 fp->Set( KGSPowerSavingQueryPluginIconDirAndName, &KDC_BITMAP_DIR, NULL ); |
|
345 |
|
346 if( aIconType == KGSIconTypeLbxItem ) |
|
347 { |
|
348 icon = AknsUtils::CreateGulIconL( |
|
349 AknsUtils::SkinInstance(), |
|
350 KAknsIIDQgnPropCpDevPsActivate, |
|
351 fp->FullName(), |
|
352 EMbmGspowersavingquerypluginQgn_prop_cp_dev_ps_activate, |
|
353 EMbmGspowersavingquerypluginQgn_prop_cp_dev_ps_activate_mask ); |
|
354 } |
|
355 else |
|
356 { |
|
357 icon = CGSPluginInterface::CreateIconL( aIconType ); |
|
358 } |
|
359 |
|
360 CleanupStack::PopAndDestroy( fp ); |
|
361 |
|
362 return icon; |
|
363 |
|
364 } |
|
365 |
|
366 // ----------------------------------------------------------------------------- |
|
367 // CGSPowerSavingQueryPlugin::SwitchOnOffValue() |
|
368 // |
|
369 // |
|
370 // ----------------------------------------------------------------------------- |
|
371 // |
|
372 void CGSPowerSavingQueryPlugin::SwitchOnOffValue( TInt& aValue ) |
|
373 { |
|
374 if ( aValue == KGSSettingOn ) |
|
375 { |
|
376 aValue = KGSIndexOn; |
|
377 } |
|
378 else if ( aValue == KGSSettingOff ) |
|
379 { |
|
380 aValue = KGSIndexOff; |
|
381 } |
|
382 } |
|
383 |
|
384 // End of File |
|