4 * Copyright (c) 2010 - 2012 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.
20 #include <pims-ipc-data.h>
23 #include "contacts_phone_log_internal.h"
24 #include "ctsvc_internal.h"
25 #include "ctsvc_ipc_define.h"
26 #include "ctsvc_client_ipc.h"
27 #include "ctsvc_ipc_marshal.h"
30 static const char CONTACTS_READ_PRIVILEGE_ID[] = "http://tizen.org/privilege/contact.read";
31 static const char CONTACTS_WRITE_PRIVILEGE_ID[] = "http://tizen.org/privilege/contact.write";
32 static const char PHONELOG_READ_PRIVILEGE_ID[] = "http://tizen.org/privilege/callhistory.read";
33 static const char PHONELOG_WRITE_PRIVILEGE_ID[] = "http://tizen.org/privilege/callhistory.write";
35 int ctsvc_client_phone_log_reset_statistics(contacts_h contact)
37 #ifndef ENABLE_LOG_FEATURE
38 return CONTACTS_ERROR_NOT_SUPPORTED;
39 #endif /* ENABLE_LOG_FEATURE */
41 int ret = CONTACTS_ERROR_NONE;
43 pims_ipc_data_h indata = NULL;
44 pims_ipc_data_h outdata = NULL;
46 RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
49 indata = pims_ipc_data_create(0);
51 CTS_ERR("ipc data created fail!");
52 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
56 ret = ctsvc_ipc_marshal_handle(contact, indata);
57 if (CONTACTS_ERROR_NONE != ret) {
58 CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
59 pims_ipc_data_destroy(indata);
64 if (ctsvc_ipc_call(CTSVC_IPC_PHONELOG_MODULE, CTSVC_IPC_SERVER_PHONELOG_RESET_STATISTICS, indata, &outdata) != 0) {
65 CTS_ERR("ctsvc_ipc_call failed");
66 pims_ipc_data_destroy(indata);
67 return CONTACTS_ERROR_IPC;
70 pims_ipc_data_destroy(indata);
73 if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &ret)) {
74 CTS_ERR("ctsvc_ipc_unmarshal_int() Fail");
75 pims_ipc_data_destroy(outdata);
76 return CONTACTS_ERROR_IPC;
79 if (CONTACTS_ERROR_NONE == ret) {
80 int transaction_ver = 0;
81 if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &transaction_ver)) {
82 CTS_ERR("ctsvc_ipc_unmarshal_int() Fail");
83 pims_ipc_data_destroy(outdata);
84 return CONTACTS_ERROR_IPC;
86 ctsvc_client_ipc_set_change_version(contact, transaction_ver);
89 pims_ipc_data_destroy(outdata);
96 int ctsvc_client_phone_log_delete(contacts_h contact, contacts_phone_log_delete_e op, va_list args)
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;
109 RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
111 indata = pims_ipc_data_create(0);
112 if (indata == NULL) {
113 CTS_ERR("ipc data created fail!");
114 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
115 pims_ipc_data_destroy(indata);
119 ret = ctsvc_ipc_marshal_handle(contact, indata);
120 if (CONTACTS_ERROR_NONE != ret) {
121 CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
122 pims_ipc_data_destroy(indata);
126 ret = ctsvc_ipc_marshal_int(op, indata);
127 if (ret != CONTACTS_ERROR_NONE) {
128 CTS_ERR("ctsvc_ipc_marshal_int fail");
129 pims_ipc_data_destroy(indata);
134 case CONTACTS_PHONE_LOG_DELETE_BY_ADDRESS:
135 number = va_arg(args, char *);
136 if (NULL == number) {
137 pims_ipc_data_destroy(indata);
138 return CONTACTS_ERROR_INVALID_PARAMETER;
140 ret = ctsvc_ipc_marshal_string(number, indata);
141 if (ret != CONTACTS_ERROR_NONE) {
142 CTS_ERR("ctsvc_ipc_marshal_string fail");
143 pims_ipc_data_destroy(indata);
147 case CONTACTS_PHONE_LOG_DELETE_BY_MESSAGE_EXTRA_DATA1:
148 case CONTACTS_PHONE_LOG_DELETE_BY_EMAIL_EXTRA_DATA1:
149 extra_data1 = va_arg(args, int);
150 ret = ctsvc_ipc_marshal_int(extra_data1, indata);
151 if (ret != CONTACTS_ERROR_NONE) {
152 CTS_ERR("ctsvc_ipc_marshal_int fail");
153 pims_ipc_data_destroy(indata);
158 CTS_ERR("Invalid parameter : operation is not proper (%d)", ret);
159 pims_ipc_data_destroy(indata);
160 return CONTACTS_ERROR_INVALID_PARAMETER;
163 if (ctsvc_ipc_call(CTSVC_IPC_PHONELOG_MODULE,
164 CTSVC_IPC_SERVER_PHONELOG_DELETE, indata, &outdata) != 0) {
165 CTS_ERR("ctsvc_ipc_call failed");
166 pims_ipc_data_destroy(indata);
167 return CONTACTS_ERROR_IPC;
170 pims_ipc_data_destroy(indata);
173 if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &ret)) {
174 CTS_ERR("ctsvc_ipc_unmarshal_int() Fail");
175 pims_ipc_data_destroy(outdata);
176 return CONTACTS_ERROR_IPC;
178 if (CONTACTS_ERROR_NONE == ret) {
179 int transaction_ver = 0;
180 if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &transaction_ver)) {
181 CTS_ERR("ctsvc_ipc_unmarshal_int() Fail");
182 pims_ipc_data_destroy(outdata);
183 return CONTACTS_ERROR_IPC;
185 ctsvc_client_ipc_set_change_version(contact, transaction_ver);
188 pims_ipc_data_destroy(outdata);