Add the audio connection storage
[apps/native/ug-bluetooth-efl.git] / src / ui / bt-profile-view.c
index 72dba6a..f5a92d5 100644 (file)
@@ -824,9 +824,11 @@ static void __bt_profile_media_option_checkbox_sel(void *data, Evas_Object *obj,
        if (dev->connected_mask & BT_STEREO_HEADSET_CONNECTED) {
                ret = __bt_profile_disconnect_option((bt_ug_data *)dev->ugd,
                                        dev, BT_STEREO_HEADSET_DEVICE);
+
        } else {
                ret = __bt_profile_connect_option((bt_ug_data *)dev->ugd,
                                        dev, BT_STEREO_HEADSET_DEVICE);
+
        }
 #endif
 
@@ -1043,20 +1045,31 @@ int __bt_profile_connect_option(bt_ug_data *ugd, bt_dev_t *dev,
        FN_START;
 
        int audio_profile;
+       int ret;
 
        retv_if(ugd == NULL, BT_UG_FAIL);
        retv_if(dev == NULL, BT_UG_FAIL);
 
        if (type == BT_HEADSET_DEVICE || type == BT_STEREO_HEADSET_DEVICE ||
                        type == BT_MUSIC_PLAYER_DEVICE) {
-               if (type == BT_STEREO_HEADSET_DEVICE)
+               if (type == BT_STEREO_HEADSET_DEVICE) {
                        audio_profile = BT_AUDIO_PROFILE_TYPE_A2DP;
+                       /* set restriction : allowed */
+                       ret = bt_device_set_profile_restricted(dev->addr_str, BT_RESTRICTED_PROFILE_A2DP, 0x0);
+                       if (ret != BT_ERROR_NONE)
+                               BT_ERR("Failed to set restriction");
+               }
 #ifdef TIZEN_BT_A2DP_SINK_ENABLE
                else if (type == BT_MUSIC_PLAYER_DEVICE)
                        audio_profile = BT_AUDIO_PROFILE_TYPE_A2DP_SINK;
 #endif
-               else
+               else {
+                       /* set restriction : allowed */
                        audio_profile = BT_AUDIO_PROFILE_TYPE_HSP_HFP;
+                       ret = bt_device_set_profile_restricted(dev->addr_str, BT_RESTRICTED_PROFILE_HFP_HS, 0x0);
+                       if (ret != BT_ERROR_NONE)
+                               BT_ERR("Failed to set restriction");
+               }
 
                if (bt_audio_connect(dev->addr_str,
                                audio_profile) != BT_ERROR_NONE) {
@@ -1128,6 +1141,7 @@ int __bt_profile_disconnect_option(bt_ug_data *ugd, bt_dev_t *dev,
        FN_START;
 
        int audio_profile;
+       int ret;
        bt_ug_ipc_param_t param;
        gboolean connected = FALSE;
        gboolean connected_nap_profile = FALSE;
@@ -1168,14 +1182,23 @@ int __bt_profile_disconnect_option(bt_ug_data *ugd, bt_dev_t *dev,
 
        if (type == BT_HEADSET_DEVICE || type == BT_STEREO_HEADSET_DEVICE ||
                        type == BT_MUSIC_PLAYER_DEVICE) {
-               if (type == BT_STEREO_HEADSET_DEVICE)
+               if (type == BT_STEREO_HEADSET_DEVICE) {
                        audio_profile = BT_AUDIO_PROFILE_TYPE_A2DP;
+                       ret = bt_device_set_profile_restricted(dev->addr_str, BT_RESTRICTED_PROFILE_A2DP, 0x1);
+                       if (ret != BT_ERROR_NONE)
+                               BT_ERR("Failed to set restriction");
+               }
 #ifdef TIZEN_BT_A2DP_SINK_ENABLE
                else if (type == BT_MUSIC_PLAYER_DEVICE)
                        audio_profile = BT_AUDIO_PROFILE_TYPE_A2DP_SINK;
 #endif
-               else
+               else {
                        audio_profile = BT_AUDIO_PROFILE_TYPE_HSP_HFP;
+                       ret = bt_device_set_profile_restricted(dev->addr_str, BT_RESTRICTED_PROFILE_HFP_HS, 0x1);
+                       if (ret != BT_ERROR_NONE)
+                               BT_ERR("Failed to set restriction");
+               }
+
 
                if (bt_audio_disconnect(dev->addr_str,
                                audio_profile) != BT_ERROR_NONE) {