1.1 --- a/epoc32/include/app/cpbkcontacteditordlg.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/app/cpbkcontacteditordlg.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,238 @@
1.4 -cpbkcontacteditordlg.h
1.5 +/*
1.6 +* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
1.7 +* All rights reserved.
1.8 +* This component and the accompanying materials are made available
1.9 +* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
1.10 +* which accompanies this distribution, and is available
1.11 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.12 +*
1.13 +* Initial Contributors:
1.14 +* Nokia Corporation - initial contribution.
1.15 +*
1.16 +* Contributors:
1.17 +*
1.18 +* Description:
1.19 +* Phonebook contact editor dialog.
1.20 +*
1.21 +*/
1.22 +
1.23 +
1.24 +#ifndef __CPbkContactEditorDlg_H__
1.25 +#define __CPbkContactEditorDlg_H__
1.26 +
1.27 +// INCLUDES
1.28 +#include <AknForm.h> // CAknForm
1.29 +#include <cntdef.h> // TContactItemId
1.30 +#include <babitflags.h> // TBitFlags
1.31 +
1.32 +
1.33 +// FORWARD DECLARATIONS
1.34 +class CAknTitlePane;
1.35 +class CPbkContextPaneIcon;
1.36 +class CPbkThumbnailPopup;
1.37 +class CPbkThumbnailCmd;
1.38 +class CPbkContactEditorFieldArray;
1.39 +class CPbkContactEngine;
1.40 +class CPbkContactItem;
1.41 +class MPbkContactEditorStrategy;
1.42 +class MPbkEditorOkToExitCallback;
1.43 +class CAknNavigationControlContainer;
1.44 +
1.45 +
1.46 +// CLASS DECLARATION
1.47 +
1.48 +/**
1.49 + * A contact editing dialog implementation. This class can be used
1.50 + * to construct an UI editor dialog that is specifically tailored
1.51 + * to edit contacts in a similar fashion as in the platform contacts
1.52 + * application.
1.53 + */
1.54 +class CPbkContactEditorDlg :
1.55 + public CAknForm
1.56 + {
1.57 + public: // Constructors and destructor
1.58 + /**
1.59 + * Creates an instance of an editor dialog for an aContactItem.
1.60 + *
1.61 + * @param aEngine Phonebook engine
1.62 + * @param aContactItem Contact item to edit
1.63 + * @param aIsNewContact Set to ETrue if aContactItem is a new contact
1.64 + * (not yet in the database)
1.65 + * @param aFocusIndex Optional index of field to focus initially,
1.66 + * default behaviour is to focus the topmost field.
1.67 + * @param aEdited If ETrue sets the contact initially to the edited state.
1.68 + * Use when some data is added to aContactItem
1.69 + * that needs to be saved even if user edits
1.70 + * nothing. Default behaviour is to set the contact to
1.71 + * non-edited state.
1.72 + * @return A new dialog object.
1.73 + */
1.74 + IMPORT_C static CPbkContactEditorDlg* NewL
1.75 + (CPbkContactEngine& aEngine,
1.76 + CPbkContactItem& aContactItem,
1.77 + TBool aIsNewContact,
1.78 + TInt aFocusIndex=-1,
1.79 + TBool aEdited=EFalse);
1.80 +
1.81 + /**
1.82 + * Destructor.
1.83 + */
1.84 + ~CPbkContactEditorDlg();
1.85 +
1.86 + public: // Interface
1.87 + /**
1.88 + * Sets aSelfPtr to NULL when this dialog is destroyed.
1.89 + * @precond Precondition: !aSelfPtr || *aSelfPtr==this
1.90 + */
1.91 + IMPORT_C void ResetWhenDestroyed(CPbkContactEditorDlg** aSelfPtr);
1.92 +
1.93 + /**
1.94 + * Runs the dialog. This object is destroyed when this function
1.95 + * returns or leaves.
1.96 + * NOTE: Current status pane layout is replaced with the
1.97 + * Phonebook one. Restoring the original pane is left to be
1.98 + * the responsibility of the caller.
1.99 + *
1.100 + * @return The id of the saved contact. KNullContactId if not saved.
1.101 + * Please note that the contact item (aContactItem passed
1.102 + * to NewL) might be modified even if it is not saved to the
1.103 + * database.
1.104 + */
1.105 + IMPORT_C TContactItemId ExecuteLD();
1.106 +
1.107 + /**
1.108 + * Hides the 'Exit' command from the options menu. This must be called
1.109 + * before calling ExecuteLD.
1.110 + */
1.111 + IMPORT_C void HideExitCommand();
1.112 +
1.113 + /**
1.114 + * Sets help context. There are many applications using contact editor
1.115 + * and they may have an own help topic to be shown, when editor's help
1.116 + * is launched. With this command it's possible to define the used
1.117 + * help content. If not called after, uses Phonebook's own help context
1.118 + * as default.
1.119 + * @param aContext Help context to use
1.120 + */
1.121 + IMPORT_C void SetHelpContext(TCoeHelpContext aContext);
1.122 +
1.123 + /**
1.124 + * Sets exit callback. The callback is called before exit happens.
1.125 + * If the callback returns EFalse, the exit process is cancelled.
1.126 + * @param aCallback Exit callback
1.127 + */
1.128 + IMPORT_C void SetExitCallback(MPbkEditorOkToExitCallback* aCallback);
1.129 +
1.130 + /**
1.131 + * Sets the exit command in the options menu to forward aCommandId to the
1.132 + * application framework. Allows clients to process and capture the exit
1.133 + * command in the application exit situation.
1.134 + * @param aCommandId Command id to send to the framework when the exit
1.135 + * occurs.
1.136 + */
1.137 + IMPORT_C void SetExitCommandId(TInt aCommandId);
1.138 +
1.139 + private: // from CCoeControl
1.140 + TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
1.141 + void GetHelpContext(TCoeHelpContext& aContext) const;
1.142 +
1.143 + private: // Command handlers
1.144 + void CmdSaveL();
1.145 + void CmdDoneL();
1.146 + void CmdEditItemLabelL();
1.147 + void CmdAddItemL();
1.148 + void CmdDeleteItemL();
1.149 + void CmdFetchThumbnailL();
1.150 + void CmdRemoveThumbnailL();
1.151 +
1.152 + private: // From CAknForm
1.153 + void PreLayoutDynInitL();
1.154 + void PostLayoutDynInitL();
1.155 + void SetInitialCurrentLine();
1.156 + void ProcessCommandL(TInt aCommandId);
1.157 + void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane);
1.158 + TBool OkToExitL(TInt aKeycode);
1.159 + void HandleControlStateChangeL(TInt aControlId);
1.160 +
1.161 + protected: // Constructors
1.162 + CPbkContactEditorDlg
1.163 + (CPbkContactEngine& aEngine,
1.164 + CPbkContactItem& aContactItem,
1.165 + TInt aFocusIndex);
1.166 + void BaseConstructL(TBool aIsNewContact, TBool aEdited);
1.167 +
1.168 + protected: // Implementation
1.169 + void StoreTitlePaneTextL();
1.170 + void ConstructContextMenuL();
1.171 + void ConstructNaviPaneL();
1.172 + TBool IsNewContact() const;
1.173 + void UpdateTitlePaneL();
1.174 + void CloseAllPopups();
1.175 + TBool ContactAlreadyExistsL();
1.176 + TBool DuplicateNameMatchL(CContactIdArray* aIdArray);
1.177 + TBool CheckForDuplicateEntryL();
1.178 + void ReloadThumbnailL();
1.179 +
1.180 + void WriteContactToDbL();
1.181 +
1.182 + /// State flag values for CPbkContactEditorDlg
1.183 + enum TStateFlag
1.184 + {
1.185 + EHideExit, // Hide exit
1.186 + EEscKeyReceived, /// Espace key received
1.187 + EUnderDestruction // The dialog is under destruction
1.188 + };
1.189 +
1.190 + protected: // data
1.191 + /// Ref: Contact item under editing
1.192 + CPbkContactItem& iContactItem;
1.193 + /// Own: Contact editor field manager
1.194 + CPbkContactEditorFieldArray* iFieldManager;
1.195 +
1.196 + private: // Data
1.197 + /// Ref; Contact engine
1.198 + CPbkContactEngine& iEngine;
1.199 + /// Own: Index of field to focus initially
1.200 + TInt iFocusIndex;
1.201 + /// Own: state flags
1.202 + mutable TBitFlags iStateFlags;
1.203 + /// Ref: pointer to ExecuteLD return value
1.204 + TContactItemId* iSavedContactPtr;
1.205 + /// Ref: application's title pane
1.206 + CAknTitlePane* iTitlePane;
1.207 + /// Own: Title pane text to restore on exit
1.208 + HBufC* iStoredTitlePaneText;
1.209 + /// Own: Phonebook context pane icon
1.210 + CPbkContextPaneIcon* iContextPaneIcon;
1.211 + /// Own: Thumbnail image handler
1.212 + CPbkThumbnailPopup* iThumbnailHandler;
1.213 + /// Own: context menu bar
1.214 + CEikMenuBar* iContextMenuBar;
1.215 + /// Own: Thumbnail command handler
1.216 + CPbkThumbnailCmd* iThumbnailCmd;
1.217 + /// Own: editor dialog strategy
1.218 + MPbkContactEditorStrategy* iEditorStrategy;
1.219 + /**
1.220 + * Ref: self pointer for easier leave handling
1.221 + * @invariant !iSelfPtr || *iSelfPtr==this
1.222 + */
1.223 + CPbkContactEditorDlg** iSelfPtr;
1.224 + class CExtension;
1.225 + /// Own: for adding extensions
1.226 + CExtension* iExtension;
1.227 + /// Own: the help context to use
1.228 + TCoeHelpContext iHelpContext;
1.229 + /// Ref: Contact editor exit callback
1.230 + MPbkEditorOkToExitCallback* iExitCallback;
1.231 + /// Own: exit command id
1.232 + TInt iExitCommandId;
1.233 + /// Ref: status pane handle
1.234 + CAknNavigationControlContainer* iNaviContainer;
1.235 +
1.236 + private: // friends
1.237 + friend class CExtension;
1.238 + };
1.239 +
1.240 +#endif // __CPbkContactEditorDlg_H__
1.241 +
1.242 +// End of File