/*
- * bluetooth-frwk
- *
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
#include "bt-request-sender.h"
#include "bt-event-handler.h"
+#ifdef TIZEN_FEATURE_BT_DPM
+#include "bt-dpm.h"
+#endif
+
BT_EXPORT_API int bluetooth_network_activate_server()
{
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);
+ if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_NETWORK_CONNECT)
+ == BLUETOOTH_ERROR_PERMISSION_DEINED) {
+ BT_ERR("Don't have a privilege to use this API");
+ return BLUETOOTH_ERROR_PERMISSION_DEINED;
+ }
+
+#ifdef TIZEN_FEATURE_BT_DPM
+ char *uuid = NULL;
+ if (_bt_check_dpm(BT_DPM_ADDRESS, (void *)device_address) == BT_DPM_RESTRICTED) {
+ BT_ERR("Blacklist device");
+ return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
+ }
+
+ switch (role) {
+ case BLUETOOTH_NETWORK_PANU_ROLE:
+ uuid = g_strdup(BT_PAN_PANU_UUID);
+ break;
+ case BLUETOOTH_NETWORK_NAP_ROLE:
+ uuid = g_strdup(BT_PAN_NAP_UUID);
+ break;
+ case BLUETOOTH_NETWORK_GN_ROLE:
+ uuid = g_strdup(BT_PAN_GN_UUID);
+ break;
+ default:
+ break;
+ }
+
+ if (_bt_check_dpm(BT_DPM_UUID, uuid) == BT_DPM_RESTRICTED) {
+ BT_ERR("Blacklist uuid");
+ g_free(uuid);
+ 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, (unsigned char *)device_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");
+ g_free(uuid);
+ return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
+ }
+ }
+ g_free(uuid);
+#endif
user_info = _bt_get_user_data(BT_COMMON);
- retv_if(user_info == NULL, BLUETOOTH_ERROR_INTERNAL);
+ retv_if(user_info->cb == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+ 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));
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);
+ if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_NETWORK_DISCONNECT)
+ == BLUETOOTH_ERROR_PERMISSION_DEINED) {
+ BT_ERR("Don't have a privilege to use this API");
+ return BLUETOOTH_ERROR_PERMISSION_DEINED;
+ }
user_info = _bt_get_user_data(BT_COMMON);
- retv_if(user_info == NULL, BLUETOOTH_ERROR_INTERNAL);
+ retv_if(user_info->cb == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+ 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));
return result;
}
+BT_EXPORT_API int bluetooth_network_server_disconnect(const bluetooth_device_address_t *device_address)
+{
+ int result;
+ bt_user_info_t *user_info;
+
+ BT_CHECK_PARAMETER(device_address, return);
+ BT_CHECK_ENABLED(return);
+
+ if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_NETWORK_SERVER_DISCONNECT)
+ == BLUETOOTH_ERROR_PERMISSION_DEINED) {
+ BT_ERR("Don't have a privilege to use this API");
+ return BLUETOOTH_ERROR_PERMISSION_DEINED;
+ }
+
+ user_info = _bt_get_user_data(BT_COMMON);
+ retv_if(user_info->cb == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+ 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_async(BT_BLUEZ_SERVICE,
+ BT_NETWORK_SERVER_DISCONNECT,
+ in_param1, in_param2, in_param3, in_param4,
+ user_info->cb, user_info->user_data);
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ return result;
+}
+