202 // |
197 // |
203 MVIMPSTStorageContactList* CVIMPSTStorageServiceView::CreateContactListL( |
198 MVIMPSTStorageContactList* CVIMPSTStorageServiceView::CreateContactListL( |
204 const TDesC& aContactListId, |
199 const TDesC& aContactListId, |
205 const TDesC& aDisplayName ) |
200 const TDesC& aDisplayName ) |
206 { |
201 { |
207 TRACE( T_LIT("CVIMPSTStorageServiceView::CreateContactListL() begin") ); |
202 TRACER_AUTO; |
208 CVIMPSTStorageContactList* contactList = |
203 CVIMPSTStorageContactList* contactList = |
209 CVIMPSTStorageContactList::NewLC(*iContactSorter, |
204 CVIMPSTStorageContactList::NewLC(*iContactSorter, |
210 aContactListId, |
205 aContactListId, |
211 aDisplayName ); |
206 aDisplayName ); |
212 |
207 |
213 TIdentityRelation< CVIMPSTStorageContactList > findBy( |
208 TIdentityRelation< CVIMPSTStorageContactList > findBy( |
214 CVIMPSTStorageServiceView::ContactListFindByContactListId); |
209 CVIMPSTStorageServiceView::ContactListFindByContactListId); |
215 TInt indexOfList( iContactListArray.Find( contactList, findBy ) ); |
210 TInt indexOfList( iContactListArray.Find( contactList, findBy ) ); |
216 if( indexOfList == KErrNotFound ) |
211 if( indexOfList == KErrNotFound ) |
217 { |
212 { |
218 TRACE( T_LIT("CVIMPSTStorageServiceView::CreateContactListL() list not exist in list") ); |
213 TRACE( "list not exist in list"); |
219 TLinearOrder< CVIMPSTStorageContactList > order( |
214 TLinearOrder< CVIMPSTStorageContactList > order( |
220 CVIMPSTStorageServiceView::ContactListOrderByDisplayName ); |
215 CVIMPSTStorageServiceView::ContactListOrderByDisplayName ); |
221 iContactListArray.InsertInOrderAllowRepeats( contactList, order ); |
216 iContactListArray.InsertInOrderAllowRepeats( contactList, order ); |
222 CleanupStack::Pop( contactList ); |
217 CleanupStack::Pop( contactList ); |
223 TRACE( T_LIT("CVIMPSTStorageServiceView::CreateContactListL() new list created") ); |
218 TRACE( " new list created"); |
224 } |
219 } |
225 else |
220 else |
226 { |
221 { |
227 TRACE( T_LIT("CVIMPSTStorageServiceView::CreateContactListL() list already exist in list") ); |
222 TRACE( " list already exist in list" ); |
228 CleanupStack::PopAndDestroy( contactList ); |
223 CleanupStack::PopAndDestroy( contactList ); |
229 contactList = iContactListArray[ indexOfList ]; |
224 contactList = iContactListArray[ indexOfList ]; |
230 } |
225 } |
231 TRACE( T_LIT("CVIMPSTStorageServiceView::CreateContactListL() end") ); |
|
232 return contactList; |
226 return contactList; |
233 } |
227 } |
234 |
228 |
235 // ----------------------------------------------------------------------------- |
229 // ----------------------------------------------------------------------------- |
236 // CVIMPSTStorageServiceView::RemoveContactList |
230 // CVIMPSTStorageServiceView::RemoveContactList |
237 // ----------------------------------------------------------------------------- |
231 // ----------------------------------------------------------------------------- |
238 // |
232 // |
239 void CVIMPSTStorageServiceView::RemoveContactList( const TDesC& aContactListId ) |
233 void CVIMPSTStorageServiceView::RemoveContactList( const TDesC& aContactListId ) |
240 { |
234 { |
241 TRACE( T_LIT("CVIMPSTStorageServiceView::RemoveContactList() begin") ); |
235 TRACER_AUTO; |
242 TInt pos( FindContactListById( aContactListId ) ); |
236 TInt pos( FindContactListById( aContactListId ) ); |
243 if( pos >= 0 ) |
237 if( pos >= 0 ) |
244 { |
238 { |
245 TRACE( T_LIT("CVIMPSTStorageServiceView::RemoveContactList() aContactListId found") ); |
239 TRACE( "aContactListId found" ); |
246 delete iContactListArray[ pos ]; |
240 delete iContactListArray[ pos ]; |
247 iContactListArray.Remove( pos ); |
241 iContactListArray.Remove( pos ); |
248 iContactListArray.Compress(); |
242 iContactListArray.Compress(); |
249 } |
243 } |
250 TRACE( T_LIT("CVIMPSTStorageServiceView::RemoveContactList() end") ); |
|
251 } |
244 } |
252 |
245 |
253 // ----------------------------------------------------------------------------- |
246 // ----------------------------------------------------------------------------- |
254 // CVIMPSTStorageServiceView::ListCount |
247 // CVIMPSTStorageServiceView::ListCount |
255 // Count of contactlists |
248 // Count of contactlists |
256 // ----------------------------------------------------------------------------- |
249 // ----------------------------------------------------------------------------- |
257 // |
250 // |
258 TInt CVIMPSTStorageServiceView::ListCount() const |
251 TInt CVIMPSTStorageServiceView::ListCount() const |
259 { |
252 { |
260 TRACE( T_LIT("CVIMPSTStorageServiceView::ListCount()") ); |
253 TRACER_AUTO; |
261 return iContactListArray.Count(); |
254 return iContactListArray.Count(); |
262 } |
255 } |
263 |
256 |
264 // ----------------------------------------------------------------------------- |
257 // ----------------------------------------------------------------------------- |
265 // CVIMPSTStorageServiceView::ListAt |
258 // CVIMPSTStorageServiceView::ListAt |
266 // Reference to contact list |
259 // Reference to contact list |
267 // ----------------------------------------------------------------------------- |
260 // ----------------------------------------------------------------------------- |
268 // |
261 // |
269 MVIMPSTStorageContactList& CVIMPSTStorageServiceView::ListAt( TInt aIndex ) const |
262 MVIMPSTStorageContactList& CVIMPSTStorageServiceView::ListAt( TInt aIndex ) const |
270 { |
263 { |
271 TRACE( T_LIT("CVIMPSTStorageServiceView::ListAt() begin") ); |
264 TRACER_AUTO; |
272 // User::LeaveIfError( aIndex < iContactListArray.Count() ? KErrNone : KErrArgument ); |
265 // User::LeaveIfError( aIndex < iContactListArray.Count() ? KErrNone : KErrArgument ); |
273 __ASSERT_ALWAYS( (aIndex < iContactListArray.Count() && aIndex >=0 ), Panic( EContactsArrayOutOfSync )); |
266 __ASSERT_ALWAYS( (aIndex < iContactListArray.Count() && aIndex >=0 ), Panic( EContactsArrayOutOfSync )); |
274 TRACE( T_LIT("CVIMPSTStorageServiceView::ListAt() end") ); |
|
275 return *iContactListArray[ aIndex ]; |
267 return *iContactListArray[ aIndex ]; |
276 } |
268 } |
277 // ----------------------------------------------------------------------------- |
269 // ----------------------------------------------------------------------------- |
278 // CVIMPSTStorageServiceView::ContactCount |
270 // CVIMPSTStorageServiceView::ContactCount |
279 // Count of contacts |
271 // Count of contacts |
280 // ----------------------------------------------------------------------------- |
272 // ----------------------------------------------------------------------------- |
281 // |
273 // |
282 TInt CVIMPSTStorageServiceView::ContactCount( TBool aSkipOfflineContacts ) const |
274 TInt CVIMPSTStorageServiceView::ContactCount( TBool aSkipOfflineContacts ) const |
283 { |
275 { |
284 TRACE( T_LIT("CVIMPSTStorageServiceView::ListAt() begin") ); |
276 TRACER_AUTO; |
285 TInt contactCount( 0 ); |
277 TInt contactCount( 0 ); |
286 TInt count( iContactListArray.Count() ); |
278 TInt count( iContactListArray.Count() ); |
287 for( TInt a( 0 ); a < count; ++a ) |
279 for( TInt a( 0 ); a < count; ++a ) |
288 { |
280 { |
289 contactCount += iContactListArray[ a ]->ContactCount( aSkipOfflineContacts, |
281 contactCount += iContactListArray[ a ]->ContactCount( aSkipOfflineContacts, |
290 EFalse ); |
282 EFalse ); |
291 } |
283 } |
292 TRACE( T_LIT("CVIMPSTStorageServiceView::ListAt() contactCount = %d") ,contactCount ); |
284 TRACE(" contactCount = %d" ,contactCount ); |
293 TRACE( T_LIT("CVIMPSTStorageServiceView::ListAt() end") ); |
|
294 return contactCount; |
285 return contactCount; |
295 } |
286 } |
296 |
287 |
297 // ----------------------------------------------------------------------------- |
288 // ----------------------------------------------------------------------------- |
298 // CVIMPSTStorageServiceView::UpdatepresenceL |
289 // CVIMPSTStorageServiceView::UpdatepresenceL |
303 TVIMPSTEnums::TOnlineStatus aStatus, |
294 TVIMPSTEnums::TOnlineStatus aStatus, |
304 const TDesC& aStatusText, |
295 const TDesC& aStatusText, |
305 const TDesC8& aAvatarData, |
296 const TDesC8& aAvatarData, |
306 TBool aIsClearingAvatar /*= EFalse*/) |
297 TBool aIsClearingAvatar /*= EFalse*/) |
307 { |
298 { |
308 TRACE( T_LIT("CVIMPSTStorageServiceView::UpdatePresenceL() begin") ); |
299 TRACER_AUTO; |
309 MVIMPSTStorageContact* contact = NULL; |
300 MVIMPSTStorageContact* contact = NULL; |
310 if( iOwnContact && ( aContactId.Compare( iOwnContact->UserId() ) == 0 ) ) |
301 if( iOwnContact && ( aContactId.Compare( iOwnContact->UserId() ) == 0 ) ) |
311 { |
302 { |
312 TRACE( T_LIT("CVIMPSTStorageServiceView::UpdatePresenceL() own Item presence") ); |
303 TRACE("own Item presence"); |
313 if( aAvatarData.Compare(iOwnContact->AvatarContent() ) != 0 ) |
304 if( aAvatarData.Compare(iOwnContact->AvatarContent() ) != 0 ) |
314 { |
305 { |
315 if((aIsClearingAvatar)||(aAvatarData.Length() > 0)) |
306 if((aIsClearingAvatar)||(aAvatarData.Length() > 0)) |
316 { |
307 { |
317 TRACE( T_LIT("CVIMPSTStorageServiceView::UpdatePresenceL() own avatar change NotifyAllObserversL") ); |
308 TRACE( "own avatar change NotifyAllObserversL"); |
318 iOwnContact->SetAvatarContentL( aAvatarData ,*iVPbkContactStore ); |
309 iOwnContact->SetAvatarContentL( aAvatarData ,*iVPbkContactStore ); |
319 NotifyAllObserversL(TVIMPSTEnums::EStorageAvatarChange,NULL,iOwnContact,0); |
310 NotifyAllObserversL(TVIMPSTEnums::EStorageAvatarChange,NULL,iOwnContact,0); |
320 } |
311 } |
321 } |
312 } |
322 if( ( iOwnContact->OnlineStatus() != aStatus ) || ( aStatusText.Compare( iOwnContact->StatusText() ) != 0 ) ) |
313 if( ( iOwnContact->OnlineStatus() != aStatus ) || ( aStatusText.Compare( iOwnContact->StatusText() ) != 0 ) ) |
323 { |
314 { |
324 // own presence has changes |
315 // own presence has changes |
325 // update to own presence |
316 // update to own presence |
326 iOwnContact->SetOnlineStatus( aStatus ); |
317 iOwnContact->SetOnlineStatus( aStatus ); |
327 iOwnContact->SetStatusTextL(aStatusText); |
318 iOwnContact->SetStatusTextL(aStatusText); |
328 TRACE( T_LIT("CVIMPSTStorageServiceView::UpdatePresenceL() own presene NotifyAllObserversL") ); |
319 TRACE( " own presene NotifyAllObserversL"); |
329 NotifyAllObserversL(TVIMPSTEnums::EStorageOwnPresenceChange,NULL, iOwnContact,0); |
320 NotifyAllObserversL(TVIMPSTEnums::EStorageOwnPresenceChange,NULL, iOwnContact,0); |
330 } |
321 } |
331 contact = iOwnContact; |
322 contact = iOwnContact; |
332 } |
323 } |
333 else |
324 else |
334 { |
325 { |
335 TRACE( T_LIT("CVIMPSTStorageServiceView::UpdatePresenceL() contact item ") ); |
326 TRACE( "contact item "); |
336 contact = FindContactByUserId( aContactId ); |
327 contact = FindContactByUserId( aContactId ); |
337 if(contact) |
328 if(contact) |
338 { |
329 { |
339 TRACE( T_LIT("CVIMPSTStorageServiceView::UpdatePresenceL() contact exist ") ); |
330 TRACE( "contact exist " ); |
340 TInt index = KErrNotFound; |
331 TInt index = KErrNotFound; |
341 TVIMPSTEnums::TOnlineStatus oldOnlineStatus = contact->OnlineStatus(); |
332 TVIMPSTEnums::TOnlineStatus oldOnlineStatus = contact->OnlineStatus(); |
342 TRACE( T_LIT("CVIMPSTStorageServiceView::UpdatePresenceL() contact oldOnlineStatus = %d"), oldOnlineStatus ); |
333 TRACE( "contact oldOnlineStatus = %d", oldOnlineStatus ); |
343 TRACE( T_LIT("CVIMPSTStorageServiceView::UpdatePresenceL() contact new presence = %d"), aStatus ); |
334 TRACE( "contact new presence = %d", aStatus ); |
344 //status text can be different for the sam status hence not inside the if condition. |
335 //status text can be different for the sam status hence not inside the if condition. |
345 if( oldOnlineStatus != aStatus ) |
336 if( oldOnlineStatus != aStatus ) |
346 { |
337 { |
347 TRACE( T_LIT("CVIMPSTStorageServiceView::UpdatePresenceL() contact presence change ") ); |
338 TRACE( "contact presence change "); |
|
339 |
348 contact->SetOnlineStatus( aStatus ); |
340 contact->SetOnlineStatus( aStatus ); |
349 TInt count = iContactListArray.Count(); |
341 TInt count = iContactListArray.Count(); |
350 for(TInt i = 0; i < count; i++) |
342 for(TInt i = 0; i < count; i++) |
351 { |
343 { |
352 index = iContactListArray[i]->FindIndexOfContact(contact); |
344 index = iContactListArray[i]->FindIndexOfContact(contact); |
353 if(KErrNotFound != index ) |
345 if(KErrNotFound != index ) |
354 { |
346 { |
355 iContactListArray[i]->ResortContact(contact); |
347 iContactListArray[i]->ResortContact(contact); |
356 TRACE( T_LIT("CVIMPSTStorageServiceView::UpdatePresenceL() contact ResortContact ") ); |
348 TRACE( "contact ResortContact " ); |
357 // get the index of the sorted contact, as after sorting the |
349 // get the index of the sorted contact, as after sorting the |
358 // index would have changed based on presence. |
350 // index would have changed based on presence. |
359 // break after the contact list is found and the contact is found |
351 // break after the contact list is found and the contact is found |
360 break; |
352 break; |
361 } |
353 } |
381 { |
373 { |
382 TInt oldIndex = IndexOfContact (contact); |
374 TInt oldIndex = IndexOfContact (contact); |
383 contact->SetAvatarContentL( aAvatarData ,*iVPbkContactStore); |
375 contact->SetAvatarContentL( aAvatarData ,*iVPbkContactStore); |
384 NotifyAllObserversL(TVIMPSTEnums::EStorageAvatarChange,NULL, contact, oldIndex ); |
376 NotifyAllObserversL(TVIMPSTEnums::EStorageAvatarChange,NULL, contact, oldIndex ); |
385 } |
377 } |
386 TRACE( T_LIT("CVIMPSTStorageServiceView::UpdatePresenceL() aStatusText = %S "), &aStatusText ); |
378 TRACE("aStatusText = %S ", &aStatusText ); |
387 TRACE( T_LIT("CVIMPSTStorageServiceView::UpdatePresenceL() NotifyAllObserversL called") ); |
379 TRACE( "NotifyAllObserversL called" ); |
388 TRACE( T_LIT("CVIMPSTStorageServiceView::UpdatePresenceL() NotifyAllObserversL finish") ); |
380 TRACE( "NotifyAllObserversL finish" ); |
389 } |
381 } |
390 } |
382 } |
391 TRACE( T_LIT("CVIMPSTStorageServiceView::UpdatePresenceL() end") ); |
|
392 return contact; |
383 return contact; |
393 } |
384 } |
394 |
385 |
395 // ----------------------------------------------------------------------------- |
386 // ----------------------------------------------------------------------------- |
396 // CVIMPSTStorageServiceView::UpdateAvatarL |
387 // CVIMPSTStorageServiceView::UpdateAvatarL |
397 // ----------------------------------------------------------------------------- |
388 // ----------------------------------------------------------------------------- |
398 // |
389 // |
399 MVIMPSTStorageContact* CVIMPSTStorageServiceView::UpdateAvatarL(const TDesC& aContactId, |
390 MVIMPSTStorageContact* CVIMPSTStorageServiceView::UpdateAvatarL(const TDesC& aContactId, |
400 const TDesC8& aAvatarData ) |
391 const TDesC8& aAvatarData ) |
401 { |
392 { |
402 TRACE( T_LIT("CVIMPSTStorageServiceView::UpdateAvatarL() begin") ); |
393 TRACER_AUTO; |
403 MVIMPSTStorageContact* contact = NULL; |
394 MVIMPSTStorageContact* contact = NULL; |
404 if( iOwnContact && ( aContactId.Compare( iOwnContact->UserId() ) == 0 ) ) |
395 if( iOwnContact && ( aContactId.Compare( iOwnContact->UserId() ) == 0 ) ) |
405 { |
396 { |
406 TRACE( T_LIT("CVIMPSTStorageServiceView::UpdateAvatarL() own avatar") ); |
397 TRACE( "own avatar" ); |
407 iOwnContact->SetAvatarContentL( aAvatarData ,*iVPbkContactStore); |
398 iOwnContact->SetAvatarContentL( aAvatarData ,*iVPbkContactStore); |
408 NotifyAllObserversL(TVIMPSTEnums::EStorageOwnPresenceChange,NULL, iOwnContact,0); |
399 NotifyAllObserversL(TVIMPSTEnums::EStorageOwnPresenceChange,NULL, iOwnContact,0); |
409 contact = iOwnContact; |
400 contact = iOwnContact; |
410 } |
401 } |
411 else |
402 else |
412 { |
403 { |
413 TRACE( T_LIT("CVIMPSTStorageServiceView::UpdateAvatarL() buddy avatar") ); |
404 TRACE( "buddy avatar" ); |
414 contact = FindContactByUserId( aContactId ); |
405 contact = FindContactByUserId( aContactId ); |
415 if(contact) |
406 if(contact) |
416 { |
407 { |
417 TRACE( T_LIT("CVIMPSTStorageServiceView::UpdateAvatarL() contact exit") ); |
408 TRACE( "contact exit"); |
418 contact->SetAvatarContentL( aAvatarData ,*iVPbkContactStore); |
409 contact->SetAvatarContentL( aAvatarData ,*iVPbkContactStore); |
419 TInt index = IndexOfContact(contact); |
410 TInt index = IndexOfContact(contact); |
420 NotifyAllObserversL(TVIMPSTEnums::EStorageAvatarChange,NULL, contact,index); |
411 NotifyAllObserversL(TVIMPSTEnums::EStorageAvatarChange,NULL, contact,index); |
421 TRACE( T_LIT("CVIMPSTStorageServiceView::UpdateAvatarL() NotifyAllObserversL called") ); |
412 TRACE( " NotifyAllObserversL called" ); |
422 } |
413 } |
423 } |
414 } |
424 TRACE( T_LIT("CVIMPSTStorageServiceView::UpdateAvatarL() end") ); |
|
425 return contact; |
415 return contact; |
426 } |
416 } |
427 |
417 |
428 // ----------------------------------------------------------------------------- |
418 // ----------------------------------------------------------------------------- |
429 // CVIMPSTStorageServiceView::FindContactListInternal |
419 // CVIMPSTStorageServiceView::FindContactListInternal |
430 // ----------------------------------------------------------------------------- |
420 // ----------------------------------------------------------------------------- |
431 // |
421 // |
432 CVIMPSTStorageContactList* CVIMPSTStorageServiceView::FindContactListInternal( |
422 CVIMPSTStorageContactList* CVIMPSTStorageServiceView::FindContactListInternal( |
433 const TDesC& aListId ) |
423 const TDesC& aListId ) |
434 { |
424 { |
435 TRACE( T_LIT("CVIMPSTStorageServiceView::FindContactListInternal begin") ); |
425 TRACER_AUTO; |
436 TInt contactListIndex( FindContactListById( aListId ) ); |
426 TInt contactListIndex( FindContactListById( aListId ) ); |
437 TRACE( T_LIT("CVIMPSTStorageServiceView::FindContactListInternal end ") ); |
|
438 return ( contactListIndex >= 0 ? iContactListArray[ contactListIndex ] : NULL ); |
427 return ( contactListIndex >= 0 ? iContactListArray[ contactListIndex ] : NULL ); |
439 } |
428 } |
440 |
429 |
441 // ----------------------------------------------------------------------------- |
430 // ----------------------------------------------------------------------------- |
442 // CVIMPSTStorageServiceView::FindContactList |
431 // CVIMPSTStorageServiceView::FindContactList |
443 // ----------------------------------------------------------------------------- |
432 // ----------------------------------------------------------------------------- |
444 // |
433 // |
445 MVIMPSTStorageContactList* CVIMPSTStorageServiceView::FindContactList( const TDesC& aListId ) |
434 MVIMPSTStorageContactList* CVIMPSTStorageServiceView::FindContactList( const TDesC& aListId ) |
446 { |
435 { |
447 TRACE( T_LIT("CVIMPSTStorageServiceView::FindContactList") ); |
436 TRACER_AUTO; |
448 return FindContactListInternal( aListId ); |
437 return FindContactListInternal( aListId ); |
449 } |
438 } |
450 |
439 |
451 // ----------------------------------------------------------------------------- |
440 // ----------------------------------------------------------------------------- |
452 // CVIMPSTStorageServiceView::FindContactListById |
441 // CVIMPSTStorageServiceView::FindContactListById |
453 // ----------------------------------------------------------------------------- |
442 // ----------------------------------------------------------------------------- |
454 // |
443 // |
455 TInt CVIMPSTStorageServiceView::FindContactListById(const TDesC& aListId ) |
444 TInt CVIMPSTStorageServiceView::FindContactListById(const TDesC& aListId ) |
456 { |
445 { |
457 TRACE( T_LIT("CVIMPSTStorageServiceView::FindContactList begin") ); |
446 TRACER_AUTO; |
458 TInt index = KErrNotFound; |
447 TInt index = KErrNotFound; |
459 TInt count( iContactListArray.Count() ); |
448 TInt count( iContactListArray.Count() ); |
460 TRACE( T_LIT("CVIMPSTStorageServiceView::FindContactList count = %d"), count ); |
449 TRACE( " count = %d", count ); |
461 for( TInt i= 0 ; i < count ; i++ ) |
450 for( TInt i= 0 ; i < count ; i++ ) |
462 { |
451 { |
463 if( KErrNone == VIMPSTStorageUtils::NeutralCompare( |
452 if( KErrNone == VIMPSTStorageUtils::NeutralCompare( |
464 aListId, |
453 aListId, |
465 iContactListArray[ i ]->ListId(), EFalse ) ) |
454 iContactListArray[ i ]->ListId(), EFalse ) ) |
466 { |
455 { |
467 TRACE( T_LIT("CVIMPSTStorageServiceView::FindContactList contact list found") ); |
456 TRACE( " contact list found" ); |
468 index = i; |
457 index = i; |
469 break; |
458 break; |
470 } |
459 } |
471 } |
460 } |
472 TRACE( T_LIT("CVIMPSTStorageServiceView::FindContactList end") ); |
|
473 return index; |
461 return index; |
474 } |
462 } |
475 |
463 |
476 // ----------------------------------------------------------------------------- |
464 // ----------------------------------------------------------------------------- |
477 // CVIMPSTStorageServiceView::FindContactListById |
465 // CVIMPSTStorageServiceView::FindContactListById |
478 // ----------------------------------------------------------------------------- |
466 // ----------------------------------------------------------------------------- |
479 // |
467 // |
480 MVIMPSTStorageContact* CVIMPSTStorageServiceView::FindContactByLink(const MVPbkContactLink& aContactLink ) |
468 MVIMPSTStorageContact* CVIMPSTStorageServiceView::FindContactByLink(const MVPbkContactLink& aContactLink ) |
481 { |
469 { |
482 TRACE( T_LIT("CVIMPSTStorageServiceView::FindContactByLink begin") ); |
470 TRACER_AUTO; |
483 MVIMPSTStorageContact* contact = NULL; |
471 MVIMPSTStorageContact* contact = NULL; |
484 TInt count( iContactListArray.Count() ); |
472 TInt count( iContactListArray.Count() ); |
485 for( TInt i= 0 ; i < count ; i++ ) |
473 for( TInt i= 0 ; i < count ; i++ ) |
486 { |
474 { |
487 CVIMPSTStorageContactList* contactList = iContactListArray[ i ]; |
475 CVIMPSTStorageContactList* contactList = iContactListArray[ i ]; |
488 contact = contactList->FindContactByContactLink( aContactLink ); |
476 contact = contactList->FindContactByContactLink( aContactLink ); |
489 if( contact ) |
477 if( contact ) |
490 { |
478 { |
491 TRACE( T_LIT("CVIMPSTStorageServiceView::FindContactByLink contact found = %d "), i ); |
479 TRACE( " contact found = %d ", i ); |
492 break; |
480 break; |
493 } |
481 } |
494 } |
482 } |
495 TRACE( T_LIT("CVIMPSTStorageServiceView::FindContactByLink end") ); |
|
496 return contact; |
483 return contact; |
497 } |
484 } |
498 |
485 |
499 // ----------------------------------------------------------------------------- |
486 // ----------------------------------------------------------------------------- |
500 // CVIMPSTStorageServiceView::GetServiceId |
487 // CVIMPSTStorageServiceView::GetServiceId |
501 // ----------------------------------------------------------------------------- |
488 // ----------------------------------------------------------------------------- |
502 // |
489 // |
503 TUint32 CVIMPSTStorageServiceView::GetServiceId() |
490 TUint32 CVIMPSTStorageServiceView::GetServiceId() |
504 { |
491 { |
505 TRACE( T_LIT("CVIMPSTStorageServiceView::GetServiceId") ); |
492 TRACER_AUTO; |
506 return iServiceId; |
493 return iServiceId; |
507 } |
494 } |
508 |
495 |
509 // ----------------------------------------------------------------------------- |
496 // ----------------------------------------------------------------------------- |
510 // CVIMPSTStorageServiceView::LocalStore |
497 // CVIMPSTStorageServiceView::LocalStore |
511 // ----------------------------------------------------------------------------- |
498 // ----------------------------------------------------------------------------- |
512 // |
499 // |
513 TBool CVIMPSTStorageServiceView::IsLocalStore() const |
500 TBool CVIMPSTStorageServiceView::IsLocalStore() const |
514 { |
501 { |
515 TRACE( T_LIT("CVIMPSTStorageServiceView::IsLocalStore") ); |
502 TRACER_AUTO; |
516 return iVPbkContactStore->LocalStore(); |
503 return iVPbkContactStore->LocalStore(); |
517 } |
504 } |
518 // ----------------------------------------------------------------------------- |
505 // ----------------------------------------------------------------------------- |
519 // CVIMPSTStorageServiceView::OwnContactL |
506 // CVIMPSTStorageServiceView::OwnContactL |
520 // ----------------------------------------------------------------------------- |
507 // ----------------------------------------------------------------------------- |
521 // |
508 // |
522 MVIMPSTStorageContact& CVIMPSTStorageServiceView::OwnContactL() |
509 MVIMPSTStorageContact& CVIMPSTStorageServiceView::OwnContactL() |
523 { |
510 { |
524 TRACE( T_LIT("CVIMPSTStorageServiceView::OwnContact begin") ); |
511 TRACER_AUTO; |
525 if( !iOwnContact ) |
512 if( !iOwnContact ) |
526 { |
513 { |
527 iOwnContact = CVIMPSTStorageContact::NewL(KNullDesC, |
514 iOwnContact = CVIMPSTStorageContact::NewL(KNullDesC, |
528 KNullDesC ) ; |
515 KNullDesC ) ; |
529 } |
516 } |
530 TRACE( T_LIT("CVIMPSTStorageServiceView::OwnContact end") ); |
|
531 return *iOwnContact; |
517 return *iOwnContact; |
532 } |
518 } |
533 |
519 |
534 // ----------------------------------------------------------------------------- |
520 // ----------------------------------------------------------------------------- |
535 // CVIMPSTStorageServiceView::SetOwnUserIdL |
521 // CVIMPSTStorageServiceView::SetOwnUserIdL |
536 // ----------------------------------------------------------------------------- |
522 // ----------------------------------------------------------------------------- |
537 // |
523 // |
538 void CVIMPSTStorageServiceView::SetOwnUserIdL(const TDesC& aUserId ) |
524 void CVIMPSTStorageServiceView::SetOwnUserIdL(const TDesC& aUserId ) |
539 { |
525 { |
540 TRACE( T_LIT("CVIMPSTStorageServiceView::SetOwnUserIdL begin") ); |
526 TRACER_AUTO; |
541 if( !iOwnContact ) |
527 if( !iOwnContact ) |
542 { |
528 { |
543 iOwnContact = CVIMPSTStorageContact::NewL(aUserId, |
529 iOwnContact = CVIMPSTStorageContact::NewL(aUserId, |
544 KNullDesC |
530 KNullDesC |
545 ) ; |
531 ) ; |
546 TRACE( T_LIT("CVIMPSTStorageServiceView::SetOwnUserIdL iOwnContact created") ); |
532 TRACE( "iOwnContact created" ); |
547 } |
533 } |
548 else if( aUserId.Compare( iOwnContact->UserId() ) != 0 ) |
534 else if( aUserId.Compare( iOwnContact->UserId() ) != 0 ) |
549 { |
535 { |
550 _LIT (KNullWithSpace, " "); |
536 _LIT (KNullWithSpace, " "); |
551 TRACE( T_LIT("CVIMPSTStorageServiceView::SetOwnUserIdL iOwnContact was existing") ); |
537 TRACE( "SetOwnUserIdL iOwnContact was existing" ); |
552 if(KNullWithSpace ().Compare(iOwnContact->UserId())!=0) |
538 if(KNullWithSpace ().Compare(iOwnContact->UserId())!=0) |
553 { |
539 { |
554 iVPbkContactStore->RemoveAllVPbkContactsL(); // if user id is changed remove all contacts |
540 iVPbkContactStore->RemoveAllVPbkContactsL(); // if user id is changed remove all contacts |
555 RemoveAllCacheContactsL(); |
541 RemoveAllCacheContactsL(); |
556 } |
542 } |
557 iOwnContact->SetUserIdL( aUserId ); |
543 iOwnContact->SetUserIdL( aUserId ); |
558 iOwnContact->SetAvatarContentL(KNullDesC8,*iVPbkContactStore ); |
544 iOwnContact->SetAvatarContentL(KNullDesC8,*iVPbkContactStore ); |
559 |
545 |
560 NotifyAllObserversL( TVIMPSTEnums::EStorageEventOwnUserChanged,NULL,iOwnContact,0 ); |
546 NotifyAllObserversL( TVIMPSTEnums::EStorageEventOwnUserChanged,NULL,iOwnContact,0 ); |
561 TRACE( T_LIT("CVIMPSTStorageServiceView::SetOwnUserIdL NotifyAllObserversL delivered") ); |
547 TRACE( "NotifyAllObserversL delivered" ); |
562 } |
548 } |
563 TRACE( T_LIT("CVIMPSTStorageServiceView::SetOwnUserIdL end") ); |
|
564 } |
549 } |
565 // ----------------------------------------------------------------------------- |
550 // ----------------------------------------------------------------------------- |
566 // CVIMPSTStorageServiceView::FindContactByUserId |
551 // CVIMPSTStorageServiceView::FindContactByUserId |
567 // From MVIMPSTStorageServiceView. |
552 // From MVIMPSTStorageServiceView. |
568 // Try to load with given ID, return NULL if not found. |
553 // Try to load with given ID, return NULL if not found. |
569 // ----------------------------------------------------------------------------- |
554 // ----------------------------------------------------------------------------- |
570 MVIMPSTStorageContact* CVIMPSTStorageServiceView::FindContactByUserId( const TDesC& aUserId ) |
555 MVIMPSTStorageContact* CVIMPSTStorageServiceView::FindContactByUserId( const TDesC& aUserId ) |
571 { |
556 { |
572 TRACE( T_LIT("CVIMPSTStorageServiceView::FindContactByUserId begin") ); |
557 TRACER_AUTO; |
573 MVIMPSTStorageContact* contact = NULL; |
558 MVIMPSTStorageContact* contact = NULL; |
574 CVIMPSTStorageContactList* contactList = NULL; |
559 CVIMPSTStorageContactList* contactList = NULL; |
575 TInt count( iContactListArray.Count() ); |
560 TInt count( iContactListArray.Count() ); |
576 for( TInt a( 0 ); a < count; ++a ) |
561 for( TInt a( 0 ); a < count; ++a ) |
577 { |
562 { |
578 contactList = iContactListArray[ a ]; |
563 contactList = iContactListArray[ a ]; |
579 contact = contactList->FindContact( aUserId ); |
564 contact = contactList->FindContact( aUserId ); |
580 if( contact ) |
565 if( contact ) |
581 { |
566 { |
582 TRACE( T_LIT("CVIMPSTStorageServiceView::FindContactByUserId contact found ") ); |
567 TRACE(" contact found " ); |
583 break; |
568 break; |
584 } |
569 } |
585 } |
570 } |
586 TRACE( T_LIT("CVIMPSTStorageServiceView::FindContactByUserId end") ); |
|
587 return contact; |
571 return contact; |
588 } |
572 } |
589 // ----------------------------------------------------------------------------- |
573 // ----------------------------------------------------------------------------- |
590 // CVIMPSTStorageServiceView::FindContactByUserId |
574 // CVIMPSTStorageServiceView::FindContactByUserId |
591 // From MVIMPSTStorageServiceView. |
575 // From MVIMPSTStorageServiceView. |
592 // Try to load with given ID, return NULL if not found. |
576 // Try to load with given ID, return NULL if not found. |
593 // ----------------------------------------------------------------------------- |
577 // ----------------------------------------------------------------------------- |
594 MVIMPSTStorageContact* CVIMPSTStorageServiceView::FindCacheContactByUserId( const TDesC& aUserId ) |
578 MVIMPSTStorageContact* CVIMPSTStorageServiceView::FindCacheContactByUserId( const TDesC& aUserId ) |
595 { |
579 { |
596 TRACE( T_LIT("CVIMPSTStorageServiceView::FindCacheContactByUserId") ); |
580 TRACER_AUTO; |
597 return FindContactByUserId( aUserId ); |
581 return FindContactByUserId( aUserId ); |
598 } |
582 } |
599 |
583 |
600 // ----------------------------------------------------------------------------- |
584 // ----------------------------------------------------------------------------- |
601 // CVIMPSTStorageServiceView::FindCacheContactByLink |
585 // CVIMPSTStorageServiceView::FindCacheContactByLink |
602 // From MVIMPSTStorageServiceView. |
586 // From MVIMPSTStorageServiceView. |
603 // Try to load with given ID, return NULL if not found. |
587 // Try to load with given ID, return NULL if not found. |
604 // ----------------------------------------------------------------------------- |
588 // ----------------------------------------------------------------------------- |
605 MVIMPSTStorageContact* CVIMPSTStorageServiceView::FindCacheContactByLink(const MVPbkContactLink& aContactLink ) |
589 MVIMPSTStorageContact* CVIMPSTStorageServiceView::FindCacheContactByLink(const MVPbkContactLink& aContactLink ) |
606 { |
590 { |
607 TRACE( T_LIT("CVIMPSTStorageServiceView::FindCacheContactByLink ") ); |
591 TRACER_AUTO; |
608 return FindContactByLink( aContactLink ); |
592 return FindContactByLink( aContactLink ); |
609 } |
593 } |
610 // ----------------------------------------------------------------------------- |
594 // ----------------------------------------------------------------------------- |
611 // CVIMPSTStorageServiceView::CreateContactL |
595 // CVIMPSTStorageServiceView::CreateContactL |
612 // ----------------------------------------------------------------------------- |
596 // ----------------------------------------------------------------------------- |
614 MVIMPSTStorageContact* CVIMPSTStorageServiceView::CreateNewContactL(const TDesC& aUserId, |
598 MVIMPSTStorageContact* CVIMPSTStorageServiceView::CreateNewContactL(const TDesC& aUserId, |
615 const TDesC& aDisplayName /*= KNullDesC*/, |
599 const TDesC& aDisplayName /*= KNullDesC*/, |
616 TBool aIsInvitationItem /*=EFalse*/, |
600 TBool aIsInvitationItem /*=EFalse*/, |
617 TBool aInvitationAutoAccept /*= EFalse */) |
601 TBool aInvitationAutoAccept /*= EFalse */) |
618 { |
602 { |
619 TRACE( T_LIT("CVIMPSTStorageServiceView::CreateNewContactL begin") ); |
603 TRACER_AUTO; |
620 // This will create a contact in the CDB file. It returns MVPbkContactLink link to the CDB file. |
604 // This will create a contact in the CDB file. It returns MVPbkContactLink link to the CDB file. |
621 MVIMPSTStorageContact* contact = FindCacheContactByUserId( aUserId ); |
605 MVIMPSTStorageContact* contact = FindCacheContactByUserId( aUserId ); |
622 if( !contact ) |
606 if( !contact ) |
623 { |
607 { |
624 iIsInvitationItem = aIsInvitationItem; |
608 iIsInvitationItem = aIsInvitationItem; |
625 TRACE( T_LIT("CVIMPSTStorageServiceView::CreateNewContactL contact does not exist in list") ); |
609 TRACE( "contact does not exist in list" ); |
626 iVPbkContactStore->CreateVPbkContactL( aUserId ,aDisplayName, aInvitationAutoAccept ); |
610 iVPbkContactStore->CreateVPbkContactL( aUserId ,aDisplayName, aInvitationAutoAccept ); |
627 TRACE( T_LIT("CVIMPSTStorageServiceView::CreateNewContactL new contact created") ); |
611 TRACE( "new contact created"); |
628 } |
612 } |
629 TRACE( T_LIT("CVIMPSTStorageServiceView::CreateNewContactL end") ); |
|
630 return contact; |
613 return contact; |
631 } |
614 } |
632 |
615 |
633 // ----------------------------------------------------------------------------- |
616 // ----------------------------------------------------------------------------- |
634 // CVIMPSTStorageServiceView::CreateNewFetchContactsL |
617 // CVIMPSTStorageServiceView::CreateNewFetchContactsL |
635 // ----------------------------------------------------------------------------- |
618 // ----------------------------------------------------------------------------- |
636 // |
619 // |
637 void CVIMPSTStorageServiceView::CreateNewFetchContactsL( RArray <TPtrC> &aFirstNameList, |
620 void CVIMPSTStorageServiceView::CreateNewFetchContactsL( RArray <TPtrC> &aFirstNameList, |
638 RArray <TPtrC> &aServiceField ) |
621 RArray <TPtrC> &aServiceField ) |
639 { |
622 { |
640 TRACE( T_LIT("CVIMPSTStorageServiceView::CreateNewFetchContactsL begin") ); |
623 TRACER_AUTO; |
641 if( !iVPbkContactStore->LocalStore() ) |
624 if( !iVPbkContactStore->LocalStore() ) |
642 { |
625 { |
643 RemoveAllCacheContactsL(); |
626 RemoveAllCacheContactsL(); |
644 } |
627 } |
645 iVPbkContactStore->AddVPbkFetchContactsL( aFirstNameList, aServiceField ); |
628 iVPbkContactStore->AddVPbkFetchContactsL( aFirstNameList, aServiceField ); |
646 TRACE( T_LIT("CVIMPSTStorageServiceView::CreateNewFetchContactsL end") ); |
|
647 } |
629 } |
648 |
630 |
649 // ----------------------------------------------------------------------------- |
631 // ----------------------------------------------------------------------------- |
650 // CVIMPSTStorageServiceView::RemoveContactL |
632 // CVIMPSTStorageServiceView::RemoveContactL |
651 // From MVIMPSTStorageServiceView. |
633 // From MVIMPSTStorageServiceView. |
652 // Try to load with given ID, return NULL if not found. |
634 // Try to load with given ID, return NULL if not found. |
653 // ----------------------------------------------------------------------------- |
635 // ----------------------------------------------------------------------------- |
654 |
636 |
655 TInt CVIMPSTStorageServiceView::RemoveContactL( MVIMPSTStorageContact* aContact ) |
637 TInt CVIMPSTStorageServiceView::RemoveContactL( MVIMPSTStorageContact* aContact ) |
656 { |
638 { |
657 TRACE( T_LIT("CVIMPSTStorageServiceView::RemoveContactL begin") ); |
639 TRACER_AUTO; |
658 TInt error = KErrArgument; |
640 TInt error = KErrArgument; |
659 if( aContact ) |
641 if( aContact ) |
660 { |
642 { |
661 TRACE( T_LIT("CVIMPSTStorageServiceView::RemoveContactL contact found") ); |
643 TRACE( "contact found" ); |
662 error = iVPbkContactStore->RemoveVPbkContactL( *aContact->ContactLink() ); |
644 error = iVPbkContactStore->RemoveVPbkContactL( *aContact->ContactLink() ); |
663 } |
645 } |
664 TRACE( T_LIT("CVIMPSTStorageServiceView::RemoveContactL end") ); |
|
665 return error; |
646 return error; |
666 } |
647 } |
667 |
648 |
668 |
649 |
669 // ----------------------------------------------------------------------------- |
650 // ----------------------------------------------------------------------------- |
670 // CVIMPSTStorageServiceView::RetriveLinkXSPIdsL |
651 // CVIMPSTStorageServiceView::RetriveLinkXSPIdsL |
671 // ----------------------------------------------------------------------------- |
652 // ----------------------------------------------------------------------------- |
672 // |
653 // |
673 TInt CVIMPSTStorageServiceView::RetriveLinkXSPIdsL(const TDesC8& aContactPackLink ) |
654 TInt CVIMPSTStorageServiceView::RetriveLinkXSPIdsL(const TDesC8& aContactPackLink ) |
674 { |
655 { |
675 TRACE( T_LIT("CVIMPSTStorageServiceView::RetriveLinkXSPIdsL") ); |
656 TRACER_AUTO; |
676 // return the no of retrived xsp of contacts |
657 // return the no of retrived xsp of contacts |
677 return iVPbkContactStore->RetrieveVPbkXSPIdL( aContactPackLink ); |
658 return iVPbkContactStore->RetrieveVPbkXSPIdL( aContactPackLink ); |
678 } |
659 } |
679 |
660 |
680 // --------------------------------------------------------------------------- |
661 // --------------------------------------------------------------------------- |
681 // CVIMPSTStorageServiceView::GetRetrieveXSPIdL |
662 // CVIMPSTStorageServiceView::GetRetrieveXSPIdL |
682 // --------------------------------------------------------------------------- |
663 // --------------------------------------------------------------------------- |
683 // |
664 // |
684 const TDesC& CVIMPSTStorageServiceView::GetRetrieveXSPIdL(TInt aIndex ) |
665 const TDesC& CVIMPSTStorageServiceView::GetRetrieveXSPIdL(TInt aIndex ) |
685 { |
666 { |
686 TRACE( T_LIT("CVIMPSTStorageServiceView::GetRetrieveXSPIdL aIndex = %d"),aIndex ); |
667 TRACER_AUTO; |
|
668 TRACE( " aIndex = %d",aIndex ); |
687 return iVPbkContactStore->GetRetrieveVPbkXSPIdL( aIndex ); |
669 return iVPbkContactStore->GetRetrieveVPbkXSPIdL( aIndex ); |
688 } |
670 } |
689 |
671 |
690 // ----------------------------------------------------------------------------- |
672 // ----------------------------------------------------------------------------- |
691 // CVIMPSTStorageServiceView::CreateNewContactFromRetrivedIdL |
673 // CVIMPSTStorageServiceView::CreateNewContactFromRetrivedIdL |
692 // ----------------------------------------------------------------------------- |
674 // ----------------------------------------------------------------------------- |
693 // |
675 // |
694 TInt CVIMPSTStorageServiceView::CreateNewContactFromRetrivedIdL( TInt aIndexToUse ) |
676 TInt CVIMPSTStorageServiceView::CreateNewContactFromRetrivedIdL( TInt aIndexToUse ) |
695 { |
677 { |
696 TRACE( T_LIT("CVIMPSTStorageServiceView::CreateNewContactFromRetrivedIdL aIndexToUse = %d"),aIndexToUse ); |
678 TRACER_AUTO; |
|
679 TRACE( "aIndexToUse = %d",aIndexToUse ); |
697 // This will create a contact in the CDB file. It returns MVPbkContactLink link to the CDB file. |
680 // This will create a contact in the CDB file. It returns MVPbkContactLink link to the CDB file. |
698 return iVPbkContactStore->CreateRetriveVPbkContactL( aIndexToUse ); |
681 return iVPbkContactStore->CreateRetriveVPbkContactL( aIndexToUse ); |
699 } |
682 } |
700 // ----------------------------------------------------------------------------- |
683 // ----------------------------------------------------------------------------- |
701 // CVIMPSTStorageServiceView::DeleteNewContactFromRetrivedIdL |
684 // CVIMPSTStorageServiceView::DeleteNewContactFromRetrivedIdL |
702 // ----------------------------------------------------------------------------- |
685 // ----------------------------------------------------------------------------- |
703 // |
686 // |
704 TInt CVIMPSTStorageServiceView::DeleteNewContactFromRetrivedIdL( TInt aIndexToUse ) |
687 TInt CVIMPSTStorageServiceView::DeleteNewContactFromRetrivedIdL( TInt aIndexToUse ) |
705 { |
688 { |
706 TRACE( T_LIT("CVIMPSTStorageServiceView::DeleteNewContactFromRetrivedIdL aIndexToUse = %d"),aIndexToUse ); |
689 TRACER_AUTO; |
|
690 TRACE( "aIndexToUse = %d",aIndexToUse ); |
707 // This will create a contact in the CDB file. It returns MVPbkContactLink link to the CDB file. |
691 // This will create a contact in the CDB file. It returns MVPbkContactLink link to the CDB file. |
708 return iVPbkContactStore->deleteRetriveVPbkContactL( aIndexToUse ); |
692 return iVPbkContactStore->deleteRetriveVPbkContactL( aIndexToUse ); |
709 } |
693 } |
710 |
694 |
711 // ---------------------------------------------------------- |
695 // ---------------------------------------------------------- |
712 // CVIMPSTStorageServiceView::DeleteDatabaseL |
696 // CVIMPSTStorageServiceView::DeleteDatabaseL |
713 // ---------------------------------------------------------- |
697 // ---------------------------------------------------------- |
714 void CVIMPSTStorageServiceView::DeleteDatabaseL() |
698 void CVIMPSTStorageServiceView::DeleteDatabaseL() |
715 { |
699 { |
716 TRACE( T_LIT("CVIMPSTStorageServiceView::DeleteDatabaseL") ); |
700 TRACER_AUTO; |
717 iVPbkContactStore->DeleteDatabaseL(); |
701 iVPbkContactStore->DeleteDatabaseL(); |
718 } |
702 } |
719 |
703 |
720 //================================================== from writer interface======================= |
704 //================================================== from writer interface======================= |
721 // ----------------------------------------------------------------------------- |
705 // ----------------------------------------------------------------------------- |
887 if( aContactToAdd->Name().Length() <= 0 && iUnNamedText ) |
869 if( aContactToAdd->Name().Length() <= 0 && iUnNamedText ) |
888 { |
870 { |
889 aContactToAdd->SetNameL( *iUnNamedText ); |
871 aContactToAdd->SetNameL( *iUnNamedText ); |
890 } |
872 } |
891 TInt index = KErrNotFound; |
873 TInt index = KErrNotFound; |
892 TRACE( T_LIT("CVIMPSTStorageServiceView::AddStorageContactToCacheL online status = %d "), TVIMPSTEnums::EPending); |
874 TRACE( " online status = %d ", TVIMPSTEnums::EPending); |
893 // if the userid(xsp field is null then the presence is unknown.) |
875 // if the userid(xsp field is null then the presence is unknown.) |
894 if(aContactToAdd->UserId().Length() == 0) |
876 if(aContactToAdd->UserId().Length() == 0) |
895 { |
877 { |
896 aContactToAdd->SetOnlineStatus(TVIMPSTEnums::EUnknown); |
878 aContactToAdd->SetOnlineStatus(TVIMPSTEnums::EUnknown); |
897 } |
879 } |
898 else |
880 else |
899 { |
881 { |
900 aContactToAdd->SetOnlineStatus(TVIMPSTEnums::EPending); |
882 aContactToAdd->SetOnlineStatus(TVIMPSTEnums::EPending); |
901 } |
883 } |
902 error = contactList->AddStorageContactToCacheL( aContactToAdd, index ); // aContactToAdd ownership is transfered |
884 error = contactList->AddStorageContactToCacheL( aContactToAdd, index ); // aContactToAdd ownership is transfered |
903 TRACE( T_LIT("CVIMPSTStorageServiceView::AddStorageContactToCacheL index = %d "),index ); |
885 TRACE( "index = %d ",index ); |
904 if( error == KErrNone ) |
886 if( error == KErrNone ) |
905 { |
887 { |
906 TInt count = iContactListArray.Count(); |
888 TInt count = iContactListArray.Count(); |
907 for(TInt i = 0; i < count; i++) |
889 for(TInt i = 0; i < count; i++) |
908 { |
890 { |
909 index = iContactListArray[i]->FindIndexOfContact(aContactToAdd); |
891 index = iContactListArray[i]->FindIndexOfContact(aContactToAdd); |
910 if(KErrNotFound != index ) |
892 if(KErrNotFound != index ) |
911 { |
893 { |
912 iContactListArray[i]->ResortContact(aContactToAdd); |
894 iContactListArray[i]->ResortContact(aContactToAdd); |
913 TRACE( T_LIT("CVIMPSTStorageServiceView::AddContactToCacheL() contact ResortContact ") ); |
895 TRACE( "contact ResortContact " ); |
914 // get the index of the sorted contact, as after sorting the |
896 // get the index of the sorted contact, as after sorting the |
915 // index would have changed based on presence. |
897 // index would have changed based on presence. |
916 // break after the contact list is found and the contact is found |
898 // break after the contact list is found and the contact is found |
917 break; |
899 break; |
918 } |
900 } |
919 } |
901 } |
920 index = IndexOfContact(aContactToAdd); |
902 index = IndexOfContact(aContactToAdd); |
921 NotifyAllObserversL( TVIMPSTEnums::EStorageEventContactAddition,NULL, aContactToAdd, index ); |
903 NotifyAllObserversL( TVIMPSTEnums::EStorageEventContactAddition,NULL, aContactToAdd, index ); |
922 } |
904 } |
923 } |
905 } |
924 TRACE( T_LIT("CVIMPSTStorageServiceView::AddStorageContactToCacheL error = %d "),error ); |
906 TRACE( " error = %d ",error ); |
925 TRACE( T_LIT("CVIMPSTStorageServiceView::AddStorageContactToCacheL end") ); |
|
926 return error; |
907 return error; |
927 } |
908 } |
928 // ----------------------------------------------------------------------------- |
909 // ----------------------------------------------------------------------------- |
929 // CVIMPSTStorageServiceView::RemoveContactFromCacheL |
910 // CVIMPSTStorageServiceView::RemoveContactFromCacheL |
930 // From MVIMPSTStorageServiceView. |
911 // From MVIMPSTStorageServiceView. |
954 } |
935 } |
955 TInt index = 0; |
936 TInt index = 0; |
956 error = contactList->RemoveContactFromCacheL( aContactLink, index ); |
937 error = contactList->RemoveContactFromCacheL( aContactLink, index ); |
957 NotifyAllObserversL( TVIMPSTEnums::EStorageEventContactDelete ,NULL,NULL,index); //contact is not valid ,deleted |
938 NotifyAllObserversL( TVIMPSTEnums::EStorageEventContactDelete ,NULL,NULL,index); //contact is not valid ,deleted |
958 } |
939 } |
959 TRACE( T_LIT("CVIMPSTStorageServiceView::RemoveContactFromCacheL error = %d "),error ); |
940 TRACE("error = %d ",error ); |
960 TRACE( T_LIT("CVIMPSTStorageServiceView::RemoveContactFromCacheL begin") ); |
|
961 return error; |
941 return error; |
962 } |
942 } |
963 // ----------------------------------------------------------------------------- |
943 // ----------------------------------------------------------------------------- |
964 // CVIMPSTStorageServiceView::RemoveAllCacheContactsL |
944 // CVIMPSTStorageServiceView::RemoveAllCacheContactsL |
965 // ----------------------------------------------------------------------------- |
945 // ----------------------------------------------------------------------------- |
966 // |
946 // |
967 void CVIMPSTStorageServiceView::RemoveAllCacheContactsL() |
947 void CVIMPSTStorageServiceView::RemoveAllCacheContactsL() |
968 { |
948 { |
969 TRACE( T_LIT("CVIMPSTStorageServiceView::RemoveContactFromCacheL begin") ); |
949 TRACER_AUTO; |
970 TRACE( T_LIT("CVIMPSTStorageServiceView::RemoveContactFromCacheL count = %d"), iContactListArray.Count()); |
950 TRACE( " count = %d", iContactListArray.Count()); |
971 iContactListArray.ResetAndDestroy(); |
951 iContactListArray.ResetAndDestroy(); |
972 TRACE( T_LIT("CVIMPSTStorageServiceView::RemoveContactFromCacheL remove sucess") ); |
952 TRACE( " remove sucess" ); |
973 NotifyAllObserversL(TVIMPSTEnums::EStorageAllContactRemoved,NULL,NULL,0 ); |
953 NotifyAllObserversL(TVIMPSTEnums::EStorageAllContactRemoved,NULL,NULL,0 ); |
974 TRACE( T_LIT("CVIMPSTStorageServiceView::RemoveContactFromCacheL begin") ); |
|
975 } |
954 } |
976 |
955 |
977 // ----------------------------------------------------------------------------- |
956 // ----------------------------------------------------------------------------- |
978 // CVIMPSTStorageServiceView::GetDefaultContactListL |
957 // CVIMPSTStorageServiceView::GetDefaultContactListL |
979 // ----------------------------------------------------------------------------- |
958 // ----------------------------------------------------------------------------- |
980 // |
959 // |
981 MVIMPSTStorageContactList* CVIMPSTStorageServiceView::GetDefaultContactListL() |
960 MVIMPSTStorageContactList* CVIMPSTStorageServiceView::GetDefaultContactListL() |
982 { |
961 { |
983 TRACE( T_LIT("CVIMPSTStorageServiceView::GetDefaultContactListL begin") ); |
962 TRACER_AUTO; |
984 MVIMPSTStorageContactList* contactList = FindContactListInternal( KFriendList ); |
963 MVIMPSTStorageContactList* contactList = FindContactListInternal( KFriendList ); |
985 TRACE( T_LIT("CVIMPSTStorageServiceView::GetDefaultContactListL end") ); |
|
986 return contactList; |
964 return contactList; |
987 } |
965 } |
988 // ----------------------------------------------------------------------------- |
966 // ----------------------------------------------------------------------------- |
989 // CVIMPSTStorageServiceView::NotifyServiceViewL |
967 // CVIMPSTStorageServiceView::NotifyServiceViewL |
990 // ----------------------------------------------------------------------------- |
968 // ----------------------------------------------------------------------------- |
991 // |
969 // |
992 void CVIMPSTStorageServiceView::NotifyServiceViewL( TVIMPSTEnums::TVIMPSTStorgaeEventType aEventType, |
970 void CVIMPSTStorageServiceView::NotifyServiceViewL( TVIMPSTEnums::TVIMPSTStorgaeEventType aEventType, |
993 MVIMPSTStorageContact* aContact /*= NULL */ ) |
971 MVIMPSTStorageContact* aContact /*= NULL */ ) |
994 { |
972 { |
995 TRACE( T_LIT("CVIMPSTStorageServiceView::NotifyServiceViewL begin") ); |
973 TRACER_AUTO; |
996 NotifyAllObserversL(aEventType,NULL, aContact,0 ); |
974 NotifyAllObserversL(aEventType,NULL, aContact,0 ); |
997 TRACE( T_LIT("CVIMPSTStorageServiceView::NotifyServiceViewL end") ); |
|
998 } |
975 } |
999 |
976 |
1000 //================================================== from writer interface end =========================== |
977 //================================================== from writer interface end =========================== |
1001 // TLinearOrder |
978 // TLinearOrder |
1002 // ----------------------------------------------------------------------------- |
979 // ----------------------------------------------------------------------------- |
1157 // |
1131 // |
1158 TInt CVIMPSTStorageServiceView::IndexOfList( MVIMPSTStorageContactList* aList, |
1132 TInt CVIMPSTStorageServiceView::IndexOfList( MVIMPSTStorageContactList* aList, |
1159 TBool /*aIgnoreOwnItem = EFalse*/, |
1133 TBool /*aIgnoreOwnItem = EFalse*/, |
1160 TBool /*aIgnoreEmptyLists = ETrue*/ ) const |
1134 TBool /*aIgnoreEmptyLists = ETrue*/ ) const |
1161 { |
1135 { |
1162 TRACE( T_LIT("CVIMPSTStorageServiceView::IndexOfList begin") ); |
1136 TRACER_AUTO; |
1163 TInt listCount( ListCount() ); |
1137 TInt listCount( ListCount() ); |
1164 TInt itemCount( 0 ); |
1138 TInt itemCount( 0 ); |
1165 for( TInt i(0); i<listCount; ++i ) |
1139 for( TInt i(0); i<listCount; ++i ) |
1166 { |
1140 { |
1167 MVIMPSTStorageContactList& list = ListAt(i); |
1141 MVIMPSTStorageContactList& list = ListAt(i); |
1168 if( &list == aList ) |
1142 if( &list == aList ) |
1169 { |
1143 { |
1170 TRACE( T_LIT("CVIMPSTStorageServiceView::IndexOfList list matched")); |
1144 TRACE( "list matched"); |
1171 break; |
1145 break; |
1172 } |
1146 } |
1173 else |
1147 else |
1174 { |
1148 { |
1175 // list will be consider for calculating the index |
1149 // list will be consider for calculating the index |
1176 // at initial state of fetching the list.count will be zero |
1150 // at initial state of fetching the list.count will be zero |
1177 // because all the lists will be fetched first and the contacts |
1151 // because all the lists will be fetched first and the contacts |
1178 itemCount = itemCount+ list.Count() + 1; |
1152 itemCount = itemCount+ list.Count() + 1; |
1179 } |
1153 } |
1180 } |
1154 } |
1181 TRACE( T_LIT("CVIMPSTStorageServiceView::IndexOfList itemCount = %d"),itemCount ); |
1155 TRACE( "itemCount = %d",itemCount ); |
1182 TRACE( T_LIT("CVIMPSTStorageServiceView::IndexOfList end") ); |
|
1183 return itemCount; |
1156 return itemCount; |
1184 } |
1157 } |
1185 // ----------------------------------------------------------------------------- |
1158 // ----------------------------------------------------------------------------- |
1186 // CVIMPSTContactListModel::MdcaCount |
1159 // CVIMPSTContactListModel::MdcaCount |
1187 // (other items were commented in a header). |
1160 // (other items were commented in a header). |
1188 // ----------------------------------------------------------------------------- |
1161 // ----------------------------------------------------------------------------- |
1189 // |
1162 // |
1190 TInt CVIMPSTStorageServiceView::MdcaCount() const |
1163 TInt CVIMPSTStorageServiceView::MdcaCount() const |
1191 { |
1164 { |
1192 TRACE( T_LIT("CVIMPSTStorageServiceView::MdcaCount") ); |
1165 TRACER_AUTO; |
1193 return Count(); |
1166 return Count(); |
1194 } |
1167 } |
1195 |
1168 |
1196 // ----------------------------------------------------------------------------- |
1169 // ----------------------------------------------------------------------------- |
1197 // CVIMPSTContactListModel::MdcaPoint |
1170 // CVIMPSTContactListModel::MdcaPoint |
1198 // (other items were commented in a header). |
1171 // (other items were commented in a header). |
1199 // ----------------------------------------------------------------------------- |
1172 // ----------------------------------------------------------------------------- |
1200 // |
1173 // |
1201 TPtrC CVIMPSTStorageServiceView::MdcaPoint( TInt /*aIndex */) const |
1174 TPtrC CVIMPSTStorageServiceView::MdcaPoint( TInt /*aIndex */) const |
1202 { |
1175 { |
1203 TRACE( T_LIT("CVIMPSTStorageServiceView::MdcaPoint") ); |
1176 TRACER_AUTO; |
1204 // These will be filtered out |
1177 // These will be filtered out |
1205 return KNullDesC(); |
1178 return KNullDesC(); |
1206 } |
1179 } |
1207 // ----------------------------------------------------------------------------- |
1180 // ----------------------------------------------------------------------------- |
1208 // CVIMPSTStorageServiceView::Sort |
1181 // CVIMPSTStorageServiceView::Sort |
1209 /// KNullDesC -> sort all |
1182 /// KNullDesC -> sort all |
1210 // ----------------------------------------------------------------------------- |
1183 // ----------------------------------------------------------------------------- |
1211 // |
1184 // |
1212 void CVIMPSTStorageServiceView::Sort( const TDesC& aContactListId /* = KNullDesC */ ) |
1185 void CVIMPSTStorageServiceView::Sort( const TDesC& aContactListId /* = KNullDesC */ ) |
1213 { |
1186 { |
1214 TRACE( T_LIT("CVIMPSTStorageServiceView::Sort() begin") ); |
1187 TRACER_AUTO; |
1215 if( aContactListId.Length() != 0 ) |
1188 if( aContactListId.Length() != 0 ) |
1216 { |
1189 { |
1217 MVIMPSTStorageContactList* list = FindContactList( aContactListId ); |
1190 MVIMPSTStorageContactList* list = FindContactList( aContactListId ); |
1218 if( list ) |
1191 if( list ) |
1219 { |
1192 { |
1220 TRACE( T_LIT("CVIMPSTStorageServiceView::Sort() list sort") ); |
1193 TRACE( " list sort" ); |
1221 list->Sort(); |
1194 list->Sort(); |
1222 } |
1195 } |
1223 } |
1196 } |
1224 else |
1197 else |
1225 { |
1198 { |
1226 TInt count( iContactListArray.Count() ); |
1199 TInt count( iContactListArray.Count() ); |
1227 for( TInt a( 0 ); a < count; ++a ) |
1200 for( TInt a( 0 ); a < count; ++a ) |
1228 { |
1201 { |
1229 MVIMPSTStorageContactList& list = *iContactListArray[ a ]; |
1202 MVIMPSTStorageContactList& list = *iContactListArray[ a ]; |
1230 TRACE( T_LIT("CVIMPSTStorageServiceView::Sort() all list sort") ); |
1203 TRACE( " all list sort" ); |
1231 list.Sort(); |
1204 list.Sort(); |
1232 } |
1205 } |
1233 } |
1206 } |
1234 TRACE( T_LIT("CVIMPSTStorageServiceView::Sort() end") ); |
|
1235 } |
1207 } |
1236 |
1208 |
1237 |
1209 |
1238 // ----------------------------------------------------------------------------- |
1210 // ----------------------------------------------------------------------------- |
1239 // CVIMPSTStorageServiceView::NotifyAllObservers |
1211 // CVIMPSTStorageServiceView::NotifyAllObservers |