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.
23 #include "ctsvc_internal.h"
24 #include "ctsvc_ipc_define.h"
25 #include "ctsvc_client_ipc.h"
26 #include <pims-ipc-data.h>
27 #include "ctsvc_ipc_marshal.h"
29 API int contacts_group_add_contact(int group_id, int contact_id)
31 int ret = CONTACTS_ERROR_NONE;
33 pims_ipc_data_h indata = NULL;
34 pims_ipc_data_h outdata = NULL;
36 RETVM_IF(group_id <= 0 || contact_id <= 0, CONTACTS_ERROR_INVALID_PARAMETER,"id should be greater than 0");
37 RETVM_IF(ctsvc_get_ipc_handle() == NULL,CONTACTS_ERROR_IPC,"contacts not connected");
40 indata = pims_ipc_data_create(0);
43 CTS_ERR("ipc data created fail!");
44 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
48 ret = ctsvc_ipc_marshal_int( group_id, indata);
49 if (ret != CONTACTS_ERROR_NONE)
51 CTS_ERR("marshal fail");
54 ret = ctsvc_ipc_marshal_int( contact_id, indata);
55 if (ret != CONTACTS_ERROR_NONE)
57 CTS_ERR("marshal fail");
62 if (ctsvc_ipc_call(CTSVC_IPC_GROUP_MODULE, CTSVC_IPC_SERVER_GROUP_ADD_CONTACT, indata, &outdata) != 0)
64 CTS_ERR("ctsvc_ipc_call failed");
65 return CONTACTS_ERROR_IPC;
70 pims_ipc_data_destroy(indata);
76 unsigned int size = 0;
77 ret = *(int*) pims_ipc_data_get(outdata, &size);
79 if (CONTACTS_ERROR_NONE == ret) {
80 int transaction_ver = 0;
81 transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
82 ctsvc_client_ipc_set_change_version(transaction_ver);
85 pims_ipc_data_destroy(outdata);
91 API int contacts_group_remove_contact(int group_id, int contact_id)
93 int ret = CONTACTS_ERROR_NONE;
95 pims_ipc_data_h indata = NULL;
96 pims_ipc_data_h outdata = NULL;
98 RETVM_IF(group_id <= 0 || contact_id <= 0, CONTACTS_ERROR_INVALID_PARAMETER,"id should be greater than 0");
99 RETVM_IF(ctsvc_get_ipc_handle() == NULL,CONTACTS_ERROR_IPC,"contacts not connected");
102 indata = pims_ipc_data_create(0);
105 CTS_ERR("ipc data created fail!");
106 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
110 ret = ctsvc_ipc_marshal_int( group_id, indata);
111 if (ret != CONTACTS_ERROR_NONE)
113 CTS_ERR("marshal fail");
116 ret = ctsvc_ipc_marshal_int( contact_id, indata);
117 if (ret != CONTACTS_ERROR_NONE)
119 CTS_ERR("marshal fail");
124 if (ctsvc_ipc_call(CTSVC_IPC_GROUP_MODULE, CTSVC_IPC_SERVER_GROUP_REMOVE_CONTACT, indata, &outdata) != 0)
126 CTS_ERR("ctsvc_ipc_call failed");
127 return CONTACTS_ERROR_IPC;
132 pims_ipc_data_destroy(indata);
138 unsigned int size = 0;
139 ret = *(int*) pims_ipc_data_get(outdata, &size);
141 if (CONTACTS_ERROR_NONE == ret) {
142 int transaction_ver = 0;
143 transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
144 ctsvc_client_ipc_set_change_version(transaction_ver);
147 pims_ipc_data_destroy(outdata);
153 API int contacts_group_set_group_order(int group_id, int previous_group_id, int next_group_id)
155 int ret = CONTACTS_ERROR_NONE;
157 pims_ipc_data_h indata = NULL;
158 pims_ipc_data_h outdata = NULL;
160 RETVM_IF(group_id <= 0 || previous_group_id < 0 || next_group_id < 0, CONTACTS_ERROR_INVALID_PARAMETER,"id should be greater than 0");
161 RETVM_IF(ctsvc_get_ipc_handle() == NULL,CONTACTS_ERROR_IPC,"contacts not connected");
164 indata = pims_ipc_data_create(0);
167 CTS_ERR("ipc data created fail!");
168 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
172 ret = ctsvc_ipc_marshal_int( group_id, indata);
173 if (ret != CONTACTS_ERROR_NONE)
175 CTS_ERR("marshal fail");
176 pims_ipc_data_destroy(indata);
179 ret = ctsvc_ipc_marshal_int( previous_group_id, indata);
180 if (ret != CONTACTS_ERROR_NONE)
182 CTS_ERR("marshal fail");
183 pims_ipc_data_destroy(indata);
186 ret = ctsvc_ipc_marshal_int( next_group_id, indata);
187 if (ret != CONTACTS_ERROR_NONE)
189 CTS_ERR("marshal fail");
190 pims_ipc_data_destroy(indata);
195 if (ctsvc_ipc_call(CTSVC_IPC_GROUP_MODULE, CTSVC_IPC_SERVER_GROUP_SET_GROUP_ORDER, indata, &outdata) != 0)
197 CTS_ERR("ctsvc_ipc_call failed");
198 pims_ipc_data_destroy(indata);
199 return CONTACTS_ERROR_IPC;
204 pims_ipc_data_destroy(indata);
210 unsigned int size = 0;
211 ret = *(int*) pims_ipc_data_get(outdata, &size);
213 if (CONTACTS_ERROR_NONE == ret) {
214 int transaction_ver = 0;
215 transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
216 ctsvc_client_ipc_set_change_version(transaction_ver);
219 pims_ipc_data_destroy(outdata);