| Start/ | End/ | |||
| True | False | - | Line | Source |
| 1 | /* | |||
| 2 | * =========================================================================== | |||
| 3 | * Name : cvimpstprocessarray.cpp | |||
| 4 | * Part of : IMUiServiceTab/vimpstcmdprocess | |||
| 5 | * Description : | |||
| 6 | * Version : %version: 68.1.31 % | |||
| 7 | * | |||
| 8 | * Copyright © 2008 Nokia. All rights reserved. | |||
| 9 | * This material, including documentation and any related computer | |||
| 10 | * programs, is protected by copyright controlled by Nokia. All | |||
| 11 | * rights are reserved. Copying, including reproducing, storing, | |||
| 12 | * adapting or translating, any or all of this material requires the | |||
| 13 | * prior written consent of Nokia. This material also contains | |||
| 14 | * confidential information which may not be disclosed to others | |||
| 15 | * without the prior written consent of Nokia. | |||
| 16 | * ============================================================================ | |||
| 17 | */ | |||
| 18 | ||||
| 19 | // INCLUDE FILES | |||
| 20 | #include <coemain.h> | |||
| 21 | #include "vimpstdebugprint.h" | |||
| 22 | ||||
| 23 | #include "cvimpstprocessarray.h" | |||
| 24 | ||||
| 25 | #include "mvimpstprocessarrayobserver.h" | |||
| 26 | #include "cvimpststoragemanagerfactory.h" | |||
| 27 | #include "mvimpststorageserviceview.h" | |||
| 28 | #include "TVIMPSTEnums.h" | |||
| 29 | #include "cvimpstprocessarrayitem.h" | |||
| 30 | #include "mvimpststorageitemmodel.h" | |||
| 31 | #include "tvimpstconsts.h" | |||
| 32 | #include "mvimpststoragecontactlist.h" | |||
| 33 | #include "mvimpststoragevpbkstorehandler.h" | |||
| 34 | #include "mvimpstengine.h" | |||
| 35 | #include "cvimpstprocessfriendrequestitem.h" | |||
| 36 | #include "mvimpstenginesubservice.h" | |||
| 37 | #include <mvpbkfieldtype.h> | |||
| 38 | #include <mvpbkcontactfielduridata.h> | |||
| 39 | #include <MVPbkContactFieldTextData.h> | |||
| 40 | //rsg file for resource id | |||
| 41 | #include <vimpstuires.rsg> | |||
| 42 | #include "vimpstutils.h" | |||
| 43 | #include <mvpbkcontactlink.h> | |||
| 44 | #include <vpbkeng.rsg> | |||
| 45 | #include "mvimpstengineimsubservice.h" | |||
| 46 | #include "mvimpstenginepresencesubservice.h" | |||
| 47 | #include "vimpstdebugtrace.h" | |||
| 48 | #include <APGTASK.H> | |||
| 49 | #include "imcvuiparams.h" | |||
| 50 | ||||
| 51 | // -------------------------------------------------------------------------- | |||
| 52 | // CVIMPSTProcessArray::CIMArrayProcess | |||
| 53 | // -------------------------------------------------------------------------- | |||
| 54 | // | |||
| 126 | 126 | 55 | CVIMPSTProcessArray::CVIMPSTProcessArray( MVIMPSTEngine& aEngine) | |
| 56 | :iOwnDataIndex(KOwnDataIndex), | |||
| 57 | iContactListIndex(KOwnDataIndex), | |||
| 58 | iEngine(aEngine) | |||
| 59 | { | |||
| 60 | iServiceId = iEngine.ServiceId(); | |||
| 61 | } | |||
| 62 | ||||
| 63 | // -------------------------------------------------------------------------- | |||
| 64 | // CVIMPSTProcessArray::~CVIMPSTProcessArray | |||
| 65 | // -------------------------------------------------------------------------- | |||
| 66 | // | |||
| 46 | 46 | 67 | CVIMPSTProcessArray::~CVIMPSTProcessArray() | |
| 68 | { | |||
| 69 | TRACE( T_LIT("CVIMPSTProcessArray::~CVIMPSTProcessArray Start") ); | |||
| 70 | if(iContactInterface) | |||
| 71 | { | |||
| 72 | iContactInterface->RemoveObserver( this ); | |||
| 73 | } | |||
| 74 | iItemArray.ResetAndDestroy(); | |||
| 75 | iItemArray.Close(); | |||
| 76 | iUnKnownContactArray.Close(); | |||
| 77 | iAddRequestArray.Close(); | |||
| 78 | ||||
| 79 | if(iData) | |||
| 80 | { | |||
| 81 | delete iData; | |||
| 82 | iData = NULL; | |||
| 83 | } | |||
| 84 | //Get IM SubService | |||
| 85 | MVIMPSTEngineSubService* subService1 = | |||
| 86 | (iEngine.SubService(TVIMPSTEnums::EIM)); | |||
| 87 | ||||
| 88 | if(subService1) | |||
| 89 | { | |||
| 90 | MVIMPSTEngineIMSubService& imSubService = | |||
| 91 | MVIMPSTEngineIMSubService::Cast (*subService1); | |||
| 92 | imSubService.UnRegisterChatObserver(this); | |||
| 93 | } | |||
| 94 | ||||
| 95 | //subscribe for ownpresencechangeevent | |||
| 96 | MVIMPSTEngineSubService* subService = | |||
| 97 | (iEngine.SubService(TVIMPSTEnums::EPresence)); | |||
| 98 | ||||
| 99 | if(subService) | |||
| 100 | { | |||
| 101 | MVIMPSTEnginePresenceSubService& presence = | |||
| 102 | MVIMPSTEnginePresenceSubService::Cast (*subService); | |||
| 103 | presence.UnRegisterPresenceEventObserver(this); | |||
| 104 | } | |||
| 105 | ||||
| 106 | TRACE( T_LIT("CVIMPSTProcessArray::~CVIMPSTProcessArray End") ); | |||
| 107 | } | |||
| 108 | ||||
| 109 | // -------------------------------------------------------------------------- | |||
| 110 | // CVIMPSTProcessArray::NewL | |||
| 111 | // -------------------------------------------------------------------------- | |||
| 112 | // | |||
| 126 | 0 | 113 | CVIMPSTProcessArray* CVIMPSTProcessArray::NewL( | |
| 114 | MVIMPSTEngine& aEngine) | |||
| 115 | { | |||
| 116 | TRACE( T_LIT("CVIMPSTProcessArray::NewL Start") ); | |||
| 117 | CVIMPSTProcessArray* self = new(ELeave) CVIMPSTProcessArray(aEngine); | |||
| 118 | CleanupStack::PushL(self); | |||
| 119 | self->ConstructL(); | |||
| 120 | CleanupStack::Pop(self); | |||
| 121 | TRACE( T_LIT("CVIMPSTProcessArray::NewL End") ); | |||
| 122 | return self; | |||
| 123 | ||||
| 124 | } | |||
| 125 | ||||
| 126 | // -------------------------------------------------------------------------- | |||
| 127 | // CVIMPSTProcessArray::ConstructL | |||
| 128 | // -------------------------------------------------------------------------- | |||
| 129 | // | |||
| 126 | 126 | 130 | void CVIMPSTProcessArray::ConstructL() | |
| 131 | { | |||
| 132 | TRACE( T_LIT("CVIMPSTProcessArray::ConstructL Start") ); | |||
| 133 | iContactInterface = CVIMPSTStorageManagerFactory::ContactListInterfaceL(iServiceId); | |||
| 134 | if(iContactInterface) | |||
| 135 | { | |||
| 136 | iContactInterface->AddObserverL( this );// listen these events.. | |||
| 137 | } | |||
| 138 | HBufC* unnamed = VIMPSTUtils::LoadResourceL( R_SERVTAB_UNNAMED ); | |||
| 139 | if( unnamed ) | |||
| 140 | { | |||
| 141 | CleanupStack::PushL( unnamed ); | |||
| 142 | iContactInterface->SetUnnamedTextL(unnamed); // takes ownership | |||
| 143 | CleanupStack::Pop( unnamed ); | |||
| 144 | } | |||
| 145 | iContactListModel = CVIMPSTStorageManagerFactory::ItemModelInterfaceL(iServiceId); | |||
| 146 | iLoginState = iEngine.ServiceState(); | |||
| 147 | //Get IM SubService | |||
| 148 | MVIMPSTEngineSubService* subService1 =(iEngine.SubService(TVIMPSTEnums::EIM)); | |||
| 149 | if(subService1) | |||
| 150 | { | |||
| 151 | MVIMPSTEngineIMSubService& imSubService = | |||
| 152 | MVIMPSTEngineIMSubService::Cast (*subService1); | |||
| 153 | imSubService.RegisterChatObserver(this); | |||
| 154 | } | |||
| 155 | iData = HBufC::NewL(512); | |||
| 156 | iAddRequestArray.Reset(); | |||
| 157 | iUnKnownContactArray.Reset(); | |||
| 158 | //subscribe for ownpresencechangeevent | |||
| 159 | MVIMPSTEngineSubService* subService = | |||
| 160 | (iEngine.SubService(TVIMPSTEnums::EPresence)); | |||
| 161 | if(subService) | |||
| 162 | { | |||
| 163 | MVIMPSTEnginePresenceSubService& presence = | |||
| 164 | MVIMPSTEnginePresenceSubService::Cast (*subService); | |||
| 165 | presence.RegisterPresenceEventObserverL(this); | |||
| 166 | } | |||
| 167 | ResetArray(); | |||
| 168 | TRACE( T_LIT("CVIMPSTProcessArray::ConstructL end") ); | |||
| 169 | } | |||
| 170 | // -------------------------------------------------------------------------- | |||
| 171 | // CVIMPSTProcessArray::HandleStorageChangeL | |||
| 172 | // -------------------------------------------------------------------------- | |||
| 173 | // | |||
| 28 | 28 | 174 | void CVIMPSTProcessArray::HandleStorageChangeL( TVIMPSTEnums::TVIMPSTStorgaeEventType aEventType, | |
| 175 | MVIMPSTStorageContactList* /*aList*/, | |||
| 176 | MVIMPSTStorageContact* aContact, | |||
| 177 | TInt aContactIndex ) | |||
| 178 | { | |||
| 179 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL Function Start") ); | |||
| 180 | // 0th index OwnItem + unknow contacts + add request | |||
| 181 | aContactIndex = aContactIndex + 1 + iUnKnownContactArray.Count() + iAddRequestArray.Count(); | |||
| 182 | ||||
| 183 | switch( aEventType ) | |||
| 184 | { | |||
| 185 | case TVIMPSTEnums::EStorageContactReadComplete: | |||
| 186 | { | |||
| 187 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageContactReadComplete Start") ); | |||
| 188 | if(iProcessObservers) | |||
| 189 | { | |||
| 190 | /* passing 0 so that the focus is on owndata item */ | |||
| 191 | iProcessObservers->HandleAdditionL(TVIMPSTEnums::EOwnStatusItem, 0 ); // focus own item | |||
| 192 | } | |||
| 193 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageContactReadComplete End") ); | |||
| 194 | break; | |||
| 195 | } | |||
| 196 | case TVIMPSTEnums::EStorageContactFetchComplete: | |||
| 197 | { | |||
| 198 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageContactFetchComplete Start") ); | |||
| 199 | TRACE( T_LIT("HandleStorageChangeL EStorageContactFetchComplete iItemArray Count: %d"), iItemArray.Count() ); | |||
| 200 | ||||
| 201 | if(iProcessObservers) | |||
| 202 | { | |||
| 203 | /* passing 0 so that the focus is on owndata item */ | |||
| 204 | iProcessObservers->HandleAdditionL(TVIMPSTEnums::EOwnStatusItem, 0 ); // focus own item | |||
| 205 | } | |||
| 206 | if(TVIMPSTEnums::ESVCEUpdatingContacts == iLoginState || | |||
| 207 | TVIMPSTEnums::ESVCERegistered == iLoginState) | |||
| 208 | { | |||
| 209 | iFetchCompleted = ETrue; | |||
| 210 | GetAndCreateOpenChatListL(); | |||
| 211 | } | |||
| 212 | ||||
| 213 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageContactFetchComplete End") ); | |||
| 214 | break; | |||
| 215 | } | |||
| 216 | case TVIMPSTEnums::EStorageContactReading: | |||
| 217 | case TVIMPSTEnums::EStorageContactFetching: | |||
| 218 | case TVIMPSTEnums::EStorageContactSynchronizing: | |||
| 219 | { | |||
| 220 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageContactFetching/EStorageContactFetching Start") ); | |||
| 221 | /* | |||
| 222 | * This event occurs whenever we have contacts added to contactlist. This happens in the following scenarios | |||
| 223 | * 1. At the time of login, when we fetch contacts, contact-by-contact is added to the storage. so we get this event. | |||
| 224 | * 2. When we add a contact manually (either from phonebook, or manu adding etc.. ) we get this callback. | |||
| 225 | */ | |||
| 226 | TRACE( T_LIT("contactindex = %d"),aContactIndex ); | |||
| 227 | CVIMPSTProcessContactItem* contactItem = CVIMPSTProcessContactItem::NewL (const_cast<TDesC&>(aContact->Name() ), | |||
| 228 | const_cast<TDesC&>(aContact->UserId() ), | |||
| 229 | aContact->ContactLink() ); | |||
| 230 | ||||
| 231 | /* 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, | |||
| 232 | * if we havent got a contactviewready, and during that if I get contactaddition, before getting contactFetchComplete, we should keep | |||
| 233 | * appending the items to the array for display, once we get the entire list, its sorted anyway while insertion, and when presence occurs | |||
| 234 | * the contacts are re-sorted. | |||
| 235 | */ | |||
| 236 | TRACE( T_LIT("itemarraycount = %d"),iItemArray.Count() ); | |||
| 237 | if (aContactIndex >= iItemArray.Count() ) | |||
| 238 | { | |||
| 239 | TRACE( T_LIT("append contact item %d"), contactItem); | |||
| 240 | iItemArray.Append(contactItem); | |||
| 241 | } | |||
| 242 | else | |||
| 243 | { | |||
| 244 | TRACE( T_LIT("Insert at index = %d"), aContactIndex); | |||
| 245 | iItemArray.Insert(contactItem, aContactIndex ); | |||
| 246 | } | |||
| 247 | if(iProcessObservers) | |||
| 248 | { | |||
| 249 | /* passing 0 so that the focus is on owndata item */ | |||
| 250 | iProcessObservers->HandleAdditionL(TVIMPSTEnums::EOwnStatusItem, 0); | |||
| 251 | } | |||
| 252 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageContactFetching/EStorageContactFetching End") ); | |||
| 253 | break; | |||
| 254 | } | |||
| 255 | case TVIMPSTEnums::EStorageEventContactAddition: | |||
| 256 | { | |||
| 257 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactAddition Start") ); | |||
| 258 | ||||
| 259 | TBool removed = RemoveFromUnknonOrInvitationListL( aContact->UserId(), EFalse ); | |||
| 260 | if( removed ) | |||
| 261 | { | |||
| 262 | aContactIndex = aContactIndex - 1; // one contact is removed from iUnknownContactArray | |||
| 263 | } | |||
| 264 | /* | |||
| 265 | * This event occurs whenever we have contacts added to contactlist. This happens in the following scenarios | |||
| 266 | * 1. At the time of login, when we fetch contacts, contact-by-contact is added to the storage. so we get this event. | |||
| 267 | * 2. When we add a contact manually (either from phonebook, or manu adding etc.. ) we get this callback. | |||
| 268 | */ | |||
| 269 | TPtrC userId = aContact->UserId(); | |||
| 270 | TRACE( T_LIT("contactindex = %d"),aContactIndex ); | |||
| 271 | CVIMPSTProcessContactItem* contactItem = CVIMPSTProcessContactItem::NewL (aContact->Name() , | |||
| 272 | userId, | |||
| 273 | aContact->ContactLink() ); | |||
| 274 | ||||
| 275 | /* 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, | |||
| 276 | * if we havent got a contactviewready, and during that if I get contactaddition, before getting contactFetchComplete, we should keep | |||
| 277 | * appending the items to the array for display, once we get the entire list, its sorted anyway while insertion, and when presence occurs | |||
| 278 | * the contacts are re-sorted. | |||
| 279 | */ | |||
| 280 | TRACE( T_LIT("itemarraycount = %d"),iItemArray.Count() ); | |||
| 281 | if (aContactIndex >= iItemArray.Count() ) | |||
| 282 | { | |||
| 283 | TRACE( T_LIT("append contact item = %d"), contactItem); | |||
| 284 | iItemArray.Append(contactItem); | |||
| 285 | } | |||
| 286 | else | |||
| 287 | { | |||
| 288 | TRACE( T_LIT("Insert at index = %d"), aContactIndex); | |||
| 289 | iItemArray.Insert(contactItem, aContactIndex ); | |||
| 290 | } | |||
| 291 | // check if pending message exist | |||
| 292 | if( TVIMPSTEnums::ESVCERegistered == iLoginState && userId.Length() ) | |||
| 293 | { | |||
| 294 | if( IsConversationExistL( userId ) ) | |||
| 295 | { | |||
| 296 | contactItem->SetConversationOpen(ETrue); | |||
| 297 | } | |||
| 298 | if( IsUnreadMessageExistsL( userId ) ) | |||
| 299 | { | |||
| 300 | contactItem->SetMsgPending(ETrue); | |||
| 301 | } | |||
| 302 | } | |||
| 303 | ||||
| 304 | if(iProcessObservers) | |||
| 305 | { | |||
| 306 | /* passing aContactIndex so that the focus is on owndata item */ | |||
| 307 | iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, aContactIndex ); | |||
| 308 | } | |||
| 309 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactAddition End") ); | |||
| 310 | break; | |||
| 311 | } | |||
| 312 | case TVIMPSTEnums::EStorageEventContactDelete: | |||
| 313 | { | |||
| 314 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactDelete Start") ); | |||
| 315 | TRACE( T_LIT("contactindex = %d"),aContactIndex ); | |||
| 316 | TRACE( T_LIT("itemarraycount = %d"),iItemArray.Count() ); | |||
| 317 | if( aContactIndex < iItemArray.Count() ) | |||
| 318 | { | |||
| 319 | MVIMPSTProcessArrayItem* deletedItem = iItemArray[ aContactIndex ]; | |||
| 320 | TRACE( T_LIT("contact removed in item array of index = %d"),aContactIndex ); | |||
| 321 | iItemArray.Remove (aContactIndex); | |||
| 322 | delete deletedItem; | |||
| 323 | iItemArray.Compress(); | |||
| 324 | TRACE( T_LIT("contactindex = %d"),aContactIndex ); | |||
| 325 | } | |||
| 326 | if(iProcessObservers) | |||
| 327 | { | |||
| 328 | iProcessObservers->HandleDeletionL(TVIMPSTEnums::EContactItem, aContactIndex); | |||
| 329 | } | |||
| 330 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactDelete End") ); | |||
| 331 | break; | |||
| 332 | } | |||
| 333 | case TVIMPSTEnums::EStorageAvatarChange: | |||
| 334 | { | |||
| 335 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange Start") ); | |||
| 336 | ResetArray(); | |||
| 337 | if(iProcessObservers && aContact ) | |||
| 338 | { | |||
| 339 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange inside if") ); | |||
| 340 | TPtrC aUserId = aContact->UserId(); | |||
| 341 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange aUserId = %S"), &aUserId ); | |||
| 342 | iProcessObservers->HandleAvatarChangeL( aContact->UserId() ); | |||
| 343 | } | |||
| 344 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange End") ); | |||
| 345 | break; | |||
| 346 | } | |||
| 347 | case TVIMPSTEnums::EStorageOwnPresenceChange: | |||
| 348 | { | |||
| 349 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange Start") ); | |||
| 350 | if(iProcessObservers) | |||
| 351 | { | |||
| 352 | /* passing index as 0, so thta focus remains at the owndata item */ | |||
| 353 | iProcessObservers->HandleAdditionL(TVIMPSTEnums::EOwnStatusItem, KErrNotFound ); | |||
| 354 | } | |||
| 355 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange End") ); | |||
| 356 | break; | |||
| 357 | } | |||
| 358 | case TVIMPSTEnums::EStorageMultiplePresenceChange: | |||
| 359 | { | |||
| 360 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange Start") ); | |||
| 361 | // mostly this will get called after just login and fetch time | |||
| 362 | ResetArray(); | |||
| 363 | if(iProcessObservers ) | |||
| 364 | { | |||
| 365 | iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, KErrNotFound ); | |||
| 366 | } | |||
| 367 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange End") ); | |||
| 368 | break; | |||
| 369 | } | |||
| 370 | case TVIMPSTEnums::EStoragePresenceChange: | |||
| 371 | { | |||
| 372 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStoragePresenceChange Start") ); | |||
| 373 | /* | |||
| 374 | * After Sort we get the new index... So first we need to remove the contact from the old position, | |||
| 375 | * and then re-insert it at the correct obtained position (newIndex in this case) | |||
| 376 | */ | |||
| 377 | TRACE( T_LIT("contactindex = %d"),aContactIndex ); | |||
| 378 | TRACE( T_LIT("itemarraycount = %d"),iItemArray.Count() ); | |||
| 379 | if( aContactIndex < iItemArray.Count() ) | |||
| 380 | { | |||
| 381 | TInt newIndex = iContactListModel->IndexOfContact( aContact ); | |||
| 382 | TRACE( T_LIT("new index = %d"),newIndex ); | |||
| 383 | CVIMPSTProcessContactItem* newItem = CVIMPSTProcessContactItem::NewL(const_cast<TDesC&>(aContact->Name() ), | |||
| 384 | const_cast<TDesC&>(aContact->UserId() ), | |||
| 385 | aContact->ContactLink() ); | |||
| 386 | MVIMPSTProcessArrayItem* oldItem = iItemArray[ aContactIndex ]; | |||
| 387 | TRACE( T_LIT("contact removed in item array of index = %d"),aContactIndex ); | |||
| 388 | iItemArray.Remove(aContactIndex ); | |||
| 389 | delete oldItem; | |||
| 390 | iItemArray.Compress(); | |||
| 391 | // Add it in the new index | |||
| 392 | newIndex = newIndex + 1 + iUnKnownContactArray.Count()+ iAddRequestArray.Count(); | |||
| 393 | if (newIndex >= iItemArray.Count()) | |||
| 394 | { | |||
| 395 | TRACE( T_LIT("append contact item = %d"), newIndex); | |||
| 396 | iItemArray.Append (newItem); | |||
| 397 | } | |||
| 398 | else | |||
| 399 | { | |||
| 400 | TRACE( T_LIT("Insert at index = %d"), newItem); | |||
| 401 | iItemArray.Insert (newItem, newIndex); | |||
| 402 | } | |||
| 403 | } | |||
| 404 | if(iProcessObservers ) | |||
| 405 | { | |||
| 406 | iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, KErrNotFound ); | |||
| 407 | } | |||
| 408 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStoragePresenceChange End") ); | |||
| 409 | break; | |||
| 410 | } | |||
| 411 | case TVIMPSTEnums::EStorageEventOwnUserChanged: | |||
| 412 | { | |||
| 413 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventOwnUserChanged Start") ); | |||
| 414 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL start Event = %d"),aEventType ); | |||
| 415 | ResetArray(); | |||
| 416 | if(iProcessObservers ) | |||
| 417 | { | |||
| 418 | iProcessObservers->HandleDeletionL(TVIMPSTEnums::EOwnStatusItem, 0 ); // focus own item | |||
| 419 | ||||
| 420 | if( aContact ) | |||
| 421 | { | |||
| 422 | iProcessObservers->HandleAvatarChangeL( aContact->UserId() ); | |||
| 423 | } | |||
| 424 | } | |||
| 425 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventOwnUserChanged End") ); | |||
| 426 | ||||
| 427 | break; | |||
| 428 | } | |||
| 429 | case TVIMPSTEnums::EStorageAllContactRemoved: | |||
| 430 | { | |||
| 431 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAllContactRemoved Start") ); | |||
| 432 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAllContactRemoved count = %d"), iItemArray.Count() ); | |||
| 433 | ResetArray(); | |||
| 434 | if(iProcessObservers ) | |||
| 435 | { | |||
| 436 | iProcessObservers->HandleDeletionL(TVIMPSTEnums::EOwnStatusItem, 0 ); // focus own item | |||
| 437 | } | |||
| 438 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAllContactRemoved End") ); | |||
| 439 | break; | |||
| 440 | } | |||
| 441 | case TVIMPSTEnums::EStorageEventContactChange: | |||
| 442 | { | |||
| 443 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactChange Start") ); | |||
| 444 | // display name is changed ,might be contact is re-arranged | |||
| 445 | TRACE( T_LIT("contactindex = %d"),aContactIndex ); | |||
| 446 | TRACE( T_LIT("itemarraycount = %d"),iItemArray.Count() ); | |||
| 447 | if( aContactIndex < iItemArray.Count() ) | |||
| 448 | { | |||
| 449 | CVIMPSTProcessContactItem* newItem = CVIMPSTProcessContactItem::NewL(const_cast<TDesC&>(aContact->Name() ), | |||
| 450 | const_cast<TDesC&>(aContact->UserId() ), | |||
| 451 | aContact->ContactLink() ); | |||
| 452 | ||||
| 453 | MVIMPSTProcessArrayItem* oldItem = iItemArray[ aContactIndex ]; | |||
| 454 | TRACE( T_LIT("contact removed in item array of index = %d"),aContactIndex ); | |||
| 455 | // set the conversation open flag from old contact, as only the display name would have changed. | |||
| 456 | newItem->SetConversationOpen(oldItem->IsConversationOpen()); | |||
| 457 | newItem->SetMsgPending( oldItem->IsMsgPending() ); | |||
| 458 | iItemArray.Remove(aContactIndex ); | |||
| 459 | delete oldItem; | |||
| 460 | iItemArray.Compress(); | |||
| 461 | TRACE( T_LIT("Insert at index = %d"), aContactIndex); | |||
| 462 | TInt newIndex = iContactListModel->IndexOfContact( aContact ); | |||
| 463 | // Add it in the new index | |||
| 464 | newIndex = newIndex + 1 + iUnKnownContactArray.Count() + iAddRequestArray.Count(); | |||
| 465 | if (newIndex >= iItemArray.Count()) | |||
| 466 | { | |||
| 467 | TRACE( T_LIT("append contact item = %d"), newIndex); | |||
| 468 | iItemArray.Append (newItem); | |||
| 469 | } | |||
| 470 | else | |||
| 471 | { | |||
| 472 | TRACE( T_LIT("Insert at index = %d"), newItem); | |||
| 473 | iItemArray.Insert(newItem, newIndex); | |||
| 474 | } | |||
| 475 | // inform the cv about the display name changes | |||
| 476 | if(aContact && aContact->UserId().Length() && newItem->IsConversationOpen()) | |||
| 477 | { | |||
| 478 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactChange ")); | |||
| 479 | TApaTaskList taskList( CCoeEnv::Static()->WsSession() ); | |||
| 480 | TApaTask task( taskList.FindApp( KConversationViewAppUid ) ); | |||
| 481 | ||||
| 482 | if ( task.Exists() ) | |||
| 483 | { | |||
| 484 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactChange:task exists")); | |||
| 485 | // packing of data ,passed to conversation view | |||
| 486 | TPckgBuf< TIMCVUiParams > params; | |||
| 487 | params().iBuddyId = aContact->UserId(); | |||
| 488 | params().iBuddyName = aContact->Name(); | |||
| 489 | params().iServiceId = iServiceId; | |||
| 490 | params().iUpdate = ETrue; | |||
| 491 | task.SendMessage( | |||
| 492 | TUid::Uid( KUidApaMessageSwitchOpenFileValue ), params ); | |||
| 493 | } | |||
| 494 | } | |||
| 495 | } | |||
| 496 | if(iProcessObservers ) | |||
| 497 | { | |||
| 498 | iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, aContactIndex ); | |||
| 499 | } | |||
| 500 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactChange End") ); | |||
| 501 | break; | |||
| 502 | } | |||
| 503 | case TVIMPSTEnums::EStorageEventUserIdPostChange: | |||
| 504 | { | |||
| 505 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventUserIdPostChange Start") ); | |||
| 506 | TRACE( T_LIT("contactindex = %d"),aContactIndex ); | |||
| 507 | TRACE( T_LIT("itemarraycount = %d"),iItemArray.Count() ); | |||
| 508 | if( aContactIndex < iItemArray.Count() ) | |||
| 509 | { | |||
| 510 | CVIMPSTProcessContactItem* newItem = CVIMPSTProcessContactItem::NewL(const_cast<TDesC&>(aContact->Name() ), | |||
| 511 | const_cast<TDesC&>(aContact->UserId() ), | |||
| 512 | aContact->ContactLink() ); | |||
| 513 | MVIMPSTProcessArrayItem* oldItem = iItemArray[ aContactIndex ]; | |||
| 514 | TRACE( T_LIT("contact removed in item array of index = %d"),aContactIndex ); | |||
| 515 | iItemArray.Remove(aContactIndex ); | |||
| 516 | delete oldItem; | |||
| 517 | iItemArray.Compress(); | |||
| 518 | TRACE( T_LIT("Insert at index = %d"), aContactIndex); | |||
| 519 | iItemArray.InsertL (newItem, aContactIndex); | |||
| 520 | } | |||
| 521 | if(iProcessObservers ) | |||
| 522 | { | |||
| 523 | iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, aContactIndex ); | |||
| 524 | } | |||
| 525 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventUserIdPostChange End") ); | |||
| 526 | break; | |||
| 527 | } | |||
| 528 | default: | |||
| 529 | { | |||
| 530 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL Event default") ); | |||
| 531 | break; | |||
| 532 | } | |||
| 533 | } | |||
| 534 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL Function End") ); | |||
| 535 | } | |||
| 536 | ||||
| 537 | // -------------------------------------------------------------------------- | |||
| 538 | // CVIMPSTProcessArray::AddObserver | |||
| 539 | // -------------------------------------------------------------------------- | |||
| 540 | // | |||
| 6 | 6 | 541 | void CVIMPSTProcessArray::AddObserver( MVIMPSTProcessArrayObserver* aObserver ) | |
| 542 | { | |||
| 543 | iProcessObservers = aObserver; | |||
| 544 | } | |||
| 545 | // -------------------------------------------------------------------------- | |||
| 546 | // CVIMPSTProcessArray::RemoveObserver | |||
| 547 | // -------------------------------------------------------------------------- | |||
| 548 | // | |||
| 0 | 0 | - | 549 | void CVIMPSTProcessArray::RemoveObserver( ) |
| 550 | { | |||
| 551 | iProcessObservers = NULL; | |||
| 552 | } | |||
| 553 | ||||
| 554 | // ----------------------------------------------------------------------------- | |||
| 555 | // CVIMPSTProcessArray::GetItemNameTextL | |||
| 556 | // ----------------------------------------------------------------------------- | |||
| 557 | ||||
| 4 | 0 | 558 | TPtrC CVIMPSTProcessArray::GetItemNameText(TInt aIndex) | |
| 559 | { | |||
| 560 | TVIMPSTEnums::TItem itemtype = GetType( aIndex ); | |||
| 561 | MVIMPSTProcessArrayItem* arrayItem = NULL; | |||
| 562 | /* Codescanner warning is ignored, since Bound check is done | |||
| 563 | * inside the GetType() | |||
| 564 | * method*/ | |||
| 565 | switch(itemtype) | |||
| 566 | { | |||
| 567 | case TVIMPSTEnums::EOwnStatusItem: | |||
| 568 | { | |||
| 569 | MVIMPSTProcessArrayItem *arrayItem = (MVIMPSTProcessArrayItem *)iItemArray[aIndex]; | |||
| 570 | return arrayItem->GetItemUserId(); // no name for own user | |||
| 571 | } | |||
| 572 | case TVIMPSTEnums::EContactListItem: | |||
| 573 | case TVIMPSTEnums::EContactItem: | |||
| 574 | { | |||
| 575 | arrayItem = (MVIMPSTProcessArrayItem *)iItemArray[aIndex]; | |||
| 576 | break; | |||
| 577 | } | |||
| 578 | case TVIMPSTEnums::EFriendRequestItem: | |||
| 579 | { | |||
| 580 | arrayItem = (MVIMPSTProcessArrayItem *)iItemArray[aIndex]; | |||
| 581 | break; | |||
| 582 | } | |||
| 583 | case TVIMPSTEnums::EUnknonContactItem: | |||
| 584 | { | |||
| 585 | arrayItem = (MVIMPSTProcessArrayItem *)iItemArray[aIndex]; | |||
| 586 | break; | |||
| 587 | } | |||
| 588 | case TVIMPSTEnums::EInvalid: | |||
| 589 | default: | |||
| 590 | { | |||
| 591 | break; | |||
| 592 | } | |||
| 593 | } | |||
| 594 | if( arrayItem ) | |||
| 595 | { | |||
| 596 | return arrayItem->GetItemNameText(); | |||
| 597 | } | |||
| 598 | return KNullDesC(); | |||
| 599 | } | |||
| 600 | ||||
| 601 | // ----------------------------------------------------------------------------- | |||
| 602 | // CVIMPSTProcessArray::GetItemUserId | |||
| 603 | // ----------------------------------------------------------------------------- | |||
| 604 | ||||
| 12 | 0 | 605 | TPtrC CVIMPSTProcessArray::GetItemUserId(TInt aIndex) | |
| 606 | { | |||
| 607 | TVIMPSTEnums::TItem itemtype = GetType( aIndex ); | |||
| 608 | ||||
| 609 | /* Codescanner warning is ignored, since Bound check is done | |||
| 610 | * inside the GetType() | |||
| 611 | * method*/ | |||
| 612 | switch(itemtype) | |||
| 613 | { | |||
| 614 | case TVIMPSTEnums::EContactItem: | |||
| 615 | case TVIMPSTEnums::EFriendRequestItem: | |||
| 616 | case TVIMPSTEnums::EUnknonContactItem: | |||
| 617 | case TVIMPSTEnums::EOwnStatusItem: | |||
| 618 | { | |||
| 619 | MVIMPSTProcessArrayItem *arrayItem = (MVIMPSTProcessArrayItem *)iItemArray[aIndex]; | |||
| 620 | return arrayItem->GetItemUserId(); // no name for own user | |||
| 621 | } | |||
| 622 | default: | |||
| 623 | { | |||
| 624 | return KNullDesC(); | |||
| 625 | } | |||
| 626 | } | |||
| 627 | } | |||
| 628 | ||||
| 629 | // ----------------------------------------------------------------------------- | |||
| 630 | // CVIMPSTProcessArray::ContactLink | |||
| 631 | // ----------------------------------------------------------------------------- | |||
| 632 | ||||
| 2 | 0 | 633 | MVPbkContactLink* CVIMPSTProcessArray::ContactLink(TInt aIndex) | |
| 634 | { | |||
| 635 | TVIMPSTEnums::TItem itemtype = GetType( aIndex ); | |||
| 636 | ||||
| 637 | /* Codescanner warning is ignored, since Bound check is done | |||
| 638 | * inside the GetType() | |||
| 639 | * method*/ | |||
| 640 | switch(itemtype) | |||
| 641 | { | |||
| 642 | case TVIMPSTEnums::EOwnStatusItem: | |||
| 643 | { | |||
| 644 | return NULL; | |||
| 645 | } | |||
| 646 | case TVIMPSTEnums::EContactListItem: | |||
| 647 | case TVIMPSTEnums::EContactItem: | |||
| 648 | { | |||
| 649 | MVIMPSTProcessArrayItem *arrayItem = (MVIMPSTProcessArrayItem *)iItemArray[aIndex]; | |||
| 650 | return arrayItem->ContactLink(); | |||
| 651 | } | |||
| 652 | case TVIMPSTEnums::EInvalid: | |||
| 653 | default: | |||
| 654 | { | |||
| 655 | } | |||
| 656 | } | |||
| 657 | return NULL; | |||
| 658 | } | |||
| 659 | ||||
| 660 | // ----------------------------------------------------------------------------- | |||
| 661 | // CVIMPSTProcessArray::Count | |||
| 662 | // ----------------------------------------------------------------------------- | |||
| 663 | ||||
| 0 | 0 | - | 664 | TInt CVIMPSTProcessArray::Count() const |
| 665 | { | |||
| 666 | // return the total count here. | |||
| 667 | return iItemArray.Count() ; | |||
| 668 | } | |||
| 669 | // ----------------------------------------------------------------------------- | |||
| 670 | // CVIMPSTProcessArray::IsSubServiceSupportedL | |||
| 671 | // ----------------------------------------------------------------------------- | |||
| 672 | ||||
| 8 | 0 | 673 | TBool CVIMPSTProcessArray::IsSubServiceSupportedL(TVIMPSTEnums::SubServiceType aType ) const | |
| 674 | { | |||
| 675 | return iEngine.IsSubServiceSupportedL(aType ); | |||
| 676 | } | |||
| 677 | // ----------------------------------------------------------------------------- | |||
| 678 | // CVIMPSTProcessArray::GetType | |||
| 679 | // Get the type from engine and return the type | |||
| 680 | // ----------------------------------------------------------------------------- | |||
| 681 | ||||
| 32 | 0 | 682 | TVIMPSTEnums::TItem CVIMPSTProcessArray::GetType(TInt aIndex) const | |
| 683 | { | |||
| 684 | TInt itemArrayCount = iItemArray.Count(); | |||
| 685 | if(itemArrayCount <=0 || (aIndex < 0 || aIndex >= itemArrayCount) ) | |||
| 686 | { | |||
| 687 | return TVIMPSTEnums::EInvalid; | |||
| 688 | } | |||
| 689 | ||||
| 690 | else if(itemArrayCount>0) | |||
| 691 | { | |||
| 692 | TInt index = aIndex <= 0 ? 0 : aIndex; | |||
| 693 | MVIMPSTProcessArrayItem* item = iItemArray[ index ]; | |||
| 694 | return item->Type(); | |||
| 695 | } | |||
| 696 | else | |||
| 697 | { | |||
| 698 | return TVIMPSTEnums::EInvalid; | |||
| 699 | } | |||
| 700 | } | |||
| 701 | // ----------------------------------------------------------------------------- | |||
| 702 | // CVIMPSTProcessArray::FillItemL | |||
| 703 | // Fill up the complete array one item at a time | |||
| 704 | // ----------------------------------------------------------------------------- | |||
| 705 | ||||
| 134 | 134 | 706 | void CVIMPSTProcessArray::FillItemL() | |
| 707 | { | |||
| 708 | TInt count = 0; | |||
| 709 | if(iContactListModel) | |||
| 710 | { | |||
| 711 | count = iContactListModel->Count(); | |||
| 712 | } | |||
| 713 | ||||
| 714 | // the index is starting from 1, because we already added owndata item to the list....... | |||
| 715 | for ( TInt index = 0; index < count ; index++) | |||
| 716 | { | |||
| 717 | // fetch the item and process correct type | |||
| 718 | MVIMPSTStorageItemModel::SItem item = iContactListModel->Item( index ); | |||
| 719 | switch( item.iType ) | |||
| 720 | { | |||
| 721 | case MVIMPSTStorageItemModel::EContactList: | |||
| 722 | break; | |||
| 723 | case MVIMPSTStorageItemModel::EContactItem: | |||
| 724 | { | |||
| 725 | // contact item | |||
| 726 | // add this items to contact item -- CONTACT | |||
| 727 | // create an object of this type and append this to the rpointerarray | |||
| 728 | MVIMPSTStorageContact* contact = item.iContact; | |||
| 729 | TPtrC userId = contact->UserId(); | |||
| 730 | CVIMPSTProcessContactItem* contactItem = | |||
| 731 | CVIMPSTProcessContactItem::NewL(contact->Name(), | |||
| 732 | userId , | |||
| 733 | contact->ContactLink() ); | |||
| 734 | TInt otherCount = 1 + iUnKnownContactArray.Count() + iAddRequestArray.Count(); | |||
| 735 | contactItem->SetItemIndex(index + otherCount ); | |||
| 736 | //append this to the array | |||
| 737 | iItemArray.AppendL(contactItem); | |||
| 738 | if( TVIMPSTEnums::ESVCERegistered == iLoginState && | |||
| 739 | TVIMPSTEnums::EBlocked != contact->OnlineStatus() && userId.Length() ) | |||
| 740 | { | |||
| 741 | if( IsUnreadMessageExistsL( userId ) ) | |||
| 742 | { | |||
| 743 | contactItem->SetMsgPending(ETrue); | |||
| 744 | } | |||
| 745 | if( IsConversationExistL( userId ) ) | |||
| 746 | { | |||
| 747 | contactItem->SetConversationOpen(ETrue); | |||
| 748 | } | |||
| 749 | } | |||
| 750 | break; | |||
| 751 | } | |||
| 752 | default: | |||
| 753 | { | |||
| 754 | // the call shouldn't be here | |||
| 755 | break; | |||
| 756 | } | |||
| 757 | } | |||
| 758 | } | |||
| 759 | ||||
| 760 | } | |||
| 761 | ||||
| 762 | // ----------------------------------------------------------------------------- | |||
| 763 | // CVIMPSTProcessArray::FillOwnDataL | |||
| 764 | // FillOwnDataL implementation | |||
| 765 | // ----------------------------------------------------------------------------- | |||
| 766 | // fill the owndata at the begining of array..... | |||
| 136 | 0 | 767 | TBool CVIMPSTProcessArray::FillOwnDataL() | |
| 768 | { | |||
| 769 | TBool ownDataAdded = EFalse; | |||
| 770 | TPtr dataPtr = iData->Des(); | |||
| 771 | // Check whether the user has logged in before, if has | |||
| 772 | // then dont update anything just return | |||
| 773 | //check if its logged in or not. | |||
| 774 | // 1. if not logged in append | |||
| 775 | switch(iLoginState) | |||
| 776 | { | |||
| 777 | case TVIMPSTEnums::ESVCERegistered: | |||
| 778 | { | |||
| 779 | TPtrC userId = iContactInterface->OwnContactL().UserId(); | |||
| 780 | dataPtr.Copy(userId); | |||
| 781 | break; | |||
| 782 | } | |||
| 783 | case TVIMPSTEnums::ESVCENetworkConnecting: | |||
| 784 | { | |||
| 785 | HBufC* tempStr = VIMPSTUtils::LoadResourceL( R_QTN_SERVTAB_LOGGING_LIST_ITEM ); | |||
| 786 | if(tempStr) | |||
| 787 | { | |||
| 788 | dataPtr.Copy(*tempStr); | |||
| 789 | delete tempStr; | |||
| 790 | } | |||
| 791 | ||||
| 792 | break; | |||
| 793 | } | |||
| 794 | case TVIMPSTEnums::ESVCEUpdatingContacts: | |||
| 795 | { | |||
| 796 | HBufC* tempStr = VIMPSTUtils::LoadResourceL( R_QTN_SERVTAB_UPDATING_LIST_ITEM ); | |||
| 797 | if(tempStr) | |||
| 798 | { | |||
| 799 | dataPtr.Copy(*tempStr); | |||
| 800 | delete tempStr; | |||
| 801 | } | |||
| 802 | ||||
| 803 | break; | |||
| 804 | } | |||
| 805 | case TVIMPSTEnums::ESVCEWaitingForNetwork: | |||
| 806 | { | |||
| 807 | HBufC* tempStr = KNetworkError().AllocL(); | |||
| 808 | if(tempStr) | |||
| 809 | { | |||
| 810 | dataPtr.Copy(*tempStr); | |||
| 811 | delete tempStr; | |||
| 812 | } | |||
| 813 | break; | |||
| 814 | } | |||
| 815 | case TVIMPSTEnums::ESVCENetworkDisConnecting: | |||
| 816 | { | |||
| 817 | HBufC* tempStr = NULL; | |||
| 818 | if ( iEngine.IsSubServiceSupportedL(TVIMPSTEnums::EPresence) ) | |||
| 819 | { | |||
| 820 | // if presence enabled use double line listbox string | |||
| 821 | tempStr= VIMPSTUtils::LoadResourceL( R_QTN_SERVTAB_LOGGINGOUT_LIST_ITEM ); | |||
| 822 | } | |||
| 823 | else | |||
| 824 | { | |||
| 825 | // if presence is not enabled use single line listbox string | |||
| 826 | tempStr= VIMPSTUtils::LoadResourceL( R_QTN_SERVTAB_SINGLE_LINE_LOGGINGOUT_LIST_ITEM ); | |||
| 827 | } | |||
| 828 | ||||
| 829 | if(tempStr) | |||
| 830 | { | |||
| 831 | dataPtr.Copy(*tempStr); | |||
| 832 | delete tempStr; | |||
| 833 | } | |||
| 834 | ||||
| 835 | break; | |||
| 836 | } | |||
| 837 | case TVIMPSTEnums::ESVCENotRegistered: | |||
| 838 | default: | |||
| 839 | { | |||
| 840 | HBufC* str = NULL; | |||
| 841 | if ( iEngine.SubService( TVIMPSTEnums::EPresence) ) | |||
| 842 | { | |||
| 843 | // if presence enabled use double line listbox string | |||
| 844 | str = VIMPSTUtils::LoadResourceL( R_QTN_SERVTAB_LOGIN_LIST_ITEM ); | |||
| 845 | } | |||
| 846 | else | |||
| 847 | { | |||
| 848 | // if presence is not enabled use single line listbox string | |||
| 849 | // get the username from settings | |||
| 850 | TPtrC ownUserId = iContactInterface->OwnContactL().UserId(); | |||
| 851 | if ( ownUserId.Length() ) | |||
| 852 | { | |||
| 853 | // if username is available then show with login item | |||
| 854 | // remove domain part and give it to resource laoder | |||
| 855 | str= VIMPSTUtils::LoadResourceL( R_QTN_SERVTAB_SINGLE_LINE_LOGIN_LIST_ITEM_WITH_USERNAME , VIMPSTUtils::DisplayId( ownUserId ) ); | |||
| 856 | } | |||
| 857 | else | |||
| 858 | { | |||
| 859 | // this condition occures when there is allocated memory for username with NO data (length =0 ) | |||
| 860 | // just make sure "no memory leak" without depending on the Function LoginUserNameFromSettingsL() | |||
| 861 | // since that would return the allocated memory without Data (length=0 ) | |||
| 862 | // just show login item since no username is available in the settings | |||
| 863 | str= VIMPSTUtils::LoadResourceL( R_QTN_SERVTAB_SINGLE_LINE_LOGIN_LIST_ITEM ); | |||
| 864 | } | |||
| 865 | } | |||
| 866 | if( str ) | |||
| 867 | { | |||
| 868 | dataPtr.Copy(*str); | |||
| 869 | delete str; | |||
| 870 | } | |||
| 871 | break; | |||
| 872 | } | |||
| 873 | } | |||
| 874 | if( iItemArray.Count() ) | |||
| 875 | { | |||
| 876 | // own item is already exist delete it before adding a fresh one | |||
| 877 | MVIMPSTProcessArrayItem* arrayItem = iItemArray[ 0 ]; // should be own data | |||
| 878 | if( arrayItem->Type() == TVIMPSTEnums::EOwnStatusItem ) | |||
| 879 | { | |||
| 880 | iItemArray.Remove(0); //iItemArray takes ownership of owndataItem, do not delete here | |||
| 881 | delete arrayItem; | |||
| 882 | iItemArray.Compress(); | |||
| 883 | } | |||
| 884 | } | |||
| 885 | //common code for all the above cases to update the owndata item to list at index 0 | |||
| 886 | CVIMPSTProcessOwnDataItem* owndataItem = CVIMPSTProcessOwnDataItem::NewL(*iData); | |||
| 887 | owndataItem->SetItemIndex(0); | |||
| 888 | //append this to the array | |||
| 889 | iItemArray.InsertL( owndataItem,0 ); //iItemArray takes ownership of owndataItem, do not delete here | |||
| 890 | iContactListIndex = 0; | |||
| 891 | ownDataAdded = ETrue; | |||
| 892 | return ownDataAdded; | |||
| 893 | } | |||
| 894 | ||||
| 895 | // ----------------------------------------------------------------------------- | |||
| 896 | // CVIMPSTProcessArray::FillArrayL | |||
| 897 | // ----------------------------------------------------------------------------- | |||
| 898 | ||||
| 134 | 134 | 899 | void CVIMPSTProcessArray::FillArrayL() | |
| 900 | { | |||
| 901 | if(FillOwnDataL() ) | |||
| 902 | { | |||
| 903 | // then fill the conversations..or open chats.... | |||
| 904 | } | |||
| 905 | else | |||
| 906 | { | |||
| 907 | iContactListIndex = 0; // we have not added any thing to main array..so index is zero... | |||
| 908 | } | |||
| 909 | FillUnknownContactsL(); //will fill all unknown contact from iUnknownContactArray to iItemArray. | |||
| 910 | FillAddRequestDataL();//will fill all requests from iAddRequestArray to iItemArray. | |||
| 911 | FillItemL(); | |||
| 912 | } | |||
| 913 | ||||
| 914 | ||||
| 915 | // ----------------------------------------------------------------------------- | |||
| 916 | // CVIMPSTProcessArray::ResetArray | |||
| 917 | // ----------------------------------------------------------------------------- | |||
| 918 | ||||
| 134 | 134 | 919 | void CVIMPSTProcessArray::ResetArray() | |
| 920 | { | |||
| 921 | RemoveUnKnownContacts(); //will remove all the unknown contacts from iItemArray. | |||
| 922 | RemoveAddRequestData();//will remove all the requests from iItemArray. | |||
| 923 | iItemArray.ResetAndDestroy(); | |||
| 924 | TRAPD( err, FillArrayL()); | |||
| 925 | if ( err != KErrNone ) | |||
| 926 | { | |||
| 927 | CActiveScheduler::Current()->Error( err ); | |||
| 928 | } | |||
| 929 | } | |||
| 930 | ||||
| 931 | // ----------------------------------------------------------------------------- | |||
| 932 | // CVIMPSTProcessArray::SetLoginState | |||
| 933 | // ----------------------------------------------------------------------------- | |||
| 934 | ||||
| 2 | 2 | 935 | void CVIMPSTProcessArray::SetLoginStateL(TVIMPSTEnums::TVIMPSTRegistrationState aLoginState) | |
| 936 | { | |||
| 937 | iLoginState = aLoginState; | |||
| 938 | if(aLoginState != TVIMPSTEnums::ESVCERegistered ) | |||
| 939 | { | |||
| 940 | iFetchCompleted = EFalse; | |||
| 941 | RemoveUnKnownContacts(); | |||
| 942 | RemoveAddRequestData(); | |||
| 943 | iUnKnownContactArray.ResetAndDestroy();// delete all items | |||
| 944 | iUnKnownContactArray.Reset(); | |||
| 945 | iAddRequestArray.ResetAndDestroy();// delete all items | |||
| 946 | iAddRequestArray.Reset(); | |||
| 947 | } | |||
| 948 | FillOwnDataL(); // this will change the own item based on connection status | |||
| 949 | } | |||
| 950 | // ----------------------------------------------------------------------------- | |||
| 951 | // CVIMPSTProcessArray::GetLoginState | |||
| 952 | // ----------------------------------------------------------------------------- | |||
| 953 | ||||
| 2 | 0 | 954 | TVIMPSTEnums::TVIMPSTRegistrationState CVIMPSTProcessArray::GetLoginState() | |
| 955 | { | |||
| 956 | return iLoginState; | |||
| 957 | } | |||
| 958 | ||||
| 959 | // ----------------------------------------------------------------------------- | |||
| 960 | // CVIMPSTProcessArray::GetOnlineStatus | |||
| 961 | // ----------------------------------------------------------------------------- | |||
| 962 | ||||
| 2 | 0 | 963 | TVIMPSTEnums::TOnlineStatus CVIMPSTProcessArray::GetOnlineStatusL(TInt aIndex) | |
| 964 | { | |||
| 965 | TVIMPSTEnums::TItem itemtype = GetType( aIndex ); | |||
| 966 | TVIMPSTEnums::TOnlineStatus status = TVIMPSTEnums::EUnknown; | |||
| 967 | switch(itemtype) | |||
| 968 | { | |||
| 969 | case TVIMPSTEnums::EOwnStatusItem: | |||
| 970 | { | |||
| 971 | if( iContactInterface ) | |||
| 972 | { | |||
| 973 | status = iContactInterface->OwnContactL().OnlineStatus(); | |||
| 974 | } | |||
| 975 | break; | |||
| 976 | } | |||
| 977 | case TVIMPSTEnums::EContactItem: | |||
| 978 | { | |||
| 979 | MVIMPSTStorageContact* contact = iContactInterface->FindContactByUserId( GetItemUserId(aIndex) ); | |||
| 980 | if(contact) | |||
| 981 | { | |||
| 982 | status = contact->OnlineStatus(); | |||
| 983 | } | |||
| 984 | break; | |||
| 985 | } | |||
| 986 | case TVIMPSTEnums::EInvalid: | |||
| 987 | default: | |||
| 988 | { | |||
| 989 | break; | |||
| 990 | } | |||
| 991 | } | |||
| 992 | return status; | |||
| 993 | } | |||
| 994 | //----------------------------------------------------------- | |||
| 995 | //CVIMPSTProcessArray::StatusText | |||
| 996 | //----------------------------------------------------------- | |||
| 997 | // | |||
| 2 | 0 | 998 | const TDesC& CVIMPSTProcessArray::StatusTextL(TInt aIndex ) | |
| 999 | { | |||
| 1000 | TVIMPSTEnums::TItem itemtype = GetType( aIndex ); | |||
| 1001 | switch(itemtype) | |||
| 1002 | { | |||
| 1003 | case TVIMPSTEnums::EOwnStatusItem: | |||
| 1004 | { | |||
| 1005 | if( iContactInterface ) | |||
| 1006 | { | |||
| 1007 | return iContactInterface->OwnContactL().StatusText(); | |||
| 1008 | } | |||
| 1009 | break; | |||
| 1010 | } | |||
| 1011 | case TVIMPSTEnums::EContactItem: | |||
| 1012 | { | |||
| 1013 | MVIMPSTStorageContact* contact = iContactInterface->FindContactByUserId(GetItemUserId(aIndex)); | |||
| 1014 | if(contact && contact->StatusText().Length() ) | |||
| 1015 | { | |||
| 1016 | // KStatusMsgMaxLenght is the max length of the status message shown | |||
| 1017 | // make sure that it copies only that much | |||
| 1018 | return contact->StatusText(); | |||
| 1019 | } | |||
| 1020 | break; | |||
| 1021 | } | |||
| 1022 | case TVIMPSTEnums::EInvalid: | |||
| 1023 | default: | |||
| 1024 | { | |||
| 1025 | break; | |||
| 1026 | } | |||
| 1027 | } | |||
| 1028 | return KNullDesC; | |||
| 1029 | } | |||
| 1030 | //----------------------------------------------------------- | |||
| 1031 | //CVIMPSTProcessArray::RemoveFromUnknonOrInvitationListL | |||
| 1032 | //----------------------------------------------------------- | |||
| 1033 | // | |||
| 2 | 0 | 1034 | TBool CVIMPSTProcessArray::RemoveFromUnknonOrInvitationListL( const TDesC& aAddedUserId ,TBool aBlocked ) | |
| 1035 | { | |||
| 1036 | TBool found = RemoveFromUnknonListL( aAddedUserId ); | |||
| 1037 | if( !found ) | |||
| 1038 | { | |||
| 1039 | found = RemoveFromInvitationListL( aAddedUserId ); | |||
| 1040 | } | |||
| 1041 | //Get IM SubService | |||
| 1042 | if( aBlocked && found && aAddedUserId.Length() ) | |||
| 1043 | { | |||
| 1044 | MVIMPSTEngineSubService* subService = | |||
| 1045 | (iEngine.SubService(TVIMPSTEnums::EIM)); | |||
| 1046 | ||||
| 1047 | if(subService ) | |||
| 1048 | { | |||
| 1049 | MVIMPSTEngineIMSubService& imSubService = | |||
| 1050 | MVIMPSTEngineIMSubService::Cast (*subService); | |||
| 1051 | imSubService.CloseConversationL( aAddedUserId ); | |||
| 1052 | } | |||
| 1053 | } | |||
| 1054 | return found; | |||
| 1055 | } | |||
| 1056 | //----------------------------------------------------------- | |||
| 1057 | //CVIMPSTProcessArray::RemoveFromUnknonListL | |||
| 1058 | //----------------------------------------------------------- | |||
| 1059 | // | |||
| 4 | 0 | 1060 | TBool CVIMPSTProcessArray::RemoveFromUnknonListL( const TDesC& aAddedUserId ) | |
| 1061 | { | |||
| 1062 | TRACE( T_LIT("CVIMPSTProcessArray::RemoveFromUnknonListL start ") ); | |||
| 1063 | TPtrC addedUserId = VIMPSTUtils::DisplayId( aAddedUserId ); | |||
| 1064 | TBool found = EFalse; | |||
| 1065 | TInt count = iUnKnownContactArray.Count(); | |||
| 1066 | CVIMPSTProcessUnknownContactItem* unknownItem = NULL; | |||
| 1067 | TInt index = KErrNotFound; | |||
| 1068 | TInt itemIndex = KErrNotFound; | |||
| 1069 | // check in unknon array | |||
| 1070 | for(index = 0 ; index < count ; index++) | |||
| 1071 | { | |||
| 1072 | unknownItem = iUnKnownContactArray[index]; | |||
| 1073 | TPtrC contactId = VIMPSTUtils::DisplayId( unknownItem->GetItemUserId() ); | |||
| 1074 | if( addedUserId.Compare( contactId ) == 0 ) | |||
| 1075 | { | |||
| 1076 | itemIndex = iItemArray.Find(unknownItem); | |||
| 1077 | if( itemIndex > -1 ) | |||
| 1078 | { | |||
| 1079 | found = ETrue; | |||
| 1080 | } | |||
| 1081 | break; | |||
| 1082 | } | |||
| 1083 | TRACE( T_LIT("CVIMPSTProcessArray::RemoveFromUnknonListL for ends") ); | |||
| 1084 | } | |||
| 1085 | if( found ) | |||
| 1086 | { | |||
| 1087 | iItemArray.Remove(itemIndex); | |||
| 1088 | iUnKnownContactArray.Remove( index ); | |||
| 1089 | delete unknownItem; | |||
| 1090 | unknownItem = NULL; | |||
| 1091 | iItemArray.Compress(); | |||
| 1092 | iUnKnownContactArray.Compress(); | |||
| 1093 | if( iProcessObservers ) | |||
| 1094 | { | |||
| 1095 | // this is to refresh the list box | |||
| 1096 | // KErrNotFound , focus remain at same position | |||
| 1097 | iProcessObservers->HandleDeletionL(TVIMPSTEnums::EUnknonContactItem, KErrNotFound ); | |||
| 1098 | } | |||
| 1099 | } | |||
| 1100 | TRACE( T_LIT("CVIMPSTProcessArray::RemoveFromUnknonListL end ") ); | |||
| 1101 | return found; | |||
| 1102 | } | |||
| 1103 | //----------------------------------------------------------- | |||
| 1104 | //CVIMPSTProcessArray::RemoveFromInvitationListL | |||
| 1105 | //----------------------------------------------------------- | |||
| 1106 | // | |||
| 2 | 0 | 1107 | TBool CVIMPSTProcessArray::RemoveFromInvitationListL( const TDesC& aAddedUserId ) | |
| 1108 | { | |||
| 1109 | TPtrC addedUserId = VIMPSTUtils::DisplayId( aAddedUserId ); | |||
| 1110 | TBool found = EFalse; | |||
| 1111 | TInt index = KErrNotFound; | |||
| 1112 | TInt itemIndex = KErrNotFound; | |||
| 1113 | // item not foun in unknown list | |||
| 1114 | // check in invitation item array | |||
| 1115 | TInt count = iAddRequestArray.Count(); | |||
| 1116 | CVIMPSTProcessFriendRequestItem* requestItem = NULL; | |||
| 1117 | for(index = 0 ; index < count ; index++) | |||
| 1118 | { | |||
| 1119 | requestItem = iAddRequestArray[index]; | |||
| 1120 | TPtrC contactId = VIMPSTUtils::DisplayId( requestItem->GetItemUserId() ); | |||
| 1121 | if( addedUserId.Compare( contactId ) == 0 ) | |||
| 1122 | { | |||
| 1123 | itemIndex = iItemArray.Find(requestItem); | |||
| 1124 | if( itemIndex > -1 ) | |||
| 1125 | { | |||
| 1126 | found = ETrue; | |||
| 1127 | } | |||
| 1128 | break; | |||
| 1129 | } | |||
| 1130 | } | |||
| 1131 | if( found ) | |||
| 1132 | { | |||
| 1133 | iItemArray.Remove(itemIndex); | |||
| 1134 | iAddRequestArray.Remove( index ); | |||
| 1135 | delete requestItem; | |||
| 1136 | requestItem = NULL; | |||
| 1137 | iItemArray.Compress(); | |||
| 1138 | iAddRequestArray.Compress(); | |||
| 1139 | if( iProcessObservers ) | |||
| 1140 | { | |||
| 1141 | // this is to refresh the list box | |||
| 1142 | // KErrNotFound , focus remain at same position | |||
| 1143 | iProcessObservers->HandleDeletionL(TVIMPSTEnums::EFriendRequestItem, KErrNotFound ); | |||
| 1144 | } | |||
| 1145 | } | |||
| 1146 | return found; | |||
| 1147 | } | |||
| 1148 | //----------------------------------------------------------- | |||
| 1149 | //CVIMPSTProcessArray::MapContactListPositions | |||
| 1150 | //----------------------------------------------------------- | |||
| 1151 | // | |||
| 0 | 0 | - | 1152 | void CVIMPSTProcessArray::MapContactListPositions(RArray<TInt>& aPos ) |
| 1153 | { | |||
| 1154 | // add conversation also this list ..and return.. | |||
| 1155 | RArray<TInt> listPos; | |||
| 1156 | ||||
| 1157 | // iContactListModel->MapContactListPositions(listPos); | |||
| 1158 | TInt positionIndex = 0; | |||
| 1159 | // if count is more than 0..fill the maparray... | |||
| 1160 | if(iItemArray.Count() + iContactListIndex > 0) | |||
| 1161 | { | |||
| 1162 | ||||
| 1163 | TInt count = listPos.Count(); | |||
| 1164 | ||||
| 1165 | for(TInt posIndex = 0; posIndex < count; posIndex++, positionIndex++) | |||
| 1166 | { | |||
| 1167 | aPos.Append( listPos[posIndex] + iContactListIndex ); | |||
| 1168 | } | |||
| 1169 | } | |||
| 1170 | listPos.Close(); | |||
| 1171 | } | |||
| 1172 | // ----------------------------------------------------------------------------- | |||
| 1173 | // CVIMPSTProcessArray::GetAndCreateOpenChatListL | |||
| 1174 | // return contact index including friend request. | |||
| 1175 | // ----------------------------------------------------------------------------- | |||
| 2 | 2 | 1176 | void CVIMPSTProcessArray::GetAndCreateOpenChatListL() | |
| 1177 | { | |||
| 1178 | //Get IM SubService | |||
| 1179 | MVIMPSTEngineSubService* subService = | |||
| 1180 | (iEngine.SubService(TVIMPSTEnums::EIM)); | |||
| 1181 | RArray<SIMCacheChatItem> openChats; | |||
| 1182 | openChats.Reset(); | |||
| 1183 | if(subService) | |||
| 1184 | { | |||
| 1185 | MVIMPSTEngineIMSubService& imSubService = | |||
| 1186 | MVIMPSTEngineIMSubService::Cast (*subService); | |||
| 1187 | openChats = imSubService.GetOpenChatListL(); | |||
| 1188 | } | |||
| 1189 | while( openChats.Count() ) | |||
| 1190 | { | |||
| 1191 | SIMCacheChatItem chat = openChats[ 0 ]; // first item | |||
| 1192 | TPtrC contactId = *chat.iBuddyId; | |||
| 1193 | MVIMPSTProcessArrayItem* arrayItem = FindArrayItem( contactId ); | |||
| 1194 | TBool msgPending = EFalse; | |||
| 1195 | if( contactId.Length() ) | |||
| 1196 | { | |||
| 1197 | if( IsUnreadMessageExistsL( contactId ) ) | |||
| 1198 | { | |||
| 1199 | msgPending = ETrue; | |||
| 1200 | } | |||
| 1201 | } | |||
| 1202 | if( arrayItem ) | |||
| 1203 | { | |||
| 1204 | arrayItem->SetConversationOpen( ETrue ); | |||
| 1205 | arrayItem->SetMsgPending( msgPending ); | |||
| 1206 | } | |||
| 1207 | else | |||
| 1208 | { | |||
| 1209 | // not in buddy List | |||
| 1210 | DoHandleUnKnownContactMessageL( contactId ,msgPending ); | |||
| 1211 | } | |||
| 1212 | openChats.Remove( 0 ); | |||
| 1213 | delete chat.iBuddyId; | |||
| 1214 | chat.iBuddyId = NULL; | |||
| 1215 | openChats.Compress(); | |||
| 1216 | } | |||
| 1217 | } | |||
| 1218 | //----------------------------------------------------------- | |||
| 1219 | //CVIMPSTProcessArray::FindArrayItem | |||
| 1220 | //----------------------------------------------------------- | |||
| 1221 | // | |||
| 2 | 0 | 1222 | MVIMPSTProcessArrayItem* CVIMPSTProcessArray::FindArrayItem( const TDesC& aSenderId ) | |
| 1223 | { | |||
| 1224 | TPtrC senderId = VIMPSTUtils::DisplayId( aSenderId ); | |||
| 1225 | MVIMPSTProcessArrayItem* arrayItem = NULL; | |||
| 1226 | TInt count = iItemArray.Count(); | |||
| 1227 | for( TInt i = 1; i < count; i++ ) | |||
| 1228 | { | |||
| 1229 | MVIMPSTProcessArrayItem* contactItem = (MVIMPSTProcessArrayItem *)iItemArray[i]; | |||
| 1230 | TPtrC contactId = VIMPSTUtils::DisplayId( contactItem->GetItemUserId() ); | |||
| 1231 | if( senderId.Compare( contactId ) == 0 ) | |||
| 1232 | { | |||
| 1233 | arrayItem = contactItem; | |||
| 1234 | break; | |||
| 1235 | } | |||
| 1236 | } | |||
| 1237 | return arrayItem; | |||
| 1238 | } | |||
| 1239 | //----------------------------------------------------------- | |||
| 1240 | //CVIMPSTProcessArray::HandleChatMessageEventL | |||
| 1241 | //----------------------------------------------------------- | |||
| 1242 | // | |||
| 12 | 12 | 1243 | void CVIMPSTProcessArray::HandleChatMessageEventL( TVIMPSTEnums::TIMEventType aEventType , | |
| 1244 | const TDesC& aSender ) | |||
| 1245 | { | |||
| 1246 | if( !iFetchCompleted ) | |||
| 1247 | { | |||
| 1248 | // contact matching will not be correct until fetching completed | |||
| 1249 | // hence return | |||
| 1250 | return; | |||
| 1251 | } | |||
| 1252 | switch( aEventType ) | |||
| 1253 | { | |||
| 1254 | case TVIMPSTEnums::EIMUnreadMessage: | |||
| 1255 | { | |||
| 1256 | if( FindAndMarkContactAsOpenChat( aSender , ETrue ) ) | |||
| 1257 | { | |||
| 1258 | if(iProcessObservers) | |||
| 1259 | { | |||
| 1260 | iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, KErrNotFound ); | |||
| 1261 | } | |||
| 1262 | } | |||
| 1263 | else | |||
| 1264 | { | |||
| 1265 | DoHandleUnKnownContactMessageL( aSender , ETrue ); | |||
| 1266 | } | |||
| 1267 | break; | |||
| 1268 | } | |||
| 1269 | case TVIMPSTEnums::EIMUnreadChange: | |||
| 1270 | { | |||
| 1271 | FindAndMarkContactAsOpenChat( aSender , EFalse ) ; | |||
| 1272 | if(iProcessObservers) | |||
| 1273 | { | |||
| 1274 | iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem,KErrNotFound ); | |||
| 1275 | } | |||
| 1276 | break; | |||
| 1277 | } | |||
| 1278 | case TVIMPSTEnums::EIMChatStarted: | |||
| 1279 | { | |||
| 1280 | if( FindAndMarkContactAsOpenChat( aSender , EFalse ) ) | |||
| 1281 | { | |||
| 1282 | if(iProcessObservers) | |||
| 1283 | { | |||
| 1284 | iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, KErrNotFound ); | |||
| 1285 | } | |||
| 1286 | } | |||
| 1287 | else | |||
| 1288 | { | |||
| 1289 | DoHandleUnKnownContactMessageL( aSender, EFalse ); | |||
| 1290 | } | |||
| 1291 | break; | |||
| 1292 | } | |||
| 1293 | case TVIMPSTEnums::EIMChatClosed: | |||
| 1294 | { | |||
| 1295 | if( !RemoveFromUnknonListL( aSender ) ) | |||
| 1296 | { | |||
| 1297 | MVIMPSTProcessArrayItem* arrayItem = FindArrayItem( aSender ); | |||
| 1298 | if( arrayItem ) | |||
| 1299 | { | |||
| 1300 | arrayItem->SetConversationOpen( EFalse ); | |||
| 1301 | arrayItem->SetMsgPending( EFalse ); | |||
| 1302 | } | |||
| 1303 | } | |||
| 1304 | if(iProcessObservers) | |||
| 1305 | { | |||
| 1306 | iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, KErrNotFound ); | |||
| 1307 | } | |||
| 1308 | break; | |||
| 1309 | } | |||
| 1310 | case TVIMPSTEnums::EIMAllChatClosed: | |||
| 1311 | { | |||
| 1312 | RemoveUnKnownContacts(); | |||
| 1313 | iUnKnownContactArray.ResetAndDestroy();// delete all items | |||
| 1314 | ResetOpenConversationPendingMsg(); | |||
| 1315 | if(iProcessObservers) | |||
| 1316 | { | |||
| 1317 | iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, KErrNotFound ); | |||
| 1318 | } | |||
| 1319 | break; | |||
| 1320 | } | |||
| 1321 | case TVIMPSTEnums::EIMRequestCompleted: | |||
| 1322 | { | |||
| 1323 | if(iProcessObservers) | |||
| 1324 | { | |||
| 1325 | iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, KErrNotFound ); | |||
| 1326 | } | |||
| 1327 | break; | |||
| 1328 | } | |||
| 1329 | default: | |||
| 1330 | { | |||
| 1331 | // do nothing | |||
| 1332 | } | |||
| 1333 | } | |||
| 1334 | } | |||
| 1335 | //----------------------------------------------------------- | |||
| 1336 | //CVIMPSTProcessArray::HandleAddRequestEventL | |||
| 1337 | //----------------------------------------------------------- | |||
| 1338 | // | |||
| 18 | 18 | 1339 | void CVIMPSTProcessArray::HandleAddRequestEventL(TVIMPSTEnums::TOperationType aType, const TDesC& aRequesterId, | |
| 1340 | const TDesC& aRequestorDisplayName ) | |||
| 1341 | { | |||
| 1342 | //add new add request item at top of list(i.e at index 1, as 0 is own id). | |||
| 1343 | //when request is entertained remove item from list. | |||
| 1344 | switch( aType ) | |||
| 1345 | { | |||
| 1346 | case TVIMPSTEnums::EAddItem : | |||
| 1347 | { | |||
| 1348 | if( (!FindAnyAddRequest(aRequesterId ) )&& ( !FindAnyContactServiceField( aRequesterId ) ) && !(IsContactBlocked( aRequesterId )) ) | |||
| 1349 | { | |||
| 1350 | CVIMPSTProcessFriendRequestItem* addRequestItem = CVIMPSTProcessFriendRequestItem::NewL(aRequesterId,aRequestorDisplayName); | |||
| 1351 | /* Add it as the first Item of IAddRequestARray as its like stack */ | |||
| 1352 | iAddRequestArray.Insert(addRequestItem,0); | |||
| 1353 | /* | |||
| 1354 | * always the new friend request will be shown in the beginning, so 0th item is own item, 1st item is new friendrequest | |||
| 1355 | * and remaining remains same.. | |||
| 1356 | */ | |||
| 1357 | // ownership is in iItemArray | |||
| 1358 | TInt invitationIndex = iUnKnownContactArray.Count()+1; | |||
| 1359 | iItemArray.Insert(addRequestItem, invitationIndex); | |||
| 1360 | if(iProcessObservers) | |||
| 1361 | { | |||
| 1362 | iProcessObservers->HandleAdditionL( TVIMPSTEnums::EFriendRequestItem ,KErrNotFound ); | |||
| 1363 | } | |||
| 1364 | } | |||
| 1365 | break; | |||
| 1366 | } | |||
| 1367 | case TVIMPSTEnums::ERemoveItem : | |||
| 1368 | { | |||
| 1369 | TInt count = iAddRequestArray.Count(); | |||
| 1370 | CVIMPSTProcessFriendRequestItem* requestItem = NULL; | |||
| 1371 | for(TInt i = 0 ; i < count ; i++) | |||
| 1372 | { | |||
| 1373 | requestItem = iAddRequestArray[i]; | |||
| 1374 | if( aRequesterId.Compare(requestItem->GetItemUserId()) == 0 ) | |||
| 1375 | { | |||
| 1376 | TInt index = iItemArray.Find(requestItem); | |||
| 1377 | if(index != KErrNotFound) | |||
| 1378 | { | |||
| 1379 | iItemArray.Remove(index); | |||
| 1380 | iItemArray.Compress(); | |||
| 1381 | } | |||
| 1382 | iAddRequestArray.Remove(i); | |||
| 1383 | delete requestItem; | |||
| 1384 | iAddRequestArray.Compress(); | |||
| 1385 | break; | |||
| 1386 | } | |||
| 1387 | } | |||
| 1388 | if(iProcessObservers) | |||
| 1389 | { | |||
| 1390 | iProcessObservers->HandleDeletionL(TVIMPSTEnums::EFriendRequestItem, KErrNotFound ); | |||
| 1391 | } | |||
| 1392 | break; | |||
| 1393 | } | |||
| 1394 | default : | |||
| 1395 | break; | |||
| 1396 | } | |||
| 1397 | } | |||
| 1398 | //----------------------------------------------------------- | |||
| 1399 | //CVIMPSTProcessArray::DoHandleUnKnownContactMessageL | |||
| 1400 | //----------------------------------------------------------- | |||
| 1401 | // | |||
| 2 | 2 | 1402 | void CVIMPSTProcessArray::DoHandleUnKnownContactMessageL( const TDesC& aSenderId ,TBool aIsMsgPending ) | |
| 1403 | { | |||
| 1404 | TBool contactExist = EFalse ; | |||
| 1405 | TInt count = iUnKnownContactArray.Count(); | |||
| 1406 | CVIMPSTProcessUnknownContactItem* unknownItem = NULL; | |||
| 1407 | for( TInt i=0; i<count; i++ ) | |||
| 1408 | { | |||
| 1409 | unknownItem = iUnKnownContactArray[i]; | |||
| 1410 | if( aSenderId.Compare( unknownItem->GetItemUserId() ) == 0 ) | |||
| 1411 | { | |||
| 1412 | contactExist = ETrue; | |||
| 1413 | unknownItem->SetConversationOpen(ETrue); | |||
| 1414 | unknownItem->SetMsgPending( aIsMsgPending ); | |||
| 1415 | break; | |||
| 1416 | } | |||
| 1417 | } | |||
| 1418 | if( !contactExist ) | |||
| 1419 | { | |||
| 1420 | CVIMPSTProcessUnknownContactItem* addItem = CVIMPSTProcessUnknownContactItem::NewL(aSenderId); | |||
| 1421 | /* Add it as the first Item of IAddRequestARray as its like stack */ | |||
| 1422 | iUnKnownContactArray.Insert(addItem,0); | |||
| 1423 | // ownership is in iItemArray | |||
| 1424 | iItemArray.Insert(addItem, 1); // just after own Item | |||
| 1425 | addItem->SetMsgPending( aIsMsgPending ); | |||
| 1426 | addItem->SetConversationOpen(ETrue); | |||
| 1427 | } | |||
| 1428 | if(iProcessObservers) | |||
| 1429 | { | |||
| 1430 | iProcessObservers->HandleAdditionL( TVIMPSTEnums::EUnknonContactItem ,KErrNotFound ); | |||
| 1431 | } | |||
| 1432 | } | |||
| 1433 | //----------------------------------------------------------- | |||
| 1434 | //CVIMPSTProcessArray::IsMsgPending | |||
| 1435 | //----------------------------------------------------------- | |||
| 1436 | // | |||
| 0 | 0 | - | 1437 | TBool CVIMPSTProcessArray::IsMsgPending(TInt aIndex) |
| 1438 | { | |||
| 1439 | if( aIndex < iItemArray.Count() && aIndex >= 0 ) | |||
| 1440 | { | |||
| 1441 | MVIMPSTProcessArrayItem* item = (MVIMPSTProcessArrayItem *)iItemArray[aIndex]; | |||
| 1442 | if(item) | |||
| 1443 | { | |||
| 1444 | return item->IsMsgPending(); | |||
| 1445 | } | |||
| 1446 | } | |||
| 1447 | return EFalse; | |||
| 1448 | } | |||
| 1449 | ||||
| 1450 | //----------------------------------------------------------- | |||
| 1451 | //CVIMPSTProcessArray::IsConversationExist | |||
| 1452 | //----------------------------------------------------------- | |||
| 1453 | // | |||
| 0 | 0 | - | 1454 | TBool CVIMPSTProcessArray::IsConversationExist(TInt aIndex) |
| 1455 | { | |||
| 1456 | if( aIndex < iItemArray.Count() && aIndex >= 0 ) | |||
| 1457 | { | |||
| 1458 | MVIMPSTProcessArrayItem* item = (MVIMPSTProcessArrayItem *)iItemArray[aIndex]; | |||
| 1459 | if(item) | |||
| 1460 | { | |||
| 1461 | return item->IsConversationOpen(); | |||
| 1462 | } | |||
| 1463 | } | |||
| 1464 | return EFalse; | |||
| 1465 | } | |||
| 1466 | ||||
| 1467 | //----------------------------------------------------------- | |||
| 1468 | //CVIMPSTProcessArray::ResetPendingMsg | |||
| 1469 | //----------------------------------------------------------- | |||
| 1470 | // | |||
| 0 | 0 | - | 1471 | void CVIMPSTProcessArray::ResetPendingMsg(TInt aIndex) |
| 1472 | { | |||
| 1473 | if( aIndex < iItemArray.Count() && aIndex >= 0 ) | |||
| 1474 | { | |||
| 1475 | MVIMPSTProcessArrayItem* item = (MVIMPSTProcessArrayItem *)iItemArray[aIndex]; | |||
| 1476 | if(item) | |||
| 1477 | { | |||
| 1478 | item->SetMsgPending( EFalse ); | |||
| 1479 | } | |||
| 1480 | } | |||
| 1481 | } | |||
| 1482 | //----------------------------------------------------------- | |||
| 1483 | //CVIMPSTProcessArray::ResetOpenConversationPendingMsg | |||
| 1484 | //----------------------------------------------------------- | |||
| 1485 | // | |||
| 2 | 2 | 1486 | void CVIMPSTProcessArray::ResetOpenConversationPendingMsg() | |
| 1487 | { | |||
| 1488 | for( TInt index = 0; index < iItemArray.Count() ;index++ ) | |||
| 1489 | { | |||
| 1490 | MVIMPSTProcessArrayItem* item = (MVIMPSTProcessArrayItem *)iItemArray[index]; | |||
| 1491 | if(item) | |||
| 1492 | { | |||
| 1493 | item->SetConversationOpen( EFalse ); | |||
| 1494 | item->SetMsgPending( EFalse ); | |||
| 1495 | } | |||
| 1496 | } | |||
| 1497 | } | |||
| 1498 | // ----------------------------------------------------------------------------- | |||
| 1499 | // CVIMPSTProcessArray::FindAnyContact | |||
| 1500 | // Try to load with given ID, return NULL if not found. | |||
| 1501 | // ----------------------------------------------------------------------------- | |||
| 4 | 0 | 1502 | TBool CVIMPSTProcessArray::FindAnyContact( const TDesC& aContactId ) | |
| 1503 | { | |||
| 1504 | if(aContactId.Length() != 0) | |||
| 1505 | { | |||
| 1506 | MVIMPSTStorageContact* contact = iContactInterface->FindContactByUserId(aContactId); | |||
| 1507 | if( contact ) | |||
| 1508 | { | |||
| 1509 | return ETrue; | |||
| 1510 | } | |||
| 1511 | } | |||
| 1512 | return EFalse; | |||
| 1513 | } | |||
| 1514 | ||||
| 1515 | // ----------------------------------------------------------------------------- | |||
| 1516 | // CVIMPSTProcessArray::FindAnyContactServiceField | |||
| 1517 | // Try to load with given ID, return NULL if not found. | |||
| 1518 | // ----------------------------------------------------------------------------- | |||
| 8 | 0 | 1519 | TBool CVIMPSTProcessArray::FindAnyContactServiceField( const TDesC& aContactId ) | |
| 1520 | { | |||
| 1521 | if(aContactId.Length() != 0) | |||
| 1522 | { | |||
| 1523 | MVIMPSTStorageContact* contact = iContactInterface->FindContactByUserId(aContactId); | |||
| 1524 | if( contact ) | |||
| 1525 | { | |||
| 1526 | return ETrue; | |||
| 1527 | } | |||
| 1528 | } | |||
| 1529 | return EFalse; | |||
| 1530 | } | |||
| 1531 | // ----------------------------------------------------------------------------- | |||
| 1532 | // CVIMPSTProcessArray::FindAndMarkContactAsOpenChat | |||
| 1533 | // Try to load with given ID, return NULL if not found. | |||
| 1534 | // ----------------------------------------------------------------------------- | |||
| 6 | 0 | 1535 | TBool CVIMPSTProcessArray::FindAndMarkContactAsOpenChat( const TDesC& aContactId, TBool aMesssagePending ) | |
| 1536 | { | |||
| 1537 | TPtrC senderId = VIMPSTUtils::DisplayId( aContactId ); | |||
| 1538 | TBool ret = EFalse; | |||
| 1539 | TInt count = iItemArray.Count(); | |||
| 1540 | for( TInt i = 1; i < count; i++ ) | |||
| 1541 | { | |||
| 1542 | MVIMPSTProcessArrayItem* contactItem = (MVIMPSTProcessArrayItem *)iItemArray[i]; | |||
| 1543 | TPtrC contactId = VIMPSTUtils::DisplayId( contactItem->GetItemUserId() ); | |||
| 1544 | if( senderId.Compare( contactId ) == 0 ) | |||
| 1545 | { | |||
| 1546 | contactItem->SetConversationOpen( ETrue ); | |||
| 1547 | contactItem->SetMsgPending( aMesssagePending ); | |||
| 1548 | ret = ETrue; | |||
| 1549 | break; | |||
| 1550 | } | |||
| 1551 | } | |||
| 1552 | return ret; | |||
| 1553 | } | |||
| 1554 | //----------------------------------------------------------------------------- | |||
| 1555 | // CVIMPSTProcessArray::IsUnreadMessageExists | |||
| 1556 | // ( Other items commented in header ) | |||
| 1557 | //----------------------------------------------------------------------------- | |||
| 136 | 0 | 1558 | TBool CVIMPSTProcessArray::IsUnreadMessageExistsL(const TDesC& aRecipientId) | |
| 1559 | { | |||
| 1560 | TBool ret = EFalse; | |||
| 1561 | TInt unreaMsgCount = KErrNone; | |||
| 1562 | //Get IM SubService | |||
| 1563 | MVIMPSTEngineSubService* subService = | |||
| 1564 | (iEngine.SubService(TVIMPSTEnums::EIM)); | |||
| 1565 | if(subService) | |||
| 1566 | { | |||
| 1567 | MVIMPSTEngineIMSubService& imSubService = | |||
| 1568 | MVIMPSTEngineIMSubService::Cast (*subService); | |||
| 1569 | unreaMsgCount = imSubService.GetUnreadCountL( aRecipientId ); | |||
| 1570 | } | |||
| 1571 | if( unreaMsgCount ) | |||
| 1572 | { | |||
| 1573 | ret = ETrue; | |||
| 1574 | } | |||
| 1575 | return ret; | |||
| 1576 | } | |||
| 1577 | //----------------------------------------------------------------------------- | |||
| 1578 | // CVIMPSTProcessArray::IsConversationExistL | |||
| 1579 | // ( Other items commented in header ) | |||
| 1580 | //----------------------------------------------------------------------------- | |||
| 138 | 0 | 1581 | TBool CVIMPSTProcessArray::IsConversationExistL(const TDesC& aRecipientId) | |
| 1582 | { | |||
| 1583 | //Get IM SubService | |||
| 1584 | MVIMPSTEngineSubService* subService1 = | |||
| 1585 | (iEngine.SubService(TVIMPSTEnums::EIM)); | |||
| 1586 | if(subService1) | |||
| 1587 | { | |||
| 1588 | MVIMPSTEngineIMSubService& imSubService = | |||
| 1589 | MVIMPSTEngineIMSubService::Cast (*subService1); | |||
| 1590 | return imSubService.IsConversationExistL( aRecipientId ); | |||
| 1591 | } | |||
| 1592 | return EFalse; | |||
| 1593 | } | |||
| 1594 | //----------------------------------------------------------------------------- | |||
| 1595 | // CVIMPSTProcessArray::FindContactIndexL | |||
| 1596 | // ( Other items commented in header ) | |||
| 1597 | //----------------------------------------------------------------------------- | |||
| 4 | 0 | 1598 | TInt CVIMPSTProcessArray::FindContactIndexL( const TDesC& aContactId ) | |
| 1599 | { | |||
| 1600 | MVIMPSTStorageContact* newContact = iContactInterface->FindContactByUserId( aContactId ); | |||
| 1601 | if(newContact) | |||
| 1602 | { | |||
| 1603 | // return the index of contact rather bool value.. | |||
| 1604 | // 1 is for own data item. | |||
| 1605 | return (iContactListIndex + 1 + iContactListModel->IndexOfContact( newContact )); | |||
| 1606 | } | |||
| 1607 | return KErrNotFound; | |||
| 1608 | } | |||
| 1609 | ||||
| 1610 | ||||
| 1611 | //----------------------------------------------------------------------------- | |||
| 1612 | // CVIMPSTProcessArray::FillUnknownContactsL | |||
| 1613 | // ( Other items commented in header ) | |||
| 1614 | //------------------------------------------------------------------------------ | |||
| 134 | 134 | 1615 | void CVIMPSTProcessArray::FillUnknownContactsL() | |
| 1616 | { | |||
| 1617 | TInt count = iUnKnownContactArray.Count(); | |||
| 1618 | /* | |||
| 1619 | * Index = 1 cos 0th index will be OwnData, and 1 - n where n is the number of friend requests, will be friend requests | |||
| 1620 | */ | |||
| 1621 | TInt index = 1; | |||
| 1622 | for(TInt i = 0 ; i < count ; i++) | |||
| 1623 | { | |||
| 1624 | // all friend request item ownership is transfered to iItemArray | |||
| 1625 | CVIMPSTProcessUnknownContactItem* unknownItem = iUnKnownContactArray[i]; | |||
| 1626 | unknownItem->SetItemIndex(index); | |||
| 1627 | iItemArray.Insert(unknownItem, index); | |||
| 1628 | index ++; | |||
| 1629 | } | |||
| 1630 | } | |||
| 1631 | ||||
| 1632 | //----------------------------------------------------------------------------- | |||
| 1633 | // CVIMPSTProcessArray::FillAddRequestDataL | |||
| 1634 | // ( Other items commented in header ) | |||
| 1635 | //------------------------------------------------------------------------------ | |||
| 134 | 134 | 1636 | void CVIMPSTProcessArray::FillAddRequestDataL() | |
| 1637 | { | |||
| 1638 | TInt count = iAddRequestArray.Count(); | |||
| 1639 | /* | |||
| 1640 | * Index = unknowncontacts are tops so after that 1 cos 0th index will be OwnData, and 1 - n where n is the number of friend requests, will be friend requests | |||
| 1641 | */ | |||
| 1642 | TInt index = iUnKnownContactArray.Count() +1 ; | |||
| 1643 | for(TInt i = 0 ; i < count ; i++) | |||
| 1644 | { | |||
| 1645 | // all friend request item ownership is transfered to iItemArray | |||
| 1646 | CVIMPSTProcessFriendRequestItem* requestItem = iAddRequestArray[i]; | |||
| 1647 | requestItem->SetItemIndex(index ); | |||
| 1648 | iItemArray.Insert(requestItem, index); | |||
| 1649 | index ++; | |||
| 1650 | } | |||
| 1651 | } | |||
| 1652 | ||||
| 1653 | //----------------------------------------------------------------------------- | |||
| 1654 | // CVIMPSTProcessArray::RemoveUnKnownContacts | |||
| 1655 | // ( Other items commented in header ) | |||
| 1656 | //------------------------------------------------------------------------------ | |||
| 136 | 136 | 1657 | void CVIMPSTProcessArray::RemoveUnKnownContacts() | |
| 1658 | { | |||
| 1659 | TInt count = iUnKnownContactArray.Count(); | |||
| 1660 | for(TInt i = 0 ; i < count ; i++) | |||
| 1661 | { | |||
| 1662 | CVIMPSTProcessUnknownContactItem* unknownItem = iUnKnownContactArray[i]; | |||
| 1663 | TInt index = iItemArray.Find(unknownItem); | |||
| 1664 | if(index > -1) | |||
| 1665 | { | |||
| 1666 | iItemArray.Remove(index); | |||
| 1667 | iItemArray.Compress(); | |||
| 1668 | } | |||
| 1669 | } | |||
| 1670 | } | |||
| 1671 | //----------------------------------------------------------------------------- | |||
| 1672 | // CVIMPSTProcessArray::RemoveAddRequestData | |||
| 1673 | // ( Other items commented in header ) | |||
| 1674 | //------------------------------------------------------------------------------ | |||
| 134 | 134 | 1675 | void CVIMPSTProcessArray::RemoveAddRequestData() | |
| 1676 | { | |||
| 1677 | TInt count = iAddRequestArray.Count(); | |||
| 1678 | for(TInt i = 0 ; i < count ; i++) | |||
| 1679 | { | |||
| 1680 | CVIMPSTProcessFriendRequestItem* requestItem = iAddRequestArray[i]; | |||
| 1681 | TInt index = iItemArray.Find(requestItem); | |||
| 1682 | if(index > -1) | |||
| 1683 | { | |||
| 1684 | iItemArray.Remove(index); | |||
| 1685 | iItemArray.Compress(); | |||
| 1686 | } | |||
| 1687 | } | |||
| 1688 | ||||
| 1689 | } | |||
| 1690 | //----------------------------------------------------------------------------- | |||
| 1691 | // CVIMPSTProcessArray::LoginUserIdFromStoreL | |||
| 1692 | // ( Other items commented in header ) | |||
| 1693 | //------------------------------------------------------------------------------ | |||
| 1694 | ||||
| 2 | 0 | 1695 | const TDesC& CVIMPSTProcessArray::LoginUserIdFromStoreL() const | |
| 1696 | { | |||
| 1697 | if( iContactInterface ) | |||
| 1698 | { | |||
| 1699 | // most of the time this get called | |||
| 1700 | return iContactInterface->OwnContactL().UserId(); | |||
| 1701 | } | |||
| 1702 | return KNullDesC; | |||
| 1703 | } | |||
| 1704 | ||||
| 1705 | //----------------------------------------------------------------------------- | |||
| 1706 | // CVIMPSTProcessArray::AvatarIndex | |||
| 1707 | // ( Other items commented in header ) | |||
| 1708 | //------------------------------------------------------------------------------ | |||
| 1709 | ||||
| 2 | 0 | 1710 | TInt CVIMPSTProcessArray::AvatarIndex(TInt aContactIndex) | |
| 1711 | { | |||
| 1712 | TVIMPSTEnums::TItem itemtype = GetType( aContactIndex ); | |||
| 1713 | /* Codescanner warning is ignored, since Bound check is done | |||
| 1714 | * inside the GetType() method*/ | |||
| 1715 | ||||
| 1716 | if( TVIMPSTEnums::EContactItem == itemtype ) | |||
| 1717 | { | |||
| 1718 | // if the type is a contact item then return the index | |||
| 1719 | MVIMPSTStorageContact* contact = iContactInterface->FindContactByUserId( GetItemUserId(aContactIndex) ); | |||
| 1720 | if(contact) | |||
| 1721 | { | |||
| 1722 | // if any contact is found then return the index | |||
| 1723 | return contact->AvatarIndex(); | |||
| 1724 | } | |||
| 1725 | } | |||
| 1726 | return KErrNone; | |||
| 1727 | } | |||
| 1728 | //----------------------------------------------------------------------------- | |||
| 1729 | // CVIMPSTProcessArray::SetAvatarIndex | |||
| 1730 | // ( Other items commented in header ) | |||
| 1731 | //------------------------------------------------------------------------------ | |||
| 1732 | ||||
| 2 | 2 | 1733 | void CVIMPSTProcessArray::SetAvatarIndex( TInt aContactIndex ,TInt aAvatarIndex ) | |
| 1734 | { | |||
| 1735 | TVIMPSTEnums::TItem itemtype = GetType( aContactIndex ); | |||
| 1736 | if( TVIMPSTEnums::EContactItem == itemtype ) | |||
| 1737 | { | |||
| 1738 | // if the type is a contact item then set the index | |||
| 1739 | MVIMPSTStorageContact* contact = iContactInterface->FindContactByUserId(GetItemUserId(aContactIndex)); | |||
| 1740 | if(contact) | |||
| 1741 | { | |||
| 1742 | // if any contact is found then set the index | |||
| 1743 | contact->SetAvatarIndex( aAvatarIndex ); | |||
| 1744 | } | |||
| 1745 | } | |||
| 1746 | ||||
| 1747 | } | |||
| 1748 | ||||
| 1749 | //----------------------------------------------------------------------------- | |||
| 1750 | // CVIMPSTProcessArray::AvatarContent | |||
| 1751 | // ( Other items commented in header ) | |||
| 1752 | //------------------------------------------------------------------------------ | |||
| 1753 | ||||
| 2 | 0 | 1754 | const TDesC8& CVIMPSTProcessArray::AvatarContent(TInt aContactIndex) | |
| 1755 | { | |||
| 1756 | TVIMPSTEnums::TItem itemtype = GetType( aContactIndex ); | |||
| 1757 | ||||
| 1758 | if( itemtype == TVIMPSTEnums::EContactItem ) | |||
| 1759 | { | |||
| 1760 | // if the type is a contact item then get the avatar content from strorage | |||
| 1761 | MVIMPSTStorageContact* contact = iContactInterface->FindContactByUserId(GetItemUserId(aContactIndex)); | |||
| 1762 | if(contact) | |||
| 1763 | { | |||
| 1764 | // if any contact is found then get the content | |||
| 1765 | return contact->AvatarContent(); | |||
| 1766 | } | |||
| 1767 | } | |||
| 1768 | return KNullDesC8(); | |||
| 1769 | } | |||
| 1770 | //----------------------------------------------------------------------------- | |||
| 1771 | // CVIMPSTProcessArray::OwnAvatarContentL | |||
| 1772 | // ( Other items commented in header ) | |||
| 1773 | //------------------------------------------------------------------------------ | |||
| 1774 | ||||
| 2 | 0 | 1775 | const TDesC8& CVIMPSTProcessArray::OwnAvatarContentL( ) const | |
| 1776 | { | |||
| 1777 | MVIMPSTStorageContact& contact = iContactInterface->OwnContactL(); | |||
| 1778 | // if any contact is found then get the content | |||
| 1779 | return contact.AvatarContent(); | |||
| 1780 | } | |||
| 1781 | //----------------------------------------------------------------------------- | |||
| 1782 | // CVIMPSTProcessArray::OwnAvatarIndexL | |||
| 1783 | // ( Other items commented in header ) | |||
| 1784 | //------------------------------------------------------------------------------ | |||
| 1785 | ||||
| 2 | 0 | 1786 | TInt CVIMPSTProcessArray::OwnAvatarIndexL( ) | |
| 1787 | { | |||
| 1788 | MVIMPSTStorageContact& contact = iContactInterface->OwnContactL(); | |||
| 1789 | return contact.AvatarIndex(); | |||
| 1790 | } | |||
| 1791 | //----------------------------------------------------------------------------- | |||
| 1792 | // CVIMPSTProcessArray::SetOwnAvatarIndexL | |||
| 1793 | // ( Other items commented in header ) | |||
| 1794 | //------------------------------------------------------------------------------ | |||
| 1795 | ||||
| 0 | 0 | - | 1796 | void CVIMPSTProcessArray::SetOwnAvatarIndexL( TInt aAvatarIndex ) |
| 1797 | { | |||
| 1798 | MVIMPSTStorageContact& contact = iContactInterface->OwnContactL(); | |||
| 1799 | contact.SetAvatarIndex( aAvatarIndex ); | |||
| 1800 | } | |||
| 1801 | ||||
| 1802 | //----------------------------------------------------------------------------- | |||
| 1803 | // CVIMPSTProcessArray::FindAnyAddRequest | |||
| 1804 | // ( Other items commented in header ) | |||
| 1805 | //------------------------------------------------------------------------------ | |||
| 1806 | ||||
| 20 | 0 | 1807 | TInt CVIMPSTProcessArray::FindAnyAddRequest( const TDesC& aRequesterId ) | |
| 1808 | { | |||
| 1809 | TInt count = iAddRequestArray.Count(); | |||
| 1810 | for(TInt i=0; i<count; i++) | |||
| 1811 | { | |||
| 1812 | if((aRequesterId.Compare(iAddRequestArray[i]->GetItemUserId()))==0 ) | |||
| 1813 | { | |||
| 1814 | return ETrue; | |||
| 1815 | } | |||
| 1816 | } | |||
| 1817 | return EFalse; | |||
| 1818 | } | |||
| 1819 | ||||
| 1820 | // ----------------------------------------------------------------------------- | |||
| 1821 | // CVIMPSTProcessArray::GetSelectedItemIndex | |||
| 1822 | // return contact index including friend request. | |||
| 1823 | // ----------------------------------------------------------------------------- | |||
| 6 | 0 | 1824 | TInt CVIMPSTProcessArray::GetSelectedItemIndex(const TDesC& aContactId) | |
| 1825 | { | |||
| 1826 | TInt itemArrayCount = iItemArray.Count(); | |||
| 1827 | for(TInt index=0; index<itemArrayCount; index++) | |||
| 1828 | { | |||
| 1829 | MVIMPSTProcessArrayItem* item = iItemArray[ index ]; | |||
| 1830 | if(0 == aContactId.Compare(item->GetItemUserId())) | |||
| 1831 | { | |||
| 1832 | return index; | |||
| 1833 | } | |||
| 1834 | } | |||
| 1835 | return KErrNotFound; | |||
| 1836 | } | |||
| 1837 | ||||
| 1838 | // -------------------------------------------------------------------------- | |||
| 1839 | // CVIMPSTProcessArray::IsContactBlocked | |||
| 1840 | // -------------------------------------------------------------------------- | |||
| 8 | 0 | 1841 | TBool CVIMPSTProcessArray::IsContactBlocked(const TDesC& aUserId) | |
| 1842 | { | |||
| 1843 | MVIMPSTEngineSubService* subService = | |||
| 1844 | (iEngine.SubService(TVIMPSTEnums::EPresence)); | |||
| 1845 | if(subService) | |||
| 1846 | { | |||
| 1847 | MVIMPSTEnginePresenceSubService& presence = | |||
| 1848 | MVIMPSTEnginePresenceSubService::Cast (*subService); | |||
| 1849 | ||||
| 1850 | RPointerArray<HBufC> *blockedlist = presence .GetBlockedList(); | |||
| 1851 | ||||
| 1852 | if(blockedlist) | |||
| 1853 | { | |||
| 1854 | for(TInt i=0; i<blockedlist->Count(); ++i) | |||
| 1855 | { | |||
| 1856 | if(0 == aUserId.CompareC((*blockedlist)[i]->Des())) | |||
| 1857 | { | |||
| 1858 | return ETrue; | |||
| 1859 | } | |||
| 1860 | } | |||
| 1861 | } | |||
| 1862 | } | |||
| 1863 | return EFalse; | |||
| 1864 | } | |||
| 1865 | ||||
| 1866 | ||||
| 1867 | //END OF FILE | |||
| ***TER 87% (47/54) of SOURCE FILE cvimpstprocessarray.cpp | ||||