Merge "Fix the warning errors" into tizen_3.0
authorDoHyun Pyun <dh79.pyun@samsung.com>
Wed, 16 Nov 2016 02:33:02 +0000 (18:33 -0800)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Wed, 16 Nov 2016 02:33:03 +0000 (18:33 -0800)
14 files changed:
bt-api/bt-event-handler.c
bt-api/bt-rfcomm-client.c
bt-api/bt-rfcomm-server.c
bt-api/include/bt-common.h
bt-service/bt-service-adapter-le.c
bt-service/bt-service-device.c
bt-service/bt-service-event-receiver.c
bt-service/bt-service-event-sender.c
bt-service/bt-service-obex-server.c
bt-service/include/bt-service-adapter-le.h
bt-service/include/bt-service-common.h
bt-service/include/bt-service-device.h
include/bluetooth-api.h
include/bt-internal-types.h

index 993eea4..ca129f0 100644 (file)
@@ -370,43 +370,6 @@ done:
        return le_dev_info;
 }
 
-static bluetooth_ibeacon_device_info_t *__bt_get_ibeacon_device_info_in_message(GVariant *parameters, int *ret)
-{
-       bluetooth_ibeacon_device_info_t *ibeacon_dev_info = NULL;
-       const char *address = NULL;
-       short addr_type = 0;
-       int company_id = 0;
-       int ibeacon_type = 0;
-       int major_id = 0;
-       int minor_id = 0;
-       int measured_power = 0;
-       const char *uuid = NULL;
-       int result = BLUETOOTH_ERROR_NONE;
-
-       g_variant_get(parameters, "(i&snnn&snnn)", &result, &address,
-                       &addr_type, &company_id, &ibeacon_type, &uuid, &major_id, &minor_id, &measured_power);
-       ibeacon_dev_info = g_malloc0(sizeof(bluetooth_ibeacon_device_info_t));
-       if (ibeacon_dev_info == NULL) {
-               result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
-               goto done;
-       }
-
-       _bt_convert_addr_string_to_type(ibeacon_dev_info->device_address.addr, address);
-       ibeacon_dev_info->addr_type = addr_type;
-       ibeacon_dev_info->company_id = company_id;
-       ibeacon_dev_info->ibeacon_type = ibeacon_type;
-       ibeacon_dev_info->major_id = major_id;
-       ibeacon_dev_info->minor_id = minor_id;
-       ibeacon_dev_info->measured_power = measured_power;
-       ibeacon_dev_info->uuid_len = strlen(uuid);
-       memcpy(ibeacon_dev_info->uuid, uuid, ibeacon_dev_info->uuid_len);
-done:
-
-       *ret = result;
-
-       return ibeacon_dev_info;
-}
-
 gboolean __bt_reliable_disable_cb(gpointer user_data)
 {
        BT_DBG("+");
@@ -786,18 +749,6 @@ void __bt_adapter_le_event_filter(GDBusConnection *connection,
                }
 
                g_free(le_device_info);
-       } else if (strcasecmp(signal_name, BT_IBEACON_DEVICE_FOUND) == 0) {
-               bluetooth_ibeacon_device_info_t *ibeacon_device_info;
-               BT_DBG("BT_IBEACON_DEVICE_FOUND");
-               ibeacon_device_info = __bt_get_ibeacon_device_info_in_message(parameters,
-                                                               &result);
-               ret_if(ibeacon_device_info == NULL);
-
-               _bt_common_event_cb(BLUETOOTH_EVENT_REMOTE_IBEACON_DEVICE_FOUND,
-                               result, ibeacon_device_info,
-                               event_info->cb, event_info->user_data);
-
-               g_free(ibeacon_device_info);
        }
 }
 
index 93f5ea6..9b2db88 100644 (file)
@@ -429,6 +429,39 @@ static void __client_connected_cb(rfcomm_cb_data_t *cb_data, char *dev_address,
        BT_DBG("-");
 }
 
