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