phonebookui/Phonebook2/spbcontentprovider/src/spbcontactstorelistener.cpp
branchRCL_3
changeset 3 04ab22b956c2
parent 0 e686773b3f54
child 64 c1e8ba0c2b16
equal deleted inserted replaced
0:e686773b3f54 3:04ab22b956c2
    97 												  TVPbkContactStoreEvent aStoreEvent )
    97 												  TVPbkContactStoreEvent aStoreEvent )
    98 	{
    98 	{
    99 	/// contact has changed, check if the number needs to be reloaded
    99 	/// contact has changed, check if the number needs to be reloaded
   100 	if( aStoreEvent.iEventType == TVPbkContactStoreEvent::EContactChanged )
   100 	if( aStoreEvent.iEventType == TVPbkContactStoreEvent::EContactChanged )
   101 		{
   101 		{
   102 		CSpbContent* content = ContentByLinkL( *aStoreEvent.iContactLink );
   102 		CSpbContent* content = ContentByLink( *aStoreEvent.iContactLink );
   103 		if( content )
   103 		if( content )
   104 			{
   104 			{
   105 			content->RefreshNumber();
   105 			content->RefreshNumberL();
   106 			}
   106 			}
   107 		}
   107 		}
       
   108 	else if( aStoreEvent.iEventType == TVPbkContactStoreEvent::EContactDeleted )
       
   109 	    {
       
   110         DeleteContentByLink( *aStoreEvent.iContactLink );
       
   111 	    }
   108 	}
   112 	}
   109 
   113 
   110 // ----------------------------------------------------------------------------
   114 // ----------------------------------------------------------------------------
   111 // CSpbContactStoreListener::ContentByLinkL
   115 // CSpbContactStoreListener::ContentByLink
   112 // ----------------------------------------------------------------------------
   116 // ----------------------------------------------------------------------------
   113 //
   117 //
   114 CSpbContent* CSpbContactStoreListener::ContentByLinkL( 
   118 CSpbContent* CSpbContactStoreListener::ContentByLink( 
   115     const MVPbkContactLink& aLink )
   119     const MVPbkContactLink& aLink )
   116     {
   120     {
   117     const TInt count( iContentCache.Count() );
   121     const TInt count( iContentCache.Count() );
   118     for( TInt i = 0 ; i < count ; ++i )
   122     for( TInt i = 0 ; i < count ; ++i )
   119         {
   123         {
   124             }
   128             }
   125         }
   129         }
   126     return NULL;
   130     return NULL;
   127     }
   131     }
   128 
   132 
       
   133 // ----------------------------------------------------------------------------
       
   134 // CSpbContactStoreListener::DeleteContentByLink
       
   135 // ----------------------------------------------------------------------------
       
   136 //
       
   137 void CSpbContactStoreListener::DeleteContentByLink( 
       
   138     const MVPbkContactLink& aLink )
       
   139     {
       
   140     const TInt count = iContentCache.Count();
       
   141     for( TInt i = 0 ; i < count ; ++i )
       
   142         {
       
   143         CSpbContent* content = iContentCache[i];
       
   144         if( content->Match( aLink ) )
       
   145             {
       
   146             delete content;
       
   147             iContentCache.Remove( i );
       
   148             break; // only one content for each contact
       
   149             }
       
   150         }
       
   151     }
       
   152 
       
   153 // End of file