2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #ifdef TIZEN_DPM_ENABLE
21 #include "bluetooth-api.h"
22 #include "bt-internal-types.h"
23 #include "bt-common.h"
24 #include "bt-request-sender.h"
25 #include "bt-event-handler.h"
26 #include "bt-event-handler.h"
29 #ifdef TIZEN_DPM_VCONF_ENABLE
30 BT_EXPORT_API int bluetooth_dpm_is_mode_allowed(void)
33 /* check VCONFKEY_BT_STATUS */
34 if (vconf_get_int(VCONFKEY_BT_DPM_STATUS, &value) != 0) {
35 BT_ERR("fail to get vconf key!");
36 return BLUETOOTH_DPM_RESULT_FAIL;
38 if (value != VCONFKEY_BT_DPM_STATUS_RESTRICTED)
39 return BLUETOOTH_DPM_RESULT_SUCCESS;
41 return BLUETOOTH_DPM_RESULT_ACCESS_DENIED;
46 static bt_dpm_status_e _bt_check_dpm_allow_restriction(void)
50 bluetooth_dpm_get_allow_mode(&mode);
52 return (mode == BLUETOOTH_DPM_BT_RESTRICTED) ? BT_DPM_RESTRICTED : BT_DPM_ALLOWED;
56 static bt_dpm_status_e _bt_check_dpm_handsfree_only(void)
60 bluetooth_dpm_get_allow_mode(&mode);
62 return (mode == BLUETOOTH_DPM_HANDSFREE_ONLY ? BT_DPM_RESTRICTED : BT_DPM_ALLOWED);
65 static bt_dpm_status_e _bt_check_dpm_pairing_restriction(void)
67 bt_dpm_status_t dpm_status = BLUETOOTH_DPM_ALLOWED;
69 bluetooth_dpm_get_pairing_state(&dpm_status);
71 return (dpm_status == BLUETOOTH_DPM_RESTRICTED ? BT_DPM_RESTRICTED : BT_DPM_ALLOWED);
74 static bt_dpm_status_e _bt_check_dpm_desktop_connectivity_restriction(void)
76 bt_dpm_status_t dpm_status = BLUETOOTH_DPM_ALLOWED;
78 bluetooth_dpm_get_desktop_connectivity_state(&dpm_status);
80 return (dpm_status == BLUETOOTH_DPM_RESTRICTED ? BT_DPM_RESTRICTED : BT_DPM_ALLOWED);
84 static bt_dpm_status_e _bt_check_dpm_visible_restriction(void)
86 bt_dpm_status_t dpm_status = BLUETOOTH_DPM_ALLOWED;
88 bluetooth_dpm_get_desktop_connectivity_state(&dpm_status);
90 return (dpm_status == BLUETOOTH_DPM_RESTRICTED ? BT_DPM_RESTRICTED : BT_DPM_ALLOWED);
93 static bt_dpm_status_e _bt_check_dpm_limited_discoverable_mode(void)
95 bt_dpm_status_t dpm_status = BLUETOOTH_DPM_ALLOWED;
97 bluetooth_dpm_get_limited_discoverable_state(&dpm_status);
99 return (dpm_status == BLUETOOTH_DPM_RESTRICTED ? BT_DPM_RESTRICTED : BT_DPM_ALLOWED);
103 static bt_dpm_status_e _bt_check_dpm_blacklist_device(bluetooth_device_address_t *address)
105 int ret = BLUETOOTH_DPM_RESULT_SUCCESS;
106 bt_dpm_device_list_t dev_list;
107 char device_address[BT_ADDRESS_STRING_SIZE] = { 0 };
109 _bt_convert_addr_type_to_string(device_address,
110 (unsigned char *)address->addr);
112 ret = bluetooth_dpm_get_devices_from_blacklist(&dev_list);
113 if (ret == BLUETOOTH_DPM_RESULT_SUCCESS) {
115 for (i = 0; i < dev_list.count; i++) {
116 char temp_address[BT_ADDRESS_STRING_SIZE] = { 0 };
117 _bt_convert_addr_type_to_string(temp_address,
118 (unsigned char *)dev_list.addresses[i].addr);
119 if (g_strcmp0(device_address, temp_address) == 0)
120 return BT_DPM_RESTRICTED;
122 return BT_DPM_ALLOWED;
125 return BT_DPM_NO_SERVICE;
127 return BT_DPM_ALLOWED;
130 static bt_dpm_status_e _bt_check_dpm_blacklist_uuid(char *uuid)
132 bt_dpm_status_e bt_dpm_status = BT_DPM_ALLOWED;
133 bt_dpm_status_t dpm_status = BLUETOOTH_DPM_ALLOWED;
134 bt_dpm_profile_t dpm_profile = BLUETOOTH_DPM_PROFILE_NONE;
135 bt_dpm_uuids_list_t uuid_list;
136 int ret = BLUETOOTH_DPM_RESULT_SUCCESS;
137 retv_if(!uuid, bt_dpm_status);
139 ret = bluetooth_dpm_get_uuids_from_blacklist(&uuid_list);
140 if (ret == BLUETOOTH_DPM_RESULT_SUCCESS) {
142 for (i = 0; i < uuid_list.count; i++) {
143 if (g_strcmp0(uuid, uuid_list.uuids[i]) == 0)
144 return BT_DPM_RESTRICTED;
146 return BT_DPM_ALLOWED;
149 return BT_DPM_NO_SERVICE;
152 if (g_strcmp0(BT_OPP_UUID, uuid) == 0) {
153 bt_dpm_status_t dpm_status = BLUETOOTH_DPM_ALLOWED;
154 bluetooth_dpm_get_data_transfer_state(&dpm_status);
155 return (dpm_status == BLUETOOTH_DPM_RESTRICTED ? BT_DPM_RESTRICTED : BT_DPM_ALLOWED);
158 /* ++ check MDM profile restriction ++ */
159 if (g_strcmp0(BT_A2DP_UUID, uuid) == 0)
160 dpm_profile = BLUETOOTH_DPM_POLICY_A2DP_PROFILE_STATE;
161 else if (g_strcmp0(BT_AVRCP_TARGET_UUID, uuid) == 0)
162 dpm_profile = BLUETOOTH_DPM_POLICY_AVRCP_PROFILE_STATE;
163 else if (g_strcmp0(BT_HFP_AUDIO_GATEWAY_UUID, uuid) == 0)
164 dpm_profile = BLUETOOTH_DPM_POLICY_HFP_PROFILE_STATE;
165 else if (g_strcmp0(BT_HSP_AUDIO_GATEWAY_UUID, uuid) == 0)
166 dpm_profile = BLUETOOTH_DPM_POLICY_HSP_PROFILE_STATE;
167 else if (g_strcmp0(BT_OBEX_PSE_UUID, uuid) == 0)
168 dpm_profile = BLUETOOTH_DPM_POLICY_PBAP_PROFILE_STATE;
170 if (dpm_profile != BLUETOOTH_DPM_PROFILE_NONE) {
171 ret = bluetooth_dpm_get_profile_state(dpm_profile, &dpm_status);
172 return (dpm_status == BLUETOOTH_DPM_RESTRICTED ? BT_DPM_RESTRICTED : BT_DPM_ALLOWED);
174 /* -- check DPM profile restriction -- */
176 return bt_dpm_status;
179 static bt_dpm_status_e _bt_check_dpm_transfer_restriction(void)
181 bt_dpm_status_e dpm_status = BT_DPM_ALLOWED;
182 bt_dpm_status_t dpm_value = BLUETOOTH_DPM_ALLOWED;
184 dpm_status = _bt_check_dpm_blacklist_uuid(BT_OPP_UUID);
186 if (dpm_status == BT_DPM_NO_SERVICE || dpm_status == BT_DPM_RESTRICTED)
189 bluetooth_dpm_get_data_transfer_state(&dpm_value);
191 return (dpm_value == BLUETOOTH_DPM_RESTRICTED ? BT_DPM_RESTRICTED : BT_DPM_ALLOWED);
194 static bt_dpm_status_e _bt_check_dpm_hsp_restriction(void)
196 bt_dpm_status_e dpm_status = BT_DPM_ALLOWED;
198 dpm_status = _bt_check_dpm_blacklist_uuid(BT_HFP_AUDIO_GATEWAY_UUID);
200 if (dpm_status == BT_DPM_NO_SERVICE || dpm_status == BT_DPM_RESTRICTED)
203 dpm_status = _bt_check_dpm_blacklist_uuid(BT_HSP_AUDIO_GATEWAY_UUID);
204 if (dpm_status == BT_DPM_NO_SERVICE || dpm_status == BT_DPM_RESTRICTED)
210 static bt_dpm_status_e _bt_check_dpm_a2dp_restriction(void)
212 bt_dpm_status_e dpm_status = BT_DPM_ALLOWED;
214 dpm_status = _bt_check_dpm_blacklist_uuid(BT_A2DP_UUID);
216 if (dpm_status == BT_DPM_NO_SERVICE || dpm_status == BT_DPM_RESTRICTED)
222 static bt_dpm_status_e _bt_check_dpm_avrcp_restriction(void)
224 bt_dpm_status_e dpm_status = BT_DPM_ALLOWED;
226 dpm_status = _bt_check_dpm_blacklist_uuid(BT_AVRCP_TARGET_UUID);
228 if (dpm_status == BT_DPM_NO_SERVICE || dpm_status == BT_DPM_RESTRICTED)
234 static bt_dpm_status_e _bt_check_dpm_spp_restriction(void)
236 bt_dpm_status_e dpm_status = BT_DPM_ALLOWED;
238 dpm_status = _bt_check_dpm_blacklist_uuid(BT_SPP_UUID);
240 if (dpm_status == BT_DPM_NO_SERVICE || dpm_status == BT_DPM_RESTRICTED)
246 int _bt_check_dpm(int service, void *param)
248 bt_dpm_status_e status = BT_DPM_ALLOWED;
250 BT_CHECK_ENABLED_ANY(return);
254 status = _bt_check_dpm_handsfree_only();
258 status = _bt_check_dpm_pairing_restriction();
261 status = _bt_check_dpm_desktop_connectivity_restriction();
263 case BT_DPM_ADDRESS: {
264 status = _bt_check_dpm_blacklist_device((bluetooth_device_address_t *)param);
269 uuid = (char *)param;
270 status = _bt_check_dpm_blacklist_uuid(uuid);
274 status = _bt_check_dpm_transfer_restriction();
277 status = _bt_check_dpm_hsp_restriction();
280 status = _bt_check_dpm_a2dp_restriction();
283 status = _bt_check_dpm_avrcp_restriction();
286 status = _bt_check_dpm_spp_restriction();
290 BT_ERR("Unknown service");
294 if (status == BT_DPM_RESTRICTED)
295 BT_INFO("Service [%d], DPM permission denied", service);
296 else if (status == BT_DPM_NO_SERVICE)
297 BT_DBG("DPM no service [%d]", status);
302 BT_EXPORT_API int bluetooth_dpm_set_allow_mode(bt_dpm_allow_t value)
304 int result = BLUETOOTH_DPM_RESULT_SUCCESS;
305 #ifdef TIZEN_DPM_VCONF_ENABLE
309 #ifdef TIZEN_DPM_VCONF_ENABLE
310 if (vconf_get_int(VCONFKEY_BT_STATUS, &bt_status) < 0)
311 BT_ERR("Error in reading VCONFKEY_BT_STATUS");
313 if (bt_status == VCONFKEY_BT_STATUS_ON) {
314 if (vconf_set_int(VCONFKEY_BT_DPM_STATUS, value) != 0) {
315 BT_ERR("Set VCONFKEY_BT_DPM_STATUS failed\n");
316 result = BLUETOOTH_DPM_RESULT_FAIL;
318 BT_ERR("Set VCONFKEY_BT_DPM_STATUS success\n");
319 result = BLUETOOTH_DPM_RESULT_SUCCESS;
323 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
325 g_array_append_vals(in_param1, &value, sizeof(int));
327 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_ALLOW_BT_MODE,
328 in_param1, in_param2, in_param3, in_param4, &out_param);
330 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
332 if (result == BLUETOOTH_DPM_RESULT_SUCCESS &&
333 value == BLUETOOTH_DPM_BT_RESTRICTED) {
334 result = bluetooth_disable_adapter();
337 if (value >= BLUETOOTH_DPM_BT_ALLOWED &&
338 value <= BLUETOOTH_DPM_BT_RESTRICTED) {
339 if (vconf_set_int(VCONFKEY_BT_DPM_STATUS, value) != 0) {
340 BT_ERR("Set VCONFKEY_BT_DPM_STATUS failed\n");
341 result = BLUETOOTH_DPM_RESULT_FAIL;
343 result = BLUETOOTH_DPM_RESULT_SUCCESS;
345 result = BLUETOOTH_DPM_RESULT_INVALID_PARAM;
349 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
351 g_array_append_vals(in_param1, &value, sizeof(int));
353 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_ALLOW_BT_MODE,
354 in_param1, in_param2, in_param3, in_param4, &out_param);
356 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
363 BT_EXPORT_API int bluetooth_dpm_get_allow_mode(bt_dpm_allow_t *value)
367 #ifdef TIZEN_DPM_VCONF_ENABLE
368 *value = bluetooth_dpm_is_mode_allowed();
369 return BLUETOOTH_DPM_RESULT_SUCCESS;
371 BT_CHECK_ENABLED_ANY(return);
374 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
376 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_ALLOW_BT_MODE,
377 in_param1, in_param2, in_param3, in_param4, &out_param);
379 if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
380 if (out_param->len > 0) {
381 *value = g_array_index(out_param,
384 BT_ERR("out_param length is 0!!");
388 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
395 BT_EXPORT_API int bluetooth_dpm_activate_device_restriction(bt_dpm_status_t value)
399 BT_CHECK_ENABLED_ANY(return);
402 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
404 g_array_append_vals(in_param1, &value, sizeof(int));
406 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_DEVICE_RESTRITION,
407 in_param1, in_param2, in_param3, in_param4, &out_param);
409 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
415 BT_EXPORT_API int bluetooth_dpm_is_device_restriction_active(bt_dpm_status_t *value)
419 BT_CHECK_ENABLED_ANY(return);
422 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
424 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DEVICE_RESTRITION,
425 in_param1, in_param2, in_param3, in_param4, &out_param);
427 if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
428 if (out_param->len > 0) {
429 *value = g_array_index(out_param,
432 BT_ERR("out_param length is 0!!");
436 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
442 BT_EXPORT_API int bluetooth_dpm_activate_uuid_restriction(bt_dpm_status_t value)
446 BT_CHECK_ENABLED_ANY(return);
449 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
451 g_array_append_vals(in_param1, &value, sizeof(int));
453 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_UUID_RESTRITION,
454 in_param1, in_param2, in_param3, in_param4, &out_param);
456 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
462 BT_EXPORT_API int bluetooth_dpm_is_uuid_restriction_active(bt_dpm_status_t *value)
466 BT_CHECK_ENABLED_ANY(return);
469 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
471 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_UUID_RESTRITION,
472 in_param1, in_param2, in_param3, in_param4, &out_param);
474 if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
475 if (out_param->len > 0) {
476 *value = g_array_index(out_param,
479 BT_ERR("out_param length is 0!!");
483 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
490 BT_EXPORT_API int bluetooth_dpm_add_devices_to_blacklist(const bluetooth_device_address_t *device_address)
494 BT_CHECK_PARAMETER(device_address, return);
495 BT_CHECK_ENABLED_ANY(return);
498 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
500 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
503 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_ADD_DEVICES_BLACKLIST,
504 in_param1, in_param2, in_param3, in_param4, &out_param);
506 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
512 BT_EXPORT_API int bluetooth_dpm_add_devices_to_whitelist(const bluetooth_device_address_t *device_address)
516 BT_CHECK_PARAMETER(device_address, return);
517 BT_CHECK_ENABLED_ANY(return);
520 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
522 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
524 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_ADD_DEVICES_WHITELIST,
525 in_param1, in_param2, in_param3, in_param4, &out_param);
527 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
534 BT_EXPORT_API int bluetooth_dpm_add_uuids_to_blacklist(const char *service_uuid)
537 char uuid[BLUETOOTH_UUID_STRING_MAX];
539 BT_CHECK_PARAMETER(service_uuid, return);
540 BT_CHECK_ENABLED_ANY(return);
544 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
546 g_strlcpy(uuid, service_uuid, sizeof(uuid));
547 g_array_append_vals(in_param1, uuid, BLUETOOTH_UUID_STRING_MAX);
549 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_ADD_UUIDS_BLACKLIST,
550 in_param1, in_param2, in_param3, in_param4, &out_param);
552 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
559 BT_EXPORT_API int bluetooth_dpm_add_uuids_to_whitelist(const char *service_uuid)
562 char uuid[BLUETOOTH_UUID_STRING_MAX];
564 BT_CHECK_PARAMETER(service_uuid, return);
565 BT_CHECK_ENABLED_ANY(return);
568 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
570 g_strlcpy(uuid, service_uuid, sizeof(uuid));
571 g_array_append_vals(in_param1, uuid, BLUETOOTH_UUID_STRING_MAX);
573 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_ADD_UUIDS_WHITELIST,
574 in_param1, in_param2, in_param3, in_param4, &out_param);
576 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
582 BT_EXPORT_API int bluetooth_dpm_clear_devices_from_blacklist(void)
586 BT_CHECK_ENABLED_ANY(return);
589 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
591 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_CLEAR_DEVICES_BLACKLIST,
592 in_param1, in_param2, in_param3, in_param4, &out_param);
594 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
600 BT_EXPORT_API int bluetooth_dpm_clear_devices_from_whitelist(void)
604 BT_CHECK_ENABLED_ANY(return);
607 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
609 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_CLEAR_DEVICES_WHITELIST,
610 in_param1, in_param2, in_param3, in_param4, &out_param);
612 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
618 BT_EXPORT_API int bluetooth_dpm_clear_uuids_from_blacklist(void)
622 BT_CHECK_ENABLED_ANY(return);
625 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
627 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_CLEAR_UUIDS_BLACKLIST,
628 in_param1, in_param2, in_param3, in_param4, &out_param);
630 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
636 BT_EXPORT_API int bluetooth_dpm_clear_uuids_from_whitelist(void)
640 BT_CHECK_ENABLED_ANY(return);
643 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
645 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_CLEAR_UUIDS_WHITELIST,
646 in_param1, in_param2, in_param3, in_param4, &out_param);
648 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
654 static void _bluetooth_extract_dpm_device_info(int count,
655 bt_dpm_device_list_t *dst_info,
656 bt_dpm_device_list_t *src_info)
660 for (i = 0; i < count; i++) {
661 memset(dst_info->addresses[i].addr, 0,
662 BLUETOOTH_ADDRESS_LENGTH);
664 g_strlcpy((gchar *)dst_info->addresses[i].addr, (gchar *)src_info->addresses[i].addr,
665 BLUETOOTH_ADDRESS_LENGTH);
667 // BT_DBG("address[%d] : %s", i, dst_info->addresses[i].addr);
671 static void _bluetooth_extract_dpm_uuid_info(int count,
672 bt_dpm_uuids_list_t *dst_info,
673 bt_dpm_uuids_list_t *src_info)
677 for (i = 0; i < count; i++) {
678 memset(dst_info->uuids[i], 0,
679 BLUETOOTH_UUID_STRING_MAX);
681 g_strlcpy(dst_info->uuids[i], src_info->uuids[i],
682 BLUETOOTH_UUID_STRING_MAX);
684 BT_DBG("uuids[%d] : %s", i, dst_info->uuids[i]);
688 BT_EXPORT_API int bluetooth_dpm_get_devices_from_blacklist(bt_dpm_device_list_t *device_list)
691 bt_dpm_device_list_t *devices = NULL;
693 BT_CHECK_ENABLED_ANY(return);
696 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
698 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DEVICES_BLACKLIST,
699 in_param1, in_param2, in_param3, in_param4, &out_param);
701 if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
702 devices = &g_array_index(out_param, bt_dpm_device_list_t, 0);
703 BT_DBG("device_list->count : %d", devices->count);
705 if (devices->count == 0) {
706 BT_ERR("device_list->count is zero !");
707 return BLUETOOTH_DPM_RESULT_FAIL;
710 device_list->count = devices->count;
712 _bluetooth_extract_dpm_device_info(devices->count,
713 device_list, devices);
715 BT_ERR("Get Devices list Failed");
718 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
723 BT_EXPORT_API int bluetooth_dpm_get_devices_from_whitelist(bt_dpm_device_list_t *device_list)
726 bt_dpm_device_list_t *devices = NULL;
728 BT_CHECK_ENABLED_ANY(return);
731 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
733 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DEVICES_WHITELIST,
734 in_param1, in_param2, in_param3, in_param4, &out_param);
736 if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
737 devices = &g_array_index(out_param, bt_dpm_device_list_t, 0);
738 BT_DBG("device_list->count : %d", devices->count);
740 if (devices->count == 0) {
741 BT_ERR("device_list->count is zero !");
742 return BLUETOOTH_DPM_RESULT_FAIL;
745 device_list->count = devices->count;
747 _bluetooth_extract_dpm_device_info(devices->count,
748 device_list, devices);
751 BT_ERR("Get Devices list Failed");
753 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
758 BT_EXPORT_API int bluetooth_dpm_get_uuids_from_blacklist(bt_dpm_uuids_list_t *uuid_list)
761 bt_dpm_uuids_list_t *uuids;
763 BT_CHECK_ENABLED_ANY(return);
766 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
768 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_UUIDS_BLACKLIST,
769 in_param1, in_param2, in_param3, in_param4, &out_param);
771 if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
772 uuids = &g_array_index(out_param, bt_dpm_uuids_list_t, 0);
773 BT_DBG("uuids->count : %d", uuids->count);
775 if (uuids->count == 0) {
776 BT_ERR("uuids->count is zero !");
777 return BLUETOOTH_DPM_RESULT_FAIL;
780 uuid_list->count = uuids->count;
781 _bluetooth_extract_dpm_uuid_info(uuids->count,
784 BT_ERR("Get UUIDS list Failed");
787 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
792 BT_EXPORT_API int bluetooth_dpm_get_uuids_from_whitelist(bt_dpm_uuids_list_t *uuid_list)
795 bt_dpm_uuids_list_t *uuids;
797 BT_CHECK_ENABLED_ANY(return);
800 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
802 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_UUIDS_WHITELIST,
803 in_param1, in_param2, in_param3, in_param4, &out_param);
805 if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
806 uuids = &g_array_index(out_param, bt_dpm_uuids_list_t, 0);
807 BT_DBG("uuids->count : %d", uuids->count);
809 if (uuids->count == 0) {
810 BT_ERR("uuids->count is zero !");
811 return BLUETOOTH_DPM_RESULT_FAIL;
814 uuid_list->count = uuids->count;
816 _bluetooth_extract_dpm_uuid_info(uuids->count,
819 BT_ERR("Get UUIDS list Failed");
822 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
827 BT_EXPORT_API int bluetooth_dpm_remove_device_from_whitelist(const bluetooth_device_address_t *device_address)
831 BT_CHECK_PARAMETER(device_address, return);
832 BT_CHECK_ENABLED_ANY(return);
835 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
837 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
839 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_REMOVE_DEVICE_WHITELIST,
840 in_param1, in_param2, in_param3, in_param4, &out_param);
842 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
847 BT_EXPORT_API int bluetooth_dpm_remove_device_from_blacklist(const bluetooth_device_address_t *device_address)
851 BT_CHECK_PARAMETER(device_address, return);
852 BT_CHECK_ENABLED_ANY(return);
855 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
857 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
859 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_REMOVE_DEVICE_BLACKLIST,
860 in_param1, in_param2, in_param3, in_param4, &out_param);
862 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
867 BT_EXPORT_API int bluetooth_dpm_remove_uuid_from_whitelist(const char *service_uuid)
870 char uuid[BLUETOOTH_UUID_STRING_MAX];
872 BT_CHECK_PARAMETER(service_uuid, return);
873 BT_CHECK_ENABLED_ANY(return);
876 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
878 g_strlcpy(uuid, service_uuid, sizeof(uuid));
879 g_array_append_vals(in_param1, uuid, BLUETOOTH_UUID_STRING_MAX);
881 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_REMOVE_UUID_WHITELIST,
882 in_param1, in_param2, in_param3, in_param4, &out_param);
884 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
889 BT_EXPORT_API int bluetooth_dpm_remove_uuid_from_blacklist(const char *service_uuid)
892 char uuid[BLUETOOTH_UUID_STRING_MAX];
894 BT_CHECK_PARAMETER(service_uuid, return);
895 BT_CHECK_ENABLED_ANY(return);
898 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
900 g_strlcpy(uuid, service_uuid, sizeof(uuid));
901 g_array_append_vals(in_param1, uuid, BLUETOOTH_UUID_STRING_MAX);
903 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_REMOVE_UUID_BLACKLIST,
904 in_param1, in_param2, in_param3, in_param4, &out_param);
906 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
912 BT_EXPORT_API int bluetooth_dpm_set_allow_outgoing_call(bt_dpm_status_t value)
916 BT_CHECK_ENABLED_ANY(return);
919 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
921 g_array_append_vals(in_param1, &value, sizeof(int));
923 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_ALLOW_OUTGOING_CALL,
924 in_param1, in_param2, in_param3, in_param4, &out_param);
926 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
931 BT_EXPORT_API int bluetooth_dpm_get_allow_outgoing_call(bt_dpm_status_t *value)
935 BT_CHECK_ENABLED_ANY(return);
938 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
940 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_ALLOW_OUTGOING_CALL,
941 in_param1, in_param2, in_param3, in_param4, &out_param);
943 if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
944 if (out_param->len > 0) {
945 *value = g_array_index(out_param,
948 BT_ERR("out_param length is 0!!");
952 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
957 BT_EXPORT_API int bluetooth_dpm_set_pairing_state(bt_dpm_status_t value)
961 BT_CHECK_ENABLED_ANY(return);
964 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
966 g_array_append_vals(in_param1, &value, sizeof(int));
968 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_PAIRING_STATE,
969 in_param1, in_param2, in_param3, in_param4, &out_param);
971 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
976 BT_EXPORT_API int bluetooth_dpm_get_pairing_state(bt_dpm_status_t *value)
980 BT_CHECK_ENABLED_ANY(return);
983 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
985 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_ALLOW_BT_MODE,
986 in_param1, in_param2, in_param3, in_param4, &out_param);
988 if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
989 if (out_param->len > 0) {
990 *value = g_array_index(out_param,
993 BT_ERR("out_param length is 0!!");
997 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1002 BT_EXPORT_API int bluetooth_dpm_set_profile_state(bt_dpm_profile_t profile, bt_dpm_status_t value)
1006 BT_CHECK_ENABLED_ANY(return);
1009 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1011 g_array_append_vals(in_param1, &profile, sizeof(int));
1012 g_array_append_vals(in_param2, &value, sizeof(int));
1014 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_PROFILE_STATE,
1015 in_param1, in_param2, in_param3, in_param4, &out_param);
1017 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1022 BT_EXPORT_API int bluetooth_dpm_get_profile_state(bt_dpm_profile_t profile, bt_dpm_status_t *value)
1026 BT_CHECK_ENABLED_ANY(return);
1029 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1031 g_array_append_vals(in_param1, &profile, sizeof(int));
1033 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_PROFILE_STATE,
1034 in_param1, in_param2, in_param3, in_param4, &out_param);
1036 if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
1037 if (out_param->len > 0) {
1038 *value = g_array_index(out_param,
1041 BT_ERR("out_param length is 0!!");
1045 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1050 BT_EXPORT_API int bluetooth_dpm_set_desktop_connectivity_state(bt_dpm_status_t value)
1054 BT_CHECK_ENABLED_ANY(return);
1057 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1059 g_array_append_vals(in_param1, &value, sizeof(int));
1061 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_DESKROP_CONNECTIVITY_STATE,
1062 in_param1, in_param2, in_param3, in_param4, &out_param);
1064 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1069 BT_EXPORT_API int bluetooth_dpm_get_desktop_connectivity_state(bt_dpm_status_t *value)
1073 BT_CHECK_ENABLED_ANY(return);
1076 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1078 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DESKROP_CONNECTIVITY_STATE,
1079 in_param1, in_param2, in_param3, in_param4, &out_param);
1081 if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
1082 if (out_param->len > 0) {
1083 *value = g_array_index(out_param,
1086 BT_ERR("out_param length is 0!!");
1090 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1095 BT_EXPORT_API int bluetooth_dpm_set_discoverable_state(bt_dpm_status_t value)
1099 BT_CHECK_ENABLED_ANY(return);
1102 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1104 g_array_append_vals(in_param1, &value, sizeof(int));
1106 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_DISCOVERABLE_STATE,
1107 in_param1, in_param2, in_param3, in_param4, &out_param);
1109 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1114 BT_EXPORT_API int bluetooth_dpm_get_discoverable_state(bt_dpm_status_t *value)
1118 BT_CHECK_ENABLED_ANY(return);
1121 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1123 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DISCOVERABLE_STATE,
1124 in_param1, in_param2, in_param3, in_param4, &out_param);
1126 if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
1127 if (out_param->len > 0) {
1128 *value = g_array_index(out_param,
1131 BT_ERR("out_param length is 0!!");
1135 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1140 BT_EXPORT_API int bluetooth_dpm_set_limited_discoverable_state(bt_dpm_status_t value)
1144 BT_CHECK_ENABLED_ANY(return);
1147 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1149 g_array_append_vals(in_param1, &value, sizeof(int));
1151 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_LIMITED_DISCOVERABLE_STATE,
1152 in_param1, in_param2, in_param3, in_param4, &out_param);
1154 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1159 BT_EXPORT_API int bluetooth_dpm_get_limited_discoverable_state(bt_dpm_status_t *value)
1163 BT_CHECK_ENABLED_ANY(return);
1166 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1168 g_array_append_vals(in_param1, &value, sizeof(int));
1170 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_LIMITED_DISCOVERABLE_STATE,
1171 in_param1, in_param2, in_param3, in_param4, &out_param);
1173 if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
1174 if (out_param->len > 0) {
1175 *value = g_array_index(out_param,
1178 BT_ERR("out_param length is 0!!");
1182 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1187 BT_EXPORT_API int bluetooth_dpm_set_data_transfer_state(bt_dpm_status_t value)
1191 BT_CHECK_ENABLED_ANY(return);
1194 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1196 g_array_append_vals(in_param1, &value, sizeof(int));
1198 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_DATA_TRANSFER_STATE,
1199 in_param1, in_param2, in_param3, in_param4, &out_param);
1201 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1206 BT_EXPORT_API int bluetooth_dpm_get_data_transfer_state(bt_dpm_status_t *value)
1210 BT_CHECK_ENABLED_ANY(return);
1213 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1215 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DATA_TRANSFER_STATE,
1216 in_param1, in_param2, in_param3, in_param4, &out_param);
1218 if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
1219 if (out_param->len > 0) {
1220 *value = g_array_index(out_param,
1223 BT_ERR("out_param length is 0!!");
1227 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1231 #endif /* #ifdef TIZEN_DPM_ENABLE */