|
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 implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CPBK2CONTACTEDITORDLGIMPL_H |
|
20 #define CPBK2CONTACTEDITORDLGIMPL_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <AknForm.h> |
|
24 #include <babitflags.h> |
|
25 #include <coeutils.h> |
|
26 #include <MPbk2ContactEditorControl.h> |
|
27 #include "MPbk2ContactEditorUiBuilder.h" |
|
28 #include "MPbk2ContactEditorUiBuilderExtension.h" |
|
29 #include "MPbk2ContactEditorControlExtension.h" |
|
30 #include "MPbk2ContactEditorEventObserver.h" |
|
31 #include "MPbk2DialogEliminator.h" |
|
32 #include "TPbk2ContactEditorParams.h" |
|
33 #include <MVPbkContactStoreObserver.h> |
|
34 #include "MPbk2BaseCommand.h" |
|
35 #include "MPbk2ImageFieldObserver.h" |
|
36 |
|
37 // FORWARD DECLARATIONS |
|
38 class CAknTitlePane; |
|
39 class MPbk2ContactEditorStrategy; |
|
40 class CPbk2FieldPropertyArray; |
|
41 class CPbk2PresentationContact; |
|
42 class CPbk2ContactEditorFieldArray; |
|
43 class MPbk2ContactNameFormatter; |
|
44 class CPbk2UIExtensionManager; |
|
45 class MPbk2ContactEditorExtension; |
|
46 class MPbk2EditedContactObserver; |
|
47 class MPbk2ContactEditorContactRelocator; |
|
48 class CAknNavigationControlContainer; |
|
49 class MPbk2ContactEditorUIField; |
|
50 class CPbk2ContactEditorFieldFactory; |
|
51 class CAknNavigationDecorator; |
|
52 class CPbk2ContactEditorArrayItem; |
|
53 class CAknInputBlock; |
|
54 class MPbk2ApplicationServices; |
|
55 |
|
56 // CLASS DECLARATION |
|
57 |
|
58 /** |
|
59 * Phonebook 2 contact editor dialog implementation. |
|
60 */ |
|
61 class CPbk2ContactEditorDlgImpl : public CAknForm, |
|
62 public MPbk2ContactEditorUiBuilder, |
|
63 public MPbk2ContactEditorUiBuilderExtension, |
|
64 public MPbk2ContactEditorEventObserver, |
|
65 public MPbk2DialogEliminator, |
|
66 public MPbk2ContactEditorControl, |
|
67 public MPbk2ContactEditorControlExtension, |
|
68 public MVPbkContactStoreObserver, |
|
69 public MPbk2ImageFieldObserver |
|
70 { |
|
71 public: // Constructors and destructor |
|
72 |
|
73 /** |
|
74 * Creates a new instance of this class. |
|
75 * |
|
76 * @param aParams Contact editor parameters. |
|
77 * @param aContact The contact to edit. |
|
78 * @param aFieldProperties Field properties. |
|
79 * @param aContactObserver Observer for the contact being edited. |
|
80 * @param aEditorStrategy Contact editing strategy. |
|
81 * @param aRelocator Contact relocator. |
|
82 * @return A new instance of this class. |
|
83 */ |
|
84 static CPbk2ContactEditorDlgImpl* NewL( |
|
85 TPbk2ContactEditorParams& aParams, |
|
86 CPbk2PresentationContact& aContact, |
|
87 CPbk2FieldPropertyArray& aFieldProperties, |
|
88 MPbk2EditedContactObserver& aContactObserver, |
|
89 MPbk2ContactEditorStrategy& aEditorStrategy, |
|
90 MPbk2ContactEditorContactRelocator& aRelocator ); |
|
91 |
|
92 /** |
|
93 * Creates a new instance of this class. |
|
94 * |
|
95 * @param aParams Contact editor parameters. |
|
96 * @param aContact The contact to edit. |
|
97 * @param aFieldProperties Field properties. |
|
98 * @param aContactObserver Observer for the contact being edited. |
|
99 * @param aEditorStrategy Contact editing strategy. |
|
100 * @param aRelocator Contact relocator. |
|
101 * @param aAppServices Pointer to Pbk2 application services |
|
102 * @param aTitleText ownership is transferred |
|
103 * @return A new instance of this class. |
|
104 */ |
|
105 static CPbk2ContactEditorDlgImpl* NewL( |
|
106 TPbk2ContactEditorParams& aParams, |
|
107 CPbk2PresentationContact& aContact, |
|
108 CPbk2FieldPropertyArray& aFieldProperties, |
|
109 MPbk2EditedContactObserver& aContactObserver, |
|
110 MPbk2ContactEditorStrategy& aEditorStrategy, |
|
111 MPbk2ContactEditorContactRelocator& aRelocator, |
|
112 MPbk2ApplicationServices* aAppServices, |
|
113 HBufC* aTitleText = NULL ); |
|
114 |
|
115 /** |
|
116 * Destructor. |
|
117 */ |
|
118 virtual ~CPbk2ContactEditorDlgImpl(); |
|
119 |
|
120 public: // Interface |
|
121 |
|
122 /** |
|
123 * Executes the dialog. |
|
124 */ |
|
125 void ExecuteLD(); |
|
126 |
|
127 /** |
|
128 * Adds item to the contact. If the given parameter is KErrNotFound |
|
129 * the add item dialog is run and the user selects the field type. |
|
130 * |
|
131 * @param aFieldTypeResourceId Specifies the field type to add. |
|
132 * @param aFieldTypeXspName Field type xSP name. |
|
133 */ |
|
134 void AddItemToContactL( |
|
135 TInt aFieldTypeResourceId, |
|
136 const TDesC& aFieldTypeXspName, |
|
137 TBool aSetFocus = ETrue ); |
|
138 |
|
139 /** |
|
140 * Closes an executing dialog nicely with TryExitL and |
|
141 * without saving any contact data. |
|
142 * |
|
143 * @param aInformObserver Indicates whether the observer |
|
144 * should be informed about dialog |
|
145 * closure. |
|
146 */ |
|
147 void CloseWithoutSaving( TBool aInformObserver ); |
|
148 |
|
149 /** |
|
150 * Tries to set the focus to the first field which is of the |
|
151 * type of the given type. |
|
152 * |
|
153 * @aFieldTypeResId Field type resource id. |
|
154 * @param aFieldTypeXspName Field type xSP name. |
|
155 */ |
|
156 void TryChangeFocusWithTypeIdL( |
|
157 TInt aFieldTypeResId, const TDesC& aFieldTypeXSpName ); |
|
158 |
|
159 public: // From CCoeControl |
|
160 TKeyResponse OfferKeyEventL( |
|
161 const TKeyEvent& aKeyEvent, |
|
162 TEventCode aType ); |
|
163 void GetHelpContext( |
|
164 TCoeHelpContext& aContext ) const; |
|
165 |
|
166 public: // From CAknForm |
|
167 void PreLayoutDynInitL(); |
|
168 void PostLayoutDynInitL(); |
|
169 void SetInitialCurrentLine(); |
|
170 void ProcessCommandL( |
|
171 TInt aCommandId ); |
|
172 void DynInitMenuPaneL( |
|
173 TInt aResourceId, |
|
174 CEikMenuPane* aMenuPane ); |
|
175 TBool OkToExitL( |
|
176 TInt aKeycode ); |
|
177 void HandleControlStateChangeL( |
|
178 TInt aControlId ); |
|
179 //Let Avkon know from which base class control has been |
|
180 //derived from in order to use the correct layout method. |
|
181 MEikDialogPageObserver::TFormControlTypes |
|
182 ConvertCustomControlTypeToBaseControlType(TInt aControlType) const; |
|
183 //Provide custom control |
|
184 SEikControlInfo CreateCustomControlL(TInt aControlType); |
|
185 void HandlePointerEventL( const TPointerEvent& aPointerEvent ); |
|
186 // Handles a change to the control's resources. |
|
187 void HandleResourceChange( TInt aType ); |
|
188 |
|
189 public: // From MPbk2ContactEditorUiBuilder |
|
190 CCoeControl* CreateLineL( |
|
191 const TDesC& aCaption, |
|
192 TInt aControlId, |
|
193 TInt aControlType ); |
|
194 CEikCaptionedControl* LineControl( |
|
195 TInt aControlId ) const; |
|
196 void DeleteControl( |
|
197 TInt aControlId ); |
|
198 void TryChangeFocusL( |
|
199 TInt aControlId ); |
|
200 void SetCurrentLineCaptionL( |
|
201 const TDesC& aText ); |
|
202 CCoeControl* Control( |
|
203 TInt aControlId ) const; |
|
204 void SetEditableL( |
|
205 TBool aState ); |
|
206 void LoadBitmapToFieldL( |
|
207 const MPbk2FieldProperty& aFieldProperty, |
|
208 const CPbk2IconInfoContainer& aIconInfoContainer, |
|
209 TInt aControlId ); |
|
210 TAny* ContactEditorUiBuilderExtension( TUid aExtensionUid ); |
|
211 |
|
212 public: // From MPbk2ContactEditorUiBuilderExtension |
|
213 CCoeControl* AddCustomFieldToFormL(TInt aIndex, TInt aResourceId); |
|
214 TBool HandleCustomFieldCommandL(TInt aCommand ); |
|
215 |
|
216 public: // From MPbk2ContactEditorEventObserver |
|
217 void ContactEditorOperationCompleted( |
|
218 MVPbkContactObserver::TContactOpResult aResult, |
|
219 MPbk2ContactEditorEventObserver::TParams aParams ); |
|
220 void ContactEditorOperationFailed( |
|
221 MVPbkContactObserver::TContactOp aOpCode, |
|
222 TInt aErrorCode, |
|
223 MPbk2ContactEditorEventObserver::TParams aParams, |
|
224 MPbk2ContactEditorEventObserver::TFailParams& aFailParams ); |
|
225 |
|
226 public: // From MPbk2DialogEliminator |
|
227 void RequestExitL( |
|
228 TInt aCommandId ); |
|
229 void ForceExit(); |
|
230 void ResetWhenDestroyed( |
|
231 MPbk2DialogEliminator** aSelfPtr ); |
|
232 |
|
233 public: // From MPbk2ContactEditorControl |
|
234 void SetFocus( |
|
235 TInt aIndex ); |
|
236 TInt NumberOfControls() const; |
|
237 TInt IndexOfCtrlType( |
|
238 TPbk2FieldCtrlType aType, |
|
239 TInt& aIndex ) const; |
|
240 TBool AreAllControlsEmpty() const; |
|
241 TBool IsControlEmptyL( |
|
242 TInt aIndex ) const; |
|
243 TBool IsCustomControlEmptyL(TInt aIndex, TBool& aRet) const; |
|
244 MPbk2ContactEditorField& EditorField( |
|
245 TInt aIndex ) const; |
|
246 virtual TAny* ContactEditorControlExtension( |
|
247 TUid /*aExtensionUid*/ ); |
|
248 |
|
249 public: // From MPbk2ContactEditorControlExtension |
|
250 void UpdateControlsL(); |
|
251 TInt FocusedControlType(); |
|
252 |
|
253 public: // From MVPbkContactStoreObserver |
|
254 void StoreReady( |
|
255 MVPbkContactStore& aContactStore ); |
|
256 void StoreUnavailable( |
|
257 MVPbkContactStore& aContactStore, |
|
258 TInt aReason ); |
|
259 void HandleStoreEventL( |
|
260 MVPbkContactStore& aContactStore, |
|
261 TVPbkContactStoreEvent aStoreEvent ); |
|
262 |
|
263 public: // From MPbk2ImageFieldObserver |
|
264 /** |
|
265 * Called when image has bee loaded. |
|
266 * |
|
267 */ |
|
268 TInt ImageLoadingComplete(); |
|
269 |
|
270 |
|
271 /** |
|
272 * Called when image loading failed. |
|
273 * |
|
274 */ |
|
275 TInt ImageLoadingFailed(); |
|
276 |
|
277 |
|
278 /** |
|
279 * Called when image loading was cancelled. |
|
280 * |
|
281 */ |
|
282 TInt ImageLoadingCancelled(); |
|
283 |
|
284 private: // From CEikDialog |
|
285 void LineChangedL( |
|
286 TInt aControlId ); |
|
287 |
|
288 private: // Implementation |
|
289 |
|
290 void DoImageLoadingCompleteL(); |
|
291 |
|
292 CPbk2ContactEditorDlgImpl( |
|
293 TPbk2ContactEditorParams& aParams, |
|
294 CPbk2PresentationContact& aContact, |
|
295 CPbk2FieldPropertyArray& aFieldProperties, |
|
296 MPbk2EditedContactObserver& aContactObserver, |
|
297 MPbk2ContactEditorStrategy& aEditorStrategy, |
|
298 MPbk2ContactEditorContactRelocator& aRelocator, |
|
299 MPbk2ApplicationServices* aAppServices = NULL, |
|
300 HBufC* aTitleText = NULL ); |
|
301 void ConstructL(); |
|
302 void StoreTitlePaneTextL(); |
|
303 void ConstructContextMenuL(); |
|
304 void ConstructNaviPaneL(); |
|
305 void UpdateTitleL(); |
|
306 void UpdateTitlePictureL(); |
|
307 void CloseDialog( |
|
308 MVPbkContactObserver::TContactOp aOpCode, |
|
309 TBool aInformObserver ); |
|
310 void ExitApplication( |
|
311 MVPbkContactObserver::TContactOp aOpCode, |
|
312 TInt aCommandId ); |
|
313 void CmdAddItemL(); |
|
314 void CmdDeleteItemL(); |
|
315 void CmdEditItemLabelL(); |
|
316 void CmdDoneL( |
|
317 MPbk2ContactEditorEventObserver::TParams& aParams ); |
|
318 TInt FocusedFieldIndexL(); |
|
319 void SetCbaButtonsL(); |
|
320 TBool EmptyContextMenuL(); |
|
321 TBool OkToExitApplicationL( |
|
322 TInt aCommandId ); |
|
323 void ForwardOkToExitL( TInt aKeycode ); |
|
324 void SetCbaCommandSetL( TInt aResourceId ); |
|
325 void UpdateCbasL(CPbk2ContactEditorArrayItem* aItemToUpdate = NULL); |
|
326 void DimItem( CEikMenuPane* aMenuPane, TInt aCmd ); |
|
327 void UnDimItem( CEikMenuPane* aMenuPane, TInt aCmd ); |
|
328 TBool CheckBaseCommandL(TInt aCommandId); |
|
329 TBool ExecuteBaseCommandL(TInt aCommandId); |
|
330 TBool CheckFieldSpecificCommandL(TInt aCommandId); |
|
331 void RemoveAndReAddCurrentFieldL(); |
|
332 void DynInitRingtoneL( |
|
333 TInt aResourceId, |
|
334 CEikMenuPane* aMenuPane, |
|
335 MPbk2ContactEditorField& aCurrentField ); |
|
336 void DynInitImageL( |
|
337 TInt aResourceId, |
|
338 CEikMenuPane* aMenuPane, |
|
339 MPbk2ContactEditorField& aCurrentField ); |
|
340 void DynInitSyncL( |
|
341 TInt aResourceId, |
|
342 CEikMenuPane* aMenuPane, |
|
343 MPbk2ContactEditorField& aCurrentField ); |
|
344 void DynInitAddressL( |
|
345 TInt aResourceId, |
|
346 CEikMenuPane* aMenuPane ); |
|
347 void ExecuteAddressDlgL(TPbk2ContactEditorParams::TActiveView aActiveView); |
|
348 void ClearControls(); |
|
349 TBool ContactHasAddress(TPbk2FieldGroupId aAddressGroup); |
|
350 void AddGroupFieldsL(TPbk2FieldGroupId aGroupId); |
|
351 TBool AreAllFieldsEmpty(); |
|
352 TBool IsUIDataChanged(); |
|
353 TBool IsAddressValidated(TPbk2FieldGroupId aGroupId); |
|
354 void DeleteActiveAddressGeoCoords(); |
|
355 void SetAddressValidationIconsL(); |
|
356 |
|
357 void WaitFinishL(); |
|
358 void CloseDialog(); |
|
359 |
|
360 private: // Data structures |
|
361 |
|
362 /** |
|
363 * Exit states. |
|
364 */ |
|
365 enum TExitState |
|
366 { |
|
367 EExitOrdered, |
|
368 EExitApproved, |
|
369 EOkToExitWithoutHandlingIt |
|
370 }; |
|
371 /** |
|
372 * Using states. |
|
373 */ |
|
374 enum TUseState |
|
375 { |
|
376 EUseReady, |
|
377 EUseOperatingContact, |
|
378 EUseFinished |
|
379 }; |
|
380 |
|
381 private: // Data |
|
382 /// Ref: Editor parameters |
|
383 TPbk2ContactEditorParams& iParams; |
|
384 /// Own: Context menu bar |
|
385 CEikMenuBar* iContextMenuBar; |
|
386 /// Ref: Application's title pane |
|
387 CAknTitlePane* iTitlePane; |
|
388 /// Own: Title pane text to restore on exit |
|
389 HBufC* iStoredTitlePaneText; |
|
390 /// Ref: A strategy for the editor |
|
391 MPbk2ContactEditorStrategy& iEditorStrategy; |
|
392 /// Ref: Phonebook 2 field properties |
|
393 CPbk2FieldPropertyArray& iFieldProperties; |
|
394 /// Ref: Presentation level contact |
|
395 CPbk2PresentationContact& iContact; |
|
396 /// Ref: For setting the title of the contact |
|
397 MPbk2ContactNameFormatter* iNameFormatter; |
|
398 /// Own: Manages dialog fields |
|
399 CPbk2ContactEditorFieldArray* iUiFieldArray; |
|
400 /// Own: Exit information for TExitState |
|
401 TBitFlags8 iExitRecord; |
|
402 /// Own: Contact editor extension |
|
403 MPbk2ContactEditorExtension* iEditorExtension; |
|
404 /// Ref: Observer for the contact being edited |
|
405 MPbk2EditedContactObserver& iContactObserver; |
|
406 /// Own: Add item selection index |
|
407 TInt iAddItemSelectionIndex; |
|
408 /// Ref: Contact relocator |
|
409 MPbk2ContactEditorContactRelocator& iRelocator; |
|
410 /// Ref: Extension manager |
|
411 CPbk2UIExtensionManager* iExtensionManager; |
|
412 /// Ref: Status pane handle |
|
413 CAknNavigationControlContainer* iNaviContainer; |
|
414 /// Ref: Pointer to dialog eliminator |
|
415 MPbk2DialogEliminator** iSelfPtr; |
|
416 /// Own: Current CBA command set |
|
417 TInt iCbaCommandSet; |
|
418 ///Own: Handle to basecommand object |
|
419 MPbk2BaseCommand* iPbk2BaseCommand; |
|
420 //Ref: Temp holder for last created custom control |
|
421 CCoeControl* iLastCreatedCustomControl; |
|
422 // Own: In order to prevent execution of multiple commands in case |
|
423 // user taps fast enough touch ui. |
|
424 TBool iCommandPending; |
|
425 /// Own: 'end-key' was pressed |
|
426 TBool iEndKeyWasPressed; |
|
427 /// Field factory |
|
428 CPbk2ContactEditorFieldFactory* iFieldFactory; |
|
429 /// Ref: Instance of Address View |
|
430 CPbk2ContactEditorDlgImpl* iAddressView; |
|
431 /// Own: If we are in stand alone Address View |
|
432 TBool iAddressViewStandalone; |
|
433 /// Dialog using state |
|
434 TUseState iUseState; |
|
435 /// Own: Wait until finish contact store operation |
|
436 CActiveSchedulerWait* iWaitFinish; |
|
437 /// Own: User input blocker |
|
438 CAknInputBlock* iInputBlock; |
|
439 // Own: Whether the service has been canceled |
|
440 TBool iServiceCanceled; |
|
441 // Own: A store contact |
|
442 MVPbkStoreContact* iStoreContact; |
|
443 // Ref: Pbk2 application services |
|
444 MPbk2ApplicationServices* iAppServices; |
|
445 // Own: Custom title text |
|
446 HBufC* iTitleText; |
|
447 // The latest command id |
|
448 TInt iCommandId; |
|
449 //Resource loader |
|
450 RCoeResourceLoader iPbk2UiResource; |
|
451 }; |
|
452 |
|
453 #endif // CPBK2CONTACTEDITORDLGIMPL_H |
|
454 |
|
455 // End of File |