103 MVIMPSTEnginePresenceSubService& presence = |
105 MVIMPSTEnginePresenceSubService& presence = |
104 MVIMPSTEnginePresenceSubService::Cast (*subService); |
106 MVIMPSTEnginePresenceSubService::Cast (*subService); |
105 presence.UnRegisterPresenceEventObserver(this); |
107 presence.UnRegisterPresenceEventObserver(this); |
106 } |
108 } |
107 |
109 |
108 TRACE( T_LIT("CVIMPSTProcessArray::~CVIMPSTProcessArray End") ); |
110 |
109 } |
111 } |
110 |
112 |
111 // -------------------------------------------------------------------------- |
113 // -------------------------------------------------------------------------- |
112 // CVIMPSTProcessArray::NewL |
114 // CVIMPSTProcessArray::NewL |
113 // -------------------------------------------------------------------------- |
115 // -------------------------------------------------------------------------- |
114 // |
116 // |
115 CVIMPSTProcessArray* CVIMPSTProcessArray::NewL( |
117 CVIMPSTProcessArray* CVIMPSTProcessArray::NewL( |
116 MVIMPSTEngine& aEngine) |
118 MVIMPSTEngine& aEngine) |
117 { |
119 { |
118 TRACE( T_LIT("CVIMPSTProcessArray::NewL Start") ); |
120 TRACER_AUTO; |
119 CVIMPSTProcessArray* self = new(ELeave) CVIMPSTProcessArray(aEngine); |
121 CVIMPSTProcessArray* self = new(ELeave) CVIMPSTProcessArray(aEngine); |
120 CleanupStack::PushL(self); |
122 CleanupStack::PushL(self); |
121 self->ConstructL(); |
123 self->ConstructL(); |
122 CleanupStack::Pop(self); |
124 CleanupStack::Pop(self); |
123 TRACE( T_LIT("CVIMPSTProcessArray::NewL End") ); |
|
124 return self; |
125 return self; |
125 |
126 |
126 } |
127 } |
127 |
128 |
128 // -------------------------------------------------------------------------- |
129 // -------------------------------------------------------------------------- |
129 // CVIMPSTProcessArray::ConstructL |
130 // CVIMPSTProcessArray::ConstructL |
130 // -------------------------------------------------------------------------- |
131 // -------------------------------------------------------------------------- |
131 // |
132 // |
132 void CVIMPSTProcessArray::ConstructL() |
133 void CVIMPSTProcessArray::ConstructL() |
133 { |
134 { |
134 TRACE( T_LIT("CVIMPSTProcessArray::ConstructL Start") ); |
135 |
|
136 TRACER_AUTO; |
135 iContactInterface = CVIMPSTStorageManagerFactory::ContactListInterfaceL(iServiceId); |
137 iContactInterface = CVIMPSTStorageManagerFactory::ContactListInterfaceL(iServiceId); |
136 if(iContactInterface) |
138 if(iContactInterface) |
137 { |
139 { |
138 iContactInterface->AddObserverL( this );// listen these events.. |
140 iContactInterface->AddObserverL( this );// listen these events.. |
139 HBufC* unnamed = VIMPSTUtils::LoadResourceL( R_SERVTAB_UNNAMED ); |
141 HBufC* unnamed = VIMPSTUtils::LoadResourceL( R_SERVTAB_UNNAMED ); |
170 MVIMPSTEnginePresenceSubService::Cast (*subService); |
172 MVIMPSTEnginePresenceSubService::Cast (*subService); |
171 presence.RegisterPresenceEventObserverL(this); |
173 presence.RegisterPresenceEventObserverL(this); |
172 iPresenceSupported = ETrue; |
174 iPresenceSupported = ETrue; |
173 } |
175 } |
174 ResetArray(); |
176 ResetArray(); |
175 TRACE( T_LIT("CVIMPSTProcessArray::ConstructL end") ); |
177 |
176 } |
178 } |
177 // -------------------------------------------------------------------------- |
179 // -------------------------------------------------------------------------- |
178 // CVIMPSTProcessArray::HandleStorageChangeL |
180 // CVIMPSTProcessArray::HandleStorageChangeL |
179 // -------------------------------------------------------------------------- |
181 // -------------------------------------------------------------------------- |
180 // |
182 // |
181 void CVIMPSTProcessArray::HandleStorageChangeL( TVIMPSTEnums::TVIMPSTStorgaeEventType aEventType, |
183 void CVIMPSTProcessArray::HandleStorageChangeL( TVIMPSTEnums::TVIMPSTStorgaeEventType aEventType, |
182 MVIMPSTStorageContactList* /*aList*/, |
184 MVIMPSTStorageContactList* /*aList*/, |
183 MVIMPSTStorageContact* aContact, |
185 MVIMPSTStorageContact* aContact, |
184 TInt aContactIndex ) |
186 TInt aContactIndex ) |
185 { |
187 { |
186 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL Function Start") ); |
188 |
|
189 TRACER_AUTO; |
187 // 0th index OwnItem + unknow contacts + add request |
190 // 0th index OwnItem + unknow contacts + add request |
188 aContactIndex = aContactIndex + 1 + iUnKnownContactArray.Count() + iAddRequestArray.Count(); |
191 aContactIndex = aContactIndex + 1 + iUnKnownContactArray.Count() + iAddRequestArray.Count(); |
189 |
192 |
190 switch( aEventType ) |
193 switch( aEventType ) |
191 { |
194 { |
192 case TVIMPSTEnums::EStorageContactReadComplete: |
195 case TVIMPSTEnums::EStorageContactReadComplete: |
193 { |
196 { |
194 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageContactReadComplete Start") ); |
197 TRACE("EStorageContactReadComplete"); |
195 if(iProcessObservers) |
198 if(iProcessObservers) |
196 { |
199 { |
197 /* passing 0 so that the focus is on owndata item */ |
200 /* passing 0 so that the focus is on owndata item */ |
198 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EOwnStatusItem, 0 ); // focus own item |
201 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EOwnStatusItem, 0 ); // focus own item |
199 } |
202 } |
200 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageContactReadComplete End") ); |
|
201 break; |
203 break; |
202 } |
204 } |
203 case TVIMPSTEnums::EStorageContactFetchComplete: |
205 case TVIMPSTEnums::EStorageContactFetchComplete: |
204 { |
206 { |
205 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageContactFetchComplete Start") ); |
207 TRACE("EStorageContactFetchComplete"); |
206 TRACE( T_LIT("HandleStorageChangeL EStorageContactFetchComplete iItemArray Count: %d"), iItemArray.Count() ); |
208 TRACE( " iItemArray Count: %d", iItemArray.Count() ); |
207 |
209 |
208 if(iProcessObservers) |
210 if(iProcessObservers) |
209 { |
211 { |
210 /* passing 0 so that the focus is on owndata item */ |
212 /* passing 0 so that the focus is on owndata item */ |
211 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EOwnStatusItem, 0 ); // focus own item |
213 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EOwnStatusItem, 0 ); // focus own item |
212 } |
214 } |
213 |
215 |
214 ResetArray(); |
216 ResetArray(); |
215 iFetchCompleted = ETrue; |
217 iFetchCompleted = ETrue; |
216 GetAndCreateOpenChatListL(); |
218 GetAndCreateOpenChatListL(); |
217 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageContactFetchComplete End") ); |
219 TRACE( "EStorageContactFetchComplete End" ); |
218 break; |
220 break; |
219 } |
221 } |
220 case TVIMPSTEnums::EStorageContactReading: |
222 case TVIMPSTEnums::EStorageContactReading: |
221 case TVIMPSTEnums::EStorageContactFetching: |
223 case TVIMPSTEnums::EStorageContactFetching: |
222 case TVIMPSTEnums::EStorageContactSynchronizing: |
224 case TVIMPSTEnums::EStorageContactSynchronizing: |
223 { |
225 { |
224 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageContactFetching/EStorageContactFetching Start") ); |
226 TRACE( "EStorageContactFetching/EStorageContactFetching" ); |
225 /* |
227 /* |
226 * This event occurs whenever we have contacts added to contactlist. This happens in the following scenarios |
228 * This event occurs whenever we have contacts added to contactlist. This happens in the following scenarios |
227 * 1. At the time of login, when we fetch contacts, contact-by-contact is added to the storage. so we get this event. |
229 * 1. At the time of login, when we fetch contacts, contact-by-contact is added to the storage. so we get this event. |
228 * 2. When we add a contact manually (either from phonebook, or manu adding etc.. ) we get this callback. |
230 * 2. When we add a contact manually (either from phonebook, or manu adding etc.. ) we get this callback. |
229 */ |
231 */ |
230 TRACE( T_LIT("contactindex = %d"),aContactIndex ); |
232 TRACE( "contactindex = %d",aContactIndex ); |
231 CVIMPSTProcessContactItem* contactItem = CVIMPSTProcessContactItem::NewL (*this, const_cast<TDesC&>(aContact->Name() ), |
233 CVIMPSTProcessContactItem* contactItem = CVIMPSTProcessContactItem::NewL (*this, const_cast<TDesC&>(aContact->Name() ), |
232 const_cast<TDesC&>(aContact->UserId() ), |
234 const_cast<TDesC&>(aContact->UserId() ), |
233 aContact->ContactLink(), |
235 aContact->ContactLink(), |
234 const_cast<TDesC&>(aContact->StatusText()), |
236 const_cast<TDesC&>(aContact->StatusText()), |
235 aContact->OnlineStatus()); |
237 aContact->OnlineStatus()); |
239 /* All the time the index should be less than the item array's count, but during the fetch of contacts from cdb file to the view, |
241 /* All the time the index should be less than the item array's count, but during the fetch of contacts from cdb file to the view, |
240 * if we havent got a contactviewready, and during that if I get contactaddition, before getting contactFetchComplete, we should keep |
242 * if we havent got a contactviewready, and during that if I get contactaddition, before getting contactFetchComplete, we should keep |
241 * appending the items to the array for display, once we get the entire list, its sorted anyway while insertion, and when presence occurs |
243 * appending the items to the array for display, once we get the entire list, its sorted anyway while insertion, and when presence occurs |
242 * the contacts are re-sorted. |
244 * the contacts are re-sorted. |
243 */ |
245 */ |
244 TRACE( T_LIT("itemarraycount = %d"),iItemArray.Count() ); |
246 TRACE( "itemarraycount = %d",iItemArray.Count() ); |
245 if (aContactIndex >= iItemArray.Count() ) |
247 if (aContactIndex >= iItemArray.Count() ) |
246 { |
248 { |
247 TRACE( T_LIT("append contact item %d"), contactItem); |
249 TRACE( "append contact item %d", contactItem); |
248 iItemArray.Append(contactItem); |
250 iItemArray.Append(contactItem); |
249 } |
251 } |
250 else |
252 else |
251 { |
253 { |
252 TRACE( T_LIT("Insert at index = %d"), aContactIndex); |
254 TRACE( "Insert at index = %d", aContactIndex); |
253 iItemArray.Insert(contactItem, aContactIndex ); |
255 iItemArray.Insert(contactItem, aContactIndex ); |
254 } |
256 } |
255 if(iProcessObservers) |
257 if(iProcessObservers) |
256 { |
258 { |
257 /* passing 0 so that the focus is on owndata item */ |
259 /* passing 0 so that the focus is on owndata item */ |
277 * This event occurs whenever we have contacts added to contactlist. This happens in the following scenarios |
279 * This event occurs whenever we have contacts added to contactlist. This happens in the following scenarios |
278 * 1. At the time of login, when we fetch contacts, contact-by-contact is added to the storage. so we get this event. |
280 * 1. At the time of login, when we fetch contacts, contact-by-contact is added to the storage. so we get this event. |
279 * 2. When we add a contact manually (either from phonebook, or manu adding etc.. ) we get this callback. |
281 * 2. When we add a contact manually (either from phonebook, or manu adding etc.. ) we get this callback. |
280 */ |
282 */ |
281 TPtrC userId = aContact->UserId(); |
283 TPtrC userId = aContact->UserId(); |
282 TRACE( T_LIT("contactindex = %d"),aContactIndex ); |
284 TRACE( "contactindex = %d",aContactIndex ); |
283 CVIMPSTProcessContactItem* contactItem = CVIMPSTProcessContactItem::NewL ( *this, aContact->Name() , |
285 CVIMPSTProcessContactItem* contactItem = CVIMPSTProcessContactItem::NewL ( *this, aContact->Name() , |
284 userId, |
286 userId, |
285 aContact->ContactLink(), |
287 aContact->ContactLink(), |
286 const_cast<TDesC&>(aContact->StatusText()), |
288 const_cast<TDesC&>(aContact->StatusText()), |
287 aContact->OnlineStatus() ); |
289 aContact->OnlineStatus() ); |
290 /* All the time the index should be less than the item array's count, but during the fetch of contacts from cdb file to the view, |
292 /* All the time the index should be less than the item array's count, but during the fetch of contacts from cdb file to the view, |
291 * if we havent got a contactviewready, and during that if I get contactaddition, before getting contactFetchComplete, we should keep |
293 * if we havent got a contactviewready, and during that if I get contactaddition, before getting contactFetchComplete, we should keep |
292 * appending the items to the array for display, once we get the entire list, its sorted anyway while insertion, and when presence occurs |
294 * appending the items to the array for display, once we get the entire list, its sorted anyway while insertion, and when presence occurs |
293 * the contacts are re-sorted. |
295 * the contacts are re-sorted. |
294 */ |
296 */ |
295 TRACE( T_LIT("itemarraycount = %d"),iItemArray.Count() ); |
297 TRACE( "itemarraycount = %d",iItemArray.Count() ); |
296 if (aContactIndex >= iItemArray.Count() ) |
298 if (aContactIndex >= iItemArray.Count() ) |
297 { |
299 { |
298 TRACE( T_LIT("append contact item = %d"), contactItem); |
300 TRACE( "append contact item = %d", contactItem); |
299 iItemArray.Append(contactItem); |
301 iItemArray.Append(contactItem); |
300 } |
302 } |
301 else |
303 else |
302 { |
304 { |
303 TRACE( T_LIT("Insert at index = %d"), aContactIndex); |
305 TRACE( "Insert at index = %d", aContactIndex); |
304 iItemArray.Insert(contactItem, aContactIndex ); |
306 iItemArray.Insert(contactItem, aContactIndex ); |
305 } |
307 } |
306 // check if pending message exist |
308 // check if pending message exist |
307 if( TVIMPSTEnums::ESVCERegistered == iLoginState && userId.Length() ) |
309 if( TVIMPSTEnums::ESVCERegistered == iLoginState && userId.Length() ) |
308 { |
310 { |
319 if(iProcessObservers) |
321 if(iProcessObservers) |
320 { |
322 { |
321 /* passing aContactIndex so that the focus is on owndata item */ |
323 /* passing aContactIndex so that the focus is on owndata item */ |
322 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, aContactIndex ); |
324 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, aContactIndex ); |
323 } |
325 } |
324 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactAddition End") ); |
326 |
325 break; |
327 break; |
326 } |
328 } |
327 case TVIMPSTEnums::EStorageEventContactDelete: |
329 case TVIMPSTEnums::EStorageEventContactDelete: |
328 { |
330 { |
329 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactDelete Start") ); |
331 TRACE( " EStorageEventContactDelete" ); |
330 TRACE( T_LIT("contactindex = %d"),aContactIndex ); |
332 TRACE( "contactindex = %d",aContactIndex ); |
331 TRACE( T_LIT("itemarraycount = %d"),iItemArray.Count() ); |
333 TRACE( "itemarraycount = %d",iItemArray.Count() ); |
332 if( aContactIndex < iItemArray.Count() ) |
334 if( aContactIndex < iItemArray.Count() ) |
333 { |
335 { |
334 MVIMPSTProcessArrayItem* deletedItem = iItemArray[ aContactIndex ]; |
336 MVIMPSTProcessArrayItem* deletedItem = iItemArray[ aContactIndex ]; |
335 TRACE( T_LIT("contact removed in item array of index = %d"),aContactIndex ); |
337 TRACE( "contact removed in item array of index = %d",aContactIndex ); |
336 iItemArray.Remove (aContactIndex); |
338 iItemArray.Remove (aContactIndex); |
337 delete deletedItem; |
339 delete deletedItem; |
338 iItemArray.Compress(); |
340 iItemArray.Compress(); |
339 TRACE( T_LIT("contactindex = %d"),aContactIndex ); |
341 TRACE( "contactindex = %d",aContactIndex ); |
340 } |
342 } |
341 if(iProcessObservers) |
343 if(iProcessObservers) |
342 { |
344 { |
343 iProcessObservers->HandleDeletionL(TVIMPSTEnums::EContactItem, aContactIndex); |
345 iProcessObservers->HandleDeletionL(TVIMPSTEnums::EContactItem, aContactIndex); |
344 } |
346 } |
345 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactDelete End") ); |
|
346 break; |
347 break; |
347 } |
348 } |
348 case TVIMPSTEnums::EStorageAvatarChange: |
349 case TVIMPSTEnums::EStorageAvatarChange: |
349 { |
350 { |
350 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange Start") ); |
351 TRACE("EStorageAvatarChange"); |
351 if(iProcessObservers && aContact ) |
352 if(iProcessObservers && aContact ) |
352 { |
353 { |
353 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange inside if") ); |
354 TRACE( "EStorageAvatarChange inside if" ); |
354 TPtrC aUserId = aContact->UserId(); |
355 TPtrC aUserId = aContact->UserId(); |
355 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange aUserId = %S"), &aUserId ); |
356 TRACE( "EStorageAvatarChange aUserId = %S", &aUserId ); |
356 iProcessObservers->HandleAvatarChangeL( aContact->UserId() ); |
357 iProcessObservers->HandleAvatarChangeL( aContact->UserId() ); |
357 } |
358 } |
358 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange End") ); |
|
359 break; |
359 break; |
360 } |
360 } |
361 case TVIMPSTEnums::EStorageOwnPresenceChange: |
361 case TVIMPSTEnums::EStorageOwnPresenceChange: |
362 { |
362 { |
363 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange Start") ); |
363 TRACE( "EStorageOwnPresenceChange" ); |
364 if(iProcessObservers) |
364 if(iProcessObservers) |
365 { |
365 { |
366 /* passing index as 0, so thta focus remains at the owndata item */ |
366 /* passing index as 0, so thta focus remains at the owndata item */ |
367 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EOwnStatusItem, KErrNotFound ); |
367 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EOwnStatusItem, KErrNotFound ); |
368 } |
368 } |
369 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange End") ); |
|
370 break; |
369 break; |
371 } |
370 } |
372 case TVIMPSTEnums::EStorageMultiplePresenceChange: |
371 case TVIMPSTEnums::EStorageMultiplePresenceChange: |
373 { |
372 { |
374 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange Start") ); |
373 TRACE("EStorageMultiplePresenceChange " ); |
375 // mostly this will get called after just login and fetch time |
374 // mostly this will get called after just login and fetch time |
376 ResetArray(); |
375 ResetArray(); |
377 if(iProcessObservers ) |
376 if(iProcessObservers ) |
378 { |
377 { |
379 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, KErrNotFound ); |
378 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, KErrNotFound ); |
380 } |
379 } |
381 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange End") ); |
|
382 break; |
380 break; |
383 } |
381 } |
384 case TVIMPSTEnums::EStoragePresenceChange: |
382 case TVIMPSTEnums::EStoragePresenceChange: |
385 { |
383 { |
386 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStoragePresenceChange Start") ); |
384 TRACE( " EStoragePresenceChange" ); |
387 /* |
385 /* |
388 * After Sort we get the new index... So first we need to remove the contact from the old position, |
386 * After Sort we get the new index... So first we need to remove the contact from the old position, |
389 * and then re-insert it at the correct obtained position (newIndex in this case) |
387 * and then re-insert it at the correct obtained position (newIndex in this case) |
390 */ |
388 */ |
391 TRACE( T_LIT("contactindex = %d"),aContactIndex ); |
389 TRACE("contactindex = %d",aContactIndex ); |
392 TRACE( T_LIT("itemarraycount = %d"),iItemArray.Count() ); |
390 TRACE( "itemarraycount = %d",iItemArray.Count() ); |
393 if( aContactIndex < iItemArray.Count() ) |
391 if( aContactIndex < iItemArray.Count() ) |
394 { |
392 { |
395 TInt newIndex = iContactListModel->IndexOfContact( aContact ); |
393 TInt newIndex = iContactListModel->IndexOfContact( aContact ); |
396 TRACE( T_LIT("new index = %d"),newIndex ); |
394 TRACE( "new index = %d",newIndex ); |
397 CVIMPSTProcessContactItem* newItem = CVIMPSTProcessContactItem::NewL(*this, const_cast<TDesC&>(aContact->Name() ), |
395 CVIMPSTProcessContactItem* newItem = CVIMPSTProcessContactItem::NewL(*this, const_cast<TDesC&>(aContact->Name() ), |
398 const_cast<TDesC&>(aContact->UserId() ), |
396 const_cast<TDesC&>(aContact->UserId() ), |
399 aContact->ContactLink(), |
397 aContact->ContactLink(), |
400 const_cast<TDesC&>(aContact->StatusText()), |
398 const_cast<TDesC&>(aContact->StatusText()), |
401 aContact->OnlineStatus() ); |
399 aContact->OnlineStatus() ); |
437 } |
435 } |
438 } |
436 } |
439 // Add it in the new index |
437 // Add it in the new index |
440 newIndex = newIndex + 1 + iUnKnownContactArray.Count()+ iAddRequestArray.Count(); |
438 newIndex = newIndex + 1 + iUnKnownContactArray.Count()+ iAddRequestArray.Count(); |
441 if (newIndex >= iItemArray.Count()) |
439 if (newIndex >= iItemArray.Count()) |
442 { |
440 { |
443 TRACE( T_LIT("append contact item = %d"), newIndex); |
441 TRACE( "append contact item = %d", newIndex); |
444 iItemArray.Append (newItem); |
442 iItemArray.Append (newItem); |
445 } |
443 } |
446 else |
444 else |
447 { |
445 { |
448 TRACE( T_LIT("Insert at index = %d"), newItem); |
446 TRACE( "Insert at index = %d", newItem); |
449 iItemArray.Insert (newItem, newIndex); |
447 iItemArray.Insert (newItem, newIndex); |
450 } |
448 } |
451 } |
449 } |
452 if(iProcessObservers ) |
450 if(iProcessObservers ) |
453 { |
451 { |
454 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, KErrNotFound ); |
452 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, KErrNotFound ); |
455 } |
453 } |
456 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStoragePresenceChange End") ); |
454 |
457 break; |
455 break; |
458 } |
456 } |
459 case TVIMPSTEnums::EStorageEventOwnUserChanged: |
457 case TVIMPSTEnums::EStorageEventOwnUserChanged: |
460 { |
458 { |
461 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventOwnUserChanged Start") ); |
459 TRACE( "EStorageEventOwnUserChanged " ); |
462 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL start Event = %d"),aEventType ); |
460 TRACE( " start Event = %d",aEventType ); |
463 ResetArray(); |
461 ResetArray(); |
464 if(iProcessObservers ) |
462 if(iProcessObservers ) |
465 { |
463 { |
466 iProcessObservers->HandleDeletionL(TVIMPSTEnums::EOwnStatusItem, 0 ); // focus own item |
464 iProcessObservers->HandleDeletionL(TVIMPSTEnums::EOwnStatusItem, 0 ); // focus own item |
467 |
465 |
468 if( aContact ) |
466 if( aContact ) |
469 { |
467 { |
470 iProcessObservers->HandleAvatarChangeL( aContact->UserId() ); |
468 iProcessObservers->HandleAvatarChangeL( aContact->UserId() ); |
471 } |
469 } |
472 } |
470 } |
473 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventOwnUserChanged End") ); |
471 |
474 |
472 |
475 break; |
473 break; |
476 } |
474 } |
477 case TVIMPSTEnums::EStorageAllContactRemoved: |
475 case TVIMPSTEnums::EStorageAllContactRemoved: |
478 { |
476 { |
479 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAllContactRemoved Start") ); |
477 TRACE("EStorageAllContactRemoved"); |
480 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAllContactRemoved count = %d"), iItemArray.Count() ); |
478 TRACE( "EStorageAllContactRemoved count = %d", iItemArray.Count() ); |
481 ResetArray(); |
479 ResetArray(); |
482 if(iProcessObservers ) |
480 if(iProcessObservers ) |
483 { |
481 { |
484 iProcessObservers->HandleDeletionL(TVIMPSTEnums::EOwnStatusItem, 0 ); // focus own item |
482 iProcessObservers->HandleDeletionL(TVIMPSTEnums::EOwnStatusItem, 0 ); // focus own item |
485 } |
483 } |
486 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAllContactRemoved End") ); |
484 |
487 break; |
485 break; |
488 } |
486 } |
489 case TVIMPSTEnums::EStorageEventContactChange: |
487 case TVIMPSTEnums::EStorageEventContactChange: |
490 { |
488 { |
491 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactChange Start") ); |
489 TRACE("EStorageEventContactChange"); |
492 // display name is changed ,might be contact is re-arranged |
490 // display name is changed ,might be contact is re-arranged |
493 TRACE( T_LIT("contactindex = %d"),aContactIndex ); |
491 TRACE( "contactindex = %d",aContactIndex ); |
494 TRACE( T_LIT("itemarraycount = %d"),iItemArray.Count() ); |
492 TRACE( "itemarraycount = %d",iItemArray.Count() ); |
495 if( aContactIndex < iItemArray.Count() ) |
493 if( aContactIndex < iItemArray.Count() ) |
496 { |
494 { |
497 if ( aContact ) |
495 if ( aContact ) |
498 { |
496 { |
499 CVIMPSTProcessContactItem* newItem = CVIMPSTProcessContactItem::NewL(*this, const_cast<TDesC&>(aContact->Name() ), |
497 CVIMPSTProcessContactItem* newItem = CVIMPSTProcessContactItem::NewL(*this, const_cast<TDesC&>(aContact->Name() ), |
503 aContact->OnlineStatus() ); |
501 aContact->OnlineStatus() ); |
504 |
502 |
505 |
503 |
506 MVIMPSTProcessArrayItem* oldItem = iItemArray[ aContactIndex ]; |
504 MVIMPSTProcessArrayItem* oldItem = iItemArray[ aContactIndex ]; |
507 newItem->SetAvatarIndex(aContact->AvatarIndex()); // copy the avatar index too. |
505 newItem->SetAvatarIndex(aContact->AvatarIndex()); // copy the avatar index too. |
508 TRACE( T_LIT("contact removed in item array of index = %d"),aContactIndex ); |
506 TRACE("contact removed in item array of index = %d",aContactIndex ); |
509 // set the conversation open flag from old contact, as only the display name would have changed. |
507 // set the conversation open flag from old contact, as only the display name would have changed. |
510 newItem->SetConversationOpen(oldItem->IsConversationOpen()); |
508 newItem->SetConversationOpen(oldItem->IsConversationOpen()); |
511 newItem->SetMsgPending( oldItem->IsMsgPending() ); |
509 newItem->SetMsgPending( oldItem->IsMsgPending() ); |
512 iItemArray.Remove(aContactIndex ); |
510 iItemArray.Remove(aContactIndex ); |
513 delete oldItem; |
511 delete oldItem; |
514 iItemArray.Compress(); |
512 iItemArray.Compress(); |
515 TRACE( T_LIT("Insert at index = %d"), aContactIndex); |
513 TRACE( "Insert at index = %d", aContactIndex); |
516 TInt newIndex = iContactListModel->IndexOfContact( aContact ); |
514 TInt newIndex = iContactListModel->IndexOfContact( aContact ); |
517 // Add it in the new index |
515 // Add it in the new index |
518 newIndex = newIndex + 1 + iUnKnownContactArray.Count() + iAddRequestArray.Count(); |
516 newIndex = newIndex + 1 + iUnKnownContactArray.Count() + iAddRequestArray.Count(); |
519 if (newIndex >= iItemArray.Count()) |
517 if (newIndex >= iItemArray.Count()) |
520 { |
518 { |
521 TRACE( T_LIT("append contact item = %d"), newIndex); |
519 TRACE("append contact item = %d", newIndex); |
522 iItemArray.Append (newItem); |
520 iItemArray.Append (newItem); |
523 } |
521 } |
524 else |
522 else |
525 { |
523 { |
526 TRACE( T_LIT("Insert at index = %d"), newItem); |
524 TRACE( "Insert at index = %d", newItem); |
527 iItemArray.Insert(newItem, newIndex); |
525 iItemArray.Insert(newItem, newIndex); |
528 } |
526 } |
529 // inform the cv about the display name changes |
527 // inform the cv about the display name changes |
530 if(aContact && aContact->UserId().Length() && newItem->IsConversationOpen()) |
528 if(aContact && aContact->UserId().Length() && newItem->IsConversationOpen()) |
531 { |
529 { |
532 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactChange ")); |
530 TRACE("EStorageEventContactChange "); |
533 TApaTaskList taskList( CCoeEnv::Static()->WsSession() ); |
531 TApaTaskList taskList( CCoeEnv::Static()->WsSession() ); |
534 TApaTask task( taskList.FindApp( KConversationViewAppUid ) ); |
532 TApaTask task( taskList.FindApp( KConversationViewAppUid ) ); |
535 |
533 |
536 if ( task.Exists() ) |
534 if ( task.Exists() ) |
537 { |
535 { |
538 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactChange:task exists")); |
536 TRACE("EStorageEventContactChange - task exists"); |
539 // packing of data ,passed to conversation view |
537 // packing of data ,passed to conversation view |
540 TPckgBuf< TIMCVUiParams > params; |
538 TPckgBuf< TIMCVUiParams > params; |
541 params().iBuddyId = aContact->UserId(); |
539 params().iBuddyId = aContact->UserId(); |
542 params().iBuddyName = aContact->Name(); |
540 params().iBuddyName = aContact->Name(); |
543 params().iServiceId = iServiceId; |
541 params().iServiceId = iServiceId; |
550 |
548 |
551 } |
549 } |
552 if(iProcessObservers ) |
550 if(iProcessObservers ) |
553 { |
551 { |
554 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, aContactIndex ); |
552 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, aContactIndex ); |
555 } |
553 } |
556 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactChange End") ); |
|
557 break; |
554 break; |
558 } |
555 } |
559 case TVIMPSTEnums::EStorageEventUserIdPostChange: |
556 case TVIMPSTEnums::EStorageEventUserIdPostChange: |
560 { |
557 { |
561 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventUserIdPostChange Start") ); |
558 TRACE( "EStorageEventUserIdPostChange" ); |
562 TRACE( T_LIT("contactindex = %d"),aContactIndex ); |
559 TRACE( "contactindex = %d",aContactIndex ); |
563 TRACE( T_LIT("itemarraycount = %d"),iItemArray.Count() ); |
560 TRACE( "itemarraycount = %d",iItemArray.Count() ); |
564 if( aContactIndex < iItemArray.Count() ) |
561 if( aContactIndex < iItemArray.Count() ) |
565 { |
562 { |
566 CVIMPSTProcessContactItem* newItem = CVIMPSTProcessContactItem::NewL(*this, const_cast<TDesC&>(aContact->Name() ), |
563 CVIMPSTProcessContactItem* newItem = CVIMPSTProcessContactItem::NewL(*this, const_cast<TDesC&>(aContact->Name() ), |
567 const_cast<TDesC&>(aContact->UserId() ), |
564 const_cast<TDesC&>(aContact->UserId() ), |
568 aContact->ContactLink(), |
565 aContact->ContactLink(), |
570 aContact->OnlineStatus() ); |
567 aContact->OnlineStatus() ); |
571 |
568 |
572 |
569 |
573 MVIMPSTProcessArrayItem* oldItem = iItemArray[ aContactIndex ]; |
570 MVIMPSTProcessArrayItem* oldItem = iItemArray[ aContactIndex ]; |
574 newItem->SetAvatarIndex(aContact->AvatarIndex()); // copy the avatar index too. |
571 newItem->SetAvatarIndex(aContact->AvatarIndex()); // copy the avatar index too. |
575 TRACE( T_LIT("contact removed in item array of index = %d"),aContactIndex ); |
572 TRACE( "contact removed in item array of index = %d",aContactIndex ); |
576 iItemArray.Remove(aContactIndex ); |
573 iItemArray.Remove(aContactIndex ); |
577 delete oldItem; |
574 delete oldItem; |
578 iItemArray.Compress(); |
575 iItemArray.Compress(); |
579 TRACE( T_LIT("Insert at index = %d"), aContactIndex); |
576 TRACE( "Insert at index = %d", aContactIndex); |
580 iItemArray.InsertL (newItem, aContactIndex); |
577 iItemArray.InsertL (newItem, aContactIndex); |
581 } |
578 } |
582 if(iProcessObservers ) |
579 if(iProcessObservers ) |
583 { |
580 { |
584 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, aContactIndex ); |
581 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, aContactIndex ); |
585 } |
582 } |
586 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventUserIdPostChange End") ); |
583 TRACE( "EStorageEventUserIdPostChange" ); |
587 break; |
584 break; |
588 } |
585 } |
589 default: |
586 default: |
590 { |
587 { |
591 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL Event default") ); |
588 TRACE("default"); |
592 break; |
589 break; |
593 } |
590 } |
594 } |
591 } |
595 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL Function End") ); |
592 |
596 } |
593 } |
597 |
594 |
598 // -------------------------------------------------------------------------- |
595 // -------------------------------------------------------------------------- |
599 // CVIMPSTProcessArray::AddObserver |
596 // CVIMPSTProcessArray::AddObserver |
600 // -------------------------------------------------------------------------- |
597 // -------------------------------------------------------------------------- |
1014 // CVIMPSTProcessArray::SetLoginState |
1013 // CVIMPSTProcessArray::SetLoginState |
1015 // ----------------------------------------------------------------------------- |
1014 // ----------------------------------------------------------------------------- |
1016 |
1015 |
1017 void CVIMPSTProcessArray::SetLoginStateL(TVIMPSTEnums::TVIMPSTRegistrationState aLoginState) |
1016 void CVIMPSTProcessArray::SetLoginStateL(TVIMPSTEnums::TVIMPSTRegistrationState aLoginState) |
1018 { |
1017 { |
|
1018 TRACER_AUTO; |
1019 iLoginState = aLoginState; |
1019 iLoginState = aLoginState; |
1020 if(aLoginState != TVIMPSTEnums::ESVCERegistered ) |
1020 if(aLoginState != TVIMPSTEnums::ESVCERegistered ) |
1021 { |
1021 { |
1022 iFetchCompleted = EFalse; |
1022 iFetchCompleted = EFalse; |
1023 RemoveUnKnownContacts(); |
1023 RemoveUnKnownContacts(); |
1024 RemoveAddRequestData(); |
1024 RemoveAddRequestData(); |
1025 iUnKnownContactArray.ResetAndDestroy();// delete all items |
1025 iUnKnownContactArray.ResetAndDestroy();// delete all items |
1026 iUnKnownContactArray.Reset(); |
1026 iUnKnownContactArray.Reset(); |
1027 iAddRequestArray.ResetAndDestroy();// delete all items |
1027 iAddRequestArray.ResetAndDestroy();// delete all items |
1028 iAddRequestArray.Reset(); |
1028 iAddRequestArray.Reset(); |
|
1029 // reset the status of all the contacts. |
|
1030 // no need to check the item type here. by the time its here all the other |
|
1031 // type except contact item are removed. |
|
1032 TInt count = iItemArray.Count(); |
|
1033 for(TInt i = 0; i < count ; i++) |
|
1034 { |
|
1035 iItemArray[i]->DoFormatStringL(); |
|
1036 } |
1029 } |
1037 } |
1030 FillOwnDataL(); // this will change the own item based on connection status |
1038 FillOwnDataL(); // this will change the own item based on connection status |
1031 } |
1039 } |
1032 // ----------------------------------------------------------------------------- |
1040 // ----------------------------------------------------------------------------- |
1033 // CVIMPSTProcessArray::GetLoginState |
1041 // CVIMPSTProcessArray::GetLoginState |
1167 // this is to refresh the list box |
1179 // this is to refresh the list box |
1168 // KErrNotFound , focus remain at same position |
1180 // KErrNotFound , focus remain at same position |
1169 iProcessObservers->HandleDeletionL(TVIMPSTEnums::EUnknonContactItem, KErrNotFound ); |
1181 iProcessObservers->HandleDeletionL(TVIMPSTEnums::EUnknonContactItem, KErrNotFound ); |
1170 } |
1182 } |
1171 } |
1183 } |
1172 TRACE( T_LIT("CVIMPSTProcessArray::RemoveFromUnknonListL end ") ); |
1184 |
1173 return found; |
1185 return found; |
1174 } |
1186 } |
1175 //----------------------------------------------------------- |
1187 //----------------------------------------------------------- |
1176 //CVIMPSTProcessArray::RemoveFromInvitationListL |
1188 //CVIMPSTProcessArray::RemoveFromInvitationListL |
1177 //----------------------------------------------------------- |
1189 //----------------------------------------------------------- |
1178 // |
1190 // |
1179 TBool CVIMPSTProcessArray::RemoveFromInvitationListL( const TDesC& aAddedUserId ) |
1191 TBool CVIMPSTProcessArray::RemoveFromInvitationListL( const TDesC& aAddedUserId ) |
1180 { |
1192 { |
|
1193 TRACER_AUTO; |
1181 TPtrC addedUserId = VIMPSTUtils::DisplayId( aAddedUserId ); |
1194 TPtrC addedUserId = VIMPSTUtils::DisplayId( aAddedUserId ); |
1182 TBool found = EFalse; |
1195 TBool found = EFalse; |
1183 TInt index = KErrNotFound; |
1196 TInt index = KErrNotFound; |
1184 TInt itemIndex = KErrNotFound; |
1197 TInt itemIndex = KErrNotFound; |
1185 // item not foun in unknown list |
1198 // item not foun in unknown list |