Feature to show group image if a call comes from a group member
[apps/osp/Call.git] / src / CallInfo.cpp
index 81fa515..1981d59 100644 (file)
@@ -27,6 +27,7 @@ using namespace Tizen::Base::Collection;
 using namespace Tizen::Graphics;
 using namespace Tizen::Media;
 using namespace Tizen::Social;
+using namespace Tizen::Telephony;
 
 AppCallInfo::AppCallInfo(void)
 {
@@ -41,6 +42,7 @@ AppCallInfo::AppCallInfo(void)
        __pEndCallCause = null;
        __pParticipantCallHandles = null;
        __pContact = null;
+       __pAddressBook = null;
 }
 
 AppCallInfo::~AppCallInfo(void)
@@ -64,6 +66,10 @@ AppCallInfo::~AppCallInfo(void)
        {
                delete __pContact;
        }
+       if(__pAddressBook != null)
+       {
+               delete __pAddressBook;
+       }
 }
 
 Long*
@@ -322,14 +328,17 @@ AppCallInfo::FetchCallerNameN(void)
        if (__pContact != null)
        {
                //fetch name to be displayed
-               __pContact->GetValue(CONTACT_PROPERTY_ID_DISPLAY_NAME, displayName);
-               if (displayName.IsEmpty())
-               {
                        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);
-                       displayName.Append(firstName + " " + 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);
                }
        }
 
@@ -344,10 +353,23 @@ 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);