phonebookui/Phonebook2/ccapplication/ccadetailsviewplugin/src/ccappdetailsviewmenuhandler.cpp
changeset 0 e686773b3f54
child 3 04ab22b956c2
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 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:  Implementation of ccappdetailsview menuhandler
       
    15 *  Version     : %version: he1s60#31.1.13 %
       
    16 *
       
    17 */
       
    18 
       
    19 #include <AiwServiceHandler.h>
       
    20 #include <AiwContactAssignDataTypes.h>
       
    21 
       
    22 #include <aknnotewrappers.h>
       
    23 
       
    24 #include <MVPbkStoreContact.h>
       
    25 #include <MVPbkContactStore.h>
       
    26 #include <CVPbkContactLinkArray.h>
       
    27 #include <MVPbkContactStoreProperties.h>
       
    28 #include <Pbk2Commands.hrh>
       
    29 #include <CPbk2ContactRelocator.h>
       
    30 #include <CPbk2CommandHandler.h>
       
    31 #include <CPbk2ApplicationServices.h>
       
    32 #include <CVPbkContactManager.h>
       
    33 #include <CPbk2PresentationContact.h>
       
    34 #include <CPbk2PresentationContactFieldCollection.h>
       
    35 #include <CPbk2FieldPropertyArray.h>
       
    36 #include <pbk2mapcommands.hrh>
       
    37 
       
    38 #include "ccappdetailsviewmenuhandler.h"
       
    39 #include "ccappdetailsviewlistboxmodel.h"
       
    40 #include "ccappdetailsviewcontainer.h"
       
    41 #include "ccappdetailsviewplugin.h"
       
    42 #include "ccappdetailsviewdefs.h"
       
    43 
       
    44 #include <mccaparameter.h>
       
    45 
       
    46 #include <ccappdetailsviewpluginrsc.rsg>
       
    47 #include "ccappdetailsview.hrh"
       
    48 
       
    49 #include <mnproviderfinder.h>
       
    50 #include <MVPbkFieldType.h>
       
    51 #include <TVPbkFieldVersitProperty.h>
       
    52 
       
    53 using namespace AiwContactAssign;
       
    54 
       
    55 // ======== MEMBER FUNCTIONS ========
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // CCCAppDetailsViewMenuHandler::NewL
       
    59 // ---------------------------------------------------------------------------
       
    60 //
       
    61 CCCAppDetailsViewMenuHandler* CCCAppDetailsViewMenuHandler::NewL(
       
    62     CCCAppDetailsViewPlugin& aPlugin)
       
    63 {
       
    64     CCCAppDetailsViewMenuHandler* self = new(ELeave) CCCAppDetailsViewMenuHandler(aPlugin);
       
    65     CleanupStack::PushL(self);
       
    66     self->ConstructL();
       
    67     CleanupStack::Pop(self);
       
    68 
       
    69     return self;
       
    70 }
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // CCCAppDetailsViewMenuHandler::~CCCAppDetailsViewMenuHandler
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 CCCAppDetailsViewMenuHandler::~CCCAppDetailsViewMenuHandler()
       
    77 {
       
    78     delete iAiwServiceHandler;
       
    79     delete iCommandHandler;
       
    80     delete iMapViewProvider;
       
    81 }
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // CCCAppDetailsViewMenuHandler::CCCAppDetailsViewMenuHandler()
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 CCCAppDetailsViewMenuHandler::CCCAppDetailsViewMenuHandler(
       
    88     CCCAppDetailsViewPlugin& aPlugin)
       
    89 :
       
    90     iPlugin(aPlugin)
       
    91 {
       
    92 }
       
    93 
       
    94 // ---------------------------------------------------------------------------
       
    95 // CCCAppDetailsViewMenuHandler::ConstructL
       
    96 // ---------------------------------------------------------------------------
       
    97 //
       
    98 void CCCAppDetailsViewMenuHandler::ConstructL()
       
    99 {
       
   100     //CCA_DP(KDetailsViewLogFile, CCA_L(">>> CCCAppDetailsViewMenuHandler::ConstructL()"));
       
   101 
       
   102     iCommandHandler = CPbk2CommandHandler::NewL();
       
   103 
       
   104     RPointerArray<CMnProvider> providers;
       
   105     CleanupClosePushL( providers );
       
   106 
       
   107     MnProviderFinder::FindProvidersL( providers,
       
   108         CMnProvider::EServiceMapView );
       
   109 
       
   110     if (providers.Count() > 0)
       
   111     {
       
   112         iMapViewProvider = providers[0];
       
   113         providers.Remove(0);
       
   114     }
       
   115 
       
   116     providers.ResetAndDestroy();
       
   117     CleanupStack::PopAndDestroy( &providers );
       
   118 
       
   119     PrepareAiwMenusL();
       
   120 
       
   121     //CCA_DP(KDetailsViewLogFile, CCA_L("<<< CCCAppDetailsViewMenuHandler::ConstructL()"));
       
   122 }
       
   123 
       
   124 // ---------------------------------------------------------------------------
       
   125 // CCCAppDetailsViewMenuHandler::DynInitMenuPaneL
       
   126 // ---------------------------------------------------------------------------
       
   127 //
       
   128 void CCCAppDetailsViewMenuHandler::DynInitMenuPaneL(TInt aResourceId,
       
   129     CEikMenuPane* aMenuPane)
       
   130 {
       
   131     //CCA_DP(KDetailsViewLogFile, CCA_L(">>> CCCAppDetailsViewMenuHandler::DynInitMenuPaneL()"));
       
   132 
       
   133     if (iAiwServiceHandler->HandleSubmenuL(*aMenuPane))
       
   134     {
       
   135         return;
       
   136     }
       
   137 
       
   138     switch (aResourceId)
       
   139     {
       
   140     case R_CCAPPDETAILSVIEW_MENUPANE:
       
   141     case R_DETAILSVIEW_DETAIL_MENUPANE:
       
   142         {
       
   143             TInt pos = 0;
       
   144 
       
   145             const CCCAppDetailsViewContainer& container =
       
   146                 static_cast<const CCCAppDetailsViewContainer&>(iPlugin.GetContainer());
       
   147 
       
   148             TBool isNumberField  = IsFocusedFieldTypeL(R_DETAILSVIEW_PHONENUMBER_SELECTOR);
       
   149             TBool isAddressField =
       
   150                 IsFocusedFieldTypeL(R_DETAILSVIEW_EL_ADDRESS_SELECTOR) ||
       
   151                 IsFocusedFieldTypeL(R_DETAILSVIEW_URL_SELECTOR);
       
   152 
       
   153             if (aMenuPane->MenuItemExists(ECCAppDetailsViewSetTopContactCmd,    pos) &&
       
   154                 aMenuPane->MenuItemExists(ECCAppDetailsViewRemoveTopContactCmd, pos)
       
   155                 )
       
   156             {
       
   157                 TBool isTopContact = container.ListBoxModel().IsTopContact();
       
   158 
       
   159                 aMenuPane->SetItemDimmed(ECCAppDetailsViewSetTopContactCmd,     isTopContact);
       
   160                 aMenuPane->SetItemDimmed(ECCAppDetailsViewRemoveTopContactCmd, !isTopContact);
       
   161             }
       
   162 
       
   163             if (aMenuPane->MenuItemExists(ECCAppDetailsViewCopyDetailCmd, pos))
       
   164             {
       
   165                 aMenuPane->SetItemDimmed(ECCAppDetailsViewCopyDetailCmd,
       
   166                     (isNumberField || isAddressField));
       
   167             }
       
   168 
       
   169             if (aMenuPane->MenuItemExists(ECCAppDetailsViewNumberCmd,  pos)/* &&
       
   170                 aMenuPane->MenuItemExists(ECCAppDetailsViewAddressCmd, pos)*/
       
   171                 )
       
   172             {
       
   173                 aMenuPane->SetItemDimmed(ECCAppDetailsViewNumberCmd,  !isNumberField);
       
   174                 // aMenuPane->SetItemDimmed(ECCAppDetailsViewAddressCmd, !isAddressField);
       
   175             }
       
   176             if (aMenuPane->MenuItemExists(ECCAppDetailsViewAddressCmd,  pos)/* &&
       
   177               //  aMenuPane->MenuItemExists(ECCAppDetailsViewAddressCmd, pos)*/
       
   178                 )
       
   179             {
       
   180                 aMenuPane->SetItemDimmed(ECCAppDetailsViewAddressCmd,  !isAddressField); 
       
   181             }
       
   182             if (aMenuPane->MenuItemExists(ECCAppDetailsViewCopyNumberCmd, pos))
       
   183             {
       
   184                 aMenuPane->SetItemDimmed(ECCAppDetailsViewCopyNumberCmd, !isNumberField);
       
   185             }
       
   186 
       
   187             if (aMenuPane->MenuItemExists(ECCAppDetailsViewCopyAddressCmd, pos))
       
   188             {
       
   189                 aMenuPane->SetItemDimmed(ECCAppDetailsViewCopyAddressCmd, !isAddressField);
       
   190             }
       
   191             
       
   192             if (aMenuPane->MenuItemExists(ECCAppDetailsViewImageCmd, pos))
       
   193             {
       
   194                 TBool isImageField = IsFocusedFieldTypeL(R_DETAILSVIEW_IMAGE_FIELDS_SELECTOR);
       
   195 
       
   196                 aMenuPane->SetItemDimmed(ECCAppDetailsViewImageCmd, !isImageField);
       
   197             }
       
   198 
       
   199             if (aMenuPane->MenuItemExists(KAiwCmdAssign, pos))
       
   200             {
       
   201                 TBool isReadOnlyContact = container.ListBoxModel().IsReadOnlyContact();
       
   202                 if (isReadOnlyContact)
       
   203                 {
       
   204                     aMenuPane->SetItemDimmed(KAiwCmdAssign, ETrue);
       
   205                     aMenuPane->SetItemDimmed(ECCAppDetailsViewDeleteCmd, ETrue);
       
   206                 }
       
   207             }
       
   208 
       
   209             if (aMenuPane->MenuItemExists(ECCAppDetailsViewPrependCmd, pos))
       
   210             {
       
   211                 aMenuPane->SetItemDimmed(ECCAppDetailsViewPrependCmd, !isNumberField);
       
   212             }
       
   213 
       
   214             if ( aMenuPane->MenuItemExists(
       
   215                 ECCAppDetailsViewFindOnMapCmd, pos )
       
   216                 && aMenuPane->MenuItemExists(
       
   217                     ECCAppDetailsViewShowOnMapCmd, pos ) )
       
   218             {
       
   219                 if ( iMapViewProvider && HasAddressFieldL() )
       
   220                 {
       
   221                     if ( IsAddressValidatedL() )
       
   222                     {
       
   223                         aMenuPane->SetItemDimmed(
       
   224                             ECCAppDetailsViewFindOnMapCmd, ETrue );
       
   225                     }
       
   226                     else
       
   227                     {
       
   228                         aMenuPane->SetItemDimmed(
       
   229                             ECCAppDetailsViewShowOnMapCmd, ETrue );
       
   230                     }
       
   231                 }
       
   232                 else
       
   233                 {
       
   234                     aMenuPane->SetItemDimmed(
       
   235                         ECCAppDetailsViewFindOnMapCmd, ETrue );
       
   236                     aMenuPane->SetItemDimmed(
       
   237                         ECCAppDetailsViewShowOnMapCmd, ETrue );
       
   238                 }
       
   239             }
       
   240 
       
   241             TBool isSdnContact = container.ListBoxModel().IsSdnContact();
       
   242 
       
   243             if( isNumberField && !isSdnContact )
       
   244             {
       
   245                 CPbk2ContactRelocator* contactRelocator = CPbk2ContactRelocator::NewL();
       
   246                 CleanupStack::PushL( contactRelocator );
       
   247                 TBool phoneMemoryInConfiguration =
       
   248                     contactRelocator->IsPhoneMemoryInConfigurationL();
       
   249                 CleanupStack::PopAndDestroy();//contactRelocator
       
   250 
       
   251                 // Weed out phone memory specific commands, if there is no
       
   252                 // phone memory in configuration
       
   253                 if (!phoneMemoryInConfiguration)
       
   254                 {
       
   255                     if (aMenuPane->MenuItemExists(ECCAppDetailsViewAssignSpeedDialCmd, pos))
       
   256                     {
       
   257                         aMenuPane->SetItemDimmed(ECCAppDetailsViewAssignSpeedDialCmd, ETrue);
       
   258                     }
       
   259                 }
       
   260 
       
   261                 TInt focusIndex = container.ListBoxModel().FocusedFieldIndex();
       
   262                 TBool hasSpeedDial = container.ListBoxModel().HasSpeedDialL(focusIndex);
       
   263 
       
   264                 // Filtering is based on the speed dial existence
       
   265                 if ( !hasSpeedDial )
       
   266                 {
       
   267                     if (aMenuPane->MenuItemExists(ECCAppDetailsViewUnassignSpeedDialCmd, pos))
       
   268                     {
       
   269                         aMenuPane->SetItemDimmed
       
   270                             ( ECCAppDetailsViewUnassignSpeedDialCmd, ETrue );
       
   271                     }
       
   272                 }
       
   273                 else
       
   274                 {
       
   275                     if (aMenuPane->MenuItemExists(ECCAppDetailsViewAssignSpeedDialCmd, pos))
       
   276                     {
       
   277                         aMenuPane->SetItemDimmed
       
   278                             ( ECCAppDetailsViewAssignSpeedDialCmd, ETrue );
       
   279                     }
       
   280                 }
       
   281             }
       
   282             else
       
   283             {
       
   284                 if( aMenuPane->MenuItemExists(ECCAppDetailsViewAssignSpeedDialCmd, pos) )
       
   285                 {
       
   286                     aMenuPane->SetItemDimmed( ECCAppDetailsViewAssignSpeedDialCmd, ETrue );
       
   287                 }
       
   288 
       
   289                 if( aMenuPane->MenuItemExists(ECCAppDetailsViewUnassignSpeedDialCmd, pos) )
       
   290                 {
       
   291                     aMenuPane->SetItemDimmed( ECCAppDetailsViewUnassignSpeedDialCmd, ETrue );
       
   292                 }
       
   293             }
       
   294 
       
   295 
       
   296 
       
   297             if (iAiwServiceHandler->IsAiwMenu(aResourceId))
       
   298             {
       
   299                 iAiwServiceHandler->InitializeMenuPaneL( *aMenuPane,
       
   300                     aResourceId, ECCAppDetailsViewAiwBaseCmd,
       
   301                     iAiwServiceHandler->InParamListL() );
       
   302             }
       
   303             break;
       
   304         }
       
   305 
       
   306     default:
       
   307         break;
       
   308     }
       
   309 
       
   310     //CCA_DP(KDetailsViewLogFile, CCA_L("<<< CCCAppDetailsViewMenuHandler::DynInitMenuPaneL()"));
       
   311 }
       
   312 
       
   313 // ---------------------------------------------------------------------------
       
   314 // CCCAppDetailsViewMenuHandler::HandleNotifyL
       
   315 // ---------------------------------------------------------------------------
       
   316 //
       
   317 TInt CCCAppDetailsViewMenuHandler::HandleNotifyL(
       
   318     TInt aCmdId,
       
   319     TInt aEventId,
       
   320     CAiwGenericParamList& aEventParamList,
       
   321     const CAiwGenericParamList& /*aInParamList*/)
       
   322 {
       
   323     CCA_DP(KDetailsViewLogFile, CCA_L(">>> CCCAppDetailsViewMenuHandler::HandleNotifyL() eventid = %d"), aEventId);
       
   324 
       
   325     TInt result = 0;
       
   326     TInt index = 0;
       
   327     
       
   328     const TAiwGenericParam* errParam = aEventParamList.FindFirst(index,
       
   329             EGenericParamError);
       
   330     
       
   331     if (errParam)
       
   332         {
       
   333         TInt32 err;
       
   334         errParam->Value().Get(err);
       
   335         if (err == (TInt32)KErrInUse)
       
   336             {
       
   337             CCoeEnv::Static()->HandleError(KErrInUse);
       
   338             }
       
   339         }
       
   340 
       
   341     if (aCmdId == KAiwCmdAssign)
       
   342     {
       
   343         if (aEventId == KAiwEventCompleted)
       
   344         {
       
   345             index = 0;
       
   346             const TAiwGenericParam* param = aEventParamList.FindFirst(index,
       
   347                 EGenericParamContactLinkArray);
       
   348             const CCCAppDetailsViewContainer& container =
       
   349                 static_cast<const CCCAppDetailsViewContainer&>(iPlugin.GetContainer());
       
   350 
       
   351             if (param)
       
   352             {
       
   353                 TPtrC8 contactLink = param->Value().AsData();
       
   354 
       
   355                 CVPbkContactLinkArray* links = CVPbkContactLinkArray::NewLC(
       
   356                     contactLink, container.ContactManager().ContactStoresL() );
       
   357 
       
   358                 if ( !links->At(0).RefersTo(*(container.ListBoxModel().StoreContact())) )
       
   359                 {
       
   360                     // Update the CCA parameter contact data
       
   361                     HBufC16* link16 = HBufC16::NewLC( contactLink.Length() );
       
   362                     link16->Des().Copy( contactLink );
       
   363                     iPlugin.AppEngine()->Parameter().SetContactDataL(link16->Des());
       
   364                     CleanupStack::PopAndDestroy(1); // link16
       
   365 
       
   366                     // Inform the CCApp engine of the contact relocation
       
   367                     iPlugin.AppEngine()->CCAppContactEventL();
       
   368 
       
   369                     // Update the details view UI
       
   370                     container.ListBoxModel().SetLinks(links);
       
   371                     CleanupStack::Pop(links);
       
   372                 }
       
   373                 else
       
   374                 {
       
   375                     CleanupStack::PopAndDestroy(); // links
       
   376                 }
       
   377             }
       
   378             index = 0;
       
   379             const TAiwGenericParam* indexparam = aEventParamList.FindFirst(index,
       
   380                 EGenericParamContactItem);
       
   381 
       
   382             if (indexparam)
       
   383             {
       
   384                 TInt focus = indexparam->Value().AsTInt32();
       
   385 
       
   386                 container.ListBoxModel().SetInitialFocusIndex(focus);
       
   387             }
       
   388 
       
   389             container.DrawDeferred();
       
   390 
       
   391         }
       
   392         else if (aEventId == KAiwEventCanceled)
       
   393         {
       
   394             /*
       
   395              iControl->ListBoxModel().SetLinks(NULL);
       
   396              iControl->DrawDeferred();
       
   397              */
       
   398         }
       
   399         else if (aEventId == KAiwEventOutParamCheck)
       
   400         {
       
   401         }
       
   402         else if (aEventId == KAiwEventQueryExit)
       
   403         {
       
   404             // Send an exit command in order to close CCA and Phonebook2
       
   405             CAknAppUi* appUi = static_cast<CAknAppUi*>( CCoeEnv::Static()->AppUi() );
       
   406 
       
   407             if ( appUi )
       
   408             {
       
   409                 appUi->ProcessCommandL( EAknCmdExit );
       
   410             }
       
   411 
       
   412             // allow pbk editor AIW service to close whole app chain
       
   413             result = ETrue;
       
   414         }
       
   415     }
       
   416 
       
   417     CCA_DP(KDetailsViewLogFile, CCA_L("<<< CCCAppDetailsViewMenuHandler::HandleNotifyL()"));
       
   418 
       
   419     return result;
       
   420 }
       
   421 
       
   422 // --------------------------------------------------------------------------
       
   423 // CCCAppDetailsViewMenuHandler::Reset
       
   424 // --------------------------------------------------------------------------
       
   425 //
       
   426 void CCCAppDetailsViewMenuHandler::Reset()
       
   427     {
       
   428     if ( iAiwServiceHandler != NULL )
       
   429         {
       
   430         iAiwServiceHandler->Reset();
       
   431         }
       
   432     }
       
   433 
       
   434 // --------------------------------------------------------------------------
       
   435 // CCCAppDetailsViewMenuHandler::Activate
       
   436 // --------------------------------------------------------------------------
       
   437 //
       
   438 void CCCAppDetailsViewMenuHandler::Activate()
       
   439     {
       
   440     if ( iAiwServiceHandler != NULL )
       
   441         {
       
   442         TRAP_IGNORE( iAiwServiceHandler->AttachL(
       
   443             R_DETAILSVIEW_AIW_SERVICE_INTERESTS) );
       
   444         }
       
   445     }
       
   446 
       
   447 // --------------------------------------------------------------------------
       
   448 // CCCAppDetailsViewMenuHandler::IsFocusedFieldTypeL
       
   449 // --------------------------------------------------------------------------
       
   450 //
       
   451 TBool CCCAppDetailsViewMenuHandler::IsFocusedFieldTypeL(TInt aSelectorResId)
       
   452 {
       
   453     const CCCAppDetailsViewContainer& container =
       
   454         static_cast<const CCCAppDetailsViewContainer&>(iPlugin.GetContainer());
       
   455 
       
   456     TBool ret = container.ListBoxModel().IsFocusedFieldTypeL(aSelectorResId);
       
   457 
       
   458     return ret;
       
   459 }
       
   460 
       
   461 // --------------------------------------------------------------------------
       
   462 // CCCAppDetailsViewMenuHandler::HasContactFieldTypeL
       
   463 // --------------------------------------------------------------------------
       
   464 //
       
   465 TBool CCCAppDetailsViewMenuHandler::HasContactFieldTypeL(TInt aSelectorResId)
       
   466 {
       
   467     const CCCAppDetailsViewContainer& container =
       
   468         static_cast<const CCCAppDetailsViewContainer&>(iPlugin.GetContainer());
       
   469 
       
   470     TBool ret = container.ListBoxModel().HasContactFieldTypeL(aSelectorResId);
       
   471 
       
   472     return ret;
       
   473 }
       
   474 
       
   475 // ---------------------------------------------------------------------------
       
   476 // CCCAppDetailsViewMenuHandler::PrepareAiwMenusL
       
   477 // Prepares plugin for AIW-menu usage
       
   478 // ---------------------------------------------------------------------------
       
   479 //
       
   480 void CCCAppDetailsViewMenuHandler::PrepareAiwMenusL()
       
   481 {
       
   482     //CCA_DP(KDetailsViewLogFile, CCA_L(">>> CCCAppDetailsViewMenuHandler::PrepareAiwMenusL()"));
       
   483 
       
   484     // Initialisation of AIW Servicehandler cannot be in
       
   485     // ConstructL, since the menus of plugin are given
       
   486     // later via ProvideApplicationResourcesL(..)
       
   487     iAiwServiceHandler = CAiwServiceHandler::NewL();
       
   488 
       
   489     iAiwServiceHandler->AttachL(
       
   490         R_DETAILSVIEW_AIW_SERVICE_INTERESTS);
       
   491 
       
   492     iCommandHandler->RegisterAiwInterestL
       
   493         ( KAiwCmdCall, R_DETAILSVIEW_DETAIL_MENUPANE,
       
   494             R_DETAILSVIEW_CALLUI_AIW_INTEREST, ETrue );
       
   495 
       
   496 
       
   497     /*iAiwServiceHandler->AttachMenuL(
       
   498      R_CCACOMMLAUNCHER_MENUPANE,
       
   499      R_CCACOMMLAUNCHER_AIW_MENU_INTERESTS );*/
       
   500 
       
   501     //CCA_DP(KDetailsViewLogFile, CCA_L("<<< CCCAppDetailsViewMenuHandler::PrepareAiwMenusL()"));
       
   502 }
       
   503 
       
   504 // ---------------------------------------------------------------------------
       
   505 // CCCAppDetailsViewMenuHandler::HandleCommandL
       
   506 // ---------------------------------------------------------------------------
       
   507 //
       
   508 void CCCAppDetailsViewMenuHandler::HandleCommandL(TInt aCommand)
       
   509 {
       
   510     //CCA_DP(KDetailsViewLogFile, CCA_L(">>> CCCAppDetailsViewMenuHandler::HandleCommandL()"));
       
   511 
       
   512     // CCApp handles the "Exit"- and "Back"-commands
       
   513 
       
   514     // Quick guide:
       
   515     // - iParameter contains the launching information like contact id/link
       
   516     // - iEnabledFields contains the fields contact has available
       
   517     // - iContactFieldsArray contains the fields already fetched from pbk
       
   518 
       
   519     // Check and handle the Aiw commands 1st
       
   520     /*
       
   521      TODO: NEEDED?
       
   522      TInt aiwCmd = iAiwServiceHandler->ServiceCmdByMenuCmd(aCommand);
       
   523      if(aiwCmd)
       
   524      {
       
   525      DoAiwCommandL(aCommand, aiwCmd);
       
   526      return;// aCommand should not match with non-Aiw commands, but just to be sure
       
   527      }
       
   528      */
       
   529     // Then check if command is normal application command
       
   530     switch (aCommand)
       
   531     {
       
   532     case EAknSoftkeyEdit:
       
   533     case KAiwCmdAssign: // AIW service cmd for Editing
       
   534     case ECCAppDetailsViewEditItemCmd:
       
   535         DoEditCmdL();
       
   536         break;
       
   537 
       
   538     case ECCAppDetailsViewImageCmd:
       
   539         DoViewImageCmdL();
       
   540         break;
       
   541 
       
   542     case ECCAppDetailsViewSendBusinessCardCmd:
       
   543         DoSendBusinessCardCmdL();
       
   544         break;
       
   545 
       
   546     case ECCAppDetailsViewSetTopContactCmd:
       
   547     case ECCAppDetailsViewRemoveTopContactCmd:
       
   548         DoTopContactCmdL();
       
   549         break;
       
   550 
       
   551     case ECCAppDetailsViewDeleteCmd:
       
   552         DoDeleteCmdL();
       
   553         break;
       
   554 
       
   555     case ECCAppDetailsViewCopyCmd:
       
   556         DoCopyCmdL();
       
   557         break;
       
   558 
       
   559     case ECCAppDetailsViewCopyDetailCmd:
       
   560         DoCopyDetailCmdL();
       
   561         break;
       
   562     case ECCAppDetailsViewCopyNumberCmd:
       
   563         DoCopyNumberCmdL();
       
   564         break;
       
   565 
       
   566     case ECCAppDetailsViewCopyAddressCmd:
       
   567         DoCopyAddressCmdL();
       
   568         break;
       
   569     case ECCAppDetailsViewAssignSpeedDialCmd:
       
   570         DoAssignSpeeddialCmdL();
       
   571         break;
       
   572 
       
   573     case ECCAppDetailsViewUnassignSpeedDialCmd:
       
   574         DoUnassignSpeeddialCmdL();
       
   575         break;
       
   576 
       
   577     case ECCAppDetailsViewSetAsDefaultCmd:
       
   578         DoSetDefaultCmdL();
       
   579         break;
       
   580 
       
   581     case ECCAppDetailsViewPrependCmd:
       
   582         DoPrependCmdL();
       
   583         break;
       
   584 
       
   585     case ECCAppDetailsViewFindOnMapCmd:
       
   586     case ECCAppDetailsViewShowOnMapCmd:
       
   587         DoShowOnMapCmdL();
       
   588         break;
       
   589 
       
   590     default:
       
   591         break;
       
   592     }
       
   593 
       
   594     //CCA_DP(KDetailsViewLogFile, CCA_L("<<< CCCAppDetailsViewMenuHandler::HandleCommandL()"));
       
   595 }
       
   596 
       
   597 // ---------------------------------------------------------------------------
       
   598 // CCCAppDetailsViewMenuHandler::DoEditCmdL
       
   599 // ---------------------------------------------------------------------------
       
   600 //
       
   601 void CCCAppDetailsViewMenuHandler::DoEditCmdL()
       
   602 {
       
   603     const CCCAppDetailsViewContainer& container =
       
   604         static_cast<const CCCAppDetailsViewContainer&>(iPlugin.GetContainer());
       
   605 
       
   606 #if 0
       
   607     container.ListBoxModel().OpenEditorL();
       
   608 #else
       
   609     CAiwGenericParamList& inParamList = iAiwServiceHandler->InParamListL();
       
   610 
       
   611     inParamList.AppendL(TAiwGenericParam(
       
   612         EGenericParamContactAssignData,
       
   613         TAiwVariant(TAiwSingleContactAssignDataV1Pckg(
       
   614             TAiwSingleContactAssignDataV1().SetFlags(EskipInfoNotes)))));
       
   615 
       
   616     HBufC8* packedLinks = container.ListBoxModel().Links()->PackLC();
       
   617 
       
   618     inParamList.AppendL(TAiwGenericParam(EGenericParamContactLinkArray,
       
   619         TAiwVariant( *packedLinks)));
       
   620 
       
   621     TInt focusIndex = container.ListBoxModel().FocusedFieldIndex();
       
   622 
       
   623     CCA_DP(KDetailsViewLogFile, CCA_L("CCCAppDetailsViewMenuHandler::DoEditCmdL() focusIndex = %d"), focusIndex);
       
   624 
       
   625     // TODO: use int instead of buf.
       
   626     TBuf<8> focusIndexBuf;
       
   627     focusIndexBuf.Num(focusIndex);
       
   628     const TAiwVariant focusIndexVariant(focusIndexBuf);
       
   629 
       
   630     inParamList.AppendL(TAiwGenericParam(EGenericParamContactItem, focusIndexVariant));
       
   631 
       
   632     iAiwServiceHandler->ExecuteServiceCmdL(
       
   633         KAiwCmdAssign,
       
   634         inParamList,
       
   635         iAiwServiceHandler->OutParamListL(),
       
   636         NULL,
       
   637         this);
       
   638 
       
   639     CleanupStack::PopAndDestroy(packedLinks);
       
   640 #endif
       
   641 }
       
   642 
       
   643 // ---------------------------------------------------------------------------
       
   644 // CCCAppDetailsViewMenuHandler::DoViewImageCmdL
       
   645 // ---------------------------------------------------------------------------
       
   646 //
       
   647 void CCCAppDetailsViewMenuHandler::DoViewImageCmdL()
       
   648 {
       
   649     CAknInformationNote* informationNote = new(ELeave) CAknInformationNote;
       
   650     informationNote->ExecuteLD(_L("Viewing image not supported yet"));
       
   651 }
       
   652 
       
   653 // ---------------------------------------------------------------------------
       
   654 // CCCAppDetailsViewMenuHandler::DoSendBusinessCardCmdL
       
   655 // ---------------------------------------------------------------------------
       
   656 //
       
   657 void CCCAppDetailsViewMenuHandler::DoSendBusinessCardCmdL()
       
   658 {
       
   659     CCCAppDetailsViewContainer& container =
       
   660         static_cast<CCCAppDetailsViewContainer&>(iPlugin.GetContainer());
       
   661 
       
   662     iCommandHandler->HandleCommandL(EPbk2CmdSend, container, NULL);
       
   663 }
       
   664 
       
   665 // ---------------------------------------------------------------------------
       
   666 // CCCAppDetailsViewMenuHandler::DoTopContactCmdL
       
   667 // ---------------------------------------------------------------------------
       
   668 //
       
   669 void CCCAppDetailsViewMenuHandler::DoTopContactCmdL()
       
   670 {
       
   671     CAknInformationNote* informationNote = new(ELeave) CAknInformationNote;
       
   672     informationNote->ExecuteLD(_L("Setting/dropping as top contact not supported yet"));
       
   673 }
       
   674 
       
   675 // ---------------------------------------------------------------------------
       
   676 // CCCAppDetailsViewMenuHandler::DoDeleteCmdL
       
   677 // ---------------------------------------------------------------------------
       
   678 //
       
   679 void CCCAppDetailsViewMenuHandler::DoDeleteCmdL()
       
   680 {
       
   681     CCCAppDetailsViewContainer& container =
       
   682         static_cast<CCCAppDetailsViewContainer&>(iPlugin.GetContainer());
       
   683 
       
   684     iCommandHandler->HandleCommandL(EPbk2CmdDeleteMe, container, NULL);
       
   685 }
       
   686 
       
   687 // ---------------------------------------------------------------------------
       
   688 // CCCAppDetailsViewMenuHandler::DoCopyCmdL
       
   689 // ---------------------------------------------------------------------------
       
   690 //
       
   691 void CCCAppDetailsViewMenuHandler::DoCopyCmdL()
       
   692 {
       
   693     CCCAppDetailsViewContainer& container =
       
   694         static_cast<CCCAppDetailsViewContainer&>(iPlugin.GetContainer());
       
   695 
       
   696     iCommandHandler->HandleCommandL(EPbk2CmdCopy, container, NULL);
       
   697 }
       
   698 
       
   699 // ---------------------------------------------------------------------------
       
   700 // CCCAppDetailsViewMenuHandler::DoCopyDetailCmdL
       
   701 // ---------------------------------------------------------------------------
       
   702 //
       
   703 void CCCAppDetailsViewMenuHandler::DoCopyDetailCmdL()
       
   704 {
       
   705     //EPbk2CmdCopyDetail
       
   706     CCCAppDetailsViewContainer& container =
       
   707             static_cast<CCCAppDetailsViewContainer&>(iPlugin.GetContainer());
       
   708 
       
   709         iCommandHandler->HandleCommandL(EPbk2CmdCopyDetail, container, NULL);
       
   710            
       
   711 }
       
   712 
       
   713 // ---------------------------------------------------------------------------
       
   714 // CCCAppDetailsViewMenuHandler::DoCopyNumberCmdL
       
   715 // ---------------------------------------------------------------------------
       
   716 //
       
   717 void CCCAppDetailsViewMenuHandler::DoCopyNumberCmdL()
       
   718 {
       
   719     //EPbk2CmdCopyNumber
       
   720     CCCAppDetailsViewContainer& container =
       
   721             static_cast<CCCAppDetailsViewContainer&>(iPlugin.GetContainer());
       
   722 
       
   723         iCommandHandler->HandleCommandL(EPbk2CmdCopyNumber, container, NULL);
       
   724            
       
   725 }
       
   726 
       
   727 // ---------------------------------------------------------------------------
       
   728 // CCCAppDetailsViewMenuHandler::DoCopyDetailCmdL
       
   729 // ---------------------------------------------------------------------------
       
   730 //
       
   731 void CCCAppDetailsViewMenuHandler::DoCopyAddressCmdL()
       
   732 {
       
   733     //EPbk2CmdCopyAddress
       
   734 	
       
   735 	CCCAppDetailsViewContainer& container =
       
   736             static_cast<CCCAppDetailsViewContainer&>(iPlugin.GetContainer());
       
   737 
       
   738         iCommandHandler->HandleCommandL(EPbk2CmdCopyAddress, container, NULL);
       
   739            
       
   740 }
       
   741 
       
   742 // ---------------------------------------------------------------------------
       
   743 // CCCAppDetailsViewMenuHandler::DoAssignSpeeddialCmdL
       
   744 // ---------------------------------------------------------------------------
       
   745 //
       
   746 void CCCAppDetailsViewMenuHandler::DoAssignSpeeddialCmdL()
       
   747 {
       
   748     CCCAppDetailsViewContainer& container =
       
   749         static_cast<CCCAppDetailsViewContainer&>(iPlugin.GetContainer());
       
   750 
       
   751     iCommandHandler->HandleCommandL( EPbk2CmdAssignSpeedDial, container, NULL );
       
   752 }
       
   753 
       
   754 // ---------------------------------------------------------------------------
       
   755 // CCCAppDetailsViewMenuHandler::DoUnassignSpeeddialCmdL
       
   756 // ---------------------------------------------------------------------------
       
   757 //
       
   758 void CCCAppDetailsViewMenuHandler::DoUnassignSpeeddialCmdL()
       
   759 {
       
   760     CCCAppDetailsViewContainer& container =
       
   761         static_cast<CCCAppDetailsViewContainer&>(iPlugin.GetContainer());
       
   762 
       
   763     iCommandHandler->HandleCommandL( EPbk2CmdRemoveSpeedDial, container, NULL );
       
   764 }
       
   765 
       
   766 // ---------------------------------------------------------------------------
       
   767 // CCCAppDetailsViewMenuHandler::DoSetDefaultCmdL
       
   768 // ---------------------------------------------------------------------------
       
   769 //
       
   770 void CCCAppDetailsViewMenuHandler::DoSetDefaultCmdL()
       
   771 {
       
   772     CAknInformationNote* informationNote = new(ELeave) CAknInformationNote;
       
   773     informationNote->ExecuteLD(_L("Default not supported yet"));
       
   774 }
       
   775 
       
   776 // ---------------------------------------------------------------------------
       
   777 // CCCAppDetailsViewMenuHandler::DoPrependCmdL
       
   778 // ---------------------------------------------------------------------------
       
   779 //
       
   780 void CCCAppDetailsViewMenuHandler::DoPrependCmdL()
       
   781 {
       
   782     CCCAppDetailsViewContainer& container =
       
   783         static_cast<CCCAppDetailsViewContainer&>(iPlugin.GetContainer());
       
   784     iCommandHandler->HandleCommandL(EPbk2CmdPrepend, container, NULL);
       
   785 }
       
   786 
       
   787 // ---------------------------------------------------------------------------
       
   788 // CCCAppDetailsViewMenuHandler::DoShowOnMapCmdL
       
   789 // ---------------------------------------------------------------------------
       
   790 //
       
   791 void CCCAppDetailsViewMenuHandler::DoShowOnMapCmdL()
       
   792 {
       
   793     CCCAppDetailsViewContainer& container =
       
   794         static_cast<CCCAppDetailsViewContainer&>(iPlugin.GetContainer());
       
   795 
       
   796     iCommandHandler->HandleCommandL(
       
   797         EPbk2ExtensionShowOnMap, container, NULL);
       
   798 }
       
   799 
       
   800 // ---------------------------------------------------------------------------
       
   801 // CCCAppDetailsViewMenuHandler::HasAddressFieldL
       
   802 // ---------------------------------------------------------------------------
       
   803 //
       
   804 TBool CCCAppDetailsViewMenuHandler::HasAddressFieldL()
       
   805 {
       
   806     TBool addressField = EFalse;
       
   807 
       
   808     const CCCAppDetailsViewContainer& container =
       
   809         static_cast<const CCCAppDetailsViewContainer&>( iPlugin.GetContainer() );
       
   810     TInt countFields =
       
   811         container.FocusedStoreContact()->Fields().FieldCount();
       
   812     for ( TInt i = 0; i < countFields; i++ )
       
   813     {
       
   814         const MVPbkStoreContactField& field =
       
   815             container.FocusedStoreContact()->Fields().FieldAt( i );
       
   816         TInt countProps =
       
   817             field.BestMatchingFieldType()->VersitProperties().Count();
       
   818         TArray<TVPbkFieldVersitProperty> props =
       
   819             field.BestMatchingFieldType()->VersitProperties();
       
   820         for ( TInt ii = 0; ii < countProps; ii++ )
       
   821         {
       
   822             if ( props[ ii ].Name() == EVPbkVersitNameADR )
       
   823             {
       
   824                 addressField = ETrue;
       
   825                 break;
       
   826             }
       
   827         }
       
   828     }
       
   829     return addressField;
       
   830 }
       
   831 
       
   832 // ---------------------------------------------------------------------------
       
   833 // CCCAppDetailsViewMenuHandler::IsAddressValidatedL
       
   834 // ---------------------------------------------------------------------------
       
   835 //
       
   836 TBool CCCAppDetailsViewMenuHandler::IsAddressValidatedL()
       
   837 {
       
   838     TBool generalAddress = ETrue;
       
   839     TBool homeAddress = ETrue;
       
   840     TBool workAddress = ETrue;
       
   841     TBool geoField = EFalse;
       
   842     TVPbkFieldTypeParameter focusedField = EVPbkVersitParamOther;
       
   843 
       
   844     if ( IsFocusedFieldTypeL( R_DETAILSVIEW_HOME_ADDRESS_SELECTOR ) )
       
   845     {
       
   846         focusedField = EVPbkVersitParamHOME;
       
   847     }
       
   848     else if ( IsFocusedFieldTypeL( R_DETAILSVIEW_WORK_ADDRESS_SELECTOR ) )
       
   849     {
       
   850         focusedField = EVPbkVersitParamWORK;
       
   851     }
       
   852     else if ( IsFocusedFieldTypeL( R_DETAILSVIEW_GENERAL_ADDRESS_SELECTOR ) )
       
   853     {
       
   854         focusedField = EVPbkVersitParamPREF;
       
   855     }
       
   856 
       
   857     const CCCAppDetailsViewContainer& container =
       
   858         static_cast<const CCCAppDetailsViewContainer&>( iPlugin.GetContainer() );
       
   859     TInt countFields =
       
   860         container.FocusedStoreContact()->Fields().FieldCount();
       
   861 
       
   862     if ( focusedField == EVPbkVersitParamOther )
       
   863     {
       
   864         for ( TInt i = 0; i < countFields; i++ )
       
   865         {
       
   866             const MVPbkStoreContactField& field =
       
   867                 container.FocusedStoreContact()->Fields().FieldAt( i );
       
   868             TInt countProps =
       
   869                 field.BestMatchingFieldType()->VersitProperties().Count();
       
   870             TArray<TVPbkFieldVersitProperty> props =
       
   871                 field.BestMatchingFieldType()->VersitProperties();
       
   872             for ( TInt ii = 0; ii < countProps; ii++ )
       
   873             {
       
   874                 if ( props[ ii ].Name() == EVPbkVersitNameADR )
       
   875                 {
       
   876                     if ( props[ ii ].Parameters().Contains(
       
   877                         EVPbkVersitParamHOME ) )
       
   878                     {
       
   879                         homeAddress = EFalse;
       
   880                     }
       
   881                     else if ( props[ ii ].Parameters().Contains(
       
   882                         EVPbkVersitParamWORK ) )
       
   883                     {
       
   884                         workAddress = EFalse;
       
   885                     }
       
   886                     else
       
   887                     {
       
   888                         generalAddress = EFalse;
       
   889                     }
       
   890                 }
       
   891             }
       
   892         }
       
   893     }
       
   894 
       
   895     for ( TInt i = 0; i < countFields; i++ )
       
   896     {
       
   897         const MVPbkStoreContactField& field =
       
   898             container.FocusedStoreContact()->Fields().FieldAt( i );
       
   899         TInt countProps =
       
   900             field.BestMatchingFieldType()->VersitProperties().Count();
       
   901         TArray<TVPbkFieldVersitProperty> props =
       
   902             field.BestMatchingFieldType()->VersitProperties();
       
   903         for ( TInt ii = 0; ii < countProps; ii++ )
       
   904         {
       
   905             if ( props[ ii ].Name() == EVPbkVersitNameGEO )
       
   906             {
       
   907                 if ( props[ ii ].Parameters().Contains(
       
   908                     EVPbkVersitParamHOME ) )
       
   909                 {
       
   910                     if ( focusedField == EVPbkVersitParamHOME )
       
   911                     {
       
   912                         return ETrue;
       
   913                     }
       
   914                     homeAddress = ETrue;
       
   915                 }
       
   916                 else if ( props[ ii ].Parameters().Contains(
       
   917                     EVPbkVersitParamWORK ) )
       
   918                 {
       
   919                     if ( focusedField == EVPbkVersitParamWORK )
       
   920                     {
       
   921                         return ETrue;
       
   922                     }
       
   923                     workAddress = ETrue;
       
   924                 }
       
   925                 else
       
   926                 {
       
   927                     if ( focusedField == EVPbkVersitParamPREF )
       
   928                     {
       
   929                         return ETrue;
       
   930                     }
       
   931                     generalAddress = ETrue;
       
   932                 }
       
   933             }
       
   934         }
       
   935     }
       
   936 
       
   937     if ( focusedField == EVPbkVersitParamOther
       
   938         && generalAddress && homeAddress && workAddress )
       
   939     {
       
   940         geoField = ETrue;
       
   941     }
       
   942 
       
   943     return geoField;
       
   944 }
       
   945 
       
   946 // End of File