2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 #include "CallHistoryEntry.h"
19 #include <Commons/Exception.h>
20 #include <dpl/shared_ptr.h>
24 using namespace DeviceAPI::Tizen;
25 using namespace WrtDeviceApis;
26 using namespace WrtDeviceApis::Commons;
30 namespace CallHistory {
32 CallHistoryEntry::CallHistoryEntry()
34 if (contacts_connect2() == CONTACTS_ERROR_NONE) {
35 LoggerD("Successful to connect Call history DB ");
37 LoggerD("Failed to connect Call history DB ");
41 CallHistoryEntry::~CallHistoryEntry()
43 if (contacts_disconnect2() == CONTACTS_ERROR_NONE) {
44 LoggerD("Successful to disconnect Call history DB ");
46 LoggerD("Failed to disconnect Call history DB ");
50 void CallHistoryEntry::setMarkSeen(const unsigned long entryId)
52 contacts_record_h record = NULL;
56 ret = contacts_db_get_record (_contacts_phone_log._uri, (int)entryId, &record);
58 if (ret != CONTACTS_ERROR_NONE) {
59 ThrowMsg(Commons::ConversionException, "Type missmatch error");
63 contacts_record_get_int (record, _contacts_phone_log.log_type, &logType);
66 contacts_record_set_int (record, _contacts_phone_log.log_type, 6);
67 } else if (logType == 7) {
68 contacts_record_set_int (record, _contacts_phone_log.log_type, 8);
70 contacts_record_destroy(record, true);
71 ThrowMsg(Commons::ConversionException, "Type missmatch error");
75 ret = contacts_db_update_record (record);
77 if (ret != CONTACTS_ERROR_NONE) {
78 contacts_record_destroy(record, true);
79 ThrowMsg(Commons::ConversionException, "Type missmatch error");
83 contacts_record_destroy(record, true);