Fix: glib error
[platform/core/connectivity/bluetooth-frwk.git] / bt-api / bt-dpm.c
index d0b6a91..3c78062 100644 (file)
@@ -33,12 +33,12 @@ BT_EXPORT_API int bluetooth_dpm_is_mode_allowed(void)
        /* check VCONFKEY_BT_STATUS */
        if (vconf_get_int(VCONFKEY_BT_DPM_STATUS, &value) != 0) {
                BT_ERR("fail to get vconf key!");
-               return BLUETOOTH_DPM_RESULT_FAIL;
+               return BLUETOOTH_ERROR_INTERNAL;
        }
        if (value != VCONFKEY_BT_DPM_STATUS_RESTRICTED)
-               return BLUETOOTH_DPM_RESULT_SUCCESS;
+               return BLUETOOTH_ERROR_NONE;
        else
-               return BLUETOOTH_DPM_RESULT_ACCESS_DENIED;
+               return BLUETOOTH_ERROR_PERMISSION_DEINED;
 }
 #endif
 
@@ -154,6 +154,7 @@ static bt_dpm_status_e _bt_check_dpm_blacklist_uuid(char *uuid)
                bluetooth_dpm_get_data_transfer_state(&dpm_status);
                return (dpm_status == BLUETOOTH_DPM_RESTRICTED ? BT_DPM_RESTRICTED : BT_DPM_ALLOWED);
        }
+       /* TODO: MAP? see above */
 
        /* ++ check MDM profile restriction ++ */
        if (g_strcmp0(BT_A2DP_UUID, uuid) == 0)
@@ -182,6 +183,7 @@ static bt_dpm_status_e _bt_check_dpm_transfer_restriction(void)
        bt_dpm_status_t dpm_value = BLUETOOTH_DPM_ALLOWED;
 
        dpm_status = _bt_check_dpm_blacklist_uuid(BT_OPP_UUID);
+       /* TODO: MAP? see above */
 
        if (dpm_status == BT_DPM_NO_SERVICE || dpm_status == BT_DPM_RESTRICTED)
                return dpm_status;
@@ -246,7 +248,7 @@ static bt_dpm_status_e _bt_check_dpm_spp_restriction(void)
 int _bt_check_dpm(int service, void *param)
 {
        bt_dpm_status_e status = BT_DPM_ALLOWED;
-
+       int ret = BLUETOOTH_ERROR_NONE;
        BT_CHECK_ENABLED_ANY(return);
 
        switch (service) {
@@ -273,6 +275,7 @@ int _bt_check_dpm(int service, void *param)
        case BT_DPM_OPP:
                status = _bt_check_dpm_transfer_restriction();
                break;
+       /* TODO: MAP? see above */
        case BT_DPM_HSP:
                status = _bt_check_dpm_hsp_restriction();
                break;
@@ -291,17 +294,20 @@ int _bt_check_dpm(int service, void *param)
                return status;
        }
 
-       if (status == BT_DPM_RESTRICTED)
+       if (status == BT_DPM_RESTRICTED) {
                BT_INFO("Service [%d], DPM permission denied", service);
-       else if (status == BT_DPM_NO_SERVICE)
+               ret = BLUETOOTH_ERROR_PERMISSION_DEINED;
+       } else if (status == BT_DPM_NO_SERVICE) {
                BT_DBG("DPM no service [%d]", status);
+               ret = BLUETOOTH_ERROR_SERVICE_NOT_FOUND;
+       }
 
-       return status;
+       return ret;
 }
 
 BT_EXPORT_API int bluetooth_dpm_set_allow_mode(bt_dpm_allow_t value)
 {
-       int result =  BLUETOOTH_DPM_RESULT_SUCCESS;
+       int result =  BLUETOOTH_ERROR_NONE;
 #ifdef TIZEN_FEATURE_BT_DPM
        int bt_status;
 #endif
@@ -313,10 +319,10 @@ BT_EXPORT_API int bluetooth_dpm_set_allow_mode(bt_dpm_allow_t value)
        if (bt_status == VCONFKEY_BT_STATUS_ON) {
                if (vconf_set_int(VCONFKEY_BT_DPM_STATUS, value) != 0) {
                        BT_ERR("Set VCONFKEY_BT_DPM_STATUS failed\n");
-                       result = BLUETOOTH_DPM_RESULT_FAIL;
+                       result = BLUETOOTH_ERROR_INTERNAL;
                } else {
                        BT_ERR("Set VCONFKEY_BT_DPM_STATUS success\n");
-                       result = BLUETOOTH_DPM_RESULT_SUCCESS;
+                       result = BLUETOOTH_ERROR_NONE;
                }
 
                BT_INIT_PARAMS();
@@ -329,7 +335,7 @@ BT_EXPORT_API int bluetooth_dpm_set_allow_mode(bt_dpm_allow_t value)
 
                BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
-               if (result == BLUETOOTH_DPM_RESULT_SUCCESS &&
+               if (result == BLUETOOTH_ERROR_NONE &&
                        value == BLUETOOTH_DPM_BT_RESTRICTED) {
                        result = bluetooth_disable_adapter();
                }
@@ -338,11 +344,11 @@ BT_EXPORT_API int bluetooth_dpm_set_allow_mode(bt_dpm_allow_t value)
                        value <= BLUETOOTH_DPM_BT_RESTRICTED) {
                        if (vconf_set_int(VCONFKEY_BT_DPM_STATUS, value) != 0) {
                                BT_ERR("Set VCONFKEY_BT_DPM_STATUS failed\n");
-                               result = BLUETOOTH_DPM_RESULT_FAIL;
+                               result = BLUETOOTH_ERROR_INTERNAL;
                        } else
-                               result = BLUETOOTH_DPM_RESULT_SUCCESS;
+                               result = BLUETOOTH_ERROR_NONE;
                } else
-                       result = BLUETOOTH_DPM_RESULT_INVALID_PARAM;
+                       result = BLUETOOTH_ERROR_INVALID_PARAM;
        }
 #else
        BT_INIT_PARAMS();
@@ -366,7 +372,7 @@ BT_EXPORT_API int bluetooth_dpm_get_allow_mode(bt_dpm_allow_t *value)
 
 #ifdef TIZEN_FEATURE_BT_DPM
        *value = bluetooth_dpm_is_mode_allowed();
-       return BLUETOOTH_DPM_RESULT_SUCCESS;
+       result = BLUETOOTH_ERROR_NONE;
 #else
        BT_CHECK_ENABLED_ANY(return);
 
@@ -376,7 +382,7 @@ BT_EXPORT_API int bluetooth_dpm_get_allow_mode(bt_dpm_allow_t *value)
        result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_ALLOW_BT_MODE,
                in_param1, in_param2, in_param3, in_param4, &out_param);
 
