uiservicetab/vimpststorage/src/cvimpststorageserviceview.cpp
branchRCL_3
changeset 9 9fdee5e1da30
parent 6 78867dafe7eb
child 13 76f25fb7a6a1
equal deleted inserted replaced
8:796276a1bdcc 9:9fdee5e1da30
    30 #include "vimpststorageutils.h"
    30 #include "vimpststorageutils.h"
    31 
    31 
    32 #include <MVPbkStoreContact.h>
    32 #include <MVPbkStoreContact.h>
    33 #include <VPbkContactStoreUris.h>
    33 #include <VPbkContactStoreUris.h>
    34 #include <TVPbkContactStoreUriPtr.h>
    34 #include <TVPbkContactStoreUriPtr.h>
    35 #include "vimpstdebugtrace.h"
    35 #include "uiservicetabtracer.h"
    36 #include "tvimpstconsts.h"
    36 #include "tvimpstconsts.h"
    37 #include "mvimpststoragecontact.h"
    37 #include "mvimpststoragecontact.h"
    38 
    38 
    39  
    39  
    40 // ============================ MEMBER FUNCTIONS ===============================
    40 // ============================ MEMBER FUNCTIONS ===============================
    55 CVIMPSTStorageServiceView::CVIMPSTStorageServiceView(TUint32 aServiceId) :
    55 CVIMPSTStorageServiceView::CVIMPSTStorageServiceView(TUint32 aServiceId) :
    56     iServiceId(aServiceId),
    56     iServiceId(aServiceId),
    57     iOwnContact( NULL ),
    57     iOwnContact( NULL ),
    58     iUnNamedText( NULL )
    58     iUnNamedText( NULL )
    59     {
    59     {
    60     TRACE( T_LIT("CVIMPSTStorageServiceView::CVIMPSTStorageServiceView()") );
    60 	TRACER_AUTO;
    61     }
    61     }
    62 
    62 
    63 // -----------------------------------------------------------------------------
    63 // -----------------------------------------------------------------------------
    64 // CVIMPSTStorageServiceView::ConstructL
    64 // CVIMPSTStorageServiceView::ConstructL
    65 // Symbian 2nd phase constructor can leave.
    65 // Symbian 2nd phase constructor can leave.
    67 // deleted elements from the persistent storage
    67 // deleted elements from the persistent storage
    68 // -----------------------------------------------------------------------------
    68 // -----------------------------------------------------------------------------
    69 //
    69 //
    70 void CVIMPSTStorageServiceView::ConstructL(const TDesC& aStoreName, const TDesC& aServiceName)
    70 void CVIMPSTStorageServiceView::ConstructL(const TDesC& aStoreName, const TDesC& aServiceName)
    71     {
    71     {
    72     TRACE( T_LIT("CVIMPSTStorageServiceView::ConstructL() begin") );
    72 	TRACER_AUTO;
    73     
    73     
    74     iActiveHandler =  CVIMPSTStorageActiveHandler::NewL(this);
    74     iActiveHandler =  CVIMPSTStorageActiveHandler::NewL(this);
    75 					 
    75 					 
    76     // create sorter for contacts
    76     // create sorter for contacts
    77     iContactSorter = CVIMPSTStorageContactSorter::NewL();
    77     iContactSorter = CVIMPSTStorageContactSorter::NewL();
    78     
    78     
    79     //set the sorting algorithem to order by presence.
    79     //set the sorting algorithem to order by presence.
    80     iContactSorter->SetSortAlgorithm( MVIMPSTStorageContact::ECompareByPresence);
    80     iContactSorter->SetSortAlgorithm( MVIMPSTStorageContact::ECompareByPresence);
    81     
    81     
    82     TRACE( T_LIT("SubServiceType() Type : %S"), &aStoreName );
    82     TRACE( "SubServiceType() Type : %S", &aStoreName );
    83     //find whether its a local store or xsp store
    83     //find whether its a local store or xsp store
    84 	if ( VPbkContactStoreUris::DefaultCntDbUri().CompareC( aStoreName, 1, NULL )
    84 	if ( VPbkContactStoreUris::DefaultCntDbUri().CompareC( aStoreName, 1, NULL )
    85 	                        != 0 )
    85 	                        != 0 )
    86 		{
    86 		{
    87 		TRACE( T_LIT("CVIMPSTStorageServiceView::ConstructL() service store created") ); 
    87 	TRACE( " service store created" );
    88 		//Create XSP Store 
    88 		//Create XSP Store 
    89     	iVPbkContactStore = 
    89     	iVPbkContactStore = 
    90     			CVIMPSTStorageVPbkServerStore::NewL(aStoreName,aServiceName ,*this );
    90     			CVIMPSTStorageVPbkServerStore::NewL(aStoreName,aServiceName ,*this );
    91 		}
    91 		}
    92 	else
    92 	else
    93 		{
    93 		{
    94 		TRACE( T_LIT("CVIMPSTStorageServiceView::ConstructL() local store created ") ); 
    94 	TRACE( "local store created " ); 
    95 		//Create Local Contacts.cdb store 
    95 		//Create Local Contacts.cdb store 
    96 		iVPbkContactStore = CVIMPSTStorageVPbkLocalStore::NewL(VPbkContactStoreUris::DefaultCntDbUri(), 
    96 		iVPbkContactStore = CVIMPSTStorageVPbkLocalStore::NewL(VPbkContactStoreUris::DefaultCntDbUri(), 
    97 															   aServiceName,
    97 															   aServiceName,
    98 															   *this );	
    98 															   *this );	
    99 		}
    99 		}
   100     TRACE( T_LIT("CVIMPSTStorageServiceView::ConstructL() end") );;
       
   101     }
   100     }
   102 
   101 
   103 
   102 
   104 // -----------------------------------------------------------------------------
   103 // -----------------------------------------------------------------------------
   105 // CVIMPSTStorageServiceView::NewL
   104 // CVIMPSTStorageServiceView::NewL
   108 //
   107 //
   109 CVIMPSTStorageServiceView* CVIMPSTStorageServiceView::NewL(TUint32 aServiceId,
   108 CVIMPSTStorageServiceView* CVIMPSTStorageServiceView::NewL(TUint32 aServiceId,
   110 										const TDesC& aStoreName,
   109 										const TDesC& aStoreName,
   111 										const TDesC& aServiceName)
   110 										const TDesC& aServiceName)
   112     {
   111     {
   113     TRACE( T_LIT("CVIMPSTStorageServiceView::NewL() begin") );
   112 	TRACER_AUTO;
   114     
   113     
   115     CVIMPSTStorageServiceView* self = new( ELeave ) CVIMPSTStorageServiceView(aServiceId);
   114     CVIMPSTStorageServiceView* self = new( ELeave ) CVIMPSTStorageServiceView(aServiceId);
   116     CleanupStack::PushL( self );
   115     CleanupStack::PushL( self );
   117     self->ConstructL(aStoreName, aServiceName);
   116     self->ConstructL(aStoreName, aServiceName);
   118     CleanupStack::Pop( self );
   117     CleanupStack::Pop( self );
   119     TRACE( T_LIT("CVIMPSTStorageServiceView::NewL() end") );
       
   120     return self;
   118     return self;
   121     }
   119     }
   122 // -----------------------------------------------------------------------------
   120 // -----------------------------------------------------------------------------
   123 // CVIMPSTStorageServiceView::~CVIMPSTStorageServiceView
   121 // CVIMPSTStorageServiceView::~CVIMPSTStorageServiceView
   124 // Two-phased constructor.
   122 // Two-phased constructor.
   125 // -----------------------------------------------------------------------------
   123 // -----------------------------------------------------------------------------
   126 // Destructor
   124 // Destructor
   127 CVIMPSTStorageServiceView::~CVIMPSTStorageServiceView()
   125 CVIMPSTStorageServiceView::~CVIMPSTStorageServiceView()
   128     {
   126     {
   129     TRACE( T_LIT("CVIMPSTStorageServiceView::~CVIMPSTStorageServiceView() begin") );
   127 	TRACER_AUTO;
   130     if( iActiveHandler )
   128     if( iActiveHandler )
   131 	    {
   129 	    {
   132 	    iActiveHandler->Cancel();
   130 	    iActiveHandler->Cancel();
   133 	    delete iActiveHandler;	
   131 	    delete iActiveHandler;	
   134 	    }
   132 	    }
   145         {
   143         {
   146         delete iUnNamedText;   
   144         delete iUnNamedText;   
   147         iUnNamedText = NULL;
   145         iUnNamedText = NULL;
   148         }        
   146         }        
   149         
   147         
   150     TRACE( T_LIT("CVIMPSTStorageServiceView::~CVIMPSTStorageServiceView() end") );
       
   151     }
   148     }
   152 // -----------------------------------------------------------------------------
   149 // -----------------------------------------------------------------------------
   153 // CVIMPSTStorageServiceView::AddObserverL
   150 // CVIMPSTStorageServiceView::AddObserverL
   154 // From MVIMPSTStorageServiceView
   151 // From MVIMPSTStorageServiceView
   155 // -----------------------------------------------------------------------------
   152 // -----------------------------------------------------------------------------
   156 //
   153 //
   157 void CVIMPSTStorageServiceView::AddObserverL( MVIMPSTStorageContactsObserver*
   154 void CVIMPSTStorageServiceView::AddObserverL( MVIMPSTStorageContactsObserver*
   158         aObserver )
   155         aObserver )
   159     {
   156     {
   160     TRACE( T_LIT("CVIMPSTStorageServiceView::AddObserverL() begin") );
   157 	TRACER_AUTO;
   161     User::LeaveIfError( aObserver ? KErrNone : KErrArgument );
   158     User::LeaveIfError( aObserver ? KErrNone : KErrArgument );
   162     TInt index = iContactObservers.Find( aObserver );
   159     TInt index = iContactObservers.Find( aObserver );
   163     if( index == KErrNotFound )
   160     if( index == KErrNotFound )
   164 	    {
   161 	    {
   165 	    TRACE( T_LIT("CVIMPSTStorageServiceView::AddObserverL() aObserver added ") );
   162 		TRACE( "aObserver added ");
   166 	    User::LeaveIfError( iContactObservers.Append( aObserver ) );	
   163 	    User::LeaveIfError( iContactObservers.Append( aObserver ) );	
   167 	    }
   164 	    }
   168 	TRACE( T_LIT("CVIMPSTStorageServiceView::AddObserverL() end") );
       
   169     }
   165     }
   170 
   166 
   171 // -----------------------------------------------------------------------------
   167 // -----------------------------------------------------------------------------
   172 // CVIMPSTStorageServiceView::RemoveObserverL
   168 // CVIMPSTStorageServiceView::RemoveObserverL
   173 // From MVIMPSTStorageServiceView
   169 // From MVIMPSTStorageServiceView
   174 // -----------------------------------------------------------------------------
   170 // -----------------------------------------------------------------------------
   175 void CVIMPSTStorageServiceView::RemoveObserver( MVIMPSTStorageContactsObserver*
   171 void CVIMPSTStorageServiceView::RemoveObserver( MVIMPSTStorageContactsObserver*
   176         aObserver )
   172         aObserver )
   177 	{
   173 	{
   178 	TRACE( T_LIT("CVIMPSTStorageServiceView::RemoveObserver() begin") );
   174 	TRACER_AUTO;
   179 	__ASSERT_ALWAYS( aObserver, Panic( EObserverIsNull ));
   175 	__ASSERT_ALWAYS( aObserver, Panic( EObserverIsNull ));
   180 	const TInt index( iContactObservers.Find( aObserver ) );
   176 	const TInt index( iContactObservers.Find( aObserver ) );
   181 	if ( index >=0)
   177 	if ( index >=0)
   182 		{
   178 		{
   183 		TRACE( T_LIT("CVIMPSTStorageServiceView::RemoveObserver() aObserver found") );
   179 		TRACE( "aObserver found" );
   184 		iContactObservers.Remove( index );
   180 		iContactObservers.Remove( index );
   185 		iContactObservers.Compress();
   181 		iContactObservers.Compress();
   186 		}
   182 		}
   187 	TRACE( T_LIT("CVIMPSTStorageServiceView::RemoveObserver() begin") );
       
   188 	}
   183 	}
   189 
   184 
   190 // -----------------------------------------------------------------------------
   185 // -----------------------------------------------------------------------------
   191 // CVIMPSTStorageServiceView::SetUnnamedTextL
   186 // CVIMPSTStorageServiceView::SetUnnamedTextL
   192 // From MVIMPSTStorageServiceView
   187 // From MVIMPSTStorageServiceView
   202 //
   197 //
   203 MVIMPSTStorageContactList* CVIMPSTStorageServiceView::CreateContactListL( 
   198 MVIMPSTStorageContactList* CVIMPSTStorageServiceView::CreateContactListL( 
   204 										   const TDesC& aContactListId, 
   199 										   const TDesC& aContactListId, 
   205                                            const TDesC& aDisplayName )
   200                                            const TDesC& aDisplayName )
   206     {
   201     {
   207     TRACE( T_LIT("CVIMPSTStorageServiceView::CreateContactListL() begin") );
   202 	TRACER_AUTO;
   208     CVIMPSTStorageContactList* contactList = 
   203     CVIMPSTStorageContactList* contactList = 
   209     						CVIMPSTStorageContactList::NewLC(*iContactSorter,
   204     						CVIMPSTStorageContactList::NewLC(*iContactSorter,
   210                                                          	  aContactListId, 
   205                                                          	  aContactListId, 
   211                                                          	  aDisplayName );
   206                                                          	  aDisplayName );
   212                                                          
   207                                                          
   213     TIdentityRelation< CVIMPSTStorageContactList > findBy( 
   208     TIdentityRelation< CVIMPSTStorageContactList > findBy( 
   214                                 CVIMPSTStorageServiceView::ContactListFindByContactListId);
   209                                 CVIMPSTStorageServiceView::ContactListFindByContactListId);
   215     TInt indexOfList( iContactListArray.Find( contactList, findBy ) );
   210     TInt indexOfList( iContactListArray.Find( contactList, findBy ) );
   216     if( indexOfList == KErrNotFound )
   211     if( indexOfList == KErrNotFound )
   217         {
   212         {
   218         TRACE( T_LIT("CVIMPSTStorageServiceView::CreateContactListL() list not exist in list") );
   213 		TRACE( "list not exist in list");
   219         TLinearOrder< CVIMPSTStorageContactList > order( 
   214         TLinearOrder< CVIMPSTStorageContactList > order( 
   220                              CVIMPSTStorageServiceView::ContactListOrderByDisplayName );
   215                              CVIMPSTStorageServiceView::ContactListOrderByDisplayName );
   221         iContactListArray.InsertInOrderAllowRepeats( contactList, order );
   216         iContactListArray.InsertInOrderAllowRepeats( contactList, order );
   222         CleanupStack::Pop( contactList ); 
   217         CleanupStack::Pop( contactList ); 
   223         TRACE( T_LIT("CVIMPSTStorageServiceView::CreateContactListL() new list created") );       
   218         TRACE( " new list created");
   224         }
   219         }
   225     else
   220     else
   226         {
   221         {
   227         TRACE( T_LIT("CVIMPSTStorageServiceView::CreateContactListL() list  already exist in list") );
   222 		TRACE( " list  already exist in list" );
   228         CleanupStack::PopAndDestroy( contactList );
   223         CleanupStack::PopAndDestroy( contactList );
   229         contactList = iContactListArray[ indexOfList ];
   224         contactList = iContactListArray[ indexOfList ];
   230         }
   225         }
   231     TRACE( T_LIT("CVIMPSTStorageServiceView::CreateContactListL() end") );
       
   232     return contactList; 
   226     return contactList; 
   233     }
   227     }
   234 
   228 
   235 // -----------------------------------------------------------------------------
   229 // -----------------------------------------------------------------------------
   236 // CVIMPSTStorageServiceView::RemoveContactList
   230 // CVIMPSTStorageServiceView::RemoveContactList
   237 // -----------------------------------------------------------------------------
   231 // -----------------------------------------------------------------------------
   238 //
   232 //
   239 void CVIMPSTStorageServiceView::RemoveContactList( const TDesC& aContactListId )
   233 void CVIMPSTStorageServiceView::RemoveContactList( const TDesC& aContactListId )
   240     {
   234     {
   241     TRACE( T_LIT("CVIMPSTStorageServiceView::RemoveContactList() begin") );
   235 	TRACER_AUTO;
   242     TInt pos( FindContactListById( aContactListId ) );
   236     TInt pos( FindContactListById( aContactListId ) );
   243     if( pos >= 0 )
   237     if( pos >= 0 )
   244         {
   238         {
   245         TRACE( T_LIT("CVIMPSTStorageServiceView::RemoveContactList() aContactListId found") );
   239 		TRACE( "aContactListId found" );
   246         delete iContactListArray[ pos ];
   240         delete iContactListArray[ pos ];
   247         iContactListArray.Remove( pos );  
   241         iContactListArray.Remove( pos );  
   248         iContactListArray.Compress();      
   242         iContactListArray.Compress();      
   249         }
   243         }
   250     TRACE( T_LIT("CVIMPSTStorageServiceView::RemoveContactList() end") );
       
   251     }
   244     }
   252 
   245 
   253 // -----------------------------------------------------------------------------
   246 // -----------------------------------------------------------------------------
   254 // CVIMPSTStorageServiceView::ListCount
   247 // CVIMPSTStorageServiceView::ListCount
   255 // Count of contactlists
   248 // Count of contactlists
   256 // -----------------------------------------------------------------------------
   249 // -----------------------------------------------------------------------------
   257 //
   250 //
   258 TInt CVIMPSTStorageServiceView::ListCount() const
   251 TInt CVIMPSTStorageServiceView::ListCount() const
   259     {
   252     {
   260     TRACE( T_LIT("CVIMPSTStorageServiceView::ListCount()") );
   253 	TRACER_AUTO;
   261     return iContactListArray.Count();
   254     return iContactListArray.Count();
   262     }
   255     }
   263 
   256 
   264 // -----------------------------------------------------------------------------
   257 // -----------------------------------------------------------------------------
   265 // CVIMPSTStorageServiceView::ListAt
   258 // CVIMPSTStorageServiceView::ListAt
   266 // Reference to contact list
   259 // Reference to contact list
   267 // -----------------------------------------------------------------------------
   260 // -----------------------------------------------------------------------------
   268 //
   261 //
   269 MVIMPSTStorageContactList& CVIMPSTStorageServiceView::ListAt( TInt aIndex ) const
   262 MVIMPSTStorageContactList& CVIMPSTStorageServiceView::ListAt( TInt aIndex ) const
   270     {   
   263     {  
   271     TRACE( T_LIT("CVIMPSTStorageServiceView::ListAt() begin") );
   264 	TRACER_AUTO;
   272     // User::LeaveIfError( aIndex < iContactListArray.Count() ? KErrNone : KErrArgument ); 
   265     // User::LeaveIfError( aIndex < iContactListArray.Count() ? KErrNone : KErrArgument ); 
   273     __ASSERT_ALWAYS( (aIndex < iContactListArray.Count() && aIndex >=0 ), Panic( EContactsArrayOutOfSync ));  
   266     __ASSERT_ALWAYS( (aIndex < iContactListArray.Count() && aIndex >=0 ), Panic( EContactsArrayOutOfSync ));  
   274     TRACE( T_LIT("CVIMPSTStorageServiceView::ListAt() end") );
       
   275     return *iContactListArray[ aIndex ];
   267     return *iContactListArray[ aIndex ];
   276     }
   268     }
   277 // -----------------------------------------------------------------------------
   269 // -----------------------------------------------------------------------------
   278 // CVIMPSTStorageServiceView::ContactCount
   270 // CVIMPSTStorageServiceView::ContactCount
   279 // Count of contacts
   271 // Count of contacts
   280 // -----------------------------------------------------------------------------
   272 // -----------------------------------------------------------------------------
   281 //
   273 //
   282 TInt CVIMPSTStorageServiceView::ContactCount( TBool aSkipOfflineContacts ) const
   274 TInt CVIMPSTStorageServiceView::ContactCount( TBool aSkipOfflineContacts ) const
   283     {
   275     {
   284     TRACE( T_LIT("CVIMPSTStorageServiceView::ListAt() begin") );
   276 	TRACER_AUTO;
   285     TInt contactCount( 0 );
   277     TInt contactCount( 0 );
   286     TInt count( iContactListArray.Count() );
   278     TInt count( iContactListArray.Count() );
   287     for( TInt a( 0 ); a < count; ++a )
   279     for( TInt a( 0 ); a < count; ++a )
   288         {
   280         {
   289         contactCount += iContactListArray[ a ]->ContactCount( aSkipOfflineContacts, 
   281         contactCount += iContactListArray[ a ]->ContactCount( aSkipOfflineContacts, 
   290                                                          EFalse );
   282                                                          EFalse );
   291         }
   283         }
   292     TRACE( T_LIT("CVIMPSTStorageServiceView::ListAt() contactCount = %d") ,contactCount );
   284 		TRACE(" contactCount = %d" ,contactCount );
   293     TRACE( T_LIT("CVIMPSTStorageServiceView::ListAt() end") );
       
   294     return contactCount;
   285     return contactCount;
   295     }
   286     }
   296     
   287     
   297 // -----------------------------------------------------------------------------
   288 // -----------------------------------------------------------------------------
   298 // CVIMPSTStorageServiceView::UpdatepresenceL
   289 // CVIMPSTStorageServiceView::UpdatepresenceL
   303 					                             TVIMPSTEnums::TOnlineStatus aStatus,
   294 					                             TVIMPSTEnums::TOnlineStatus aStatus,
   304 					                             const TDesC& aStatusText,
   295 					                             const TDesC& aStatusText,
   305 					                             const TDesC8& aAvatarData,
   296 					                             const TDesC8& aAvatarData,
   306 					                             TBool aIsClearingAvatar /*= EFalse*/)
   297 					                             TBool aIsClearingAvatar /*= EFalse*/)
   307 	{
   298 	{
   308 	TRACE( T_LIT("CVIMPSTStorageServiceView::UpdatePresenceL() begin") );
   299 	TRACER_AUTO;
   309 	MVIMPSTStorageContact* contact = NULL;
   300 	MVIMPSTStorageContact* contact = NULL;
   310 	if( iOwnContact && ( aContactId.Compare( iOwnContact->UserId() ) == 0  ) )
   301 	if( iOwnContact && ( aContactId.Compare( iOwnContact->UserId() ) == 0  ) )
   311 	    {
   302 	    {
   312 	    TRACE( T_LIT("CVIMPSTStorageServiceView::UpdatePresenceL() own Item presence") );
   303 		TRACE("own Item presence");
   313 	    if( aAvatarData.Compare(iOwnContact->AvatarContent() ) != 0 )
   304 	    if( aAvatarData.Compare(iOwnContact->AvatarContent() ) != 0 )
   314 	        {
   305 	        {
   315 	        if((aIsClearingAvatar)||(aAvatarData.Length() > 0))
   306 	        if((aIsClearingAvatar)||(aAvatarData.Length() > 0))
   316 	            {
   307 	            {
   317 	            TRACE( T_LIT("CVIMPSTStorageServiceView::UpdatePresenceL() own avatar change NotifyAllObserversL") );
   308 				TRACE( "own avatar change NotifyAllObserversL");
   318 	            iOwnContact->SetAvatarContentL( aAvatarData ,*iVPbkContactStore );  
   309 	            iOwnContact->SetAvatarContentL( aAvatarData ,*iVPbkContactStore );  
   319 	            NotifyAllObserversL(TVIMPSTEnums::EStorageAvatarChange,NULL,iOwnContact,0);
   310 	            NotifyAllObserversL(TVIMPSTEnums::EStorageAvatarChange,NULL,iOwnContact,0);
   320 	            }
   311 	            }
   321 	        }
   312 	        }
   322 	    if( ( iOwnContact->OnlineStatus() !=  aStatus ) || ( aStatusText.Compare( iOwnContact->StatusText() ) != 0 ) )
   313 	    if( ( iOwnContact->OnlineStatus() !=  aStatus ) || ( aStatusText.Compare( iOwnContact->StatusText() ) != 0 ) )
   323 	        {
   314 	        {
   324 		    // own presence has changes
   315 		    // own presence has changes
   325 		    // update to own presence
   316 		    // update to own presence
   326 		    iOwnContact->SetOnlineStatus( aStatus );
   317 		    iOwnContact->SetOnlineStatus( aStatus );
   327 		    iOwnContact->SetStatusTextL(aStatusText);
   318 		    iOwnContact->SetStatusTextL(aStatusText);
   328 		    TRACE( T_LIT("CVIMPSTStorageServiceView::UpdatePresenceL() own presene NotifyAllObserversL") );
   319 		    TRACE( " own presene NotifyAllObserversL");
   329 		    NotifyAllObserversL(TVIMPSTEnums::EStorageOwnPresenceChange,NULL, iOwnContact,0);
   320 		    NotifyAllObserversL(TVIMPSTEnums::EStorageOwnPresenceChange,NULL, iOwnContact,0);
   330 		    }
   321 		    }
   331 	    contact = iOwnContact;
   322 	    contact = iOwnContact;
   332 		}
   323 		}
   333 	else
   324 	else
   334 		{
   325 		{
   335 		TRACE( T_LIT("CVIMPSTStorageServiceView::UpdatePresenceL() contact item ") );
   326 		TRACE( "contact item ");
   336 		contact = FindContactByUserId( aContactId );
   327 		contact = FindContactByUserId( aContactId );
   337 		if(contact)
   328 		if(contact)
   338 			{
   329 			{
   339 			TRACE( T_LIT("CVIMPSTStorageServiceView::UpdatePresenceL() contact exist ") );
   330 			TRACE( "contact exist " );
   340 			TInt index = KErrNotFound;
   331 			TInt index = KErrNotFound;
   341 			TVIMPSTEnums::TOnlineStatus oldOnlineStatus = contact->OnlineStatus();
   332 			TVIMPSTEnums::TOnlineStatus oldOnlineStatus = contact->OnlineStatus();
   342 			TRACE( T_LIT("CVIMPSTStorageServiceView::UpdatePresenceL() contact oldOnlineStatus = %d"), oldOnlineStatus );
   333 			TRACE( "contact oldOnlineStatus = %d", oldOnlineStatus );
   343 			TRACE( T_LIT("CVIMPSTStorageServiceView::UpdatePresenceL() contact new presence = %d"), aStatus );
   334 			TRACE( "contact new presence = %d", aStatus );
   344 			//status text can be different for the sam status hence not inside the if condition.
   335 			//status text can be different for the sam status hence not inside the if condition.
   345 			if(  oldOnlineStatus != aStatus )
   336 			if(  oldOnlineStatus != aStatus )
   346 			    {
   337 			    {
   347 			    TRACE( T_LIT("CVIMPSTStorageServiceView::UpdatePresenceL() contact presence change ") );
   338 				TRACE( "contact presence change ");
       
   339 
   348 			    contact->SetOnlineStatus( aStatus );
   340 			    contact->SetOnlineStatus( aStatus );
   349 			    TInt count = iContactListArray.Count();
   341 			    TInt count = iContactListArray.Count();
   350 			    for(TInt i = 0; i < count; i++)
   342 			    for(TInt i = 0; i < count; i++)
   351 			        {
   343 			        {
   352 			        index = iContactListArray[i]->FindIndexOfContact(contact);
   344 			        index = iContactListArray[i]->FindIndexOfContact(contact);
   353 			        if(KErrNotFound != index )
   345 			        if(KErrNotFound != index )
   354 			            {
   346 			            {
   355 			            iContactListArray[i]->ResortContact(contact);
   347 			            iContactListArray[i]->ResortContact(contact);
   356 			            TRACE( T_LIT("CVIMPSTStorageServiceView::UpdatePresenceL() contact ResortContact ") );
   348 			            TRACE( "contact ResortContact " );
   357 			            // get the index of the sorted contact, as after sorting the 
   349 			            // get the index of the sorted contact, as after sorting the 
   358 			            // index would have changed based on presence.
   350 			            // index would have changed based on presence.
   359 			            // break after the contact list is found and the contact is found
   351 			            // break after the contact list is found and the contact is found
   360 			            break;
   352 			            break;
   361 			            }
   353 			            }
   381 			    {
   373 			    {
   382 			    TInt oldIndex = IndexOfContact (contact);   
   374 			    TInt oldIndex = IndexOfContact (contact);   
   383 			    contact->SetAvatarContentL( aAvatarData ,*iVPbkContactStore);  
   375 			    contact->SetAvatarContentL( aAvatarData ,*iVPbkContactStore);  
   384 			    NotifyAllObserversL(TVIMPSTEnums::EStorageAvatarChange,NULL, contact, oldIndex );
   376 			    NotifyAllObserversL(TVIMPSTEnums::EStorageAvatarChange,NULL, contact, oldIndex );
   385 			    }
   377 			    }
   386 			TRACE( T_LIT("CVIMPSTStorageServiceView::UpdatePresenceL() aStatusText = %S "), &aStatusText );
   378 			TRACE("aStatusText = %S ", &aStatusText );
   387 			TRACE( T_LIT("CVIMPSTStorageServiceView::UpdatePresenceL() NotifyAllObserversL called") );
   379 			TRACE( "NotifyAllObserversL called" );
   388 			TRACE( T_LIT("CVIMPSTStorageServiceView::UpdatePresenceL() NotifyAllObserversL finish") );	
   380 			TRACE( "NotifyAllObserversL finish" );	
   389 			}
   381 			}
   390 	 	}
   382 	 	}	
   391 	TRACE( T_LIT("CVIMPSTStorageServiceView::UpdatePresenceL() end") );
       
   392     return contact;
   383     return contact;
   393     }
   384     }
   394  
   385  
   395  // -----------------------------------------------------------------------------
   386  // -----------------------------------------------------------------------------
   396 // CVIMPSTStorageServiceView::UpdateAvatarL
   387 // CVIMPSTStorageServiceView::UpdateAvatarL
   397 // -----------------------------------------------------------------------------
   388 // -----------------------------------------------------------------------------
   398 //
   389 //
   399  MVIMPSTStorageContact* CVIMPSTStorageServiceView::UpdateAvatarL(const TDesC& aContactId,
   390  MVIMPSTStorageContact* CVIMPSTStorageServiceView::UpdateAvatarL(const TDesC& aContactId,
   400 							                  const TDesC8& aAvatarData ) 
   391 							                  const TDesC8& aAvatarData ) 
   401  {
   392  {
   402  TRACE( T_LIT("CVIMPSTStorageServiceView::UpdateAvatarL() begin") );
   393  TRACER_AUTO;
   403  MVIMPSTStorageContact* contact = NULL;
   394  MVIMPSTStorageContact* contact = NULL;
   404  if( iOwnContact && ( aContactId.Compare( iOwnContact->UserId() ) == 0  ) )
   395  if( iOwnContact && ( aContactId.Compare( iOwnContact->UserId() ) == 0  ) )
   405 		{
   396 		{
   406 		TRACE( T_LIT("CVIMPSTStorageServiceView::UpdateAvatarL() own avatar") );
   397 		TRACE( "own avatar" );
   407 		iOwnContact->SetAvatarContentL( aAvatarData ,*iVPbkContactStore);	
   398 		iOwnContact->SetAvatarContentL( aAvatarData ,*iVPbkContactStore);	
   408 		NotifyAllObserversL(TVIMPSTEnums::EStorageOwnPresenceChange,NULL, iOwnContact,0);
   399 		NotifyAllObserversL(TVIMPSTEnums::EStorageOwnPresenceChange,NULL, iOwnContact,0);
   409 	    contact = iOwnContact;
   400 	    contact = iOwnContact;
   410 		}
   401 		}
   411 	else
   402 	else
   412 		{
   403 		{
   413 		TRACE( T_LIT("CVIMPSTStorageServiceView::UpdateAvatarL() buddy avatar") );
   404 		TRACE( "buddy avatar" );
   414 	    contact = FindContactByUserId( aContactId );
   405 	    contact = FindContactByUserId( aContactId );
   415 		if(contact)
   406 		if(contact)
   416 			{
   407 			{
   417 			TRACE( T_LIT("CVIMPSTStorageServiceView::UpdateAvatarL() contact exit") );
   408 			TRACE( "contact exit");
   418 			contact->SetAvatarContentL( aAvatarData ,*iVPbkContactStore);	
   409 			contact->SetAvatarContentL( aAvatarData ,*iVPbkContactStore);	
   419 			TInt index = IndexOfContact(contact);
   410 			TInt index = IndexOfContact(contact);
   420 		    NotifyAllObserversL(TVIMPSTEnums::EStorageAvatarChange,NULL, contact,index);
   411 		    NotifyAllObserversL(TVIMPSTEnums::EStorageAvatarChange,NULL, contact,index);
   421 		    TRACE( T_LIT("CVIMPSTStorageServiceView::UpdateAvatarL() NotifyAllObserversL called") );		
   412 		    TRACE( " NotifyAllObserversL called" );		
   422 			}
   413 			}
   423 	   	}
   414 	   	}
   424    TRACE( T_LIT("CVIMPSTStorageServiceView::UpdateAvatarL() end") );
       
   425    return contact;
   415    return contact;
   426    }
   416    }
   427            
   417            
   428 // -----------------------------------------------------------------------------
   418 // -----------------------------------------------------------------------------
   429 // CVIMPSTStorageServiceView::FindContactListInternal
   419 // CVIMPSTStorageServiceView::FindContactListInternal
   430 // -----------------------------------------------------------------------------
   420 // -----------------------------------------------------------------------------
   431 //
   421 //
   432 CVIMPSTStorageContactList* CVIMPSTStorageServiceView::FindContactListInternal( 
   422 CVIMPSTStorageContactList* CVIMPSTStorageServiceView::FindContactListInternal( 
   433                                                 const TDesC& aListId )
   423                                                 const TDesC& aListId )
   434     {
   424     {
   435     TRACE( T_LIT("CVIMPSTStorageServiceView::FindContactListInternal begin") );    
   425 	TRACER_AUTO;
   436 	TInt contactListIndex( FindContactListById( aListId ) );
   426 	TInt contactListIndex( FindContactListById( aListId ) );
   437 	TRACE( T_LIT("CVIMPSTStorageServiceView::FindContactListInternal end ") );
       
   438     return ( contactListIndex >= 0 ? iContactListArray[ contactListIndex ] : NULL );
   427     return ( contactListIndex >= 0 ? iContactListArray[ contactListIndex ] : NULL );
   439     }
   428     }
   440 
   429 
   441 // -----------------------------------------------------------------------------
   430 // -----------------------------------------------------------------------------
   442 // CVIMPSTStorageServiceView::FindContactList
   431 // CVIMPSTStorageServiceView::FindContactList
   443 // -----------------------------------------------------------------------------
   432 // -----------------------------------------------------------------------------
   444 //
   433 //
   445 MVIMPSTStorageContactList* CVIMPSTStorageServiceView::FindContactList( const TDesC& aListId )
   434 MVIMPSTStorageContactList* CVIMPSTStorageServiceView::FindContactList( const TDesC& aListId )
   446     {
   435     {
   447     TRACE( T_LIT("CVIMPSTStorageServiceView::FindContactList") ); 
   436 	TRACER_AUTO;     
   448     return FindContactListInternal( aListId );
   437     return FindContactListInternal( aListId );
   449     }
   438     }
   450 
   439 
   451 // -----------------------------------------------------------------------------
   440 // -----------------------------------------------------------------------------
   452 // CVIMPSTStorageServiceView::FindContactListById
   441 // CVIMPSTStorageServiceView::FindContactListById
   453 // -----------------------------------------------------------------------------
   442 // -----------------------------------------------------------------------------
   454 //
   443 //
   455 TInt CVIMPSTStorageServiceView::FindContactListById(const TDesC& aListId )
   444 TInt CVIMPSTStorageServiceView::FindContactListById(const TDesC& aListId )
   456 	{
   445 	{
   457 	TRACE( T_LIT("CVIMPSTStorageServiceView::FindContactList begin") );
   446 	TRACER_AUTO;
   458 	TInt index = KErrNotFound;
   447 	TInt index = KErrNotFound;
   459 	TInt count( iContactListArray.Count() );
   448 	TInt count( iContactListArray.Count() );
   460 	TRACE( T_LIT("CVIMPSTStorageServiceView::FindContactList count = %d"), count );
   449 	TRACE( " count = %d", count );
   461 	for( TInt i= 0  ; i < count ; i++ )
   450 	for( TInt i= 0  ; i < count ; i++ )
   462 		{
   451 		{
   463 		if( KErrNone == VIMPSTStorageUtils::NeutralCompare( 
   452 		if( KErrNone == VIMPSTStorageUtils::NeutralCompare( 
   464 							 aListId, 
   453 							 aListId, 
   465                              iContactListArray[ i ]->ListId(), EFalse )   )
   454                              iContactListArray[ i ]->ListId(), EFalse )   )
   466 			{
   455 			{
   467 			TRACE( T_LIT("CVIMPSTStorageServiceView::FindContactList contact list found") );
   456 			TRACE( " contact list found" );
   468 			index = i;
   457 			index = i;
   469 			break;
   458 			break;
   470 			}
   459 			}
   471 		}
   460 		}
   472 	TRACE( T_LIT("CVIMPSTStorageServiceView::FindContactList end") );
       
   473 	return index;
   461 	return index;
   474 	}
   462 	}
   475 	
   463 	
   476 // -----------------------------------------------------------------------------
   464 // -----------------------------------------------------------------------------
   477 // CVIMPSTStorageServiceView::FindContactListById
   465 // CVIMPSTStorageServiceView::FindContactListById
   478 // -----------------------------------------------------------------------------
   466 // -----------------------------------------------------------------------------
   479 //
   467 //
   480 MVIMPSTStorageContact* CVIMPSTStorageServiceView::FindContactByLink(const MVPbkContactLink& aContactLink )
   468 MVIMPSTStorageContact* CVIMPSTStorageServiceView::FindContactByLink(const MVPbkContactLink& aContactLink )
   481 	{
   469 	{
   482 	TRACE( T_LIT("CVIMPSTStorageServiceView::FindContactByLink begin") );
   470 	TRACER_AUTO;
   483 	MVIMPSTStorageContact* contact = NULL;
   471 	MVIMPSTStorageContact* contact = NULL;
   484 	TInt count( iContactListArray.Count() );
   472 	TInt count( iContactListArray.Count() );
   485     for( TInt i= 0  ; i < count ; i++ )
   473     for( TInt i= 0  ; i < count ; i++ )
   486         {
   474         {
   487         CVIMPSTStorageContactList* contactList = iContactListArray[ i ];
   475         CVIMPSTStorageContactList* contactList = iContactListArray[ i ];
   488         contact = contactList->FindContactByContactLink( aContactLink );
   476         contact = contactList->FindContactByContactLink( aContactLink );
   489         if( contact )
   477         if( contact )
   490             { 
   478             { 
   491             TRACE( T_LIT("CVIMPSTStorageServiceView::FindContactByLink contact found = %d "), i );           
   479             TRACE( " contact found = %d ", i );           
   492             break;
   480             break;
   493             }
   481             }
   494         }
   482         }
   495     TRACE( T_LIT("CVIMPSTStorageServiceView::FindContactByLink end") );
       
   496     return contact;
   483     return contact;
   497   	}
   484   	}
   498 
   485 
   499 // -----------------------------------------------------------------------------
   486 // -----------------------------------------------------------------------------
   500 // CVIMPSTStorageServiceView::GetServiceId
   487 // CVIMPSTStorageServiceView::GetServiceId
   501 // -----------------------------------------------------------------------------
   488 // -----------------------------------------------------------------------------
   502 //
   489 //
   503 TUint32 CVIMPSTStorageServiceView::GetServiceId()
   490 TUint32 CVIMPSTStorageServiceView::GetServiceId()
   504     {
   491     {
   505     TRACE( T_LIT("CVIMPSTStorageServiceView::GetServiceId") );
   492 	TRACER_AUTO;
   506     return iServiceId;
   493     return iServiceId;
   507     }
   494     }
   508     
   495     
   509 // -----------------------------------------------------------------------------
   496 // -----------------------------------------------------------------------------
   510 // CVIMPSTStorageServiceView::LocalStore
   497 // CVIMPSTStorageServiceView::LocalStore
   511 // -----------------------------------------------------------------------------
   498 // -----------------------------------------------------------------------------
   512 //
   499 //
   513 TBool CVIMPSTStorageServiceView::IsLocalStore() const
   500 TBool CVIMPSTStorageServiceView::IsLocalStore() const
   514 	{
   501 	{
   515 	TRACE( T_LIT("CVIMPSTStorageServiceView::IsLocalStore") );
   502 	TRACER_AUTO;
   516 	return iVPbkContactStore->LocalStore();	
   503 	return iVPbkContactStore->LocalStore();	
   517 	}  
   504 	}  
   518 // -----------------------------------------------------------------------------
   505 // -----------------------------------------------------------------------------
   519 // CVIMPSTStorageServiceView::OwnContactL
   506 // CVIMPSTStorageServiceView::OwnContactL
   520 // -----------------------------------------------------------------------------
   507 // -----------------------------------------------------------------------------
   521 //
   508 //
   522 MVIMPSTStorageContact& CVIMPSTStorageServiceView::OwnContactL()
   509 MVIMPSTStorageContact& CVIMPSTStorageServiceView::OwnContactL()
   523 	{
   510 	{
   524 	TRACE( T_LIT("CVIMPSTStorageServiceView::OwnContact begin") );
   511 	TRACER_AUTO;
   525 	if( !iOwnContact )
   512 	if( !iOwnContact )
   526 		{
   513 		{
   527 		iOwnContact = CVIMPSTStorageContact::NewL(KNullDesC,
   514 		iOwnContact = CVIMPSTStorageContact::NewL(KNullDesC,
   528 		        								  KNullDesC )	;	
   515 		        								  KNullDesC )	;	
   529 		}
   516 		}
   530 	TRACE( T_LIT("CVIMPSTStorageServiceView::OwnContact end") );
       
   531 	return *iOwnContact;	
   517 	return *iOwnContact;	
   532 	} 
   518 	} 
   533 
   519 
   534 // -----------------------------------------------------------------------------
   520 // -----------------------------------------------------------------------------
   535 // CVIMPSTStorageServiceView::SetOwnUserIdL
   521 // CVIMPSTStorageServiceView::SetOwnUserIdL
   536 // -----------------------------------------------------------------------------
   522 // -----------------------------------------------------------------------------
   537 //
   523 //
   538 void CVIMPSTStorageServiceView::SetOwnUserIdL(const TDesC& aUserId ) 
   524 void CVIMPSTStorageServiceView::SetOwnUserIdL(const TDesC& aUserId ) 
   539 	{
   525 	{
   540 	TRACE( T_LIT("CVIMPSTStorageServiceView::SetOwnUserIdL begin") );
   526 	TRACER_AUTO;
   541 	if( !iOwnContact )
   527 	if( !iOwnContact )
   542 		{
   528 		{
   543 		iOwnContact = CVIMPSTStorageContact::NewL(aUserId,
   529 		iOwnContact = CVIMPSTStorageContact::NewL(aUserId,
   544 		        								  KNullDesC
   530 		        								  KNullDesC
   545 		        								  )	;
   531 		        								  )	;
   546 		TRACE( T_LIT("CVIMPSTStorageServiceView::SetOwnUserIdL iOwnContact created") );
   532 		TRACE( "iOwnContact created" );
   547 		}
   533 		}
   548 	else if( aUserId.Compare( iOwnContact->UserId() ) != 0 )
   534 	else if( aUserId.Compare( iOwnContact->UserId() ) != 0 )
   549 		{
   535 		{
   550 	    _LIT (KNullWithSpace, " ");
   536 	    _LIT (KNullWithSpace, " ");
   551 		TRACE( T_LIT("CVIMPSTStorageServiceView::SetOwnUserIdL iOwnContact was existing") );
   537 		TRACE( "SetOwnUserIdL iOwnContact was existing" );
   552 	    if(KNullWithSpace ().Compare(iOwnContact->UserId())!=0)
   538 	    if(KNullWithSpace ().Compare(iOwnContact->UserId())!=0)
   553 	        { 
   539 	        { 
   554 	        iVPbkContactStore->RemoveAllVPbkContactsL(); // if user id is changed remove all contacts 	
   540 	        iVPbkContactStore->RemoveAllVPbkContactsL(); // if user id is changed remove all contacts 	
   555 	        RemoveAllCacheContactsL();
   541 	        RemoveAllCacheContactsL();
   556 	        }
   542 	        }
   557 		iOwnContact->SetUserIdL( aUserId );
   543 		iOwnContact->SetUserIdL( aUserId );
   558 		iOwnContact->SetAvatarContentL(KNullDesC8,*iVPbkContactStore );
   544 		iOwnContact->SetAvatarContentL(KNullDesC8,*iVPbkContactStore );
   559 
   545 
   560 		NotifyAllObserversL( TVIMPSTEnums::EStorageEventOwnUserChanged,NULL,iOwnContact,0 );
   546 		NotifyAllObserversL( TVIMPSTEnums::EStorageEventOwnUserChanged,NULL,iOwnContact,0 );
   561 		TRACE( T_LIT("CVIMPSTStorageServiceView::SetOwnUserIdL NotifyAllObserversL delivered") );
   547 		TRACE( "NotifyAllObserversL delivered" );
   562 		}
   548 		}
   563 	TRACE( T_LIT("CVIMPSTStorageServiceView::SetOwnUserIdL end") );
       
   564 	}    
   549 	}    
   565 // -----------------------------------------------------------------------------
   550 // -----------------------------------------------------------------------------
   566 // CVIMPSTStorageServiceView::FindContactByUserId
   551 // CVIMPSTStorageServiceView::FindContactByUserId
   567 // From MVIMPSTStorageServiceView.
   552 // From MVIMPSTStorageServiceView.
   568 // Try to load with given ID, return NULL if not found.
   553 // Try to load with given ID, return NULL if not found.
   569 // -----------------------------------------------------------------------------
   554 // -----------------------------------------------------------------------------
   570 MVIMPSTStorageContact* CVIMPSTStorageServiceView::FindContactByUserId( const TDesC& aUserId )
   555 MVIMPSTStorageContact* CVIMPSTStorageServiceView::FindContactByUserId( const TDesC& aUserId )
   571 	{
   556 	{
   572 	TRACE( T_LIT("CVIMPSTStorageServiceView::FindContactByUserId begin") );
   557 	TRACER_AUTO;
   573 	MVIMPSTStorageContact* contact = NULL;
   558 	MVIMPSTStorageContact* contact = NULL;
   574 	CVIMPSTStorageContactList* contactList = NULL;
   559 	CVIMPSTStorageContactList* contactList = NULL;
   575 	TInt count( iContactListArray.Count() );
   560 	TInt count( iContactListArray.Count() );
   576     for( TInt a( 0 ); a < count; ++a )
   561     for( TInt a( 0 ); a < count; ++a )
   577         {
   562         {
   578         contactList = iContactListArray[ a ];
   563         contactList = iContactListArray[ a ];
   579         contact = contactList->FindContact( aUserId );
   564         contact = contactList->FindContact( aUserId );
   580         if( contact )
   565         if( contact )
   581             {  
   566             {  
   582             TRACE( T_LIT("CVIMPSTStorageServiceView::FindContactByUserId contact found ") );          
   567             TRACE(" contact found " );          
   583             break;
   568             break;
   584             }
   569             }
   585         }
   570         }
   586     TRACE( T_LIT("CVIMPSTStorageServiceView::FindContactByUserId end") );
       
   587     return contact;
   571     return contact;
   588   	}
   572   	}
   589 // -----------------------------------------------------------------------------
   573 // -----------------------------------------------------------------------------
   590 // CVIMPSTStorageServiceView::FindContactByUserId
   574 // CVIMPSTStorageServiceView::FindContactByUserId
   591 // From MVIMPSTStorageServiceView.
   575 // From MVIMPSTStorageServiceView.
   592 // Try to load with given ID, return NULL if not found.
   576 // Try to load with given ID, return NULL if not found.
   593 // -----------------------------------------------------------------------------
   577 // -----------------------------------------------------------------------------
   594 MVIMPSTStorageContact* CVIMPSTStorageServiceView::FindCacheContactByUserId( const TDesC& aUserId )
   578 MVIMPSTStorageContact* CVIMPSTStorageServiceView::FindCacheContactByUserId( const TDesC& aUserId )
   595     {
   579     {
   596     TRACE( T_LIT("CVIMPSTStorageServiceView::FindCacheContactByUserId") );
   580 	TRACER_AUTO;
   597     return FindContactByUserId( aUserId );
   581     return FindContactByUserId( aUserId );
   598     }
   582     }
   599 
   583 
   600 // -----------------------------------------------------------------------------
   584 // -----------------------------------------------------------------------------
   601 // CVIMPSTStorageServiceView::FindCacheContactByLink
   585 // CVIMPSTStorageServiceView::FindCacheContactByLink
   602 // From MVIMPSTStorageServiceView.
   586 // From MVIMPSTStorageServiceView.
   603 // Try to load with given ID, return NULL if not found.
   587 // Try to load with given ID, return NULL if not found.
   604 // -----------------------------------------------------------------------------
   588 // -----------------------------------------------------------------------------
   605 MVIMPSTStorageContact* CVIMPSTStorageServiceView::FindCacheContactByLink(const MVPbkContactLink& aContactLink )
   589 MVIMPSTStorageContact* CVIMPSTStorageServiceView::FindCacheContactByLink(const MVPbkContactLink& aContactLink )
   606     {
   590     {
   607     TRACE( T_LIT("CVIMPSTStorageServiceView::FindCacheContactByLink ") );
   591 	TRACER_AUTO;
   608     return FindContactByLink( aContactLink );
   592     return FindContactByLink( aContactLink );
   609     }
   593     }
   610 // -----------------------------------------------------------------------------
   594 // -----------------------------------------------------------------------------
   611 // CVIMPSTStorageServiceView::CreateContactL
   595 // CVIMPSTStorageServiceView::CreateContactL
   612 // -----------------------------------------------------------------------------
   596 // -----------------------------------------------------------------------------
   614 MVIMPSTStorageContact* CVIMPSTStorageServiceView::CreateNewContactL(const TDesC& aUserId, 
   598 MVIMPSTStorageContact* CVIMPSTStorageServiceView::CreateNewContactL(const TDesC& aUserId, 
   615         										   	   	         	const TDesC& aDisplayName /*= KNullDesC*/,
   599         										   	   	         	const TDesC& aDisplayName /*= KNullDesC*/,
   616         										   	   	         	TBool aIsInvitationItem /*=EFalse*/,
   600         										   	   	         	TBool aIsInvitationItem /*=EFalse*/,
   617         										   	   	         	TBool aInvitationAutoAccept /*= EFalse */)
   601         										   	   	         	TBool aInvitationAutoAccept /*= EFalse */)
   618     {
   602     {
   619     TRACE( T_LIT("CVIMPSTStorageServiceView::CreateNewContactL begin") );
   603 	TRACER_AUTO;
   620     // This will create a contact in the CDB file.  It returns MVPbkContactLink link to the CDB file.
   604     // This will create a contact in the CDB file.  It returns MVPbkContactLink link to the CDB file.
   621     MVIMPSTStorageContact* contact = FindCacheContactByUserId( aUserId );
   605     MVIMPSTStorageContact* contact = FindCacheContactByUserId( aUserId );
   622     if( !contact )
   606     if( !contact )
   623 	    {
   607 	    {
   624 	    iIsInvitationItem = aIsInvitationItem;
   608 	    iIsInvitationItem = aIsInvitationItem;
   625 	    TRACE( T_LIT("CVIMPSTStorageServiceView::CreateNewContactL contact does not exist in list") );
   609 	    TRACE( "contact does not exist in list" );
   626 	    iVPbkContactStore->CreateVPbkContactL( aUserId ,aDisplayName, aInvitationAutoAccept );	
   610 	    iVPbkContactStore->CreateVPbkContactL( aUserId ,aDisplayName, aInvitationAutoAccept );	
   627 	    TRACE( T_LIT("CVIMPSTStorageServiceView::CreateNewContactL new contact created") );
   611 	    TRACE( "new contact created");
   628 	    }
   612 	    }
   629 	TRACE( T_LIT("CVIMPSTStorageServiceView::CreateNewContactL end") );
       
   630     return contact;
   613     return contact;
   631     }
   614     }
   632 
   615 
   633 // -----------------------------------------------------------------------------
   616 // -----------------------------------------------------------------------------
   634 // CVIMPSTStorageServiceView::CreateNewFetchContactsL
   617 // CVIMPSTStorageServiceView::CreateNewFetchContactsL
   635 // -----------------------------------------------------------------------------
   618 // -----------------------------------------------------------------------------
   636 //
   619 //
   637  void CVIMPSTStorageServiceView::CreateNewFetchContactsL( RArray <TPtrC> &aFirstNameList, 
   620  void CVIMPSTStorageServiceView::CreateNewFetchContactsL( RArray <TPtrC> &aFirstNameList, 
   638                                                          RArray <TPtrC> &aServiceField ) 
   621                                                          RArray <TPtrC> &aServiceField ) 
   639     {
   622     {
   640     TRACE( T_LIT("CVIMPSTStorageServiceView::CreateNewFetchContactsL begin") );
   623 	 TRACER_AUTO;
   641     if( !iVPbkContactStore->LocalStore() )
   624     if( !iVPbkContactStore->LocalStore() )
   642         {
   625         {
   643         RemoveAllCacheContactsL();
   626         RemoveAllCacheContactsL();
   644         }
   627         }
   645     iVPbkContactStore->AddVPbkFetchContactsL( aFirstNameList, aServiceField );
   628     iVPbkContactStore->AddVPbkFetchContactsL( aFirstNameList, aServiceField );
   646     TRACE( T_LIT("CVIMPSTStorageServiceView::CreateNewFetchContactsL end") );
       
   647     }
   629     }
   648  
   630  
   649 // -----------------------------------------------------------------------------
   631 // -----------------------------------------------------------------------------
   650 // CVIMPSTStorageServiceView::RemoveContactL
   632 // CVIMPSTStorageServiceView::RemoveContactL
   651 // From MVIMPSTStorageServiceView.
   633 // From MVIMPSTStorageServiceView.
   652 // Try to load with given ID, return NULL if not found.
   634 // Try to load with given ID, return NULL if not found.
   653 // -----------------------------------------------------------------------------
   635 // -----------------------------------------------------------------------------
   654 
   636 
   655 TInt CVIMPSTStorageServiceView::RemoveContactL( MVIMPSTStorageContact* aContact ) 
   637 TInt CVIMPSTStorageServiceView::RemoveContactL( MVIMPSTStorageContact* aContact ) 
   656 	{
   638 	{
   657 	TRACE( T_LIT("CVIMPSTStorageServiceView::RemoveContactL begin") );
   639 	TRACER_AUTO;
   658 	TInt error = KErrArgument;
   640 	TInt error = KErrArgument;
   659 	if( aContact )
   641 	if( aContact )
   660 		{
   642 		{
   661 		TRACE( T_LIT("CVIMPSTStorageServiceView::RemoveContactL contact found") );
   643 		TRACE( "contact found" );
   662 		error = iVPbkContactStore->RemoveVPbkContactL( *aContact->ContactLink() );
   644 		error = iVPbkContactStore->RemoveVPbkContactL( *aContact->ContactLink() );
   663 		}
   645 		}
   664 	TRACE( T_LIT("CVIMPSTStorageServiceView::RemoveContactL end") );
       
   665 	return error;	
   646 	return error;	
   666 	}
   647 	}
   667 
   648 
   668 
   649 
   669  // -----------------------------------------------------------------------------
   650  // -----------------------------------------------------------------------------
   670 // CVIMPSTStorageServiceView::RetriveLinkXSPIdsL
   651 // CVIMPSTStorageServiceView::RetriveLinkXSPIdsL
   671 // -----------------------------------------------------------------------------
   652 // -----------------------------------------------------------------------------
   672 //
   653 //
   673 TInt CVIMPSTStorageServiceView::RetriveLinkXSPIdsL(const TDesC8& aContactPackLink )
   654 TInt CVIMPSTStorageServiceView::RetriveLinkXSPIdsL(const TDesC8& aContactPackLink )
   674     {
   655     {
   675     TRACE( T_LIT("CVIMPSTStorageServiceView::RetriveLinkXSPIdsL") );
   656 	TRACER_AUTO;
   676     // return the no of retrived xsp of contacts 
   657     // return the no of retrived xsp of contacts 
   677     return iVPbkContactStore->RetrieveVPbkXSPIdL( aContactPackLink );
   658     return iVPbkContactStore->RetrieveVPbkXSPIdL( aContactPackLink );
   678     }
   659     }
   679  
   660  
   680  // ---------------------------------------------------------------------------
   661  // ---------------------------------------------------------------------------
   681 // CVIMPSTStorageServiceView::GetRetrieveXSPIdL
   662 // CVIMPSTStorageServiceView::GetRetrieveXSPIdL
   682 // ---------------------------------------------------------------------------
   663 // ---------------------------------------------------------------------------
   683 //  
   664 //  
   684 const TDesC& CVIMPSTStorageServiceView::GetRetrieveXSPIdL(TInt aIndex ) 
   665 const TDesC& CVIMPSTStorageServiceView::GetRetrieveXSPIdL(TInt aIndex ) 
   685 	{
   666 	{
   686 	TRACE( T_LIT("CVIMPSTStorageServiceView::GetRetrieveXSPIdL aIndex = %d"),aIndex  );
   667 	TRACER_AUTO;
       
   668 	TRACE( " aIndex = %d",aIndex  );
   687 	return iVPbkContactStore->GetRetrieveVPbkXSPIdL( aIndex );
   669 	return iVPbkContactStore->GetRetrieveVPbkXSPIdL( aIndex );
   688     }
   670     }
   689 
   671 
   690 // -----------------------------------------------------------------------------
   672 // -----------------------------------------------------------------------------
   691 // CVIMPSTStorageServiceView::CreateNewContactFromRetrivedIdL
   673 // CVIMPSTStorageServiceView::CreateNewContactFromRetrivedIdL
   692 // -----------------------------------------------------------------------------
   674 // -----------------------------------------------------------------------------
   693 //
   675 //
   694 TInt CVIMPSTStorageServiceView::CreateNewContactFromRetrivedIdL( TInt aIndexToUse )
   676 TInt CVIMPSTStorageServiceView::CreateNewContactFromRetrivedIdL( TInt aIndexToUse )
   695     {
   677     {
   696     TRACE( T_LIT("CVIMPSTStorageServiceView::CreateNewContactFromRetrivedIdL aIndexToUse = %d"),aIndexToUse  );
   678 	TRACER_AUTO;
       
   679     TRACE( "aIndexToUse = %d",aIndexToUse  );
   697     // This will create a contact in the CDB file.  It returns MVPbkContactLink link to the CDB file.
   680     // This will create a contact in the CDB file.  It returns MVPbkContactLink link to the CDB file.
   698     return iVPbkContactStore->CreateRetriveVPbkContactL( aIndexToUse );    
   681     return iVPbkContactStore->CreateRetriveVPbkContactL( aIndexToUse );    
   699     }
   682     }
   700 // -----------------------------------------------------------------------------
   683 // -----------------------------------------------------------------------------
   701 // CVIMPSTStorageServiceView::DeleteNewContactFromRetrivedIdL
   684 // CVIMPSTStorageServiceView::DeleteNewContactFromRetrivedIdL
   702 // -----------------------------------------------------------------------------
   685 // -----------------------------------------------------------------------------
   703 //
   686 //
   704 TInt CVIMPSTStorageServiceView::DeleteNewContactFromRetrivedIdL( TInt aIndexToUse )
   687 TInt CVIMPSTStorageServiceView::DeleteNewContactFromRetrivedIdL( TInt aIndexToUse )
   705     {
   688     {
   706     TRACE( T_LIT("CVIMPSTStorageServiceView::DeleteNewContactFromRetrivedIdL aIndexToUse = %d"),aIndexToUse  );
   689 	TRACER_AUTO;
       
   690     TRACE( "aIndexToUse = %d",aIndexToUse  );
   707     // This will create a contact in the CDB file.  It returns MVPbkContactLink link to the CDB file.
   691     // This will create a contact in the CDB file.  It returns MVPbkContactLink link to the CDB file.
   708     return iVPbkContactStore->deleteRetriveVPbkContactL( aIndexToUse );    
   692     return iVPbkContactStore->deleteRetriveVPbkContactL( aIndexToUse );    
   709     }
   693     }
   710 
   694 
   711  // ----------------------------------------------------------
   695  // ----------------------------------------------------------
   712 // CVIMPSTStorageServiceView::DeleteDatabaseL
   696 // CVIMPSTStorageServiceView::DeleteDatabaseL
   713 // ----------------------------------------------------------
   697 // ----------------------------------------------------------
   714 void CVIMPSTStorageServiceView::DeleteDatabaseL()
   698 void CVIMPSTStorageServiceView::DeleteDatabaseL()
   715     {
   699     {
   716     TRACE( T_LIT("CVIMPSTStorageServiceView::DeleteDatabaseL") );
   700 	TRACER_AUTO;
   717    	iVPbkContactStore->DeleteDatabaseL();
   701    	iVPbkContactStore->DeleteDatabaseL();
   718     }
   702     }
   719  
   703  
   720 //================================================== from writer interface=======================
   704 //================================================== from writer interface=======================
   721  // -----------------------------------------------------------------------------
   705  // -----------------------------------------------------------------------------
   725 MVIMPSTStorageContact* CVIMPSTStorageServiceView::UpdateCacheContactL(const MVPbkContactLink& aContactLink,
   709 MVIMPSTStorageContact* CVIMPSTStorageServiceView::UpdateCacheContactL(const MVPbkContactLink& aContactLink,
   726 																 const TDesC& aUserId, 
   710 																 const TDesC& aUserId, 
   727         										   	   	         const TDesC& aDisplayName,
   711         										   	   	         const TDesC& aDisplayName,
   728         										   	   	         const TDesC8& aAvatarContent)
   712         										   	   	         const TDesC8& aAvatarContent)
   729     {
   713     {
   730     TRACE( T_LIT("CVIMPSTStorageServiceView::UpdateCacheContactL begin") );
   714 	TRACER_AUTO;
   731     MVIMPSTStorageContact* contact = FindContactByLink(aContactLink);
   715     MVIMPSTStorageContact* contact = FindContactByLink(aContactLink);
   732     if( contact )
   716     if( contact )
   733 	    {
   717 	    {
   734 	    TInt oldIndex = IndexOfContact( contact );
   718 	    TInt oldIndex = IndexOfContact( contact );
   735 	    TBool sortNeeded = EFalse;
   719 	    TBool sortNeeded = EFalse;
   736 	    if( contact->UserId().Compare( aUserId) != 0 )
   720 	    if( contact->UserId().Compare( aUserId) != 0 )
   737 	        {
   721 	        {
   738 	        TRACE( T_LIT("CVIMPSTStorageServiceView::UpdateCacheContactL user id changed") );	        
   722 	        TRACE( "user id changed" );	        
   739 	        NotifyAllObserversL( TVIMPSTEnums::EStorageEventUserIdPreChange,NULL, contact,oldIndex);
   723 	        NotifyAllObserversL( TVIMPSTEnums::EStorageEventUserIdPreChange,NULL, contact,oldIndex);
   740 	        contact->SetUserIdL( aUserId );
   724 	        contact->SetUserIdL( aUserId );
   741 	        if(aUserId.Length()== 0)
   725 	        if(aUserId.Length()== 0)
   742                {
   726                {
   743                 sortNeeded = ETrue;
   727                 sortNeeded = ETrue;
   744                contact->SetOnlineStatus(TVIMPSTEnums::EUnknown);
   728                contact->SetOnlineStatus(TVIMPSTEnums::EUnknown);
   745                }
   729                }
   746 	        NotifyAllObserversL( TVIMPSTEnums::EStorageEventUserIdPostChange,NULL, contact,oldIndex);
   730 	        NotifyAllObserversL( TVIMPSTEnums::EStorageEventUserIdPostChange,NULL, contact,oldIndex);
   747 	        TRACE( T_LIT("CVIMPSTStorageServiceView::UpdateCacheContactL NotifyAllObserversL delivered") );
   731 	        TRACE( "NotifyAllObserversL delivered" );
   748 	        }
   732 	        }
   749 	    if(contact->Name().Compare(aDisplayName) != 0 )
   733 	    if(contact->Name().Compare(aDisplayName) != 0 )
   750 	        {
   734 	        {
   751             sortNeeded = ETrue;
   735             sortNeeded = ETrue;
   752 	        TRACE( T_LIT("CVIMPSTStorageServiceView::UpdateCacheContactL display name changed") );
   736 	        TRACE( "display name changed" );
   753 	        if( aDisplayName.Length() <= 0 && iUnNamedText )
   737 	        if( aDisplayName.Length() <= 0 && iUnNamedText )
   754 				{
   738 				{
   755 				contact->SetNameL( *iUnNamedText );	
   739 				contact->SetNameL( *iUnNamedText );	
   756 				}
   740 				}
   757 			else
   741 			else
   777 		        }
   761 		        }
   778 	   NotifyAllObserversL( TVIMPSTEnums::EStorageEventContactChange,NULL,contact, oldIndex );
   762 	   NotifyAllObserversL( TVIMPSTEnums::EStorageEventContactChange,NULL,contact, oldIndex );
   779 	        }
   763 	        }
   780 	   if( contact->AvatarContent().Compare( aAvatarContent ) != 0 )
   764 	   if( contact->AvatarContent().Compare( aAvatarContent ) != 0 )
   781 	        {
   765 	        {
   782 	        TRACE( T_LIT("CVIMPSTStorageServiceView::UpdateCacheContactL user id changed") );           
   766 	        TRACE( "User id changed" );           
   783 	        contact->SetAvatarContentL( aAvatarContent,*iVPbkContactStore  );
   767 	        contact->SetAvatarContentL( aAvatarContent,*iVPbkContactStore  );
   784 	        NotifyAllObserversL( TVIMPSTEnums::EStorageAvatarChange,NULL, contact, KErrNotFound);
   768 	        NotifyAllObserversL( TVIMPSTEnums::EStorageAvatarChange,NULL, contact, KErrNotFound);
   785 	        TRACE( T_LIT("CVIMPSTStorageServiceView::UpdateCacheContactL NotifyAllObserversL delivered") );
   769 	        TRACE( " NotifyAllObserversL delivered" );
   786 	        }
   770 	        }
   787 	    }
   771 	    }
   788 	TRACE( T_LIT("CVIMPSTStorageServiceView::UpdateCacheContactL end") );
       
   789     return contact;
   772     return contact;
   790     }
   773     }
   791 // -----------------------------------------------------------------------------
   774 // -----------------------------------------------------------------------------
   792 // CVIMPSTStorageServiceView::AddContactToCacheL
   775 // CVIMPSTStorageServiceView::AddContactToCacheL
   793 // -----------------------------------------------------------------------------
   776 // -----------------------------------------------------------------------------
   795 																 const TDesC& aUserId, 
   778 																 const TDesC& aUserId, 
   796         										   	   	         const TDesC& aDisplayName,
   779         										   	   	         const TDesC& aDisplayName,
   797         										   	   	         const TDesC8& aAvatarContent,
   780         										   	   	         const TDesC8& aAvatarContent,
   798         										   	   	         TVIMPSTEnums::TVIMPSTStorgaeEventType aType )
   781         										   	   	         TVIMPSTEnums::TVIMPSTStorgaeEventType aType )
   799 	{
   782 	{
   800 	TRACE( T_LIT("CVIMPSTStorageServiceView::AddContactToCacheL begin") );
   783 	TRACER_AUTO;
   801 	TRACE( T_LIT("CVIMPSTStorageServiceView::AddContactToCacheL user id: %S"), &aUserId);
   784 	TRACE(" user id: %S", &aUserId);
   802 	TRACE( T_LIT("CVIMPSTStorageServiceView::AddContactToCacheL storageeventtype: %d"), aType );
   785 	TRACE( " storageeventtype: %d", aType );
   803 	MVIMPSTStorageContactList* contactList = FindContactListInternal( KFriendList );
   786 	MVIMPSTStorageContactList* contactList = FindContactListInternal( KFriendList );
   804 	if( !contactList )
   787 	if( !contactList )
   805 		{
   788 		{
   806 		contactList = CreateContactListL(KFriendList,KNullDesC); 
   789 		contactList = CreateContactListL(KFriendList,KNullDesC); 
   807 		}
   790 		}
   808 	TRACE( T_LIT("CVIMPSTStorageServiceView::AddContactToCacheL before findcontactlink") ); 
   791 	TRACE(" Before findcontactlink" ); 
   809 	MVIMPSTStorageContact* contact = FindContactByLink(aContactLink);
   792 	MVIMPSTStorageContact* contact = FindContactByLink(aContactLink);
   810 	TRACE( T_LIT("CVIMPSTStorageServiceView::AddContactToCacheL after findcontactlink ") ); 
   793 	TRACE( " After findcontactlink " ); 
   811 	if( !contact )
   794 	if( !contact )
   812 		{
   795 		{
   813 		TRACE( T_LIT("CVIMPSTStorageServiceView::AddContactToCacheL contact not exist ") ); 
   796 		TRACE( " contact not exist "); 
   814 		TInt error = KErrGeneral;
   797 		TInt error = KErrGeneral;
   815 		TInt index = KErrNotFound;
   798 		TInt index = KErrNotFound;
   816 		if( aDisplayName.Length() <= 0 && iUnNamedText )
   799 		if( aDisplayName.Length() <= 0 && iUnNamedText )
   817 			{
   800 			{
   818 			TRACE( T_LIT("CVIMPSTStorageServiceView::AddContactToCacheL no display name ") ); 
   801 			TRACE(" no display name " ); 
   819 			contact = CVIMPSTStorageContact::NewLC( aUserId, *iUnNamedText , aContactLink ,aAvatarContent );	
   802 			contact = CVIMPSTStorageContact::NewLC( aUserId, *iUnNamedText , aContactLink ,aAvatarContent );	
   820 			}
   803 			}
   821 		else
   804 		else
   822 			{
   805 			{
   823 			TRACE( T_LIT("CVIMPSTStorageServiceView::AddContactToCacheL has display name ") ); 
   806 			TRACE( " has display name " ); 
   824 			contact = CVIMPSTStorageContact::NewLC( aUserId, aDisplayName , aContactLink, aAvatarContent);		
   807 			contact = CVIMPSTStorageContact::NewLC( aUserId, aDisplayName , aContactLink, aAvatarContent);		
   825 			}
   808 			}
   826 		// if the xsp id is numm, then the presence state should be EUnknown;
   809 		// if the xsp id is numm, then the presence state should be EUnknown;
   827 		if(0 == aUserId.Length())
   810 		if(0 == aUserId.Length())
   828 		    {
   811 		    {
   834 	        // if user has choosen add contact set the default status as pending
   817 	        // if user has choosen add contact set the default status as pending
   835 	        // to avoid any kind of flickering
   818 	        // to avoid any kind of flickering
   836 	        contact->SetOnlineStatus(TVIMPSTEnums::EPending);
   819 	        contact->SetOnlineStatus(TVIMPSTEnums::EPending);
   837 	        }
   820 	        }
   838 		error = contactList->AddStorageContactToCacheL( contact, index );
   821 		error = contactList->AddStorageContactToCacheL( contact, index );
   839 		TRACE( T_LIT("CVIMPSTStorageServiceView::AddContactToCacheL AddStorageContactToCacheL error= %d "),error ); 
   822 		TRACE( "AddStorageContactToCacheL error= %d ",error ); 
   840 		if( error == KErrNone )
   823 		if( error == KErrNone )
   841 			{
   824 			{
   842 			TRACE( T_LIT("CVIMPSTStorageServiceView::AddContactToCacheL success ") );
   825 			TRACE( "success " );
   843 			CleanupStack::Pop(); // contact
   826 			CleanupStack::Pop(); // contact
   844 			TInt count = iContactListArray.Count();
   827 			TInt count = iContactListArray.Count();
   845 			for(TInt i = 0; i < count; i++)
   828 			for(TInt i = 0; i < count; i++)
   846 				{
   829 				{
   847 				index = iContactListArray[i]->FindIndexOfContact(contact);
   830 				index = iContactListArray[i]->FindIndexOfContact(contact);
   848 				if(KErrNotFound != index )
   831 				if(KErrNotFound != index )
   849 				    {
   832 				    {
   850 				    iContactListArray[i]->ResortContact(contact);
   833 				    iContactListArray[i]->ResortContact(contact);
   851 				    TRACE( T_LIT("CVIMPSTStorageServiceView::AddContactToCacheL() contact ResortContact ") );
   834 				    TRACE( " contact ResortContact " );
   852 				    // get the index of the sorted contact, as after sorting the 
   835 				    // get the index of the sorted contact, as after sorting the 
   853 				    // index would have changed based on presence.
   836 				    // index would have changed based on presence.
   854 				    // break after the contact list is found and the contact is found
   837 				    // break after the contact list is found and the contact is found
   855 				    break;
   838 				    break;
   856 				    }
   839 				    }
   858 			index = IndexOfContact(contact);
   841 			index = IndexOfContact(contact);
   859 		  	NotifyAllObserversL( aType,NULL, contact, index );	
   842 		  	NotifyAllObserversL( aType,NULL, contact, index );	
   860 			}
   843 			}
   861 		else
   844 		else
   862 			{
   845 			{
   863 			TRACE( T_LIT("CVIMPSTStorageServiceView::AddContactToCacheL not success ") );
   846 			TRACE( " not success " );
   864 			CleanupStack::PopAndDestroy(); // contact	
   847 			CleanupStack::PopAndDestroy(); // contact	
   865 			contact = NULL;
   848 			contact = NULL;
   866 			}
   849 			}
   867 		}
   850 		}
   868 	iIsInvitationItem = EFalse; // reset the flag 
   851 	iIsInvitationItem = EFalse; // reset the flag 
   869 	TRACE( T_LIT("CVIMPSTStorageServiceView::AddContactToCacheL end") );
       
   870 	return contact;
   852 	return contact;
   871 	}
   853 	}
   872 // -----------------------------------------------------------------------------
   854 // -----------------------------------------------------------------------------
   873 // CVIMPSTStorageServiceView::AddStorageContactToCacheL
   855 // CVIMPSTStorageServiceView::AddStorageContactToCacheL
   874 // -----------------------------------------------------------------------------
   856 // -----------------------------------------------------------------------------
   875 //
   857 //
   876 TInt CVIMPSTStorageServiceView::AddStorageContactToCacheL(MVIMPSTStorageContact* aContactToAdd ) 
   858 TInt CVIMPSTStorageServiceView::AddStorageContactToCacheL(MVIMPSTStorageContact* aContactToAdd ) 
   877 	{
   859 	{
   878 	TRACE( T_LIT("CVIMPSTStorageServiceView::AddStorageContactToCacheL begin") );
   860 	TRACER_AUTO;
   879 	TInt error = KErrGeneral;
   861 	TInt error = KErrGeneral;
   880     MVIMPSTStorageContactList* contactList = FindContactListInternal( KFriendList );
   862     MVIMPSTStorageContactList* contactList = FindContactListInternal( KFriendList );
   881     if( !contactList )
   863     if( !contactList )
   882         {        
   864         {        
   883         contactList = CreateContactListL(KFriendList,KNullDesC); // create the default list :TODO chnage to proper sol
   865         contactList = CreateContactListL(KFriendList,KNullDesC); // create the default list :TODO chnage to proper sol
   887 		if( aContactToAdd->Name().Length() <= 0 && iUnNamedText )
   869 		if( aContactToAdd->Name().Length() <= 0 && iUnNamedText )
   888 			{
   870 			{
   889 			aContactToAdd->SetNameL( *iUnNamedText );	
   871 			aContactToAdd->SetNameL( *iUnNamedText );	
   890 			}
   872 			}
   891 		TInt index = KErrNotFound;
   873 		TInt index = KErrNotFound;
   892         TRACE( T_LIT("CVIMPSTStorageServiceView::AddStorageContactToCacheL online status = %d "), TVIMPSTEnums::EPending);
   874         TRACE( " online status = %d ", TVIMPSTEnums::EPending);
   893         // if the userid(xsp field is null then the presence is unknown.)
   875         // if the userid(xsp field is null then the presence is unknown.)
   894         if(aContactToAdd->UserId().Length() == 0)
   876         if(aContactToAdd->UserId().Length() == 0)
   895             {
   877             {
   896             aContactToAdd->SetOnlineStatus(TVIMPSTEnums::EUnknown); 
   878             aContactToAdd->SetOnlineStatus(TVIMPSTEnums::EUnknown); 
   897             }
   879             }
   898         else
   880         else
   899             {
   881             {
   900             aContactToAdd->SetOnlineStatus(TVIMPSTEnums::EPending);    
   882             aContactToAdd->SetOnlineStatus(TVIMPSTEnums::EPending);    
   901             }
   883             }
   902 		error = contactList->AddStorageContactToCacheL( aContactToAdd, index ); // aContactToAdd ownership is transfered
   884 		error = contactList->AddStorageContactToCacheL( aContactToAdd, index ); // aContactToAdd ownership is transfered
   903 		TRACE( T_LIT("CVIMPSTStorageServiceView::AddStorageContactToCacheL index = %d "),index );
   885 		TRACE( "index = %d ",index );
   904 		if( error == KErrNone )
   886 		if( error == KErrNone )
   905 			{
   887 			{
   906 			TInt count = iContactListArray.Count();
   888 			TInt count = iContactListArray.Count();
   907 			for(TInt i = 0; i < count; i++)
   889 			for(TInt i = 0; i < count; i++)
   908 				{
   890 				{
   909 				index = iContactListArray[i]->FindIndexOfContact(aContactToAdd);
   891 				index = iContactListArray[i]->FindIndexOfContact(aContactToAdd);
   910 				if(KErrNotFound != index )
   892 				if(KErrNotFound != index )
   911 					{
   893 					{
   912 					iContactListArray[i]->ResortContact(aContactToAdd);
   894 					iContactListArray[i]->ResortContact(aContactToAdd);
   913 					TRACE( T_LIT("CVIMPSTStorageServiceView::AddContactToCacheL() contact ResortContact ") );
   895 					TRACE( "contact ResortContact " );
   914 					// get the index of the sorted contact, as after sorting the 
   896 					// get the index of the sorted contact, as after sorting the 
   915 					// index would have changed based on presence.
   897 					// index would have changed based on presence.
   916 					// break after the contact list is found and the contact is found
   898 					// break after the contact list is found and the contact is found
   917 					break;
   899 					break;
   918 					}
   900 					}
   919 				}
   901 				}
   920 			index = IndexOfContact(aContactToAdd);
   902 			index = IndexOfContact(aContactToAdd);
   921 			NotifyAllObserversL( TVIMPSTEnums::EStorageEventContactAddition,NULL, aContactToAdd, index );	
   903 			NotifyAllObserversL( TVIMPSTEnums::EStorageEventContactAddition,NULL, aContactToAdd, index );	
   922 			}
   904 			}
   923 		}
   905 		}
   924 	TRACE( T_LIT("CVIMPSTStorageServiceView::AddStorageContactToCacheL error = %d "),error );
   906 	TRACE( " error = %d ",error );
   925 	TRACE( T_LIT("CVIMPSTStorageServiceView::AddStorageContactToCacheL end") );
       
   926 	return error;
   907 	return error;
   927     }
   908     }
   928 // -----------------------------------------------------------------------------
   909 // -----------------------------------------------------------------------------
   929 // CVIMPSTStorageServiceView::RemoveContactFromCacheL
   910 // CVIMPSTStorageServiceView::RemoveContactFromCacheL
   930 // From MVIMPSTStorageServiceView.
   911 // From MVIMPSTStorageServiceView.
   932 // -----------------------------------------------------------------------------
   913 // -----------------------------------------------------------------------------
   933 
   914 
   934 TInt CVIMPSTStorageServiceView::RemoveContactFromCacheL(const MVPbkContactLink& aContactLink,
   915 TInt CVIMPSTStorageServiceView::RemoveContactFromCacheL(const MVPbkContactLink& aContactLink,
   935 														 TVIMPSTEnums::TVIMPSTStorgaeEventType aType) 
   916 														 TVIMPSTEnums::TVIMPSTStorgaeEventType aType) 
   936 	{
   917 	{
   937 	TRACE( T_LIT("CVIMPSTStorageServiceView::RemoveContactFromCacheL begin") );
   918 	TRACER_AUTO;
   938 	TInt error = KErrNotFound;
   919 	TInt error = KErrNotFound;
   939 	MVIMPSTStorageContactList* contactList = FindContactListInternal( KFriendList );
   920 	MVIMPSTStorageContactList* contactList = FindContactListInternal( KFriendList );
   940     if( !contactList )
   921     if( !contactList )
   941         {        
   922         {        
   942         contactList = CreateContactListL( KFriendList,KNullDesC ); // create the default list :TODO chnage to proper sol
   923         contactList = CreateContactListL( KFriendList,KNullDesC ); // create the default list :TODO chnage to proper sol
   954 			}
   935 			}
   955 		TInt index = 0;
   936 		TInt index = 0;
   956 	    error = contactList->RemoveContactFromCacheL( aContactLink, index );
   937 	    error = contactList->RemoveContactFromCacheL( aContactLink, index );
   957 	    NotifyAllObserversL( TVIMPSTEnums::EStorageEventContactDelete ,NULL,NULL,index); //contact is not valid ,deleted
   938 	    NotifyAllObserversL( TVIMPSTEnums::EStorageEventContactDelete ,NULL,NULL,index); //contact is not valid ,deleted
   958 		}
   939 		}
   959 	TRACE( T_LIT("CVIMPSTStorageServiceView::RemoveContactFromCacheL error = %d "),error );
   940 	TRACE("error = %d ",error );
   960 	TRACE( T_LIT("CVIMPSTStorageServiceView::RemoveContactFromCacheL begin") );
       
   961     return error;
   941     return error;
   962 	}
   942 	}
   963 // -----------------------------------------------------------------------------
   943 // -----------------------------------------------------------------------------
   964 // CVIMPSTStorageServiceView::RemoveAllCacheContactsL
   944 // CVIMPSTStorageServiceView::RemoveAllCacheContactsL
   965 // -----------------------------------------------------------------------------
   945 // -----------------------------------------------------------------------------
   966 //
   946 //
   967 void CVIMPSTStorageServiceView::RemoveAllCacheContactsL()
   947 void CVIMPSTStorageServiceView::RemoveAllCacheContactsL()
   968     {
   948     {
   969     TRACE( T_LIT("CVIMPSTStorageServiceView::RemoveContactFromCacheL begin") );
   949 	TRACER_AUTO;
   970     TRACE( T_LIT("CVIMPSTStorageServiceView::RemoveContactFromCacheL  count = %d"), iContactListArray.Count());
   950     TRACE( "  count = %d", iContactListArray.Count());
   971     iContactListArray.ResetAndDestroy();
   951     iContactListArray.ResetAndDestroy();
   972     TRACE( T_LIT("CVIMPSTStorageServiceView::RemoveContactFromCacheL remove sucess") );
   952     TRACE( " remove sucess" );
   973     NotifyAllObserversL(TVIMPSTEnums::EStorageAllContactRemoved,NULL,NULL,0 );
   953     NotifyAllObserversL(TVIMPSTEnums::EStorageAllContactRemoved,NULL,NULL,0 );
   974     TRACE( T_LIT("CVIMPSTStorageServiceView::RemoveContactFromCacheL begin") );
       
   975     }
   954     }
   976  
   955  
   977 // -----------------------------------------------------------------------------
   956 // -----------------------------------------------------------------------------
   978 // CVIMPSTStorageServiceView::GetDefaultContactListL
   957 // CVIMPSTStorageServiceView::GetDefaultContactListL
   979 // -----------------------------------------------------------------------------
   958 // -----------------------------------------------------------------------------
   980 //
   959 //
   981 MVIMPSTStorageContactList* CVIMPSTStorageServiceView::GetDefaultContactListL()
   960 MVIMPSTStorageContactList* CVIMPSTStorageServiceView::GetDefaultContactListL()
   982     {
   961     {
   983     TRACE( T_LIT("CVIMPSTStorageServiceView::GetDefaultContactListL begin") );
   962 	TRACER_AUTO;
   984     MVIMPSTStorageContactList* contactList = FindContactListInternal( KFriendList );
   963     MVIMPSTStorageContactList* contactList = FindContactListInternal( KFriendList );
   985     TRACE( T_LIT("CVIMPSTStorageServiceView::GetDefaultContactListL end") );
       
   986     return contactList;
   964     return contactList;
   987     }
   965     }
   988 // -----------------------------------------------------------------------------
   966 // -----------------------------------------------------------------------------
   989 // CVIMPSTStorageServiceView::NotifyServiceViewL
   967 // CVIMPSTStorageServiceView::NotifyServiceViewL
   990 // -----------------------------------------------------------------------------
   968 // -----------------------------------------------------------------------------
   991 //
   969 //
   992 void CVIMPSTStorageServiceView::NotifyServiceViewL( TVIMPSTEnums::TVIMPSTStorgaeEventType aEventType,
   970 void CVIMPSTStorageServiceView::NotifyServiceViewL( TVIMPSTEnums::TVIMPSTStorgaeEventType aEventType,
   993 													MVIMPSTStorageContact* aContact /*= NULL */ )
   971 													MVIMPSTStorageContact* aContact /*= NULL */ )
   994     {
   972     {
   995     TRACE( T_LIT("CVIMPSTStorageServiceView::NotifyServiceViewL begin") );
   973 	TRACER_AUTO;
   996     NotifyAllObserversL(aEventType,NULL, aContact,0 ); 
   974     NotifyAllObserversL(aEventType,NULL, aContact,0 ); 
   997     TRACE( T_LIT("CVIMPSTStorageServiceView::NotifyServiceViewL end") );
       
   998     }
   975     }
   999  
   976  
  1000  //================================================== from writer interface end ===========================
   977  //================================================== from writer interface end ===========================
  1001 // TLinearOrder
   978 // TLinearOrder
  1002 // -----------------------------------------------------------------------------
   979 // -----------------------------------------------------------------------------
  1005 //
   982 //
  1006 TInt CVIMPSTStorageServiceView::ContactListOrderByDisplayName(
   983 TInt CVIMPSTStorageServiceView::ContactListOrderByDisplayName(
  1007                                        const CVIMPSTStorageContactList& aContactListA, 
   984                                        const CVIMPSTStorageContactList& aContactListA, 
  1008                                        const CVIMPSTStorageContactList& aContactListB )
   985                                        const CVIMPSTStorageContactList& aContactListB )
  1009     {
   986     {
  1010     TRACE( T_LIT("CVIMPSTStorageServiceView::ContactListOrderByDisplayName") );
   987 	TRACER_AUTO;
  1011     return aContactListA.DisplayName().CompareC( aContactListB.DisplayName() );
   988     return aContactListA.DisplayName().CompareC( aContactListB.DisplayName() );
  1012     }
   989     }
  1013 
   990 
  1014 // TIdentityRelation
   991 // TIdentityRelation
  1015 // -----------------------------------------------------------------------------
   992 // -----------------------------------------------------------------------------
  1018 //
   995 //
  1019 TBool CVIMPSTStorageServiceView::ContactListFindByContactListId( 
   996 TBool CVIMPSTStorageServiceView::ContactListFindByContactListId( 
  1020                                        const CVIMPSTStorageContactList& aContactListA, 
   997                                        const CVIMPSTStorageContactList& aContactListA, 
  1021                                        const CVIMPSTStorageContactList& aContactListB )
   998                                        const CVIMPSTStorageContactList& aContactListB )
  1022     {
   999     {
  1023     TRACE( T_LIT("CVIMPSTStorageServiceView::ContactListFindByContactListId start") );
  1000 	TRACER_AUTO;
  1024     const MVIMPSTStorageContactList& listA = aContactListA;
  1001     const MVIMPSTStorageContactList& listA = aContactListA;
  1025     const MVIMPSTStorageContactList& listB = aContactListB;
  1002     const MVIMPSTStorageContactList& listB = aContactListB;
  1026     TRACE( T_LIT("CVIMPSTStorageServiceView::ContactListFindByContactListId return") );
  1003    TRACE(" return" );
  1027     return ( VIMPSTStorageUtils::NeutralCompare( listA.ListId(), 
  1004     return ( VIMPSTStorageUtils::NeutralCompare( listA.ListId(), 
  1028                                       listB.ListId(), EFalse ) == 0 );
  1005                                       listB.ListId(), EFalse ) == 0 );
  1029     }
  1006     }
  1030 // -----------------------------------------------------------------------------
  1007 // -----------------------------------------------------------------------------
  1031 // CVIMPSTStorageServiceView::Count
  1008 // CVIMPSTStorageServiceView::Count
  1033 // (other items were commented in a header).
  1010 // (other items were commented in a header).
  1034 // -----------------------------------------------------------------------------
  1011 // -----------------------------------------------------------------------------
  1035 //
  1012 //
  1036 TInt CVIMPSTStorageServiceView::Count() const
  1013 TInt CVIMPSTStorageServiceView::Count() const
  1037 	{
  1014 	{
  1038 	TRACE( T_LIT("CVIMPSTStorageServiceView::Count start") );
  1015 	TRACER_AUTO;
  1039 	// fetch contact list count from storage
  1016 	// fetch contact list count from storage
  1040 	// and add contact counts from expanded contact lists
  1017 	// and add contact counts from expanded contact lists
  1041 	TInt listCount( ListCount() );
  1018 	TInt listCount( ListCount() );
  1042 	TInt itemCount( 0 );
  1019 	TInt itemCount( 0 );
  1043 	TInt contactCount = 0;
  1020 	TInt contactCount = 0;
  1052 			// in this list to item count
  1029 			// in this list to item count
  1053 			itemCount += contactCount;
  1030 			itemCount += contactCount;
  1054 		   //check for this
  1031 		   //check for this
  1055 			}
  1032 			}
  1056 	    }
  1033 	    }
  1057 	TRACE( T_LIT("CVIMPSTStorageServiceView::itemCount =%d"),itemCount );
  1034 	TRACE( "itemCount =%d",itemCount );
  1058 	TRACE( T_LIT("CVIMPSTStorageServiceView::Count end") );
       
  1059    	return itemCount;
  1035    	return itemCount;
  1060 	}
  1036 	}
  1061 
  1037 
  1062 // -----------------------------------------------------------------------------
  1038 // -----------------------------------------------------------------------------
  1063 // CVIMPSTStorageServiceView::Item
  1039 // CVIMPSTStorageServiceView::Item
  1065 // (other items were commented in a header).
  1041 // (other items were commented in a header).
  1066 // -----------------------------------------------------------------------------
  1042 // -----------------------------------------------------------------------------
  1067 //
  1043 //
  1068 MVIMPSTStorageItemModel::SItem CVIMPSTStorageServiceView::Item( TInt aIndex  ) const
  1044 MVIMPSTStorageItemModel::SItem CVIMPSTStorageServiceView::Item( TInt aIndex  ) const
  1069     {
  1045     {
  1070     TRACE( T_LIT("CVIMPSTStorageServiceView::Item start") );
  1046 	TRACER_AUTO;
  1071     MVIMPSTStorageItemModel::SItem item;
  1047     MVIMPSTStorageItemModel::SItem item;
  1072     item.iType = MVIMPSTStorageItemModel::EInvalid;
  1048     item.iType = MVIMPSTStorageItemModel::EInvalid;
  1073     item.iContactList = NULL;
  1049     item.iContactList = NULL;
  1074     item.iContact = NULL;
  1050     item.iContact = NULL;
  1075 	TInt contactCount = 0;
  1051 	TInt contactCount = 0;
  1083         ++count;
  1059         ++count;
  1084 	    if( count > aIndex )
  1060 	    if( count > aIndex )
  1085 	        {
  1061 	        {
  1086 	        // there's a list in given index
  1062 	        // there's a list in given index
  1087 	        item.iType = MVIMPSTStorageItemModel::EContactList;
  1063 	        item.iType = MVIMPSTStorageItemModel::EContactList;
  1088 	        TRACE( T_LIT("CVIMPSTStorageServiceView::Item end") );
  1064 	        TRACE( "Item end" );
  1089 	        return item;
  1065 	        return item;
  1090 	        }
  1066 	        }
  1091 	    contactCount = list.Count() ;
  1067 	    contactCount = list.Count() ;
  1092         if( contactCount > 0  )
  1068         if( contactCount > 0  )
  1093 			{
  1069 			{
  1096 			    {
  1072 			    {
  1097 			    // there's a contact in given index
  1073 			    // there's a contact in given index
  1098 			    TInt contactIndex( aIndex - count );
  1074 			    TInt contactIndex( aIndex - count );
  1099 			    item.iType = MVIMPSTStorageItemModel::EContactItem;
  1075 			    item.iType = MVIMPSTStorageItemModel::EContactItem;
  1100 			    item.iContact = &list[contactIndex];
  1076 			    item.iContact = &list[contactIndex];
  1101 			    TRACE( T_LIT("CVIMPSTStorageServiceView::Item end") );
  1077 			    TRACE( "Item end" );
  1102 			    return item;
  1078 			    return item;
  1103 			    }
  1079 			    }
  1104 			// add expanded list's contact count
  1080 			// add expanded list's contact count
  1105 			count += contactCount;
  1081 			count += contactCount;
  1106 			}
  1082 			}
  1107 	    }
  1083 	    }
  1108     // not found
  1084     // not found
  1109     TRACE( T_LIT("CVIMPSTStorageServiceView::Item end") );
       
  1110     return item;
  1085     return item;
  1111 	}
  1086 	}
  1112 
  1087 
  1113 // -----------------------------------------------------------------------------
  1088 // -----------------------------------------------------------------------------
  1114 // CVIMPSTStorageServiceView::IndexOfContact
  1089 // CVIMPSTStorageServiceView::IndexOfContact
  1116 // (other items were commented in a header).
  1091 // (other items were commented in a header).
  1117 // -----------------------------------------------------------------------------
  1092 // -----------------------------------------------------------------------------
  1118 //
  1093 //
  1119 TInt CVIMPSTStorageServiceView::IndexOfContact( MVIMPSTStorageContact* aContact ) const
  1094 TInt CVIMPSTStorageServiceView::IndexOfContact( MVIMPSTStorageContact* aContact ) const
  1120 	{
  1095 	{
  1121 	TRACE( T_LIT("CVIMPSTStorageServiceView::IndexOfContact begin") );
  1096 	TRACER_AUTO;
  1122 	TInt listCount( ListCount() );
  1097 	TInt listCount( ListCount() );
  1123 	TInt itemCount( 0 );
  1098 	TInt itemCount( 0 );
  1124 	TInt contactCount = 0;
  1099 	TInt contactCount = 0;
  1125 	TInt indexOfContact = KErrNotFound;
  1100 	TInt indexOfContact = KErrNotFound;
  1126 	for( TInt i(0); i < listCount; ++i )
  1101 	for( TInt i(0); i < listCount; ++i )
  1142 			{	
  1117 			{	
  1143 			itemCount += contactCount;
  1118 			itemCount += contactCount;
  1144 			}
  1119 			}
  1145 		//add the code for if contact not found in first list
  1120 		//add the code for if contact not found in first list
  1146 		}
  1121 		}
  1147 	TRACE( T_LIT("CVIMPSTStorageServiceView::IndexOfContact indexOfContact = %d"), indexOfContact );
  1122 	TRACE( " indexOfContact = %d", indexOfContact );
  1148 	TRACE( T_LIT("CVIMPSTStorageServiceView::IndexOfContact end") );
       
  1149 	return indexOfContact;
  1123 	return indexOfContact;
  1150 	}
  1124 	}
  1151 
  1125 
  1152 // -----------------------------------------------------------------------------
  1126 // -----------------------------------------------------------------------------
  1153 // CVIMPSTStorageServiceView::IndexOfList
  1127 // CVIMPSTStorageServiceView::IndexOfList
  1157 //
  1131 //
  1158 TInt CVIMPSTStorageServiceView::IndexOfList( MVIMPSTStorageContactList* aList,
  1132 TInt CVIMPSTStorageServiceView::IndexOfList( MVIMPSTStorageContactList* aList,
  1159                                        TBool /*aIgnoreOwnItem = EFalse*/,
  1133                                        TBool /*aIgnoreOwnItem = EFalse*/,
  1160                                        TBool /*aIgnoreEmptyLists = ETrue*/ ) const
  1134                                        TBool /*aIgnoreEmptyLists = ETrue*/ ) const
  1161     {
  1135     {
  1162     TRACE( T_LIT("CVIMPSTStorageServiceView::IndexOfList begin") );
  1136 	TRACER_AUTO;
  1163 	TInt listCount( ListCount() );
  1137 	TInt listCount( ListCount() );
  1164    	TInt itemCount( 0 );
  1138    	TInt itemCount( 0 );
  1165 	for( TInt i(0); i<listCount; ++i )
  1139 	for( TInt i(0); i<listCount; ++i )
  1166 	    {
  1140 	    {
  1167 	    MVIMPSTStorageContactList& list = ListAt(i);
  1141 	    MVIMPSTStorageContactList& list = ListAt(i);
  1168 	    if( &list == aList )
  1142 	    if( &list == aList )
  1169 	        {
  1143 	        {
  1170 	        TRACE( T_LIT("CVIMPSTStorageServiceView::IndexOfList list matched"));
  1144 	        TRACE( "list matched");
  1171 	        break;
  1145 	        break;
  1172 	        }
  1146 	        }
  1173 	    else
  1147 	    else
  1174 		    {
  1148 		    {
  1175 		    // list will be consider for calculating the index
  1149 		    // list will be consider for calculating the index
  1176 	    	// at initial state of fetching the list.count will be zero
  1150 	    	// at initial state of fetching the list.count will be zero
  1177 	    	// because all the lists will be fetched first and the contacts
  1151 	    	// because all the lists will be fetched first and the contacts
  1178 	    	itemCount = itemCount+ list.Count() + 1;	
  1152 	    	itemCount = itemCount+ list.Count() + 1;	
  1179 		    }
  1153 		    }
  1180 	    }
  1154 	    }
  1181 	TRACE( T_LIT("CVIMPSTStorageServiceView::IndexOfList itemCount = %d"),itemCount );
  1155 	TRACE( "itemCount = %d",itemCount );
  1182 	TRACE( T_LIT("CVIMPSTStorageServiceView::IndexOfList end") );
       
  1183 	return itemCount;
  1156 	return itemCount;
  1184     }
  1157     }
  1185 // -----------------------------------------------------------------------------
  1158 // -----------------------------------------------------------------------------
  1186 // CVIMPSTContactListModel::MdcaCount
  1159 // CVIMPSTContactListModel::MdcaCount
  1187 // (other items were commented in a header).
  1160 // (other items were commented in a header).
  1188 // -----------------------------------------------------------------------------
  1161 // -----------------------------------------------------------------------------
  1189 //
  1162 //
  1190 TInt CVIMPSTStorageServiceView::MdcaCount() const
  1163 TInt CVIMPSTStorageServiceView::MdcaCount() const
  1191     {
  1164     {
  1192     TRACE( T_LIT("CVIMPSTStorageServiceView::MdcaCount") );
  1165 	TRACER_AUTO;
  1193     return Count();
  1166     return Count();
  1194     }
  1167     }
  1195 
  1168 
  1196 // -----------------------------------------------------------------------------
  1169 // -----------------------------------------------------------------------------
  1197 // CVIMPSTContactListModel::MdcaPoint
  1170 // CVIMPSTContactListModel::MdcaPoint
  1198 // (other items were commented in a header).
  1171 // (other items were commented in a header).
  1199 // -----------------------------------------------------------------------------
  1172 // -----------------------------------------------------------------------------
  1200 //
  1173 //
  1201 TPtrC CVIMPSTStorageServiceView::MdcaPoint( TInt /*aIndex */) const
  1174 TPtrC CVIMPSTStorageServiceView::MdcaPoint( TInt /*aIndex */) const
  1202     {
  1175     {
  1203     TRACE( T_LIT("CVIMPSTStorageServiceView::MdcaPoint") );
  1176 	TRACER_AUTO;
  1204     // These will be filtered out
  1177     // These will be filtered out
  1205     return KNullDesC();
  1178     return KNullDesC();
  1206     } 
  1179     } 
  1207  // -----------------------------------------------------------------------------
  1180  // -----------------------------------------------------------------------------
  1208 // CVIMPSTStorageServiceView::Sort
  1181 // CVIMPSTStorageServiceView::Sort
  1209 /// KNullDesC -> sort all
  1182 /// KNullDesC -> sort all
  1210 // -----------------------------------------------------------------------------
  1183 // -----------------------------------------------------------------------------
  1211 //
  1184 //
  1212 void CVIMPSTStorageServiceView::Sort( const TDesC& aContactListId /* = KNullDesC */ )
  1185 void CVIMPSTStorageServiceView::Sort( const TDesC& aContactListId /* = KNullDesC */ )
  1213     {
  1186     {
  1214     TRACE( T_LIT("CVIMPSTStorageServiceView::Sort() begin") );
  1187 	TRACER_AUTO;
  1215     if( aContactListId.Length() != 0 )
  1188     if( aContactListId.Length() != 0 )
  1216         {
  1189         {
  1217         MVIMPSTStorageContactList* list = FindContactList( aContactListId );
  1190         MVIMPSTStorageContactList* list = FindContactList( aContactListId );
  1218         if( list )
  1191         if( list )
  1219             {
  1192             {
  1220             TRACE( T_LIT("CVIMPSTStorageServiceView::Sort() list sort") );
  1193             TRACE( " list sort" );
  1221             list->Sort();
  1194             list->Sort();
  1222             }
  1195             }
  1223         }
  1196         }
  1224     else
  1197     else
  1225         {
  1198         {
  1226         TInt count( iContactListArray.Count() );
  1199         TInt count( iContactListArray.Count() );
  1227         for( TInt a( 0 ); a < count; ++a )
  1200         for( TInt a( 0 ); a < count; ++a )
  1228             {
  1201             {
  1229             MVIMPSTStorageContactList& list = *iContactListArray[ a ];
  1202             MVIMPSTStorageContactList& list = *iContactListArray[ a ];
  1230             TRACE( T_LIT("CVIMPSTStorageServiceView::Sort() all list sort") );
  1203             TRACE( " all list sort" );
  1231             list.Sort();
  1204             list.Sort();
  1232             }
  1205             }
  1233         } 
  1206         } 
  1234     TRACE( T_LIT("CVIMPSTStorageServiceView::Sort() end") );   
       
  1235     }
  1207     }
  1236 
  1208 
  1237 
  1209 
  1238 // -----------------------------------------------------------------------------
  1210 // -----------------------------------------------------------------------------
  1239 // CVIMPSTStorageServiceView::NotifyAllObservers
  1211 // CVIMPSTStorageServiceView::NotifyAllObservers
  1242 void CVIMPSTStorageServiceView::NotifyAllObserversL( TVIMPSTEnums::TVIMPSTStorgaeEventType aType,
  1214 void CVIMPSTStorageServiceView::NotifyAllObserversL( TVIMPSTEnums::TVIMPSTStorgaeEventType aType,
  1243 					        						  MVIMPSTStorageContactList *aList, 
  1215 					        						  MVIMPSTStorageContactList *aList, 
  1244 					                                  MVIMPSTStorageContact* aContact,
  1216 					                                  MVIMPSTStorageContact* aContact,
  1245 					                                  TInt aContactIndex )
  1217 					                                  TInt aContactIndex )
  1246     {
  1218     {
  1247     TRACE( T_LIT("CVIMPSTStorageServiceView::NotifyAllObserversL() begin") );
  1219 	TRACER_AUTO;
  1248 	TInt count = iContactObservers.Count();
  1220 	TInt count = iContactObservers.Count();
  1249 	for( TInt i=0; i<count; i++ )
  1221 	for( TInt i=0; i<count; i++ )
  1250 		{
  1222 		{
  1251 		iContactObservers[i]->HandleStorageChangeL(  aType, aList, aContact, aContactIndex );	
  1223 		iContactObservers[i]->HandleStorageChangeL(  aType, aList, aContact, aContactIndex );	
  1252 		}
  1224 		}
  1253     TRACE( T_LIT("CVIMPSTStorageServiceView::NotifyAllObserversL() end") );
       
  1254     }
  1225     }
  1255 
  1226 
  1256 // -----------------------------------------------------------------------------
  1227 // -----------------------------------------------------------------------------
  1257 // CVIMPSTStorageServiceView::NotifyAllObserversWithDelay
  1228 // CVIMPSTStorageServiceView::NotifyAllObserversWithDelay
  1258 // -----------------------------------------------------------------------------
  1229 // -----------------------------------------------------------------------------
  1260 void CVIMPSTStorageServiceView::NotifyAllObserversWithDelay( TVIMPSTEnums::TVIMPSTStorgaeEventType aType,
  1231 void CVIMPSTStorageServiceView::NotifyAllObserversWithDelay( TVIMPSTEnums::TVIMPSTStorgaeEventType aType,
  1261 							        						 MVIMPSTStorageContactList *aList, 
  1232 							        						 MVIMPSTStorageContactList *aList, 
  1262 							                                 MVIMPSTStorageContact* aContact,
  1233 							                                 MVIMPSTStorageContact* aContact,
  1263 							                                 TInt aContactIndex )
  1234 							                                 TInt aContactIndex )
  1264 	{
  1235 	{
  1265     TRACE( T_LIT("CVIMPSTStorageServiceView::NotifyAllObserversWithDelay() begin") );
  1236 	TRACER_AUTO;
  1266     if(iActiveHandler->IsActive() )
  1237     if(iActiveHandler->IsActive() )
  1267         {
  1238         {
  1268         iActiveHandler->Cancel();
  1239         iActiveHandler->Cancel();
  1269         }
  1240         }
  1270     iActiveHandler->IssueRequest( aType, aList, aContact, aContactIndex );
  1241     iActiveHandler->IssueRequest( aType, aList, aContact, aContactIndex );
  1271     TRACE( T_LIT("CVIMPSTStorageServiceView::NotifyAllObserversWithDelay() end") );
       
  1272     }
  1242     }
  1273 
  1243 
  1274 // -----------------------------------------------------------------------------
  1244 // -----------------------------------------------------------------------------
  1275 // CVIMPSTStorageServiceView::HandleDelayedNotificationL
  1245 // CVIMPSTStorageServiceView::HandleDelayedNotificationL
  1276 // -----------------------------------------------------------------------------
  1246 // -----------------------------------------------------------------------------
  1278 void CVIMPSTStorageServiceView::HandleDelayedNotificationL(TVIMPSTEnums::TVIMPSTStorgaeEventType aType,
  1248 void CVIMPSTStorageServiceView::HandleDelayedNotificationL(TVIMPSTEnums::TVIMPSTStorgaeEventType aType,
  1279 														   MVIMPSTStorageContactList *aList,
  1249 														   MVIMPSTStorageContactList *aList,
  1280 								                           MVIMPSTStorageContact* aContact,
  1250 								                           MVIMPSTStorageContact* aContact,
  1281 								                           TInt aContactIndex) 
  1251 								                           TInt aContactIndex) 
  1282 	{
  1252 	{
  1283 	TRACE( T_LIT("CVIMPSTStorageServiceView::HandleDelayedNotificationL() begin") );
  1253 	TRACER_AUTO;
  1284 	NotifyAllObserversL( aType, aList, aContact, aContactIndex );
  1254 	NotifyAllObserversL( aType, aList, aContact, aContactIndex );
  1285 	TRACE( T_LIT("CVIMPSTStorageServiceView::HandleDelayedNotificationL() end") );	
       
  1286 	}
  1255 	}
  1287 //  End of File
  1256 //  End of File