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 "ctsvc_internal.h"
25 #include "ctsvc_ipc_define.h"
26 #include "ctsvc_client_ipc.h"
27 #include "ctsvc_ipc_marshal.h"
29 API int contacts_person_link_person(int base_person_id, int person_id)
32 int ret = CONTACTS_ERROR_NONE;
34 pims_ipc_data_h indata = NULL;
35 pims_ipc_data_h outdata = NULL;
37 RETVM_IF(base_person_id <= 0 || person_id <= 0, CONTACTS_ERROR_INVALID_PARAMETER,"id should be greater than 0");
40 indata = pims_ipc_data_create(0);
43 CTS_ERR("ipc data created fail!");
44 return CONTACTS_ERROR_OUT_OF_MEMORY;
49 if( ctsvc_ipc_marshal_int( base_person_id, indata) != CONTACTS_ERROR_NONE ) break;
50 if( ctsvc_ipc_marshal_int( person_id, indata) != CONTACTS_ERROR_NONE ) break;
55 if( success == false ) {
56 CTS_ERR("marshal fail");
57 pims_ipc_data_destroy(indata);
58 return CONTACTS_ERROR_IPC;
62 ret = ctsvc_ipc_marshal_int( base_person_id, indata);
63 if (ret != CONTACTS_ERROR_NONE)
65 CTS_ERR("marshal fail");
68 ret = ctsvc_ipc_marshal_int( person_id, indata);
69 if (ret != CONTACTS_ERROR_NONE)
71 CTS_ERR("marshal fail");
77 if (ctsvc_ipc_call(CTSVC_IPC_PERSON_MODULE, CTSVC_IPC_SERVER_PERSON_LINK_PERSON, indata, &outdata) != 0)
79 CTS_ERR("ctsvc_ipc_call failed");
80 pims_ipc_data_destroy(indata);
81 return CONTACTS_ERROR_IPC;
84 pims_ipc_data_destroy(indata);
89 unsigned int size = 0;
90 ret = *(int*) pims_ipc_data_get(outdata, &size);
92 if (CONTACTS_ERROR_NONE == ret) {
93 int transaction_ver = 0;
94 transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
95 ctsvc_client_ipc_set_change_version(transaction_ver);
98 pims_ipc_data_destroy(outdata);
104 API int contacts_person_unlink_contact(int person_id, int contact_id, int* unlinked_person_id)
106 int ret = CONTACTS_ERROR_NONE;
108 pims_ipc_data_h indata = NULL;
109 pims_ipc_data_h outdata = NULL;
111 RETVM_IF(person_id <= 0 || contact_id <= 0, CONTACTS_ERROR_INVALID_PARAMETER,"id should be greater than 0");
113 if (unlinked_person_id)
114 *unlinked_person_id = 0;
117 indata = pims_ipc_data_create(0);
120 CTS_ERR("ipc data created fail!");
121 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
125 ret = ctsvc_ipc_marshal_int( person_id, indata);
126 if (ret != CONTACTS_ERROR_NONE)
128 CTS_ERR("marshal fail");
129 pims_ipc_data_destroy(indata);
132 ret = ctsvc_ipc_marshal_int( contact_id, indata);
133 if (ret != CONTACTS_ERROR_NONE)
135 CTS_ERR("marshal fail");
136 pims_ipc_data_destroy(indata);
141 if (ctsvc_ipc_call(CTSVC_IPC_PERSON_MODULE, CTSVC_IPC_SERVER_PERSON_UNLINK_CONTACT, indata, &outdata) != 0)
143 CTS_ERR("ctsvc_ipc_call failed");
144 pims_ipc_data_destroy(indata);
145 return CONTACTS_ERROR_IPC;
148 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);
161 if (unlinked_person_id)
162 *unlinked_person_id = *(int*)pims_ipc_data_get(outdata,&size);
165 pims_ipc_data_destroy(outdata);
171 API int contacts_person_reset_usage(int person_id, contacts_usage_type_e type)
173 int ret = CONTACTS_ERROR_NONE;
175 pims_ipc_data_h indata = NULL;
176 pims_ipc_data_h outdata = NULL;
178 RETVM_IF(person_id <= 0, CONTACTS_ERROR_INVALID_PARAMETER,"contact_id should be greater than 0");
181 indata = pims_ipc_data_create(0);
184 CTS_ERR("ipc data created fail!");
185 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
189 ret = ctsvc_ipc_marshal_int( person_id, indata);
190 if (ret != CONTACTS_ERROR_NONE)
192 CTS_ERR("marshal fail");
193 pims_ipc_data_destroy(indata);
196 ret = ctsvc_ipc_marshal_int( (int)type, indata);
197 if (ret != CONTACTS_ERROR_NONE)
199 CTS_ERR("marshal fail");
200 pims_ipc_data_destroy(indata);
205 if (ctsvc_ipc_call(CTSVC_IPC_PERSON_MODULE, CTSVC_IPC_SERVER_PERSON_RESET_USAGE, indata, &outdata) != 0)
207 CTS_ERR("ctsvc_ipc_call failed");
208 pims_ipc_data_destroy(indata);
209 return CONTACTS_ERROR_IPC;
212 pims_ipc_data_destroy(indata);
217 unsigned int size = 0;
218 ret = *(int*) pims_ipc_data_get(outdata, &size);
220 if (CONTACTS_ERROR_NONE == ret) {
221 int transaction_ver = 0;
222 transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
223 ctsvc_client_ipc_set_change_version(transaction_ver);
226 pims_ipc_data_destroy(outdata);
232 API int contacts_person_set_favorite_order(int person_id, int previous_person_id, int next_person_id)
234 int ret = CONTACTS_ERROR_NONE;
236 pims_ipc_data_h indata = NULL;
237 pims_ipc_data_h outdata = NULL;
239 RETVM_IF(person_id <= 0 || previous_person_id < 0 || next_person_id < 0, CONTACTS_ERROR_INVALID_PARAMETER,"id should be greater than 0");
242 indata = pims_ipc_data_create(0);
245 CTS_ERR("ipc data created fail!");
246 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
250 ret = ctsvc_ipc_marshal_int( person_id, indata);
251 if (ret != CONTACTS_ERROR_NONE)
253 CTS_ERR("marshal fail");
254 pims_ipc_data_destroy(indata);
257 ret = ctsvc_ipc_marshal_int( previous_person_id, indata);
258 if (ret != CONTACTS_ERROR_NONE)
260 CTS_ERR("marshal fail");
261 pims_ipc_data_destroy(indata);
264 ret = ctsvc_ipc_marshal_int( next_person_id, indata);
265 if (ret != CONTACTS_ERROR_NONE)
267 CTS_ERR("marshal fail");
268 pims_ipc_data_destroy(indata);
273 if (ctsvc_ipc_call(CTSVC_IPC_PERSON_MODULE, CTSVC_IPC_SERVER_PERSON_SET_FAVORITE_ORDER, indata, &outdata) != 0)
275 CTS_ERR("ctsvc_ipc_call failed");
276 pims_ipc_data_destroy(indata);
277 return CONTACTS_ERROR_IPC;
280 pims_ipc_data_destroy(indata);
285 unsigned int size = 0;
286 ret = *(int*) pims_ipc_data_get(outdata, &size);
288 if (CONTACTS_ERROR_NONE == ret) {
289 int transaction_ver = 0;
290 transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
291 ctsvc_client_ipc_set_change_version(transaction_ver);
294 pims_ipc_data_destroy(outdata);
301 API int contacts_person_set_default_property(contacts_person_property_e property,
302 int person_id, int id)
304 int ret = CONTACTS_ERROR_NONE;
306 pims_ipc_data_h indata = NULL;
307 pims_ipc_data_h outdata = NULL;
309 RETVM_IF(person_id <= 0 || id <= 0, CONTACTS_ERROR_INVALID_PARAMETER,"id should be greater than 0");
312 indata = pims_ipc_data_create(0);
315 CTS_ERR("ipc data created fail!");
316 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
320 ret = ctsvc_ipc_marshal_int( person_id, indata);
321 if (ret != CONTACTS_ERROR_NONE)
323 CTS_ERR("marshal fail");
324 pims_ipc_data_destroy(indata);
327 ret = ctsvc_ipc_marshal_unsigned_int( property, indata);
328 if (ret != CONTACTS_ERROR_NONE)
330 CTS_ERR("marshal fail");
331 pims_ipc_data_destroy(indata);
334 ret = ctsvc_ipc_marshal_int( id, indata);
335 if (ret != CONTACTS_ERROR_NONE)
337 CTS_ERR("marshal fail");
338 pims_ipc_data_destroy(indata);
343 if (ctsvc_ipc_call(CTSVC_IPC_PERSON_MODULE, CTSVC_IPC_SERVER_PERSON_SET_DEFAULT_PROPERTY, indata, &outdata) != 0)
345 CTS_ERR("ctsvc_ipc_call failed");
346 pims_ipc_data_destroy(indata);
347 return CONTACTS_ERROR_IPC;
350 pims_ipc_data_destroy(indata);
355 unsigned int size = 0;
356 ret = *(int*) pims_ipc_data_get(outdata, &size);
357 if (CONTACTS_ERROR_NONE == ret) {
358 int transaction_ver = 0;
359 transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
360 ctsvc_client_ipc_set_change_version(transaction_ver);
363 pims_ipc_data_destroy(outdata);
369 API int contacts_person_get_default_property(contacts_person_property_e property,
370 int person_id, int *id)
372 int ret = CONTACTS_ERROR_NONE;
373 pims_ipc_data_h indata = NULL;
374 pims_ipc_data_h outdata = NULL;
376 RETVM_IF(person_id <= 0 || id == NULL, CONTACTS_ERROR_INVALID_PARAMETER,"id should be greater than 0");
380 indata = pims_ipc_data_create(0);
381 if (indata == NULL) {
382 CTS_ERR("ipc data created fail!");
383 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
387 ret = ctsvc_ipc_marshal_int(person_id, indata);
388 if (ret != CONTACTS_ERROR_NONE) {
389 CTS_ERR("marshal fail");
390 pims_ipc_data_destroy(indata);
394 ret = ctsvc_ipc_marshal_unsigned_int(property, indata);
395 if (ret != CONTACTS_ERROR_NONE) {
396 CTS_ERR("marshal fail");
397 pims_ipc_data_destroy(indata);
402 if (ctsvc_ipc_call(CTSVC_IPC_PERSON_MODULE, CTSVC_IPC_SERVER_PERSON_GET_DEFAULT_PROPERTY,
403 indata, &outdata) != 0) {
404 CTS_ERR("ctsvc_ipc_call failed");
405 pims_ipc_data_destroy(indata);
406 return CONTACTS_ERROR_IPC;
409 pims_ipc_data_destroy(indata);
413 unsigned int size = 0;
414 ret = *(int*) pims_ipc_data_get(outdata, &size);
415 if (ret == CONTACTS_ERROR_NONE) {
417 *id = *(int*)pims_ipc_data_get(outdata,&size);
419 pims_ipc_data_destroy(outdata);