+void _bt_rfcomm_client_disconnect_all(void)
+{
+       GSList *client;
+       GSList *conn;
+
+       BT_INFO_C("### Disconnect all RFCOMM client connections");
+
+       for (client = rfcomm_clients; client; ) {
+               rfcomm_cb_data_t *info = client->data;
+
+               for (conn = info->rfcomm_conns; conn; conn = conn->next) {
+                       rfcomm_conn_info_t *conn_info = conn->data;
+
+                       if (conn_info == NULL)
+                               continue;
+
+                       if (conn_info->watch_id == 0 || conn_info->disconnected)
+                               continue;
+
+                       close(conn_info->fd);
+                       conn_info->disconnected = TRUE;
+
+                       _bt_disconnect_profile(conn_info->bt_addr, info->uuid,
+                                       NULL,NULL);
+
+               }
+
+               client = client->next;
+               __rfcomm_client_disconnect(info);
+       }
+
+       return;
+}
 #endif
 
 int new_connection(const char *path, int fd, bluetooth_device_address_t *addr)
@@ -436,24 +469,32 @@ int new_connection(const char *path, int fd, bluetooth_device_address_t *addr)
        rfcomm_cb_data_t *info;
        GIOChannel *data_io;
        rfcomm_conn_info_t *conn_info = NULL;
-       BT_DBG("%s %d", path, fd);
        char address[BT_ADDRESS_STRING_SIZE];
+
+       BT_INFO("%s %d", path, fd);
+
        _bt_convert_addr_type_to_string(address,
                                (unsigned char *)addr);
+
        info = __find_rfcomm_info_from_path(path);
-       if (info == NULL)
+       if (info == NULL) {
+               BT_ERR("rfcomm info is NULL");
                return -1;
-       conn_info = __get_conn_info_from_address(info, address);
+       }
 
+       conn_info = __get_conn_info_from_address(info, address);
        if (conn_info == NULL) {
-               BT_ERR("Device Address %s not found in connection list", address);
+               BT_ERR("connection info is NULL");
                return -1;
        }
+
        conn_info->fd = fd;
-       BT_DBG("connection info fd %d", conn_info->fd);
+
        data_io = g_io_channel_unix_new(fd);
+
        g_io_channel_set_encoding(data_io, NULL, NULL);
        g_io_channel_set_flags(data_io, G_IO_FLAG_NONBLOCK, NULL);
+
        conn_info->watch_id = g_io_add_watch(data_io,
                                G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
                                __client_data_received_cb, info);
@@ -834,10 +875,6 @@ BT_EXPORT_API int bluetooth_rfcomm_disconnect(int socket_fd)
        BT_INFO("conn_info %s", conn_info->bt_addr);
        _bt_disconnect_profile(conn_info->bt_addr, info->uuid, NULL, NULL);
 
-       /*
-        * ToDo : If idle_id is not zero, it means disconnect request is
-        * going on. Such a case, in-progress error should be returned.
-        */
        if (info->idle_id == 0)
                info->idle_id = g_idle_add(__rfcomm_client_disconnect, info);
 
index a2794de..3409a1d 100644 (file)
@@ -355,6 +355,20 @@ int new_server_connection(const char *path, int fd, bluetooth_device_address_t *
        if (info == NULL)
                return -1;
 
+#ifdef TIZEN_DPM_ENABLE
+       if (_bt_check_dpm(BT_DPM_SPP, NULL) == BT_DPM_RESTRICTED) {
+               char addr_str[20];
+
+               BT_ERR("Not allow to use SPP profile");
+
+               close(fd);
+               _bt_convert_addr_type_to_string(addr_str, addr->addr);
+               _bt_disconnect_profile(addr_str, info->uuid, NULL,NULL);
+
+               return -1;
+       }
+#endif
+
        conn = g_new0(rfcomm_conn_t, 1);
        conn->fd = fd;
        memcpy(&conn->addr, addr, sizeof(bluetooth_device_address_t));
@@ -454,13 +468,48 @@ void free_rfcomm_info(rfcomm_info_t *info)
        g_free(info);
 }
 
