#include "bt-common.h"
#include "bt-request-sender.h"
#include "bt-event-handler.h"
+#include "bt-dpm.h"
static void __bt_get_file_size(char **files, unsigned long *file_size, int *count)
{
}
BT_EXPORT_API int bluetooth_opc_push_files(bluetooth_device_address_t *remote_address,
- char **file_name_array)
+ char **file_name_array)
{
int result;
int i;
return BLUETOOTH_ERROR_PERMISSION_DEINED;
}
+ if (_bt_check_dpm(BT_DPM_ADDRESS, remote_address) == BT_DPM_RESTRICTED) {
+ BT_ERR("Blacklist device");
+ return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
+ }
+
+ if (_bt_check_dpm(BT_DPM_OPP, NULL) == BT_DPM_RESTRICTED) {
+ BT_ERR("Not allow to send files");
+ return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
+ }
+
+ if (_bt_check_dpm(BT_DPM_DESKTOP, NULL) == BT_DPM_RESTRICTED) {
+ char address[BT_ADDRESS_STRING_SIZE] = { 0 };
+ bluetooth_device_class_t dev_class;
+
+ _bt_convert_addr_type_to_string(address, remote_address->addr);
+ _bt_get_cod_by_address(address, &dev_class);
+
+ if (dev_class.major_class == BLUETOOTH_DEVICE_MAJOR_CLASS_COMPUTER) {
+ BT_ERR("Reject a authorization due to MDM Policy");
+ return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
+ }
+ }
+
__bt_get_file_size(file_name_array, &size, &file_count);
retv_if(file_count == 0, BLUETOOTH_ERROR_INVALID_PARAM);
result = _bt_send_request(BT_OBEX_SERVICE, BT_OPP_IS_PUSHING_FILES,
in_param1, in_param2, in_param3, in_param4, &out_param);
- if (result == BLUETOOTH_ERROR_NONE) {
+ if (result == BLUETOOTH_ERROR_NONE)
*is_sending = g_array_index(out_param, gboolean, 0);
+ else
+ BT_ERR("Fail to send request");
+
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ return result;
+}
+
+BT_EXPORT_API int bluetooth_opp_get_transfer_progress(bluetooth_opp_transfer_type_t transfer_type,
+ int transfer_id, unsigned char *progress)
+{
+ int result;
+ int direction = transfer_type;
+ int percentage = 0;
+ 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, &direction, sizeof(int));
+ g_array_append_vals(in_param2, &transfer_id, sizeof(int));
+
+ result = _bt_send_request(BT_OBEX_SERVICE, BT_OPP_GET_TRANSFER_PROGRESS,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ if (result == BLUETOOTH_ERROR_NONE) {
+ percentage = g_array_index(out_param, guint8, 0);
+ BT_DBG("Percentage: %d", percentage);
} else {
BT_ERR("Fail to send request");
}
+ if (progress)
+ *progress = percentage;
+
BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
return result;
}
-