|
1 /* |
|
2 * Copyright (c) 2005-2008 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: Base class for plugins containing other plugins. Asynchronous |
|
15 * loading of plugins is used. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <gsparentplugin.h> |
|
22 #include <gsparentcontainer.h> |
|
23 #include <gsplugininterface.h> |
|
24 #include "GsLogger.h" |
|
25 #include <gscommon.hrh> |
|
26 #include <GSParentPluginRsc.rsg> |
|
27 #include <gsfwviewuids.h> |
|
28 #include <avkon.rsg> |
|
29 |
|
30 #include <aknlists.h> |
|
31 #include <ConeResLoader.h> |
|
32 #include <featmgr.h> |
|
33 #include <akntitle.h> |
|
34 #include <aknViewAppUi.h> |
|
35 #include <bautils.h> |
|
36 #include <eikmenup.h> |
|
37 #include <eikbtgpc.h> |
|
38 #include <hlplch.h> |
|
39 #include <StringLoader.h> |
|
40 #include <LayoutMetaData.cdl.h> |
|
41 // Middle Softkey control ID. |
|
42 const TInt KGSMSKControlID = 3; |
|
43 const TInt KGSMSKLength = 256; |
|
44 const TInt KGSPluginArrayInitSize = 10; |
|
45 |
|
46 // ========================= MEMBER FUNCTIONS ================================ |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // CGSParentPlugin::CGSParentPlugin() |
|
50 // |
|
51 // |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 EXPORT_C CGSParentPlugin::CGSParentPlugin() |
|
55 : iResourceLoader( *iCoeEnv ) |
|
56 { |
|
57 } |
|
58 |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // CGSParentPlugin::BaseConstructL() |
|
62 // |
|
63 // |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 EXPORT_C void CGSParentPlugin::BaseConstructL( |
|
67 TInt aViewRscId, |
|
68 TInt aTitleRscId ) |
|
69 { |
|
70 iTitleRscId = aTitleRscId; |
|
71 iSelectedPluginUid = KGSNoneSelected; |
|
72 iTopPluginUid = KGSNoneSelected; |
|
73 |
|
74 __GSLOGSTRING( "[CGSParentPlugin] ConstructL()" ); |
|
75 iAppUi = AppUi(); |
|
76 |
|
77 OpenLocalizedResourceFileL( KGSParentPluginResourceFileName, |
|
78 iResourceLoader ); |
|
79 CAknView::BaseConstructL( aViewRscId ); |
|
80 |
|
81 if( !iOptionFlags[ EGSLoadChildrenOnActivation ] ) |
|
82 { |
|
83 StartAsyncPluginLoadL(); |
|
84 } |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------------------------- |
|
88 // CGSParentPlugin::StartAsyncPluginLoadL() |
|
89 // |
|
90 // |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 void CGSParentPlugin::StartAsyncPluginLoadL() |
|
94 { |
|
95 //Initialize array and start loading plugins into it. |
|
96 iPluginArray = new (ELeave) CArrayPtrFlat<CGSPluginInterface>( KGSPluginArrayInitSize ); |
|
97 iPluginLoader = CGSPluginLoader::NewL( iAppUi ); |
|
98 iPluginLoader->SetObserver( this ); |
|
99 iPluginLoader->LoadAsyncL( KGSPluginInterfaceUid, Id(), iPluginArray ); |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------------------------- |
|
103 // CGSParentPlugin::UpperLevelViewUid() |
|
104 // |
|
105 // |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 EXPORT_C TUid CGSParentPlugin::UpperLevelViewUid() |
|
109 { |
|
110 __GSLOGSTRING( "[CGSParentPlugin] UpperLevelViewUid()" ); |
|
111 return iPrevViewId.iViewUid; |
|
112 } |
|
113 |
|
114 |
|
115 // --------------------------------------------------------------------------- |
|
116 // CGSParentPlugin::~CGSParentPlugin() |
|
117 // |
|
118 // |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 EXPORT_C CGSParentPlugin::~CGSParentPlugin() |
|
122 { |
|
123 __GSLOGSTRING( "[CGSParentPlugin] ~CGSParentPlugin" ); |
|
124 if ( iPluginLoader ) |
|
125 { |
|
126 iPluginLoader->AbortAsyncLoad(); |
|
127 } |
|
128 delete iPluginLoader; |
|
129 |
|
130 if ( iPluginArray ) |
|
131 { |
|
132 iPluginArray->Reset();//Do not destroy - Plugins are owned by iAppUi |
|
133 } |
|
134 delete iPluginArray; |
|
135 iResourceLoader.Close(); |
|
136 |
|
137 if( iContainer ) |
|
138 { |
|
139 iAppUi->RemoveFromViewStack( *this, iContainer ); |
|
140 delete iContainer; |
|
141 } |
|
142 } |
|
143 |
|
144 |
|
145 // --------------------------------------------------------------------------- |
|
146 // CGSParentPlugin::OpenLocalizedResourceFileL() |
|
147 // |
|
148 // |
|
149 // --------------------------------------------------------------------------- |
|
150 // |
|
151 EXPORT_C void CGSParentPlugin::OpenLocalizedResourceFileL( |
|
152 const TDesC& aResourceFileName, |
|
153 RConeResourceLoader& aResourceLoader ) |
|
154 { |
|
155 RFs fsSession; |
|
156 User::LeaveIfError( fsSession.Connect() ); |
|
157 |
|
158 // Find the resource file: |
|
159 TParse parse; |
|
160 parse.Set( aResourceFileName, &KDC_RESOURCE_FILES_DIR, NULL ); |
|
161 TFileName fileName( parse.FullName() ); |
|
162 |
|
163 // Get language of resource file: |
|
164 BaflUtils::NearestLanguageFile( fsSession, fileName ); |
|
165 |
|
166 // Open resource file: |
|
167 aResourceLoader.OpenL( fileName ); |
|
168 |
|
169 // If leave occurs before this, close is called automatically when the |
|
170 // thread exits. |
|
171 fsSession.Close(); |
|
172 } |
|
173 |
|
174 |
|
175 // --------------------------------------------------------------------------- |
|
176 // CGSParentPlugin::DoActivateL() |
|
177 // |
|
178 // |
|
179 // --------------------------------------------------------------------------- |
|
180 // |
|
181 EXPORT_C void CGSParentPlugin::DoActivateL( const TVwsViewId& aPrevViewId, |
|
182 TUid /*aCustomMessageId*/, |
|
183 const TDesC8& /*aCustomMessage*/ ) |
|
184 { |
|
185 __GSLOGSTRING( "[CGSParentPlugin::DoActivateL]" ); |
|
186 iPrevViewId = aPrevViewId; |
|
187 |
|
188 // If iPluginArray does not exist. Lazy loading is enabled and should start |
|
189 // loading now. |
|
190 if( !iPluginArray ) |
|
191 { |
|
192 StartAsyncPluginLoadL(); |
|
193 } |
|
194 |
|
195 // Set priority only after plugin loader is created in |
|
196 // StartAsyncPluginLoadL. |
|
197 iPluginLoader->RequestPriority( CActive::EPriorityHigh ); |
|
198 |
|
199 //if( iContainer ) |
|
200 // { |
|
201 // iAppUi->RemoveFromViewStack( *this, iContainer ); |
|
202 // delete iContainer; |
|
203 // iContainer=NULL; |
|
204 // } |
|
205 |
|
206 if ( !iContainer ) |
|
207 { |
|
208 ConstructContainerL(); |
|
209 |
|
210 // Set the empty text of list box. |
|
211 _LIT( KEmptyText, "" ); |
|
212 TBuf<1> empty( KEmptyText ); |
|
213 iContainer->SetListBoxEmptyTextL( empty ); |
|
214 |
|
215 // Update listbox from already existing iPluginArray: |
|
216 iContainer->UpdateListBoxL(); |
|
217 if (position.Count() > 0) |
|
218 { |
|
219 if (iScreenMode == Layout_Meta_Data::IsLandscapeOrientation()) |
|
220 { |
|
221 iContainer->SetPosition(position, EFalse); |
|
222 } |
|
223 else |
|
224 { |
|
225 iContainer->SetPosition(position, ETrue); |
|
226 } |
|
227 } |
|
228 iAppUi->AddToViewStackL(*this, iContainer); |
|
229 // Navigating to parent view will reset all child plugin selected indexes: |
|
230 for( TInt i = 0; i < iPluginArray->Count(); i++ ) |
|
231 { |
|
232 CGSPluginInterface* plugin = iPluginArray->operator[]( i ); |
|
233 plugin->ResetSelectedItemIndex(); |
|
234 } |
|
235 |
|
236 iMskCommandId = EAknSoftkeyOpen; |
|
237 |
|
238 SetMiddleSoftKeyLabelL( R_QTN_MSK_OPEN, EAknSoftkeyOpen ); |
|
239 CheckMiddleSoftkeyLabelL(); |
|
240 |
|
241 // If this view was launched from external source, use "exit" as RSK |
|
242 if (iPrevViewId.iAppUid != KUidGS) |
|
243 { |
|
244 CEikButtonGroupContainer* cbaGroup = Cba(); |
|
245 if (cbaGroup) |
|
246 { |
|
247 HBufC* rightSKText = StringLoader::LoadLC( |
|
248 R_GS_PARENTPLUGIN_CBA_EXIT); |
|
249 TPtr rskPtr = rightSKText->Des(); |
|
250 cbaGroup->SetCommandL(2, EAknSoftkeyExit, *rightSKText); |
|
251 CleanupStack::PopAndDestroy(rightSKText); |
|
252 } |
|
253 } |
|
254 |
|
255 } |
|
256 } |
|
257 |
|
258 // --------------------------------------------------------------------------- |
|
259 // CGSParentPlugin::DoDeactivate() |
|
260 // |
|
261 // |
|
262 // --------------------------------------------------------------------------- |
|
263 EXPORT_C void CGSParentPlugin::DoDeactivate() |
|
264 { |
|
265 __GSLOGSTRING( "[CGSParentPlugin::DoDeactivate]" ); |
|
266 |
|
267 iPluginLoader->RequestPriority( CActive::EPriorityLow ); |
|
268 |
|
269 if ( iContainer ) |
|
270 { |
|
271 if (position.Count() > 0) |
|
272 { |
|
273 position.Reset(); |
|
274 } |
|
275 TRAPD(err, iContainer->GetPositionL(position)); |
|
276 iScreenMode = Layout_Meta_Data::IsLandscapeOrientation(); |
|
277 |
|
278 iAppUi->RemoveFromViewStack(*this, iContainer); |
|
279 delete iContainer; |
|
280 iContainer = NULL; |
|
281 } |
|
282 __GSLOGSTRING( "[CGSParentPlugin::DoDeactivate] Done" ); |
|
283 } |
|
284 |
|
285 |
|
286 // --------------------------------------------------------------------------- |
|
287 // CGSParentPlugin::ConstructContainerL() |
|
288 // |
|
289 // |
|
290 // --------------------------------------------------------------------------- |
|
291 // |
|
292 void CGSParentPlugin::ConstructContainerL() |
|
293 { |
|
294 iContainer = new( ELeave ) CGSParentContainer; |
|
295 iContainer->SetMopParent( this ); |
|
296 |
|
297 TRAPD |
|
298 ( |
|
299 error, |
|
300 iContainer->ConstructL( |
|
301 ClientRect() , |
|
302 AppUi(), |
|
303 iPluginArray, |
|
304 iTitleRscId, |
|
305 this, |
|
306 ListBoxType() ) |
|
307 ); |
|
308 |
|
309 if ( error ) |
|
310 { |
|
311 delete iContainer; |
|
312 iContainer = NULL; |
|
313 User::Leave( error ); |
|
314 } |
|
315 } |
|
316 |
|
317 |
|
318 // --------------------------------------------------------------------------- |
|
319 // CGSParentPlugin::HandleCommandL() |
|
320 // |
|
321 // |
|
322 // --------------------------------------------------------------------------- |
|
323 // |
|
324 EXPORT_C void CGSParentPlugin::HandleCommandL( TInt aCommand ) |
|
325 { |
|
326 __GSLOGSTRING1( "[CGSParentPlugin] HandleCommandL(%d)", aCommand ); |
|
327 |
|
328 switch ( aCommand ) |
|
329 { |
|
330 case EAknSoftkeyBack: |
|
331 __GSLOGSTRING1( "[CGSParentPlugin] Returning to view 0x%X", |
|
332 UpperLevelViewUid().iUid ); |
|
333 iAppUi->ActivateLocalViewL( UpperLevelViewUid() ); |
|
334 break; |
|
335 // These all should be handled similarily: |
|
336 case EAknSoftkeyOpen: |
|
337 case EGSCmdAppChange: |
|
338 case EGSCmdAppOpen: |
|
339 if( iContainer && iPluginArray->Count() > 0 ) |
|
340 { |
|
341 CGSPluginInterface* selectedPlugin = |
|
342 iContainer->SelectedPlugin(); |
|
343 |
|
344 if ( NULL != selectedPlugin ) |
|
345 { |
|
346 switch( selectedPlugin->ItemType() ) |
|
347 { |
|
348 // In these cases the plugin is a view: |
|
349 case EGSItemTypeSingleLarge: |
|
350 case EGSItemTypeSetting: |
|
351 case EGSItemTypeSettingIcon: |
|
352 iAppUi->ActivateLocalViewL( selectedPlugin->Id() ); |
|
353 break; |
|
354 // In these cases the plugin is a dialog: |
|
355 case EGSItemTypeSettingDialog: |
|
356 case EGSItemTypeSingleLargeDialog: |
|
357 selectedPlugin->HandleSelection( |
|
358 EGSSelectionByMenu ); |
|
359 break; |
|
360 } |
|
361 } |
|
362 |
|
363 } |
|
364 break; |
|
365 case EGSMSKCmdAppChange: |
|
366 iContainer->HandleSelectionKeyL(); |
|
367 break; |
|
368 case EAknCmdHelp: |
|
369 { |
|
370 if( FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
371 { |
|
372 HlpLauncher::LaunchHelpApplicationL( |
|
373 iEikonEnv->WsSession(), iAppUi->AppHelpContextL() ); |
|
374 } |
|
375 break; |
|
376 } |
|
377 default: |
|
378 iAppUi->HandleCommandL( aCommand ); |
|
379 break; |
|
380 } |
|
381 } |
|
382 |
|
383 |
|
384 // --------------------------------------------------------------------------- |
|
385 // CGSParentPlugin::HandlePluginLoaded() |
|
386 // |
|
387 // |
|
388 // --------------------------------------------------------------------------- |
|
389 // |
|
390 EXPORT_C void CGSParentPlugin::HandlePluginLoaded( KGSPluginLoaderStatus aStatus ) |
|
391 { |
|
392 __GSLOGSTRING1( "[CGSParentPlugin::HandlePluginLoaded] aStatus:%d", aStatus ); |
|
393 |
|
394 switch( aStatus ) |
|
395 { |
|
396 case MGSPluginLoadObserver::EGSSuccess: |
|
397 // Should not update each time when plugin is loaded, only when |
|
398 // finished loading spesific view plugins? |
|
399 break; |
|
400 case MGSPluginLoadObserver::EGSFinished: |
|
401 if( iContainer ) |
|
402 { |
|
403 TRAPD( ignore, iContainer->UpdateListBoxL(); ); |
|
404 if( ignore != KErrNone ) |
|
405 { |
|
406 __GSLOGSTRING1( |
|
407 "[CGSParentPlugin] HandlePluginLoaded error:%d", |
|
408 ignore ); |
|
409 } |
|
410 } |
|
411 break; |
|
412 default: |
|
413 break; |
|
414 } |
|
415 } |
|
416 |
|
417 |
|
418 // --------------------------------------------------------------------------- |
|
419 // CGSParentPlugin::TransferDynamicPluginL() |
|
420 // |
|
421 // |
|
422 // --------------------------------------------------------------------------- |
|
423 // |
|
424 EXPORT_C void CGSParentPlugin::TransferDynamicPluginL( CGSPluginInterface* aPlugin ) |
|
425 { |
|
426 __GSLOGSTRING1( "[CGSParentPlugin] CGSParentPlugin::TransferDynamicPluginL() - plugin id: 0x%x added to appUi.", aPlugin->Id() ); |
|
427 |
|
428 CleanupStack::PushL( aPlugin ); |
|
429 iAppUi->AddViewL( aPlugin ); |
|
430 CleanupStack::Pop( aPlugin ); |
|
431 |
|
432 // Add to the overall plugin array for this parent plugin |
|
433 iPluginArray->AppendL( aPlugin ); |
|
434 |
|
435 // Resort the plugins so that they are in order |
|
436 iPluginLoader->SortPluginsL( iPluginArray ); |
|
437 |
|
438 // Update the listbox with the new information |
|
439 HandlePluginLoaded( MGSPluginLoadObserver::EGSSuccess ); |
|
440 } |
|
441 |
|
442 |
|
443 // --------------------------------------------------------------------------- |
|
444 // CGSParentPlugin::ListBoxType() |
|
445 // Default implementation. Overwrite if different type of listbox is needed. |
|
446 // |
|
447 // --------------------------------------------------------------------------- |
|
448 // |
|
449 EXPORT_C TGSListboxTypes CGSParentPlugin::ListBoxType() |
|
450 { |
|
451 return EGSListBoxTypeSingleLarge; |
|
452 } |
|
453 |
|
454 |
|
455 // --------------------------------------------------------------------------- |
|
456 // CGSParentPlugin::UpdateView() |
|
457 // |
|
458 // |
|
459 // --------------------------------------------------------------------------- |
|
460 // |
|
461 EXPORT_C void CGSParentPlugin::UpdateView() |
|
462 { |
|
463 __GSLOGSTRING( "[CGSParentPlugin::UpdateView]" ); |
|
464 TRAP_IGNORE |
|
465 ( |
|
466 if( iContainer ) |
|
467 { |
|
468 iContainer->UpdateListBoxL(); |
|
469 } |
|
470 ); |
|
471 } |
|
472 |
|
473 |
|
474 // ----------------------------------------------------------------------------- |
|
475 // CGSParentPlugin::ResetSelectedItemIndex() |
|
476 // |
|
477 // |
|
478 // ----------------------------------------------------------------------------- |
|
479 // |
|
480 EXPORT_C void CGSParentPlugin::ResetSelectedItemIndex() |
|
481 { |
|
482 iSelectedPluginUid = KGSNoneSelected; |
|
483 if( iContainer ) |
|
484 { |
|
485 iContainer->ListBox()->SetCurrentItemIndex( 0 ); |
|
486 } |
|
487 } |
|
488 |
|
489 |
|
490 // ----------------------------------------------------------------------------- |
|
491 // CGSParentPlugin::SetOptionFlags() |
|
492 // |
|
493 // |
|
494 // ----------------------------------------------------------------------------- |
|
495 // |
|
496 EXPORT_C void CGSParentPlugin::SetOptionFlags( TBitFlags& aOptionFlags ) |
|
497 { |
|
498 iOptionFlags = aOptionFlags; |
|
499 } |
|
500 |
|
501 |
|
502 // ----------------------------------------------------------------------------- |
|
503 // CGSParentPlugin::OptionFlags() |
|
504 // |
|
505 // |
|
506 // ----------------------------------------------------------------------------- |
|
507 // |
|
508 EXPORT_C const TBitFlags& CGSParentPlugin::OptionFlags() const |
|
509 { |
|
510 return iOptionFlags; |
|
511 } |
|
512 |
|
513 |
|
514 // ----------------------------------------------------------------------------- |
|
515 // CGSParentPlugin::DynInitMenuPaneL() |
|
516 // |
|
517 // |
|
518 // ----------------------------------------------------------------------------- |
|
519 // |
|
520 EXPORT_C void CGSParentPlugin::DynInitMenuPaneL( TInt /*aResourceId*/, |
|
521 CEikMenuPane* aMenuPane ) |
|
522 { |
|
523 // Check what is the plugin's desired menu item type for activating the |
|
524 // plugin. If it doesn't match to the item defined by parent plugin menu |
|
525 // resource, change the item dynamically. |
|
526 if ( iContainer->SelectedPlugin() ) |
|
527 { |
|
528 CGSPluginInterface* selectedPlugin = iContainer->SelectedPlugin(); |
|
529 TGSMenuActivationItems desiredItemType = selectedPlugin->MenuActivationItem(); |
|
530 |
|
531 // Append new item after this position, delete item in this position. |
|
532 TInt removableItemPos; |
|
533 |
|
534 // MSK command should be identical to the desired activation command in |
|
535 // options menu. Posibilities are such as 'open' (also as default), |
|
536 // 'change' or custom text. |
|
537 // Note: Activation item in options menu is depending on the highlighted |
|
538 // child plugin's MenuActivationItem() function. |
|
539 switch( desiredItemType ) |
|
540 { |
|
541 case EGSMenuActivationItemDefault: |
|
542 case EGSMenuActivationItemOpen: |
|
543 if( aMenuPane->MenuItemExists( EGSCmdAppChange, removableItemPos ) ) |
|
544 { |
|
545 aMenuPane->AddMenuItemsL( R_GS_MENU_ITEM_OPEN, removableItemPos ); |
|
546 aMenuPane->DeleteBetweenMenuItems( removableItemPos, removableItemPos ); |
|
547 } |
|
548 break; |
|
549 |
|
550 case EGSMenuActivationItemChange: |
|
551 if( aMenuPane->MenuItemExists( EAknSoftkeyOpen, removableItemPos ) ) |
|
552 { |
|
553 aMenuPane->AddMenuItemsL( R_GS_MENU_ITEM_CHANGE, removableItemPos ); |
|
554 aMenuPane->DeleteBetweenMenuItems( removableItemPos, removableItemPos ); |
|
555 } |
|
556 break; |
|
557 |
|
558 case EGSMenuActivationItemCustom: |
|
559 { |
|
560 // Using EGSCmdAppChange as EGSMenuActivationItemCustom |
|
561 // functionality is same as for EGSMenuActivationItemChange. |
|
562 // Here we're replacing EGSCmdAppChange always because we |
|
563 // cannot be sure whether it's the actual custom command |
|
564 // already or just EAknSoftkeyOpen. Custom commands will be set |
|
565 // to use the same command ID (EGSCmdAppChange). |
|
566 // |
|
567 CEikMenuPaneItem::SData menuItem; |
|
568 selectedPlugin->GetValue( EGSCustomMenuActivationText, menuItem.iText ); |
|
569 menuItem.iCommandId = EGSCmdAppChange; |
|
570 menuItem.iCascadeId = 0; |
|
571 menuItem.iFlags = 0; |
|
572 |
|
573 if( aMenuPane->MenuItemExists( EGSCmdAppChange, removableItemPos ) ) |
|
574 { |
|
575 // Add custom item before 'change' and then remove 'change' |
|
576 if( menuItem.iText.Length() > 0) |
|
577 { |
|
578 aMenuPane->AddMenuItemL( menuItem, EGSCmdAppChange ); |
|
579 } |
|
580 aMenuPane->DeleteBetweenMenuItems( removableItemPos, removableItemPos ); |
|
581 } |
|
582 else if( aMenuPane->MenuItemExists( EAknSoftkeyOpen, removableItemPos ) ) |
|
583 { |
|
584 // Add custom item before 'open' and then remove 'open' |
|
585 if( menuItem.iText.Length() > 0 ) |
|
586 { |
|
587 aMenuPane->AddMenuItemL( menuItem, EAknSoftkeyOpen ); |
|
588 } |
|
589 aMenuPane->DeleteBetweenMenuItems( removableItemPos, removableItemPos ); |
|
590 } |
|
591 break; |
|
592 } |
|
593 default: |
|
594 break; |
|
595 } |
|
596 } |
|
597 } |
|
598 |
|
599 |
|
600 // ----------------------------------------------------------------------------- |
|
601 // CGSParentPlugin::GetHelpContext() |
|
602 // |
|
603 // |
|
604 // ----------------------------------------------------------------------------- |
|
605 // |
|
606 EXPORT_C void CGSParentPlugin::GetHelpContext( TCoeHelpContext& /*aContext*/ ) |
|
607 { |
|
608 // Default implementation does nothing. |
|
609 } |
|
610 |
|
611 // ----------------------------------------------------------------------------- |
|
612 // When this method is called, view checks based on highlight focus, if the MSK |
|
613 // label is correct. |
|
614 // ----------------------------------------------------------------------------- |
|
615 // |
|
616 void CGSParentPlugin::CheckMiddleSoftkeyLabelL() |
|
617 { |
|
618 if ( iContainer->SelectedPlugin() ) |
|
619 { |
|
620 // Remove current MSK |
|
621 RemoveCommandFromMSK( iMskCommandId ); |
|
622 |
|
623 CGSPluginInterface* selectedPlugin = iContainer->SelectedPlugin(); |
|
624 TGSMenuActivationItems desiredItemType = |
|
625 selectedPlugin->MenuActivationItem(); |
|
626 |
|
627 switch( desiredItemType ) |
|
628 { |
|
629 case EGSMenuActivationItemChange: |
|
630 SetMiddleSoftKeyLabelL( R_QTN_MSK_CHANGE, EGSMSKCmdAppChange ); |
|
631 iMskCommandId = EGSMSKCmdAppChange; |
|
632 break; |
|
633 case EGSMenuActivationItemOpen: |
|
634 case EGSMenuActivationItemDefault: |
|
635 SetMiddleSoftKeyLabelL( R_QTN_MSK_OPEN, EAknSoftkeyOpen ); |
|
636 iMskCommandId = EAknSoftkeyOpen; |
|
637 break; |
|
638 case EGSMenuActivationItemCustom: |
|
639 { |
|
640 HBufC* mskText = HBufC::NewLC( KGSMSKLength ); |
|
641 TPtr mskPtr = mskText->Des(); |
|
642 selectedPlugin->GetValue( EGSCustomMenuActivationText, mskPtr ); |
|
643 SetMiddleSoftKeyLabelTextL( mskPtr, EGSMSKCmdAppChange ); |
|
644 CleanupStack::PopAndDestroy( mskText ); |
|
645 break; |
|
646 } |
|
647 default: |
|
648 // Use 'open' as default |
|
649 SetMiddleSoftKeyLabelL( R_QTN_MSK_OPEN, EAknSoftkeyOpen ); |
|
650 iMskCommandId = EAknSoftkeyOpen; |
|
651 break; |
|
652 } |
|
653 } |
|
654 } |
|
655 |
|
656 // ----------------------------------------------------------------------------- |
|
657 // Remove unnecessary commands from Middle softkey. |
|
658 // ----------------------------------------------------------------------------- |
|
659 // |
|
660 void CGSParentPlugin::RemoveCommandFromMSK( TInt aMskCommandId ) |
|
661 { |
|
662 CEikButtonGroupContainer* cbaGroup = Cba(); |
|
663 if ( cbaGroup ) |
|
664 { |
|
665 cbaGroup->RemoveCommandFromStack( KGSMSKControlID, aMskCommandId ); |
|
666 } |
|
667 } |
|
668 |
|
669 // --------------------------------------------------------------------------- |
|
670 // Sets middle softkey label. |
|
671 // --------------------------------------------------------------------------- |
|
672 // |
|
673 void CGSParentPlugin::SetMiddleSoftKeyLabelL( |
|
674 const TInt aResourceId, const TInt aCommandId ) |
|
675 { |
|
676 CEikButtonGroupContainer* cbaGroup = Cba(); |
|
677 if ( cbaGroup ) |
|
678 { |
|
679 HBufC* middleSKText = StringLoader::LoadLC( aResourceId ); |
|
680 TPtr mskPtr = middleSKText->Des(); |
|
681 cbaGroup->AddCommandToStackL( |
|
682 KGSMSKControlID, |
|
683 aCommandId, |
|
684 mskPtr ); |
|
685 CleanupStack::PopAndDestroy( middleSKText ); |
|
686 } |
|
687 } |
|
688 |
|
689 // --------------------------------------------------------------------------- |
|
690 // Sets middle softkey label. |
|
691 // --------------------------------------------------------------------------- |
|
692 // |
|
693 void CGSParentPlugin::SetMiddleSoftKeyLabelTextL( |
|
694 const TPtr aMskLabel, const TInt aCommandId ) |
|
695 { |
|
696 CEikButtonGroupContainer* cbaGroup = Cba(); |
|
697 if ( cbaGroup ) |
|
698 { |
|
699 cbaGroup->AddCommandToStackL( |
|
700 KGSMSKControlID, |
|
701 aCommandId, |
|
702 aMskLabel ); |
|
703 } |
|
704 } |
|
705 |
|
706 // --------------------------------------------------------------------------- |
|
707 // Returns selected plugin. |
|
708 // --------------------------------------------------------------------------- |
|
709 // |
|
710 EXPORT_C CGSPluginInterface* CGSParentPlugin::SelectedPlugin() |
|
711 { |
|
712 CGSPluginInterface* selectedPlugin = NULL; |
|
713 if( iContainer ) |
|
714 { |
|
715 selectedPlugin = iContainer->SelectedPlugin(); |
|
716 } |
|
717 return selectedPlugin; |
|
718 } |
|
719 |
|
720 |
|
721 void CGSParentPlugin::RequestPriority( CActive::TPriority aPriority ) |
|
722 { |
|
723 iPluginLoader->RequestPriority( aPriority ); |
|
724 __GSLOGSTRING2( "[CGSParentPlugin::RequestPriority] 0x%X aPriority:%d", Id().iUid, aPriority ); |
|
725 } |
|
726 |
|
727 // End of File |