phonebookui/Phonebook2/inc/CPbk2FetchDlg.h
changeset 0 e686773b3f54
child 15 e8e3147d53eb
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2005-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 fetch dialog.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CPBK2FETCHDLG_H
       
    20 #define CPBK2FETCHDLG_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <AknDialog.h>
       
    24 #include "MPbk2FetchDlg.h"
       
    25 #include "MPbk2FetchResultsObserver.h"
       
    26 #include <MPbk2DialogEliminator.h>
       
    27 #include <babitflags.h>
       
    28 
       
    29 //  FORWARD DECLARATIONS
       
    30 class CVPbkContactLinkArray;
       
    31 class CAknNavigationDecorator;
       
    32 class MPbk2FetchDlgPages;
       
    33 class MVPbkContactOperationBase;
       
    34 class MPbk2ContactUiControl;
       
    35 class MVPbkViewContact;
       
    36 class MPbk2ExitCallback;
       
    37 class CPbk2FetchResults;
       
    38 class CPbk2NamesListControl;
       
    39 
       
    40 // CLASS DECLARATIONS
       
    41 
       
    42 /**
       
    43  * Phonebook 2 fetch dialog.
       
    44  * Responsible for:
       
    45  * - presenting a fetch dialog for the user
       
    46  * - managing dialog pages
       
    47  * - handling select/deselect of contacts
       
    48  */
       
    49 class CPbk2FetchDlg : public CAknDialog,
       
    50                       public MPbk2FetchDlg,
       
    51                       public MPbk2DialogEliminator,
       
    52                       private MPbk2FetchResultsObserver
       
    53     {
       
    54     public: // Data structures
       
    55 
       
    56         /**
       
    57          * Fetch parameter flags.
       
    58          */
       
    59         enum TFetchFlags
       
    60             {
       
    61             /// Multiple entry fetch
       
    62             EFetchMultiple  = 0x0001,
       
    63             /// Single entry fetch
       
    64             EFetchSingle    = 0x0002,
       
    65             /// Call item fetch
       
    66             EFetchCallItem  = 0x0004
       
    67             };
       
    68 
       
    69         /**
       
    70          * Exit parameter flags
       
    71          */
       
    72        enum TExitState
       
    73             {
       
    74             EExitOrdered,
       
    75             EExitApproved,
       
    76             EOkToExitWithoutHandlingIt
       
    77             };
       
    78 
       
    79         /**
       
    80          * Fetch parameters struct.
       
    81          * Parameters specify the fetch return value.
       
    82          */
       
    83         class TParams
       
    84             {
       
    85             public: // Interface
       
    86 
       
    87                 /**
       
    88                  * Constructor.
       
    89                  */
       
    90                 IMPORT_C TParams();
       
    91 
       
    92                 /**
       
    93                  * Returns a cleanup item which will release all resources
       
    94                  * held by this object in case a leave occurs.
       
    95                  */
       
    96                 IMPORT_C operator TCleanupItem();
       
    97 
       
    98             private: // Implementation
       
    99                 static void Cleanup(
       
   100                         TAny* aPtr );
       
   101 
       
   102             private: // Unimplemented
       
   103                 /// Unimplemented assignment operator
       
   104                 TParams& operator=(
       
   105                         const TParams& );
       
   106 
       
   107             public: // Input parameters
       
   108                 /// Own: Fetch flags, defaults to EFetchSingle
       
   109                 /// @see TFetchFlags
       
   110                 TUint iFlags;
       
   111                 /// Own: PBK2_FETCH_DIALOG resource id
       
   112                 /// Defaults to r_pbk2_single_entry_fetch_dlg
       
   113                 TInt iResId;
       
   114                 /// Ref: Pre-marked entries
       
   115                 MVPbkContactLinkArray* iMarkedEntries;
       
   116                 /// Ref: The contact view shown in the names list page
       
   117                 MVPbkContactViewBase* iNamesListView;
       
   118                 /// Ref: The contact view shown in the groups list page
       
   119                 MVPbkContactViewBase* iGroupsListView;
       
   120                 /// Own: Optional fetch softkey resource id
       
   121                 TInt iCbaId;
       
   122                 /// Own: Optional navi pane resource id
       
   123                 TInt iNaviPaneId;
       
   124                 /// Ref: Exit callback
       
   125                 MPbk2ExitCallback* iExitCallback;
       
   126             };
       
   127 
       
   128     public: // Construction and destruction
       
   129 
       
   130         /**
       
   131          * Creates a new instance of this class.
       
   132          *
       
   133          * @param aParams   The fetch parameters.
       
   134          * @param aObserver Fetch observer.
       
   135          * @return  A new instance of this class.
       
   136          */
       
   137         IMPORT_C static CPbk2FetchDlg* NewL(
       
   138                 TParams aParams,
       
   139                 MPbk2FetchDlgObserver& aObserver );
       
   140 
       
   141         /**
       
   142          * Destructor.
       
   143          */
       
   144         ~CPbk2FetchDlg();
       
   145 
       
   146     public: // Interface
       
   147 
       
   148         /**
       
   149          * Marks the given contact as selected.
       
   150          *
       
   151          * @param aContactLink  Link to a contact to select.
       
   152          */
       
   153         IMPORT_C void AcceptDelayedFetchL(
       
   154                 const TDesC8& aContactLink );
       
   155 
       
   156     public: // From CEikDialog
       
   157         IMPORT_C TInt ExecuteLD();
       
   158 
       
   159     public: // From MPbk2DialogEliminator
       
   160         void RequestExitL(
       
   161                 TInt aCommandId );
       
   162         void ForceExit();
       
   163         void ResetWhenDestroyed(
       
   164                 MPbk2DialogEliminator** aSelfPtr );
       
   165 
       
   166     private: // From CEikDialog
       
   167         SEikControlInfo CreateCustomControlL(
       
   168                 TInt aControlType );
       
   169         void PreLayoutDynInitL();
       
   170         TBool OkToExitL(
       
   171                 TInt aButtonId );
       
   172         void PageChangedL(
       
   173                 TInt aPageId );
       
   174         TKeyResponse OfferKeyEventL(
       
   175                 const TKeyEvent& aKeyEvent,
       
   176                 TEventCode aType );
       
   177         void HandleResourceChange(
       
   178                 TInt aType );
       
   179         void LineChangedL(
       
   180                 TInt aControlId );
       
   181 
       
   182     private: // From MPbk2FetchDlg
       
   183         CCoeControl* FetchDlgControl(
       
   184                 TInt aCtrlId ) const;
       
   185         MVPbkContactViewBase& FetchDlgViewL(
       
   186                 TInt aControlId ) const;
       
   187         void SetFetchDlgViewL(
       
   188                 TInt aControlId,
       
   189                 MVPbkContactViewBase& aView );
       
   190         MVPbkContactLinkArray& FetchDlgSelection();
       
   191         void FetchDlgHandleError(
       
   192                 TInt aError );
       
   193         TRect FetchDlgClientRect() const;
       
   194         void FetchDlgPageChangedL(
       
   195                 MPbk2FetchDlgPage& aPage );
       
   196         MPbk2FetchDlgObserver& FetchDlgObserver() const;
       
   197         void SelectContactL(
       
   198                 const MVPbkContactLink& aLink,
       
   199                 TBool aSelected );
       
   200 
       
   201     private: // From MPbk2ControlObserver
       
   202         void HandleControlEventL(
       
   203                 MPbk2ContactUiControl& aControl,
       
   204                 const TPbk2ControlEvent& aEvent );
       
   205 
       
   206     private: // From MPbk2FetchResultsObserver
       
   207         void ContactSelected(
       
   208                 const MVPbkContactLink& aLink,
       
   209                 TBool aSelected );
       
   210         void ContactSelectionFailed();
       
   211 
       
   212     private: // Implementation
       
   213         CPbk2FetchDlg(
       
   214                 TParams aParams,
       
   215                 MPbk2FetchDlgObserver& aObserver );
       
   216         void ConstructL();
       
   217         void SetCbaCommandSetL(
       
   218                 TInt aResourceId );
       
   219         void SetupStatusPaneL();
       
   220         void UpdateCbasL();
       
   221         void UpdateMultiSelectionMSKL(
       
   222                 TBool aContactSelected );
       
   223         void RemoveCommandFromMSK();
       
   224         void SetMiddleSoftKeyLabelL(
       
   225                 const TInt aResourceId,
       
   226                 const TInt aCommandId );
       
   227         static TInt TryAcceptSelectionL(
       
   228                 TAny* aSelf );
       
   229         TBool CheckIsOkToExitL(
       
   230                 TInt aButtonId );
       
   231         TBool Canceled(
       
   232                 TInt aButtonId );
       
   233         void SkinTabsL();
       
   234         static TInt DelaySkinning(
       
   235                 TAny* aFetchDlg );
       
   236         static TInt RestoreSelections(
       
   237                 TAny* aFetchDlg );
       
   238         void RestoreSelectionsL();
       
   239         TBool OkToExitApplicationL(
       
   240                 TInt aCommandId );
       
   241         void ExitApplication(
       
   242                 TInt aCommandId );
       
   243 
       
   244     private: // Types and data structures
       
   245         /// Resource data, see PBK2_FETCHENTRY_DIALOG.
       
   246         struct TResData
       
   247             {
       
   248             /**
       
   249              * Reads the data from resources.
       
   250              *
       
   251              * @param aReader   Resource reader pointed
       
   252              *                  to PBK2_FETCHENTRY_DIALOG resource.
       
   253              */
       
   254             void ReadFromResource(
       
   255                     TResourceReader& aReader );
       
   256 
       
   257             /// Own: Dialog resource id
       
   258             TInt iDialogId;
       
   259             /// Own: CBA resource id
       
   260             TInt iCbaId;
       
   261             /// Own: Empty CBA resource id
       
   262             TInt iEmptyCbaId;
       
   263             /// Own: Navi pane resource id
       
   264             TInt iNaviPaneId;
       
   265             };
       
   266 
       
   267     private: // Data
       
   268         /// Own: Parameters
       
   269         TParams iParams;
       
   270         /// Own: Resource data
       
   271         TResData iResData;
       
   272         /// Own: Navi pane control
       
   273         CAknNavigationDecorator* iNaviDecorator;
       
   274         /// Ref: Set to NULL when this dialog is destroyed
       
   275         MPbk2DialogEliminator** iSelfPtr;
       
   276         /// Ref: Set to ETrue when the execution enters destructor
       
   277         TBool* iDestroyedPtr;
       
   278         /// Own: Dialog pages
       
   279         MPbk2FetchDlgPages* iPages;
       
   280         /// Own: Current CBA command set
       
   281         TInt iCbaCommandSet;
       
   282         /// Ref: Observer
       
   283         MPbk2FetchDlgObserver& iObserver;
       
   284         /// Own: Exit handling
       
   285         TBitFlags8 iExitRecord;
       
   286         /// Own: Dialog accepter
       
   287         CAsyncCallBack* iDialogAccepter;
       
   288         /// Own: Delay for tab skinning
       
   289         CIdle* iTabSkinDelay;
       
   290         /// Own: Fetch results
       
   291         CPbk2FetchResults* iResults;
       
   292         /// Own: Link to focused contact
       
   293         MVPbkContactLink* iFocusedContactLink;
       
   294         /// Own: Delay for restoring selections
       
   295         CIdle* iSelectionRestorer;
       
   296         /// Own: Set to EFalse if MSK is not enabled in the current layout
       
   297         TBool iMSKEnabled;
       
   298         /// Not own: Names list control
       
   299         CPbk2NamesListControl* iNamesListControl;
       
   300         /// Not own: Group list control
       
   301         CPbk2NamesListControl* iGroupListControl;
       
   302     };
       
   303 
       
   304 #endif // CPBK2FETCHDLG_H
       
   305 
       
   306 // End of File