Merge "Not enable BT on booting time in factory mode" into tizen
[platform/core/connectivity/bluetooth-frwk.git] / bt-api / bt-rfcomm-server.c
index 05c311d..2701d03 100644 (file)
@@ -341,6 +341,12 @@ static gboolean __data_received_cb(GIOChannel *chan, GIOCondition cond,
                        result, &data_r,
                        event_info->cb, event_info->user_data);
 
+       if (bluetooth_get_battery_monitor_state()) {
+               int ret = _bt_common_send_rfcomm_rx_details(&data_r);
+               if (ret != BLUETOOTH_ERROR_NONE)
+                       BT_ERR("RFCOMM received data details not sent to battery monitor frwk");
+       }
+
        g_free(buffer);
 
        return TRUE;
@@ -488,7 +494,7 @@ void _bt_rfcomm_server_disconnect_all(void)
        GSList *conn;
        char addr[20];
 
-       BT_INFO("### Disconnect all RFCOMM server connections");
+       BT_INFO(" ### Disconnect all RFCOMM server connections");
 
        for (server = rfcomm_nodes; server; ) {
                rfcomm_info_t *info = server->data;
@@ -1050,7 +1056,7 @@ err:
        return FALSE;
 }
 
-static int __rfcomm_listen(rfcomm_server_info_t *server_info)
+static int __rfcomm_listen(rfcomm_server_info_t *server_info, bool accept)
 {
        int result;
        GUnixFDList *out_fd_list = NULL;
@@ -1061,9 +1067,15 @@ static int __rfcomm_listen(rfcomm_server_info_t *server_info)
        BT_INIT_PARAMS();
        BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
-       g_array_append_vals(in_param1, server_info->uuid, BLUETOOTH_UUID_STRING_MAX);
-       result = _bt_send_request_with_unix_fd_list(BT_BLUEZ_SERVICE, BT_RFCOMM_LISTEN,
-                       in_param1, in_param2, in_param3, in_param4, NULL, &out_param, &out_fd_list);
+       if (accept == false) {
+               g_array_append_vals(in_param1, server_info->uuid, BLUETOOTH_UUID_STRING_MAX);
+               result = _bt_send_request_with_unix_fd_list(BT_BLUEZ_SERVICE, BT_RFCOMM_LISTEN,
+                               in_param1, in_param2, in_param3, in_param4, NULL, &out_param, &out_fd_list);
+       } else {
+               g_array_append_vals(in_param1, server_info->uuid, BLUETOOTH_UUID_STRING_MAX);
+               result = _bt_send_request_with_unix_fd_list(BT_BLUEZ_SERVICE, BT_RFCOMM_LISTEN_AND_ACCEPT,
+                               in_param1, in_param2, in_param3, in_param4, NULL, &out_param, &out_fd_list);
+       }
 
        BT_DBG("result: %x", result);
        if (result != BLUETOOTH_ERROR_NONE) {
@@ -1278,7 +1290,7 @@ BT_EXPORT_API int bluetooth_rfcomm_server_disconnect(int socket_fd)
 
        char address[20];
 
-       BT_INFO("### Disconnect RFCOMM server");
+       BT_INFO(" ### Disconnect RFCOMM server");
        if (socket_fd < 0) {
                BT_ERR("Invalid FD");
                return BLUETOOTH_ERROR_INVALID_PARAM;
@@ -1473,7 +1485,7 @@ BT_EXPORT_API int bluetooth_rfcomm_listen_and_accept(int id, int max_pending_con
        server_info->max_pending_conn = max_pending_connection;
        server_info->auto_accept = TRUE;
 
-       return __rfcomm_listen(server_info);
+       return __rfcomm_listen(server_info, true);
 #endif
 }
 
@@ -1580,7 +1592,7 @@ BT_EXPORT_API int bluetooth_rfcomm_listen(int id, int max_pending_connection)
 
        server_info->max_pending_conn = max_pending_connection;
        server_info->auto_accept = FALSE;
-       return __rfcomm_listen(server_info);
+       return __rfcomm_listen(server_info, false);
 #endif
 }