-       if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
+       if (result == BLUETOOTH_ERROR_NONE) {
                if (out_param->len > 0) {
                        *value = g_array_index(out_param,
                                        int, 0);
@@ -424,7 +430,7 @@ BT_EXPORT_API int bluetooth_dpm_is_device_restriction_active(bt_dpm_status_t *va
        result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DEVICE_RESTRITION,
                in_param1, in_param2, in_param3, in_param4, &out_param);
 
-       if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
+       if (result == BLUETOOTH_ERROR_NONE) {
                if (out_param->len > 0) {
                        *value = g_array_index(out_param,
                                        int, 0);
@@ -471,7 +477,7 @@ BT_EXPORT_API int bluetooth_dpm_is_uuid_restriction_active(bt_dpm_status_t *valu
        result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_UUID_RESTRITION,
                in_param1, in_param2, in_param3, in_param4, &out_param);
 
-       if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
+       if (result == BLUETOOTH_ERROR_NONE) {
                if (out_param->len > 0) {
                        *value = g_array_index(out_param,
                                        int, 0);
@@ -698,13 +704,13 @@ BT_EXPORT_API int bluetooth_dpm_get_devices_from_blacklist(bt_dpm_device_list_t
        result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DEVICES_BLACKLIST,
                in_param1, in_param2, in_param3, in_param4, &out_param);
 
-       if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
+       if (result == BLUETOOTH_ERROR_NONE) {
                devices = &g_array_index(out_param, bt_dpm_device_list_t, 0);
                BT_DBG("device_list->count : %d", devices->count);
 
                if (devices->count == 0) {
                        BT_ERR("device_list->count is zero !");
-                       return BLUETOOTH_DPM_RESULT_FAIL;
+                       result = BLUETOOTH_ERROR_NOT_FOUND;
                }
 
                device_list->count = devices->count;
@@ -733,13 +739,13 @@ BT_EXPORT_API int bluetooth_dpm_get_devices_from_whitelist(bt_dpm_device_list_t
        result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DEVICES_WHITELIST,
                in_param1, in_param2, in_param3, in_param4, &out_param);
 
-       if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
+       if (result == BLUETOOTH_ERROR_NONE) {
                devices = &g_array_index(out_param, bt_dpm_device_list_t, 0);
                BT_DBG("device_list->count : %d", devices->count);
 
                if (devices->count == 0) {
                        BT_ERR("device_list->count is zero !");
-                       return BLUETOOTH_DPM_RESULT_FAIL;
+                       result = BLUETOOTH_ERROR_NOT_FOUND;
                }
 
                device_list->count = devices->count;
@@ -768,13 +774,13 @@ BT_EXPORT_API int bluetooth_dpm_get_uuids_from_blacklist(bt_dpm_uuids_list_t *uu
        result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_UUIDS_BLACKLIST,
                in_param1, in_param2, in_param3, in_param4, &out_param);
 
-       if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
+       if (result == BLUETOOTH_ERROR_NONE) {
                uuids = &g_array_index(out_param, bt_dpm_uuids_list_t, 0);
                BT_DBG("uuids->count : %d", uuids->count);
 
                if (uuids->count == 0) {
                        BT_ERR("uuids->count is zero !");
-                       return BLUETOOTH_DPM_RESULT_FAIL;
+                       result = BLUETOOTH_ERROR_NOT_FOUND;
                }
 
                uuid_list->count = uuids->count;
@@ -802,13 +808,13 @@ BT_EXPORT_API int bluetooth_dpm_get_uuids_from_whitelist(bt_dpm_uuids_list_t *uu
        result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_UUIDS_WHITELIST,
                in_param1, in_param2, in_param3, in_param4, &out_param);
 
-       if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
+       if (result == BLUETOOTH_ERROR_NONE) {
                uuids = &g_array_index(out_param, bt_dpm_uuids_list_t, 0);
                BT_DBG("uuids->count : %d", uuids->count);
 
                if (uuids->count == 0) {
                        BT_ERR("uuids->count is zero !");
-                       return BLUETOOTH_DPM_RESULT_FAIL;
+                       result = BLUETOOTH_ERROR_NOT_FOUND;
                }
 
                uuid_list->count = uuids->count;
@@ -940,7 +946,7 @@ BT_EXPORT_API int bluetooth_dpm_get_allow_outgoing_call(bt_dpm_status_t *value)
        result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_ALLOW_OUTGOING_CALL,
                in_param1, in_param2, in_param3, in_param4, &out_param);
 
-       if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
+       if (result == BLUETOOTH_ERROR_NONE) {
                if (out_param->len > 0) {
                        *value = g_array_index(out_param,
                                        int, 0);
@@ -985,7 +991,7 @@ BT_EXPORT_API int bluetooth_dpm_get_pairing_state(bt_dpm_status_t *value)
        result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_ALLOW_BT_MODE,
                in_param1, in_param2, in_param3, in_param4, &out_param);
 
-       if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
+       if (result == BLUETOOTH_ERROR_NONE) {
                if (out_param->len > 0) {
                        *value = g_array_index(out_param,
                                        int, 0);
@@ -1033,7 +1039,7 @@ BT_EXPORT_API int bluetooth_dpm_get_profile_state(bt_dpm_profile_t profile, bt_d
        result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_PROFILE_STATE,
                in_param1, in_param2, in_param3, in_param4, &out_param);
 
-       if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
+       if (result == BLUETOOTH_ERROR_NONE) {
                if (out_param->len > 0) {
                        *value = g_array_index(out_param,
                                        int, 0);
@@ -1078,7 +1084,7 @@ BT_EXPORT_API int bluetooth_dpm_get_desktop_connectivity_state(bt_dpm_status_t *
        result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DESKROP_CONNECTIVITY_STATE,
                in_param1, in_param2, in_param3, in_param4, &out_param);
 
-       if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
+       if (result == BLUETOOTH_ERROR_NONE) {
                if (out_param->len > 0) {
                        *value = g_array_index(out_param,
                                        int, 0);
@@ -1123,7 +1129,7 @@ BT_EXPORT_API int bluetooth_dpm_get_discoverable_state(bt_dpm_status_t *value)
        result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DISCOVERABLE_STATE,
                in_param1, in_param2, in_param3, in_param4, &out_param);
 
-       if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
+       if (result == BLUETOOTH_ERROR_NONE) {
                if (out_param->len > 0) {
                        *value = g_array_index(out_param,
                                        int, 0);
@@ -1170,7 +1176,7 @@ BT_EXPORT_API int bluetooth_dpm_get_limited_discoverable_state(bt_dpm_status_t *
        result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_LIMITED_DISCOVERABLE_STATE,
                in_param1, in_param2, in_param3, in_param4, &out_param);
 
-       if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
+       if (result == BLUETOOTH_ERROR_NONE) {
                if (out_param->len > 0) {
                        *value = g_array_index(out_param,
                                        int, 0);
@@ -1215,7 +1221,7 @@ BT_EXPORT_API int bluetooth_dpm_get_data_transfer_state(bt_dpm_status_t *value)
        result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DATA_TRANSFER_STATE,
                in_param1, in_param2, in_param3, in_param4, &out_param);
 
-       if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
+       if (result == BLUETOOTH_ERROR_NONE) {
                if (out_param->len > 0) {
                        *value = g_array_index(out_param,
                                        int, 0);