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 ret = ctsvc_db_insert_records(list, &ids, &id_count);
1249 *outdata = pims_ipc_data_create(0);
1250 if (NULL == *outdata) {
1251 /* LCOV_EXCL_START */
1252 ERR("pims_ipc_data_create() Fail");
1254 /* LCOV_EXCL_STOP */
1256 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1257 /* LCOV_EXCL_START */
1258 pims_ipc_data_destroy(*outdata);
1260 ERR("ctsvc_ipc_marshal_int() Fail");
1262 /* LCOV_EXCL_STOP */
1265 if (ret == CONTACTS_ERROR_NONE) {
1266 int transaction_ver = ctsvc_get_transaction_ver();
1267 if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
1268 /* LCOV_EXCL_START */
1269 pims_ipc_data_destroy(*outdata);
1271 ERR("ctsvc_ipc_marshal_int() Fail");
1272 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
1274 /* LCOV_EXCL_STOP */
1276 /* marshal : id_count+property_id+[ids]*id_count */
1278 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(id_count, *outdata)) {
1279 /* LCOV_EXCL_START */
1280 pims_ipc_data_destroy(*outdata);
1282 ERR("ctsvc_ipc_marshal_int() Fail");
1283 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
1285 /* LCOV_EXCL_STOP */
1288 for (i = 0; i < id_count; i++) {
1290 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ids[i], *outdata)) {
1291 /* LCOV_EXCL_START */
1292 pims_ipc_data_destroy(*outdata);
1294 ERR("ctsvc_ipc_marshal_int() Fail");
1295 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
1297 /* LCOV_EXCL_STOP */
1302 /* LCOV_EXCL_START */
1303 ERR("outdata is NULL");
1304 /* LCOV_EXCL_STOP */
1310 *outdata = pims_ipc_data_create(0);
1311 if (NULL == *outdata) {
1312 /* LCOV_EXCL_START */
1313 ERR("pims_ipc_data_create() Fail");
1315 /* LCOV_EXCL_STOP */
1317 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1318 /* LCOV_EXCL_START */
1319 pims_ipc_data_destroy(*outdata);
1321 ERR("ctsvc_ipc_marshal_int() Fail");
1323 /* LCOV_EXCL_STOP */
1326 /* LCOV_EXCL_START */
1327 ERR("outdata is NULL");
1328 /* LCOV_EXCL_STOP */
1331 ctsvc_handle_destroy(contact);
1332 contacts_list_destroy(list, true);
1334 ctsvc_server_start_timeout();
1338 void ctsvc_ipc_server_db_update_records(pims_ipc_h ipc, pims_ipc_data_h indata,
1339 pims_ipc_data_h *outdata, void *userdata)
1341 int ret = CONTACTS_ERROR_NONE;
1342 contacts_list_h list = NULL;
1343 contacts_h contact = NULL;
1346 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
1347 if (CONTACTS_ERROR_NONE != ret) {
1348 /* LCOV_EXCL_START */
1349 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
1351 /* LCOV_EXCL_STOP */
1354 ret = ctsvc_ipc_unmarshal_list(indata, &list);
1355 if (ret != CONTACTS_ERROR_NONE) {
1356 /* LCOV_EXCL_START */
1357 ERR("ctsvc_ipc_unmarshal_list Fail");
1359 /* LCOV_EXCL_STOP */
1362 /* LCOV_EXCL_START */
1363 ERR("ctsvc_ipc_server_db_insert_record() Fail");
1365 /* LCOV_EXCL_STOP */
1369 contacts_record_h record = NULL;
1370 contacts_list_first(list);
1372 ret = contacts_list_get_current_record_p(list, &record);
1373 if (CONTACTS_ERROR_NONE != ret) {
1374 /* LCOV_EXCL_START */
1375 ERR("contacts_list_get_current_record_p() Fail(%d)", ret);
1377 /* LCOV_EXCL_STOP */
1380 if (!ctsvc_have_permission(ipc, ctsvc_required_write_permission(((ctsvc_record_s*)record)->view_uri))) {
1381 /* LCOV_EXCL_START */
1382 ret = CONTACTS_ERROR_PERMISSION_DENIED;
1384 /* LCOV_EXCL_STOP */
1386 } while (CONTACTS_ERROR_NONE == contacts_list_next(list));
1387 contacts_list_first(list);
1390 ret = ctsvc_db_update_records(list);
1393 *outdata = pims_ipc_data_create(0);
1394 if (NULL == *outdata) {
1395 /* LCOV_EXCL_START */
1396 ERR("pims_ipc_data_create() Fail");
1398 /* LCOV_EXCL_STOP */
1400 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1401 /* LCOV_EXCL_START */
1402 pims_ipc_data_destroy(*outdata);
1404 ERR("ctsvc_ipc_marshal_int() Fail");
1406 /* LCOV_EXCL_STOP */
1409 if (ret == CONTACTS_ERROR_NONE) {
1410 int transaction_ver = ctsvc_get_transaction_ver();
1411 if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
1412 /* LCOV_EXCL_START */
1413 pims_ipc_data_destroy(*outdata);
1415 ERR("ctsvc_ipc_marshal_int() Fail");
1416 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
1418 /* LCOV_EXCL_STOP */
1422 /* LCOV_EXCL_START */
1423 ERR("outdata is NULL");
1424 /* LCOV_EXCL_STOP */
1430 *outdata = pims_ipc_data_create(0);
1431 if (NULL == *outdata) {
1432 /* LCOV_EXCL_START */
1433 ERR("pims_ipc_data_create() Fail");
1435 /* LCOV_EXCL_STOP */
1437 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1438 /* LCOV_EXCL_START */
1439 pims_ipc_data_destroy(*outdata);
1441 ERR("ctsvc_ipc_marshal_int() Fail");
1443 /* LCOV_EXCL_STOP */
1446 /* LCOV_EXCL_START */
1447 ERR("outdata is NULL");
1448 /* LCOV_EXCL_STOP */
1451 ctsvc_handle_destroy(contact);
1452 contacts_list_destroy(list, true);
1453 ctsvc_server_start_timeout();
1457 void ctsvc_ipc_server_db_delete_records(pims_ipc_h ipc, pims_ipc_data_h indata,
1458 pims_ipc_data_h *outdata, void *userdata)
1460 int ret = CONTACTS_ERROR_NONE;
1465 contacts_h contact = NULL;
1468 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
1469 if (CONTACTS_ERROR_NONE != ret) {
1470 /* LCOV_EXCL_START */
1471 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
1473 /* LCOV_EXCL_STOP */
1476 ret = ctsvc_ipc_unmarshal_string(indata, &uri);
1477 if (ret != CONTACTS_ERROR_NONE) {
1478 /* LCOV_EXCL_START */
1479 ERR("ctsvc_ipc_unmarshal_string Fail");
1481 /* LCOV_EXCL_STOP */
1483 ret = ctsvc_ipc_unmarshal_int(indata, &count);
1484 if (ret != CONTACTS_ERROR_NONE) {
1485 /* LCOV_EXCL_START */
1486 ERR("ctsvc_ipc_unmarshal_int() Fail");
1488 /* LCOV_EXCL_STOP */
1491 /* LCOV_EXCL_START */
1492 ret = CONTACTS_ERROR_INVALID_PARAMETER;
1494 /* LCOV_EXCL_STOP */
1496 ids = (int*)malloc(sizeof(int)*count);
1497 for (i = 0; i < count; i++) {
1498 ret = ctsvc_ipc_unmarshal_int(indata, &ids[i]);
1499 if (ret != CONTACTS_ERROR_NONE) {
1500 /* LCOV_EXCL_START */
1501 ERR("ctsvc_ipc_unmarshal_int() Fail");
1503 /* LCOV_EXCL_STOP */
1507 /* LCOV_EXCL_START */
1508 ERR("ctsvc_ipc_server_db_insert_record() Fail");
1510 /* LCOV_EXCL_STOP */
1513 if (!ctsvc_have_permission(ipc, ctsvc_required_write_permission(uri))) {
1514 /* LCOV_EXCL_START */
1515 ret = CONTACTS_ERROR_PERMISSION_DENIED;
1517 /* LCOV_EXCL_STOP */
1520 ret = ctsvc_db_delete_records(uri, ids, count);
1523 *outdata = pims_ipc_data_create(0);
1524 if (NULL == *outdata) {
1525 /* LCOV_EXCL_START */
1526 ERR("pims_ipc_data_create() Fail");
1528 /* LCOV_EXCL_STOP */
1531 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1532 /* LCOV_EXCL_START */
1533 pims_ipc_data_destroy(*outdata);
1535 ERR("ctsvc_ipc_marshal_int() Fail");
1537 /* LCOV_EXCL_STOP */
1540 if (ret == CONTACTS_ERROR_NONE) {
1541 int transaction_ver = ctsvc_get_transaction_ver();
1542 if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
1543 /* LCOV_EXCL_START */
1544 pims_ipc_data_destroy(*outdata);
1546 ERR("ctsvc_ipc_marshal_int() Fail");
1547 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
1549 /* LCOV_EXCL_STOP */
1553 /* LCOV_EXCL_START */
1554 ERR("outdata is NULL");
1555 /* LCOV_EXCL_STOP */
1562 *outdata = pims_ipc_data_create(0);
1563 if (NULL == *outdata) {
1564 /* LCOV_EXCL_START */
1565 ERR("pims_ipc_data_create() Fail");
1567 /* LCOV_EXCL_STOP */
1569 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1570 /* LCOV_EXCL_START */
1571 pims_ipc_data_destroy(*outdata);
1573 ERR("ctsvc_ipc_marshal_int() Fail");
1575 /* LCOV_EXCL_STOP */
1578 /* LCOV_EXCL_START */
1579 ERR("outdata is NULL");
1580 /* LCOV_EXCL_STOP */
1583 ctsvc_handle_destroy(contact);
1586 ctsvc_server_start_timeout();
1590 void ctsvc_ipc_server_db_replace_records(pims_ipc_h ipc, pims_ipc_data_h indata,
1591 pims_ipc_data_h *outdata, void *userdata)
1593 int ret = CONTACTS_ERROR_NONE;
1594 contacts_list_h list = NULL;
1598 contacts_h contact = NULL;
1601 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
1602 if (CONTACTS_ERROR_NONE != ret) {
1603 /* LCOV_EXCL_START */
1604 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
1606 /* LCOV_EXCL_STOP */
1609 ret = ctsvc_ipc_unmarshal_list(indata, &list);
1610 if (ret != CONTACTS_ERROR_NONE) {
1611 /* LCOV_EXCL_START */
1612 ERR("ctsvc_ipc_unmarshal_list Fail");
1614 /* LCOV_EXCL_STOP */
1617 ret = ctsvc_ipc_unmarshal_int(indata, &count);
1618 if (ret != CONTACTS_ERROR_NONE) {
1619 /* LCOV_EXCL_START */
1620 ERR("ctsvc_ipc_unmarshal_int() Fail");
1622 /* LCOV_EXCL_STOP */
1626 /* LCOV_EXCL_START */
1627 ret = CONTACTS_ERROR_INVALID_PARAMETER;
1629 /* LCOV_EXCL_STOP */
1632 ids = (int*)malloc(sizeof(int)*count);
1633 for (i = 0; i < count; i++) {
1634 ret = ctsvc_ipc_unmarshal_int(indata, &ids[i]);
1635 if (ret != CONTACTS_ERROR_NONE) {
1636 /* LCOV_EXCL_START */
1637 ERR("ctsvc_ipc_unmarshal_int() Fail");
1639 /* LCOV_EXCL_STOP */
1643 /* LCOV_EXCL_START */
1644 ERR("ctsvc_ipc_server_db_repalce_records Fail");
1646 /* LCOV_EXCL_STOP */
1650 contacts_record_h record = NULL;
1651 contacts_list_first(list);
1653 ret = contacts_list_get_current_record_p(list, &record);
1654 if (CONTACTS_ERROR_NONE != ret) {
1655 /* LCOV_EXCL_START */
1656 ERR("contacts_list_get_current_record_p() Fail(%d)", ret);
1658 /* LCOV_EXCL_STOP */
1661 if (!ctsvc_have_permission(ipc, ctsvc_required_write_permission(((ctsvc_record_s*)record)->view_uri))) {
1662 /* LCOV_EXCL_START */
1663 ret = CONTACTS_ERROR_PERMISSION_DENIED;
1665 /* LCOV_EXCL_STOP */
1667 } while (CONTACTS_ERROR_NONE == contacts_list_next(list));
1668 contacts_list_first(list);
1671 ret = ctsvc_db_replace_records(list, ids, count);
1674 *outdata = pims_ipc_data_create(0);
1675 if (NULL == *outdata) {
1676 /* LCOV_EXCL_START */
1677 ERR("pims_ipc_data_create() Fail");
1679 /* LCOV_EXCL_STOP */
1681 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1682 /* LCOV_EXCL_START */
1683 pims_ipc_data_destroy(*outdata);
1685 ERR("ctsvc_ipc_marshal_int() Fail");
1687 /* LCOV_EXCL_STOP */
1689 if (ret == CONTACTS_ERROR_NONE) {
1690 int transaction_ver = ctsvc_get_transaction_ver();
1691 if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
1692 /* LCOV_EXCL_START */
1693 pims_ipc_data_destroy(*outdata);
1695 ERR("ctsvc_ipc_marshal_int() Fail");
1696 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
1698 /* LCOV_EXCL_STOP */
1702 /* LCOV_EXCL_START */
1703 ERR("outdata is NULL");
1704 /* LCOV_EXCL_STOP */
1710 *outdata = pims_ipc_data_create(0);
1711 if (NULL == *outdata) {
1712 /* LCOV_EXCL_START */
1713 ERR("pims_ipc_data_create() Fail");
1715 /* LCOV_EXCL_STOP */
1717 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1718 /* LCOV_EXCL_START */
1719 pims_ipc_data_destroy(*outdata);
1721 ERR("ctsvc_ipc_marshal_int() Fail");
1723 /* LCOV_EXCL_STOP */
1726 /* LCOV_EXCL_START */
1727 ERR("outdata is NULL");
1728 /* LCOV_EXCL_STOP */
1731 ctsvc_handle_destroy(contact);
1732 contacts_list_destroy(list, true);
1734 ctsvc_server_start_timeout();
1738 void ctsvc_ipc_server_db_get_changes_by_version(pims_ipc_h ipc, pims_ipc_data_h indata,
1739 pims_ipc_data_h *outdata, void *userdata)
1741 int ret = CONTACTS_ERROR_NONE;
1742 char *view_uri = NULL;
1743 int address_book_id = 0;
1744 int contacts_db_version = 0;
1745 contacts_list_h record_list = NULL;
1746 int current_contacts_db_version = 0;
1747 contacts_h contact = NULL;
1750 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
1751 if (CONTACTS_ERROR_NONE != ret) {
1752 /* LCOV_EXCL_START */
1753 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
1755 /* LCOV_EXCL_STOP */
1758 ret = ctsvc_ipc_unmarshal_string(indata, &view_uri);
1759 if (ret != CONTACTS_ERROR_NONE) {
1760 /* LCOV_EXCL_START */
1761 ERR("ctsvc_ipc_unmarshal_string Fail");
1763 /* LCOV_EXCL_STOP */
1765 ret = ctsvc_ipc_unmarshal_int(indata, &address_book_id);
1766 if (ret != CONTACTS_ERROR_NONE) {
1767 /* LCOV_EXCL_START */
1768 ERR("ctsvc_ipc_unmarshal_int() Fail");
1770 /* LCOV_EXCL_STOP */
1772 ret = ctsvc_ipc_unmarshal_int(indata, &contacts_db_version);
1773 if (ret != CONTACTS_ERROR_NONE) {
1774 /* LCOV_EXCL_START */
1775 ERR("ctsvc_ipc_unmarshal_int() Fail");
1777 /* LCOV_EXCL_STOP */
1780 /* LCOV_EXCL_START */
1781 ERR("ctsvc_ipc_server_db_insert_record() Fail");
1783 /* LCOV_EXCL_STOP */
1786 if (!ctsvc_have_permission(ipc, CTSVC_PERMISSION_CONTACT_READ)) {
1787 /* LCOV_EXCL_START */
1788 ret = CONTACTS_ERROR_PERMISSION_DENIED;
1790 /* LCOV_EXCL_STOP */
1793 ret = ctsvc_db_get_changes_by_version(view_uri, address_book_id, contacts_db_version,
1794 &record_list, ¤t_contacts_db_version);
1797 *outdata = pims_ipc_data_create(0);
1798 if (NULL == *outdata) {
1799 /* LCOV_EXCL_START */
1800 ERR("pims_ipc_data_create() Fail");
1802 /* LCOV_EXCL_STOP */
1804 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1805 /* LCOV_EXCL_START */
1806 pims_ipc_data_destroy(*outdata);
1808 ERR("ctsvc_ipc_marshal_int() Fail");
1810 /* LCOV_EXCL_STOP */
1813 if (CONTACTS_ERROR_NO_DATA == ret) {
1815 } else if (CONTACTS_ERROR_NONE == ret) {
1816 ret = ctsvc_ipc_marshal_list(record_list, *outdata);
1817 if (ret != CONTACTS_ERROR_NONE) {
1818 /* LCOV_EXCL_START */
1819 ERR("ctsvc_ipc_marshal_list Fail");
1820 pims_ipc_data_destroy(*outdata);
1822 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
1824 /* LCOV_EXCL_STOP */
1826 ret = ctsvc_ipc_marshal_int(current_contacts_db_version, *outdata);
1827 if (ret != CONTACTS_ERROR_NONE) {
1828 /* LCOV_EXCL_START */
1829 ERR("ctsvc_ipc_marshal_int() Fail");
1830 pims_ipc_data_destroy(*outdata);
1832 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
1834 /* LCOV_EXCL_STOP */
1838 /* LCOV_EXCL_START */
1839 ERR("outdata is NULL");
1840 /* LCOV_EXCL_STOP */
1846 *outdata = pims_ipc_data_create(0);
1847 if (NULL == *outdata) {
1848 /* LCOV_EXCL_START */
1849 ERR("pims_ipc_data_create() Fail");
1851 /* LCOV_EXCL_STOP */
1853 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1854 /* LCOV_EXCL_START */
1855 pims_ipc_data_destroy(*outdata);
1857 ERR("ctsvc_ipc_marshal_int() Fail");
1859 /* LCOV_EXCL_STOP */
1862 /* LCOV_EXCL_START */
1863 ERR("outdata is NULL");
1864 /* LCOV_EXCL_STOP */
1867 ctsvc_handle_destroy(contact);
1868 contacts_list_destroy(record_list, true);
1870 ctsvc_server_start_timeout();
1874 void ctsvc_ipc_server_db_get_current_version(pims_ipc_h ipc, pims_ipc_data_h indata,
1875 pims_ipc_data_h *outdata, void *userdata)
1877 int ret = CONTACTS_ERROR_NONE;
1878 int contacts_db_version = 0;
1879 contacts_h contact = NULL;
1882 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
1883 if (CONTACTS_ERROR_NONE != ret) {
1884 /* LCOV_EXCL_START */
1885 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
1887 /* LCOV_EXCL_STOP */
1891 if (!ctsvc_have_permission(ipc, CTSVC_PERMISSION_CONTACT_READ) &&
1892 !ctsvc_have_permission(ipc, CTSVC_PERMISSION_PHONELOG_READ)) {
1893 /* LCOV_EXCL_START */
1894 ret = CONTACTS_ERROR_PERMISSION_DENIED;
1896 /* LCOV_EXCL_STOP */
1899 ret = ctsvc_db_get_current_version(&contacts_db_version);
1903 *outdata = pims_ipc_data_create(0);
1904 if (NULL == *outdata) {
1905 /* LCOV_EXCL_START */
1906 ERR("pims_ipc_data_create() Fail");
1908 /* LCOV_EXCL_STOP */
1910 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
1911 /* LCOV_EXCL_START */
1912 pims_ipc_data_destroy(*outdata);
1914 ERR("ctsvc_ipc_marshal_int() Fail");
1916 /* LCOV_EXCL_STOP */
1919 if (CONTACTS_ERROR_NO_DATA == ret) {
1921 } else if (CONTACTS_ERROR_NONE == ret) {
1922 ret = ctsvc_ipc_marshal_int(contacts_db_version, *outdata);
1923 if (ret != CONTACTS_ERROR_NONE) {
1924 /* LCOV_EXCL_START */
1925 ERR("ctsvc_ipc_marshal_int() Fail");
1927 /* LCOV_EXCL_STOP */
1931 /* LCOV_EXCL_START */
1932 ERR("outdata is NULL");
1933 /* LCOV_EXCL_STOP */
1937 ctsvc_handle_destroy(contact);
1938 ctsvc_server_start_timeout();
1942 void ctsvc_ipc_server_db_search_records_for_snippet(pims_ipc_h ipc,
1943 pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
1945 int ret = CONTACTS_ERROR_NONE;
1946 char *view_uri = NULL;
1947 char *keyword = NULL;
1950 contacts_list_h list = NULL;
1951 contacts_h contact = NULL;
1952 char *start_match = NULL;
1953 char *end_match = NULL;
1954 int token_number = 0;
1957 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
1958 if (CONTACTS_ERROR_NONE != ret) {
1959 /* LCOV_EXCL_START */
1960 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
1962 /* LCOV_EXCL_STOP */
1964 ret = ctsvc_ipc_unmarshal_string(indata, &view_uri);
1965 if (ret != CONTACTS_ERROR_NONE) {
1966 /* LCOV_EXCL_START */
1967 ERR("ctsvc_ipc_unmarshal_record() Fail(%d)", ret);
1969 /* LCOV_EXCL_STOP */
1971 ret = ctsvc_ipc_unmarshal_string(indata, &keyword);
1972 if (ret != CONTACTS_ERROR_NONE) {
1973 /* LCOV_EXCL_START */
1974 ERR("ctsvc_ipc_unmarshal_record() Fail(%d)", ret);
1976 /* LCOV_EXCL_STOP */
1978 ret = ctsvc_ipc_unmarshal_int(indata, &offset);
1979 if (ret != CONTACTS_ERROR_NONE) {
1980 /* LCOV_EXCL_START */
1981 ERR("ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
1983 /* LCOV_EXCL_STOP */
1985 ret = ctsvc_ipc_unmarshal_int(indata, &limit);
1986 if (ret != CONTACTS_ERROR_NONE) {
1987 /* LCOV_EXCL_START */
1988 ERR("ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
1990 /* LCOV_EXCL_STOP */
1992 ret = ctsvc_ipc_unmarshal_string(indata, &start_match);
1993 if (ret != CONTACTS_ERROR_NONE) {
1994 /* LCOV_EXCL_START */
1995 ERR("ctsvc_ipc_unmarshal_record() Fail");
1997 /* LCOV_EXCL_STOP */
1999 ret = ctsvc_ipc_unmarshal_string(indata, &end_match);
2000 if (ret != CONTACTS_ERROR_NONE) {
2001 /* LCOV_EXCL_START */
2002 ERR("ctsvc_ipc_unmarshal_record() Fail");
2004 /* LCOV_EXCL_STOP */
2006 ret = ctsvc_ipc_unmarshal_int(indata, &token_number);
2007 if (ret != CONTACTS_ERROR_NONE) {
2008 /* LCOV_EXCL_START */
2009 ERR("ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
2011 /* LCOV_EXCL_STOP */
2014 /* LCOV_EXCL_START */
2015 ERR("ctsvc_ipc_server_db_insert_record() Fail");
2017 /* LCOV_EXCL_STOP */
2020 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(view_uri))) {
2021 /* LCOV_EXCL_START */
2022 ret = CONTACTS_ERROR_PERMISSION_DENIED;
2024 /* LCOV_EXCL_STOP */
2027 ret = ctsvc_db_search_records_for_snippet(view_uri, keyword, offset, limit,
2028 start_match, end_match, token_number, &list);
2031 *outdata = pims_ipc_data_create(0);
2032 if (NULL == *outdata) {
2033 /* LCOV_EXCL_START */
2034 ERR("pims_ipc_data_create() Fail");
2036 /* LCOV_EXCL_STOP */
2038 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2039 /* LCOV_EXCL_START */
2040 pims_ipc_data_destroy(*outdata);
2042 ERR("ctsvc_ipc_marshal_int() Fail");
2044 /* LCOV_EXCL_STOP */
2047 if (CONTACTS_ERROR_NO_DATA == ret) {
2049 } else if (CONTACTS_ERROR_NONE == ret) {
2050 ret = ctsvc_ipc_marshal_list(list, *outdata);
2052 if (ret != CONTACTS_ERROR_NONE) {
2053 /* LCOV_EXCL_START */
2054 ERR("ctsvc_ipc_unmarshal_int() Fail");
2056 /* LCOV_EXCL_STOP */
2060 /* LCOV_EXCL_START */
2061 ERR("outdata is NULL");
2062 /* LCOV_EXCL_STOP */
2068 *outdata = pims_ipc_data_create(0);
2069 if (NULL == *outdata) {
2070 /* LCOV_EXCL_START */
2071 ERR("pims_ipc_data_create() Fail");
2073 /* LCOV_EXCL_STOP */
2075 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2076 /* LCOV_EXCL_START */
2077 pims_ipc_data_destroy(*outdata);
2079 ERR("ctsvc_ipc_marshal_int() Fail");
2081 /* LCOV_EXCL_STOP */
2084 /* LCOV_EXCL_START */
2085 ERR("outdata is NULL");
2086 /* LCOV_EXCL_STOP */
2089 ctsvc_handle_destroy(contact);
2090 contacts_list_destroy(list, true);
2093 ctsvc_server_start_timeout();
2097 void ctsvc_ipc_server_db_search_records_with_range_for_snippet(pims_ipc_h ipc,
2098 pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
2100 int ret = CONTACTS_ERROR_NONE;
2101 char *view_uri = NULL;
2102 char *keyword = NULL;
2106 contacts_list_h list = NULL;
2107 contacts_h contact = NULL;
2108 char *start_match = NULL;
2109 char *end_match = NULL;
2110 int token_number = 0;
2113 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
2114 if (CONTACTS_ERROR_NONE != ret) {
2115 /* LCOV_EXCL_START */
2116 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
2118 /* LCOV_EXCL_STOP */
2120 ret = ctsvc_ipc_unmarshal_string(indata, &view_uri);
2121 if (ret != CONTACTS_ERROR_NONE) {
2122 /* LCOV_EXCL_START */
2123 ERR("ctsvc_ipc_unmarshal_record() Fail");
2125 /* LCOV_EXCL_STOP */
2127 ret = ctsvc_ipc_unmarshal_string(indata, &keyword);
2128 if (ret != CONTACTS_ERROR_NONE) {
2129 /* LCOV_EXCL_START */
2130 ERR("ctsvc_ipc_unmarshal_record() Fail");
2132 /* LCOV_EXCL_STOP */
2134 ret = ctsvc_ipc_unmarshal_int(indata, &offset);
2135 if (ret != CONTACTS_ERROR_NONE) {
2136 /* LCOV_EXCL_START */
2137 ERR("ctsvc_ipc_unmarshal_int() Fail");
2139 /* LCOV_EXCL_STOP */
2141 ret = ctsvc_ipc_unmarshal_int(indata, &limit);
2142 if (ret != CONTACTS_ERROR_NONE) {
2143 /* LCOV_EXCL_START */
2144 ERR("ctsvc_ipc_unmarshal_int() Fail");
2146 /* LCOV_EXCL_STOP */
2148 ret = ctsvc_ipc_unmarshal_int(indata, &range);
2149 if (ret != CONTACTS_ERROR_NONE) {
2150 /* LCOV_EXCL_START */
2151 ERR("ctsvc_ipc_unmarshal_int() Fail");
2153 /* LCOV_EXCL_STOP */
2155 ret = ctsvc_ipc_unmarshal_string(indata, &start_match);
2156 if (ret != CONTACTS_ERROR_NONE) {
2157 /* LCOV_EXCL_START */
2158 ERR("ctsvc_ipc_unmarshal_record() Fail");
2160 /* LCOV_EXCL_STOP */
2162 ret = ctsvc_ipc_unmarshal_string(indata, &end_match);
2163 if (ret != CONTACTS_ERROR_NONE) {
2164 /* LCOV_EXCL_START */
2165 ERR("ctsvc_ipc_unmarshal_record() Fail");
2167 /* LCOV_EXCL_STOP */
2169 ret = ctsvc_ipc_unmarshal_int(indata, &token_number);
2170 if (ret != CONTACTS_ERROR_NONE) {
2171 /* LCOV_EXCL_START */
2172 ERR("ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
2174 /* LCOV_EXCL_STOP */
2177 /* LCOV_EXCL_START */
2178 ERR("ctsvc_ipc_server_db_insert_record() Fail");
2180 /* LCOV_EXCL_START */
2183 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(view_uri))) {
2184 /* LCOV_EXCL_START */
2185 ret = CONTACTS_ERROR_PERMISSION_DENIED;
2187 /* LCOV_EXCL_STOP */
2190 ret = ctsvc_db_search_records_with_range_for_snippet(view_uri, keyword, offset,
2191 limit, range, start_match, end_match, token_number, &list);
2194 *outdata = pims_ipc_data_create(0);
2195 if (NULL == *outdata) {
2196 /* LCOV_EXCL_START */
2197 ERR("pims_ipc_data_create() Fail");
2199 /* LCOV_EXCL_STOP */
2201 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2202 /* LCOV_EXCL_START */
2203 pims_ipc_data_destroy(*outdata);
2205 ERR("ctsvc_ipc_marshal_int() Fail");
2207 /* LCOV_EXCL_STOP */
2210 if (CONTACTS_ERROR_NO_DATA == ret) {
2212 } else if (CONTACTS_ERROR_NONE == ret) {
2213 ret = ctsvc_ipc_marshal_list(list, *outdata);
2215 if (ret != CONTACTS_ERROR_NONE) {
2216 /* LCOV_EXCL_START */
2217 ERR("ctsvc_ipc_unmarshal_int() Fail");
2219 /* LCOV_EXCL_STOP */
2223 /* LCOV_EXCL_START */
2224 ERR("outdata is NULL");
2225 /* LCOV_EXCL_STOP */
2231 *outdata = pims_ipc_data_create(0);
2232 if (NULL == *outdata) {
2233 /* LCOV_EXCL_START */
2234 ERR("pims_ipc_data_create() Fail");
2236 /* LCOV_EXCL_STOP */
2238 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2239 /* LCOV_EXCL_START */
2240 pims_ipc_data_destroy(*outdata);
2242 ERR("ctsvc_ipc_marshal_int() Fail");
2244 /* LCOV_EXCL_STOP */
2247 /* LCOV_EXCL_START */
2248 ERR("outdata is NULL");
2249 /* LCOV_EXCL_STOP */
2253 ctsvc_handle_destroy(contact);
2254 contacts_list_destroy(list, true);
2257 ctsvc_server_start_timeout();
2261 void ctsvc_ipc_server_db_search_records_with_query_for_snippet(pims_ipc_h ipc,
2262 pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
2264 int ret = CONTACTS_ERROR_NONE;
2265 contacts_query_h query = NULL;
2266 char *keyword = NULL;
2269 contacts_list_h list = NULL;
2270 contacts_h contact = NULL;
2271 char *start_match = NULL;
2272 char *end_match = NULL;
2273 int token_number = 0;
2276 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
2277 if (CONTACTS_ERROR_NONE != ret) {
2278 /* LCOV_EXCL_START */
2279 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
2281 /* LCOV_EXCL_STOP */
2283 ret = ctsvc_ipc_unmarshal_query(indata, &query);
2284 if (ret != CONTACTS_ERROR_NONE) {
2285 /* LCOV_EXCL_START */
2286 ERR("ctsvc_ipc_unmarshal_record() Fail");
2288 /* LCOV_EXCL_STOP */
2290 ret = ctsvc_ipc_unmarshal_string(indata, &keyword);
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_int(indata, &offset);
2298 if (ret != CONTACTS_ERROR_NONE) {
2299 /* LCOV_EXCL_START */
2300 ERR("ctsvc_ipc_unmarshal_int() Fail");
2302 /* LCOV_EXCL_STOP */
2304 ret = ctsvc_ipc_unmarshal_int(indata, &limit);
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_string(indata, &start_match);
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_string(indata, &end_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_int(indata, &token_number);
2326 if (ret != CONTACTS_ERROR_NONE) {
2327 /* LCOV_EXCL_START */
2328 ERR("ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
2330 /* LCOV_EXCL_STOP */
2333 /* LCOV_EXCL_START */
2334 ERR("ctsvc_ipc_server_db_insert_record() Fail");
2336 /* LCOV_EXCL_STOP */
2339 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(((ctsvc_query_s*)query)->view_uri))) {
2340 /* LCOV_EXCL_START */
2341 ret = CONTACTS_ERROR_PERMISSION_DENIED;
2343 /* LCOV_EXCL_STOP */
2346 ret = ctsvc_db_search_records_with_query_for_snippet(query, keyword, offset, limit,
2347 start_match, end_match, token_number, &list);
2350 *outdata = pims_ipc_data_create(0);
2351 if (NULL == *outdata) {
2352 /* LCOV_EXCL_START */
2353 ERR("pims_ipc_data_create() Fail");
2355 /* LCOV_EXCL_STOP */
2357 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2358 /* LCOV_EXCL_START */
2359 pims_ipc_data_destroy(*outdata);
2361 ERR("ctsvc_ipc_marshal_int() Fail");
2363 /* LCOV_EXCL_STOP */
2366 if (CONTACTS_ERROR_NO_DATA == ret) {
2368 } else if (CONTACTS_ERROR_NONE == ret) {
2369 ret = ctsvc_ipc_marshal_list(list, *outdata);
2371 if (ret != CONTACTS_ERROR_NONE) {
2372 /* LCOV_EXCL_START */
2373 ERR("ctsvc_ipc_marshal_list Fail");
2375 /* LCOV_EXCL_STOP */
2379 /* LCOV_EXCL_START */
2380 ERR("outdata is NULL");
2381 /* LCOV_EXCL_STOP */
2387 *outdata = pims_ipc_data_create(0);
2388 if (NULL == *outdata) {
2389 /* LCOV_EXCL_START */
2390 ERR("pims_ipc_data_create() Fail");
2392 /* LCOV_EXCL_STOP */
2394 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2395 /* LCOV_EXCL_START */
2396 pims_ipc_data_destroy(*outdata);
2398 ERR("ctsvc_ipc_marshal_int() Fail");
2400 /* LCOV_EXCL_STOP */
2403 /* LCOV_EXCL_START */
2404 ERR("outdata is NULL");
2405 /* LCOV_EXCL_STOP */
2408 ctsvc_handle_destroy(contact);
2409 contacts_list_destroy(list, true);
2410 contacts_query_destroy(query);
2412 ctsvc_server_start_timeout();
2416 void ctsvc_ipc_server_db_search_records(pims_ipc_h ipc, pims_ipc_data_h indata,
2417 pims_ipc_data_h *outdata, void *userdata)
2419 int ret = CONTACTS_ERROR_NONE;
2420 char *view_uri = NULL;
2421 char *keyword = NULL;
2424 contacts_list_h list = NULL;
2425 contacts_h contact = NULL;
2428 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
2429 if (CONTACTS_ERROR_NONE != ret) {
2430 /* LCOV_EXCL_START */
2431 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
2433 /* LCOV_EXCL_STOP */
2435 ret = ctsvc_ipc_unmarshal_string(indata, &view_uri);
2436 if (ret != CONTACTS_ERROR_NONE) {
2437 /* LCOV_EXCL_START */
2438 ERR("ctsvc_ipc_unmarshal_record() Fail(%d)", ret);
2440 /* LCOV_EXCL_STOP */
2442 ret = ctsvc_ipc_unmarshal_string(indata, &keyword);
2443 if (ret != CONTACTS_ERROR_NONE) {
2444 /* LCOV_EXCL_START */
2445 ERR("ctsvc_ipc_unmarshal_record() Fail(%d)", ret);
2447 /* LCOV_EXCL_STOP */
2449 ret = ctsvc_ipc_unmarshal_int(indata, &offset);
2450 if (ret != CONTACTS_ERROR_NONE) {
2451 /* LCOV_EXCL_START */
2452 ERR("ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
2454 /* LCOV_EXCL_STOP */
2456 ret = ctsvc_ipc_unmarshal_int(indata, &limit);
2457 if (ret != CONTACTS_ERROR_NONE) {
2458 /* LCOV_EXCL_START */
2459 ERR("ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
2461 /* LCOV_EXCL_STOP */
2464 /* LCOV_EXCL_START */
2465 ERR("ctsvc_ipc_server_db_insert_record() Fail");
2467 /* LCOV_EXCL_STOP */
2470 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(view_uri))) {
2471 /* LCOV_EXCL_START */
2472 ret = CONTACTS_ERROR_PERMISSION_DENIED;
2474 /* LCOV_EXCL_STOP */
2477 ret = ctsvc_db_search_records(view_uri, keyword, offset, limit, &list);
2480 *outdata = pims_ipc_data_create(0);
2481 if (NULL == *outdata) {
2482 /* LCOV_EXCL_START */
2483 ERR("pims_ipc_data_create() Fail");
2485 /* LCOV_EXCL_STOP */
2487 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2488 /* LCOV_EXCL_START */
2489 pims_ipc_data_destroy(*outdata);
2491 ERR("ctsvc_ipc_marshal_int() Fail");
2493 /* LCOV_EXCL_STOP */
2496 if (CONTACTS_ERROR_NO_DATA == ret) {
2498 } else if (CONTACTS_ERROR_NONE == ret) {
2499 ret = ctsvc_ipc_marshal_list(list, *outdata);
2501 if (ret != CONTACTS_ERROR_NONE) {
2502 /* LCOV_EXCL_START */
2503 ERR("ctsvc_ipc_unmarshal_int() Fail");
2505 /* LCOV_EXCL_STOP */
2509 /* LCOV_EXCL_START */
2510 ERR("outdata is NULL");
2511 /* LCOV_EXCL_STOP */
2517 *outdata = pims_ipc_data_create(0);
2518 if (NULL == *outdata) {
2519 /* LCOV_EXCL_START */
2520 ERR("pims_ipc_data_create() Fail");
2522 /* LCOV_EXCL_STOP */
2524 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2525 /* LCOV_EXCL_START */
2526 pims_ipc_data_destroy(*outdata);
2528 ERR("ctsvc_ipc_marshal_int() Fail");
2530 /* LCOV_EXCL_STOP */
2533 /* LCOV_EXCL_START */
2534 ERR("outdata is NULL");
2535 /* LCOV_EXCL_STOP */
2538 ctsvc_handle_destroy(contact);
2539 contacts_list_destroy(list, true);
2542 ctsvc_server_start_timeout();
2546 void ctsvc_ipc_server_db_search_records_with_range(pims_ipc_h ipc,
2547 pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
2549 int ret = CONTACTS_ERROR_NONE;
2550 char *view_uri = NULL;
2551 char *keyword = NULL;
2555 contacts_list_h list = NULL;
2556 contacts_h contact = NULL;
2559 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
2560 if (CONTACTS_ERROR_NONE != ret) {
2561 /* LCOV_EXCL_START */
2562 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
2564 /* LCOV_EXCL_STOP */
2566 ret = ctsvc_ipc_unmarshal_string(indata, &view_uri);
2567 if (ret != CONTACTS_ERROR_NONE) {
2568 /* LCOV_EXCL_START */
2569 ERR("ctsvc_ipc_unmarshal_record() Fail");
2571 /* LCOV_EXCL_STOP */
2573 ret = ctsvc_ipc_unmarshal_string(indata, &keyword);
2574 if (ret != CONTACTS_ERROR_NONE) {
2575 /* LCOV_EXCL_START */
2576 ERR("ctsvc_ipc_unmarshal_record() Fail");
2578 /* LCOV_EXCL_STOP */
2580 ret = ctsvc_ipc_unmarshal_int(indata, &offset);
2581 if (ret != CONTACTS_ERROR_NONE) {
2582 /* LCOV_EXCL_START */
2583 ERR("ctsvc_ipc_unmarshal_int() Fail");
2585 /* LCOV_EXCL_STOP */
2587 ret = ctsvc_ipc_unmarshal_int(indata, &limit);
2588 if (ret != CONTACTS_ERROR_NONE) {
2589 /* LCOV_EXCL_START */
2590 ERR("ctsvc_ipc_unmarshal_int() Fail");
2592 /* LCOV_EXCL_STOP */
2594 ret = ctsvc_ipc_unmarshal_int(indata, &range);
2595 if (ret != CONTACTS_ERROR_NONE) {
2596 /* LCOV_EXCL_START */
2597 ERR("ctsvc_ipc_unmarshal_int() Fail");
2599 /* LCOV_EXCL_STOP */
2602 /* LCOV_EXCL_START */
2603 ERR("ctsvc_ipc_server_db_insert_record() Fail");
2605 /* LCOV_EXCL_STOP */
2608 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(view_uri))) {
2609 /* LCOV_EXCL_START */
2610 ret = CONTACTS_ERROR_PERMISSION_DENIED;
2612 /* LCOV_EXCL_STOP */
2615 ret = ctsvc_db_search_records_with_range(view_uri, keyword, offset, limit, range,
2619 *outdata = pims_ipc_data_create(0);
2620 if (NULL == *outdata) {
2621 /* LCOV_EXCL_START */
2622 ERR("pims_ipc_data_create() Fail");
2624 /* LCOV_EXCL_STOP */
2626 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2627 /* LCOV_EXCL_START */
2628 pims_ipc_data_destroy(*outdata);
2630 ERR("ctsvc_ipc_marshal_int() Fail");
2632 /* LCOV_EXCL_STOP */
2635 if (CONTACTS_ERROR_NO_DATA == ret) {
2637 } else if (CONTACTS_ERROR_NONE == ret) {
2638 ret = ctsvc_ipc_marshal_list(list, *outdata);
2640 if (ret != CONTACTS_ERROR_NONE) {
2641 /* LCOV_EXCL_START */
2642 ERR("ctsvc_ipc_unmarshal_int() Fail");
2644 /* LCOV_EXCL_STOP */
2648 /* LCOV_EXCL_START */
2649 ERR("outdata is NULL");
2650 /* LCOV_EXCL_STOP */
2656 *outdata = pims_ipc_data_create(0);
2657 if (NULL == *outdata) {
2658 /* LCOV_EXCL_START */
2659 ERR("pims_ipc_data_create() Fail");
2661 /* LCOV_EXCL_STOP */
2663 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2664 /* LCOV_EXCL_START */
2665 pims_ipc_data_destroy(*outdata);
2667 ERR("ctsvc_ipc_marshal_int() Fail");
2669 /* LCOV_EXCL_STOP */
2672 /* LCOV_EXCL_START */
2673 ERR("outdata is NULL");
2674 /* LCOV_EXCL_STOP */
2678 ctsvc_handle_destroy(contact);
2679 contacts_list_destroy(list, true);
2682 ctsvc_server_start_timeout();
2686 void ctsvc_ipc_server_db_search_records_with_query(pims_ipc_h ipc,
2687 pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
2689 int ret = CONTACTS_ERROR_NONE;
2690 contacts_query_h query = NULL;
2691 char *keyword = NULL;
2694 contacts_list_h list = NULL;
2695 contacts_h contact = NULL;
2698 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
2699 if (CONTACTS_ERROR_NONE != ret) {
2700 /* LCOV_EXCL_START */
2701 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
2703 /* LCOV_EXCL_STOP */
2705 ret = ctsvc_ipc_unmarshal_query(indata, &query);
2706 if (ret != CONTACTS_ERROR_NONE) {
2707 /* LCOV_EXCL_START */
2708 ERR("ctsvc_ipc_unmarshal_record() Fail");
2710 /* LCOV_EXCL_STOP */
2712 ret = ctsvc_ipc_unmarshal_string(indata, &keyword);
2713 if (ret != CONTACTS_ERROR_NONE) {
2714 /* LCOV_EXCL_START */
2715 ERR("ctsvc_ipc_unmarshal_record() Fail");
2717 /* LCOV_EXCL_STOP */
2719 ret = ctsvc_ipc_unmarshal_int(indata, &offset);
2720 if (ret != CONTACTS_ERROR_NONE) {
2721 /* LCOV_EXCL_START */
2722 ERR("ctsvc_ipc_unmarshal_int() Fail");
2724 /* LCOV_EXCL_STOP */
2726 ret = ctsvc_ipc_unmarshal_int(indata, &limit);
2727 if (ret != CONTACTS_ERROR_NONE) {
2728 /* LCOV_EXCL_START */
2729 ERR("ctsvc_ipc_unmarshal_int() Fail");
2731 /* LCOV_EXCL_STOP */
2734 /* LCOV_EXCL_START */
2735 ERR("ctsvc_ipc_server_db_insert_record() Fail");
2737 /* LCOV_EXCL_STOP */
2741 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(((ctsvc_query_s*)query)->view_uri))) {
2742 /* LCOV_EXCL_START */
2743 ret = CONTACTS_ERROR_PERMISSION_DENIED;
2745 /* LCOV_EXCL_STOP */
2749 ret = ctsvc_db_search_records_with_query(query, keyword, offset, limit, &list);
2752 *outdata = pims_ipc_data_create(0);
2753 if (NULL == *outdata) {
2754 /* LCOV_EXCL_START */
2755 ERR("pims_ipc_data_create() Fail");
2757 /* LCOV_EXCL_STOP */
2759 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2760 /* LCOV_EXCL_START */
2761 pims_ipc_data_destroy(*outdata);
2763 ERR("ctsvc_ipc_marshal_int() Fail");
2765 /* LCOV_EXCL_STOP */
2768 if (CONTACTS_ERROR_NO_DATA == ret) {
2770 } else if (CONTACTS_ERROR_NONE == ret) {
2771 ret = ctsvc_ipc_marshal_list(list, *outdata);
2773 if (ret != CONTACTS_ERROR_NONE) {
2774 /* LCOV_EXCL_START */
2775 ERR("ctsvc_ipc_marshal_list Fail");
2777 /* LCOV_EXCL_STOP */
2781 /* LCOV_EXCL_START */
2782 ERR("outdata is NULL");
2783 /* LCOV_EXCL_STOP */
2789 *outdata = pims_ipc_data_create(0);
2790 if (NULL == *outdata) {
2791 /* LCOV_EXCL_START */
2792 ERR("pims_ipc_data_create() Fail");
2794 /* LCOV_EXCL_STOP */
2796 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2797 /* LCOV_EXCL_START */
2798 pims_ipc_data_destroy(*outdata);
2800 ERR("ctsvc_ipc_marshal_int() Fail");
2802 /* LCOV_EXCL_STOP */
2805 /* LCOV_EXCL_START */
2806 ERR("outdata is NULL");
2807 /* LCOV_EXCL_STOP */
2810 ctsvc_handle_destroy(contact);
2811 contacts_list_destroy(list, true);
2812 contacts_query_destroy(query);
2814 ctsvc_server_start_timeout();
2818 void ctsvc_ipc_server_db_get_status(pims_ipc_h ipc, pims_ipc_data_h indata,
2819 pims_ipc_data_h *outdata, void *userdata)
2821 int ret = CONTACTS_ERROR_NONE;
2822 contacts_db_status_e status;
2823 contacts_h contact = NULL;
2826 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
2827 if (CONTACTS_ERROR_NONE != ret) {
2828 /* LCOV_EXCL_START */
2829 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
2831 /* LCOV_EXCL_STOP */
2835 ret = ctsvc_db_get_status(&status);
2839 *outdata = pims_ipc_data_create(0);
2840 if (NULL == *outdata) {
2841 /* LCOV_EXCL_START */
2842 ERR("pims_ipc_data_create() Fail");
2844 /* LCOV_EXCL_STOP */
2847 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2848 /* LCOV_EXCL_START */
2849 pims_ipc_data_destroy(*outdata);
2851 ERR("ctsvc_ipc_marshal_int() Fail");
2853 /* LCOV_EXCL_STOP */
2856 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(status, *outdata)) {
2857 /* LCOV_EXCL_START */
2858 pims_ipc_data_destroy(*outdata);
2860 ERR("ctsvc_ipc_marshal_int() Fail");
2862 /* LCOV_EXCL_STOP */
2865 /* LCOV_EXCL_START */
2866 ERR("outdata is NULL");
2867 /* LCOV_EXCL_STOP */
2870 ctsvc_handle_destroy(contact);
2871 ctsvc_server_start_timeout();