1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
/*
* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdlib.h>
#include <string.h>
#include <tizen.h>
#include <calllog.h>
#include <calllog_private.h>
#include <contacts-svc.h>
#include <dlog.h>
#ifdef LOG_TAG
#undef LOG_TAG
#endif
#define LOG_TAG "TIZEN_N_CALLLOG"
#define LOG_MODE (1)
int _calllog_foreach_calllog_grouped_from_db(calllog_foreach_cb cb, void* user_data)
{
if(cb == NULL) {
LOGE("[%s] CALLLOG_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALLLOG_ERROR_INVALID_PARAMETER);
return CALLLOG_ERROR_INVALID_PARAMETER;
}
CTSiter *iter = NULL;
int func_ret = 0;
if(CTS_SUCCESS != contacts_svc_get_list(CTS_LIST_GROUPING_CALL_PLOG, &iter)) {
LOGE("[%s] CALLLOG_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALLLOG_ERROR_DB_FAILED);
return CALLLOG_ERROR_DB_FAILED;
}
while(CTS_SUCCESS == contacts_svc_iter_next(iter)) {
CTSvalue* foreach_data = contacts_svc_iter_get_info(iter);
if(foreach_data == NULL)
break;
calllog_query_detail_s query_data;
query_data.calllog_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_PLOG_ID_INT);
query_data.calllog_type = contacts_svc_value_get_int(foreach_data, CTS_LIST_PLOG_LOG_TYPE_INT);
query_data.contact_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_PLOG_RELATED_ID_INT);
query_data.first_name = _calllog_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_PLOG_FIRST_NAME_STR));
query_data.last_name = _calllog_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_PLOG_LAST_NAME_STR));
query_data.display_name = _calllog_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_PLOG_DISPLAY_NAME_STR));
query_data.contact_image_path = _calllog_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_PLOG_IMG_PATH_STR));
query_data.phone_number_type = contacts_svc_value_get_int(foreach_data, CTS_LIST_PLOG_NUM_TYPE_INT);
query_data.phone_number = _calllog_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_PLOG_NUMBER_STR));
query_data.short_message = _calllog_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_PLOG_SHORTMSG_STR));
query_data.timestamp = (time_t)contacts_svc_value_get_int(foreach_data, CTS_LIST_PLOG_LOG_TIME_INT);
query_data.duration_sec = contacts_svc_value_get_int(foreach_data, CTS_LIST_PLOG_DURATION_INT);
func_ret = cb(&query_data, user_data);
contacts_svc_value_free(foreach_data);
_calllog_safe_free(query_data.first_name);
_calllog_safe_free(query_data.last_name);
_calllog_safe_free(query_data.display_name);
_calllog_safe_free(query_data.contact_image_path);
_calllog_safe_free(query_data.phone_number);
_calllog_safe_free(query_data.short_message);
}
contacts_svc_iter_remove(iter);
return CALLLOG_ERROR_NONE;
}
int _calllog_get_shortmsg(calllog_h log, char** shortmsg)
{
if(log == NULL || shortmsg == NULL) {
LOGE("[%s] CALLLOG_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALLLOG_ERROR_INVALID_PARAMETER);
return CALLLOG_ERROR_INVALID_PARAMETER;
}
*shortmsg = _calllog_safe_strdup(((_calllog_s*)log)->extra_data2);
if(*shortmsg == NULL) {
LOGE("[%s] CALLLOG_ERROR_NO_DATA(0x%08x)", __FUNCTION__, CALLLOG_ERROR_NO_DATA);
return CALLLOG_ERROR_NO_DATA;
}
return CALLLOG_ERROR_NONE;
}
int _calllog_set_shortmsg(calllog_h log, const char* shortmsg)
{
if(log == NULL || shortmsg == NULL) {
LOGE("[%s] CALLLOG_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALLLOG_ERROR_INVALID_PARAMETER);
return CALLLOG_ERROR_INVALID_PARAMETER;
}
CTSvalue * CTSlog = (CTSvalue *)log;
((_calllog_s*)CTSlog)->extra_data2 = (char*)shortmsg;
return CALLLOG_ERROR_NONE;
}
|