CTC++ Coverage Report - Execution Profile #40/43
Directory Summary | Files Summary | Functions Summary | Execution Profile
To files: First | Previous | Next | Last | Index | No Index
File: \meco_domain\conversations\uiservicetab\vimpstcmdprocess\src\cvimpstprocessarray.cpp
Instrumentation mode: function-decision
TER: 56 % (285/511)

Start/ | End/ |  |  |
True | False | - | Line | Source
| 1 | /*
| 2 | * ===========================================================================
| 3 | * Name : cvimpstprocessarray.cpp
| 4 | * Part of : IMUiServiceTab/vimpstcmdprocess
| 5 | * Description :
| 6 | * Version : %version: 68.1.29 %
| 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 | //
118 | 118 |  | 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") );
46 | 0 | - | 70 | if(iContactInterface)
| 71 | {
| 72 | iContactInterface->RemoveObserver( this );
| 73 | }
| 74 | iItemArray.ResetAndDestroy();
| 75 | iItemArray.Close();
| 76 | iUnKnownContactArray.Close();
| 77 | iAddRequestArray.Close();
| 78 |
46 | 0 | - | 79 | if(iData)
| 80 | {
| 81 | delete iData;
| 82 | iData = NULL;
| 83 | }
| 84 | //Get IM SubService
| 85 | MVIMPSTEngineSubService* subService1 =
| 86 | (iEngine.SubService(TVIMPSTEnums::EIM));
| 87 |
0 | 46 | - | 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 |
46 | 0 | - | 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 | //
118 | 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") );
118 |  |  | 122 | return self;
| 123 |
| 124 | }
| 125 |
| 126 | // --------------------------------------------------------------------------
| 127 | // CVIMPSTProcessArray::ConstructL
| 128 | // --------------------------------------------------------------------------
| 129 | //
118 | 118 |  | 130 | void CVIMPSTProcessArray::ConstructL()
| 131 | {
| 132 | TRACE( T_LIT("CVIMPSTProcessArray::ConstructL Start") );
| 133 | iContactInterface = CVIMPSTStorageManagerFactory::ContactListInterfaceL(iServiceId);
118 | 0 | - | 134 | if(iContactInterface)
| 135 | {
| 136 | iContactInterface->AddObserverL( this );// listen these events..
| 137 | }
| 138 | HBufC* unnamed = VIMPSTUtils::LoadResourceL( R_SERVTAB_UNNAMED );
0 | 118 | - | 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));
0 | 118 | - | 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));
118 | 0 | - | 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 | {
2 |  |  | 185 | case TVIMPSTEnums::EStorageContactReadComplete:
| 186 | {
| 187 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageContactReadComplete Start") );
2 | 0 | - | 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") );
2 |  |  | 194 | break;
| 195 | }
2 |  |  | 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 |
2 | 0 | - | 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 | iFetchCompleted = ETrue;
| 207 | GetAndCreateOpenChatListL();
| 208 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageContactFetchComplete End") );
2 |  |  | 209 | break;
| 210 | }
2 |  |  | 211 | case TVIMPSTEnums::EStorageContactReading:
2 |  |  | 212 | case TVIMPSTEnums::EStorageContactFetching:
0 |  | - | 213 | case TVIMPSTEnums::EStorageContactSynchronizing:
| 214 | {
| 215 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageContactFetching/EStorageContactFetching Start") );
| 216 | /*
| 217 | * This event occurs whenever we have contacts added to contactlist. This happens in the following scenarios
| 218 | * 1. At the time of login, when we fetch contacts, contact-by-contact is added to the storage. so we get this event.
| 219 | * 2. When we add a contact manually (either from phonebook, or manu adding etc.. ) we get this callback.
| 220 | */
| 221 | TRACE( T_LIT("contactindex = %d"),aContactIndex );
| 222 | CVIMPSTProcessContactItem* contactItem = CVIMPSTProcessContactItem::NewL (const_cast<TDesC&>(aContact->Name() ),
| 223 | const_cast<TDesC&>(aContact->UserId() ),
| 224 | aContact->ContactLink() );
| 225 |
| 226 | /* 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,
| 227 | * if we havent got a contactviewready, and during that if I get contactaddition, before getting contactFetchComplete, we should keep
| 228 | * appending the items to the array for display, once we get the entire list, its sorted anyway while insertion, and when presence occurs
| 229 | * the contacts are re-sorted.
| 230 | */
| 231 | TRACE( T_LIT("itemarraycount = %d"),iItemArray.Count() );
3 | 1 |  | 232 | if (aContactIndex >= iItemArray.Count() )
| 233 | {
| 234 | TRACE( T_LIT("append contact item %d"), contactItem);
| 235 | iItemArray.Append(contactItem);
| 236 | }
|  |  | 237 | else
| 238 | {
| 239 | TRACE( T_LIT("Insert at index = %d"), aContactIndex);
| 240 | iItemArray.Insert(contactItem, aContactIndex );
| 241 | }
4 | 0 | - | 242 | if(iProcessObservers)
| 243 | {
| 244 | /* passing 0 so that the focus is on owndata item */
| 245 | iProcessObservers->HandleAdditionL(TVIMPSTEnums::EOwnStatusItem, 0);
| 246 | }
4 | 0 | - | 247 | if( aContact->AvatarContent().Length() && iProcessObservers )
| 248 | {
| 249 | iProcessObservers->HandleAvatarChangeL( aContact->UserId() );
| 250 | }
| 251 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageContactFetching/EStorageContactFetching End") );
4 |  |  | 252 | break;
| 253 | }
2 |  |  | 254 | case TVIMPSTEnums::EStorageEventContactAddition:
| 255 | {
| 256 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactAddition Start") );
| 257 |
| 258 | TBool removed = RemoveFromUnknonOrInvitationListL( aContact->UserId(), EFalse );
0 | 2 | - | 259 | if( removed )
| 260 | {
| 261 | aContactIndex = aContactIndex - 1; // one contact is removed from iUnknownContactArray
| 262 | }
| 263 | /*
| 264 | * This event occurs whenever we have contacts added to contactlist. This happens in the following scenarios
| 265 | * 1. At the time of login, when we fetch contacts, contact-by-contact is added to the storage. so we get this event.
| 266 | * 2. When we add a contact manually (either from phonebook, or manu adding etc.. ) we get this callback.
| 267 | */
| 268 | TPtrC userId = aContact->UserId();
| 269 | TRACE( T_LIT("contactindex = %d"),aContactIndex );
| 270 | CVIMPSTProcessContactItem* contactItem = CVIMPSTProcessContactItem::NewL (aContact->Name() ,
| 271 | userId,
| 272 | aContact->ContactLink() );
| 273 |
| 274 | /* 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,
| 275 | * if we havent got a contactviewready, and during that if I get contactaddition, before getting contactFetchComplete, we should keep
| 276 | * appending the items to the array for display, once we get the entire list, its sorted anyway while insertion, and when presence occurs
| 277 | * the contacts are re-sorted.
| 278 | */
| 279 | TRACE( T_LIT("itemarraycount = %d"),iItemArray.Count() );
2 | 0 | - | 280 | if (aContactIndex >= iItemArray.Count() )
| 281 | {
| 282 | TRACE( T_LIT("append contact item = %d"), contactItem);
| 283 | iItemArray.Append(contactItem);
| 284 | }
|  |  | 285 | else
| 286 | {
| 287 | TRACE( T_LIT("Insert at index = %d"), aContactIndex);
| 288 | iItemArray.Insert(contactItem, aContactIndex );
| 289 | }
| 290 | // check if pending message exist
2 | 0 | - | 291 | if( TVIMPSTEnums::ESVCERegistered == iLoginState && userId.Length() )
| 292 | {
0 | 2 | - | 293 | if( IsConversationExistL( userId ) )
| 294 | {
| 295 | contactItem->SetConversationOpen(ETrue);
| 296 | }
0 | 2 | - | 297 | if( IsUnreadMessageExistsL( userId ) )
| 298 | {
| 299 | contactItem->SetMsgPending(ETrue);
| 300 | }
| 301 | }
| 302 |
2 | 0 | - | 303 | if(iProcessObservers)
| 304 | {
| 305 | /* passing aContactIndex so that the focus is on owndata item */
| 306 | iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, aContactIndex );
| 307 | }
| 308 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactAddition End") );
2 |  |  | 309 | break;
| 310 | }
2 |  |  | 311 | case TVIMPSTEnums::EStorageEventContactDelete:
| 312 | {
| 313 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactDelete Start") );
| 314 | TRACE( T_LIT("contactindex = %d"),aContactIndex );
| 315 | TRACE( T_LIT("itemarraycount = %d"),iItemArray.Count() );
1 | 1 |  | 316 | if( aContactIndex < iItemArray.Count() )
| 317 | {
| 318 | MVIMPSTProcessArrayItem* deletedItem = iItemArray[ aContactIndex ];
| 319 | TRACE( T_LIT("contact removed in item array of index = %d"),aContactIndex );
| 320 | iItemArray.Remove (aContactIndex);
| 321 | delete deletedItem;
| 322 | iItemArray.Compress();
| 323 | TRACE( T_LIT("contactindex = %d"),aContactIndex );
| 324 | }
2 | 0 | - | 325 | if(iProcessObservers)
| 326 | {
| 327 | iProcessObservers->HandleDeletionL(TVIMPSTEnums::EContactItem, aContactIndex);
| 328 | }
| 329 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactDelete End") );
2 |  |  | 330 | break;
| 331 | }
2 |  |  | 332 | case TVIMPSTEnums::EStorageAvatarChange:
| 333 | {
| 334 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange Start") );
2 | 0 | - | 335 | if(iProcessObservers && aContact )
| 336 | {
| 337 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange inside if") );
| 338 | TPtrC aUserId = aContact->UserId();
| 339 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange aUserId = %S"), &aUserId );
| 340 | iProcessObservers->HandleAvatarChangeL( aContact->UserId() );
| 341 | }
| 342 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange End") );
2 |  |  | 343 | break;
| 344 | }
2 |  |  | 345 | case TVIMPSTEnums::EStorageOwnPresenceChange:
| 346 | {
| 347 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange Start") );
2 | 0 | - | 348 | if(iProcessObservers)
| 349 | {
| 350 | /* passing index as 0, so thta focus remains at the owndata item */
| 351 | iProcessObservers->HandleAdditionL(TVIMPSTEnums::EOwnStatusItem, KErrNotFound );
| 352 | }
| 353 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange End") );
2 |  |  | 354 | break;
| 355 | }
2 |  |  | 356 | case TVIMPSTEnums::EStorageMultiplePresenceChange:
| 357 | {
| 358 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange Start") );
| 359 | // mostly this will get called after just login and fetch time
| 360 | ResetArray();
2 | 0 | - | 361 | if(iProcessObservers )
| 362 | {
| 363 | iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, KErrNotFound );
| 364 | }
| 365 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange End") );
2 |  |  | 366 | break;
| 367 | }
2 |  |  | 368 | case TVIMPSTEnums::EStoragePresenceChange:
| 369 | {
| 370 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStoragePresenceChange Start") );
| 371 | /*
| 372 | * After Sort we get the new index... So first we need to remove the contact from the old position,
| 373 | * and then re-insert it at the correct obtained position (newIndex in this case)
| 374 | */
| 375 | TRACE( T_LIT("contactindex = %d"),aContactIndex );
| 376 | TRACE( T_LIT("itemarraycount = %d"),iItemArray.Count() );
0 | 2 | - | 377 | if( aContactIndex < iItemArray.Count() )
| 378 | {
| 379 | TInt newIndex = iContactListModel->IndexOfContact( aContact );
| 380 | TRACE( T_LIT("new index = %d"),newIndex );
| 381 | CVIMPSTProcessContactItem* newItem = CVIMPSTProcessContactItem::NewL(const_cast<TDesC&>(aContact->Name() ),
| 382 | const_cast<TDesC&>(aContact->UserId() ),
| 383 | aContact->ContactLink() );
| 384 | MVIMPSTProcessArrayItem* oldItem = iItemArray[ aContactIndex ];
| 385 | TRACE( T_LIT("contact removed in item array of index = %d"),aContactIndex );
| 386 | iItemArray.Remove(aContactIndex );
| 387 | delete oldItem;
| 388 | iItemArray.Compress();
| 389 | // Add it in the new index
| 390 | newIndex = newIndex + 1 + iUnKnownContactArray.Count()+ iAddRequestArray.Count();
0 | 0 | - | 391 | if (newIndex >= iItemArray.Count())
| 392 | {
| 393 | TRACE( T_LIT("append contact item = %d"), newIndex);
| 394 | iItemArray.Append (newItem);
| 395 | }
|  |  | 396 | else
| 397 | {
| 398 | TRACE( T_LIT("Insert at index = %d"), newItem);
| 399 | iItemArray.Insert (newItem, newIndex);
| 400 | }
| 401 | }
2 | 0 | - | 402 | if(iProcessObservers )
| 403 | {
| 404 | iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, KErrNotFound );
| 405 | }
| 406 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStoragePresenceChange End") );
2 |  |  | 407 | break;
| 408 | }
2 |  |  | 409 | case TVIMPSTEnums::EStorageEventOwnUserChanged:
| 410 | {
| 411 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventOwnUserChanged Start") );
| 412 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL start Event = %d"),aEventType );
| 413 | ResetArray();
2 | 0 | - | 414 | if(iProcessObservers )
| 415 | {
| 416 | iProcessObservers->HandleDeletionL(TVIMPSTEnums::EOwnStatusItem, 0 ); // focus own item
| 417 |
2 | 0 | - | 418 | if( aContact )
| 419 | {
| 420 | iProcessObservers->HandleAvatarChangeL( aContact->UserId() );
| 421 | }
| 422 | }
| 423 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventOwnUserChanged End") );
| 424 |
2 |  |  | 425 | break;
| 426 | }
2 |  |  | 427 | case TVIMPSTEnums::EStorageAllContactRemoved:
| 428 | {
| 429 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAllContactRemoved Start") );
| 430 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAllContactRemoved count = %d"), iItemArray.Count() );
| 431 | ResetArray();
2 | 0 | - | 432 | if(iProcessObservers )
| 433 | {
| 434 | iProcessObservers->HandleDeletionL(TVIMPSTEnums::EOwnStatusItem, 0 ); // focus own item
| 435 | }
| 436 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAllContactRemoved End") );
2 |  |  | 437 | break;
| 438 | }
2 |  |  | 439 | case TVIMPSTEnums::EStorageEventContactChange:
| 440 | {
| 441 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactChange Start") );
| 442 | // display name is changed ,might be contact is re-arranged
| 443 | TRACE( T_LIT("contactindex = %d"),aContactIndex );
| 444 | TRACE( T_LIT("itemarraycount = %d"),iItemArray.Count() );
0 | 2 | - | 445 | if( aContactIndex < iItemArray.Count() )
| 446 | {
| 447 | CVIMPSTProcessContactItem* newItem = CVIMPSTProcessContactItem::NewL(const_cast<TDesC&>(aContact->Name() ),
| 448 | const_cast<TDesC&>(aContact->UserId() ),
| 449 | aContact->ContactLink() );
| 450 |
| 451 | MVIMPSTProcessArrayItem* oldItem = iItemArray[ aContactIndex ];
| 452 | TRACE( T_LIT("contact removed in item array of index = %d"),aContactIndex );
| 453 | // set the conversation open flag from old contact, as only the display name would have changed.
| 454 | newItem->SetConversationOpen(oldItem->IsConversationOpen());
| 455 | newItem->SetMsgPending( oldItem->IsMsgPending() );
| 456 | iItemArray.Remove(aContactIndex );
| 457 | delete oldItem;
| 458 | iItemArray.Compress();
| 459 | TRACE( T_LIT("Insert at index = %d"), aContactIndex);
| 460 | TInt newIndex = iContactListModel->IndexOfContact( aContact );
| 461 | // Add it in the new index
| 462 | newIndex = newIndex + 1 + iUnKnownContactArray.Count() + iAddRequestArray.Count();
0 | 0 | - | 463 | if (newIndex >= iItemArray.Count())
| 464 | {
| 465 | TRACE( T_LIT("append contact item = %d"), newIndex);
| 466 | iItemArray.Append (newItem);
| 467 | }
|  |  | 468 | else
| 469 | {
| 470 | TRACE( T_LIT("Insert at index = %d"), newItem);
| 471 | iItemArray.Insert(newItem, newIndex);
| 472 | }
| 473 | // inform the cv about the display name changes
0 | 0 | - | 474 | if(aContact && aContact->UserId().Length() && newItem->IsConversationOpen())
| 475 | {
| 476 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactChange "));
| 477 | TApaTaskList taskList( CCoeEnv::Static()->WsSession() );
| 478 | TApaTask task( taskList.FindApp( KConversationViewAppUid ) );
| 479 |
0 | 0 | - | 480 | if ( task.Exists() )
| 481 | {
| 482 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactChange:task exists"));
| 483 | // packing of data ,passed to conversation view
| 484 | TPckgBuf< TIMCVUiParams > params;
| 485 | params().iBuddyId = aContact->UserId();
| 486 | params().iBuddyName = aContact->Name();
| 487 | params().iServiceId = iServiceId;
| 488 | params().iUpdate = ETrue;
| 489 | task.SendMessage(
| 490 | TUid::Uid( KUidApaMessageSwitchOpenFileValue ), params );
| 491 | }
| 492 | }
| 493 | }
2 | 0 | - | 494 | if(iProcessObservers )
| 495 | {
| 496 | iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, aContactIndex );
| 497 | }
| 498 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactChange End") );
2 |  |  | 499 | break;
| 500 | }
2 |  |  | 501 | case TVIMPSTEnums::EStorageEventUserIdPostChange:
| 502 | {
| 503 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventUserIdPostChange Start") );
| 504 | TRACE( T_LIT("contactindex = %d"),aContactIndex );
| 505 | TRACE( T_LIT("itemarraycount = %d"),iItemArray.Count() );
0 | 2 | - | 506 | if( aContactIndex < iItemArray.Count() )
| 507 | {
| 508 | CVIMPSTProcessContactItem* newItem = CVIMPSTProcessContactItem::NewL(const_cast<TDesC&>(aContact->Name() ),
| 509 | const_cast<TDesC&>(aContact->UserId() ),
| 510 | aContact->ContactLink() );
| 511 | MVIMPSTProcessArrayItem* oldItem = iItemArray[ aContactIndex ];
| 512 | TRACE( T_LIT("contact removed in item array of index = %d"),aContactIndex );
| 513 | iItemArray.Remove(aContactIndex );
| 514 | delete oldItem;
| 515 | iItemArray.Compress();
| 516 | TRACE( T_LIT("Insert at index = %d"), aContactIndex);
| 517 | iItemArray.InsertL (newItem, aContactIndex);
| 518 | }
2 | 0 | - | 519 | if(iProcessObservers )
| 520 | {
| 521 | iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, aContactIndex );
| 522 | }
| 523 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventUserIdPostChange End") );
2 |  |  | 524 | break;
| 525 | }
0 |  | - | 526 | default:
| 527 | {
| 528 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL Event default") );
0 |  | - | 529 | break;
| 530 | }
| 531 | }
| 532 | TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL Function End") );
| 533 | }
| 534 |
| 535 | // --------------------------------------------------------------------------
| 536 | // CVIMPSTProcessArray::AddObserver
| 537 | // --------------------------------------------------------------------------
| 538 | //
6 | 6 |  | 539 | void CVIMPSTProcessArray::AddObserver( MVIMPSTProcessArrayObserver* aObserver )
| 540 | {
| 541 | iProcessObservers = aObserver;
| 542 | }
| 543 | // --------------------------------------------------------------------------
| 544 | // CVIMPSTProcessArray::RemoveObserver
| 545 | // --------------------------------------------------------------------------
| 546 | //
0 | 0 | - | 547 | void CVIMPSTProcessArray::RemoveObserver( )
| 548 | {
| 549 | iProcessObservers = NULL;
| 550 | }
| 551 |
| 552 | // -----------------------------------------------------------------------------
| 553 | // CVIMPSTProcessArray::GetItemNameTextL
| 554 | // -----------------------------------------------------------------------------
| 555 |
4 | 0 |  | 556 | TPtrC CVIMPSTProcessArray::GetItemNameText(TInt aIndex)
| 557 | {
| 558 | TVIMPSTEnums::TItem itemtype = GetType( aIndex );
| 559 | MVIMPSTProcessArrayItem* arrayItem = NULL;
| 560 | /* Codescanner warning is ignored, since Bound check is done
| 561 | * inside the GetType()
| 562 | * method*/
|  |  | 563 | switch(itemtype)
| 564 | {
2 |  |  | 565 | case TVIMPSTEnums::EOwnStatusItem:
| 566 | {
| 567 | MVIMPSTProcessArrayItem *arrayItem = (MVIMPSTProcessArrayItem *)iItemArray[aIndex];
2 |  |  | 568 | return arrayItem->GetItemUserId(); // no name for own user
| 569 | }
0 |  | - | 570 | case TVIMPSTEnums::EContactListItem:
0 |  | - | 571 | case TVIMPSTEnums::EContactItem:
| 572 | {
| 573 | arrayItem = (MVIMPSTProcessArrayItem *)iItemArray[aIndex];
0 |  | - | 574 | break;
| 575 | }
0 |  | - | 576 | case TVIMPSTEnums::EFriendRequestItem:
| 577 | {
| 578 | arrayItem = (MVIMPSTProcessArrayItem *)iItemArray[aIndex];
0 |  | - | 579 | break;
| 580 | }
0 |  | - | 581 | case TVIMPSTEnums::EUnknonContactItem:
| 582 | {
| 583 | arrayItem = (MVIMPSTProcessArrayItem *)iItemArray[aIndex];
0 |  | - | 584 | break;
| 585 | }
2 |  |  | 586 | case TVIMPSTEnums::EInvalid:
0 |  | - | 587 | default:
| 588 | {
2 |  |  | 589 | break;
| 590 | }
| 591 | }
0 | 2 | - | 592 | if( arrayItem )
| 593 | {
0 |  | - | 594 | return arrayItem->GetItemNameText();
| 595 | }
2 |  |  | 596 | return KNullDesC();
| 597 | }
| 598 |
| 599 | // -----------------------------------------------------------------------------
| 600 | // CVIMPSTProcessArray::GetItemUserId
| 601 | // -----------------------------------------------------------------------------
| 602 |
12 | 0 |  | 603 | TPtrC CVIMPSTProcessArray::GetItemUserId(TInt aIndex)
| 604 | {
| 605 | TVIMPSTEnums::TItem itemtype = GetType( aIndex );
| 606 |
| 607 | /* Codescanner warning is ignored, since Bound check is done
| 608 | * inside the GetType()
| 609 | * method*/
|  |  | 610 | switch(itemtype)
| 611 | {
8 |  |  | 612 | case TVIMPSTEnums::EContactItem:
0 |  | - | 613 | case TVIMPSTEnums::EFriendRequestItem:
0 |  | - | 614 | case TVIMPSTEnums::EUnknonContactItem:
2 |  |  | 615 | case TVIMPSTEnums::EOwnStatusItem:
| 616 | {
| 617 | MVIMPSTProcessArrayItem *arrayItem = (MVIMPSTProcessArrayItem *)iItemArray[aIndex];
10 |  |  | 618 | return arrayItem->GetItemUserId(); // no name for own user
| 619 | }
2 |  |  | 620 | default:
| 621 | {
2 |  |  | 622 | return KNullDesC();
| 623 | }
| 624 | }
| 625 | }
| 626 |
| 627 | // -----------------------------------------------------------------------------
| 628 | // CVIMPSTProcessArray::ContactLink
| 629 | // -----------------------------------------------------------------------------
| 630 |
2 | 0 |  | 631 | MVPbkContactLink* CVIMPSTProcessArray::ContactLink(TInt aIndex)
| 632 | {
| 633 | TVIMPSTEnums::TItem itemtype = GetType( aIndex );
| 634 |
| 635 | /* Codescanner warning is ignored, since Bound check is done
| 636 | * inside the GetType()
| 637 | * method*/
|  |  | 638 | switch(itemtype)
| 639 | {
0 |  | - | 640 | case TVIMPSTEnums::EOwnStatusItem:
| 641 | {
0 |  | - | 642 | return NULL;
| 643 | }
0 |  | - | 644 | case TVIMPSTEnums::EContactListItem:
1 |  |  | 645 | case TVIMPSTEnums::EContactItem:
| 646 | {
| 647 | MVIMPSTProcessArrayItem *arrayItem = (MVIMPSTProcessArrayItem *)iItemArray[aIndex];
1 |  |  | 648 | return arrayItem->ContactLink();
| 649 | }
1 |  |  | 650 | case TVIMPSTEnums::EInvalid:
0 |  | - | 651 | default:
| 652 | {
| 653 | }
| 654 | }
1 |  |  | 655 | return NULL;
| 656 | }
| 657 |
| 658 | // -----------------------------------------------------------------------------
| 659 | // CVIMPSTProcessArray::Count
| 660 | // -----------------------------------------------------------------------------
| 661 |
0 | 0 | - | 662 | TInt CVIMPSTProcessArray::Count() const
| 663 | {
| 664 | // return the total count here.
0 |  | - | 665 | return iItemArray.Count() ;
| 666 | }
| 667 | // -----------------------------------------------------------------------------
| 668 | // CVIMPSTProcessArray::IsSubServiceSupportedL
| 669 | // -----------------------------------------------------------------------------
| 670 |
8 | 0 |  | 671 | TBool CVIMPSTProcessArray::IsSubServiceSupportedL(TVIMPSTEnums::SubServiceType aType ) const
| 672 | {
8 |  |  | 673 | return iEngine.IsSubServiceSupportedL(aType );
| 674 | }
| 675 | // -----------------------------------------------------------------------------
| 676 | // CVIMPSTProcessArray::GetType
| 677 | // Get the type from engine and return the type
| 678 | // -----------------------------------------------------------------------------
| 679 |
32 | 0 |  | 680 | TVIMPSTEnums::TItem CVIMPSTProcessArray::GetType(TInt aIndex) const
| 681 | {
| 682 | TInt itemArrayCount = iItemArray.Count();
5 | 27 |  | 683 | if(itemArrayCount <=0 || (aIndex < 0 || aIndex >= itemArrayCount) )
| 684 | {
5 |  |  | 685 | return TVIMPSTEnums::EInvalid;
| 686 | }
| 687 |
27 | 0 | - | 688 | else if(itemArrayCount>0)
| 689 | {
|  |  | 690 | TInt index = aIndex <= 0 ? 0 : aIndex;
5 | 22 |  | 690 | ternary-?: aIndex <= 0
| 691 | MVIMPSTProcessArrayItem* item = iItemArray[ index ];
27 |  |  | 692 | return item->Type();
| 693 | }
|  |  | 694 | else
| 695 | {
0 |  | - | 696 | return TVIMPSTEnums::EInvalid;
| 697 | }
| 698 | }
| 699 | // -----------------------------------------------------------------------------
| 700 | // CVIMPSTProcessArray::FillItemL
| 701 | // Fill up the complete array one item at a time
| 702 | // -----------------------------------------------------------------------------
| 703 |
124 | 124 |  | 704 | void CVIMPSTProcessArray::FillItemL()
| 705 | {
| 706 | TInt count = 0;
66 | 58 |  | 707 | if(iContactListModel)
| 708 | {
| 709 | count = iContactListModel->Count();
| 710 | }
| 711 |
| 712 | // the index is starting from 1, because we already added owndata item to the list.......
66 | 124 |  | 713 | for ( TInt index = 0; index < count ; index++)
| 714 | {
| 715 | // fetch the item and process correct type
| 716 | MVIMPSTStorageItemModel::SItem item = iContactListModel->Item( index );
|  |  | 717 | switch( item.iType )
| 718 | {
0 |  | - | 719 | case MVIMPSTStorageItemModel::EContactList:
0 |  | - | 720 | break;
66 |  |  | 721 | case MVIMPSTStorageItemModel::EContactItem:
| 722 | {
| 723 | // contact item
| 724 | // add this items to contact item -- CONTACT
| 725 | // create an object of this type and append this to the rpointerarray
| 726 | MVIMPSTStorageContact* contact = item.iContact;
| 727 | TPtrC userId = contact->UserId();
| 728 | CVIMPSTProcessContactItem* contactItem =
| 729 | CVIMPSTProcessContactItem::NewL(contact->Name(),
| 730 | userId ,
| 731 | contact->ContactLink() );
| 732 | TInt otherCount = 1 + iUnKnownContactArray.Count() + iAddRequestArray.Count();
| 733 | contactItem->SetItemIndex(index + otherCount );
| 734 | //append this to the array
| 735 | iItemArray.AppendL(contactItem);
| 736 | if( TVIMPSTEnums::ESVCERegistered == iLoginState &&
66 | 0 | - | 737 | TVIMPSTEnums::EBlocked != contact->OnlineStatus() && userId.Length() )
| 738 | {
0 | 66 | - | 739 | if( IsUnreadMessageExistsL( userId ) )
| 740 | {
| 741 | contactItem->SetMsgPending(ETrue);
| 742 | }
0 | 66 | - | 743 | if( IsConversationExistL( userId ) )
| 744 | {
| 745 | contactItem->SetConversationOpen(ETrue);
| 746 | }
| 747 | }
66 |  |  | 748 | break;
| 749 | }
0 |  | - | 750 | default:
| 751 | {
| 752 | // the call shouldn't be here
0 |  | - | 753 | break;
| 754 | }
| 755 | }
| 756 | }
| 757 |
| 758 | }
| 759 |
| 760 | // -----------------------------------------------------------------------------
| 761 | // CVIMPSTProcessArray::FillOwnDataL
| 762 | // FillOwnDataL implementation
| 763 | // -----------------------------------------------------------------------------
| 764 | // fill the owndata at the begining of array.....
126 | 0 |  | 765 | TBool CVIMPSTProcessArray::FillOwnDataL()
| 766 | {
| 767 | TBool ownDataAdded = EFalse;
| 768 | TPtr dataPtr = iData->Des();
| 769 | // Check whether the user has logged in before, if has
| 770 | // then dont update anything just return
| 771 | //check if its logged in or not.
| 772 | // 1. if not logged in append
|  |  | 773 | switch(iLoginState)
| 774 | {
126 |  |  | 775 | case TVIMPSTEnums::ESVCERegistered:
| 776 | {
126 | 0 | - | 777 | if(iContactInterface)
| 778 | {
| 779 | TPtrC userId = iContactInterface->OwnContactL().UserId();
| 780 | dataPtr.Copy(userId);
| 781 | }
126 |  |  | 782 | break;
| 783 | }
0 |  | - | 784 | case TVIMPSTEnums::ESVCENetworkConnecting:
| 785 | {
| 786 | HBufC* tempStr = VIMPSTUtils::LoadResourceL( R_QTN_SERVTAB_LOGGING_LIST_ITEM );
0 | 0 | - | 787 | if(tempStr)
| 788 | {
| 789 | dataPtr.Copy(*tempStr);
| 790 | delete tempStr;
| 791 | }
| 792 |
0 |  | - | 793 | break;
| 794 | }
0 |  | - | 795 | case TVIMPSTEnums::ESVCEUpdatingContacts:
| 796 | {
| 797 | HBufC* tempStr = VIMPSTUtils::LoadResourceL( R_QTN_SERVTAB_UPDATING_LIST_ITEM );
0 | 0 | - | 798 | if(tempStr)
| 799 | {
| 800 | dataPtr.Copy(*tempStr);
| 801 | delete tempStr;
| 802 | }
| 803 |
0 |  | - | 804 | break;
| 805 | }
0 |  | - | 806 | case TVIMPSTEnums::ESVCEWaitingForNetwork:
| 807 | {
| 808 | HBufC* tempStr = KNetworkError().AllocL();
0 | 0 | - | 809 | if(tempStr)
| 810 | {
| 811 | dataPtr.Copy(*tempStr);
| 812 | delete tempStr;
| 813 | }
0 |  | - | 814 | break;
| 815 | }
0 |  | - | 816 | case TVIMPSTEnums::ESVCENetworkDisConnecting:
| 817 | {
| 818 | HBufC* tempStr = NULL;
0 | 0 | - | 819 | if ( iEngine.IsSubServiceSupportedL(TVIMPSTEnums::EPresence) )
| 820 | {
| 821 | // if presence enabled use double line listbox string
| 822 | tempStr= VIMPSTUtils::LoadResourceL( R_QTN_SERVTAB_LOGGINGOUT_LIST_ITEM );
| 823 | }
|  |  | 824 | else
| 825 | {
| 826 | // if presence is not enabled use single line listbox string
| 827 | tempStr= VIMPSTUtils::LoadResourceL( R_QTN_SERVTAB_SINGLE_LINE_LOGGINGOUT_LIST_ITEM );
| 828 | }
| 829 |
0 | 0 | - | 830 | if(tempStr)
| 831 | {
| 832 | dataPtr.Copy(*tempStr);
| 833 | delete tempStr;
| 834 | }
| 835 |
0 |  | - | 836 | break;
| 837 | }
0 |  | - | 838 | case TVIMPSTEnums::ESVCENotRegistered:
0 |  | - | 839 | default:
| 840 | {
| 841 | HBufC* str = NULL;
0 | 0 | - | 842 | if ( iEngine.SubService( TVIMPSTEnums::EPresence) )
| 843 | {
| 844 | // if presence enabled use double line listbox string
| 845 | str = VIMPSTUtils::LoadResourceL( R_QTN_SERVTAB_LOGIN_LIST_ITEM );
| 846 | }
|  |  | 847 | else
| 848 | {
| 849 | // if presence is not enabled use single line listbox string
| 850 | // get the username from settings
| 851 | TPtrC ownUserId = iContactInterface->OwnContactL().UserId();
0 | 0 | - | 852 | if ( ownUserId.Length() )
| 853 | {
| 854 | // if username is available then show with login item
| 855 | // remove domain part and give it to resource laoder
| 856 | str= VIMPSTUtils::LoadResourceL( R_QTN_SERVTAB_SINGLE_LINE_LOGIN_LIST_ITEM_WITH_USERNAME , VIMPSTUtils::DisplayId( ownUserId ) );
| 857 | }
|  |  | 858 | else
| 859 | {
| 860 | // this condition occures when there is allocated memory for username with NO data (length =0 )
| 861 | // just make sure "no memory leak" without depending on the Function LoginUserNameFromSettingsL()
| 862 | // since that would return the allocated memory without Data (length=0 )
| 863 | // just show login item since no username is available in the settings
| 864 | str= VIMPSTUtils::LoadResourceL( R_QTN_SERVTAB_SINGLE_LINE_LOGIN_LIST_ITEM );
| 865 | }
| 866 | }
0 | 0 | - | 867 | if( str )
| 868 | {
| 869 | dataPtr.Copy(*str);
| 870 | delete str;
| 871 | }
0 |  | - | 872 | break;
| 873 | }
| 874 | }
2 | 124 |  | 875 | if( iItemArray.Count() )
| 876 | {
| 877 | // own item is already exist delete it before adding a fresh one
| 878 | MVIMPSTProcessArrayItem* arrayItem = iItemArray[ 0 ]; // should be own data
2 | 0 | - | 879 | if( arrayItem->Type() == TVIMPSTEnums::EOwnStatusItem )
| 880 | {
| 881 | iItemArray.Remove(0); //iItemArray takes ownership of owndataItem, do not delete here
| 882 | delete arrayItem;
| 883 | iItemArray.Compress();
| 884 | }
| 885 | }
| 886 | //common code for all the above cases to update the owndata item to list at index 0
| 887 | CVIMPSTProcessOwnDataItem* owndataItem = CVIMPSTProcessOwnDataItem::NewL(*iData);
| 888 | owndataItem->SetItemIndex(0);
| 889 | //append this to the array
| 890 | iItemArray.InsertL( owndataItem,0 ); //iItemArray takes ownership of owndataItem, do not delete here
| 891 | iContactListIndex = 0;
| 892 | ownDataAdded = ETrue;
126 |  |  | 893 | return ownDataAdded;
| 894 | }
| 895 |
| 896 | // -----------------------------------------------------------------------------
| 897 | // CVIMPSTProcessArray::FillArrayL
| 898 | // -----------------------------------------------------------------------------
| 899 |
124 | 124 |  | 900 | void CVIMPSTProcessArray::FillArrayL()
| 901 | {
124 | 0 | - | 902 | if(FillOwnDataL() )
| 903 | {
| 904 | // then fill the conversations..or open chats....
| 905 | }
|  |  | 906 | else
| 907 | {
| 908 | iContactListIndex = 0; // we have not added any thing to main array..so index is zero...
| 909 | }
| 910 | FillUnknownContactsL(); //will fill all unknown contact from iUnknownContactArray to iItemArray.
| 911 | FillAddRequestDataL();//will fill all requests from iAddRequestArray to iItemArray.
| 912 | FillItemL();
| 913 | }
| 914 |
| 915 |
| 916 | // -----------------------------------------------------------------------------
| 917 | // CVIMPSTProcessArray::ResetArray
| 918 | // -----------------------------------------------------------------------------
| 919 |
124 | 124 |  | 920 | void CVIMPSTProcessArray::ResetArray()
| 921 | {
| 922 | RemoveUnKnownContacts(); //will remove all the unknown contacts from iItemArray.
| 923 | RemoveAddRequestData();//will remove all the requests from iItemArray.
| 924 | iItemArray.ResetAndDestroy();
124 | 124 |  | 925 | TRAPD( err, FillArrayL());
0 |  | - | 925 | catch (XLeaveException & l)
0 |  | - | 925 | catch (...)
0 | 124 | - | 926 | if ( err != KErrNone )
| 927 | {
| 928 | CActiveScheduler::Current()->Error( err );
| 929 | }
| 930 | }
| 931 |
| 932 | // -----------------------------------------------------------------------------
| 933 | // CVIMPSTProcessArray::SetLoginState
| 934 | // -----------------------------------------------------------------------------
| 935 |
2 | 2 |  | 936 | void CVIMPSTProcessArray::SetLoginStateL(TVIMPSTEnums::TVIMPSTRegistrationState aLoginState)
| 937 | {
| 938 | iLoginState = aLoginState;
0 | 2 | - | 939 | if(aLoginState != TVIMPSTEnums::ESVCERegistered )
| 940 | {
| 941 | iFetchCompleted = EFalse;
| 942 | RemoveUnKnownContacts();
| 943 | RemoveAddRequestData();
| 944 | iUnKnownContactArray.ResetAndDestroy();// delete all items
| 945 | iUnKnownContactArray.Reset();
| 946 | iAddRequestArray.ResetAndDestroy();// delete all items
| 947 | iAddRequestArray.Reset();
| 948 | }
| 949 | FillOwnDataL(); // this will change the own item based on connection status
| 950 | }
| 951 | // -----------------------------------------------------------------------------
| 952 | // CVIMPSTProcessArray::GetLoginState
| 953 | // -----------------------------------------------------------------------------
| 954 |
2 | 0 |  | 955 | TVIMPSTEnums::TVIMPSTRegistrationState CVIMPSTProcessArray::GetLoginState()
| 956 | {
2 |  |  | 957 | return iLoginState;
| 958 | }
| 959 |
| 960 | // -----------------------------------------------------------------------------
| 961 | // CVIMPSTProcessArray::GetOnlineStatus
| 962 | // -----------------------------------------------------------------------------
| 963 |
2 | 0 |  | 964 | TVIMPSTEnums::TOnlineStatus CVIMPSTProcessArray::GetOnlineStatusL(TInt aIndex)
| 965 | {
| 966 | TVIMPSTEnums::TItem itemtype = GetType( aIndex );
| 967 | TVIMPSTEnums::TOnlineStatus status = TVIMPSTEnums::EUnknown;
|  |  | 968 | switch(itemtype)
| 969 | {
2 |  |  | 970 | case TVIMPSTEnums::EOwnStatusItem:
| 971 | {
2 | 0 | - | 972 | if( iContactInterface )
| 973 | {
| 974 | status = iContactInterface->OwnContactL().OnlineStatus();
| 975 | }
2 |  |  | 976 | break;
| 977 | }
0 |  | - | 978 | case TVIMPSTEnums::EContactItem:
| 979 | {
| 980 | MVIMPSTStorageContact* contact = iContactInterface->FindContactByUserId( GetItemUserId(aIndex) );
0 | 0 | - | 981 | if(contact)
| 982 | {
| 983 | status = contact->OnlineStatus();
| 984 | }
0 |  | - | 985 | break;
| 986 | }
0 |  | - | 987 | case TVIMPSTEnums::EInvalid:
0 |  | - | 988 | default:
| 989 | {
0 |  | - | 990 | break;
| 991 | }
| 992 | }
2 |  |  | 993 | return status;
| 994 | }
| 995 | //-----------------------------------------------------------
| 996 | //CVIMPSTProcessArray::StatusText
| 997 | //-----------------------------------------------------------
| 998 | //
2 | 0 |  | 999 | const TDesC& CVIMPSTProcessArray::StatusTextL(TInt aIndex )
| 1000 | {
| 1001 | TVIMPSTEnums::TItem itemtype = GetType( aIndex );
|  |  | 1002 | switch(itemtype)
| 1003 | {
2 |  |  | 1004 | case TVIMPSTEnums::EOwnStatusItem:
| 1005 | {
2 | 0 | - | 1006 | if( iContactInterface )
| 1007 | {
2 |  |  | 1008 | return iContactInterface->OwnContactL().StatusText();
| 1009 | }
0 |  | - | 1010 | break;
| 1011 | }
0 |  | - | 1012 | case TVIMPSTEnums::EContactItem:
| 1013 | {
| 1014 | MVIMPSTStorageContact* contact = iContactInterface->FindContactByUserId(GetItemUserId(aIndex));
0 | 0 | - | 1015 | if(contact && contact->StatusText().Length() )
| 1016 | {
| 1017 | // KStatusMsgMaxLenght is the max length of the status message shown
| 1018 | // make sure that it copies only that much
0 |  | - | 1019 | return contact->StatusText();
| 1020 | }
0 |  | - | 1021 | break;
| 1022 | }
0 |  | - | 1023 | case TVIMPSTEnums::EInvalid:
0 |  | - | 1024 | default:
| 1025 | {
0 |  | - | 1026 | break;
| 1027 | }
| 1028 | }
0 |  | - | 1029 | return KNullDesC;
| 1030 | }
| 1031 | //-----------------------------------------------------------
| 1032 | //CVIMPSTProcessArray::RemoveFromUnknonOrInvitationListL
| 1033 | //-----------------------------------------------------------
| 1034 | //
2 | 0 |  | 1035 | TBool CVIMPSTProcessArray::RemoveFromUnknonOrInvitationListL( const TDesC& aAddedUserId ,TBool aBlocked )
| 1036 | {
| 1037 | TBool found = RemoveFromUnknonListL( aAddedUserId );
2 | 0 | - | 1038 | if( !found )
| 1039 | {
| 1040 | found = RemoveFromInvitationListL( aAddedUserId );
| 1041 | }
| 1042 | //Get IM SubService
0 | 2 | - | 1043 | if( aBlocked && found && aAddedUserId.Length() )
| 1044 | {
| 1045 | MVIMPSTEngineSubService* subService =
| 1046 | (iEngine.SubService(TVIMPSTEnums::EIM));
| 1047 |
0 | 0 | - | 1048 | if(subService )
| 1049 | {
| 1050 | MVIMPSTEngineIMSubService& imSubService =
| 1051 | MVIMPSTEngineIMSubService::Cast (*subService);
| 1052 | imSubService.CloseConversationL( aAddedUserId );
| 1053 | }
| 1054 | }
2 |  |  | 1055 | return found;
| 1056 | }
| 1057 | //-----------------------------------------------------------
| 1058 | //CVIMPSTProcessArray::RemoveFromUnknonListL
| 1059 | //-----------------------------------------------------------
| 1060 | //
4 | 0 |  | 1061 | TBool CVIMPSTProcessArray::RemoveFromUnknonListL( const TDesC& aAddedUserId )
| 1062 | {
| 1063 | TRACE( T_LIT("CVIMPSTProcessArray::RemoveFromUnknonListL start ") );
| 1064 | TPtrC addedUserId = VIMPSTUtils::DisplayId( aAddedUserId );
| 1065 | TBool found = EFalse;
| 1066 | TInt count = iUnKnownContactArray.Count();
| 1067 | CVIMPSTProcessUnknownContactItem* unknownItem = NULL;
| 1068 | TInt index = KErrNotFound;
| 1069 | TInt itemIndex = KErrNotFound;
| 1070 | // check in unknon array
2 | 2 |  | 1071 | for(index = 0 ; index < count ; index++)
| 1072 | {
| 1073 | unknownItem = iUnKnownContactArray[index];
| 1074 | TPtrC contactId = VIMPSTUtils::DisplayId( unknownItem->GetItemUserId() );
2 | 0 | - | 1075 | if( addedUserId.Compare( contactId ) == 0 )
| 1076 | {
| 1077 | itemIndex = iItemArray.Find(unknownItem);
2 | 0 | - | 1078 | if( itemIndex > -1 )
| 1079 | {
| 1080 | found = ETrue;
| 1081 | }
2 |  |  | 1082 | break;
| 1083 | }
| 1084 | TRACE( T_LIT("CVIMPSTProcessArray::RemoveFromUnknonListL for ends") );
| 1085 | }
2 | 2 |  | 1086 | if( found )
| 1087 | {
| 1088 | iItemArray.Remove(itemIndex);
| 1089 | iUnKnownContactArray.Remove( index );
| 1090 | delete unknownItem;
| 1091 | unknownItem = NULL;
| 1092 | iItemArray.Compress();
| 1093 | iUnKnownContactArray.Compress();
2 | 0 | - | 1094 | if( iProcessObservers )
| 1095 | {
| 1096 | // this is to refresh the list box
| 1097 | // KErrNotFound , focus remain at same position
| 1098 | iProcessObservers->HandleDeletionL(TVIMPSTEnums::EUnknonContactItem, KErrNotFound );
| 1099 | }
| 1100 | }
| 1101 | TRACE( T_LIT("CVIMPSTProcessArray::RemoveFromUnknonListL end ") );
4 |  |  | 1102 | return found;
| 1103 | }
| 1104 | //-----------------------------------------------------------
| 1105 | //CVIMPSTProcessArray::RemoveFromInvitationListL
| 1106 | //-----------------------------------------------------------
| 1107 | //
2 | 0 |  | 1108 | TBool CVIMPSTProcessArray::RemoveFromInvitationListL( const TDesC& aAddedUserId )
| 1109 | {
| 1110 | TPtrC addedUserId = VIMPSTUtils::DisplayId( aAddedUserId );
| 1111 | TBool found = EFalse;
| 1112 | TInt index = KErrNotFound;
| 1113 | TInt itemIndex = KErrNotFound;
| 1114 | // item not foun in unknown list
| 1115 | // check in invitation item array
| 1116 | TInt count = iAddRequestArray.Count();
| 1117 | CVIMPSTProcessFriendRequestItem* requestItem = NULL;
0 | 2 | - | 1118 | for(index = 0 ; index < count ; index++)
| 1119 | {
| 1120 | requestItem = iAddRequestArray[index];
| 1121 | TPtrC contactId = VIMPSTUtils::DisplayId( requestItem->GetItemUserId() );
0 | 0 | - | 1122 | if( addedUserId.Compare( contactId ) == 0 )
| 1123 | {
| 1124 | itemIndex = iItemArray.Find(requestItem);
0 | 0 | - | 1125 | if( itemIndex > -1 )
| 1126 | {
| 1127 | found = ETrue;
| 1128 | }
0 |  | - | 1129 | break;
| 1130 | }
| 1131 | }
0 | 2 | - | 1132 | if( found )
| 1133 | {
| 1134 | iItemArray.Remove(itemIndex);
| 1135 | iAddRequestArray.Remove( index );
| 1136 | delete requestItem;
| 1137 | requestItem = NULL;
| 1138 | iItemArray.Compress();
| 1139 | iAddRequestArray.Compress();
0 | 0 | - | 1140 | if( iProcessObservers )
| 1141 | {
| 1142 | // this is to refresh the list box
| 1143 | // KErrNotFound , focus remain at same position
| 1144 | iProcessObservers->HandleDeletionL(TVIMPSTEnums::EFriendRequestItem, KErrNotFound );
| 1145 | }
| 1146 | }
2 |  |  | 1147 | return found;
| 1148 | }
| 1149 | //-----------------------------------------------------------
| 1150 | //CVIMPSTProcessArray::MapContactListPositions
| 1151 | //-----------------------------------------------------------
| 1152 | //
0 | 0 | - | 1153 | void CVIMPSTProcessArray::MapContactListPositions(RArray<TInt>& aPos )
| 1154 | {
| 1155 | // add conversation also this list ..and return..
| 1156 | RArray<TInt> listPos;
| 1157 |
| 1158 | // iContactListModel->MapContactListPositions(listPos);
| 1159 | TInt positionIndex = 0;
| 1160 | // if count is more than 0..fill the maparray...
0 | 0 | - | 1161 | if(iItemArray.Count() + iContactListIndex > 0)
| 1162 | {
| 1163 |
| 1164 | TInt count = listPos.Count();
| 1165 |
0 | 0 | - | 1166 | for(TInt posIndex = 0; posIndex < count; posIndex++, positionIndex++)
| 1167 | {
| 1168 | aPos.Append( listPos[posIndex] + iContactListIndex );
| 1169 | }
| 1170 | }
| 1171 | listPos.Close();
| 1172 | }
| 1173 | // -----------------------------------------------------------------------------
| 1174 | // CVIMPSTProcessArray::GetAndCreateOpenChatListL
| 1175 | // return contact index including friend request.
| 1176 | // -----------------------------------------------------------------------------
2 | 2 |  | 1177 | void CVIMPSTProcessArray::GetAndCreateOpenChatListL()
| 1178 | {
| 1179 | //Get IM SubService
| 1180 | MVIMPSTEngineSubService* subService =
| 1181 | (iEngine.SubService(TVIMPSTEnums::EIM));
| 1182 | RArray<SIMCacheChatItem> openChats;
| 1183 | openChats.Reset();
0 | 2 | - | 1184 | if(subService)
| 1185 | {
| 1186 | MVIMPSTEngineIMSubService& imSubService =
| 1187 | MVIMPSTEngineIMSubService::Cast (*subService);
| 1188 | openChats = imSubService.GetOpenChatListL();
| 1189 | }
0 | 2 | - | 1190 | while( openChats.Count() )
| 1191 | {
| 1192 | SIMCacheChatItem chat = openChats[ 0 ]; // first item
| 1193 | TPtrC contactId = *chat.iBuddyId;
| 1194 | MVIMPSTProcessArrayItem* arrayItem = FindArrayItem( contactId );
| 1195 | TBool msgPending = EFalse;
0 | 0 | - | 1196 | if( contactId.Length() )
| 1197 | {
0 | 0 | - | 1198 | if( IsUnreadMessageExistsL( contactId ) )
| 1199 | {
| 1200 | msgPending = ETrue;
| 1201 | }
| 1202 | }
0 | 0 | - | 1203 | if( arrayItem )
| 1204 | {
| 1205 | arrayItem->SetConversationOpen( ETrue );
| 1206 | arrayItem->SetMsgPending( msgPending );
| 1207 | }
|  |  | 1208 | else
| 1209 | {
| 1210 | // not in buddy List
| 1211 | DoHandleUnKnownContactMessageL( contactId ,msgPending );
| 1212 | }
| 1213 | openChats.Remove( 0 );
| 1214 | delete chat.iBuddyId;
| 1215 | chat.iBuddyId = NULL;
| 1216 | openChats.Compress();
| 1217 | }
| 1218 | }
| 1219 | //-----------------------------------------------------------
| 1220 | //CVIMPSTProcessArray::FindArrayItem
| 1221 | //-----------------------------------------------------------
| 1222 | //
2 | 0 |  | 1223 | MVIMPSTProcessArrayItem* CVIMPSTProcessArray::FindArrayItem( const TDesC& aSenderId )
| 1224 | {
| 1225 | TPtrC senderId = VIMPSTUtils::DisplayId( aSenderId );
| 1226 | MVIMPSTProcessArrayItem* arrayItem = NULL;
| 1227 | TInt count = iItemArray.Count();
3 | 0 | - | 1228 | for( TInt i = 1; i < count; i++ )
| 1229 | {
| 1230 | MVIMPSTProcessArrayItem* contactItem = (MVIMPSTProcessArrayItem *)iItemArray[i];
| 1231 | TPtrC contactId = VIMPSTUtils::DisplayId( contactItem->GetItemUserId() );
2 | 1 |  | 1232 | if( senderId.Compare( contactId ) == 0 )
| 1233 | {
| 1234 | arrayItem = contactItem;
2 |  |  | 1235 | break;
| 1236 | }
| 1237 | }
2 |  |  | 1238 | return arrayItem;
| 1239 | }
| 1240 | //-----------------------------------------------------------
| 1241 | //CVIMPSTProcessArray::HandleChatMessageEventL
| 1242 | //-----------------------------------------------------------
| 1243 | //
12 | 12 |  | 1244 | void CVIMPSTProcessArray::HandleChatMessageEventL( TVIMPSTEnums::TIMEventType aEventType ,
| 1245 | const TDesC& aSender )
| 1246 | {
0 | 12 | - | 1247 | if( !iFetchCompleted )
| 1248 | {
| 1249 | // contact matching will not be correct until fetching completed
| 1250 | // hence return
0 |  | - | 1251 | return;
| 1252 | }
|  |  | 1253 | switch( aEventType )
| 1254 | {
2 |  |  | 1255 | case TVIMPSTEnums::EIMUnreadMessage:
| 1256 | {
0 | 2 | - | 1257 | if( FindAndMarkContactAsOpenChat( aSender , ETrue ) )
| 1258 | {
0 | 0 | - | 1259 | if(iProcessObservers)
| 1260 | {
| 1261 | iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, KErrNotFound );
| 1262 | }
| 1263 | }
|  |  | 1264 | else
| 1265 | {
| 1266 | DoHandleUnKnownContactMessageL( aSender , ETrue );
| 1267 | }
2 |  |  | 1268 | break;
| 1269 | }
2 |  |  | 1270 | case TVIMPSTEnums::EIMUnreadChange:
| 1271 | {
| 1272 | FindAndMarkContactAsOpenChat( aSender , EFalse ) ;
2 | 0 | - | 1273 | if(iProcessObservers)
| 1274 | {
| 1275 | iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem,KErrNotFound );
| 1276 | }
2 |  |  | 1277 | break;
| 1278 | }
2 |  |  | 1279 | case TVIMPSTEnums::EIMChatStarted:
| 1280 | {
2 | 0 | - | 1281 | if( FindAndMarkContactAsOpenChat( aSender , EFalse ) )
| 1282 | {
2 | 0 | - | 1283 | if(iProcessObservers)
| 1284 | {
| 1285 | iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, KErrNotFound );
| 1286 | }
| 1287 | }
|  |  | 1288 | else
| 1289 | {
| 1290 | DoHandleUnKnownContactMessageL( aSender, EFalse );
| 1291 | }
2 |  |  | 1292 | break;
| 1293 | }
2 |  |  | 1294 | case TVIMPSTEnums::EIMChatClosed:
| 1295 | {
0 | 2 | - | 1296 | if( !RemoveFromUnknonListL( aSender ) )
| 1297 | {
| 1298 | MVIMPSTProcessArrayItem* arrayItem = FindArrayItem( aSender );
0 | 0 | - | 1299 | if( arrayItem )
| 1300 | {
| 1301 | arrayItem->SetConversationOpen( EFalse );
| 1302 | arrayItem->SetMsgPending( EFalse );
| 1303 | }
| 1304 | }
2 | 0 | - | 1305 | if(iProcessObservers)
| 1306 | {
| 1307 | iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, KErrNotFound );
| 1308 | }
2 |  |  | 1309 | break;
| 1310 | }
2 |  |  | 1311 | case TVIMPSTEnums::EIMAllChatClosed:
| 1312 | {
| 1313 | RemoveUnKnownContacts();
| 1314 | iUnKnownContactArray.ResetAndDestroy();// delete all items
| 1315 | ResetOpenConversationPendingMsg();
2 | 0 | - | 1316 | if(iProcessObservers)
| 1317 | {
| 1318 | iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, KErrNotFound );
| 1319 | }
2 |  |  | 1320 | break;
| 1321 | }
2 |  |  | 1322 | case TVIMPSTEnums::EIMRequestCompleted:
| 1323 | {
2 | 0 | - | 1324 | if(iProcessObservers)
| 1325 | {
| 1326 | iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, KErrNotFound );
| 1327 | }
2 |  |  | 1328 | break;
| 1329 | }
0 |  | - | 1330 | default:
| 1331 | {
| 1332 | // do nothing
| 1333 | }
| 1334 | }
| 1335 | }
| 1336 | //-----------------------------------------------------------
| 1337 | //CVIMPSTProcessArray::HandleAddRequestEventL
| 1338 | //-----------------------------------------------------------
| 1339 | //
18 | 18 |  | 1340 | void CVIMPSTProcessArray::HandleAddRequestEventL(TVIMPSTEnums::TOperationType aType, const TDesC& aRequesterId )
| 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 | {
16 |  |  | 1346 | case TVIMPSTEnums::EAddItem :
| 1347 | {
4 | 12 |  | 1348 | if( (!FindAnyAddRequest(aRequesterId ) )&& ( !FindAnyContactServiceField( aRequesterId ) ) && !(IsContactBlocked( aRequesterId )) )
| 1349 | {
| 1350 | CVIMPSTProcessFriendRequestItem* addRequestItem = CVIMPSTProcessFriendRequestItem::NewL(aRequesterId);
| 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);
0 | 4 | - | 1360 | if(iProcessObservers)
| 1361 | {
| 1362 | iProcessObservers->HandleAdditionL( TVIMPSTEnums::EFriendRequestItem ,KErrNotFound );
| 1363 | }
| 1364 | }
16 |  |  | 1365 | break;
| 1366 | }
2 |  |  | 1367 | case TVIMPSTEnums::ERemoveItem :
| 1368 | {
| 1369 | TInt count = iAddRequestArray.Count();
| 1370 | CVIMPSTProcessFriendRequestItem* requestItem = NULL;
2 | 0 | - | 1371 | for(TInt i = 0 ; i < count ; i++)
| 1372 | {
| 1373 | requestItem = iAddRequestArray[i];
2 | 0 | - | 1374 | if( aRequesterId.Compare(requestItem->GetItemUserId()) == 0 )
| 1375 | {
| 1376 | TInt index = iItemArray.Find(requestItem);
2 | 0 | - | 1377 | if(index != KErrNotFound)
| 1378 | {
| 1379 | iItemArray.Remove(index);
| 1380 | iItemArray.Compress();
| 1381 | }
| 1382 | iAddRequestArray.Remove(i);
| 1383 | delete requestItem;
| 1384 | iAddRequestArray.Compress();
2 |  |  | 1385 | break;
| 1386 | }
| 1387 | }
2 | 0 | - | 1388 | if(iProcessObservers)
| 1389 | {
| 1390 | iProcessObservers->HandleDeletionL(TVIMPSTEnums::EFriendRequestItem, KErrNotFound );
| 1391 | }
2 |  |  | 1392 | break;
| 1393 | }
0 |  | - | 1394 | default :
0 |  | - | 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;
0 | 2 | - | 1407 | for( TInt i=0; i<count; i++ )
| 1408 | {
| 1409 | unknownItem = iUnKnownContactArray[i];
0 | 0 | - | 1410 | if( aSenderId.Compare( unknownItem->GetItemUserId() ) == 0 )
| 1411 | {
| 1412 | contactExist = ETrue;
| 1413 | unknownItem->SetConversationOpen(ETrue);
| 1414 | unknownItem->SetMsgPending( aIsMsgPending );
0 |  | - | 1415 | break;
| 1416 | }
| 1417 | }
2 | 0 | - | 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 | }
2 | 0 | - | 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 | {
0 | 0 | - | 1439 | if( aIndex < iItemArray.Count() && aIndex >= 0 )
| 1440 | {
| 1441 | MVIMPSTProcessArrayItem* item = (MVIMPSTProcessArrayItem *)iItemArray[aIndex];
0 | 0 | - | 1442 | if(item)
| 1443 | {
0 |  | - | 1444 | return item->IsMsgPending();
| 1445 | }
| 1446 | }
0 |  | - | 1447 | return EFalse;
| 1448 | }
| 1449 |
| 1450 | //-----------------------------------------------------------
| 1451 | //CVIMPSTProcessArray::IsConversationExist
| 1452 | //-----------------------------------------------------------
| 1453 | //
0 | 0 | - | 1454 | TBool CVIMPSTProcessArray::IsConversationExist(TInt aIndex)
| 1455 | {
0 | 0 | - | 1456 | if( aIndex < iItemArray.Count() && aIndex >= 0 )
| 1457 | {
| 1458 | MVIMPSTProcessArrayItem* item = (MVIMPSTProcessArrayItem *)iItemArray[aIndex];
0 | 0 | - | 1459 | if(item)
| 1460 | {
0 |  | - | 1461 | return item->IsConversationOpen();
| 1462 | }
| 1463 | }
0 |  | - | 1464 | return EFalse;
| 1465 | }
| 1466 |
| 1467 | //-----------------------------------------------------------
| 1468 | //CVIMPSTProcessArray::ResetPendingMsg
| 1469 | //-----------------------------------------------------------
| 1470 | //
0 | 0 | - | 1471 | void CVIMPSTProcessArray::ResetPendingMsg(TInt aIndex)
| 1472 | {
0 | 0 | - | 1473 | if( aIndex < iItemArray.Count() && aIndex >= 0 )
| 1474 | {
| 1475 | MVIMPSTProcessArrayItem* item = (MVIMPSTProcessArrayItem *)iItemArray[aIndex];
0 | 0 | - | 1476 | if(item)
| 1477 | {
| 1478 | item->SetMsgPending( EFalse );
| 1479 | }
| 1480 | }
| 1481 | }
| 1482 | //-----------------------------------------------------------
| 1483 | //CVIMPSTProcessArray::ResetOpenConversationPendingMsg
| 1484 | //-----------------------------------------------------------
| 1485 | //
2 | 2 |  | 1486 | void CVIMPSTProcessArray::ResetOpenConversationPendingMsg()
| 1487 | {
5 | 2 |  | 1488 | for( TInt index = 0; index < iItemArray.Count() ;index++ )
| 1489 | {
| 1490 | MVIMPSTProcessArrayItem* item = (MVIMPSTProcessArrayItem *)iItemArray[index];
5 | 0 | - | 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 | // -----------------------------------------------------------------------------
3 | 0 |  | 1502 | TBool CVIMPSTProcessArray::FindAnyContact( const TDesC& aContactId )
| 1503 | {
2 | 1 |  | 1504 | if(aContactId.Length() != 0)
| 1505 | {
| 1506 | MVIMPSTStorageContact* contact = iContactInterface->FindContactByUserId(aContactId);
1 | 1 |  | 1507 | if( contact )
| 1508 | {
1 |  |  | 1509 | return ETrue;
| 1510 | }
| 1511 | }
2 |  |  | 1512 | return EFalse;
| 1513 | }
| 1514 |
| 1515 | // -----------------------------------------------------------------------------
| 1516 | // CVIMPSTProcessArray::FindAnyContactServiceField
| 1517 | // Try to load with given ID, return NULL if not found.
| 1518 | // -----------------------------------------------------------------------------
7 | 0 |  | 1519 | TBool CVIMPSTProcessArray::FindAnyContactServiceField( const TDesC& aContactId )
| 1520 | {
6 | 1 |  | 1521 | if(aContactId.Length() != 0)
| 1522 | {
| 1523 | MVIMPSTStorageContact* contact = iContactInterface->FindContactByUserId(aContactId);
1 | 5 |  | 1524 | if( contact )
| 1525 | {
1 |  |  | 1526 | return ETrue;
| 1527 | }
| 1528 | }
6 |  |  | 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();
7 | 2 |  | 1540 | for( TInt i = 1; i < count; i++ )
| 1541 | {
| 1542 | MVIMPSTProcessArrayItem* contactItem = (MVIMPSTProcessArrayItem *)iItemArray[i];
| 1543 | TPtrC contactId = VIMPSTUtils::DisplayId( contactItem->GetItemUserId() );
4 | 3 |  | 1544 | if( senderId.Compare( contactId ) == 0 )
| 1545 | {
| 1546 | contactItem->SetConversationOpen( ETrue );
| 1547 | contactItem->SetMsgPending( aMesssagePending );
| 1548 | ret = ETrue;
4 |  |  | 1549 | break;
| 1550 | }
| 1551 | }
6 |  |  | 1552 | return ret;
| 1553 | }
| 1554 | //-----------------------------------------------------------------------------
| 1555 | // CVIMPSTProcessArray::IsUnreadMessageExists
| 1556 | // ( Other items commented in header )
| 1557 | //-----------------------------------------------------------------------------
68 | 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));
0 | 68 | - | 1565 | if(subService)
| 1566 | {
| 1567 | MVIMPSTEngineIMSubService& imSubService =
| 1568 | MVIMPSTEngineIMSubService::Cast (*subService);
| 1569 | unreaMsgCount = imSubService.GetUnreadCountL( aRecipientId );
| 1570 | }
0 | 68 | - | 1571 | if( unreaMsgCount )
| 1572 | {
| 1573 | ret = ETrue;
| 1574 | }
68 |  |  | 1575 | return ret;
| 1576 | }
| 1577 | //-----------------------------------------------------------------------------
| 1578 | // CVIMPSTProcessArray::IsConversationExistL
| 1579 | // ( Other items commented in header )
| 1580 | //-----------------------------------------------------------------------------
71 | 0 |  | 1581 | TBool CVIMPSTProcessArray::IsConversationExistL(const TDesC& aRecipientId)
| 1582 | {
| 1583 | //Get IM SubService
| 1584 | MVIMPSTEngineSubService* subService1 =
| 1585 | (iEngine.SubService(TVIMPSTEnums::EIM));
0 | 71 | - | 1586 | if(subService1)
| 1587 | {
| 1588 | MVIMPSTEngineIMSubService& imSubService =
| 1589 | MVIMPSTEngineIMSubService::Cast (*subService1);
0 |  | - | 1590 | return imSubService.IsConversationExistL( aRecipientId );
| 1591 | }
71 |  |  | 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 );
2 | 2 |  | 1601 | if(newContact)
| 1602 | {
| 1603 | // return the index of contact rather bool value..
| 1604 | // 1 is for own data item.
2 |  |  | 1605 | return (iContactListIndex + 1 + iContactListModel->IndexOfContact( newContact ));
| 1606 | }
2 |  |  | 1607 | return KErrNotFound;
| 1608 | }
| 1609 |
| 1610 |
| 1611 | //-----------------------------------------------------------------------------
| 1612 | // CVIMPSTProcessArray::FillUnknownContactsL
| 1613 | // ( Other items commented in header )
| 1614 | //------------------------------------------------------------------------------
124 | 124 |  | 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;
0 | 124 | - | 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 | //------------------------------------------------------------------------------
124 | 124 |  | 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 ;
0 | 124 | - | 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 | //------------------------------------------------------------------------------
126 | 126 |  | 1657 | void CVIMPSTProcessArray::RemoveUnKnownContacts()
| 1658 | {
| 1659 | TInt count = iUnKnownContactArray.Count();
0 | 126 | - | 1660 | for(TInt i = 0 ; i < count ; i++)
| 1661 | {
| 1662 | CVIMPSTProcessUnknownContactItem* unknownItem = iUnKnownContactArray[i];
| 1663 | TInt index = iItemArray.Find(unknownItem);
0 | 0 | - | 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 | //------------------------------------------------------------------------------
124 | 124 |  | 1675 | void CVIMPSTProcessArray::RemoveAddRequestData()
| 1676 | {
| 1677 | TInt count = iAddRequestArray.Count();
0 | 124 | - | 1678 | for(TInt i = 0 ; i < count ; i++)
| 1679 | {
| 1680 | CVIMPSTProcessFriendRequestItem* requestItem = iAddRequestArray[i];
| 1681 | TInt index = iItemArray.Find(requestItem);
0 | 0 | - | 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 | {
2 | 0 | - | 1697 | if( iContactInterface )
| 1698 | {
| 1699 | // most of the time this get called
2 |  |  | 1700 | return iContactInterface->OwnContactL().UserId();
| 1701 | }
0 |  | - | 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 |
2 | 0 | - | 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) );
2 | 0 | - | 1720 | if(contact)
| 1721 | {
| 1722 | // if any contact is found then return the index
2 |  |  | 1723 | return contact->AvatarIndex();
| 1724 | }
| 1725 | }
0 |  | - | 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 );
2 | 0 | - | 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));
2 | 0 | - | 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 |
2 | 0 | - | 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));
2 | 0 | - | 1762 | if(contact)
| 1763 | {
| 1764 | // if any contact is found then get the content
2 |  |  | 1765 | return contact->AvatarContent();
| 1766 | }
| 1767 | }
0 |  | - | 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
2 |  |  | 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();
2 |  |  | 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();
16 | 6 |  | 1810 | for(TInt i=0; i<count; i++)
| 1811 | {
14 | 2 |  | 1812 | if((aRequesterId.Compare(iAddRequestArray[i]->GetItemUserId()))==0 )
| 1813 | {
14 |  |  | 1814 | return ETrue;
| 1815 | }
| 1816 | }
6 |  |  | 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();
9 | 2 |  | 1827 | for(TInt index=0; index<itemArrayCount; index++)
| 1828 | {
| 1829 | MVIMPSTProcessArrayItem* item = iItemArray[ index ];
4 | 5 |  | 1830 | if(0 == aContactId.Compare(item->GetItemUserId()))
| 1831 | {
4 |  |  | 1832 | return index;
| 1833 | }
| 1834 | }
2 |  |  | 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));
8 | 0 | - | 1845 | if(subService)
| 1846 | {
| 1847 | MVIMPSTEnginePresenceSubService& presence =
| 1848 | MVIMPSTEnginePresenceSubService::Cast (*subService);
| 1849 |
| 1850 | RPointerArray<HBufC> *blockedlist = presence .GetBlockedList();
| 1851 |
8 | 0 | - | 1852 | if(blockedlist)
| 1853 | {
8 | 6 |  | 1854 | for(TInt i=0; i<blockedlist->Count(); ++i)
| 1855 | {
2 | 6 |  | 1856 | if(0 == aUserId.CompareC((*blockedlist)[i]->Des()))
| 1857 | {
2 |  |  | 1858 | return ETrue;
| 1859 | }
| 1860 | }
| 1861 | }
| 1862 | }
6 |  |  | 1863 | return EFalse;
| 1864 | }
| 1865 |
| 1866 |
| 1867 | //END OF FILE
***TER 56% (285/511) of SOURCE FILE cvimpstprocessarray.cpp

Directory Summary | Files Summary | Functions Summary | Execution Profile
To files: First | Previous | Next | Last | Top | Index | No Index