phonebookui/Phonebook2/GroupExtension/inc/CPguRemoveFromGroupCmd.h
changeset 0 e686773b3f54
child 74 6b5524b4f673
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 Group UI Extension remove from group command.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CPGUREMOVEFROMGROUPCMD_H
       
    20 #define CPGUREMOVEFROMGROUPCMD_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <AknProgressDialog.h> // MProgressDialogCallback
       
    25 #include <MPbk2Command.h>
       
    26 #include <CPbk2FetchDlg.h>
       
    27 #include <MVPbkContactObserver.h>
       
    28 #include <MVPbkSingleContactOperationObserver.h>
       
    29 #include <MVPbkContactViewObserver.h>
       
    30 #include <MVPbkContactSelector.h>
       
    31 
       
    32 // FORWARD DECLARATIONS
       
    33 class MPbk2ContactUiControl;
       
    34 class MVPbkContactGroup;
       
    35 class MVPbkContactStore;
       
    36 class MVPbkContactLink;
       
    37 class MVPbkContactLinkArray;
       
    38 class MVPbkContactOperationBase;
       
    39 class MVPbkContactViewBase;
       
    40 class CEikProgressInfo;
       
    41 class CAknProgressDialog;
       
    42 class CAknInputBlock;
       
    43 
       
    44 /**
       
    45  * Phonebook 2 progress dialog
       
    46  * If end call key is pressed,it will destroy itself in any case.
       
    47  */
       
    48 class CPbk2AknProgressDialog : 
       
    49         public CAknProgressDialog
       
    50     {
       
    51     public: // Construction and destruction     
       
    52         /**
       
    53          * Constructor
       
    54          *   Use this if the length of the process is unknown but the progress
       
    55          *   can be calculated.
       
    56          * @param    aSelfPtr        Pointer to itself. The pointer must be
       
    57          *                           valid when the dialog is dismissed and it must
       
    58          *                           not be on the stack.
       
    59          * @param    aVisibilityDelayOff If set ETrue the dialog will be visible
       
    60          *                                   immediality. Use only when the length of
       
    61          *                                   the process is ALWAYS over 1.5 seconds.
       
    62          */
       
    63         CPbk2AknProgressDialog(CEikDialog** aSelfPtr,TBool aVisibilityDelayOff);
       
    64 
       
    65         /**
       
    66          * Destructor
       
    67          */
       
    68         virtual ~CPbk2AknProgressDialog();
       
    69         	
       
    70     public: // From CAknProgressDialog
       
    71         /**
       
    72          *  Handle key events (part of CONE framework)
       
    73          */
       
    74        TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
       
    75                 
       
    76     protected: // From CAknProgressDialog 
       
    77         /**
       
    78          * Called by the dialog framework, returns true if the 
       
    79          * dialog can exit, false otherwise.
       
    80          *
       
    81          * @param aButtonId  Id of the softkey which was pressed
       
    82          * @return           ETrue if the dialog can exit, false otherwise.
       
    83          */
       
    84     TBool OkToExitL(TInt aButtonId);
       
    85                 
       
    86     private: // Data
       
    87         /// Own: The flag indicates if the end call key pressed
       
    88         TBool iEndCallKeyPressed; 
       
    89     };
       
    90 
       
    91 /**
       
    92  * Phonebook 2 Group UI Extension remove from group command.
       
    93  */
       
    94 class CPguRemoveFromGroupCmd : 
       
    95         public CActive,
       
    96         public MPbk2Command,
       
    97         private MVPbkSingleContactOperationObserver,
       
    98         private MVPbkContactObserver,
       
    99         private MVPbkContactViewObserver,
       
   100         private MProgressDialogCallback
       
   101 
       
   102     {
       
   103     public: // Construction and destruction
       
   104 
       
   105         /**
       
   106          * Creates a new instance of this class.
       
   107          *
       
   108          * @param aGroup        Link to the group to remove.
       
   109          * @param aUiControl    Contact UI control.
       
   110          * @return  A new instance of this class.
       
   111          */
       
   112         static CPguRemoveFromGroupCmd* NewLC(
       
   113                 MVPbkContactLink& aGroup,
       
   114                 MPbk2ContactUiControl& aUiControl );
       
   115 
       
   116         /**
       
   117          * Destructor.
       
   118          */
       
   119         ~CPguRemoveFromGroupCmd();
       
   120 
       
   121     public: // From MPbk2Command
       
   122         void ExecuteLD();
       
   123         void AddObserver(
       
   124                 MPbk2CommandObserver& aObserver );
       
   125         void ResetUiControl(
       
   126                 MPbk2ContactUiControl& aUiControl );
       
   127 
       
   128     private: // From CActive
       
   129         void DoCancel();
       
   130         void RunL();
       
   131         TInt RunError(
       
   132                 TInt aError );
       
   133 
       
   134     private: // From MVPbkSingleContactOperationObserver
       
   135         void VPbkSingleContactOperationComplete(
       
   136                 MVPbkContactOperationBase& aOperation,
       
   137                 MVPbkStoreContact* aContact );
       
   138         void VPbkSingleContactOperationFailed(
       
   139                 MVPbkContactOperationBase& aOperation,
       
   140                 TInt aError );
       
   141 
       
   142     private: // From MVPbkContactObserver
       
   143         void ContactOperationCompleted(
       
   144                 TContactOpResult aResult );
       
   145         void ContactOperationFailed(
       
   146                 TContactOp aOpCode,
       
   147                 TInt aErrorCode,
       
   148                 TBool aErrorNotified );
       
   149 
       
   150     private: // From MVPbkContactViewObserver
       
   151         void ContactViewReady(
       
   152                 MVPbkContactViewBase& aView );
       
   153         void ContactViewUnavailable(
       
   154                 MVPbkContactViewBase& aView );
       
   155         void ContactAddedToView(
       
   156                 MVPbkContactViewBase& aView,
       
   157                 TInt aIndex,
       
   158                 const MVPbkContactLink& aContactLink );
       
   159         void ContactRemovedFromView(
       
   160                 MVPbkContactViewBase& aView,
       
   161                 TInt aIndex,
       
   162                 const MVPbkContactLink& aContactLink );
       
   163         void ContactViewError(
       
   164                 MVPbkContactViewBase& aView,
       
   165                 TInt aError,
       
   166                 TBool aErrorNotified );
       
   167 
       
   168     private: // From MProgressDialogCallback
       
   169         void DialogDismissedL(
       
   170                 TInt aButtonId );
       
   171 
       
   172     private:  // Implementation
       
   173         CPguRemoveFromGroupCmd(
       
   174                 MVPbkContactLink& aContactGroup,
       
   175                 MPbk2ContactUiControl& aUiControl );
       
   176         void ConstructL();
       
   177         TBool MoreContactsToRemove() const;
       
   178         TBool IsProcessDone() const;
       
   179         void StepL();
       
   180         void IssueRequest();
       
   181         void CompleteL();
       
   182         void CompleteWithError();
       
   183         void DeleteProgressNoteL();
       
   184         void RetrieveContactL(
       
   185                 const MVPbkContactLink& aContactLink );
       
   186         void ConfirmRemovingL();
       
   187         void InitProgressDlgL();
       
   188         void HandleRemovingL();
       
   189         void ReactivateUIBlockL();
       
   190 
       
   191     private: // Data structures
       
   192         /// Process states
       
   193         enum TProcessState
       
   194             {
       
   195             ERetrieving,
       
   196             EConfirming,
       
   197             ERetrievingGroupContact,
       
   198             ERemoving,
       
   199             ECompleting,
       
   200             ECompletingWithError
       
   201             };
       
   202 
       
   203     private: // Data
       
   204         /// Ref: UI control
       
   205         MPbk2ContactUiControl* iUiControl;
       
   206         /// Ref: Command observer
       
   207         MPbk2CommandObserver* iCommandObserver;
       
   208         /// Own: Retrieve operation
       
   209         MVPbkContactOperationBase* iRetrieveOperation;
       
   210         /// Ref: A group where to add members
       
   211         MVPbkContactLink& iGroupLink;
       
   212         /// Own: Contact group
       
   213         MVPbkContactGroup* iContactGroup;
       
   214         /// Own: Contacts to be removed
       
   215         MVPbkContactLinkArray* iSelectedContacts;
       
   216         /// Ref: Focused contact
       
   217         const MVPbkBaseContact* iFocusedContact;
       
   218         /// Ref: Progress dialog info
       
   219         CEikProgressInfo* iProgressDlgInfo;
       
   220         /// Own: Indicates whether this object has been destroyed
       
   221         TBool iDestroyed;
       
   222         /// Own: Progress note dialog
       
   223         CAknProgressDialog* iProgressDialog;
       
   224         /// Own: Count of contacts succesfully removed
       
   225         TInt iRemovedCount;
       
   226         /// Own: Dialog dismissed flag
       
   227         TBool iDialogDismissed;
       
   228         /// Own: Contacts to remove count
       
   229         TInt iTotalContactsToRemove;
       
   230         /// Own: Store contact
       
   231         MVPbkStoreContact* iStoreContact;
       
   232         /// Own: Current state of process
       
   233         TProcessState iState;
       
   234         /// Own: Initially focused contact index
       
   235         TInt iFocusedContactIndex;
       
   236         // Own: User input blocker
       
   237         CAknInputBlock* iInputBlock;
       
   238     };
       
   239 
       
   240 #endif // CPGUREMOVEFROMGROUPCMD_H
       
   241 
       
   242 // End of File