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