Add the internal API to get the pbap connected status 01/93601/1 accepted/tizen/3.0/ivi/20161103.002130 accepted/tizen/3.0/mobile/20161103.002040 accepted/tizen/3.0/tv/20161103.002100 accepted/tizen/3.0/wearable/20161103.002116 submit/tizen_3.0/20161102.022329
authorDoHyun Pyun <dh79.pyun@samsung.com>
Tue, 25 Oct 2016 05:11:22 +0000 (14:11 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Tue, 25 Oct 2016 05:11:22 +0000 (14:11 +0900)
Change-Id: Ied719209bd17b9b9dd541d30852a62e590c0b6f5
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
include/mobile/bluetooth_internal.h
include/tv/bluetooth_internal.h
include/wearable/bluetooth_internal.h
src/bluetooth-pbap.c
test/bt_unit_test.c
test/bt_unit_test.h

index a6d097e884a1a747ad491a010097cfd3803819ac..36c1e447549adf2313efd0a0d385443a8cf66690 100644 (file)
@@ -3148,6 +3148,25 @@ int bt_ipsp_set_connection_state_changed_cb(bt_ipsp_connection_state_changed_cb
  */
 int bt_ipsp_unset_connection_state_changed_cb(void);
 
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_PBAP_MODULE
+ * @brief Gets the pbap connected status.
+ * @since_tizen 3.0
+ * @param[in] remote_address The address of the remote device
+ * @param[out] connected_status the connected status
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #BT_ERROR_NONE  Successful
+ * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
+ * @retval #BT_ERROR_NOT_ENABLED  Not enabled
+ * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED  Remote device not bonded
+ * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
+ * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
+ *
+ * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED.
+ */
+int bt_pbap_client_is_connected(const char *address, bool *connected_status);
+
 /**
  * @}
  */
index a6d097e884a1a747ad491a010097cfd3803819ac..36c1e447549adf2313efd0a0d385443a8cf66690 100644 (file)
@@ -3148,6 +3148,25 @@ int bt_ipsp_set_connection_state_changed_cb(bt_ipsp_connection_state_changed_cb
  */
 int bt_ipsp_unset_connection_state_changed_cb(void);
 
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_PBAP_MODULE
+ * @brief Gets the pbap connected status.
+ * @since_tizen 3.0
+ * @param[in] remote_address The address of the remote device
+ * @param[out] connected_status the connected status
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #BT_ERROR_NONE  Successful
+ * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
+ * @retval #BT_ERROR_NOT_ENABLED  Not enabled
+ * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED  Remote device not bonded
+ * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
+ * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
+ *
+ * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED.
+ */
+int bt_pbap_client_is_connected(const char *address, bool *connected_status);
+
 /**
  * @}
  */
index 291b0a03a6ec7d0aa266fd829c37967a19cb4b22..a2568200d7b0adf025f526f46e6abccb5def89f7 100644 (file)
@@ -3296,6 +3296,25 @@ int bt_ipsp_set_connection_state_changed_cb(bt_ipsp_connection_state_changed_cb
  */
 int bt_ipsp_unset_connection_state_changed_cb(void);
 
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_PBAP_MODULE
+ * @brief Gets the pbap connected status.
+ * @since_tizen 3.0
+ * @param[in] remote_address The address of the remote device
+ * @param[out] connected_status the connected status
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #BT_ERROR_NONE  Successful
+ * @retval #BT_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
+ * @retval #BT_ERROR_NOT_ENABLED  Not enabled
+ * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED  Remote device not bonded
+ * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
+ * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
+ *
+ * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED.
+ */
+int bt_pbap_client_is_connected(const char *address, bool *connected_status);
+
 /**
  * @}
  */
index 6e81256dc8c1a09907b59ad4ea69405046f54c9b..716f4597851c6aa4bf21997499e98bf8f3a2f9e6 100644 (file)
@@ -109,6 +109,31 @@ int bt_pbap_client_disconnect(const char *address)
        return error_code;
 }
 
+int bt_pbap_client_is_connected(const char *address, bool *connected_status)
+{
+       bluetooth_device_address_t addr_hex = { {0,} };
+       int ret;
+       gboolean is_connected = FALSE;
+
+       BT_CHECK_PBAP_CLIENT_SUPPORT();
+       BT_CHECK_INIT_STATUS();
+       BT_CHECK_INPUT_PARAMETER(address);
+
+       _bt_convert_address_to_hex(&addr_hex, address);
+
+       ret = _bt_get_error_code(bluetooth_is_device_connected(&addr_hex,
+                                                               BLUETOOTH_PBAP_SERVICE, &is_connected));
+       *connected_status = is_connected ? true : false;
+
+       if (ret != BT_ERROR_NONE) {
+               BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); /* LCOV_EXCL_LINE */
+               return ret;
+       }
+
+       return ret;
+
+}
+
 int bt_pbap_client_get_phone_book_size(const char *address, bt_pbap_address_book_source_e source,
                bt_pbap_folder_type_e folder_type, bt_pbap_phone_book_size_cb callback, void *user_data)
 {
index 9e9b2c4b0afa93f12b26450c6c87fe22df5ae612..6b6c6121d3933c86305489029d27a84fa3affa19 100644 (file)
@@ -1011,6 +1011,8 @@ tc_table_t tc_pbap_client[] = {
                , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_CONNECT},
        {"bt_pbap_client_disconnect()"
                , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_DISCONNECT},
+       {"bt_pbap_client_is_connected()"
+               , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_IS_CONNECTED},
        {"bt_pbap_client_get_phone_book_size()"
                , BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_GETSIZE},
        {"bt_pbap_client_get_phone_book()"
@@ -8891,6 +8893,17 @@ int test_input_callback(void *data)
                        TC_PRT("returns %s\n", __bt_get_error_message(ret));
                        break;
                }
+               case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_IS_CONNECTED: {
+                       bool connected_status = false;
+
+                       ret = bt_pbap_client_is_connected(remote_addr, &connected_status);
+                       if (ret < BT_ERROR_NONE)
+                               TC_PRT("returns %s\n", __bt_get_error_message(ret));
+
+                       TC_PRT("PBAP Profile [%s]",
+                               connected_status ? "Connected" : "Disconnected");
+                       break;
+               }
                case BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_GETSIZE: {
                        ret = bt_pbap_client_get_phone_book_size(remote_addr,
                                        0, 0,
index 13162f12bdcc04e0eb16937eebf1bab82c6bbd80..edcc964465ec03182d3f21970fbb0fc1d87d81c4 100644 (file)
@@ -421,6 +421,7 @@ typedef enum {
        BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_UNSET_CONNECTION_STATE_CHANGED_CB,
        BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_CONNECT,
        BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_DISCONNECT,
+       BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_IS_CONNECTED,
        BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_GETSIZE,
        BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_PHONEBOOKPULL,
        BT_UNIT_TEST_FUNCTION_PBAP_CLIENT_VCARDLIST,