|
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 Optical joystick |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "GSOpticalJoystickPlugin.h" |
|
21 #include "GSOpticalJoystickPluginContainer.h" |
|
22 #include "GSOpticalJoystickPlugin.hrh" |
|
23 #include "GsLogger.h" |
|
24 #include <gsopticaljoystickplugin.mbg> // Icons |
|
25 #include <gsopticaljoystickpluginrsc.rsg> |
|
26 #include <gsfwviewuids.h> |
|
27 #include <gsprivatepluginproviderids.h> |
|
28 |
|
29 #include <AknQueryDialog.h> |
|
30 #include <aknradiobuttonsettingpage.h> |
|
31 #include <aknViewAppUi.h> |
|
32 #include <featmgr.h> |
|
33 #include <StringLoader.h> |
|
34 #include <bautils.h> |
|
35 #include <coeaui.h> |
|
36 #include <e32svr.h> |
|
37 #include <eikfrlbd.h> |
|
38 #include <gulicon.h> |
|
39 #include <hlplch.h> // For HlpLauncher |
|
40 |
|
41 #include <gscommon.hrh> |
|
42 |
|
43 // EXTERNAL DATA STRUCTURES |
|
44 |
|
45 // EXTERNAL FUNCTION PROTOTYPES |
|
46 |
|
47 // CONSTANTS |
|
48 |
|
49 // MACROS |
|
50 |
|
51 // LOCAL CONSTANTS AND MACROS |
|
52 |
|
53 _LIT( KGSOpticalJoystickPluginResourceFileName, "z:GSOpticalJoystickPluginRsc.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 // CGSOpticalJoystickPlugin::CGSOpticalJoystickPlugin() |
|
67 // |
|
68 // Constructor |
|
69 // ---------------------------------------------------------------------------- |
|
70 // |
|
71 CGSOpticalJoystickPlugin::CGSOpticalJoystickPlugin() |
|
72 : iResourceLoader( *iCoeEnv ) |
|
73 { |
|
74 } |
|
75 |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // CGSOpticalJoystickPlugin::NewL() |
|
79 // |
|
80 // Symbian OS default constructor |
|
81 // --------------------------------------------------------------------------- |
|
82 CGSOpticalJoystickPlugin* CGSOpticalJoystickPlugin::NewL( TAny* /*aInitParams*/ ) |
|
83 { |
|
84 CGSOpticalJoystickPlugin* self = new( ELeave ) CGSOpticalJoystickPlugin (); |
|
85 |
|
86 CleanupStack::PushL( self ); |
|
87 self->ConstructL(); |
|
88 CleanupStack::Pop(); |
|
89 |
|
90 return self; |
|
91 } |
|
92 |
|
93 |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // CGSOpticalJoystickPlugin::ConstructL() |
|
97 // |
|
98 // Symbian OS two-phased constructor |
|
99 // --------------------------------------------------------------------------- |
|
100 void CGSOpticalJoystickPlugin::ConstructL() |
|
101 { |
|
102 FeatureManager::InitializeLibL(); |
|
103 // Find the resource file |
|
104 TParse parse; |
|
105 parse.Set( KGSOpticalJoystickPluginResourceFileName, |
|
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_OPTICALJOYSTICK_VIEW ); |
|
116 } |
|
117 |
|
118 |
|
119 // ---------------------------------------------------------------------------- |
|
120 // CGSOpticalJoystickPlugin::~CGSOpticalJoystickPlugin |
|
121 // |
|
122 // Destructor |
|
123 // ---------------------------------------------------------------------------- |
|
124 CGSOpticalJoystickPlugin::~CGSOpticalJoystickPlugin() |
|
125 { |
|
126 FeatureManager::UnInitializeLib(); |
|
127 iResourceLoader.Close(); |
|
128 } |
|
129 |
|
130 |
|
131 // --------------------------------------------------------------------------- |
|
132 // TUid CGSOpticalJoystickPlugin::Id() |
|
133 // |
|
134 // Returns view's ID. |
|
135 // --------------------------------------------------------------------------- |
|
136 TUid CGSOpticalJoystickPlugin::Id() const |
|
137 { |
|
138 return KGSOpticalJoystickPluginUid; |
|
139 } |
|
140 |
|
141 |
|
142 // ========================= From CGSPluginInterface ================== |
|
143 |
|
144 // ---------------------------------------------------------------------------- |
|
145 // CGSOpticalJoystickPlugin::GetCaption |
|
146 // |
|
147 // Return application/view caption. |
|
148 // ---------------------------------------------------------------------------- |
|
149 // |
|
150 void CGSOpticalJoystickPlugin::GetCaptionL( TDes& aCaption ) const |
|
151 { |
|
152 // the resource file is already opened. |
|
153 HBufC* result = StringLoader::LoadL( R_GS_OPTICALJOYSTICK_VIEW_CAPTION ); |
|
154 |
|
155 aCaption.Copy( *result ); |
|
156 delete result; |
|
157 } |
|
158 |
|
159 |
|
160 // ---------------------------------------------------------------------------- |
|
161 // CGSOpticalJoystickPlugin::PluginProviderCategory |
|
162 // |
|
163 // A means to identify the location of this plug-in in the framework. |
|
164 // ---------------------------------------------------------------------------- |
|
165 // |
|
166 TInt CGSOpticalJoystickPlugin::PluginProviderCategory() const |
|
167 { |
|
168 //To identify internal plug-ins. |
|
169 return KGSPluginProviderInternal; |
|
170 } |
|
171 |
|
172 |
|
173 // ---------------------------------------------------------------------------- |
|
174 // CGSOpticalJoystickPlugin::Visible |
|
175 // |
|
176 // Provides the visibility status of self to framework. |
|
177 // ---------------------------------------------------------------------------- |
|
178 // |
|
179 TBool CGSOpticalJoystickPlugin::Visible() const |
|
180 { |
|
181 if( FeatureManager::FeatureSupported( 193 /* KFeatureIdFfOfnFeature */) ) |
|
182 { |
|
183 return ETrue; |
|
184 } |
|
185 else |
|
186 { |
|
187 return EFalse; |
|
188 } |
|
189 } |
|
190 |
|
191 |
|
192 // --------------------------------------------------------------------------- |
|
193 // CGSOpticalJoystickPlugin::HandleCommandL(TInt aCommand) |
|
194 // |
|
195 // Handles commands directed to this class. |
|
196 // --------------------------------------------------------------------------- |
|
197 void CGSOpticalJoystickPlugin::HandleCommandL( TInt aCommand ) |
|
198 { |
|
199 switch ( aCommand ) |
|
200 { |
|
201 case EGSMSKCmdAppChange: |
|
202 case EGSCmdAppChange: |
|
203 HandleListBoxSelectionL(); |
|
204 break; |
|
205 case EAknSoftkeyBack: |
|
206 iAppUi->ActivateLocalViewL( KGSDeviceManagementPluginUid ); |
|
207 break; |
|
208 case EAknCmdHelp: |
|
209 { |
|
210 if( FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
211 { |
|
212 HlpLauncher::LaunchHelpApplicationL( |
|
213 iEikonEnv->WsSession(), iAppUi->AppHelpContextL() ); |
|
214 } |
|
215 break; |
|
216 } |
|
217 default: |
|
218 iAppUi->HandleCommandL( aCommand ); |
|
219 break; |
|
220 } |
|
221 } |
|
222 |
|
223 |
|
224 // --------------------------------------------------------------------------- |
|
225 // CGSOpticalJoystickPlugin::UpdateListBoxL |
|
226 // |
|
227 // Updates listbox items. |
|
228 // --------------------------------------------------------------------------- |
|
229 // |
|
230 void CGSOpticalJoystickPlugin::UpdateListBoxL( TInt aItemId ) |
|
231 { |
|
232 if( Container() ) |
|
233 { |
|
234 Container()->UpdateListBoxL( aItemId ); |
|
235 } |
|
236 } |
|
237 |
|
238 |
|
239 // ---------------------------------------------------------------------------- |
|
240 // CGSOpticalJoystickPlugin::Container |
|
241 // |
|
242 // Return handle to container class. |
|
243 // ---------------------------------------------------------------------------- |
|
244 // |
|
245 CGSOpticalJoystickPluginContainer* CGSOpticalJoystickPlugin::Container() |
|
246 { |
|
247 return static_cast<CGSOpticalJoystickPluginContainer*>( iContainer ); |
|
248 } |
|
249 |
|
250 |
|
251 // --------------------------------------------------------------------------- |
|
252 // CGSOpticalJoystickPlugin::NewContainerL() |
|
253 // |
|
254 // Creates new iContainer. |
|
255 // --------------------------------------------------------------------------- |
|
256 // |
|
257 void CGSOpticalJoystickPlugin::NewContainerL() |
|
258 { |
|
259 iContainer = new( ELeave ) CGSOpticalJoystickPluginContainer; |
|
260 } |
|
261 |
|
262 |
|
263 // ---------------------------------------------------------------------------- |
|
264 // CGSOpticalJoystickPlugin::DoActivateL |
|
265 // |
|
266 // First method called by the Avkon framwork to invoke a view. |
|
267 // ---------------------------------------------------------------------------- |
|
268 // |
|
269 void CGSOpticalJoystickPlugin::DoActivateL( const TVwsViewId& aPrevViewId, |
|
270 TUid aCustomMessageId, |
|
271 const TDesC8& aCustomMessage ) |
|
272 { |
|
273 CGSBaseView::DoActivateL( aPrevViewId, aCustomMessageId, aCustomMessage ); |
|
274 } |
|
275 |
|
276 |
|
277 // ---------------------------------------------------------------------------- |
|
278 // CGSOpticalJoystickPlugin::DoDeactivate |
|
279 // |
|
280 // Called by the Avkon view framework when closing. |
|
281 // ---------------------------------------------------------------------------- |
|
282 // |
|
283 void CGSOpticalJoystickPlugin::DoDeactivate() |
|
284 { |
|
285 CGSBaseView::DoDeactivate(); |
|
286 } |
|
287 |
|
288 |
|
289 // --------------------------------------------------------------------------- |
|
290 // CGSOpticalJoystickPlugin::HandleListBoxSelectionL() |
|
291 // |
|
292 // Handles events raised through a rocker key. |
|
293 // --------------------------------------------------------------------------- |
|
294 void CGSOpticalJoystickPlugin::HandleListBoxSelectionL() |
|
295 { |
|
296 const TInt currentFeatureId = Container()->CurrentFeatureId(); |
|
297 |
|
298 switch ( currentFeatureId ) |
|
299 { |
|
300 case KGSSettIdOptJoyst: |
|
301 ShowSettingPageL(); |
|
302 break; |
|
303 default: |
|
304 break; |
|
305 } |
|
306 } |
|
307 |
|
308 |
|
309 // --------------------------------------------------------------------------- |
|
310 // CGSOpticalJoystickPlugin::HandleSettingPageEventL |
|
311 // |
|
312 // Handle any setting page related events |
|
313 // --------------------------------------------------------------------------- |
|
314 // |
|
315 void CGSOpticalJoystickPlugin::HandleSettingPageEventL( CAknSettingPage* /*aSettingPage*/, |
|
316 TAknSettingPageEvent /*aEventType*/ ) |
|
317 { |
|
318 } |
|
319 |
|
320 // --------------------------------------------------------------------------- |
|
321 // CGSOpticalJoystickPlugin::ShowDialupAutodisconSettingPageL |
|
322 // |
|
323 // Display dialup auto disconnect setting page. |
|
324 // --------------------------------------------------------------------------- |
|
325 // |
|
326 void CGSOpticalJoystickPlugin::ShowSettingPageL() |
|
327 { |
|
328 TInt currentValue; // This value should be got from Hardware |
|
329 TInt err = 0; |
|
330 |
|
331 Container()->GetOpticalJoystickStatus( currentValue ); |
|
332 |
|
333 __GSLOGSTRING1("[CGSOpticalJoystickPlugin]--> ShowSettingPageL(), value: %d", currentValue ); |
|
334 |
|
335 CDesCArrayFlat* items = iCoeEnv->ReadDesC16ArrayResourceL( |
|
336 R_OPTICALJOYSTICK_SETTING_PAGE_LBX ); |
|
337 CleanupStack::PushL( items ); |
|
338 |
|
339 CAknRadioButtonSettingPage* dlg = new( ELeave ) CAknRadioButtonSettingPage( |
|
340 R_OPTICALJOYSTICK_SETTING_PAGE, |
|
341 currentValue, items ); |
|
342 |
|
343 dlg->SetSettingId( KGSOpticalJoystickSettingId ); |
|
344 dlg->SetSettingPageObserver( this ); |
|
345 |
|
346 if ( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged ) ) |
|
347 { |
|
348 Container()->SetOpticalJoystickStatusL( currentValue ); |
|
349 |
|
350 __GSLOGSTRING1("[CGSOpticalJoystickPlugin]--> ShowSettingPageL(), value: %d", currentValue); |
|
351 |
|
352 UpdateListBoxL( KGSSettIdOptJoyst ); |
|
353 } |
|
354 |
|
355 CleanupStack::PopAndDestroy( items ); |
|
356 } |
|
357 |
|
358 // ----------------------------------------------------------------------------- |
|
359 // CGSOpticalJoystickPlugin::CreateIconL() |
|
360 // |
|
361 // |
|
362 // ----------------------------------------------------------------------------- |
|
363 // |
|
364 CGulIcon* CGSOpticalJoystickPlugin::CreateIconL( const TUid aIconType ) |
|
365 { |
|
366 //EMbm<Mbm_file_name><Bitmap_name> |
|
367 CGulIcon* icon; |
|
368 TParse* fp = new( ELeave ) TParse(); |
|
369 CleanupStack::PushL( fp ); |
|
370 fp->Set( KGSOpticalJoystickPluginIconDirAndName, &KDC_BITMAP_DIR, NULL ); |
|
371 |
|
372 if( aIconType == KGSIconTypeLbxItem ) |
|
373 { |
|
374 icon = AknsUtils::CreateGulIconL( |
|
375 AknsUtils::SkinInstance(), |
|
376 KAknsIIDQgnPropCpOptiJoystick, |
|
377 fp->FullName(), |
|
378 EMbmGsopticaljoystickpluginQgn_prop_cp_opti_joystick, |
|
379 EMbmGsopticaljoystickpluginQgn_prop_cp_opti_joystick_mask ); |
|
380 } |
|
381 else |
|
382 { |
|
383 icon = CGSPluginInterface::CreateIconL( aIconType ); |
|
384 } |
|
385 |
|
386 CleanupStack::PopAndDestroy( fp ); |
|
387 |
|
388 return icon; |
|
389 } |
|
390 |
|
391 |
|
392 // ----------------------------------------------------------------------------- |
|
393 // CGSOpticalJoystickPlugin::DynInitMenuPaneL() |
|
394 // |
|
395 // dynamically handle help item if not supported |
|
396 // ----------------------------------------------------------------------------- |
|
397 // |
|
398 void CGSOpticalJoystickPlugin::DynInitMenuPaneL( TInt aResourceId, |
|
399 CEikMenuPane* aMenuPane ) |
|
400 { |
|
401 if( aResourceId == R_GS_MENU_ITEM_HELP ) |
|
402 { |
|
403 User::LeaveIfNull( aMenuPane ); |
|
404 |
|
405 if ( FeatureManager::FeatureSupported( KFeatureIdHelp )) |
|
406 { |
|
407 aMenuPane->SetItemDimmed( EAknCmdHelp, EFalse ); |
|
408 } |
|
409 else |
|
410 { |
|
411 aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue ); |
|
412 } |
|
413 } |
|
414 } |
|
415 |
|
416 // End of File |