4 * Copyright (c) 2010 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Dohyung Jin <dh.jin@samsung.com>
7 * Jongwon Lee <gogosing.lee@samsung.com>
8 * Donghee Ye <donghee.ye@samsung.com>
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
24 #include "ctsvc_internal.h"
25 #include "ctsvc_client_ipc.h"
26 #include "ctsvc_client_handle.h"
27 #include "ctsvc_client_service_helper.h"
29 API int contacts_connect_with_flags(unsigned int flags)
33 contacts_h contact = NULL;
35 ret = ctsvc_client_handle_get_current_p(&contact);
36 if (CONTACTS_ERROR_NO_DATA == ret) {
37 ret = ctsvc_client_handle_create(&contact);
38 RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_create() Fail(%d)", ret);
40 else if (CONTACTS_ERROR_NONE != ret) {
41 CTS_ERR("ctsvc_client_handle_get_current_p() Fail(%d)", ret);
45 ret = ctsvc_client_connect_with_flags(contact, flags);
50 API int contacts_connect(void)
54 contacts_h contact = NULL;
56 ret = ctsvc_client_handle_get_current_p(&contact);
57 if (CONTACTS_ERROR_NO_DATA == ret) {
58 ret = ctsvc_client_handle_create(&contact);
59 RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_create() Fail(%d)", ret);
61 else if (CONTACTS_ERROR_NONE != ret) {
62 CTS_ERR("ctsvc_client_handle_get_current_p() Fail(%d)", ret);
65 ret = ctsvc_client_connect(contact);
70 API int contacts_disconnect(void)
74 contacts_h contact = NULL;
76 ret = ctsvc_client_handle_get_current_p(&contact);
77 RETV_IF(CONTACTS_ERROR_NO_DATA == ret, CONTACTS_ERROR_NONE);
78 RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
80 ret = ctsvc_client_disconnect(contact);
81 WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_client_disconnect() Fail(%d)", ret);
86 API int contacts_connect_on_thread(void)
90 contacts_h contact = NULL;
92 ret = ctsvc_client_handle_get_current_p(&contact);
93 if (CONTACTS_ERROR_NO_DATA == ret) {
94 ret = ctsvc_client_handle_create(&contact);
95 RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_create() Fail(%d)", ret);
97 else if (CONTACTS_ERROR_NONE != ret) {
98 CTS_ERR("ctsvc_client_handle_get_current_p() Fail(%d)", ret);
102 ret = ctsvc_client_connect_on_thread(contact);
103 WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_client_connect_on_thread() Fail(%d)", ret);
108 API int contacts_disconnect_on_thread(void)
112 contacts_h contact = NULL;
114 ret = ctsvc_client_handle_get_current_p(&contact);
115 RETV_IF(CONTACTS_ERROR_NO_DATA == ret, CONTACTS_ERROR_NONE);
116 RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
118 ret = ctsvc_client_disconnect_on_thread(contact);
119 WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_client_disconnect_on_thread() Fail(%d)", ret);