DPM: Modify/Remove the DPM APIs and Expose DPM BT-APIs
[platform/core/connectivity/bluetooth-frwk.git] / bt-api / bt-adapter.c
old mode 100755 (executable)
new mode 100644 (file)
index 0a8b7df..2391393
@@ -1,11 +1,5 @@
 /*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
- *              Girishashok Joshi <girish.joshi@samsung.com>
- *              Chanyeol Park <chanyeol.park@samsung.com>
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -88,16 +82,26 @@ BT_EXPORT_API int bluetooth_check_adapter(void)
 BT_EXPORT_API int bluetooth_enable_adapter(void)
 {
        int result;
+       bt_user_info_t *user_info;
 
        BT_INFO("");
        retv_if(bluetooth_check_adapter() == BLUETOOTH_ADAPTER_ENABLED,
                                BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED);
 
+#ifdef TIZEN_DPM_VCONF_ENABLE
+       retv_if(bluetooth_dpm_is_bluetooth_mode_allowed() == BLUETOOTH_DPM_RESULT_ACCESS_DENIED,
+                               BLUETOOTH_ERROR_PERMISSION_DEINED);
+#endif
+
+       user_info = _bt_get_user_data(BT_COMMON);
+       retv_if(user_info->cb == NULL, BLUETOOTH_ERROR_INTERNAL);
+
        BT_INIT_PARAMS();
        BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
-       result = _bt_send_request(BT_BLUEZ_SERVICE, BT_ENABLE_ADAPTER,
-               in_param1, in_param2, in_param3, in_param4, &out_param);
+       result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_ENABLE_ADAPTER,
+               in_param1, in_param2, in_param3, in_param4,
+               user_info->cb, user_info->user_data);
 
        BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
@@ -107,15 +111,20 @@ BT_EXPORT_API int bluetooth_enable_adapter(void)
 BT_EXPORT_API int bluetooth_disable_adapter(void)
 {
        int result;
+       bt_user_info_t *user_info;
 
        BT_INFO("");
        BT_CHECK_ENABLED(return);
 
+       user_info = _bt_get_user_data(BT_COMMON);
+       retv_if(user_info->cb == NULL, BLUETOOTH_ERROR_INTERNAL);
+
        BT_INIT_PARAMS();
        BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
-       result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DISABLE_ADAPTER,
-               in_param1, in_param2, in_param3, in_param4, &out_param);
+       result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_DISABLE_ADAPTER,
+               in_param1, in_param2, in_param3, in_param4,
+               user_info->cb, user_info->user_data);
 
        BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
@@ -285,7 +294,7 @@ BT_EXPORT_API int bluetooth_get_discoverable_mode(bluetooth_discoverable_mode_t
        if (bluetooth_check_adapter() == BLUETOOTH_ADAPTER_DISABLED) {
                if (vconf_get_int(BT_FILE_VISIBLE_TIME, &timeout) != 0) {
                        BT_ERR("Fail to get the timeout value");
-                       return BLUETOOTH_ERROR_INTERNAL;
+                       return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
                }
 
                if (timeout == -1) {
@@ -296,6 +305,8 @@ BT_EXPORT_API int bluetooth_get_discoverable_mode(bluetooth_discoverable_mode_t
 
                return BLUETOOTH_ERROR_NONE;
        }
+#else
+       BT_CHECK_ENABLED(return);
 #endif
 
        BT_INIT_PARAMS();