|
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 * Interface : Private |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 |
|
22 #include "chatngclient.hrh" // application resources |
|
23 #include "CCAContactEditor.h" // header for this .cpp... |
|
24 #include "CCAStatusPaneHandler.h" // For title pane changes |
|
25 #include "ChatDebugPrint.h" |
|
26 #include "CAExternalInterface.h" |
|
27 #include "IMNoteMapper.h" |
|
28 #include "IMDialogUtils.h" |
|
29 #include "chatdefinitions.h" |
|
30 #include "CCAAppUi.h" |
|
31 #include "CCAEngine.h" |
|
32 #include "CCAUISessionManager.h" |
|
33 #include "ImpsCSPAllErrors.h" |
|
34 #include "CCAUINGUtils.h" |
|
35 #include "CAUtils.h" |
|
36 #include "ccasyncchecker.h" |
|
37 #include "ccafetchwaiter.h" |
|
38 #include "MCAError.h" |
|
39 #include "MCASettingsPC.h" |
|
40 #include "TEnumsPC.h" |
|
41 #include "IMUtils.h" |
|
42 #include "CCAPCUtils.h" |
|
43 |
|
44 |
|
45 #include <eikcapc.h> // CEikCaptionedControl |
|
46 #include <eikbtgpc.h> // CEikButtonGroupContainer |
|
47 #include <eikedwin.h> // Edwin |
|
48 #include <eikmenup.h> // menu pane handling |
|
49 #include <ChatNG.rsg> // application resources |
|
50 #include <aknnotewrappers.h> |
|
51 #include <aknquerydialog.h> // AVKON's query dialog |
|
52 #include <StringLoader.h> // StringLoader |
|
53 #include <hlplch.h> |
|
54 #include <csxhelp/imng.hlp.hrh> |
|
55 #include <featmgr.h> |
|
56 #include <cntdb.h> |
|
57 #include <EscapeUtils.h> |
|
58 |
|
59 #include <akndef.h> |
|
60 |
|
61 #include "CCACommandManagerFactory.h" |
|
62 #include "CCACommandManager.h" |
|
63 #include "CCAContactEditCmd.h" |
|
64 #include "MCAContactEditPC.h" |
|
65 #include "MCAProcessManager.h" |
|
66 #include "MCABlockingPC.h" |
|
67 |
|
68 #include "imnginternalcrkeys.h" |
|
69 #include "IMPrivateCRKeys.h" |
|
70 #include "IMVariant.hrh" |
|
71 |
|
72 // The Settings have been moved to Cenrep (also retained in the Resource file), |
|
73 // so the enums for keys and central repository header is added here |
|
74 #include "VariantKeys.h" |
|
75 |
|
76 // CONSTANTS |
|
77 const TInt KAlphaCodeA = 0x61; |
|
78 const TInt KAlphaCodeZ = 0x7A; |
|
79 const TInt KNumCode0 = 0x2F; |
|
80 const TInt KNumCode9 = 0x39; |
|
81 |
|
82 |
|
83 // ================= MEMBER FUNCTIONS ======================= |
|
84 |
|
85 // C++ default constructor can NOT contain any code, that |
|
86 // might leave. |
|
87 // |
|
88 CCAContactEditor::CCAContactEditor( |
|
89 TBool& aSaved, |
|
90 const TBool aContactPCInitialise ) |
|
91 : |
|
92 iAllFieldsEmpty( ETrue ), |
|
93 iContactWasSaved( aSaved ), |
|
94 iOwnStatus( EFalse ), |
|
95 iInitialFocus( EChatEditWV ), |
|
96 iContactEditPCInitialised( aContactPCInitialise )/*, |
|
97 iNewContactID(aNewContactID), |
|
98 iNewListID(aNewContactID)*/ |
|
99 { |
|
100 iContactWasSaved = EFalse; |
|
101 } |
|
102 |
|
103 |
|
104 // Destructor |
|
105 CCAContactEditor::~CCAContactEditor() |
|
106 { |
|
107 // reset the iContact and iOwnData |
|
108 //only release resources if this has been initialised within contact editor |
|
109 if ( iContactEditPCInitialised && iCCAContactEditPC ) |
|
110 { |
|
111 iCCAContactEditPC->ReleaseResources(); |
|
112 } |
|
113 |
|
114 |
|
115 delete iUserId; |
|
116 delete iOrigId; |
|
117 delete iAlias; |
|
118 delete iNick; |
|
119 delete iListId; |
|
120 delete iIdentification; |
|
121 delete iCCAContactEditCmd; |
|
122 delete iNewUserId; |
|
123 |
|
124 } |
|
125 |
|
126 |
|
127 // --------------------------------------------------------- |
|
128 // CCAContactEditor::NewL |
|
129 // (other items were commented in a header). |
|
130 // --------------------------------------------------------- |
|
131 // |
|
132 CCAContactEditor* CCAContactEditor::NewL( |
|
133 TInt aIndex, |
|
134 TBool& aSaved, |
|
135 const TBool aContactPCInitialise /*= ETrue*/ ) |
|
136 { |
|
137 CCAContactEditor* temp = CCAContactEditor::NewLC( aIndex, aSaved, aContactPCInitialise ); |
|
138 CleanupStack::Pop( temp ); |
|
139 return temp; |
|
140 } |
|
141 |
|
142 |
|
143 |
|
144 |
|
145 // --------------------------------------------------------- |
|
146 // CCAContactEditor::NewLC |
|
147 // (other items were commented in a header). |
|
148 // --------------------------------------------------------- |
|
149 // |
|
150 CCAContactEditor* CCAContactEditor::NewLC( |
|
151 TInt aIndex, |
|
152 TBool& aSaved, |
|
153 const TBool aContactPCInitialise /*= ETrue*/ ) |
|
154 { |
|
155 |
|
156 CCAContactEditor* temp = new( ELeave )CCAContactEditor( aSaved, aContactPCInitialise ); |
|
157 CleanupStack::PushL( temp ); |
|
158 temp->ConstructL( aIndex ); |
|
159 |
|
160 return temp; |
|
161 } |
|
162 |
|
163 // --------------------------------------------------------- |
|
164 // CCAContactEditor::ConstructL |
|
165 // (other items were commented in a header). |
|
166 // --------------------------------------------------------- |
|
167 // |
|
168 void CCAContactEditor::ConstructL( TInt aIndex ) |
|
169 { |
|
170 CAknForm::ConstructL( R_CHAT_CEDITOR_MENUBAR ); // superclass |
|
171 |
|
172 // finalize construction |
|
173 iAliasEnabled = IMUtils::IntResourceValueL( RSC_CHAT_VARIATION_HAVE_ALIAS ); |
|
174 iNicknameEnabled = IMUtils::IntResourceValueL( |
|
175 RSC_CHAT_VARIATION_HAVE_NICKNAME ); |
|
176 iTextualInputMode = IMUtils::IntResourceValueL( |
|
177 RSC_CHAT_VARIATION_USERID_TEXTUAL_INPUTMODE ); |
|
178 iUserIDNotEditable = IMUtils::IntResourceValueL( |
|
179 RSC_CHAT_VARIATION_UNEDITABLE_USERID ); |
|
180 |
|
181 iAppUI = static_cast <CCAAppUi*> ( CCoeEnv::Static()->AppUi() ); |
|
182 |
|
183 |
|
184 iCCAContactEditPC = iAppUI->GetProcessManager().GetContactEditInterface(); |
|
185 |
|
186 //only initialise if iContactEditPCInitialised = ETrue |
|
187 //also initialise only if we have a valid index |
|
188 if ( ( -1 != aIndex ) && ( iContactEditPCInitialised ) ) |
|
189 { |
|
190 iCCAContactEditPC->InitialiseL( |
|
191 *iAppUI->GetProcessManager().GetArrayInterface(), |
|
192 aIndex, iOwnStatus ); |
|
193 } |
|
194 |
|
195 if ( !iContactEditPCInitialised ) |
|
196 { |
|
197 iOwnStatus = iCCAContactEditPC->IsOwnData(); |
|
198 } |
|
199 |
|
200 MCACommandFactory* commandManager = CCACommandManagerFactory::InstanceL()->GetCommandManager(); |
|
201 |
|
202 |
|
203 iCCAContactEditCmd = static_cast< CCAContactEditCmd* > ( commandManager->NewCommandL( EChatClientDetailsEdit, iAppUI->GetProcessManager(), *this ) ); |
|
204 |
|
205 |
|
206 } |
|
207 |
|
208 // --------------------------------------------------------- |
|
209 // CCAContactEditor::EditContactLD |
|
210 // (other items were commented in a header). |
|
211 // --------------------------------------------------------- |
|
212 // |
|
213 TInt CCAContactEditor::EditContactLD( TEnumsPC::TContactEditorMode aCreateNew, |
|
214 const TDesC& aListId, |
|
215 const TDesC& aWVID /* = KNullDesC */, |
|
216 const TDesC& aNickName /* = KNullDesC */, |
|
217 TBool aLoadFromStore /* = ETrue */, |
|
218 TBool /*aFetchAlias = ETrue */, |
|
219 TBool aCursorToBeginning /* = EFalse */ ) |
|
220 { |
|
221 TInt retval = 0; |
|
222 |
|
223 CleanupStack::PushL( this ); |
|
224 TPtrC dummy( KNullDesC() ); |
|
225 |
|
226 CCAStatusPaneHandler& titlePane( *iAppUI->CAStatusPane() ); |
|
227 |
|
228 |
|
229 // Check disk space before editing |
|
230 IMUtils::FFSSpaceBelowCriticalLevelL( KContactSizeEstimate ); |
|
231 |
|
232 switch ( aCreateNew ) |
|
233 { |
|
234 case TEnumsPC::EAddToContact: |
|
235 { |
|
236 iInternalMode = TEnumsPC::EAddToContact; |
|
237 iWVUID = &aWVID; |
|
238 iNickName = &aNickName; |
|
239 break; |
|
240 } |
|
241 case TEnumsPC::EEditContact: |
|
242 { |
|
243 iInternalMode = TEnumsPC::EEditContact; |
|
244 iWVUID = &aWVID; |
|
245 iNickName = &aNickName; |
|
246 break; |
|
247 } |
|
248 case TEnumsPC::ECreateNew: |
|
249 { |
|
250 iInternalMode = TEnumsPC::EAddToContact; |
|
251 iWVUID = &dummy; |
|
252 iNickName = &dummy; |
|
253 break; |
|
254 } |
|
255 default: |
|
256 { |
|
257 iInternalMode = TEnumsPC::EUnknownMode; |
|
258 } |
|
259 } |
|
260 |
|
261 // set the mode and get default values for user id and nick name |
|
262 |
|
263 if ( ( !aCreateNew ) && ( aLoadFromStore ) && ( !( iCCAContactEditPC->IsContact() ) ) ) |
|
264 { |
|
265 if ( ( aWVID.Length() != 0 ) && ( aListId.Length() != 0 ) ) |
|
266 { |
|
267 iCCAContactEditPC->InitialiseL( aWVID, aListId, iOwnStatus ); |
|
268 //cross verification |
|
269 if ( !iCCAContactEditPC->IsContact() ) |
|
270 { |
|
271 //some serious issue dont open contact editor |
|
272 CleanupStack::PopAndDestroy( this ); |
|
273 return retval; |
|
274 } |
|
275 } |
|
276 } |
|
277 |
|
278 if ( !( ( iCCAContactEditPC->IsContact() ) && ( aLoadFromStore ) ) ) |
|
279 { |
|
280 if ( aWVID.Length() != 0 ) |
|
281 { |
|
282 iUserId = aWVID.AllocL(); |
|
283 } |
|
284 } |
|
285 |
|
286 |
|
287 iCursorToBeginning = aCursorToBeginning; |
|
288 |
|
289 if ( ( aListId.Length() == 0 ) && ( !iOwnStatus ) ) |
|
290 { |
|
291 // and go to contact list creation |
|
292 iListId = GetListIdL( aWVID, 0 ); |
|
293 if ( !iListId ) |
|
294 { |
|
295 CleanupStack::PopAndDestroy( this ); |
|
296 return retval; |
|
297 } |
|
298 } |
|
299 else |
|
300 { |
|
301 iListId = aListId.AllocL(); |
|
302 } |
|
303 |
|
304 // We have to use stacking decorators, because we can have stacked dialogs. |
|
305 // REMEMBER to pop out the pushed decorator |
|
306 titlePane.ClearNaviPaneL( ETrue ); |
|
307 |
|
308 // execute the actual form |
|
309 CleanupStack::Pop( this ); |
|
310 |
|
311 retval = ExecuteLD( R_CHAT_CONTACT_EDITOR_DLG ); |
|
312 |
|
313 // Restore navipane(show tabs id available) |
|
314 // fix for when add to im contacts is called from chatView,ConversationView |
|
315 // doesnt affect the rest |
|
316 titlePane.PopNaviPane(); |
|
317 |
|
318 return retval; |
|
319 |
|
320 } |
|
321 |
|
322 // --------------------------------------------------------- |
|
323 // CCAContactEditor::EditContactLD |
|
324 // (other items were commented in a header). |
|
325 // --------------------------------------------------------- |
|
326 // |
|
327 TInt CCAContactEditor::EditContactLD( |
|
328 TInt aInitialFocus, |
|
329 TEnumsPC::TContactEditorMode aCreateNew, |
|
330 const TDesC& aListId ) |
|
331 { |
|
332 iInitialFocus = aInitialFocus; |
|
333 TInt retval = EditContactLD( aCreateNew, aListId ); |
|
334 return retval; |
|
335 } |
|
336 |
|
337 // --------------------------------------------------------- |
|
338 // CCAContactEditor::LoadFormDataL |
|
339 // Loads all data displayed in form |
|
340 // (other items were commented in a header). |
|
341 // --------------------------------------------------------- |
|
342 // |
|
343 void CCAContactEditor::LoadFormDataL() |
|
344 { |
|
345 |
|
346 if ( iInternalMode == TEnumsPC::EAddToContact ) |
|
347 { |
|
348 // adding new contact, fetch the default values if they exist |
|
349 if ( iWVUID ) |
|
350 { |
|
351 |
|
352 // get a copy of original id |
|
353 delete iOrigId; |
|
354 iOrigId = NULL; |
|
355 iOrigId = iWVUID->AllocL(); |
|
356 |
|
357 TPtrC displayId( CCAAppUi::DisplayId( *iOrigId ) ); |
|
358 GetFormEdwin( EChatEditWV )->SetTextL( &displayId ); |
|
359 |
|
360 // set numeric as default, if requested |
|
361 GetFormEdwin( EChatEditWV )->SetAknEditorInputMode( |
|
362 iTextualInputMode ? |
|
363 EAknEditorTextInputMode : |
|
364 EAknEditorNumericInputMode ); |
|
365 |
|
366 if ( iCursorToBeginning ) |
|
367 { |
|
368 GetFormEdwin( EChatEditWV )->AddFlagToUserFlags( |
|
369 CEikEdwin::ENoAutoSelection ); |
|
370 } |
|
371 |
|
372 SetChangesPending( ETrue ); |
|
373 } |
|
374 |
|
375 if ( iNicknameEnabled ) |
|
376 { |
|
377 if ( iNickName ) |
|
378 { |
|
379 GetFormEdwin( EChatEditNick )->SetTextL( iNickName ); |
|
380 SetChangesPending( ETrue ); |
|
381 } |
|
382 } |
|
383 |
|
384 if ( iAliasEnabled ) |
|
385 { |
|
386 |
|
387 delete iAlias; |
|
388 |
|
389 //iAlias is assigned NULL as GetAliasFromPresenceL may leave |
|
390 iAlias = NULL; |
|
391 iAlias = iCCAContactEditPC->GetAliasFromPresenceL( *iWVUID ); |
|
392 |
|
393 // set the alias field as read-only, as we are now editing |
|
394 if ( iAlias ) |
|
395 { |
|
396 GetFormEdwin( EChatEditAlias )->SetTextL( iAlias ); |
|
397 } |
|
398 GetFormEdwin( EChatEditAlias )->SetReadOnly( ETrue ); |
|
399 GetFormEdwin( EChatEditAlias )-> |
|
400 AddFlagToUserFlags( CEikEdwin::EAvkonDisableCursor | |
|
401 CEikEdwin::ENoAutoSelection ); |
|
402 SetChangesPending( ETrue ); |
|
403 } |
|
404 |
|
405 HideEmptyFieldsL(); |
|
406 } |
|
407 else |
|
408 { |
|
409 |
|
410 iContactEditOperation = MCAUiContactEditCmdCB::TContactEditParams::ELoadContactDetails; |
|
411 |
|
412 iCCAContactEditCmd->ExecuteCommandL(); |
|
413 |
|
414 |
|
415 // viewing or editing |
|
416 if ( iUserId ) |
|
417 { |
|
418 |
|
419 // editing or viewing existing contact, load nick name and wvid |
|
420 { |
|
421 |
|
422 TPtrC displayId( CCAAppUi::DisplayId( *iOrigId ) ); |
|
423 GetFormEdwin( EChatEditWV )->SetTextL( &displayId ); |
|
424 // Make the text not highlighted and cursor at the end |
|
425 GetFormEdwin( EChatEditWV )-> |
|
426 AddFlagToUserFlags( CEikEdwin::ENoAutoSelection | |
|
427 CEikEdwin::EJustAutoCurEnd ); |
|
428 |
|
429 if ( iUserIDNotEditable || iOwnStatus ) |
|
430 { |
|
431 // we can't edit WVID of existing contact. |
|
432 GetFormEdwin( EChatEditWV )->SetReadOnly( ETrue ); |
|
433 GetFormEdwin( EChatEditWV )-> |
|
434 AddFlagToUserFlags( CEikEdwin::EAvkonDisableCursor | |
|
435 CEikEdwin::ENoAutoSelection ); |
|
436 } |
|
437 |
|
438 // set numeric as default, if requested |
|
439 GetFormEdwin( EChatEditWV )->SetAknEditorInputMode( |
|
440 iTextualInputMode ? |
|
441 EAknEditorTextInputMode : |
|
442 EAknEditorNumericInputMode ); |
|
443 |
|
444 // alias |
|
445 if ( ! iAliasEnabled ) |
|
446 { |
|
447 // no alias |
|
448 // 1. hide the alias entry completely |
|
449 DeleteLine( EChatEditAlias, EFalse ); |
|
450 } |
|
451 else |
|
452 { |
|
453 // alias |
|
454 // 1. put alias to alias field |
|
455 // 2. make alias field not editable (in OfferKeyEventL display a note) |
|
456 if ( iAlias ) |
|
457 { |
|
458 TPtrC aliasPtr( *iAlias ); |
|
459 GetFormEdwin( EChatEditAlias )->SetTextL( &aliasPtr ); |
|
460 |
|
461 // User can only edit his/her own alias |
|
462 if ( !iOwnStatus ) |
|
463 { |
|
464 GetFormEdwin( EChatEditAlias )->SetReadOnly( ETrue ); |
|
465 GetFormEdwin( EChatEditAlias )-> |
|
466 AddFlagToUserFlags( CEikEdwin::EAvkonDisableCursor | |
|
467 CEikEdwin::ENoAutoSelection ); |
|
468 } |
|
469 } |
|
470 } |
|
471 // nickname |
|
472 if ( iNicknameEnabled ) |
|
473 { |
|
474 // nickname |
|
475 if ( iNick ) |
|
476 { |
|
477 GetFormEdwin( EChatEditNick )->SetTextL( iNick ); |
|
478 GetFormEdwin( EChatEditNick )-> |
|
479 AddFlagToUserFlags( CEikEdwin::ENoAutoSelection | |
|
480 CEikEdwin::EJustAutoCurEnd ); |
|
481 } |
|
482 } |
|
483 } |
|
484 |
|
485 HideEmptyFieldsL(); |
|
486 } |
|
487 |
|
488 } |
|
489 |
|
490 // Hide the nick if it is not enabled |
|
491 if ( !iNicknameEnabled || iOwnStatus ) |
|
492 { |
|
493 DeleteLine( EChatEditNick, EFalse ); |
|
494 } |
|
495 |
|
496 UpdateTitleBarL(); |
|
497 } |
|
498 |
|
499 // --------------------------------------------------------- |
|
500 // CCAContactEditor::GetFormEdwin |
|
501 // Fetches handler to edwin control pointed by aId |
|
502 // (other items were commented in a header). |
|
503 // --------------------------------------------------------- |
|
504 // |
|
505 CEikEdwin* CCAContactEditor::GetFormEdwin( TInt aId ) |
|
506 { |
|
507 return static_cast<CEikEdwin*>( Control( aId ) ) ; |
|
508 } |
|
509 |
|
510 // --------------------------------------------------------- |
|
511 // CCAContactEditor::GetEdwinTextBufferL |
|
512 // Copies text to buffer and returns handle to it |
|
513 // (other items were commented in a header). |
|
514 // --------------------------------------------------------- |
|
515 // |
|
516 HBufC* CCAContactEditor::GetEdwinTextBufferL( TInt aId ) |
|
517 { |
|
518 return GetFormEdwin( aId )->GetTextInHBufL(); |
|
519 } |
|
520 |
|
521 // --------------------------------------------------------- |
|
522 // CCAContactEditor::GetEdwinTextBufferLC |
|
523 // Copies edwin's text to buffer and returns handle to it |
|
524 // (other items were commented in a header). |
|
525 // --------------------------------------------------------- |
|
526 // |
|
527 HBufC* CCAContactEditor::GetEdwinTextBufferLC( TInt aId ) |
|
528 { |
|
529 HBufC* text = GetEdwinTextBufferL( aId ); |
|
530 CleanupStack::PushL( text ); |
|
531 return text; |
|
532 } |
|
533 |
|
534 |
|
535 // --------------------------------------------------------- |
|
536 // CCAContactEditor::SetMenuBarTitleResourceL |
|
537 // Update CBA-container with resource pointed by aResourceId |
|
538 // (other items were commented in a header). |
|
539 // --------------------------------------------------------- |
|
540 // |
|
541 void CCAContactEditor::SetMenuBarTitleResourceL( TInt aResourceId ) |
|
542 { |
|
543 // Get handle to current cba-button container and update container with |
|
544 // resource pointed by aResourceId (RESOURCE CBA) |
|
545 CEikButtonGroupContainer* container = CEikButtonGroupContainer::Current(); |
|
546 container->SetCommandSetL( aResourceId ); |
|
547 container->DrawNow(); |
|
548 } |
|
549 |
|
550 // --------------------------------------------------------- |
|
551 // CCAContactEditor::UpdateTitleBarL |
|
552 // Updates title bar according to current data edited |
|
553 // (other items were commented in a header). |
|
554 // --------------------------------------------------------- |
|
555 // |
|
556 void CCAContactEditor::UpdateTitleBarL() |
|
557 { |
|
558 |
|
559 CCAStatusPaneHandler* statusPane = iAppUI->CAStatusPane(); |
|
560 |
|
561 if ( iInternalMode == TEnumsPC::EAddToContact ) |
|
562 { |
|
563 HBufC* title = iEikonEnv->AllocReadResourceLC( R_CHAT_CD_NEW_ENTRY ); |
|
564 statusPane->SetTitleL( *title ); |
|
565 CleanupStack::PopAndDestroy( title ); |
|
566 } |
|
567 else if ( iOwnStatus ) |
|
568 { |
|
569 HBufC* title = iEikonEnv->AllocReadResourceLC( |
|
570 R_QTN_CHAT_CD_OWN_DATA_TITLE ); |
|
571 |
|
572 statusPane->SetTitleL( *title ); |
|
573 CleanupStack::PopAndDestroy( title ); |
|
574 } |
|
575 else |
|
576 { |
|
577 // editing existing |
|
578 HBufC* title; |
|
579 |
|
580 // Identification of contact is one of the following |
|
581 // in this order: |
|
582 // 1. Nick name |
|
583 // 2. Alias |
|
584 // 3. WV ID |
|
585 if ( iNicknameEnabled ) |
|
586 { |
|
587 title = GetEdwinTextBufferL( EChatEditNick ); |
|
588 if ( title ) |
|
589 { |
|
590 CleanupStack::PushL( title ); |
|
591 statusPane->SetTitleL( *title ); |
|
592 CleanupStack::PopAndDestroy( title ); |
|
593 return; |
|
594 } |
|
595 } |
|
596 |
|
597 if ( iAliasEnabled && iAlias ) |
|
598 { |
|
599 statusPane->SetTitleL( *iAlias ); |
|
600 return; |
|
601 } |
|
602 |
|
603 title = GetEdwinTextBufferL( EChatEditWV ); |
|
604 if ( title ) |
|
605 { |
|
606 CleanupStack::PushL( title ); |
|
607 statusPane->SetTitleL( *title ); |
|
608 CleanupStack::PopAndDestroy( title ); |
|
609 return; |
|
610 } |
|
611 } |
|
612 } |
|
613 |
|
614 // --------------------------------------------------------- |
|
615 // CCAContactEditor::HideEmptyFieldsL |
|
616 // Hides fields that have no data |
|
617 // (other items were commented in a header). |
|
618 // --------------------------------------------------------- |
|
619 // |
|
620 void CCAContactEditor::HideEmptyFieldsL() |
|
621 { |
|
622 if ( iInternalMode == TEnumsPC::EAddToContact ) |
|
623 { |
|
624 // in this case empty alias should be hidden |
|
625 if ( ControlOrNull( EChatEditAlias ) ) |
|
626 { |
|
627 if ( GetFormEdwin( EChatEditAlias )->TextLength() == 0 ) |
|
628 { |
|
629 DeleteLine( EChatEditAlias ); |
|
630 } |
|
631 } |
|
632 } |
|
633 } |
|
634 |
|
635 // --------------------------------------------------------- |
|
636 // CCAContactEditor::SetFocusToAvailableFieldL |
|
637 // Sets focus to field that is available |
|
638 // (other items were commented in a header). |
|
639 // --------------------------------------------------------- |
|
640 // |
|
641 void CCAContactEditor::SetFocusToAvailableFieldL() |
|
642 { |
|
643 TBool readOnly = ETrue; |
|
644 TInt controlId = EChatEditWV; |
|
645 TBool aliasField = EFalse, nickField( EFalse ), wvField( EFalse ); |
|
646 |
|
647 if ( ControlOrNull( EChatEditNick ) ) |
|
648 { |
|
649 nickField = ETrue; |
|
650 } |
|
651 |
|
652 if ( ControlOrNull( EChatEditAlias ) ) |
|
653 { |
|
654 aliasField = ETrue; |
|
655 } |
|
656 |
|
657 if ( ControlOrNull( EChatEditWV ) ) |
|
658 { |
|
659 wvField = ETrue; |
|
660 } |
|
661 |
|
662 // When opening the editing view from the details view, the cursor is in the end of |
|
663 // the text field that was in focus on details view. |
|
664 // Check if focus must be changed to get it visible |
|
665 if ( ControlOrNull( iInitialFocus ) ) |
|
666 { |
|
667 switch ( iInitialFocus ) |
|
668 { |
|
669 case EChatEditNick: |
|
670 { |
|
671 if ( nickField && |
|
672 ( !GetFormEdwin( EChatEditNick )->IsReadOnly() ) |
|
673 ) |
|
674 { |
|
675 readOnly = EFalse; |
|
676 controlId = EChatEditNick; |
|
677 } |
|
678 break; |
|
679 } |
|
680 |
|
681 case EChatEditAlias: |
|
682 { |
|
683 if ( aliasField && |
|
684 ( !GetFormEdwin( EChatEditAlias )->IsReadOnly() ) |
|
685 ) |
|
686 { |
|
687 readOnly = EFalse; |
|
688 controlId = EChatEditAlias; |
|
689 } |
|
690 break; |
|
691 } |
|
692 |
|
693 case EChatEditWV: |
|
694 { |
|
695 if ( wvField && |
|
696 ( !GetFormEdwin( EChatEditWV )->IsReadOnly() ) |
|
697 ) |
|
698 { |
|
699 readOnly = EFalse; |
|
700 } |
|
701 break; |
|
702 } |
|
703 |
|
704 default: |
|
705 { |
|
706 break; |
|
707 } |
|
708 } |
|
709 |
|
710 //In case the focused field cannot be edited, then focus is |
|
711 //in the first editable field from the top of the list. |
|
712 //Identify from top which field is readOnly |
|
713 if ( readOnly ) |
|
714 { |
|
715 |
|
716 if ( wvField |
|
717 && ( !GetFormEdwin( EChatEditWV )->IsReadOnly() ) |
|
718 ) |
|
719 { |
|
720 controlId = EChatEditWV; |
|
721 } |
|
722 else if ( aliasField |
|
723 && ( !GetFormEdwin( EChatEditAlias )->IsReadOnly() ) |
|
724 ) |
|
725 { |
|
726 controlId = EChatEditAlias; |
|
727 } |
|
728 else if ( nickField |
|
729 && ( !GetFormEdwin( EChatEditNick )->IsReadOnly() ) |
|
730 ) |
|
731 { |
|
732 controlId = EChatEditNick ; |
|
733 } |
|
734 } |
|
735 |
|
736 if ( ControlOrNull( controlId ) ) |
|
737 { |
|
738 TryChangeFocusToL( controlId ); |
|
739 GetFormEdwin( controlId )->ClearSelectionL(); |
|
740 } |
|
741 |
|
742 } |
|
743 |
|
744 |
|
745 } |
|
746 |
|
747 // --------------------------------------------------------- |
|
748 // CCAContactEditor::SetInitialCurrentLine |
|
749 // Set initial line to be in edit-state when edit or add-state is chosen |
|
750 // (other items were commented in a header). |
|
751 // --------------------------------------------------------- |
|
752 // |
|
753 void CCAContactEditor::SetInitialCurrentLine() |
|
754 { |
|
755 CAknForm::SetInitialCurrentLine(); |
|
756 |
|
757 // try to set the focus to what it was in contact |
|
758 // details viewer, if the caller gave us that |
|
759 if ( iInitialFocus != EChatEditDummy ) |
|
760 { |
|
761 TRAPD( error, |
|
762 |
|
763 // the field might not be available, this call |
|
764 // takes care of moving to a correct field |
|
765 SetFocusToAvailableFieldL(); ); |
|
766 |
|
767 if ( error ) |
|
768 { |
|
769 CActiveScheduler::Current()->Error( error ); |
|
770 } |
|
771 } |
|
772 } |
|
773 |
|
774 // --------------------------------------------------------- |
|
775 // CCAContactEditor::OfferKeyEventL |
|
776 // Overridden method for giving selection-key a default method (edit) |
|
777 // (other items were commented in a header). |
|
778 // --------------------------------------------------------- |
|
779 // |
|
780 |
|
781 TKeyResponse CCAContactEditor::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
782 TEventCode aType ) |
|
783 { |
|
784 CHAT_DP( D_CHAT_LIT( "aKeyEvent.iScanCode == %d" ), aKeyEvent.iScanCode ); |
|
785 CHAT_DP( D_CHAT_LIT( "aKeyEvent.iModifiers == %d" ), aKeyEvent.iModifiers ); |
|
786 CHAT_DP( D_CHAT_LIT( "aKeyEvent.iRepeats == %d" ), aKeyEvent.iRepeats ); |
|
787 CHAT_DP( D_CHAT_LIT( "IsEditAble() == %d" ), IsEditable() ); |
|
788 |
|
789 |
|
790 |
|
791 // Show note when user is trying to edit WV ID |
|
792 if ( IsEditable() && |
|
793 IsEditingKey( aKeyEvent ) && |
|
794 IdOfFocusControl() == EChatEditWV && |
|
795 aType == EEventKey && |
|
796 ( iOwnStatus || ( iUserIDNotEditable && iInternalMode != TEnumsPC::EAddToContact ) ) ) |
|
797 { |
|
798 IMDialogUtils::DisplayInformationNoteL( |
|
799 R_QTN_CHAT_UNABLE_MODIFY_USERID, |
|
800 KNullDesC ); |
|
801 |
|
802 return EKeyWasConsumed; |
|
803 } |
|
804 |
|
805 // Show note when user is trying to edit contacts alias |
|
806 if ( !iOwnStatus && |
|
807 IsEditable() && |
|
808 IsEditingKey( aKeyEvent ) && |
|
809 IdOfFocusControl() == EChatEditAlias && |
|
810 aType == EEventKey ) |
|
811 { |
|
812 IMDialogUtils::DisplayInformationNoteL( |
|
813 R_QTN_CHAT_UNABLE_MODIFY_ALIAS, |
|
814 KNullDesC ); |
|
815 |
|
816 return EKeyWasConsumed; |
|
817 } |
|
818 |
|
819 if ( aKeyEvent.iCode == EKeyPhoneSend ) |
|
820 { |
|
821 return EKeyWasConsumed; |
|
822 } |
|
823 |
|
824 TKeyResponse retVal = CAknForm::OfferKeyEventL( aKeyEvent, aType ); |
|
825 |
|
826 // Show domain selection query if variated so |
|
827 if ( IMUtils::IntResourceValueL( RSC_CHAT_VARIATION_DOMAIN_SELECTION ) |
|
828 && IsEditable() |
|
829 && IdOfFocusControl() == EChatEditWV |
|
830 && aType == EEventKey |
|
831 && ( aKeyEvent.iCode == EKeyBackspace || aKeyEvent.iCode == EKeyDelete ) ) |
|
832 { |
|
833 CEikEdwin* edwin = GetFormEdwin( EChatEditWV ); |
|
834 if ( edwin->TextLength() == 0 ) |
|
835 { |
|
836 HBufC* userName = HBufC::NewLC( KServerWVUserIdMaxLength ); |
|
837 TPtr userPtr( userName->Des() ); |
|
838 |
|
839 |
|
840 if ( iAppUI-> |
|
841 UISessionManager().DisplayDomainSelectionQueryL( userPtr ) ) |
|
842 { |
|
843 // Domain selected |
|
844 edwin->SetTextL( userName ); |
|
845 edwin->SetCursorPosL( 0, EFalse ); |
|
846 } |
|
847 |
|
848 CleanupStack::PopAndDestroy( userName ); |
|
849 } |
|
850 } |
|
851 |
|
852 return retVal; |
|
853 } |
|
854 |
|
855 // --------------------------------------------------------- |
|
856 // CCAContactEditor::DynInitMenuPaneL |
|
857 // Gets called before form is displayed |
|
858 // (other items were commented in a header). |
|
859 // --------------------------------------------------------- |
|
860 // |
|
861 void CCAContactEditor::DynInitMenuPaneL( TInt aResourceId, |
|
862 CEikMenuPane* aMenuPane ) |
|
863 { |
|
864 // Execute base class's DynInitMenuPaneL |
|
865 CAknForm::DynInitMenuPaneL( aResourceId, aMenuPane ); |
|
866 |
|
867 // if we're displaying general menu and help feature is not supported.. |
|
868 if ( aResourceId == R_CHATCLIENT_GENERAL_MENU && |
|
869 !FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
870 { |
|
871 // dimm the help menu item |
|
872 aMenuPane->SetItemDimmed( EChatClientCmdHelp, ETrue ); |
|
873 } |
|
874 else if ( aResourceId == R_AVKON_FORM_MENUPANE ) |
|
875 { |
|
876 // Deleting is not needed when editing... |
|
877 // nor when viewing own status |
|
878 if ( IsEditable() || iOwnStatus ) |
|
879 { |
|
880 aMenuPane->SetItemDimmed( EChatClientFriendsListViewCmdDelete, |
|
881 ETrue ); |
|
882 } |
|
883 else |
|
884 { |
|
885 aMenuPane->SetItemDimmed( EChatClientFriendsListViewCmdDelete, |
|
886 EFalse ); |
|
887 } |
|
888 |
|
889 if ( !iAliasEnabled && iOwnStatus ) |
|
890 { |
|
891 aMenuPane->SetItemDimmed( EAknFormCmdEdit, ETrue ); |
|
892 } |
|
893 |
|
894 if ( !FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
895 { |
|
896 aMenuPane->SetItemDimmed( EChatClientCmdHelp, ETrue ); |
|
897 } |
|
898 // Disable unnecessary items, that CAknForm adds... |
|
899 aMenuPane->SetItemDimmed( EAknFormCmdDelete, ETrue ); |
|
900 aMenuPane->SetItemDimmed( EAknFormCmdAdd, ETrue ); |
|
901 aMenuPane->SetItemDimmed( EAknFormCmdLabel, ETrue ); |
|
902 aMenuPane->SetItemDimmed( EAknFormCmdSave, ETrue ); |
|
903 } |
|
904 } |
|
905 |
|
906 // --------------------------------------------------------- |
|
907 // CCAContactEditor::PreLayoutDynInitL |
|
908 // Gets called before form is displayed |
|
909 // (other items were commented in a header). |
|
910 // --------------------------------------------------------- |
|
911 // |
|
912 void CCAContactEditor::PreLayoutDynInitL() |
|
913 { |
|
914 //SetMenuBarTitleResourceL( R_AVKON_SOFTKEYS_DONE_CANCEL ); |
|
915 SetMenuBarTitleResourceL( R_CHAT_SOFTKEYS_DONE_CANCEL__EMPTY ); |
|
916 |
|
917 LoadFormDataL(); |
|
918 |
|
919 SetInitialCurrentLine(); |
|
920 |
|
921 CAknForm::PreLayoutDynInitL(); |
|
922 |
|
923 // set own status, but for landscape mode only |
|
924 iAppUI->UISessionManager().SetStatusPaneIconsL(); |
|
925 } |
|
926 |
|
927 // --------------------------------------------------------- |
|
928 // |
|
929 // (other items were commented in a header). |
|
930 // --------------------------------------------------------- |
|
931 // |
|
932 void CCAContactEditor::PostLayoutDynInitL() |
|
933 { |
|
934 CAknForm::PostLayoutDynInitL(); |
|
935 SetEditableL( ETrue ); |
|
936 } |
|
937 |
|
938 // --------------------------------------------------------- |
|
939 // CCAContactEditor::SaveFormDataL |
|
940 // Gets called when user chooses to save data |
|
941 // (other items were commented in a header). |
|
942 // --------------------------------------------------------- |
|
943 // |
|
944 TBool CCAContactEditor::SaveFormDataL() |
|
945 { |
|
946 // we need to be logged in |
|
947 if ( !iAppUI->UISessionManager().LoginL( MCAUiLoginCmdCB::EQueryLogin ) ) |
|
948 { |
|
949 return EFalse; |
|
950 } |
|
951 |
|
952 |
|
953 // wait for background fetch |
|
954 if ( !CCASyncChecker::CheckSyncStateL() ) |
|
955 { |
|
956 // canceled or not logged in |
|
957 return EFalse; |
|
958 } |
|
959 MCABlockingPC* blockingInterface = iAppUI->GetProcessManager().GetBlockingInterface(); |
|
960 |
|
961 iAllFieldsEmpty = ETrue; |
|
962 iContactWasSaved = EFalse; |
|
963 iSaveStarted = ETrue; |
|
964 |
|
965 if ( iOwnStatus ) |
|
966 { |
|
967 if ( iAliasEnabled ) |
|
968 { |
|
969 HBufC* alias = GetEdwinTextBufferLC( EChatEditAlias ); |
|
970 if ( !alias ) |
|
971 { |
|
972 CleanupStack::PopAndDestroy( alias ); |
|
973 if ( IMUtils::IntResourceValueL( RSC_CHAT_VARIATION_ALIAS_MANDATORY ) ) |
|
974 { |
|
975 IMDialogUtils::DisplayQueryDialogL( R_QTN_CHAT_NO_ALIAS_DEF ); |
|
976 iAllFieldsEmpty = EFalse; |
|
977 iSaveStarted = EFalse; |
|
978 return EFalse; |
|
979 } |
|
980 //it should never be empty |
|
981 alias = KNullDesC().AllocLC(); |
|
982 } |
|
983 |
|
984 //call function tat will UpdateOwnAliasL( alias->Des() ); |
|
985 iAppUI->ShowWaitDialogLC( R_QTN_GEN_NOTE_SAVING, ETrue ); |
|
986 |
|
987 MCASettingsPC* settingsPC = iAppUI->GetProcessManager().GetSettingsInterface(); |
|
988 |
|
989 iContactEditOperationError = iCCAContactEditPC->UpdateOwnAliasL( *alias ); |
|
990 |
|
991 CleanupStack::Pop(); //wait dialog |
|
992 |
|
993 CleanupStack::PopAndDestroy( alias ); |
|
994 |
|
995 if ( iContactEditOperationError ) |
|
996 { |
|
997 iAppUI->DismissWaitDialogL( KErrNone, EFalse, KNullDesC ); |
|
998 iAliasNotOk = ETrue; |
|
999 if ( iContactEditOperationError == ECSPInvalidPresenceValue ) |
|
1000 { |
|
1001 //iAliasNotOk = ETrue; |
|
1002 iAllFieldsEmpty = EFalse; |
|
1003 HBufC* text = StringLoader::LoadLC( R_QTN_CHAT_TOO_LONG_ALIAS_TEXT ); |
|
1004 IMDialogUtils::DisplayErrorNoteL( *text ); |
|
1005 CleanupStack::PopAndDestroy( text ); |
|
1006 } |
|
1007 iSaveStarted = EFalse; |
|
1008 return EFalse; |
|
1009 } |
|
1010 else |
|
1011 { |
|
1012 iAppUI->DismissWaitDialogL( KErrNone, EFalse, KNullDesC ); |
|
1013 // Alias saved OK, show confirmation note |
|
1014 IMDialogUtils::DisplayInformationNoteL( R_QTN_CHAT_CNOTE_SAVED ); |
|
1015 iAllFieldsEmpty = EFalse; |
|
1016 iContactWasSaved = ETrue; |
|
1017 } |
|
1018 } |
|
1019 iSaveStarted = EFalse; |
|
1020 return ETrue; |
|
1021 } |
|
1022 |
|
1023 //delete the old iNewUserId if exists |
|
1024 if ( iNewUserId ) |
|
1025 { |
|
1026 delete iNewUserId; |
|
1027 iNewUserId = NULL; |
|
1028 } |
|
1029 |
|
1030 //delete the old iNick if exists |
|
1031 if ( iNick ) |
|
1032 { |
|
1033 delete iNick; |
|
1034 iNick = NULL; |
|
1035 } |
|
1036 |
|
1037 // Get nickname |
|
1038 if ( iNicknameEnabled ) |
|
1039 { |
|
1040 iNick = GetEdwinTextBufferL( EChatEditNick ); |
|
1041 if ( iNick ) |
|
1042 { |
|
1043 iAllFieldsEmpty = EFalse; |
|
1044 } |
|
1045 } |
|
1046 |
|
1047 // make sure we have some kind of nick |
|
1048 if ( !iNick ) |
|
1049 { |
|
1050 iNick = HBufC::NewL( 0 ); |
|
1051 } |
|
1052 |
|
1053 iNewUserId = GetEdwinTextBufferL( EChatEditWV ); |
|
1054 |
|
1055 if ( !iNewUserId ) // if the field is empty |
|
1056 { |
|
1057 |
|
1058 // Create empty buffer |
|
1059 iNewUserId = HBufC::NewL( 0 ); |
|
1060 |
|
1061 if ( !iAllFieldsEmpty ) |
|
1062 { |
|
1063 CAknQueryDialog* dlg = |
|
1064 new ( ELeave ) CAknQueryDialog( CAknQueryDialog::ENoTone ); |
|
1065 TInt ret( dlg->ExecuteLD( |
|
1066 R_CHAT_CEDITOR_ERROR_WVIDMISSING_QUERY ) ); |
|
1067 if ( ( ret != EAknSoftkeyOk ) && ( ret != EAknSoftkeyYes ) ) |
|
1068 { |
|
1069 if ( iInternalMode == TEnumsPC::EAddToContact ) |
|
1070 { |
|
1071 // just get out of here, nothing to delete |
|
1072 iContactDeleted = ETrue; |
|
1073 iSaveStarted = EFalse; |
|
1074 return ETrue; |
|
1075 } |
|
1076 else |
|
1077 { |
|
1078 |
|
1079 TInt err = DeleteCurrentContactL( EFalse ); |
|
1080 if ( err == KErrNone ) |
|
1081 { |
|
1082 iContactDeleted = ETrue; |
|
1083 CHAT_DP_TXT( "contact should NOT be saved.." ); |
|
1084 iSaveStarted = EFalse; |
|
1085 return ETrue; |
|
1086 } |
|
1087 else |
|
1088 { |
|
1089 // let user out of contact editor but report the error |
|
1090 iContactDeleted = ETrue; |
|
1091 CActiveScheduler::Current()->Error( err ); |
|
1092 iSaveStarted = EFalse; |
|
1093 return ETrue; |
|
1094 } |
|
1095 } |
|
1096 } |
|
1097 |
|
1098 CHAT_DP_TXT( "wvid missing, changing focus to editor.." ); |
|
1099 TryChangeFocusToL( EChatEditWV ); |
|
1100 iSaveStarted = EFalse; |
|
1101 return EFalse; |
|
1102 } |
|
1103 } |
|
1104 else |
|
1105 { |
|
1106 iAllFieldsEmpty = EFalse; |
|
1107 |
|
1108 if ( iOrigId ) |
|
1109 { |
|
1110 // we have some user id, so reconstruct it (add removed "wv:" and "@something") |
|
1111 HBufC* newId = CAUtils::ReconstructIdL( *iOrigId, *iNewUserId ); |
|
1112 |
|
1113 // replace the id with new one |
|
1114 delete iNewUserId; |
|
1115 iNewUserId = newId; |
|
1116 } |
|
1117 } |
|
1118 |
|
1119 if ( !CAUtils::ValidLoginIdL( *iNewUserId ) ) |
|
1120 { |
|
1121 HBufC* text = StringLoader::LoadLC( R_CHAT_ERROR_WRONG_WVID, *iNewUserId ); |
|
1122 IMDialogUtils::DisplayErrorNoteL( *text ); |
|
1123 CleanupStack::PopAndDestroy( text ); // text |
|
1124 iSaveStarted = EFalse; |
|
1125 return EFalse; |
|
1126 } |
|
1127 |
|
1128 // If all fields are empty then we can go back without saving contact |
|
1129 if ( iAllFieldsEmpty ) |
|
1130 { |
|
1131 iSaveStarted = EFalse; |
|
1132 return ETrue; |
|
1133 } |
|
1134 |
|
1135 |
|
1136 // check if there's already a contact with same wvid |
|
1137 |
|
1138 TBool contactInList( EFalse ); |
|
1139 TDesC* tmpUsrId = NULL; |
|
1140 |
|
1141 //Check whether a new contact/existing contact |
|
1142 TBool createNew = ( iInternalMode == TEnumsPC::EAddToContact ) ? ETrue : EFalse; |
|
1143 |
|
1144 TBool emptyNick = ( iNick->CompareC( KNullDesC ) == 0 ); |
|
1145 TBool sameNick = emptyNick ? EFalse |
|
1146 : iCCAContactEditPC->FindAnyContactByNickL( *iNick ); |
|
1147 |
|
1148 |
|
1149 if ( sameNick ) |
|
1150 { |
|
1151 // Contact with same nick was found from stored contacts, |
|
1152 // ask if user wants to edit nick |
|
1153 TInt ret = IMDialogUtils::DisplayYesNoConfirmationDialogL( |
|
1154 R_QTN_CHAT_SAME_NICK_NAME ); |
|
1155 |
|
1156 // If user wants to edit nick move focus to nick and highlight it. |
|
1157 // Otherwise continue saving with current nick |
|
1158 if ( ret == EAknSoftkeyOk || ret == EAknSoftkeyYes ) |
|
1159 { |
|
1160 FocusEdwinL( EChatEditNick, ETrue ); |
|
1161 iSaveStarted = EFalse; |
|
1162 return EFalse; |
|
1163 } |
|
1164 } |
|
1165 |
|
1166 if ( blockingInterface->IsContactBlocked( *iNewUserId ) |
|
1167 && ( 1 == IMUtils::IntResourceValueL( RSC_CHAT_VARIATION_BLOCKING ) ) ) |
|
1168 { |
|
1169 iCCAContactEditPC->DeleteContactL( *iNewUserId ); |
|
1170 } |
|
1171 |
|
1172 if ( iCCAContactEditPC->IsWVIDAvailableAndValidL( createNew, *iListId, *iNewUserId, |
|
1173 contactInList, tmpUsrId ) ) |
|
1174 { |
|
1175 if ( contactInList ) |
|
1176 { |
|
1177 |
|
1178 TInt ret( IMDialogUtils::DisplayYesNoConfirmationDialogL( |
|
1179 R_QTN_CHAT_CREATE_CONFQ_EX_WVID ) ); |
|
1180 |
|
1181 if ( ( ret == EAknSoftkeyOk ) || ( ret == EAknSoftkeyYes ) ) |
|
1182 { |
|
1183 iInternalMode = TEnumsPC::EEditContact; |
|
1184 // Change user id to match new target contact. |
|
1185 delete iUserId; |
|
1186 iUserId = NULL; |
|
1187 iUserId = tmpUsrId->AllocL(); |
|
1188 } |
|
1189 else |
|
1190 { |
|
1191 // move focus to wvid and highlight it |
|
1192 FocusEdwinL( EChatEditWV, ETrue ); |
|
1193 iSaveStarted = EFalse; |
|
1194 return EFalse; |
|
1195 } |
|
1196 } |
|
1197 |
|
1198 } |
|
1199 |
|
1200 else |
|
1201 { |
|
1202 iInternalMode = TEnumsPC::EAddToContact; |
|
1203 } |
|
1204 |
|
1205 |
|
1206 // check if unblock query enabled and blocked contacts |
|
1207 // are not shown in the contact list |
|
1208 TBool showUnblockQuery = |
|
1209 ( ( IMUtils::CRKeyL( KCRUidIMVariation, KIMVariationKey ) |
|
1210 & EIMFeatAddBlockedContactQuery ) |
|
1211 && ( IMUtils::IntResourceValueL( RSC_CHAT_VARIATION_BLOCKING ) != 2 ) ); |
|
1212 |
|
1213 if ( showUnblockQuery ) |
|
1214 { |
|
1215 |
|
1216 |
|
1217 // check if the wvid to be added is blocked |
|
1218 if ( blockingInterface->IsContactBlocked( *iNewUserId ) ) |
|
1219 { |
|
1220 // show query |
|
1221 HBufC* prompt = NULL; |
|
1222 prompt = StringLoader::LoadLC( R_QTN_CHAT_CONTACT_ADD_BLOCKED, |
|
1223 CCAPCUtils::DisplayId( *iNewUserId ) ); |
|
1224 |
|
1225 TInt ret( IMDialogUtils::DisplayYesNoConfirmationDialogL( |
|
1226 *prompt ) ); |
|
1227 |
|
1228 if ( ( ret == EAknSoftkeyOk ) || ( ret == EAknSoftkeyYes ) ) |
|
1229 { |
|
1230 //We have to create a list of users to be unblocked |
|
1231 CDesCArrayFlat* unBlockList = |
|
1232 new ( ELeave ) CDesCArrayFlat( 1 ); |
|
1233 CleanupStack::PushL( unBlockList ); |
|
1234 unBlockList->AppendL( *iNewUserId ); |
|
1235 |
|
1236 // unblock |
|
1237 iAppUI->ShowWaitDialogL( R_CHAT_BLOCK_REMOVING ); |
|
1238 TInt errorCode( KErrNone ); |
|
1239 TRAPD( err, errorCode = |
|
1240 blockingInterface->RemoveL( unBlockList, NULL ) ); |
|
1241 iAppUI->DismissWaitDialogL( err ); |
|
1242 |
|
1243 if ( errorCode != KErrNone ) |
|
1244 { |
|
1245 IMDialogUtils::DisplayErrorNoteL( errorCode ); |
|
1246 } |
|
1247 CleanupStack::PopAndDestroy( 2, prompt ); // unBlockList, prompt |
|
1248 } |
|
1249 else |
|
1250 { |
|
1251 CleanupStack::PopAndDestroy( prompt ); |
|
1252 prompt = StringLoader::LoadLC( R_QTN_CHAT_CONTACT_ADD_BLOCKED_NOT ); |
|
1253 IMDialogUtils::DisplayErrorNoteL( *prompt ); |
|
1254 CleanupStack::PopAndDestroy( prompt ); // prompt |
|
1255 // Return to place where adding was initiated |
|
1256 iContactWasSaved = ETrue; |
|
1257 iSaveStarted = EFalse; |
|
1258 return ETrue; |
|
1259 } |
|
1260 } |
|
1261 } |
|
1262 |
|
1263 HBufC* oldUserId = NULL; |
|
1264 |
|
1265 // proceed with adding or saving |
|
1266 if ( iInternalMode == TEnumsPC::EAddToContact ) |
|
1267 { |
|
1268 iAppUI->ShowWaitDialogLC( R_QTN_CHAT_FRIEND_ADDPB ); |
|
1269 |
|
1270 //*******************// add called |
|
1271 iContactEditOperation = MCAUiContactEditCmdCB::TContactEditParams::EAddContact; |
|
1272 iCCAContactEditCmd->ExecuteCommandL(); |
|
1273 |
|
1274 CleanupStack::PopAndDestroy(); // iAppUI->DismissWaitDialog |
|
1275 } |
|
1276 else |
|
1277 { |
|
1278 // editing a contact |
|
1279 if ( iUserId ) |
|
1280 { |
|
1281 oldUserId = iUserId->AllocLC(); |
|
1282 } |
|
1283 else |
|
1284 { |
|
1285 // in this case it's NULL, more nicer cleanup later |
|
1286 CleanupStack::PushL( oldUserId ); |
|
1287 } |
|
1288 |
|
1289 iAppUI->ShowWaitDialogLC( R_QTN_GEN_NOTE_SAVING ); |
|
1290 |
|
1291 |
|
1292 if ( iUserId && ( CAUtils::NeutralCompare( *iNewUserId, *iUserId ) == 0 ) ) |
|
1293 { |
|
1294 //call for update ****************** |
|
1295 |
|
1296 iContactEditOperation = MCAUiContactEditCmdCB::TContactEditParams::EUpdateContact; |
|
1297 iCCAContactEditCmd->ExecuteCommandL(); |
|
1298 |
|
1299 if ( iContactEditOperationError == KErrNone ) |
|
1300 { |
|
1301 delete iUserId; |
|
1302 iUserId = NULL; |
|
1303 iUserId = iNewUserId->AllocL(); |
|
1304 } |
|
1305 } |
|
1306 else |
|
1307 { |
|
1308 iCCAContactEditPC->SetAnyContactL( *iNewUserId ); |
|
1309 //*******************// add called |
|
1310 iContactEditOperation = MCAUiContactEditCmdCB::TContactEditParams::EAddContact; |
|
1311 iCCAContactEditCmd->ExecuteCommandL(); |
|
1312 |
|
1313 } |
|
1314 CleanupStack::PopAndDestroy(); // iAppUI->DismissWaitDialog |
|
1315 |
|
1316 } |
|
1317 |
|
1318 // handle possible error cases |
|
1319 CHAT_DP( D_CHAT_LIT( "*UpdateContactL error %d" ), iContactEditOperationError ); |
|
1320 |
|
1321 iSaveStarted = EFalse; |
|
1322 |
|
1323 HBufC* text = NULL; |
|
1324 |
|
1325 switch ( iContactEditOperationError ) |
|
1326 { |
|
1327 case ECSPAccountLost: // this error occurs when the list is full |
|
1328 case ECSPContactListFull: // flowthrough |
|
1329 { |
|
1330 text = iEikonEnv->AllocReadResourceLC( |
|
1331 R_QTN_CHAT_CONTACT_LIST_FULL ); |
|
1332 IMDialogUtils::DisplayErrorNoteL( *text ); |
|
1333 CleanupStack::PopAndDestroy( text ); |
|
1334 break; |
|
1335 } |
|
1336 |
|
1337 case ECSPUnknownUserId: // this error occurs when the userID is unknown |
|
1338 { |
|
1339 text = iEikonEnv->AllocReadResourceLC( |
|
1340 R_QTN_CHAT_VALIDATING_CONTACT_FAILED ); |
|
1341 IMDialogUtils::DisplayErrorNoteL( *text ); |
|
1342 CleanupStack::PopAndDestroy( text ); |
|
1343 |
|
1344 // move focus to wvid and highlight it |
|
1345 FocusEdwinL( EChatEditWV ); |
|
1346 |
|
1347 //iCCAContactEditPC->SetContactL( *iListId, *iNewUserId ); |
|
1348 |
|
1349 if ( iInternalMode != TEnumsPC::EAddToContact ) |
|
1350 { |
|
1351 CleanupStack::PopAndDestroy( oldUserId ); // oldUserId |
|
1352 } |
|
1353 |
|
1354 return EFalse; |
|
1355 } |
|
1356 |
|
1357 |
|
1358 case KErrNone: // contact added |
|
1359 { |
|
1360 iContactWasSaved = ETrue; |
|
1361 break; |
|
1362 } |
|
1363 |
|
1364 default: |
|
1365 { |
|
1366 // show error code |
|
1367 IMNoteMapper::ShowNoteL( iContactEditOperationError, *iNewUserId ); |
|
1368 break; |
|
1369 } |
|
1370 } |
|
1371 |
|
1372 if ( iInternalMode != TEnumsPC::EAddToContact ) |
|
1373 { |
|
1374 // editing a contact |
|
1375 |
|
1376 // got some error, so restore userid |
|
1377 if ( iContactEditOperationError != KErrNone ) |
|
1378 { |
|
1379 if ( oldUserId ) |
|
1380 { |
|
1381 delete iUserId; |
|
1382 iUserId = oldUserId; |
|
1383 } |
|
1384 CleanupStack::Pop( oldUserId ); |
|
1385 } |
|
1386 else |
|
1387 { |
|
1388 // it could be NULL, doesn't matter |
|
1389 CleanupStack::PopAndDestroy( oldUserId ); |
|
1390 } |
|
1391 } |
|
1392 |
|
1393 if ( iContactEditOperationError != KErrNone ) |
|
1394 { |
|
1395 return EFalse; |
|
1396 } |
|
1397 |
|
1398 |
|
1399 return ETrue; |
|
1400 } |
|
1401 |
|
1402 // --------------------------------------------------------- |
|
1403 // CCAContactEditor::DoNotSaveFormDataL |
|
1404 // Gets called when user chooses not to save data |
|
1405 // (other items were commented in a header). |
|
1406 // --------------------------------------------------------- |
|
1407 // |
|
1408 void CCAContactEditor::DoNotSaveFormDataL() |
|
1409 { |
|
1410 // Refresh screen data |
|
1411 if ( iInternalMode == TEnumsPC::EEditAfterView ) |
|
1412 { |
|
1413 iInternalMode = TEnumsPC::EViewContact; |
|
1414 LoadFormDataL(); |
|
1415 SetEditableL( EFalse ); |
|
1416 } |
|
1417 } |
|
1418 |
|
1419 // --------------------------------------------------------- |
|
1420 // CCAContactEditor::OkToExitL |
|
1421 // Button that was pressed for dismissing dialog |
|
1422 // (other items were commented in a header). |
|
1423 // --------------------------------------------------------- |
|
1424 // |
|
1425 TBool CCAContactEditor::OkToExitL( TInt aButtonId ) |
|
1426 { |
|
1427 CHAT_DP_TXT( "CCAContactEditor::OkToExitL" ); |
|
1428 if ( iSaveStarted ) |
|
1429 { |
|
1430 return EFalse; |
|
1431 } |
|
1432 |
|
1433 HideMenu(); |
|
1434 |
|
1435 if ( aButtonId == EAknSoftkeyEmpty ) |
|
1436 { |
|
1437 return EFalse; |
|
1438 } |
|
1439 // If user chose exit, then dialog can be dismissed from any state |
|
1440 if ( aButtonId == EEikCmdExit || aButtonId == EAknSoftkeyExit || aButtonId == EAknSoftkeyCancel ) |
|
1441 { |
|
1442 return ETrue; |
|
1443 } |
|
1444 |
|
1445 |
|
1446 // Functionality of EAknSoftkeyDone is the same as EAknSoftkeyBack |
|
1447 if ( aButtonId == EAknSoftkeyDone ) |
|
1448 { |
|
1449 aButtonId = EAknSoftkeyBack; |
|
1450 } |
|
1451 |
|
1452 if ( !iAppUI->UISessionManager().IsLoggedIn() ) |
|
1453 { |
|
1454 iAppUI->UISessionManager().LoginL(MCAUiLoginCmdCB::EQueryLogin); |
|
1455 SaveFormDataL(); |
|
1456 } |
|
1457 |
|
1458 // Call base class to handle the event |
|
1459 TBool okToExit( CAknForm::OkToExitL( aButtonId ) ); |
|
1460 |
|
1461 if ( aButtonId != EAknSoftkeyBack ) |
|
1462 { |
|
1463 return okToExit; |
|
1464 } |
|
1465 |
|
1466 if ( !iAppUI->UISessionManager().IsLoggedIn() ) |
|
1467 { |
|
1468 return EFalse; |
|
1469 } |
|
1470 |
|
1471 // iAllFieldsEmpty is ETrue if |
|
1472 // - Nothing has been changed. |
|
1473 // - All fields are empty |
|
1474 |
|
1475 // iContactDeleted is ETrue if |
|
1476 // - Contact is deleted |
|
1477 // - Wvid is empty and user wants to close edit mode. |
|
1478 |
|
1479 // iContactWasAdded is ETrue if |
|
1480 // - Contact is added successfully |
|
1481 |
|
1482 // None of these can be set at the same time if situation is ok to exit. |
|
1483 |
|
1484 if ( ( iAllFieldsEmpty ^ iContactDeleted ^ iContactWasSaved ) ) |
|
1485 { |
|
1486 if ( iInternalMode == EEditAfterView ) |
|
1487 { |
|
1488 // Change focus if needed |
|
1489 SetFocusToAvailableFieldL(); |
|
1490 //Set the internal state |
|
1491 DoNotSaveFormDataL(); |
|
1492 |
|
1493 // Reset flags |
|
1494 iAllFieldsEmpty = ETrue; |
|
1495 iContactDeleted = EFalse; |
|
1496 iContactWasSaved = EFalse; |
|
1497 return EFalse; |
|
1498 } |
|
1499 else |
|
1500 { |
|
1501 return ETrue; |
|
1502 } |
|
1503 } |
|
1504 return EFalse; |
|
1505 } |
|
1506 |
|
1507 // --------------------------------------------------------- |
|
1508 // CCAContactEditor::LaunchHelpL() |
|
1509 // (other items were commented in a header). |
|
1510 // --------------------------------------------------------- |
|
1511 // |
|
1512 void CCAContactEditor::LaunchHelpL( const TDesC& aContext ) |
|
1513 { |
|
1514 if ( FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
1515 { |
|
1516 //make context array |
|
1517 //granularity 1 is ok cos there is added just one item |
|
1518 CArrayFix< TCoeHelpContext >* cntx = new( ELeave ) CArrayFixFlat < |
|
1519 TCoeHelpContext > ( 1 ); |
|
1520 CleanupStack::PushL( cntx ); |
|
1521 |
|
1522 cntx->AppendL( TCoeHelpContext( KUidChatClient, aContext ) ); |
|
1523 CleanupStack::Pop( cntx ); |
|
1524 |
|
1525 //and launch help - takes ownership of context array |
|
1526 HlpLauncher::LaunchHelpApplicationL( |
|
1527 CEikonEnv::Static()->WsSession(), cntx ); |
|
1528 } |
|
1529 } |
|
1530 |
|
1531 // --------------------------------------------------------- |
|
1532 // CCAContactEditor::QuerySaveChangesL |
|
1533 // Do not ask about saving the contact |
|
1534 // (other items were commented in a header). |
|
1535 // --------------------------------------------------------- |
|
1536 // |
|
1537 TBool CCAContactEditor::QuerySaveChangesL() |
|
1538 { |
|
1539 return ETrue; |
|
1540 } |
|
1541 |
|
1542 |
|
1543 |
|
1544 // ----------------------------------------------------------------------------- |
|
1545 // CCAContactEditor::IsNonEditingKey() |
|
1546 // ----------------------------------------------------------------------------- |
|
1547 // |
|
1548 TBool CCAContactEditor::IsEditingKey( const TKeyEvent &aKeyEvent ) |
|
1549 { |
|
1550 switch ( aKeyEvent.iScanCode ) |
|
1551 { |
|
1552 // list of editing keys |
|
1553 case EStdKeyForwardSlash: // fallthrough |
|
1554 case EStdKeyBackSlash: |
|
1555 case EStdKeySemiColon: |
|
1556 case EStdKeySingleQuote: |
|
1557 case EStdKeyHash: |
|
1558 case EStdKeySquareBracketLeft: |
|
1559 case EStdKeySquareBracketRight: |
|
1560 case EStdKeyMinus: |
|
1561 case EStdKeyEquals: |
|
1562 case EStdKeyNkpForwardSlash: |
|
1563 case EStdKeyNkpAsterisk: |
|
1564 case EStdKeyNkpMinus: |
|
1565 case EStdKeyNkpPlus: |
|
1566 case EStdKeyNkpEnter: |
|
1567 case EStdKeyNkp1: |
|
1568 case EStdKeyNkp2: |
|
1569 case EStdKeyNkp3: |
|
1570 case EStdKeyNkp4: |
|
1571 case EStdKeyNkp5: |
|
1572 case EStdKeyNkp6: |
|
1573 case EStdKeyNkp7: |
|
1574 case EStdKeyNkp8: |
|
1575 case EStdKeyNkp9: |
|
1576 case EStdKeyNkp0: |
|
1577 case EStdKeyBackspace: |
|
1578 case EStdKeyTab: |
|
1579 case EStdKeyEnter: |
|
1580 case EStdKeySpace: |
|
1581 { |
|
1582 return ETrue; |
|
1583 } |
|
1584 } |
|
1585 |
|
1586 // qwerty keyboard: alphapetic keys 'a'-'z' |
|
1587 if ( aKeyEvent.iCode >= KAlphaCodeA && aKeyEvent.iCode <= KAlphaCodeZ ) |
|
1588 { |
|
1589 return ETrue; |
|
1590 } |
|
1591 |
|
1592 // numeric keys '0'-'9' |
|
1593 if ( aKeyEvent.iCode >= KNumCode0 && aKeyEvent.iCode <= KNumCode9 ) |
|
1594 { |
|
1595 return ETrue; |
|
1596 } |
|
1597 |
|
1598 // non editing key |
|
1599 return EFalse; |
|
1600 } |
|
1601 |
|
1602 |
|
1603 // ----------------------------------------------------------------------------- |
|
1604 // CCAContactEditor::FocusEdwinL |
|
1605 // ----------------------------------------------------------------------------- |
|
1606 // |
|
1607 void CCAContactEditor::FocusEdwinL( TInt aId, TBool aHighlight /*= EFalse*/ ) |
|
1608 { |
|
1609 TryChangeFocusToL( aId ); |
|
1610 CEikEdwin* wvField = GetFormEdwin( aId ); |
|
1611 if ( aHighlight ) |
|
1612 { |
|
1613 // Set field to be highlighted |
|
1614 wvField->SelectAllL(); |
|
1615 } |
|
1616 wvField->SetCursorPosL( wvField->TextLength(), aHighlight ); |
|
1617 } |
|
1618 |
|
1619 |
|
1620 // ----------------------------------------------------------------------------- |
|
1621 // CCAContactEditor::GetParameters |
|
1622 // this function is called by the contact edit object |
|
1623 // this function is called by the contact edit object |
|
1624 // based on the iContactEditOperation - The Command object |
|
1625 // gets the required data from UI |
|
1626 // ----------------------------------------------------------------------------- |
|
1627 // |
|
1628 |
|
1629 void CCAContactEditor::GetParameters( MCAUiContactEditCmdCB::TContactEditParams& aParam ) |
|
1630 { |
|
1631 |
|
1632 aParam.iContactEditOperation = iContactEditOperation; |
|
1633 |
|
1634 switch ( aParam.iContactEditOperation ) |
|
1635 { |
|
1636 case MCAUiContactEditCmdCB::TContactEditParams::ELoadContactDetails : |
|
1637 //load exisiting contact details |
|
1638 { |
|
1639 aParam.iAliasEnabled = iAliasEnabled; |
|
1640 aParam.iNicknameEnabled = iNicknameEnabled; |
|
1641 break; |
|
1642 } |
|
1643 |
|
1644 case MCAUiContactEditCmdCB::TContactEditParams::EAddContact : |
|
1645 //add a new contact |
|
1646 { |
|
1647 aParam.iListId = iListId; |
|
1648 aParam.iUserId = iNewUserId; |
|
1649 aParam.iNickname = iNick; |
|
1650 aParam.iAlias = iAlias; |
|
1651 aParam.iNewContact = ETrue; |
|
1652 break; |
|
1653 } |
|
1654 case MCAUiContactEditCmdCB::TContactEditParams::EUpdateContact : |
|
1655 //update an existing contact |
|
1656 { |
|
1657 aParam.iListId = iListId; |
|
1658 aParam.iUserId = iNewUserId; |
|
1659 aParam.iNickname = iNick; |
|
1660 aParam.iAlias = iAlias; |
|
1661 aParam.iNewContact = EFalse; |
|
1662 break; |
|
1663 } |
|
1664 case MCAUiContactEditCmdCB::TContactEditParams::EMoveContact : |
|
1665 //move a exisiting contact from one list to another |
|
1666 { |
|
1667 aParam.iListId = iListId; |
|
1668 aParam.iUserId = iUserId; |
|
1669 break; |
|
1670 } |
|
1671 default: |
|
1672 { |
|
1673 break; |
|
1674 } |
|
1675 } |
|
1676 } |
|
1677 |
|
1678 |
|
1679 // ----------------------------------------------------------------------------- |
|
1680 // CCAContactEditor::SetParameters |
|
1681 // this function is called by the contact edit object |
|
1682 // based on the iContactEditOperation - command object sets the |
|
1683 // data required by UI. |
|
1684 // The ownership of pointer varibles is also transferred to the UI. |
|
1685 // Hence UI must delete the allocated data. |
|
1686 // ----------------------------------------------------------------------------- |
|
1687 // |
|
1688 void CCAContactEditor::SetParameters( MCAUiContactEditCmdCB::TContactEditParams& aParam ) |
|
1689 { |
|
1690 switch ( aParam.iContactEditOperation ) |
|
1691 { |
|
1692 case MCAUiContactEditCmdCB::TContactEditParams::ELoadContactDetails : |
|
1693 { |
|
1694 iOwnStatus = aParam.iOwnData; |
|
1695 iOrigId = aParam.iOrigId; |
|
1696 iUserId = aParam.iUserId; |
|
1697 iAlias = aParam.iAlias; |
|
1698 iIdentification = aParam.iIdentification; |
|
1699 iNick = aParam.iNickname; |
|
1700 break; |
|
1701 } |
|
1702 |
|
1703 case MCAUiContactEditCmdCB::TContactEditParams::EAddContact : |
|
1704 case MCAUiContactEditCmdCB::TContactEditParams::EUpdateContact : |
|
1705 case MCAUiContactEditCmdCB::TContactEditParams::EMoveContact : |
|
1706 { |
|
1707 iContactEditOperationError = aParam.iContactEditOperationError; |
|
1708 break; |
|
1709 } |
|
1710 default: |
|
1711 { |
|
1712 break; |
|
1713 } |
|
1714 } |
|
1715 } |
|
1716 |
|
1717 |
|
1718 // ----------------------------------------------------------------------------- |
|
1719 // CCAContactEditor::DeleteCurrentContactL |
|
1720 // ----------------------------------------------------------------------------- |
|
1721 // |
|
1722 TInt CCAContactEditor::DeleteCurrentContactL( TBool aAskConfirmation /*= ETrue*/ ) |
|
1723 { |
|
1724 // can't delete self |
|
1725 if ( iOwnStatus ) |
|
1726 { |
|
1727 return KErrAccessDenied; |
|
1728 } |
|
1729 |
|
1730 // Get the name of the friend to be deleted |
|
1731 TPtrC name( *iIdentification ); |
|
1732 |
|
1733 // Load and format confirmation string from resource |
|
1734 HBufC* prompt = StringLoader::LoadLC( RSC_CHAT_DELETE_CONFIRMATION, name ); |
|
1735 |
|
1736 TInt ret = aAskConfirmation ? |
|
1737 IMDialogUtils::DisplayQueryDialogL( |
|
1738 R_GENERIC_YES_NO_CONFIRMATION_QUERY, *prompt ) : |
|
1739 EAknSoftkeyOk; |
|
1740 CleanupStack::PopAndDestroy( prompt ); |
|
1741 |
|
1742 TInt error( KErrCancel ); |
|
1743 |
|
1744 // Check what the user responded |
|
1745 if ( ( ret == EAknSoftkeyOk ) || ( ret == EAknSoftkeyYes ) ) |
|
1746 { |
|
1747 // accepted, lets delete the contact |
|
1748 iAppUI->ShowWaitDialogLC( R_QTN_CHAT_DELETING_CONTACT ); |
|
1749 |
|
1750 error = iCCAContactEditPC->DeleteCurrentContactL( *iListId, *iOrigId ); |
|
1751 |
|
1752 CleanupStack::PopAndDestroy(); //iAppUI->DismissWaitDialogL() |
|
1753 if ( error <= Imps_ERROR_BASE ) |
|
1754 { |
|
1755 // server error |
|
1756 IMNoteMapper::ShowNoteL( error ); |
|
1757 } |
|
1758 } |
|
1759 |
|
1760 return error; |
|
1761 } |
|
1762 |
|
1763 // ----------------------------------------------------------------------------- |
|
1764 // CCAContactEditor::GetListIdL() |
|
1765 // ----------------------------------------------------------------------------- |
|
1766 // |
|
1767 |
|
1768 HBufC* CCAContactEditor::GetListIdL( const TDesC& aId, TInt aNoListsResource ) |
|
1769 { |
|
1770 |
|
1771 TInt itemCount( 0 ); |
|
1772 CDesCArrayFlat* listIdArray = NULL; |
|
1773 |
|
1774 RArray <TInt> indexArray; |
|
1775 |
|
1776 HBufC* listId = NULL; |
|
1777 |
|
1778 listId = iCCAContactEditPC->GetListIdL( aId, aNoListsResource, itemCount, |
|
1779 listIdArray, indexArray, |
|
1780 ( iInternalMode == TEnumsPC::EMoveContact ) ? ETrue : EFalse |
|
1781 ); |
|
1782 |
|
1783 if ( !listId ) |
|
1784 { |
|
1785 if ( itemCount == 0 ) |
|
1786 { |
|
1787 if ( aNoListsResource != 0 ) |
|
1788 { |
|
1789 IMDialogUtils::DisplayInformationNoteL( aNoListsResource ); |
|
1790 } |
|
1791 else |
|
1792 { |
|
1793 // Show note with OK softkey, return value can be ignored |
|
1794 IMDialogUtils::DisplayQueryDialogL( R_QTN_CHAT_CEDITOR_NOCONTACTLISTS ); |
|
1795 TInt initValue = KErrNotFound; |
|
1796 // Advance to list creation |
|
1797 TInt ret = CCAUINGUtils::NewContactListL( initValue ); |
|
1798 |
|
1799 if ( ret == KErrNone ) |
|
1800 { |
|
1801 // List created succesfully, call this recursively to get list id |
|
1802 return iCCAContactEditPC->GetListIdL( aId, aNoListsResource, itemCount, |
|
1803 listIdArray, indexArray, |
|
1804 ( iInternalMode == TEnumsPC::EMoveContact ) ? ETrue : EFalse ); |
|
1805 } |
|
1806 else |
|
1807 { |
|
1808 CActiveScheduler::Current()->Error( ret ); |
|
1809 } |
|
1810 } |
|
1811 } |
|
1812 else if ( itemCount > 1 ) |
|
1813 { |
|
1814 //this means thats indexArray, listIdArray has been allocated by GetListIdL function. |
|
1815 //so we need to push the same in cleanupstack again |
|
1816 CleanupClosePushL( indexArray ); |
|
1817 CleanupStack::PushL( listIdArray ) ; |
|
1818 |
|
1819 TInt selectedIndex( 0 ); |
|
1820 HBufC* titleText = CCoeEnv::Static()->AllocReadResourceLC( |
|
1821 R_QTN_CHAT_SERVCONT_SELLIST ); |
|
1822 // launch the list query |
|
1823 TInt ret( IMDialogUtils::DisplayListQueryDialogL( &selectedIndex, listIdArray, |
|
1824 R_PRIVATE_CHAT_LIST_SELECT_RECIP_DLG, |
|
1825 *titleText, KNullDesC, ETrue ) ); |
|
1826 CleanupStack::PopAndDestroy( 2, listIdArray ); // listIdArray, titleText |
|
1827 |
|
1828 if ( ( ret == EAknSoftkeyOk || ret == EAknSoftkeyDone || ret == |
|
1829 EAknSoftkeySelect ) && ( iAppUI->UISessionManager().IsLoggedIn() ) ) |
|
1830 { |
|
1831 HBufC* listId = iCCAContactEditPC->GetListIdAtIndexL( indexArray[selectedIndex] ); |
|
1832 CleanupStack::PopAndDestroy( &indexArray ); //indexArray |
|
1833 return listId; |
|
1834 } |
|
1835 else |
|
1836 { |
|
1837 CleanupStack::PopAndDestroy( &indexArray ); //indexArray |
|
1838 } |
|
1839 } |
|
1840 } |
|
1841 |
|
1842 return listId; |
|
1843 } |
|
1844 |
|
1845 |
|
1846 // --------------------------------------------------------- |
|
1847 // CCAContactEditor::MoveContactL |
|
1848 // (other items were commented in a header). |
|
1849 // --------------------------------------------------------- |
|
1850 // |
|
1851 TBool CCAContactEditor::MoveContactL( const TDesC& aListId, |
|
1852 HBufC*& aMovedListId, TBool& aCollapsed ) |
|
1853 { |
|
1854 CHAT_DP_TXT( "CCAContactEditor::MoveContactL() start" ); |
|
1855 aMovedListId = NULL; |
|
1856 if ( !iCCAContactEditPC->IsContact() ) |
|
1857 { |
|
1858 User::Leave( KErrNotFound ); |
|
1859 } |
|
1860 |
|
1861 if ( !CCASyncChecker::CheckSyncStateL() ) |
|
1862 { |
|
1863 return EFalse; |
|
1864 } |
|
1865 |
|
1866 iInternalMode = TEnumsPC::EMoveContact; |
|
1867 |
|
1868 // select list |
|
1869 HBufC* listId = GetListIdL( aListId, R_QTN_CHAT_NO_LISTS ); |
|
1870 |
|
1871 if ( !listId ) |
|
1872 { |
|
1873 // no other lists available |
|
1874 return EFalse; |
|
1875 } |
|
1876 |
|
1877 // copy the listid, where the contacts has to be moved, |
|
1878 // Ownership is transfered to the caller. |
|
1879 aMovedListId = listId->AllocL(); |
|
1880 |
|
1881 // Get the status of the list(collapsed/expanded) |
|
1882 // before performing the actual move. |
|
1883 aCollapsed = iCCAContactEditPC->IsCollapsedL( *listId ); |
|
1884 |
|
1885 CleanupStack::PushL( listId ); |
|
1886 |
|
1887 /* In case the contact is already in the selected list, it is |
|
1888 removed from the current list, but not moved to the selected list anymore. |
|
1889 */ |
|
1890 // check if there's already a contact with same wvid |
|
1891 TBool contactInList( EFalse ); |
|
1892 TDesC* tmpUsrId = NULL; |
|
1893 const TDesC& userId = iCCAContactEditPC->GetCurrentContactUserId(); |
|
1894 |
|
1895 if ( iCCAContactEditPC->IsWVIDAvailableAndValidL( ETrue, *listId, |
|
1896 userId, |
|
1897 contactInList, tmpUsrId ) ) |
|
1898 { |
|
1899 if ( contactInList ) |
|
1900 { |
|
1901 TInt error = iCCAContactEditPC->DeleteCurrentContactL( aListId, userId ); |
|
1902 CleanupStack::PopAndDestroy(); |
|
1903 return EFalse; |
|
1904 } |
|
1905 } |
|
1906 |
|
1907 |
|
1908 iListId = aListId.AllocL(); |
|
1909 |
|
1910 iUserId = listId->AllocL(); |
|
1911 |
|
1912 CCAWaitNote* note = CCAWaitNote::ShowWaitNoteLC( |
|
1913 R_QTN_CHAT_MOVING_CONTACT ); |
|
1914 |
|
1915 iContactEditOperation = MCAUiContactEditCmdCB::TContactEditParams::EMoveContact; |
|
1916 iCCAContactEditCmd->ExecuteCommandL(); |
|
1917 |
|
1918 CleanupStack::PopAndDestroy( 2, listId ); //note, listid |
|
1919 |
|
1920 switch ( iContactEditOperationError ) |
|
1921 { |
|
1922 |
|
1923 case ECSPContactListFull: // flowthrough |
|
1924 { |
|
1925 HBufC* text = iEikonEnv->AllocReadResourceLC( |
|
1926 R_QTN_CHAT_CONTACT_LIST_FULL ); |
|
1927 IMDialogUtils::DisplayErrorNoteL( *text ); |
|
1928 CleanupStack::PopAndDestroy( text ); |
|
1929 break; |
|
1930 } |
|
1931 case KErrNone: |
|
1932 { |
|
1933 // show note |
|
1934 IMDialogUtils::DisplayConfirmationNoteL( R_QTN_CHAT_CONTACT_MOVED ); |
|
1935 return ETrue;// if the control comes here..move was successful... |
|
1936 } |
|
1937 case ECSPPartiallySuccessful: |
|
1938 { |
|
1939 CCAUINGUtils::HandlePartialSuccessL(); |
|
1940 break; |
|
1941 } |
|
1942 default: |
|
1943 { |
|
1944 IMNoteMapper::ShowNoteL( iContactEditOperationError ); |
|
1945 break; |
|
1946 } |
|
1947 } |
|
1948 |
|
1949 CHAT_DP_TXT( "CCAContactEditor::MoveContactL() done" ); |
|
1950 return EFalse;// if the control comes here..move was failed... |
|
1951 } |
|
1952 |
|
1953 |
|
1954 // End of File |