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"
28 static const char CONTACTS_READ_PRIVILEGE_ID[] = "http://tizen.org/privilege/contact.read";
29 static const char CONTACTS_WRITE_PRIVILEGE_ID[] = "http://tizen.org/privilege/contact.write";
30 static const char PHONELOG_READ_PRIVILEGE_ID[] = "http://tizen.org/privilege/callhistory.read";
31 static const char PHONELOG_WRITE_PRIVILEGE_ID[] = "http://tizen.org/privilege/callhistory.write";
34 int ctsvc_client_activity_delete_by_contact_id(contacts_h contact, int contact_id)
36 int ret = CONTACTS_ERROR_NONE;
37 pims_ipc_data_h indata = NULL;
38 pims_ipc_data_h outdata = NULL;
40 RETV_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER);
41 RETVM_IF(contact_id <= 0, CONTACTS_ERROR_INVALID_PARAMETER,
42 "id should be greater than 0");
45 indata = pims_ipc_data_create(0);
47 ERR("pims_ipc_data_create() Fail");
48 return CONTACTS_ERROR_OUT_OF_MEMORY;
51 ret = ctsvc_ipc_marshal_handle(contact, indata);
52 if (CONTACTS_ERROR_NONE != ret) {
53 ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
54 pims_ipc_data_destroy(indata);
58 ret = ctsvc_ipc_marshal_int(contact_id, indata);
59 if (ret != CONTACTS_ERROR_NONE) {
60 ERR("ctsvc_ipc_marshal_int() Fail(%d)", ret);
61 pims_ipc_data_destroy(indata);
66 ret = ctsvc_ipc_call(CTSVC_IPC_ACTIVITY_MODULE,
67 CTSVC_IPC_SERVER_ACTIVITY_DELETE_BY_CONTACT_ID, indata, &outdata);
69 ERR("ctsvc_ipc_call() Fail(%d)", ret);
70 pims_ipc_data_destroy(indata);
71 return CONTACTS_ERROR_IPC;
74 pims_ipc_data_destroy(indata);
77 int transaction_ver = 0;
80 if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &ret)) {
81 ERR("ctsvc_ipc_unmarshal_int() Fail");
82 pims_ipc_data_destroy(outdata);
83 return CONTACTS_ERROR_IPC;
85 if (CONTACTS_ERROR_NONE == ret) {
86 if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &transaction_ver)) {
87 ERR("ctsvc_ipc_unmarshal_int() Fail");
88 pims_ipc_data_destroy(outdata);
89 return CONTACTS_ERROR_IPC;
91 ctsvc_client_ipc_set_change_version(contact, transaction_ver);
93 pims_ipc_data_destroy(outdata);
99 int ctsvc_client_activity_delete_by_account_id(contacts_h contact, int account_id)
101 int ret = CONTACTS_ERROR_NONE;
102 pims_ipc_data_h indata = NULL;
103 pims_ipc_data_h outdata = NULL;
105 RETV_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER);
106 RETVM_IF(account_id <= 0, CONTACTS_ERROR_INVALID_PARAMETER,
107 "id should be greater than 0");
110 indata = pims_ipc_data_create(0);
111 if (indata == NULL) {
112 ERR("pims_ipc_data_create() Fail");
113 return CONTACTS_ERROR_OUT_OF_MEMORY;
116 ret = ctsvc_ipc_marshal_handle(contact, indata);
117 if (CONTACTS_ERROR_NONE != ret) {
118 ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
119 pims_ipc_data_destroy(indata);
123 ret = ctsvc_ipc_marshal_int(account_id, indata);
124 if (ret != CONTACTS_ERROR_NONE) {
125 ERR("ctsvc_ipc_marshal_record() Fail");
126 pims_ipc_data_destroy(indata);
131 ret = ctsvc_ipc_call(CTSVC_IPC_ACTIVITY_MODULE,
132 CTSVC_IPC_SERVER_ACTIVITY_DELETE_BY_ACCOUNT_ID, indata, &outdata);
134 ERR("ctsvc_ipc_call() Fail(%d)", ret);
135 pims_ipc_data_destroy(indata);
136 return CONTACTS_ERROR_IPC;
139 pims_ipc_data_destroy(indata);
142 int transaction_ver = 0;
143 if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &ret)) {
144 ERR("ctsvc_ipc_unmarshal_int() Fail");
145 pims_ipc_data_destroy(outdata);
146 return CONTACTS_ERROR_IPC;
149 if (CONTACTS_ERROR_NONE == ret) {
150 if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &transaction_ver)) {
151 ERR("ctsvc_ipc_unmarshal_int() Fail");
152 pims_ipc_data_destroy(outdata);
153 return CONTACTS_ERROR_IPC;
155 ctsvc_client_ipc_set_change_version(contact, transaction_ver);
157 pims_ipc_data_destroy(outdata);