epoc32/include/app/cpbkcontacteditordlg.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2 * Copyright (c) 2002 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: 
    15 *     Phonebook contact editor dialog.
    16 *
    17 */
    18 
    19 
    20 #ifndef __CPbkContactEditorDlg_H__
    21 #define __CPbkContactEditorDlg_H__
    22 
    23 //  INCLUDES
    24 #include <AknForm.h>    // CAknForm
    25 #include <cntdef.h>     // TContactItemId
    26 #include <babitflags.h>     // TBitFlags
    27 
    28 
    29 // FORWARD DECLARATIONS
    30 class CAknTitlePane;
    31 class CPbkContextPaneIcon;
    32 class CPbkThumbnailPopup;
    33 class CPbkThumbnailCmd;
    34 class CPbkContactEditorFieldArray;
    35 class CPbkContactEngine;
    36 class CPbkContactItem;
    37 class MPbkContactEditorStrategy;
    38 class MPbkEditorOkToExitCallback;
    39 class CAknNavigationControlContainer;
    40 
    41 
    42 // CLASS DECLARATION
    43 
    44 /**
    45  * A contact editing dialog implementation. This class can be used
    46  * to construct an UI editor dialog that is specifically tailored
    47  * to edit contacts in a similar fashion as in the platform contacts
    48  * application. 
    49  */
    50 class CPbkContactEditorDlg :
    51         public CAknForm
    52     {
    53     public:  // Constructors and destructor
    54         /**
    55          * Creates an instance of an editor dialog for an aContactItem.
    56          *
    57          * @param aEngine   Phonebook engine
    58          * @param aContactItem  Contact item to edit
    59          * @param aIsNewContact Set to ETrue if aContactItem is a new contact
    60          *        (not yet in the database)
    61          * @param aFocusIndex   Optional index of field to focus initially, 
    62          *                      default behaviour is to focus the topmost field.
    63          * @param aEdited   If ETrue sets the contact initially to the edited state.
    64          *        Use when some data is added to aContactItem
    65          *        that needs to be saved even if user edits
    66          *        nothing. Default behaviour is to set the contact to 
    67          *        non-edited state.
    68          * @return A new dialog object.
    69          */
    70         IMPORT_C static CPbkContactEditorDlg* NewL
    71             (CPbkContactEngine& aEngine,
    72             CPbkContactItem& aContactItem,
    73             TBool aIsNewContact,
    74             TInt aFocusIndex=-1,
    75             TBool aEdited=EFalse);
    76 
    77         /**
    78          * Destructor.
    79          */
    80         ~CPbkContactEditorDlg();
    81 
    82     public:  // Interface
    83         /**
    84          * Sets aSelfPtr to NULL when this dialog is destroyed.
    85          * @precond Precondition: !aSelfPtr || *aSelfPtr==this
    86          */
    87         IMPORT_C void ResetWhenDestroyed(CPbkContactEditorDlg** aSelfPtr);
    88 
    89         /**
    90          * Runs the dialog. This object is destroyed when this function
    91          * returns or leaves.
    92          * NOTE: Current status pane layout is replaced with the
    93          *       Phonebook one. Restoring the original pane is left to be
    94          *       the responsibility of the caller.
    95          *
    96          * @return  The id of the saved contact. KNullContactId if not saved.
    97          *          Please note that the contact item (aContactItem passed
    98          *          to NewL) might be modified even if it is not saved to the
    99          *          database.
   100          */
   101         IMPORT_C TContactItemId ExecuteLD();
   102 
   103         /**
   104          * Hides the 'Exit' command from the options menu. This must be called
   105          * before calling ExecuteLD.
   106          */
   107         IMPORT_C void HideExitCommand();
   108 
   109         /**
   110          * Sets help context. There are many applications using contact editor
   111          * and they may have an own help topic to be shown, when editor's help
   112          * is launched. With this command it's possible to define the used
   113          * help content. If not called after, uses Phonebook's own help context
   114          * as default.
   115          * @param aContext Help context to use
   116          */
   117         IMPORT_C void SetHelpContext(TCoeHelpContext aContext);
   118 
   119         /**
   120          * Sets exit callback. The callback is called before exit happens.
   121          * If the callback returns EFalse, the exit process is cancelled.
   122          * @param aCallback Exit callback
   123          */
   124         IMPORT_C void SetExitCallback(MPbkEditorOkToExitCallback* aCallback);
   125 
   126         /**
   127          * Sets the exit command in the options menu to forward aCommandId to the
   128          * application framework. Allows clients to process and capture the exit 
   129          * command in the application exit situation.
   130          * @param aCommandId    Command id to send to the framework when the exit
   131          *                      occurs.
   132          */
   133         IMPORT_C void SetExitCommandId(TInt aCommandId);
   134 
   135     private:  // from CCoeControl
   136         TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
   137         void GetHelpContext(TCoeHelpContext& aContext) const;
   138 
   139     private:  // Command handlers
   140         void CmdSaveL();
   141         void CmdDoneL();
   142         void CmdEditItemLabelL();
   143         void CmdAddItemL();
   144         void CmdDeleteItemL();
   145         void CmdFetchThumbnailL();
   146         void CmdRemoveThumbnailL();
   147 
   148     private:  // From CAknForm
   149         void PreLayoutDynInitL();
   150         void PostLayoutDynInitL();
   151         void SetInitialCurrentLine();
   152         void ProcessCommandL(TInt aCommandId);
   153         void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane);
   154         TBool OkToExitL(TInt aKeycode);
   155         void HandleControlStateChangeL(TInt aControlId);
   156 
   157     protected:  // Constructors
   158         CPbkContactEditorDlg
   159             (CPbkContactEngine& aEngine,
   160             CPbkContactItem& aContactItem,
   161             TInt aFocusIndex);
   162         void BaseConstructL(TBool aIsNewContact, TBool aEdited);
   163 
   164     protected:  // Implementation
   165         void StoreTitlePaneTextL();
   166         void ConstructContextMenuL();
   167         void ConstructNaviPaneL();
   168         TBool IsNewContact() const;
   169         void UpdateTitlePaneL();
   170         void CloseAllPopups();
   171         TBool ContactAlreadyExistsL(); 
   172         TBool DuplicateNameMatchL(CContactIdArray* aIdArray); 
   173         TBool CheckForDuplicateEntryL(); 
   174 	    void ReloadThumbnailL();
   175 
   176         void WriteContactToDbL();
   177 
   178         /// State flag values for CPbkContactEditorDlg
   179         enum TStateFlag
   180             {
   181             EHideExit, // Hide exit
   182             EEscKeyReceived, /// Espace key received
   183             EUnderDestruction // The dialog is under destruction
   184             };
   185 
   186     protected: // data
   187         /// Ref: Contact item under editing
   188         CPbkContactItem& iContactItem;
   189         /// Own: Contact editor field manager
   190         CPbkContactEditorFieldArray* iFieldManager;
   191 
   192     private:  // Data
   193         /// Ref; Contact engine
   194         CPbkContactEngine& iEngine;
   195         /// Own: Index of field to focus initially
   196         TInt iFocusIndex;
   197         /// Own: state flags
   198         mutable TBitFlags iStateFlags;
   199         /// Ref: pointer to ExecuteLD return value
   200         TContactItemId* iSavedContactPtr;
   201         /// Ref: application's title pane
   202         CAknTitlePane* iTitlePane;
   203         /// Own: Title pane text to restore on exit
   204         HBufC* iStoredTitlePaneText;
   205         /// Own: Phonebook context pane icon
   206         CPbkContextPaneIcon* iContextPaneIcon;
   207         /// Own: Thumbnail image handler
   208         CPbkThumbnailPopup* iThumbnailHandler;
   209         /// Own: context menu bar
   210         CEikMenuBar* iContextMenuBar;
   211         /// Own: Thumbnail command handler
   212         CPbkThumbnailCmd* iThumbnailCmd;
   213         /// Own: editor dialog strategy
   214         MPbkContactEditorStrategy* iEditorStrategy;
   215         /**
   216          * Ref: self pointer for easier leave handling
   217          * @invariant !iSelfPtr || *iSelfPtr==this
   218          */
   219         CPbkContactEditorDlg** iSelfPtr;
   220         class CExtension;
   221         /// Own: for adding extensions
   222         CExtension* iExtension;
   223         /// Own: the help context to use
   224         TCoeHelpContext iHelpContext;
   225         /// Ref: Contact editor exit callback
   226         MPbkEditorOkToExitCallback* iExitCallback;
   227         /// Own: exit command id
   228         TInt iExitCommandId;
   229         /// Ref: status pane handle
   230         CAknNavigationControlContainer* iNaviContainer;
   231 
   232     private: // friends
   233         friend class CExtension;
   234      };
   235 
   236 #endif // __CPbkContactEditorDlg_H__
   237 
   238 // End of File