phonebookui/Phonebook2/ccapplication/ccacommlauncherplugin/src/ccappcommlaunchermenuhandler.cpp
branchRCL_3
changeset 63 f4a778e096c2
child 64 c1e8ba0c2b16
child 74 6b5524b4f673
equal deleted inserted replaced
62:5b6f26637ad3 63:f4a778e096c2
       
     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:  Implementation of ccappcommlauncher menuhandler
       
    15 *
       
    16 */
       
    17 
       
    18 #include "ccappcommlauncherheaders.h"
       
    19 
       
    20 #include <mccacontactobserver.h>
       
    21 #include <mccappengine.h>
       
    22 
       
    23 #include <mnproviderfinder.h>
       
    24 #include <mnprovider.h>
       
    25 
       
    26 using namespace AiwContactAssign;
       
    27 
       
    28 // ======== MEMBER FUNCTIONS ========
       
    29 
       
    30 // ---------------------------------------------------------------------------
       
    31 // CCCAppCommLauncherMenuHandler::NewL
       
    32 // ---------------------------------------------------------------------------
       
    33 //
       
    34 CCCAppCommLauncherMenuHandler* CCCAppCommLauncherMenuHandler::NewL(
       
    35     CCCAppCommLauncherPlugin& aPlugin )
       
    36     {
       
    37     CCA_DP(KCommLauncherLogFile, CCA_L("->CCCAppCommLauncherMenuHandler::NewL()"));
       
    38     CCCAppCommLauncherMenuHandler* self = new ( ELeave ) CCCAppCommLauncherMenuHandler( aPlugin );
       
    39     CleanupStack::PushL( self );
       
    40     self->ConstructL();
       
    41     CleanupStack::Pop( self );
       
    42     CCA_DP(KCommLauncherLogFile, CCA_L("<-CCCAppCommLauncherMenuHandler::NewL()"));
       
    43     return self;
       
    44     }
       
    45 
       
    46 // ---------------------------------------------------------------------------
       
    47 // CCCAppCommLauncherMenuHandler::~CCCAppCommLauncherMenuHandler
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 CCCAppCommLauncherMenuHandler::~CCCAppCommLauncherMenuHandler()
       
    51     {
       
    52     CCA_DP(KCommLauncherLogFile, CCA_L("~CCCAppCommLauncherMenuHandler()"));
       
    53     // iView is deleted through the alfdisplay
       
    54     delete iPbkCmd;
       
    55     delete iAiwServiceHandler;
       
    56     if ( iInputBlock )
       
    57         {
       
    58         iInputBlock->Cancel();
       
    59         }    
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // CCCAppCommLauncherMenuHandler::CCCAppCommLauncherMenuHandler()
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 CCCAppCommLauncherMenuHandler::CCCAppCommLauncherMenuHandler(
       
    67     CCCAppCommLauncherPlugin& aPlugin ) :
       
    68         iPlugin( aPlugin ),iInputBlock( NULL )
       
    69     {
       
    70     CCA_DP(KCommLauncherLogFile, CCA_L("CCCAppCommLauncherMenuHandler()"));
       
    71     }
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // CCCAppCommLauncherMenuHandler::ConstructL
       
    75 // ---------------------------------------------------------------------------
       
    76 //
       
    77 void CCCAppCommLauncherMenuHandler::ConstructL()
       
    78     {
       
    79     CCA_DP(KCommLauncherLogFile, CCA_L("CCCAppCommLauncherMenuHandler::ConstructL()"));
       
    80     PrepareAiwMenusL();
       
    81     }
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // CCCAppCommLauncherMenuHandler::PrepareAiwMenusL
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 void CCCAppCommLauncherMenuHandler::PrepareAiwMenusL()
       
    88     {
       
    89     CCA_DP(KCommLauncherLogFile, CCA_L("->CCCAppCommLauncherMenuHandler::PrepareAiwMenusL()"));
       
    90 
       
    91     // Initialisation of AIW Servicehandler cannot be in
       
    92     // ConstructL, since the menus of plugin are given
       
    93     // later via ProvideApplicationResourcesL(..)
       
    94     iAiwServiceHandler = CAiwServiceHandler::NewL();
       
    95     iAiwServiceHandler->AttachL(
       
    96         R_CCACOMMLAUNCHER_AIW_SERVICE_INTERESTS );
       
    97     iAiwServiceHandler->AttachMenuL(
       
    98         R_CCACOMMLAUNCHER_MENUPANE,
       
    99         R_CCACOMMLAUNCHER_AIW_MENU_INTERESTS );
       
   100 
       
   101     CCA_DP(KCommLauncherLogFile, CCA_L("<-CCCAppCommLauncherMenuHandler::PrepareAiwMenusL()"));
       
   102     }
       
   103 
       
   104 // ---------------------------------------------------------------------------
       
   105 // CCCAppCommLauncherMenuHandler::AknInputBlockCancel
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 void CCCAppCommLauncherMenuHandler::AknInputBlockCancel()
       
   109     {
       
   110     iInputBlock = NULL;
       
   111     }
       
   112 
       
   113 // ---------------------------------------------------------------------------
       
   114 // CCCAppCommLauncherMenuHandler::StopInputBlock
       
   115 // ---------------------------------------------------------------------------
       
   116 //
       
   117 void CCCAppCommLauncherMenuHandler::StopInputBlock()
       
   118     {
       
   119     // stop user input blocker
       
   120     if( iInputBlock )
       
   121         {
       
   122         iInputBlock->Cancel();
       
   123         }
       
   124     }
       
   125 
       
   126 // ---------------------------------------------------------------------------
       
   127 // CCCAppCommLauncherMenuHandler::SetContactStore
       
   128 // ---------------------------------------------------------------------------
       
   129 //
       
   130 void CCCAppCommLauncherMenuHandler::SetContactStore(
       
   131     const TCmsContactStore& aStore )
       
   132     {
       
   133     CCA_DP(KCommLauncherLogFile, CCA_L("CCCAppCommLauncherMenuHandler::SetContactStore() - %d"), (TInt)aStore );
       
   134     iContactStore = aStore;
       
   135     }
       
   136 
       
   137 // ---------------------------------------------------------------------------
       
   138 // CCCAppCommLauncherMenuHandler::DynInitMenuPaneL
       
   139 // ---------------------------------------------------------------------------
       
   140 //
       
   141 void CCCAppCommLauncherMenuHandler::DynInitMenuPaneL(
       
   142     TInt aResourceId,
       
   143     CEikMenuPane* aMenuPane )
       
   144     {
       
   145     CCA_DP(KCommLauncherLogFile, CCA_L("->CCCAppCommLauncherMenuHandler::DynInitMenuPaneL()"));
       
   146 
       
   147     if ( iAiwServiceHandler->HandleSubmenuL( *aMenuPane ))
       
   148         return;
       
   149 
       
   150     switch ( aResourceId )
       
   151         {
       
   152         case R_CCACOMMLAUNCHER_MENUPANE:
       
   153             {
       
   154             SelectDynInitMenuPaneL( aMenuPane );
       
   155 
       
   156             if ( iAiwServiceHandler->IsAiwMenu( aResourceId ))
       
   157                 {
       
   158                 
       
   159                 iAiwServiceHandler->InitializeMenuPaneL(
       
   160                     *aMenuPane, aResourceId, ECCAppCommLauncherAiwBaseCmd,
       
   161                     iAiwServiceHandler->InParamListL() );
       
   162                 }
       
   163             break;
       
   164             }
       
   165         default:
       
   166             break;
       
   167         }
       
   168 
       
   169     CCA_DP(KCommLauncherLogFile, CCA_L("<-CCCAppCommLauncherMenuHandler::DynInitMenuPaneL()"));
       
   170     }
       
   171 
       
   172 // ---------------------------------------------------------------------------
       
   173 // CCCAppCommLauncherMenuHandler::SelectDynInitMenuPaneL
       
   174 // ---------------------------------------------------------------------------
       
   175 //
       
   176 void CCCAppCommLauncherMenuHandler::SelectDynInitMenuPaneL(
       
   177     CEikMenuPane* aMenuPane )
       
   178     {
       
   179     CCA_DP(KCommLauncherLogFile, CCA_L("->CCCAppCommLauncherMenuHandler::SelectDynInitMenuPaneL()"));
       
   180 
       
   181     switch ( iContactStore )
       
   182         {
       
   183         case ECmsContactStorePbk :
       
   184             PbkContactDynInitMenuPaneL( aMenuPane );
       
   185             break;
       
   186         case ECmsContactStoreSim :
       
   187             SimContactDynInitMenuPaneL( aMenuPane );
       
   188             break;
       
   189         case ECmsContactStoreSdn :
       
   190             SdnContactDynInitMenuPaneL( aMenuPane );
       
   191             break;
       
   192         case ECmsContactStoreXsp :
       
   193             XspContactDynInitMenuPaneL( aMenuPane );
       
   194             break;
       
   195         default:
       
   196             CCA_DP(KCommLauncherLogFile, CCA_L("::DynInitMenuPaneL() - unsupported store type"));
       
   197             break;
       
   198         }
       
   199 
       
   200     CCA_DP(KCommLauncherLogFile, CCA_L("<-CCCAppCommLauncherMenuHandler::SelectDynInitMenuPaneL()"));
       
   201     }
       
   202 
       
   203 // ---------------------------------------------------------------------------
       
   204 // CCCAppCommLauncherMenuHandler::PbkContactDynInitMenuPaneL
       
   205 // ---------------------------------------------------------------------------
       
   206 //
       
   207 void CCCAppCommLauncherMenuHandler::PbkContactDynInitMenuPaneL(
       
   208     CEikMenuPane* aMenuPane )
       
   209     {
       
   210     CCA_DP(KCommLauncherLogFile, CCA_L("->CCCAppCommLauncherMenuHandler::ContactDynInitMenuPaneL()"));
       
   211 
       
   212     DynInitSelectMenuItemL( aMenuPane );
       
   213     DynInitSelectOtherMenuItemL( aMenuPane );
       
   214 
       
   215     CCA_DP(KCommLauncherLogFile, CCA_L("<-CCCAppCommLauncherMenuHandler::ContactDynInitMenuPaneL()"));
       
   216     }
       
   217 
       
   218 // ---------------------------------------------------------------------------
       
   219 // CCCAppCommLauncherMenuHandler::SimContactDynInitMenuPaneL
       
   220 // ---------------------------------------------------------------------------
       
   221 //
       
   222 void CCCAppCommLauncherMenuHandler::SimContactDynInitMenuPaneL(
       
   223     CEikMenuPane* aMenuPane )
       
   224     {
       
   225     CCA_DP(KCommLauncherLogFile, CCA_L("->CCCAppCommLauncherMenuHandler::SimContactDynInitMenuPaneL()"));
       
   226 
       
   227     DynInitSelectMenuItemL( aMenuPane );
       
   228     aMenuPane->DeleteMenuItem( ECCAppCommLauncherSelectOtherNmbCmd );
       
   229     aMenuPane->DeleteMenuItem( ECCAppCommLauncherSelectOtherAddrCmd );
       
   230     aMenuPane->DeleteMenuItem( ECCAppCommLauncherDefaultsCmd );
       
   231     aMenuPane->DeleteMenuItem( ECCAppCommLauncherVoiceTagDetailsCmd );
       
   232 
       
   233     CCA_DP(KCommLauncherLogFile, CCA_L("<-CCCAppCommLauncherMenuHandler::SimContactDynInitMenuPaneL()"));
       
   234 
       
   235     }
       
   236 
       
   237 // ---------------------------------------------------------------------------
       
   238 // CCCAppCommLauncherMenuHandler::SdnContactDynInitMenuPaneL
       
   239 // ---------------------------------------------------------------------------
       
   240 //
       
   241 void CCCAppCommLauncherMenuHandler::SdnContactDynInitMenuPaneL(
       
   242     CEikMenuPane* aMenuPane )
       
   243     {
       
   244     CCA_DP(KCommLauncherLogFile, CCA_L("->CCCAppCommLauncherMenuHandler::SdnContactDynInitMenuPaneL()"));
       
   245 
       
   246     DynInitSelectMenuItemL( aMenuPane );
       
   247     aMenuPane->DeleteMenuItem( ECCAppCommLauncherSelectOtherNmbCmd );
       
   248     aMenuPane->DeleteMenuItem( ECCAppCommLauncherSelectOtherAddrCmd );
       
   249     aMenuPane->DeleteMenuItem( KAiwCmdAssign );
       
   250     aMenuPane->DeleteMenuItem( ECCAppCommLauncherDefaultsCmd );
       
   251     aMenuPane->DeleteMenuItem( ECCAppCommLauncherVoiceTagDetailsCmd );
       
   252     aMenuPane->DeleteMenuItem( ECCAppCommLauncherDeleteCmd );
       
   253 
       
   254     CCA_DP(KCommLauncherLogFile, CCA_L("<-CCCAppCommLauncherMenuHandler::SdnContactDynInitMenuPaneL()"));
       
   255     }
       
   256 
       
   257 // ---------------------------------------------------------------------------
       
   258 // CCCAppCommLauncherMenuHandler::DynInitSelectMenuItemL
       
   259 // ---------------------------------------------------------------------------
       
   260 //
       
   261 void CCCAppCommLauncherMenuHandler::DynInitSelectMenuItemL(
       
   262     CEikMenuPane* aMenuPane )
       
   263     {
       
   264     CCA_DP(KCommLauncherLogFile, CCA_L("->CCCAppCommLauncherMenuHandler::DynInitSelectMenuItemL()"));
       
   265     
       
   266     if ( !iPlugin.Container().CommMethodsAvailable() )
       
   267         {// no comm methods available
       
   268         aMenuPane->DeleteMenuItem( ECCAppCommLauncherSelectCmd );
       
   269         // ECCAppCommLauncherDefaultsCmd is deleted in the SimContactDynInitMenuPaneL() method
       
   270         if (iContactStore != ECmsContactStoreSim)
       
   271             {
       
   272             aMenuPane->DeleteMenuItem( ECCAppCommLauncherDefaultsCmd );
       
   273             }
       
   274         }
       
   275     else
       
   276     	{
       
   277         CCCAppCommLauncherContactHandler& contactHandler = iPlugin.ContactHandler();
       
   278         
       
   279         // Get the number how many addresses are defined.
       
   280         const TInt addressAmount = 
       
   281              contactHandler.AddressAmount( VPbkFieldTypeSelectorFactory::EFindOnMapSelector);
       
   282         
       
   283         // If the amount of address is not 0 and the amount of listbox in launcher view is 1.
       
   284         // That means only address is defined in the contact.
       
   285         if ( ( addressAmount > 0 ) 
       
   286         	   && ( iPlugin.Container().GetListBoxItemAmount() == 1 ) )
       
   287         	{
       
   288         	aMenuPane->DeleteMenuItem( ECCAppCommLauncherDefaultsCmd );
       
   289         	}
       
   290     	}
       
   291     
       
   292     CCA_DP(KCommLauncherLogFile, CCA_L("<-CCCAppCommLauncherMenuHandler::DynInitSelectMenuItemL()"));
       
   293     }
       
   294 
       
   295 // ---------------------------------------------------------------------------
       
   296 // CCCAppCommLauncherMenuHandler::DynInitSelectOtherMenuItemL
       
   297 // ---------------------------------------------------------------------------
       
   298 //
       
   299 void CCCAppCommLauncherMenuHandler::DynInitSelectOtherMenuItemL(
       
   300     CEikMenuPane* aMenuPane )
       
   301     {
       
   302     CCA_DP(KCommLauncherLogFile, CCA_L("->CCCAppCommLauncherMenuHandler::DynInitSelectOtherMenuItemL()"));
       
   303 
       
   304     if ( iPlugin.Container().CommMethodsAvailable() && 
       
   305     		iPlugin.Container().IsListBoxHighlightEnabled())
       
   306         {// comm methods available, continue..
       
   307         VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector contactAction =
       
   308             iPlugin.Container().SelectedCommunicationMethod();
       
   309         CCCAppCommLauncherContactHandler& contactHandler = iPlugin.ContactHandler();//not owned
       
   310 
       
   311         if ( contactHandler.IsItNumberAddress( contactAction ))
       
   312             {
       
   313             aMenuPane->DeleteMenuItem( ECCAppCommLauncherSelectOtherAddrCmd );
       
   314 
       
   315             if ( contactHandler.AddressAmount( contactAction ) < 2
       
   316                  || !contactHandler.HasDefaultAttribute( contactAction ))
       
   317                 {
       
   318                 aMenuPane->DeleteMenuItem( ECCAppCommLauncherSelectOtherNmbCmd );
       
   319                 }
       
   320             }
       
   321         else
       
   322             {
       
   323             aMenuPane->DeleteMenuItem( ECCAppCommLauncherSelectOtherNmbCmd );
       
   324 
       
   325             if ( contactHandler.AddressAmount( contactAction ) < 2
       
   326                  || !contactHandler.HasDefaultAttribute( contactAction ))
       
   327                 {
       
   328                 aMenuPane->DeleteMenuItem( ECCAppCommLauncherSelectOtherAddrCmd );
       
   329                 }
       
   330             }
       
   331         }
       
   332     else
       
   333         {// no comm methods available or Listbox highlight is disabled, don't show anything
       
   334         aMenuPane->DeleteMenuItem( ECCAppCommLauncherSelectOtherNmbCmd );
       
   335         aMenuPane->DeleteMenuItem( ECCAppCommLauncherSelectOtherAddrCmd );
       
   336         }
       
   337 
       
   338     CCA_DP(KCommLauncherLogFile, CCA_L("<-CCCAppCommLauncherMenuHandler::DynInitSelectOtherMenuItemL()"));
       
   339     }
       
   340 
       
   341 // ---------------------------------------------------------------------------
       
   342 // CCCAppCommLauncherMenuHandler::HandleCommandL
       
   343 // ---------------------------------------------------------------------------
       
   344 //
       
   345 void CCCAppCommLauncherMenuHandler::HandleCommandL( TInt aCommand )
       
   346     {
       
   347     CCA_DP(KCommLauncherLogFile, CCA_L("->CCCAppCommLauncherMenuHandler::HandleCommandL()"));
       
   348 
       
   349     // Check and handle the Aiw commands 1st
       
   350     TInt aiwCmd = iAiwServiceHandler->ServiceCmdByMenuCmd( aCommand );
       
   351     if( aiwCmd )
       
   352         {
       
   353         DoAiwCommandL( aCommand, aiwCmd );
       
   354         return;// aCommand should not match with non-Aiw commands, but just to be sure
       
   355         }
       
   356 
       
   357     // Then check if command is normal application command
       
   358     switch( aCommand )
       
   359         {
       
   360         case EAknSoftkeySelect:
       
   361         case ECCAppCommLauncherSelectCmd:
       
   362             DoSelectCmdL( ETrue );// use default
       
   363             break;
       
   364         case ECCAppCommLauncherSelectOtherNmbCmd:
       
   365         case ECCAppCommLauncherSelectOtherAddrCmd:
       
   366             DoSelectCmdL( EFalse );// do not use default
       
   367             break;
       
   368         case KAiwCmdAssign:// AIW service cmd for Editing
       
   369             DoEditCmdL();
       
   370             break;
       
   371         case ECCAppCommLauncherDefaultsCmd:
       
   372             DoSetDefaultCmdL();
       
   373             break;
       
   374         case ECCAppCommLauncherDeleteCmd:
       
   375             DoDeleteCmdL();
       
   376             break;
       
   377         default:
       
   378             break;
       
   379         }
       
   380 
       
   381     CCA_DP(KCommLauncherLogFile, CCA_L("<-CCCAppCommLauncherMenuHandler::HandleCommandL()"));
       
   382     }
       
   383 
       
   384 // ---------------------------------------------------------------------------
       
   385 // CCCAppCommLauncherMenuHandler::DoSelectCmdL
       
   386 // ---------------------------------------------------------------------------
       
   387 //
       
   388 void CCCAppCommLauncherMenuHandler::DoSelectCmdL( TBool aUseDefaultAddress )
       
   389     {
       
   390     CCA_DP(KCommLauncherLogFile, CCA_L("->CCCAppCommLauncherMenuHandler::DoSelectCmdL()"));
       
   391 
       
   392     if ( iPlugin.Container().SelectedCommunicationMethod()
       
   393     		== VPbkFieldTypeSelectorFactory::EFindOnMapSelector )
       
   394     	{
       
   395     	DoShowOnMapCmdL();
       
   396     	}
       
   397     else
       
   398     	{
       
   399         TPtrC fullName;
       
   400         iPlugin.ContactHandler().ContactFieldItemDataL(
       
   401             CCmsContactFieldItem::ECmsFullName, fullName );
       
   402         TUint paramFlag =
       
   403             aUseDefaultAddress ? CCAContactorService::TCSParameter::EEnableDefaults : 0;
       
   404         CCAContactorService::TCSParameter param(
       
   405             iPlugin.Container().SelectedCommunicationMethod(),
       
   406             *iPlugin.ContactHandler().ContactIdentifierLC(),//contactlinkarray
       
   407             paramFlag,
       
   408             fullName );
       
   409 
       
   410         iPlugin.ExecuteServiceL( param );
       
   411         CleanupStack::PopAndDestroy( 1 );// contactlinkarray
       
   412     	}
       
   413     
       
   414     CCA_DP(KCommLauncherLogFile, CCA_L("<-CCCAppCommLauncherMenuHandler::DoSelectCmdL()"));
       
   415     }
       
   416 
       
   417 // ---------------------------------------------------------------------------
       
   418 // CCCAppCommLauncherMenuHandler::DoEditCmdL
       
   419 // ---------------------------------------------------------------------------
       
   420 //
       
   421 void CCCAppCommLauncherMenuHandler::DoEditCmdL()
       
   422     {
       
   423     CCA_DP(KCommLauncherLogFile, CCA_L("->CCCAppCommLauncherMenuHandler::DoEditCmdL()"));
       
   424 
       
   425     TCCAppCommandState& cmdState( iPlugin.CommandState() );
       
   426     cmdState.SetRunningAndPushCleanupL();
       
   427     
       
   428     // Avoid user input during Edit command execution
       
   429     if( iInputBlock )
       
   430         {
       
   431         iInputBlock->Cancel();
       
   432         }
       
   433 
       
   434     iInputBlock = CAknInputBlock::NewCancelHandlerLC( this );
       
   435     CleanupStack::Pop( iInputBlock );
       
   436     iInputBlock->SetCancelDelete( iInputBlock );
       
   437     CAiwGenericParamList& inParamList = iAiwServiceHandler->InParamListL();
       
   438     TInt popAndDestroyUs = 0;
       
   439 
       
   440     inParamList.AppendL(
       
   441         TAiwGenericParam(
       
   442             EGenericParamContactAssignData,
       
   443             TAiwVariant( TAiwSingleContactAssignDataV1Pckg(
       
   444                 TAiwSingleContactAssignDataV1().SetFlags( EskipInfoNotes )))));
       
   445 
       
   446     popAndDestroyUs += PackedContactLinkArrayToInParamListLC( inParamList );
       
   447 
       
   448     iAiwServiceHandler->ExecuteServiceCmdL(
       
   449         KAiwCmdAssign,
       
   450         inParamList,
       
   451         iAiwServiceHandler->OutParamListL(), NULL, this );
       
   452 
       
   453    CleanupStack::PopAndDestroy( popAndDestroyUs );
       
   454    // Async AIW command -> set state to not running in HandleNotifyL.
       
   455    cmdState.PopCleanup();
       
   456 
       
   457    CCA_DP(KCommLauncherLogFile, CCA_L("<-CCCAppCommLauncherMenuHandler::DoEditCmdL()"));
       
   458     }
       
   459 
       
   460 // ---------------------------------------------------------------------------
       
   461 // CCCAppCommLauncherMenuHandler::DoAiwCommandL
       
   462 // ---------------------------------------------------------------------------
       
   463 //
       
   464 void CCCAppCommLauncherMenuHandler::DoAiwCommandL( TInt aCmdId, TInt aServiceId )
       
   465     {
       
   466     CCA_DP(KCommLauncherLogFile, CCA_L("->CCCAppCommLauncherMenuHandler::DoAiwCommandL()"));
       
   467 
       
   468     // Command state is checked in CCCAppCommLauncherPlugin::HandleCommandL 
       
   469     // before calling the menuhandler.
       
   470     TCCAppCommandState& cmdState( iPlugin.CommandState() );
       
   471     cmdState.SetRunningAndPushCleanupL();
       
   472     
       
   473     CAiwGenericParamList& inParamList = iAiwServiceHandler->InParamListL();
       
   474     TInt popAndDestroyUs = 0;
       
   475 
       
   476     switch( aServiceId )
       
   477         {
       
   478         case KAiwCmdSindInfoView:
       
   479             popAndDestroyUs += PackedContactLinkArrayToInParamListLC( inParamList );
       
   480             break;
       
   481         default:
       
   482             break;
       
   483         }
       
   484 
       
   485     iAiwServiceHandler->ExecuteMenuCmdL(
       
   486         aCmdId,
       
   487         inParamList,
       
   488         iAiwServiceHandler->OutParamListL(), NULL, NULL );// not needed (so far)
       
   489 
       
   490    CleanupStack::PopAndDestroy( popAndDestroyUs );
       
   491    // Synchronous AIW call -> state to not running.
       
   492    cmdState.SetNotRunningAndPopCleanup();
       
   493 
       
   494    CCA_DP(KCommLauncherLogFile, CCA_L("<-CCCAppCommLauncherMenuHandler::DoAiwCommandL()"));
       
   495    }
       
   496 
       
   497 // ---------------------------------------------------------------------------
       
   498 // CCCAppCommLauncherMenuHandler::PackedContactLinkArrayToInParamListLC
       
   499 // ---------------------------------------------------------------------------
       
   500 //
       
   501 TInt CCCAppCommLauncherMenuHandler::PackedContactLinkArrayToInParamListLC(
       
   502     CAiwGenericParamList& aInParamList )
       
   503     {
       
   504     CCA_DP(KCommLauncherLogFile, CCA_L("->CCCAppCommLauncherMenuHandler::PrepareAiwParamListForVoiceTagLC()"));
       
   505 
       
   506     HBufC8* packedLinks = iPlugin.ContactHandler().ContactIdentifierLC();
       
   507 
       
   508     aInParamList.AppendL(
       
   509         TAiwGenericParam( EGenericParamContactLinkArray,
       
   510         TAiwVariant( *packedLinks )));
       
   511 
       
   512     CCA_DP(KCommLauncherLogFile, CCA_L("<-CCCAppCommLauncherMenuHandler::PrepareAiwParamListForVoiceTagLC()"));
       
   513     return 1;// packedLinks
       
   514     }
       
   515 
       
   516 // ---------------------------------------------------------------------------
       
   517 // CCCAppCommLauncherMenuHandler::HandleNotifyL
       
   518 // ---------------------------------------------------------------------------
       
   519 //
       
   520 TInt CCCAppCommLauncherMenuHandler::HandleNotifyL(
       
   521     TInt aCmdId,
       
   522     TInt aEventId,
       
   523     CAiwGenericParamList& aEventParamList,
       
   524     const CAiwGenericParamList& /*aInParamList*/ )
       
   525     {
       
   526     if ( aEventId == KAiwEventCompleted || 
       
   527          aEventId == KAiwEventCanceled ||
       
   528          aEventId == KAiwEventError )
       
   529         {
       
   530         iPlugin.CommandState().SetNotRunning();
       
   531         }
       
   532     
       
   533     TInt returnValue = KErrNone;
       
   534     TInt index = 0;
       
   535     const TAiwGenericParam* param = aEventParamList.FindFirst(index,
       
   536         EGenericParamContactLinkArray);
       
   537     
       
   538     index = 0;
       
   539     const TAiwGenericParam* errParam = aEventParamList.FindFirst(index,
       
   540             EGenericParamError);
       
   541 
       
   542     if (param)
       
   543         {
       
   544         TPtrC8 contactLink = param->Value().AsData();
       
   545 
       
   546         // Update the CCA parameter contact data
       
   547         TInt length = contactLink.Length();
       
   548         if ( length > 0 )
       
   549             {
       
   550             HBufC16* link16 = HBufC16::NewLC( length );
       
   551             link16->Des().Copy( contactLink );
       
   552             iPlugin.AppEngine()->Parameter().SetContactDataL( link16->Des() );
       
   553             // Set contact data flag to EContactLink, because the parameters returned from 
       
   554             // phonebook AIW provider have conatct link but not contact id.
       
   555             iPlugin.AppEngine()->Parameter().SetContactDataFlag( MCCAParameter::EContactLink );
       
   556             CleanupStack::PopAndDestroy(1); // link16
       
   557 
       
   558             // Inform the app engine of the contact event
       
   559             iPlugin.AppEngine()->CCAppContactEventL();
       
   560 
       
   561             // Update the commlauncher the UI contact data
       
   562             iPlugin.ContactHandler().RefetchContactL();
       
   563             iPlugin.Container().ContactsChangedL();
       
   564             
       
   565             //Update the Store
       
   566             SetContactStore(iPlugin.ContactHandler().ContactStore());
       
   567             }
       
   568         }
       
   569 
       
   570     if (errParam)
       
   571         {
       
   572         TInt32 err;
       
   573         errParam->Value().Get(err);
       
   574         if (err == (TInt32)KErrInUse)
       
   575             {
       
   576             CCoeEnv::Static()->HandleError(KErrInUse);
       
   577             }
       
   578         }
       
   579     
       
   580     if ( KAiwCmdAssign == aCmdId && KAiwEventQueryExit == aEventId )
       
   581         {
       
   582         // Send an exit command in order to close CCA and Phonebook2
       
   583 		CAknAppUi* appUi = static_cast<CAknAppUi*>( CCoeEnv::Static()->AppUi() );
       
   584 
       
   585 		if ( appUi )
       
   586 			{
       
   587 			appUi->ProcessCommandL( EAknCmdExit );
       
   588 			}
       
   589 
       
   590 		// allow pbk editor AIW service to close whole app chain
       
   591         returnValue = ETrue;
       
   592         }
       
   593     
       
   594     // stop user input blocker
       
   595     StopInputBlock();
       
   596     
       
   597     return returnValue;
       
   598     }
       
   599 
       
   600 // ---------------------------------------------------------------------------
       
   601 // CCCAppCommLauncherMenuHandler::DoSetDefaultCmdL
       
   602 // ---------------------------------------------------------------------------
       
   603 //
       
   604 void CCCAppCommLauncherMenuHandler::DoSetDefaultCmdL()
       
   605     {
       
   606     if( !iPbkCmd )
       
   607         iPbkCmd = CCCAppCommLauncherPbkCmd::NewL( iPlugin );
       
   608 
       
   609     iPbkCmd->ExecutePbk2CmdAssignDefaultL(
       
   610         *iPlugin.ContactHandler().ContactIdentifierLC() );
       
   611 
       
   612     CleanupStack::PopAndDestroy( 1 ); // ContactIdentifierLC
       
   613     }
       
   614 
       
   615 // ---------------------------------------------------------------------------
       
   616 // CCCAppCommLauncherMenuHandler::DoShowOnMapCmdL
       
   617 // ---------------------------------------------------------------------------
       
   618 //
       
   619 void CCCAppCommLauncherMenuHandler::DoShowOnMapCmdL()
       
   620     {
       
   621     if( !iPbkCmd )
       
   622     	{
       
   623         iPbkCmd = CCCAppCommLauncherPbkCmd::NewL( iPlugin );
       
   624     	}
       
   625         
       
   626     iPbkCmd->ExecutePbk2CmdShowMapL(
       
   627             iPlugin.ContactHandler().ContactIdentifierLC(),
       
   628             (TPbk2CommandId)EPbk2ExtensionShowOnMap );
       
   629 
       
   630     CleanupStack::PopAndDestroy( 1 ); // ContactIdentifierLC
       
   631     }
       
   632 
       
   633 // ---------------------------------------------------------------------------
       
   634 // CCCAppCommLauncherMenuHandler::DoDeleteCmdL
       
   635 // ---------------------------------------------------------------------------
       
   636 //
       
   637 void CCCAppCommLauncherMenuHandler::DoDeleteCmdL()
       
   638     {
       
   639     if( !iPbkCmd )
       
   640 	    {
       
   641         iPbkCmd = CCCAppCommLauncherPbkCmd::NewL( iPlugin );
       
   642         }
       
   643     iPbkCmd->ExecutePbk2CmdDeleteL(
       
   644         *iPlugin.ContactHandler().ContactIdentifierLC() );
       
   645 
       
   646     CleanupStack::PopAndDestroy( 1 ); // ContactIdentifierLC
       
   647     }
       
   648 
       
   649 // ---------------------------------------------------------------------------
       
   650 // CCCAppCommLauncherMenuHandler::XspContactDynInitMenuPaneL
       
   651 // ---------------------------------------------------------------------------
       
   652 //
       
   653 void CCCAppCommLauncherMenuHandler::XspContactDynInitMenuPaneL(
       
   654     CEikMenuPane* aMenuPane )
       
   655     {
       
   656     CCA_DP(KCommLauncherLogFile, CCA_L("->CCCAppCommLauncherMenuHandler::XspContactDynInitMenuPaneL()"));
       
   657 
       
   658     DynInitSelectMenuItemL( aMenuPane );
       
   659     DynInitSelectOtherMenuItemL( aMenuPane );
       
   660 
       
   661     CCA_DP(KCommLauncherLogFile, CCA_L("<-CCCAppCommLauncherMenuHandler::XspContactDynInitMenuPaneL()"));
       
   662     }
       
   663 
       
   664 
       
   665 // End of File