idlehomescreen/xmluicontroller/src/aixuikonmenueventhandler.cpp
branchRCL_3
changeset 9 f966699dea19
parent 5 c743ef5928ba
child 12 119a7c064f0f
child 15 ff572dfe6d86
equal deleted inserted replaced
5:c743ef5928ba 9:f966699dea19
     1 /*
       
     2 * Copyright (c) 2007-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:  Used for handling XUIKON menu events
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "aixuikonmenueventhandler.h"
       
    20 #include "aiconsts.h"
       
    21 #include "aixmluiconstants.h"
       
    22 #include "aixmluiutils.h"
       
    23 
       
    24 #include "mxncomponentinterface.h"
       
    25 #include "xnmenuadapter.h"
       
    26 #include "xnappuiadapter.h"
       
    27 #include "xntext.h"
       
    28 #include "xnnodeappif.h"
       
    29 #include "xndomnode.h"
       
    30 #include "xndomlist.h"
       
    31 #include "xntype.h"
       
    32 #include <gulicon.h>
       
    33 #include <aiutility.h>
       
    34 #include <aistrparser.h>
       
    35 #include "aifweventhandler.h"
       
    36 #include "xnproperty.h"
       
    37 #include "xnuiengineappif.h"
       
    38 #include "xndompropertyvalue.h"
       
    39 #include <aipspropertyobserver.h>
       
    40 #include <avkondomainpskeys.h> 
       
    41 #include <aknviewappui.h>		//CaknViewAppui
       
    42 #include "xnplugindefs.h"
       
    43 
       
    44 _LIT8( KMenubar, "menubar" );
       
    45 _LIT8( KClass, "class" );
       
    46 _LIT8( KId, "id" );
       
    47 _LIT8( KEditWidget, "edit_widget" );
       
    48 _LIT8( KRemoveItem, "removeitem" );
       
    49 _LIT8( KWidget, "widget" );
       
    50 _LIT8( KRemovable, "removable" );
       
    51 _LIT ( KMenuItem, "menuitem");
       
    52 
       
    53 using namespace AiXmlUiController;
       
    54 
       
    55 
       
    56 // ---------------------------------------------------------------------------
       
    57 // FindFromContentModelL
       
    58 // ---------------------------------------------------------------------------
       
    59 // 
       
    60 static CXnNodeAppIf* FindFromContentModelL( CXnNodeAppIf* aNode )
       
    61     {
       
    62     if ( !aNode )
       
    63         {
       
    64         return NULL;
       
    65         }
       
    66 
       
    67     CXnProperty* node = aNode->GetPropertyL( KClass ); 
       
    68     if ( node && node->StringValue() == KContentSource )
       
    69         {
       
    70         return aNode;
       
    71         }
       
    72 
       
    73     // Recurse children        
       
    74     RPointerArray< CXnNodeAppIf > children( aNode->ChildrenL() );
       
    75     CleanupClosePushL( children );
       
    76 
       
    77     CXnNodeAppIf* retval( NULL );
       
    78 
       
    79     for ( TInt i = 0; i < children.Count(); i++ )
       
    80         {
       
    81         CXnNodeAppIf* node( FindFromContentModelL( children[i] ) );
       
    82 
       
    83         if ( node )
       
    84             {
       
    85             retval = node;
       
    86             break;
       
    87             }
       
    88         }
       
    89 
       
    90     CleanupStack::PopAndDestroy( &children );
       
    91 
       
    92     return retval;
       
    93     }
       
    94 
       
    95 // ---------------------------------------------------------------------------
       
    96 // FindFromConfigurationL
       
    97 // ---------------------------------------------------------------------------
       
    98 // 
       
    99 static CXnNodeAppIf* FindFromConfigurationL( CXnNodeAppIf* aNode )
       
   100     {
       
   101     if ( !aNode )
       
   102         {
       
   103         return NULL;
       
   104         }
       
   105     // Is this node type of settingsconfiguration
       
   106     if ( aNode->Type()->Type() == KSettingsConfiguration )
       
   107         {
       
   108         return aNode;
       
   109         }
       
   110 
       
   111     // Recurse children        
       
   112     RPointerArray< CXnNodeAppIf > children( aNode->ChildrenL() );
       
   113     CleanupClosePushL( children );
       
   114 
       
   115     CXnNodeAppIf* retval( NULL );
       
   116 
       
   117     for ( TInt i = 0; i < children.Count(); i++ )
       
   118         {               
       
   119         CXnNodeAppIf* node( FindFromConfigurationL( children[i] ) );
       
   120         
       
   121         if ( node )
       
   122             {
       
   123             retval = node;
       
   124             break;
       
   125             }
       
   126         }
       
   127 
       
   128     CleanupStack::PopAndDestroy( &children );
       
   129 
       
   130     return retval;
       
   131     }
       
   132 
       
   133 // ---------------------------------------------------------------------------
       
   134 // DeletePluginNames
       
   135 // ---------------------------------------------------------------------------
       
   136 // 
       
   137 static void DeletePluginNames( TAny* aObject )
       
   138     {
       
   139     reinterpret_cast<
       
   140         RPointerArray<HBufC16>*>( aObject )->ResetAndDestroy();
       
   141     }
       
   142 
       
   143 CAIXuikonMenuEventHandler::CAIXuikonMenuEventHandler( TXnUiEngineAppIf& aUiEngine,
       
   144                                                       MAiFwEventHandler* aFwEventHandler,
       
   145                                                       CXnAppUiAdapter* aAppUi )
       
   146   : iCurrentCBA( EAIMenuOff ),
       
   147     iUiEngine( &aUiEngine ),
       
   148     iFwEventHandler( aFwEventHandler ),
       
   149     iAppUi( aAppUi )
       
   150     {
       
   151     }
       
   152 
       
   153 void CAIXuikonMenuEventHandler::ConstructL()
       
   154     {
       
   155     iStrParser = AiUtility::CreateStrParserL();
       
   156     iKeylockObserver = AiUtility::CreatePSPropertyObserverL
       
   157         ( TCallBack( HandleKeylockEvent, this ),
       
   158             KPSUidAvkonDomain, KAknKeyguardStatus );  
       
   159     }
       
   160 
       
   161 void CAIXuikonMenuEventHandler::SetObserverL( const TDesC8& aParam, CXnDomNode* aEvent )
       
   162     {
       
   163     if ( aEvent )
       
   164         {
       
   165         CXnNodeAppIf* node( iUiEngine->FindNodeByIdL( aParam, aEvent->Namespace() ) );
       
   166         
       
   167         if ( node && node->Type()->Type() == KMenubar )
       
   168             {
       
   169             XnMenuInterface::MXnMenuInterface* menuIf( NULL );
       
   170             XnComponentInterface::MakeInterfaceL( menuIf, *node );
       
   171     
       
   172             if ( menuIf )
       
   173                 {
       
   174                 menuIf->SetObserver( *this );
       
   175                 }
       
   176             }
       
   177         }
       
   178     }
       
   179 
       
   180 TInt CAIXuikonMenuEventHandler::HandleKeylockEvent( TAny* aSelf )
       
   181     {
       
   182     // Stop displaying menu when keylock is activated.
       
   183     CAIXuikonMenuEventHandler* self = 
       
   184         static_cast<CAIXuikonMenuEventHandler*>( aSelf );
       
   185     TInt err = KErrNone;
       
   186     TInt value = EKeyguardNotActive;
       
   187     if ( self )
       
   188         {
       
   189         TInt err = self->iKeylockObserver->Get( value );
       
   190         if ( err == KErrNone )
       
   191             {
       
   192 			if ( value > EKeyguardNotActive )
       
   193 				{
       
   194 		        if ( self->iAppUi && self->iCurrentCBA == EAIMenuOn )
       
   195 		        	{
       
   196 		        	self->iAppUi->StopDisplayingMenuBar();
       
   197 		        	TRAP_IGNORE( self->iUiEngine->RefreshMenuL() );
       
   198 		        	}			
       
   199 				}        				
       
   200             }
       
   201         }
       
   202     return err;
       
   203     }
       
   204 
       
   205 CAIXuikonMenuEventHandler* CAIXuikonMenuEventHandler::NewL( TXnUiEngineAppIf& aUiEngine,
       
   206                                                             MAiFwEventHandler* aFwEventHandler,
       
   207                                                             CXnAppUiAdapter* aAppUi )
       
   208     {
       
   209     CAIXuikonMenuEventHandler* self = 
       
   210         new( ELeave ) CAIXuikonMenuEventHandler( aUiEngine, aFwEventHandler, aAppUi );
       
   211     CleanupStack::PushL( self );
       
   212     self->ConstructL();
       
   213     CleanupStack::Pop( self );
       
   214     return self;
       
   215     }
       
   216 
       
   217 CAIXuikonMenuEventHandler::~CAIXuikonMenuEventHandler()
       
   218     {
       
   219     Release ( iKeylockObserver );
       
   220     Release( iStrParser );
       
   221     delete iActivationEvent;
       
   222     delete iSettingsEvent;
       
   223                 
       
   224     // Delete stored label id's
       
   225     delete iMenuModeLskLabel;
       
   226     delete iMenuModeRskLabel;
       
   227     delete iNormalModeLskLabel;
       
   228     delete iNormalModeRskLabel;  
       
   229     }
       
   230 
       
   231 TBool CAIXuikonMenuEventHandler::HandleEventL( const TDesC8& aEventString8, CXnNodeAppIf* aOrigin, CXnDomNode* aEvent )
       
   232     {
       
   233     if ( aEventString8 == AiUiDef::xml::event::KScreenDeviceChange )
       
   234         {
       
   235         iUiEngine = iAppUi->UiEngineL();
       
   236         return ETrue;
       
   237         }
       
   238     else if ( aEventString8.Left(KAIDynamicMenuPrefixLen).Compare( KAIDynamicMenuPrefix ) != 0 )
       
   239         {
       
   240         // For optimization when dynamic menu prefix is not found from event string start
       
   241         // return immediate from here.
       
   242         return EFalse;
       
   243         }
       
   244 
       
   245     if ( (iCurrentCBA == EAIMenuOff && aEventString8.Find(KAIMenuEventIfMenuOff) >= 0 ) ||
       
   246         (iCurrentCBA == EAIMenuOn && aEventString8.Find(KAIMenuEventIfMenuOn) >= 0) )
       
   247         {
       
   248         TPtrC8 eventString;
       
   249         ParseParameterStringL(aEventString8, eventString);
       
   250         if ( !HandleEventL(eventString, aOrigin, aEvent ) )
       
   251             {
       
   252             // Default action from the event string
       
   253             HBufC16* eventString16 = NULL;
       
   254             eventString16 = iStrParser->CopyToBufferL( eventString16, eventString );
       
   255             CleanupStack::PushL( eventString16 );
       
   256             if ( iFwEventHandler && eventString16 )
       
   257                 {
       
   258                 iFwEventHandler->HandlePluginEvent( *eventString16 );
       
   259                 }
       
   260             CleanupStack::PopAndDestroy( eventString16 );
       
   261             }
       
   262         return ETrue;
       
   263         }
       
   264     else if ( aEventString8 == KAIMenuEventInitPluginItems )
       
   265         {
       
   266         if ( !aEvent )
       
   267             {
       
   268             return ETrue;
       
   269             }
       
   270 
       
   271         CXnDomList& children( aEvent->ChildNodes() );
       
   272 
       
   273         TInt count( children.Length() );
       
   274 
       
   275         for ( TInt i = 0; i < count; i++ )
       
   276             {
       
   277             CXnDomNode* node = static_cast< CXnDomNode* >( children.Item( i ) );
       
   278 
       
   279             const TDesC8& type( node->Name() );
       
   280 
       
   281             if ( type == XnPropertyNames::action::KProperty )
       
   282                 {
       
   283                 const TDesC8& id( node->AttributeValue( 
       
   284                                     XnPropertyNames::action::KValue ) );
       
   285 
       
   286                 if ( id != KNullDesC8 )
       
   287                     {
       
   288                     CXnNodeAppIf* nodeById( iUiEngine->FindNodeByIdL( id, aEvent->Namespace() ) );
       
   289                     
       
   290                     if ( nodeById )
       
   291                         {                            
       
   292                         TBool showItem( DynInitItemL( *nodeById, aOrigin ) ); 
       
   293                                                     
       
   294                         const TDesC8 *value( NULL );
       
   295                         
       
   296                         if ( showItem )
       
   297                             {
       
   298                             value = &XnPropertyNames::style::common::display::KBlock;
       
   299                             }
       
   300                         else
       
   301                             {
       
   302                             value = &XnPropertyNames::style::common::display::KNone;
       
   303                             }            
       
   304 
       
   305                         CXnDomStringPool& sp( aEvent->StringPool() );
       
   306 
       
   307                         // create property
       
   308                         CXnProperty* prop = CXnProperty::NewL( XnPropertyNames::style::common::KDisplay, 
       
   309                                                                *value, 
       
   310                                                                CXnDomPropertyValue::EString, 
       
   311                                                                sp );
       
   312 
       
   313                         CleanupStack::PushL( prop );
       
   314 
       
   315                         // and set it
       
   316                         nodeById->SetPropertyL( prop );
       
   317 
       
   318                         CleanupStack::Pop( prop );
       
   319                         }
       
   320                     }
       
   321                 }
       
   322             }
       
   323 
       
   324         return ETrue;
       
   325         }
       
   326     else if ( aEventString8 == KAIMenuEventInitEmptyItems  ||
       
   327               aEventString8 == KAIMenuEventInitWidgetItems )
       
   328         {
       
   329         if ( !aEvent )
       
   330             {
       
   331             return ETrue;
       
   332             }
       
   333 
       
   334         CXnProperty* pluginId( aOrigin->GetPropertyL( KPluginId ) );
       
   335         CXnProperty* pluginName( aOrigin->GetPropertyL( KPluginName ) );
       
   336 
       
   337         TBool showItem( EFalse );
       
   338 
       
   339         if ( aEventString8 == KAIMenuEventInitWidgetItems )
       
   340             {
       
   341             if( pluginId && pluginName && pluginName->StringValue() != KDummy8 )                        
       
   342                 {
       
   343                 // check if plugin can be removed
       
   344                 CXnProperty* removable = GetWidgetPropertyL(*aOrigin, KRemovable);
       
   345                 if ( removable && removable->StringValue() == XnPropertyNames::KFalse )
       
   346                     {
       
   347                     showItem = EFalse;
       
   348                     }
       
   349                 else
       
   350                     {
       
   351                     showItem = ETrue;
       
   352                     }
       
   353                 }                                
       
   354             }
       
   355         else
       
   356             {
       
   357             if ( pluginId && pluginName && pluginName->StringValue() == KDummy8 )
       
   358                 {
       
   359                 showItem = ETrue;
       
   360                 }
       
   361             }
       
   362 
       
   363         CXnDomList& children( aEvent->ChildNodes() );
       
   364 
       
   365         TInt count( children.Length() );
       
   366 
       
   367         for ( TInt i = 0; i < count; i++ )
       
   368             {
       
   369             CXnDomNode* node = static_cast< CXnDomNode* >( children.Item( i ) );
       
   370 
       
   371             const TDesC8& type( node->Name() );
       
   372 
       
   373             if ( type == XnPropertyNames::action::KProperty )
       
   374                 {
       
   375                 const TDesC8& id( node->AttributeValue( 
       
   376                                     XnPropertyNames::action::KValue ) );
       
   377 
       
   378                 if ( id != KNullDesC8 )
       
   379                     {
       
   380                     CXnNodeAppIf* nodeById( iUiEngine->FindNodeByIdL( id, aEvent->Namespace() ) );
       
   381 
       
   382                     if ( nodeById )
       
   383                         {
       
   384                         const TDesC8 *value( NULL );
       
   385 
       
   386                         if ( showItem )
       
   387                             {
       
   388                             value = &XnPropertyNames::style::common::display::KBlock;
       
   389                             }
       
   390                         else
       
   391                             {
       
   392                             value = &XnPropertyNames::style::common::display::KNone;
       
   393                             }
       
   394 
       
   395                         CXnDomStringPool& sp( aEvent->StringPool() );
       
   396 
       
   397                         // create property
       
   398                         CXnProperty* prop = CXnProperty::NewL( XnPropertyNames::style::common::KDisplay, 
       
   399                                                                *value, 
       
   400                                                                CXnDomPropertyValue::EString, 
       
   401                                                                sp );
       
   402 
       
   403                         CleanupStack::PushL( prop );
       
   404 
       
   405                         // and set it
       
   406                         nodeById->SetPropertyL( prop );
       
   407 
       
   408                         CleanupStack::Pop( prop );
       
   409                         }
       
   410                     }
       
   411                 }
       
   412             }
       
   413 
       
   414         return ETrue;
       
   415         }
       
   416     else if ( aEventString8.Find( KAIMenuEventIfMenuOff ) >= 0 )
       
   417         {
       
   418         return ETrue;
       
   419         }
       
   420     else if ( aEventString8.Find( KAIMenuEventIfMenuOn ) >= 0 )
       
   421         {
       
   422         return ETrue;
       
   423         }
       
   424     else if ( aEventString8.Compare( KAIMenuEventGenerateSetActivationEvent ) == 0 )
       
   425         {
       
   426         // Generate set plugin event
       
   427         if ( iFwEventHandler && iActivationEvent )
       
   428             {
       
   429             iFwEventHandler->HandlePluginEvent( *iActivationEvent );
       
   430             }
       
   431         return ETrue;
       
   432         }
       
   433     else if ( aEventString8.Find( KAIMenuEventSetActivationEvent ) >= 0 )
       
   434         {
       
   435         // find event string
       
   436         TPtrC8 eventString;
       
   437         ParseParameterStringL( aEventString8, eventString );
       
   438         delete iActivationEvent;
       
   439         iActivationEvent = NULL;
       
   440         // store activation event (plugin event string)
       
   441         iActivationEvent = iStrParser->CopyToBufferL( iActivationEvent, eventString );
       
   442         return ETrue;
       
   443         }
       
   444     else if (aEventString8.Compare( KAIMenuEventGenerateOpenSettingsEvent ) == 0)
       
   445         {
       
   446         // Generate set plugin event
       
   447         if ( iFwEventHandler && iSettingsEvent )
       
   448             {
       
   449             iFwEventHandler->HandlePluginEvent( *iSettingsEvent );
       
   450             }
       
   451         return ETrue;
       
   452         }
       
   453     else if ( aEventString8.Find( KAIMenuEventSetOpenSettingsnEvent ) >= 0 )
       
   454         {
       
   455         // find event string
       
   456         TPtrC8 eventString;
       
   457         ParseParameterStringL( aEventString8, eventString );
       
   458         delete iSettingsEvent;
       
   459         iSettingsEvent = NULL;
       
   460         // store activation event (plugin event string)
       
   461         iSettingsEvent = iStrParser->CopyToBufferL( iSettingsEvent, eventString );
       
   462         return ETrue;
       
   463         }
       
   464     else if ( aEventString8.Find( KAIMenuEventShowMenuItem ) >= 0 )
       
   465         {
       
   466         if (iCurrentCBA == EAIMenuOn)
       
   467             {
       
   468             // find node by id
       
   469             TPtrC8 menuItem;
       
   470             ParseParameterStringL( aEventString8, menuItem );
       
   471             // set visibility property to visible
       
   472             ShowMenuItemL( menuItem, ETrue, aEvent );
       
   473             }
       
   474         return ETrue;
       
   475         }
       
   476     else if ( aEventString8.Find( KAIMenuEventHideMenuItem ) >= 0 )
       
   477         {
       
   478         if ( iCurrentCBA == EAIMenuOn )
       
   479             {
       
   480             // find node by id
       
   481             TPtrC8 menuItem;
       
   482             ParseParameterStringL( aEventString8, menuItem );
       
   483             // set visibility property to visible
       
   484             ShowMenuItemL( menuItem, EFalse, aEvent );
       
   485             }
       
   486         return ETrue;
       
   487         }
       
   488     else if ( aEventString8.Find( KAIMenuEventShowHideMenuItem ) >= 0 )
       
   489             {
       
   490             if ( iCurrentCBA == EAIMenuOn )
       
   491                 {
       
   492                 // find node by id
       
   493                 TPtrC8 menuItem;
       
   494                 ParseParameterStringL( aEventString8, menuItem );
       
   495                 // set visibility property
       
   496                 if ( IsMenuItemVisibleL( menuItem, aEvent ) )
       
   497                     {
       
   498                     ShowMenuItemL( menuItem, EFalse, aEvent );
       
   499                     }
       
   500                 else
       
   501                     {
       
   502                     ShowMenuItemL( menuItem, ETrue, aEvent );
       
   503                     }
       
   504                 }
       
   505             return ETrue;
       
   506             }
       
   507     else if ( aEventString8.Compare( KAIMenuEventMenuOn ) == 0 )
       
   508         {
       
   509         if ( iCurrentCBA != EAIMenuOn )
       
   510             {
       
   511             // also updates current state
       
   512             SetCBALabelsL( EAIMenuOn, aEvent );
       
   513             }
       
   514         return ETrue;
       
   515         }
       
   516     else if ( aEventString8.Compare( KAIMenuEventMenuOff ) == 0 )
       
   517         {
       
   518         if ( iCurrentCBA != EAIMenuOff )
       
   519             {
       
   520             // also updates current state
       
   521             SetCBALabelsL( EAIMenuOff, aEvent );
       
   522             }
       
   523         return ETrue;
       
   524         }
       
   525     else if ( ( aEventString8.Find( KAIMenuEventShowAll ) ) >= 0 )
       
   526         {
       
   527         if ( iCurrentCBA == EAIMenuOn )
       
   528             {
       
   529             // Show all menu items. Xuikon actually open the menu it self..
       
   530             TPtrC8 menu;
       
   531             ParseParameterStringL( aEventString8, menu );
       
   532             ShowMenuL( ETrue, menu, aEvent );
       
   533             }
       
   534         return ETrue;
       
   535         }
       
   536     else if ( aEventString8.Find( KAIMenuEventRefresh ) >= 0 )
       
   537         {
       
   538         if ( iCurrentCBA == EAIMenuOn )
       
   539             {
       
   540             iUiEngine->RefreshMenuL();
       
   541             }
       
   542         return ETrue;
       
   543         }
       
   544     else if ( aEventString8.Find( KAIMenuEventHideAll ) >= 0 )
       
   545         {
       
   546         // Hide all menu items
       
   547         TPtrC8 menu;
       
   548         ParseParameterStringL( aEventString8, menu );
       
   549         ShowMenuL( EFalse, menu, aEvent );
       
   550         return ETrue;
       
   551         }
       
   552     else if ( aEventString8.Find( KAIMenuEventSetCloseAction ) >= 0 )
       
   553         {
       
   554         // Set menu mode close action / RSK action
       
   555         TPtrC8 closeActionId;
       
   556         ParseParameterStringL( aEventString8, closeActionId );
       
   557 
       
   558         // Store close action macroset node id
       
   559         iCloseActionId.Set( closeActionId );
       
   560         return ETrue;
       
   561         }
       
   562     else if ( aEventString8.Find( KAIMenuEventCloseAction ) >= 0 )
       
   563         {
       
   564         // Decide action
       
   565         if ( iCurrentCBA == EAIMenuOff )
       
   566             {
       
   567             TPtrC8 eventString;
       
   568             ParseParameterStringL( aEventString8, eventString );
       
   569             
       
   570             // Default action
       
   571             HBufC16* eventString16 = NULL;
       
   572             eventString16 = iStrParser->CopyToBufferL( eventString16, eventString );
       
   573             CleanupStack::PushL( eventString16 );
       
   574             if ( iFwEventHandler && eventString16 )
       
   575                 {
       
   576                 iFwEventHandler->HandlePluginEvent( *eventString16 );
       
   577                 }
       
   578             CleanupStack::PopAndDestroy( eventString16 );
       
   579             }
       
   580         else
       
   581             {
       
   582             DoMacrosetL( iCloseActionId, aEvent );
       
   583             }
       
   584         return ETrue;
       
   585         }
       
   586     else if ( aEventString8.Find( KAIMenuEventSetSoftKeyId ) >= 0 )
       
   587         {
       
   588         // Store softkey labels and label node id's
       
   589         TPtrC8 softkeyString;
       
   590         ParseParameterStringL( aEventString8, softkeyString );
       
   591         TPtrC8 softkeyId;
       
   592         ParseParameterStringL( softkeyString, softkeyId );
       
   593         if ( softkeyString.Find( KAIMenuModeLsk ) >= 0)
       
   594             {
       
   595             GetTextFromElementL( iMenuModeLskLabel, softkeyId, aEvent );
       
   596             if ( iMenuModeLskLabel && iMenuModeLskLabel->Length() <= 0 )
       
   597                 {
       
   598                 delete iMenuModeLskLabel;
       
   599                 iMenuModeLskLabel = NULL;
       
   600                 }
       
   601             iLskMenuModeNode.Set( softkeyId );
       
   602             }
       
   603         else if ( softkeyString.Find( KAIMenuModeRsk ) >= 0 )
       
   604             {
       
   605             GetTextFromElementL( iMenuModeRskLabel, softkeyId, aEvent );
       
   606             if ( iMenuModeLskLabel && iMenuModeRskLabel->Length() <= 0 )
       
   607                 {
       
   608                 delete iMenuModeRskLabel;
       
   609                 iMenuModeRskLabel = NULL;
       
   610                 }
       
   611             iRskMenuModeNode.Set( softkeyId );
       
   612             }
       
   613         else if ( softkeyString.Find( KAINormalModeLskLabel ) >= 0)
       
   614             {
       
   615             GetTextFromElementL( iNormalModeLskLabel, softkeyId, aEvent );
       
   616             iNormalModeLskLabelId.Set( softkeyId );
       
   617             }
       
   618         else if ( softkeyString.Find( KAINormalModeRskLabel ) >= 0)
       
   619             {
       
   620             GetTextFromElementL( iNormalModeRskLabel, softkeyId, aEvent );
       
   621             iNormalModeRskLabelId.Set( softkeyId );
       
   622             }
       
   623         else if ( softkeyString.Find( KAINormalModeLskIcon ) >= 0)
       
   624             {
       
   625             iNormalModeLskIconId.Set( softkeyId );
       
   626             }
       
   627         else if ( softkeyString.Find( KAINormalModeRskIcon ) >= 0)
       
   628             {
       
   629             iNormalModeRskIconId.Set( softkeyId );
       
   630             }
       
   631         else if ( softkeyString.Find( KAIMenuLsk ) >= 0)
       
   632             {
       
   633             iLskId.Set( softkeyId );
       
   634             }
       
   635         else if ( softkeyString.Find( KAIMenuRsk ) >= 0)
       
   636             {
       
   637             iRskId.Set( softkeyId );
       
   638             }
       
   639 
       
   640         return ETrue;
       
   641         }
       
   642     else if ( aEventString8.Find( KAIMenuEventSettingsReady ) >= 0)
       
   643         {
       
   644         SetCBALabelsL( EAIMenuOff, aEvent );
       
   645         return ETrue;
       
   646         }
       
   647     else if ( aEventString8.Find( KAIMenuEventDoMacroset ) >= 0 )
       
   648         {
       
   649         // Do defined macro set
       
   650         
       
   651         // Parse macroset node id
       
   652         TPtrC8 macroNodeId;
       
   653         ParseParameterStringL( aEventString8, macroNodeId );
       
   654         if ( macroNodeId != KNullDesC8 )
       
   655             {
       
   656             DoMacrosetL( macroNodeId, aEvent );
       
   657             }
       
   658         return ETrue;
       
   659         }
       
   660     else if ( aEventString8.Find( KAIMenuEventSetDynMenuItemObserver ) >= 0 )
       
   661         {
       
   662         TPtrC8 eventString;
       
   663         ParseParameterStringL( aEventString8, eventString );
       
   664         SetObserverL( eventString, aEvent );
       
   665         return ETrue;
       
   666         }
       
   667     else if ( aEventString8 ==  KAIToggleWidgetsState )
       
   668         {
       
   669         iFwEventHandler->SetPluginsVisibility( iUiEngine->WidgetsVisible() );
       
   670         return ETrue;
       
   671         }
       
   672     else
       
   673         {
       
   674         // Handlers for macroset operations
       
   675         TPtrC8 targetNodeName;
       
   676         ParseParameterStringL( aEventString8, targetNodeName );
       
   677         TBool handledEvent = EFalse;
       
   678         
       
   679         if ( targetNodeName != KNullDesC8 )
       
   680             {
       
   681             CXnNodeAppIf* eventTargetNode = NULL;
       
   682             if ( aEvent )
       
   683                 {
       
   684                 eventTargetNode = iUiEngine->FindNodeByIdL( targetNodeName, aEvent->Namespace() );
       
   685                 }
       
   686             if ( eventTargetNode )
       
   687                 {
       
   688                 handledEvent = HandleMacroOperationL(
       
   689                                     aEventString8, *eventTargetNode, *aEvent );
       
   690                 iUiEngine->RenderUIL( NULL );
       
   691                 }
       
   692             }
       
   693         return handledEvent;
       
   694         }
       
   695     }
       
   696 
       
   697 void CAIXuikonMenuEventHandler::ParseParameterStringL( const TDesC8& aSourcePtr,
       
   698                                                        TPtrC8& aTargetPtr )
       
   699     {
       
   700     // Parses parameter string between the first '(' and last ')'
       
   701     // Trailing and heading white spaces ARE NOT handled!
       
   702     
       
   703     const TInt separatorPos = aSourcePtr.Locate( KEventParameterSeparator );
       
   704     User::LeaveIfError( separatorPos );
       
   705 
       
   706     const TInt eventSeparatorPos = aSourcePtr.LocateReverse(
       
   707                                                 KEventParameterSeparatorEnd );
       
   708     User::LeaveIfError( eventSeparatorPos );
       
   709 
       
   710     // separatorPos + 1 must be smaller than eventSeparatorPos - 1
       
   711     User::LeaveIfError( ( eventSeparatorPos ) - ( separatorPos + 1 ) );
       
   712     
       
   713     // Extract event and parameter string
       
   714     TPtrC8 menuName( aSourcePtr.Mid( separatorPos + 1,
       
   715                                     ( eventSeparatorPos ) - ( separatorPos + 1 ) ) );
       
   716     
       
   717     aTargetPtr.Set( menuName );
       
   718     }
       
   719 
       
   720 void CAIXuikonMenuEventHandler::SetCBALabelsL( TAICBA aCBA, CXnDomNode* aEvent )
       
   721     {
       
   722     // Set CBA labels according to mode, to the predefined CBA nodes
       
   723     if ( (iLskId == KNullDesC8) || (iRskId == KNullDesC8) || !aEvent )
       
   724         {
       
   725         return;
       
   726         }
       
   727     CXnNodeAppIf* lskNode = iUiEngine->FindNodeByIdL( iLskId, aEvent->Namespace() );
       
   728     CXnNodeAppIf* rskNode = iUiEngine->FindNodeByIdL( iRskId, aEvent->Namespace() );
       
   729 
       
   730     TBool propertyUpdated = EFalse;
       
   731 
       
   732     if ( rskNode && lskNode )
       
   733         {
       
   734         CXnNodeAppIf* menuBar = lskNode->ParentL();
       
   735 
       
   736         XnMenuInterface::MXnMenuInterface* lskControl = NULL;
       
   737         XnMenuInterface::MXnMenuInterface* rskControl = NULL;
       
   738 
       
   739         if ( menuBar )
       
   740             {
       
   741             XnComponentInterface::MakeInterfaceL( lskControl, *menuBar );
       
   742             XnComponentInterface::MakeInterfaceL( rskControl, *menuBar );
       
   743             }
       
   744         if ( !lskControl || !rskControl )
       
   745             {
       
   746             return;
       
   747             }
       
   748         switch ( aCBA )
       
   749             {
       
   750             case EAIMenuOff:
       
   751                 {
       
   752                 CXnNodeAppIf* lskIconNode = NULL;
       
   753                 CXnNodeAppIf* rskIconNode = NULL;
       
   754                 XnImageInterface::MXnImageInterface* lskIconControl = NULL;
       
   755                 XnImageInterface::MXnImageInterface* rskIconControl = NULL;
       
   756                 if ( iNormalModeLskIconId != KNullDesC8 )
       
   757                     {
       
   758                     lskIconNode = iUiEngine->FindNodeByIdL( iNormalModeLskIconId, aEvent->Namespace() );
       
   759                     XnComponentInterface::MakeInterfaceL( lskIconControl, *lskIconNode );
       
   760                     }
       
   761 
       
   762                 if ( iNormalModeRskIconId != KNullDesC8 )
       
   763                     {
       
   764                     rskIconNode = iUiEngine->FindNodeByIdL( iNormalModeRskIconId, aEvent->Namespace() );
       
   765                     XnComponentInterface::MakeInterfaceL( rskIconControl, *rskIconNode );
       
   766                     }
       
   767 
       
   768                 // Try to set the icon, if the icon setting fails
       
   769                 // try to set the text
       
   770                 if ( !AttemptRestoreSoftkeyIconL( lskControl,
       
   771                      lskIconControl,
       
   772                      lskIconNode,
       
   773                      XnMenuInterface::MXnMenuInterface::ELeft ) )
       
   774                     {
       
   775                     if ( iNormalModeLskLabelId != KNullDesC8 )
       
   776                         {
       
   777                         GetTextFromElementL( iNormalModeLskLabel, iNormalModeLskLabelId, aEvent );
       
   778                         }
       
   779 
       
   780                     SetSoftkeyLabelL( lskControl, iNormalModeLskLabel,
       
   781                             XnMenuInterface::MXnMenuInterface::ELeft );
       
   782                     }
       
   783 
       
   784                 if ( !AttemptRestoreSoftkeyIconL( rskControl,
       
   785                      rskIconControl,
       
   786                      rskIconNode,
       
   787                      XnMenuInterface::MXnMenuInterface::ERight ) )
       
   788                     {
       
   789                     if ( iNormalModeRskLabelId != KNullDesC8 )
       
   790                         {
       
   791                         GetTextFromElementL( iNormalModeRskLabel, iNormalModeRskLabelId, aEvent );
       
   792                         }
       
   793 
       
   794                     SetSoftkeyLabelL( rskControl, iNormalModeRskLabel,
       
   795                             XnMenuInterface::MXnMenuInterface::ERight );
       
   796                     }
       
   797                 propertyUpdated = ETrue;
       
   798                 break;
       
   799                 }
       
   800             case EAIMenuOn:
       
   801                 {
       
   802                 // Need to set the bitmaps back after
       
   803                 // the menu is closed
       
   804                 iMenumodeBitmapLsk = NULL;
       
   805                 iMenumodeBitmapRsk = NULL;
       
   806                 if ( !iMenuModeLskLabel )
       
   807                     {
       
   808                     GetTextFromElementL( iMenuModeLskLabel, iLskMenuModeNode, aEvent );
       
   809                     }
       
   810                 SetSoftkeyLabelL( lskControl, iMenuModeLskLabel,
       
   811                         XnMenuInterface::MXnMenuInterface::ELeft );
       
   812 
       
   813                 if ( !iMenuModeRskLabel )
       
   814                     {
       
   815                     GetTextFromElementL( iMenuModeRskLabel, iRskMenuModeNode, aEvent );
       
   816                     }
       
   817                 SetSoftkeyLabelL( rskControl, iMenuModeRskLabel,
       
   818                         XnMenuInterface::MXnMenuInterface::ERight );
       
   819                 propertyUpdated = ETrue;
       
   820                 break;
       
   821                 }
       
   822             default:
       
   823                 break;
       
   824             }
       
   825         }
       
   826     iCurrentCBA = aCBA;
       
   827     if ( propertyUpdated )
       
   828         {
       
   829     	iUiEngine->RefreshMenuL();
       
   830         }
       
   831     }
       
   832 
       
   833 void CAIXuikonMenuEventHandler::ShowMenuL( TBool aShow, const TDesC8& aMenuId, CXnDomNode* aEvent )
       
   834     {
       
   835     if ( aEvent )
       
   836         {
       
   837         // Show or hide all menu items
       
   838         CXnNodeAppIf* lskNode = iUiEngine->FindNodeByIdL( aMenuId, aEvent->Namespace() );
       
   839 
       
   840         if ( lskNode )
       
   841             {
       
   842             RecurseChildrenL( aShow, lskNode );
       
   843             }
       
   844         }
       
   845     }
       
   846 
       
   847 void CAIXuikonMenuEventHandler::RecurseChildrenL( TBool aShow, CXnNodeAppIf* aNode )
       
   848     {
       
   849     RPointerArray<CXnNodeAppIf> children = aNode->ChildrenL();
       
   850     CleanupClosePushL( children );
       
   851 
       
   852     for ( TInt i=0; i<children.Count(); i++ )
       
   853         {
       
   854         CXnNodeAppIf* node = children[i];
       
   855         if ( node && ( node->Type()->Type() == KAIMenuItem || 
       
   856                        node->Type()->Type() == KAIMenu ) )
       
   857             {
       
   858             if ( aShow )
       
   859                 {
       
   860                 SetPropertyToNodeL( *node, XnPropertyNames::style::common::KVisibility,
       
   861                     XnPropertyNames::style::common::visibility::KVisible );
       
   862                 }
       
   863             else
       
   864                 {
       
   865                 SetPropertyToNodeL( *node, XnPropertyNames::style::common::KVisibility,
       
   866                     XnPropertyNames::style::common::visibility::KHidden );
       
   867                 }
       
   868 
       
   869             if ( node->Type()->Type() == KAIMenu )
       
   870                 {
       
   871                 RecurseChildrenL(aShow, node);
       
   872                 }
       
   873             }
       
   874         }
       
   875 
       
   876     CleanupStack::PopAndDestroy( &children );
       
   877     }
       
   878 
       
   879 void CAIXuikonMenuEventHandler::DoMacrosetL( const TDesC8& aMacrosetNodeId, CXnDomNode* aEvent )
       
   880     {
       
   881     if ( !aEvent )
       
   882         {
       
   883         return;
       
   884         }
       
   885     // Do operations in a macroset
       
   886     CXnNodeAppIf* actionNode = iUiEngine->FindNodeByIdL( aMacrosetNodeId, aEvent->Namespace() );
       
   887     if ( !actionNode )
       
   888         {
       
   889         return;
       
   890         }
       
   891     RPointerArray<CXnNodeAppIf> children = actionNode->ChildrenL();
       
   892     for ( TInt i=0; i<children.Count(); i++ )
       
   893         {
       
   894         CXnNodeAppIf* node = children[i];
       
   895         const TDesC8* value =
       
   896             PropertyValue( *node, XnPropertyNames::action::event::KName );
       
   897         if ( value )
       
   898             {
       
   899             // Set display none
       
   900             TPtrC8 targetNodeName;
       
   901             ParseParameterStringL( *value, targetNodeName );
       
   902             
       
   903             if ( targetNodeName != KNullDesC8 )
       
   904                 {
       
   905                 CXnNodeAppIf* eventTargetNode = iUiEngine->FindNodeByIdL( targetNodeName, aEvent->Namespace() );
       
   906                 if ( eventTargetNode )
       
   907                     {
       
   908                     HandleMacroOperationL( *value, *eventTargetNode, *aEvent );
       
   909                     }
       
   910                 }
       
   911             }
       
   912         }
       
   913     children.Reset();
       
   914     }
       
   915 
       
   916 void CAIXuikonMenuEventHandler::ShowMenuItemL( const TDesC8& aMenuItemId, TBool aShow, CXnDomNode* aEvent )
       
   917     {
       
   918     if ( aEvent )
       
   919         {
       
   920         // Show a single menuitem
       
   921         CXnNodeAppIf* itemNode = iUiEngine->FindNodeByIdL( aMenuItemId, aEvent->Namespace() );
       
   922         if ( itemNode && ( itemNode->Type()->Type() == KAIMenuItem ||
       
   923                            itemNode->Type()->Type() == KAIMenu ) )
       
   924             {
       
   925             if ( aShow )
       
   926                 {
       
   927                 SetPropertyToNodeL( *itemNode, XnPropertyNames::style::common::KVisibility,
       
   928                         XnPropertyNames::style::common::visibility::KVisible );
       
   929                 }
       
   930             else
       
   931                 {
       
   932                 SetPropertyToNodeL( *itemNode, XnPropertyNames::style::common::KVisibility,
       
   933                         XnPropertyNames::style::common::visibility::KHidden );
       
   934                 }
       
   935             }
       
   936         }
       
   937     }
       
   938 
       
   939 TBool CAIXuikonMenuEventHandler::IsMenuItemVisibleL( const TDesC8& aMenuItemId, CXnDomNode* aEvent )
       
   940     {
       
   941     TBool ret = EFalse;
       
   942     if ( aEvent )
       
   943         {
       
   944         CXnNodeAppIf* itemNode = iUiEngine->FindNodeByIdL( aMenuItemId, aEvent->Namespace() );
       
   945         if ( itemNode && ( itemNode->Type()->Type() == KAIMenuItem ||
       
   946                            itemNode->Type()->Type() == KAIMenu ) )
       
   947             {
       
   948             CXnProperty* visibility = itemNode->GetPropertyL( XnPropertyNames::style::common::KVisibility );
       
   949             if ( visibility && (visibility->StringValue() == XnPropertyNames::style::common::visibility::KVisible) )
       
   950                 {
       
   951                 ret = ETrue;
       
   952                 }
       
   953             }
       
   954         }
       
   955     return ret;
       
   956     }
       
   957 
       
   958 void CAIXuikonMenuEventHandler::GetTextFromElementL( HBufC8*& aMemberPtr,
       
   959                                                      const TDesC8& aItemId,
       
   960                                                      CXnDomNode* aEvent )
       
   961     {
       
   962     delete aMemberPtr;
       
   963     aMemberPtr = NULL;
       
   964     if ( aEvent )
       
   965         {
       
   966         CXnNodeAppIf* labelNode = iUiEngine->FindNodeByIdL( aItemId, aEvent->Namespace() );
       
   967         
       
   968         if ( labelNode )
       
   969             {
       
   970             if ( labelNode->Type() )
       
   971                 {
       
   972                 const TDesC8& type = labelNode->Type()->Type();
       
   973                 if ( type == XnTextInterface::MXnTextInterface::Type() )
       
   974                     {
       
   975                     XnTextInterface::MXnTextInterface* textControl = NULL;
       
   976                     XnComponentInterface::MakeInterfaceL( textControl, *labelNode );
       
   977                     if ( textControl )
       
   978                         {
       
   979                         // Set text
       
   980                         aMemberPtr = iStrParser->CopyToBufferL( aMemberPtr,
       
   981                                                                 *(textControl->Text()) );
       
   982                         }
       
   983                     }
       
   984                 }
       
   985             }
       
   986         }
       
   987     }
       
   988 
       
   989 TBool CAIXuikonMenuEventHandler::HandleMacroOperationL( const TDesC8& aSourcePtr,
       
   990                                                         CXnNodeAppIf& aTargetNode,
       
   991                                                         CXnDomNode& aEvent )
       
   992     {
       
   993     if ( aSourcePtr.Find( KAIMenuEventSetFocus ) >= 0 )
       
   994         {
       
   995         // Set focus
       
   996         aTargetNode.SetStateL( XnPropertyNames::style::common::KFocus );
       
   997         return ETrue;
       
   998         }
       
   999     else if ( aSourcePtr.Find( KAIMenuEventSetDisplayNone ) >= 0 )
       
  1000         {
       
  1001         SetPropertyToNodeL( aTargetNode, XnPropertyNames::style::common::KDisplay,
       
  1002                 XnPropertyNames::style::common::display::KNone );
       
  1003         return ETrue;
       
  1004         }
       
  1005     else if ( aSourcePtr.Find( KAIMenuEventSetDisplayBlock) >= 0 )
       
  1006         {
       
  1007         SetPropertyToNodeL( aTargetNode, XnPropertyNames::style::common::KDisplay,
       
  1008                 XnPropertyNames::style::common::display::KBlock );
       
  1009         return ETrue;
       
  1010         }
       
  1011     else 
       
  1012         {
       
  1013         HandleEventL( aSourcePtr, &aTargetNode, &aEvent );
       
  1014         return ETrue;
       
  1015         }
       
  1016     }
       
  1017 
       
  1018 TBool CAIXuikonMenuEventHandler::AttemptRestoreSoftkeyIconL(
       
  1019                             XnMenuInterface::MXnMenuInterface* aControl,
       
  1020                             XnImageInterface::MXnImageInterface* aIconControl,
       
  1021                             CXnNodeAppIf* aSourceNode,
       
  1022                             XnMenuInterface::MXnMenuInterface::TSoftKeyPosition aPos )
       
  1023     {
       
  1024     if ( aControl && aSourceNode )
       
  1025         {
       
  1026         const TDesC8* isVisible =
       
  1027                     PropertyValue( *aSourceNode,
       
  1028                             XnPropertyNames::style::common::KVisibility );
       
  1029 
       
  1030         // node not "visible" so assume that text has been published
       
  1031         // after image
       
  1032         if ( !isVisible || *isVisible == XnPropertyNames::style::common::visibility::KHidden )
       
  1033             {
       
  1034             return EFalse;
       
  1035             }
       
  1036 
       
  1037         CGulIcon* icon = NULL;
       
  1038         TBool transferOwnership = ETrue;
       
  1039         // First try to get the icon from image interface
       
  1040         if ( aIconControl )
       
  1041             {
       
  1042             CFbsBitmap* bitmap = NULL;
       
  1043             CFbsBitmap* mask = NULL;
       
  1044             aIconControl->ContentBitmaps( bitmap, mask );
       
  1045             if ( bitmap )
       
  1046                 {
       
  1047                 icon = CGulIcon::NewL( bitmap, mask );
       
  1048                 icon->SetBitmapsOwnedExternally( ETrue );
       
  1049                 // image adapter wants to keep ownership
       
  1050                 transferOwnership = EFalse;
       
  1051                 CleanupStack::PushL( icon );
       
  1052                 }
       
  1053             }
       
  1054         // Then try to load it ourselves.
       
  1055         if ( !icon )
       
  1056             {
       
  1057             const TDesC8* value =
       
  1058                 PropertyValue( *aSourceNode, XnPropertyNames::image::KPath );
       
  1059 
       
  1060             if ( value )
       
  1061                 {
       
  1062                 icon = LoadIconLC( *aSourceNode );
       
  1063                 icon->SetBitmapsOwnedExternally( ETrue );
       
  1064                 // transfer ownerhsip to menunode
       
  1065                 transferOwnership = ETrue;
       
  1066                 }
       
  1067             }
       
  1068         // This icon is already in menu, no need to set it
       
  1069         // again
       
  1070         if ( icon &&
       
  1071              (icon->Bitmap() == iMenumodeBitmapLsk ||
       
  1072              icon->Bitmap() == iMenumodeBitmapRsk) )
       
  1073             {
       
  1074             CleanupStack::PopAndDestroy( icon );
       
  1075             return ETrue;
       
  1076             }
       
  1077         else if ( icon )
       
  1078             {
       
  1079             switch ( aPos )
       
  1080                 {
       
  1081                 case XnMenuInterface::MXnMenuInterface::ELeft:
       
  1082                     iMenumodeBitmapLsk = icon->Bitmap();
       
  1083                     break;
       
  1084                 case XnMenuInterface::MXnMenuInterface::ERight:
       
  1085                     iMenumodeBitmapRsk = icon->Bitmap();
       
  1086                     break;
       
  1087                 default:
       
  1088                     break;
       
  1089                 }
       
  1090             aControl->SetSoftKeyImageL(
       
  1091                 icon->Bitmap(),
       
  1092                 icon->Mask(),
       
  1093                 aPos,
       
  1094                 ETrue, /* preserve aspect ratio */
       
  1095                 EFalse, /* !invert mask */
       
  1096                 transferOwnership
       
  1097                 );
       
  1098             CleanupStack::PopAndDestroy( icon );
       
  1099             return ETrue;
       
  1100             }
       
  1101         }
       
  1102     return EFalse;
       
  1103     }
       
  1104 
       
  1105 void CAIXuikonMenuEventHandler::SetSoftkeyLabelL(
       
  1106                             XnMenuInterface::MXnMenuInterface* aControl,
       
  1107                             const TDesC8* aLabel,
       
  1108                             XnMenuInterface::MXnMenuInterface::TSoftKeyPosition aPos )
       
  1109     {
       
  1110     if ( aControl && aLabel )
       
  1111         {
       
  1112         HBufC16* string16 = NULL;
       
  1113         string16 = iStrParser->CopyToBufferL( string16, *aLabel );
       
  1114         CleanupStack::PushL( string16 );
       
  1115         // Trapped because this will leave when setting the same again
       
  1116         TRAP_IGNORE(
       
  1117             aControl->SetSoftKeyTextL( *string16, aPos );
       
  1118             )
       
  1119         CleanupStack::PopAndDestroy( string16 );
       
  1120         }
       
  1121     }
       
  1122 
       
  1123 TBool CAIXuikonMenuEventHandler::InitEditModeMenuItemL( CXnNodeAppIf& aMenuItem, CXnNodeAppIf* aFocused, const TDesC8& aSource )
       
  1124     {
       
  1125     TBool showItem( EFalse );
       
  1126     CXnNodeAppIf* focused( aFocused );
       
  1127     
       
  1128     if ( focused && aSource == KContentModel )
       
  1129         {
       
  1130         CXnNodeAppIf* node = FindFromContentModelL( focused );
       
  1131         if ( !node ) 
       
  1132             {
       
  1133             // no plugin or no launch action
       
  1134             return showItem;
       
  1135             }
       
  1136         CXnProperty* plugin ( node->GetPropertyL( KName ) ) ;
       
  1137         if ( !plugin )
       
  1138             {
       
  1139             // no plugin or no launch action
       
  1140             return showItem;
       
  1141             }
       
  1142         HBufC* pluginName( plugin->StringValueL() );
       
  1143         CleanupStack::PushL( pluginName );
       
  1144         HBufC* item ( aMenuItem.GetPropertyL( KName )->StringValueL() ); 
       
  1145         CleanupStack::PushL( item );
       
  1146 
       
  1147         showItem = iFwEventHandler->HasMenuItem( *pluginName , *item );
       
  1148 
       
  1149         if ( showItem )
       
  1150             {
       
  1151             // pluginName/menuitem(item)
       
  1152             // Create launch event and store it to menuitem's property
       
  1153             HBufC8* eventstr = HBufC8::NewLC( pluginName->Length() 
       
  1154                                               + 15 // / ( ) 
       
  1155                                               + item->Length() );
       
  1156             TPtr8 str ( eventstr->Des() );
       
  1157             str.Copy( pluginName->Des() );
       
  1158             str.Append( TChar( '/' ));
       
  1159             str.Append( KMenuItem );
       
  1160             str.Append( TChar( '(' ));
       
  1161             str.Append( item->Des() );
       
  1162             str.Append( TChar( ')' ));
       
  1163 
       
  1164             CXnDomStringPool& sp( iUiEngine->StringPool() );
       
  1165 
       
  1166             CXnDomPropertyValue* newValue = CXnDomPropertyValue::NewL( sp );
       
  1167             CleanupStack::PushL( newValue );
       
  1168 
       
  1169             newValue->SetStringValueL( CXnDomPropertyValue::EString, str );
       
  1170 
       
  1171             CXnProperty* prop = CXnProperty::NewL( XnPropertyNames::menu::KEvent, 
       
  1172                                                    newValue, sp );
       
  1173 
       
  1174             CleanupStack::Pop( newValue );
       
  1175 
       
  1176             CleanupStack::PushL( prop );
       
  1177 
       
  1178             // and set it
       
  1179             aMenuItem.SetPropertyL( prop );
       
  1180             CleanupStack::Pop( prop );
       
  1181 
       
  1182             CleanupStack::PopAndDestroy(eventstr ); // eventstr, children
       
  1183             }
       
  1184 
       
  1185         CleanupStack::PopAndDestroy( item );
       
  1186         CleanupStack::PopAndDestroy( pluginName );
       
  1187         }
       
  1188     else if ( focused && aSource == KConfigurationModel ) 
       
  1189         {
       
  1190         CXnNodeAppIf* node( FindFromConfigurationL( focused ) );
       
  1191 
       
  1192         if ( node )
       
  1193             {
       
  1194             CXnProperty* launch( node->GetPropertyL( KLaunch ) );
       
  1195             CXnProperty* plugin( node->GetPropertyL( KName ) );
       
  1196 
       
  1197             if ( !launch || !plugin )
       
  1198                 {
       
  1199                 // no plugin or no launch action
       
  1200                 return showItem;
       
  1201                 }
       
  1202 
       
  1203             HBufC* pluginName( plugin->StringValueL() );
       
  1204             CleanupStack::PushL( pluginName );
       
  1205 
       
  1206             CXnProperty* prop( aMenuItem.GetPropertyL( KName ) );
       
  1207 
       
  1208             if ( prop )
       
  1209                 {
       
  1210                 HBufC* item( prop->StringValueL() );
       
  1211                 CleanupStack::PushL( item );
       
  1212 
       
  1213                 showItem = iFwEventHandler->HasMenuItem( *pluginName, *item );
       
  1214 
       
  1215                 CleanupStack::PopAndDestroy( item );
       
  1216                 }
       
  1217             else
       
  1218                 {
       
  1219                 showItem = iFwEventHandler->HasMenuItem( *pluginName, KNullDesC );
       
  1220                 }
       
  1221 
       
  1222             CleanupStack::PopAndDestroy( pluginName );
       
  1223 
       
  1224             if ( showItem )
       
  1225                 {
       
  1226                 // Create launch event and store it to menuitem's property
       
  1227                 RPointerArray<CXnNodeAppIf> children( node->ChildrenL() );
       
  1228                 CleanupClosePushL( children );
       
  1229 
       
  1230                 TInt count( children.Count() );
       
  1231 
       
  1232                 TInt length( launch->StringValue().Length() + 2 ); // +2 for '(' and ')'
       
  1233 
       
  1234                 for ( TInt i = 0; i < count; i++ )
       
  1235                     {
       
  1236                     if ( i > 0 )
       
  1237                         {
       
  1238                         length += 1;
       
  1239                         }
       
  1240 
       
  1241                     CXnProperty* prop( children[i]->GetPropertyL( KName ) );
       
  1242 
       
  1243                     if ( prop )
       
  1244                         {
       
  1245                         length += prop->StringValue().Length();
       
  1246                         }
       
  1247                     }
       
  1248 
       
  1249                 HBufC8* eventstr = HBufC8::NewLC( length );
       
  1250 
       
  1251                 TPtr8 str( eventstr->Des() );
       
  1252 
       
  1253                 str.Append( launch->StringValue() );
       
  1254 
       
  1255                 str.Append( TChar( '(' ) );
       
  1256 
       
  1257                 for ( TInt i = 0; i < count; i++ )
       
  1258                     {
       
  1259                     if ( i > 0 )
       
  1260                         {
       
  1261                         str.Append( TChar( ',' ) ); 
       
  1262                         }
       
  1263 
       
  1264                     CXnProperty* prop( children[i]->GetPropertyL( KName ) );
       
  1265 
       
  1266                     if ( prop )
       
  1267                         {
       
  1268                         str.Append( prop->StringValue() );
       
  1269                         }
       
  1270                     }
       
  1271 
       
  1272                 str.Append( TChar( ')' ) );
       
  1273 
       
  1274                 CXnDomStringPool& sp( iUiEngine->StringPool() );
       
  1275 
       
  1276                 CXnDomPropertyValue* newValue = CXnDomPropertyValue::NewL( sp );
       
  1277                 CleanupStack::PushL( newValue );
       
  1278 
       
  1279                 newValue->SetStringValueL( CXnDomPropertyValue::EString, str );
       
  1280 
       
  1281                 CXnProperty* prop = CXnProperty::NewL( XnPropertyNames::menu::KEvent, 
       
  1282                                                        newValue, sp );
       
  1283 
       
  1284                 CleanupStack::Pop( newValue );
       
  1285 
       
  1286                 CleanupStack::PushL( prop );
       
  1287 
       
  1288                 // and set it
       
  1289                 aMenuItem.SetPropertyL( prop );
       
  1290                 CleanupStack::Pop( prop );
       
  1291 
       
  1292                 CleanupStack::PopAndDestroy( 2, &children ); // eventstr, children
       
  1293                 }
       
  1294             }
       
  1295         }
       
  1296 
       
  1297     return showItem;
       
  1298     }
       
  1299 
       
  1300 TBool CAIXuikonMenuEventHandler::InitDefaultModeMenuItemL( CXnNodeAppIf& aMenuItem, CXnNodeAppIf* aFocused, const TDesC8& aSource )
       
  1301     {
       
  1302     TBool showItem( EFalse );
       
  1303     TInt len( 0 );
       
  1304     if ( aSource == KContentModel )
       
  1305         {
       
  1306         CXnProperty* prop( aMenuItem.GetPropertyL( KName ) );
       
  1307         if ( !prop )
       
  1308             {
       
  1309             return showItem;
       
  1310             }
       
  1311 
       
  1312         RPointerArray<HBufC16> plnNames;
       
  1313         CleanupStack::PushL( TCleanupItem( DeletePluginNames, &plnNames ) );
       
  1314 
       
  1315         CXnNodeAppIf* focused( aFocused );
       
  1316         HBufC* item ( prop->StringValueL() );
       
  1317 	    CleanupStack::PushL( item );
       
  1318 	   
       
  1319 	    if( item->Des() == KHSOnLine_OffLine() ) 
       
  1320 	    	{
       
  1321 	    	TBool webContent = EFalse;
       
  1322 	    	RPointerArray<CXnNodeAppIf> plugins = iUiEngine->FindNodeByClassL( KContentSource16 ) ;
       
  1323 	    	CleanupClosePushL( plugins );
       
  1324 			if( plugins.Count() <= 0  )
       
  1325 				{
       
  1326 				CleanupStack::PopAndDestroy(&plugins);
       
  1327 				CleanupStack::PopAndDestroy( item );
       
  1328 				CleanupStack::PopAndDestroy(&plnNames);
       
  1329 				return showItem;
       
  1330 				}
       
  1331 			for (TInt i = 0; i < plugins.Count(); i++)
       
  1332 				{
       
  1333 				 CXnProperty* property ( plugins[i]->GetPropertyL( KName ) ) ;
       
  1334 				 if ( property )
       
  1335 					 {
       
  1336 					 HBufC16* pluginName ( property->StringValueL() );
       
  1337 					 CleanupStack::PushL( pluginName ); 
       
  1338 					 if( iFwEventHandler->HasMenuItem( *pluginName , *item ) )
       
  1339 						 {
       
  1340                          webContent = ETrue;	 
       
  1341                          CleanupStack::PopAndDestroy( pluginName );
       
  1342 						 break;
       
  1343 						 }
       
  1344 				     CleanupStack::PopAndDestroy( pluginName );
       
  1345 					 }
       
  1346 				}
       
  1347 			CleanupStack::PopAndDestroy(&plugins);
       
  1348 			
       
  1349 			// At least one widget using web content
       
  1350 	    	if ( webContent )
       
  1351 	    		{
       
  1352 	    		CXnProperty* status( aMenuItem.GetPropertyL(KStatus) );
       
  1353 				if ( status )
       
  1354 					{
       
  1355 					HBufC* statusValue ( status->StringValueL() );
       
  1356 					CleanupStack::PushL( statusValue );
       
  1357 					if ( (statusValue->Des() == KHSOnLine()) && !iFwEventHandler->IsPluginsOnline() )
       
  1358 					   {
       
  1359 					   plnNames.AppendL( KHSOnLine().Alloc() );
       
  1360 					   len = KHSOnLine().Length();
       
  1361 					   }
       
  1362 					else if ( (statusValue->Des() == KHSOffLine()) && iFwEventHandler->IsPluginsOnline() )
       
  1363 					   {
       
  1364 					   plnNames.AppendL( KHSOffLine().Alloc() );
       
  1365 					   len = KHSOffLine().Length();
       
  1366 					   }
       
  1367 					 CleanupStack::PopAndDestroy( statusValue );
       
  1368 					}
       
  1369 	    		}
       
  1370 	    	}
       
  1371 	    else
       
  1372 	    	{
       
  1373 			if( focused )  
       
  1374 				{
       
  1375 				RPointerArray< CXnNodeAppIf > plugins;
       
  1376 				CleanupClosePushL( plugins );
       
  1377 				
       
  1378 				iUiEngine->GetPluginNodeArrayL( plugins );
       
  1379 							
       
  1380 				CXnNodeAppIf* node( NULL );
       
  1381 				
       
  1382 				for( ; focused; focused = focused->ParentL() )
       
  1383 					{
       
  1384 					if( plugins.Find( focused ) != KErrNotFound )
       
  1385 						{                    
       
  1386 						node = FindFromContentModelL( focused );                    
       
  1387 						break;
       
  1388 						}
       
  1389 					}
       
  1390 					
       
  1391 				CleanupStack::PopAndDestroy( &plugins );
       
  1392 							 
       
  1393 				 if( !node ) 
       
  1394 					 {
       
  1395 					 // no plugin or no launch action
       
  1396 					 CleanupStack::PopAndDestroy(item );
       
  1397 					 CleanupStack::PopAndDestroy(&plnNames);
       
  1398 					 return showItem;
       
  1399 					 }
       
  1400 				 CXnProperty* plugin ( node->GetPropertyL( KName ) ) ;
       
  1401 				 if( !plugin )
       
  1402 					{
       
  1403 					// no plugin or no launch action
       
  1404 					CleanupStack::PopAndDestroy(item );
       
  1405 					CleanupStack::PopAndDestroy(&plnNames);
       
  1406 					return showItem;
       
  1407 					}
       
  1408 				 HBufC16* pluginName( plugin->StringValueL() );
       
  1409 				 CleanupStack::PushL( pluginName );
       
  1410 				 if( iFwEventHandler->HasMenuItem( *pluginName , *item ) )
       
  1411 					 {
       
  1412 					 plnNames.AppendL( pluginName );
       
  1413 					 len += pluginName->Length();
       
  1414 					 CleanupStack::Pop( pluginName );
       
  1415 					 } 
       
  1416 				 else
       
  1417 					 {
       
  1418 					 CleanupStack::PopAndDestroy( pluginName );
       
  1419 					 }
       
  1420 				}
       
  1421 		   else
       
  1422 			   {
       
  1423 				RPointerArray<CXnNodeAppIf> plugins = iUiEngine->FindNodeByClassL( KContentSource16 ) ;
       
  1424 				if( plugins.Count() <= 0  )
       
  1425 					{
       
  1426 					CleanupStack::PopAndDestroy( item );
       
  1427 					CleanupStack::PopAndDestroy(&plnNames);
       
  1428 					return showItem;
       
  1429 					}
       
  1430 				CleanupClosePushL( plugins );
       
  1431 				for (TInt i = 0; i < plugins.Count(); i++)
       
  1432 					{
       
  1433 					 CXnProperty* property ( plugins[i]->GetPropertyL( KName ) ) ;
       
  1434 					 if ( property )
       
  1435 						 {
       
  1436 						 HBufC16* pluginName ( property->StringValueL() );
       
  1437 						 CleanupStack::PushL( pluginName ); 
       
  1438 						 if( iFwEventHandler->HasMenuItem( *pluginName , *item ) )
       
  1439 							 {
       
  1440 							 plnNames.AppendL( pluginName );	 
       
  1441 							 len += pluginName->Length();
       
  1442 							 CleanupStack::Pop( pluginName );
       
  1443 							 }
       
  1444 						 else
       
  1445 							 {
       
  1446 							 CleanupStack::PopAndDestroy( pluginName );
       
  1447 							 }
       
  1448 						 }
       
  1449 					}
       
  1450 				 CleanupStack::PopAndDestroy(&plugins);
       
  1451 			   }
       
  1452 	    	}
       
  1453 	    
       
  1454          TInt count = plnNames.Count();
       
  1455     	 if( count > 0 )
       
  1456             {
       
  1457             showItem = ETrue;
       
  1458             // [pluginName1,...]/menuitem(item)
       
  1459             // Create launch event and store it to menuitem's property
       
  1460             HBufC8* eventstr = HBufC8::NewLC( len + 
       
  1461                                               + 15 // / ( ) [ ]
       
  1462                                               + item->Length() );
       
  1463             TPtr8 str ( eventstr->Des() );
       
  1464             str.Copy( KOpenBrace );
       
  1465             for ( TInt i = 0; i < count; i++ )
       
  1466                 {
       
  1467                 str.Append( plnNames[i]->Des() );
       
  1468                 if ( i+1 != count ) str.Append( TChar( ',' ) );
       
  1469                 }
       
  1470             str.Append( KCloseBrace );
       
  1471             str.Append( TChar( '/' ) );
       
  1472             str.Append( KMenuItem );
       
  1473             str.Append( TChar( '(' ) );
       
  1474             str.Append( item->Des() );
       
  1475             str.Append( TChar( ')' ) );
       
  1476 
       
  1477             CXnDomStringPool& sp( iUiEngine->StringPool() );
       
  1478 
       
  1479             CXnDomPropertyValue* newValue = CXnDomPropertyValue::NewL( sp );
       
  1480             CleanupStack::PushL( newValue );
       
  1481 
       
  1482             newValue->SetStringValueL( CXnDomPropertyValue::EString, str );
       
  1483 
       
  1484             CXnProperty* prop = CXnProperty::NewL( XnPropertyNames::menu::KEvent, 
       
  1485                                                    newValue, sp );
       
  1486 
       
  1487             CleanupStack::Pop( newValue );
       
  1488 
       
  1489             CleanupStack::PushL( prop );
       
  1490 
       
  1491             // and set it
       
  1492             aMenuItem.SetPropertyL( prop );
       
  1493             CleanupStack::Pop( prop );
       
  1494 
       
  1495             CleanupStack::PopAndDestroy( eventstr ); // eventstr, children
       
  1496             }
       
  1497 
       
  1498         CleanupStack::PopAndDestroy( item );
       
  1499         CleanupStack::PopAndDestroy( &plnNames );
       
  1500         }
       
  1501     else if ( aFocused && aSource == KConfigurationModel ) 
       
  1502         {
       
  1503         CXnNodeAppIf* node( FindFromConfigurationL( aFocused ) );
       
  1504 
       
  1505         if ( node )
       
  1506             {
       
  1507             CXnProperty* launch( node->GetPropertyL( KLaunch ) );
       
  1508             CXnProperty* plugin( node->GetPropertyL( KName ) );
       
  1509 
       
  1510             if ( !launch || !plugin )
       
  1511                 {
       
  1512                 // no plugin or no launch action
       
  1513                 return showItem;
       
  1514                 }
       
  1515 
       
  1516             HBufC* pluginName( plugin->StringValueL() );
       
  1517             CleanupStack::PushL( pluginName );
       
  1518 
       
  1519             CXnProperty* prop( aMenuItem.GetPropertyL( KName ) );
       
  1520 
       
  1521             if ( prop )
       
  1522                 {
       
  1523                 HBufC* item( prop->StringValueL() );
       
  1524                 CleanupStack::PushL( item );
       
  1525 
       
  1526                 showItem = iFwEventHandler->HasMenuItem( *pluginName, *item );
       
  1527 
       
  1528                 CleanupStack::PopAndDestroy( item );
       
  1529                 }
       
  1530             else
       
  1531                 {
       
  1532                 showItem = iFwEventHandler->HasMenuItem( *pluginName, KNullDesC );
       
  1533                 }
       
  1534 
       
  1535             CleanupStack::PopAndDestroy( pluginName );
       
  1536 
       
  1537             if ( showItem )
       
  1538                 {
       
  1539                 // Create launch event and store it to menuitem's property
       
  1540                 RPointerArray<CXnNodeAppIf> children( node->ChildrenL() );
       
  1541                 CleanupClosePushL( children );
       
  1542 
       
  1543                 TInt count( children.Count() );
       
  1544 
       
  1545                 TInt length( launch->StringValue().Length() + 2 ); // +2 for '(' and ')'
       
  1546 
       
  1547                 for ( TInt i = 0; i < count; i++ )
       
  1548                     {
       
  1549                     if ( i > 0 )
       
  1550                         {
       
  1551                         length += 1;
       
  1552                         }
       
  1553 
       
  1554                     CXnProperty* prop( children[i]->GetPropertyL( KName ) );
       
  1555 
       
  1556                     if ( prop )
       
  1557                         {
       
  1558                         length += prop->StringValue().Length();
       
  1559                         }
       
  1560                     }
       
  1561 
       
  1562                 HBufC8* eventstr = HBufC8::NewLC( length );
       
  1563 
       
  1564                 TPtr8 str( eventstr->Des() );
       
  1565 
       
  1566                 str.Append( launch->StringValue() );
       
  1567 
       
  1568                 str.Append( TChar( '(' ) );
       
  1569 
       
  1570                 for ( TInt i = 0; i < count; i++ )
       
  1571                     {
       
  1572                     if ( i > 0 )
       
  1573                         {
       
  1574                         str.Append( TChar( ',' ) ); 
       
  1575                         }
       
  1576 
       
  1577                     CXnProperty* prop( children[i]->GetPropertyL( KName ) );
       
  1578 
       
  1579                     if ( prop )
       
  1580                         {
       
  1581                         str.Append( prop->StringValue() );
       
  1582                         }
       
  1583                     }
       
  1584 
       
  1585                 str.Append( TChar( ')' ) );
       
  1586 
       
  1587                 CXnDomStringPool& sp( iUiEngine->StringPool() );
       
  1588 
       
  1589                 CXnDomPropertyValue* newValue = CXnDomPropertyValue::NewL( sp );
       
  1590                 CleanupStack::PushL( newValue );
       
  1591 
       
  1592                 newValue->SetStringValueL( CXnDomPropertyValue::EString, str );
       
  1593 
       
  1594                 CXnProperty* prop = CXnProperty::NewL( XnPropertyNames::menu::KEvent, 
       
  1595                                                        newValue, sp );
       
  1596 
       
  1597                 CleanupStack::Pop( newValue );
       
  1598 
       
  1599                 CleanupStack::PushL( prop );
       
  1600 
       
  1601                 // and set it
       
  1602                 aMenuItem.SetPropertyL( prop );
       
  1603                 CleanupStack::Pop( prop );
       
  1604 
       
  1605                 CleanupStack::PopAndDestroy( 2, &children ); // eventstr, children
       
  1606                 }
       
  1607             }
       
  1608         }
       
  1609 
       
  1610     // Currently we don't support default mode dynamic menu item for ConfigurationModel
       
  1611     return showItem;
       
  1612     }
       
  1613 
       
  1614 CXnProperty* CAIXuikonMenuEventHandler::GetWidgetPropertyL(CXnNodeAppIf& aPlugin, const TDesC8& aProperty)
       
  1615     {
       
  1616     CXnProperty* retval = NULL;
       
  1617     RPointerArray<CXnNodeAppIf> children(aPlugin.ChildrenL());
       
  1618     CleanupClosePushL( children );
       
  1619     TInt childCount = children.Count();
       
  1620     for (TInt i = 0; i < childCount; i++)
       
  1621         {
       
  1622         //search for widget element and get given property
       
  1623         CXnNodeAppIf* widget = children[i];
       
  1624         if (widget && widget->InternalDomNodeType() == KWidget)
       
  1625             {
       
  1626             retval = widget->GetPropertyL(aProperty);
       
  1627             i = childCount;
       
  1628             }
       
  1629         }
       
  1630     CleanupStack::PopAndDestroy( &children );
       
  1631     return retval;
       
  1632     }
       
  1633 
       
  1634 TBool CAIXuikonMenuEventHandler::DynInitItemL( CXnNodeAppIf& aMenuItem, CXnNodeAppIf* aFocused )
       
  1635     {
       
  1636     CXnProperty* prop( aMenuItem.GetPropertyL( KSource ) );
       
  1637     if ( prop )
       
  1638         {
       
  1639         if ( prop && prop->StringValue().Length() > 0 )
       
  1640             {
       
  1641             if ( iUiEngine->IsEditMode() )
       
  1642                 {
       
  1643                 return InitEditModeMenuItemL( aMenuItem, aFocused, prop->StringValue() );
       
  1644                 }
       
  1645             else
       
  1646                 {
       
  1647                 return InitDefaultModeMenuItemL( aMenuItem, aFocused, prop->StringValue() ); 
       
  1648                 }
       
  1649             }
       
  1650         }
       
  1651     else
       
  1652         {
       
  1653         CXnProperty* idProp( aMenuItem.GetPropertyL( KId ) );
       
  1654         if ( idProp )
       
  1655             {
       
  1656             const TDesC8& id = idProp->StringValue();
       
  1657             if ( id == KEditWidget )
       
  1658                 {                
       
  1659                 if ( aFocused )
       
  1660                     {
       
  1661                     for ( CXnNodeAppIf* candidate = aFocused; candidate; candidate = candidate->ParentL() )
       
  1662                         {
       
  1663                         if ( candidate->InternalDomNodeType() == KPlugin && !iUiEngine->IsEditMode() )
       
  1664                             {
       
  1665                             return ETrue;
       
  1666                             }
       
  1667                         }
       
  1668                     }
       
  1669                 }
       
  1670             else if( id == KRemoveItem && iUiEngine->IsEditMode() )
       
  1671                 {
       
  1672                 // get plugin node from focused
       
  1673                 CXnNodeAppIf* node = aFocused;
       
  1674                 CXnNodeAppIf* pluginNode = NULL;
       
  1675                 for(; node && node->Type()->Type() != KView; node = node->ParentL() )
       
  1676                     {
       
  1677                     CXnProperty* configurationId( node->GetPropertyL( KConfigurationId ) );
       
  1678                     CXnProperty* pluginId( node->GetPropertyL( KPluginId ) );
       
  1679                     
       
  1680                     if( configurationId && pluginId )
       
  1681                         {           
       
  1682                         pluginNode = node;
       
  1683                         break;
       
  1684                         }
       
  1685                     }
       
  1686                 
       
  1687                 if( pluginNode )
       
  1688                     {
       
  1689                     // check if plugin can be removed
       
  1690                     CXnProperty* removable = GetWidgetPropertyL(*pluginNode, KRemovable);
       
  1691                     if ( removable && removable->StringValue() == XnPropertyNames::KFalse )
       
  1692                         {
       
  1693                         return EFalse;
       
  1694                         }
       
  1695                     // hide menu item if the focused plugin is an "empty" widget
       
  1696                     CXnProperty* pluginName = pluginNode->GetPropertyL( KPluginName );
       
  1697                     if( pluginName )
       
  1698                         {
       
  1699                         const TDesC8& nameStr = pluginName->StringValue();
       
  1700                         if( nameStr == KDummy8 )
       
  1701                             {
       
  1702                             return EFalse;
       
  1703                             }
       
  1704                         else
       
  1705                             {
       
  1706                             return ETrue;
       
  1707                             }
       
  1708                         }
       
  1709                     }
       
  1710                 }
       
  1711             }
       
  1712         }
       
  1713         
       
  1714     return EFalse;        
       
  1715     }
       
  1716 
       
  1717 
       
  1718 TBool CAIXuikonMenuEventHandler::DynInitMenuItemL( CXnNodeAppIf& aMenuItem )
       
  1719     {      
       
  1720     TBool ret = EFalse;
       
  1721     if( !iUiEngine->WidgetsVisible() )
       
  1722         {
       
  1723         // only online/offline dynamic menu item is allowed to show now
       
  1724         CXnProperty* prop( aMenuItem.GetPropertyL(KName) );
       
  1725         if ( prop )
       
  1726         	{
       
  1727         	HBufC* item ( prop->StringValueL() );
       
  1728         	CleanupStack::PushL( item );
       
  1729         	if (item->Des() == KHSOnLine_OffLine() )
       
  1730         		{
       
  1731         		ret = DynInitItemL( aMenuItem, iUiEngine->FocusedNode() );
       
  1732         		}
       
  1733         	CleanupStack::PopAndDestroy( item );
       
  1734         	}
       
  1735         }
       
  1736     else
       
  1737     	{
       
  1738     	ret = DynInitItemL( aMenuItem, iUiEngine->FocusedNode() );
       
  1739     	}
       
  1740     return ret;
       
  1741     }
       
  1742