phonebookui/Phonebook2/CommandsExtension/inc/CPbk2CreateNewContactCmd.h
changeset 0 e686773b3f54
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 create new contact command object.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CPBK2CREATENEWCONTACTCMD_H
       
    20 #define CPBK2CREATENEWCONTACTCMD_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <MPbk2Command.h>
       
    25 #include <MPbk2EditedContactObserver.h>
       
    26 #include <MVPbkContactStoreObserver.h>
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 class MPbk2ContactUiControl;
       
    30 class MVPbkContactStore;
       
    31 class MVPbkStoreContact;
       
    32 class MVPbkBaseContactField;
       
    33 class CPbk2ApplicationServices;
       
    34 
       
    35 // CLASS DECLARATION
       
    36 
       
    37 /**
       
    38  * Phonebook 2 create new contact command object.
       
    39  * Responsible for:
       
    40  * - verifying saving store availability and fullness
       
    41  * - displaying information notes  if store is not available or it is full
       
    42  * - creating new contact to the store
       
    43  * - adding possible find text to the created contact's last name field
       
    44  * - verifying synchronization field existence
       
    45  * - launching contact editor for the new contact
       
    46  * - updating UI control after the editor is exited
       
    47  * - notifying command observer when the command is finished
       
    48  */
       
    49 NONSHARABLE_CLASS(CPbk2CreateNewContactCmd) :
       
    50             public CActive,
       
    51             public MPbk2Command,
       
    52             public MPbk2EditedContactObserver,
       
    53             public MVPbkContactStoreObserver
       
    54 
       
    55     {
       
    56     public: // Construction and destruction
       
    57         /**
       
    58          * Creates a new instance of this class.
       
    59          *
       
    60          * @param aUiControl    Contact UI control.
       
    61          * @return  A new instance of this class.
       
    62          */
       
    63         static CPbk2CreateNewContactCmd* NewL(
       
    64                 MPbk2ContactUiControl& aUiControl );
       
    65 
       
    66         /**
       
    67          * Destructor.
       
    68          */
       
    69         virtual ~CPbk2CreateNewContactCmd();
       
    70         
       
    71     private: // From CActive
       
    72         void RunL();        
       
    73         void DoCancel();
       
    74         TInt RunError( TInt aError );
       
    75         void HandleError( TInt aError );
       
    76         
       
    77     public: // From MPbk2Command
       
    78         void ExecuteLD();
       
    79         void AddObserver(MPbk2CommandObserver& aObserver );
       
    80         void ResetUiControl(MPbk2ContactUiControl& aUiControl);
       
    81 
       
    82     private: // From MPbk2EditedContactObserver
       
    83         void ContactEditingComplete(
       
    84                 MVPbkStoreContact* aEditedContact );
       
    85         void ContactEditingDeletedContact(
       
    86                 MVPbkStoreContact* aEditedContact );
       
    87         void ContactEditingAborted();
       
    88         
       
    89     private: // From MVPbkContactStoreObserver
       
    90         void StoreReady( MVPbkContactStore& aContactStore );
       
    91         void StoreUnavailable( 
       
    92                 MVPbkContactStore& aContactStore, 
       
    93                 TInt aReason );
       
    94         void HandleStoreEventL(
       
    95                 MVPbkContactStore& aContactStore, 
       
    96                 TVPbkContactStoreEvent aStoreEvent );
       
    97 
       
    98     private: // Implementation
       
    99         CPbk2CreateNewContactCmd(
       
   100                 MPbk2ContactUiControl& aUiControl );
       
   101         void ConstructL();        
       
   102         TInt AddFindTextL(
       
   103                 MVPbkStoreContact& aContact );
       
   104         void ShowStoreFullNoteL(
       
   105                 const MVPbkContactStore& aTargetStore );
       
   106         void HandleContactEditingCompleteL(
       
   107                 MVPbkStoreContact* aEditedContact );
       
   108         TInt ShowCreateNewToPhoneQueryL() const;
       
   109         void LoadContactStoreL();
       
   110         void OpenContactStoreL();
       
   111         void ValidateStoreL();
       
   112         void CreateNewContactL();
       
   113         void IssueRequest();
       
   114         
       
   115     private: // Data structures
       
   116         /// Process states
       
   117         enum TProcessState
       
   118             {            
       
   119             ELoadContactStore,
       
   120             EOpenContactStore,
       
   121             EValidateStore,
       
   122             ECreateNewContact,
       
   123             EFinishCommand
       
   124             };        
       
   125 
       
   126     private: // Data
       
   127         /// Ref: Contact UI control
       
   128         MPbk2ContactUiControl* iUiControl;
       
   129         /// Ref: Target store
       
   130         MVPbkContactStore* iTargetStore;
       
   131         /// Ref: Command observer
       
   132         MPbk2CommandObserver* iCommandObserver;
       
   133         /// Own: Current state of process
       
   134         TProcessState iState;
       
   135         /// Own: Application Services pointer
       
   136         CPbk2ApplicationServices* iAppServices;
       
   137     };
       
   138 
       
   139 #endif // CPBK2CREATENEWCONTACTCMD_H
       
   140 
       
   141 // End of File