phonebookui/Phonebook2/GroupExtension/src/CPguGroupMembersView.cpp
changeset 0 e686773b3f54
child 6 e8e3147d53eb
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2006-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:  Phonebook 2 group members view.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "CPguGroupMembersView.h"
       
    20 
       
    21 // Phonebook 2
       
    22 #include "CPguAddMembersCmd.h"
       
    23 #include "CPguRemoveFromGroupCmd.h"
       
    24 #include "Pbk2GroupUi.hrh"
       
    25 #include <Pbk2GroupUIRes.rsg>
       
    26 #include <CPbk2AppUiBase.h>
       
    27 #include <Pbk2Commands.rsg>
       
    28 #include <CPbk2UIExtensionView.h>
       
    29 #include <CPbk2DocumentBase.h>
       
    30 #include <CPbk2NamesListControl.h>
       
    31 #include <CPbk2ViewState.h>
       
    32 #include <CPbk2ControlContainer.h>
       
    33 #include <MPbk2ViewActivationTransaction.h>
       
    34 #include <MPbk2ViewExplorer.h>
       
    35 #include <MPbk2CommandHandler.h>
       
    36 #include <CPbk2SortOrderManager.h>
       
    37 #include <MPbk2ContactNavigation.h>
       
    38 #include <MPbk2ContactNavigationLoader.h>
       
    39 #include <Pbk2NavigatorFactory.h>
       
    40 #include <Pbk2Commands.hrh>
       
    41 #include <MPbk2ContactNameFormatter.h>
       
    42 #include <CPbk2ViewStateTransformer.h>
       
    43 #include <csxhelp/phob.hlp.hrh>
       
    44 #include <Pbk2UID.h>
       
    45 #include <MPbk2StartupMonitor.h>
       
    46 #include <MVPbkContactViewObserver.h>
       
    47 #include <CPbk2ContactUiControlSubstitute.h>
       
    48 #include <MPbk2StoreConfigurationObserver.h>
       
    49 #include <MPbk2ControlObserver.h>
       
    50 #include <MPbk2NavigationObserver.h>
       
    51 #include <MPbk2MenuCommandObserver.h>
       
    52 #include <Pbk2CommonUi.rsg>
       
    53 #include <Pbk2UIControls.rsg>
       
    54 #include <MPbk2PointerEventInspector.h>
       
    55 #include <MPbk2ApplicationServices.h>
       
    56 #include <MPbk2ContactViewSupplier.h>
       
    57 #include <CPbk2StoreConfiguration.h>
       
    58 #include <MPbk2AppUi.h>
       
    59 
       
    60 // Virtual Phonebook
       
    61 #include <MVPbkContactViewBase.h>
       
    62 #include <MVPbkViewContact.h>
       
    63 #include <MVPbkExpandable.h>
       
    64 #include <MVPbkContactLink.h>
       
    65 #include <CVPbkContactStoreUriArray.h>
       
    66 #include <CVPbkContactManager.h>
       
    67 #include <MVPbkContactStoreList.h>
       
    68 #include <MVPbkContactStore.h>
       
    69 #include <MVPbkContactStoreProperties.h>
       
    70 
       
    71 // System includes
       
    72 #include <akntitle.h>
       
    73 #include <eikbtgpc.h>
       
    74 #include <avkon.rsg>
       
    75 #include <aknnavide.h>
       
    76 #include <akntabgrp.h>
       
    77 #include <StringLoader.h>
       
    78 #include <AknUtils.h>
       
    79 #include <eiklbx.h>
       
    80 #include <eiklbo.h>
       
    81 #include <touchfeedback.h>
       
    82 
       
    83 
       
    84 /// Unnamed namespace for local definitions
       
    85 namespace {
       
    86 
       
    87 const TInt KFirstItem = 0; // First item index
       
    88 
       
    89 /**
       
    90  * Returns ETrue if shift is depressed in aKeyEvent.
       
    91  *
       
    92  * @param aKeyEvent     Key event.
       
    93  * @return  ETrue if shift is depressed.
       
    94  */
       
    95 inline TBool ShiftDown( const TKeyEvent& aKeyEvent )
       
    96     {
       
    97     return ( ( aKeyEvent.iModifiers ) &
       
    98              ( EModifierShift|EModifierLeftShift|EModifierRightShift )
       
    99                 ) != 0;
       
   100     }
       
   101 
       
   102 /**
       
   103  * Returns ETrue if either Shift or Control key is depressed.
       
   104  *
       
   105  * @param aKeyEvent Key event.
       
   106  * @return  ETrue if shift or control is down.
       
   107  */
       
   108 inline TBool IsShiftOrControlDown( const TKeyEvent& aKeyEvent )
       
   109     {
       
   110     return ( aKeyEvent.iModifiers &
       
   111         ( EModifierShift | EModifierLeftShift | EModifierRightShift |
       
   112           EModifierCtrl | EModifierLeftCtrl | EModifierRightCtrl ) ) != 0;
       
   113     }
       
   114 
       
   115 /**
       
   116  * Phonebook 2 group members transaction.
       
   117  * Encapsulates the information that is needed
       
   118  * to switch from group to group viewing.
       
   119  */
       
   120 class CGroupMembersViewTransaction : public CBase
       
   121     {
       
   122     public: // Construction and destruction
       
   123 
       
   124         /**
       
   125          * Creates new instance of this class.
       
   126          *
       
   127          * @return  A new instace of this class.
       
   128          */
       
   129         static CGroupMembersViewTransaction* NewLC();
       
   130 
       
   131         /**
       
   132          * Destructor
       
   133          */
       
   134         ~CGroupMembersViewTransaction();
       
   135 
       
   136     public: // Interface
       
   137 
       
   138         /**
       
   139          * Sets group members view.
       
   140          *
       
   141          * @param aGroupMembersView     Group members view to set.
       
   142          */
       
   143         void SetGroupMembersView(
       
   144                 MVPbkContactViewBase* aGroupMembersView );
       
   145 
       
   146         /**
       
   147          * Set group's name.
       
   148          *
       
   149          * @param aGroupName        Group name to set.
       
   150          */
       
   151         void SetGroupName(
       
   152                 HBufC* aGroupName );
       
   153 
       
   154         /**
       
   155          * Sets group link.
       
   156          *
       
   157          * @param aGroupLink Group link to set.
       
   158          */
       
   159         void SetGroupLink(
       
   160                 MVPbkContactLink* aGroupLink );
       
   161 
       
   162         /**
       
   163          * Returns group link.
       
   164          *
       
   165          * @return  Group link.
       
   166          */
       
   167         MVPbkContactLink* GroupLink() const;
       
   168 
       
   169         /**
       
   170          * Returns group link, ownership is transferred.
       
   171          *
       
   172          * @return  Group link.
       
   173          */
       
   174         MVPbkContactLink* GetGroupLink();
       
   175 
       
   176         /**
       
   177          * Returns group name.
       
   178          *
       
   179          * @return  Group name.
       
   180          */
       
   181         HBufC* GetGroupName();
       
   182 
       
   183         /**
       
   184          * Returns group members view.
       
   185          *
       
   186          * @return  Group members view.
       
   187          */
       
   188         MVPbkContactViewBase* GroupMembersView() const;
       
   189 
       
   190         /**
       
   191          * Returns group members view, ownership is transferred.
       
   192          *
       
   193          * @return  Group members view.
       
   194          */
       
   195         MVPbkContactViewBase* GetGroupMembersView();
       
   196 
       
   197     private: // Implementation
       
   198         CGroupMembersViewTransaction();
       
   199 
       
   200     private: // Data
       
   201         /// Own: Group members view
       
   202         MVPbkContactViewBase* iGroupMembersView;
       
   203         /// Own: Group name
       
   204         HBufC* iGroupName;
       
   205         /// Own: Group link
       
   206         MVPbkContactLink* iGroupLink;
       
   207     };
       
   208 
       
   209 // --------------------------------------------------------------------------
       
   210 // CGroupMembersViewTransaction::CGroupMembersViewTransaction
       
   211 // --------------------------------------------------------------------------
       
   212 //
       
   213 CGroupMembersViewTransaction::CGroupMembersViewTransaction()
       
   214     {
       
   215     }
       
   216 
       
   217 // --------------------------------------------------------------------------
       
   218 // CGroupMembersViewTransaction::~CGroupMembersViewTransaction
       
   219 // --------------------------------------------------------------------------
       
   220 //
       
   221 CGroupMembersViewTransaction::~CGroupMembersViewTransaction()
       
   222     {
       
   223     delete iGroupMembersView;
       
   224     delete iGroupName;
       
   225     delete iGroupLink;
       
   226     }
       
   227 
       
   228 // --------------------------------------------------------------------------
       
   229 // CGroupMembersViewTransaction::NewLC
       
   230 // --------------------------------------------------------------------------
       
   231 //
       
   232 CGroupMembersViewTransaction* CGroupMembersViewTransaction::NewLC()
       
   233     {
       
   234     CGroupMembersViewTransaction* self =
       
   235         new ( ELeave ) CGroupMembersViewTransaction;
       
   236     CleanupStack::PushL( self );
       
   237     return self;
       
   238     }
       
   239 
       
   240 // --------------------------------------------------------------------------
       
   241 // CGroupMembersViewTransaction::SetGroupMembersView
       
   242 // --------------------------------------------------------------------------
       
   243 //
       
   244 void CGroupMembersViewTransaction::SetGroupMembersView
       
   245         ( MVPbkContactViewBase* aGroupMembersView )
       
   246     {
       
   247     delete iGroupMembersView;
       
   248     iGroupMembersView = aGroupMembersView;
       
   249     }
       
   250 
       
   251 // --------------------------------------------------------------------------
       
   252 // CGroupMembersViewTransaction::SetGroupName
       
   253 // --------------------------------------------------------------------------
       
   254 //
       
   255 void CGroupMembersViewTransaction::SetGroupName
       
   256         ( HBufC* aGroupName )
       
   257     {
       
   258     delete iGroupName;
       
   259     iGroupName = aGroupName;
       
   260     }
       
   261 
       
   262 // --------------------------------------------------------------------------
       
   263 // CGroupMembersViewTransaction::SetGroupLink
       
   264 // --------------------------------------------------------------------------
       
   265 //
       
   266 void CGroupMembersViewTransaction::SetGroupLink
       
   267         ( MVPbkContactLink* aGroupLink )
       
   268     {
       
   269     delete iGroupLink;
       
   270     iGroupLink = aGroupLink;
       
   271     }
       
   272 
       
   273 // --------------------------------------------------------------------------
       
   274 // CGroupMembersViewTransaction::GroupLink
       
   275 // --------------------------------------------------------------------------
       
   276 //
       
   277 MVPbkContactLink* CGroupMembersViewTransaction::GroupLink() const
       
   278     {
       
   279     return iGroupLink;
       
   280     }
       
   281 
       
   282 // --------------------------------------------------------------------------
       
   283 // CGroupMembersViewTransaction::GetGroupLink
       
   284 // --------------------------------------------------------------------------
       
   285 //
       
   286 MVPbkContactLink* CGroupMembersViewTransaction::GetGroupLink()
       
   287     {
       
   288     MVPbkContactLink* groupLink = iGroupLink;
       
   289     iGroupLink = NULL;
       
   290     return groupLink;
       
   291     }
       
   292 
       
   293 // --------------------------------------------------------------------------
       
   294 // CGroupMembersViewTransaction::GetGroupName
       
   295 // --------------------------------------------------------------------------
       
   296 //
       
   297 HBufC* CGroupMembersViewTransaction::GetGroupName()
       
   298     {
       
   299     HBufC* groupName = iGroupName;
       
   300     iGroupName = NULL;
       
   301     return groupName;
       
   302     }
       
   303 
       
   304 // --------------------------------------------------------------------------
       
   305 // CGroupMembersViewTransaction::GroupMembersView
       
   306 // --------------------------------------------------------------------------
       
   307 //
       
   308 MVPbkContactViewBase* CGroupMembersViewTransaction::GroupMembersView() const
       
   309     {
       
   310     return iGroupMembersView;
       
   311     }
       
   312 
       
   313 // --------------------------------------------------------------------------
       
   314 // CGroupMembersViewTransaction::GetGroupMembersView
       
   315 // --------------------------------------------------------------------------
       
   316 //
       
   317 MVPbkContactViewBase* CGroupMembersViewTransaction::GetGroupMembersView()
       
   318     {
       
   319     MVPbkContactViewBase* groupMembersView = iGroupMembersView;
       
   320     iGroupMembersView = NULL;
       
   321     return groupMembersView;
       
   322     }
       
   323 
       
   324 } /// namespace
       
   325 
       
   326 /**
       
   327  * Phonebook 2 group members view implementation base class.
       
   328  */
       
   329 class CPguGroupMembersView::CGroupMembersViewImpl :
       
   330         public CBase,
       
   331         protected MVPbkContactViewObserver
       
   332     {
       
   333     public: // Interface
       
   334 
       
   335         /**
       
   336          * Creates control.
       
   337          *
       
   338          * @param aClientRect   Client's rect.
       
   339          */
       
   340         virtual void CreateControlL(
       
   341                 const TRect& aClientRect ) = 0;
       
   342 
       
   343         /**
       
   344          * Returns the control.
       
   345          *
       
   346          * @return  Control.
       
   347          */
       
   348         virtual MPbk2ContactUiControl* Control() = 0;
       
   349 
       
   350         /**
       
   351          * Return view's state.
       
   352          *
       
   353          * @return  View state.
       
   354          */
       
   355         virtual CPbk2ViewState* ViewStateLC() const = 0;
       
   356 
       
   357         /**
       
   358          * Handles command key
       
   359          *
       
   360          * @param aKeyEvent     Key event.
       
   361          * @param aType         Command type.
       
   362          * @return  ETrue if command handled in function, else EFalse.
       
   363          */
       
   364         virtual TBool HandleCommandKeyL(
       
   365                 const TKeyEvent& aKeyEvent,
       
   366                 TEventCode aType ) = 0;
       
   367 
       
   368         /**
       
   369          * Returns menu filtering flags.
       
   370          *
       
   371          * @return  The flags.
       
   372          */
       
   373         virtual TInt GetViewSpecificMenuFilteringFlagsL() const = 0;
       
   374 
       
   375         /**
       
   376          * Dynamically initialises a menu pane.
       
   377          *
       
   378          * @param aResourceId   Resource id of the menu.
       
   379          * @param aMenuPane     The in-memory representation of
       
   380          *                      the menu pane.
       
   381          */
       
   382         virtual void DynInitMenuPaneL(
       
   383                 TInt aResourceId,
       
   384                 CEikMenuPane* aMenuPane ) = 0;
       
   385 
       
   386         /**
       
   387          * Restores view's state.
       
   388          *
       
   389          * @param aState    The state to restore.
       
   390          */
       
   391         virtual void RestoreControlStateL(
       
   392                 CPbk2ViewState* aState ) = 0;
       
   393 
       
   394         /**
       
   395          * Handles command,
       
   396          *
       
   397          * @param aCommand  Id of the command to respond to.
       
   398          */
       
   399         virtual void HandleCommandL(
       
   400                 TInt aCommand ) = 0;
       
   401 
       
   402         /**
       
   403          * Handles a change in the position or size
       
   404          * of the screen area occupied by the status pane.
       
   405          */
       
   406         virtual void HandleStatusPaneSizeChange() = 0;
       
   407 
       
   408 
       
   409         /**
       
   410          * Handles listbox events in derived classes
       
   411          * Note that this is not derived from MEikListBoxObserver but defined here
       
   412          */
       
   413         virtual void HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType ) = 0;
       
   414 
       
   415 
       
   416         /**
       
   417          * Handles listbox events in derived classes
       
   418          * Note that this is not derived from MEikListBoxObserver but defined here
       
   419          */
       
   420         virtual void ShowContextMenuL() = 0;
       
   421 
       
   422 
       
   423 
       
   424         /**
       
   425          * Handles pointer events.
       
   426          *
       
   427          * @param aPointerEvent     The pointer event.
       
   428          */
       
   429         virtual void HandlePointerEventL(
       
   430                 const TPointerEvent& aPointerEvent) = 0;
       
   431 
       
   432         /**
       
   433          * Updates Cba buttons.
       
   434          */
       
   435         virtual void UpdateCbasL() = 0;
       
   436 
       
   437         /**
       
   438          * Handles long tap event.
       
   439          *
       
   440          * @param aPenEventLocation         Pen location
       
   441          * @param aPenEventScreenLocation   Pen screen location.
       
   442          */
       
   443         virtual void HandleLongTapEventL(
       
   444                 const TPoint& aPenEventLocation,
       
   445                 const TPoint& aPenEventScreenLocation ) = 0;
       
   446 
       
   447     public: // From MVPbkContactViewObserver
       
   448         void ContactViewUnavailable(
       
   449                 MVPbkContactViewBase& aView );
       
   450         void ContactAddedToView(
       
   451                 MVPbkContactViewBase& aView,
       
   452                 TInt aIndex,
       
   453                 const MVPbkContactLink& aContactLink );
       
   454         void ContactRemovedFromView(
       
   455                 MVPbkContactViewBase& aView,
       
   456                 TInt aIndex,
       
   457                 const MVPbkContactLink& aContactLink );
       
   458         void ContactViewError(
       
   459                 MVPbkContactViewBase& aView,
       
   460                 TInt aError,
       
   461                 TBool aErrorNotified );
       
   462 
       
   463     public: // Base class interface
       
   464 
       
   465         /**
       
   466          * Destructor.
       
   467          */
       
   468         virtual ~CGroupMembersViewImpl()
       
   469             {}
       
   470 
       
   471     protected: // Implementation
       
   472         CGroupMembersViewImpl()
       
   473             {}
       
   474     };
       
   475 
       
   476 
       
   477 /**
       
   478  * Group members view implementation class. This class encapsulates
       
   479  * the view implementation when the group members view isnt ready, so
       
   480  * all the nesessary information needed to create the group members view
       
   481  * isnt ready. This class iniates the all groups view loading and waits
       
   482  * for its completion. Up on completion it switches to the next state.
       
   483  */
       
   484 class CPguGroupMembersView::CGroupMembersAllGroupsNotReady :
       
   485         public CPguGroupMembersView::CGroupMembersViewImpl
       
   486     {
       
   487     public: // interface
       
   488         /**
       
   489          * Creates a new instance of this class.
       
   490          *
       
   491          * @param aViewParent           Parent view.
       
   492          * @param aView                 UI extension view.
       
   493          * @param aFocusedGroupLink     Focused groups.
       
   494          * @return  A new instance of this class.
       
   495          */
       
   496         static CGroupMembersAllGroupsNotReady* NewL(
       
   497                 MPbk2GroupMembersViewActivationCallback& aViewParent,
       
   498                 CPbk2UIExtensionView& aView,
       
   499                 const MVPbkContactLink* aFocusedGroupLink );
       
   500 
       
   501         /**
       
   502          * Destructor.
       
   503          */
       
   504         ~CGroupMembersAllGroupsNotReady();
       
   505 
       
   506     public: // From CGroupMembersViewImpl
       
   507         void CreateControlL(
       
   508                 const TRect& aClientRect );
       
   509         MPbk2ContactUiControl* Control();
       
   510         CPbk2ViewState* ViewStateLC() const;
       
   511         TBool HandleCommandKeyL(
       
   512                 const TKeyEvent& aKeyEvent,
       
   513                 TEventCode aType );
       
   514         TInt GetViewSpecificMenuFilteringFlagsL() const;
       
   515         void DynInitMenuPaneL(
       
   516                 TInt aResourceId,
       
   517                 CEikMenuPane* aMenuPane );
       
   518         void RestoreControlStateL(
       
   519                 CPbk2ViewState* aState );
       
   520         void HandleCommandL(
       
   521                 TInt aCommand );
       
   522         void HandleStatusPaneSizeChange();
       
   523 
       
   524         /**
       
   525          * Handles listbox events.
       
   526          * Note that this is not derived from MEikListBoxObserver but defined here
       
   527          */
       
   528         void HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType );
       
   529 
       
   530         void ShowContextMenuL();
       
   531 
       
   532         void HandlePointerEventL(
       
   533                 const TPointerEvent& aPointerEvent );
       
   534         void UpdateCbasL();
       
   535         void HandleLongTapEventL(
       
   536                 const TPoint& aPenEventLocation,
       
   537                 const TPoint& aPenEventScreenLocation );
       
   538 
       
   539     public: // From MVPbkContactViewObserver
       
   540         void ContactViewReady(
       
   541                 MVPbkContactViewBase& aView );
       
   542 
       
   543     private: // Implementation
       
   544         CGroupMembersAllGroupsNotReady(
       
   545                 MPbk2GroupMembersViewActivationCallback& aViewParent,
       
   546                 CPbk2UIExtensionView& aView,
       
   547                 const MVPbkContactLink* aFocusedGroupLink );
       
   548         void ConstructL();
       
   549 
       
   550     private: // Data
       
   551         /// Ref: Parent view
       
   552         MPbk2GroupMembersViewActivationCallback& iViewParent;
       
   553         /// Ref: UI extension view
       
   554         CPbk2UIExtensionView& iView;
       
   555         /// Ref: Focused group link
       
   556         const MVPbkContactLink* iFocusedGroupLink;
       
   557         /// RefO observed all groups view
       
   558         MVPbkContactViewBase* iAllGroupsView;
       
   559         /// This view's control container type
       
   560         typedef CPbk2ControlContainer<
       
   561             CPbk2ContactUiControlSubstitute> CContainer;
       
   562         /// Own: This view's control container
       
   563         CContainer* iContainer;
       
   564         /// Ref: Empty control
       
   565         CPbk2ContactUiControlSubstitute* iControl;
       
   566         
       
   567     };
       
   568 
       
   569 
       
   570 /**
       
   571  * Group members view implementation class. This class encapsulates
       
   572  * the situation when all nesessary information to show the group
       
   573  * members data is present and it can be shown to the user. The navigation
       
   574  * from group to group and user commands are handled in this state.
       
   575  */
       
   576 class CPguGroupMembersView::CGroupMembersAllGroupsReady :
       
   577         public CPguGroupMembersView::CGroupMembersViewImpl,
       
   578         private MPbk2StoreConfigurationObserver,
       
   579         private MPbk2ContactNavigationLoader,
       
   580         private MPbk2MenuCommandObserver,
       
   581         private MPbk2ControlObserver,
       
   582         private MPbk2NavigationObserver
       
   583     {
       
   584     public: // Construction and destruction
       
   585 
       
   586         /**
       
   587          * Creates a new instance of this class.
       
   588          *
       
   589          * @param aViewParent           Parent view.
       
   590          * @param aView                 UI extension view.
       
   591          * @param aContactManager       Contact manager.
       
   592          * @param aContactNameFormatter Name formatter
       
   593          * @param aStorePropertyArray   Store property array.
       
   594          * @param aCommandHandler       Command handler.
       
   595          * @param aSortOrderManager     Sort order manager.
       
   596          * @param aFocusedGroupIndex    Focused group index.
       
   597          * @return  A new instance of this class
       
   598          */
       
   599         static CGroupMembersAllGroupsReady* NewL(
       
   600                 MPbk2GroupMembersViewActivationCallback& aViewParent,
       
   601                 CPbk2UIExtensionView& aView,
       
   602                 CVPbkContactManager& aContactManager,
       
   603                 MPbk2ContactNameFormatter& aContactNameFormatter,
       
   604                 CPbk2StorePropertyArray& aStorePropertyArray,
       
   605                 MPbk2CommandHandler& aCommandHandler,
       
   606                 CPbk2SortOrderManager& aSortOrderManager,
       
   607                 const TInt aFocusedGroupIndex );
       
   608 
       
   609         /**
       
   610          * Destructor
       
   611          */
       
   612         ~CGroupMembersAllGroupsReady();
       
   613 
       
   614     public: // From CGroupMembersViewImpl
       
   615         void CreateControlL(
       
   616                 const TRect& aClientRect );
       
   617         MPbk2ContactUiControl* Control();
       
   618         CPbk2ViewState* ViewStateLC() const;
       
   619         TBool HandleCommandKeyL(
       
   620                 const TKeyEvent& aKeyEvent,
       
   621                 TEventCode aType );
       
   622         TInt GetViewSpecificMenuFilteringFlagsL() const;
       
   623         void DynInitMenuPaneL(
       
   624                 TInt aResourceId,
       
   625                 CEikMenuPane* aMenuPane );
       
   626         void RestoreControlStateL(
       
   627                 CPbk2ViewState* aState );
       
   628         void HandleCommandL(
       
   629                 TInt aCommand );
       
   630         void HandleStatusPaneSizeChange();
       
   631         /**
       
   632          * Handles listbox events.
       
   633          * Note that this is not derived from MEikListBoxObserver but defined here
       
   634          */
       
   635         void HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType );
       
   636         void ShowContextMenuL();
       
   637 
       
   638         void HandlePointerEventL(
       
   639                 const TPointerEvent& aPointerEvent );
       
   640         void UpdateCbasL();
       
   641         void HandleLongTapEventL(
       
   642                 const TPoint& aPenEventLocation,
       
   643                 const TPoint& aPenEventScreenLocation );
       
   644 
       
   645     private: // From MPbk2ControlObserver
       
   646         void HandleControlEventL(
       
   647                 MPbk2ContactUiControl& aControl,
       
   648                 const TPbk2ControlEvent& aEvent );
       
   649 
       
   650     private: // From MPbk2StoreConfigurationObserver
       
   651         void ConfigurationChanged();
       
   652         void ConfigurationChangedComplete();
       
   653 
       
   654     private: // From MPbk2ContactNavigationLoader
       
   655         void ChangeContactL(
       
   656                 const MVPbkContactLink& aContactLink );
       
   657         MVPbkContactLink* ContactLinkLC() const;
       
   658 
       
   659     private: // From MPbk2MenuCommandObserver
       
   660         void PreCommandExecutionL(
       
   661                 const MPbk2Command& aCommand );
       
   662         void PostCommandExecutionL(
       
   663                 const MPbk2Command& aCommand );
       
   664 
       
   665     private: // From MVPbkContactViewObserver
       
   666         void ContactViewReady(
       
   667                 MVPbkContactViewBase& aView );
       
   668 
       
   669     private: // From MPbk2NavigationObserver
       
   670         void HandleNavigationEvent(
       
   671                 const TEventType& aEventType );
       
   672 
       
   673     private: // Implementation
       
   674         CGroupMembersAllGroupsReady(
       
   675                 MPbk2GroupMembersViewActivationCallback& aViewParent,
       
   676                 CPbk2UIExtensionView& aView,
       
   677                 CVPbkContactManager& aContactManager,
       
   678                 MPbk2ContactNameFormatter& aContactNameFormatter,
       
   679                 CPbk2StorePropertyArray& aStorePropertyArray,
       
   680                 MPbk2CommandHandler& aCommandHandler,
       
   681                 CPbk2SortOrderManager& aSortOrderManager );
       
   682         void ConstructL(
       
   683                 const TInt aFocusedGroupIndex );
       
   684         void DoCommitTransActionL(
       
   685                 MVPbkContactViewBase& aView );
       
   686         static void ChangeTitlePaneL(
       
   687                 HBufC* aTitleText );
       
   688         void UpdateListEmptyTextL(
       
   689                 TInt aListState );
       
   690 
       
   691     private: // Data
       
   692         /// Ref: Parent view
       
   693         MPbk2GroupMembersViewActivationCallback& iViewParent;
       
   694         /// Ref: UI extension view
       
   695         CPbk2UIExtensionView& iView;
       
   696         /// Ref: Contact manager
       
   697         CVPbkContactManager& iContactManager;
       
   698         /// Ref: Contact name formatter
       
   699         MPbk2ContactNameFormatter& iContactNameFormatter;
       
   700         /// Ref: Store properties
       
   701         CPbk2StorePropertyArray& iStoreProperties;
       
   702         /// Ref: Command handler
       
   703         MPbk2CommandHandler& iCommandHandler;
       
   704         /// Ref: Sort order
       
   705         CPbk2SortOrderManager& iSortOrderManager;
       
   706         /// This view's control container type
       
   707         typedef CPbk2ControlContainer<CPbk2NamesListControl> CContainer;
       
   708         /// Own: This view's control container
       
   709         CContainer* iContainer;
       
   710         /// Ref: This view's control
       
   711         MPbk2ContactUiControl* iControl;
       
   712         /// Ref: Focus movement observer
       
   713         MPbk2PointerEventInspector* iPointerEventInspector;
       
   714         /// Own: Navigation strategy
       
   715         MPbk2ContactNavigation* iNavigation;
       
   716         /// Own: Group members view
       
   717         MVPbkContactViewBase* iGroupMembersView;
       
   718         /// Own: View transition transaction
       
   719         CGroupMembersViewTransaction* iViewTransitionTransaction;
       
   720         /// Own: List of stores used
       
   721         RPointerArray<MVPbkContactStore> iStoreList;
       
   722         /// Own: ETrue, if any selection modifier key is depressed
       
   723         TBool iSelectionModifierUsed;
       
   724         /// Own: Stylus popup menu state indicator
       
   725         TBool iStylusPopupMenuLaunched;
       
   726         // Ref: Store management ptr
       
   727         CPbk2StoreConfiguration* iStoreConf;
       
   728     };
       
   729 
       
   730 // --------------------------------------------------------------------------
       
   731 // CPguGroupMembersView::CGroupMembersViewImpl:::ContactViewUnavailable
       
   732 // --------------------------------------------------------------------------
       
   733 //
       
   734 void CPguGroupMembersView::CGroupMembersViewImpl::ContactViewUnavailable
       
   735         ( MVPbkContactViewBase& /*aView*/ )
       
   736     {
       
   737     TRAP_IGNORE( UpdateCbasL() );
       
   738     }
       
   739 
       
   740 // --------------------------------------------------------------------------
       
   741 // CPguGroupMembersView::CGroupMembersViewImpl:::ContactAddedToView
       
   742 // --------------------------------------------------------------------------
       
   743 //
       
   744 void CPguGroupMembersView::CGroupMembersViewImpl::ContactAddedToView
       
   745         ( MVPbkContactViewBase& /*aView*/, TInt /*aIndex*/,
       
   746           const MVPbkContactLink& /*aContactLink*/ )
       
   747     {
       
   748     TRAP_IGNORE( UpdateCbasL() );
       
   749     }
       
   750 
       
   751 // --------------------------------------------------------------------------
       
   752 // CPguGroupMembersView::CGroupMembersViewImpl:::ContactRemovedFromView
       
   753 // --------------------------------------------------------------------------
       
   754 //
       
   755 void CPguGroupMembersView::CGroupMembersViewImpl::ContactRemovedFromView
       
   756         ( MVPbkContactViewBase& /*aView*/, TInt /*aIndex*/,
       
   757           const MVPbkContactLink& /*aContactLink*/ )
       
   758     {
       
   759     TRAP_IGNORE( UpdateCbasL() );
       
   760     }
       
   761 
       
   762 // --------------------------------------------------------------------------
       
   763 // CPguGroupMembersView::CGroupMembersViewImpl:::ContactViewError
       
   764 // --------------------------------------------------------------------------
       
   765 //
       
   766 void CPguGroupMembersView::CGroupMembersViewImpl::ContactViewError
       
   767         ( MVPbkContactViewBase& /*aView*/, TInt /*aError*/,
       
   768           TBool /*aErrorNotified*/ )
       
   769     {
       
   770     // Do nothing
       
   771     }
       
   772 
       
   773 // --------------------------------------------------------------------------
       
   774 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::CGroupMembersAllGrou
       
   775 // --------------------------------------------------------------------------
       
   776 //
       
   777 CPguGroupMembersView::CGroupMembersAllGroupsNotReady::
       
   778     CGroupMembersAllGroupsNotReady
       
   779             ( MPbk2GroupMembersViewActivationCallback& aViewParent,
       
   780               CPbk2UIExtensionView& aView,
       
   781               const MVPbkContactLink* aFocusedGroupLink ) :
       
   782                 iViewParent(aViewParent),
       
   783                 iView(aView),
       
   784                 iFocusedGroupLink(aFocusedGroupLink)
       
   785     {
       
   786     }
       
   787 
       
   788 // --------------------------------------------------------------------------
       
   789 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::~CGroupMembersAllGro
       
   790 // --------------------------------------------------------------------------
       
   791 //
       
   792 CPguGroupMembersView::CGroupMembersAllGroupsNotReady::
       
   793         ~CGroupMembersAllGroupsNotReady()
       
   794     {
       
   795     iAllGroupsView->RemoveObserver( *this );
       
   796 
       
   797     // Remove control from stack
       
   798     if (iContainer)
       
   799         {
       
   800         CCoeEnv::Static()->AppUi()->RemoveFromStack(iContainer);
       
   801         delete iContainer;
       
   802         }
       
   803     }
       
   804 
       
   805 // --------------------------------------------------------------------------
       
   806 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::ConstructL
       
   807 // --------------------------------------------------------------------------
       
   808 //
       
   809 void CPguGroupMembersView::CGroupMembersAllGroupsNotReady::ConstructL()
       
   810     {
       
   811     // The all groups view isnt ready, observe it then expand
       
   812     Phonebook2::Pbk2AppUi()->ApplicationServices().
       
   813         ViewSupplier().AllGroupsViewL()->AddObserverL( *this );
       
   814 
       
   815     iViewParent.SetFocusedContact( iFocusedGroupLink->CloneLC() );
       
   816     CleanupStack::Pop();
       
   817     }
       
   818 
       
   819 // --------------------------------------------------------------------------
       
   820 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::NewL
       
   821 // --------------------------------------------------------------------------
       
   822 //
       
   823 CPguGroupMembersView::CGroupMembersAllGroupsNotReady*
       
   824     CPguGroupMembersView::CGroupMembersAllGroupsNotReady::NewL
       
   825         ( MPbk2GroupMembersViewActivationCallback& aViewParent,
       
   826           CPbk2UIExtensionView& aView,
       
   827           const MVPbkContactLink* aFocusedGroupLink )
       
   828     {
       
   829     CGroupMembersAllGroupsNotReady* self =
       
   830         new ( ELeave ) CGroupMembersAllGroupsNotReady
       
   831             ( aViewParent, aView, aFocusedGroupLink );
       
   832     CleanupStack::PushL( self );
       
   833     self->ConstructL();
       
   834     CleanupStack::Pop( self );
       
   835     return self;
       
   836     }
       
   837 
       
   838 // --------------------------------------------------------------------------
       
   839 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::CreateControlL
       
   840 // --------------------------------------------------------------------------
       
   841 //
       
   842 void CPguGroupMembersView::CGroupMembersAllGroupsNotReady::CreateControlL
       
   843         ( const TRect& aClientRect )
       
   844     {
       
   845     // Create the container and control
       
   846     CContainer* container = CContainer::NewLC( &iView, &iView, iView );
       
   847     container->SetHelpContext(
       
   848             TCoeHelpContext(iView.ApplicationUid(),
       
   849             KPHOB_HLP_GROUP_MEMBER_LIST));
       
   850 
       
   851     // create empty control
       
   852     CPbk2ContactUiControlSubstitute* control =
       
   853             CPbk2ContactUiControlSubstitute::NewL();
       
   854 
       
   855     // Takes ownership
       
   856     container->SetControl(control, aClientRect);
       
   857 
       
   858     control->SetContainerWindowL(*container);
       
   859     HBufC* emptyText = StringLoader::LoadLC( R_QTN_PHOB_NO_ENTRIES_IN_GRP );
       
   860     control->SetTextL( *emptyText );
       
   861     CleanupStack::PopAndDestroy( emptyText );
       
   862 
       
   863     CCoeEnv::Static()->AppUi()->AddToStackL(iView, container);
       
   864     CleanupStack::Pop(container);
       
   865     iContainer = container;
       
   866     iControl = control;
       
   867 
       
   868     iContainer->ActivateL();
       
   869     iContainer->Control()->MakeVisible(ETrue);
       
   870 
       
   871     // set CBA
       
   872     iView.Cba()->SetCommandSetL(R_AVKON_SOFTKEYS_BACK);
       
   873     iView.Cba()->DrawDeferred();
       
   874     }
       
   875 
       
   876 // --------------------------------------------------------------------------
       
   877 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::Control
       
   878 // --------------------------------------------------------------------------
       
   879 //
       
   880 MPbk2ContactUiControl* CPguGroupMembersView::
       
   881         CGroupMembersAllGroupsNotReady::Control()
       
   882     {
       
   883     return iControl;
       
   884     }
       
   885 
       
   886 // --------------------------------------------------------------------------
       
   887 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::ContactViewReady
       
   888 // --------------------------------------------------------------------------
       
   889 //
       
   890 void CPguGroupMembersView::CGroupMembersAllGroupsNotReady::ContactViewReady
       
   891         ( MVPbkContactViewBase& aView )
       
   892     {
       
   893     // If we have a new view, lets change it
       
   894     if (&aView == iAllGroupsView)
       
   895         {
       
   896         TInt groupIndex = KErrNotFound;
       
   897         TRAPD(leaveCode,
       
   898             {
       
   899             groupIndex = iAllGroupsView->IndexOfLinkL(*iFocusedGroupLink);
       
   900             // switch to ready state
       
   901             iViewParent.TransformViewActivationStateToReadyL(groupIndex);
       
   902             });
       
   903         if (leaveCode != KErrNone)
       
   904             {
       
   905             // notify user
       
   906             CCoeEnv::Static()->HandleError(leaveCode);
       
   907             }
       
   908         }
       
   909     else
       
   910         {
       
   911         // When ContactViewReady() is called, the program needs to check whether 
       
   912         // the namelist control in the container is visible or not. 
       
   913         // If visible, call DrawDeferred() to refresh the container, 
       
   914         // and if not, the container needs not to be refreshed to avoid flicker on the background.
       
   915         if ( iContainer->Control() && iContainer->Control()->IsVisible() )
       
   916             {
       
   917             iContainer->DrawDeferred();
       
   918             }
       
   919         }
       
   920     }
       
   921 
       
   922 // --------------------------------------------------------------------------
       
   923 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::ViewStateLC
       
   924 // --------------------------------------------------------------------------
       
   925 //
       
   926 CPbk2ViewState* CPguGroupMembersView::
       
   927         CGroupMembersAllGroupsNotReady::ViewStateLC() const
       
   928     {
       
   929     CPbk2ViewState* state = CPbk2ViewState::NewLC();
       
   930     MVPbkContactLink* parentContactLink =
       
   931         iViewParent.FocusedContact()->CloneLC();
       
   932     state->SetParentContact( parentContactLink );
       
   933     CleanupStack::Pop(); // parentContactLink
       
   934     return state;
       
   935     }
       
   936 
       
   937 // --------------------------------------------------------------------------
       
   938 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::HandleCommandKeyL
       
   939 // --------------------------------------------------------------------------
       
   940 //
       
   941 TBool CPguGroupMembersView::CGroupMembersAllGroupsNotReady::HandleCommandKeyL
       
   942         ( const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/ )
       
   943     {
       
   944     // No handling in this state
       
   945     return EFalse;
       
   946     }
       
   947 
       
   948 // --------------------------------------------------------------------------
       
   949 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::HandleStatusPaneSize
       
   950 // --------------------------------------------------------------------------
       
   951 //
       
   952 void CPguGroupMembersView::CGroupMembersAllGroupsNotReady::
       
   953         HandleStatusPaneSizeChange()
       
   954     {
       
   955     // Resize the container to fill the client rectangle
       
   956     if(iContainer)
       
   957         {
       
   958         iContainer->SetRect(iView.ClientRect());
       
   959         }
       
   960     }
       
   961 
       
   962 
       
   963 // ----------------------------------------------------------------------------
       
   964 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::HandleListBoxEventL
       
   965 // ----------------------------------------------------------------------------
       
   966 //
       
   967 void CPguGroupMembersView::CGroupMembersAllGroupsNotReady::HandleListBoxEventL(CEikListBox* /*aListBox*/ ,TListBoxEvent /*aEventType*/ )
       
   968     {
       
   969     }
       
   970 
       
   971 
       
   972 
       
   973 // --------------------------------------------------------------------------
       
   974 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::HandlePointerEventL
       
   975 // --------------------------------------------------------------------------
       
   976 //
       
   977 void CPguGroupMembersView::CGroupMembersAllGroupsNotReady::HandlePointerEventL
       
   978         ( const TPointerEvent& /*aPointerEvent*/ )
       
   979     {
       
   980     }
       
   981 
       
   982 
       
   983 // --------------------------------------------------------------------------
       
   984 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::ShowContextMenuL
       
   985 // --------------------------------------------------------------------------
       
   986 //
       
   987 void CPguGroupMembersView::CGroupMembersAllGroupsNotReady::ShowContextMenuL()
       
   988     {
       
   989     }
       
   990    
       
   991 
       
   992 
       
   993 
       
   994 // --------------------------------------------------------------------------
       
   995 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::UpdateCbasL
       
   996 // --------------------------------------------------------------------------
       
   997 //
       
   998 void CPguGroupMembersView::CGroupMembersAllGroupsNotReady::UpdateCbasL()
       
   999     {
       
  1000     }
       
  1001 
       
  1002 // --------------------------------------------------------------------------
       
  1003 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::HandleLongTapEventL
       
  1004 // --------------------------------------------------------------------------
       
  1005 //
       
  1006 void CPguGroupMembersView::CGroupMembersAllGroupsNotReady::HandleLongTapEventL
       
  1007         ( const TPoint& /*aPenEventLocation*/,
       
  1008           const TPoint& /*aPenEventScreenLocation*/ )
       
  1009     {
       
  1010     }
       
  1011 
       
  1012 // --------------------------------------------------------------------------
       
  1013 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::GetViewSpecificMenu
       
  1014 // --------------------------------------------------------------------------
       
  1015 //
       
  1016 TInt CPguGroupMembersView::CGroupMembersAllGroupsNotReady::
       
  1017         GetViewSpecificMenuFilteringFlagsL() const
       
  1018     {
       
  1019     return iControl->GetMenuFilteringFlagsL();
       
  1020     }
       
  1021 
       
  1022 // --------------------------------------------------------------------------
       
  1023 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::DynInitMenuPaneL
       
  1024 // --------------------------------------------------------------------------
       
  1025 //
       
  1026 void CPguGroupMembersView::CGroupMembersAllGroupsNotReady::DynInitMenuPaneL
       
  1027         ( TInt /*aResourceId*/, CEikMenuPane* /*aMenuPane*/ )
       
  1028     {
       
  1029     // Do nothing
       
  1030     }
       
  1031 
       
  1032 // --------------------------------------------------------------------------
       
  1033 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::RestoreControlStateL
       
  1034 // --------------------------------------------------------------------------
       
  1035 //
       
  1036 void CPguGroupMembersView::CGroupMembersAllGroupsNotReady::
       
  1037         RestoreControlStateL( CPbk2ViewState* /*aState*/ )
       
  1038     {
       
  1039     // Nothing to restore
       
  1040     }
       
  1041 
       
  1042 // --------------------------------------------------------------------------
       
  1043 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::HandleCommandL
       
  1044 // --------------------------------------------------------------------------
       
  1045 //
       
  1046 void CPguGroupMembersView::CGroupMembersAllGroupsNotReady::HandleCommandL
       
  1047         ( TInt /*aCommand*/ )
       
  1048     {
       
  1049     // Do nothing
       
  1050     }
       
  1051 
       
  1052 // --------------------------------------------------------------------------
       
  1053 // CPguGroupMembersView::CGroupMembersAllGroupsReady::CGroupMembersAllGroups
       
  1054 // --------------------------------------------------------------------------
       
  1055 //
       
  1056 CPguGroupMembersView::CGroupMembersAllGroupsReady::CGroupMembersAllGroupsReady
       
  1057         ( MPbk2GroupMembersViewActivationCallback& aViewParent,
       
  1058           CPbk2UIExtensionView& aView,
       
  1059           CVPbkContactManager& aContactManager,
       
  1060           MPbk2ContactNameFormatter& aContactNameFormatter,
       
  1061           CPbk2StorePropertyArray& aStorePropertyArray,
       
  1062           MPbk2CommandHandler& aCommandHandler,
       
  1063           CPbk2SortOrderManager& aSortOrderManager ) :
       
  1064             iViewParent(aViewParent),
       
  1065             iView(aView),
       
  1066             iContactManager(aContactManager),
       
  1067             iContactNameFormatter(aContactNameFormatter),
       
  1068             iStoreProperties(aStorePropertyArray),
       
  1069             iCommandHandler(aCommandHandler),
       
  1070             iSortOrderManager(aSortOrderManager)
       
  1071     {
       
  1072     }
       
  1073 
       
  1074 // --------------------------------------------------------------------------
       
  1075 // CPguGroupMembersView::CGroupMembersAllGroupsReady::~CGroupMembersAllGroups
       
  1076 // --------------------------------------------------------------------------
       
  1077 //
       
  1078 CPguGroupMembersView::CGroupMembersAllGroupsReady::
       
  1079         ~CGroupMembersAllGroupsReady()
       
  1080     {    
       
  1081     iCommandHandler.RemoveMenuCommandObserver( *this );
       
  1082 
       
  1083     if ( iStoreConf )
       
  1084         {
       
  1085         iStoreConf->RemoveObserver( *this );
       
  1086         }
       
  1087 
       
  1088     delete iViewTransitionTransaction;
       
  1089 
       
  1090     // remove control from stack
       
  1091     if (iContainer)
       
  1092         {
       
  1093         iContainer->Control()->HideThumbnail();
       
  1094         iContainer->Control()->MakeVisible(EFalse);
       
  1095         CCoeEnv::Static()->AppUi()->RemoveFromStack(iContainer);
       
  1096         delete iContainer;
       
  1097         }
       
  1098 
       
  1099     // Stop observing group members view
       
  1100     if (iGroupMembersView)
       
  1101         {
       
  1102         iGroupMembersView->RemoveObserver( *this );
       
  1103         }
       
  1104     delete iGroupMembersView;
       
  1105     delete iNavigation;
       
  1106     iStoreList.Reset();
       
  1107     iStoreList.Close();
       
  1108     }
       
  1109 
       
  1110 // --------------------------------------------------------------------------
       
  1111 // CPguGroupMembersView::CGroupMembersAllGroupsReady::ConstructL
       
  1112 // --------------------------------------------------------------------------
       
  1113 //
       
  1114 void CPguGroupMembersView::CGroupMembersAllGroupsReady::ConstructL
       
  1115         ( const TInt aFocusedGroupIndex )
       
  1116     {
       
  1117     // Add this view to observe command events
       
  1118     iCommandHandler.AddMenuCommandObserver(*this);
       
  1119 
       
  1120     iStoreConf = &( Phonebook2::Pbk2AppUi()->ApplicationServices().
       
  1121     	StoreConfiguration() );
       
  1122     iStoreConf->AddObserverL( *this );
       
  1123 
       
  1124     // Expand the group members view from the all groups view
       
  1125     const MVPbkViewContact& group =
       
  1126         Phonebook2::Pbk2AppUi()->ApplicationServices().
       
  1127             ViewSupplier().AllGroupsViewL()->ContactAtL
       
  1128                 ( aFocusedGroupIndex );
       
  1129     iGroupMembersView = group.Expandable()->ExpandLC(*this,
       
  1130                 iSortOrderManager.SortOrder());
       
  1131     CleanupStack::Pop(); // ExpandLC
       
  1132 
       
  1133     // create a store list that contains all the stores
       
  1134     MVPbkContactStoreList& storeList = iContactManager.ContactStoresL();
       
  1135     for (TInt i = 0; i < storeList.Count(); ++i)
       
  1136         {
       
  1137         MVPbkContactStore& store = storeList.At(i);
       
  1138         iStoreList.Append(&store);
       
  1139         }
       
  1140 
       
  1141     // Create a navigation object which can navigate all the available groups
       
  1142     iNavigation = Pbk2NavigatorFactory::CreateContactNavigatorL
       
  1143         ( iView.Id(), *this, *this, iStoreList.Array(),
       
  1144           R_QTN_PHOB_NAVI_POS_INDICATOR_GROUP_MEMBERS_VIEW );
       
  1145 
       
  1146     // Navigation view remains the same
       
  1147     iNavigation->SetScrollViewL
       
  1148         ( Phonebook2::Pbk2AppUi()->ApplicationServices().
       
  1149           ViewSupplier().AllGroupsViewL(), EFalse );
       
  1150 
       
  1151     // Set the group title to the title pane
       
  1152     HBufC* titleText = iContactNameFormatter.GetContactTitleL(group.Fields(),
       
  1153             MPbk2ContactNameFormatter::EPreserveLeadingSpaces );
       
  1154     CleanupStack::PushL( titleText );
       
  1155     ChangeTitlePaneL(titleText);
       
  1156     CleanupStack::Pop( titleText );
       
  1157     }
       
  1158 
       
  1159 // --------------------------------------------------------------------------
       
  1160 // CPguGroupMembersView::CGroupMembersAllGroupsReady::NewL
       
  1161 // --------------------------------------------------------------------------
       
  1162 //
       
  1163 CPguGroupMembersView::CGroupMembersAllGroupsReady*
       
  1164     CPguGroupMembersView::CGroupMembersAllGroupsReady::NewL
       
  1165             ( MPbk2GroupMembersViewActivationCallback& aViewParent,
       
  1166               CPbk2UIExtensionView& aView,
       
  1167               CVPbkContactManager& aContactManager,
       
  1168               MPbk2ContactNameFormatter& aContactNameFormatter,
       
  1169               CPbk2StorePropertyArray& aStorePropertyArray,
       
  1170               MPbk2CommandHandler& aCommandHandler,
       
  1171               CPbk2SortOrderManager& aSortOrderManager,
       
  1172               const TInt aFocusedGroupIndex )
       
  1173     {
       
  1174     CGroupMembersAllGroupsReady* self =
       
  1175         new ( ELeave ) CGroupMembersAllGroupsReady
       
  1176             ( aViewParent, aView, aContactManager,
       
  1177               aContactNameFormatter, aStorePropertyArray, aCommandHandler,
       
  1178               aSortOrderManager );
       
  1179     CleanupStack::PushL (self );
       
  1180     self->ConstructL( aFocusedGroupIndex );
       
  1181     CleanupStack::Pop( self );
       
  1182     return self;
       
  1183     }
       
  1184 
       
  1185 // --------------------------------------------------------------------------
       
  1186 // CPguGroupMembersView::CGroupMembersAllGroupsReady::CreateControlL
       
  1187 // --------------------------------------------------------------------------
       
  1188 //
       
  1189 void CPguGroupMembersView::CGroupMembersAllGroupsReady::CreateControlL
       
  1190         ( const TRect& aClientRect )
       
  1191     {
       
  1192     // Create the container and control
       
  1193     CContainer* container = CContainer::NewLC( &iView, &iView, iView );
       
  1194     container->SetHelpContext(
       
  1195             TCoeHelpContext(iView.ApplicationUid(),
       
  1196             KPHOB_HLP_GROUP_MEMBER_LIST));
       
  1197 
       
  1198     CPbk2NamesListControl* control = CPbk2NamesListControl::NewL(
       
  1199             R_PBK2_GROUPMEMBERS_CONTROL,
       
  1200             container, iContactManager, *iGroupMembersView,
       
  1201             iContactNameFormatter, iStoreProperties);
       
  1202 
       
  1203     // Takes ownership
       
  1204     container->SetControl(control, aClientRect);
       
  1205     control->SetTextL( KNullDesC );
       
  1206     control->AddObserverL(*this);
       
  1207 
       
  1208     iNavigation->UpdateNaviIndicatorsL(*iViewParent.FocusedContact());
       
  1209     //Set the current group link to Nameslist control
       
  1210     control->SetCurrentGroupLinkL(iViewParent.FocusedContact());
       
  1211 
       
  1212     CCoeEnv::Static()->AppUi()->AddToStackL(iView, container);
       
  1213     CleanupStack::Pop(container);
       
  1214     iContainer = container;
       
  1215     iControl = control;
       
  1216     iPointerEventInspector = control;
       
  1217 
       
  1218     iContainer->ActivateL();
       
  1219     iContainer->Control()->MakeVisible( ETrue );
       
  1220     }
       
  1221 
       
  1222 // --------------------------------------------------------------------------
       
  1223 // CPguGroupMembersView::CGroupMembersAllGroupsReady::Control
       
  1224 // --------------------------------------------------------------------------
       
  1225 //
       
  1226 MPbk2ContactUiControl* CPguGroupMembersView::CGroupMembersAllGroupsReady::
       
  1227         Control()
       
  1228     {
       
  1229     return iControl;
       
  1230     }
       
  1231 
       
  1232 // --------------------------------------------------------------------------
       
  1233 // CPguGroupMembersView::CGroupMembersAllGroupsReady::HandleControlEventL
       
  1234 // --------------------------------------------------------------------------
       
  1235 //
       
  1236 void CPguGroupMembersView::CGroupMembersAllGroupsReady::HandleControlEventL
       
  1237         ( MPbk2ContactUiControl& /*aControl*/,
       
  1238           const TPbk2ControlEvent& aEvent )
       
  1239     {
       
  1240     switch(aEvent.iEventType)
       
  1241         {
       
  1242         case TPbk2ControlEvent::EReady:
       
  1243             {
       
  1244             UpdateCbasL();
       
  1245 
       
  1246             // Restore control state
       
  1247             iViewParent.RestoreStateL();
       
  1248             if (iControl)
       
  1249                 {
       
  1250                 iControl->ShowThumbnail();
       
  1251                 }
       
  1252             break;
       
  1253             }
       
  1254         case TPbk2ControlEvent::EControlLeavesSelectionMode: // FALLTHROUGH
       
  1255         case TPbk2ControlEvent::EItemRemoved:                // FALLTHROUGH
       
  1256         case TPbk2ControlEvent::EContactSelected:            // FALLTHROUGH
       
  1257         case TPbk2ControlEvent::EContactUnselected:          // FALLTHROUGH
       
  1258         case TPbk2ControlEvent::EContactUnselectedAll:       
       
  1259             {
       
  1260             UpdateCbasL();
       
  1261             break;
       
  1262             }
       
  1263         case TPbk2ControlEvent::EControlStateChanged:
       
  1264             {
       
  1265             UpdateCbasL();
       
  1266             UpdateListEmptyTextL( aEvent.iInt );
       
  1267             iContainer->Control()->DrawDeferred();
       
  1268             break;
       
  1269             }
       
  1270         default:
       
  1271             {
       
  1272             // Do nothing
       
  1273             break;
       
  1274             }
       
  1275         }
       
  1276     }
       
  1277 
       
  1278 // --------------------------------------------------------------------------
       
  1279 // CPguGroupMembersView::CGroupMembersAllGroupsReady::ConfigurationChanged
       
  1280 // --------------------------------------------------------------------------
       
  1281 //
       
  1282 void CPguGroupMembersView::CGroupMembersAllGroupsReady::ConfigurationChanged()
       
  1283     {
       
  1284     // Update navigations scroll view
       
  1285     TRAPD( error,
       
  1286         iNavigation->SetScrollViewL
       
  1287             ( Phonebook2::Pbk2AppUi()->ApplicationServices().
       
  1288               ViewSupplier().AllGroupsViewL(), EFalse ) );
       
  1289     if ( error != KErrNone )
       
  1290         {
       
  1291         CCoeEnv::Static()->HandleError( error );
       
  1292         }
       
  1293     }
       
  1294 
       
  1295 // --------------------------------------------------------------------------
       
  1296 // CPguGroupMembersView::CGroupMembersAllGroupsReady::ConfigurationChangedCo
       
  1297 // --------------------------------------------------------------------------
       
  1298 //
       
  1299 void CPguGroupMembersView::CGroupMembersAllGroupsReady::
       
  1300         ConfigurationChangedComplete()
       
  1301     {
       
  1302     // Do nothing
       
  1303     }
       
  1304 
       
  1305 // --------------------------------------------------------------------------
       
  1306 // CPguGroupMembersView::CGroupMembersAllGroupsReady::ChangeContactL
       
  1307 // Called through MPbk2ContactNavigationCallback to change the
       
  1308 // group that is viewed.
       
  1309 // --------------------------------------------------------------------------
       
  1310 //
       
  1311 void CPguGroupMembersView::CGroupMembersAllGroupsReady::ChangeContactL
       
  1312         ( const MVPbkContactLink& aContactLink )
       
  1313     {
       
  1314     if (iViewTransitionTransaction)
       
  1315         {
       
  1316         // remove observer from view
       
  1317         iViewTransitionTransaction->GroupMembersView()->RemoveObserver( *this );
       
  1318 
       
  1319         // destroy tranaction
       
  1320         delete iViewTransitionTransaction;
       
  1321         iViewTransitionTransaction = NULL;
       
  1322         }
       
  1323 
       
  1324     CGroupMembersViewTransaction* transaction =
       
  1325         CGroupMembersViewTransaction::NewLC();
       
  1326     // create a copy of the group link
       
  1327     MVPbkContactLink* groupLink = aContactLink.CloneLC();
       
  1328 
       
  1329     // Get the index of the group to view from the all groups view
       
  1330     const TInt groupIndex = Phonebook2::Pbk2AppUi()->ApplicationServices().
       
  1331         ViewSupplier().AllGroupsViewL()->IndexOfLinkL( *groupLink );
       
  1332     if (groupIndex != KErrNotFound)
       
  1333         {
       
  1334         // Get the group at position from the all groups view
       
  1335         const MVPbkViewContact& group = Phonebook2::Pbk2AppUi()->ApplicationServices().
       
  1336         ViewSupplier().AllGroupsViewL()->ContactAtL( groupIndex );
       
  1337 
       
  1338         // retrieve group name, which is later shown on the title pane
       
  1339         HBufC* groupName = iContactNameFormatter.GetContactTitleL(group.Fields(),
       
  1340                 MPbk2ContactNameFormatter::EPreserveLeadingSpaces);
       
  1341         CleanupStack::PushL(groupName);
       
  1342 
       
  1343         // initiate the next group members view loading
       
  1344         MVPbkContactViewBase* groupMembersView = group.Expandable()->ExpandLC(*this,
       
  1345                 iSortOrderManager.SortOrder());
       
  1346 
       
  1347         // the group members view loading has initiated, transfer ownership of these
       
  1348         // items to the transaction. Transaction will be committed when the view
       
  1349         // reaches the ready state
       
  1350         transaction->SetGroupMembersView(groupMembersView);
       
  1351         CleanupStack::Pop(); // ExpandLC
       
  1352         transaction->SetGroupName(groupName);
       
  1353         CleanupStack::Pop(groupName);
       
  1354         transaction->SetGroupLink(groupLink);
       
  1355         CleanupStack::Pop(); // CloneLC
       
  1356 
       
  1357         // now assign the transaction and wait for the view to become ready
       
  1358         iViewTransitionTransaction = transaction;
       
  1359         CleanupStack::Pop(transaction);
       
  1360         }
       
  1361     else
       
  1362         {
       
  1363         // the all groups view isnt ready, so contact change isnt possible
       
  1364         // cleanup
       
  1365         CleanupStack::PopAndDestroy(2, transaction); // groupLink, transaction
       
  1366         User::Leave(KErrNotReady);
       
  1367         }
       
  1368     }
       
  1369 
       
  1370 // --------------------------------------------------------------------------
       
  1371 // CPguGroupMembersView::CGroupMembersAllGroupsReady::ViewStateLC
       
  1372 // --------------------------------------------------------------------------
       
  1373 //
       
  1374 MVPbkContactLink* CPguGroupMembersView::CGroupMembersAllGroupsReady::
       
  1375         ContactLinkLC() const
       
  1376     {
       
  1377     return iViewParent.FocusedContact()->CloneLC();
       
  1378     }
       
  1379 
       
  1380 // --------------------------------------------------------------------------
       
  1381 // CPguGroupMembersView::CGroupMembersAllGroupsReady::ViewStateLC
       
  1382 // --------------------------------------------------------------------------
       
  1383 //
       
  1384 CPbk2ViewState* CPguGroupMembersView::CGroupMembersAllGroupsReady::
       
  1385         ViewStateLC() const
       
  1386     {
       
  1387     CPbk2ViewState* state = iControl->ControlStateL();
       
  1388     CleanupStack::PushL( state );
       
  1389     MVPbkContactLink* parentContactLink =
       
  1390         iViewParent.FocusedContact()->CloneLC();
       
  1391     state->SetParentContact( parentContactLink );
       
  1392     CleanupStack::Pop(); // parentContactLink
       
  1393     return state;
       
  1394     }
       
  1395 
       
  1396 // --------------------------------------------------------------------------
       
  1397 // CPguGroupMembersView::CGroupMembersAllGroupsReady::HandleCommandKeyL
       
  1398 // --------------------------------------------------------------------------
       
  1399 //
       
  1400 TBool CPguGroupMembersView::CGroupMembersAllGroupsReady::HandleCommandKeyL
       
  1401         ( const TKeyEvent& aKeyEvent, TEventCode aType )
       
  1402     {
       
  1403     TBool itemSpecEnabled = 
       
  1404         Phonebook2::Pbk2AppUi()->ActiveView()->MenuBar()->ItemSpecificCommandsEnabled();
       
  1405     TBool result = iNavigation->HandleCommandKeyL( aKeyEvent, aType );
       
  1406 
       
  1407     if(!result && aType == EEventKey)
       
  1408         {
       
  1409         switch (aKeyEvent.iCode)
       
  1410             {
       
  1411             case EKeyBackspace:
       
  1412                 {
       
  1413                 if ( (itemSpecEnabled && (iControl->NumberOfContacts() > 0) )
       
  1414                         || iControl->ContactsMarked() )
       
  1415                     {
       
  1416                     if ( iControl->FindTextL() == KNullDesC )
       
  1417                         {
       
  1418                         HandleCommandL( EPbk2CmdRemoveFromGroup );
       
  1419                         result = ETrue;
       
  1420                         }
       
  1421                     }
       
  1422                 break;
       
  1423                 }
       
  1424             case EKeyEnter: // FALLTHROUGH
       
  1425             case EKeyOK:
       
  1426                 {
       
  1427                 if ( !ShiftDown(aKeyEvent) ) // pure OK or ENTER key
       
  1428 					{	
       
  1429                     if ( iControl->ContactsMarked() && itemSpecEnabled )
       
  1430                     	{
       
  1431                     	iView.LaunchPopupMenuL(
       
  1432                     		R_PHONEBOOK2_GROUPMEMBERS_CONTEXT_MENUBAR);
       
  1433 						result = ETrue;
       
  1434 						}
       
  1435 					else if ( iControl->NumberOfContacts() == 0 )
       
  1436 						{
       
  1437 						result = ETrue;
       
  1438 						}
       
  1439                     }
       
  1440                 break;
       
  1441                 }
       
  1442 
       
  1443             case EKeyPhoneSend:
       
  1444                 {
       
  1445                 // Use the EPbk2CmdCall id to identify that
       
  1446                 // call is being launched with send key
       
  1447                 if ( itemSpecEnabled && (iControl->NumberOfContacts() > 0) &&
       
  1448                      !iControl->ContactsMarked() )
       
  1449                     {
       
  1450                     // If there is a dialog display on the top of screen, don't make call.
       
  1451                     if ( !(CEikonEnv::Static()->EikAppUi()->IsDisplayingDialog()) )
       
  1452                         {
       
  1453                         // Use the EPbk2CmdCall id to identify that
       
  1454                         // call is being launched with send key
       
  1455                         HandleCommandL( EPbk2CmdCall );
       
  1456                         }
       
  1457                     result = ETrue;
       
  1458                     }
       
  1459                 break;
       
  1460                 }
       
  1461 
       
  1462             case EKeyPoC:
       
  1463                 {
       
  1464                 // Use the EPbk2CmdPoC id to identify that
       
  1465                 // call is being launched with PoC key
       
  1466                 HandleCommandL( EPbk2CmdPoC );
       
  1467                 result = ETrue;
       
  1468                 break;
       
  1469                 }
       
  1470 
       
  1471             default:
       
  1472                 {
       
  1473                 break;
       
  1474                 }
       
  1475             }
       
  1476         }
       
  1477 
       
  1478     // Update selection modifier key state
       
  1479     iSelectionModifierUsed = IsShiftOrControlDown( aKeyEvent ) ||
       
  1480         ( (aType == EEventKeyDown) && (aKeyEvent.iCode == EStdKeyHash) );
       
  1481 
       
  1482     return result;
       
  1483     }
       
  1484 
       
  1485 // --------------------------------------------------------------------------
       
  1486 // CPguGroupMembersView::CGroupMembersAllGroupsReady::GetViewSpecificMenuFi
       
  1487 // --------------------------------------------------------------------------
       
  1488 //
       
  1489 TInt CPguGroupMembersView::CGroupMembersAllGroupsReady::
       
  1490         GetViewSpecificMenuFilteringFlagsL() const
       
  1491     {
       
  1492     return iControl->GetMenuFilteringFlagsL();
       
  1493     }
       
  1494 
       
  1495 // --------------------------------------------------------------------------
       
  1496 // CPguGroupMembersView::CGroupMembersAllGroupsReady::DynInitMenuPaneL
       
  1497 // --------------------------------------------------------------------------
       
  1498 //
       
  1499 void CPguGroupMembersView::CGroupMembersAllGroupsReady::DynInitMenuPaneL
       
  1500         ( TInt aResourceId, CEikMenuPane* aMenuPane )
       
  1501     {
       
  1502     // Ask the control do control specific filtering
       
  1503     // (for example call HandleMarkableListDynInitMenuPane if needed)
       
  1504     iControl->DynInitMenuPaneL(aResourceId, aMenuPane);
       
  1505     
       
  1506     switch ( aResourceId )
       
  1507         {
       
  1508         case R_PHONEBOOK2_OPEN_ME_MENU:
       
  1509             {
       
  1510             // Weed out commands not meant to be used with empty list
       
  1511             // Weed out commands not meant to be used with marked items
       
  1512             if ( iControl->NumberOfContacts() == 0 ||
       
  1513                     iControl->ContactsMarked() )
       
  1514                 {
       
  1515                 aMenuPane->SetItemDimmed( EPbk2CmdOpenCca, ETrue );
       
  1516                 }
       
  1517             break;
       
  1518             }
       
  1519 
       
  1520         case R_PHONEBOOK2_GROUPMEMBERS_MENU:
       
  1521             {
       
  1522             // Weed out commands not meant to be used with empty list
       
  1523             if ( iControl->NumberOfContacts() == 0 )
       
  1524                 {
       
  1525                 aMenuPane->SetItemDimmed( EPbk2CmdRemoveFromGroup, ETrue );
       
  1526                 aMenuPane->SetItemDimmed( EPbk2CmdBelongsToGroups, ETrue );
       
  1527                 }
       
  1528 
       
  1529             if ( iControl->ContactsMarked() )
       
  1530                 {
       
  1531                 aMenuPane->SetItemDimmed( EPbk2CmdBelongsToGroups, ETrue );
       
  1532                 aMenuPane->SetItemDimmed( EPbk2CmdAddMembers, ETrue );
       
  1533                 aMenuPane->SetItemSpecific( EPbk2CmdRemoveFromGroup, EFalse );
       
  1534                 }
       
  1535             // Weed out commands not meant to be if names list is empty
       
  1536             if ( Phonebook2::Pbk2AppUi()->ApplicationServices().
       
  1537                     ViewSupplier().AllContactsViewL()->ContactCountL() == 0 )
       
  1538                 {
       
  1539                 aMenuPane->SetItemDimmed( EPbk2CmdAddMembers, ETrue );
       
  1540                 }
       
  1541             break;
       
  1542             }
       
  1543 
       
  1544         case R_PHONEBOOK2_BCARD_SEND_MENU:
       
  1545             {
       
  1546             // Weed out commands not meant to be used with empty list
       
  1547             if ( iControl->NumberOfContacts() == 0 )
       
  1548                 {
       
  1549                 aMenuPane->SetItemDimmed( EPbk2CmdSend, ETrue );
       
  1550                 }
       
  1551             if ( iControl->ContactsMarked() )
       
  1552                 {
       
  1553                 aMenuPane->SetItemSpecific( EPbk2CmdSend, EFalse );
       
  1554                 }
       
  1555             break;
       
  1556             }
       
  1557 
       
  1558         case R_PHONEBOOK2_GROUPMEMBERS_CONTEXT_MENU:
       
  1559             {
       
  1560             // Weed out commands not meant to be used with empty list
       
  1561             if ( iControl->NumberOfContacts() == 0 )
       
  1562                 {
       
  1563                 aMenuPane->SetItemDimmed( EPbk2CmdRemoveFromGroup, ETrue );
       
  1564                 }
       
  1565 
       
  1566             // Weed out commands not meant to be used with marked items
       
  1567             if ( iControl->ContactsMarked() )
       
  1568                 {
       
  1569                 aMenuPane->SetItemDimmed( EPbk2CmdAddMembers, ETrue );
       
  1570                 }
       
  1571 
       
  1572             // Weed out commands not meant to be if names list is empty
       
  1573             if ( Phonebook2::Pbk2AppUi()->ApplicationServices().
       
  1574                     ViewSupplier().AllContactsViewL()->ContactCountL() == 0 )
       
  1575                 {
       
  1576                 aMenuPane->SetItemDimmed( EPbk2CmdAddMembers, ETrue );
       
  1577                 }
       
  1578             break;
       
  1579             }
       
  1580 
       
  1581         default:
       
  1582             {
       
  1583             
       
  1584             // Phonebook 2 menu filtering happens in Commands
       
  1585             iCommandHandler.DynInitMenuPaneL(aResourceId,
       
  1586                     aMenuPane, iView, *iControl );
       
  1587             }
       
  1588       
       
  1589         };
       
  1590     }
       
  1591 
       
  1592 // --------------------------------------------------------------------------
       
  1593 // CPguGroupMembersView::CGroupMembersAllGroupsReady::ContactViewReady
       
  1594 // --------------------------------------------------------------------------
       
  1595 //
       
  1596 void CPguGroupMembersView::CGroupMembersAllGroupsReady::ContactViewReady
       
  1597         ( MVPbkContactViewBase& aView )
       
  1598     {
       
  1599     // If we have a new view, lets change it
       
  1600     if ((&aView != iGroupMembersView) &&
       
  1601         (&aView == iViewTransitionTransaction->GroupMembersView()))
       
  1602         {
       
  1603         TRAP_IGNORE(DoCommitTransActionL(aView));
       
  1604         }
       
  1605     else
       
  1606         {
       
  1607         // When ContactViewReady() is called, the program needs to check whether 
       
  1608         // the namelist control in the container is visible or not. 
       
  1609         // If visible, call DrawDeferred() to refresh the container, 
       
  1610         // and if not, the container needs not to be refreshed to avoid flicker on the background.
       
  1611         if ( iContainer->Control() && iContainer->Control()->IsVisible() )
       
  1612             {
       
  1613             iContainer->DrawDeferred();
       
  1614             }
       
  1615         }
       
  1616     }
       
  1617 
       
  1618 // --------------------------------------------------------------------------
       
  1619 // CPguGroupMembersView::CGroupMembersAllGroupsReady::HandleNavigationEvent
       
  1620 // --------------------------------------------------------------------------
       
  1621 //
       
  1622 void CPguGroupMembersView::CGroupMembersAllGroupsReady::HandleNavigationEvent
       
  1623         ( const TEventType& aEventType )
       
  1624     {
       
  1625     if (aEventType == MPbk2NavigationObserver::EContactDeleted)
       
  1626         {
       
  1627         // Return to the previous view
       
  1628         TRAPD( err,
       
  1629             {
       
  1630             CPbk2ViewState* state = ViewStateLC();
       
  1631             if ( iViewParent.FocusedContact() )
       
  1632                 {
       
  1633                 // change focused contact to current focused contact
       
  1634                 state->SetFocusedContact(
       
  1635                     iViewParent.FocusedContact()->CloneLC() );
       
  1636                 CleanupStack::Pop(); // currentGroup
       
  1637                 }
       
  1638             Phonebook2::Pbk2AppUi()->Pbk2ViewExplorer()->
       
  1639                 ActivatePreviousViewL( state );
       
  1640             CleanupStack::PopAndDestroy(state);
       
  1641             } ); // TRAPD
       
  1642 
       
  1643         if ( err != KErrNone )
       
  1644             {
       
  1645             CCoeEnv::Static()->HandleError( err );
       
  1646             }
       
  1647         }
       
  1648     }
       
  1649 
       
  1650 // --------------------------------------------------------------------------
       
  1651 // CPguGroupMembersView::CGroupMembersAllGroupsReady::DoCommitTransActionL
       
  1652 // --------------------------------------------------------------------------
       
  1653 //
       
  1654 void CPguGroupMembersView::CGroupMembersAllGroupsReady::DoCommitTransActionL
       
  1655         ( MVPbkContactViewBase& aView )
       
  1656     {
       
  1657     MVPbkContactLink* groupLink = iViewTransitionTransaction->GroupLink();
       
  1658     HBufC* titleText = iViewTransitionTransaction->GetGroupName();
       
  1659     CleanupStack::PushL( titleText );
       
  1660 
       
  1661     // Update navi indicators in the navi pane
       
  1662     iNavigation->UpdateNaviIndicatorsL( *groupLink );
       
  1663 
       
  1664     // Change title pane text
       
  1665     ChangeTitlePaneL(titleText);
       
  1666     CleanupStack::Pop(titleText);
       
  1667 
       
  1668     // Reset old view before changing
       
  1669     iContainer->Control()->Reset();
       
  1670 
       
  1671     // Set control's active view next
       
  1672     iContainer->Control()->SetViewL( aView );
       
  1673 
       
  1674     // Trash old view
       
  1675     if (iGroupMembersView)
       
  1676         {
       
  1677         iGroupMembersView->RemoveObserver( *this );
       
  1678         delete iGroupMembersView;
       
  1679         iGroupMembersView = NULL;
       
  1680         }
       
  1681 
       
  1682     // Set correct focused index (First item)
       
  1683     iContainer->Control()->SetFocusedContactIndexL(KFirstItem);
       
  1684 
       
  1685     //Set the current group link to Nameslist control
       
  1686    iContainer->Control()->SetCurrentGroupLinkL(groupLink);
       
  1687     // The new base view is already being observed by this class
       
  1688     // (observer set in ExpandLC call in ChangeContactL method)
       
  1689 
       
  1690     // commit the transaction
       
  1691     MVPbkContactViewBase* groupMembersView =
       
  1692         iViewTransitionTransaction->GetGroupMembersView();
       
  1693     groupLink = iViewTransitionTransaction->GetGroupLink();
       
  1694     iGroupMembersView = groupMembersView;
       
  1695     iViewParent.SetFocusedContact(groupLink);
       
  1696 
       
  1697     // delete the transaction
       
  1698     delete iViewTransitionTransaction;
       
  1699     iViewTransitionTransaction = NULL;
       
  1700     }
       
  1701 
       
  1702 // --------------------------------------------------------------------------
       
  1703 // CPguGroupMembersView::CGroupMembersAllGroupsReady::ChangeTitlePaneL
       
  1704 // --------------------------------------------------------------------------
       
  1705 //
       
  1706 void CPguGroupMembersView::CGroupMembersAllGroupsReady::ChangeTitlePaneL
       
  1707         ( HBufC* aTitleText )
       
  1708     {
       
  1709     CEikStatusPane* statusPane =
       
  1710         CEikonEnv::Static()->AppUiFactory()->StatusPane();
       
  1711 
       
  1712     if (statusPane && statusPane->PaneCapabilities(
       
  1713             TUid::Uid(EEikStatusPaneUidTitle)).IsPresent())
       
  1714         {
       
  1715         CAknTitlePane* titlePane = static_cast<CAknTitlePane*>(statusPane->
       
  1716                             ControlL(TUid::Uid(EEikStatusPaneUidTitle)));
       
  1717         titlePane->SetText(aTitleText); // Takes ownership of aTitle
       
  1718         }
       
  1719     }
       
  1720 
       
  1721 // --------------------------------------------------------------------------
       
  1722 // CPguGroupMembersView::CGroupMembersAllGroupsReady::UpdateListEmptyTextL
       
  1723 // --------------------------------------------------------------------------
       
  1724 //
       
  1725 void CPguGroupMembersView::CGroupMembersAllGroupsReady::UpdateListEmptyTextL
       
  1726         ( TInt aListState )
       
  1727     {
       
  1728     HBufC* text = NULL;
       
  1729 
       
  1730     switch ( aListState )
       
  1731         {
       
  1732         case CPbk2NamesListControl::EStateEmpty:
       
  1733             {
       
  1734             text = StringLoader::LoadLC( R_QTN_PHOB_NO_ENTRIES_IN_GRP );
       
  1735             break;
       
  1736             }
       
  1737         case CPbk2NamesListControl::EStateFiltered:
       
  1738             {
       
  1739             text = StringLoader::LoadLC( R_PBK2_FIND_NO_MATCHES );
       
  1740             break;
       
  1741             }
       
  1742         default:
       
  1743             {
       
  1744             text = KNullDesC().AllocLC();
       
  1745             break;
       
  1746             }
       
  1747         }
       
  1748 
       
  1749     if ( text )
       
  1750         {
       
  1751         iControl->SetTextL( *text );
       
  1752         CleanupStack::PopAndDestroy(); // text
       
  1753         }
       
  1754     }
       
  1755 
       
  1756 // --------------------------------------------------------------------------
       
  1757 // CPguGroupMembersView::CGroupMembersAllGroupsReady::UpdateCbasL
       
  1758 // --------------------------------------------------------------------------
       
  1759 //
       
  1760 void CPguGroupMembersView::CGroupMembersAllGroupsReady::UpdateCbasL()
       
  1761     {
       
  1762     if ( iControl )
       
  1763         {
       
  1764         if ( iControl->NumberOfContacts() > 0
       
  1765             && !iControl->ContactsMarked() )
       
  1766             {
       
  1767             // Set middle softkey as Open.
       
  1768             iView.Cba()->SetCommandSetL(R_PGU_SOFTKEYS_OPTIONS_BACK_OPEN);
       
  1769             iView.Cba()->DrawDeferred();
       
  1770             }
       
  1771         else
       
  1772             {
       
  1773             // If names list is empty, MSK should be empty
       
  1774             if ( Phonebook2::Pbk2AppUi()->ApplicationServices().
       
  1775                     ViewSupplier().AllContactsViewL()->ContactCountL() == 0 )
       
  1776                 {
       
  1777                 // Set middle softkey as Context menu.
       
  1778                 iView.Cba()->SetCommandSetL(
       
  1779                     R_PBK2_SOFTKEYS_OPTIONS_BACK_EMPTY);
       
  1780                 }
       
  1781             else
       
  1782                 {
       
  1783                 // Set middle softkey as Context menu.
       
  1784                 iView.Cba()->SetCommandSetL(
       
  1785                     R_PBK2_SOFTKEYS_OPTIONS_BACK_CONTEXT);
       
  1786                 }
       
  1787             iView.Cba()->DrawDeferred();
       
  1788             // Change context menu when marked items
       
  1789             iView.MenuBar()->SetContextMenuTitleResourceId
       
  1790                 ( R_PHONEBOOK2_GROUPMEMBERS_CONTEXT_MENUBAR );
       
  1791             }
       
  1792         }
       
  1793     }
       
  1794 
       
  1795 // --------------------------------------------------------------------------
       
  1796 // CPguGroupMembersView::CGroupMembersAllGroupsReady::RestoreControlStateL
       
  1797 // --------------------------------------------------------------------------
       
  1798 //
       
  1799 void CPguGroupMembersView::CGroupMembersAllGroupsReady::RestoreControlStateL
       
  1800         ( CPbk2ViewState* aState )
       
  1801     {
       
  1802     if ( iControl )
       
  1803         {
       
  1804         iControl->RestoreControlStateL(aState);
       
  1805         }
       
  1806     }
       
  1807 
       
  1808 // --------------------------------------------------------------------------
       
  1809 // CPguGroupMembersView::CGroupMembersAllGroupsReady::HandleCommandL
       
  1810 // --------------------------------------------------------------------------
       
  1811 //
       
  1812 void CPguGroupMembersView::CGroupMembersAllGroupsReady::HandleCommandL
       
  1813         ( TInt aCommand )
       
  1814     { 
       
  1815         switch(aCommand)
       
  1816             {
       
  1817             case EPbk2CmdRemoveFromGroup:
       
  1818                 {
       
  1819                 if ( iControl && ( iControl->FocusedContactIndex() != KErrNotFound ) )
       
  1820                     {
       
  1821                     CPguRemoveFromGroupCmd* cmd =
       
  1822                             CPguRemoveFromGroupCmd::NewLC(
       
  1823                                 *iViewParent.FocusedContact(),
       
  1824                                 *iControl);
       
  1825                     iCommandHandler.AddAndExecuteCommandL(cmd);
       
  1826                     
       
  1827                     CleanupStack::Pop(cmd);  // command handler takes the ownership
       
  1828                     }
       
  1829                 break;
       
  1830                 }
       
  1831     
       
  1832             case EPbk2CmdAddMembers:
       
  1833                 {
       
  1834                 CPguAddMembersCmd* cmd =
       
  1835                         CPguAddMembersCmd::NewLC(*iViewParent.FocusedContact(),
       
  1836                             *iControl);
       
  1837                 iCommandHandler.AddAndExecuteCommandL(cmd);
       
  1838                 CleanupStack::Pop(cmd); // command handler takes the ownership
       
  1839                 break;
       
  1840                 }
       
  1841     
       
  1842             default:
       
  1843                 {
       
  1844                 // Do nothing
       
  1845                 break;
       
  1846                 }
       
  1847             }
       
  1848         
       
  1849     if ( iControl && !iCommandHandler.HandleCommandL( aCommand, *iControl,
       
  1850         &iView ) )
       
  1851             {
       
  1852             iControl->ProcessCommandL( aCommand );
       
  1853             Phonebook2::Pbk2AppUi()->HandleCommandL( aCommand );
       
  1854             }
       
  1855         
       
  1856     UpdateCbasL();
       
  1857     }
       
  1858 
       
  1859 // --------------------------------------------------------------------------
       
  1860 // CPguGroupMembersView::CGroupMembersAllGroupsReady::HandleStatusPaneSizeCh
       
  1861 // --------------------------------------------------------------------------
       
  1862 //
       
  1863 void CPguGroupMembersView::CGroupMembersAllGroupsReady::
       
  1864     HandleStatusPaneSizeChange()
       
  1865     {
       
  1866     // Resize the container to fill the client rectangle
       
  1867     if( iContainer )
       
  1868         {
       
  1869         iContainer->SetRect(iView.ClientRect());
       
  1870         }
       
  1871     }
       
  1872 
       
  1873 
       
  1874 // ----------------------------------------------------------------------------
       
  1875 // CPguGroupMembersView::CGroupMembersAllGroupsReady::HandleListBoxEventL
       
  1876 // ----------------------------------------------------------------------------
       
  1877 //
       
  1878 void CPguGroupMembersView::CGroupMembersAllGroupsReady::HandleListBoxEventL(CEikListBox* /*aListBox*/,TListBoxEvent aEventType)
       
  1879     { 
       
  1880 
       
  1881     if( AknLayoutUtils::PenEnabled() )  
       
  1882         {
       
  1883         switch ( aEventType )
       
  1884             {
       
  1885             case EEventItemDoubleClicked:
       
  1886             case EEventItemSingleClicked:
       
  1887                 {
       
  1888 
       
  1889                 ShowContextMenuL();
       
  1890                 break;
       
  1891                 }
       
  1892             case EEventItemClicked: //Happens after focus changed
       
  1893             break;
       
  1894             case EEventEnterKeyPressed:
       
  1895                 {
       
  1896                 if (iControl->NumberOfContacts() > 0 &&
       
  1897                     !iControl->ContactsMarked())
       
  1898                     {
       
  1899                     // Select key is mapped to "Open Contact" command
       
  1900                     HandleCommandL( EPbk2CmdOpenCca );
       
  1901                     }
       
  1902                 else
       
  1903                     {
       
  1904                     iView.LaunchPopupMenuL(
       
  1905                             R_PHONEBOOK2_GROUPMEMBERS_CONTEXT_MENUBAR);
       
  1906                     }
       
  1907                 break;
       
  1908                 }
       
  1909             default:
       
  1910                break;
       
  1911             }
       
  1912         }
       
  1913 
       
  1914 
       
  1915     }
       
  1916 
       
  1917 
       
  1918 
       
  1919 
       
  1920 // --------------------------------------------------------------------------
       
  1921 // CPguGroupMembersView::CGroupMembersAllGroupsReady::HandlePointerEventL
       
  1922 // --------------------------------------------------------------------------
       
  1923 //
       
  1924 void CPguGroupMembersView::CGroupMembersAllGroupsReady::HandlePointerEventL
       
  1925         ( const TPointerEvent& aPointerEvent )
       
  1926     {
       
  1927 
       
  1928 
       
  1929     if ( AknLayoutUtils::PenEnabled() )
       
  1930         {
       
  1931         if ( iPointerEventInspector->FocusableItemPointed() && iContainer && !(iControl->ContactsMarked()))
       
  1932             {
       
  1933             iContainer->LongTapDetectorL().PointerEventL( aPointerEvent );
       
  1934             }
       
  1935             
       
  1936 
       
  1937 
       
  1938         if ( iControl->NumberOfContacts()==0) 
       
  1939             {       
       
  1940             if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
       
  1941                 {
       
  1942                 MTouchFeedback* feedback = MTouchFeedback::Instance();
       
  1943                 if ( feedback )
       
  1944                     {
       
  1945                     feedback->InstantFeedback( ETouchFeedbackBasic );
       
  1946                     }
       
  1947                 }
       
  1948             else if  ( aPointerEvent.iType == TPointerEvent::EButton1Up )       
       
  1949                 {
       
  1950                 ShowContextMenuL();
       
  1951                 }
       
  1952             }
       
  1953 
       
  1954         }
       
  1955 
       
  1956     }
       
  1957     
       
  1958     
       
  1959 // --------------------------------------------------------------------------
       
  1960 // CPguGroupMembersView::CGroupMembersAllGroupsReady::ShowContextMenuL
       
  1961 // --------------------------------------------------------------------------
       
  1962 //
       
  1963 void CPguGroupMembersView::CGroupMembersAllGroupsReady::ShowContextMenuL()
       
  1964     {
       
  1965     if ( iStylusPopupMenuLaunched )
       
  1966         {
       
  1967         // Absorb EButton1Up event if we already launched the
       
  1968         // stylus popup menu
       
  1969         iStylusPopupMenuLaunched = EFalse;
       
  1970         }
       
  1971     else if ( !iPointerEventInspector->SearchFieldPointed() &&
       
  1972               !iSelectionModifierUsed )
       
  1973         {
       
  1974         if ( iControl->NumberOfContacts() > 0 && 
       
  1975                 iPointerEventInspector->FocusedItemPointed() )
       
  1976             {
       
  1977             if ( iControl->ContactsMarked() )
       
  1978                 {
       
  1979                 iView.LaunchPopupMenuL(
       
  1980                     R_PHONEBOOK2_GROUPMEMBERS_CONTEXT_MENUBAR );
       
  1981                 }
       
  1982             else
       
  1983                 {
       
  1984                 // Open contact
       
  1985                 HandleCommandL(EPbk2CmdOpenCca);
       
  1986                 }
       
  1987             }
       
  1988         }
       
  1989     }
       
  1990    
       
  1991     
       
  1992     
       
  1993 
       
  1994 // --------------------------------------------------------------------------
       
  1995 // CPguGroupMembersView::CGroupMembersAllGroupsReady::HandleLongTapEventL
       
  1996 // --------------------------------------------------------------------------
       
  1997 //
       
  1998 void CPguGroupMembersView::CGroupMembersAllGroupsReady::HandleLongTapEventL
       
  1999         ( const TPoint& /*aPenEventLocation*/,
       
  2000           const TPoint& aPenEventScreenLocation )
       
  2001     {
       
  2002     if( iControl->ContactsMarked() )
       
  2003         {
       
  2004         //if there are marked contacts, context menu should not open
       
  2005         return;
       
  2006         }
       
  2007     }
       
  2008 
       
  2009 // --------------------------------------------------------------------------
       
  2010 // CPguGroupMembersView::CGroupMembersAllGroupsReady::PreCommandExecutionL
       
  2011 // --------------------------------------------------------------------------
       
  2012 //
       
  2013 void CPguGroupMembersView::CGroupMembersAllGroupsReady::PreCommandExecutionL
       
  2014         ( const MPbk2Command& /*aCommand*/ )
       
  2015     {    
       
  2016     if (iContainer && iContainer->Control())
       
  2017         {
       
  2018         iContainer->Control()->HideThumbnail();
       
  2019         }
       
  2020     }
       
  2021 
       
  2022 // --------------------------------------------------------------------------
       
  2023 // CPguGroupMembersView::CGroupMembersAllGroupsReady::PostCommandExecutionL
       
  2024 // --------------------------------------------------------------------------
       
  2025 //
       
  2026 void CPguGroupMembersView::CGroupMembersAllGroupsReady::PostCommandExecutionL
       
  2027         ( const MPbk2Command& /*aCommand*/ )
       
  2028     {    
       
  2029     if ( iContainer && iContainer->Control() )
       
  2030         {
       
  2031         iContainer->Control()->ShowThumbnail();
       
  2032         }
       
  2033 
       
  2034     UpdateCbasL();
       
  2035     }
       
  2036 
       
  2037 // --------------------------------------------------------------------------
       
  2038 // CPguGroupMembersView::CPguGroupMembersView
       
  2039 // --------------------------------------------------------------------------
       
  2040 //
       
  2041 CPguGroupMembersView::CPguGroupMembersView( CPbk2UIExtensionView& aView ) :
       
  2042             iView( aView )
       
  2043     {
       
  2044     }
       
  2045 
       
  2046 // --------------------------------------------------------------------------
       
  2047 // CPguGroupMembersView::~CPguGroupMembersView
       
  2048 // --------------------------------------------------------------------------
       
  2049 //
       
  2050 CPguGroupMembersView::~CPguGroupMembersView()
       
  2051     {
       
  2052     delete iFocusedGroup;
       
  2053     delete iControlState;
       
  2054     delete iViewImpl;
       
  2055     }
       
  2056 
       
  2057 // --------------------------------------------------------------------------
       
  2058 // CPguGroupMembersView::NewL
       
  2059 // --------------------------------------------------------------------------
       
  2060 //
       
  2061 CPguGroupMembersView* CPguGroupMembersView::NewL
       
  2062         ( CPbk2UIExtensionView& aView )
       
  2063     {
       
  2064     CPguGroupMembersView* self =
       
  2065         new(ELeave) CPguGroupMembersView( aView );
       
  2066     return self;
       
  2067     }
       
  2068 
       
  2069 // --------------------------------------------------------------------------
       
  2070 // CPguGroupMembersView::HandleStatusPaneSizeChange
       
  2071 // --------------------------------------------------------------------------
       
  2072 //
       
  2073 void CPguGroupMembersView::HandleStatusPaneSizeChange()
       
  2074     {
       
  2075     if ( iViewImpl )
       
  2076         {
       
  2077         iViewImpl->HandleStatusPaneSizeChange();
       
  2078         }
       
  2079     }
       
  2080 
       
  2081 // --------------------------------------------------------------------------
       
  2082 // CPguGroupMembersView::ViewStateLC
       
  2083 // --------------------------------------------------------------------------
       
  2084 //
       
  2085 CPbk2ViewState* CPguGroupMembersView::ViewStateLC() const
       
  2086     {
       
  2087     CPbk2ViewState* ret = NULL;
       
  2088     if ( iViewImpl )
       
  2089         {
       
  2090         ret = iViewImpl->ViewStateLC();
       
  2091         }
       
  2092     else
       
  2093         {
       
  2094         CleanupStack::PushL( ret ); // LC function semantics
       
  2095         }
       
  2096 
       
  2097     return ret;
       
  2098     }
       
  2099 
       
  2100 // --------------------------------------------------------------------------
       
  2101 // CPguGroupMembersView::HandleCommandKeyL
       
  2102 // --------------------------------------------------------------------------
       
  2103 //
       
  2104 TBool CPguGroupMembersView::HandleCommandKeyL(
       
  2105         const TKeyEvent& aKeyEvent,
       
  2106         TEventCode aType )
       
  2107     {
       
  2108     // Pass the key event to the strategy
       
  2109     return iViewImpl->HandleCommandKeyL(aKeyEvent, aType);
       
  2110     }
       
  2111 
       
  2112 // --------------------------------------------------------------------------
       
  2113 // CPguGroupMembersView::GetViewSpecificMenuFilteringFlagsL
       
  2114 // --------------------------------------------------------------------------
       
  2115 //
       
  2116 TInt CPguGroupMembersView::GetViewSpecificMenuFilteringFlagsL() const
       
  2117     {
       
  2118     return iViewImpl->GetViewSpecificMenuFilteringFlagsL();
       
  2119     }
       
  2120 
       
  2121 // --------------------------------------------------------------------------
       
  2122 // CPguGroupMembersView::DoActivateL
       
  2123 // --------------------------------------------------------------------------
       
  2124 //
       
  2125 void CPguGroupMembersView::DoActivateL
       
  2126         ( const TVwsViewId& aPrevViewId, TUid aCustomMessageId,
       
  2127           const TDesC8& aCustomMessage )
       
  2128     {
       
  2129     UpdateViewStateL(aCustomMessageId, aCustomMessage);
       
  2130 
       
  2131     MPbk2ApplicationServices& appServices =
       
  2132         Phonebook2::Pbk2AppUi()->ApplicationServices();
       
  2133 
       
  2134     // Focus setting cannot be done here as the group view might not be ready
       
  2135     // when using view launch
       
  2136 
       
  2137     MVPbkContactViewBase* allGroupsView =
       
  2138         appServices.ViewSupplier().AllGroupsViewL();
       
  2139 
       
  2140     // get the focused group from the view parameters
       
  2141     const MVPbkContactLink* focusedGroupLink = iControlState->FocusedContact();
       
  2142     // find the group's index from the group view
       
  2143     TInt groupIndex = allGroupsView->IndexOfLinkL(*focusedGroupLink);
       
  2144     if (groupIndex == KErrNotFound)
       
  2145         {
       
  2146         // if the parameter is correct check whether the focused group is set
       
  2147         groupIndex = allGroupsView->IndexOfLinkL(*iFocusedGroup);
       
  2148         }
       
  2149     else
       
  2150         {
       
  2151         delete iFocusedGroup;
       
  2152         iFocusedGroup = iControlState->TakeFocusedContact();
       
  2153         }
       
  2154 
       
  2155     MPbk2ViewActivationTransaction* viewActivationTransaction = NULL;
       
  2156     if (groupIndex == KErrNotFound)
       
  2157         {
       
  2158         // if the group view isnt ready, thus the index cannot be retrieved,
       
  2159         // do a alternative view and refresh later, when the view is ready
       
  2160         viewActivationTransaction =
       
  2161             Phonebook2::Pbk2AppUi()->Pbk2ViewExplorer()->HandleViewActivationLC
       
  2162                 ( iView.Id(), aPrevViewId, NULL, NULL,
       
  2163                   Phonebook2::EUpdateNaviPane | Phonebook2::EUpdateTitlePane |
       
  2164                   Phonebook2::EUpdateContextPane );
       
  2165 
       
  2166         iViewImpl = CPguGroupMembersView::CGroupMembersAllGroupsNotReady::NewL
       
  2167             ( *this, iView, focusedGroupLink );
       
  2168         }
       
  2169     else
       
  2170         {
       
  2171         // standard phonebook view activation
       
  2172         const MVPbkViewContact& contact = allGroupsView->ContactAtL(groupIndex);
       
  2173         HBufC* title = appServices.NameFormatter().GetContactTitleL
       
  2174                 ( contact.Fields(),
       
  2175                   MPbk2ContactNameFormatter::EPreserveLeadingSpaces );
       
  2176         CleanupStack::PushL( title );
       
  2177 
       
  2178         viewActivationTransaction =
       
  2179             Phonebook2::Pbk2AppUi()->Pbk2ViewExplorer()->HandleViewActivationLC
       
  2180                 ( iView.Id(), aPrevViewId, title, NULL,
       
  2181                   Phonebook2::EUpdateNaviPane | Phonebook2::EUpdateTitlePane |
       
  2182                   Phonebook2::EUpdateContextPane );
       
  2183 
       
  2184 
       
  2185 
       
  2186         iViewImpl = CGroupMembersAllGroupsReady::NewL
       
  2187             ( *this, iView, appServices.ContactManager(),
       
  2188                 appServices.NameFormatter(), appServices.StoreProperties(),
       
  2189                 *appServices.CommandHandlerL(), appServices.SortOrderManager(),
       
  2190                 groupIndex );
       
  2191         }
       
  2192 
       
  2193     // notifies startup monitor of view activation
       
  2194     if (Phonebook2::Pbk2AppUi()->Pbk2StartupMonitor())
       
  2195         {
       
  2196         Phonebook2::Pbk2AppUi()->Pbk2StartupMonitor()->
       
  2197             NotifyViewActivationL( iView.Id() );
       
  2198         }
       
  2199 
       
  2200     iViewImpl->CreateControlL(iView.ClientRect());
       
  2201     
       
  2202     CPbk2NamesListControl* nlctrl=static_cast <CPbk2NamesListControl*> (iViewImpl->Control());
       
  2203     CCoeControl* ctrl=nlctrl->ComponentControl(0);
       
  2204     CEikListBox* listbox=static_cast <CEikListBox*> (ctrl);
       
  2205     listbox->SetListBoxObserver( this ); 
       
  2206 
       
  2207     iPreviousViewId = aPrevViewId;
       
  2208 
       
  2209     viewActivationTransaction->Commit();
       
  2210     CleanupStack::PopAndDestroy(); // viewActivationTransaction
       
  2211     if (groupIndex != KErrNotFound)
       
  2212         {
       
  2213         CleanupStack::PopAndDestroy(); // title
       
  2214         }
       
  2215     }
       
  2216 
       
  2217 // --------------------------------------------------------------------------
       
  2218 // CPguGroupMembersView::DoDeactivate
       
  2219 // --------------------------------------------------------------------------
       
  2220 //
       
  2221 void CPguGroupMembersView::DoDeactivate()
       
  2222     {
       
  2223     // Trash the old states
       
  2224     delete iControlState;
       
  2225     iControlState = NULL;
       
  2226 
       
  2227     // Store current state, safe to ignore. There's no real harm,
       
  2228     // if theres no stored state when activating this view again
       
  2229     TRAP_IGNORE( StoreStateL() );
       
  2230 
       
  2231     delete iViewImpl;
       
  2232     iViewImpl = NULL;
       
  2233     }
       
  2234 
       
  2235 // --------------------------------------------------------------------------
       
  2236 // CPguGroupMembersView::HandleCommandL
       
  2237 // --------------------------------------------------------------------------
       
  2238 //
       
  2239 void CPguGroupMembersView::HandleCommandL( TInt aCommand )
       
  2240     {
       
  2241     switch ( aCommand )
       
  2242         {
       
  2243         case EAknSoftkeyBack:       // FALLTHROUGH
       
  2244         case EPbk2CmdOpenPreviousView:
       
  2245             {
       
  2246             ReturnToPreviousViewL();
       
  2247             break;
       
  2248             }
       
  2249         default:
       
  2250             {
       
  2251             if ( iViewImpl )
       
  2252                 {
       
  2253                 // route handle command to view implementation
       
  2254                 iViewImpl->HandleCommandL(aCommand);
       
  2255                 }
       
  2256             break;
       
  2257             }
       
  2258         }
       
  2259     }
       
  2260 
       
  2261 // --------------------------------------------------------------------------
       
  2262 // CPguGroupMembersView::DynInitMenuPaneL
       
  2263 // --------------------------------------------------------------------------
       
  2264 //
       
  2265 void CPguGroupMembersView::DynInitMenuPaneL(
       
  2266         TInt aResourceId, CEikMenuPane* aMenuPane )
       
  2267     {
       
  2268     if ( iViewImpl )
       
  2269         {
       
  2270         // Ask the control do control specific filtering
       
  2271         // (for example call HandleMarkableListDynInitMenuPane if needed)
       
  2272         iViewImpl->DynInitMenuPaneL(aResourceId, aMenuPane);
       
  2273         }
       
  2274     }
       
  2275 
       
  2276 // ----------------------------------------------------------------------------
       
  2277 // CPguGroupMembersView::HandleListBoxEventL
       
  2278 // ----------------------------------------------------------------------------
       
  2279 //
       
  2280 void CPguGroupMembersView::HandleListBoxEventL(CEikListBox* aListBox,TListBoxEvent aEventType)
       
  2281     {
       
  2282     
       
  2283     
       
  2284     
       
  2285     if( AknLayoutUtils::PenEnabled() )  
       
  2286         {
       
  2287         switch ( aEventType )
       
  2288             {
       
  2289             case EEventItemDoubleClicked:
       
  2290             case EEventItemSingleClicked:
       
  2291 		    case EEventEnterKeyPressed:
       
  2292                 {
       
  2293 
       
  2294                 if ( iViewImpl )
       
  2295                     {
       
  2296                     // route the events to the view implementing the application
       
  2297                     // view currently
       
  2298                     iViewImpl->HandleListBoxEventL(aListBox,aEventType);
       
  2299                     }
       
  2300                 break;
       
  2301                 }
       
  2302             case EEventItemClicked: //Happens after focus changed
       
  2303             break;
       
  2304             default:
       
  2305                break;
       
  2306             }
       
  2307         }
       
  2308      
       
  2309     }
       
  2310 
       
  2311 
       
  2312 
       
  2313 // --------------------------------------------------------------------------
       
  2314 // CPguGroupMembersView::HandlePointerEventL
       
  2315 // --------------------------------------------------------------------------
       
  2316 //
       
  2317 void CPguGroupMembersView::HandlePointerEventL(
       
  2318         const TPointerEvent& aPointerEvent)
       
  2319     {
       
  2320     if ( iViewImpl )
       
  2321         {
       
  2322         // route the pointer events to the view implementing the application
       
  2323         // view currently
       
  2324         iViewImpl->HandlePointerEventL(aPointerEvent);
       
  2325         }
       
  2326     }
       
  2327 
       
  2328 // --------------------------------------------------------------------------
       
  2329 // CPguGroupMembersView::HandleLongTapEventL
       
  2330 // --------------------------------------------------------------------------
       
  2331 //
       
  2332 void CPguGroupMembersView::HandleLongTapEventL(
       
  2333         const TPoint& aPenEventLocation,
       
  2334         const TPoint& aPenEventScreenLocation )
       
  2335     {
       
  2336     if ( iViewImpl )
       
  2337         {
       
  2338         // route the long tap event to the view implementing the application
       
  2339         // view currently
       
  2340         iViewImpl->HandleLongTapEventL(
       
  2341             aPenEventLocation, aPenEventScreenLocation );
       
  2342         }
       
  2343     }
       
  2344 
       
  2345 // --------------------------------------------------------------------------
       
  2346 // CPguGroupMembersView::TransformViewActivationStateToReady
       
  2347 // --------------------------------------------------------------------------
       
  2348 //
       
  2349 void CPguGroupMembersView::TransformViewActivationStateToReadyL(
       
  2350         const TInt aGroupIndex)
       
  2351     {
       
  2352     if ( aGroupIndex == KErrNotFound )
       
  2353         {
       
  2354         ReturnToPreviousViewL();
       
  2355         }
       
  2356     else
       
  2357         {
       
  2358         // Pops the control from the control stack
       
  2359         delete iViewImpl;
       
  2360         iViewImpl = NULL;
       
  2361 
       
  2362         // Switch view control states
       
  2363         MPbk2ApplicationServices& appServices =
       
  2364             Phonebook2::Pbk2AppUi()->ApplicationServices();
       
  2365         iViewImpl = CPguGroupMembersView::CGroupMembersAllGroupsReady::NewL
       
  2366             ( *this, iView, appServices.ContactManager(),
       
  2367               appServices.NameFormatter(), appServices.StoreProperties(),
       
  2368               *appServices.CommandHandlerL(), appServices.SortOrderManager(),
       
  2369               aGroupIndex );
       
  2370 
       
  2371         // Creates and activates the control
       
  2372         iViewImpl->CreateControlL(iView.ClientRect());
       
  2373         }
       
  2374     }
       
  2375 
       
  2376 // --------------------------------------------------------------------------
       
  2377 // CPguGroupMembersView::FocusedContact
       
  2378 // --------------------------------------------------------------------------
       
  2379 //
       
  2380 MVPbkContactLink* CPguGroupMembersView::FocusedContact() const
       
  2381     {
       
  2382     return iFocusedGroup;
       
  2383     }
       
  2384 
       
  2385 // --------------------------------------------------------------------------
       
  2386 // CPguGroupMembersView::SetFocusedContact
       
  2387 // --------------------------------------------------------------------------
       
  2388 //
       
  2389 void CPguGroupMembersView::SetFocusedContact(MVPbkContactLink* aGroupLink)
       
  2390     {
       
  2391     delete iFocusedGroup;
       
  2392     iFocusedGroup = aGroupLink;
       
  2393     }
       
  2394 
       
  2395 // --------------------------------------------------------------------------
       
  2396 // CPguGroupMembersView::StoreStateL
       
  2397 // --------------------------------------------------------------------------
       
  2398 //
       
  2399 void CPguGroupMembersView::StoreStateL()
       
  2400     {
       
  2401     // retrieves the views state from the implementation
       
  2402     CPbk2ViewState* state = ViewStateLC();
       
  2403     CleanupStack::Pop(state);
       
  2404     if ( state )
       
  2405         {
       
  2406         // and stores it as member data
       
  2407         delete iControlState;
       
  2408         iControlState = state;
       
  2409         }
       
  2410     }
       
  2411 
       
  2412 // --------------------------------------------------------------------------
       
  2413 // CPguGroupMembersView::RestoreStateL
       
  2414 // --------------------------------------------------------------------------
       
  2415 //
       
  2416 void CPguGroupMembersView::RestoreStateL()
       
  2417     {
       
  2418     iViewImpl->RestoreControlStateL(iControlState);
       
  2419     delete iControlState;
       
  2420     iControlState = NULL;
       
  2421     }
       
  2422 
       
  2423 // --------------------------------------------------------------------------
       
  2424 // CPguGroupMembersView::UpdateViewStateL
       
  2425 // --------------------------------------------------------------------------
       
  2426 //
       
  2427 void CPguGroupMembersView::UpdateViewStateL(
       
  2428         const TUid aCustomMessageId,
       
  2429         const TDesC8& aCustomMessage)
       
  2430     {
       
  2431     CPbk2ViewState* viewState = NULL;
       
  2432     // Read the desired UI state from aCustomMessage
       
  2433     if (aCustomMessageId == TUid::Uid(KPbkViewStateUid))
       
  2434         {
       
  2435         // Handle lecagy view state message
       
  2436         CPbk2ViewStateTransformer* transformer =
       
  2437             CPbk2ViewStateTransformer::NewLC
       
  2438                 ( Phonebook2::Pbk2AppUi()->ApplicationServices().
       
  2439                     ContactManager() );
       
  2440         viewState = transformer->TransformLegacyViewStateToPbk2ViewStateLC
       
  2441             ( aCustomMessage );
       
  2442         CleanupStack::Pop(); // viewState
       
  2443         CleanupStack::PopAndDestroy(transformer);
       
  2444         }
       
  2445     else if (aCustomMessageId == CPbk2ViewState::Uid())
       
  2446         {
       
  2447         // Read the desired UI state from aCustomMessage
       
  2448         viewState = CPbk2ViewState::NewL(aCustomMessage);
       
  2449         }
       
  2450     else
       
  2451         {
       
  2452         User::Leave(KErrNotSupported);
       
  2453         }
       
  2454 
       
  2455     if ( iControlState )
       
  2456         {
       
  2457         // Merge parameter view state with the stored state
       
  2458         if ( viewState->FocusedContact() &&
       
  2459              viewState->FocusedContact() != iControlState->FocusedContact() )
       
  2460             {
       
  2461             iControlState->SetFocusedContact(
       
  2462                             viewState->TakeFocusedContact() );
       
  2463             iControlState->SetFocusedFieldIndex( KErrNotFound );
       
  2464             iControlState->SetTopFieldIndex( KErrNotFound );
       
  2465             }
       
  2466         if ( viewState->FocusedFieldIndex() >= 0 )
       
  2467             {
       
  2468             iControlState->SetFocusedFieldIndex(
       
  2469                     viewState->FocusedFieldIndex() );
       
  2470             }
       
  2471         if ( viewState->TopFieldIndex() >= 0 )
       
  2472             {
       
  2473             iControlState->SetTopFieldIndex(
       
  2474                     viewState->TopFieldIndex() );
       
  2475             }
       
  2476         if ( viewState->ParentContact() &&
       
  2477              viewState->ParentContact() != iControlState->ParentContact() )
       
  2478             {
       
  2479             iControlState->SetParentContact(
       
  2480                 viewState->TakeParentContact() );
       
  2481             }
       
  2482 
       
  2483         // Input state overwrites the saved state. When the view is deactivated
       
  2484         // and then again activated marks are not set if the input state
       
  2485         /// doesn't say otherwise.
       
  2486         iControlState->SetMarkedContacts( viewState->TakeMarkedContacts() );
       
  2487 
       
  2488         // Delete parameter view state
       
  2489         delete viewState;
       
  2490         }
       
  2491     else
       
  2492         {
       
  2493         // No stored state, use the parameter supplied one
       
  2494         iControlState = viewState;
       
  2495         }
       
  2496     }
       
  2497 
       
  2498 // --------------------------------------------------------------------------
       
  2499 // CPguGroupMembersView::ReturnToPreviousViewL
       
  2500 // --------------------------------------------------------------------------
       
  2501 //
       
  2502 void CPguGroupMembersView::ReturnToPreviousViewL() const
       
  2503     {
       
  2504     CPbk2ViewState* state = ViewStateLC();
       
  2505     if ( iFocusedGroup )
       
  2506         {
       
  2507         // Change focused contact to current focused contact
       
  2508         state->SetFocusedContact( iFocusedGroup->CloneLC() );
       
  2509         CleanupStack::Pop(); // currentGroup
       
  2510         }
       
  2511     Phonebook2::Pbk2AppUi()->Pbk2ViewExplorer()->
       
  2512         ActivatePreviousViewL( state );
       
  2513     CleanupStack::PopAndDestroy(state);
       
  2514     }
       
  2515 
       
  2516 // End of File