|
1 /* |
|
2 * Copyright (c) 2006 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: Contact editor / viewer |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CCACONTACTEDITOR_H |
|
21 #define CCACONTACTEDITOR_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <aknform.h> |
|
25 #include "MCAUiContactEditCmdCB.h" |
|
26 #include "TEnumsPC.h" |
|
27 |
|
28 // FORWARD DECLARATIONS |
|
29 //class MCAStoredContact; |
|
30 class CCAStatusPaneHandler; |
|
31 class CEikEdwin; |
|
32 class CCAContactEditCmd; |
|
33 class MCAContactEditPC; |
|
34 class CCAAppUi; |
|
35 |
|
36 |
|
37 |
|
38 // CLASS DECLARATION |
|
39 |
|
40 /** |
|
41 * Contact editor / viewer |
|
42 * |
|
43 * @lib chatNG.app |
|
44 * @since 3.2 |
|
45 */ |
|
46 class CCAContactEditor : public CAknForm, |
|
47 public MCAUiContactEditCmdCB |
|
48 { |
|
49 public: // Constructors and destructor |
|
50 |
|
51 /** |
|
52 * Symbian default constructor |
|
53 * @since 3.2 |
|
54 * @param aIndex - Index of the contact to be edited in MainviewArryPC |
|
55 * @param aSaved - Ref to the Bool - Etrue denotes that the contact was edited |
|
56 * @param aContactPCInitialise - EFalse denotes that the Contact EditorsPC Component |
|
57 * has been initialised by the caller. Hence ContactEditor should |
|
58 * call initialise/release of the Process Component. |
|
59 */ |
|
60 static CCAContactEditor* NewL( TInt aIndex, |
|
61 TBool& aSaved, |
|
62 const TBool aContactPCInitialise = ETrue ); |
|
63 |
|
64 /** |
|
65 * Symbian default constructor |
|
66 * @since 3.2 |
|
67 * @param aIndex - Index of the contact to be edited in MainviewArryPC |
|
68 * @param aSaved - Ref to the Bool - Etrue denotes that the contact was edited |
|
69 * @param aContactPCInitialise - EFalse denotes that the Contact EditorsPC Component |
|
70 * has been initialised by the caller. Hence ContactEditor should |
|
71 * call initialise/release of the Process Component. |
|
72 */ |
|
73 static CCAContactEditor* NewLC( |
|
74 TInt aIndex, |
|
75 TBool& aSaved, |
|
76 const TBool aContactPCInitialise = ETrue ); |
|
77 |
|
78 |
|
79 /** |
|
80 * Destructor. |
|
81 * @since 3.2 |
|
82 */ |
|
83 virtual ~CCAContactEditor(); |
|
84 |
|
85 public: // New functions |
|
86 |
|
87 /** |
|
88 * Launches contact editor. |
|
89 * @param aCreateNew ETrue if new contact should be created |
|
90 * @param aListId Id of the contact list, where the contact is to be |
|
91 * stored |
|
92 * @param aWVID WVID to be inserted for new contact |
|
93 * (can be set to NULL) |
|
94 * @param aNickName Name to be insterted for new contact (can be NULL) |
|
95 * @param aLoadFromStore Load the contact from storage |
|
96 * @param aFetchAlias Fetch alias for the provided wvid |
|
97 * @param aCursorToBeginning Move cursor of wv id editor to beginning |
|
98 * @return zero if it was the cancel button ELSE EAknSoftkeyDone |
|
99 * @since 3.2 |
|
100 */ |
|
101 TInt EditContactLD( TEnumsPC::TContactEditorMode aCreateNew, |
|
102 const TDesC& aListId, |
|
103 const TDesC& aWVID = KNullDesC, |
|
104 const TDesC& aNickName = KNullDesC, |
|
105 TBool aLoadFromStore = ETrue, |
|
106 TBool aFetchAlias = ETrue, |
|
107 TBool aCursorToBeginning = EFalse ); |
|
108 |
|
109 /** |
|
110 * Launches contact editor, with focus on the given field. |
|
111 * Used by Contact Details Dialog. |
|
112 * @param aInitialFocus The initial focus line (command ID) |
|
113 * @see EditContactLD |
|
114 * @return zero if it was the cancel button ELSE EAknSoftkeyDone |
|
115 * @since 3.2 |
|
116 */ |
|
117 TInt EditContactLD( |
|
118 TInt aInitialFocus, |
|
119 TEnumsPC::TContactEditorMode aCreateNew, |
|
120 const TDesC& aListId ); |
|
121 |
|
122 |
|
123 /** |
|
124 * Move specified contact to another list |
|
125 * @param aContactItemId Id of contact to be moved |
|
126 * @since 3.2 |
|
127 */ |
|
128 TBool MoveContactL( const TDesC& aListId, HBufC*& aMovedListId, TBool& aCollapsed ); |
|
129 |
|
130 |
|
131 |
|
132 private: // Enumerations |
|
133 |
|
134 /** |
|
135 * Internal state transitions only |
|
136 * EAdd: Edit mode for adding contact |
|
137 * EView: View-mode. User can select edit from there. |
|
138 * EEdit: Edit mode for editing contact |
|
139 * EEditAfterView: Edit selected from view-mode.. |
|
140 * @since 3.2 |
|
141 */ |
|
142 enum TInternalStates |
|
143 { |
|
144 EAdd = 1, |
|
145 EView, |
|
146 EEdit, |
|
147 EEditAfterView, |
|
148 EMove |
|
149 }; |
|
150 |
|
151 private: // Constructors and destructor |
|
152 |
|
153 /** |
|
154 * C++ default constructor. |
|
155 * @since 3.2 |
|
156 * @param aSaved - Ref to the Bool - Etrue denotes that the contact was edited |
|
157 * @param aContactPCInitialise - Etrue denotes that the Contact EditorsPC Component |
|
158 * has been initialised by the caller. Hence ContactEditor should |
|
159 * call initialise/release of the Process Component. |
|
160 */ |
|
161 CCAContactEditor( TBool& aSaved, const TBool aContactPCInitialise ); |
|
162 |
|
163 /** |
|
164 * 2nd level constructor for this class |
|
165 * @since 3.2 |
|
166 */ |
|
167 void ConstructL( TInt aIndex ); |
|
168 |
|
169 private: // New functions |
|
170 |
|
171 /** |
|
172 * Loads all data that is displayed in form |
|
173 * @since 3.2 |
|
174 */ |
|
175 void LoadFormDataL(); |
|
176 |
|
177 /** |
|
178 * Fetches handler to edwin control pointed by aId |
|
179 * @param aId Control's id |
|
180 * @return Pointer to Edwin |
|
181 * @since 3.2 |
|
182 */ |
|
183 CEikEdwin* GetFormEdwin( TInt aId ); |
|
184 |
|
185 /** |
|
186 * Copies edwin's text to buffer and returns handle to it |
|
187 * Transfers ownership to caller!!! |
|
188 * Leaves on failure |
|
189 * @param aId Control's id |
|
190 * @return Buffer with text |
|
191 * @since 3.2 |
|
192 */ |
|
193 HBufC* GetEdwinTextBufferL( TInt aId ); |
|
194 |
|
195 /** |
|
196 * Copies edwin's text to buffer and returns handle to it |
|
197 * Transfers ownership to caller!!! |
|
198 * Pushes pointer to cleanup stack, leaves on failure. |
|
199 * @param aId Control's id |
|
200 * @return Buffer with text |
|
201 * @since 3.2 |
|
202 */ |
|
203 HBufC* GetEdwinTextBufferLC( TInt aId ); |
|
204 |
|
205 /** |
|
206 * Updates CBA-labels with resource given by aResourceId (RESOURCE CBA) |
|
207 * @param aResourceId Resource that is used to update labels |
|
208 * @since 3.2 |
|
209 */ |
|
210 void SetMenuBarTitleResourceL( TInt aResourceId ); |
|
211 |
|
212 /** |
|
213 * Updates title bar according to current data edited |
|
214 * @since 3.2 |
|
215 */ |
|
216 void UpdateTitleBarL(); |
|
217 |
|
218 /** |
|
219 * Hides fields that have no data |
|
220 * @since 3.2 |
|
221 */ |
|
222 void HideEmptyFieldsL(); |
|
223 |
|
224 /** |
|
225 * Sets focus to field that is available |
|
226 * If currently focused is not, then try nick->real->wvid |
|
227 * @since 3.2 |
|
228 */ |
|
229 void SetFocusToAvailableFieldL(); |
|
230 |
|
231 private: // Functions from base classes (CAknDialog) |
|
232 |
|
233 /** |
|
234 * From CAknDialog, Handles key events |
|
235 * @param aKeyEvent Key that caused the event |
|
236 * @param aType Event type |
|
237 * @return Response |
|
238 * @since 3.2 |
|
239 */ |
|
240 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ); |
|
241 |
|
242 /** |
|
243 * From CAknForm, Set initial line to be in edit-state when edit |
|
244 * or add-state is chosen |
|
245 * @since 3.2 |
|
246 */ |
|
247 void SetInitialCurrentLine(); |
|
248 |
|
249 |
|
250 private: // Functions from base classes |
|
251 |
|
252 /** |
|
253 * From MEikMenuObserver, Gets called before menu is displayed |
|
254 * @param aResourceId Id of a resource being built |
|
255 * @param aMenuPane Handle to menupane that is about to be shown |
|
256 * @since 3.2 |
|
257 */ |
|
258 void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane ); |
|
259 |
|
260 /** |
|
261 * From CEikDialog, Gets called before form is displayed |
|
262 * @since 3.2 |
|
263 */ |
|
264 void PreLayoutDynInitL(); |
|
265 |
|
266 /** |
|
267 * From CEikDialog, Gets called before form is displayed |
|
268 * @since 3.2 |
|
269 */ |
|
270 void PostLayoutDynInitL(); |
|
271 |
|
272 /** |
|
273 * From CAknDialog, Gets called before form is dismissed |
|
274 * @param aButtonId Button that was pressed for dismissing dialog |
|
275 * @return Is it ok to exit or not |
|
276 * @since 3.2 |
|
277 */ |
|
278 TBool OkToExitL( TInt aButtonId ); |
|
279 |
|
280 /** |
|
281 * From CAknForm, Gets called when user chooses to save data |
|
282 * @return Was saving successful |
|
283 * @since 3.2 |
|
284 */ |
|
285 TBool SaveFormDataL(); |
|
286 |
|
287 /** |
|
288 * From CAknForm, Gets called when user chooses not to save data |
|
289 * @since 3.2 |
|
290 */ |
|
291 void DoNotSaveFormDataL() ; |
|
292 |
|
293 /** |
|
294 * From CAknForm, Gets called when user chooses to save data, |
|
295 * we don't ask for confirmation |
|
296 * @return Save or not |
|
297 * @since 3.2 |
|
298 */ |
|
299 TBool QuerySaveChangesL() ; |
|
300 |
|
301 private: |
|
302 |
|
303 /** |
|
304 * Launch help dialog |
|
305 * @since 3.2 |
|
306 */ |
|
307 void LaunchHelpL( const TDesC& aContext ); |
|
308 |
|
309 /** |
|
310 * Uses list query to get list for contact for editing and adding. |
|
311 * @param aId - current User Id in case of operation other than move |
|
312 * - current listid in case the operation is move |
|
313 * @param aNoListsResource Resource id of text to be used if |
|
314 * there aren't any lists avalaible. |
|
315 * Use 0 to get qtn_chat_no_contact_lists |
|
316 * information note with OK softkey |
|
317 * and force list creation after the note. |
|
318 * @return ListId if success, NULL otherwise. |
|
319 * @since 3.2 |
|
320 */ |
|
321 HBufC* GetListIdL( const TDesC& aId, TInt aNoListsResource ); |
|
322 |
|
323 /** |
|
324 * Check if given key would edit the text in focus. |
|
325 * @param aKeyEvent Key event to check. |
|
326 * @return ETrue if key would edit text. |
|
327 * @since 3.2 |
|
328 */ |
|
329 TBool IsEditingKey( const TKeyEvent &aKeyEvent ); |
|
330 |
|
331 /** |
|
332 * Changes own alias to aAlias |
|
333 * @param aAlias New own alias |
|
334 * @return None |
|
335 * @since 3.2 |
|
336 */ |
|
337 void UpdateOwnAliasL( const TDesC& aAlias ); |
|
338 |
|
339 /** |
|
340 * Deletes currently viewed contact. |
|
341 * @param aAskConfirmation If EFalse confirmation about |
|
342 * deletion is not shown and contact |
|
343 * is deleted. |
|
344 * @return General error code or KErrNone if successfull. |
|
345 * @since 3.0 |
|
346 */ |
|
347 TInt DeleteCurrentContactL( TBool aAskConfirmation = ETrue ); |
|
348 |
|
349 /** |
|
350 * Focuses Edwin control. |
|
351 * Cursor is set in the end of text. |
|
352 * @since 3.2 |
|
353 */ |
|
354 void FocusEdwinL( TInt aId, TBool aHighlight = EFalse ); |
|
355 |
|
356 public: |
|
357 /** |
|
358 * This is invoked by the command object to get |
|
359 * the current parameters before performing an operation |
|
360 |
|
361 * this function is called by the contact edit object |
|
362 * based on the iContactEditOperation - The Command object |
|
363 * gets the required data from UI |
|
364 * @since 3.2 |
|
365 */ |
|
366 virtual void GetParameters( MCAUiContactEditCmdCB::TContactEditParams& aParam ) ; |
|
367 |
|
368 /** |
|
369 * This is invoked by the command object to set |
|
370 * the result values after performing an operation |
|
371 * based on the iContactEditOperation - command object sets the |
|
372 * data required by UI. |
|
373 * The ownership of pointer varibles is also transferred to the UI. |
|
374 * Hence UI must delete the allocated data. |
|
375 * @since 3.2 |
|
376 */ |
|
377 virtual void SetParameters( MCAUiContactEditCmdCB::TContactEditParams& aParam ) ; |
|
378 |
|
379 private: // Data |
|
380 |
|
381 // Doesn't own |
|
382 const TDesC* iWVUID; |
|
383 // Doesn't own |
|
384 const TDesC* iNickName; |
|
385 |
|
386 /// owns list id of saved contact |
|
387 HBufC* iListId; |
|
388 |
|
389 // owns user id of saved contact |
|
390 HBufC* iUserId; |
|
391 |
|
392 // owns. original user id |
|
393 HBufC* iOrigId; |
|
394 |
|
395 // owns. Identification of contact |
|
396 HBufC* iIdentification; |
|
397 |
|
398 //// owns. Nickname of contact |
|
399 HBufC* iNick; |
|
400 |
|
401 // owns. alias |
|
402 HBufC* iAlias; |
|
403 |
|
404 //owns the new user id thats is to be edited |
|
405 HBufC* iNewUserId; |
|
406 |
|
407 // if all fields are empty |
|
408 TBool iAllFieldsEmpty; |
|
409 |
|
410 // Tells editor in what mode it should be (view/add/edit...) internally |
|
411 TEnumsPC::TContactEditorMode iInternalMode; |
|
412 |
|
413 // if the contact was deleted from here |
|
414 TBool iContactDeleted; |
|
415 |
|
416 // ETrue if contact is saved |
|
417 TBool& iContactWasSaved; |
|
418 |
|
419 // ETrue, if support for alias is enabled |
|
420 TBool iAliasEnabled; |
|
421 |
|
422 // ETrue, if nick name is enabled in brand variation |
|
423 TBool iNicknameEnabled; |
|
424 |
|
425 // ETrue, if WVID fields should have textual input mode |
|
426 // (enabled through brand variation) |
|
427 TBool iTextualInputMode; |
|
428 |
|
429 // ETrue, if user id cannot be edited |
|
430 TBool iUserIDNotEditable; |
|
431 |
|
432 // ETrue if contact is own status |
|
433 TBool iOwnStatus; |
|
434 |
|
435 // initial focus (form control id) |
|
436 TInt iInitialFocus; |
|
437 |
|
438 TBool iAliasNotOk; |
|
439 |
|
440 //initial cursor position |
|
441 TBool iCursorToBeginning; |
|
442 |
|
443 //Owns - Ptr to CCAContactEditCmd object |
|
444 CCAContactEditCmd *iCCAContactEditCmd; |
|
445 |
|
446 //Does'nt own - process component object for contact editor |
|
447 MCAContactEditPC *iCCAContactEditPC; |
|
448 |
|
449 //holds the contact edit operation to be performed |
|
450 MCAUiContactEditCmdCB::TContactEditParams::TContactEditOperations iContactEditOperation; |
|
451 |
|
452 //holds the error after an operation on contact was performed. |
|
453 TInt iContactEditOperationError; |
|
454 |
|
455 // not owned, from CCoeEnv |
|
456 CCAAppUi* iAppUI; |
|
457 |
|
458 //ETrue - denotes that the PC Component |
|
459 //has been initialised by the ContactEditor. |
|
460 TBool iContactEditPCInitialised; |
|
461 |
|
462 TBool iSaveStarted; |
|
463 |
|
464 }; |
|
465 |
|
466 #endif // CCACONTACTEDITOR_H |
|
467 |
|
468 // End of File |