Fix for N_SE-47660
authorAmith Kumar Mahale <amith.m@samsung.com>
Wed, 31 Jul 2013 14:42:08 +0000 (20:12 +0530)
committerAmith Kumar Mahale <amith.m@samsung.com>
Wed, 31 Jul 2013 14:42:08 +0000 (20:12 +0530)
Change-Id: I9bc3bdf377a265544d8b67c7f55f6a443286cfce
Signed-off-by: Amith Kumar Mahale <amith.m@samsung.com>
src/CallInfo.cpp
src/CallSoundManager.cpp
src/CalllogManager.cpp

index 1e5af54..88df76f 100644 (file)
@@ -419,13 +419,17 @@ AppCallInfo::FetchContactN(const Tizen::Base::String& phoneNumber)
                                }
                        }
                        delete pPhoneEnum;
-                               pPhoneNumberList->RemoveAll(true);
-                               delete pPhoneNumberList;
-                       }
+                       pPhoneNumberList->RemoveAll(true);
+                       delete pPhoneNumberList;
+               }
+               if(pFoundContact != null)
+               {
+                       break;
                }
-               delete pContactEnum;
-               pContactList->RemoveAll(true);
-               delete pContactList;
+       }
+       delete pContactEnum;
+       pContactList->RemoveAll(true);
+       delete pContactList;
 
        if(pFoundContact == null)
        {
index bc7006f..2a85416 100644 (file)
@@ -604,26 +604,26 @@ SoundManager::StartAlert(String& contactRingTone)
                res = __pPlayer->OpenFile(ringTonePath,false);
                if(res != E_SUCCESS)
                {
-                       AppLogDebug("__pPlayer Construct failed with %d",res);
+                       AppLogDebug("__pPlayer OpenFile failed with %d",res);
                        return;
                }
                res = __pPlayer->SetLooping(true);
                if(res != E_SUCCESS)
                {
-                       AppLogDebug("__pPlayer Construct failed with %d",res);
+                       AppLogDebug("__pPlayer SetLooping failed with %d",res);
                        return;
                }
                res = __pPlayer->SetVolume(80);
                if(res != E_SUCCESS)
                {
-                       AppLogDebug("__pPlayer Construct failed with %d",res);
+                       AppLogDebug("__pPlayer SetVolume failed with %d",res);
                        return;
                }
                res = SetSoundMode(SOUND_MODE_RINGTONE);
                res = __pPlayer->Play();
                if(res != E_SUCCESS)
                {
-                       AppLogDebug("__pPlayer Construct failed with %d",res);
+                       AppLogDebug("__pPlayer Play failed with %d",res);
                        return;
                }
        }
@@ -654,13 +654,13 @@ SoundManager::StopAlert(void)
                        if(res != E_SUCCESS)
                        {
                                AppLogDebug("__pPlayer Stop failed with %d",res);
-                               return;
+
                        }
                        res = __pPlayer->Close();
                        if(res != E_SUCCESS)
                        {
                                AppLogDebug("__pPlayer Close failed with %d",res);
-                               return;
+
                        }
                        SetSoundMode(SOUND_MODE_VOICE);
                        __isSoundStatusOn = false;
index 98dc827..2814c23 100644 (file)
@@ -216,18 +216,54 @@ CallLogManager::GetDuration(long long start_time)
 int
 CallLogManager::GetPersonId(Tizen::Base::String& phoneNumber)
 {
+       AppLogDebug("Enter");
        int personId = -1;
+       bool bContactFound = false;
        if (pAddressBook != null)
        {
                IList* pNumberContactsList = pAddressBook->SearchContactsByPhoneNumberN(phoneNumber);
+               if (pNumberContactsList == null || IsFailed(GetLastResult()))
+               {
+                       return -1;
+               }
+
+               //Fetch the contact's info to be displayed
+               IEnumerator* pContactEnum = pNumberContactsList->GetEnumeratorN();
                if(pNumberContactsList != null)
                {
-                       Contact* pContact = static_cast<Contact*>(pNumberContactsList->GetAt(0));
-                       if(pContact != null)
+                       while (E_SUCCESS == pContactEnum->MoveNext())
                        {
-                               personId = pContact->GetPersonId();
+                               Contact* pContact = static_cast<Contact*>(pContactEnum->GetCurrent());
+
+                               IList* pPhoneNumberList = pContact->GetValuesN(CONTACT_MPROPERTY_ID_PHONE_NUMBERS);
+                               if (pPhoneNumberList != null)
+                               {
+                                       IEnumerator* pPhoneEnum = pPhoneNumberList->GetEnumeratorN();
+                                       while (E_SUCCESS == pPhoneEnum->MoveNext())
+                                       {
+                                               PhoneNumber* pPhoneNumber = (PhoneNumber*) pPhoneEnum->GetCurrent();
+                                               //Check if this is the correct contact
+                                               if (pPhoneNumber->GetPhoneNumber().Equals(phoneNumber))
+                                               {
+                                                       //save newly fetched contact info.
+                                                       bContactFound = true;
+                                                       personId = pContact->GetPersonId();
+                                                       break;
+                                               }
+                                       }
+                                       delete pPhoneEnum;
+                                       pPhoneNumberList->RemoveAll(true);
+                                       delete pPhoneNumberList;
+                               }
+                               if(bContactFound == true)
+                               {
+                                       break;
+                               }
                        }
                }
+               delete pContactEnum;
+               pNumberContactsList->RemoveAll(true);
+               delete pNumberContactsList;
        }
        return personId;
 }