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