satengine/SatServer/Commands/SetUpMenuCmd/src/CSetUpMenuHandler.cpp
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     1 /*
       
     2 * Copyright (c) 2002-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:  Handles the SetUpMenu command from SIM.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include    <MSatShellController.h>
       
    20 #include    "MSatApi.h"
       
    21 #include    "MSatUiSession.h"
       
    22 #include    "SatSOpcodes.h"
       
    23 #include    "MSatSUiClientHandler.h"
       
    24 #include    "CSetUpMenuHandler.h"
       
    25 #include    "SATPrivateCRKeys.h"
       
    26 #include    "SatLog.h"
       
    27 
       
    28 const TInt KMaxSatAppName = 30;
       
    29 
       
    30 // ======== MEMBER FUNCTIONS ========
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // CSetUpMenuHandler::CSetUpMenuHandler
       
    34 // C++ default constructor can NOT contain any code, that
       
    35 // might leave.
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 CSetUpMenuHandler::CSetUpMenuHandler() :
       
    39     CSatCommandHandler(),
       
    40     iSetUpMenuData(),
       
    41     iSetUpMenuPckg( iSetUpMenuData ),
       
    42     iArrivedSetUpMenuData(),
       
    43     iArrivedSetUpMenuPckg( iArrivedSetUpMenuData ),
       
    44     iSatAppNameUpdated( EFalse ),
       
    45     iSatServiceAvailable( EFalse ),
       
    46     // To be removed when icons are allowed in this command
       
    47     iIconCommand( EFalse )
       
    48     {
       
    49     LOG( SIMPLE,
       
    50         "SETUPMENU: CSetUpMenuHandler::CSetUpMenuHandler calling - exiting" )
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CSetUpMenuHandler::ConstructL
       
    55 // Symbian 2nd phase constructor can leave.
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 void CSetUpMenuHandler::ConstructL()
       
    59     {
       
    60     LOG( SIMPLE, "SETUPMENU: CSetUpMenuHandler::ConstructL calling" )
       
    61 
       
    62     // Register Service request handler for this command handler.
       
    63     iUtils->RegisterServiceRequestL(
       
    64         ESatSProactiveSetUpMenu,
       
    65         ESatSNone,
       
    66         this );
       
    67 
       
    68     // Remove the sat ui client icon from the shell, otherwise
       
    69     // sat icon remains in shell once set in shell.
       
    70     iUtils->SatUiHandler().ShellController().RemoveSatUiL();
       
    71 
       
    72     // When sim session arrives, setupmenu may need to be displayed.
       
    73     iUtils->RegisterL( this, MSatUtils::ESimSessionEndExecuting );
       
    74     iUtils->RegisterL( this, MSatUtils::ESatUiLaunched );
       
    75     iUtils->RegisterL( this, MSatUtils::ESetUpMenuNeeded );
       
    76     iUtils->RegisterL( this, MSatUtils::EApplNameUpdated );
       
    77     iUtils->RegisterL( this, MSatUtils::ESimResetCalled );
       
    78     iUtils->RegisterL( this, MSatUtils::ERemoveSatUiCalled );
       
    79     iUtils->RegisterL( this, MSatUtils::EAddSatUiCalled );
       
    80     iUtils->RegisterL( this, MSatUtils::ECallControlDone );
       
    81 
       
    82     LOG( SIMPLE, "SETUPMENU: CSetUpMenuHandler::ConstructL exiting" )
       
    83     }
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // CSetUpMenuHandler::NewL
       
    87 // Two-phased constructor.
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 CSetUpMenuHandler* CSetUpMenuHandler::NewL( MSatUtils* aUtils )
       
    91     {
       
    92     LOG( SIMPLE, "SETUPMENU: CSetUpMenuHandler::NewL calling" )
       
    93 
       
    94     CSetUpMenuHandler* self = new( ELeave ) CSetUpMenuHandler;
       
    95 
       
    96     CleanupStack::PushL( self );
       
    97     self->BaseConstructL( aUtils ); // Need to be called before ConstructL
       
    98     self->ConstructL();
       
    99     CleanupStack::Pop( self );
       
   100 
       
   101     LOG( SIMPLE, "SETUPMENU: CSetUpMenuHandler::NewL exiting" )
       
   102     return self;
       
   103     }
       
   104 
       
   105 
       
   106 // Destructor
       
   107 CSetUpMenuHandler::~CSetUpMenuHandler()
       
   108     {
       
   109     LOG( SIMPLE, "SETUPMENU: CSetUpMenuHandler::~CSetUpMenuHandler calling" )
       
   110 
       
   111     Cancel();
       
   112 
       
   113     LOG( SIMPLE, "SETUPMENU: CSetUpMenuHandler::~CSetUpMenuHandler exiting" )
       
   114     }
       
   115 
       
   116 // -----------------------------------------------------------------------------
       
   117 // CSetUpMenuHandler::ClientResponse
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 void CSetUpMenuHandler::ClientResponse()
       
   121     {
       
   122     // This is needed to prevent Panic when UI is closed right after start
       
   123     }
       
   124 
       
   125 // -----------------------------------------------------------------------------
       
   126 // CSetUpMenuHandler::Event
       
   127 // Event notification
       
   128 // -----------------------------------------------------------------------------
       
   129 //
       
   130 void CSetUpMenuHandler::Event( TInt aEvent )
       
   131     {
       
   132     LOG( SIMPLE, "SETUPMENU: CSetUpMenuHandler::Event calling" )
       
   133 
       
   134     switch ( aEvent )
       
   135         {
       
   136         // Sim session has arrived from SIM or ui launched
       
   137         case MSatUtils::ESatUiLaunched:
       
   138             {
       
   139             LOG( NORMAL, "SETUPMENU:   Event: ESatUiLaunched" )
       
   140             // Send SetUpMenu to ui client if ui client is running,
       
   141             // ui client is launced by user and the set up menu data
       
   142             // has arrived from SIM.
       
   143             if ( iSetUpMenuArrived )
       
   144                 {
       
   145                 LOG( NORMAL, "SETUPMENU:   Event: iSetUpMenuArrived true" )
       
   146                 SendSetUpMenuToClient();
       
   147                 }
       
   148             else
       
   149                 {
       
   150                 SendEmptySetupMenuToClient();
       
   151                 }
       
   152 
       
   153             break;
       
   154             }
       
   155 
       
   156         case MSatUtils::ESetUpMenuNeeded:
       
   157             {
       
   158             LOG( NORMAL, "SETUPMENU:   Event: ESetUpMenuNeeded" )
       
   159             // Some command has finished executing and needs SetUpMenu.
       
   160             SendSetUpMenuToClient();
       
   161             break;
       
   162             }
       
   163 
       
   164         case MSatUtils::EApplNameUpdated:
       
   165             {
       
   166             LOG( NORMAL, "SETUPMENU:   Event: EApplNameUpdated" )
       
   167             // Update SetUpMenu to ui client if ui client is running,
       
   168             // ui client is launced by user and the set up menu data
       
   169             // has arrived from SIM.
       
   170             TRAPD( err, UpdateSetUpMenuToClientL() );
       
   171             if ( KErrNone != err )
       
   172                 {
       
   173                 LOG2( SIMPLE, "SETUPMENU:   Error: %i", err )
       
   174                 }            
       
   175             break;
       
   176             }
       
   177 
       
   178         case MSatUtils::ESimSessionEndExecuting:
       
   179             {
       
   180             LOG( NORMAL, "SETUPMENU:   Event: ESimSessionEndExecuting" )
       
   181             // If the sim session end is only command active currently
       
   182             // then send the setupmenu to client.
       
   183             if ( 1 == iUtils->NumberOfExecutingCommandHandlers() )
       
   184                 {
       
   185                 LOG( NORMAL, "SETUPMENU:   Event: setupmenu" )
       
   186                 SendSetUpMenuToClient();
       
   187                 }
       
   188             break;
       
   189             }
       
   190 
       
   191         case MSatUtils::ESimResetCalled:
       
   192             {
       
   193             LOG( NORMAL, "SETUPMENU:   Event: ESimResetCalled" )
       
   194             // Close SatUi and remove Sat icon from application shell
       
   195             MSatUiSession* uiSession = iUtils->SatUiHandler().UiSession();
       
   196             if ( uiSession )
       
   197                 {
       
   198                 LOG( NORMAL, "SETUPMENU:   Event: CloseUiSession" )
       
   199                 uiSession->CloseUiSession();
       
   200                 }
       
   201             TRAP_IGNORE( RemoveIconFromShellL() )
       
   202             break;
       
   203             }
       
   204 
       
   205         case MSatUtils::EAddSatUiCalled:
       
   206             {
       
   207             LOG( NORMAL, "SETUPMENU:   Event: EAddSatUiCalled" )
       
   208             iSatServiceAvailable = ETrue;
       
   209             if ( iSetUpMenuArrived )
       
   210                 {
       
   211                 LOG( NORMAL, "SETUPMENU:   Event: iSetUpMenuArrived true" )
       
   212                 TRAP_IGNORE( AddIconToShellL(
       
   213                     iArrivedSetUpMenuData.iAlphaId.iAlphaId,
       
   214                     iArrivedSetUpMenuData.iIconId ) )
       
   215                 }
       
   216             break;
       
   217             }
       
   218 
       
   219         case MSatUtils::ERemoveSatUiCalled:
       
   220             {
       
   221             iSatServiceAvailable = EFalse;
       
   222             LOG( NORMAL, "SETUPMENU:   Event: ERemoveSatUiCalled" )
       
   223             // Close SAT UI and remove SAT icon from Application Shell.
       
   224             MSatUiSession* uiSession = iUtils->SatUiHandler().UiSession();
       
   225             if ( uiSession )
       
   226                 {
       
   227                 LOG( NORMAL, "SETUPMENU:   Event: CloseUiSession" )
       
   228                 uiSession->CloseUiSession();
       
   229                 }
       
   230             TRAP_IGNORE( RemoveIconFromShellL() )
       
   231             break;
       
   232             }
       
   233 
       
   234         case MSatUtils::ECallControlDone:
       
   235             {
       
   236             // If all commands end up, send the setupmenu to client.
       
   237             if ( 0 == iUtils->NumberOfExecutingCommandHandlers() )
       
   238                 {
       
   239                 LOG( NORMAL, "SETUPMENU:   Event: setupmenu" )
       
   240                 SendSetUpMenuToClient();
       
   241                 }
       
   242             break;
       
   243             }
       
   244 
       
   245         default:
       
   246             {
       
   247             LOG2( NORMAL, "SETUPMENU:   Unexpected event: %i", aEvent )
       
   248             CSatCommandHandler::Event( aEvent );
       
   249             }
       
   250         }
       
   251 
       
   252     LOG( SIMPLE, "SETUPMENU: CSetUpMenuHandler::Event exiting" )
       
   253     }
       
   254 
       
   255 // -----------------------------------------------------------------------------
       
   256 // CSetUpMenuHandler::DoCancel
       
   257 // Cancels the SetUpMenu notification from SIM.
       
   258 // -----------------------------------------------------------------------------
       
   259 //
       
   260 void CSetUpMenuHandler::DoCancel()
       
   261     {
       
   262     LOG( SIMPLE, "SETUPMENU: CSetUpMenuHandler::DoCancel calling" )
       
   263 
       
   264     iUtils->USatAPI().NotifySetUpMenuCancel();
       
   265 
       
   266     LOG( SIMPLE, "SETUPMENU: CSetUpMenuHandler::DoCancel exiting" )
       
   267     }
       
   268 
       
   269 // -----------------------------------------------------------------------------
       
   270 // CSetUpMenuHandler::AddIconToShellL
       
   271 // -----------------------------------------------------------------------------
       
   272 //
       
   273 void CSetUpMenuHandler::AddIconToShellL(
       
   274     const TDesC& aAlphaId, // Alpha id of SetUpMenu command
       
   275     const RSat::TIconId& aIconId ) // Icon id of SetUpMenu command
       
   276     {
       
   277     LOG( SIMPLE, "SETUPMENU: CSetUpMenuHandler::AddIconToShellL calling" )
       
   278     TPtrC name( aAlphaId );
       
   279 
       
   280     if ( 0 != aAlphaId.Length() )
       
   281         {
       
   282         LOG( SIMPLE, 
       
   283         "SETUPMENU: CSetUpMenuHandler::AddIconToShellL aAlphaId not null" )
       
   284         // Set new sat app name.
       
   285         iUtils->SetSatAppNameL( aAlphaId );
       
   286         }
       
   287     else
       
   288         {
       
   289         LOG( SIMPLE, 
       
   290         "SETUPMENU: CSetUpMenuHandler::AddIconToShellL aAlphaId null" )
       
   291         iUtils->RestoreSatAppNameL();
       
   292         name.Set( iUtils->SatAppName() );
       
   293         }
       
   294 
       
   295     // Menu application needs only a short name.
       
   296     if ( iUtils->SatAppName().Length() > KMaxSatAppName )
       
   297         {
       
   298         LOG( SIMPLE, 
       
   299         "SETUPMENU: CSetUpMenuHandler::AddIconToShellL AppName too long" )
       
   300         name.Set( iUtils->SatAppName().Left( KMaxSatAppName ) );
       
   301         }
       
   302     else
       
   303         {
       
   304         name.Set( iUtils->SatAppName() );
       
   305         }
       
   306 
       
   307     // Check if there is icon available.
       
   308     MSatShellController& controller = iUtils->SatUiHandler().ShellController();
       
   309     if ( ( RSat::ENoIconId == aIconId.iQualifier ) ||
       
   310          ( RSat::EIconQualifierNotSet == aIconId.iQualifier ) )
       
   311         {
       
   312         LOG( SIMPLE, 
       
   313         "SETUPMENU: CSetUpMenuHandler::AddIconToShellL no icon" )
       
   314         controller.AddSatUiL( name );
       
   315         }
       
   316     else
       
   317         {
       
   318         controller.AddSatUiL( name, aIconId.iIdentifier );
       
   319         }
       
   320 
       
   321     LOG( SIMPLE, "SETUPMENU: CSetUpMenuHandler::AddIconToShellL exiting" )
       
   322     }
       
   323 
       
   324 // -----------------------------------------------------------------------------
       
   325 // CSetUpMenuHandler::RemoveIconFromShellL
       
   326 // -----------------------------------------------------------------------------
       
   327 //
       
   328 void CSetUpMenuHandler::RemoveIconFromShellL()
       
   329     {
       
   330     LOG( SIMPLE, "SETUPMENU: CSetUpMenuHandler::RemoveIconFromShellL calling" )
       
   331 
       
   332     iUtils->SatUiHandler().ShellController().RemoveSatUiL();
       
   333 
       
   334     // Restore the original name of SAT application.
       
   335     iUtils->RestoreSatAppNameL();
       
   336 
       
   337     LOG( SIMPLE, "SETUPMENU: CSetUpMenuHandler::RemoveIconFromShellL exiting" )
       
   338     }
       
   339 
       
   340 // -----------------------------------------------------------------------------
       
   341 // CSetUpMenuHandler::SendSetUpMenuToClient
       
   342 // -----------------------------------------------------------------------------
       
   343 //
       
   344 void CSetUpMenuHandler::SendSetUpMenuToClient()
       
   345     {
       
   346     LOG( SIMPLE, "SETUPMENU: CSetUpMenuHandler::SendSetUpMenuToClient calling" )
       
   347 
       
   348     MSatUiSession* uiSession = iUtils->SatUiHandler().UiSession();
       
   349     if ( uiSession &&
       
   350          iUtils->SatUiHandler().UiLaunchedByUser() &&
       
   351          iSetUpMenuArrived )
       
   352         {
       
   353         LOG( SIMPLE, 
       
   354         "SETUPMENU: CSetUpMenuHandler::SendSetUpMenuToClient setupmenu" )
       
   355 
       
   356         // Does not update SIM application name when it is restored and service
       
   357         // is not available.
       
   358         if ( iSatServiceAvailable )
       
   359             {
       
   360             LOG( SIMPLE, 
       
   361             "SETUPMENU: CSetUpMenuHandler::SendSetUpMenuToClient \
       
   362             iSatServiceAvailable true" )
       
   363             // When ME is launched with special SIM and SetUpMenu made with
       
   364             // different name. Then also SetUpMenu data update is needed
       
   365             // when Menu name was already OK.
       
   366             iArrivedSetUpMenuData.iAlphaId.iAlphaId.Zero();
       
   367             iArrivedSetUpMenuData.iAlphaId.iAlphaId.Copy(
       
   368                 iUtils->SatAppName() );
       
   369             }
       
   370 
       
   371         // Client does not respond to setupmenu cmd, therefore NULL.
       
   372         uiSession->SendCommand(
       
   373             &iArrivedSetUpMenuPckg,
       
   374             NULL,
       
   375             ESatSProactiveSetUpMenu );
       
   376         }
       
   377 
       
   378     LOG( SIMPLE, "SETUPMENU: CSetUpMenuHandler::SendSetUpMenuToClient exiting" )
       
   379     }
       
   380 
       
   381 // -----------------------------------------------------------------------------
       
   382 // CSetUpMenuHandler::SendEmptySetupMenuToClient
       
   383 // -----------------------------------------------------------------------------
       
   384 //
       
   385 void CSetUpMenuHandler::SendEmptySetupMenuToClient()
       
   386     {
       
   387     LOG( SIMPLE, "SETUPMENU: CSetUpMenuHandler::SendEmptySetupMenuToClient\
       
   388      calling" )
       
   389 
       
   390     MSatUiSession* uiSession = iUtils->SatUiHandler().UiSession();
       
   391     if ( uiSession &&
       
   392          iUtils->SatUiHandler().UiLaunchedByUser() )
       
   393         {
       
   394         LOG( SIMPLE, "SETUPMENU: CSetUpMenuHandler::SendEmptySetupMenuToClient\
       
   395         send setupmenu" )
       
   396         // Client does not respond to setupmenu cmd, therefore NULL.
       
   397         uiSession->SendCommand(
       
   398             &iSetUpMenuPckg,
       
   399             NULL,
       
   400             ESatSProactiveSetUpMenu );
       
   401         }
       
   402 
       
   403     LOG( SIMPLE, "SETUPMENU: CSetUpMenuHandler::SendEmptySetupMenuToClient\
       
   404      exiting" )
       
   405     }
       
   406 
       
   407 // -----------------------------------------------------------------------------
       
   408 // CSetUpMenuHandler::UpdateSetUpMenuToClientL
       
   409 // -----------------------------------------------------------------------------
       
   410 //
       
   411 void CSetUpMenuHandler::UpdateSetUpMenuToClientL()
       
   412     {
       
   413     LOG( SIMPLE,
       
   414         "SETUPMENU: CSetUpMenuHandler::UpdateSetUpMenuToClientL calling" )
       
   415 
       
   416     iSatAppNameUpdated = ETrue;
       
   417     if ( iSetUpMenuArrived )
       
   418         {
       
   419         // SetUpMenu application name update is needed.
       
   420         iArrivedSetUpMenuData.iAlphaId.iAlphaId.Zero();
       
   421         iArrivedSetUpMenuData.iAlphaId.iAlphaId.Append( iUtils->SatAppName() );
       
   422         LOG( NORMAL, "SETUPMENU:   Name updated" )
       
   423 
       
   424         // Restore icon after update.
       
   425         AddIconToShellL(
       
   426             iArrivedSetUpMenuData.iAlphaId.iAlphaId,
       
   427             iArrivedSetUpMenuData.iIconId );
       
   428 
       
   429         // Update display, when ui is launched.
       
   430         MSatUiSession* uiSession = iUtils->SatUiHandler().UiSession();
       
   431         if ( uiSession && iUtils->SatUiHandler().UiLaunchedByUser() )
       
   432             {
       
   433             LOG( SIMPLE,
       
   434             "SETUPMENU: CSetUpMenuHandler::UpdateSetUpMenuToClientL \
       
   435             UiLaunchedByUser" )
       
   436             // Update it only when it is not empty.
       
   437             if ( 0 != iArrivedSetUpMenuData.NumberOfItems() )
       
   438                 {
       
   439                 LOG( SIMPLE,
       
   440                 "SETUPMENU: CSetUpMenuHandler::UpdateSetUpMenuToClientL \
       
   441                 item not empty" )
       
   442                 // Send update to ui.
       
   443                 // Client does not respond to setupmenu cmd, therefore NULL.
       
   444                 uiSession->SendCommand(
       
   445                     &iArrivedSetUpMenuPckg,
       
   446                     NULL,
       
   447                     ESatSProactiveSetUpMenu );
       
   448                 }
       
   449             }
       
   450         }
       
   451 
       
   452     LOG( SIMPLE,
       
   453         "SETUPMENU: CSetUpMenuHandler::UpdateSetUpMenuToClientL exiting" )
       
   454     }
       
   455 
       
   456 // -----------------------------------------------------------------------------
       
   457 // CSetUpMenuHandler::IssueUSATRequest
       
   458 // Makes the request of SetUpMenu from SIM
       
   459 // -----------------------------------------------------------------------------
       
   460 //
       
   461 void CSetUpMenuHandler::IssueUSATRequest( TRequestStatus& aStatus )
       
   462     {
       
   463     LOG( SIMPLE, "SETUPMENU: CSetUpMenuHandler::IssueUSATRequest calling" )
       
   464 
       
   465     // Without reset, old menu items stay in the list.
       
   466     iSetUpMenuData.Reset();
       
   467 
       
   468 #ifdef __WINS__
       
   469     // Empty the IPC data
       
   470     RSat::TSetUpMenuV2 temp;
       
   471     iSetUpMenuData = temp;
       
   472 #endif
       
   473 
       
   474     iUtils->USatAPI().NotifySetUpMenu( aStatus, iSetUpMenuPckg );
       
   475 
       
   476     LOG( SIMPLE, "SETUPMENU: CSetUpMenuHandler::IssueUSATRequestx exiting" )
       
   477     }
       
   478 
       
   479 // -----------------------------------------------------------------------------
       
   480 // CSetUpMenuHandler::CommandAllowed
       
   481 // SetUpMenu is allowed always.
       
   482 // -----------------------------------------------------------------------------
       
   483 //
       
   484 TBool CSetUpMenuHandler::CommandAllowed()
       
   485     {
       
   486     LOG( SIMPLE,
       
   487         "SETUPMENU: CSetUpMenuHandler::CommandAllowed calling" )
       
   488 
       
   489     TBool commandAllowed( ETrue );
       
   490     TBool nullText( EFalse );
       
   491     TInt err ( KErrNone );
       
   492     RSat::TItem item;
       
   493     TUint numberOfItems( iSetUpMenuData.NumberOfItems() );
       
   494     TBool titleIcon(
       
   495         ( RSat::ENotSelfExplanatory == iSetUpMenuData.iIconId.iQualifier ) ||
       
   496         ( RSat::ESelfExplanatory == iSetUpMenuData.iIconId.iQualifier ) );
       
   497     TBool itemIcons(
       
   498         ( RSat::ENotSelfExplanatory == iSetUpMenuData.iIconListQualifier ) ||
       
   499         ( RSat::ESelfExplanatory == iSetUpMenuData.iIconListQualifier ) );
       
   500     RSat::TSetUpMenuRspV1 setUpMenuRsp;
       
   501     RSat::TSetUpMenuRspV1Pckg setUpMenuRspPckg( setUpMenuRsp );
       
   502 
       
   503     // Check if some item does not have text
       
   504     for ( TUint count = 1; ( count <= numberOfItems ) && !nullText &&
       
   505         ( KErrNone == err ); count++ )
       
   506         {
       
   507         err = iSetUpMenuData.GetItem( count, item );
       
   508 
       
   509         if ( ( KErrNone == err ) && ( 0 == item.iItemString.Length() ) )
       
   510             {
       
   511             LOG( SIMPLE,
       
   512             "SETUPMENU: CSetUpMenuHandler::CommandAllowed item null" )
       
   513             nullText = ETrue;
       
   514             }
       
   515         }
       
   516     LOG2( SIMPLE,
       
   517     "SETUPMENU: CSetUpMenuHandler::CommandAllowed numberOfItems:%d",
       
   518     numberOfItems )
       
   519     // If icon is provided without any text
       
   520     if ( ( ( RSat::EAlphaIdProvided != iSetUpMenuData.iAlphaId.iStatus ) &&
       
   521              titleIcon ) || ( nullText && itemIcons ) )
       
   522         {
       
   523         setUpMenuRsp.iGeneralResult = RSat::KCmdDataNotUnderstood;
       
   524         setUpMenuRsp.iInfoType = RSat::KNoAdditionalInfo;
       
   525         setUpMenuRsp.iAdditionalInfo.Zero();
       
   526         setUpMenuRsp.SetPCmdNumber( setUpMenuRsp.PCmdNumber() );
       
   527         TerminalRsp( RSat::ESetUpMenu, setUpMenuRspPckg );
       
   528         commandAllowed = EFalse;
       
   529         LOG( NORMAL, "SETUPMENU: CSetUpMenuHandler::\
       
   530             CommandAllowed icon received without alpha id" )
       
   531         }
       
   532     // Set icon command flag whether icon data was received and set qualifier
       
   533     // to no icon id
       
   534     // To be removed when icons are allowed in this command
       
   535     else if ( !titleIcon && !itemIcons )
       
   536         {
       
   537         LOG( SIMPLE,
       
   538         "SETUPMENU: CSetUpMenuHandler::CommandAllowed no icon" )
       
   539         iIconCommand = EFalse;
       
   540         }
       
   541     else
       
   542         {
       
   543         iIconCommand = ETrue;
       
   544 
       
   545         if ( titleIcon )
       
   546             {
       
   547             LOG( SIMPLE,
       
   548             "SETUPMENU: CSetUpMenuHandler::CommandAllowed titleIcon true" )
       
   549             iSetUpMenuData.iIconId.iQualifier = RSat::ENoIconId;
       
   550             }
       
   551 
       
   552         if ( itemIcons )
       
   553             {
       
   554             LOG( SIMPLE,
       
   555             "SETUPMENU: CSetUpMenuHandler::CommandAllowed itemIcons true" )
       
   556             iSetUpMenuData.iIconListQualifier = RSat::ENoIconId;
       
   557             }
       
   558         }
       
   559 
       
   560     LOG2( SIMPLE,
       
   561     "SETUPMENU: CSetUpMenuHandler::CommandAllowed exiting,commandAllowed: %d",
       
   562     commandAllowed )
       
   563     return commandAllowed;
       
   564     }
       
   565 
       
   566 // -----------------------------------------------------------------------------
       
   567 // CSetUpMenuHandler::NeedUiSession
       
   568 // SetUpMenu command itself does not need ui session.
       
   569 // -----------------------------------------------------------------------------
       
   570 //
       
   571 TBool CSetUpMenuHandler::NeedUiSession()
       
   572     {
       
   573     LOG( SIMPLE,
       
   574         "SETUPMENU: CSetUpMenuHandler::NeedUiSession calling - exiting" )
       
   575     return EFalse;
       
   576     }
       
   577 
       
   578 // -----------------------------------------------------------------------------
       
   579 // CSetUpMenuHandler::HandleCommand
       
   580 // Handles the SetUpMenu proactive command.
       
   581 // -----------------------------------------------------------------------------
       
   582 //
       
   583 void CSetUpMenuHandler::HandleCommand()
       
   584     {
       
   585     LOG( SIMPLE, "SETUPMENU: CSetUpMenuHandler::HandleCommand calling" )
       
   586 
       
   587     // This could be moved to base class.
       
   588     iUtils->NotifyEvent( MSatUtils::ESetUpMenuExecuting );
       
   589 
       
   590     iArrivedSetUpMenuData = iSetUpMenuData;
       
   591 
       
   592     TInt err( KErrNone );
       
   593 
       
   594     if ( iSetUpMenuData.IsRemoveMenu() ||
       
   595          ( 0 == iSetUpMenuData.NumberOfItems() ) )
       
   596         {
       
   597         LOG( SIMPLE, 
       
   598         "SETUPMENU: CSetUpMenuHandler::HandleCommand remove icon" )
       
   599         TRAP( err, RemoveIconFromShellL() );
       
   600         }
       
   601     else
       
   602         {
       
   603         // If name has been changed prior launch of SetUpMenu, update name.
       
   604         if ( iSatAppNameUpdated )
       
   605             {
       
   606             LOG( SIMPLE, 
       
   607             "SETUPMENU: CSetUpMenuHandler::HandleCommand iSatAppNameUpdated" )
       
   608             iArrivedSetUpMenuData.iAlphaId.iAlphaId.Zero();
       
   609             }
       
   610 
       
   611         // Set SAT name to alpha id if alpha ID is zero.
       
   612         if ( 0 == iArrivedSetUpMenuData.iAlphaId.iAlphaId.Length() )
       
   613             {
       
   614             TRAP( err, iUtils->RestoreSatAppNameL() );
       
   615             iArrivedSetUpMenuData.iAlphaId.iAlphaId.Append(
       
   616                 iUtils->SatAppName() );
       
   617             LOG( NORMAL, 
       
   618             "SETUPMENU: CSetUpMenuHandler::HandleCommand Name updated" )
       
   619             }        
       
   620         //Rentain the title of "SIM card application" for special card
       
   621         else
       
   622             {
       
   623             // Set new sat app name.
       
   624             TRAP( err, iUtils->SetSatAppNameL( 
       
   625                                iArrivedSetUpMenuData.iAlphaId.iAlphaId ) );            
       
   626             iArrivedSetUpMenuData.iAlphaId.iAlphaId.Zero();
       
   627             iArrivedSetUpMenuData.iAlphaId.iAlphaId.Copy(
       
   628                 iUtils->SatAppName() );            
       
   629             }
       
   630             
       
   631         MSatUiSession* session = iUtils->SatUiHandler().UiSession();
       
   632         if ( session )
       
   633             {
       
   634             LOG( SIMPLE, 
       
   635             "SETUPMENU: CSetUpMenuHandler::HandleCommand session true" )
       
   636             // Send the setupmenu to ui client.
       
   637             session->SendCommand(
       
   638                 &iArrivedSetUpMenuPckg,
       
   639                 NULL,
       
   640                 ESatSProactiveSetUpMenu );
       
   641             }
       
   642 
       
   643         if ( KErrNone == err )
       
   644             {
       
   645             LOG( SIMPLE, 
       
   646             "SETUPMENU: CSetUpMenuHandler::HandleCommand AddIconToShellL" )
       
   647             TRAP( err, AddIconToShellL(
       
   648                 iArrivedSetUpMenuData.iAlphaId.iAlphaId,
       
   649                 iArrivedSetUpMenuData.iIconId ) );
       
   650             }
       
   651 
       
   652         }
       
   653 
       
   654     RSat::TSetUpMenuRspV1 setUpMenuRsp;
       
   655     RSat::TSetUpMenuRspV1Pckg setUpMenuRspPckg( setUpMenuRsp );
       
   656     setUpMenuRsp.iInfoType = RSat::KNoAdditionalInfo;
       
   657     setUpMenuRsp.iAdditionalInfo.Zero();
       
   658     setUpMenuRsp.SetPCmdNumber( iArrivedSetUpMenuData.PCmdNumber() );
       
   659 
       
   660     if ( KErrNone == err )
       
   661         {
       
   662         LOG( SIMPLE, 
       
   663         "SETUPMENU: CSetUpMenuHandler::HandleCommand no error" )
       
   664         iSetUpMenuArrived = ETrue;
       
   665         setUpMenuRsp.iGeneralResult = RSat::KSuccess;
       
   666         // If command had icon data and was done succesfully, report that icon
       
   667         // was not shown
       
   668         // To be removed when icons are allowed in this command
       
   669         // Result of icon showing must be received
       
   670         if ( iIconCommand )
       
   671             {
       
   672             LOG( SIMPLE, 
       
   673             "SETUPMENU: CSetUpMenuHandler::HandleCommand iIconCommand true" )
       
   674             setUpMenuRsp.iGeneralResult =
       
   675                         RSat::KSuccessRequestedIconNotDisplayed;
       
   676             }
       
   677         }
       
   678     else
       
   679         {
       
   680         LOG( SIMPLE, 
       
   681         "SETUPMENU: CSetUpMenuHandler::HandleCommand error" )
       
   682         setUpMenuRsp.iGeneralResult = RSat::KMeUnableToProcessCmd;
       
   683         }
       
   684 
       
   685     CSatCommandHandler::TerminalRsp( RSat::ESetUpMenu, setUpMenuRspPckg );
       
   686 
       
   687     LOG( SIMPLE, "SETUPMENU: CSetUpMenuHandler::HandleCommand exiting" )
       
   688     }
       
   689 
       
   690 // -----------------------------------------------------------------------------
       
   691 // CSetUpMenuHandler::UiLaunchFailed
       
   692 // -----------------------------------------------------------------------------
       
   693 //
       
   694 void CSetUpMenuHandler::UiLaunchFailed()
       
   695     {
       
   696     LOG( SIMPLE,
       
   697         "SETUPMENU: CSetUpMenuHandler::UiLaunchFailed calling - exiting" )
       
   698     // SetUpMenu command does not launch UI.
       
   699     }