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) {
190 bluetooth_dpm_get_data_transfer_state(&dpm_value);
192 return (dpm_value == BLUETOOTH_DPM_RESTRICTED ? BT_DPM_RESTRICTED : BT_DPM_ALLOWED);
195 static bt_dpm_status_e _bt_check_dpm_hsp_restriction(void)
197 bt_dpm_status_e dpm_status = BT_DPM_ALLOWED;
199 dpm_status = _bt_check_dpm_blacklist_uuid(BT_HFP_AUDIO_GATEWAY_UUID);
201 if (dpm_status == BT_DPM_NO_SERVICE || dpm_status == BT_DPM_RESTRICTED) {
205 dpm_status = _bt_check_dpm_blacklist_uuid(BT_HSP_AUDIO_GATEWAY_UUID);
206 if (dpm_status == BT_DPM_NO_SERVICE || dpm_status == BT_DPM_RESTRICTED) {
212 static bt_dpm_status_e _bt_check_dpm_a2dp_restriction(void)
214 bt_dpm_status_e dpm_status = BT_DPM_ALLOWED;
216 dpm_status = _bt_check_dpm_blacklist_uuid(BT_A2DP_UUID);
218 if (dpm_status == BT_DPM_NO_SERVICE || dpm_status == BT_DPM_RESTRICTED) {
225 static bt_dpm_status_e _bt_check_dpm_avrcp_restriction(void)
227 bt_dpm_status_e dpm_status = BT_DPM_ALLOWED;
229 dpm_status = _bt_check_dpm_blacklist_uuid(BT_AVRCP_TARGET_UUID);
231 if (dpm_status == BT_DPM_NO_SERVICE || dpm_status == BT_DPM_RESTRICTED) {
238 static bt_dpm_status_e _bt_check_dpm_spp_restriction(void)
240 bt_dpm_status_e dpm_status = BT_DPM_ALLOWED;
242 dpm_status = _bt_check_dpm_blacklist_uuid(BT_SPP_UUID);
244 if (dpm_status == BT_DPM_NO_SERVICE || dpm_status == BT_DPM_RESTRICTED) {
251 int _bt_check_dpm(int service, void *param)
253 bt_dpm_status_e status = BT_DPM_ALLOWED;
255 BT_CHECK_ENABLED_ANY(return);
259 status= _bt_check_dpm_handsfree_only();
263 status = _bt_check_dpm_pairing_restriction();
266 status = _bt_check_dpm_desktop_connectivity_restriction();
268 case BT_DPM_ADDRESS: {
269 status = _bt_check_dpm_blacklist_device((bluetooth_device_address_t *)param);
274 uuid = (char *)param;
275 status = _bt_check_dpm_blacklist_uuid(uuid);
279 status = _bt_check_dpm_transfer_restriction();
282 status = _bt_check_dpm_hsp_restriction();
285 status = _bt_check_dpm_a2dp_restriction();
288 status = _bt_check_dpm_avrcp_restriction();
291 status = _bt_check_dpm_spp_restriction();
295 BT_ERR("Unknown service");
299 if (status == BT_DPM_RESTRICTED)
300 BT_INFO("Service [%d], DPM permission denied", service);
301 else if (status == BT_DPM_NO_SERVICE)
302 BT_DBG("DPM no service [%d]",status);
307 BT_EXPORT_API int bluetooth_dpm_set_allow_mode(bt_dpm_allow_t value)
309 int result = BLUETOOTH_DPM_RESULT_SUCCESS;
310 #ifdef TIZEN_DPM_VCONF_ENABLE
314 #ifdef TIZEN_DPM_VCONF_ENABLE
315 if (vconf_get_int(VCONFKEY_BT_STATUS, &bt_status) < 0) {
316 BT_ERR("Error in reading VCONFKEY_BT_STATUS");
319 if (bt_status == VCONFKEY_BT_STATUS_ON) {
320 if (vconf_set_int(VCONFKEY_BT_DPM_STATUS, value) != 0) {
321 BT_ERR("Set VCONFKEY_BT_DPM_STATUS failed\n");
322 result = BLUETOOTH_DPM_RESULT_FAIL;
324 result = BLUETOOTH_DPM_RESULT_SUCCESS;
327 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
329 g_array_append_vals(in_param1, &value, sizeof(int));
331 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_ALLOW_BT_MODE,
332 in_param1, in_param2, in_param3, in_param4, &out_param);
334 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
336 if (result == BLUETOOTH_DPM_RESULT_SUCCESS &&
337 value == BLUETOOTH_DPM_BT_RESTRICTED) {
338 result = bluetooth_disable_adapter();
341 if (value >= BLUETOOTH_DPM_BT_ALLOWED &&
342 value <= BLUETOOTH_DPM_BT_RESTRICTED) {
343 if (vconf_set_int(VCONFKEY_BT_DPM_STATUS, value) != 0) {
344 BT_ERR("Set VCONFKEY_BT_DPM_STATUS failed\n");
345 result = BLUETOOTH_DPM_RESULT_FAIL;
347 result = BLUETOOTH_DPM_RESULT_SUCCESS;
349 result = BLUETOOTH_DPM_RESULT_INVALID_PARAM;
353 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
355 g_array_append_vals(in_param1, &value, sizeof(int));
357 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_ALLOW_BT_MODE,
358 in_param1, in_param2, in_param3, in_param4, &out_param);
360 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
367 BT_EXPORT_API int bluetooth_dpm_get_allow_mode(bt_dpm_allow_t *value)
371 #ifdef TIZEN_DPM_VCONF_ENABLE
372 *value = bluetooth_dpm_is_mode_allowed();
373 return BLUETOOTH_DPM_RESULT_SUCCESS;
375 BT_CHECK_ENABLED_ANY(return);
378 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
380 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_ALLOW_BT_MODE,
381 in_param1, in_param2, in_param3, in_param4, &out_param);
383 if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
384 if (out_param->len > 0) {
385 *value = g_array_index(out_param,
388 BT_ERR("out_param length is 0!!");
392 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
399 BT_EXPORT_API int bluetooth_dpm_activate_device_restriction(bt_dpm_status_t value)
403 BT_CHECK_ENABLED_ANY(return);
406 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
408 g_array_append_vals(in_param1, &value, sizeof(int));
410 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_DEVICE_RESTRITION,
411 in_param1, in_param2, in_param3, in_param4, &out_param);
413 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
419 BT_EXPORT_API int bluetooth_dpm_is_device_restriction_active(bt_dpm_status_t *value)
423 BT_CHECK_ENABLED_ANY(return);
426 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
428 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DEVICE_RESTRITION,
429 in_param1, in_param2, in_param3, in_param4, &out_param);
431 if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
432 if (out_param->len > 0) {
433 *value = g_array_index(out_param,
436 BT_ERR("out_param length is 0!!");
440 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
446 BT_EXPORT_API int bluetooth_dpm_activate_uuid_restriction(bt_dpm_status_t value)
450 BT_CHECK_ENABLED_ANY(return);
453 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
455 g_array_append_vals(in_param1, &value, sizeof(int));
457 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_UUID_RESTRITION,
458 in_param1, in_param2, in_param3, in_param4, &out_param);
460 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
466 BT_EXPORT_API int bluetooth_dpm_is_uuid_restriction_active(bt_dpm_status_t *value)
470 BT_CHECK_ENABLED_ANY(return);
473 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
475 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_UUID_RESTRITION,
476 in_param1, in_param2, in_param3, in_param4, &out_param);
478 if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
479 if (out_param->len > 0) {
480 *value = g_array_index(out_param,
483 BT_ERR("out_param length is 0!!");
487 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
494 BT_EXPORT_API int bluetooth_dpm_add_devices_to_blacklist(const bluetooth_device_address_t *device_address)
498 BT_CHECK_PARAMETER(device_address, return);
499 BT_CHECK_ENABLED_ANY(return);
502 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
504 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
507 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_ADD_DEVICES_BLACKLIST,
508 in_param1, in_param2, in_param3, in_param4, &out_param);
510 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
516 BT_EXPORT_API int bluetooth_dpm_add_devices_to_whitelist(const bluetooth_device_address_t *device_address)
520 BT_CHECK_PARAMETER(device_address, return);
521 BT_CHECK_ENABLED_ANY(return);
524 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
526 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
528 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_ADD_DEVICES_WHITELIST,
529 in_param1, in_param2, in_param3, in_param4, &out_param);
531 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
538 BT_EXPORT_API int bluetooth_dpm_add_uuids_to_blacklist(const char *service_uuid)
541 char uuid[BLUETOOTH_UUID_STRING_MAX];
543 BT_CHECK_PARAMETER(service_uuid, return);
544 BT_CHECK_ENABLED_ANY(return);
548 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
550 g_strlcpy(uuid, service_uuid, sizeof(uuid));
551 g_array_append_vals(in_param1, uuid, BLUETOOTH_UUID_STRING_MAX);
553 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_ADD_UUIDS_BLACKLIST,
554 in_param1, in_param2, in_param3, in_param4, &out_param);
556 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
563 BT_EXPORT_API int bluetooth_dpm_add_uuids_to_whitelist(const char *service_uuid)
566 char uuid[BLUETOOTH_UUID_STRING_MAX];
568 BT_CHECK_PARAMETER(service_uuid, return);
569 BT_CHECK_ENABLED_ANY(return);
572 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
574 g_strlcpy(uuid, service_uuid, sizeof(uuid));
575 g_array_append_vals(in_param1, uuid, BLUETOOTH_UUID_STRING_MAX);
577 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_ADD_UUIDS_WHITELIST,
578 in_param1, in_param2, in_param3, in_param4, &out_param);
580 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
586 BT_EXPORT_API int bluetooth_dpm_clear_devices_from_blacklist(void)
590 BT_CHECK_ENABLED_ANY(return);
593 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
595 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_CLEAR_DEVICES_BLACKLIST,
596 in_param1, in_param2, in_param3, in_param4, &out_param);
598 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
604 BT_EXPORT_API int bluetooth_dpm_clear_devices_from_whitelist(void)
608 BT_CHECK_ENABLED_ANY(return);
611 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
613 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_CLEAR_DEVICES_WHITELIST,
614 in_param1, in_param2, in_param3, in_param4, &out_param);
616 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
622 BT_EXPORT_API int bluetooth_dpm_clear_uuids_from_blacklist(void)
626 BT_CHECK_ENABLED_ANY(return);
629 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
631 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_CLEAR_UUIDS_BLACKLIST,
632 in_param1, in_param2, in_param3, in_param4, &out_param);
634 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
640 BT_EXPORT_API int bluetooth_dpm_clear_uuids_from_whitelist(void)
644 BT_CHECK_ENABLED_ANY(return);
647 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
649 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_CLEAR_UUIDS_WHITELIST,
650 in_param1, in_param2, in_param3, in_param4, &out_param);
652 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
658 static void _bluetooth_extract_dpm_device_info(int count,
659 bt_dpm_device_list_t *dst_info,
660 bt_dpm_device_list_t *src_info)
664 for (i = 0; i < count; i++) {
665 memset(dst_info->addresses[i].addr, 0,
666 BT_ADDRESS_STRING_SIZE);
668 g_strlcpy((gchar *)dst_info->addresses[i].addr, (gchar *)src_info->addresses[i].addr,
669 BT_ADDRESS_STRING_SIZE);
671 // BT_DBG("address[%d] : %s", i, dst_info->addresses[i].addr);
675 static void _bluetooth_extract_dpm_uuid_info(int count,
676 bt_dpm_uuids_list_t *dst_info,
677 bt_dpm_uuids_list_t *src_info)
681 for (i = 0; i < count; i++) {
682 memset(dst_info->uuids[i], 0,
683 BLUETOOTH_UUID_STRING_MAX);
685 g_strlcpy(dst_info->uuids[i], src_info->uuids[i],
686 BLUETOOTH_UUID_STRING_MAX);
688 BT_DBG("uuids[%d] : %s", i, dst_info->uuids[i]);
692 BT_EXPORT_API int bluetooth_dpm_get_devices_from_blacklist(bt_dpm_device_list_t *device_list)
695 bt_dpm_device_list_t *devices = NULL;
697 BT_CHECK_ENABLED_ANY(return);
700 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
702 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DEVICES_BLACKLIST,
703 in_param1, in_param2, in_param3, in_param4, &out_param);
705 if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
706 devices = &g_array_index(out_param, bt_dpm_device_list_t, 0);
707 BT_DBG("device_list->count : %d", devices->count);
709 if (devices->count == 0) {
710 BT_ERR("device_list->count is zero !");
711 return BLUETOOTH_DPM_RESULT_FAIL;
714 device_list->count = devices->count;
716 _bluetooth_extract_dpm_device_info(devices->count,
717 device_list, devices);
719 BT_ERR("Get Devices list Failed");
722 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
727 BT_EXPORT_API int bluetooth_dpm_get_devices_from_whitelist(bt_dpm_device_list_t *device_list)
730 bt_dpm_device_list_t *devices = NULL;
732 BT_CHECK_ENABLED_ANY(return);
735 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
737 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DEVICES_WHITELIST,
738 in_param1, in_param2, in_param3, in_param4, &out_param);
740 if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
741 devices = &g_array_index(out_param, bt_dpm_device_list_t, 0);
742 BT_DBG("device_list->count : %d", devices->count);
744 if (devices->count == 0) {
745 BT_ERR("device_list->count is zero !");
746 return BLUETOOTH_DPM_RESULT_FAIL;
749 device_list->count = devices->count;
751 _bluetooth_extract_dpm_device_info(devices->count,
752 device_list, devices);
755 BT_ERR("Get Devices list Failed");
757 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
762 BT_EXPORT_API int bluetooth_dpm_get_uuids_from_blacklist(bt_dpm_uuids_list_t *uuid_list)
765 bt_dpm_uuids_list_t *uuids;
767 BT_CHECK_ENABLED_ANY(return);
770 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
772 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_UUIDS_BLACKLIST,
773 in_param1, in_param2, in_param3, in_param4, &out_param);
775 if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
776 uuids = &g_array_index(out_param, bt_dpm_uuids_list_t, 0);
777 BT_DBG("uuids->count : %d", uuids->count);
779 if (uuids->count == 0) {
780 BT_ERR("uuids->count is zero !");
781 return BLUETOOTH_DPM_RESULT_FAIL;
784 uuid_list->count = uuids->count;
785 _bluetooth_extract_dpm_uuid_info(uuids->count,
788 BT_ERR("Get UUIDS list Failed");
791 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
796 BT_EXPORT_API int bluetooth_dpm_get_uuids_from_whitelist(bt_dpm_uuids_list_t *uuid_list)
799 bt_dpm_uuids_list_t *uuids;
801 BT_CHECK_ENABLED_ANY(return);
804 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
806 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_UUIDS_WHITELIST,
807 in_param1, in_param2, in_param3, in_param4, &out_param);
809 if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
810 uuids = &g_array_index(out_param, bt_dpm_uuids_list_t, 0);
811 BT_DBG("uuids->count : %d", uuids->count);
813 if (uuids->count == 0) {
814 BT_ERR("uuids->count is zero !");
815 return BLUETOOTH_DPM_RESULT_FAIL;
818 uuid_list->count = uuids->count;
820 _bluetooth_extract_dpm_uuid_info(uuids->count,
823 BT_ERR("Get UUIDS list Failed");
826 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
831 BT_EXPORT_API int bluetooth_dpm_remove_device_from_whitelist(const bluetooth_device_address_t *device_address)
835 BT_CHECK_PARAMETER(device_address, return);
836 BT_CHECK_ENABLED_ANY(return);
839 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
841 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
843 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_REMOVE_DEVICE_WHITELIST,
844 in_param1, in_param2, in_param3, in_param4, &out_param);
846 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
851 BT_EXPORT_API int bluetooth_dpm_remove_device_from_blacklist(const bluetooth_device_address_t *device_address)
855 BT_CHECK_PARAMETER(device_address, return);
856 BT_CHECK_ENABLED_ANY(return);
859 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
861 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
863 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_REMOVE_DEVICE_BLACKLIST,
864 in_param1, in_param2, in_param3, in_param4, &out_param);
866 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
871 BT_EXPORT_API int bluetooth_dpm_remove_uuid_from_whitelist(const char *service_uuid)
874 char uuid[BLUETOOTH_UUID_STRING_MAX];
876 BT_CHECK_PARAMETER(service_uuid, return);
877 BT_CHECK_ENABLED_ANY(return);
880 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
882 g_strlcpy(uuid, service_uuid, sizeof(uuid));
883 g_array_append_vals(in_param1, uuid, BLUETOOTH_UUID_STRING_MAX);
885 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_REMOVE_UUID_WHITELIST,
886 in_param1, in_param2, in_param3, in_param4, &out_param);
888 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
893 BT_EXPORT_API int bluetooth_dpm_remove_uuid_from_blacklist(const char *service_uuid)
896 char uuid[BLUETOOTH_UUID_STRING_MAX];
898 BT_CHECK_PARAMETER(service_uuid, return);
899 BT_CHECK_ENABLED_ANY(return);
902 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
904 g_strlcpy(uuid, service_uuid, sizeof(uuid));
905 g_array_append_vals(in_param1, uuid, BLUETOOTH_UUID_STRING_MAX);
907 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_REMOVE_UUID_BLACKLIST,
908 in_param1, in_param2, in_param3, in_param4, &out_param);
910 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
916 BT_EXPORT_API int bluetooth_dpm_set_allow_outgoing_call(bt_dpm_status_t value)
920 BT_CHECK_ENABLED_ANY(return);
923 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
925 g_array_append_vals(in_param1, &value, sizeof(int));
927 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_ALLOW_OUTGOING_CALL,
928 in_param1, in_param2, in_param3, in_param4, &out_param);
930 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
935 BT_EXPORT_API int bluetooth_dpm_get_allow_outgoing_call(bt_dpm_status_t *value)
939 BT_CHECK_ENABLED_ANY(return);
942 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
944 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_ALLOW_OUTGOING_CALL,
945 in_param1, in_param2, in_param3, in_param4, &out_param);
947 if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
948 if (out_param->len > 0) {
949 *value = g_array_index(out_param,
952 BT_ERR("out_param length is 0!!");
956 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
961 BT_EXPORT_API int bluetooth_dpm_set_pairing_state(bt_dpm_status_t value)
965 BT_CHECK_ENABLED_ANY(return);
968 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
970 g_array_append_vals(in_param1, &value, sizeof(int));
972 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_PAIRING_STATE,
973 in_param1, in_param2, in_param3, in_param4, &out_param);
975 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
980 BT_EXPORT_API int bluetooth_dpm_get_pairing_state(bt_dpm_status_t *value)
984 BT_CHECK_ENABLED_ANY(return);
987 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
989 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_ALLOW_BT_MODE,
990 in_param1, in_param2, in_param3, in_param4, &out_param);
992 if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
993 if (out_param->len > 0) {
994 *value = g_array_index(out_param,
997 BT_ERR("out_param length is 0!!");
1001 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1006 BT_EXPORT_API int bluetooth_dpm_set_profile_state(bt_dpm_profile_t profile, bt_dpm_status_t value)
1010 BT_CHECK_ENABLED_ANY(return);
1013 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1015 g_array_append_vals(in_param1, &profile, sizeof(int));
1016 g_array_append_vals(in_param2, &value, sizeof(int));
1018 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_PROFILE_STATE,
1019 in_param1, in_param2, in_param3, in_param4, &out_param);
1021 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1026 BT_EXPORT_API int bluetooth_dpm_get_profile_state(bt_dpm_profile_t profile, bt_dpm_status_t *value)
1030 BT_CHECK_ENABLED_ANY(return);
1033 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1035 g_array_append_vals(in_param1, &profile, sizeof(int));
1037 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_PROFILE_STATE,
1038 in_param1, in_param2, in_param3, in_param4, &out_param);
1040 if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
1041 if (out_param->len > 0) {
1042 *value = g_array_index(out_param,
1045 BT_ERR("out_param length is 0!!");
1049 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1054 BT_EXPORT_API int bluetooth_dpm_set_desktop_connectivity_state(bt_dpm_status_t value)
1058 BT_CHECK_ENABLED_ANY(return);
1061 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1063 g_array_append_vals(in_param1, &value, sizeof(int));
1065 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_DESKROP_CONNECTIVITY_STATE,
1066 in_param1, in_param2, in_param3, in_param4, &out_param);
1068 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1073 BT_EXPORT_API int bluetooth_dpm_get_desktop_connectivity_state(bt_dpm_status_t *value)
1077 BT_CHECK_ENABLED_ANY(return);
1080 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1082 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DESKROP_CONNECTIVITY_STATE,
1083 in_param1, in_param2, in_param3, in_param4, &out_param);
1085 if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
1086 if (out_param->len > 0) {
1087 *value = g_array_index(out_param,
1090 BT_ERR("out_param length is 0!!");
1094 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1099 BT_EXPORT_API int bluetooth_dpm_set_discoverable_state(bt_dpm_status_t value)
1103 BT_CHECK_ENABLED_ANY(return);
1106 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1108 g_array_append_vals(in_param1, &value, sizeof(int));
1110 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_DISCOVERABLE_STATE,
1111 in_param1, in_param2, in_param3, in_param4, &out_param);
1113 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1118 BT_EXPORT_API int bluetooth_dpm_get_discoverable_state(bt_dpm_status_t *value)
1122 BT_CHECK_ENABLED_ANY(return);
1125 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1127 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DISCOVERABLE_STATE,
1128 in_param1, in_param2, in_param3, in_param4, &out_param);
1130 if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
1131 if (out_param->len > 0) {
1132 *value = g_array_index(out_param,
1135 BT_ERR("out_param length is 0!!");
1139 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1144 BT_EXPORT_API int bluetooth_dpm_set_limited_discoverable_state(bt_dpm_status_t value)
1148 BT_CHECK_ENABLED_ANY(return);
1151 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1153 g_array_append_vals(in_param1, &value, sizeof(int));
1155 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_LIMITED_DISCOVERABLE_STATE,
1156 in_param1, in_param2, in_param3, in_param4, &out_param);
1158 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1163 BT_EXPORT_API int bluetooth_dpm_get_limited_discoverable_state(bt_dpm_status_t *value)
1167 BT_CHECK_ENABLED_ANY(return);
1170 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1172 g_array_append_vals(in_param1, &value, sizeof(int));
1174 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_LIMITED_DISCOVERABLE_STATE,
1175 in_param1, in_param2, in_param3, in_param4, &out_param);
1177 if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
1178 if (out_param->len > 0) {
1179 *value = g_array_index(out_param,
1182 BT_ERR("out_param length is 0!!");
1186 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1191 BT_EXPORT_API int bluetooth_dpm_set_data_transfer_state(bt_dpm_status_t value)
1195 BT_CHECK_ENABLED_ANY(return);
1198 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1200 g_array_append_vals(in_param1, &value, sizeof(int));
1202 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_DATA_TRANSFER_STATE,
1203 in_param1, in_param2, in_param3, in_param4, &out_param);
1205 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1210 BT_EXPORT_API int bluetooth_dpm_get_data_transfer_state(bt_dpm_status_t *value)
1214 BT_CHECK_ENABLED_ANY(return);
1217 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1219 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DATA_TRANSFER_STATE,
1220 in_param1, in_param2, in_param3, in_param4, &out_param);
1222 if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
1223 if (out_param->len > 0) {
1224 *value = g_array_index(out_param,
1227 BT_ERR("out_param length is 0!!");
1231 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1235 #endif /* #ifdef TIZEN_DPM_ENABLE */