phonebookui/Phonebook2/inc/CPbk2ContactEditorDlg.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 contact editor dialog.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CPBK2CONTACTEDITORDLG_H
       
    20 #define CPBK2CONTACTEDITORDLG_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <babitflags.h>
       
    25 #include <MPbk2ContactRelocatorObserver.h>
       
    26 #include <MPbk2EditedContactObserver.h>
       
    27 #include "TPbk2ContactEditorParams.h"
       
    28 #include "MPbk2ContactEditorContactRelocator.h"
       
    29 #include "MPbk2DialogEliminator.h"
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 class MPbk2ContactEditorStrategy;
       
    33 class CPbk2FieldPropertyArray;
       
    34 class CPbk2StoreSpecificFieldPropertyArray;
       
    35 class CPbk2PresentationContact;
       
    36 class CPbk2ContactEditorDlgImpl;
       
    37 class CPbk2ContactRelocator;
       
    38 class MPbk2ApplicationServices;
       
    39 
       
    40 
       
    41 // CLASS DECLARATION
       
    42 
       
    43 /**
       
    44  * Phonebook 2 contact editor dialog.
       
    45  */
       
    46 class CPbk2ContactEditorDlg : public CBase,
       
    47                               public MPbk2DialogEliminator,
       
    48                               public MPbk2ContactRelocatorObserver,
       
    49                               public MPbk2ContactEditorContactRelocator,
       
    50                               private MPbk2EditedContactObserver
       
    51     {
       
    52     public: // Constructors and destructor
       
    53 
       
    54         /**
       
    55          * Creates a new instance of this class.
       
    56          *
       
    57          * @param aParams   Contact editor parameters.
       
    58          * @param aContact  The contact to edit. Ownership is taken.
       
    59          * @param aObserver Observer for the contact being edited.
       
    60          * @return  A new instance of this class.
       
    61          */
       
    62         IMPORT_C static CPbk2ContactEditorDlg* NewL(
       
    63                 TPbk2ContactEditorParams& aParams,
       
    64                 MVPbkStoreContact* aContact,
       
    65                 MPbk2EditedContactObserver& aContactObserver );
       
    66         
       
    67         /**
       
    68 		* Creates a new instance of this class.
       
    69 		*
       
    70 		* @param aParams   Contact editor parameters.
       
    71 		* @param aContact  The contact to edit. Ownership is taken.
       
    72 		* @param aObserver Observer for the contact being edited.
       
    73 		* @param aAppServices Application services.
       
    74 		* @param aTitleText   ownership is transferred, if function doesn't leave
       
    75 		* @param aEditorFieldsId Supported editor fields resource id (@see PbkPresentation.rss : R_PHONEBOOK_FIELD_PROPERTIES)
       
    76 		* @return  A new instance of this class.
       
    77 		*/
       
    78 	   IMPORT_C static CPbk2ContactEditorDlg* NewL(
       
    79 			   TPbk2ContactEditorParams& aParams,
       
    80 			   MVPbkStoreContact* aContact,
       
    81 			   MPbk2EditedContactObserver& aContactObserver,
       
    82 			   MPbk2ApplicationServices* aAppServices,
       
    83 			   HBufC* aTitleText = NULL,
       
    84 			   TInt aEditorFieldsId = KErrNotFound );
       
    85 
       
    86         /**
       
    87          * Destructor.
       
    88          */
       
    89         virtual ~CPbk2ContactEditorDlg();
       
    90 
       
    91     public: // Interface
       
    92 
       
    93         /**
       
    94          * Executes the dialog.
       
    95          */
       
    96         IMPORT_C void ExecuteLD();
       
    97 
       
    98     public: // From MPbk2DialogEliminator
       
    99         void RequestExitL(
       
   100                 TInt aCommandId );
       
   101         void ForceExit();
       
   102         void ResetWhenDestroyed(
       
   103                 MPbk2DialogEliminator** aSelfPtr );
       
   104         
       
   105     private: // From MPbk2ContactRelocatorObserver
       
   106         void ContactRelocatedL(
       
   107                 MVPbkStoreContact* aRelocatedContact );
       
   108         void ContactRelocationFailed(
       
   109                 TInt aReason,
       
   110                 MVPbkStoreContact* aContact );
       
   111         void ContactsRelocationFailed(
       
   112                 TInt aReason,
       
   113                 CVPbkContactLinkArray* aContacts );
       
   114         void RelocationProcessComplete();
       
   115 
       
   116     private: // From MPbk2ContactEditorContactRelocator
       
   117         TBool RelocateContactL(
       
   118                 TPbk2RelocationQyeryPolicy aQueryPolicy );
       
   119         TBool RelocateContactL(
       
   120                 TInt aAddItemFieldTypeResourceId,
       
   121                 const TDesC& aAddItemXspName,
       
   122                 TPbk2RelocationQyeryPolicy aQueryPolicy );
       
   123         TBool IsPhoneMemoryInConfigurationL();
       
   124         void EditorReadyL();
       
   125 
       
   126     private: // From MPbk2EditedContactObserver
       
   127         void ContactEditingComplete(
       
   128             MVPbkStoreContact* aEditedContact );
       
   129         void ContactEditingDeletedContact(
       
   130             MVPbkStoreContact* aEditedContact );
       
   131         void ContactEditingAborted();
       
   132 
       
   133     private: // Implementation
       
   134         CPbk2ContactEditorDlg(
       
   135                 TPbk2ContactEditorParams& aParams,
       
   136                 MPbk2EditedContactObserver& aContactObserver,
       
   137                 MPbk2ApplicationServices* aAppServices = NULL,
       
   138                 TInt aEditorFieldsId = KErrNotFound );
       
   139         void ConstructL( MVPbkStoreContact* aStoreContact );
       
   140         void HandleRelocationProcessCompleteL();
       
   141         void CreatePresentationContactL();
       
   142         void CreatePresentationContactL(MVPbkStoreContact& aStoreContact);
       
   143         TBool ContinueAfterRelocation();
       
   144         TBool IsTemplateFieldL( TInt aResId, const TDesC& aXSpName );
       
   145 
       
   146     private: // Types
       
   147         /// Relocation states
       
   148         enum TRelocationState
       
   149             {
       
   150             ERelocationDueToItemAddition,
       
   151             ERelocationCancelled,
       
   152             ERelocationFailed
       
   153             };
       
   154 
       
   155     private: // Data
       
   156         /// Own: Editor dialog implementation
       
   157         CPbk2ContactEditorDlgImpl* iImplementation;
       
   158         /// Ref: Dialog eliminator
       
   159         MPbk2DialogEliminator* iEliminator;
       
   160         /// Ref: Editor parameters
       
   161         TPbk2ContactEditorParams& iParams;
       
   162         /// Own: Store contact
       
   163         MVPbkStoreContact* iStoreContact;
       
   164         /// Own: Phonebook 2 field properties
       
   165         CPbk2FieldPropertyArray* iFieldProperties;
       
   166         /// Own: Store specific properties
       
   167         CPbk2StoreSpecificFieldPropertyArray* iSpecificFieldProperties;
       
   168         /// Own: Presentation level contact
       
   169         CPbk2PresentationContact* iContact;
       
   170         /// Ref: Observer for the contact being edited
       
   171         MPbk2EditedContactObserver& iContactObserver;
       
   172         /// Own: A strategy for the editor
       
   173         MPbk2ContactEditorStrategy* iEditorStrategy;
       
   174         /// Own: Add item field type resource id
       
   175         /// used in contact relocation process
       
   176         TInt iAddItemFieldTypeResourceId;
       
   177         /// Own: Add item field type xSP name
       
   178         /// used in contact relocation process
       
   179         HBufC* iAddItemFieldTypeXspName;
       
   180         /// Own: Contact relocator
       
   181         CPbk2ContactRelocator* iContactRelocator;
       
   182         /// Ref: Indicates relocation state
       
   183         TBitFlags8 iRelocationState;
       
   184         /// Ref: A pointer to stack variable in ExecuteLD for knowing
       
   185         /// if the destructor has already been called
       
   186         TBool* iDestroyedPtr;
       
   187         /// Ref: Pointer to dialog eliminator
       
   188         MPbk2DialogEliminator** iSelfPtr;
       
   189         /// Ref: Applications services
       
   190         MPbk2ApplicationServices* iAppServices;
       
   191 		/// Own Custom title text
       
   192 		HBufC* iTitleText;
       
   193 		// REF: Custom editor fields 
       
   194 		TInt iEditorFieldsId;
       
   195 		
       
   196     };
       
   197 
       
   198 #endif // CPBK2CONTACTEDITORDLG_H
       
   199 
       
   200 // End of File