-void _bt_rfcomm_server_free_all()
+void _bt_rfcomm_server_free_all(void)
 {
        BT_DBG("Free all the servers");
 
        g_slist_free_full(rfcomm_nodes, (GDestroyNotify)free_rfcomm_info);
        rfcomm_nodes = NULL;
 }
+
+void _bt_rfcomm_server_disconnect_all(void)
+{
+       GSList *server;
+       GSList *conn;
+       char addr[20];
+
+       BT_INFO("### Disconnect all RFCOMM server connections");
+
+       for (server = rfcomm_nodes; server; ) {
+               rfcomm_info_t *info = server->data;
+
+               for (conn = info->rfcomm_conns; conn; conn = conn->next) {
+                       rfcomm_conn_t *conn_info = conn->data;
+
+                       if (conn_info == NULL)
+                               continue;
+
+                       if (conn_info->watch_id == 0 || conn_info->disconnected)
+                               continue;
+
+                       close(conn_info->fd);
+                       conn_info->disconnected = TRUE;
+
+                       _bt_convert_addr_type_to_string(addr,
+                                                       conn_info->addr.addr);
+                       _bt_disconnect_profile(addr, info->uuid, NULL,NULL);
+               }
+
+               server = server->next;
+               __rfcomm_server_disconnect(info);
+       }
+
+       return;
+}
 #endif
 
 BT_EXPORT_API int bluetooth_rfcomm_create_socket(const char *uuid)
index dfce86a..c60c459 100644 (file)
@@ -364,13 +364,18 @@ void _bt_convert_device_path_to_address(const char *device_path,
                                char *device_address);
 
 #ifdef RFCOMM_DIRECT
-void _bt_rfcomm_server_free_all();
+void _bt_rfcomm_server_free_all(void);
+
+void _bt_rfcomm_server_disconnect_all(void);
+
+void _bt_rfcomm_client_disconnect_all(void);
 
 gboolean _check_uuid_path(char *path, char *uuid);
 #endif
 
 void _bluetooth_hid_free_hid_info(void);
 
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index e124352..02a97db 100644 (file)
@@ -1945,36 +1945,6 @@ void _bt_send_scan_result_event(const bt_remote_le_dev_info_t *le_dev_info,
        }
 }
 
