//
// Copyright (c) 2012 Samsung Electronics Co., Ltd.
//
-// Licensed under the Flora License, Version 1.0 (the License);
+// Licensed under the Flora License, Version 1.1 (the License);
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
using namespace Tizen::Graphics;
using namespace Tizen::Media;
using namespace Tizen::Social;
+using namespace Tizen::Telephony;
AppCallInfo::AppCallInfo(void)
{
__callType = VOICE_CALL;
__isOnHold = false;
__callConnectTime = 0;
+ __durationTime = 0;
__callNotificationTime = 0;
__pCallHandle = null;
__pEndCallCause = null;
__pParticipantCallHandles = null;
__pContact = null;
+ __pAddressBook = null;
}
AppCallInfo::~AppCallInfo(void)
{
delete __pContact;
}
+ if(__pAddressBook != null)
+ {
+ delete __pAddressBook;
+ }
}
Long*
}
void
+AppCallInfo::ResetContactNumber(String* contactNumber)
+{
+ if(contactNumber == null)
+ {
+ if (__isConfCall == false)
+ {
+ __contactNumber = null;
+ }
+ }
+
+}
+
+void
+AppCallInfo::ResetContactInfo(const Contact* contact)
+{
+ if(contact == null)
+ {
+ if (__pContact != null)
+ {
+ delete __pContact;
+ __pContact = null;
+ }
+ }
+}
+void
AppCallInfo::SetContactNumber(String& contactNumber)
{
if (__isConfCall == false)
__callConnectTime = connectTime;
}
+void
+AppCallInfo::SetDurationTime(long long durationTime)
+{
+ __durationTime = durationTime;
+}
+
long long
AppCallInfo::GetCallNotificationTime(void)
{
return __callNotificationTime;
}
+long long
+AppCallInfo::GetDurationTime(void)
+{
+ return __durationTime;
+}
+
void
AppCallInfo::SetCallNotificationTime(long long callNotificationTime)
{
this->__isOnHold = rhs.__isOnHold;
//call connected time
this->__callConnectTime = rhs.__callConnectTime;
+ this->__durationTime = rhs.__durationTime;
//call notification time
this->__callNotificationTime = rhs.__callNotificationTime;
this->__calllogType = rhs.__calllogType;
AppCallInfo::FetchCallerNameN(void)
{
String displayName(L"");
-
//get caller name from already fetched contact info
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_FIRST_NAME, firstName);
+ __pContact->GetValue(CONTACT_PROPERTY_ID_LAST_NAME, lastName);
__pContact->GetValue(CONTACT_PROPERTY_ID_MIDDLE_NAME, middlename);
displayName.Append(firstName + middlename + lastName);
return new (std::nothrow) String(displayName);
}
+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;
+ }
+ if(pFoundContact != null)
+ {
+ break;
+ }
+ }
+ 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);
+ }
+ delete pContact;
+ }
+
+ 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;
+
+}
+
Bitmap*
AppCallInfo::FetchCallerPhotoN(void)
{
{
String thumbnailPath;
Bitmap* pThumbnail = null;
- // __pContact->GetValue(CONTACT_PROPERTY_ID_THUMBNAIL, thumbnailPath);
- thumbnailPath = __pContact->GetThumbnailPath();
+ __pAddressBook = AddressbookManager::GetInstance()->GetAddressbookN();
+
+ result r = __pContact->GetValue(CONTACT_PROPERTY_ID_THUMBNAIL, thumbnailPath);
+ //Now check if there is a group ring tone
+ 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();
+ }
+ }
+ //thumbnailPath = __pContact->GetThumbnailPath();
ImageBuffer thumbnailImageBuffer;
- result r = thumbnailImageBuffer.Construct(thumbnailPath);
+ r = thumbnailImageBuffer.Construct(thumbnailPath);
if (r == E_SUCCESS)
{
pThumbnail = thumbnailImageBuffer.GetBitmapN(BITMAP_PIXEL_FORMAT_ARGB8888, BUFFER_SCALING_NONE);