phonebookui/Phonebook2/xSPExtensionManager/src/CxSPSortNamesListViewExtension.cpp
changeset 0 e686773b3f54
child 21 9da50d567e3c
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2006 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: 
       
    15 *       Implementation for CxSPSortNamesListViewExtension.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "CxSPSortNamesListViewExtension.h"
       
    22 
       
    23 // System includes
       
    24 #include <eikmenup.h>
       
    25 #include <AknGlobalNote.h>
       
    26 
       
    27 // From Phonebook2
       
    28 #include <MPbk2AppUi.h>
       
    29 #include <MPbk2ContactUiControl.h>
       
    30 #include <MPbk2ViewExplorer.h>
       
    31 #include <CPbk2ViewState.h>
       
    32 
       
    33 // internal
       
    34 #include "ExtensionManager.hrh"
       
    35 #include <ExtensionManagerRes.rsg>
       
    36 #include "MxSPCommandMapper.h"
       
    37 #include "ExtensionManagerUID.H"
       
    38 
       
    39 using namespace Phonebook2;
       
    40 
       
    41 // ================= MEMBER FUNCTIONS =======================
       
    42 
       
    43 inline CxSPSortNamesListViewExtension::CxSPSortNamesListViewExtension()
       
    44     {
       
    45     }
       
    46 
       
    47 inline void CxSPSortNamesListViewExtension::ConstructL()
       
    48     {
       
    49     }
       
    50 
       
    51 CxSPSortNamesListViewExtension* CxSPSortNamesListViewExtension::NewL()
       
    52     {
       
    53     CxSPSortNamesListViewExtension* self = new(ELeave) CxSPSortNamesListViewExtension();
       
    54     CleanupStack::PushL(self);
       
    55     self->ConstructL();
       
    56     CleanupStack::Pop(self);
       
    57     return self;
       
    58     }
       
    59 
       
    60 CxSPSortNamesListViewExtension::~CxSPSortNamesListViewExtension()
       
    61     {
       
    62     }
       
    63 
       
    64 void CxSPSortNamesListViewExtension::DoRelease()
       
    65     {
       
    66     delete this;
       
    67     }
       
    68 
       
    69 void CxSPSortNamesListViewExtension::DynInitMenuPaneL
       
    70         ( TInt /*aResourceId*/, CEikMenuPane* /*aMenuPane*/ )
       
    71     {
       
    72     }
       
    73     
       
    74 void CxSPSortNamesListViewExtension::DynInitNamesListMainMenuPaneL
       
    75   		( TInt /*aResourceId*/, CEikMenuPane* aMenuPane )
       
    76   		{
       
    77   		AddMenuContentsL( *aMenuPane );
       
    78        	ChangeCommandL( *aMenuPane, EExtensionManagerCmdSort );	
       
    79   		}
       
    80     
       
    81 void CxSPSortNamesListViewExtension::AddMenuContentsL( CEikMenuPane& aMenuPane )
       
    82     {
       
    83     TInt newCommand;
       
    84 	TInt err = iMapper->GetNewCommand( KEXTENSIONMANAGERIMPLEMENTATIONUID, 
       
    85 									   EExtensionManagerCmdSort, 
       
    86 									   newCommand );		
       
    87 	User::LeaveIfError( err );	        
       
    88     TInt pos;
       
    89     if( !aMenuPane.MenuItemExists( newCommand, pos ) )
       
    90     	{
       
    91         aMenuPane.AddMenuItemsL( R_SORT_NAMES_LIST_VIEW_MENU );
       
    92     	}
       
    93     }    
       
    94     
       
    95 void CxSPSortNamesListViewExtension::ChangeCommandL( CEikMenuPane& aMenuPane, TInt aOldCommand )
       
    96 	{		
       
    97 	TInt pos;
       
    98 	if( aMenuPane.MenuItemExists( aOldCommand, pos ) )
       
    99 		{
       
   100 		TInt newCommand;
       
   101 		TInt err = iMapper->GetNewCommand( KEXTENSIONMANAGERIMPLEMENTATIONUID, 
       
   102 										   aOldCommand, 
       
   103 										   newCommand );
       
   104 		User::LeaveIfError( err );		
       
   105 		CEikMenuPaneItem::SData& data = aMenuPane.ItemDataByIndexL( pos );
       
   106 		data.iCommandId = newCommand;
       
   107 		}
       
   108 	}
       
   109 
       
   110 TBool CxSPSortNamesListViewExtension::HandleCommandL( TInt aCommandId,
       
   111 													MPbk2ContactUiControl* aUiControl )
       
   112     {
       
   113     TBool result( EFalse );
       
   114 	TInt oldCommand;
       
   115 	TInt err = iMapper->GetOldCommand( KEXTENSIONMANAGERIMPLEMENTATIONUID, aCommandId, oldCommand );
       
   116 	
       
   117 	if( !err )
       
   118 		{
       
   119 		switch( oldCommand )
       
   120 	        {
       
   121 	        case EExtensionManagerCmdSort:
       
   122 	            {
       
   123 	            CPbk2ViewState* state = aUiControl->ControlStateL();
       
   124         		CleanupStack::PushL( state );
       
   125         		Pbk2AppUi()->Pbk2ViewExplorer()->
       
   126             		ActivatePhonebook2ViewL( TUid::Uid(
       
   127                 		EExtensionManagerSortViewId ), state );
       
   128         		CleanupStack::PopAndDestroy( state );
       
   129         		aUiControl->UpdateAfterCommandExecution();
       
   130 	            result = ETrue;
       
   131 	            break;
       
   132 	            }
       
   133 	        default:
       
   134 	            {
       
   135 	            break;
       
   136 	            }
       
   137 	        }	
       
   138 		}
       
   139     
       
   140     return result;
       
   141     }
       
   142 
       
   143 void CxSPSortNamesListViewExtension::RegisterCommandMapper( MxSPCommandMapper& aMapper )
       
   144 	{
       
   145 	iMapper = &aMapper;
       
   146 	}
       
   147 	
       
   148 TInt CxSPSortNamesListViewExtension::CommandInfoResource() const
       
   149 	{
       
   150 	return R_EXTENSION_MANAGER_COMMAND_INFO;
       
   151 	}
       
   152 
       
   153 //  End of File