-void _bt_send_ibeacon_scan_result_event(const bt_remote_ibeacon_dev_info_t *ibeacon_dev_info)
-{
-       int result = BLUETOOTH_ERROR_NONE;
-       GSList *l;
-       GVariant *param;
-       bt_adapter_le_scanner_t *scanner = NULL;
-
-       ret_if(ibeacon_dev_info == NULL);
-       BT_DBG("_bt_send_ibeacon_scan_result_event");
-
-       for (l = scanner_list; l != NULL; l = g_slist_next(l)) {
-               scanner = l->data;
-               if (scanner->is_scanning == FALSE)
-                       continue;
-
-               param = g_variant_new("(isnnnsnnn)",
-                                       result,
-                                       ibeacon_dev_info->address,
-                                       ibeacon_dev_info->addr_type,
-                                       ibeacon_dev_info->company_id,
-                                       ibeacon_dev_info->ibeacon_type,
-                                       ibeacon_dev_info->uuid,
-                                       ibeacon_dev_info->major_id,
-                                       ibeacon_dev_info->minor_id,
-                                       ibeacon_dev_info->measured_power);
-
-               _bt_send_event(BT_LE_ADAPTER_EVENT, BLUETOOTH_EVENT_REMOTE_IBEACON_DEVICE_FOUND, param);
-       }
-}
-
 int _bt_add_white_list(bluetooth_device_address_t *device_address, bluetooth_device_address_type_t address_type)
 {
        GDBusProxy *proxy;
index 37186ae..26120bc 100644 (file)
@@ -2237,6 +2237,47 @@ int _bt_connect_profile(char *address, char *uuid,
        return BLUETOOTH_ERROR_NONE;
 }
 
+int _bt_disconnect_all(char *address)
+{
+       int ret = BLUETOOTH_ERROR_NONE;
+       char *object_path;
+       GDBusProxy *proxy;
+       GDBusConnection *conn;
+       GVariant *result = NULL;
+       GError *err = NULL;
+
+       BT_DBG("");
+       conn = _bt_gdbus_get_system_gconn();
+       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       object_path = _bt_get_device_object_path(address);
+       retv_if(object_path == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                       NULL, BT_BLUEZ_NAME,
+                                       object_path, BT_DEVICE_INTERFACE,  NULL, NULL);
+       g_free(object_path);
+       retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       result = g_dbus_proxy_call_sync(proxy, "Disconnect",
+               NULL,
+               G_DBUS_CALL_FLAGS_NONE,
+               -1, NULL,
+               &err);
+
+       if (err != NULL) {
+               BT_ERR("Dbus Call Error:[%s]", err->message);
+               g_error_free(err);
+               ret = BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       g_object_unref(proxy);
+       if (result)
+               g_variant_unref(result);
+
+       return ret;
+}
+
 int _bt_disconnect_profile(char *address, char *uuid,
                                                void *cb, gpointer func_data)
 {
index 428e5f3..48b83da 100644 (file)
@@ -2261,25 +2261,6 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                                                event,
                                                param);
                g_free(address);
-       } else if (strcasecmp(member, "iBeaconReport") == 0) {
-               bt_remote_ibeacon_dev_info_t *ibeacon_dev_info = NULL;
-
-               ret_if(_bt_is_le_scanning() == FALSE);
-
-               ibeacon_dev_info = g_malloc0(sizeof(bt_remote_ibeacon_dev_info_t));
-               if (ibeacon_dev_info == NULL)
-                       return;
-
-               g_variant_get(msg, "(syuusuuy)", &ibeacon_dev_info->address,
-                                               &ibeacon_dev_info->addr_type,
-                                               &ibeacon_dev_info->company_id,
-                                               &ibeacon_dev_info->ibeacon_type,
-                                               &ibeacon_dev_info->uuid,
-                                               &ibeacon_dev_info->major_id,
-                                               &ibeacon_dev_info->minor_id,
-                                               &ibeacon_dev_info->measured_power);
-               _bt_send_ibeacon_scan_result_event(ibeacon_dev_info);
-               g_free(ibeacon_dev_info);
        }
 }
 
index d269e75..40c19d3 100644 (file)
@@ -421,9 +421,6 @@ int _bt_send_event(int event_type, int event, GVariant *param)
        case BLUETOOTH_EVENT_LE_DATA_LENGTH_CHANGED:
                signal = BT_LE_DATA_LENGTH_CHANGED;
                break;
-       case BLUETOOTH_EVENT_REMOTE_IBEACON_DEVICE_FOUND:
-               signal = BT_IBEACON_DEVICE_FOUND;
-               break;
        case BLUETOOTH_EVENT_PXP_PROPERTY_CHANGED:
                signal = BT_PXP_PROPERTY_CHANGED;
                break;
