uiservicetab/vimpstcmdprocess/src/cvimpstprocessArray.cpp
branchRCL_3
changeset 14 9fdee5e1da30
parent 11 bef90b82da71
child 19 76f25fb7a6a1
equal deleted inserted replaced
13:796276a1bdcc 14:9fdee5e1da30
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    20 #include <coemain.h>
    20 #include <coemain.h>
    21 #include    "vimpstdebugprint.h" 
    21 
       
    22 #include "uiservicetabtracer.h"
    22 
    23 
    23 #include "cvimpstprocessarray.h"
    24 #include "cvimpstprocessarray.h"
    24 
    25 
    25 #include "mvimpstprocessArrayobserver.h"
    26 #include "mvimpstprocessArrayobserver.h"
    26 #include "cvimpststoragemanagerfactory.h"
    27 #include "cvimpststoragemanagerfactory.h"
    42 #include "vimpstutils.h"
    43 #include "vimpstutils.h"
    43 #include <MVPbkContactLink.h>
    44 #include <MVPbkContactLink.h>
    44 #include <VPbkEng.rsg>
    45 #include <VPbkEng.rsg>
    45 #include "mvimpstengineimsubservice.h"
    46 #include "mvimpstengineimsubservice.h"
    46 #include "mvimpstenginepresencesubservice.h"
    47 #include "mvimpstenginepresencesubservice.h"
    47 #include "vimpstdebugtrace.h"
    48 
    48 #include <apgtask.h> 
    49 #include <apgtask.h> 
    49 #include "imcvuiparams.h"
    50 #include "imcvuiparams.h"
    50 
    51 
    51 // --------------------------------------------------------------------------
    52 // --------------------------------------------------------------------------
    52 // CVIMPSTProcessArray::CIMArrayProcess
    53 // CVIMPSTProcessArray::CIMArrayProcess
    64 // CVIMPSTProcessArray::~CVIMPSTProcessArray
    65 // CVIMPSTProcessArray::~CVIMPSTProcessArray
    65 // --------------------------------------------------------------------------
    66 // --------------------------------------------------------------------------
    66 //
    67 //
    67 CVIMPSTProcessArray::~CVIMPSTProcessArray()
    68 CVIMPSTProcessArray::~CVIMPSTProcessArray()
    68     {
    69     {
    69     TRACE( T_LIT("CVIMPSTProcessArray::~CVIMPSTProcessArray Start") );
    70    
       
    71     TRACER_AUTO;
    70     if(iContactInterface)
    72     if(iContactInterface)
    71         {
    73         {
    72         iContactInterface->RemoveObserver( this );	
    74         iContactInterface->RemoveObserver( this );	
    73         }
    75         }
    74     iItemArray.ResetAndDestroy();
    76     iItemArray.ResetAndDestroy();
   103         MVIMPSTEnginePresenceSubService& presence = 
   105         MVIMPSTEnginePresenceSubService& presence = 
   104         MVIMPSTEnginePresenceSubService::Cast (*subService);
   106         MVIMPSTEnginePresenceSubService::Cast (*subService);
   105         presence.UnRegisterPresenceEventObserver(this);
   107         presence.UnRegisterPresenceEventObserver(this);
   106         } 
   108         } 
   107 
   109 
   108     TRACE( T_LIT("CVIMPSTProcessArray::~CVIMPSTProcessArray End") );
   110     
   109     }
   111     }
   110 
   112 
   111 // --------------------------------------------------------------------------
   113 // --------------------------------------------------------------------------
   112 // CVIMPSTProcessArray::NewL
   114 // CVIMPSTProcessArray::NewL
   113 // --------------------------------------------------------------------------
   115 // --------------------------------------------------------------------------
   114 //
   116 //
   115 CVIMPSTProcessArray* CVIMPSTProcessArray::NewL(
   117 CVIMPSTProcessArray* CVIMPSTProcessArray::NewL(
   116         MVIMPSTEngine& aEngine)
   118         MVIMPSTEngine& aEngine)
   117     {
   119     {
   118     TRACE( T_LIT("CVIMPSTProcessArray::NewL Start") );
   120     TRACER_AUTO;
   119     CVIMPSTProcessArray* self = new(ELeave) CVIMPSTProcessArray(aEngine);
   121     CVIMPSTProcessArray* self = new(ELeave) CVIMPSTProcessArray(aEngine);
   120     CleanupStack::PushL(self);
   122     CleanupStack::PushL(self);
   121     self->ConstructL();
   123     self->ConstructL();
   122     CleanupStack::Pop(self);
   124     CleanupStack::Pop(self);   
   123     TRACE( T_LIT("CVIMPSTProcessArray::NewL End") );
       
   124     return self;
   125     return self;
   125     
   126     
   126     }
   127     }
   127 
   128 
   128 // --------------------------------------------------------------------------
   129 // --------------------------------------------------------------------------
   129 // CVIMPSTProcessArray::ConstructL
   130 // CVIMPSTProcessArray::ConstructL
   130 // --------------------------------------------------------------------------
   131 // --------------------------------------------------------------------------
   131 //
   132 //
   132 void CVIMPSTProcessArray::ConstructL()
   133 void CVIMPSTProcessArray::ConstructL()
   133     {
   134     {
   134     TRACE( T_LIT("CVIMPSTProcessArray::ConstructL Start") );
   135    
       
   136     TRACER_AUTO;
   135     iContactInterface = CVIMPSTStorageManagerFactory::ContactListInterfaceL(iServiceId);
   137     iContactInterface = CVIMPSTStorageManagerFactory::ContactListInterfaceL(iServiceId);
   136     if(iContactInterface)
   138     if(iContactInterface)
   137         {        
   139         {        
   138         iContactInterface->AddObserverL( this );// listen these events..        
   140         iContactInterface->AddObserverL( this );// listen these events..        
   139         HBufC* unnamed = VIMPSTUtils::LoadResourceL( R_SERVTAB_UNNAMED );
   141         HBufC* unnamed = VIMPSTUtils::LoadResourceL( R_SERVTAB_UNNAMED );
   170         MVIMPSTEnginePresenceSubService::Cast (*subService);
   172         MVIMPSTEnginePresenceSubService::Cast (*subService);
   171         presence.RegisterPresenceEventObserverL(this);     
   173         presence.RegisterPresenceEventObserverL(this);     
   172         iPresenceSupported = ETrue;
   174         iPresenceSupported = ETrue;
   173         }
   175         }
   174 	ResetArray();
   176 	ResetArray();
   175 	TRACE( T_LIT("CVIMPSTProcessArray::ConstructL end") );
   177 	
   176     }
   178     }
   177 // --------------------------------------------------------------------------
   179 // --------------------------------------------------------------------------
   178 // CVIMPSTProcessArray::HandleStorageChangeL
   180 // CVIMPSTProcessArray::HandleStorageChangeL
   179 // --------------------------------------------------------------------------
   181 // --------------------------------------------------------------------------
   180 //
   182 //
   181 void CVIMPSTProcessArray::HandleStorageChangeL( TVIMPSTEnums::TVIMPSTStorgaeEventType aEventType,
   183 void CVIMPSTProcessArray::HandleStorageChangeL( TVIMPSTEnums::TVIMPSTStorgaeEventType aEventType,
   182 			         							MVIMPSTStorageContactList* /*aList*/, 
   184 			         							MVIMPSTStorageContactList* /*aList*/, 
   183 				        						MVIMPSTStorageContact* aContact,
   185 				        						MVIMPSTStorageContact* aContact,
   184 				        						TInt aContactIndex )
   186 				        						TInt aContactIndex )
   185     {
   187     {
   186     TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL Function Start") );
   188    
       
   189     TRACER_AUTO;
   187     // 0th index OwnItem + unknow contacts + add request
   190     // 0th index OwnItem + unknow contacts + add request
   188     aContactIndex = aContactIndex + 1 + iUnKnownContactArray.Count() + iAddRequestArray.Count();
   191     aContactIndex = aContactIndex + 1 + iUnKnownContactArray.Count() + iAddRequestArray.Count();
   189     
   192     
   190     switch( aEventType )
   193     switch( aEventType )
   191         {
   194         {
   192         case TVIMPSTEnums::EStorageContactReadComplete:
   195         case TVIMPSTEnums::EStorageContactReadComplete:
   193             {
   196             {           
   194             TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageContactReadComplete Start") );
   197             TRACE("EStorageContactReadComplete");
   195             if(iProcessObservers)
   198             if(iProcessObservers)
   196                 {
   199                 {
   197                 /* passing 0 so that the focus is on owndata item */
   200                 /* passing 0 so that the focus is on owndata item */
   198                 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EOwnStatusItem, 0 ); // focus own item
   201                 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EOwnStatusItem, 0 ); // focus own item
   199                 }
   202                 }           
   200             TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageContactReadComplete End") );
       
   201             break;
   203             break;
   202             }
   204             }
   203         case TVIMPSTEnums::EStorageContactFetchComplete:
   205         case TVIMPSTEnums::EStorageContactFetchComplete:
   204             {
   206             {            
   205             TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageContactFetchComplete Start") );
   207             TRACE("EStorageContactFetchComplete");
   206             TRACE( T_LIT("HandleStorageChangeL EStorageContactFetchComplete iItemArray Count: %d"), iItemArray.Count() );
   208             TRACE( " iItemArray Count: %d", iItemArray.Count() );
   207 
   209 
   208             if(iProcessObservers)
   210             if(iProcessObservers)
   209                 {
   211                 {
   210                 /* passing 0 so that the focus is on owndata item */
   212                 /* passing 0 so that the focus is on owndata item */
   211                 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EOwnStatusItem, 0 ); // focus own item
   213                 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EOwnStatusItem, 0 ); // focus own item
   212                 }
   214                 }
   213 
   215 
   214             ResetArray();
   216             ResetArray();
   215             iFetchCompleted = ETrue;
   217             iFetchCompleted = ETrue;
   216             GetAndCreateOpenChatListL();
   218             GetAndCreateOpenChatListL();
   217             TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageContactFetchComplete End") );
   219             TRACE( "EStorageContactFetchComplete End" );
   218             break; 	
   220             break; 	
   219             }
   221             }
   220         case TVIMPSTEnums::EStorageContactReading:
   222         case TVIMPSTEnums::EStorageContactReading:
   221         case TVIMPSTEnums::EStorageContactFetching:
   223         case TVIMPSTEnums::EStorageContactFetching:
   222         case TVIMPSTEnums::EStorageContactSynchronizing:
   224         case TVIMPSTEnums::EStorageContactSynchronizing:
   223             {
   225             {
   224             TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageContactFetching/EStorageContactFetching Start") );
   226             TRACE( "EStorageContactFetching/EStorageContactFetching" );
   225             /*
   227             /*
   226              *	This event occurs whenever we have contacts added to contactlist. This happens in the following scenarios
   228              *	This event occurs whenever we have contacts added to contactlist. This happens in the following scenarios
   227              *	1. At the time of login, when we fetch contacts, contact-by-contact is added to the storage. so we get this event.
   229              *	1. At the time of login, when we fetch contacts, contact-by-contact is added to the storage. so we get this event.
   228              * 	2. When we add a contact manually (either from phonebook, or manu adding etc.. ) we get this callback.
   230              * 	2. When we add a contact manually (either from phonebook, or manu adding etc.. ) we get this callback.
   229              */
   231              */
   230             TRACE( T_LIT("contactindex = %d"),aContactIndex );
   232             TRACE( "contactindex = %d",aContactIndex );
   231             CVIMPSTProcessContactItem* contactItem = CVIMPSTProcessContactItem::NewL (*this, const_cast<TDesC&>(aContact->Name() ),
   233             CVIMPSTProcessContactItem* contactItem = CVIMPSTProcessContactItem::NewL (*this, const_cast<TDesC&>(aContact->Name() ),
   232                     const_cast<TDesC&>(aContact->UserId() ),
   234                     const_cast<TDesC&>(aContact->UserId() ),
   233                     aContact->ContactLink(),
   235                     aContact->ContactLink(),
   234                     const_cast<TDesC&>(aContact->StatusText()),
   236                     const_cast<TDesC&>(aContact->StatusText()),
   235                     aContact->OnlineStatus());
   237                     aContact->OnlineStatus());
   239             /* All the time the index should be less than the item array's count, but during the fetch of contacts from cdb file to the view, 
   241             /* All the time the index should be less than the item array's count, but during the fetch of contacts from cdb file to the view, 
   240              * if we havent got a contactviewready, and during that if I get contactaddition, before getting contactFetchComplete, we should keep 
   242              * if we havent got a contactviewready, and during that if I get contactaddition, before getting contactFetchComplete, we should keep 
   241              * appending the items to the array for display, once we get the entire list, its sorted anyway while insertion, and when presence occurs
   243              * appending the items to the array for display, once we get the entire list, its sorted anyway while insertion, and when presence occurs
   242              * the contacts are re-sorted. 
   244              * the contacts are re-sorted. 
   243              */
   245              */
   244             TRACE( T_LIT("itemarraycount = %d"),iItemArray.Count() );
   246             TRACE( "itemarraycount = %d",iItemArray.Count() );
   245             if (aContactIndex >= iItemArray.Count() )
   247             if (aContactIndex >= iItemArray.Count() )
   246                 {
   248                 {                
   247                 TRACE( T_LIT("append contact item %d"), contactItem);
   249                 TRACE( "append contact item %d", contactItem);
   248                 iItemArray.Append(contactItem);
   250                 iItemArray.Append(contactItem);
   249                 }
   251                 }
   250             else
   252             else
   251                 {
   253                 {              
   252                 TRACE( T_LIT("Insert at index = %d"), aContactIndex);
   254                 TRACE( "Insert at index = %d", aContactIndex);
   253                 iItemArray.Insert(contactItem, aContactIndex );
   255                 iItemArray.Insert(contactItem, aContactIndex );
   254                 }               
   256                 }               
   255             if(iProcessObservers)
   257             if(iProcessObservers)
   256                 {
   258                 {
   257                 /* passing 0 so that the focus is on owndata item */
   259                 /* passing 0 so that the focus is on owndata item */
   259                 }
   261                 }
   260             if( aContact->AvatarContent().Length() && iProcessObservers )
   262             if( aContact->AvatarContent().Length() && iProcessObservers )
   261                 {
   263                 {
   262                 iProcessObservers->HandleAvatarChangeL( aContact->UserId() );
   264                 iProcessObservers->HandleAvatarChangeL( aContact->UserId() );
   263                 }
   265                 }
   264             TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageContactFetching/EStorageContactFetching End") );
   266            
   265             break;
   267             break;
   266             }
   268             }
   267         case TVIMPSTEnums::EStorageEventContactAddition:
   269         case TVIMPSTEnums::EStorageEventContactAddition:
   268             {
   270             {            
   269             TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactAddition Start") );
   271             TRACE("EStorageEventContactAddition");
   270 
   272 
   271             TBool removed = RemoveFromUnknonOrInvitationListL( aContact->UserId(), EFalse );
   273             TBool removed = RemoveFromUnknonOrInvitationListL( aContact->UserId(), EFalse );
   272             if( removed )
   274             if( removed )
   273                 {
   275                 {
   274                 aContactIndex = aContactIndex - 1; // one contact is removed from iUnknownContactArray 
   276                 aContactIndex = aContactIndex - 1; // one contact is removed from iUnknownContactArray 
   277              *	This event occurs whenever we have contacts added to contactlist. This happens in the following scenarios
   279              *	This event occurs whenever we have contacts added to contactlist. This happens in the following scenarios
   278              *	1. At the time of login, when we fetch contacts, contact-by-contact is added to the storage. so we get this event.
   280              *	1. At the time of login, when we fetch contacts, contact-by-contact is added to the storage. so we get this event.
   279              * 	2. When we add a contact manually (either from phonebook, or manu adding etc.. ) we get this callback.
   281              * 	2. When we add a contact manually (either from phonebook, or manu adding etc.. ) we get this callback.
   280                  */
   282                  */
   281             TPtrC userId = aContact->UserId();
   283             TPtrC userId = aContact->UserId();
   282                 TRACE( T_LIT("contactindex = %d"),aContactIndex );
   284                 TRACE( "contactindex = %d",aContactIndex );
   283                 CVIMPSTProcessContactItem* contactItem = CVIMPSTProcessContactItem::NewL ( *this, aContact->Name() ,
   285                 CVIMPSTProcessContactItem* contactItem = CVIMPSTProcessContactItem::NewL ( *this, aContact->Name() ,
   284                                                                                             userId,
   286                                                                                             userId,
   285                                                                                             aContact->ContactLink(),
   287                                                                                             aContact->ContactLink(),
   286                                                                                             const_cast<TDesC&>(aContact->StatusText()),
   288                                                                                             const_cast<TDesC&>(aContact->StatusText()),
   287                                                                                             aContact->OnlineStatus() );
   289                                                                                             aContact->OnlineStatus() );
   290             /* All the time the index should be less than the item array's count, but during the fetch of contacts from cdb file to the view, 
   292             /* All the time the index should be less than the item array's count, but during the fetch of contacts from cdb file to the view, 
   291              * if we havent got a contactviewready, and during that if I get contactaddition, before getting contactFetchComplete, we should keep 
   293              * if we havent got a contactviewready, and during that if I get contactaddition, before getting contactFetchComplete, we should keep 
   292              * appending the items to the array for display, once we get the entire list, its sorted anyway while insertion, and when presence occurs
   294              * appending the items to the array for display, once we get the entire list, its sorted anyway while insertion, and when presence occurs
   293              * the contacts are re-sorted. 
   295              * the contacts are re-sorted. 
   294              */
   296              */
   295             TRACE( T_LIT("itemarraycount = %d"),iItemArray.Count() );
   297             TRACE( "itemarraycount = %d",iItemArray.Count() );
   296             if (aContactIndex >= iItemArray.Count() )
   298             if (aContactIndex >= iItemArray.Count() )
   297                 {
   299                 {                
   298                 TRACE( T_LIT("append contact item = %d"), contactItem);
   300                 TRACE( "append contact item = %d", contactItem);
   299                 iItemArray.Append(contactItem);
   301                 iItemArray.Append(contactItem);
   300                 }                
   302                 }                
   301             else
   303             else
   302                 {
   304                 {                
   303                 TRACE( T_LIT("Insert at index = %d"), aContactIndex);
   305                 TRACE( "Insert at index = %d", aContactIndex);
   304                 iItemArray.Insert(contactItem, aContactIndex );
   306                 iItemArray.Insert(contactItem, aContactIndex );
   305                 }                
   307                 }                
   306              // check if  pending message exist
   308              // check if  pending message exist
   307             if( TVIMPSTEnums::ESVCERegistered == iLoginState && userId.Length() )
   309             if( TVIMPSTEnums::ESVCERegistered == iLoginState && userId.Length() )
   308                 {
   310                 {
   319             if(iProcessObservers)
   321             if(iProcessObservers)
   320                 {
   322                 {
   321                 /* passing aContactIndex so that the focus is on owndata item */
   323                 /* passing aContactIndex so that the focus is on owndata item */
   322                 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, aContactIndex );
   324                 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, aContactIndex );
   323                 }   
   325                 }   
   324             TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactAddition End") );
   326            
   325             break;
   327             break;
   326             }
   328             }
   327         case TVIMPSTEnums::EStorageEventContactDelete:
   329         case TVIMPSTEnums::EStorageEventContactDelete:
   328             {
   330             {
   329             TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactDelete Start") );
   331             TRACE( " EStorageEventContactDelete" );
   330             TRACE( T_LIT("contactindex = %d"),aContactIndex );
   332             TRACE( "contactindex = %d",aContactIndex );
   331             TRACE( T_LIT("itemarraycount = %d"),iItemArray.Count() );
   333             TRACE( "itemarraycount = %d",iItemArray.Count() );
   332             if( aContactIndex < iItemArray.Count() )
   334             if( aContactIndex < iItemArray.Count() )
   333                 {
   335                 {
   334                 MVIMPSTProcessArrayItem* deletedItem = iItemArray[ aContactIndex ]; 
   336                 MVIMPSTProcessArrayItem* deletedItem = iItemArray[ aContactIndex ];               
   335                 TRACE( T_LIT("contact removed in item array of index = %d"),aContactIndex );
   337                 TRACE( "contact removed in item array of index = %d",aContactIndex );
   336                 iItemArray.Remove (aContactIndex);
   338                 iItemArray.Remove (aContactIndex);
   337                 delete deletedItem;
   339                 delete deletedItem;
   338                 iItemArray.Compress();
   340                 iItemArray.Compress();
   339                 TRACE( T_LIT("contactindex = %d"),aContactIndex );
   341                 TRACE( "contactindex = %d",aContactIndex );
   340                 }
   342                 }
   341             if(iProcessObservers)
   343             if(iProcessObservers)
   342                 {
   344                 {
   343                 iProcessObservers->HandleDeletionL(TVIMPSTEnums::EContactItem, aContactIndex);
   345                 iProcessObservers->HandleDeletionL(TVIMPSTEnums::EContactItem, aContactIndex);
   344                 }
   346                 }            
   345             TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactDelete End") );
       
   346             break;
   347             break;
   347             }
   348             }
   348         case TVIMPSTEnums::EStorageAvatarChange:
   349         case TVIMPSTEnums::EStorageAvatarChange:
   349             {
   350             {           
   350             TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange Start") );
   351             TRACE("EStorageAvatarChange");
   351             if(iProcessObservers  && aContact )
   352             if(iProcessObservers  && aContact )
   352                 {
   353                 {               
   353                 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange inside if") );
   354                 TRACE( "EStorageAvatarChange inside if" );
   354                 TPtrC aUserId = aContact->UserId();
   355                 TPtrC aUserId = aContact->UserId();                
   355                 TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange aUserId = %S"), &aUserId );
   356                 TRACE( "EStorageAvatarChange aUserId = %S", &aUserId );
   356                 iProcessObservers->HandleAvatarChangeL( aContact->UserId() );
   357                 iProcessObservers->HandleAvatarChangeL( aContact->UserId() );
   357                 }
   358                 }           
   358             TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange End") );
       
   359             break;            
   359             break;            
   360             }
   360             }
   361         case TVIMPSTEnums::EStorageOwnPresenceChange:
   361         case TVIMPSTEnums::EStorageOwnPresenceChange:
   362             {
   362             {
   363             TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange Start") );
   363             TRACE( "EStorageOwnPresenceChange" );
   364             if(iProcessObservers)
   364             if(iProcessObservers)
   365                 {
   365                 {
   366                 /* passing index as 0, so thta focus remains at the owndata item */
   366                 /* passing index as 0, so thta focus remains at the owndata item */
   367                 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EOwnStatusItem, KErrNotFound );
   367                 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EOwnStatusItem, KErrNotFound );
   368                 }
   368                 }           
   369             TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange End") );
       
   370             break;
   369             break;
   371             }
   370             }
   372         case TVIMPSTEnums::EStorageMultiplePresenceChange:
   371         case TVIMPSTEnums::EStorageMultiplePresenceChange:
   373 	        {
   372 	        {	        
   374 	        TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange Start") );
   373 	        TRACE("EStorageMultiplePresenceChange " );
   375 	        // mostly this will get called after just login and fetch time
   374 	        // mostly this will get called after just login and fetch time
   376 	        ResetArray();
   375 	        ResetArray();
   377             if(iProcessObservers )
   376             if(iProcessObservers )
   378                 {
   377                 {
   379                 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, KErrNotFound );
   378                 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, KErrNotFound );
   380                 }
   379                 }            
   381             TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAvatarChange End") );
       
   382 	        break;	
   380 	        break;	
   383 	        }
   381 	        }
   384         case TVIMPSTEnums::EStoragePresenceChange:
   382         case TVIMPSTEnums::EStoragePresenceChange:
   385             {
   383             {           
   386             TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStoragePresenceChange Start") );
   384             TRACE( " EStoragePresenceChange" );
   387             /* 
   385             /* 
   388              *	After Sort we get the new index... So first we need to remove the contact from the old position, 
   386              *	After Sort we get the new index... So first we need to remove the contact from the old position, 
   389              *	and then re-insert it at the correct obtained position (newIndex in this case)
   387              *	and then re-insert it at the correct obtained position (newIndex in this case)
   390              */
   388              */
   391             TRACE( T_LIT("contactindex = %d"),aContactIndex );
   389             TRACE("contactindex = %d",aContactIndex );
   392             TRACE( T_LIT("itemarraycount = %d"),iItemArray.Count() );
   390             TRACE( "itemarraycount = %d",iItemArray.Count() );
   393             if( aContactIndex < iItemArray.Count() )
   391             if( aContactIndex < iItemArray.Count() )
   394                 {                
   392                 {                
   395                 TInt newIndex = iContactListModel->IndexOfContact( aContact );
   393                 TInt newIndex = iContactListModel->IndexOfContact( aContact );               
   396                 TRACE( T_LIT("new index = %d"),newIndex );
   394                 TRACE( "new index = %d",newIndex );
   397                 CVIMPSTProcessContactItem* newItem = CVIMPSTProcessContactItem::NewL(*this, const_cast<TDesC&>(aContact->Name() ),
   395                 CVIMPSTProcessContactItem* newItem = CVIMPSTProcessContactItem::NewL(*this, const_cast<TDesC&>(aContact->Name() ),
   398                         const_cast<TDesC&>(aContact->UserId() ),
   396                         const_cast<TDesC&>(aContact->UserId() ),
   399                         aContact->ContactLink(),
   397                         aContact->ContactLink(),
   400                         const_cast<TDesC&>(aContact->StatusText()),
   398                         const_cast<TDesC&>(aContact->StatusText()),
   401                         aContact->OnlineStatus() );
   399                         aContact->OnlineStatus() );
   417                     if( IsUnreadMessageExistsL( aContact->UserId() ) )
   415                     if( IsUnreadMessageExistsL( aContact->UserId() ) )
   418                         {
   416                         {
   419                         isOldMsgPending = ETrue;
   417                         isOldMsgPending = ETrue;
   420                         }
   418                         }
   421                    }
   419                    }
   422                 TRACE( T_LIT("contact removed in item array of index = %d"),aContactIndex );
   420                 TRACE( "contact removed in item array of index = %d",aContactIndex );
   423                 iItemArray.Remove(aContactIndex );
   421                 iItemArray.Remove(aContactIndex );
   424                 delete oldItem;
   422                 delete oldItem;
   425                 iItemArray.Compress();
   423                 iItemArray.Compress();
   426                 
   424                 
   427                 // restoring if previously chat/msgs were existing
   425                 // restoring if previously chat/msgs were existing
   437                         }
   435                         }
   438                     }
   436                     }
   439                 // Add it in the new index
   437                 // Add it in the new index
   440                 newIndex = newIndex + 1 + iUnKnownContactArray.Count()+ iAddRequestArray.Count();
   438                 newIndex = newIndex + 1 + iUnKnownContactArray.Count()+ iAddRequestArray.Count();
   441                 if (newIndex >= iItemArray.Count())
   439                 if (newIndex >= iItemArray.Count())
   442                     {
   440                     {                   
   443                     TRACE( T_LIT("append contact item = %d"), newIndex);
   441                     TRACE( "append contact item = %d", newIndex);
   444                     iItemArray.Append (newItem);
   442                     iItemArray.Append (newItem);
   445                     }
   443                     }
   446                 else
   444                 else
   447                     {
   445                     {                    
   448                     TRACE( T_LIT("Insert at index = %d"), newItem);
   446                     TRACE( "Insert at index = %d", newItem);
   449                     iItemArray.Insert (newItem, newIndex);
   447                     iItemArray.Insert (newItem, newIndex);
   450                     }   
   448                     }   
   451                 }
   449                 }
   452             if(iProcessObservers )
   450             if(iProcessObservers )
   453                 {
   451                 {
   454                 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, KErrNotFound );
   452                 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, KErrNotFound );
   455                 }
   453                 }
   456             TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStoragePresenceChange End") );
   454             
   457             break;
   455             break;
   458             }
   456             }
   459         case TVIMPSTEnums::EStorageEventOwnUserChanged:
   457         case TVIMPSTEnums::EStorageEventOwnUserChanged:
   460             {
   458             {
   461             TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventOwnUserChanged Start") );
   459             TRACE( "EStorageEventOwnUserChanged " );
   462             TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL start Event = %d"),aEventType );
   460             TRACE( " start Event = %d",aEventType );
   463             ResetArray();
   461             ResetArray();
   464             if(iProcessObservers )
   462             if(iProcessObservers )
   465                 {
   463                 {
   466                 iProcessObservers->HandleDeletionL(TVIMPSTEnums::EOwnStatusItem, 0 ); // focus own item
   464                 iProcessObservers->HandleDeletionL(TVIMPSTEnums::EOwnStatusItem, 0 ); // focus own item
   467 
   465 
   468                 if( aContact )
   466                 if( aContact )
   469                     {
   467                     {
   470                     iProcessObservers->HandleAvatarChangeL( aContact->UserId() );
   468                     iProcessObservers->HandleAvatarChangeL( aContact->UserId() );
   471                     }
   469                     }
   472                 }
   470                 }
   473             TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventOwnUserChanged End") );
   471             
   474 
   472 
   475             break;
   473             break;
   476             }
   474             }
   477         case TVIMPSTEnums::EStorageAllContactRemoved:
   475         case TVIMPSTEnums::EStorageAllContactRemoved:
   478             {
   476             {           
   479             TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAllContactRemoved Start") );
   477             TRACE("EStorageAllContactRemoved");
   480             TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAllContactRemoved count = %d"), iItemArray.Count() );
   478             TRACE( "EStorageAllContactRemoved count = %d", iItemArray.Count() );
   481             ResetArray();
   479             ResetArray();
   482             if(iProcessObservers )
   480             if(iProcessObservers )
   483                 {
   481                 {
   484                 iProcessObservers->HandleDeletionL(TVIMPSTEnums::EOwnStatusItem, 0 ); // focus own item
   482                 iProcessObservers->HandleDeletionL(TVIMPSTEnums::EOwnStatusItem, 0 ); // focus own item
   485                 }
   483                 }
   486             TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageAllContactRemoved End") );
   484           
   487             break;
   485             break;
   488             }
   486             }
   489         case TVIMPSTEnums::EStorageEventContactChange: 
   487         case TVIMPSTEnums::EStorageEventContactChange: 
   490 	        {
   488 	        {
   491 	        TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactChange Start") );
   489 	        TRACE("EStorageEventContactChange");	        
   492 	        // display name is changed ,might be contact is re-arranged
   490 	        // display name is changed ,might be contact is re-arranged
   493             TRACE( T_LIT("contactindex = %d"),aContactIndex );
   491             TRACE( "contactindex = %d",aContactIndex );
   494             TRACE( T_LIT("itemarraycount = %d"),iItemArray.Count() );
   492             TRACE( "itemarraycount = %d",iItemArray.Count() );
   495             if( aContactIndex < iItemArray.Count() )
   493             if( aContactIndex < iItemArray.Count() )
   496                 {
   494                 {
   497                 if ( aContact )
   495                 if ( aContact )
   498                      {
   496                      {
   499                     CVIMPSTProcessContactItem* newItem = CVIMPSTProcessContactItem::NewL(*this, const_cast<TDesC&>(aContact->Name() ),
   497                     CVIMPSTProcessContactItem* newItem = CVIMPSTProcessContactItem::NewL(*this, const_cast<TDesC&>(aContact->Name() ),
   503                             aContact->OnlineStatus() );
   501                             aContact->OnlineStatus() );
   504                     
   502                     
   505                     
   503                     
   506                     MVIMPSTProcessArrayItem* oldItem = iItemArray[ aContactIndex ];
   504                     MVIMPSTProcessArrayItem* oldItem = iItemArray[ aContactIndex ];
   507                     newItem->SetAvatarIndex(aContact->AvatarIndex()); // copy the avatar index too.
   505                     newItem->SetAvatarIndex(aContact->AvatarIndex()); // copy the avatar index too.
   508                     TRACE( T_LIT("contact removed in item array of index = %d"),aContactIndex );
   506                 TRACE("contact removed in item array of index = %d",aContactIndex );
   509                     // set the conversation open flag from old contact, as only the display name would have changed.
   507                     // set the conversation open flag from old contact, as only the display name would have changed.
   510                     newItem->SetConversationOpen(oldItem->IsConversationOpen());
   508                     newItem->SetConversationOpen(oldItem->IsConversationOpen());
   511                     newItem->SetMsgPending( oldItem->IsMsgPending() );
   509                     newItem->SetMsgPending( oldItem->IsMsgPending() );
   512                     iItemArray.Remove(aContactIndex );
   510                     iItemArray.Remove(aContactIndex );
   513                     delete oldItem;
   511                     delete oldItem;
   514                     iItemArray.Compress();
   512                     iItemArray.Compress();
   515                     TRACE( T_LIT("Insert at index = %d"), aContactIndex);
   513                 TRACE( "Insert at index = %d", aContactIndex);
   516                     TInt newIndex = iContactListModel->IndexOfContact( aContact );
   514                     TInt newIndex = iContactListModel->IndexOfContact( aContact );
   517                      // Add it in the new index
   515                      // Add it in the new index
   518                     newIndex = newIndex + 1 + iUnKnownContactArray.Count() + iAddRequestArray.Count();
   516                     newIndex = newIndex + 1 + iUnKnownContactArray.Count() + iAddRequestArray.Count();
   519                     if (newIndex >= iItemArray.Count())
   517                     if (newIndex >= iItemArray.Count())
   520                         {
   518                         {
   521                         TRACE( T_LIT("append contact item = %d"), newIndex);
   519                     TRACE("append contact item = %d", newIndex);
   522                         iItemArray.Append (newItem);
   520                         iItemArray.Append (newItem);
   523                         }
   521                         }
   524                     else
   522                     else
   525                         {
   523                         {
   526                         TRACE( T_LIT("Insert at index = %d"), newItem);
   524                     TRACE( "Insert at index = %d", newItem);
   527                         iItemArray.Insert(newItem, newIndex);
   525                         iItemArray.Insert(newItem, newIndex);
   528                         } 
   526                         } 
   529                     // inform the cv about the display name changes
   527                     // inform the cv about the display name changes
   530                     if(aContact && aContact->UserId().Length() && newItem->IsConversationOpen())
   528                     if(aContact && aContact->UserId().Length() && newItem->IsConversationOpen())
   531                         {
   529                         {
   532                         TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactChange "));
   530                     TRACE("EStorageEventContactChange ");
   533                         TApaTaskList taskList( CCoeEnv::Static()->WsSession() );
   531                         TApaTaskList taskList( CCoeEnv::Static()->WsSession() );
   534                         TApaTask task( taskList.FindApp( KConversationViewAppUid ) );
   532                         TApaTask task( taskList.FindApp( KConversationViewAppUid ) );
   535                     
   533                     
   536                         if ( task.Exists() )
   534                         if ( task.Exists() )
   537                             {
   535                             {
   538                             TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactChange:task exists"));
   536                         TRACE("EStorageEventContactChange - task exists");                       
   539                             // packing of data ,passed to conversation view
   537                             // packing of data ,passed to conversation view
   540                             TPckgBuf< TIMCVUiParams > params;
   538                             TPckgBuf< TIMCVUiParams > params;
   541                             params().iBuddyId = aContact->UserId();
   539                             params().iBuddyId = aContact->UserId();
   542                             params().iBuddyName = aContact->Name();
   540                             params().iBuddyName = aContact->Name();
   543                             params().iServiceId = iServiceId;
   541                             params().iServiceId = iServiceId;
   550                 
   548                 
   551               }
   549               }
   552             if(iProcessObservers )
   550             if(iProcessObservers )
   553                 {
   551                 {
   554                 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, aContactIndex );
   552                 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, aContactIndex );
   555                 }
   553                 }           
   556             TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventContactChange End") );
       
   557 	        break;	
   554 	        break;	
   558 	        }          
   555 	        }          
   559         case TVIMPSTEnums::EStorageEventUserIdPostChange:
   556         case TVIMPSTEnums::EStorageEventUserIdPostChange:
   560             {
   557             {
   561             TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventUserIdPostChange Start") );
   558             TRACE( "EStorageEventUserIdPostChange" );
   562             TRACE( T_LIT("contactindex = %d"),aContactIndex );
   559             TRACE( "contactindex = %d",aContactIndex );
   563             TRACE( T_LIT("itemarraycount = %d"),iItemArray.Count() );
   560             TRACE( "itemarraycount = %d",iItemArray.Count() );
   564             if( aContactIndex < iItemArray.Count() )
   561             if( aContactIndex < iItemArray.Count() )
   565                 {
   562                 {
   566                 CVIMPSTProcessContactItem* newItem = CVIMPSTProcessContactItem::NewL(*this, const_cast<TDesC&>(aContact->Name() ),
   563                 CVIMPSTProcessContactItem* newItem = CVIMPSTProcessContactItem::NewL(*this, const_cast<TDesC&>(aContact->Name() ),
   567                         const_cast<TDesC&>(aContact->UserId() ),
   564                         const_cast<TDesC&>(aContact->UserId() ),
   568                         aContact->ContactLink(),
   565                         aContact->ContactLink(),
   570                         aContact->OnlineStatus() );
   567                         aContact->OnlineStatus() );
   571                 
   568                 
   572                 
   569                 
   573                 MVIMPSTProcessArrayItem* oldItem = iItemArray[ aContactIndex ];
   570                 MVIMPSTProcessArrayItem* oldItem = iItemArray[ aContactIndex ];
   574                 newItem->SetAvatarIndex(aContact->AvatarIndex()); // copy the avatar index too.
   571                 newItem->SetAvatarIndex(aContact->AvatarIndex()); // copy the avatar index too.
   575                 TRACE( T_LIT("contact removed in item array of index = %d"),aContactIndex );
   572                 TRACE( "contact removed in item array of index = %d",aContactIndex );
   576                 iItemArray.Remove(aContactIndex );
   573                 iItemArray.Remove(aContactIndex );
   577                 delete oldItem;
   574                 delete oldItem;
   578                 iItemArray.Compress();
   575                 iItemArray.Compress();
   579                 TRACE( T_LIT("Insert at index = %d"), aContactIndex);
   576                 TRACE( "Insert at index = %d", aContactIndex);
   580                 iItemArray.InsertL (newItem, aContactIndex);
   577                 iItemArray.InsertL (newItem, aContactIndex);
   581                 }
   578                 }
   582             if(iProcessObservers )
   579             if(iProcessObservers )
   583                 {
   580                 {
   584                 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, aContactIndex );
   581                 iProcessObservers->HandleAdditionL(TVIMPSTEnums::EContactItem, aContactIndex );
   585                 }
   582                 }
   586             TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL EStorageEventUserIdPostChange End") );
   583             TRACE( "EStorageEventUserIdPostChange" );
   587             break;
   584             break;
   588             }
   585             }
   589         default:
   586         default:
   590             {
   587             {
   591             TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL Event default") );
   588             TRACE("default");          
   592             break;
   589             break;
   593             }
   590             }
   594         }
   591         }
   595     TRACE( T_LIT("CVIMPSTProcessArray::HandleStorageChangeL Function End") );
   592     
   596     }
   593     }
   597 
   594 
   598 // --------------------------------------------------------------------------
   595 // --------------------------------------------------------------------------
   599 // CVIMPSTProcessArray::AddObserver
   596 // CVIMPSTProcessArray::AddObserver
   600 // --------------------------------------------------------------------------
   597 // --------------------------------------------------------------------------
   781 // Fill up the complete array one item at a time
   778 // Fill up the complete array one item at a time
   782 // -----------------------------------------------------------------------------
   779 // -----------------------------------------------------------------------------
   783 
   780 
   784 void CVIMPSTProcessArray::FillItemL()
   781 void CVIMPSTProcessArray::FillItemL()
   785     {
   782     {
       
   783     TRACER_AUTO;
   786     TInt count = 0;
   784     TInt count = 0;
   787     if(iContactListModel)
   785     if(iContactListModel)
   788         {
   786         {
   789         count = iContactListModel->Count();
   787         count = iContactListModel->Count();
   790         }
   788         }
   846 // FillOwnDataL implementation
   844 // FillOwnDataL implementation
   847 // -----------------------------------------------------------------------------
   845 // -----------------------------------------------------------------------------
   848 // fill the owndata at the begining of array.....
   846 // fill the owndata at the begining of array.....
   849 TBool CVIMPSTProcessArray::FillOwnDataL()
   847 TBool CVIMPSTProcessArray::FillOwnDataL()
   850     {
   848     {
       
   849     TRACER_AUTO;
   851     TBool ownDataAdded = EFalse;
   850     TBool ownDataAdded = EFalse;
   852     TPtr dataPtr = iData->Des();    
   851     TPtr dataPtr = iData->Des();    
   853     // Check whether the user has logged in before, if has
   852     // Check whether the user has logged in before, if has
   854     // then dont update anything just return   
   853     // then dont update anything just return   
   855     //check if its logged in or not.
   854     //check if its logged in or not.
  1014 // CVIMPSTProcessArray::SetLoginState
  1013 // CVIMPSTProcessArray::SetLoginState
  1015 // -----------------------------------------------------------------------------
  1014 // -----------------------------------------------------------------------------
  1016 
  1015 
  1017 void CVIMPSTProcessArray::SetLoginStateL(TVIMPSTEnums::TVIMPSTRegistrationState aLoginState)
  1016 void CVIMPSTProcessArray::SetLoginStateL(TVIMPSTEnums::TVIMPSTRegistrationState aLoginState)
  1018     {
  1017     {
       
  1018     TRACER_AUTO;
  1019     iLoginState = aLoginState;
  1019     iLoginState = aLoginState;
  1020     if(aLoginState != TVIMPSTEnums::ESVCERegistered )
  1020     if(aLoginState != TVIMPSTEnums::ESVCERegistered )
  1021         {
  1021         {
  1022         iFetchCompleted = EFalse;
  1022         iFetchCompleted = EFalse;
  1023         RemoveUnKnownContacts();
  1023         RemoveUnKnownContacts();
  1024         RemoveAddRequestData();
  1024         RemoveAddRequestData();
  1025         iUnKnownContactArray.ResetAndDestroy();// delete all items
  1025         iUnKnownContactArray.ResetAndDestroy();// delete all items
  1026         iUnKnownContactArray.Reset();
  1026         iUnKnownContactArray.Reset();
  1027         iAddRequestArray.ResetAndDestroy();// delete all items
  1027         iAddRequestArray.ResetAndDestroy();// delete all items
  1028         iAddRequestArray.Reset();
  1028         iAddRequestArray.Reset();
       
  1029         // reset the status of all the contacts.
       
  1030         // no need to check the item type here. by the time its here all the other 
       
  1031         // type except contact item are removed.
       
  1032         TInt count = iItemArray.Count();
       
  1033         for(TInt i = 0; i < count ; i++)
       
  1034             {
       
  1035              iItemArray[i]->DoFormatStringL();
       
  1036             }
  1029         }
  1037         }
  1030     FillOwnDataL(); // this will change the own item based on connection status
  1038     FillOwnDataL(); // this will change the own item based on connection status
  1031     }
  1039     }
  1032 // -----------------------------------------------------------------------------
  1040 // -----------------------------------------------------------------------------
  1033 // CVIMPSTProcessArray::GetLoginState
  1041 // CVIMPSTProcessArray::GetLoginState
  1042 // CVIMPSTProcessArray::GetOnlineStatus
  1050 // CVIMPSTProcessArray::GetOnlineStatus
  1043 // -----------------------------------------------------------------------------
  1051 // -----------------------------------------------------------------------------
  1044 
  1052 
  1045 TVIMPSTEnums::TOnlineStatus CVIMPSTProcessArray::GetOnlineStatusL(TInt aIndex)
  1053 TVIMPSTEnums::TOnlineStatus CVIMPSTProcessArray::GetOnlineStatusL(TInt aIndex)
  1046     {
  1054     {
       
  1055     TRACER_AUTO;
  1047     TVIMPSTEnums::TItem itemtype = GetType( aIndex );
  1056     TVIMPSTEnums::TItem itemtype = GetType( aIndex );
  1048     TVIMPSTEnums::TOnlineStatus status = TVIMPSTEnums::EUnknown;
  1057     TVIMPSTEnums::TOnlineStatus status = TVIMPSTEnums::EUnknown;
  1049     switch(itemtype)
  1058     switch(itemtype)
  1050         {
  1059         {
  1051         case TVIMPSTEnums::EOwnStatusItem:
  1060         case TVIMPSTEnums::EOwnStatusItem:
  1074 //CVIMPSTProcessArray::StatusText
  1083 //CVIMPSTProcessArray::StatusText
  1075 //-----------------------------------------------------------
  1084 //-----------------------------------------------------------
  1076 // 
  1085 // 
  1077 const TDesC&  CVIMPSTProcessArray::StatusTextL(TInt aIndex ) 
  1086 const TDesC&  CVIMPSTProcessArray::StatusTextL(TInt aIndex ) 
  1078     {
  1087     {
       
  1088     TRACER_AUTO;
  1079     TVIMPSTEnums::TItem itemtype = GetType( aIndex );
  1089     TVIMPSTEnums::TItem itemtype = GetType( aIndex );
  1080     switch(itemtype)
  1090     switch(itemtype)
  1081         {
  1091         {
  1082         case TVIMPSTEnums::EOwnStatusItem:
  1092         case TVIMPSTEnums::EOwnStatusItem:
  1083             {
  1093             {
  1103 //CVIMPSTProcessArray::RemoveFromUnknonOrInvitationListL
  1113 //CVIMPSTProcessArray::RemoveFromUnknonOrInvitationListL
  1104 //-----------------------------------------------------------
  1114 //-----------------------------------------------------------
  1105 //
  1115 //
  1106 TBool CVIMPSTProcessArray::RemoveFromUnknonOrInvitationListL( const TDesC& aAddedUserId ,TBool aBlocked )
  1116 TBool CVIMPSTProcessArray::RemoveFromUnknonOrInvitationListL( const TDesC& aAddedUserId ,TBool aBlocked )
  1107     {
  1117     {
       
  1118     TRACER_AUTO;
  1108     TBool found = RemoveFromUnknonListL( aAddedUserId );
  1119     TBool found = RemoveFromUnknonListL( aAddedUserId );
  1109     if( !found )
  1120     if( !found )
  1110         {
  1121         {
  1111         found = RemoveFromInvitationListL( aAddedUserId );
  1122         found = RemoveFromInvitationListL( aAddedUserId );
  1112         }
  1123         }
  1129 //CVIMPSTProcessArray::RemoveFromUnknonListL
  1140 //CVIMPSTProcessArray::RemoveFromUnknonListL
  1130 //-----------------------------------------------------------
  1141 //-----------------------------------------------------------
  1131 //
  1142 //
  1132 TBool CVIMPSTProcessArray::RemoveFromUnknonListL( const TDesC& aAddedUserId )
  1143 TBool CVIMPSTProcessArray::RemoveFromUnknonListL( const TDesC& aAddedUserId )
  1133     {
  1144     {
  1134     TRACE( T_LIT("CVIMPSTProcessArray::RemoveFromUnknonListL start ") );
  1145    
       
  1146     TRACER_AUTO;
  1135     TPtrC addedUserId = VIMPSTUtils::DisplayId( aAddedUserId );
  1147     TPtrC addedUserId = VIMPSTUtils::DisplayId( aAddedUserId );
  1136     TBool found = EFalse;
  1148     TBool found = EFalse;
  1137     TInt count = iUnKnownContactArray.Count();
  1149     TInt count = iUnKnownContactArray.Count();
  1138     CVIMPSTProcessUnknownContactItem* unknownItem = NULL;
  1150     CVIMPSTProcessUnknownContactItem* unknownItem = NULL;
  1139     TInt index = KErrNotFound;
  1151     TInt index = KErrNotFound;
  1150                 {
  1162                 {
  1151                 found = ETrue;
  1163                 found = ETrue;
  1152                 }
  1164                 }
  1153             break;
  1165             break;
  1154             }
  1166             }
  1155         TRACE( T_LIT("CVIMPSTProcessArray::RemoveFromUnknonListL  for ends") );
  1167        
  1156         }
  1168         }
  1157     if( found )
  1169     if( found )
  1158         {
  1170         {
  1159         iItemArray.Remove(itemIndex);
  1171         iItemArray.Remove(itemIndex);
  1160         iUnKnownContactArray.Remove( index );
  1172         iUnKnownContactArray.Remove( index );
  1167             // this is to refresh the list box
  1179             // this is to refresh the list box
  1168             // KErrNotFound , focus remain at same position
  1180             // KErrNotFound , focus remain at same position
  1169             iProcessObservers->HandleDeletionL(TVIMPSTEnums::EUnknonContactItem, KErrNotFound );
  1181             iProcessObservers->HandleDeletionL(TVIMPSTEnums::EUnknonContactItem, KErrNotFound );
  1170             }
  1182             }
  1171         }
  1183         }
  1172     TRACE( T_LIT("CVIMPSTProcessArray::RemoveFromUnknonListL end ") );
  1184   
  1173     return found;
  1185     return found;
  1174     }
  1186     }
  1175 //-----------------------------------------------------------
  1187 //-----------------------------------------------------------
  1176 //CVIMPSTProcessArray::RemoveFromInvitationListL
  1188 //CVIMPSTProcessArray::RemoveFromInvitationListL
  1177 //-----------------------------------------------------------
  1189 //-----------------------------------------------------------
  1178 //
  1190 //
  1179 TBool CVIMPSTProcessArray::RemoveFromInvitationListL( const TDesC& aAddedUserId )
  1191 TBool CVIMPSTProcessArray::RemoveFromInvitationListL( const TDesC& aAddedUserId )
  1180     {
  1192     {
       
  1193     TRACER_AUTO;
  1181     TPtrC addedUserId = VIMPSTUtils::DisplayId( aAddedUserId );
  1194     TPtrC addedUserId = VIMPSTUtils::DisplayId( aAddedUserId );
  1182     TBool found = EFalse;
  1195     TBool found = EFalse;
  1183     TInt index = KErrNotFound;
  1196     TInt index = KErrNotFound;
  1184     TInt itemIndex = KErrNotFound;
  1197     TInt itemIndex = KErrNotFound;
  1185     // item not foun in unknown list
  1198     // item not foun in unknown list
  1245 // CVIMPSTProcessArray::GetAndCreateOpenChatListL
  1258 // CVIMPSTProcessArray::GetAndCreateOpenChatListL
  1246 // return contact index including friend request.
  1259 // return contact index including friend request.
  1247 // -----------------------------------------------------------------------------
  1260 // -----------------------------------------------------------------------------
  1248 void CVIMPSTProcessArray::GetAndCreateOpenChatListL() 
  1261 void CVIMPSTProcessArray::GetAndCreateOpenChatListL() 
  1249     {
  1262     {
       
  1263     TRACER_AUTO;
  1250     //Get IM SubService     
  1264     //Get IM SubService     
  1251     MVIMPSTEngineSubService* subService =         
  1265     MVIMPSTEngineSubService* subService =         
  1252                 (iEngine.SubService(TVIMPSTEnums::EIM));
  1266                 (iEngine.SubService(TVIMPSTEnums::EIM));
  1253     RArray<SIMCacheChatItem> openChats;
  1267     RArray<SIMCacheChatItem> openChats;
  1254     openChats.Reset();
  1268     openChats.Reset();
  1313 //-----------------------------------------------------------
  1327 //-----------------------------------------------------------
  1314 // 
  1328 // 
  1315 void CVIMPSTProcessArray::HandleChatMessageEventL( TVIMPSTEnums::TIMEventType aEventType ,
  1329 void CVIMPSTProcessArray::HandleChatMessageEventL( TVIMPSTEnums::TIMEventType aEventType ,
  1316                                                     const TDesC& aSender )
  1330                                                     const TDesC& aSender )
  1317     {
  1331     {
       
  1332     TRACER_AUTO;
  1318     if( !iFetchCompleted )
  1333     if( !iFetchCompleted )
  1319         {
  1334         {
  1320         // contact matching will not be correct until fetching completed
  1335         // contact matching will not be correct until fetching completed
  1321         // hence return 
  1336         // hence return 
  1322         return;
  1337         return;
  1409 //-----------------------------------------------------------
  1424 //-----------------------------------------------------------
  1410 // 
  1425 // 
  1411 void  CVIMPSTProcessArray::HandleAddRequestEventL(TVIMPSTEnums::TOperationType aType, const TDesC& aRequesterId,
  1426 void  CVIMPSTProcessArray::HandleAddRequestEventL(TVIMPSTEnums::TOperationType aType, const TDesC& aRequesterId,
  1412                                                     const TDesC& aRequestorDisplayName )
  1427                                                     const TDesC& aRequestorDisplayName )
  1413     {
  1428     {
       
  1429     TRACER_AUTO;
  1414   	//add new add request item at top of list(i.e at index 1, as 0 is own id).
  1430   	//add new add request item at top of list(i.e at index 1, as 0 is own id).
  1415     //when request is entertained remove item from list.
  1431     //when request is entertained remove item from list.
  1416     switch( aType )
  1432     switch( aType )
  1417 	    {
  1433 	    {
  1418 		case TVIMPSTEnums::EAddItem :
  1434 		case TVIMPSTEnums::EAddItem :
  1471 //CVIMPSTProcessArray::DoHandleUnKnownContactMessageL
  1487 //CVIMPSTProcessArray::DoHandleUnKnownContactMessageL
  1472 //-----------------------------------------------------------
  1488 //-----------------------------------------------------------
  1473 // 
  1489 // 
  1474 void CVIMPSTProcessArray::DoHandleUnKnownContactMessageL( const TDesC& aSenderId ,TBool aIsMsgPending )
  1490 void CVIMPSTProcessArray::DoHandleUnKnownContactMessageL( const TDesC& aSenderId ,TBool aIsMsgPending )
  1475     {
  1491     {
       
  1492     TRACER_AUTO;
  1476     TBool contactExist = EFalse ;
  1493     TBool contactExist = EFalse ;
  1477     TInt count = iUnKnownContactArray.Count();
  1494     TInt count = iUnKnownContactArray.Count();
  1478     CVIMPSTProcessUnknownContactItem* unknownItem = NULL;
  1495     CVIMPSTProcessUnknownContactItem* unknownItem = NULL;
  1479     for( TInt i=0; i<count; i++ )
  1496     for( TInt i=0; i<count; i++ )
  1480         {
  1497         {