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.
21 #include <pims-ipc-data.h>
24 #include "ctsvc_internal.h"
25 #include "ctsvc_ipc_define.h"
26 #include "ctsvc_ipc_marshal.h"
27 #include "ctsvc_client_ipc.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";
35 int ctsvc_client_activity_delete_by_contact_id(contacts_h contact, int contact_id)
37 int ret = CONTACTS_ERROR_NONE;
38 pims_ipc_data_h indata = NULL;
39 pims_ipc_data_h outdata = NULL;
41 RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
42 RETVM_IF(contact_id <= 0,CONTACTS_ERROR_INVALID_PARAMETER,"id should be greater than 0");
45 indata = pims_ipc_data_create(0);
47 CTS_ERR("ipc data created fail!");
48 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
52 ret = ctsvc_ipc_marshal_handle(contact, indata);
53 if (CONTACTS_ERROR_NONE != ret) {
54 CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
55 pims_ipc_data_destroy(indata);
59 ret = ctsvc_ipc_marshal_int(contact_id, indata);
60 if (ret != CONTACTS_ERROR_NONE) {
61 CTS_ERR("marshal fail");
62 pims_ipc_data_destroy(indata);
67 if (ctsvc_ipc_call(CTSVC_IPC_ACTIVITY_MODULE, CTSVC_IPC_SERVER_ACTIVITY_DELETE_BY_CONTACT_ID, indata, &outdata) != 0) {
68 CTS_ERR("ctsvc_ipc_call failed");
69 pims_ipc_data_destroy(indata);
70 return CONTACTS_ERROR_IPC;
73 pims_ipc_data_destroy(indata);
76 int transaction_ver = 0;
79 if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &ret)) {
80 CTS_ERR("ctsvc_ipc_unmarshal_int() Fail");
81 pims_ipc_data_destroy(outdata);
82 return CONTACTS_ERROR_IPC;
84 if (CONTACTS_ERROR_NONE == ret) {
85 if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &transaction_ver)) {
86 CTS_ERR("ctsvc_ipc_unmarshal_int() Fail");
87 pims_ipc_data_destroy(outdata);
88 return CONTACTS_ERROR_IPC;
90 ctsvc_client_ipc_set_change_version(contact, transaction_ver);
92 pims_ipc_data_destroy(outdata);
98 int ctsvc_client_activity_delete_by_account_id(contacts_h contact, int account_id)
100 int ret = CONTACTS_ERROR_NONE;
101 pims_ipc_data_h indata = NULL;
102 pims_ipc_data_h outdata = NULL;
104 RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
105 RETVM_IF(account_id <= 0,CONTACTS_ERROR_INVALID_PARAMETER,"id should be greater than 0");
108 indata = pims_ipc_data_create(0);
109 if (indata == NULL) {
110 CTS_ERR("ipc data created fail!");
111 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
115 ret = ctsvc_ipc_marshal_handle(contact, indata);
116 if (CONTACTS_ERROR_NONE != ret) {
117 CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
118 pims_ipc_data_destroy(indata);
122 ret = ctsvc_ipc_marshal_int(account_id, indata);
123 if (ret != CONTACTS_ERROR_NONE) {
124 CTS_ERR("marshal fail");
125 pims_ipc_data_destroy(indata);
130 if (ctsvc_ipc_call(CTSVC_IPC_ACTIVITY_MODULE, CTSVC_IPC_SERVER_ACTIVITY_DELETE_BY_ACCOUNT_ID, indata, &outdata) != 0) {
131 CTS_ERR("ctsvc_ipc_call failed");
132 pims_ipc_data_destroy(indata);
133 return CONTACTS_ERROR_IPC;
136 pims_ipc_data_destroy(indata);
139 int transaction_ver = 0;
140 if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &ret)) {
141 CTS_ERR("ctsvc_ipc_unmarshal_int() Fail");
142 pims_ipc_data_destroy(outdata);
143 return CONTACTS_ERROR_IPC;
146 if (CONTACTS_ERROR_NONE == ret) {
147 if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &transaction_ver)) {
148 CTS_ERR("ctsvc_ipc_unmarshal_int() Fail");
149 pims_ipc_data_destroy(outdata);
150 return CONTACTS_ERROR_IPC;
152 ctsvc_client_ipc_set_change_version(contact, transaction_ver);
154 pims_ipc_data_destroy(outdata);