+Contact*
+AppCallInfo::FetchContactN(const Tizen::Base::String& phoneNumber)
+{
+ Tizen::Social::Contact* pFoundContact = null;
+ if(__pAddressBook == null)
+ {
+ __pAddressBook = AddressbookManager::GetInstance()->GetAddressbookN();
+ }
+ IList* pContactList = __pAddressBook->SearchContactsByPhoneNumberN(phoneNumber);
+ if (pContactList == null || IsFailed(GetLastResult()))
+ {
+ return null;
+ }
+
+ //Fetch the contact's info to be displayed
+ IEnumerator* pContactEnum = pContactList->GetEnumeratorN();
+ while (E_SUCCESS == pContactEnum->MoveNext())
+ {
+ 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.
+ pFoundContact = new (std::nothrow) Contact(*pContact);
+ break;
+ }
+ }
+ delete pPhoneEnum;
+ pPhoneNumberList->RemoveAll(true);
+ delete pPhoneNumberList;
+ }
+ }
+ delete pContactEnum;
+ pContactList->RemoveAll(true);
+ delete pContactList;
+
+ if(pFoundContact == null)
+ {
+ return null;
+ }
+
+ return pFoundContact;
+
+}
+
+
+String*
+AppCallInfo::FetchLatestCallerNameN(const Tizen::Base::String& phoneNumber)
+{
+ String displayName(L"");
+ Tizen::Social::Contact* pContact = null;
+ //Fetch the contact for a number from address book
+ pContact = FetchContactN(phoneNumber);
+ if(pContact != null)
+ {
+ String firstName(L"");
+ String lastName(L"");
+ String middlename(L"");
+ pContact->GetValue(CONTACT_PROPERTY_ID_FIRST_NAME, firstName);
+ pContact->GetValue(CONTACT_PROPERTY_ID_LAST_NAME, lastName);
+ pContact->GetValue(CONTACT_PROPERTY_ID_MIDDLE_NAME, middlename);
+ displayName.Append(firstName + middlename + lastName);
+
+ if (displayName.IsEmpty() == false)
+ {
+ pContact->GetValue(CONTACT_PROPERTY_ID_DISPLAY_NAME, displayName);
+ }
+ }
+
+ return new (std::nothrow) String(displayName);
+
+
+}
+Bitmap*
+AppCallInfo::FetchLatestCallerPhotoN(const Tizen::Base::String& phoneNumber)
+{
+ result r = E_FAILURE;
+ Tizen::Social::Contact* pContact = null;
+ String thumbnailPath;
+ Bitmap* pThumbnail = null;
+ pContact = FetchContactN(phoneNumber);
+ if(pContact != null)
+ {
+ pContact->GetValue(CONTACT_PROPERTY_ID_THUMBNAIL,thumbnailPath);
+ if(thumbnailPath.IsEmpty() == true)
+ {
+ IList* pCategoryList = __pAddressBook->GetCategoriesByContactN(pContact->GetRecordId());
+ if(pCategoryList != null && pCategoryList->GetCount() > 0)
+ {
+ AppLogDebug("Changes to get thumbnail group photo");
+ Category* pCategory = static_cast<Category*>(pCategoryList->GetAt(0));
+ thumbnailPath = pCategory->GetThumbnailPath();
+ }
+ }
+ ImageBuffer thumbnailImageBuffer;
+ r = thumbnailImageBuffer.Construct(thumbnailPath);
+ if (r == E_SUCCESS)
+ {
+ pThumbnail = thumbnailImageBuffer.GetBitmapN(BITMAP_PIXEL_FORMAT_ARGB8888, BUFFER_SCALING_NONE);
+ }
+
+ if(pThumbnail != null)
+ {
+ return pThumbnail;
+ }
+ }
+
+ return null;
+
+}
+