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.
21 #include <pims-ipc-data.h>
24 #include "contacts_phone_log_internal.h"
25 #include "ctsvc_internal.h"
26 #include "ctsvc_ipc_define.h"
27 #include "ctsvc_client_ipc.h"
28 #include "ctsvc_ipc_marshal.h"
30 API int contacts_phone_log_reset_statistics(void)
32 #ifndef ENABLE_LOG_FEATURE
33 return CONTACTS_ERROR_NOT_SUPPORTED;
34 #endif // ENABLE_LOG_FEATURE
36 int ret = CONTACTS_ERROR_NONE;
38 pims_ipc_data_h indata = NULL;
39 pims_ipc_data_h outdata = NULL;
42 indata = pims_ipc_data_create(0);
45 CTS_ERR("ipc data created fail!");
46 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
51 if (ctsvc_ipc_call(CTSVC_IPC_PHONELOG_MODULE, CTSVC_IPC_SERVER_PHONELOG_RESET_STATISTICS, indata, &outdata) != 0)
53 CTS_ERR("ctsvc_ipc_call failed");
54 pims_ipc_data_destroy(indata);
55 return CONTACTS_ERROR_IPC;
58 pims_ipc_data_destroy(indata);
63 unsigned int size = 0;
64 ret = *(int*) pims_ipc_data_get(outdata, &size);
66 if (CONTACTS_ERROR_NONE == ret) {
67 int transaction_ver = 0;
68 transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
69 ctsvc_client_ipc_set_change_version(transaction_ver);
72 pims_ipc_data_destroy(outdata);
79 API int contacts_phone_log_delete(contacts_phone_log_delete_e op, ...)
81 #ifndef ENABLE_LOG_FEATURE
82 return CONTACTS_ERROR_NOT_SUPPORTED;
83 #endif // ENABLE_LOG_FEATURE
85 int ret = CONTACTS_ERROR_NONE;
87 pims_ipc_data_h indata = NULL;
88 pims_ipc_data_h outdata = NULL;
94 indata = pims_ipc_data_create(0);
96 CTS_ERR("ipc data created fail!");
97 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
98 pims_ipc_data_destroy(indata);
102 ret = ctsvc_ipc_marshal_int( op, indata);
103 if (ret != CONTACTS_ERROR_NONE) {
104 CTS_ERR("ctsvc_ipc_marshal_int fail");
105 pims_ipc_data_destroy(indata);
110 case CONTACTS_PHONE_LOG_DELETE_BY_ADDRESS:
112 number = va_arg(args, char *);
114 if (NULL == number) {
115 pims_ipc_data_destroy(indata);
116 return CONTACTS_ERROR_INVALID_PARAMETER;
118 ret = ctsvc_ipc_marshal_string(number, indata);
119 if (ret != CONTACTS_ERROR_NONE) {
120 CTS_ERR("ctsvc_ipc_marshal_string fail");
121 pims_ipc_data_destroy(indata);
125 case CONTACTS_PHONE_LOG_DELETE_BY_MESSAGE_EXTRA_DATA1:
126 case CONTACTS_PHONE_LOG_DELETE_BY_EMAIL_EXTRA_DATA1:
128 extra_data1 = va_arg(args, int);
130 ret = ctsvc_ipc_marshal_int(extra_data1, indata);
131 if (ret != CONTACTS_ERROR_NONE) {
132 CTS_ERR("ctsvc_ipc_marshal_int fail");
133 pims_ipc_data_destroy(indata);
138 CTS_ERR("Invalid parameter : operation is not proper (%d)", ret);
139 pims_ipc_data_destroy(indata);
140 return CONTACTS_ERROR_INVALID_PARAMETER;
143 if (ctsvc_ipc_call(CTSVC_IPC_PHONELOG_MODULE,
144 CTSVC_IPC_SERVER_PHONELOG_DELETE, indata, &outdata) != 0) {
145 CTS_ERR("ctsvc_ipc_call failed");
146 pims_ipc_data_destroy(indata);
147 return CONTACTS_ERROR_IPC;
150 pims_ipc_data_destroy(indata);
153 unsigned int size = 0;
154 ret = *(int*) pims_ipc_data_get(outdata, &size);
156 if (CONTACTS_ERROR_NONE == ret) {
157 int transaction_ver = 0;
158 transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
159 ctsvc_client_ipc_set_change_version(transaction_ver);
162 pims_ipc_data_destroy(outdata);