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_FEATURE_BT_DPM
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_FEATURE_BT_DPM
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_ERROR_INTERNAL;
38 if (value != VCONFKEY_BT_DPM_STATUS_RESTRICTED)
39 return BLUETOOTH_ERROR_NONE;
41 return BLUETOOTH_ERROR_PERMISSION_DEINED;
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;
249 int ret = BLUETOOTH_ERROR_NONE;
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 ret = BLUETOOTH_ERROR_PERMISSION_DEINED;
297 } else if (status == BT_DPM_NO_SERVICE) {
298 BT_DBG("DPM no service [%d]", status);
299 ret = BLUETOOTH_ERROR_SERVICE_NOT_FOUND;
305 BT_EXPORT_API int bluetooth_dpm_set_allow_mode(bt_dpm_allow_t value)
307 int result = BLUETOOTH_ERROR_NONE;
308 #ifdef TIZEN_FEATURE_BT_DPM
312 #ifdef TIZEN_FEATURE_BT_DPM
313 if (vconf_get_int(VCONFKEY_BT_STATUS, &bt_status) < 0)
314 BT_ERR("Error in reading VCONFKEY_BT_STATUS");
316 if (bt_status == VCONFKEY_BT_STATUS_ON) {
317 if (vconf_set_int(VCONFKEY_BT_DPM_STATUS, value) != 0) {
318 BT_ERR("Set VCONFKEY_BT_DPM_STATUS failed\n");
319 result = BLUETOOTH_ERROR_INTERNAL;
321 BT_ERR("Set VCONFKEY_BT_DPM_STATUS success\n");
322 result = BLUETOOTH_ERROR_NONE;
326 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
328 g_array_append_vals(in_param1, &value, sizeof(int));
330 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_ALLOW_BT_MODE,
331 in_param1, in_param2, in_param3, in_param4, &out_param);
333 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
335 if (result == BLUETOOTH_ERROR_NONE &&
336 value == BLUETOOTH_DPM_BT_RESTRICTED) {
337 result = bluetooth_disable_adapter();
340 if (value >= BLUETOOTH_DPM_BT_ALLOWED &&
341 value <= BLUETOOTH_DPM_BT_RESTRICTED) {
342 if (vconf_set_int(VCONFKEY_BT_DPM_STATUS, value) != 0) {
343 BT_ERR("Set VCONFKEY_BT_DPM_STATUS failed\n");
344 result = BLUETOOTH_ERROR_INTERNAL;
346 result = BLUETOOTH_ERROR_NONE;
348 result = BLUETOOTH_ERROR_INVALID_PARAM;
352 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
354 g_array_append_vals(in_param1, &value, sizeof(int));
356 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_ALLOW_BT_MODE,
357 in_param1, in_param2, in_param3, in_param4, &out_param);
359 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
366 BT_EXPORT_API int bluetooth_dpm_get_allow_mode(bt_dpm_allow_t *value)
370 #ifdef TIZEN_FEATURE_BT_DPM
371 *value = bluetooth_dpm_is_mode_allowed();
372 result = BLUETOOTH_ERROR_NONE;
374 BT_CHECK_ENABLED_ANY(return);
377 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
379 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_ALLOW_BT_MODE,
380 in_param1, in_param2, in_param3, in_param4, &out_param);
382 if (result == BLUETOOTH_ERROR_NONE) {
383 if (out_param->len > 0) {
384 *value = g_array_index(out_param,
387 BT_ERR("out_param length is 0!!");
391 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
398 BT_EXPORT_API int bluetooth_dpm_activate_device_restriction(bt_dpm_status_t value)
402 BT_CHECK_ENABLED_ANY(return);
405 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
407 g_array_append_vals(in_param1, &value, sizeof(int));
409 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_DEVICE_RESTRITION,
410 in_param1, in_param2, in_param3, in_param4, &out_param);
412 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
418 BT_EXPORT_API int bluetooth_dpm_is_device_restriction_active(bt_dpm_status_t *value)
422 BT_CHECK_ENABLED_ANY(return);
425 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
427 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DEVICE_RESTRITION,
428 in_param1, in_param2, in_param3, in_param4, &out_param);
430 if (result == BLUETOOTH_ERROR_NONE) {
431 if (out_param->len > 0) {
432 *value = g_array_index(out_param,
435 BT_ERR("out_param length is 0!!");
439 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
445 BT_EXPORT_API int bluetooth_dpm_activate_uuid_restriction(bt_dpm_status_t value)
449 BT_CHECK_ENABLED_ANY(return);
452 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
454 g_array_append_vals(in_param1, &value, sizeof(int));
456 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_UUID_RESTRITION,
457 in_param1, in_param2, in_param3, in_param4, &out_param);
459 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
465 BT_EXPORT_API int bluetooth_dpm_is_uuid_restriction_active(bt_dpm_status_t *value)
469 BT_CHECK_ENABLED_ANY(return);
472 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
474 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_UUID_RESTRITION,
475 in_param1, in_param2, in_param3, in_param4, &out_param);
477 if (result == BLUETOOTH_ERROR_NONE) {
478 if (out_param->len > 0) {
479 *value = g_array_index(out_param,
482 BT_ERR("out_param length is 0!!");
486 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
493 BT_EXPORT_API int bluetooth_dpm_add_devices_to_blacklist(const bluetooth_device_address_t *device_address)
497 BT_CHECK_PARAMETER(device_address, return);
498 BT_CHECK_ENABLED_ANY(return);
501 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
503 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
506 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_ADD_DEVICES_BLACKLIST,
507 in_param1, in_param2, in_param3, in_param4, &out_param);
509 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
515 BT_EXPORT_API int bluetooth_dpm_add_devices_to_whitelist(const bluetooth_device_address_t *device_address)
519 BT_CHECK_PARAMETER(device_address, return);
520 BT_CHECK_ENABLED_ANY(return);
523 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
525 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
527 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_ADD_DEVICES_WHITELIST,
528 in_param1, in_param2, in_param3, in_param4, &out_param);
530 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
537 BT_EXPORT_API int bluetooth_dpm_add_uuids_to_blacklist(const char *service_uuid)
540 char uuid[BLUETOOTH_UUID_STRING_MAX];
542 BT_CHECK_PARAMETER(service_uuid, return);
543 BT_CHECK_ENABLED_ANY(return);
547 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
549 g_strlcpy(uuid, service_uuid, sizeof(uuid));
550 g_array_append_vals(in_param1, uuid, BLUETOOTH_UUID_STRING_MAX);
552 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_ADD_UUIDS_BLACKLIST,
553 in_param1, in_param2, in_param3, in_param4, &out_param);
555 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
562 BT_EXPORT_API int bluetooth_dpm_add_uuids_to_whitelist(const char *service_uuid)
565 char uuid[BLUETOOTH_UUID_STRING_MAX];
567 BT_CHECK_PARAMETER(service_uuid, return);
568 BT_CHECK_ENABLED_ANY(return);
571 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
573 g_strlcpy(uuid, service_uuid, sizeof(uuid));
574 g_array_append_vals(in_param1, uuid, BLUETOOTH_UUID_STRING_MAX);
576 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_ADD_UUIDS_WHITELIST,
577 in_param1, in_param2, in_param3, in_param4, &out_param);
579 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
585 BT_EXPORT_API int bluetooth_dpm_clear_devices_from_blacklist(void)
589 BT_CHECK_ENABLED_ANY(return);
592 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
594 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_CLEAR_DEVICES_BLACKLIST,
595 in_param1, in_param2, in_param3, in_param4, &out_param);
597 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
603 BT_EXPORT_API int bluetooth_dpm_clear_devices_from_whitelist(void)
607 BT_CHECK_ENABLED_ANY(return);
610 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
612 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_CLEAR_DEVICES_WHITELIST,
613 in_param1, in_param2, in_param3, in_param4, &out_param);
615 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
621 BT_EXPORT_API int bluetooth_dpm_clear_uuids_from_blacklist(void)
625 BT_CHECK_ENABLED_ANY(return);
628 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
630 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_CLEAR_UUIDS_BLACKLIST,
631 in_param1, in_param2, in_param3, in_param4, &out_param);
633 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
639 BT_EXPORT_API int bluetooth_dpm_clear_uuids_from_whitelist(void)
643 BT_CHECK_ENABLED_ANY(return);
646 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
648 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_CLEAR_UUIDS_WHITELIST,
649 in_param1, in_param2, in_param3, in_param4, &out_param);
651 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
657 static void _bluetooth_extract_dpm_device_info(int count,
658 bt_dpm_device_list_t *dst_info,
659 bt_dpm_device_list_t *src_info)
663 for (i = 0; i < count; i++) {
664 memset(dst_info->addresses[i].addr, 0,
665 BLUETOOTH_ADDRESS_LENGTH);
667 g_strlcpy((gchar *)dst_info->addresses[i].addr, (gchar *)src_info->addresses[i].addr,
668 BLUETOOTH_ADDRESS_LENGTH);
670 // BT_DBG("address[%d] : %s", i, dst_info->addresses[i].addr);
674 static void _bluetooth_extract_dpm_uuid_info(int count,
675 bt_dpm_uuids_list_t *dst_info,
676 bt_dpm_uuids_list_t *src_info)
680 for (i = 0; i < count; i++) {
681 memset(dst_info->uuids[i], 0,
682 BLUETOOTH_UUID_STRING_MAX);
684 g_strlcpy(dst_info->uuids[i], src_info->uuids[i],
685 BLUETOOTH_UUID_STRING_MAX);
687 BT_DBG("uuids[%d] : %s", i, dst_info->uuids[i]);
691 BT_EXPORT_API int bluetooth_dpm_get_devices_from_blacklist(bt_dpm_device_list_t *device_list)
694 bt_dpm_device_list_t *devices = NULL;
696 BT_CHECK_ENABLED_ANY(return);
699 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
701 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DEVICES_BLACKLIST,
702 in_param1, in_param2, in_param3, in_param4, &out_param);
704 if (result == BLUETOOTH_ERROR_NONE) {
705 devices = &g_array_index(out_param, bt_dpm_device_list_t, 0);
706 BT_DBG("device_list->count : %d", devices->count);
708 if (devices->count == 0) {
709 BT_ERR("device_list->count is zero !");
710 result = BLUETOOTH_ERROR_NOT_FOUND;
713 device_list->count = devices->count;
715 _bluetooth_extract_dpm_device_info(devices->count,
716 device_list, devices);
718 BT_ERR("Get Devices list Failed");
721 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
726 BT_EXPORT_API int bluetooth_dpm_get_devices_from_whitelist(bt_dpm_device_list_t *device_list)
729 bt_dpm_device_list_t *devices = NULL;
731 BT_CHECK_ENABLED_ANY(return);
734 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
736 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DEVICES_WHITELIST,
737 in_param1, in_param2, in_param3, in_param4, &out_param);
739 if (result == BLUETOOTH_ERROR_NONE) {
740 devices = &g_array_index(out_param, bt_dpm_device_list_t, 0);
741 BT_DBG("device_list->count : %d", devices->count);
743 if (devices->count == 0) {
744 BT_ERR("device_list->count is zero !");
745 result = BLUETOOTH_ERROR_NOT_FOUND;
748 device_list->count = devices->count;
750 _bluetooth_extract_dpm_device_info(devices->count,
751 device_list, devices);
754 BT_ERR("Get Devices list Failed");
756 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
761 BT_EXPORT_API int bluetooth_dpm_get_uuids_from_blacklist(bt_dpm_uuids_list_t *uuid_list)
764 bt_dpm_uuids_list_t *uuids;
766 BT_CHECK_ENABLED_ANY(return);
769 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
771 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_UUIDS_BLACKLIST,
772 in_param1, in_param2, in_param3, in_param4, &out_param);
774 if (result == BLUETOOTH_ERROR_NONE) {
775 uuids = &g_array_index(out_param, bt_dpm_uuids_list_t, 0);
776 BT_DBG("uuids->count : %d", uuids->count);
778 if (uuids->count == 0) {
779 BT_ERR("uuids->count is zero !");
780 result = BLUETOOTH_ERROR_NOT_FOUND;
783 uuid_list->count = uuids->count;
784 _bluetooth_extract_dpm_uuid_info(uuids->count,
787 BT_ERR("Get UUIDS list Failed");
790 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
795 BT_EXPORT_API int bluetooth_dpm_get_uuids_from_whitelist(bt_dpm_uuids_list_t *uuid_list)
798 bt_dpm_uuids_list_t *uuids;
800 BT_CHECK_ENABLED_ANY(return);
803 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
805 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_UUIDS_WHITELIST,
806 in_param1, in_param2, in_param3, in_param4, &out_param);
808 if (result == BLUETOOTH_ERROR_NONE) {
809 uuids = &g_array_index(out_param, bt_dpm_uuids_list_t, 0);
810 BT_DBG("uuids->count : %d", uuids->count);
812 if (uuids->count == 0) {
813 BT_ERR("uuids->count is zero !");
814 result = BLUETOOTH_ERROR_NOT_FOUND;
817 uuid_list->count = uuids->count;
819 _bluetooth_extract_dpm_uuid_info(uuids->count,
822 BT_ERR("Get UUIDS list Failed");
825 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
830 BT_EXPORT_API int bluetooth_dpm_remove_device_from_whitelist(const bluetooth_device_address_t *device_address)
834 BT_CHECK_PARAMETER(device_address, return);
835 BT_CHECK_ENABLED_ANY(return);
838 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
840 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
842 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_REMOVE_DEVICE_WHITELIST,
843 in_param1, in_param2, in_param3, in_param4, &out_param);
845 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
850 BT_EXPORT_API int bluetooth_dpm_remove_device_from_blacklist(const bluetooth_device_address_t *device_address)
854 BT_CHECK_PARAMETER(device_address, return);
855 BT_CHECK_ENABLED_ANY(return);
858 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
860 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
862 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_REMOVE_DEVICE_BLACKLIST,
863 in_param1, in_param2, in_param3, in_param4, &out_param);
865 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
870 BT_EXPORT_API int bluetooth_dpm_remove_uuid_from_whitelist(const char *service_uuid)
873 char uuid[BLUETOOTH_UUID_STRING_MAX];
875 BT_CHECK_PARAMETER(service_uuid, return);
876 BT_CHECK_ENABLED_ANY(return);
879 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
881 g_strlcpy(uuid, service_uuid, sizeof(uuid));
882 g_array_append_vals(in_param1, uuid, BLUETOOTH_UUID_STRING_MAX);
884 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_REMOVE_UUID_WHITELIST,
885 in_param1, in_param2, in_param3, in_param4, &out_param);
887 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
892 BT_EXPORT_API int bluetooth_dpm_remove_uuid_from_blacklist(const char *service_uuid)
895 char uuid[BLUETOOTH_UUID_STRING_MAX];
897 BT_CHECK_PARAMETER(service_uuid, return);
898 BT_CHECK_ENABLED_ANY(return);
901 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
903 g_strlcpy(uuid, service_uuid, sizeof(uuid));
904 g_array_append_vals(in_param1, uuid, BLUETOOTH_UUID_STRING_MAX);
906 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_REMOVE_UUID_BLACKLIST,
907 in_param1, in_param2, in_param3, in_param4, &out_param);
909 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
915 BT_EXPORT_API int bluetooth_dpm_set_allow_outgoing_call(bt_dpm_status_t value)
919 BT_CHECK_ENABLED_ANY(return);
922 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
924 g_array_append_vals(in_param1, &value, sizeof(int));
926 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_ALLOW_OUTGOING_CALL,
927 in_param1, in_param2, in_param3, in_param4, &out_param);
929 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
934 BT_EXPORT_API int bluetooth_dpm_get_allow_outgoing_call(bt_dpm_status_t *value)
938 BT_CHECK_ENABLED_ANY(return);
941 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
943 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_ALLOW_OUTGOING_CALL,
944 in_param1, in_param2, in_param3, in_param4, &out_param);
946 if (result == BLUETOOTH_ERROR_NONE) {
947 if (out_param->len > 0) {
948 *value = g_array_index(out_param,
951 BT_ERR("out_param length is 0!!");
955 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
960 BT_EXPORT_API int bluetooth_dpm_set_pairing_state(bt_dpm_status_t value)
964 BT_CHECK_ENABLED_ANY(return);
967 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
969 g_array_append_vals(in_param1, &value, sizeof(int));
971 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_PAIRING_STATE,
972 in_param1, in_param2, in_param3, in_param4, &out_param);
974 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
979 BT_EXPORT_API int bluetooth_dpm_get_pairing_state(bt_dpm_status_t *value)
983 BT_CHECK_ENABLED_ANY(return);
986 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
988 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_ALLOW_BT_MODE,
989 in_param1, in_param2, in_param3, in_param4, &out_param);
991 if (result == BLUETOOTH_ERROR_NONE) {
992 if (out_param->len > 0) {
993 *value = g_array_index(out_param,
996 BT_ERR("out_param length is 0!!");
1000 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1005 BT_EXPORT_API int bluetooth_dpm_set_profile_state(bt_dpm_profile_t profile, bt_dpm_status_t value)
1009 BT_CHECK_ENABLED_ANY(return);
1012 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1014 g_array_append_vals(in_param1, &profile, sizeof(int));
1015 g_array_append_vals(in_param2, &value, sizeof(int));
1017 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_PROFILE_STATE,
1018 in_param1, in_param2, in_param3, in_param4, &out_param);
1020 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1025 BT_EXPORT_API int bluetooth_dpm_get_profile_state(bt_dpm_profile_t profile, bt_dpm_status_t *value)
1029 BT_CHECK_ENABLED_ANY(return);
1032 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1034 g_array_append_vals(in_param1, &profile, sizeof(int));
1036 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_PROFILE_STATE,
1037 in_param1, in_param2, in_param3, in_param4, &out_param);
1039 if (result == BLUETOOTH_ERROR_NONE) {
1040 if (out_param->len > 0) {
1041 *value = g_array_index(out_param,
1044 BT_ERR("out_param length is 0!!");
1048 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1053 BT_EXPORT_API int bluetooth_dpm_set_desktop_connectivity_state(bt_dpm_status_t value)
1057 BT_CHECK_ENABLED_ANY(return);
1060 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1062 g_array_append_vals(in_param1, &value, sizeof(int));
1064 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_DESKROP_CONNECTIVITY_STATE,
1065 in_param1, in_param2, in_param3, in_param4, &out_param);
1067 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1072 BT_EXPORT_API int bluetooth_dpm_get_desktop_connectivity_state(bt_dpm_status_t *value)
1076 BT_CHECK_ENABLED_ANY(return);
1079 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1081 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DESKROP_CONNECTIVITY_STATE,
1082 in_param1, in_param2, in_param3, in_param4, &out_param);
1084 if (result == BLUETOOTH_ERROR_NONE) {
1085 if (out_param->len > 0) {
1086 *value = g_array_index(out_param,
1089 BT_ERR("out_param length is 0!!");
1093 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1098 BT_EXPORT_API int bluetooth_dpm_set_discoverable_state(bt_dpm_status_t value)
1102 BT_CHECK_ENABLED_ANY(return);
1105 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1107 g_array_append_vals(in_param1, &value, sizeof(int));
1109 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_DISCOVERABLE_STATE,
1110 in_param1, in_param2, in_param3, in_param4, &out_param);
1112 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1117 BT_EXPORT_API int bluetooth_dpm_get_discoverable_state(bt_dpm_status_t *value)
1121 BT_CHECK_ENABLED_ANY(return);
1124 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1126 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DISCOVERABLE_STATE,
1127 in_param1, in_param2, in_param3, in_param4, &out_param);
1129 if (result == BLUETOOTH_ERROR_NONE) {
1130 if (out_param->len > 0) {
1131 *value = g_array_index(out_param,
1134 BT_ERR("out_param length is 0!!");
1138 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1143 BT_EXPORT_API int bluetooth_dpm_set_limited_discoverable_state(bt_dpm_status_t value)
1147 BT_CHECK_ENABLED_ANY(return);
1150 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1152 g_array_append_vals(in_param1, &value, sizeof(int));
1154 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_LIMITED_DISCOVERABLE_STATE,
1155 in_param1, in_param2, in_param3, in_param4, &out_param);
1157 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1162 BT_EXPORT_API int bluetooth_dpm_get_limited_discoverable_state(bt_dpm_status_t *value)
1166 BT_CHECK_ENABLED_ANY(return);
1169 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1171 g_array_append_vals(in_param1, &value, sizeof(int));
1173 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_LIMITED_DISCOVERABLE_STATE,
1174 in_param1, in_param2, in_param3, in_param4, &out_param);
1176 if (result == BLUETOOTH_ERROR_NONE) {
1177 if (out_param->len > 0) {
1178 *value = g_array_index(out_param,
1181 BT_ERR("out_param length is 0!!");
1185 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1190 BT_EXPORT_API int bluetooth_dpm_set_data_transfer_state(bt_dpm_status_t value)
1194 BT_CHECK_ENABLED_ANY(return);
1197 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1199 g_array_append_vals(in_param1, &value, sizeof(int));
1201 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_DATA_TRANSFER_STATE,
1202 in_param1, in_param2, in_param3, in_param4, &out_param);
1204 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1209 BT_EXPORT_API int bluetooth_dpm_get_data_transfer_state(bt_dpm_status_t *value)
1213 BT_CHECK_ENABLED_ANY(return);
1216 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1218 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DATA_TRANSFER_STATE,
1219 in_param1, in_param2, in_param3, in_param4, &out_param);
1221 if (result == BLUETOOTH_ERROR_NONE) {
1222 if (out_param->len > 0) {
1223 *value = g_array_index(out_param,
1226 BT_ERR("out_param length is 0!!");
1230 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1234 #endif /* #ifdef TIZEN_FEATURE_BT_DPM */