phoneuis/easydialing/src/easydialingcontactdatamanager.cpp
branchRCL_3
changeset 4 24062c24fe38
parent 3 8871b09be73b
child 5 2a26698d78ba
--- a/phoneuis/easydialing/src/easydialingcontactdatamanager.cpp	Fri Feb 19 22:50:26 2010 +0200
+++ b/phoneuis/easydialing/src/easydialingcontactdatamanager.cpp	Fri Mar 12 15:42:40 2010 +0200
@@ -42,6 +42,8 @@
 #include <MVPbkStoreContact.h>
 #include <centralrepository.h>
 
+#include <PbkGlobalSettingFactory.h>
+
 #include "easydialingcontactdata.h"
 #include "easydialingcontactdatamanager.h"
 #include "easydialingutils.h"
@@ -78,6 +80,12 @@
         {
         iContactStore->Close( *this);
         }
+    
+    if ( iPbkSettings )
+        {
+        iPbkSettings->Close();
+        }
+    delete iPbkSettings;
     }
 
 // ---------------------------------------------------------------------------
@@ -104,6 +112,20 @@
     CleanupStack::PushL( cenrep );
     User::LeaveIfError( cenrep->Get( KEasyDialingContactThumbnails, iContactThumbnailSetting ) );
     CleanupStack::PopAndDestroy( cenrep );
+    
+    iPbkSettings = PbkGlobalSettingFactory::CreatePersistentSettingL();
+    iPbkSettings->ConnectL( MPbkGlobalSetting::EGeneralSettingCategory );
+    
+    /*
+    * Phonebook name ordering flag, integer value, possible values:
+    * 0: name order Lastname Firstname
+    * 1: name order Firstname Lastname
+    * 2: name order undefined
+    */
+    TInt nameOrderSetting;
+    iPbkSettings->Get( MPbkGlobalSetting::ENameOrdering, nameOrderSetting );
+    iNameOrder = ( nameOrderSetting == 0 ? ELastnameFirstname : EFirstnameLastname );
+    iPbkSettings->RegisterObserverL( this );
     }
 
 // ---------------------------------------------------------------------------
@@ -254,7 +276,7 @@
 // CEasyDialingContactDataManager::FavContactStringLC
 // ---------------------------------------------------------------------------
 //
-HBufC* CEasyDialingContactDataManager::FavContactStringLC( TInt aIndex, CPbkContactEngine::TPbkNameOrder aNameOrder )
+HBufC* CEasyDialingContactDataManager::FavContactStringLC( TInt aIndex, TNameOrder aNameOrder )
     {
     const MVPbkBaseContactFieldCollection& fields = iFavsView->ContactAtL( aIndex ).Fields();
     TPtrC firstName;
@@ -295,6 +317,15 @@
     }
 
 // ---------------------------------------------------------------------------
+// CEasyDialingContactDataManager::NameOrder
+// ---------------------------------------------------------------------------
+//
+CEasyDialingContactDataManager::TNameOrder CEasyDialingContactDataManager::NameOrder()
+    {
+    return iNameOrder;
+    }
+
+// ---------------------------------------------------------------------------
 // CEasyDialingContactDataManager::InitReady
 // ---------------------------------------------------------------------------
 //
@@ -394,6 +425,25 @@
     }
 
 // ---------------------------------------------------------------------------
+// CEasyDialingContactDataManager::SettingChangedL
+// From MPbkGlobalSettingObserver
+// ---------------------------------------------------------------------------
+//
+void CEasyDialingContactDataManager::SettingChangedL( MPbkGlobalSetting::TPbkGlobalSetting aKey )
+    {
+    if ( aKey == MPbkGlobalSetting::ENameOrdering )
+        {
+        TInt nameOrderSetting;
+        iPbkSettings->Get( MPbkGlobalSetting::ENameOrdering, nameOrderSetting );
+        iNameOrder = ( nameOrderSetting == 0 ? ELastnameFirstname : EFirstnameLastname );
+        if ( iObserver )
+            {
+            iObserver->NameOrderChanged();
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
 // CEasyDialingContactDataManager::DoHandleImageGetCompleteL
 // ---------------------------------------------------------------------------
 //