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