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);
157 /* TODO: MAP? see above */
159 /* ++ check MDM profile restriction ++ */
160 if (g_strcmp0(BT_A2DP_UUID, uuid) == 0)
161 dpm_profile = BLUETOOTH_DPM_POLICY_A2DP_PROFILE_STATE;
162 else if (g_strcmp0(BT_AVRCP_TARGET_UUID, uuid) == 0)
163 dpm_profile = BLUETOOTH_DPM_POLICY_AVRCP_PROFILE_STATE;
164 else if (g_strcmp0(BT_HFP_AUDIO_GATEWAY_UUID, uuid) == 0)
165 dpm_profile = BLUETOOTH_DPM_POLICY_HFP_PROFILE_STATE;
166 else if (g_strcmp0(BT_HSP_AUDIO_GATEWAY_UUID, uuid) == 0)
167 dpm_profile = BLUETOOTH_DPM_POLICY_HSP_PROFILE_STATE;
168 else if (g_strcmp0(BT_OBEX_PSE_UUID, uuid) == 0)
169 dpm_profile = BLUETOOTH_DPM_POLICY_PBAP_PROFILE_STATE;
171 if (dpm_profile != BLUETOOTH_DPM_PROFILE_NONE) {
172 ret = bluetooth_dpm_get_profile_state(dpm_profile, &dpm_status);
173 return (dpm_status == BLUETOOTH_DPM_RESTRICTED ? BT_DPM_RESTRICTED : BT_DPM_ALLOWED);
175 /* -- check DPM profile restriction -- */
177 return bt_dpm_status;
180 static bt_dpm_status_e _bt_check_dpm_transfer_restriction(void)
182 bt_dpm_status_e dpm_status = BT_DPM_ALLOWED;
183 bt_dpm_status_t dpm_value = BLUETOOTH_DPM_ALLOWED;
185 dpm_status = _bt_check_dpm_blacklist_uuid(BT_OPP_UUID);
186 /* TODO: MAP? see above */
188 if (dpm_status == BT_DPM_NO_SERVICE || dpm_status == BT_DPM_RESTRICTED)
191 bluetooth_dpm_get_data_transfer_state(&dpm_value);
193 return (dpm_value == BLUETOOTH_DPM_RESTRICTED ? BT_DPM_RESTRICTED : BT_DPM_ALLOWED);
196 static bt_dpm_status_e _bt_check_dpm_hsp_restriction(void)
198 bt_dpm_status_e dpm_status = BT_DPM_ALLOWED;
200 dpm_status = _bt_check_dpm_blacklist_uuid(BT_HFP_AUDIO_GATEWAY_UUID);
202 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)
224 static bt_dpm_status_e _bt_check_dpm_avrcp_restriction(void)
226 bt_dpm_status_e dpm_status = BT_DPM_ALLOWED;
228 dpm_status = _bt_check_dpm_blacklist_uuid(BT_AVRCP_TARGET_UUID);
230 if (dpm_status == BT_DPM_NO_SERVICE || dpm_status == BT_DPM_RESTRICTED)
236 static bt_dpm_status_e _bt_check_dpm_spp_restriction(void)
238 bt_dpm_status_e dpm_status = BT_DPM_ALLOWED;
240 dpm_status = _bt_check_dpm_blacklist_uuid(BT_SPP_UUID);
242 if (dpm_status == BT_DPM_NO_SERVICE || dpm_status == BT_DPM_RESTRICTED)
248 int _bt_check_dpm(int service, void *param)
250 bt_dpm_status_e status = BT_DPM_ALLOWED;
251 BT_CHECK_ENABLED_ANY(return);
255 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();
276 /* TODO: MAP? see above */
278 status = _bt_check_dpm_hsp_restriction();
281 status = _bt_check_dpm_a2dp_restriction();
284 status = _bt_check_dpm_avrcp_restriction();
287 status = _bt_check_dpm_spp_restriction();
290 BT_ERR("Unknown service");
297 BT_EXPORT_API int bluetooth_dpm_set_allow_mode(bt_dpm_allow_t value)
299 int result = BLUETOOTH_ERROR_NONE;
300 #ifdef TIZEN_FEATURE_BT_DPM
304 #ifdef TIZEN_FEATURE_BT_DPM
305 if (value >= BLUETOOTH_DPM_BT_ALLOWED &&
306 value <= BLUETOOTH_DPM_BT_RESTRICTED) {
307 if (vconf_set_int(VCONFKEY_BT_DPM_STATUS, value) != 0) {
308 BT_ERR("Set VCONFKEY_BT_DPM_STATUS failed\n");
309 result = BLUETOOTH_ERROR_INTERNAL;
311 result = BLUETOOTH_ERROR_NONE;
313 result = BLUETOOTH_ERROR_INVALID_PARAM;
315 if (vconf_get_int(VCONFKEY_BT_STATUS, &bt_status) < 0)
316 BT_ERR("Error in reading VCONFKEY_BT_STATUS");
318 if (bt_status == VCONFKEY_BT_STATUS_ON) {
320 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
322 g_array_append_vals(in_param1, &value, sizeof(int));
324 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_ALLOW_BT_MODE,
325 in_param1, in_param2, in_param3, in_param4, &out_param);
327 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
329 if (result == BLUETOOTH_ERROR_NONE &&
330 value == BLUETOOTH_DPM_BT_RESTRICTED) {
331 result = bluetooth_disable_adapter();
336 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
338 g_array_append_vals(in_param1, &value, sizeof(int));
340 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_ALLOW_BT_MODE,
341 in_param1, in_param2, in_param3, in_param4, &out_param);
343 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
350 BT_EXPORT_API int bluetooth_dpm_get_allow_mode(bt_dpm_allow_t *value)
354 #ifdef TIZEN_FEATURE_BT_DPM
355 if (vconf_get_int(VCONFKEY_BT_DPM_STATUS, value) != 0) {
356 BT_ERR("fail to get vconf key!");
357 return BLUETOOTH_ERROR_INTERNAL;
359 result = BLUETOOTH_ERROR_NONE;
361 BT_CHECK_ENABLED_ANY(return);
364 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
366 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_ALLOW_BT_MODE,
367 in_param1, in_param2, in_param3, in_param4, &out_param);
369 if (result == BLUETOOTH_ERROR_NONE) {
370 if (out_param->len > 0) {
371 *value = g_array_index(out_param,
374 BT_ERR("out_param length is 0!!");
378 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
385 BT_EXPORT_API int bluetooth_dpm_activate_device_restriction(bt_dpm_status_t value)
389 BT_CHECK_ENABLED_ANY(return);
392 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
394 g_array_append_vals(in_param1, &value, sizeof(int));
396 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_DEVICE_RESTRITION,
397 in_param1, in_param2, in_param3, in_param4, &out_param);
399 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
405 BT_EXPORT_API int bluetooth_dpm_is_device_restriction_active(bt_dpm_status_t *value)
409 BT_CHECK_ENABLED_ANY(return);
412 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
414 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DEVICE_RESTRITION,
415 in_param1, in_param2, in_param3, in_param4, &out_param);
417 if (result == BLUETOOTH_ERROR_NONE) {
418 if (out_param->len > 0) {
419 *value = g_array_index(out_param,
422 BT_ERR("out_param length is 0!!");
426 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
432 BT_EXPORT_API int bluetooth_dpm_activate_uuid_restriction(bt_dpm_status_t value)
436 BT_CHECK_ENABLED_ANY(return);
439 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
441 g_array_append_vals(in_param1, &value, sizeof(int));
443 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_UUID_RESTRITION,
444 in_param1, in_param2, in_param3, in_param4, &out_param);
446 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
452 BT_EXPORT_API int bluetooth_dpm_is_uuid_restriction_active(bt_dpm_status_t *value)
456 BT_CHECK_ENABLED_ANY(return);
459 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
461 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_UUID_RESTRITION,
462 in_param1, in_param2, in_param3, in_param4, &out_param);
464 if (result == BLUETOOTH_ERROR_NONE) {
465 if (out_param->len > 0) {
466 *value = g_array_index(out_param,
469 BT_ERR("out_param length is 0!!");
473 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
480 BT_EXPORT_API int bluetooth_dpm_add_devices_to_blacklist(const bluetooth_device_address_t *device_address)
484 BT_CHECK_PARAMETER(device_address, return);
485 BT_CHECK_ENABLED_ANY(return);
488 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
490 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
493 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_ADD_DEVICES_BLACKLIST,
494 in_param1, in_param2, in_param3, in_param4, &out_param);
496 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
502 BT_EXPORT_API int bluetooth_dpm_add_devices_to_whitelist(const bluetooth_device_address_t *device_address)
506 BT_CHECK_PARAMETER(device_address, return);
507 BT_CHECK_ENABLED_ANY(return);
510 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
512 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
514 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_ADD_DEVICES_WHITELIST,
515 in_param1, in_param2, in_param3, in_param4, &out_param);
517 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
524 BT_EXPORT_API int bluetooth_dpm_add_uuids_to_blacklist(const char *service_uuid)
527 char uuid[BLUETOOTH_UUID_STRING_MAX];
529 BT_CHECK_PARAMETER(service_uuid, return);
530 BT_CHECK_ENABLED_ANY(return);
534 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
536 g_strlcpy(uuid, service_uuid, sizeof(uuid));
537 g_array_append_vals(in_param1, uuid, BLUETOOTH_UUID_STRING_MAX);
539 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_ADD_UUIDS_BLACKLIST,
540 in_param1, in_param2, in_param3, in_param4, &out_param);
542 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
549 BT_EXPORT_API int bluetooth_dpm_add_uuids_to_whitelist(const char *service_uuid)
552 char uuid[BLUETOOTH_UUID_STRING_MAX];
554 BT_CHECK_PARAMETER(service_uuid, return);
555 BT_CHECK_ENABLED_ANY(return);
558 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
560 g_strlcpy(uuid, service_uuid, sizeof(uuid));
561 g_array_append_vals(in_param1, uuid, BLUETOOTH_UUID_STRING_MAX);
563 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_ADD_UUIDS_WHITELIST,
564 in_param1, in_param2, in_param3, in_param4, &out_param);
566 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
572 BT_EXPORT_API int bluetooth_dpm_clear_devices_from_blacklist(void)
576 BT_CHECK_ENABLED_ANY(return);
579 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
581 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_CLEAR_DEVICES_BLACKLIST,
582 in_param1, in_param2, in_param3, in_param4, &out_param);
584 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
590 BT_EXPORT_API int bluetooth_dpm_clear_devices_from_whitelist(void)
594 BT_CHECK_ENABLED_ANY(return);
597 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
599 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_CLEAR_DEVICES_WHITELIST,
600 in_param1, in_param2, in_param3, in_param4, &out_param);
602 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
608 BT_EXPORT_API int bluetooth_dpm_clear_uuids_from_blacklist(void)
612 BT_CHECK_ENABLED_ANY(return);
615 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
617 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_CLEAR_UUIDS_BLACKLIST,
618 in_param1, in_param2, in_param3, in_param4, &out_param);
620 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
626 BT_EXPORT_API int bluetooth_dpm_clear_uuids_from_whitelist(void)
630 BT_CHECK_ENABLED_ANY(return);
633 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
635 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_CLEAR_UUIDS_WHITELIST,
636 in_param1, in_param2, in_param3, in_param4, &out_param);
638 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
644 static void _bluetooth_extract_dpm_device_info(int count,
645 bt_dpm_device_list_t *dst_info,
646 bt_dpm_device_list_t *src_info)
650 for (i = 0; i < count; i++) {
651 memset(dst_info->addresses[i].addr, 0,
652 BLUETOOTH_ADDRESS_LENGTH);
654 g_strlcpy((gchar *)dst_info->addresses[i].addr, (gchar *)src_info->addresses[i].addr,
655 BLUETOOTH_ADDRESS_LENGTH);
657 // BT_DBG("address[%d] : %s", i, dst_info->addresses[i].addr);
661 static void _bluetooth_extract_dpm_uuid_info(int count,
662 bt_dpm_uuids_list_t *dst_info,
663 bt_dpm_uuids_list_t *src_info)
667 for (i = 0; i < count; i++) {
668 memset(dst_info->uuids[i], 0,
669 BLUETOOTH_UUID_STRING_MAX);
671 g_strlcpy(dst_info->uuids[i], src_info->uuids[i],
672 BLUETOOTH_UUID_STRING_MAX);
674 BT_DBG("uuids[%d] : %s", i, dst_info->uuids[i]);
678 BT_EXPORT_API int bluetooth_dpm_get_devices_from_blacklist(bt_dpm_device_list_t *device_list)
681 bt_dpm_device_list_t *devices = NULL;
683 BT_CHECK_ENABLED_ANY(return);
686 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
688 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DEVICES_BLACKLIST,
689 in_param1, in_param2, in_param3, in_param4, &out_param);
691 if (result == BLUETOOTH_ERROR_NONE) {
692 devices = &g_array_index(out_param, bt_dpm_device_list_t, 0);
693 BT_DBG("device_list->count : %d", devices->count);
695 if (devices->count == 0) {
696 BT_ERR("device_list->count is zero !");
697 result = BLUETOOTH_ERROR_NOT_FOUND;
700 device_list->count = devices->count;
702 _bluetooth_extract_dpm_device_info(devices->count,
703 device_list, devices);
705 BT_ERR("Get Devices list Failed");
708 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
713 BT_EXPORT_API int bluetooth_dpm_get_devices_from_whitelist(bt_dpm_device_list_t *device_list)
716 bt_dpm_device_list_t *devices = NULL;
718 BT_CHECK_ENABLED_ANY(return);
721 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
723 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DEVICES_WHITELIST,
724 in_param1, in_param2, in_param3, in_param4, &out_param);
726 if (result == BLUETOOTH_ERROR_NONE) {
727 devices = &g_array_index(out_param, bt_dpm_device_list_t, 0);
728 BT_DBG("device_list->count : %d", devices->count);
730 if (devices->count == 0) {
731 BT_ERR("device_list->count is zero !");
732 result = BLUETOOTH_ERROR_NOT_FOUND;
735 device_list->count = devices->count;
737 _bluetooth_extract_dpm_device_info(devices->count,
738 device_list, devices);
741 BT_ERR("Get Devices list Failed");
743 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
748 BT_EXPORT_API int bluetooth_dpm_get_uuids_from_blacklist(bt_dpm_uuids_list_t *uuid_list)
751 bt_dpm_uuids_list_t *uuids;
753 BT_CHECK_ENABLED_ANY(return);
756 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
758 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_UUIDS_BLACKLIST,
759 in_param1, in_param2, in_param3, in_param4, &out_param);
761 if (result == BLUETOOTH_ERROR_NONE) {
762 uuids = &g_array_index(out_param, bt_dpm_uuids_list_t, 0);
763 BT_DBG("uuids->count : %d", uuids->count);
765 if (uuids->count == 0) {
766 BT_ERR("uuids->count is zero !");
767 result = BLUETOOTH_ERROR_NOT_FOUND;
770 uuid_list->count = uuids->count;
771 _bluetooth_extract_dpm_uuid_info(uuids->count,
774 BT_ERR("Get UUIDS list Failed");
777 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
782 BT_EXPORT_API int bluetooth_dpm_get_uuids_from_whitelist(bt_dpm_uuids_list_t *uuid_list)
785 bt_dpm_uuids_list_t *uuids;
787 BT_CHECK_ENABLED_ANY(return);
790 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
792 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_UUIDS_WHITELIST,
793 in_param1, in_param2, in_param3, in_param4, &out_param);
795 if (result == BLUETOOTH_ERROR_NONE) {
796 uuids = &g_array_index(out_param, bt_dpm_uuids_list_t, 0);
797 BT_DBG("uuids->count : %d", uuids->count);
799 if (uuids->count == 0) {
800 BT_ERR("uuids->count is zero !");
801 result = BLUETOOTH_ERROR_NOT_FOUND;
804 uuid_list->count = uuids->count;
806 _bluetooth_extract_dpm_uuid_info(uuids->count,
809 BT_ERR("Get UUIDS list Failed");
812 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
817 BT_EXPORT_API int bluetooth_dpm_remove_device_from_whitelist(const bluetooth_device_address_t *device_address)
821 BT_CHECK_PARAMETER(device_address, return);
822 BT_CHECK_ENABLED_ANY(return);
825 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
827 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
829 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_REMOVE_DEVICE_WHITELIST,
830 in_param1, in_param2, in_param3, in_param4, &out_param);
832 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
837 BT_EXPORT_API int bluetooth_dpm_remove_device_from_blacklist(const bluetooth_device_address_t *device_address)
841 BT_CHECK_PARAMETER(device_address, return);
842 BT_CHECK_ENABLED_ANY(return);
845 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
847 g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
849 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_REMOVE_DEVICE_BLACKLIST,
850 in_param1, in_param2, in_param3, in_param4, &out_param);
852 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
857 BT_EXPORT_API int bluetooth_dpm_remove_uuid_from_whitelist(const char *service_uuid)
860 char uuid[BLUETOOTH_UUID_STRING_MAX];
862 BT_CHECK_PARAMETER(service_uuid, return);
863 BT_CHECK_ENABLED_ANY(return);
866 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
868 g_strlcpy(uuid, service_uuid, sizeof(uuid));
869 g_array_append_vals(in_param1, uuid, BLUETOOTH_UUID_STRING_MAX);
871 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_REMOVE_UUID_WHITELIST,
872 in_param1, in_param2, in_param3, in_param4, &out_param);
874 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
879 BT_EXPORT_API int bluetooth_dpm_remove_uuid_from_blacklist(const char *service_uuid)
882 char uuid[BLUETOOTH_UUID_STRING_MAX];
884 BT_CHECK_PARAMETER(service_uuid, return);
885 BT_CHECK_ENABLED_ANY(return);
888 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
890 g_strlcpy(uuid, service_uuid, sizeof(uuid));
891 g_array_append_vals(in_param1, uuid, BLUETOOTH_UUID_STRING_MAX);
893 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_REMOVE_UUID_BLACKLIST,
894 in_param1, in_param2, in_param3, in_param4, &out_param);
896 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
902 BT_EXPORT_API int bluetooth_dpm_set_allow_outgoing_call(bt_dpm_status_t value)
906 BT_CHECK_ENABLED_ANY(return);
909 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
911 g_array_append_vals(in_param1, &value, sizeof(int));
913 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_ALLOW_OUTGOING_CALL,
914 in_param1, in_param2, in_param3, in_param4, &out_param);
916 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
921 BT_EXPORT_API int bluetooth_dpm_get_allow_outgoing_call(bt_dpm_status_t *value)
925 BT_CHECK_ENABLED_ANY(return);
928 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
930 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_ALLOW_OUTGOING_CALL,
931 in_param1, in_param2, in_param3, in_param4, &out_param);
933 if (result == BLUETOOTH_ERROR_NONE) {
934 if (out_param->len > 0) {
935 *value = g_array_index(out_param,
938 BT_ERR("out_param length is 0!!");
942 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
947 BT_EXPORT_API int bluetooth_dpm_set_pairing_state(bt_dpm_status_t value)
951 BT_CHECK_ENABLED_ANY(return);
954 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
956 g_array_append_vals(in_param1, &value, sizeof(int));
958 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_PAIRING_STATE,
959 in_param1, in_param2, in_param3, in_param4, &out_param);
961 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
966 BT_EXPORT_API int bluetooth_dpm_get_pairing_state(bt_dpm_status_t *value)
970 BT_CHECK_ENABLED_ANY(return);
973 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
975 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_ALLOW_BT_MODE,
976 in_param1, in_param2, in_param3, in_param4, &out_param);
978 if (result == BLUETOOTH_ERROR_NONE) {
979 if (out_param->len > 0) {
980 *value = g_array_index(out_param,
983 BT_ERR("out_param length is 0!!");
987 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
992 BT_EXPORT_API int bluetooth_dpm_set_profile_state(bt_dpm_profile_t profile, bt_dpm_status_t value)
996 BT_CHECK_ENABLED_ANY(return);
999 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1001 g_array_append_vals(in_param1, &profile, sizeof(int));
1002 g_array_append_vals(in_param2, &value, sizeof(int));
1004 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_PROFILE_STATE,
1005 in_param1, in_param2, in_param3, in_param4, &out_param);
1007 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1012 BT_EXPORT_API int bluetooth_dpm_get_profile_state(bt_dpm_profile_t profile, bt_dpm_status_t *value)
1016 BT_CHECK_ENABLED_ANY(return);
1019 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1021 g_array_append_vals(in_param1, &profile, sizeof(int));
1023 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_PROFILE_STATE,
1024 in_param1, in_param2, in_param3, in_param4, &out_param);
1026 if (result == BLUETOOTH_ERROR_NONE) {
1027 if (out_param->len > 0) {
1028 *value = g_array_index(out_param,
1031 BT_ERR("out_param length is 0!!");
1035 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1040 BT_EXPORT_API int bluetooth_dpm_set_desktop_connectivity_state(bt_dpm_status_t value)
1044 BT_CHECK_ENABLED_ANY(return);
1047 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1049 g_array_append_vals(in_param1, &value, sizeof(int));
1051 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_DESKROP_CONNECTIVITY_STATE,
1052 in_param1, in_param2, in_param3, in_param4, &out_param);
1054 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1059 BT_EXPORT_API int bluetooth_dpm_get_desktop_connectivity_state(bt_dpm_status_t *value)
1063 BT_CHECK_ENABLED_ANY(return);
1066 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1068 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DESKROP_CONNECTIVITY_STATE,
1069 in_param1, in_param2, in_param3, in_param4, &out_param);
1071 if (result == BLUETOOTH_ERROR_NONE) {
1072 if (out_param->len > 0) {
1073 *value = g_array_index(out_param,
1076 BT_ERR("out_param length is 0!!");
1080 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1085 BT_EXPORT_API int bluetooth_dpm_set_discoverable_state(bt_dpm_status_t value)
1089 BT_CHECK_ENABLED_ANY(return);
1092 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1094 g_array_append_vals(in_param1, &value, sizeof(int));
1096 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_DISCOVERABLE_STATE,
1097 in_param1, in_param2, in_param3, in_param4, &out_param);
1099 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1104 BT_EXPORT_API int bluetooth_dpm_get_discoverable_state(bt_dpm_status_t *value)
1108 BT_CHECK_ENABLED_ANY(return);
1111 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1113 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DISCOVERABLE_STATE,
1114 in_param1, in_param2, in_param3, in_param4, &out_param);
1116 if (result == BLUETOOTH_ERROR_NONE) {
1117 if (out_param->len > 0) {
1118 *value = g_array_index(out_param,
1121 BT_ERR("out_param length is 0!!");
1125 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1130 BT_EXPORT_API int bluetooth_dpm_set_limited_discoverable_state(bt_dpm_status_t value)
1134 BT_CHECK_ENABLED_ANY(return);
1137 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1139 g_array_append_vals(in_param1, &value, sizeof(int));
1141 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_LIMITED_DISCOVERABLE_STATE,
1142 in_param1, in_param2, in_param3, in_param4, &out_param);
1144 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1149 BT_EXPORT_API int bluetooth_dpm_get_limited_discoverable_state(bt_dpm_status_t *value)
1153 BT_CHECK_ENABLED_ANY(return);
1156 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1158 g_array_append_vals(in_param1, &value, sizeof(int));
1160 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_LIMITED_DISCOVERABLE_STATE,
1161 in_param1, in_param2, in_param3, in_param4, &out_param);
1163 if (result == BLUETOOTH_ERROR_NONE) {
1164 if (out_param->len > 0) {
1165 *value = g_array_index(out_param,
1168 BT_ERR("out_param length is 0!!");
1172 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1177 BT_EXPORT_API int bluetooth_dpm_set_data_transfer_state(bt_dpm_status_t value)
1181 BT_CHECK_ENABLED_ANY(return);
1184 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1186 g_array_append_vals(in_param1, &value, sizeof(int));
1188 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_DATA_TRANSFER_STATE,
1189 in_param1, in_param2, in_param3, in_param4, &out_param);
1191 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1196 BT_EXPORT_API int bluetooth_dpm_get_data_transfer_state(bt_dpm_status_t *value)
1200 BT_CHECK_ENABLED_ANY(return);
1203 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1205 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DATA_TRANSFER_STATE,
1206 in_param1, in_param2, in_param3, in_param4, &out_param);
1208 if (result == BLUETOOTH_ERROR_NONE) {
1209 if (out_param->len > 0) {
1210 *value = g_array_index(out_param,
1213 BT_ERR("out_param length is 0!!");
1217 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1221 #endif /* #ifdef TIZEN_FEATURE_BT_DPM */