4 * Copyright (c) 2000 - 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-svc.h>
24 #include "ctsvc_handle.h"
25 #include "ctsvc_server_service.h"
26 #include "ctsvc_db_init.h"
27 #include "ctsvc_db_query.h"
28 #include "ctsvc_db_access_control.h"
30 #include "ctsvc_ipc_marshal.h"
31 #include "ctsvc_internal.h"
32 #include "ctsvc_ipc_server.h"
33 #include "ctsvc_db_utils.h"
34 #include "ctsvc_server_utils.h"
36 void ctsvc_ipc_server_connect(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
39 int ret = CONTACTS_ERROR_NONE;
40 contacts_h contact = NULL;
43 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
44 if (ret != CONTACTS_ERROR_NONE) {
46 ERR("ctsvc_ipc_unmarshal_handle() Fail");
52 ERR("There is no indata Fail");
53 ret = CONTACTS_ERROR_SYSTEM;
58 ret = ctsvc_connect();
60 if (CONTACTS_ERROR_NONE == ret) {
62 if (0 != pims_ipc_svc_get_smack_label(ipc, &smack))
63 ERR("pims_ipc_svc_get_smack_label() Fail()");
64 ctsvc_set_client_access_info(ipc, smack);
70 *outdata = pims_ipc_data_create(0);
71 if (NULL == *outdata) {
73 ERR("pims_ipc_data_create() Fail");
78 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
80 pims_ipc_data_destroy(*outdata);
82 ERR("ctsvc_ipc_unmarshal_int() Fail");
87 ERR("outdata is NULL");
90 ctsvc_handle_destroy(contact);
93 void ctsvc_ipc_server_disconnect(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
95 int ret = CONTACTS_ERROR_NONE;
96 contacts_h contact = NULL;
98 #ifdef TIZEN_TEST_GCOV
99 void __gcov_flush(void);
105 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
106 if (CONTACTS_ERROR_NONE != ret) {
107 /* LCOV_EXCL_START */
108 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
109 ret = CONTACTS_ERROR_IPC;
115 ret = ctsvc_disconnect();
119 *outdata = pims_ipc_data_create(0);
120 if (NULL == *outdata) {
121 /* LCOV_EXCL_START */
122 ERR("pims_ipc_data_create() Fail");
126 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
127 /* LCOV_EXCL_START */
128 pims_ipc_data_destroy(*outdata);
130 ERR("ctsvc_ipc_marshal_int() Fail");
135 /* LCOV_EXCL_START */
136 ERR("outdata is NULL");
140 ctsvc_handle_destroy(contact);
141 ctsvc_server_trim_memory();
142 ctsvc_server_start_timeout();
145 void ctsvc_ipc_server_check_permission(pims_ipc_h ipc, pims_ipc_data_h indata,
146 pims_ipc_data_h *outdata, void *userdata)
148 int ret = CONTACTS_ERROR_NONE;
152 if (NULL == indata) {
153 /* LCOV_EXCL_START */
154 ret = CONTACTS_ERROR_INVALID_PARAMETER;
155 ERR("check permission Fail");
160 ret = ctsvc_ipc_unmarshal_int(indata, &permission);
161 if (ret != CONTACTS_ERROR_NONE) {
162 /* LCOV_EXCL_START */
163 ERR("ctsvc_ipc_unmarshal_int() Fail");
168 result = ctsvc_have_permission(ipc, permission);
171 *outdata = pims_ipc_data_create(0);
172 if (NULL == *outdata) {
173 /* LCOV_EXCL_START */
174 ERR("pims_ipc_data_create() Fail");
175 ctsvc_server_start_timeout();
180 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
181 /* LCOV_EXCL_START */
182 pims_ipc_data_destroy(*outdata);
184 ERR("ctsvc_ipc_marshal_int() Fail");
185 ctsvc_server_start_timeout();
190 if (ret == CONTACTS_ERROR_NONE) {
191 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_bool(result, *outdata)) {
192 /* LCOV_EXCL_START */
193 pims_ipc_data_destroy(*outdata);
195 ERR("ctsvc_ipc_marshal_bool() Fail");
196 ctsvc_server_start_timeout();
201 ctsvc_server_start_timeout();
204 void ctsvc_ipc_server_db_insert_record(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
206 int ret = CONTACTS_ERROR_NONE;
207 contacts_record_h record = NULL;
209 contacts_h contact = NULL;
212 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
213 if (CONTACTS_ERROR_NONE != ret) {
214 /* LCOV_EXCL_START */
215 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
216 ret = CONTACTS_ERROR_IPC;
221 ret = ctsvc_ipc_unmarshal_record(indata, &record);
222 if (ret != CONTACTS_ERROR_NONE) {
223 /* LCOV_EXCL_START */
224 ERR("ctsvc_ipc_unmarshal_record() Fail");
230 /* LCOV_EXCL_START */
231 ERR("ctsvc_ipc_server_db_insert_record() Fail");
236 if (!ctsvc_have_permission(ipc, ctsvc_required_write_permission(((ctsvc_record_s*)record)->view_uri))) {
237 /* LCOV_EXCL_START */
238 ret = CONTACTS_ERROR_PERMISSION_DENIED;
243 ret = ctsvc_db_insert_record(record, &id);
246 *outdata = pims_ipc_data_create(0);
247 if (NULL == *outdata) {
248 /* LCOV_EXCL_START */
249 ERR("pims_ipc_data_create() Fail");
253 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
254 /* LCOV_EXCL_START */
255 pims_ipc_data_destroy(*outdata);
257 ERR("ctsvc_ipc_marshal_int() Fail");
261 if (ret == CONTACTS_ERROR_NONE) {
262 int transaction_ver = ctsvc_get_transaction_ver();
263 if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
264 /* LCOV_EXCL_START */
265 pims_ipc_data_destroy(*outdata);
267 ERR("ctsvc_ipc_marshal_int() Fail");
268 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
272 if (ctsvc_ipc_marshal_int(id, *outdata) != CONTACTS_ERROR_NONE) {
273 /* LCOV_EXCL_START */
274 pims_ipc_data_destroy(*outdata);
275 ERR("ctsvc_ipc_marshal_int() Fail");
276 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
282 /* LCOV_EXCL_START */
283 ERR("outdata is NULL");
290 *outdata = pims_ipc_data_create(0);
291 if (NULL == *outdata) {
292 /* LCOV_EXCL_START */
293 ERR("pims_ipc_data_create() Fail");
297 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
298 /* LCOV_EXCL_START */
299 pims_ipc_data_destroy(*outdata);
301 ERR("ctsvc_ipc_marshal_int() Fail");
306 /* LCOV_EXCL_START */
307 ERR("outdata is NULL");
312 ctsvc_handle_destroy(contact);
313 contacts_record_destroy(record, true);
314 ctsvc_server_trim_memory();
315 ctsvc_server_start_timeout();
319 void ctsvc_ipc_server_db_get_record(pims_ipc_h ipc, pims_ipc_data_h indata,
320 pims_ipc_data_h *outdata, void *userdata)
322 int ret = CONTACTS_ERROR_NONE;
323 char *view_uri = NULL;
325 contacts_record_h record = NULL;
326 contacts_h contact = NULL;
329 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
330 if (CONTACTS_ERROR_NONE != ret) {
331 /* LCOV_EXCL_START */
332 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
333 ret = CONTACTS_ERROR_IPC;
337 ret = ctsvc_ipc_unmarshal_string(indata, &view_uri);
338 if (ret != CONTACTS_ERROR_NONE) {
339 /* LCOV_EXCL_START */
340 ERR("ctsvc_ipc_unmarshal_string Fail");
344 ret = ctsvc_ipc_unmarshal_int(indata, &id);
345 if (ret != CONTACTS_ERROR_NONE) {
346 /* LCOV_EXCL_START */
347 ERR("ctsvc_ipc_unmarshal_int() Fail");
352 /* LCOV_EXCL_START */
353 ERR("ctsvc_ipc_server_db_insert_record() Fail");
358 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(view_uri))) {
359 /* LCOV_EXCL_START */
360 ret = CONTACTS_ERROR_PERMISSION_DENIED;
365 ret = ctsvc_db_get_record(view_uri, id, &record);
369 *outdata = pims_ipc_data_create(0);
370 if (NULL == *outdata) {
371 /* LCOV_EXCL_START */
372 ERR("pims_ipc_data_create() Fail");
376 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
377 /* LCOV_EXCL_START */
378 pims_ipc_data_destroy(*outdata);
380 ERR("ctsvc_ipc_marshal_int() Fail");
385 if (CONTACTS_ERROR_NO_DATA == ret) {
387 } else if (CONTACTS_ERROR_NONE == ret) {
388 if (ctsvc_ipc_marshal_record(record, *outdata) != CONTACTS_ERROR_NONE) {
389 /* LCOV_EXCL_START */
390 pims_ipc_data_destroy(*outdata);
392 ERR("ctsvc_ipc_marshal_record() Fail");
398 /* LCOV_EXCL_START */
399 ERR("outdata is NULL");
403 ctsvc_handle_destroy(contact);
404 contacts_record_destroy(record, true);
406 ctsvc_server_start_timeout();
410 void ctsvc_ipc_server_db_update_record(pims_ipc_h ipc, pims_ipc_data_h indata,
411 pims_ipc_data_h *outdata, void *userdata)
413 int ret = CONTACTS_ERROR_NONE;
414 contacts_record_h record = NULL;
415 contacts_h contact = NULL;
418 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
419 if (CONTACTS_ERROR_NONE != ret) {
420 /* LCOV_EXCL_START */
421 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
422 ret = CONTACTS_ERROR_IPC;
426 ret = ctsvc_ipc_unmarshal_record(indata, &record);
427 if (ret != CONTACTS_ERROR_NONE) {
428 /* LCOV_EXCL_START */
429 ERR("ctsvc_ipc_unmarshal_record() Fail");
434 /* LCOV_EXCL_START */
435 ERR("ctsvc_ipc_server_db_insert_record() Fail");
440 if (!ctsvc_have_permission(ipc, ctsvc_required_write_permission(((ctsvc_record_s*)record)->view_uri))) {
441 /* LCOV_EXCL_START */
442 ret = CONTACTS_ERROR_PERMISSION_DENIED;
447 ret = ctsvc_db_update_record(record);
450 *outdata = pims_ipc_data_create(0);
451 if (NULL == *outdata) {
452 /* LCOV_EXCL_START */
453 ERR("pims_ipc_data_create() Fail");
457 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
458 /* LCOV_EXCL_START */
459 pims_ipc_data_destroy(*outdata);
461 ERR("ctsvc_ipc_marshal_int() Fail");
466 if (ret == CONTACTS_ERROR_NONE) {
467 int transaction_ver = ctsvc_get_transaction_ver();
468 if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
469 /* LCOV_EXCL_START */
470 pims_ipc_data_destroy(*outdata);
472 ERR("ctsvc_ipc_marshal_int() Fail");
473 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
484 *outdata = pims_ipc_data_create(0);
485 if (NULL == *outdata) {
486 /* LCOV_EXCL_START */
487 ERR("pims_ipc_data_create() Fail");
491 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
492 /* LCOV_EXCL_START */
493 pims_ipc_data_destroy(*outdata);
495 ERR("ctsvc_ipc_marshal_int() Fail");
500 /* LCOV_EXCL_START */
501 ERR("outdata is NULL");
505 ctsvc_handle_destroy(contact);
506 contacts_record_destroy(record, true);
507 ctsvc_server_trim_memory();
508 ctsvc_server_start_timeout();
512 void ctsvc_ipc_server_db_delete_record(pims_ipc_h ipc, pims_ipc_data_h indata,
513 pims_ipc_data_h *outdata, void *userdata)
515 int ret = CONTACTS_ERROR_NONE;
516 char *view_uri = NULL;
518 contacts_h contact = NULL;
521 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
522 if (CONTACTS_ERROR_NONE != ret) {
523 /* LCOV_EXCL_START */
524 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
525 ret = CONTACTS_ERROR_IPC;
529 ret = ctsvc_ipc_unmarshal_string(indata, &view_uri);
530 if (ret != CONTACTS_ERROR_NONE) {
531 /* LCOV_EXCL_START */
532 ERR("ctsvc_ipc_unmarshal_record() Fail");
536 ret = ctsvc_ipc_unmarshal_int(indata, &id);
537 if (ret != CONTACTS_ERROR_NONE) {
538 /* LCOV_EXCL_START */
539 ERR("ctsvc_ipc_unmarshal_int() Fail");
544 /* LCOV_EXCL_START */
545 ERR("ctsvc_ipc_server_db_insert_record() Fail");
550 if (!ctsvc_have_permission(ipc, ctsvc_required_write_permission(view_uri))) {
551 /* LCOV_EXCL_START */
552 ret = CONTACTS_ERROR_PERMISSION_DENIED;
557 ret = ctsvc_db_delete_record(view_uri, id);
560 *outdata = pims_ipc_data_create(0);
561 if (NULL == *outdata) {
562 /* LCOV_EXCL_START */
563 ERR("pims_ipc_data_create() Fail");
567 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
568 /* LCOV_EXCL_START */
569 pims_ipc_data_destroy(*outdata);
571 ERR("ctsvc_ipc_marshal_int() Fail");
576 if (ret == CONTACTS_ERROR_NONE) {
577 int transaction_ver = ctsvc_get_transaction_ver();
578 if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
579 /* LCOV_EXCL_START */
580 pims_ipc_data_destroy(*outdata);
582 ERR("ctsvc_ipc_marshal_int() Fail");
583 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
594 *outdata = pims_ipc_data_create(0);
595 if (NULL == *outdata) {
596 /* LCOV_EXCL_START */
597 ERR("pims_ipc_data_create() Fail");
601 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
602 /* LCOV_EXCL_START */
603 pims_ipc_data_destroy(*outdata);
605 ERR("ctsvc_ipc_marshal_int() Fail");
610 /* LCOV_EXCL_START */
611 ERR("outdata is NULL");
616 ctsvc_handle_destroy(contact);
618 ctsvc_server_start_timeout();
622 void ctsvc_ipc_server_db_replace_record(pims_ipc_h ipc, pims_ipc_data_h indata,
623 pims_ipc_data_h *outdata, void *userdata)
625 int ret = CONTACTS_ERROR_NONE;
626 contacts_record_h record = NULL;
628 contacts_h contact = NULL;
631 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
632 if (CONTACTS_ERROR_NONE != ret) {
633 /* LCOV_EXCL_START */
634 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
635 ret = CONTACTS_ERROR_IPC;
640 ret = ctsvc_ipc_unmarshal_record(indata, &record);
641 if (ret != CONTACTS_ERROR_NONE) {
642 /* LCOV_EXCL_START */
643 ERR("ctsvc_ipc_unmarshal_record() Fail");
648 ret = ctsvc_ipc_unmarshal_int(indata, &id);
649 if (ret != CONTACTS_ERROR_NONE) {
650 /* LCOV_EXCL_START */
651 ERR("ctsvc_ipc_unmarshal_int() Fail");
656 /* LCOV_EXCL_START */
657 ERR("ctsvc_ipc_server_db_replace_record Fail");
662 if (!ctsvc_have_permission(ipc, ctsvc_required_write_permission(((ctsvc_record_s*)record)->view_uri))) {
663 /* LCOV_EXCL_START */
664 ret = CONTACTS_ERROR_PERMISSION_DENIED;
670 ret = ctsvc_db_replace_record(record, id);
673 *outdata = pims_ipc_data_create(0);
674 if (NULL == *outdata) {
675 /* LCOV_EXCL_START */
676 ERR("pims_ipc_data_create() Fail");
681 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
682 /* LCOV_EXCL_START */
683 pims_ipc_data_destroy(*outdata);
685 ERR("ctsvc_ipc_marshal_int() Fail");
690 if (ret == CONTACTS_ERROR_NONE) {
691 int transaction_ver = ctsvc_get_transaction_ver();
692 if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
693 /* LCOV_EXCL_START */
694 pims_ipc_data_destroy(*outdata);
696 ERR("ctsvc_ipc_marshal_int() Fail");
697 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
703 /* LCOV_EXCL_START */
704 ERR("outdata is NULL");
711 *outdata = pims_ipc_data_create(0);
712 if (NULL == *outdata) {
713 /* LCOV_EXCL_START */
714 ERR("pims_ipc_data_create() Fail");
718 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
719 /* LCOV_EXCL_START */
720 pims_ipc_data_destroy(*outdata);
722 ERR("ctsvc_ipc_marshal_int() Fail");
727 /* LCOV_EXCL_START */
728 ERR("outdata is NULL");
733 ctsvc_handle_destroy(contact);
734 contacts_record_destroy(record, true);
735 ctsvc_server_start_timeout();
739 void ctsvc_ipc_server_db_get_all_records(pims_ipc_h ipc, pims_ipc_data_h indata,
740 pims_ipc_data_h *outdata, void *userdata)
742 int ret = CONTACTS_ERROR_NONE;
743 char *view_uri = NULL;
746 contacts_list_h list = NULL;
747 contacts_h contact = NULL;
750 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
751 if (CONTACTS_ERROR_NONE != ret) {
752 /* LCOV_EXCL_START */
753 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
754 ret = CONTACTS_ERROR_IPC;
759 ret = ctsvc_ipc_unmarshal_string(indata, &view_uri);
760 if (ret != CONTACTS_ERROR_NONE) {
761 /* LCOV_EXCL_START */
762 ERR("ctsvc_ipc_unmarshal_record() Fail");
766 ret = ctsvc_ipc_unmarshal_int(indata, &offset);
767 if (ret != CONTACTS_ERROR_NONE) {
768 /* LCOV_EXCL_START */
769 ERR("ctsvc_ipc_unmarshal_int() Fail");
773 ret = ctsvc_ipc_unmarshal_int(indata, &limit);
774 if (ret != CONTACTS_ERROR_NONE) {
775 /* LCOV_EXCL_START */
776 ERR("ctsvc_ipc_unmarshal_int() Fail");
781 /* LCOV_EXCL_START */
782 ERR("ctsvc_ipc_server_db_insert_record() Fail");
787 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(view_uri))) {
788 /* LCOV_EXCL_START */
789 ret = CONTACTS_ERROR_PERMISSION_DENIED;
794 ret = ctsvc_db_get_all_records(view_uri, offset, limit, &list);
797 *outdata = pims_ipc_data_create(0);
798 if (NULL == *outdata) {
799 /* LCOV_EXCL_START */
800 ERR("pims_ipc_data_create() Fail");
804 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
805 /* LCOV_EXCL_START */
806 pims_ipc_data_destroy(*outdata);
808 ERR("ctsvc_ipc_marshal_int() Fail");
813 if (CONTACTS_ERROR_NO_DATA == ret) {
815 } else if (CONTACTS_ERROR_NONE == ret) {
816 ret = ctsvc_ipc_marshal_list(list, *outdata);
818 if (ret != CONTACTS_ERROR_NONE) {
819 /* LCOV_EXCL_START */
820 ERR("ctsvc_ipc_unmarshal_int() Fail");
827 /* LCOV_EXCL_START */
828 ERR("outdata is NULL");
836 *outdata = pims_ipc_data_create(0);
837 if (NULL == *outdata) {
838 /* LCOV_EXCL_START */
839 ERR("pims_ipc_data_create() Fail");
843 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
844 /* LCOV_EXCL_START */
845 pims_ipc_data_destroy(*outdata);
847 ERR("ctsvc_ipc_marshal_int() Fail");
852 /* LCOV_EXCL_START */
853 ERR("outdata is NULL");
857 ctsvc_handle_destroy(contact);
858 contacts_list_destroy(list, true);
860 ctsvc_server_start_timeout();
864 void ctsvc_ipc_server_db_get_records_with_query(pims_ipc_h ipc, pims_ipc_data_h indata,
865 pims_ipc_data_h *outdata, void *userdata)
867 int ret = CONTACTS_ERROR_NONE;
868 contacts_query_h query = NULL;
871 contacts_list_h list = NULL;
872 contacts_h contact = NULL;
875 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
876 if (CONTACTS_ERROR_NONE != ret) {
877 /* LCOV_EXCL_START */
878 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
883 ret = ctsvc_ipc_unmarshal_query(indata, &query);
884 if (ret != CONTACTS_ERROR_NONE) {
885 /* LCOV_EXCL_START */
886 ERR("ctsvc_ipc_unmarshal_record() Fail");
890 ret = ctsvc_ipc_unmarshal_int(indata, &offset);
891 if (ret != CONTACTS_ERROR_NONE) {
892 /* LCOV_EXCL_START */
893 ERR("ctsvc_ipc_unmarshal_int() Fail");
897 ret = ctsvc_ipc_unmarshal_int(indata, &limit);
898 if (ret != CONTACTS_ERROR_NONE) {
899 /* LCOV_EXCL_START */
900 ERR("ctsvc_ipc_unmarshal_int() Fail");
905 /* LCOV_EXCL_START */
906 ERR("ctsvc_ipc_server_db_insert_record() Fail");
911 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(((ctsvc_query_s*)query)->view_uri))) {
912 /* LCOV_EXCL_START */
913 ret = CONTACTS_ERROR_PERMISSION_DENIED;
918 ret = ctsvc_db_get_records_with_query(query, offset, limit, &list);
921 *outdata = pims_ipc_data_create(0);
922 if (NULL == *outdata) {
923 /* LCOV_EXCL_START */
924 ERR("pims_ipc_data_create() Fail");
928 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
929 /* LCOV_EXCL_START */
930 pims_ipc_data_destroy(*outdata);
932 ERR("ctsvc_ipc_marshal_int() Fail");
937 if (CONTACTS_ERROR_NO_DATA == ret) {
939 } else if (CONTACTS_ERROR_NONE == ret) {
940 ret = ctsvc_ipc_marshal_list(list, *outdata);
942 if (ret != CONTACTS_ERROR_NONE) {
943 /* LCOV_EXCL_START */
944 ERR("ctsvc_ipc_unmarshal_int() Fail");
950 /* LCOV_EXCL_START */
951 ERR("outdata is NULL");
958 *outdata = pims_ipc_data_create(0);
959 if (NULL == *outdata) {
960 /* LCOV_EXCL_START */
961 ERR("pims_ipc_data_create() Fail");
965 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
966 /* LCOV_EXCL_START */
967 pims_ipc_data_destroy(*outdata);
969 ERR("ctsvc_ipc_marshal_int() Fail");
974 /* LCOV_EXCL_START */
975 ERR("outdata is NULL");
979 ctsvc_handle_destroy(contact);
980 contacts_list_destroy(list, true);
981 contacts_query_destroy(query);
982 ctsvc_server_start_timeout();
987 void ctsvc_ipc_server_db_get_count(pims_ipc_h ipc, pims_ipc_data_h indata,
988 pims_ipc_data_h *outdata, void *userdata)
990 int ret = CONTACTS_ERROR_NONE;
991 char *view_uri = NULL;
993 contacts_h contact = NULL;
996 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
997 if (CONTACTS_ERROR_NONE != ret) {
998 /* LCOV_EXCL_START */
999 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
1001 /* LCOV_EXCL_STOP */
1004 ret = ctsvc_ipc_unmarshal_string(indata, &view_uri);
1005 if (ret != CONTACTS_ERROR_NONE) {
1006 /* LCOV_EXCL_START */
1007 ERR("ctsvc_ipc_unmarshal_record() Fail");
1009 /* LCOV_EXCL_STOP */
1012 /* LCOV_EXCL_START */
1013 ERR("ctsvc_ipc_server_db_insert_record() Fail");
1015 /* LCOV_EXCL_STOP */
1018 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(view_uri))) {
1019 /* LCOV_EXCL_START */
1020 ret = CONTACTS_ERROR_PERMISSION_DENIED;
1022 /* LCOV_EXCL_STOP */
1025 ret = ctsvc_db_get_count(view_uri, &count);
1028 *outdata = pims_ipc_data_create(0);
1029 if (NULL == *outdata) {
1030 /* LCOV_EXCL_START */
1031 ERR("pims_ipc_data_create() Fail");
1033 /* LCOV_EXCL_STOP */
1035 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1036 /* LCOV_EXCL_START */
1037 pims_ipc_data_destroy(*outdata);
1039 ERR("ctsvc_ipc_marshal_int() Fail");
1041 /* LCOV_EXCL_STOP */
1044 if (CONTACTS_ERROR_NO_DATA == ret) {
1046 } else if (CONTACTS_ERROR_NONE == ret) {
1047 ret = ctsvc_ipc_marshal_int(count, *outdata);
1049 if (ret != CONTACTS_ERROR_NONE) {
1050 /* LCOV_EXCL_START */
1051 ERR("ctsvc_ipc_unmarshal_int() Fail");
1053 /* LCOV_EXCL_STOP */
1057 /* LCOV_EXCL_START */
1058 ERR("outdata is NULL");
1059 /* LCOV_EXCL_STOP */
1065 *outdata = pims_ipc_data_create(0);
1066 if (NULL == *outdata) {
1067 /* LCOV_EXCL_START */
1068 ERR("pims_ipc_data_create() Fail");
1070 /* LCOV_EXCL_STOP */
1072 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1073 /* LCOV_EXCL_START */
1074 pims_ipc_data_destroy(*outdata);
1076 ERR("ctsvc_ipc_marshal_int() Fail");
1078 /* LCOV_EXCL_STOP */
1081 /* LCOV_EXCL_START */
1082 ERR("outdata is NULL");
1083 /* LCOV_EXCL_STOP */
1086 ctsvc_handle_destroy(contact);
1088 ctsvc_server_start_timeout();
1092 void ctsvc_ipc_server_db_get_count_with_query(pims_ipc_h ipc, pims_ipc_data_h indata,
1093 pims_ipc_data_h *outdata, void *userdata)
1095 int ret = CONTACTS_ERROR_NONE;
1096 contacts_query_h query = NULL;
1098 contacts_h contact = NULL;
1101 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
1102 if (CONTACTS_ERROR_NONE != ret) {
1103 /* LCOV_EXCL_START */
1104 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
1106 /* LCOV_EXCL_STOP */
1109 ret = ctsvc_ipc_unmarshal_query(indata, &query);
1110 if (ret != CONTACTS_ERROR_NONE) {
1111 /* LCOV_EXCL_START */
1112 ERR("ctsvc_ipc_unmarshal_record() Fail");
1114 /* LCOV_EXCL_STOP */
1117 /* LCOV_EXCL_START */
1118 ERR("ctsvc_ipc_server_db_insert_record() Fail");
1120 /* LCOV_EXCL_STOP */
1123 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(((ctsvc_query_s*)query)->view_uri))) {
1124 /* LCOV_EXCL_START */
1125 ret = CONTACTS_ERROR_PERMISSION_DENIED;
1127 /* LCOV_EXCL_STOP */
1130 ret = ctsvc_db_get_count_with_query(query, &count);
1133 *outdata = pims_ipc_data_create(0);
1134 if (NULL == *outdata) {
1135 /* LCOV_EXCL_START */
1136 ERR("pims_ipc_data_create() Fail");
1138 /* LCOV_EXCL_STOP */
1140 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1141 /* LCOV_EXCL_START */
1142 pims_ipc_data_destroy(*outdata);
1144 ERR("ctsvc_ipc_marshal_int() Fail");
1146 /* LCOV_EXCL_STOP */
1149 if (CONTACTS_ERROR_NO_DATA == ret) {
1151 } else if (CONTACTS_ERROR_NONE == ret) {
1152 ret = ctsvc_ipc_marshal_int(count, *outdata);
1154 if (ret != CONTACTS_ERROR_NONE) {
1155 /* LCOV_EXCL_START */
1156 ERR("ctsvc_ipc_unmarshal_int() Fail");
1158 /* LCOV_EXCL_STOP */
1162 /* LCOV_EXCL_START */
1163 ERR("outdata is NULL");
1164 /* LCOV_EXCL_STOP */
1170 *outdata = pims_ipc_data_create(0);
1171 if (NULL == *outdata) {
1172 /* LCOV_EXCL_START */
1173 ERR("pims_ipc_data_create() Fail");
1175 /* LCOV_EXCL_STOP */
1177 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1178 /* LCOV_EXCL_START */
1179 pims_ipc_data_destroy(*outdata);
1181 ERR("ctsvc_ipc_marshal_int() Fail");
1183 /* LCOV_EXCL_STOP */
1186 /* LCOV_EXCL_START */
1187 ERR("outdata is NULL");
1188 /* LCOV_EXCL_STOP */
1191 ctsvc_handle_destroy(contact);
1192 contacts_query_destroy(query);
1193 ctsvc_server_start_timeout();
1197 void ctsvc_ipc_server_db_insert_records(pims_ipc_h ipc, pims_ipc_data_h indata,
1198 pims_ipc_data_h *outdata, void *userdata)
1200 int ret = CONTACTS_ERROR_NONE;
1201 contacts_list_h list = NULL;
1205 contacts_h contact = NULL;
1208 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
1209 if (CONTACTS_ERROR_NONE != ret) {
1210 /* LCOV_EXCL_START */
1211 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
1213 /* LCOV_EXCL_STOP */
1216 ret = ctsvc_ipc_unmarshal_list(indata, &list);
1217 if (ret != CONTACTS_ERROR_NONE) {
1218 /* LCOV_EXCL_START */
1219 ERR("ctsvc_ipc_unmarshal_list Fail");
1221 /* LCOV_EXCL_STOP */
1224 /* LCOV_EXCL_START */
1225 ERR("ctsvc_ipc_server_db_insert_record() Fail");
1227 /* LCOV_EXCL_STOP */
1231 contacts_record_h record = NULL;
1232 contacts_list_first(list);
1234 ret = contacts_list_get_current_record_p(list, &record);
1235 if (CONTACTS_ERROR_NONE != ret) {
1236 /* LCOV_EXCL_START */
1237 ERR("contacts_list_get_current_record_p() Fail(%d)", ret);
1239 /* LCOV_EXCL_STOP */
1242 if (!ctsvc_have_permission(ipc, ctsvc_required_write_permission(((ctsvc_record_s*)record)->view_uri))) {
1243 /* LCOV_EXCL_START */
1244 ret = CONTACTS_ERROR_PERMISSION_DENIED;
1246 /* LCOV_EXCL_STOP */
1248 } while (CONTACTS_ERROR_NONE == contacts_list_next(list));
1249 contacts_list_first(list);
1252 ctsvc_server_stop_timeout();
1253 ret = ctsvc_db_insert_records(list, &ids, &id_count);
1256 *outdata = pims_ipc_data_create(0);
1257 if (NULL == *outdata) {
1258 /* LCOV_EXCL_START */
1259 ERR("pims_ipc_data_create() Fail");
1261 /* LCOV_EXCL_STOP */
1263 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1264 /* LCOV_EXCL_START */
1265 pims_ipc_data_destroy(*outdata);
1267 ERR("ctsvc_ipc_marshal_int() Fail");
1269 /* LCOV_EXCL_STOP */
1272 if (ret == CONTACTS_ERROR_NONE) {
1273 int transaction_ver = ctsvc_get_transaction_ver();
1274 if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
1275 /* LCOV_EXCL_START */
1276 pims_ipc_data_destroy(*outdata);
1278 ERR("ctsvc_ipc_marshal_int() Fail");
1279 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
1281 /* LCOV_EXCL_STOP */
1283 /* marshal : id_count+property_id+[ids]*id_count */
1285 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(id_count, *outdata)) {
1286 /* LCOV_EXCL_START */
1287 pims_ipc_data_destroy(*outdata);
1289 ERR("ctsvc_ipc_marshal_int() Fail");
1290 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
1292 /* LCOV_EXCL_STOP */
1295 for (i = 0; i < id_count; i++) {
1297 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ids[i], *outdata)) {
1298 /* LCOV_EXCL_START */
1299 pims_ipc_data_destroy(*outdata);
1301 ERR("ctsvc_ipc_marshal_int() Fail");
1302 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
1304 /* LCOV_EXCL_STOP */
1309 /* LCOV_EXCL_START */
1310 ERR("outdata is NULL");
1311 /* LCOV_EXCL_STOP */
1317 *outdata = pims_ipc_data_create(0);
1318 if (NULL == *outdata) {
1319 /* LCOV_EXCL_START */
1320 ERR("pims_ipc_data_create() Fail");
1322 /* LCOV_EXCL_STOP */
1324 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1325 /* LCOV_EXCL_START */
1326 pims_ipc_data_destroy(*outdata);
1328 ERR("ctsvc_ipc_marshal_int() Fail");
1330 /* LCOV_EXCL_STOP */
1333 /* LCOV_EXCL_START */
1334 ERR("outdata is NULL");
1335 /* LCOV_EXCL_STOP */
1338 ctsvc_handle_destroy(contact);
1339 contacts_list_destroy(list, true);
1341 ctsvc_server_start_timeout();
1345 void ctsvc_ipc_server_db_update_records(pims_ipc_h ipc, pims_ipc_data_h indata,
1346 pims_ipc_data_h *outdata, void *userdata)
1348 int ret = CONTACTS_ERROR_NONE;
1349 contacts_list_h list = NULL;
1350 contacts_h contact = NULL;
1353 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
1354 if (CONTACTS_ERROR_NONE != ret) {
1355 /* LCOV_EXCL_START */
1356 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
1358 /* LCOV_EXCL_STOP */
1361 ret = ctsvc_ipc_unmarshal_list(indata, &list);
1362 if (ret != CONTACTS_ERROR_NONE) {
1363 /* LCOV_EXCL_START */
1364 ERR("ctsvc_ipc_unmarshal_list Fail");
1366 /* LCOV_EXCL_STOP */
1369 /* LCOV_EXCL_START */
1370 ERR("ctsvc_ipc_server_db_insert_record() Fail");
1372 /* LCOV_EXCL_STOP */
1376 contacts_record_h record = NULL;
1377 contacts_list_first(list);
1379 ret = contacts_list_get_current_record_p(list, &record);
1380 if (CONTACTS_ERROR_NONE != ret) {
1381 /* LCOV_EXCL_START */
1382 ERR("contacts_list_get_current_record_p() Fail(%d)", ret);
1384 /* LCOV_EXCL_STOP */
1387 if (!ctsvc_have_permission(ipc, ctsvc_required_write_permission(((ctsvc_record_s*)record)->view_uri))) {
1388 /* LCOV_EXCL_START */
1389 ret = CONTACTS_ERROR_PERMISSION_DENIED;
1391 /* LCOV_EXCL_STOP */
1393 } while (CONTACTS_ERROR_NONE == contacts_list_next(list));
1394 contacts_list_first(list);
1397 ctsvc_server_stop_timeout();
1398 ret = ctsvc_db_update_records(list);
1401 *outdata = pims_ipc_data_create(0);
1402 if (NULL == *outdata) {
1403 /* LCOV_EXCL_START */
1404 ERR("pims_ipc_data_create() Fail");
1406 /* LCOV_EXCL_STOP */
1408 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1409 /* LCOV_EXCL_START */
1410 pims_ipc_data_destroy(*outdata);
1412 ERR("ctsvc_ipc_marshal_int() Fail");
1414 /* LCOV_EXCL_STOP */
1417 if (ret == CONTACTS_ERROR_NONE) {
1418 int transaction_ver = ctsvc_get_transaction_ver();
1419 if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
1420 /* LCOV_EXCL_START */
1421 pims_ipc_data_destroy(*outdata);
1423 ERR("ctsvc_ipc_marshal_int() Fail");
1424 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
1426 /* LCOV_EXCL_STOP */
1430 /* LCOV_EXCL_START */
1431 ERR("outdata is NULL");
1432 /* LCOV_EXCL_STOP */
1438 *outdata = pims_ipc_data_create(0);
1439 if (NULL == *outdata) {
1440 /* LCOV_EXCL_START */
1441 ERR("pims_ipc_data_create() Fail");
1443 /* LCOV_EXCL_STOP */
1445 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1446 /* LCOV_EXCL_START */
1447 pims_ipc_data_destroy(*outdata);
1449 ERR("ctsvc_ipc_marshal_int() Fail");
1451 /* LCOV_EXCL_STOP */
1454 /* LCOV_EXCL_START */
1455 ERR("outdata is NULL");
1456 /* LCOV_EXCL_STOP */
1459 ctsvc_handle_destroy(contact);
1460 contacts_list_destroy(list, true);
1461 ctsvc_server_start_timeout();
1465 void ctsvc_ipc_server_db_delete_records(pims_ipc_h ipc, pims_ipc_data_h indata,
1466 pims_ipc_data_h *outdata, void *userdata)
1468 int ret = CONTACTS_ERROR_NONE;
1473 contacts_h contact = NULL;
1476 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
1477 if (CONTACTS_ERROR_NONE != ret) {
1478 /* LCOV_EXCL_START */
1479 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
1481 /* LCOV_EXCL_STOP */
1484 ret = ctsvc_ipc_unmarshal_string(indata, &uri);
1485 if (ret != CONTACTS_ERROR_NONE) {
1486 /* LCOV_EXCL_START */
1487 ERR("ctsvc_ipc_unmarshal_string Fail");
1489 /* LCOV_EXCL_STOP */
1491 ret = ctsvc_ipc_unmarshal_int(indata, &count);
1492 if (ret != CONTACTS_ERROR_NONE) {
1493 /* LCOV_EXCL_START */
1494 ERR("ctsvc_ipc_unmarshal_int() Fail");
1496 /* LCOV_EXCL_STOP */
1499 /* LCOV_EXCL_START */
1500 ret = CONTACTS_ERROR_INVALID_PARAMETER;
1502 /* LCOV_EXCL_STOP */
1504 ids = (int*)malloc(sizeof(int)*count);
1506 ERR("malloc failed()");
1509 for (i = 0; i < count; i++) {
1510 ret = ctsvc_ipc_unmarshal_int(indata, &ids[i]);
1511 if (ret != CONTACTS_ERROR_NONE) {
1512 /* LCOV_EXCL_START */
1513 ERR("ctsvc_ipc_unmarshal_int() Fail");
1515 /* LCOV_EXCL_STOP */
1519 /* LCOV_EXCL_START */
1520 ERR("ctsvc_ipc_server_db_insert_record() Fail");
1522 /* LCOV_EXCL_STOP */
1525 if (!ctsvc_have_permission(ipc, ctsvc_required_write_permission(uri))) {
1526 /* LCOV_EXCL_START */
1527 ret = CONTACTS_ERROR_PERMISSION_DENIED;
1529 /* LCOV_EXCL_STOP */
1532 ret = ctsvc_db_delete_records(uri, ids, count);
1535 *outdata = pims_ipc_data_create(0);
1536 if (NULL == *outdata) {
1537 /* LCOV_EXCL_START */
1538 ERR("pims_ipc_data_create() Fail");
1540 /* LCOV_EXCL_STOP */
1543 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1544 /* LCOV_EXCL_START */
1545 pims_ipc_data_destroy(*outdata);
1547 ERR("ctsvc_ipc_marshal_int() Fail");
1549 /* LCOV_EXCL_STOP */
1552 if (ret == CONTACTS_ERROR_NONE) {
1553 int transaction_ver = ctsvc_get_transaction_ver();
1554 if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
1555 /* LCOV_EXCL_START */
1556 pims_ipc_data_destroy(*outdata);
1558 ERR("ctsvc_ipc_marshal_int() Fail");
1559 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
1561 /* LCOV_EXCL_STOP */
1565 /* LCOV_EXCL_START */
1566 ERR("outdata is NULL");
1567 /* LCOV_EXCL_STOP */
1574 *outdata = pims_ipc_data_create(0);
1575 if (NULL == *outdata) {
1576 /* LCOV_EXCL_START */
1577 ERR("pims_ipc_data_create() Fail");
1579 /* LCOV_EXCL_STOP */
1581 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1582 /* LCOV_EXCL_START */
1583 pims_ipc_data_destroy(*outdata);
1585 ERR("ctsvc_ipc_marshal_int() Fail");
1587 /* LCOV_EXCL_STOP */
1590 /* LCOV_EXCL_START */
1591 ERR("outdata is NULL");
1592 /* LCOV_EXCL_STOP */
1595 ctsvc_handle_destroy(contact);
1598 ctsvc_server_start_timeout();
1602 void ctsvc_ipc_server_db_replace_records(pims_ipc_h ipc, pims_ipc_data_h indata,
1603 pims_ipc_data_h *outdata, void *userdata)
1605 int ret = CONTACTS_ERROR_NONE;
1606 contacts_list_h list = NULL;
1610 contacts_h contact = NULL;
1613 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
1614 if (CONTACTS_ERROR_NONE != ret) {
1615 /* LCOV_EXCL_START */
1616 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
1618 /* LCOV_EXCL_STOP */
1621 ret = ctsvc_ipc_unmarshal_list(indata, &list);
1622 if (ret != CONTACTS_ERROR_NONE) {
1623 /* LCOV_EXCL_START */
1624 ERR("ctsvc_ipc_unmarshal_list Fail");
1626 /* LCOV_EXCL_STOP */
1629 ret = ctsvc_ipc_unmarshal_int(indata, &count);
1630 if (ret != CONTACTS_ERROR_NONE) {
1631 /* LCOV_EXCL_START */
1632 ERR("ctsvc_ipc_unmarshal_int() Fail");
1634 /* LCOV_EXCL_STOP */
1638 /* LCOV_EXCL_START */
1639 ret = CONTACTS_ERROR_INVALID_PARAMETER;
1641 /* LCOV_EXCL_STOP */
1644 ids = (int*)malloc(sizeof(int)*count);
1646 ERR("malloc() failed");
1649 for (i = 0; i < count; i++) {
1650 ret = ctsvc_ipc_unmarshal_int(indata, &ids[i]);
1651 if (ret != CONTACTS_ERROR_NONE) {
1652 /* LCOV_EXCL_START */
1653 ERR("ctsvc_ipc_unmarshal_int() Fail");
1655 /* LCOV_EXCL_STOP */
1659 /* LCOV_EXCL_START */
1660 ERR("ctsvc_ipc_server_db_repalce_records Fail");
1662 /* LCOV_EXCL_STOP */
1666 contacts_record_h record = NULL;
1667 contacts_list_first(list);
1669 ret = contacts_list_get_current_record_p(list, &record);
1670 if (CONTACTS_ERROR_NONE != ret) {
1671 /* LCOV_EXCL_START */
1672 ERR("contacts_list_get_current_record_p() Fail(%d)", ret);
1674 /* LCOV_EXCL_STOP */
1677 if (!ctsvc_have_permission(ipc, ctsvc_required_write_permission(((ctsvc_record_s*)record)->view_uri))) {
1678 /* LCOV_EXCL_START */
1679 ret = CONTACTS_ERROR_PERMISSION_DENIED;
1681 /* LCOV_EXCL_STOP */
1683 } while (CONTACTS_ERROR_NONE == contacts_list_next(list));
1684 contacts_list_first(list);
1687 ctsvc_server_stop_timeout();
1688 ret = ctsvc_db_replace_records(list, ids, count);
1691 *outdata = pims_ipc_data_create(0);
1692 if (NULL == *outdata) {
1693 /* LCOV_EXCL_START */
1694 ERR("pims_ipc_data_create() Fail");
1696 /* LCOV_EXCL_STOP */
1698 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1699 /* LCOV_EXCL_START */
1700 pims_ipc_data_destroy(*outdata);
1702 ERR("ctsvc_ipc_marshal_int() Fail");
1704 /* LCOV_EXCL_STOP */
1706 if (ret == CONTACTS_ERROR_NONE) {
1707 int transaction_ver = ctsvc_get_transaction_ver();
1708 if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
1709 /* LCOV_EXCL_START */
1710 pims_ipc_data_destroy(*outdata);
1712 ERR("ctsvc_ipc_marshal_int() Fail");
1713 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
1715 /* LCOV_EXCL_STOP */
1719 /* LCOV_EXCL_START */
1720 ERR("outdata is NULL");
1721 /* LCOV_EXCL_STOP */
1727 *outdata = pims_ipc_data_create(0);
1728 if (NULL == *outdata) {
1729 /* LCOV_EXCL_START */
1730 ERR("pims_ipc_data_create() Fail");
1732 /* LCOV_EXCL_STOP */
1734 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1735 /* LCOV_EXCL_START */
1736 pims_ipc_data_destroy(*outdata);
1738 ERR("ctsvc_ipc_marshal_int() Fail");
1740 /* LCOV_EXCL_STOP */
1743 /* LCOV_EXCL_START */
1744 ERR("outdata is NULL");
1745 /* LCOV_EXCL_STOP */
1748 ctsvc_handle_destroy(contact);
1749 contacts_list_destroy(list, true);
1751 ctsvc_server_start_timeout();
1755 void ctsvc_ipc_server_db_get_changes_by_version(pims_ipc_h ipc, pims_ipc_data_h indata,
1756 pims_ipc_data_h *outdata, void *userdata)
1758 int ret = CONTACTS_ERROR_NONE;
1759 char *view_uri = NULL;
1760 int address_book_id = 0;
1761 int contacts_db_version = 0;
1762 contacts_list_h record_list = NULL;
1763 int current_contacts_db_version = 0;
1764 contacts_h contact = NULL;
1767 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
1768 if (CONTACTS_ERROR_NONE != ret) {
1769 /* LCOV_EXCL_START */
1770 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
1772 /* LCOV_EXCL_STOP */
1775 ret = ctsvc_ipc_unmarshal_string(indata, &view_uri);
1776 if (ret != CONTACTS_ERROR_NONE) {
1777 /* LCOV_EXCL_START */
1778 ERR("ctsvc_ipc_unmarshal_string Fail");
1780 /* LCOV_EXCL_STOP */
1782 ret = ctsvc_ipc_unmarshal_int(indata, &address_book_id);
1783 if (ret != CONTACTS_ERROR_NONE) {
1784 /* LCOV_EXCL_START */
1785 ERR("ctsvc_ipc_unmarshal_int() Fail");
1787 /* LCOV_EXCL_STOP */
1789 ret = ctsvc_ipc_unmarshal_int(indata, &contacts_db_version);
1790 if (ret != CONTACTS_ERROR_NONE) {
1791 /* LCOV_EXCL_START */
1792 ERR("ctsvc_ipc_unmarshal_int() Fail");
1794 /* LCOV_EXCL_STOP */
1797 /* LCOV_EXCL_START */
1798 ERR("ctsvc_ipc_server_db_insert_record() Fail");
1800 /* LCOV_EXCL_STOP */
1803 if (!ctsvc_have_permission(ipc, CTSVC_PERMISSION_CONTACT_READ)) {
1804 /* LCOV_EXCL_START */
1805 ret = CONTACTS_ERROR_PERMISSION_DENIED;
1807 /* LCOV_EXCL_STOP */
1810 ret = ctsvc_db_get_changes_by_version(view_uri, address_book_id, contacts_db_version,
1811 &record_list, ¤t_contacts_db_version);
1814 *outdata = pims_ipc_data_create(0);
1815 if (NULL == *outdata) {
1816 /* LCOV_EXCL_START */
1817 ERR("pims_ipc_data_create() Fail");
1819 /* LCOV_EXCL_STOP */
1821 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1822 /* LCOV_EXCL_START */
1823 pims_ipc_data_destroy(*outdata);
1825 ERR("ctsvc_ipc_marshal_int() Fail");
1827 /* LCOV_EXCL_STOP */
1830 if (CONTACTS_ERROR_NO_DATA == ret) {
1832 } else if (CONTACTS_ERROR_NONE == ret) {
1833 ret = ctsvc_ipc_marshal_list(record_list, *outdata);
1834 if (ret != CONTACTS_ERROR_NONE) {
1835 /* LCOV_EXCL_START */
1836 ERR("ctsvc_ipc_marshal_list Fail");
1837 pims_ipc_data_destroy(*outdata);
1839 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
1841 /* LCOV_EXCL_STOP */
1843 ret = ctsvc_ipc_marshal_int(current_contacts_db_version, *outdata);
1844 if (ret != CONTACTS_ERROR_NONE) {
1845 /* LCOV_EXCL_START */
1846 ERR("ctsvc_ipc_marshal_int() Fail");
1847 pims_ipc_data_destroy(*outdata);
1849 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
1851 /* LCOV_EXCL_STOP */
1855 /* LCOV_EXCL_START */
1856 ERR("outdata is NULL");
1857 /* LCOV_EXCL_STOP */
1863 *outdata = pims_ipc_data_create(0);
1864 if (NULL == *outdata) {
1865 /* LCOV_EXCL_START */
1866 ERR("pims_ipc_data_create() Fail");
1868 /* LCOV_EXCL_STOP */
1870 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1871 /* LCOV_EXCL_START */
1872 pims_ipc_data_destroy(*outdata);
1874 ERR("ctsvc_ipc_marshal_int() Fail");
1876 /* LCOV_EXCL_STOP */
1879 /* LCOV_EXCL_START */
1880 ERR("outdata is NULL");
1881 /* LCOV_EXCL_STOP */
1884 ctsvc_handle_destroy(contact);
1885 contacts_list_destroy(record_list, true);
1887 ctsvc_server_start_timeout();
1891 void ctsvc_ipc_server_db_get_current_version(pims_ipc_h ipc, pims_ipc_data_h indata,
1892 pims_ipc_data_h *outdata, void *userdata)
1894 int ret = CONTACTS_ERROR_NONE;
1895 int contacts_db_version = 0;
1896 contacts_h contact = NULL;
1899 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
1900 if (CONTACTS_ERROR_NONE != ret) {
1901 /* LCOV_EXCL_START */
1902 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
1904 /* LCOV_EXCL_STOP */
1908 if (!ctsvc_have_permission(ipc, CTSVC_PERMISSION_CONTACT_READ) &&
1909 !ctsvc_have_permission(ipc, CTSVC_PERMISSION_PHONELOG_READ)) {
1910 /* LCOV_EXCL_START */
1911 ret = CONTACTS_ERROR_PERMISSION_DENIED;
1913 /* LCOV_EXCL_STOP */
1916 ret = ctsvc_db_get_current_version(&contacts_db_version);
1920 *outdata = pims_ipc_data_create(0);
1921 if (NULL == *outdata) {
1922 /* LCOV_EXCL_START */
1923 ERR("pims_ipc_data_create() Fail");
1925 /* LCOV_EXCL_STOP */
1927 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1928 /* LCOV_EXCL_START */
1929 pims_ipc_data_destroy(*outdata);
1931 ERR("ctsvc_ipc_marshal_int() Fail");
1933 /* LCOV_EXCL_STOP */
1936 if (CONTACTS_ERROR_NO_DATA == ret) {
1938 } else if (CONTACTS_ERROR_NONE == ret) {
1939 ret = ctsvc_ipc_marshal_int(contacts_db_version, *outdata);
1940 if (ret != CONTACTS_ERROR_NONE) {
1941 /* LCOV_EXCL_START */
1942 ERR("ctsvc_ipc_marshal_int() Fail");
1944 /* LCOV_EXCL_STOP */
1948 /* LCOV_EXCL_START */
1949 ERR("outdata is NULL");
1950 /* LCOV_EXCL_STOP */
1954 ctsvc_handle_destroy(contact);
1955 ctsvc_server_start_timeout();
1959 void ctsvc_ipc_server_db_search_records_for_snippet(pims_ipc_h ipc,
1960 pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
1962 int ret = CONTACTS_ERROR_NONE;
1963 char *view_uri = NULL;
1964 char *keyword = NULL;
1967 contacts_list_h list = NULL;
1968 contacts_h contact = NULL;
1969 char *start_match = NULL;
1970 char *end_match = NULL;
1971 int token_number = 0;
1974 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
1975 if (CONTACTS_ERROR_NONE != ret) {
1976 /* LCOV_EXCL_START */
1977 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
1979 /* LCOV_EXCL_STOP */
1981 ret = ctsvc_ipc_unmarshal_string(indata, &view_uri);
1982 if (ret != CONTACTS_ERROR_NONE) {
1983 /* LCOV_EXCL_START */
1984 ERR("ctsvc_ipc_unmarshal_record() Fail(%d)", ret);
1986 /* LCOV_EXCL_STOP */
1988 ret = ctsvc_ipc_unmarshal_string(indata, &keyword);
1989 if (ret != CONTACTS_ERROR_NONE) {
1990 /* LCOV_EXCL_START */
1991 ERR("ctsvc_ipc_unmarshal_record() Fail(%d)", ret);
1993 /* LCOV_EXCL_STOP */
1995 ret = ctsvc_ipc_unmarshal_int(indata, &offset);
1996 if (ret != CONTACTS_ERROR_NONE) {
1997 /* LCOV_EXCL_START */
1998 ERR("ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
2000 /* LCOV_EXCL_STOP */
2002 ret = ctsvc_ipc_unmarshal_int(indata, &limit);
2003 if (ret != CONTACTS_ERROR_NONE) {
2004 /* LCOV_EXCL_START */
2005 ERR("ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
2007 /* LCOV_EXCL_STOP */
2009 ret = ctsvc_ipc_unmarshal_string(indata, &start_match);
2010 if (ret != CONTACTS_ERROR_NONE) {
2011 /* LCOV_EXCL_START */
2012 ERR("ctsvc_ipc_unmarshal_record() Fail");
2014 /* LCOV_EXCL_STOP */
2016 ret = ctsvc_ipc_unmarshal_string(indata, &end_match);
2017 if (ret != CONTACTS_ERROR_NONE) {
2018 /* LCOV_EXCL_START */
2019 ERR("ctsvc_ipc_unmarshal_record() Fail");
2021 /* LCOV_EXCL_STOP */
2023 ret = ctsvc_ipc_unmarshal_int(indata, &token_number);
2024 if (ret != CONTACTS_ERROR_NONE) {
2025 /* LCOV_EXCL_START */
2026 ERR("ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
2028 /* LCOV_EXCL_STOP */
2031 /* LCOV_EXCL_START */
2032 ERR("ctsvc_ipc_server_db_insert_record() Fail");
2034 /* LCOV_EXCL_STOP */
2037 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(view_uri))) {
2038 /* LCOV_EXCL_START */
2039 ret = CONTACTS_ERROR_PERMISSION_DENIED;
2041 /* LCOV_EXCL_STOP */
2044 ret = ctsvc_db_search_records_for_snippet(view_uri, keyword, offset, limit,
2045 start_match, end_match, token_number, &list);
2048 *outdata = pims_ipc_data_create(0);
2049 if (NULL == *outdata) {
2050 /* LCOV_EXCL_START */
2051 ERR("pims_ipc_data_create() Fail");
2053 /* LCOV_EXCL_STOP */
2055 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2056 /* LCOV_EXCL_START */
2057 pims_ipc_data_destroy(*outdata);
2059 ERR("ctsvc_ipc_marshal_int() Fail");
2061 /* LCOV_EXCL_STOP */
2064 if (CONTACTS_ERROR_NO_DATA == ret) {
2066 } else if (CONTACTS_ERROR_NONE == ret) {
2067 ret = ctsvc_ipc_marshal_list(list, *outdata);
2069 if (ret != CONTACTS_ERROR_NONE) {
2070 /* LCOV_EXCL_START */
2071 ERR("ctsvc_ipc_unmarshal_int() Fail");
2073 /* LCOV_EXCL_STOP */
2077 /* LCOV_EXCL_START */
2078 ERR("outdata is NULL");
2079 /* LCOV_EXCL_STOP */
2085 *outdata = pims_ipc_data_create(0);
2086 if (NULL == *outdata) {
2087 /* LCOV_EXCL_START */
2088 ERR("pims_ipc_data_create() Fail");
2090 /* LCOV_EXCL_STOP */
2092 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2093 /* LCOV_EXCL_START */
2094 pims_ipc_data_destroy(*outdata);
2096 ERR("ctsvc_ipc_marshal_int() Fail");
2098 /* LCOV_EXCL_STOP */
2101 /* LCOV_EXCL_START */
2102 ERR("outdata is NULL");
2103 /* LCOV_EXCL_STOP */
2106 ctsvc_handle_destroy(contact);
2107 contacts_list_destroy(list, true);
2112 ctsvc_server_start_timeout();
2116 void ctsvc_ipc_server_db_search_records_with_range_for_snippet(pims_ipc_h ipc,
2117 pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
2119 int ret = CONTACTS_ERROR_NONE;
2120 char *view_uri = NULL;
2121 char *keyword = NULL;
2125 contacts_list_h list = NULL;
2126 contacts_h contact = NULL;
2127 char *start_match = NULL;
2128 char *end_match = NULL;
2129 int token_number = 0;
2132 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
2133 if (CONTACTS_ERROR_NONE != ret) {
2134 /* LCOV_EXCL_START */
2135 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
2137 /* LCOV_EXCL_STOP */
2139 ret = ctsvc_ipc_unmarshal_string(indata, &view_uri);
2140 if (ret != CONTACTS_ERROR_NONE) {
2141 /* LCOV_EXCL_START */
2142 ERR("ctsvc_ipc_unmarshal_record() Fail");
2144 /* LCOV_EXCL_STOP */
2146 ret = ctsvc_ipc_unmarshal_string(indata, &keyword);
2147 if (ret != CONTACTS_ERROR_NONE) {
2148 /* LCOV_EXCL_START */
2149 ERR("ctsvc_ipc_unmarshal_record() Fail");
2151 /* LCOV_EXCL_STOP */
2153 ret = ctsvc_ipc_unmarshal_int(indata, &offset);
2154 if (ret != CONTACTS_ERROR_NONE) {
2155 /* LCOV_EXCL_START */
2156 ERR("ctsvc_ipc_unmarshal_int() Fail");
2158 /* LCOV_EXCL_STOP */
2160 ret = ctsvc_ipc_unmarshal_int(indata, &limit);
2161 if (ret != CONTACTS_ERROR_NONE) {
2162 /* LCOV_EXCL_START */
2163 ERR("ctsvc_ipc_unmarshal_int() Fail");
2165 /* LCOV_EXCL_STOP */
2167 ret = ctsvc_ipc_unmarshal_int(indata, &range);
2168 if (ret != CONTACTS_ERROR_NONE) {
2169 /* LCOV_EXCL_START */
2170 ERR("ctsvc_ipc_unmarshal_int() Fail");
2172 /* LCOV_EXCL_STOP */
2174 ret = ctsvc_ipc_unmarshal_string(indata, &start_match);
2175 if (ret != CONTACTS_ERROR_NONE) {
2176 /* LCOV_EXCL_START */
2177 ERR("ctsvc_ipc_unmarshal_record() Fail");
2179 /* LCOV_EXCL_STOP */
2181 ret = ctsvc_ipc_unmarshal_string(indata, &end_match);
2182 if (ret != CONTACTS_ERROR_NONE) {
2183 /* LCOV_EXCL_START */
2184 ERR("ctsvc_ipc_unmarshal_record() Fail");
2186 /* LCOV_EXCL_STOP */
2188 ret = ctsvc_ipc_unmarshal_int(indata, &token_number);
2189 if (ret != CONTACTS_ERROR_NONE) {
2190 /* LCOV_EXCL_START */
2191 ERR("ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
2193 /* LCOV_EXCL_STOP */
2196 /* LCOV_EXCL_START */
2197 ERR("ctsvc_ipc_server_db_insert_record() Fail");
2199 /* LCOV_EXCL_START */
2202 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(view_uri))) {
2203 /* LCOV_EXCL_START */
2204 ret = CONTACTS_ERROR_PERMISSION_DENIED;
2206 /* LCOV_EXCL_STOP */
2209 ret = ctsvc_db_search_records_with_range_for_snippet(view_uri, keyword, offset,
2210 limit, range, start_match, end_match, token_number, &list);
2213 *outdata = pims_ipc_data_create(0);
2214 if (NULL == *outdata) {
2215 /* LCOV_EXCL_START */
2216 ERR("pims_ipc_data_create() Fail");
2218 /* LCOV_EXCL_STOP */
2220 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2221 /* LCOV_EXCL_START */
2222 pims_ipc_data_destroy(*outdata);
2224 ERR("ctsvc_ipc_marshal_int() Fail");
2226 /* LCOV_EXCL_STOP */
2229 if (CONTACTS_ERROR_NO_DATA == ret) {
2231 } else if (CONTACTS_ERROR_NONE == ret) {
2232 ret = ctsvc_ipc_marshal_list(list, *outdata);
2234 if (ret != CONTACTS_ERROR_NONE) {
2235 /* LCOV_EXCL_START */
2236 ERR("ctsvc_ipc_unmarshal_int() Fail");
2238 /* LCOV_EXCL_STOP */
2242 /* LCOV_EXCL_START */
2243 ERR("outdata is NULL");
2244 /* LCOV_EXCL_STOP */
2250 *outdata = pims_ipc_data_create(0);
2251 if (NULL == *outdata) {
2252 /* LCOV_EXCL_START */
2253 ERR("pims_ipc_data_create() Fail");
2255 /* LCOV_EXCL_STOP */
2257 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2258 /* LCOV_EXCL_START */
2259 pims_ipc_data_destroy(*outdata);
2261 ERR("ctsvc_ipc_marshal_int() Fail");
2263 /* LCOV_EXCL_STOP */
2266 /* LCOV_EXCL_START */
2267 ERR("outdata is NULL");
2268 /* LCOV_EXCL_STOP */
2272 ctsvc_handle_destroy(contact);
2273 contacts_list_destroy(list, true);
2278 ctsvc_server_start_timeout();
2282 void ctsvc_ipc_server_db_search_records_with_query_for_snippet(pims_ipc_h ipc,
2283 pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
2285 int ret = CONTACTS_ERROR_NONE;
2286 contacts_query_h query = NULL;
2287 char *keyword = NULL;
2290 contacts_list_h list = NULL;
2291 contacts_h contact = NULL;
2292 char *start_match = NULL;
2293 char *end_match = NULL;
2294 int token_number = 0;
2297 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
2298 if (CONTACTS_ERROR_NONE != ret) {
2299 /* LCOV_EXCL_START */
2300 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
2302 /* LCOV_EXCL_STOP */
2304 ret = ctsvc_ipc_unmarshal_query(indata, &query);
2305 if (ret != CONTACTS_ERROR_NONE) {
2306 /* LCOV_EXCL_START */
2307 ERR("ctsvc_ipc_unmarshal_record() Fail");
2309 /* LCOV_EXCL_STOP */
2311 ret = ctsvc_ipc_unmarshal_string(indata, &keyword);
2312 if (ret != CONTACTS_ERROR_NONE) {
2313 /* LCOV_EXCL_START */
2314 ERR("ctsvc_ipc_unmarshal_record() Fail");
2316 /* LCOV_EXCL_STOP */
2318 ret = ctsvc_ipc_unmarshal_int(indata, &offset);
2319 if (ret != CONTACTS_ERROR_NONE) {
2320 /* LCOV_EXCL_START */
2321 ERR("ctsvc_ipc_unmarshal_int() Fail");
2323 /* LCOV_EXCL_STOP */
2325 ret = ctsvc_ipc_unmarshal_int(indata, &limit);
2326 if (ret != CONTACTS_ERROR_NONE) {
2327 /* LCOV_EXCL_START */
2328 ERR("ctsvc_ipc_unmarshal_int() Fail");
2330 /* LCOV_EXCL_STOP */
2332 ret = ctsvc_ipc_unmarshal_string(indata, &start_match);
2333 if (ret != CONTACTS_ERROR_NONE) {
2334 /* LCOV_EXCL_START */
2335 ERR("ctsvc_ipc_unmarshal_record() Fail");
2337 /* LCOV_EXCL_STOP */
2339 ret = ctsvc_ipc_unmarshal_string(indata, &end_match);
2340 if (ret != CONTACTS_ERROR_NONE) {
2341 /* LCOV_EXCL_START */
2342 ERR("ctsvc_ipc_unmarshal_record() Fail");
2344 /* LCOV_EXCL_STOP */
2346 ret = ctsvc_ipc_unmarshal_int(indata, &token_number);
2347 if (ret != CONTACTS_ERROR_NONE) {
2348 /* LCOV_EXCL_START */
2349 ERR("ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
2351 /* LCOV_EXCL_STOP */
2354 /* LCOV_EXCL_START */
2355 ERR("ctsvc_ipc_server_db_insert_record() Fail");
2357 /* LCOV_EXCL_STOP */
2360 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(((ctsvc_query_s*)query)->view_uri))) {
2361 /* LCOV_EXCL_START */
2362 ret = CONTACTS_ERROR_PERMISSION_DENIED;
2364 /* LCOV_EXCL_STOP */
2367 ret = ctsvc_db_search_records_with_query_for_snippet(query, keyword, offset, limit,
2368 start_match, end_match, token_number, &list);
2371 *outdata = pims_ipc_data_create(0);
2372 if (NULL == *outdata) {
2373 /* LCOV_EXCL_START */
2374 ERR("pims_ipc_data_create() Fail");
2376 /* LCOV_EXCL_STOP */
2378 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2379 /* LCOV_EXCL_START */
2380 pims_ipc_data_destroy(*outdata);
2382 ERR("ctsvc_ipc_marshal_int() Fail");
2384 /* LCOV_EXCL_STOP */
2387 if (CONTACTS_ERROR_NO_DATA == ret) {
2389 } else if (CONTACTS_ERROR_NONE == ret) {
2390 ret = ctsvc_ipc_marshal_list(list, *outdata);
2392 if (ret != CONTACTS_ERROR_NONE) {
2393 /* LCOV_EXCL_START */
2394 ERR("ctsvc_ipc_marshal_list Fail");
2396 /* LCOV_EXCL_STOP */
2400 /* LCOV_EXCL_START */
2401 ERR("outdata is NULL");
2402 /* LCOV_EXCL_STOP */
2408 *outdata = pims_ipc_data_create(0);
2409 if (NULL == *outdata) {
2410 /* LCOV_EXCL_START */
2411 ERR("pims_ipc_data_create() Fail");
2413 /* LCOV_EXCL_STOP */
2415 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2416 /* LCOV_EXCL_START */
2417 pims_ipc_data_destroy(*outdata);
2419 ERR("ctsvc_ipc_marshal_int() Fail");
2421 /* LCOV_EXCL_STOP */
2424 /* LCOV_EXCL_START */
2425 ERR("outdata is NULL");
2426 /* LCOV_EXCL_STOP */
2429 ctsvc_handle_destroy(contact);
2430 contacts_list_destroy(list, true);
2431 contacts_query_destroy(query);
2435 ctsvc_server_start_timeout();
2439 void ctsvc_ipc_server_db_search_records(pims_ipc_h ipc, pims_ipc_data_h indata,
2440 pims_ipc_data_h *outdata, void *userdata)
2442 int ret = CONTACTS_ERROR_NONE;
2443 char *view_uri = NULL;
2444 char *keyword = NULL;
2447 contacts_list_h list = NULL;
2448 contacts_h contact = NULL;
2451 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
2452 if (CONTACTS_ERROR_NONE != ret) {
2453 /* LCOV_EXCL_START */
2454 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
2456 /* LCOV_EXCL_STOP */
2458 ret = ctsvc_ipc_unmarshal_string(indata, &view_uri);
2459 if (ret != CONTACTS_ERROR_NONE) {
2460 /* LCOV_EXCL_START */
2461 ERR("ctsvc_ipc_unmarshal_record() Fail(%d)", ret);
2463 /* LCOV_EXCL_STOP */
2465 ret = ctsvc_ipc_unmarshal_string(indata, &keyword);
2466 if (ret != CONTACTS_ERROR_NONE) {
2467 /* LCOV_EXCL_START */
2468 ERR("ctsvc_ipc_unmarshal_record() Fail(%d)", ret);
2470 /* LCOV_EXCL_STOP */
2472 ret = ctsvc_ipc_unmarshal_int(indata, &offset);
2473 if (ret != CONTACTS_ERROR_NONE) {
2474 /* LCOV_EXCL_START */
2475 ERR("ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
2477 /* LCOV_EXCL_STOP */
2479 ret = ctsvc_ipc_unmarshal_int(indata, &limit);
2480 if (ret != CONTACTS_ERROR_NONE) {
2481 /* LCOV_EXCL_START */
2482 ERR("ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
2484 /* LCOV_EXCL_STOP */
2487 /* LCOV_EXCL_START */
2488 ERR("ctsvc_ipc_server_db_insert_record() Fail");
2490 /* LCOV_EXCL_STOP */
2493 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(view_uri))) {
2494 /* LCOV_EXCL_START */
2495 ret = CONTACTS_ERROR_PERMISSION_DENIED;
2497 /* LCOV_EXCL_STOP */
2500 ret = ctsvc_db_search_records(view_uri, keyword, offset, limit, &list);
2503 *outdata = pims_ipc_data_create(0);
2504 if (NULL == *outdata) {
2505 /* LCOV_EXCL_START */
2506 ERR("pims_ipc_data_create() Fail");
2508 /* LCOV_EXCL_STOP */
2510 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2511 /* LCOV_EXCL_START */
2512 pims_ipc_data_destroy(*outdata);
2514 ERR("ctsvc_ipc_marshal_int() Fail");
2516 /* LCOV_EXCL_STOP */
2519 if (CONTACTS_ERROR_NO_DATA == ret) {
2521 } else if (CONTACTS_ERROR_NONE == ret) {
2522 ret = ctsvc_ipc_marshal_list(list, *outdata);
2524 if (ret != CONTACTS_ERROR_NONE) {
2525 /* LCOV_EXCL_START */
2526 ERR("ctsvc_ipc_unmarshal_int() Fail");
2528 /* LCOV_EXCL_STOP */
2532 /* LCOV_EXCL_START */
2533 ERR("outdata is NULL");
2534 /* LCOV_EXCL_STOP */
2540 *outdata = pims_ipc_data_create(0);
2541 if (NULL == *outdata) {
2542 /* LCOV_EXCL_START */
2543 ERR("pims_ipc_data_create() Fail");
2545 /* LCOV_EXCL_STOP */
2547 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2548 /* LCOV_EXCL_START */
2549 pims_ipc_data_destroy(*outdata);
2551 ERR("ctsvc_ipc_marshal_int() Fail");
2553 /* LCOV_EXCL_STOP */
2556 /* LCOV_EXCL_START */
2557 ERR("outdata is NULL");
2558 /* LCOV_EXCL_STOP */
2561 ctsvc_handle_destroy(contact);
2562 contacts_list_destroy(list, true);
2565 ctsvc_server_start_timeout();
2569 void ctsvc_ipc_server_db_search_records_with_range(pims_ipc_h ipc,
2570 pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
2572 int ret = CONTACTS_ERROR_NONE;
2573 char *view_uri = NULL;
2574 char *keyword = NULL;
2578 contacts_list_h list = NULL;
2579 contacts_h contact = NULL;
2582 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
2583 if (CONTACTS_ERROR_NONE != ret) {
2584 /* LCOV_EXCL_START */
2585 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
2587 /* LCOV_EXCL_STOP */
2589 ret = ctsvc_ipc_unmarshal_string(indata, &view_uri);
2590 if (ret != CONTACTS_ERROR_NONE) {
2591 /* LCOV_EXCL_START */
2592 ERR("ctsvc_ipc_unmarshal_record() Fail");
2594 /* LCOV_EXCL_STOP */
2596 ret = ctsvc_ipc_unmarshal_string(indata, &keyword);
2597 if (ret != CONTACTS_ERROR_NONE) {
2598 /* LCOV_EXCL_START */
2599 ERR("ctsvc_ipc_unmarshal_record() Fail");
2601 /* LCOV_EXCL_STOP */
2603 ret = ctsvc_ipc_unmarshal_int(indata, &offset);
2604 if (ret != CONTACTS_ERROR_NONE) {
2605 /* LCOV_EXCL_START */
2606 ERR("ctsvc_ipc_unmarshal_int() Fail");
2608 /* LCOV_EXCL_STOP */
2610 ret = ctsvc_ipc_unmarshal_int(indata, &limit);
2611 if (ret != CONTACTS_ERROR_NONE) {
2612 /* LCOV_EXCL_START */
2613 ERR("ctsvc_ipc_unmarshal_int() Fail");
2615 /* LCOV_EXCL_STOP */
2617 ret = ctsvc_ipc_unmarshal_int(indata, &range);
2618 if (ret != CONTACTS_ERROR_NONE) {
2619 /* LCOV_EXCL_START */
2620 ERR("ctsvc_ipc_unmarshal_int() Fail");
2622 /* LCOV_EXCL_STOP */
2625 /* LCOV_EXCL_START */
2626 ERR("ctsvc_ipc_server_db_insert_record() Fail");
2628 /* LCOV_EXCL_STOP */
2631 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(view_uri))) {
2632 /* LCOV_EXCL_START */
2633 ret = CONTACTS_ERROR_PERMISSION_DENIED;
2635 /* LCOV_EXCL_STOP */
2638 ret = ctsvc_db_search_records_with_range(view_uri, keyword, offset, limit, range,
2642 *outdata = pims_ipc_data_create(0);
2643 if (NULL == *outdata) {
2644 /* LCOV_EXCL_START */
2645 ERR("pims_ipc_data_create() Fail");
2647 /* LCOV_EXCL_STOP */
2649 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2650 /* LCOV_EXCL_START */
2651 pims_ipc_data_destroy(*outdata);
2653 ERR("ctsvc_ipc_marshal_int() Fail");
2655 /* LCOV_EXCL_STOP */
2658 if (CONTACTS_ERROR_NO_DATA == ret) {
2660 } else if (CONTACTS_ERROR_NONE == ret) {
2661 ret = ctsvc_ipc_marshal_list(list, *outdata);
2663 if (ret != CONTACTS_ERROR_NONE) {
2664 /* LCOV_EXCL_START */
2665 ERR("ctsvc_ipc_unmarshal_int() Fail");
2667 /* LCOV_EXCL_STOP */
2671 /* LCOV_EXCL_START */
2672 ERR("outdata is NULL");
2673 /* LCOV_EXCL_STOP */
2679 *outdata = pims_ipc_data_create(0);
2680 if (NULL == *outdata) {
2681 /* LCOV_EXCL_START */
2682 ERR("pims_ipc_data_create() Fail");
2684 /* LCOV_EXCL_STOP */
2686 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2687 /* LCOV_EXCL_START */
2688 pims_ipc_data_destroy(*outdata);
2690 ERR("ctsvc_ipc_marshal_int() Fail");
2692 /* LCOV_EXCL_STOP */
2695 /* LCOV_EXCL_START */
2696 ERR("outdata is NULL");
2697 /* LCOV_EXCL_STOP */
2701 ctsvc_handle_destroy(contact);
2702 contacts_list_destroy(list, true);
2705 ctsvc_server_start_timeout();
2709 void ctsvc_ipc_server_db_search_records_with_query(pims_ipc_h ipc,
2710 pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
2712 int ret = CONTACTS_ERROR_NONE;
2713 contacts_query_h query = NULL;
2714 char *keyword = NULL;
2717 contacts_list_h list = NULL;
2718 contacts_h contact = NULL;
2721 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
2722 if (CONTACTS_ERROR_NONE != ret) {
2723 /* LCOV_EXCL_START */
2724 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
2726 /* LCOV_EXCL_STOP */
2728 ret = ctsvc_ipc_unmarshal_query(indata, &query);
2729 if (ret != CONTACTS_ERROR_NONE) {
2730 /* LCOV_EXCL_START */
2731 ERR("ctsvc_ipc_unmarshal_record() Fail");
2733 /* LCOV_EXCL_STOP */
2735 ret = ctsvc_ipc_unmarshal_string(indata, &keyword);
2736 if (ret != CONTACTS_ERROR_NONE) {
2737 /* LCOV_EXCL_START */
2738 ERR("ctsvc_ipc_unmarshal_record() Fail");
2740 /* LCOV_EXCL_STOP */
2742 ret = ctsvc_ipc_unmarshal_int(indata, &offset);
2743 if (ret != CONTACTS_ERROR_NONE) {
2744 /* LCOV_EXCL_START */
2745 ERR("ctsvc_ipc_unmarshal_int() Fail");
2747 /* LCOV_EXCL_STOP */
2749 ret = ctsvc_ipc_unmarshal_int(indata, &limit);
2750 if (ret != CONTACTS_ERROR_NONE) {
2751 /* LCOV_EXCL_START */
2752 ERR("ctsvc_ipc_unmarshal_int() Fail");
2754 /* LCOV_EXCL_STOP */
2757 /* LCOV_EXCL_START */
2758 ERR("ctsvc_ipc_server_db_insert_record() Fail");
2760 /* LCOV_EXCL_STOP */
2764 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(((ctsvc_query_s*)query)->view_uri))) {
2765 /* LCOV_EXCL_START */
2766 ret = CONTACTS_ERROR_PERMISSION_DENIED;
2768 /* LCOV_EXCL_STOP */
2772 ret = ctsvc_db_search_records_with_query(query, keyword, offset, limit, &list);
2775 *outdata = pims_ipc_data_create(0);
2776 if (NULL == *outdata) {
2777 /* LCOV_EXCL_START */
2778 ERR("pims_ipc_data_create() Fail");
2780 /* LCOV_EXCL_STOP */
2782 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2783 /* LCOV_EXCL_START */
2784 pims_ipc_data_destroy(*outdata);
2786 ERR("ctsvc_ipc_marshal_int() Fail");
2788 /* LCOV_EXCL_STOP */
2791 if (CONTACTS_ERROR_NO_DATA == ret) {
2793 } else if (CONTACTS_ERROR_NONE == ret) {
2794 ret = ctsvc_ipc_marshal_list(list, *outdata);
2796 if (ret != CONTACTS_ERROR_NONE) {
2797 /* LCOV_EXCL_START */
2798 ERR("ctsvc_ipc_marshal_list Fail");
2800 /* LCOV_EXCL_STOP */
2804 /* LCOV_EXCL_START */
2805 ERR("outdata is NULL");
2806 /* LCOV_EXCL_STOP */
2812 *outdata = pims_ipc_data_create(0);
2813 if (NULL == *outdata) {
2814 /* LCOV_EXCL_START */
2815 ERR("pims_ipc_data_create() Fail");
2817 /* LCOV_EXCL_STOP */
2819 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2820 /* LCOV_EXCL_START */
2821 pims_ipc_data_destroy(*outdata);
2823 ERR("ctsvc_ipc_marshal_int() Fail");
2825 /* LCOV_EXCL_STOP */
2828 /* LCOV_EXCL_START */
2829 ERR("outdata is NULL");
2830 /* LCOV_EXCL_STOP */
2833 ctsvc_handle_destroy(contact);
2834 contacts_list_destroy(list, true);
2835 contacts_query_destroy(query);
2837 ctsvc_server_start_timeout();
2841 void ctsvc_ipc_server_db_get_status(pims_ipc_h ipc, pims_ipc_data_h indata,
2842 pims_ipc_data_h *outdata, void *userdata)
2844 int ret = CONTACTS_ERROR_NONE;
2845 contacts_db_status_e status = CONTACTS_DB_STATUS_NORMAL;
2846 contacts_h contact = NULL;
2849 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
2850 if (CONTACTS_ERROR_NONE != ret) {
2851 /* LCOV_EXCL_START */
2852 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
2854 /* LCOV_EXCL_STOP */
2858 ret = ctsvc_db_get_status(&status);
2862 *outdata = pims_ipc_data_create(0);
2863 if (NULL == *outdata) {
2864 /* LCOV_EXCL_START */
2865 ERR("pims_ipc_data_create() Fail");
2867 /* LCOV_EXCL_STOP */
2870 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2871 /* LCOV_EXCL_START */
2872 pims_ipc_data_destroy(*outdata);
2874 ERR("ctsvc_ipc_marshal_int() Fail");
2876 /* LCOV_EXCL_STOP */
2879 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(status, *outdata)) {
2880 /* LCOV_EXCL_START */
2881 pims_ipc_data_destroy(*outdata);
2883 ERR("ctsvc_ipc_marshal_int() Fail");
2885 /* LCOV_EXCL_STOP */
2888 /* LCOV_EXCL_START */
2889 ERR("outdata is NULL");
2890 /* LCOV_EXCL_STOP */
2893 ctsvc_handle_destroy(contact);
2894 ctsvc_server_start_timeout();
2898 void ctsvc_ipc_server_db_get_count_for_search_records(pims_ipc_h ipc,
2899 pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
2901 int ret = CONTACTS_ERROR_NONE;
2902 char *view_uri = NULL;
2904 contacts_h contact = NULL;
2905 char *keyword = NULL;
2908 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
2909 if (CONTACTS_ERROR_NONE != ret) {
2910 /* LCOV_EXCL_START */
2911 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
2913 /* LCOV_EXCL_STOP */
2916 ret = ctsvc_ipc_unmarshal_string(indata, &view_uri);
2917 if (ret != CONTACTS_ERROR_NONE) {
2918 /* LCOV_EXCL_START */
2919 ERR("ctsvc_ipc_unmarshal_record() Fail");
2921 /* LCOV_EXCL_STOP */
2924 ret = ctsvc_ipc_unmarshal_string(indata, &keyword);
2925 if (ret != CONTACTS_ERROR_NONE) {
2926 /* LCOV_EXCL_START */
2927 ERR("ctsvc_ipc_unmarshal_string() Fail");
2929 /* LCOV_EXCL_STOP */
2932 /* LCOV_EXCL_START */
2933 ERR("ctsvc_ipc_server_db_insert_record() Fail");
2935 /* LCOV_EXCL_STOP */
2938 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(view_uri))) {
2939 /* LCOV_EXCL_START */
2940 ret = CONTACTS_ERROR_PERMISSION_DENIED;
2942 /* LCOV_EXCL_STOP */
2945 ret = ctsvc_db_get_count_for_search_records(view_uri, keyword, &count);
2948 *outdata = pims_ipc_data_create(0);
2949 if (NULL == *outdata) {
2950 /* LCOV_EXCL_START */
2951 ERR("pims_ipc_data_create() Fail");
2953 /* LCOV_EXCL_STOP */
2955 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2956 /* LCOV_EXCL_START */
2957 pims_ipc_data_destroy(*outdata);
2959 ERR("ctsvc_ipc_marshal_int() Fail");
2961 /* LCOV_EXCL_STOP */
2964 if (CONTACTS_ERROR_NO_DATA == ret) {
2966 } else if (CONTACTS_ERROR_NONE == ret) {
2967 ret = ctsvc_ipc_marshal_int(count, *outdata);
2969 if (ret != CONTACTS_ERROR_NONE) {
2970 /* LCOV_EXCL_START */
2971 ERR("ctsvc_ipc_unmarshal_int() Fail");
2973 /* LCOV_EXCL_STOP */
2977 /* LCOV_EXCL_START */
2978 ERR("outdata is NULL");
2979 /* LCOV_EXCL_STOP */
2985 *outdata = pims_ipc_data_create(0);
2986 if (NULL == *outdata) {
2987 /* LCOV_EXCL_START */
2988 ERR("pims_ipc_data_create() Fail");
2990 /* LCOV_EXCL_STOP */
2992 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2993 /* LCOV_EXCL_START */
2994 pims_ipc_data_destroy(*outdata);
2996 ERR("ctsvc_ipc_marshal_int() Fail");
2998 /* LCOV_EXCL_STOP */
3001 /* LCOV_EXCL_START */
3002 ERR("outdata is NULL");
3003 /* LCOV_EXCL_STOP */
3006 ctsvc_handle_destroy(contact);
3009 ctsvc_server_start_timeout();
3013 void ctsvc_ipc_server_db_get_count_for_search_records_with_range(pims_ipc_h ipc,
3014 pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
3016 int ret = CONTACTS_ERROR_NONE;
3017 char *view_uri = NULL;
3019 contacts_h contact = NULL;
3020 char *keyword = NULL;
3024 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
3025 if (CONTACTS_ERROR_NONE != ret) {
3026 /* LCOV_EXCL_START */
3027 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
3029 /* LCOV_EXCL_STOP */
3032 ret = ctsvc_ipc_unmarshal_string(indata, &view_uri);
3033 if (ret != CONTACTS_ERROR_NONE) {
3034 /* LCOV_EXCL_START */
3035 ERR("ctsvc_ipc_unmarshal_record() Fail");
3037 /* LCOV_EXCL_STOP */
3040 ret = ctsvc_ipc_unmarshal_string(indata, &keyword);
3041 if (ret != CONTACTS_ERROR_NONE) {
3042 /* LCOV_EXCL_START */
3043 ERR("ctsvc_ipc_unmarshal_string() Fail");
3045 /* LCOV_EXCL_STOP */
3048 ret = ctsvc_ipc_unmarshal_int(indata, &range);
3049 if (ret != CONTACTS_ERROR_NONE) {
3050 /* LCOV_EXCL_START */
3051 ERR("ctsvc_ipc_unmarshal_string() Fail");
3053 /* LCOV_EXCL_STOP */
3056 /* LCOV_EXCL_START */
3057 ERR("ctsvc_ipc_server_db_insert_record() Fail");
3059 /* LCOV_EXCL_STOP */
3062 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(view_uri))) {
3063 /* LCOV_EXCL_START */
3064 ret = CONTACTS_ERROR_PERMISSION_DENIED;
3066 /* LCOV_EXCL_STOP */
3069 ret = ctsvc_db_get_count_for_search_records_with_range(view_uri, keyword, range, &count);
3072 *outdata = pims_ipc_data_create(0);
3073 if (NULL == *outdata) {
3074 /* LCOV_EXCL_START */
3075 ERR("pims_ipc_data_create() Fail");
3077 /* LCOV_EXCL_STOP */
3079 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
3080 /* LCOV_EXCL_START */
3081 pims_ipc_data_destroy(*outdata);
3083 ERR("ctsvc_ipc_marshal_int() Fail");
3085 /* LCOV_EXCL_STOP */
3088 if (CONTACTS_ERROR_NO_DATA == ret) {
3090 } else if (CONTACTS_ERROR_NONE == ret) {
3091 ret = ctsvc_ipc_marshal_int(count, *outdata);
3093 if (ret != CONTACTS_ERROR_NONE) {
3094 /* LCOV_EXCL_START */
3095 ERR("ctsvc_ipc_unmarshal_int() Fail");
3097 /* LCOV_EXCL_STOP */
3101 /* LCOV_EXCL_START */
3102 ERR("outdata is NULL");
3103 /* LCOV_EXCL_STOP */
3109 *outdata = pims_ipc_data_create(0);
3110 if (NULL == *outdata) {
3111 /* LCOV_EXCL_START */
3112 ERR("pims_ipc_data_create() Fail");
3114 /* LCOV_EXCL_STOP */
3116 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
3117 /* LCOV_EXCL_START */
3118 pims_ipc_data_destroy(*outdata);
3120 ERR("ctsvc_ipc_marshal_int() Fail");
3122 /* LCOV_EXCL_STOP */
3125 /* LCOV_EXCL_START */
3126 ERR("outdata is NULL");
3127 /* LCOV_EXCL_STOP */
3130 ctsvc_handle_destroy(contact);
3133 ctsvc_server_start_timeout();
3137 void ctsvc_ipc_server_db_get_count_for_search_records_with_query(pims_ipc_h ipc,
3138 pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
3140 int ret = CONTACTS_ERROR_NONE;
3141 contacts_query_h query = NULL;
3143 contacts_h contact = NULL;
3144 char *keyword = NULL;
3147 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
3148 if (CONTACTS_ERROR_NONE != ret) {
3149 /* LCOV_EXCL_START */
3150 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
3152 /* LCOV_EXCL_STOP */
3155 ret = ctsvc_ipc_unmarshal_query(indata, &query);
3156 if (ret != CONTACTS_ERROR_NONE) {
3157 /* LCOV_EXCL_START */
3158 ERR("ctsvc_ipc_unmarshal_query() Fail");
3160 /* LCOV_EXCL_STOP */
3163 ret = ctsvc_ipc_unmarshal_string(indata, &keyword);
3164 if (ret != CONTACTS_ERROR_NONE) {
3165 /* LCOV_EXCL_START */
3166 ERR("ctsvc_ipc_unmarshal_string() Fail");
3168 /* LCOV_EXCL_STOP */
3171 /* LCOV_EXCL_START */
3172 ERR("ctsvc_ipc_server_db_get_count_for_search_records_with_query() Fail");
3174 /* LCOV_EXCL_STOP */
3177 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(((ctsvc_query_s*)query)->view_uri))) {
3178 /* LCOV_EXCL_START */
3179 ret = CONTACTS_ERROR_PERMISSION_DENIED;
3181 /* LCOV_EXCL_STOP */
3184 ret = ctsvc_db_get_count_for_search_records_with_query(query, keyword, &count);
3187 *outdata = pims_ipc_data_create(0);
3188 if (NULL == *outdata) {
3189 /* LCOV_EXCL_START */
3190 ERR("pims_ipc_data_create() Fail");
3192 /* LCOV_EXCL_STOP */
3194 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
3195 /* LCOV_EXCL_START */
3196 pims_ipc_data_destroy(*outdata);
3198 ERR("ctsvc_ipc_marshal_int() Fail");
3200 /* LCOV_EXCL_STOP */
3203 if (CONTACTS_ERROR_NO_DATA == ret) {
3205 } else if (CONTACTS_ERROR_NONE == ret) {
3206 ret = ctsvc_ipc_marshal_int(count, *outdata);
3208 if (ret != CONTACTS_ERROR_NONE) {
3209 /* LCOV_EXCL_START */
3210 ERR("ctsvc_ipc_unmarshal_int() Fail");
3212 /* LCOV_EXCL_STOP */
3216 /* LCOV_EXCL_START */
3217 ERR("outdata is NULL");
3218 /* LCOV_EXCL_STOP */
3224 *outdata = pims_ipc_data_create(0);
3225 if (NULL == *outdata) {
3226 /* LCOV_EXCL_START */
3227 ERR("pims_ipc_data_create() Fail");
3229 /* LCOV_EXCL_STOP */
3231 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
3232 /* LCOV_EXCL_START */
3233 pims_ipc_data_destroy(*outdata);
3235 ERR("ctsvc_ipc_marshal_int() Fail");
3237 /* LCOV_EXCL_STOP */
3240 /* LCOV_EXCL_START */
3241 ERR("outdata is NULL");
3242 /* LCOV_EXCL_STOP */
3245 ctsvc_handle_destroy(contact);
3246 contacts_query_destroy(query);
3248 ctsvc_server_start_timeout();