4 * Copyright (c) 2010 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 #include <pims-ipc-data.h>
22 #include "contacts_phone_log_internal.h"
23 #include "ctsvc_internal.h"
24 #include "ctsvc_ipc_define.h"
25 #include "ctsvc_client_ipc.h"
26 #include "ctsvc_ipc_marshal.h"
29 static const char CONTACTS_READ_PRIVILEGE_ID[] = "http://tizen.org/privilege/contact.read";
30 static const char CONTACTS_WRITE_PRIVILEGE_ID[] = "http://tizen.org/privilege/contact.write";
31 static const char PHONELOG_READ_PRIVILEGE_ID[] = "http://tizen.org/privilege/callhistory.read";
32 static const char PHONELOG_WRITE_PRIVILEGE_ID[] = "http://tizen.org/privilege/callhistory.write";
34 int ctsvc_client_phone_log_reset_statistics(contacts_h contact)
36 #ifndef ENABLE_LOG_FEATURE
37 return CONTACTS_ERROR_NOT_SUPPORTED;
38 #endif /* ENABLE_LOG_FEATURE */
40 int ret = CONTACTS_ERROR_NONE;
42 pims_ipc_data_h indata = NULL;
43 pims_ipc_data_h outdata = NULL;
45 RETV_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER);
48 indata = pims_ipc_data_create(0);
50 ERR("pims_ipc_data_create() Fail");
51 return CONTACTS_ERROR_OUT_OF_MEMORY;
54 ret = ctsvc_ipc_marshal_handle(contact, indata);
55 if (CONTACTS_ERROR_NONE != ret) {
56 ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
57 pims_ipc_data_destroy(indata);
62 if (ctsvc_ipc_call(CTSVC_IPC_PHONELOG_MODULE, CTSVC_IPC_SERVER_PHONELOG_RESET_STATISTICS,
63 indata, &outdata) != 0) {
64 ERR("ctsvc_ipc_call() Fail");
65 pims_ipc_data_destroy(indata);
66 return CONTACTS_ERROR_IPC;
69 pims_ipc_data_destroy(indata);
72 if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &ret)) {
73 ERR("ctsvc_ipc_unmarshal_int() Fail");
74 pims_ipc_data_destroy(outdata);
75 return CONTACTS_ERROR_IPC;
78 if (CONTACTS_ERROR_NONE == ret) {
79 int transaction_ver = 0;
80 if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &transaction_ver)) {
81 ERR("ctsvc_ipc_unmarshal_int() Fail");
82 pims_ipc_data_destroy(outdata);
83 return CONTACTS_ERROR_IPC;
85 ctsvc_client_ipc_set_change_version(contact, transaction_ver);
88 pims_ipc_data_destroy(outdata);
95 int ctsvc_client_phone_log_reset_statistics_by_sim(contacts_h contact,
98 #ifndef ENABLE_LOG_FEATURE
99 return CONTACTS_ERROR_NOT_SUPPORTED;
100 #endif /* ENABLE_LOG_FEATURE */
102 int ret = CONTACTS_ERROR_NONE;
104 pims_ipc_data_h indata = NULL;
105 pims_ipc_data_h outdata = NULL;
107 RETV_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER);
108 RETV_IF(sim_slot_no < 0, CONTACTS_ERROR_INVALID_PARAMETER);
111 indata = pims_ipc_data_create(0);
112 if (indata == NULL) {
113 ERR("pims_ipc_data_create() Fail");
114 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
118 ret = ctsvc_ipc_marshal_handle(contact, indata);
119 if (CONTACTS_ERROR_NONE != ret) {
120 ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
121 pims_ipc_data_destroy(indata);
125 ret = ctsvc_ipc_marshal_int(sim_slot_no, indata);
126 if (CONTACTS_ERROR_NONE != ret) {
127 ERR("ctsvc_ipc_marshal_int() Fail(%d)", ret);
128 pims_ipc_data_destroy(indata);
133 if (ctsvc_ipc_call(CTSVC_IPC_PHONELOG_MODULE,
134 CTSVC_IPC_SERVER_PHONELOG_RESET_STATISTICS_BY_SIM,
135 indata, &outdata) != 0) {
136 ERR("ctsvc_ipc_call() Fail");
137 pims_ipc_data_destroy(indata);
138 return CONTACTS_ERROR_IPC;
141 pims_ipc_data_destroy(indata);
144 if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &ret)) {
145 ERR("ctsvc_ipc_unmarshal_int() Fail");
146 pims_ipc_data_destroy(outdata);
147 return CONTACTS_ERROR_IPC;
150 if (CONTACTS_ERROR_NONE == ret) {
151 int transaction_ver = 0;
152 if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &transaction_ver)) {
153 ERR("ctsvc_ipc_unmarshal_int() Fail");
154 pims_ipc_data_destroy(outdata);
155 return CONTACTS_ERROR_IPC;
157 ctsvc_client_ipc_set_change_version(contact, transaction_ver);
160 pims_ipc_data_destroy(outdata);
166 int ctsvc_client_phone_log_delete(contacts_h contact, contacts_phone_log_delete_e op,
169 #ifndef ENABLE_LOG_FEATURE
170 return CONTACTS_ERROR_NOT_SUPPORTED;
171 #endif /* ENABLE_LOG_FEATURE */
173 int ret = CONTACTS_ERROR_NONE;
175 pims_ipc_data_h indata = NULL;
176 pims_ipc_data_h outdata = NULL;
180 RETV_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER);
182 indata = pims_ipc_data_create(0);
183 if (indata == NULL) {
184 ERR("pims_ipc_data_create() Fail");
185 return CONTACTS_ERROR_OUT_OF_MEMORY;
188 ret = ctsvc_ipc_marshal_handle(contact, indata);
189 if (CONTACTS_ERROR_NONE != ret) {
190 ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
191 pims_ipc_data_destroy(indata);
195 ret = ctsvc_ipc_marshal_int(op, indata);
196 if (ret != CONTACTS_ERROR_NONE) {
197 ERR("ctsvc_ipc_marshal_int fail");
198 pims_ipc_data_destroy(indata);
203 case CONTACTS_PHONE_LOG_DELETE_BY_ADDRESS:
204 number = va_arg(args, char *);
205 if (NULL == number) {
206 pims_ipc_data_destroy(indata);
207 return CONTACTS_ERROR_INVALID_PARAMETER;
209 ret = ctsvc_ipc_marshal_string(number, indata);
210 if (ret != CONTACTS_ERROR_NONE) {
211 ERR("ctsvc_ipc_marshal_string fail");
212 pims_ipc_data_destroy(indata);
216 case CONTACTS_PHONE_LOG_DELETE_BY_MESSAGE_EXTRA_DATA1:
217 case CONTACTS_PHONE_LOG_DELETE_BY_EMAIL_EXTRA_DATA1:
218 extra_data1 = va_arg(args, int);
219 ret = ctsvc_ipc_marshal_int(extra_data1, indata);
220 if (ret != CONTACTS_ERROR_NONE) {
221 ERR("ctsvc_ipc_marshal_int fail");
222 pims_ipc_data_destroy(indata);
227 ERR("operation is not proper (%d)", ret);
228 pims_ipc_data_destroy(indata);
229 return CONTACTS_ERROR_INVALID_PARAMETER;
232 if (ctsvc_ipc_call(CTSVC_IPC_PHONELOG_MODULE,
233 CTSVC_IPC_SERVER_PHONELOG_DELETE, indata, &outdata) != 0) {
234 ERR("ctsvc_ipc_call() Fail");
235 pims_ipc_data_destroy(indata);
236 return CONTACTS_ERROR_IPC;
239 pims_ipc_data_destroy(indata);
242 if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &ret)) {
243 ERR("ctsvc_ipc_unmarshal_int() Fail");
244 pims_ipc_data_destroy(outdata);
245 return CONTACTS_ERROR_IPC;
247 if (CONTACTS_ERROR_NONE == ret) {
248 int transaction_ver = 0;
249 if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &transaction_ver)) {
250 ERR("ctsvc_ipc_unmarshal_int() Fail");
251 pims_ipc_data_destroy(outdata);
252 return CONTACTS_ERROR_IPC;
254 ctsvc_client_ipc_set_change_version(contact, transaction_ver);
257 pims_ipc_data_destroy(outdata);