phonebookui/Phonebook2/ccapplication/ccacommlauncherplugin/src/ccappcommlaunchercontacthandler.cpp
branchRCL_3
changeset 35 4ae315f230bc
parent 26 0d28c1c5b6dd
child 64 c1e8ba0c2b16
--- a/phonebookui/Phonebook2/ccapplication/ccacommlauncherplugin/src/ccappcommlaunchercontacthandler.cpp	Tue May 11 16:00:21 2010 +0300
+++ b/phonebookui/Phonebook2/ccapplication/ccacommlauncherplugin/src/ccappcommlaunchercontacthandler.cpp	Tue May 25 12:26:45 2010 +0300
@@ -66,6 +66,7 @@
         iCmsWrapper->Release();
         }
     iDynamicVoipAddressGroup.Close();
+    iAddressCache.Close();
     }
 
 // --------------------------------------------------------------------------
@@ -165,6 +166,7 @@
         == aParameter.iType )
         {
         iDynamicAddressGroupSet = EFalse;
+        iAddressCache.Close(); // reset cache on change
         iObserver.ContactsChangedL();
         }
     else if (MCCAppContactFieldDataObserver::TParameter::EContactPresenceChanged == aParameter.iType)
@@ -228,7 +230,14 @@
 TInt CCCAppCommLauncherContactHandler::AddressAmount( 
     VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector aContactAction )
     {
-    return iCmsWrapper->GetContactActionFieldCount(aContactAction);
+    TInt* count = iAddressCache.Find( aContactAction );
+    if( !count )
+        {
+        TInt newcount = iCmsWrapper->GetContactActionFieldCount( aContactAction );
+        iAddressCache.Insert( aContactAction, newcount );
+        return newcount;
+        }
+    return *count;
     }
 
 // ---------------------------------------------------------------------------
@@ -549,6 +558,7 @@
     {
     iCmsWrapper->RefetchContactL();
     iCmsWrapper->AddObserverL( *this );
+    iAddressCache.Close();
     }
 
 // --------------------------------------------------------------------------