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;
99 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
100 if (CONTACTS_ERROR_NONE != ret) {
101 /* LCOV_EXCL_START */
102 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
103 ret = CONTACTS_ERROR_IPC;
109 ret = ctsvc_disconnect();
113 *outdata = pims_ipc_data_create(0);
114 if (NULL == *outdata) {
115 /* LCOV_EXCL_START */
116 ERR("pims_ipc_data_create() Fail");
120 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
121 /* LCOV_EXCL_START */
122 pims_ipc_data_destroy(*outdata);
124 ERR("ctsvc_ipc_marshal_int() Fail");
129 /* LCOV_EXCL_START */
130 ERR("outdata is NULL");
134 ctsvc_handle_destroy(contact);
135 ctsvc_server_trim_memory();
136 ctsvc_server_start_timeout();
139 void ctsvc_ipc_server_check_permission(pims_ipc_h ipc, pims_ipc_data_h indata,
140 pims_ipc_data_h *outdata, void *userdata)
142 int ret = CONTACTS_ERROR_NONE;
146 if (NULL == indata) {
147 /* LCOV_EXCL_START */
148 ret = CONTACTS_ERROR_INVALID_PARAMETER;
149 ERR("check permission Fail");
154 ret = ctsvc_ipc_unmarshal_int(indata, &permission);
155 if (ret != CONTACTS_ERROR_NONE) {
156 /* LCOV_EXCL_START */
157 ERR("ctsvc_ipc_unmarshal_int() Fail");
162 result = ctsvc_have_permission(ipc, permission);
165 *outdata = pims_ipc_data_create(0);
166 if (NULL == *outdata) {
167 /* LCOV_EXCL_START */
168 ERR("pims_ipc_data_create() Fail");
169 ctsvc_server_start_timeout();
174 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
175 /* LCOV_EXCL_START */
176 pims_ipc_data_destroy(*outdata);
178 ERR("ctsvc_ipc_marshal_int() Fail");
179 ctsvc_server_start_timeout();
184 if (ret == CONTACTS_ERROR_NONE) {
185 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_bool(result, *outdata)) {
186 /* LCOV_EXCL_START */
187 pims_ipc_data_destroy(*outdata);
189 ERR("ctsvc_ipc_marshal_bool() Fail");
190 ctsvc_server_start_timeout();
195 ctsvc_server_start_timeout();
198 void ctsvc_ipc_server_db_insert_record(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
200 int ret = CONTACTS_ERROR_NONE;
201 contacts_record_h record = NULL;
203 contacts_h contact = NULL;
206 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
207 if (CONTACTS_ERROR_NONE != ret) {
208 /* LCOV_EXCL_START */
209 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
210 ret = CONTACTS_ERROR_IPC;
215 ret = ctsvc_ipc_unmarshal_record(indata, &record);
216 if (ret != CONTACTS_ERROR_NONE) {
217 /* LCOV_EXCL_START */
218 ERR("ctsvc_ipc_unmarshal_record() Fail");
224 /* LCOV_EXCL_START */
225 ERR("ctsvc_ipc_server_db_insert_record() Fail");
230 if (!ctsvc_have_permission(ipc, ctsvc_required_write_permission(((ctsvc_record_s*)record)->view_uri))) {
231 /* LCOV_EXCL_START */
232 ret = CONTACTS_ERROR_PERMISSION_DENIED;
237 ret = ctsvc_db_insert_record(record, &id);
240 *outdata = pims_ipc_data_create(0);
241 if (NULL == *outdata) {
242 /* LCOV_EXCL_START */
243 ERR("pims_ipc_data_create() Fail");
247 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
248 /* LCOV_EXCL_START */
249 pims_ipc_data_destroy(*outdata);
251 ERR("ctsvc_ipc_marshal_int() Fail");
255 if (ret == CONTACTS_ERROR_NONE) {
256 int transaction_ver = ctsvc_get_transaction_ver();
257 if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
258 /* LCOV_EXCL_START */
259 pims_ipc_data_destroy(*outdata);
261 ERR("ctsvc_ipc_marshal_int() Fail");
262 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
266 if (ctsvc_ipc_marshal_int(id, *outdata) != CONTACTS_ERROR_NONE) {
267 /* LCOV_EXCL_START */
268 pims_ipc_data_destroy(*outdata);
269 ERR("ctsvc_ipc_marshal_int() Fail");
270 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
276 /* LCOV_EXCL_START */
277 ERR("outdata is NULL");
284 *outdata = pims_ipc_data_create(0);
285 if (NULL == *outdata) {
286 /* LCOV_EXCL_START */
287 ERR("pims_ipc_data_create() Fail");
291 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
292 /* LCOV_EXCL_START */
293 pims_ipc_data_destroy(*outdata);
295 ERR("ctsvc_ipc_marshal_int() Fail");
300 /* LCOV_EXCL_START */
301 ERR("outdata is NULL");
306 ctsvc_handle_destroy(contact);
307 contacts_record_destroy(record, true);
308 ctsvc_server_trim_memory();
309 ctsvc_server_start_timeout();
313 void ctsvc_ipc_server_db_get_record(pims_ipc_h ipc, pims_ipc_data_h indata,
314 pims_ipc_data_h *outdata, void *userdata)
316 int ret = CONTACTS_ERROR_NONE;
317 char *view_uri = NULL;
319 contacts_record_h record = NULL;
320 contacts_h contact = NULL;
323 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
324 if (CONTACTS_ERROR_NONE != ret) {
325 /* LCOV_EXCL_START */
326 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
327 ret = CONTACTS_ERROR_IPC;
331 ret = ctsvc_ipc_unmarshal_string(indata, &view_uri);
332 if (ret != CONTACTS_ERROR_NONE) {
333 /* LCOV_EXCL_START */
334 ERR("ctsvc_ipc_unmarshal_string Fail");
338 ret = ctsvc_ipc_unmarshal_int(indata, &id);
339 if (ret != CONTACTS_ERROR_NONE) {
340 /* LCOV_EXCL_START */
341 ERR("ctsvc_ipc_unmarshal_int() Fail");
346 /* LCOV_EXCL_START */
347 ERR("ctsvc_ipc_server_db_insert_record() Fail");
352 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(view_uri))) {
353 /* LCOV_EXCL_START */
354 ret = CONTACTS_ERROR_PERMISSION_DENIED;
359 ret = ctsvc_db_get_record(view_uri, id, &record);
363 *outdata = pims_ipc_data_create(0);
364 if (NULL == *outdata) {
365 /* LCOV_EXCL_START */
366 ERR("pims_ipc_data_create() Fail");
370 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
371 /* LCOV_EXCL_START */
372 pims_ipc_data_destroy(*outdata);
374 ERR("ctsvc_ipc_marshal_int() Fail");
379 if (CONTACTS_ERROR_NO_DATA == ret) {
381 } else if (CONTACTS_ERROR_NONE == ret) {
382 if (ctsvc_ipc_marshal_record(record, *outdata) != CONTACTS_ERROR_NONE) {
383 /* LCOV_EXCL_START */
384 pims_ipc_data_destroy(*outdata);
386 ERR("ctsvc_ipc_marshal_record() Fail");
392 /* LCOV_EXCL_START */
393 ERR("outdata is NULL");
397 ctsvc_handle_destroy(contact);
398 contacts_record_destroy(record, true);
400 ctsvc_server_start_timeout();
404 void ctsvc_ipc_server_db_update_record(pims_ipc_h ipc, pims_ipc_data_h indata,
405 pims_ipc_data_h *outdata, void *userdata)
407 int ret = CONTACTS_ERROR_NONE;
408 contacts_record_h record = NULL;
409 contacts_h contact = NULL;
412 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
413 if (CONTACTS_ERROR_NONE != ret) {
414 /* LCOV_EXCL_START */
415 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
416 ret = CONTACTS_ERROR_IPC;
420 ret = ctsvc_ipc_unmarshal_record(indata, &record);
421 if (ret != CONTACTS_ERROR_NONE) {
422 /* LCOV_EXCL_START */
423 ERR("ctsvc_ipc_unmarshal_record() Fail");
428 /* LCOV_EXCL_START */
429 ERR("ctsvc_ipc_server_db_insert_record() Fail");
434 if (!ctsvc_have_permission(ipc, ctsvc_required_write_permission(((ctsvc_record_s*)record)->view_uri))) {
435 /* LCOV_EXCL_START */
436 ret = CONTACTS_ERROR_PERMISSION_DENIED;
441 ret = ctsvc_db_update_record(record);
444 *outdata = pims_ipc_data_create(0);
445 if (NULL == *outdata) {
446 /* LCOV_EXCL_START */
447 ERR("pims_ipc_data_create() Fail");
451 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
452 /* LCOV_EXCL_START */
453 pims_ipc_data_destroy(*outdata);
455 ERR("ctsvc_ipc_marshal_int() Fail");
460 if (ret == CONTACTS_ERROR_NONE) {
461 int transaction_ver = ctsvc_get_transaction_ver();
462 if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
463 /* LCOV_EXCL_START */
464 pims_ipc_data_destroy(*outdata);
466 ERR("ctsvc_ipc_marshal_int() Fail");
467 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
478 *outdata = pims_ipc_data_create(0);
479 if (NULL == *outdata) {
480 /* LCOV_EXCL_START */
481 ERR("pims_ipc_data_create() Fail");
485 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
486 /* LCOV_EXCL_START */
487 pims_ipc_data_destroy(*outdata);
489 ERR("ctsvc_ipc_marshal_int() Fail");
494 /* LCOV_EXCL_START */
495 ERR("outdata is NULL");
499 ctsvc_handle_destroy(contact);
500 contacts_record_destroy(record, true);
501 ctsvc_server_trim_memory();
502 ctsvc_server_start_timeout();
506 void ctsvc_ipc_server_db_delete_record(pims_ipc_h ipc, pims_ipc_data_h indata,
507 pims_ipc_data_h *outdata, void *userdata)
509 int ret = CONTACTS_ERROR_NONE;
510 char *view_uri = NULL;
512 contacts_h contact = NULL;
515 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
516 if (CONTACTS_ERROR_NONE != ret) {
517 /* LCOV_EXCL_START */
518 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
519 ret = CONTACTS_ERROR_IPC;
523 ret = ctsvc_ipc_unmarshal_string(indata, &view_uri);
524 if (ret != CONTACTS_ERROR_NONE) {
525 /* LCOV_EXCL_START */
526 ERR("ctsvc_ipc_unmarshal_record() Fail");
530 ret = ctsvc_ipc_unmarshal_int(indata, &id);
531 if (ret != CONTACTS_ERROR_NONE) {
532 /* LCOV_EXCL_START */
533 ERR("ctsvc_ipc_unmarshal_int() Fail");
538 /* LCOV_EXCL_START */
539 ERR("ctsvc_ipc_server_db_insert_record() Fail");
544 if (!ctsvc_have_permission(ipc, ctsvc_required_write_permission(view_uri))) {
545 /* LCOV_EXCL_START */
546 ret = CONTACTS_ERROR_PERMISSION_DENIED;
551 ret = ctsvc_db_delete_record(view_uri, id);
554 *outdata = pims_ipc_data_create(0);
555 if (NULL == *outdata) {
556 /* LCOV_EXCL_START */
557 ERR("pims_ipc_data_create() Fail");
561 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
562 /* LCOV_EXCL_START */
563 pims_ipc_data_destroy(*outdata);
565 ERR("ctsvc_ipc_marshal_int() Fail");
570 if (ret == CONTACTS_ERROR_NONE) {
571 int transaction_ver = ctsvc_get_transaction_ver();
572 if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
573 /* LCOV_EXCL_START */
574 pims_ipc_data_destroy(*outdata);
576 ERR("ctsvc_ipc_marshal_int() Fail");
577 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
588 *outdata = pims_ipc_data_create(0);
589 if (NULL == *outdata) {
590 /* LCOV_EXCL_START */
591 ERR("pims_ipc_data_create() Fail");
595 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
596 /* LCOV_EXCL_START */
597 pims_ipc_data_destroy(*outdata);
599 ERR("ctsvc_ipc_marshal_int() Fail");
604 /* LCOV_EXCL_START */
605 ERR("outdata is NULL");
610 ctsvc_handle_destroy(contact);
612 ctsvc_server_start_timeout();
616 void ctsvc_ipc_server_db_replace_record(pims_ipc_h ipc, pims_ipc_data_h indata,
617 pims_ipc_data_h *outdata, void *userdata)
619 int ret = CONTACTS_ERROR_NONE;
620 contacts_record_h record = NULL;
622 contacts_h contact = NULL;
625 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
626 if (CONTACTS_ERROR_NONE != ret) {
627 /* LCOV_EXCL_START */
628 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
629 ret = CONTACTS_ERROR_IPC;
634 ret = ctsvc_ipc_unmarshal_record(indata, &record);
635 if (ret != CONTACTS_ERROR_NONE) {
636 /* LCOV_EXCL_START */
637 ERR("ctsvc_ipc_unmarshal_record() Fail");
642 ret = ctsvc_ipc_unmarshal_int(indata, &id);
643 if (ret != CONTACTS_ERROR_NONE) {
644 /* LCOV_EXCL_START */
645 ERR("ctsvc_ipc_unmarshal_int() Fail");
650 /* LCOV_EXCL_START */
651 ERR("ctsvc_ipc_server_db_replace_record Fail");
656 if (!ctsvc_have_permission(ipc, ctsvc_required_write_permission(((ctsvc_record_s*)record)->view_uri))) {
657 /* LCOV_EXCL_START */
658 ret = CONTACTS_ERROR_PERMISSION_DENIED;
664 ret = ctsvc_db_replace_record(record, id);
667 *outdata = pims_ipc_data_create(0);
668 if (NULL == *outdata) {
669 /* LCOV_EXCL_START */
670 ERR("pims_ipc_data_create() Fail");
675 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
676 /* LCOV_EXCL_START */
677 pims_ipc_data_destroy(*outdata);
679 ERR("ctsvc_ipc_marshal_int() Fail");
684 if (ret == CONTACTS_ERROR_NONE) {
685 int transaction_ver = ctsvc_get_transaction_ver();
686 if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
687 /* LCOV_EXCL_START */
688 pims_ipc_data_destroy(*outdata);
690 ERR("ctsvc_ipc_marshal_int() Fail");
691 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
697 /* LCOV_EXCL_START */
698 ERR("outdata is NULL");
705 *outdata = pims_ipc_data_create(0);
706 if (NULL == *outdata) {
707 /* LCOV_EXCL_START */
708 ERR("pims_ipc_data_create() Fail");
712 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
713 /* LCOV_EXCL_START */
714 pims_ipc_data_destroy(*outdata);
716 ERR("ctsvc_ipc_marshal_int() Fail");
721 /* LCOV_EXCL_START */
722 ERR("outdata is NULL");
727 ctsvc_handle_destroy(contact);
728 contacts_record_destroy(record, true);
729 ctsvc_server_start_timeout();
733 void ctsvc_ipc_server_db_get_all_records(pims_ipc_h ipc, pims_ipc_data_h indata,
734 pims_ipc_data_h *outdata, void *userdata)
736 int ret = CONTACTS_ERROR_NONE;
737 char *view_uri = NULL;
740 contacts_list_h list = NULL;
741 contacts_h contact = NULL;
744 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
745 if (CONTACTS_ERROR_NONE != ret) {
746 /* LCOV_EXCL_START */
747 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
748 ret = CONTACTS_ERROR_IPC;
753 ret = ctsvc_ipc_unmarshal_string(indata, &view_uri);
754 if (ret != CONTACTS_ERROR_NONE) {
755 /* LCOV_EXCL_START */
756 ERR("ctsvc_ipc_unmarshal_record() Fail");
760 ret = ctsvc_ipc_unmarshal_int(indata, &offset);
761 if (ret != CONTACTS_ERROR_NONE) {
762 /* LCOV_EXCL_START */
763 ERR("ctsvc_ipc_unmarshal_int() Fail");
767 ret = ctsvc_ipc_unmarshal_int(indata, &limit);
768 if (ret != CONTACTS_ERROR_NONE) {
769 /* LCOV_EXCL_START */
770 ERR("ctsvc_ipc_unmarshal_int() Fail");
775 /* LCOV_EXCL_START */
776 ERR("ctsvc_ipc_server_db_insert_record() Fail");
781 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(view_uri))) {
782 /* LCOV_EXCL_START */
783 ret = CONTACTS_ERROR_PERMISSION_DENIED;
788 ret = ctsvc_db_get_all_records(view_uri, offset, limit, &list);
791 *outdata = pims_ipc_data_create(0);
792 if (NULL == *outdata) {
793 /* LCOV_EXCL_START */
794 ERR("pims_ipc_data_create() Fail");
798 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
799 /* LCOV_EXCL_START */
800 pims_ipc_data_destroy(*outdata);
802 ERR("ctsvc_ipc_marshal_int() Fail");
807 if (CONTACTS_ERROR_NO_DATA == ret) {
809 } else if (CONTACTS_ERROR_NONE == ret) {
810 ret = ctsvc_ipc_marshal_list(list, *outdata);
812 if (ret != CONTACTS_ERROR_NONE) {
813 /* LCOV_EXCL_START */
814 ERR("ctsvc_ipc_unmarshal_int() Fail");
821 /* LCOV_EXCL_START */
822 ERR("outdata is NULL");
830 *outdata = pims_ipc_data_create(0);
831 if (NULL == *outdata) {
832 /* LCOV_EXCL_START */
833 ERR("pims_ipc_data_create() Fail");
837 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
838 /* LCOV_EXCL_START */
839 pims_ipc_data_destroy(*outdata);
841 ERR("ctsvc_ipc_marshal_int() Fail");
846 /* LCOV_EXCL_START */
847 ERR("outdata is NULL");
851 ctsvc_handle_destroy(contact);
852 contacts_list_destroy(list, true);
854 ctsvc_server_start_timeout();
858 void ctsvc_ipc_server_db_get_records_with_query(pims_ipc_h ipc, pims_ipc_data_h indata,
859 pims_ipc_data_h *outdata, void *userdata)
861 int ret = CONTACTS_ERROR_NONE;
862 contacts_query_h query = NULL;
865 contacts_list_h list = NULL;
866 contacts_h contact = NULL;
869 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
870 if (CONTACTS_ERROR_NONE != ret) {
871 /* LCOV_EXCL_START */
872 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
877 ret = ctsvc_ipc_unmarshal_query(indata, &query);
878 if (ret != CONTACTS_ERROR_NONE) {
879 /* LCOV_EXCL_START */
880 ERR("ctsvc_ipc_unmarshal_record() Fail");
884 ret = ctsvc_ipc_unmarshal_int(indata, &offset);
885 if (ret != CONTACTS_ERROR_NONE) {
886 /* LCOV_EXCL_START */
887 ERR("ctsvc_ipc_unmarshal_int() Fail");
891 ret = ctsvc_ipc_unmarshal_int(indata, &limit);
892 if (ret != CONTACTS_ERROR_NONE) {
893 /* LCOV_EXCL_START */
894 ERR("ctsvc_ipc_unmarshal_int() Fail");
899 /* LCOV_EXCL_START */
900 ERR("ctsvc_ipc_server_db_insert_record() Fail");
905 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(((ctsvc_query_s*)query)->view_uri))) {
906 /* LCOV_EXCL_START */
907 ret = CONTACTS_ERROR_PERMISSION_DENIED;
912 ret = ctsvc_db_get_records_with_query(query, offset, limit, &list);
915 *outdata = pims_ipc_data_create(0);
916 if (NULL == *outdata) {
917 /* LCOV_EXCL_START */
918 ERR("pims_ipc_data_create() Fail");
922 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
923 /* LCOV_EXCL_START */
924 pims_ipc_data_destroy(*outdata);
926 ERR("ctsvc_ipc_marshal_int() Fail");
931 if (CONTACTS_ERROR_NO_DATA == ret) {
933 } else if (CONTACTS_ERROR_NONE == ret) {
934 ret = ctsvc_ipc_marshal_list(list, *outdata);
936 if (ret != CONTACTS_ERROR_NONE) {
937 /* LCOV_EXCL_START */
938 ERR("ctsvc_ipc_unmarshal_int() Fail");
944 /* LCOV_EXCL_START */
945 ERR("outdata is NULL");
952 *outdata = pims_ipc_data_create(0);
953 if (NULL == *outdata) {
954 /* LCOV_EXCL_START */
955 ERR("pims_ipc_data_create() Fail");
959 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
960 /* LCOV_EXCL_START */
961 pims_ipc_data_destroy(*outdata);
963 ERR("ctsvc_ipc_marshal_int() Fail");
968 /* LCOV_EXCL_START */
969 ERR("outdata is NULL");
973 ctsvc_handle_destroy(contact);
974 contacts_list_destroy(list, true);
975 contacts_query_destroy(query);
976 ctsvc_server_start_timeout();
981 void ctsvc_ipc_server_db_get_count(pims_ipc_h ipc, pims_ipc_data_h indata,
982 pims_ipc_data_h *outdata, void *userdata)
984 int ret = CONTACTS_ERROR_NONE;
985 char *view_uri = NULL;
987 contacts_h contact = NULL;
990 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
991 if (CONTACTS_ERROR_NONE != ret) {
992 /* LCOV_EXCL_START */
993 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
998 ret = ctsvc_ipc_unmarshal_string(indata, &view_uri);
999 if (ret != CONTACTS_ERROR_NONE) {
1000 /* LCOV_EXCL_START */
1001 ERR("ctsvc_ipc_unmarshal_record() Fail");
1003 /* LCOV_EXCL_STOP */
1006 /* LCOV_EXCL_START */
1007 ERR("ctsvc_ipc_server_db_insert_record() Fail");
1009 /* LCOV_EXCL_STOP */
1012 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(view_uri))) {
1013 /* LCOV_EXCL_START */
1014 ret = CONTACTS_ERROR_PERMISSION_DENIED;
1016 /* LCOV_EXCL_STOP */
1019 ret = ctsvc_db_get_count(view_uri, &count);
1022 *outdata = pims_ipc_data_create(0);
1023 if (NULL == *outdata) {
1024 /* LCOV_EXCL_START */
1025 ERR("pims_ipc_data_create() Fail");
1027 /* LCOV_EXCL_STOP */
1029 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1030 /* LCOV_EXCL_START */
1031 pims_ipc_data_destroy(*outdata);
1033 ERR("ctsvc_ipc_marshal_int() Fail");
1035 /* LCOV_EXCL_STOP */
1038 if (CONTACTS_ERROR_NO_DATA == ret) {
1040 } else if (CONTACTS_ERROR_NONE == ret) {
1041 ret = ctsvc_ipc_marshal_int(count, *outdata);
1043 if (ret != CONTACTS_ERROR_NONE) {
1044 /* LCOV_EXCL_START */
1045 ERR("ctsvc_ipc_unmarshal_int() Fail");
1047 /* LCOV_EXCL_STOP */
1051 /* LCOV_EXCL_START */
1052 ERR("outdata is NULL");
1053 /* LCOV_EXCL_STOP */
1059 *outdata = pims_ipc_data_create(0);
1060 if (NULL == *outdata) {
1061 /* LCOV_EXCL_START */
1062 ERR("pims_ipc_data_create() Fail");
1064 /* LCOV_EXCL_STOP */
1066 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1067 /* LCOV_EXCL_START */
1068 pims_ipc_data_destroy(*outdata);
1070 ERR("ctsvc_ipc_marshal_int() Fail");
1072 /* LCOV_EXCL_STOP */
1075 /* LCOV_EXCL_START */
1076 ERR("outdata is NULL");
1077 /* LCOV_EXCL_STOP */
1080 ctsvc_handle_destroy(contact);
1082 ctsvc_server_start_timeout();
1086 void ctsvc_ipc_server_db_get_count_with_query(pims_ipc_h ipc, pims_ipc_data_h indata,
1087 pims_ipc_data_h *outdata, void *userdata)
1089 int ret = CONTACTS_ERROR_NONE;
1090 contacts_query_h query = NULL;
1092 contacts_h contact = NULL;
1095 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
1096 if (CONTACTS_ERROR_NONE != ret) {
1097 /* LCOV_EXCL_START */
1098 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
1100 /* LCOV_EXCL_STOP */
1103 ret = ctsvc_ipc_unmarshal_query(indata, &query);
1104 if (ret != CONTACTS_ERROR_NONE) {
1105 /* LCOV_EXCL_START */
1106 ERR("ctsvc_ipc_unmarshal_record() Fail");
1108 /* LCOV_EXCL_STOP */
1111 /* LCOV_EXCL_START */
1112 ERR("ctsvc_ipc_server_db_insert_record() Fail");
1114 /* LCOV_EXCL_STOP */
1117 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(((ctsvc_query_s*)query)->view_uri))) {
1118 /* LCOV_EXCL_START */
1119 ret = CONTACTS_ERROR_PERMISSION_DENIED;
1121 /* LCOV_EXCL_STOP */
1124 ret = ctsvc_db_get_count_with_query(query, &count);
1127 *outdata = pims_ipc_data_create(0);
1128 if (NULL == *outdata) {
1129 /* LCOV_EXCL_START */
1130 ERR("pims_ipc_data_create() Fail");
1132 /* LCOV_EXCL_STOP */
1134 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1135 /* LCOV_EXCL_START */
1136 pims_ipc_data_destroy(*outdata);
1138 ERR("ctsvc_ipc_marshal_int() Fail");
1140 /* LCOV_EXCL_STOP */
1143 if (CONTACTS_ERROR_NO_DATA == ret) {
1145 } else if (CONTACTS_ERROR_NONE == ret) {
1146 ret = ctsvc_ipc_marshal_int(count, *outdata);
1148 if (ret != CONTACTS_ERROR_NONE) {
1149 /* LCOV_EXCL_START */
1150 ERR("ctsvc_ipc_unmarshal_int() Fail");
1152 /* LCOV_EXCL_STOP */
1156 /* LCOV_EXCL_START */
1157 ERR("outdata is NULL");
1158 /* LCOV_EXCL_STOP */
1164 *outdata = pims_ipc_data_create(0);
1165 if (NULL == *outdata) {
1166 /* LCOV_EXCL_START */
1167 ERR("pims_ipc_data_create() Fail");
1169 /* LCOV_EXCL_STOP */
1171 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1172 /* LCOV_EXCL_START */
1173 pims_ipc_data_destroy(*outdata);
1175 ERR("ctsvc_ipc_marshal_int() Fail");
1177 /* LCOV_EXCL_STOP */
1180 /* LCOV_EXCL_START */
1181 ERR("outdata is NULL");
1182 /* LCOV_EXCL_STOP */
1185 ctsvc_handle_destroy(contact);
1186 contacts_query_destroy(query);
1187 ctsvc_server_start_timeout();
1191 void ctsvc_ipc_server_db_insert_records(pims_ipc_h ipc, pims_ipc_data_h indata,
1192 pims_ipc_data_h *outdata, void *userdata)
1194 int ret = CONTACTS_ERROR_NONE;
1195 contacts_list_h list = NULL;
1199 contacts_h contact = NULL;
1202 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
1203 if (CONTACTS_ERROR_NONE != ret) {
1204 /* LCOV_EXCL_START */
1205 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
1207 /* LCOV_EXCL_STOP */
1210 ret = ctsvc_ipc_unmarshal_list(indata, &list);
1211 if (ret != CONTACTS_ERROR_NONE) {
1212 /* LCOV_EXCL_START */
1213 ERR("ctsvc_ipc_unmarshal_list Fail");
1215 /* LCOV_EXCL_STOP */
1218 /* LCOV_EXCL_START */
1219 ERR("ctsvc_ipc_server_db_insert_record() Fail");
1221 /* LCOV_EXCL_STOP */
1225 contacts_record_h record = NULL;
1226 contacts_list_first(list);
1228 ret = contacts_list_get_current_record_p(list, &record);
1229 if (CONTACTS_ERROR_NONE != ret) {
1230 /* LCOV_EXCL_START */
1231 ERR("contacts_list_get_current_record_p() Fail(%d)", ret);
1233 /* LCOV_EXCL_STOP */
1236 if (!ctsvc_have_permission(ipc, ctsvc_required_write_permission(((ctsvc_record_s*)record)->view_uri))) {
1237 /* LCOV_EXCL_START */
1238 ret = CONTACTS_ERROR_PERMISSION_DENIED;
1240 /* LCOV_EXCL_STOP */
1242 } while (CONTACTS_ERROR_NONE == contacts_list_next(list));
1243 contacts_list_first(list);
1246 ctsvc_server_stop_timeout();
1247 ret = ctsvc_db_insert_records(list, &ids, &id_count);
1250 *outdata = pims_ipc_data_create(0);
1251 if (NULL == *outdata) {
1252 /* LCOV_EXCL_START */
1253 ERR("pims_ipc_data_create() Fail");
1255 /* LCOV_EXCL_STOP */
1257 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1258 /* LCOV_EXCL_START */
1259 pims_ipc_data_destroy(*outdata);
1261 ERR("ctsvc_ipc_marshal_int() Fail");
1263 /* LCOV_EXCL_STOP */
1266 if (ret == CONTACTS_ERROR_NONE) {
1267 int transaction_ver = ctsvc_get_transaction_ver();
1268 if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
1269 /* LCOV_EXCL_START */
1270 pims_ipc_data_destroy(*outdata);
1272 ERR("ctsvc_ipc_marshal_int() Fail");
1273 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
1275 /* LCOV_EXCL_STOP */
1277 /* marshal : id_count+property_id+[ids]*id_count */
1279 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(id_count, *outdata)) {
1280 /* LCOV_EXCL_START */
1281 pims_ipc_data_destroy(*outdata);
1283 ERR("ctsvc_ipc_marshal_int() Fail");
1284 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
1286 /* LCOV_EXCL_STOP */
1289 for (i = 0; i < id_count; i++) {
1291 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ids[i], *outdata)) {
1292 /* LCOV_EXCL_START */
1293 pims_ipc_data_destroy(*outdata);
1295 ERR("ctsvc_ipc_marshal_int() Fail");
1296 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
1298 /* LCOV_EXCL_STOP */
1303 /* LCOV_EXCL_START */
1304 ERR("outdata is NULL");
1305 /* LCOV_EXCL_STOP */
1311 *outdata = pims_ipc_data_create(0);
1312 if (NULL == *outdata) {
1313 /* LCOV_EXCL_START */
1314 ERR("pims_ipc_data_create() Fail");
1316 /* LCOV_EXCL_STOP */
1318 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1319 /* LCOV_EXCL_START */
1320 pims_ipc_data_destroy(*outdata);
1322 ERR("ctsvc_ipc_marshal_int() Fail");
1324 /* LCOV_EXCL_STOP */
1327 /* LCOV_EXCL_START */
1328 ERR("outdata is NULL");
1329 /* LCOV_EXCL_STOP */
1332 ctsvc_handle_destroy(contact);
1333 contacts_list_destroy(list, true);
1335 ctsvc_server_start_timeout();
1339 void ctsvc_ipc_server_db_update_records(pims_ipc_h ipc, pims_ipc_data_h indata,
1340 pims_ipc_data_h *outdata, void *userdata)
1342 int ret = CONTACTS_ERROR_NONE;
1343 contacts_list_h list = NULL;
1344 contacts_h contact = NULL;
1347 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
1348 if (CONTACTS_ERROR_NONE != ret) {
1349 /* LCOV_EXCL_START */
1350 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
1352 /* LCOV_EXCL_STOP */
1355 ret = ctsvc_ipc_unmarshal_list(indata, &list);
1356 if (ret != CONTACTS_ERROR_NONE) {
1357 /* LCOV_EXCL_START */
1358 ERR("ctsvc_ipc_unmarshal_list Fail");
1360 /* LCOV_EXCL_STOP */
1363 /* LCOV_EXCL_START */
1364 ERR("ctsvc_ipc_server_db_insert_record() Fail");
1366 /* LCOV_EXCL_STOP */
1370 contacts_record_h record = NULL;
1371 contacts_list_first(list);
1373 ret = contacts_list_get_current_record_p(list, &record);
1374 if (CONTACTS_ERROR_NONE != ret) {
1375 /* LCOV_EXCL_START */
1376 ERR("contacts_list_get_current_record_p() Fail(%d)", ret);
1378 /* LCOV_EXCL_STOP */
1381 if (!ctsvc_have_permission(ipc, ctsvc_required_write_permission(((ctsvc_record_s*)record)->view_uri))) {
1382 /* LCOV_EXCL_START */
1383 ret = CONTACTS_ERROR_PERMISSION_DENIED;
1385 /* LCOV_EXCL_STOP */
1387 } while (CONTACTS_ERROR_NONE == contacts_list_next(list));
1388 contacts_list_first(list);
1391 ctsvc_server_stop_timeout();
1392 ret = ctsvc_db_update_records(list);
1395 *outdata = pims_ipc_data_create(0);
1396 if (NULL == *outdata) {
1397 /* LCOV_EXCL_START */
1398 ERR("pims_ipc_data_create() Fail");
1400 /* LCOV_EXCL_STOP */
1402 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1403 /* LCOV_EXCL_START */
1404 pims_ipc_data_destroy(*outdata);
1406 ERR("ctsvc_ipc_marshal_int() Fail");
1408 /* LCOV_EXCL_STOP */
1411 if (ret == CONTACTS_ERROR_NONE) {
1412 int transaction_ver = ctsvc_get_transaction_ver();
1413 if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
1414 /* LCOV_EXCL_START */
1415 pims_ipc_data_destroy(*outdata);
1417 ERR("ctsvc_ipc_marshal_int() Fail");
1418 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
1420 /* LCOV_EXCL_STOP */
1424 /* LCOV_EXCL_START */
1425 ERR("outdata is NULL");
1426 /* LCOV_EXCL_STOP */
1432 *outdata = pims_ipc_data_create(0);
1433 if (NULL == *outdata) {
1434 /* LCOV_EXCL_START */
1435 ERR("pims_ipc_data_create() Fail");
1437 /* LCOV_EXCL_STOP */
1439 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1440 /* LCOV_EXCL_START */
1441 pims_ipc_data_destroy(*outdata);
1443 ERR("ctsvc_ipc_marshal_int() Fail");
1445 /* LCOV_EXCL_STOP */
1448 /* LCOV_EXCL_START */
1449 ERR("outdata is NULL");
1450 /* LCOV_EXCL_STOP */
1453 ctsvc_handle_destroy(contact);
1454 contacts_list_destroy(list, true);
1455 ctsvc_server_start_timeout();
1459 void ctsvc_ipc_server_db_delete_records(pims_ipc_h ipc, pims_ipc_data_h indata,
1460 pims_ipc_data_h *outdata, void *userdata)
1462 int ret = CONTACTS_ERROR_NONE;
1467 contacts_h contact = NULL;
1470 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
1471 if (CONTACTS_ERROR_NONE != ret) {
1472 /* LCOV_EXCL_START */
1473 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
1475 /* LCOV_EXCL_STOP */
1478 ret = ctsvc_ipc_unmarshal_string(indata, &uri);
1479 if (ret != CONTACTS_ERROR_NONE) {
1480 /* LCOV_EXCL_START */
1481 ERR("ctsvc_ipc_unmarshal_string Fail");
1483 /* LCOV_EXCL_STOP */
1485 ret = ctsvc_ipc_unmarshal_int(indata, &count);
1486 if (ret != CONTACTS_ERROR_NONE) {
1487 /* LCOV_EXCL_START */
1488 ERR("ctsvc_ipc_unmarshal_int() Fail");
1490 /* LCOV_EXCL_STOP */
1493 /* LCOV_EXCL_START */
1494 ret = CONTACTS_ERROR_INVALID_PARAMETER;
1496 /* LCOV_EXCL_STOP */
1498 ids = (int*)malloc(sizeof(int)*count);
1499 for (i = 0; i < count; i++) {
1500 ret = ctsvc_ipc_unmarshal_int(indata, &ids[i]);
1501 if (ret != CONTACTS_ERROR_NONE) {
1502 /* LCOV_EXCL_START */
1503 ERR("ctsvc_ipc_unmarshal_int() Fail");
1505 /* LCOV_EXCL_STOP */
1509 /* LCOV_EXCL_START */
1510 ERR("ctsvc_ipc_server_db_insert_record() Fail");
1512 /* LCOV_EXCL_STOP */
1515 if (!ctsvc_have_permission(ipc, ctsvc_required_write_permission(uri))) {
1516 /* LCOV_EXCL_START */
1517 ret = CONTACTS_ERROR_PERMISSION_DENIED;
1519 /* LCOV_EXCL_STOP */
1522 ret = ctsvc_db_delete_records(uri, ids, count);
1525 *outdata = pims_ipc_data_create(0);
1526 if (NULL == *outdata) {
1527 /* LCOV_EXCL_START */
1528 ERR("pims_ipc_data_create() Fail");
1530 /* LCOV_EXCL_STOP */
1533 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1534 /* LCOV_EXCL_START */
1535 pims_ipc_data_destroy(*outdata);
1537 ERR("ctsvc_ipc_marshal_int() Fail");
1539 /* LCOV_EXCL_STOP */
1542 if (ret == CONTACTS_ERROR_NONE) {
1543 int transaction_ver = ctsvc_get_transaction_ver();
1544 if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
1545 /* LCOV_EXCL_START */
1546 pims_ipc_data_destroy(*outdata);
1548 ERR("ctsvc_ipc_marshal_int() Fail");
1549 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
1551 /* LCOV_EXCL_STOP */
1555 /* LCOV_EXCL_START */
1556 ERR("outdata is NULL");
1557 /* LCOV_EXCL_STOP */
1564 *outdata = pims_ipc_data_create(0);
1565 if (NULL == *outdata) {
1566 /* LCOV_EXCL_START */
1567 ERR("pims_ipc_data_create() Fail");
1569 /* LCOV_EXCL_STOP */
1571 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1572 /* LCOV_EXCL_START */
1573 pims_ipc_data_destroy(*outdata);
1575 ERR("ctsvc_ipc_marshal_int() Fail");
1577 /* LCOV_EXCL_STOP */
1580 /* LCOV_EXCL_START */
1581 ERR("outdata is NULL");
1582 /* LCOV_EXCL_STOP */
1585 ctsvc_handle_destroy(contact);
1588 ctsvc_server_start_timeout();
1592 void ctsvc_ipc_server_db_replace_records(pims_ipc_h ipc, pims_ipc_data_h indata,
1593 pims_ipc_data_h *outdata, void *userdata)
1595 int ret = CONTACTS_ERROR_NONE;
1596 contacts_list_h list = NULL;
1600 contacts_h contact = NULL;
1603 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
1604 if (CONTACTS_ERROR_NONE != ret) {
1605 /* LCOV_EXCL_START */
1606 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
1608 /* LCOV_EXCL_STOP */
1611 ret = ctsvc_ipc_unmarshal_list(indata, &list);
1612 if (ret != CONTACTS_ERROR_NONE) {
1613 /* LCOV_EXCL_START */
1614 ERR("ctsvc_ipc_unmarshal_list Fail");
1616 /* LCOV_EXCL_STOP */
1619 ret = ctsvc_ipc_unmarshal_int(indata, &count);
1620 if (ret != CONTACTS_ERROR_NONE) {
1621 /* LCOV_EXCL_START */
1622 ERR("ctsvc_ipc_unmarshal_int() Fail");
1624 /* LCOV_EXCL_STOP */
1628 /* LCOV_EXCL_START */
1629 ret = CONTACTS_ERROR_INVALID_PARAMETER;
1631 /* LCOV_EXCL_STOP */
1634 ids = (int*)malloc(sizeof(int)*count);
1635 for (i = 0; i < count; i++) {
1636 ret = ctsvc_ipc_unmarshal_int(indata, &ids[i]);
1637 if (ret != CONTACTS_ERROR_NONE) {
1638 /* LCOV_EXCL_START */
1639 ERR("ctsvc_ipc_unmarshal_int() Fail");
1641 /* LCOV_EXCL_STOP */
1645 /* LCOV_EXCL_START */
1646 ERR("ctsvc_ipc_server_db_repalce_records Fail");
1648 /* LCOV_EXCL_STOP */
1652 contacts_record_h record = NULL;
1653 contacts_list_first(list);
1655 ret = contacts_list_get_current_record_p(list, &record);
1656 if (CONTACTS_ERROR_NONE != ret) {
1657 /* LCOV_EXCL_START */
1658 ERR("contacts_list_get_current_record_p() Fail(%d)", ret);
1660 /* LCOV_EXCL_STOP */
1663 if (!ctsvc_have_permission(ipc, ctsvc_required_write_permission(((ctsvc_record_s*)record)->view_uri))) {
1664 /* LCOV_EXCL_START */
1665 ret = CONTACTS_ERROR_PERMISSION_DENIED;
1667 /* LCOV_EXCL_STOP */
1669 } while (CONTACTS_ERROR_NONE == contacts_list_next(list));
1670 contacts_list_first(list);
1673 ctsvc_server_stop_timeout();
1674 ret = ctsvc_db_replace_records(list, ids, count);
1677 *outdata = pims_ipc_data_create(0);
1678 if (NULL == *outdata) {
1679 /* LCOV_EXCL_START */
1680 ERR("pims_ipc_data_create() Fail");
1682 /* LCOV_EXCL_STOP */
1684 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1685 /* LCOV_EXCL_START */
1686 pims_ipc_data_destroy(*outdata);
1688 ERR("ctsvc_ipc_marshal_int() Fail");
1690 /* LCOV_EXCL_STOP */
1692 if (ret == CONTACTS_ERROR_NONE) {
1693 int transaction_ver = ctsvc_get_transaction_ver();
1694 if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
1695 /* LCOV_EXCL_START */
1696 pims_ipc_data_destroy(*outdata);
1698 ERR("ctsvc_ipc_marshal_int() Fail");
1699 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
1701 /* LCOV_EXCL_STOP */
1705 /* LCOV_EXCL_START */
1706 ERR("outdata is NULL");
1707 /* LCOV_EXCL_STOP */
1713 *outdata = pims_ipc_data_create(0);
1714 if (NULL == *outdata) {
1715 /* LCOV_EXCL_START */
1716 ERR("pims_ipc_data_create() Fail");
1718 /* LCOV_EXCL_STOP */
1720 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1721 /* LCOV_EXCL_START */
1722 pims_ipc_data_destroy(*outdata);
1724 ERR("ctsvc_ipc_marshal_int() Fail");
1726 /* LCOV_EXCL_STOP */
1729 /* LCOV_EXCL_START */
1730 ERR("outdata is NULL");
1731 /* LCOV_EXCL_STOP */
1734 ctsvc_handle_destroy(contact);
1735 contacts_list_destroy(list, true);
1737 ctsvc_server_start_timeout();
1741 void ctsvc_ipc_server_db_get_changes_by_version(pims_ipc_h ipc, pims_ipc_data_h indata,
1742 pims_ipc_data_h *outdata, void *userdata)
1744 int ret = CONTACTS_ERROR_NONE;
1745 char *view_uri = NULL;
1746 int address_book_id = 0;
1747 int contacts_db_version = 0;
1748 contacts_list_h record_list = NULL;
1749 int current_contacts_db_version = 0;
1750 contacts_h contact = NULL;
1753 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
1754 if (CONTACTS_ERROR_NONE != ret) {
1755 /* LCOV_EXCL_START */
1756 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
1758 /* LCOV_EXCL_STOP */
1761 ret = ctsvc_ipc_unmarshal_string(indata, &view_uri);
1762 if (ret != CONTACTS_ERROR_NONE) {
1763 /* LCOV_EXCL_START */
1764 ERR("ctsvc_ipc_unmarshal_string Fail");
1766 /* LCOV_EXCL_STOP */
1768 ret = ctsvc_ipc_unmarshal_int(indata, &address_book_id);
1769 if (ret != CONTACTS_ERROR_NONE) {
1770 /* LCOV_EXCL_START */
1771 ERR("ctsvc_ipc_unmarshal_int() Fail");
1773 /* LCOV_EXCL_STOP */
1775 ret = ctsvc_ipc_unmarshal_int(indata, &contacts_db_version);
1776 if (ret != CONTACTS_ERROR_NONE) {
1777 /* LCOV_EXCL_START */
1778 ERR("ctsvc_ipc_unmarshal_int() Fail");
1780 /* LCOV_EXCL_STOP */
1783 /* LCOV_EXCL_START */
1784 ERR("ctsvc_ipc_server_db_insert_record() Fail");
1786 /* LCOV_EXCL_STOP */
1789 if (!ctsvc_have_permission(ipc, CTSVC_PERMISSION_CONTACT_READ)) {
1790 /* LCOV_EXCL_START */
1791 ret = CONTACTS_ERROR_PERMISSION_DENIED;
1793 /* LCOV_EXCL_STOP */
1796 ret = ctsvc_db_get_changes_by_version(view_uri, address_book_id, contacts_db_version,
1797 &record_list, ¤t_contacts_db_version);
1800 *outdata = pims_ipc_data_create(0);
1801 if (NULL == *outdata) {
1802 /* LCOV_EXCL_START */
1803 ERR("pims_ipc_data_create() Fail");
1805 /* LCOV_EXCL_STOP */
1807 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1808 /* LCOV_EXCL_START */
1809 pims_ipc_data_destroy(*outdata);
1811 ERR("ctsvc_ipc_marshal_int() Fail");
1813 /* LCOV_EXCL_STOP */
1816 if (CONTACTS_ERROR_NO_DATA == ret) {
1818 } else if (CONTACTS_ERROR_NONE == ret) {
1819 ret = ctsvc_ipc_marshal_list(record_list, *outdata);
1820 if (ret != CONTACTS_ERROR_NONE) {
1821 /* LCOV_EXCL_START */
1822 ERR("ctsvc_ipc_marshal_list Fail");
1823 pims_ipc_data_destroy(*outdata);
1825 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
1827 /* LCOV_EXCL_STOP */
1829 ret = ctsvc_ipc_marshal_int(current_contacts_db_version, *outdata);
1830 if (ret != CONTACTS_ERROR_NONE) {
1831 /* LCOV_EXCL_START */
1832 ERR("ctsvc_ipc_marshal_int() Fail");
1833 pims_ipc_data_destroy(*outdata);
1835 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
1837 /* LCOV_EXCL_STOP */
1841 /* LCOV_EXCL_START */
1842 ERR("outdata is NULL");
1843 /* LCOV_EXCL_STOP */
1849 *outdata = pims_ipc_data_create(0);
1850 if (NULL == *outdata) {
1851 /* LCOV_EXCL_START */
1852 ERR("pims_ipc_data_create() Fail");
1854 /* LCOV_EXCL_STOP */
1856 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1857 /* LCOV_EXCL_START */
1858 pims_ipc_data_destroy(*outdata);
1860 ERR("ctsvc_ipc_marshal_int() Fail");
1862 /* LCOV_EXCL_STOP */
1865 /* LCOV_EXCL_START */
1866 ERR("outdata is NULL");
1867 /* LCOV_EXCL_STOP */
1870 ctsvc_handle_destroy(contact);
1871 contacts_list_destroy(record_list, true);
1873 ctsvc_server_start_timeout();
1877 void ctsvc_ipc_server_db_get_current_version(pims_ipc_h ipc, pims_ipc_data_h indata,
1878 pims_ipc_data_h *outdata, void *userdata)
1880 int ret = CONTACTS_ERROR_NONE;
1881 int contacts_db_version = 0;
1882 contacts_h contact = NULL;
1885 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
1886 if (CONTACTS_ERROR_NONE != ret) {
1887 /* LCOV_EXCL_START */
1888 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
1890 /* LCOV_EXCL_STOP */
1894 if (!ctsvc_have_permission(ipc, CTSVC_PERMISSION_CONTACT_READ) &&
1895 !ctsvc_have_permission(ipc, CTSVC_PERMISSION_PHONELOG_READ)) {
1896 /* LCOV_EXCL_START */
1897 ret = CONTACTS_ERROR_PERMISSION_DENIED;
1899 /* LCOV_EXCL_STOP */
1902 ret = ctsvc_db_get_current_version(&contacts_db_version);
1906 *outdata = pims_ipc_data_create(0);
1907 if (NULL == *outdata) {
1908 /* LCOV_EXCL_START */
1909 ERR("pims_ipc_data_create() Fail");
1911 /* LCOV_EXCL_STOP */
1913 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1914 /* LCOV_EXCL_START */
1915 pims_ipc_data_destroy(*outdata);
1917 ERR("ctsvc_ipc_marshal_int() Fail");
1919 /* LCOV_EXCL_STOP */
1922 if (CONTACTS_ERROR_NO_DATA == ret) {
1924 } else if (CONTACTS_ERROR_NONE == ret) {
1925 ret = ctsvc_ipc_marshal_int(contacts_db_version, *outdata);
1926 if (ret != CONTACTS_ERROR_NONE) {
1927 /* LCOV_EXCL_START */
1928 ERR("ctsvc_ipc_marshal_int() Fail");
1930 /* LCOV_EXCL_STOP */
1934 /* LCOV_EXCL_START */
1935 ERR("outdata is NULL");
1936 /* LCOV_EXCL_STOP */
1940 ctsvc_handle_destroy(contact);
1941 ctsvc_server_start_timeout();
1945 void ctsvc_ipc_server_db_search_records_for_snippet(pims_ipc_h ipc,
1946 pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
1948 int ret = CONTACTS_ERROR_NONE;
1949 char *view_uri = NULL;
1950 char *keyword = NULL;
1953 contacts_list_h list = NULL;
1954 contacts_h contact = NULL;
1955 char *start_match = NULL;
1956 char *end_match = NULL;
1957 int token_number = 0;
1960 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
1961 if (CONTACTS_ERROR_NONE != ret) {
1962 /* LCOV_EXCL_START */
1963 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
1965 /* LCOV_EXCL_STOP */
1967 ret = ctsvc_ipc_unmarshal_string(indata, &view_uri);
1968 if (ret != CONTACTS_ERROR_NONE) {
1969 /* LCOV_EXCL_START */
1970 ERR("ctsvc_ipc_unmarshal_record() Fail(%d)", ret);
1972 /* LCOV_EXCL_STOP */
1974 ret = ctsvc_ipc_unmarshal_string(indata, &keyword);
1975 if (ret != CONTACTS_ERROR_NONE) {
1976 /* LCOV_EXCL_START */
1977 ERR("ctsvc_ipc_unmarshal_record() Fail(%d)", ret);
1979 /* LCOV_EXCL_STOP */
1981 ret = ctsvc_ipc_unmarshal_int(indata, &offset);
1982 if (ret != CONTACTS_ERROR_NONE) {
1983 /* LCOV_EXCL_START */
1984 ERR("ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
1986 /* LCOV_EXCL_STOP */
1988 ret = ctsvc_ipc_unmarshal_int(indata, &limit);
1989 if (ret != CONTACTS_ERROR_NONE) {
1990 /* LCOV_EXCL_START */
1991 ERR("ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
1993 /* LCOV_EXCL_STOP */
1995 ret = ctsvc_ipc_unmarshal_string(indata, &start_match);
1996 if (ret != CONTACTS_ERROR_NONE) {
1997 /* LCOV_EXCL_START */
1998 ERR("ctsvc_ipc_unmarshal_record() Fail");
2000 /* LCOV_EXCL_STOP */
2002 ret = ctsvc_ipc_unmarshal_string(indata, &end_match);
2003 if (ret != CONTACTS_ERROR_NONE) {
2004 /* LCOV_EXCL_START */
2005 ERR("ctsvc_ipc_unmarshal_record() Fail");
2007 /* LCOV_EXCL_STOP */
2009 ret = ctsvc_ipc_unmarshal_int(indata, &token_number);
2010 if (ret != CONTACTS_ERROR_NONE) {
2011 /* LCOV_EXCL_START */
2012 ERR("ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
2014 /* LCOV_EXCL_STOP */
2017 /* LCOV_EXCL_START */
2018 ERR("ctsvc_ipc_server_db_insert_record() Fail");
2020 /* LCOV_EXCL_STOP */
2023 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(view_uri))) {
2024 /* LCOV_EXCL_START */
2025 ret = CONTACTS_ERROR_PERMISSION_DENIED;
2027 /* LCOV_EXCL_STOP */
2030 ret = ctsvc_db_search_records_for_snippet(view_uri, keyword, offset, limit,
2031 start_match, end_match, token_number, &list);
2034 *outdata = pims_ipc_data_create(0);
2035 if (NULL == *outdata) {
2036 /* LCOV_EXCL_START */
2037 ERR("pims_ipc_data_create() Fail");
2039 /* LCOV_EXCL_STOP */
2041 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2042 /* LCOV_EXCL_START */
2043 pims_ipc_data_destroy(*outdata);
2045 ERR("ctsvc_ipc_marshal_int() Fail");
2047 /* LCOV_EXCL_STOP */
2050 if (CONTACTS_ERROR_NO_DATA == ret) {
2052 } else if (CONTACTS_ERROR_NONE == ret) {
2053 ret = ctsvc_ipc_marshal_list(list, *outdata);
2055 if (ret != CONTACTS_ERROR_NONE) {
2056 /* LCOV_EXCL_START */
2057 ERR("ctsvc_ipc_unmarshal_int() Fail");
2059 /* LCOV_EXCL_STOP */
2063 /* LCOV_EXCL_START */
2064 ERR("outdata is NULL");
2065 /* LCOV_EXCL_STOP */
2071 *outdata = pims_ipc_data_create(0);
2072 if (NULL == *outdata) {
2073 /* LCOV_EXCL_START */
2074 ERR("pims_ipc_data_create() Fail");
2076 /* LCOV_EXCL_STOP */
2078 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2079 /* LCOV_EXCL_START */
2080 pims_ipc_data_destroy(*outdata);
2082 ERR("ctsvc_ipc_marshal_int() Fail");
2084 /* LCOV_EXCL_STOP */
2087 /* LCOV_EXCL_START */
2088 ERR("outdata is NULL");
2089 /* LCOV_EXCL_STOP */
2092 ctsvc_handle_destroy(contact);
2093 contacts_list_destroy(list, true);
2098 ctsvc_server_start_timeout();
2102 void ctsvc_ipc_server_db_search_records_with_range_for_snippet(pims_ipc_h ipc,
2103 pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
2105 int ret = CONTACTS_ERROR_NONE;
2106 char *view_uri = NULL;
2107 char *keyword = NULL;
2111 contacts_list_h list = NULL;
2112 contacts_h contact = NULL;
2113 char *start_match = NULL;
2114 char *end_match = NULL;
2115 int token_number = 0;
2118 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
2119 if (CONTACTS_ERROR_NONE != ret) {
2120 /* LCOV_EXCL_START */
2121 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
2123 /* LCOV_EXCL_STOP */
2125 ret = ctsvc_ipc_unmarshal_string(indata, &view_uri);
2126 if (ret != CONTACTS_ERROR_NONE) {
2127 /* LCOV_EXCL_START */
2128 ERR("ctsvc_ipc_unmarshal_record() Fail");
2130 /* LCOV_EXCL_STOP */
2132 ret = ctsvc_ipc_unmarshal_string(indata, &keyword);
2133 if (ret != CONTACTS_ERROR_NONE) {
2134 /* LCOV_EXCL_START */
2135 ERR("ctsvc_ipc_unmarshal_record() Fail");
2137 /* LCOV_EXCL_STOP */
2139 ret = ctsvc_ipc_unmarshal_int(indata, &offset);
2140 if (ret != CONTACTS_ERROR_NONE) {
2141 /* LCOV_EXCL_START */
2142 ERR("ctsvc_ipc_unmarshal_int() Fail");
2144 /* LCOV_EXCL_STOP */
2146 ret = ctsvc_ipc_unmarshal_int(indata, &limit);
2147 if (ret != CONTACTS_ERROR_NONE) {
2148 /* LCOV_EXCL_START */
2149 ERR("ctsvc_ipc_unmarshal_int() Fail");
2151 /* LCOV_EXCL_STOP */
2153 ret = ctsvc_ipc_unmarshal_int(indata, &range);
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_string(indata, &start_match);
2161 if (ret != CONTACTS_ERROR_NONE) {
2162 /* LCOV_EXCL_START */
2163 ERR("ctsvc_ipc_unmarshal_record() Fail");
2165 /* LCOV_EXCL_STOP */
2167 ret = ctsvc_ipc_unmarshal_string(indata, &end_match);
2168 if (ret != CONTACTS_ERROR_NONE) {
2169 /* LCOV_EXCL_START */
2170 ERR("ctsvc_ipc_unmarshal_record() Fail");
2172 /* LCOV_EXCL_STOP */
2174 ret = ctsvc_ipc_unmarshal_int(indata, &token_number);
2175 if (ret != CONTACTS_ERROR_NONE) {
2176 /* LCOV_EXCL_START */
2177 ERR("ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
2179 /* LCOV_EXCL_STOP */
2182 /* LCOV_EXCL_START */
2183 ERR("ctsvc_ipc_server_db_insert_record() Fail");
2185 /* LCOV_EXCL_START */
2188 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(view_uri))) {
2189 /* LCOV_EXCL_START */
2190 ret = CONTACTS_ERROR_PERMISSION_DENIED;
2192 /* LCOV_EXCL_STOP */
2195 ret = ctsvc_db_search_records_with_range_for_snippet(view_uri, keyword, offset,
2196 limit, range, start_match, end_match, token_number, &list);
2199 *outdata = pims_ipc_data_create(0);
2200 if (NULL == *outdata) {
2201 /* LCOV_EXCL_START */
2202 ERR("pims_ipc_data_create() Fail");
2204 /* LCOV_EXCL_STOP */
2206 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2207 /* LCOV_EXCL_START */
2208 pims_ipc_data_destroy(*outdata);
2210 ERR("ctsvc_ipc_marshal_int() Fail");
2212 /* LCOV_EXCL_STOP */
2215 if (CONTACTS_ERROR_NO_DATA == ret) {
2217 } else if (CONTACTS_ERROR_NONE == ret) {
2218 ret = ctsvc_ipc_marshal_list(list, *outdata);
2220 if (ret != CONTACTS_ERROR_NONE) {
2221 /* LCOV_EXCL_START */
2222 ERR("ctsvc_ipc_unmarshal_int() Fail");
2224 /* LCOV_EXCL_STOP */
2228 /* LCOV_EXCL_START */
2229 ERR("outdata is NULL");
2230 /* LCOV_EXCL_STOP */
2236 *outdata = pims_ipc_data_create(0);
2237 if (NULL == *outdata) {
2238 /* LCOV_EXCL_START */
2239 ERR("pims_ipc_data_create() Fail");
2241 /* LCOV_EXCL_STOP */
2243 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2244 /* LCOV_EXCL_START */
2245 pims_ipc_data_destroy(*outdata);
2247 ERR("ctsvc_ipc_marshal_int() Fail");
2249 /* LCOV_EXCL_STOP */
2252 /* LCOV_EXCL_START */
2253 ERR("outdata is NULL");
2254 /* LCOV_EXCL_STOP */
2258 ctsvc_handle_destroy(contact);
2259 contacts_list_destroy(list, true);
2264 ctsvc_server_start_timeout();
2268 void ctsvc_ipc_server_db_search_records_with_query_for_snippet(pims_ipc_h ipc,
2269 pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
2271 int ret = CONTACTS_ERROR_NONE;
2272 contacts_query_h query = NULL;
2273 char *keyword = NULL;
2276 contacts_list_h list = NULL;
2277 contacts_h contact = NULL;
2278 char *start_match = NULL;
2279 char *end_match = NULL;
2280 int token_number = 0;
2283 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
2284 if (CONTACTS_ERROR_NONE != ret) {
2285 /* LCOV_EXCL_START */
2286 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
2288 /* LCOV_EXCL_STOP */
2290 ret = ctsvc_ipc_unmarshal_query(indata, &query);
2291 if (ret != CONTACTS_ERROR_NONE) {
2292 /* LCOV_EXCL_START */
2293 ERR("ctsvc_ipc_unmarshal_record() Fail");
2295 /* LCOV_EXCL_STOP */
2297 ret = ctsvc_ipc_unmarshal_string(indata, &keyword);
2298 if (ret != CONTACTS_ERROR_NONE) {
2299 /* LCOV_EXCL_START */
2300 ERR("ctsvc_ipc_unmarshal_record() Fail");
2302 /* LCOV_EXCL_STOP */
2304 ret = ctsvc_ipc_unmarshal_int(indata, &offset);
2305 if (ret != CONTACTS_ERROR_NONE) {
2306 /* LCOV_EXCL_START */
2307 ERR("ctsvc_ipc_unmarshal_int() Fail");
2309 /* LCOV_EXCL_STOP */
2311 ret = ctsvc_ipc_unmarshal_int(indata, &limit);
2312 if (ret != CONTACTS_ERROR_NONE) {
2313 /* LCOV_EXCL_START */
2314 ERR("ctsvc_ipc_unmarshal_int() Fail");
2316 /* LCOV_EXCL_STOP */
2318 ret = ctsvc_ipc_unmarshal_string(indata, &start_match);
2319 if (ret != CONTACTS_ERROR_NONE) {
2320 /* LCOV_EXCL_START */
2321 ERR("ctsvc_ipc_unmarshal_record() Fail");
2323 /* LCOV_EXCL_STOP */
2325 ret = ctsvc_ipc_unmarshal_string(indata, &end_match);
2326 if (ret != CONTACTS_ERROR_NONE) {
2327 /* LCOV_EXCL_START */
2328 ERR("ctsvc_ipc_unmarshal_record() Fail");
2330 /* LCOV_EXCL_STOP */
2332 ret = ctsvc_ipc_unmarshal_int(indata, &token_number);
2333 if (ret != CONTACTS_ERROR_NONE) {
2334 /* LCOV_EXCL_START */
2335 ERR("ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
2337 /* LCOV_EXCL_STOP */
2340 /* LCOV_EXCL_START */
2341 ERR("ctsvc_ipc_server_db_insert_record() Fail");
2343 /* LCOV_EXCL_STOP */
2346 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(((ctsvc_query_s*)query)->view_uri))) {
2347 /* LCOV_EXCL_START */
2348 ret = CONTACTS_ERROR_PERMISSION_DENIED;
2350 /* LCOV_EXCL_STOP */
2353 ret = ctsvc_db_search_records_with_query_for_snippet(query, keyword, offset, limit,
2354 start_match, end_match, token_number, &list);
2357 *outdata = pims_ipc_data_create(0);
2358 if (NULL == *outdata) {
2359 /* LCOV_EXCL_START */
2360 ERR("pims_ipc_data_create() Fail");
2362 /* LCOV_EXCL_STOP */
2364 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2365 /* LCOV_EXCL_START */
2366 pims_ipc_data_destroy(*outdata);
2368 ERR("ctsvc_ipc_marshal_int() Fail");
2370 /* LCOV_EXCL_STOP */
2373 if (CONTACTS_ERROR_NO_DATA == ret) {
2375 } else if (CONTACTS_ERROR_NONE == ret) {
2376 ret = ctsvc_ipc_marshal_list(list, *outdata);
2378 if (ret != CONTACTS_ERROR_NONE) {
2379 /* LCOV_EXCL_START */
2380 ERR("ctsvc_ipc_marshal_list Fail");
2382 /* LCOV_EXCL_STOP */
2386 /* LCOV_EXCL_START */
2387 ERR("outdata is NULL");
2388 /* LCOV_EXCL_STOP */
2394 *outdata = pims_ipc_data_create(0);
2395 if (NULL == *outdata) {
2396 /* LCOV_EXCL_START */
2397 ERR("pims_ipc_data_create() Fail");
2399 /* LCOV_EXCL_STOP */
2401 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2402 /* LCOV_EXCL_START */
2403 pims_ipc_data_destroy(*outdata);
2405 ERR("ctsvc_ipc_marshal_int() Fail");
2407 /* LCOV_EXCL_STOP */
2410 /* LCOV_EXCL_START */
2411 ERR("outdata is NULL");
2412 /* LCOV_EXCL_STOP */
2415 ctsvc_handle_destroy(contact);
2416 contacts_list_destroy(list, true);
2417 contacts_query_destroy(query);
2421 ctsvc_server_start_timeout();
2425 void ctsvc_ipc_server_db_search_records(pims_ipc_h ipc, pims_ipc_data_h indata,
2426 pims_ipc_data_h *outdata, void *userdata)
2428 int ret = CONTACTS_ERROR_NONE;
2429 char *view_uri = NULL;
2430 char *keyword = NULL;
2433 contacts_list_h list = NULL;
2434 contacts_h contact = NULL;
2437 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
2438 if (CONTACTS_ERROR_NONE != ret) {
2439 /* LCOV_EXCL_START */
2440 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
2442 /* LCOV_EXCL_STOP */
2444 ret = ctsvc_ipc_unmarshal_string(indata, &view_uri);
2445 if (ret != CONTACTS_ERROR_NONE) {
2446 /* LCOV_EXCL_START */
2447 ERR("ctsvc_ipc_unmarshal_record() Fail(%d)", ret);
2449 /* LCOV_EXCL_STOP */
2451 ret = ctsvc_ipc_unmarshal_string(indata, &keyword);
2452 if (ret != CONTACTS_ERROR_NONE) {
2453 /* LCOV_EXCL_START */
2454 ERR("ctsvc_ipc_unmarshal_record() Fail(%d)", ret);
2456 /* LCOV_EXCL_STOP */
2458 ret = ctsvc_ipc_unmarshal_int(indata, &offset);
2459 if (ret != CONTACTS_ERROR_NONE) {
2460 /* LCOV_EXCL_START */
2461 ERR("ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
2463 /* LCOV_EXCL_STOP */
2465 ret = ctsvc_ipc_unmarshal_int(indata, &limit);
2466 if (ret != CONTACTS_ERROR_NONE) {
2467 /* LCOV_EXCL_START */
2468 ERR("ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
2470 /* LCOV_EXCL_STOP */
2473 /* LCOV_EXCL_START */
2474 ERR("ctsvc_ipc_server_db_insert_record() Fail");
2476 /* LCOV_EXCL_STOP */
2479 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(view_uri))) {
2480 /* LCOV_EXCL_START */
2481 ret = CONTACTS_ERROR_PERMISSION_DENIED;
2483 /* LCOV_EXCL_STOP */
2486 ret = ctsvc_db_search_records(view_uri, keyword, offset, limit, &list);
2489 *outdata = pims_ipc_data_create(0);
2490 if (NULL == *outdata) {
2491 /* LCOV_EXCL_START */
2492 ERR("pims_ipc_data_create() Fail");
2494 /* LCOV_EXCL_STOP */
2496 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2497 /* LCOV_EXCL_START */
2498 pims_ipc_data_destroy(*outdata);
2500 ERR("ctsvc_ipc_marshal_int() Fail");
2502 /* LCOV_EXCL_STOP */
2505 if (CONTACTS_ERROR_NO_DATA == ret) {
2507 } else if (CONTACTS_ERROR_NONE == ret) {
2508 ret = ctsvc_ipc_marshal_list(list, *outdata);
2510 if (ret != CONTACTS_ERROR_NONE) {
2511 /* LCOV_EXCL_START */
2512 ERR("ctsvc_ipc_unmarshal_int() Fail");
2514 /* LCOV_EXCL_STOP */
2518 /* LCOV_EXCL_START */
2519 ERR("outdata is NULL");
2520 /* LCOV_EXCL_STOP */
2526 *outdata = pims_ipc_data_create(0);
2527 if (NULL == *outdata) {
2528 /* LCOV_EXCL_START */
2529 ERR("pims_ipc_data_create() Fail");
2531 /* LCOV_EXCL_STOP */
2533 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2534 /* LCOV_EXCL_START */
2535 pims_ipc_data_destroy(*outdata);
2537 ERR("ctsvc_ipc_marshal_int() Fail");
2539 /* LCOV_EXCL_STOP */
2542 /* LCOV_EXCL_START */
2543 ERR("outdata is NULL");
2544 /* LCOV_EXCL_STOP */
2547 ctsvc_handle_destroy(contact);
2548 contacts_list_destroy(list, true);
2551 ctsvc_server_start_timeout();
2555 void ctsvc_ipc_server_db_search_records_with_range(pims_ipc_h ipc,
2556 pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
2558 int ret = CONTACTS_ERROR_NONE;
2559 char *view_uri = NULL;
2560 char *keyword = NULL;
2564 contacts_list_h list = NULL;
2565 contacts_h contact = NULL;
2568 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
2569 if (CONTACTS_ERROR_NONE != ret) {
2570 /* LCOV_EXCL_START */
2571 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
2573 /* LCOV_EXCL_STOP */
2575 ret = ctsvc_ipc_unmarshal_string(indata, &view_uri);
2576 if (ret != CONTACTS_ERROR_NONE) {
2577 /* LCOV_EXCL_START */
2578 ERR("ctsvc_ipc_unmarshal_record() Fail");
2580 /* LCOV_EXCL_STOP */
2582 ret = ctsvc_ipc_unmarshal_string(indata, &keyword);
2583 if (ret != CONTACTS_ERROR_NONE) {
2584 /* LCOV_EXCL_START */
2585 ERR("ctsvc_ipc_unmarshal_record() Fail");
2587 /* LCOV_EXCL_STOP */
2589 ret = ctsvc_ipc_unmarshal_int(indata, &offset);
2590 if (ret != CONTACTS_ERROR_NONE) {
2591 /* LCOV_EXCL_START */
2592 ERR("ctsvc_ipc_unmarshal_int() Fail");
2594 /* LCOV_EXCL_STOP */
2596 ret = ctsvc_ipc_unmarshal_int(indata, &limit);
2597 if (ret != CONTACTS_ERROR_NONE) {
2598 /* LCOV_EXCL_START */
2599 ERR("ctsvc_ipc_unmarshal_int() Fail");
2601 /* LCOV_EXCL_STOP */
2603 ret = ctsvc_ipc_unmarshal_int(indata, &range);
2604 if (ret != CONTACTS_ERROR_NONE) {
2605 /* LCOV_EXCL_START */
2606 ERR("ctsvc_ipc_unmarshal_int() Fail");
2608 /* LCOV_EXCL_STOP */
2611 /* LCOV_EXCL_START */
2612 ERR("ctsvc_ipc_server_db_insert_record() Fail");
2614 /* LCOV_EXCL_STOP */
2617 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(view_uri))) {
2618 /* LCOV_EXCL_START */
2619 ret = CONTACTS_ERROR_PERMISSION_DENIED;
2621 /* LCOV_EXCL_STOP */
2624 ret = ctsvc_db_search_records_with_range(view_uri, keyword, offset, limit, range,
2628 *outdata = pims_ipc_data_create(0);
2629 if (NULL == *outdata) {
2630 /* LCOV_EXCL_START */
2631 ERR("pims_ipc_data_create() Fail");
2633 /* LCOV_EXCL_STOP */
2635 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2636 /* LCOV_EXCL_START */
2637 pims_ipc_data_destroy(*outdata);
2639 ERR("ctsvc_ipc_marshal_int() Fail");
2641 /* LCOV_EXCL_STOP */
2644 if (CONTACTS_ERROR_NO_DATA == ret) {
2646 } else if (CONTACTS_ERROR_NONE == ret) {
2647 ret = ctsvc_ipc_marshal_list(list, *outdata);
2649 if (ret != CONTACTS_ERROR_NONE) {
2650 /* LCOV_EXCL_START */
2651 ERR("ctsvc_ipc_unmarshal_int() Fail");
2653 /* LCOV_EXCL_STOP */
2657 /* LCOV_EXCL_START */
2658 ERR("outdata is NULL");
2659 /* LCOV_EXCL_STOP */
2665 *outdata = pims_ipc_data_create(0);
2666 if (NULL == *outdata) {
2667 /* LCOV_EXCL_START */
2668 ERR("pims_ipc_data_create() Fail");
2670 /* LCOV_EXCL_STOP */
2672 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2673 /* LCOV_EXCL_START */
2674 pims_ipc_data_destroy(*outdata);
2676 ERR("ctsvc_ipc_marshal_int() Fail");
2678 /* LCOV_EXCL_STOP */
2681 /* LCOV_EXCL_START */
2682 ERR("outdata is NULL");
2683 /* LCOV_EXCL_STOP */
2687 ctsvc_handle_destroy(contact);
2688 contacts_list_destroy(list, true);
2691 ctsvc_server_start_timeout();
2695 void ctsvc_ipc_server_db_search_records_with_query(pims_ipc_h ipc,
2696 pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
2698 int ret = CONTACTS_ERROR_NONE;
2699 contacts_query_h query = NULL;
2700 char *keyword = NULL;
2703 contacts_list_h list = NULL;
2704 contacts_h contact = NULL;
2707 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
2708 if (CONTACTS_ERROR_NONE != ret) {
2709 /* LCOV_EXCL_START */
2710 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
2712 /* LCOV_EXCL_STOP */
2714 ret = ctsvc_ipc_unmarshal_query(indata, &query);
2715 if (ret != CONTACTS_ERROR_NONE) {
2716 /* LCOV_EXCL_START */
2717 ERR("ctsvc_ipc_unmarshal_record() Fail");
2719 /* LCOV_EXCL_STOP */
2721 ret = ctsvc_ipc_unmarshal_string(indata, &keyword);
2722 if (ret != CONTACTS_ERROR_NONE) {
2723 /* LCOV_EXCL_START */
2724 ERR("ctsvc_ipc_unmarshal_record() Fail");
2726 /* LCOV_EXCL_STOP */
2728 ret = ctsvc_ipc_unmarshal_int(indata, &offset);
2729 if (ret != CONTACTS_ERROR_NONE) {
2730 /* LCOV_EXCL_START */
2731 ERR("ctsvc_ipc_unmarshal_int() Fail");
2733 /* LCOV_EXCL_STOP */
2735 ret = ctsvc_ipc_unmarshal_int(indata, &limit);
2736 if (ret != CONTACTS_ERROR_NONE) {
2737 /* LCOV_EXCL_START */
2738 ERR("ctsvc_ipc_unmarshal_int() Fail");
2740 /* LCOV_EXCL_STOP */
2743 /* LCOV_EXCL_START */
2744 ERR("ctsvc_ipc_server_db_insert_record() Fail");
2746 /* LCOV_EXCL_STOP */
2750 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(((ctsvc_query_s*)query)->view_uri))) {
2751 /* LCOV_EXCL_START */
2752 ret = CONTACTS_ERROR_PERMISSION_DENIED;
2754 /* LCOV_EXCL_STOP */
2758 ret = ctsvc_db_search_records_with_query(query, keyword, offset, limit, &list);
2761 *outdata = pims_ipc_data_create(0);
2762 if (NULL == *outdata) {
2763 /* LCOV_EXCL_START */
2764 ERR("pims_ipc_data_create() Fail");
2766 /* LCOV_EXCL_STOP */
2768 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2769 /* LCOV_EXCL_START */
2770 pims_ipc_data_destroy(*outdata);
2772 ERR("ctsvc_ipc_marshal_int() Fail");
2774 /* LCOV_EXCL_STOP */
2777 if (CONTACTS_ERROR_NO_DATA == ret) {
2779 } else if (CONTACTS_ERROR_NONE == ret) {
2780 ret = ctsvc_ipc_marshal_list(list, *outdata);
2782 if (ret != CONTACTS_ERROR_NONE) {
2783 /* LCOV_EXCL_START */
2784 ERR("ctsvc_ipc_marshal_list Fail");
2786 /* LCOV_EXCL_STOP */
2790 /* LCOV_EXCL_START */
2791 ERR("outdata is NULL");
2792 /* LCOV_EXCL_STOP */
2798 *outdata = pims_ipc_data_create(0);
2799 if (NULL == *outdata) {
2800 /* LCOV_EXCL_START */
2801 ERR("pims_ipc_data_create() Fail");
2803 /* LCOV_EXCL_STOP */
2805 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2806 /* LCOV_EXCL_START */
2807 pims_ipc_data_destroy(*outdata);
2809 ERR("ctsvc_ipc_marshal_int() Fail");
2811 /* LCOV_EXCL_STOP */
2814 /* LCOV_EXCL_START */
2815 ERR("outdata is NULL");
2816 /* LCOV_EXCL_STOP */
2819 ctsvc_handle_destroy(contact);
2820 contacts_list_destroy(list, true);
2821 contacts_query_destroy(query);
2823 ctsvc_server_start_timeout();
2827 void ctsvc_ipc_server_db_get_status(pims_ipc_h ipc, pims_ipc_data_h indata,
2828 pims_ipc_data_h *outdata, void *userdata)
2830 int ret = CONTACTS_ERROR_NONE;
2831 contacts_db_status_e status = CONTACTS_DB_STATUS_NORMAL;
2832 contacts_h contact = NULL;
2835 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
2836 if (CONTACTS_ERROR_NONE != ret) {
2837 /* LCOV_EXCL_START */
2838 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
2840 /* LCOV_EXCL_STOP */
2844 ret = ctsvc_db_get_status(&status);
2848 *outdata = pims_ipc_data_create(0);
2849 if (NULL == *outdata) {
2850 /* LCOV_EXCL_START */
2851 ERR("pims_ipc_data_create() Fail");
2853 /* LCOV_EXCL_STOP */
2856 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2857 /* LCOV_EXCL_START */
2858 pims_ipc_data_destroy(*outdata);
2860 ERR("ctsvc_ipc_marshal_int() Fail");
2862 /* LCOV_EXCL_STOP */
2865 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(status, *outdata)) {
2866 /* LCOV_EXCL_START */
2867 pims_ipc_data_destroy(*outdata);
2869 ERR("ctsvc_ipc_marshal_int() Fail");
2871 /* LCOV_EXCL_STOP */
2874 /* LCOV_EXCL_START */
2875 ERR("outdata is NULL");
2876 /* LCOV_EXCL_STOP */
2879 ctsvc_handle_destroy(contact);
2880 ctsvc_server_start_timeout();