Handle the privilege permission error for agent methods
[platform/core/connectivity/bluetooth-frwk.git] / bt-api / bt-common.c
index a846c80..76448b1 100644 (file)
@@ -2095,6 +2095,25 @@ int _bt_get_uuid_specification_name(const char *uuid, char **name)
        return BLUETOOTH_ERROR_NONE;
 }
 
+int _bt_get_error_value_from_message(const char *error_message)
+{
+       if (error_message == NULL) {
+               BT_ERR("Error message NULL");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       BT_ERR("Error message = %s", error_message);
+
+       if (g_strrstr(error_message, BT_ERROR_OPERATION_NOT_SUPPORTED))
+               return BLUETOOTH_ERROR_NOT_IN_OPERATION;
+       else if (g_strrstr(error_message, BT_ERROR_OPERATION_NOT_ALLOWED))
+               return BLUETOOTH_ERROR_PERMISSION_DEINED;
+       else if (g_strrstr(error_message, BT_ERROR_ACCESS_DENIED))
+               return BLUETOOTH_ERROR_PERMISSION_DEINED;
+       else
+               return BLUETOOTH_ERROR_INTERNAL;
+}
+
 BT_EXPORT_API int bluetooth_is_supported(void)
 {
        int is_supported = 0;