|
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: Process Component for Contact Editing |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // ============================ HEADER FILES =============================== |
|
21 // INCLUDE FILES |
|
22 #include "CCAContactEditPC.h" |
|
23 #include "CCAStorageManagerFactory.h" |
|
24 #include "MCAPresence.h" |
|
25 #include "CAPresenceManager.h" |
|
26 #include "MCAMainViewArrayPC.h" |
|
27 #include "MCAContactLists.h" |
|
28 #include "MCAPresence.h" |
|
29 #include "MCAPresenceError.h" |
|
30 #include "MCAPresenceErrors.h" |
|
31 #include "MCAContactList.h" |
|
32 #include "CCAMainViewArrayPC.h" |
|
33 #include "CAUtils.h" |
|
34 |
|
35 #include "ChatDebugAssert.h" |
|
36 #include "ChatDebugPrint.h" |
|
37 |
|
38 #include "MCAStoredContact.h" |
|
39 #include "MCAStoredContacts.h" |
|
40 #include "MCAProcessManager.h" |
|
41 #include "MCASettingsPC.h" |
|
42 |
|
43 |
|
44 // ============================ MEMBER FUNCTIONS =============================== |
|
45 |
|
46 |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CCAContactEditPC::NewL |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CCAContactEditPC* CCAContactEditPC::NewL( MCASettingsPC& aCCASettingsPC ) |
|
53 { |
|
54 CCAContactEditPC* self = CCAContactEditPC::NewLC( aCCASettingsPC ); |
|
55 CleanupStack::Pop( self ); |
|
56 return self; |
|
57 } |
|
58 |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CCAContactEditPC::NewLC |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 CCAContactEditPC* CCAContactEditPC::NewLC( MCASettingsPC& aCCASettingsPC ) |
|
65 { |
|
66 CCAContactEditPC* self = new( ELeave ) CCAContactEditPC( aCCASettingsPC ); |
|
67 CleanupStack::PushL( self ); |
|
68 return self; |
|
69 } |
|
70 |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // Destructor |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 CCAContactEditPC::~CCAContactEditPC() |
|
77 { |
|
78 |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CCAContactEditPC::CCAContactEditPC |
|
83 // |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 |
|
87 CCAContactEditPC::CCAContactEditPC( MCASettingsPC& aCCASettingsPC ) |
|
88 : iContact( NULL ), |
|
89 iCCASettingsPC( aCCASettingsPC ) |
|
90 |
|
91 { |
|
92 |
|
93 } |
|
94 |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CCAContactEditPC::GetContactDetailsL |
|
98 // |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 void CCAContactEditPC::GetContactDetailsL( |
|
102 const TBool aAliasEnabled, |
|
103 const TBool aNicknameEnabled, |
|
104 TBool& aOwnData, |
|
105 HBufC*& aOrigId, |
|
106 HBufC*& aAlias, |
|
107 HBufC*& aNickname, |
|
108 HBufC*& aUserId, |
|
109 HBufC*& aIdentification |
|
110 ) |
|
111 { |
|
112 |
|
113 if ( iContact ) |
|
114 { |
|
115 // found an existing contact, store the user id |
|
116 aOwnData = iOwnData; |
|
117 aUserId = iContact->UserId().AllocL(); |
|
118 |
|
119 aOrigId = iContact->UserId().AllocL(); |
|
120 |
|
121 aIdentification = iContact->Identification().AllocL(); |
|
122 |
|
123 if ( aAliasEnabled ) |
|
124 { |
|
125 |
|
126 aAlias = iContact->Alias().AllocL(); |
|
127 |
|
128 if ( ! aAlias->Length() ) |
|
129 { |
|
130 delete aAlias; |
|
131 aAlias = NULL; |
|
132 |
|
133 if ( aOwnData ) |
|
134 { |
|
135 // this is our own status |
|
136 // so get the alias from engine |
|
137 aAlias = iCCASettingsPC.GetSapSettingValuePCL( |
|
138 TEnumsPC::EOwnAlias, NULL ); |
|
139 |
|
140 iContact->SetAliasL( aAlias ? ( *aAlias ) : KNullDesC() ); |
|
141 |
|
142 } |
|
143 } |
|
144 |
|
145 } |
|
146 |
|
147 if ( aNicknameEnabled ) |
|
148 { |
|
149 aNickname = iContact->Nickname().AllocL(); |
|
150 } |
|
151 } |
|
152 |
|
153 } |
|
154 |
|
155 |
|
156 |
|
157 // ----------------------------------------------------------------------------- |
|
158 // CCAContactEditPC::IsWVIDAvailableAndValidL |
|
159 // |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 |
|
163 TBool CCAContactEditPC::IsWVIDAvailableAndValidL( TBool aCreateNew, |
|
164 const TDesC& aListId, |
|
165 const TDesC& aWVID, TBool& aContactInList, |
|
166 TDesC*& aUserID ) |
|
167 { |
|
168 |
|
169 TBool retValue = EFalse; |
|
170 TBool validContact = ETrue; //This is ETrue, if we are creating a new contact |
|
171 |
|
172 // check if there's already a contact with same wvid |
|
173 MCAStoredContacts* contacts = |
|
174 CCAStorageManagerFactory::ContactListInterfaceL(); |
|
175 |
|
176 |
|
177 MCAStoredContact* contactInList = contacts->FindContact( aListId, aWVID ); |
|
178 |
|
179 if ( !aCreateNew ) |
|
180 { |
|
181 //if contact editor in EditMode |
|
182 // validContact is EFalse if iContact not a valid contact |
|
183 validContact = contacts->IsContactValid( iContact ); |
|
184 } |
|
185 |
|
186 |
|
187 if ( contactInList && validContact ) |
|
188 { |
|
189 |
|
190 retValue = ETrue; |
|
191 |
|
192 if ( iContact != contactInList ) |
|
193 //this is a new contact |
|
194 { |
|
195 aContactInList = ETrue; |
|
196 aUserID = const_cast <TDesC *>( &contactInList->UserId() ); |
|
197 |
|
198 } |
|
199 } |
|
200 |
|
201 return retValue; |
|
202 |
|
203 } |
|
204 |
|
205 |
|
206 // ----------------------------------------------------------------------------- |
|
207 // CCAContactEditPC::FindAnyContactByNickL |
|
208 // |
|
209 // ----------------------------------------------------------------------------- |
|
210 // |
|
211 |
|
212 TBool CCAContactEditPC::FindAnyContactByNickL( const TDesC& aNickName ) |
|
213 { |
|
214 TBool retValue = EFalse; |
|
215 MCAStoredContacts* contacts = |
|
216 CCAStorageManagerFactory::ContactListInterfaceL(); |
|
217 |
|
218 MCAStoredContact* contact = contacts->FindAnyContactByNick( aNickName ); |
|
219 |
|
220 if ( ( contact ) && ( contact != iContact ) ) |
|
221 { |
|
222 retValue = ETrue; |
|
223 } |
|
224 return retValue; |
|
225 } |
|
226 |
|
227 |
|
228 |
|
229 // ----------------------------------------------------------------------------- |
|
230 // CCAContactEditPC::AddContactL |
|
231 // |
|
232 // ----------------------------------------------------------------------------- |
|
233 // |
|
234 |
|
235 TInt CCAContactEditPC::AddContactL( |
|
236 const TDesC& aListId, |
|
237 const TDesC& aWVID, const TDesC& aNickName, |
|
238 const TDesC& aAlias ) |
|
239 { |
|
240 // fetch the contacts in list |
|
241 MCAStoredContact *addedContact = NULL; |
|
242 MCAPresence* presence = CAPresenceManager::InstanceL(); |
|
243 MCAContactLists* listInterface = presence->ContactLists(); |
|
244 TRAPD( err, addedContact = listInterface->AddServerContactL( |
|
245 aListId, aWVID, aNickName ) ); |
|
246 |
|
247 if ( addedContact ) |
|
248 { |
|
249 if ( &aAlias ) //time being fix for crash |
|
250 { |
|
251 addedContact->SetAliasL( aAlias ); |
|
252 } |
|
253 iContact = addedContact; |
|
254 } |
|
255 return err; |
|
256 } |
|
257 |
|
258 |
|
259 // ----------------------------------------------------------------------------- |
|
260 // CCAContactEditPC::UpdateContactL |
|
261 // |
|
262 // ----------------------------------------------------------------------------- |
|
263 // |
|
264 TInt CCAContactEditPC::UpdateContactL( const TDesC& aListId, |
|
265 const TDesC& aWVID, |
|
266 const TDesC& aNickName ) |
|
267 { |
|
268 MCAPresence* presence = CAPresenceManager::InstanceL(); |
|
269 MCAContactLists* listInterface = presence->ContactLists(); |
|
270 |
|
271 TRAPD( err, listInterface->UpdateContactNicknameL( aListId, aWVID, |
|
272 aNickName ) ); |
|
273 return err; |
|
274 } |
|
275 |
|
276 |
|
277 |
|
278 // ----------------------------------------------------------------------------- |
|
279 // CCAContactEditPC::RemoveContactL |
|
280 // |
|
281 // ----------------------------------------------------------------------------- |
|
282 // |
|
283 |
|
284 TInt CCAContactEditPC::RemoveContactL( |
|
285 const TDesC& aListId, |
|
286 const TDesC& aWVID ) |
|
287 { |
|
288 // fetch the contacts in list |
|
289 MCAPresence* presence = CAPresenceManager::InstanceL(); |
|
290 MCAContactLists* listInterface = presence->ContactLists(); |
|
291 TRAPD( err, listInterface->DeleteServerContactL( aListId, aWVID ) ); |
|
292 return err; |
|
293 } |
|
294 |
|
295 // ----------------------------------------------------------------------------- |
|
296 // CCAContactEditPC::SetAnyContactL |
|
297 // |
|
298 // ----------------------------------------------------------------------------- |
|
299 // |
|
300 void CCAContactEditPC::SetAnyContactL( const TDesC& aWVID ) |
|
301 { |
|
302 MCAStoredContacts* contacts = |
|
303 CCAStorageManagerFactory::ContactListInterfaceL(); |
|
304 MCAStoredContact* contact = contacts->FindAnyContact( aWVID ); |
|
305 iContact = contact; |
|
306 } |
|
307 |
|
308 |
|
309 // ----------------------------------------------------------------------------- |
|
310 // CCAContactEditPC::SetContactL |
|
311 // |
|
312 // ----------------------------------------------------------------------------- |
|
313 // |
|
314 void CCAContactEditPC::SetContactL( const TDesC& aListId, |
|
315 const TDesC& aWVID ) |
|
316 { |
|
317 MCAStoredContacts* contacts = |
|
318 CCAStorageManagerFactory::ContactListInterfaceL(); |
|
319 MCAStoredContact* contact = contacts->FindContact( aListId, aWVID ); |
|
320 iContact = contact; |
|
321 } |
|
322 |
|
323 |
|
324 // ----------------------------------------------------------------------------- |
|
325 // CCAContactEditPC::GetCurrentContactNickname |
|
326 // |
|
327 // ----------------------------------------------------------------------------- |
|
328 // |
|
329 const TDesC& CCAContactEditPC::GetCurrentContactNickname() const |
|
330 { |
|
331 __CHAT_ASSERT_DEBUG( iContact ); |
|
332 return iContact->Nickname(); |
|
333 } |
|
334 |
|
335 // ----------------------------------------------------------------------------- |
|
336 // CCAContactEditPC::GetCurrentContactUserId |
|
337 // |
|
338 // ----------------------------------------------------------------------------- |
|
339 // |
|
340 const TDesC& CCAContactEditPC::GetCurrentContactUserId() const |
|
341 { |
|
342 __CHAT_ASSERT_DEBUG( iContact ); |
|
343 return iContact->UserId(); |
|
344 } |
|
345 |
|
346 |
|
347 // ----------------------------------------------------------------------------- |
|
348 // CCAContactEditPC::InitialiseL |
|
349 // |
|
350 // ----------------------------------------------------------------------------- |
|
351 // |
|
352 void CCAContactEditPC::InitialiseL( |
|
353 MCAMainViewArrayPC& aMainViewArrayPC, |
|
354 const TInt index, TBool& aOwnStatus ) |
|
355 { |
|
356 |
|
357 //reset the member variables |
|
358 iOwnData = EFalse; |
|
359 iContact = NULL; |
|
360 |
|
361 CCAMainViewArrayPC& ccaMainViewArrayPC = |
|
362 static_cast<CCAMainViewArrayPC&>( aMainViewArrayPC ); |
|
363 MCAStoredContacts* contactlist = |
|
364 CCAStorageManagerFactory::ContactListInterfaceL(); |
|
365 if ( index != -1 ) |
|
366 { |
|
367 iContact = ccaMainViewArrayPC.GetContactForContactEditor( index ) ; |
|
368 |
|
369 // check for own status |
|
370 if ( iContact == &contactlist->OwnStatus() ) |
|
371 { |
|
372 iOwnData = ETrue; |
|
373 aOwnStatus = ETrue; |
|
374 } |
|
375 |
|
376 } |
|
377 } |
|
378 |
|
379 // ----------------------------------------------------------------------------- |
|
380 // CCAContactEditPC::IsContact |
|
381 // |
|
382 // ----------------------------------------------------------------------------- |
|
383 // |
|
384 TBool CCAContactEditPC::IsContact() const |
|
385 { |
|
386 if ( iContact ) |
|
387 { |
|
388 return ETrue; |
|
389 } |
|
390 |
|
391 return EFalse; |
|
392 } |
|
393 |
|
394 |
|
395 // ----------------------------------------------------------------------------- |
|
396 // CCAContactEditPC::GetAliasFromPresenceL |
|
397 // |
|
398 // ----------------------------------------------------------------------------- |
|
399 // |
|
400 HBufC* CCAContactEditPC::GetAliasFromPresenceL( const TDesC& aWVID ) |
|
401 { |
|
402 // add mode - contact does not exist |
|
403 // get the alias from the network, |
|
404 MCAPresence* presence = CAPresenceManager::InstanceL(); |
|
405 |
|
406 if ( aWVID.Length() ) |
|
407 { |
|
408 return presence->AliasL( aWVID ); |
|
409 } |
|
410 else |
|
411 { |
|
412 // write manually, WVID does not exist, thus can't get alias |
|
413 // so use an empty alias |
|
414 return KNullDesC().AllocL(); |
|
415 } |
|
416 } |
|
417 |
|
418 |
|
419 // ----------------------------------------------------------------------------- |
|
420 // CCAContactEditPC::DeleteCurrentContactL |
|
421 // |
|
422 // ----------------------------------------------------------------------------- |
|
423 // |
|
424 TInt CCAContactEditPC::DeleteCurrentContactL( const TDesC& aListId, |
|
425 const TDesC& aOrigId ) |
|
426 { |
|
427 // can't delete self |
|
428 if ( iOwnData ) |
|
429 { |
|
430 return KErrAccessDenied; |
|
431 } |
|
432 |
|
433 MCAStoredContacts* contacts = |
|
434 CCAStorageManagerFactory::ContactListInterfaceL(); |
|
435 |
|
436 MCAPresence* presence = CAPresenceManager::InstanceL(); |
|
437 MCAContactLists* listInterface = presence->ContactLists(); |
|
438 |
|
439 // delete contact |
|
440 TRAPD( error, |
|
441 listInterface->DeleteServerContactL( aListId, aOrigId ) ); |
|
442 |
|
443 if ( error == KErrNone ) |
|
444 { |
|
445 iContact = NULL; |
|
446 } |
|
447 |
|
448 return error; |
|
449 } |
|
450 |
|
451 |
|
452 |
|
453 // ----------------------------------------------------------------------------- |
|
454 // CCAContactEditPC::LastContactEditOperationResultL |
|
455 // |
|
456 // ----------------------------------------------------------------------------- |
|
457 // |
|
458 const RPointerArray<MCAPresenceError>& CCAContactEditPC::LastContactEditOperationResultL( void ) |
|
459 { |
|
460 // show the detailed error codes |
|
461 MCAPresence* presence = CAPresenceManager::InstanceL(); |
|
462 MCAContactLists* listInterface = presence->ContactLists(); |
|
463 const MCAPresenceErrors& lastResult = |
|
464 listInterface->LastOperationResult(); |
|
465 return lastResult.DetailedErrors(); |
|
466 |
|
467 } |
|
468 |
|
469 |
|
470 |
|
471 // ----------------------------------------------------------------------------- |
|
472 // CCAContactEditPC::GetListIdLC |
|
473 // |
|
474 // ----------------------------------------------------------------------------- |
|
475 // |
|
476 HBufC* CCAContactEditPC::GetListIdL( const TDesC& aId, TInt /*aNoListsResource*/, |
|
477 TInt &aItemCount, CDesCArrayFlat*& aListIdArray, |
|
478 RArray< TInt > &aIndexArray, |
|
479 const TBool aMoveOperation /*= EFalse*/ ) |
|
480 { |
|
481 |
|
482 //make sure that we push iIndexArray to the cleanupstack |
|
483 CleanupClosePushL( aIndexArray ); |
|
484 |
|
485 MCAStoredContacts* contacts = CCAStorageManagerFactory::ContactListInterfaceL(); |
|
486 |
|
487 // Get list id from listquery. |
|
488 TInt listCount = contacts->ListCount(); |
|
489 |
|
490 // Granularity has to be > 0 |
|
491 aListIdArray = new ( ELeave ) CDesCArrayFlat( Max( listCount, 1 ) ); |
|
492 |
|
493 CleanupStack::PushL( aListIdArray ) ; |
|
494 |
|
495 if ( !aMoveOperation ) |
|
496 { |
|
497 //In case of Add, all contact lists in which contact is not available is shown. |
|
498 |
|
499 for ( TInt index( 0 ); index < listCount; ++index ) |
|
500 { |
|
501 MCAContactList& contactList = contacts->ListAt( index ) ; |
|
502 if ( !contacts->FindContact( contactList.ListId(), aId ) ) |
|
503 { |
|
504 aListIdArray->AppendL( contactList.DisplayName() ); |
|
505 aIndexArray.AppendL( index ); |
|
506 } |
|
507 } |
|
508 } |
|
509 else |
|
510 { |
|
511 /* In case of Move, all contact lists, except the current list, are shown in the list |
|
512 in same order as in IM contact list. |
|
513 */ |
|
514 for ( TInt index( 0 ); index < listCount; ++index ) |
|
515 { |
|
516 MCAContactList& contactList = contacts->ListAt( index ) ; |
|
517 TPtrC listid = contactList.ListId(); |
|
518 |
|
519 //check whether its the current contact list |
|
520 if ( !CAUtils::NeutralCompare( |
|
521 aId, |
|
522 listid, EFalse ) ) |
|
523 { |
|
524 //we have found the current list - Now add all other lists other |
|
525 //then the current one. |
|
526 for ( TInt jIndex( index + 1 ); jIndex < listCount; ++jIndex ) |
|
527 { |
|
528 MCAContactList& contactLst = contacts->ListAt( jIndex ) ; |
|
529 aListIdArray->AppendL( contactLst.DisplayName() ); |
|
530 aIndexArray.AppendL( jIndex ); |
|
531 } |
|
532 //all contact list has been added so break. |
|
533 break; |
|
534 |
|
535 } |
|
536 else |
|
537 { |
|
538 //this is not the current contact list so add it to the list |
|
539 aListIdArray->AppendL( contactList.DisplayName() ); |
|
540 aIndexArray.AppendL( index ); |
|
541 } |
|
542 } |
|
543 } |
|
544 |
|
545 |
|
546 aItemCount = aIndexArray.Count() ; |
|
547 |
|
548 if ( aItemCount == 0 ) |
|
549 { |
|
550 CleanupStack::PopAndDestroy( 2 ); //aIndexArray, aListIdArray |
|
551 aListIdArray = NULL; |
|
552 return NULL; |
|
553 } |
|
554 else if ( aItemCount == 1 ) |
|
555 { |
|
556 HBufC* listId = contacts->ListAt( aIndexArray[ 0 ] ).ListId().AllocL(); |
|
557 CleanupStack::PopAndDestroy( 2 ); //aIndexArray, aListIdArray |
|
558 aListIdArray = NULL; |
|
559 return listId; |
|
560 } |
|
561 |
|
562 CleanupStack::Pop( 2 ); //aIndexArray, aListIdArray |
|
563 |
|
564 return NULL; |
|
565 } |
|
566 |
|
567 |
|
568 |
|
569 // ----------------------------------------------------------------------------- |
|
570 // CCAContactEditPC::GetListIdAtIndexLC |
|
571 // |
|
572 // ----------------------------------------------------------------------------- |
|
573 // |
|
574 HBufC* CCAContactEditPC::GetListIdAtIndexL( TInt aSelectedIndex ) const |
|
575 { |
|
576 |
|
577 |
|
578 MCAStoredContacts* contacts = |
|
579 CCAStorageManagerFactory::ContactListInterfaceL(); |
|
580 HBufC* listId = contacts->ListAt( aSelectedIndex ).ListId().AllocL(); |
|
581 |
|
582 return listId; |
|
583 } |
|
584 |
|
585 |
|
586 // ----------------------------------------------------------------------------- |
|
587 // CCAContactEditPC::UpdateOwnAliasL |
|
588 // |
|
589 // ----------------------------------------------------------------------------- |
|
590 // |
|
591 TInt CCAContactEditPC::UpdateOwnAliasL( const TDesC & aAlias ) |
|
592 { |
|
593 |
|
594 TRAPD( errAlias, iCCASettingsPC.SetSapSettingValuePCL( TEnumsPC::EOwnAlias, |
|
595 aAlias, NULL, NULL ) ); |
|
596 |
|
597 if ( !errAlias ) |
|
598 { |
|
599 TRAPD ( err, iContact->SetAliasL( aAlias ) ); |
|
600 return err; |
|
601 } |
|
602 |
|
603 return errAlias; |
|
604 } |
|
605 |
|
606 |
|
607 // ----------------------------------------------------------------------------- |
|
608 // CCAContactEditPC::InitialiseL |
|
609 // |
|
610 // ----------------------------------------------------------------------------- |
|
611 // |
|
612 void CCAContactEditPC::InitialiseL( const TDesC& aWVID, |
|
613 const TDesC& aListId, TBool& aOwnStatus ) |
|
614 { |
|
615 |
|
616 //reset the member variables |
|
617 iOwnData = EFalse; |
|
618 iContact = NULL; |
|
619 |
|
620 MCAStoredContacts* contacts = |
|
621 CCAStorageManagerFactory::ContactListInterfaceL(); |
|
622 |
|
623 MCAStoredContact* contactInList = contacts->FindContact( aListId, aWVID ); |
|
624 |
|
625 if ( contactInList ) |
|
626 { |
|
627 iContact = contactInList; |
|
628 // check for own status |
|
629 if ( iContact == &contacts->OwnStatus() ) |
|
630 { |
|
631 iOwnData = ETrue; |
|
632 aOwnStatus = ETrue; |
|
633 } |
|
634 } |
|
635 |
|
636 } |
|
637 |
|
638 |
|
639 // ----------------------------------------------------------------------------- |
|
640 // CCAContactEditPC::GetOnlineStatus |
|
641 // |
|
642 // ----------------------------------------------------------------------------- |
|
643 // |
|
644 TEnumsPC::TOnlineStatus CCAContactEditPC::GetOnlineStatus() const |
|
645 { |
|
646 |
|
647 TEnumsPC::TOnlineStatus contactStatus = TEnumsPC::EUnknown; |
|
648 |
|
649 switch ( iContact->OnlineStatus() ) |
|
650 { |
|
651 case TStorageManagerGlobals::EUnknown : |
|
652 { |
|
653 contactStatus = TEnumsPC::EUnknown; |
|
654 break; |
|
655 } |
|
656 |
|
657 case TStorageManagerGlobals::EOffline : |
|
658 { |
|
659 contactStatus = TEnumsPC::EOffline; |
|
660 break; |
|
661 } |
|
662 |
|
663 case TStorageManagerGlobals::EOnline : |
|
664 { |
|
665 contactStatus = TEnumsPC::EOnline; |
|
666 break; |
|
667 } |
|
668 |
|
669 case TStorageManagerGlobals::EInvisible : |
|
670 { |
|
671 // this can only come for own status item, no need to check since |
|
672 // for other contacts this state is impossible |
|
673 contactStatus = TEnumsPC::EInvisible; |
|
674 break; |
|
675 } |
|
676 |
|
677 case TStorageManagerGlobals::EAway : |
|
678 { |
|
679 contactStatus = TEnumsPC::EAway; |
|
680 break; |
|
681 } |
|
682 |
|
683 case TStorageManagerGlobals::EBusy : |
|
684 { |
|
685 contactStatus = TEnumsPC::EBusy; |
|
686 break; |
|
687 } |
|
688 default : |
|
689 { |
|
690 __CHAT_ASSERT_DEBUG( EFalse ); |
|
691 break; |
|
692 } |
|
693 } |
|
694 |
|
695 return contactStatus; |
|
696 } |
|
697 |
|
698 |
|
699 // ----------------------------------------------------------------------------- |
|
700 // CCAContactEditPC::GetClientType |
|
701 // |
|
702 // ----------------------------------------------------------------------------- |
|
703 // |
|
704 TEnumsPC::TClientType CCAContactEditPC::GetClientType() const |
|
705 { |
|
706 |
|
707 TEnumsPC::TClientType clientType = TEnumsPC::EUnknownClient; |
|
708 |
|
709 switch ( iContact->ClientType() ) |
|
710 { |
|
711 case TStorageManagerGlobals::EUnknownClient : |
|
712 { |
|
713 clientType = TEnumsPC::EUnknownClient; |
|
714 break; |
|
715 } |
|
716 |
|
717 case TStorageManagerGlobals::EMobile : |
|
718 { |
|
719 clientType = TEnumsPC::EMobile; |
|
720 break; |
|
721 } |
|
722 |
|
723 case TStorageManagerGlobals::EPC : |
|
724 { |
|
725 clientType = TEnumsPC::EPC; |
|
726 break; |
|
727 } |
|
728 |
|
729 default : |
|
730 { |
|
731 __CHAT_ASSERT_DEBUG( EFalse ); |
|
732 break; |
|
733 } |
|
734 } |
|
735 |
|
736 return clientType; |
|
737 |
|
738 } |
|
739 |
|
740 // ----------------------------------------------------------------------------- |
|
741 // CCAContactEditPC::GetStatusText |
|
742 // |
|
743 // ----------------------------------------------------------------------------- |
|
744 // |
|
745 const TDesC& CCAContactEditPC::GetStatusText() const |
|
746 { |
|
747 __CHAT_ASSERT_DEBUG( iContact ); |
|
748 return iContact->StatusText(); |
|
749 } |
|
750 |
|
751 |
|
752 // ----------------------------------------------------------------------------- |
|
753 // CCAContactEditPC::GetCurrentContactIdentification |
|
754 // |
|
755 // ----------------------------------------------------------------------------- |
|
756 // |
|
757 const TDesC& CCAContactEditPC::GetCurrentContactIdentification() const |
|
758 { |
|
759 __CHAT_ASSERT_DEBUG( iContact ); |
|
760 return iContact->Identification(); |
|
761 } |
|
762 |
|
763 // ----------------------------------------------------------------------------- |
|
764 // CCAContactEditPC::GetCurrentContactAlias |
|
765 // |
|
766 // ----------------------------------------------------------------------------- |
|
767 // |
|
768 const TDesC& CCAContactEditPC::GetCurrentContactAlias() const |
|
769 { |
|
770 __CHAT_ASSERT_DEBUG( iContact ); |
|
771 return iContact->Alias(); |
|
772 } |
|
773 |
|
774 // ----------------------------------------------------------------------------- |
|
775 // CCAContactEditPC::ReleaseResources |
|
776 // |
|
777 // ----------------------------------------------------------------------------- |
|
778 // |
|
779 void CCAContactEditPC::ReleaseResources() |
|
780 { |
|
781 //reset the member variables |
|
782 iOwnData = EFalse; |
|
783 iContact = NULL; |
|
784 } |
|
785 |
|
786 // ----------------------------------------------------------------------------- |
|
787 // CCAContactEditPC::IsContactValidL |
|
788 // |
|
789 // ----------------------------------------------------------------------------- |
|
790 // |
|
791 TBool CCAContactEditPC::IsContactValidL( const TDesC& aListId ) |
|
792 { |
|
793 MCAStoredContacts* contactlist = |
|
794 CCAStorageManagerFactory::ContactListInterfaceL(); |
|
795 MCAStoredContact* contact = NULL; |
|
796 |
|
797 // Check for own status |
|
798 if ( iOwnData ) |
|
799 { |
|
800 contact = &contactlist->OwnStatus(); |
|
801 } |
|
802 else |
|
803 { |
|
804 // Find contact |
|
805 contact = contactlist->FindContact( aListId, iContact->UserId() ); |
|
806 } |
|
807 |
|
808 if ( contact && contact != iContact ) |
|
809 { |
|
810 // new contact pointer found for the original ID's. |
|
811 // Let's use it and assume the old one is invalid. |
|
812 CHAT_DP_TXT( "CCAContactEditPC::IsContactValidL: new pointer to contact!" ); |
|
813 iContact = contact; |
|
814 } |
|
815 return contact ? ETrue : EFalse; |
|
816 } |
|
817 |
|
818 |
|
819 // ----------------------------------------------------------------------------- |
|
820 // CCAContactEditPC::IsContactValidL |
|
821 // |
|
822 // ----------------------------------------------------------------------------- |
|
823 // |
|
824 TBool CCAContactEditPC::IsOwnData() const |
|
825 { |
|
826 return iOwnData; |
|
827 } |
|
828 |
|
829 // ----------------------------------------------------------------------------- |
|
830 // CCAMainViewArrayPC::SetCollapsed |
|
831 // ----------------------------------------------------------------------------- |
|
832 // |
|
833 TBool CCAContactEditPC::IsCollapsedL( const TDesC& aListId ) |
|
834 { |
|
835 // this operation should be on list only..otherwise throw exception.. |
|
836 TBool isCollapsed = EFalse; |
|
837 MCAStoredContacts* contactlist = |
|
838 CCAStorageManagerFactory::ContactListInterfaceL(); |
|
839 MCAContactList* contactList = contactlist->FindContactList( aListId ); |
|
840 isCollapsed = contactList->Collapsed(); |
|
841 return isCollapsed; |
|
842 } |
|
843 |
|
844 // ----------------------------------------------------------------------------- |
|
845 // CCAContactEditPC::DeleteContactL |
|
846 // ----------------------------------------------------------------------------- |
|
847 // |
|
848 TInt CCAContactEditPC::DeleteContactL( const TDesC& aBlockedContact ) |
|
849 { |
|
850 |
|
851 TInt errorCode( KErrNone ); |
|
852 |
|
853 // if block is in hide mode. We have to delete those items from contact lists. |
|
854 MCAStoredContacts* contacts = CCAStorageManagerFactory::ContactListInterfaceL(); |
|
855 |
|
856 |
|
857 TInt countOfLists( contacts->ListCount() ); |
|
858 for ( TInt listCount( 0 ); listCount < countOfLists && errorCode == KErrNone; ++listCount ) |
|
859 { |
|
860 MCAContactList& list = contacts->ListAt( listCount ); |
|
861 MCAStoredContact* contact = NULL; |
|
862 |
|
863 contact = contacts->FindContact( list.ListId(), aBlockedContact ); |
|
864 |
|
865 if ( contact ) |
|
866 { |
|
867 MCAPresence* presence = CAPresenceManager::InstanceL(); |
|
868 MCAContactLists* listInterface = presence->ContactLists(); |
|
869 // don't update to network directly |
|
870 TRAP( errorCode, listInterface->DeleteServerContactL( list.ListId(), |
|
871 contact->UserId(), EFalse ) ); |
|
872 } |
|
873 } |
|
874 |
|
875 // Update all changes with one operation |
|
876 MCAPresence* presence = CAPresenceManager::InstanceL(); |
|
877 MCAContactLists* listInterface = presence->ContactLists(); |
|
878 listInterface->CommitDeleteServerContactL(); |
|
879 |
|
880 return errorCode; |
|
881 } |
|
882 |
|
883 // End of File |