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.
20 #include <pims-ipc-data.h>
23 #include "ctsvc_internal.h"
24 #include "ctsvc_ipc_define.h"
25 #include "ctsvc_ipc_marshal.h"
26 #include "ctsvc_client_ipc.h"
29 int ctsvc_client_activity_delete_by_contact_id(contacts_h contact, int contact_id)
31 int ret = CONTACTS_ERROR_NONE;
32 pims_ipc_data_h indata = NULL;
33 pims_ipc_data_h outdata = NULL;
35 RETV_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER);
36 RETVM_IF(contact_id <= 0, CONTACTS_ERROR_INVALID_PARAMETER,
37 "id should be greater than 0");
40 indata = pims_ipc_data_create(0);
43 ERR("pims_ipc_data_create() Fail");
44 return CONTACTS_ERROR_OUT_OF_MEMORY;
48 ret = ctsvc_ipc_marshal_handle(contact, indata);
49 if (CONTACTS_ERROR_NONE != ret) {
51 ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
52 pims_ipc_data_destroy(indata);
57 ret = ctsvc_ipc_marshal_int(contact_id, indata);
58 if (ret != CONTACTS_ERROR_NONE) {
60 ERR("ctsvc_ipc_marshal_int() Fail(%d)", ret);
61 pims_ipc_data_destroy(indata);
67 ret = ctsvc_ipc_call(CTSVC_IPC_ACTIVITY_MODULE,
68 CTSVC_IPC_SERVER_ACTIVITY_DELETE_BY_CONTACT_ID, indata, &outdata);
71 ERR("ctsvc_ipc_call() Fail(%d)", ret);
72 pims_ipc_data_destroy(indata);
73 return CONTACTS_ERROR_IPC;
77 pims_ipc_data_destroy(indata);
80 int transaction_ver = 0;
83 if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &ret)) {
85 ERR("ctsvc_ipc_unmarshal_int() Fail");
86 pims_ipc_data_destroy(outdata);
87 return CONTACTS_ERROR_IPC;
90 if (CONTACTS_ERROR_NONE == ret) {
91 if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &transaction_ver)) {
93 ERR("ctsvc_ipc_unmarshal_int() Fail");
94 pims_ipc_data_destroy(outdata);
95 return CONTACTS_ERROR_IPC;
98 ctsvc_client_ipc_set_change_version(contact, transaction_ver);
100 pims_ipc_data_destroy(outdata);
106 int ctsvc_client_activity_delete_by_account_id(contacts_h contact, int account_id)
108 int ret = CONTACTS_ERROR_NONE;
109 pims_ipc_data_h indata = NULL;
110 pims_ipc_data_h outdata = NULL;
112 RETV_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER);
113 RETVM_IF(account_id <= 0, CONTACTS_ERROR_INVALID_PARAMETER,
114 "id should be greater than 0");
117 indata = pims_ipc_data_create(0);
118 if (indata == NULL) {
119 /* LCOV_EXCL_START */
120 ERR("pims_ipc_data_create() Fail");
121 return CONTACTS_ERROR_OUT_OF_MEMORY;
125 ret = ctsvc_ipc_marshal_handle(contact, indata);
126 if (CONTACTS_ERROR_NONE != ret) {
127 /* LCOV_EXCL_START */
128 ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
129 pims_ipc_data_destroy(indata);
134 ret = ctsvc_ipc_marshal_int(account_id, indata);
135 if (ret != CONTACTS_ERROR_NONE) {
136 /* LCOV_EXCL_START */
137 ERR("ctsvc_ipc_marshal_int() Fail");
138 pims_ipc_data_destroy(indata);
144 ret = ctsvc_ipc_call(CTSVC_IPC_ACTIVITY_MODULE,
145 CTSVC_IPC_SERVER_ACTIVITY_DELETE_BY_ACCOUNT_ID, indata, &outdata);
147 /* LCOV_EXCL_START */
148 ERR("ctsvc_ipc_call() Fail(%d)", ret);
149 pims_ipc_data_destroy(indata);
150 return CONTACTS_ERROR_IPC;
154 pims_ipc_data_destroy(indata);
157 int transaction_ver = 0;
158 if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &ret)) {
159 /* LCOV_EXCL_START */
160 ERR("ctsvc_ipc_unmarshal_int() Fail");
161 pims_ipc_data_destroy(outdata);
162 return CONTACTS_ERROR_IPC;
166 if (CONTACTS_ERROR_NONE == ret) {
167 if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &transaction_ver)) {
168 /* LCOV_EXCL_START */
169 ERR("ctsvc_ipc_unmarshal_int() Fail");
170 pims_ipc_data_destroy(outdata);
171 return CONTACTS_ERROR_IPC;
174 ctsvc_client_ipc_set_change_version(contact, transaction_ver);
176 pims_ipc_data_destroy(outdata);