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);
2096 ctsvc_server_start_timeout();
2100 void ctsvc_ipc_server_db_search_records_with_range_for_snippet(pims_ipc_h ipc,
2101 pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
2103 int ret = CONTACTS_ERROR_NONE;
2104 char *view_uri = NULL;
2105 char *keyword = NULL;
2109 contacts_list_h list = NULL;
2110 contacts_h contact = NULL;
2111 char *start_match = NULL;
2112 char *end_match = NULL;
2113 int token_number = 0;
2116 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
2117 if (CONTACTS_ERROR_NONE != ret) {
2118 /* LCOV_EXCL_START */
2119 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
2121 /* LCOV_EXCL_STOP */
2123 ret = ctsvc_ipc_unmarshal_string(indata, &view_uri);
2124 if (ret != CONTACTS_ERROR_NONE) {
2125 /* LCOV_EXCL_START */
2126 ERR("ctsvc_ipc_unmarshal_record() Fail");
2128 /* LCOV_EXCL_STOP */
2130 ret = ctsvc_ipc_unmarshal_string(indata, &keyword);
2131 if (ret != CONTACTS_ERROR_NONE) {
2132 /* LCOV_EXCL_START */
2133 ERR("ctsvc_ipc_unmarshal_record() Fail");
2135 /* LCOV_EXCL_STOP */
2137 ret = ctsvc_ipc_unmarshal_int(indata, &offset);
2138 if (ret != CONTACTS_ERROR_NONE) {
2139 /* LCOV_EXCL_START */
2140 ERR("ctsvc_ipc_unmarshal_int() Fail");
2142 /* LCOV_EXCL_STOP */
2144 ret = ctsvc_ipc_unmarshal_int(indata, &limit);
2145 if (ret != CONTACTS_ERROR_NONE) {
2146 /* LCOV_EXCL_START */
2147 ERR("ctsvc_ipc_unmarshal_int() Fail");
2149 /* LCOV_EXCL_STOP */
2151 ret = ctsvc_ipc_unmarshal_int(indata, &range);
2152 if (ret != CONTACTS_ERROR_NONE) {
2153 /* LCOV_EXCL_START */
2154 ERR("ctsvc_ipc_unmarshal_int() Fail");
2156 /* LCOV_EXCL_STOP */
2158 ret = ctsvc_ipc_unmarshal_string(indata, &start_match);
2159 if (ret != CONTACTS_ERROR_NONE) {
2160 /* LCOV_EXCL_START */
2161 ERR("ctsvc_ipc_unmarshal_record() Fail");
2163 /* LCOV_EXCL_STOP */
2165 ret = ctsvc_ipc_unmarshal_string(indata, &end_match);
2166 if (ret != CONTACTS_ERROR_NONE) {
2167 /* LCOV_EXCL_START */
2168 ERR("ctsvc_ipc_unmarshal_record() Fail");
2170 /* LCOV_EXCL_STOP */
2172 ret = ctsvc_ipc_unmarshal_int(indata, &token_number);
2173 if (ret != CONTACTS_ERROR_NONE) {
2174 /* LCOV_EXCL_START */
2175 ERR("ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
2177 /* LCOV_EXCL_STOP */
2180 /* LCOV_EXCL_START */
2181 ERR("ctsvc_ipc_server_db_insert_record() Fail");
2183 /* LCOV_EXCL_START */
2186 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(view_uri))) {
2187 /* LCOV_EXCL_START */
2188 ret = CONTACTS_ERROR_PERMISSION_DENIED;
2190 /* LCOV_EXCL_STOP */
2193 ret = ctsvc_db_search_records_with_range_for_snippet(view_uri, keyword, offset,
2194 limit, range, start_match, end_match, token_number, &list);
2197 *outdata = pims_ipc_data_create(0);
2198 if (NULL == *outdata) {
2199 /* LCOV_EXCL_START */
2200 ERR("pims_ipc_data_create() Fail");
2202 /* LCOV_EXCL_STOP */
2204 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2205 /* LCOV_EXCL_START */
2206 pims_ipc_data_destroy(*outdata);
2208 ERR("ctsvc_ipc_marshal_int() Fail");
2210 /* LCOV_EXCL_STOP */
2213 if (CONTACTS_ERROR_NO_DATA == ret) {
2215 } else if (CONTACTS_ERROR_NONE == ret) {
2216 ret = ctsvc_ipc_marshal_list(list, *outdata);
2218 if (ret != CONTACTS_ERROR_NONE) {
2219 /* LCOV_EXCL_START */
2220 ERR("ctsvc_ipc_unmarshal_int() Fail");
2222 /* LCOV_EXCL_STOP */
2226 /* LCOV_EXCL_START */
2227 ERR("outdata is NULL");
2228 /* LCOV_EXCL_STOP */
2234 *outdata = pims_ipc_data_create(0);
2235 if (NULL == *outdata) {
2236 /* LCOV_EXCL_START */
2237 ERR("pims_ipc_data_create() Fail");
2239 /* LCOV_EXCL_STOP */
2241 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2242 /* LCOV_EXCL_START */
2243 pims_ipc_data_destroy(*outdata);
2245 ERR("ctsvc_ipc_marshal_int() Fail");
2247 /* LCOV_EXCL_STOP */
2250 /* LCOV_EXCL_START */
2251 ERR("outdata is NULL");
2252 /* LCOV_EXCL_STOP */
2256 ctsvc_handle_destroy(contact);
2257 contacts_list_destroy(list, true);
2260 ctsvc_server_start_timeout();
2264 void ctsvc_ipc_server_db_search_records_with_query_for_snippet(pims_ipc_h ipc,
2265 pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
2267 int ret = CONTACTS_ERROR_NONE;
2268 contacts_query_h query = NULL;
2269 char *keyword = NULL;
2272 contacts_list_h list = NULL;
2273 contacts_h contact = NULL;
2274 char *start_match = NULL;
2275 char *end_match = NULL;
2276 int token_number = 0;
2279 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
2280 if (CONTACTS_ERROR_NONE != ret) {
2281 /* LCOV_EXCL_START */
2282 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
2284 /* LCOV_EXCL_STOP */
2286 ret = ctsvc_ipc_unmarshal_query(indata, &query);
2287 if (ret != CONTACTS_ERROR_NONE) {
2288 /* LCOV_EXCL_START */
2289 ERR("ctsvc_ipc_unmarshal_record() Fail");
2291 /* LCOV_EXCL_STOP */
2293 ret = ctsvc_ipc_unmarshal_string(indata, &keyword);
2294 if (ret != CONTACTS_ERROR_NONE) {
2295 /* LCOV_EXCL_START */
2296 ERR("ctsvc_ipc_unmarshal_record() Fail");
2298 /* LCOV_EXCL_STOP */
2300 ret = ctsvc_ipc_unmarshal_int(indata, &offset);
2301 if (ret != CONTACTS_ERROR_NONE) {
2302 /* LCOV_EXCL_START */
2303 ERR("ctsvc_ipc_unmarshal_int() Fail");
2305 /* LCOV_EXCL_STOP */
2307 ret = ctsvc_ipc_unmarshal_int(indata, &limit);
2308 if (ret != CONTACTS_ERROR_NONE) {
2309 /* LCOV_EXCL_START */
2310 ERR("ctsvc_ipc_unmarshal_int() Fail");
2312 /* LCOV_EXCL_STOP */
2314 ret = ctsvc_ipc_unmarshal_string(indata, &start_match);
2315 if (ret != CONTACTS_ERROR_NONE) {
2316 /* LCOV_EXCL_START */
2317 ERR("ctsvc_ipc_unmarshal_record() Fail");
2319 /* LCOV_EXCL_STOP */
2321 ret = ctsvc_ipc_unmarshal_string(indata, &end_match);
2322 if (ret != CONTACTS_ERROR_NONE) {
2323 /* LCOV_EXCL_START */
2324 ERR("ctsvc_ipc_unmarshal_record() Fail");
2326 /* LCOV_EXCL_STOP */
2328 ret = ctsvc_ipc_unmarshal_int(indata, &token_number);
2329 if (ret != CONTACTS_ERROR_NONE) {
2330 /* LCOV_EXCL_START */
2331 ERR("ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
2333 /* LCOV_EXCL_STOP */
2336 /* LCOV_EXCL_START */
2337 ERR("ctsvc_ipc_server_db_insert_record() Fail");
2339 /* LCOV_EXCL_STOP */
2342 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(((ctsvc_query_s*)query)->view_uri))) {
2343 /* LCOV_EXCL_START */
2344 ret = CONTACTS_ERROR_PERMISSION_DENIED;
2346 /* LCOV_EXCL_STOP */
2349 ret = ctsvc_db_search_records_with_query_for_snippet(query, keyword, offset, limit,
2350 start_match, end_match, token_number, &list);
2353 *outdata = pims_ipc_data_create(0);
2354 if (NULL == *outdata) {
2355 /* LCOV_EXCL_START */
2356 ERR("pims_ipc_data_create() Fail");
2358 /* LCOV_EXCL_STOP */
2360 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2361 /* LCOV_EXCL_START */
2362 pims_ipc_data_destroy(*outdata);
2364 ERR("ctsvc_ipc_marshal_int() Fail");
2366 /* LCOV_EXCL_STOP */
2369 if (CONTACTS_ERROR_NO_DATA == ret) {
2371 } else if (CONTACTS_ERROR_NONE == ret) {
2372 ret = ctsvc_ipc_marshal_list(list, *outdata);
2374 if (ret != CONTACTS_ERROR_NONE) {
2375 /* LCOV_EXCL_START */
2376 ERR("ctsvc_ipc_marshal_list Fail");
2378 /* LCOV_EXCL_STOP */
2382 /* LCOV_EXCL_START */
2383 ERR("outdata is NULL");
2384 /* LCOV_EXCL_STOP */
2390 *outdata = pims_ipc_data_create(0);
2391 if (NULL == *outdata) {
2392 /* LCOV_EXCL_START */
2393 ERR("pims_ipc_data_create() Fail");
2395 /* LCOV_EXCL_STOP */
2397 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2398 /* LCOV_EXCL_START */
2399 pims_ipc_data_destroy(*outdata);
2401 ERR("ctsvc_ipc_marshal_int() Fail");
2403 /* LCOV_EXCL_STOP */
2406 /* LCOV_EXCL_START */
2407 ERR("outdata is NULL");
2408 /* LCOV_EXCL_STOP */
2411 ctsvc_handle_destroy(contact);
2412 contacts_list_destroy(list, true);
2413 contacts_query_destroy(query);
2415 ctsvc_server_start_timeout();
2419 void ctsvc_ipc_server_db_search_records(pims_ipc_h ipc, pims_ipc_data_h indata,
2420 pims_ipc_data_h *outdata, void *userdata)
2422 int ret = CONTACTS_ERROR_NONE;
2423 char *view_uri = NULL;
2424 char *keyword = NULL;
2427 contacts_list_h list = NULL;
2428 contacts_h contact = NULL;
2431 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
2432 if (CONTACTS_ERROR_NONE != ret) {
2433 /* LCOV_EXCL_START */
2434 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
2436 /* LCOV_EXCL_STOP */
2438 ret = ctsvc_ipc_unmarshal_string(indata, &view_uri);
2439 if (ret != CONTACTS_ERROR_NONE) {
2440 /* LCOV_EXCL_START */
2441 ERR("ctsvc_ipc_unmarshal_record() Fail(%d)", ret);
2443 /* LCOV_EXCL_STOP */
2445 ret = ctsvc_ipc_unmarshal_string(indata, &keyword);
2446 if (ret != CONTACTS_ERROR_NONE) {
2447 /* LCOV_EXCL_START */
2448 ERR("ctsvc_ipc_unmarshal_record() Fail(%d)", ret);
2450 /* LCOV_EXCL_STOP */
2452 ret = ctsvc_ipc_unmarshal_int(indata, &offset);
2453 if (ret != CONTACTS_ERROR_NONE) {
2454 /* LCOV_EXCL_START */
2455 ERR("ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
2457 /* LCOV_EXCL_STOP */
2459 ret = ctsvc_ipc_unmarshal_int(indata, &limit);
2460 if (ret != CONTACTS_ERROR_NONE) {
2461 /* LCOV_EXCL_START */
2462 ERR("ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
2464 /* LCOV_EXCL_STOP */
2467 /* LCOV_EXCL_START */
2468 ERR("ctsvc_ipc_server_db_insert_record() Fail");
2470 /* LCOV_EXCL_STOP */
2473 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(view_uri))) {
2474 /* LCOV_EXCL_START */
2475 ret = CONTACTS_ERROR_PERMISSION_DENIED;
2477 /* LCOV_EXCL_STOP */
2480 ret = ctsvc_db_search_records(view_uri, keyword, offset, limit, &list);
2483 *outdata = pims_ipc_data_create(0);
2484 if (NULL == *outdata) {
2485 /* LCOV_EXCL_START */
2486 ERR("pims_ipc_data_create() Fail");
2488 /* LCOV_EXCL_STOP */
2490 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2491 /* LCOV_EXCL_START */
2492 pims_ipc_data_destroy(*outdata);
2494 ERR("ctsvc_ipc_marshal_int() Fail");
2496 /* LCOV_EXCL_STOP */
2499 if (CONTACTS_ERROR_NO_DATA == ret) {
2501 } else if (CONTACTS_ERROR_NONE == ret) {
2502 ret = ctsvc_ipc_marshal_list(list, *outdata);
2504 if (ret != CONTACTS_ERROR_NONE) {
2505 /* LCOV_EXCL_START */
2506 ERR("ctsvc_ipc_unmarshal_int() Fail");
2508 /* LCOV_EXCL_STOP */
2512 /* LCOV_EXCL_START */
2513 ERR("outdata is NULL");
2514 /* LCOV_EXCL_STOP */
2520 *outdata = pims_ipc_data_create(0);
2521 if (NULL == *outdata) {
2522 /* LCOV_EXCL_START */
2523 ERR("pims_ipc_data_create() Fail");
2525 /* LCOV_EXCL_STOP */
2527 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2528 /* LCOV_EXCL_START */
2529 pims_ipc_data_destroy(*outdata);
2531 ERR("ctsvc_ipc_marshal_int() Fail");
2533 /* LCOV_EXCL_STOP */
2536 /* LCOV_EXCL_START */
2537 ERR("outdata is NULL");
2538 /* LCOV_EXCL_STOP */
2541 ctsvc_handle_destroy(contact);
2542 contacts_list_destroy(list, true);
2545 ctsvc_server_start_timeout();
2549 void ctsvc_ipc_server_db_search_records_with_range(pims_ipc_h ipc,
2550 pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
2552 int ret = CONTACTS_ERROR_NONE;
2553 char *view_uri = NULL;
2554 char *keyword = NULL;
2558 contacts_list_h list = NULL;
2559 contacts_h contact = NULL;
2562 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
2563 if (CONTACTS_ERROR_NONE != ret) {
2564 /* LCOV_EXCL_START */
2565 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
2567 /* LCOV_EXCL_STOP */
2569 ret = ctsvc_ipc_unmarshal_string(indata, &view_uri);
2570 if (ret != CONTACTS_ERROR_NONE) {
2571 /* LCOV_EXCL_START */
2572 ERR("ctsvc_ipc_unmarshal_record() Fail");
2574 /* LCOV_EXCL_STOP */
2576 ret = ctsvc_ipc_unmarshal_string(indata, &keyword);
2577 if (ret != CONTACTS_ERROR_NONE) {
2578 /* LCOV_EXCL_START */
2579 ERR("ctsvc_ipc_unmarshal_record() Fail");
2581 /* LCOV_EXCL_STOP */
2583 ret = ctsvc_ipc_unmarshal_int(indata, &offset);
2584 if (ret != CONTACTS_ERROR_NONE) {
2585 /* LCOV_EXCL_START */
2586 ERR("ctsvc_ipc_unmarshal_int() Fail");
2588 /* LCOV_EXCL_STOP */
2590 ret = ctsvc_ipc_unmarshal_int(indata, &limit);
2591 if (ret != CONTACTS_ERROR_NONE) {
2592 /* LCOV_EXCL_START */
2593 ERR("ctsvc_ipc_unmarshal_int() Fail");
2595 /* LCOV_EXCL_STOP */
2597 ret = ctsvc_ipc_unmarshal_int(indata, &range);
2598 if (ret != CONTACTS_ERROR_NONE) {
2599 /* LCOV_EXCL_START */
2600 ERR("ctsvc_ipc_unmarshal_int() Fail");
2602 /* LCOV_EXCL_STOP */
2605 /* LCOV_EXCL_START */
2606 ERR("ctsvc_ipc_server_db_insert_record() Fail");
2608 /* LCOV_EXCL_STOP */
2611 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(view_uri))) {
2612 /* LCOV_EXCL_START */
2613 ret = CONTACTS_ERROR_PERMISSION_DENIED;
2615 /* LCOV_EXCL_STOP */
2618 ret = ctsvc_db_search_records_with_range(view_uri, keyword, offset, limit, range,
2622 *outdata = pims_ipc_data_create(0);
2623 if (NULL == *outdata) {
2624 /* LCOV_EXCL_START */
2625 ERR("pims_ipc_data_create() Fail");
2627 /* LCOV_EXCL_STOP */
2629 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2630 /* LCOV_EXCL_START */
2631 pims_ipc_data_destroy(*outdata);
2633 ERR("ctsvc_ipc_marshal_int() Fail");
2635 /* LCOV_EXCL_STOP */
2638 if (CONTACTS_ERROR_NO_DATA == ret) {
2640 } else if (CONTACTS_ERROR_NONE == ret) {
2641 ret = ctsvc_ipc_marshal_list(list, *outdata);
2643 if (ret != CONTACTS_ERROR_NONE) {
2644 /* LCOV_EXCL_START */
2645 ERR("ctsvc_ipc_unmarshal_int() Fail");
2647 /* LCOV_EXCL_STOP */
2651 /* LCOV_EXCL_START */
2652 ERR("outdata is NULL");
2653 /* LCOV_EXCL_STOP */
2659 *outdata = pims_ipc_data_create(0);
2660 if (NULL == *outdata) {
2661 /* LCOV_EXCL_START */
2662 ERR("pims_ipc_data_create() Fail");
2664 /* LCOV_EXCL_STOP */
2666 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2667 /* LCOV_EXCL_START */
2668 pims_ipc_data_destroy(*outdata);
2670 ERR("ctsvc_ipc_marshal_int() Fail");
2672 /* LCOV_EXCL_STOP */
2675 /* LCOV_EXCL_START */
2676 ERR("outdata is NULL");
2677 /* LCOV_EXCL_STOP */
2681 ctsvc_handle_destroy(contact);
2682 contacts_list_destroy(list, true);
2685 ctsvc_server_start_timeout();
2689 void ctsvc_ipc_server_db_search_records_with_query(pims_ipc_h ipc,
2690 pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
2692 int ret = CONTACTS_ERROR_NONE;
2693 contacts_query_h query = NULL;
2694 char *keyword = NULL;
2697 contacts_list_h list = NULL;
2698 contacts_h contact = NULL;
2701 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
2702 if (CONTACTS_ERROR_NONE != ret) {
2703 /* LCOV_EXCL_START */
2704 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
2706 /* LCOV_EXCL_STOP */
2708 ret = ctsvc_ipc_unmarshal_query(indata, &query);
2709 if (ret != CONTACTS_ERROR_NONE) {
2710 /* LCOV_EXCL_START */
2711 ERR("ctsvc_ipc_unmarshal_record() Fail");
2713 /* LCOV_EXCL_STOP */
2715 ret = ctsvc_ipc_unmarshal_string(indata, &keyword);
2716 if (ret != CONTACTS_ERROR_NONE) {
2717 /* LCOV_EXCL_START */
2718 ERR("ctsvc_ipc_unmarshal_record() Fail");
2720 /* LCOV_EXCL_STOP */
2722 ret = ctsvc_ipc_unmarshal_int(indata, &offset);
2723 if (ret != CONTACTS_ERROR_NONE) {
2724 /* LCOV_EXCL_START */
2725 ERR("ctsvc_ipc_unmarshal_int() Fail");
2727 /* LCOV_EXCL_STOP */
2729 ret = ctsvc_ipc_unmarshal_int(indata, &limit);
2730 if (ret != CONTACTS_ERROR_NONE) {
2731 /* LCOV_EXCL_START */
2732 ERR("ctsvc_ipc_unmarshal_int() Fail");
2734 /* LCOV_EXCL_STOP */
2737 /* LCOV_EXCL_START */
2738 ERR("ctsvc_ipc_server_db_insert_record() Fail");
2740 /* LCOV_EXCL_STOP */
2744 if (!ctsvc_have_permission(ipc, ctsvc_required_read_permission(((ctsvc_query_s*)query)->view_uri))) {
2745 /* LCOV_EXCL_START */
2746 ret = CONTACTS_ERROR_PERMISSION_DENIED;
2748 /* LCOV_EXCL_STOP */
2752 ret = ctsvc_db_search_records_with_query(query, keyword, offset, limit, &list);
2755 *outdata = pims_ipc_data_create(0);
2756 if (NULL == *outdata) {
2757 /* LCOV_EXCL_START */
2758 ERR("pims_ipc_data_create() Fail");
2760 /* LCOV_EXCL_STOP */
2762 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2763 /* LCOV_EXCL_START */
2764 pims_ipc_data_destroy(*outdata);
2766 ERR("ctsvc_ipc_marshal_int() Fail");
2768 /* LCOV_EXCL_STOP */
2771 if (CONTACTS_ERROR_NO_DATA == ret) {
2773 } else if (CONTACTS_ERROR_NONE == ret) {
2774 ret = ctsvc_ipc_marshal_list(list, *outdata);
2776 if (ret != CONTACTS_ERROR_NONE) {
2777 /* LCOV_EXCL_START */
2778 ERR("ctsvc_ipc_marshal_list Fail");
2780 /* LCOV_EXCL_STOP */
2784 /* LCOV_EXCL_START */
2785 ERR("outdata is NULL");
2786 /* LCOV_EXCL_STOP */
2792 *outdata = pims_ipc_data_create(0);
2793 if (NULL == *outdata) {
2794 /* LCOV_EXCL_START */
2795 ERR("pims_ipc_data_create() Fail");
2797 /* LCOV_EXCL_STOP */
2799 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2800 /* LCOV_EXCL_START */
2801 pims_ipc_data_destroy(*outdata);
2803 ERR("ctsvc_ipc_marshal_int() Fail");
2805 /* LCOV_EXCL_STOP */
2808 /* LCOV_EXCL_START */
2809 ERR("outdata is NULL");
2810 /* LCOV_EXCL_STOP */
2813 ctsvc_handle_destroy(contact);
2814 contacts_list_destroy(list, true);
2815 contacts_query_destroy(query);
2817 ctsvc_server_start_timeout();
2821 void ctsvc_ipc_server_db_get_status(pims_ipc_h ipc, pims_ipc_data_h indata,
2822 pims_ipc_data_h *outdata, void *userdata)
2824 int ret = CONTACTS_ERROR_NONE;
2825 contacts_db_status_e status = CONTACTS_DB_STATUS_NORMAL;
2826 contacts_h contact = NULL;
2829 ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
2830 if (CONTACTS_ERROR_NONE != ret) {
2831 /* LCOV_EXCL_START */
2832 ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
2834 /* LCOV_EXCL_STOP */
2838 ret = ctsvc_db_get_status(&status);
2842 *outdata = pims_ipc_data_create(0);
2843 if (NULL == *outdata) {
2844 /* LCOV_EXCL_START */
2845 ERR("pims_ipc_data_create() Fail");
2847 /* LCOV_EXCL_STOP */
2850 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(ret, *outdata)) {
2851 /* LCOV_EXCL_START */
2852 pims_ipc_data_destroy(*outdata);
2854 ERR("ctsvc_ipc_marshal_int() Fail");
2856 /* LCOV_EXCL_STOP */
2859 if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(status, *outdata)) {
2860 /* LCOV_EXCL_START */
2861 pims_ipc_data_destroy(*outdata);
2863 ERR("ctsvc_ipc_marshal_int() Fail");
2865 /* LCOV_EXCL_STOP */
2868 /* LCOV_EXCL_START */
2869 ERR("outdata is NULL");
2870 /* LCOV_EXCL_STOP */
2873 ctsvc_handle_destroy(contact);
2874 ctsvc_server_start_timeout();