phonebookui/Phonebook2/ccapplication/ccadetailsviewplugin/src/ccappdetailsviewmenuhandler.cpp
branchRCL_3
changeset 3 04ab22b956c2
parent 0 e686773b3f54
child 14 81f8547efd4f
equal deleted inserted replaced
0:e686773b3f54 3:04ab22b956c2
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  Implementation of ccappdetailsview menuhandler
    14 * Description:  Implementation of ccappdetailsview menuhandler
    15 *  Version     : %version: he1s60#31.1.13 %
    15 *  Version     : %version: he1s60#31.1.15 %
    16 *
    16 *
    17 */
    17 */
    18 
    18 
    19 #include <AiwServiceHandler.h>
    19 #include <AiwServiceHandler.h>
    20 #include <AiwContactAssignDataTypes.h>
    20 #include <AiwContactAssignDataTypes.h>
   530     switch (aCommand)
   530     switch (aCommand)
   531     {
   531     {
   532     case EAknSoftkeyEdit:
   532     case EAknSoftkeyEdit:
   533     case KAiwCmdAssign: // AIW service cmd for Editing
   533     case KAiwCmdAssign: // AIW service cmd for Editing
   534     case ECCAppDetailsViewEditItemCmd:
   534     case ECCAppDetailsViewEditItemCmd:
   535         DoEditCmdL();
   535         DoEditCmdL( aCommand );
   536         break;
   536         break;
   537 
   537 
   538     case ECCAppDetailsViewImageCmd:
   538     case ECCAppDetailsViewImageCmd:
   539         DoViewImageCmdL();
   539         DoViewImageCmdL();
   540         break;
   540         break;
   596 
   596 
   597 // ---------------------------------------------------------------------------
   597 // ---------------------------------------------------------------------------
   598 // CCCAppDetailsViewMenuHandler::DoEditCmdL
   598 // CCCAppDetailsViewMenuHandler::DoEditCmdL
   599 // ---------------------------------------------------------------------------
   599 // ---------------------------------------------------------------------------
   600 //
   600 //
   601 void CCCAppDetailsViewMenuHandler::DoEditCmdL()
   601 void CCCAppDetailsViewMenuHandler::DoEditCmdL(  TInt aCommand )
   602 {
   602 {
   603     const CCCAppDetailsViewContainer& container =
   603     const CCCAppDetailsViewContainer& container =
   604         static_cast<const CCCAppDetailsViewContainer&>(iPlugin.GetContainer());
   604         static_cast<const CCCAppDetailsViewContainer&>(iPlugin.GetContainer());
   605 
   605 
   606 #if 0
   606 #if 0
   615 
   615 
   616     HBufC8* packedLinks = container.ListBoxModel().Links()->PackLC();
   616     HBufC8* packedLinks = container.ListBoxModel().Links()->PackLC();
   617 
   617 
   618     inParamList.AppendL(TAiwGenericParam(EGenericParamContactLinkArray,
   618     inParamList.AppendL(TAiwGenericParam(EGenericParamContactLinkArray,
   619         TAiwVariant( *packedLinks)));
   619         TAiwVariant( *packedLinks)));
   620 
   620     
   621     TInt focusIndex = container.ListBoxModel().FocusedFieldIndex();
   621     TInt focusIndex = container.ListBoxModel().FocusedFieldIndex();
       
   622     
       
   623     TBool itemFocused = iPlugin.MenuBar()->ItemSpecificCommandsEnabled();
       
   624     TBool isAddressField = EFalse;
       
   625     MVPbkBaseContactField* focusedField = container.ListBoxModel().FocusedFieldLC();
       
   626     if ( focusedField )
       
   627         {
       
   628         const MVPbkFieldType* type = focusedField->BestMatchingFieldType();
       
   629         const TArray<TVPbkFieldVersitProperty> propArr = type->VersitProperties();
       
   630         if(propArr.Count())
       
   631             {
       
   632             const TVPbkFieldVersitProperty prop = propArr[0];
       
   633             if(prop.Name() == EVPbkVersitNameADR)
       
   634                 {
       
   635                 isAddressField = ETrue;
       
   636                 }
       
   637             }
       
   638         }
       
   639     CleanupStack::PopAndDestroy( focusedField );
       
   640     
       
   641     // this is only for the case, if there is only address field( address field is in first 
       
   642     // item in details view), when select "Edit" from options menu, if the item is not focused,
       
   643     // contact eidtor view should be opened instead of address editor view.
       
   644     // if the address field is focused or or select the list item directly, address editor view
       
   645     // should be opened insdead of contact eidtor view.
       
   646     // set focusIndex to KErrNotFound in order to open contact editor view.
       
   647     if ( isAddressField && !itemFocused && aCommand != ECCAppDetailsViewEditItemCmd )
       
   648         {
       
   649         focusIndex = KErrNotFound;
       
   650         }
   622 
   651 
   623     CCA_DP(KDetailsViewLogFile, CCA_L("CCCAppDetailsViewMenuHandler::DoEditCmdL() focusIndex = %d"), focusIndex);
   652     CCA_DP(KDetailsViewLogFile, CCA_L("CCCAppDetailsViewMenuHandler::DoEditCmdL() focusIndex = %d"), focusIndex);
   624 
   653 
   625     // TODO: use int instead of buf.
   654     // TODO: use int instead of buf.
   626     TBuf<8> focusIndexBuf;
   655     TBuf<8> focusIndexBuf;
   807 
   836 
   808     const CCCAppDetailsViewContainer& container =
   837     const CCCAppDetailsViewContainer& container =
   809         static_cast<const CCCAppDetailsViewContainer&>( iPlugin.GetContainer() );
   838         static_cast<const CCCAppDetailsViewContainer&>( iPlugin.GetContainer() );
   810     TInt countFields =
   839     TInt countFields =
   811         container.FocusedStoreContact()->Fields().FieldCount();
   840         container.FocusedStoreContact()->Fields().FieldCount();
       
   841     for ( TInt i = 0; i < countFields; i++ )
       
   842     {
       
   843         const MVPbkStoreContactField& field =
       
   844             container.FocusedStoreContact()->Fields().FieldAt( i );
       
   845         const MVPbkFieldType* fieldType = field.BestMatchingFieldType();
       
   846         if ( fieldType )
       
   847             {
       
   848             TInt countProps = fieldType->VersitProperties().Count();
       
   849             TArray<TVPbkFieldVersitProperty> props =
       
   850                 fieldType->VersitProperties();
       
   851             for (TInt ii = 0; ii < countProps; ii++ )
       
   852                 {
       
   853                 if ( props[ii].Name() == EVPbkVersitNameADR )
       
   854                     {
       
   855                     addressField = ETrue;
       
   856                     break;
       
   857                     }
       
   858                 }
       
   859             }
       
   860     }
       
   861     return addressField;
       
   862 }
       
   863 
       
   864 // ---------------------------------------------------------------------------
       
   865 // CCCAppDetailsViewMenuHandler::IsAddressValidatedL
       
   866 // ---------------------------------------------------------------------------
       
   867 //
       
   868 TBool CCCAppDetailsViewMenuHandler::IsAddressValidatedL()
       
   869 {
       
   870     TBool generalAddress = ETrue;
       
   871     TBool homeAddress = ETrue;
       
   872     TBool workAddress = ETrue;
       
   873     TBool geoField = EFalse;
       
   874     TVPbkFieldTypeParameter focusedField = EVPbkVersitParamOther;
       
   875 
       
   876     if ( IsFocusedFieldTypeL( R_DETAILSVIEW_HOME_ADDRESS_SELECTOR ) )
       
   877     {
       
   878         focusedField = EVPbkVersitParamHOME;
       
   879     }
       
   880     else if ( IsFocusedFieldTypeL( R_DETAILSVIEW_WORK_ADDRESS_SELECTOR ) )
       
   881     {
       
   882         focusedField = EVPbkVersitParamWORK;
       
   883     }
       
   884     else if ( IsFocusedFieldTypeL( R_DETAILSVIEW_GENERAL_ADDRESS_SELECTOR ) )
       
   885     {
       
   886         focusedField = EVPbkVersitParamPREF;
       
   887     }
       
   888 
       
   889     const CCCAppDetailsViewContainer& container =
       
   890         static_cast<const CCCAppDetailsViewContainer&>( iPlugin.GetContainer() );
       
   891     TInt countFields =
       
   892         container.FocusedStoreContact()->Fields().FieldCount();
       
   893 
       
   894     if ( focusedField == EVPbkVersitParamOther )
       
   895     {
       
   896         for ( TInt i = 0; i < countFields; i++ )
       
   897         {
       
   898             const MVPbkStoreContactField& field =
       
   899                 container.FocusedStoreContact()->Fields().FieldAt( i );
       
   900             TInt countProps =
       
   901                 field.BestMatchingFieldType()->VersitProperties().Count();
       
   902             TArray<TVPbkFieldVersitProperty> props =
       
   903                 field.BestMatchingFieldType()->VersitProperties();
       
   904             for ( TInt ii = 0; ii < countProps; ii++ )
       
   905             {
       
   906                 if ( props[ ii ].Name() == EVPbkVersitNameADR )
       
   907                 {
       
   908                     if ( props[ ii ].Parameters().Contains(
       
   909                         EVPbkVersitParamHOME ) )
       
   910                     {
       
   911                         homeAddress = EFalse;
       
   912                     }
       
   913                     else if ( props[ ii ].Parameters().Contains(
       
   914                         EVPbkVersitParamWORK ) )
       
   915                     {
       
   916                         workAddress = EFalse;
       
   917                     }
       
   918                     else
       
   919                     {
       
   920                         generalAddress = EFalse;
       
   921                     }
       
   922                 }
       
   923             }
       
   924         }
       
   925     }
       
   926 
   812     for ( TInt i = 0; i < countFields; i++ )
   927     for ( TInt i = 0; i < countFields; i++ )
   813     {
   928     {
   814         const MVPbkStoreContactField& field =
   929         const MVPbkStoreContactField& field =
   815             container.FocusedStoreContact()->Fields().FieldAt( i );
   930             container.FocusedStoreContact()->Fields().FieldAt( i );
   816         TInt countProps =
   931         TInt countProps =
   817             field.BestMatchingFieldType()->VersitProperties().Count();
   932             field.BestMatchingFieldType()->VersitProperties().Count();
   818         TArray<TVPbkFieldVersitProperty> props =
   933         TArray<TVPbkFieldVersitProperty> props =
   819             field.BestMatchingFieldType()->VersitProperties();
   934             field.BestMatchingFieldType()->VersitProperties();
   820         for ( TInt ii = 0; ii < countProps; ii++ )
   935         for ( TInt ii = 0; ii < countProps; ii++ )
   821         {
   936         {
   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 )
   937             if ( props[ ii ].Name() == EVPbkVersitNameGEO )
   906             {
   938             {
   907                 if ( props[ ii ].Parameters().Contains(
   939                 if ( props[ ii ].Parameters().Contains(
   908                     EVPbkVersitParamHOME ) )
   940                     EVPbkVersitParamHOME ) )
   909                 {
   941                 {