[Boiler Plate] Update Boiler plate to remove unwanted information
[platform/core/connectivity/bluetooth-frwk.git] / bt-api / bt-hid.c
old mode 100644 (file)
new mode 100755 (executable)
index a1a06bb..557a2bd
@@ -1,13 +1,11 @@
 /*
- * 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,
@@ -64,14 +62,20 @@ BT_EXPORT_API int bluetooth_hid_connect(hid_device_address_t *device_address)
        int result;
        bt_user_info_t *user_info;
 
-       BT_CHECK_PARAMETER(device_address);
-       BT_CHECK_ENABLED();
+       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_HID_CONNECT)
+            == 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_HID);
-       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));
 
@@ -89,14 +93,20 @@ BT_EXPORT_API int bluetooth_hid_disconnect(hid_device_address_t *device_address)
        int result;
        bt_user_info_t *user_info;
 
-       BT_CHECK_PARAMETER(device_address);
-       BT_CHECK_ENABLED();
+       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_HID_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_HID);
-       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));