remove build warning
[platform/core/pim/contacts-service.git] / client / ctsvc_client_person_helper.c
1 /*
2  * Contacts Service
3  *
4  * Copyright (c) 2010 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
5  *
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
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  *
18  */
19 #include <pims-ipc-data.h>
20
21 #include "contacts.h"
22 #include "ctsvc_internal.h"
23 #include "ctsvc_ipc_define.h"
24 #include "ctsvc_client_ipc.h"
25 #include "ctsvc_ipc_marshal.h"
26
27
28 int ctsvc_client_person_link_person(contacts_h contact, int base_person_id, int person_id)
29 {
30         int ret = CONTACTS_ERROR_NONE;
31
32         pims_ipc_data_h indata = NULL;
33         pims_ipc_data_h outdata = NULL;
34
35         RETV_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER);
36         RETVM_IF(base_person_id <= 0 || person_id <= 0, CONTACTS_ERROR_INVALID_PARAMETER,
37                         "id should be greater than 0");
38
39         /* make indata */
40         indata = pims_ipc_data_create(0);
41         if (NULL == indata) {
42                 /* LCOV_EXCL_START */
43                 ERR("pims_ipc_data_create() Fail");
44                 return CONTACTS_ERROR_OUT_OF_MEMORY;
45                 /* LCOV_EXCL_STOP */
46         }
47         ret = ctsvc_ipc_marshal_handle(contact, indata);
48         if (CONTACTS_ERROR_NONE != ret) {
49                 /* LCOV_EXCL_START */
50                 ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
51                 pims_ipc_data_destroy(indata);
52                 return ret;
53                 /* LCOV_EXCL_STOP */
54         }
55
56         bool success = false;
57         do {
58                 if (ctsvc_ipc_marshal_int(base_person_id, indata) != CONTACTS_ERROR_NONE)
59                         break;
60                 if (ctsvc_ipc_marshal_int(person_id, indata) != CONTACTS_ERROR_NONE)
61                         break;
62
63                 success = true;
64         } while (0);
65
66         if (success == false) {
67                 /* LCOV_EXCL_START */
68                 ERR("ctsvc_ipc_marshal_int() Fail");
69                 pims_ipc_data_destroy(indata);
70                 return CONTACTS_ERROR_IPC;
71                 /* LCOV_EXCL_STOP */
72         }
73
74         /*
75            ret = ctsvc_ipc_marshal_int(base_person_id, indata);
76            if (CONTACTS_ERROR_NONE != ret) {
77            ERR("marshal fail");
78            return ret;
79            }
80            ret = ctsvc_ipc_marshal_int(person_id, indata);
81            if (CONTACTS_ERROR_NONE != ret) {
82            ERR("marshal fail");
83            return ret;
84            }
85            */
86
87         /* ipc call */
88         if (ctsvc_ipc_call(CTSVC_IPC_PERSON_MODULE, CTSVC_IPC_SERVER_PERSON_LINK_PERSON,
89                                 indata, &outdata) != 0) {
90                 /* LCOV_EXCL_START */
91                 ERR("ctsvc_ipc_call() Fail");
92                 pims_ipc_data_destroy(indata);
93                 return CONTACTS_ERROR_IPC;
94                 /* LCOV_EXCL_STOP */
95         }
96
97         pims_ipc_data_destroy(indata);
98
99         if (outdata) {
100                 if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &ret)) {
101                         /* LCOV_EXCL_START */
102                         ERR("ctsvc_ipc_unmarshal_int() Fail");
103                         pims_ipc_data_destroy(outdata);
104                         return CONTACTS_ERROR_IPC;
105                         /* LCOV_EXCL_STOP */
106                 }
107
108                 if (CONTACTS_ERROR_NONE == ret) {
109                         int transaction_ver = 0;
110                         if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &transaction_ver)) {
111                                 /* LCOV_EXCL_START */
112                                 ERR("ctsvc_ipc_unmarshal_int() Fail");
113                                 pims_ipc_data_destroy(outdata);
114                                 return CONTACTS_ERROR_IPC;
115                                 /* LCOV_EXCL_STOP */
116                         }
117                         ctsvc_client_ipc_set_change_version(contact, transaction_ver);
118                 }
119
120                 pims_ipc_data_destroy(outdata);
121         }
122
123         return ret;
124 }
125
126 int ctsvc_client_person_unlink_contact(contacts_h contact, int person_id, int contact_id,
127                 int *unlinked_person_id)
128 {
129         int ret = CONTACTS_ERROR_NONE;
130
131         pims_ipc_data_h indata = NULL;
132         pims_ipc_data_h outdata = NULL;
133
134         RETV_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER);
135         RETVM_IF(person_id <= 0 || contact_id <= 0, CONTACTS_ERROR_INVALID_PARAMETER,
136                         "id should be greater than 0");
137
138         if (unlinked_person_id)
139                 *unlinked_person_id = 0;
140
141         /* make indata */
142         indata = pims_ipc_data_create(0);
143         if (NULL == indata) {
144                 /* LCOV_EXCL_START */
145                 ERR("pims_ipc_data_create() Fail");
146                 return CONTACTS_ERROR_OUT_OF_MEMORY;
147                 /* LCOV_EXCL_STOP */
148         }
149
150         ret = ctsvc_ipc_marshal_handle(contact, indata);
151         if (CONTACTS_ERROR_NONE != ret) {
152                 /* LCOV_EXCL_START */
153                 ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
154                 pims_ipc_data_destroy(indata);
155                 return ret;
156                 /* LCOV_EXCL_STOP */
157         }
158
159         ret = ctsvc_ipc_marshal_int(person_id, indata);
160         if (CONTACTS_ERROR_NONE != ret) {
161                 /* LCOV_EXCL_START */
162                 ERR("ctsvc_ipc_marshal_int() Fail(%d)", ret);
163                 pims_ipc_data_destroy(indata);
164                 return ret;
165                 /* LCOV_EXCL_STOP */
166         }
167         ret = ctsvc_ipc_marshal_int(contact_id, indata);
168         if (CONTACTS_ERROR_NONE != ret) {
169                 /* LCOV_EXCL_START */
170                 ERR("ctsvc_ipc_marshal_int() Fail(%d)", ret);
171                 pims_ipc_data_destroy(indata);
172                 return ret;
173                 /* LCOV_EXCL_STOP */
174         }
175
176         /* ipc call */
177         if (ctsvc_ipc_call(CTSVC_IPC_PERSON_MODULE, CTSVC_IPC_SERVER_PERSON_UNLINK_CONTACT,
178                                 indata, &outdata) != 0) {
179                 /* LCOV_EXCL_START */
180                 ERR("ctsvc_ipc_call() Fail");
181                 pims_ipc_data_destroy(indata);
182                 return CONTACTS_ERROR_IPC;
183                 /* LCOV_EXCL_STOP */
184         }
185
186         pims_ipc_data_destroy(indata);
187
188         if (outdata) {
189                 if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &ret)) {
190                         /* LCOV_EXCL_START */
191                         ERR("ctsvc_ipc_unmarshal_int() Fail");
192                         pims_ipc_data_destroy(outdata);
193                         return CONTACTS_ERROR_IPC;
194                         /* LCOV_EXCL_STOP */
195                 }
196
197                 if (CONTACTS_ERROR_NONE == ret) {
198                         int transaction_ver = 0;
199                         if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &transaction_ver)) {
200                                 /* LCOV_EXCL_START */
201                                 ERR("ctsvc_ipc_unmarshal_int() Fail");
202                                 pims_ipc_data_destroy(outdata);
203                                 return CONTACTS_ERROR_IPC;
204                                 /* LCOV_EXCL_STOP */
205                         }
206                         ctsvc_client_ipc_set_change_version(contact, transaction_ver);
207
208                         if (unlinked_person_id) {
209                                 if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata,
210                                                         unlinked_person_id)) {
211                                         /* LCOV_EXCL_START */
212                                         ERR("ctsvc_ipc_unmarshal_int() Fail");
213                                         pims_ipc_data_destroy(outdata);
214                                         return CONTACTS_ERROR_IPC;
215                                         /* LCOV_EXCL_STOP */
216                                 }
217                         }
218                 }
219                 pims_ipc_data_destroy(outdata);
220         }
221
222         return ret;
223 }
224
225 int ctsvc_client_person_reset_usage(contacts_h contact, int person_id,
226                 contacts_usage_type_e type)
227 {
228         int ret = CONTACTS_ERROR_NONE;
229
230         pims_ipc_data_h indata = NULL;
231         pims_ipc_data_h outdata = NULL;
232
233         RETV_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER);
234         RETVM_IF(person_id <= 0, CONTACTS_ERROR_INVALID_PARAMETER,
235                         "contact_id should be greater than 0");
236
237         /* make indata */
238         indata = pims_ipc_data_create(0);
239         if (NULL == indata) {
240                 /* LCOV_EXCL_START */
241                 ERR("pims_ipc_data_create() Fail");
242                 return CONTACTS_ERROR_OUT_OF_MEMORY;
243                 /* LCOV_EXCL_STOP */
244         }
245
246         ret = ctsvc_ipc_marshal_handle(contact, indata);
247         if (CONTACTS_ERROR_NONE != ret) {
248                 /* LCOV_EXCL_START */
249                 ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
250                 pims_ipc_data_destroy(indata);
251                 return ret;
252                 /* LCOV_EXCL_STOP */
253         }
254
255
256         ret = ctsvc_ipc_marshal_int(person_id, indata);
257         if (CONTACTS_ERROR_NONE != ret) {
258                 /* LCOV_EXCL_START */
259                 ERR("ctsvc_ipc_marshal_int() Fail(%d)", ret);
260                 pims_ipc_data_destroy(indata);
261                 return ret;
262                 /* LCOV_EXCL_STOP */
263         }
264         ret = ctsvc_ipc_marshal_int((int)type, indata);
265         if (CONTACTS_ERROR_NONE != ret) {
266                 /* LCOV_EXCL_START */
267                 ERR("ctsvc_ipc_marshal_int() Fail(%d)", ret);
268                 pims_ipc_data_destroy(indata);
269                 return ret;
270                 /* LCOV_EXCL_STOP */
271         }
272
273         /* ipc call */
274         if (ctsvc_ipc_call(CTSVC_IPC_PERSON_MODULE, CTSVC_IPC_SERVER_PERSON_RESET_USAGE,
275                                 indata, &outdata) != 0) {
276                 /* LCOV_EXCL_START */
277                 ERR("ctsvc_ipc_call() Fail");
278                 pims_ipc_data_destroy(indata);
279                 return CONTACTS_ERROR_IPC;
280                 /* LCOV_EXCL_STOP */
281         }
282
283         pims_ipc_data_destroy(indata);
284
285         if (outdata) {
286                 if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &ret)) {
287                         /* LCOV_EXCL_START */
288                         ERR("ctsvc_ipc_unmarshal_int() Fail");
289                         pims_ipc_data_destroy(outdata);
290                         return CONTACTS_ERROR_IPC;
291                         /* LCOV_EXCL_STOP */
292                 }
293
294                 if (CONTACTS_ERROR_NONE == ret) {
295                         int transaction_ver = 0;
296                         if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &transaction_ver)) {
297                                 /* LCOV_EXCL_START */
298                                 ERR("ctsvc_ipc_unmarshal_int() Fail");
299                                 pims_ipc_data_destroy(outdata);
300                                 return CONTACTS_ERROR_IPC;
301                                 /* LCOV_EXCL_STOP */
302                         }
303                         ctsvc_client_ipc_set_change_version(contact, transaction_ver);
304                 }
305
306                 pims_ipc_data_destroy(outdata);
307         }
308
309         return ret;
310 }
311
312 int ctsvc_client_person_set_favorite_order(contacts_h contact, int person_id,
313                 int previous_person_id, int next_person_id)
314 {
315         int ret = CONTACTS_ERROR_NONE;
316
317         pims_ipc_data_h indata = NULL;
318         pims_ipc_data_h outdata = NULL;
319
320         RETV_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER);
321         RETVM_IF(person_id <= 0 || previous_person_id < 0 || next_person_id < 0,
322                         CONTACTS_ERROR_INVALID_PARAMETER, "id should be greater than 0");
323
324         /* make indata */
325         indata = pims_ipc_data_create(0);
326         if (NULL == indata) {
327                 /* LCOV_EXCL_START */
328                 ERR("pims_ipc_data_create() Fail");
329                 return CONTACTS_ERROR_OUT_OF_MEMORY;
330                 /* LCOV_EXCL_STOP */
331         }
332
333         ret = ctsvc_ipc_marshal_handle(contact, indata);
334         if (CONTACTS_ERROR_NONE != ret) {
335                 /* LCOV_EXCL_START */
336                 ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
337                 pims_ipc_data_destroy(indata);
338                 return ret;
339                 /* LCOV_EXCL_STOP */
340         }
341
342         ret = ctsvc_ipc_marshal_int(person_id, indata);
343         if (CONTACTS_ERROR_NONE != ret) {
344                 /* LCOV_EXCL_START */
345                 ERR("ctsvc_ipc_marshal_int() Fail(%d)", ret);
346                 pims_ipc_data_destroy(indata);
347                 return ret;
348                 /* LCOV_EXCL_STOP */
349         }
350         ret = ctsvc_ipc_marshal_int(previous_person_id, indata);
351         if (CONTACTS_ERROR_NONE != ret) {
352                 /* LCOV_EXCL_START */
353                 ERR("ctsvc_ipc_marshal_int() Fail(%d)", ret);
354                 pims_ipc_data_destroy(indata);
355                 return ret;
356                 /* LCOV_EXCL_STOP */
357         }
358         ret = ctsvc_ipc_marshal_int(next_person_id, indata);
359         if (CONTACTS_ERROR_NONE != ret) {
360                 /* LCOV_EXCL_START */
361                 ERR("ctsvc_ipc_marshal_int() Fail(%d)", ret);
362                 pims_ipc_data_destroy(indata);
363                 return ret;
364                 /* LCOV_EXCL_STOP */
365         }
366
367         /* ipc call */
368         ret = ctsvc_ipc_call(CTSVC_IPC_PERSON_MODULE,
369                         CTSVC_IPC_SERVER_PERSON_SET_FAVORITE_ORDER, indata, &outdata);
370         if (0 != ret) {
371                 /* LCOV_EXCL_START */
372                 ERR("ctsvc_ipc_call() Fail");
373                 pims_ipc_data_destroy(indata);
374                 return CONTACTS_ERROR_IPC;
375                 /* LCOV_EXCL_STOP */
376         }
377
378         pims_ipc_data_destroy(indata);
379
380         if (outdata) {
381                 if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &ret)) {
382                         /* LCOV_EXCL_START */
383                         ERR("ctsvc_ipc_unmarshal_int() Fail");
384                         pims_ipc_data_destroy(outdata);
385                         return CONTACTS_ERROR_IPC;
386                         /* LCOV_EXCL_STOP */
387                 }
388
389                 if (CONTACTS_ERROR_NONE == ret) {
390                         int transaction_ver = 0;
391                         if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &transaction_ver)) {
392                                 /* LCOV_EXCL_START */
393                                 ERR("ctsvc_ipc_unmarshal_int() Fail");
394                                 pims_ipc_data_destroy(outdata);
395                                 return CONTACTS_ERROR_IPC;
396                                 /* LCOV_EXCL_STOP */
397                         }
398                         ctsvc_client_ipc_set_change_version(contact, transaction_ver);
399                 }
400
401                 pims_ipc_data_destroy(outdata);
402         }
403
404         return ret;
405
406 }
407
408 int ctsvc_client_person_set_default_property(contacts_h contact,
409                 contacts_person_property_e property, int person_id, int id)
410 {
411         int ret = CONTACTS_ERROR_NONE;
412
413         pims_ipc_data_h indata = NULL;
414         pims_ipc_data_h outdata = NULL;
415
416         RETV_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER);
417         RETVM_IF(person_id <= 0 || id <= 0, CONTACTS_ERROR_INVALID_PARAMETER,
418                         "id should be greater than 0");
419
420         /* make indata */
421         indata = pims_ipc_data_create(0);
422         if (NULL == indata) {
423                 /* LCOV_EXCL_START */
424                 ERR("pims_ipc_data_create() Fail");
425                 return CONTACTS_ERROR_OUT_OF_MEMORY;
426                 /* LCOV_EXCL_STOP */
427         }
428
429         ret = ctsvc_ipc_marshal_handle(contact, indata);
430         if (CONTACTS_ERROR_NONE != ret) {
431                 /* LCOV_EXCL_START */
432                 ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
433                 pims_ipc_data_destroy(indata);
434                 return ret;
435                 /* LCOV_EXCL_STOP */
436         }
437
438         ret = ctsvc_ipc_marshal_int(person_id, indata);
439         if (CONTACTS_ERROR_NONE != ret) {
440                 /* LCOV_EXCL_START */
441                 ERR("ctsvc_ipc_marshal_int() Fail(%d)", ret);
442                 pims_ipc_data_destroy(indata);
443                 return ret;
444                 /* LCOV_EXCL_STOP */
445         }
446         ret = ctsvc_ipc_marshal_unsigned_int(property, indata);
447         if (CONTACTS_ERROR_NONE != ret) {
448                 /* LCOV_EXCL_START */
449                 ERR("ctsvc_ipc_marshal_unsigned_int() Fail(%d)", ret);
450                 pims_ipc_data_destroy(indata);
451                 return ret;
452                 /* LCOV_EXCL_STOP */
453         }
454         ret = ctsvc_ipc_marshal_int(id, indata);
455         if (CONTACTS_ERROR_NONE != ret) {
456                 /* LCOV_EXCL_START */
457                 ERR("ctsvc_ipc_marshal_int() Fail(%d)", ret);
458                 pims_ipc_data_destroy(indata);
459                 return ret;
460                 /* LCOV_EXCL_STOP */
461         }
462
463         /* ipc call */
464         if (ctsvc_ipc_call(CTSVC_IPC_PERSON_MODULE, CTSVC_IPC_SERVER_PERSON_SET_DEFAULT_PROPERTY,
465                                 indata, &outdata) != 0) {
466                 /* LCOV_EXCL_START */
467                 ERR("ctsvc_ipc_call() Fail");
468                 pims_ipc_data_destroy(indata);
469                 return CONTACTS_ERROR_IPC;
470                 /* LCOV_EXCL_STOP */
471         }
472
473         pims_ipc_data_destroy(indata);
474
475         if (outdata) {
476                 if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &ret)) {
477                         /* LCOV_EXCL_START */
478                         ERR("ctsvc_ipc_unmarshal_int() Fail");
479                         pims_ipc_data_destroy(outdata);
480                         return CONTACTS_ERROR_IPC;
481                         /* LCOV_EXCL_STOP */
482                 }
483                 if (CONTACTS_ERROR_NONE == ret) {
484                         int transaction_ver = 0;
485                         if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &transaction_ver)) {
486                                 /* LCOV_EXCL_START */
487                                 ERR("ctsvc_ipc_unmarshal_int() Fail");
488                                 pims_ipc_data_destroy(outdata);
489                                 return CONTACTS_ERROR_IPC;
490                                 /* LCOV_EXCL_STOP */
491                         }
492                         ctsvc_client_ipc_set_change_version(contact, transaction_ver);
493                 }
494
495                 pims_ipc_data_destroy(outdata);
496         }
497
498         return ret;
499 }
500
501 int ctsvc_client_person_get_default_property(contacts_h contact,
502                 contacts_person_property_e property, int person_id, int *id)
503 {
504         int ret = CONTACTS_ERROR_NONE;
505         pims_ipc_data_h indata = NULL;
506         pims_ipc_data_h outdata = NULL;
507
508         RETV_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER);
509         RETVM_IF(person_id <= 0 || id == NULL, CONTACTS_ERROR_INVALID_PARAMETER,
510                         "id should be greater than 0");
511         *id = 0;
512
513         /* make indata */
514         indata = pims_ipc_data_create(0);
515         if (NULL == indata) {
516                 /* LCOV_EXCL_START */
517                 ERR("pims_ipc_data_create() Fail");
518                 return CONTACTS_ERROR_OUT_OF_MEMORY;
519                 /* LCOV_EXCL_STOP */
520         }
521
522         ret = ctsvc_ipc_marshal_handle(contact, indata);
523         if (CONTACTS_ERROR_NONE != ret) {
524                 /* LCOV_EXCL_START */
525                 ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
526                 pims_ipc_data_destroy(indata);
527                 return ret;
528                 /* LCOV_EXCL_STOP */
529         }
530
531         ret = ctsvc_ipc_marshal_int(person_id, indata);
532         if (CONTACTS_ERROR_NONE != ret) {
533                 /* LCOV_EXCL_START */
534                 ERR("ctsvc_ipc_marshal_int() Fail(%d)", ret);
535                 pims_ipc_data_destroy(indata);
536                 return ret;
537                 /* LCOV_EXCL_STOP */
538         }
539
540         ret = ctsvc_ipc_marshal_unsigned_int(property, indata);
541         if (CONTACTS_ERROR_NONE != ret) {
542                 /* LCOV_EXCL_START */
543                 ERR("ctsvc_ipc_marshal_unsigned_int() Fail(%d)", ret);
544                 pims_ipc_data_destroy(indata);
545                 return ret;
546                 /* LCOV_EXCL_STOP */
547         }
548
549         /* ipc call */
550         if (ctsvc_ipc_call(CTSVC_IPC_PERSON_MODULE, CTSVC_IPC_SERVER_PERSON_GET_DEFAULT_PROPERTY,
551                                 indata, &outdata) != 0) {
552                 /* LCOV_EXCL_START */
553                 ERR("ctsvc_ipc_call() Fail");
554                 pims_ipc_data_destroy(indata);
555                 return CONTACTS_ERROR_IPC;
556                 /* LCOV_EXCL_STOP */
557         }
558
559         pims_ipc_data_destroy(indata);
560
561         if (outdata) {
562                 if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, &ret)) {
563                         /* LCOV_EXCL_START */
564                         ERR("ctsvc_ipc_unmarshal_int() Fail");
565                         pims_ipc_data_destroy(outdata);
566                         return CONTACTS_ERROR_IPC;
567                         /* LCOV_EXCL_STOP */
568                 }
569                 if (ret == CONTACTS_ERROR_NONE && id) {
570                         if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(outdata, id)) {
571                                 /* LCOV_EXCL_START */
572                                 ERR("ctsvc_ipc_unmarshal_int() Fail");
573                                 pims_ipc_data_destroy(outdata);
574                                 return CONTACTS_ERROR_IPC;
575                                 /* LCOV_EXCL_STOP */
576                         }
577                 }
578                 pims_ipc_data_destroy(outdata);
579         }
580
581         return ret;
582 }
583
584 int ctsvc_client_person_get_aggregation_suggestions(contacts_h contact,
585                 int person_id, int limit, contacts_list_h *out_list)
586 {
587         int ret = CONTACTS_ERROR_NONE;
588         int ret_val = CONTACTS_ERROR_NONE;
589
590         pims_ipc_data_h indata = NULL;
591         pims_ipc_data_h outdata = NULL;
592
593         RETV_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER);
594         RETV_IF(person_id <= 0 || NULL == out_list, CONTACTS_ERROR_INVALID_PARAMETER);
595
596         /* make indata */
597         indata = pims_ipc_data_create(0);
598         if (NULL == indata) {
599                 /* LCOV_EXCL_START */
600                 ERR("pims_ipc_data_create() Fail");
601                 return CONTACTS_ERROR_OUT_OF_MEMORY;
602                 /* LCOV_EXCL_STOP */
603         }
604
605         ret = ctsvc_ipc_marshal_handle(contact, indata);
606         if (CONTACTS_ERROR_NONE != ret) {
607                 /* LCOV_EXCL_START */
608                 ERR("ctsvc_ipc_marshal_handle Fail(%d)", ret);
609                 pims_ipc_data_destroy(indata);
610                 return ret;
611                 /* LCOV_EXCL_STOP */
612         }
613
614         ret = ctsvc_ipc_marshal_int(person_id, indata);
615         if (CONTACTS_ERROR_NONE != ret) {
616                 /* LCOV_EXCL_START */
617                 ERR("ctsvc_ipc_marshal_int() Fail(%d)", ret);
618                 pims_ipc_data_destroy(indata);
619                 return ret;
620                 /* LCOV_EXCL_STOP */
621         }
622
623         ret = ctsvc_ipc_marshal_int(limit, indata);
624         if (CONTACTS_ERROR_NONE != ret) {
625                 /* LCOV_EXCL_START */
626                 ERR("ctsvc_ipc_marshal_int() Fail(%d)", ret);
627                 pims_ipc_data_destroy(indata);
628                 return ret;
629                 /* LCOV_EXCL_STOP */
630         }
631
632         /* ipc call */
633         ret = ctsvc_ipc_call(CTSVC_IPC_PERSON_MODULE, CTSVC_IPC_SERVER_PERSON_GET_AGGREGATION_SUGGESTIONS,
634                         indata, &outdata);
635         pims_ipc_data_destroy(indata);
636         if (CONTACTS_ERROR_NONE != ret) {
637                 /* LCOV_EXCL_START */
638                 ERR("ctsvc_ipc_call() Fail(%d)", ret);
639                 return CONTACTS_ERROR_IPC;
640                 /* LCOV_EXCL_STOP */
641         }
642
643         if (outdata) {
644                 ret = ctsvc_ipc_unmarshal_int(outdata, &ret_val);
645                 if (CONTACTS_ERROR_NONE != ret) {
646                         /* LCOV_EXCL_START */
647                         ERR("ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
648                         pims_ipc_data_destroy(outdata);
649                         return CONTACTS_ERROR_IPC;
650                         /* LCOV_EXCL_STOP */
651                 }
652
653                 if (CONTACTS_ERROR_NONE == ret_val) {
654                         ret = ctsvc_ipc_unmarshal_list(outdata, out_list);
655                         if (CONTACTS_ERROR_NONE != ret) {
656                                 /* LCOV_EXCL_START */
657                                 ERR("ctsvc_ipc_unmarshal_list() Fail(%d)");
658                                 pims_ipc_data_destroy(outdata);
659                                 return CONTACTS_ERROR_IPC;
660                                 /* LCOV_EXCL_STOP */
661                         }
662                 }
663                 pims_ipc_data_destroy(outdata);
664         }
665
666         return ret_val;
667 }