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);
74 unsigned int size = 0;
75 ret = *(int*) pims_ipc_data_get(outdata, &size);
77 if (CONTACTS_ERROR_NONE == ret) {
78 int transaction_ver = 0;
79 transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
80 ctsvc_client_ipc_set_change_version(contact, transaction_ver);
83 pims_ipc_data_destroy(outdata);
90 int ctsvc_client_phone_log_delete(contacts_h contact, contacts_phone_log_delete_e op, va_list args)
92 #ifndef ENABLE_LOG_FEATURE
93 return CONTACTS_ERROR_NOT_SUPPORTED;
94 #endif /* ENABLE_LOG_FEATURE */
96 int ret = CONTACTS_ERROR_NONE;
98 pims_ipc_data_h indata = NULL;
99 pims_ipc_data_h outdata = NULL;
103 RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
105 indata = pims_ipc_data_create(0);
106 if (indata == NULL) {
107 CTS_ERR("ipc data created fail!");
108 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
109 pims_ipc_data_destroy(indata);
113 ret = ctsvc_ipc_marshal_handle(contact, indata);
114 if (CONTACTS_ERROR_NONE != ret) {
115 CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
116 pims_ipc_data_destroy(indata);
120 ret = ctsvc_ipc_marshal_int(op, indata);
121 if (ret != CONTACTS_ERROR_NONE) {
122 CTS_ERR("ctsvc_ipc_marshal_int fail");
123 pims_ipc_data_destroy(indata);
128 case CONTACTS_PHONE_LOG_DELETE_BY_ADDRESS:
129 number = va_arg(args, char *);
130 if (NULL == number) {
131 pims_ipc_data_destroy(indata);
132 return CONTACTS_ERROR_INVALID_PARAMETER;
134 ret = ctsvc_ipc_marshal_string(number, indata);
135 if (ret != CONTACTS_ERROR_NONE) {
136 CTS_ERR("ctsvc_ipc_marshal_string fail");
137 pims_ipc_data_destroy(indata);
141 case CONTACTS_PHONE_LOG_DELETE_BY_MESSAGE_EXTRA_DATA1:
142 case CONTACTS_PHONE_LOG_DELETE_BY_EMAIL_EXTRA_DATA1:
143 extra_data1 = va_arg(args, int);
144 ret = ctsvc_ipc_marshal_int(extra_data1, indata);
145 if (ret != CONTACTS_ERROR_NONE) {
146 CTS_ERR("ctsvc_ipc_marshal_int fail");
147 pims_ipc_data_destroy(indata);
152 CTS_ERR("Invalid parameter : operation is not proper (%d)", ret);
153 pims_ipc_data_destroy(indata);
154 return CONTACTS_ERROR_INVALID_PARAMETER;
157 if (ctsvc_ipc_call(CTSVC_IPC_PHONELOG_MODULE,
158 CTSVC_IPC_SERVER_PHONELOG_DELETE, indata, &outdata) != 0) {
159 CTS_ERR("ctsvc_ipc_call failed");
160 pims_ipc_data_destroy(indata);
161 return CONTACTS_ERROR_IPC;
164 pims_ipc_data_destroy(indata);
167 unsigned int size = 0;
168 ret = *(int*) pims_ipc_data_get(outdata, &size);
170 if (CONTACTS_ERROR_NONE == ret) {
171 int transaction_ver = 0;
172 transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
173 ctsvc_client_ipc_set_change_version(contact, transaction_ver);
176 pims_ipc_data_destroy(outdata);