|
1 /* |
|
2 * Copyright (c) 2005-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: View for Active Idle skinning. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // This plugin specific. |
|
20 #include <pslnactiveidlepluginrsc.rsg> |
|
21 #include <pslnactiveidleplugin.mbg> |
|
22 #include "pslnactiveidleplugin.h" |
|
23 #include "pslnactiveidleplugincontainer.h" |
|
24 #include "pslnactiveidlepluginengine.h" |
|
25 #include "pslnactiveidlepluginuids.h" |
|
26 |
|
27 // General services. |
|
28 #include <stringloader.h> |
|
29 #include <featmgr.h> |
|
30 #include <gsfwviewuids.h> |
|
31 |
|
32 // Psln Framework specific. |
|
33 #include <pslnfwviewuids.h> |
|
34 #include <psln.hrh> |
|
35 #include <pslncommon.rsg> |
|
36 #include <psln.rsg> |
|
37 |
|
38 |
|
39 // Path to mbm file. |
|
40 _LIT(KPslnActiveIdleIconFileName, "pslnactiveidleplugin.mbm"); |
|
41 |
|
42 // Path to compiled resource file. |
|
43 _LIT(KPslnActiveIdlePluginResourceFileName, "z:pslnactiveidlepluginrsc.rsc"); |
|
44 |
|
45 // Path to common personalization resources. This resource file is meant for |
|
46 // shared resources between application and plugins. |
|
47 _LIT(KPslnCommonResourceFileName, "z:pslncommon.rsc"); |
|
48 |
|
49 // Path to Psln application resource file. Plugin uses some localized texts |
|
50 // from Psln's resources. |
|
51 _LIT(KPslnApplicationResourceFileName, "z:psln.rsc"); |
|
52 |
|
53 // Location of this plugin view within Psln's tab group. |
|
54 const TInt KPslnActiveIdlePluginLocation = 2; |
|
55 |
|
56 const TUid KPslnActiveIdlePluginUid = { KPslnActiveIdlePluginImplementationUID }; |
|
57 |
|
58 // Middle Softkey control ID. |
|
59 const TInt KPslnMSKControlId = 3; |
|
60 |
|
61 // ---------------------------------------------------------------------------- |
|
62 // CPslnActiveIdlePlugin::CPslnActiveIdlePlugin() |
|
63 // |
|
64 // Constructor |
|
65 // ---------------------------------------------------------------------------- |
|
66 // |
|
67 CPslnActiveIdlePlugin::CPslnActiveIdlePlugin(CAknViewAppUi* aAppUi) |
|
68 : |
|
69 iResourceLoader(*iCoeEnv), |
|
70 iResourceLoaderCommon(*iCoeEnv), |
|
71 iResourceLoaderPsln(*iCoeEnv), |
|
72 iAppUi(aAppUi) |
|
73 { |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // CPslnActiveIdlePlugin::NewL |
|
78 // |
|
79 // Symbian OS default constructor |
|
80 // --------------------------------------------------------------------------- |
|
81 CPslnActiveIdlePlugin* CPslnActiveIdlePlugin::NewL(TAny* aAppUi) |
|
82 { |
|
83 CAknViewAppUi* appUi = reinterpret_cast<CAknViewAppUi*>(aAppUi); |
|
84 CPslnActiveIdlePlugin* self = new(ELeave) CPslnActiveIdlePlugin (appUi); |
|
85 |
|
86 CleanupStack::PushL(self); |
|
87 self->ConstructL(); |
|
88 CleanupStack::Pop(self); |
|
89 |
|
90 return self; |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // CPslnActiveIdlePlugin::ConstructL |
|
95 // |
|
96 // Symbian OS two-phased constructor |
|
97 // --------------------------------------------------------------------------- |
|
98 void CPslnActiveIdlePlugin::ConstructL() |
|
99 { |
|
100 #ifdef _MY_DEBUG |
|
101 RDebug::Print(_L("XAI: CPslnActiveIdlePlugin::ConstructL")); |
|
102 #endif |
|
103 |
|
104 // Find the resource file: |
|
105 TParse* parse = new (ELeave) TParse; |
|
106 CleanupStack::PushL(parse); |
|
107 parse->Set(KPslnCommonResourceFileName, &KDC_APP_RESOURCE_DIR, NULL); |
|
108 TFileName* fileName = new (ELeave) TFileName(parse->FullName()); |
|
109 CleanupStack::PushL(fileName); |
|
110 |
|
111 // Open resource file: |
|
112 iResourceLoaderCommon.OpenL(*fileName); |
|
113 CleanupStack::PopAndDestroy(fileName); |
|
114 |
|
115 // Find the resource file: |
|
116 parse->Set(KPslnApplicationResourceFileName, &KDC_APP_RESOURCE_DIR, NULL); |
|
117 fileName = new (ELeave) TFileName(parse->FullName()); |
|
118 CleanupStack::PushL(fileName); |
|
119 |
|
120 // Open resource file: |
|
121 iResourceLoaderPsln.OpenL(*fileName); |
|
122 CleanupStack::PopAndDestroy(fileName); |
|
123 CleanupStack::PopAndDestroy(parse); |
|
124 |
|
125 // Open own resources for reading. |
|
126 OpenLocalizedResourceFileL( |
|
127 KPslnActiveIdlePluginResourceFileName, |
|
128 iResourceLoader); |
|
129 |
|
130 BaseConstructL(R_PSLN_ACTIVE_IDLE_VIEW); |
|
131 |
|
132 iEngine = new (ELeave) CPslnActiveIdlePluginEngine(this); |
|
133 iEngine->ConstructL( TRect() ); |
|
134 iEngine->ManualGetSkinsRestartL(ETrue); // Force start |
|
135 |
|
136 } |
|
137 |
|
138 // ---------------------------------------------------------------------------- |
|
139 // CPslnActiveIdlePlugin::~CPslnActiveIdlePlugin |
|
140 // |
|
141 // Destructor |
|
142 // ---------------------------------------------------------------------------- |
|
143 CPslnActiveIdlePlugin::~CPslnActiveIdlePlugin() |
|
144 { |
|
145 iResourceLoaderCommon.Close(); |
|
146 iResourceLoaderPsln.Close(); |
|
147 iResourceLoader.Close(); |
|
148 delete iEngine; |
|
149 } |
|
150 |
|
151 // --------------------------------------------------------------------------- |
|
152 // TUid CPslnActiveIdlePlugin::Id() |
|
153 // |
|
154 // Returns view's ID. |
|
155 // --------------------------------------------------------------------------- |
|
156 TUid CPslnActiveIdlePlugin::Id() const |
|
157 { |
|
158 return KPslnActiveIdlePluginUid; |
|
159 } |
|
160 |
|
161 // ---------------------------------------------------------------------------- |
|
162 // CPslnActiveIdlePlugin::GetCaption |
|
163 // |
|
164 // Return application/view caption. 128 |
|
165 // ---------------------------------------------------------------------------- |
|
166 // |
|
167 void CPslnActiveIdlePlugin::GetCaptionL(TDes& aCaption) const |
|
168 { |
|
169 // the resource file is already opened. |
|
170 HBufC* result = StringLoader::LoadL(R_PSLN_AI_LIST_VIEW_CAPTION); |
|
171 if (aCaption.MaxLength() >= result->Length()) |
|
172 { |
|
173 aCaption.Copy(*result); |
|
174 } |
|
175 delete result; |
|
176 } |
|
177 |
|
178 // ---------------------------------------------------------------------------- |
|
179 // CPslnActiveIdlePlugin::GetTabTextL |
|
180 // |
|
181 // Return tab text. 128 |
|
182 // ---------------------------------------------------------------------------- |
|
183 // |
|
184 void CPslnActiveIdlePlugin::GetTabTextL(TDes& aCaption) const |
|
185 { |
|
186 // the resource file is already opened. |
|
187 HBufC* result = StringLoader::LoadL(R_PSLN_AI_TAB_NAME); |
|
188 if (aCaption.MaxLength() >= result->Length()) |
|
189 { |
|
190 aCaption.Copy(*result); |
|
191 } |
|
192 delete result; |
|
193 } |
|
194 |
|
195 // ---------------------------------------------------------------------------- |
|
196 // CPslnActiveIdlePlugin::CreateIconL |
|
197 // |
|
198 // Creates Main view icon. |
|
199 // ---------------------------------------------------------------------------- |
|
200 // |
|
201 CGulIcon* CPslnActiveIdlePlugin::CreateIconL() |
|
202 { |
|
203 // Find the resource file: |
|
204 TParse* parse = new (ELeave) TParse; |
|
205 CleanupStack::PushL(parse); |
|
206 parse->Set(KPslnActiveIdleIconFileName, &KDC_APP_BITMAP_DIR, NULL); |
|
207 HBufC* fileName = parse->FullName().AllocLC(); |
|
208 TPtr fileNamePtr = fileName->Des(); |
|
209 |
|
210 CGulIcon* icon = AknsUtils::CreateGulIconL( |
|
211 AknsUtils::SkinInstance(), |
|
212 KAknsIIDQgnPropPslnAiSub, |
|
213 fileNamePtr, |
|
214 EMbmPslnactiveidlepluginQgn_prop_psln_ai_sub, |
|
215 EMbmPslnactiveidlepluginQgn_prop_psln_ai_sub_mask); |
|
216 |
|
217 CleanupStack::PopAndDestroy(2, parse); // fileName, parse |
|
218 |
|
219 return icon; |
|
220 } |
|
221 |
|
222 // ----------------------------------------------------------------------------- |
|
223 // CPslnActiveIdlePlugin::GetLocationTypeAndIndex() |
|
224 // |
|
225 // |
|
226 // ----------------------------------------------------------------------------- |
|
227 // |
|
228 void CPslnActiveIdlePlugin::GetLocationTypeAndIndex( |
|
229 TPslnFWLocationType& aType, |
|
230 TInt& aIndex) const |
|
231 { |
|
232 aType = CPslnFWPluginInterface::EPslnFWSpecified; |
|
233 aIndex = KPslnActiveIdlePluginLocation; |
|
234 } |
|
235 |
|
236 // --------------------------------------------------------------------------- |
|
237 // CPslnActiveIdlePlugin::HandleCommandL(TInt aCommand) |
|
238 // |
|
239 // Handles commands directed to this class. |
|
240 // --------------------------------------------------------------------------- |
|
241 void CPslnActiveIdlePlugin::HandleCommandL(TInt aCommand) |
|
242 { |
|
243 switch (aCommand) |
|
244 { |
|
245 case EPslnCmdAppActivate: |
|
246 iEngine->ActivateThemeL(); |
|
247 break; |
|
248 |
|
249 case EAknSoftkeyBack: |
|
250 RemoveCommandFromMSK(); |
|
251 if (iAppUi->View(KPslnMainViewUid)) |
|
252 { |
|
253 // if we are in Psln activate Psln main view... |
|
254 iAppUi->ActivateLocalViewL(KPslnMainViewUid); |
|
255 } |
|
256 else if (iAppUi->View(KGSMainViewUid)) |
|
257 { |
|
258 // ... else if we are in GS activate parent plugin view (standby view)... |
|
259 iAppUi->ActivateLocalViewL(KGSStandbyPluginUid); |
|
260 } |
|
261 else |
|
262 { |
|
263 iAppUi->HandleCommandL(aCommand); |
|
264 } |
|
265 break; |
|
266 |
|
267 case EAknSoftkeyExit: |
|
268 // This is here because we use different softkey setups |
|
269 iAppUi->HandleCommandL(EAknCmdExit); |
|
270 break; |
|
271 |
|
272 case EPslnCmdAppHelp: |
|
273 case EAknCmdHelp:// Fall trough |
|
274 CPslnFWBaseView::HandleCommandL(aCommand); |
|
275 break; |
|
276 |
|
277 default: |
|
278 iAppUi->HandleCommandL(aCommand); |
|
279 break; |
|
280 } |
|
281 } |
|
282 |
|
283 // ---------------------------------------------------------------------------- |
|
284 // CPslnActiveIdlePlugin::Container |
|
285 // |
|
286 // Return handle to container class. |
|
287 // ---------------------------------------------------------------------------- |
|
288 // |
|
289 CPslnActiveIdlePluginContainer* CPslnActiveIdlePlugin::Container() |
|
290 { |
|
291 return static_cast<CPslnActiveIdlePluginContainer*>(iContainer); |
|
292 } |
|
293 |
|
294 // ----------------------------------------------------------------------------- |
|
295 // Checks is there a need to update the middle softkey label. |
|
296 // This method should do nothing but MSK issues, since it is still called |
|
297 // if the framework does not support MSK. |
|
298 // ----------------------------------------------------------------------------- |
|
299 // |
|
300 void CPslnActiveIdlePlugin::CheckMiddleSoftkeyLabelL() |
|
301 { |
|
302 CPslnActiveIdlePluginContainer* container = Container(); |
|
303 TInt highlightedItem = iContainer->iListBox->CurrentItemIndex(); |
|
304 |
|
305 #ifdef _MY_DEBUG |
|
306 RDebug::Print(_L("XAI: CPslnActiveIdlePlugin::CheckMiddleSoftkeyLabelL highl = %d, curr = %d"), highlightedItem, container->GetCurrentlySelectedIndex()); |
|
307 #endif |
|
308 |
|
309 // First remove any previous commands. |
|
310 RemoveCommandFromMSK(); |
|
311 |
|
312 if (highlightedItem >= 0 && |
|
313 highlightedItem != container->GetCurrentlySelectedIndex()) |
|
314 { |
|
315 // Activate: |
|
316 CPslnFWBaseView::SetMiddleSoftKeyLabelL( |
|
317 R_PSLN_MSK_ACTIVATE, |
|
318 EPslnCmdAppActivate); |
|
319 } |
|
320 else |
|
321 { |
|
322 CPslnFWBaseView::SetMiddleSoftKeyLabelL( |
|
323 R_PSLN_MSK_DUMMY, |
|
324 EPslnCmdEmptyCommand ); |
|
325 } |
|
326 } |
|
327 |
|
328 // ----------------------------------------------------------------------------- |
|
329 // Return engine instance. |
|
330 // ----------------------------------------------------------------------------- |
|
331 // |
|
332 CPslnActiveIdlePluginEngine* CPslnActiveIdlePlugin::Engine() |
|
333 { |
|
334 return iEngine; |
|
335 } |
|
336 |
|
337 // ---------------------------------------------------------------------------- |
|
338 // CPslnActiveIdlePlugin::DoActivateL |
|
339 // |
|
340 // First method called by the Avkon framwork to invoke a view. |
|
341 // ---------------------------------------------------------------------------- |
|
342 // |
|
343 void CPslnActiveIdlePlugin::DoActivateL( |
|
344 const TVwsViewId& aPrevViewId, |
|
345 TUid aCustomMessageId, |
|
346 const TDesC8& aCustomMessage) |
|
347 { |
|
348 #ifdef MY_DEBUG |
|
349 RDebug::Print(_L("XAI: CPslnActiveIdlePlugin::DoActivateL")); |
|
350 RDebug::Print(_L("XAI: aCustomMessageId = 0x%08x"), aCustomMessageId.iUid); |
|
351 RDebug::Print(_L("XAI: aPrevViewId = 0x%08x"), aPrevViewId.iAppUid.iUid); |
|
352 #endif |
|
353 |
|
354 // If called from Psln - set tab group location. |
|
355 if (iAppUi->View(KPslnMainViewUid)) |
|
356 { |
|
357 CPslnFWBaseView::SetNaviPaneL(KPslnActiveIdlePluginLocation); |
|
358 } |
|
359 |
|
360 CEikButtonGroupContainer* cba = Cba(); |
|
361 |
|
362 if (cba) |
|
363 { |
|
364 if (aCustomMessageId == KUidActiveIdle) |
|
365 { |
|
366 cba->SetCommandSetL(R_SOFTKEYS_OPTIONS_EXIT_EMPTY); |
|
367 } |
|
368 else |
|
369 { |
|
370 cba->SetCommandSetL(R_SOFTKEYS_OPTIONS_BACK_EMPTY); |
|
371 } |
|
372 cba->DrawDeferred(); |
|
373 } |
|
374 |
|
375 CPslnFWBaseView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage); |
|
376 |
|
377 CheckMiddleSoftkeyLabelL(); |
|
378 |
|
379 iEngine->ManualGetSkinsRestartL(); |
|
380 } |
|
381 |
|
382 // ---------------------------------------------------------------------------- |
|
383 // CPslnActiveIdlePlugin::DoDeactivate |
|
384 // |
|
385 // Called by the Avkon view framework when closing. |
|
386 // ---------------------------------------------------------------------------- |
|
387 // |
|
388 void CPslnActiveIdlePlugin::DoDeactivate() |
|
389 { |
|
390 #ifdef _MY_DEBUG |
|
391 RDebug::Print(_L("XAI: CPslnActiveIdlePlugin::DoDeactivate")); |
|
392 #endif |
|
393 CPslnFWBaseView::DoDeactivate(); |
|
394 RemoveCommandFromMSK(); |
|
395 } |
|
396 |
|
397 // ---------------------------------------------------------------------------- |
|
398 // CPslnActiveIdlePlugin::DynInitMenuPaneL |
|
399 // |
|
400 // |
|
401 // ---------------------------------------------------------------------------- |
|
402 // |
|
403 void CPslnActiveIdlePlugin::DynInitMenuPaneL( |
|
404 TInt aResourceId, CEikMenuPane* aMenuPane) |
|
405 { |
|
406 if (aResourceId == R_PSLN_GEN_VIEW_MENUPANE && |
|
407 aMenuPane) |
|
408 { |
|
409 // Since this is common resource it contains download, |
|
410 // set it off. |
|
411 aMenuPane->SetItemDimmed(EPslnCmdAppDownload, ETrue); |
|
412 |
|
413 CPslnActiveIdlePluginContainer* container = Container(); |
|
414 TInt highlightedItem = iContainer->iListBox->CurrentItemIndex(); |
|
415 // Remove Activate command, if highlighted item is already active. |
|
416 if (highlightedItem == container->GetCurrentlySelectedIndex()) |
|
417 { |
|
418 aMenuPane->SetItemDimmed(EPslnCmdAppActivate, ETrue); |
|
419 } |
|
420 } |
|
421 else if (aResourceId == R_PSLN_AI_BASIC_MENUPANE && |
|
422 aMenuPane) |
|
423 { |
|
424 if (!FeatureManager::FeatureSupported(KFeatureIdHelp)) |
|
425 { |
|
426 // Disable help if not supported |
|
427 aMenuPane->SetItemDimmed(EPslnCmdAppHelp, ETrue); |
|
428 } |
|
429 } |
|
430 } |
|
431 |
|
432 // --------------------------------------------------------------------------- |
|
433 // CPslnActiveIdlePlugin::NewContainerL() |
|
434 // |
|
435 // Creates new iContainer. |
|
436 // --------------------------------------------------------------------------- |
|
437 // |
|
438 void CPslnActiveIdlePlugin::NewContainerL() |
|
439 { |
|
440 if( !iContainer ) |
|
441 { |
|
442 TBool isGSCalling = (NULL != iAppUi->View(KGSMainViewUid)); |
|
443 iContainer = new (ELeave) CPslnActiveIdlePluginContainer(isGSCalling, this); |
|
444 iContainer->SetMiddleSoftkeyObserver(this); |
|
445 } |
|
446 |
|
447 RemoveCommandFromMSK(); |
|
448 } |
|
449 |
|
450 // --------------------------------------------------------------------------- |
|
451 // CPslnActiveIdlePlugin::HandleListBoxSelectionL() |
|
452 // |
|
453 // Handles events raised through a rocker key. |
|
454 // --------------------------------------------------------------------------- |
|
455 void CPslnActiveIdlePlugin::HandleListBoxSelectionL() |
|
456 { |
|
457 TInt currentItem = iContainer->iListBox->CurrentItemIndex(); |
|
458 CPslnFWBaseView::SetCurrentItem(currentItem); |
|
459 |
|
460 CPslnActiveIdlePluginContainer* container = Container(); |
|
461 |
|
462 if (currentItem != container->GetCurrentlySelectedIndex()) |
|
463 { |
|
464 HandleCommandL(EPslnCmdAppActivate); |
|
465 } |
|
466 } |
|
467 |
|
468 // ----------------------------------------------------------------------------- |
|
469 // Remove MSK command mappings. |
|
470 // This method should do nothing but MSK issues. |
|
471 // ----------------------------------------------------------------------------- |
|
472 // |
|
473 void CPslnActiveIdlePlugin::RemoveCommandFromMSK() |
|
474 { |
|
475 CEikButtonGroupContainer* cba = Cba(); |
|
476 |
|
477 if (cba && iContainer) |
|
478 { |
|
479 cba->RemoveCommandFromStack(KPslnMSKControlId, EPslnCmdEmptyCommand); |
|
480 cba->RemoveCommandFromStack(KPslnMSKControlId, EPslnCmdAppActivate); |
|
481 } |
|
482 } |
|
483 |
|
484 // --------------------------------------------------------------------------- |
|
485 // CPslnActiveIdlePlugin::SetTitlePaneL() |
|
486 // |
|
487 // Gives resource ID to be used as plugin view title. |
|
488 // --------------------------------------------------------------------------- |
|
489 // |
|
490 void CPslnActiveIdlePlugin::SetTitlePaneL( TInt& aResourceId ) |
|
491 { |
|
492 #ifdef RD_CONTROL_PANEL |
|
493 aResourceId = R_PSLN_AI_LIST_VIEW_CAPTION; |
|
494 #endif // RD_CONTROL_PANEL |
|
495 } |
|
496 |
|
497 // End of File. |