gatt client adaptation feature changes bt-api bt-service OAL
[platform/core/connectivity/bluetooth-frwk.git] / bt-api / bt-device.c
index 0d80b05..fff273a 100644 (file)
@@ -22,7 +22,7 @@
 #include "bt-request-sender.h"
 #include "bt-event-handler.h"
 
-#ifdef TIZEN_DPM_ENABLE
+#ifdef TIZEN_FEATURE_BT_DPM
 #include "bt-dpm.h"
 #endif
 
@@ -40,7 +40,7 @@ BT_EXPORT_API int bluetooth_bond_device(const bluetooth_device_address_t *device
                return BLUETOOTH_ERROR_PERMISSION_DEINED;
        }
 
-#ifdef TIZEN_DPM_ENABLE
+#ifdef TIZEN_FEATURE_BT_DPM
        if (_bt_check_dpm(BT_DPM_PAIRING, NULL) == BT_DPM_RESTRICTED) {
                        BT_ERR("Not allow to pair the device");
                        return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
@@ -182,6 +182,31 @@ BT_EXPORT_API int bluetooth_get_bonded_device(const bluetooth_device_address_t *
        return result;
 }
 
+BT_EXPORT_API int bluetooth_get_is_alias_set(const bluetooth_device_address_t *device_address,
+                               gboolean *is_alias_set)
+{
+       int result;
+
+       BT_CHECK_PARAMETER(device_address, return);
+       BT_CHECK_PARAMETER(is_alias_set, return);
+       BT_CHECK_ENABLED(return);
+
+       BT_INIT_PARAMS();
+       BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+       g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
+
+       result = _bt_send_request(BT_BLUEZ_SERVICE, BT_GET_IS_ALIAS_SET,
+               in_param1, in_param2, in_param3, in_param4, &out_param);
+
+       if (result == BLUETOOTH_ERROR_NONE)
+               *is_alias_set = g_array_index(out_param, gboolean, 0);
+
+       BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+       return result;
+}
+
 BT_EXPORT_API int bluetooth_get_remote_device(const bluetooth_device_address_t *device_address)
 {
        return BLUETOOTH_ERROR_NONE;
@@ -292,7 +317,7 @@ BT_EXPORT_API int bluetooth_is_device_connected(const bluetooth_device_address_t
        BT_CHECK_PARAMETER(is_connected, return);
        BT_CHECK_ENABLED(return);
 
-#ifdef RFCOMM_DIRECT
+#ifdef TIZEN_FEATURE_BT_RFCOMM_DIRECT
        if (type & BLUETOOTH_RFCOMM_SERVICE) {
                result = bluetooth_rfcomm_client_is_connected(device_address, is_connected);
                if (*is_connected == FALSE)
@@ -311,16 +336,20 @@ BT_EXPORT_API int bluetooth_is_device_connected(const bluetooth_device_address_t
        result = _bt_send_request(BT_BLUEZ_SERVICE, BT_IS_DEVICE_CONNECTED,
                in_param1, in_param2, in_param3, in_param4, &out_param);
 
-       if (result == BLUETOOTH_ERROR_NONE) {
+       if (result == BLUETOOTH_ERROR_NONE)
                *is_connected = g_array_index(out_param, gboolean, 0);
-       }
 
        BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
        return result;
 }
 
+#ifdef TIZEN_GATT_CLIENT
+BT_EXPORT_API int bluetooth_connect_le(const bluetooth_device_address_t *device_address,
+                                       gboolean auto_connect, int client_id)
+#else
 BT_EXPORT_API int bluetooth_connect_le(const bluetooth_device_address_t *device_address, gboolean auto_connect)
+#endif
 {
        int result;
        bt_user_info_t *user_info;
@@ -340,6 +369,10 @@ BT_EXPORT_API int bluetooth_connect_le(const bluetooth_device_address_t *device_
        g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
        g_array_append_vals(in_param2, &auto_connect, sizeof(gboolean));
 
+#ifdef TIZEN_GATT_CLIENT
+       g_array_append_vals(in_param3, &client_id, sizeof(int));
+#endif
+
        user_info = _bt_get_user_data(BT_COMMON);
        retv_if(user_info == NULL, BLUETOOTH_ERROR_INTERNAL);
 
@@ -353,7 +386,12 @@ BT_EXPORT_API int bluetooth_connect_le(const bluetooth_device_address_t *device_
        return result;
 }
 
+#ifdef TIZEN_GATT_CLIENT
+BT_EXPORT_API int bluetooth_disconnect_le(const bluetooth_device_address_t *device_address,
+               int client_id)
+#else
 BT_EXPORT_API int bluetooth_disconnect_le(const bluetooth_device_address_t *device_address)
+#endif
 {
        int result;
        bt_user_info_t *user_info;
@@ -362,7 +400,7 @@ BT_EXPORT_API int bluetooth_disconnect_le(const bluetooth_device_address_t *devi
        BT_CHECK_ENABLED_ANY(return);
 
        if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_DISCONNECT_LE)
-            == BLUETOOTH_ERROR_PERMISSION_DEINED) {
+                       == BLUETOOTH_ERROR_PERMISSION_DEINED) {
                BT_ERR("Don't have a privilege to use this API");
                return BLUETOOTH_ERROR_PERMISSION_DEINED;
        }
@@ -371,6 +409,10 @@ BT_EXPORT_API int bluetooth_disconnect_le(const bluetooth_device_address_t *devi
        BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
        g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
+#ifdef TIZEN_GATT_CLIENT
+       BT_INFO("Send GATT disconnect using Client Interface [%d]", client_id);
+       g_array_append_vals(in_param2, &client_id, sizeof(int));
+#endif
        user_info = _bt_get_user_data(BT_COMMON);
        retv_if(user_info == NULL, BLUETOOTH_ERROR_INTERNAL);
 
@@ -476,9 +518,8 @@ BT_EXPORT_API int bluetooth_get_connected_link_type(
        result = _bt_send_request(BT_BLUEZ_SERVICE, BT_GET_CONNECTED_LINK_TYPE,
                        in_param1, in_param2, in_param3, in_param4, &out_param);
 
-       if (result == BLUETOOTH_ERROR_NONE) {
+       if (result == BLUETOOTH_ERROR_NONE)
                *connected = g_array_index(out_param, guint, 0);
-       }
 
        BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
@@ -606,9 +647,8 @@ BT_EXPORT_API int bluetooth_get_att_mtu(const bluetooth_device_address_t *device
        result = _bt_send_request(BT_BLUEZ_SERVICE, BT_GET_ATT_MTU,
                in_param1, in_param2, in_param3, in_param4, &out_param);
 
-       if (result == BLUETOOTH_ERROR_NONE) {
+       if (result == BLUETOOTH_ERROR_NONE)
                *mtu = g_array_index(out_param, unsigned int, 0);
-       }
 
        BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
@@ -680,9 +720,8 @@ BT_EXPORT_API int bluetooth_set_profile_trusted(
        result = _bt_send_request(BT_BLUEZ_SERVICE, BT_SET_PROFILE_TRUSTED,
                        in_param1, in_param2, in_param3, in_param4, &out_param);
 
-       if (result == BLUETOOTH_ERROR_NONE) {
+       if (result == BLUETOOTH_ERROR_NONE)
                BT_DBG("SUCCESSFUL");
-       }
 
        BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
@@ -718,63 +757,6 @@ BT_EXPORT_API int bluetooth_get_profile_trusted(
        return result;
 }
 
-BT_EXPORT_API int bluetooth_set_profile_restricted(
-               const bluetooth_device_address_t *device_address,
-               int profile, int restricted)
-{
-       int result;
-
-       BT_CHECK_PARAMETER(device_address, return);
-       BT_CHECK_ENABLED(return);
-
-       BT_INIT_PARAMS();
-       BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
-
-       g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
-       g_array_append_vals(in_param2, &profile, sizeof(int));
-       g_array_append_vals(in_param3, &restricted, sizeof(int));
-
-       result = _bt_send_request(BT_BLUEZ_SERVICE, BT_SET_PROFILE_RESTRICTED,
-                       in_param1, in_param2, in_param3, in_param4, &out_param);
-
-       if (result == BLUETOOTH_ERROR_NONE) {
-               BT_DBG("SUCCESSFUL");
-       }
-
-       BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
-
-       return result;
-}
-
-BT_EXPORT_API int bluetooth_get_profile_restricted(
-               const bluetooth_device_address_t *device_address,
-               int profile, int *restricted)
-{
-       int result;
-       int restrict_profile = 0;
-       BT_CHECK_PARAMETER(device_address, return);
-       BT_CHECK_ENABLED(return);
-
-       BT_INIT_PARAMS();
-       BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
-
-       g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
-       g_array_append_vals(in_param2, &profile, sizeof(int));
-
-       result = _bt_send_request(BT_BLUEZ_SERVICE, BT_GET_PROFILE_RESTRICTED,
-                       in_param1, in_param2, in_param3, in_param4, &out_param);
-
-       if (result == BLUETOOTH_ERROR_NONE) {
-               restrict_profile = g_array_index(out_param, guint, 0);
-               BT_DBG("SUCCESSFUL");
-       }
-       BT_DBG("Restricted %d", restrict_profile);
-       *restricted = restrict_profile;
-       BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
-
-       return result;
-}
-
 BT_EXPORT_API int bluetooth_passkey_reply(char *passkey, gboolean reply)
 {
        int result;