License and Privilege changes
[apps/osp/Call.git] / src / CalllogManager.cpp
index 6f1f749..0aabdda 100644 (file)
@@ -1,7 +1,7 @@
 //
 // 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
 //
@@ -32,6 +32,7 @@ CallLogManager*       CallLogManager::__pCallogManager = null;
 CallLogManager::CallLogManager(void)
 {
 
+       pAddressBook = AddressbookManager::GetInstance()->GetAddressbookN();
 }
 
 CallLogManager::~CallLogManager(void)
@@ -83,7 +84,7 @@ CallLogManager::DestroyInstance(void)
 }
 
 result
-CallLogManager::AddCallogInfoToDatabase(CallInfo* calllogInfo)
+CallLogManager::AddCallogInfoToDatabase(AppCallInfo* calllogInfo)
 {
        AppLog(" AddVoiceCallInfo Entry");
        int duration = 0;
@@ -101,7 +102,7 @@ CallLogManager::AddCallogInfoToDatabase(CallInfo* calllogInfo)
                case CALL_LOG_TYPE_VOICE_OUTGOING:
                        logType = CONTACTS_PLOG_TYPE_VOICE_OUTGOING;
                        break;
-               case CALL_LOG_TYPE_VOICE_MISSED:
+               case CALL_LOG_TYPE_VOICE_MISSED_UNSEEN:
                        logType = CONTACTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN;
                        break;
                case CALL_LOG_TYPE_VOICE_REJECTED:
@@ -153,6 +154,14 @@ CallLogManager::AddCallogInfoToDatabase(CallInfo* calllogInfo)
                }
                int id;
 
+               int personid = GetPersonId(PhNumber);
+               if (personid != -1)
+               {
+                       if(contacts_record_set_int(hContactLog,_contacts_phone_log.person_id,personid) != CONTACTS_ERROR_NONE)
+                       {
+                               AppLog(" calllog_set_type personid failed");
+                       }
+               }
 
                if (contacts_record_set_int(hContactLog,_contacts_phone_log.log_type,logType) != CONTACTS_ERROR_NONE)
                {
@@ -197,4 +206,22 @@ CallLogManager::GetDuration(long long start_time)
        call_duration_in_sec = curr_time - start_time;
        return call_duration_in_sec;
 }
+int
+CallLogManager::GetPersonId(Tizen::Base::String& phoneNumber)
+{
+       int personId = -1;
+       if (pAddressBook != null)
+       {
+               IList* pNumberContactsList = pAddressBook->SearchContactsByPhoneNumberN(phoneNumber);
+               if(pNumberContactsList != null)
+               {
+                       Contact* pContact = static_cast<Contact*>(pNumberContactsList->GetAt(0));
+                       if(pContact != null)
+                       {
+                               personId = pContact->GetPersonId();
+                       }
+               }
+       }
+       return personId;
+}