index 4363a7e..0dcf9ea 100644 (file)
@@ -811,9 +811,9 @@ void _bt_obex_transfer_completed(const char *transfer_path, gboolean success)
                        g_variant_builder_add(builder, "y", agent_info.auth_info->contact_auth_info[i]);
 
                param = g_variant_new("(isssstii(ay))", result,
+                                       transfer_info->device_name,
                                        transfer_info->filename,
                                        transfer_info->type,
-                                       transfer_info->device_name,
                                        transfer_info->address,
                                        transfer_info->file_size,
                                        transfer_info->transfer_id,
index 6c79a6e..124a270 100644 (file)
@@ -115,8 +115,6 @@ bt_le_scan_type_t _bt_get_le_scan_type(void);
 
 void _bt_send_scan_result_event(const bt_remote_le_dev_info_t *le_dev_info, const bt_le_adv_info_t *adv_info);
 
-void _bt_send_ibeacon_scan_result_event(const bt_remote_ibeacon_dev_info_t *ibeacon_dev_info);
-
 int _bt_add_white_list(bluetooth_device_address_t *device_address, bluetooth_device_address_type_t address_type);
 
 int _bt_remove_white_list(bluetooth_device_address_t *device_address, bluetooth_device_address_type_t address_type);
index 2753d13..814a620 100644 (file)
@@ -304,19 +304,6 @@ typedef struct {
 } bt_remote_le_dev_info_t;
 
 typedef struct {
-       char *address;
-       int addr_type;
-       int rssi;
-       int adv_type;
-       int company_id;
-       int ibeacon_type;
-       int major_id;
-       int minor_id;
-       int measured_power;
-       char *uuid;
-} bt_remote_ibeacon_dev_info_t;
-
-typedef struct {
        int rssi;
        int class;
        char *address;
index 5391e22..ab78174 100644 (file)
@@ -98,6 +98,8 @@ int _bt_get_le_connection_parameter(bluetooth_le_connection_mode_t mode,
 int _bt_connect_profile(char *address, char *uuid,
                                                void *cb, gpointer func_data);
 
+int _bt_disconnect_all(char *address);
+
 int _bt_disconnect_profile(char *address, char *uuid,
                                                void *cb, gpointer func_data);
 
index 20cfd24..1b5e7b8 100644 (file)
@@ -531,7 +531,6 @@ typedef enum {
        BLUETOOTH_EVENT_LE_DISCOVERY_STARTED,           /**< Bluetooth event LE discovery started */
        BLUETOOTH_EVENT_LE_DISCOVERY_FINISHED,  /**< Bluetooth event LE discovery finished */
        BLUETOOTH_EVENT_REMOTE_LE_DEVICE_FOUND,     /**< Bluetooth event remote deice found (LE dev) */
-       BLUETOOTH_EVENT_REMOTE_IBEACON_DEVICE_FOUND,    /**< Bluetooth event remote ibeacon device found (iBeacon LE dev) */
        BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED,/**< Bluetooth event remote device name updated*/
        BLUETOOTH_EVENT_BONDING_FINISHED,           /**< Bluetooth event bonding completed */
        BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED,      /**< Bluetooth event bonding removed */
@@ -1011,20 +1010,6 @@ typedef struct {
 } bluetooth_le_device_info_t;
 
 typedef struct {
-       bluetooth_device_address_t device_address;      /**< device address */
-       int addr_type;                  /**< address type*/
-       int rssi;                       /**< received strength signal*/
-       int adv_type;
-       int company_id;         /** <Company ID> */
-       int ibeacon_type;       /** <iBeacon type> */
-       int major_id;           /** <Major ID> */
-       int minor_id;           /** <Minor ID> */
-       int measured_power; /** <Measured Power value for proximity> */
-       int uuid_len;           /** <uuid string len> */
-       char uuid[BLUETOOTH_UUID_STRING_MAX];   /** <customr/specific UUID> */
-} bluetooth_ibeacon_device_info_t;
-
-typedef struct {
        int slot_id;
        bluetooth_le_scan_filter_feature_t added_features;              /**< added features */
        bluetooth_device_address_t device_address;                      /**< device address */
index 878a19d..c9ccce9 100644 (file)
@@ -522,7 +522,6 @@ typedef struct {
 #define BT_IPSP_CONNECTED "IpspConnected"
 #define BT_IPSP_DISCONNECTED "IpspDisconnected"
 #define BT_LE_DATA_LENGTH_CHANGED "LEDataLengthChanged"
-#define BT_IBEACON_DEVICE_FOUND "iBeaconDeviceFound"
 #define BT_PXP_PROPERTY_CHANGED "PxpValueChanged"
 
 #ifdef __cplusplus