OSDN Git Service

Add support for the LegacyPairing property
authorJohan Hedberg <johan.hedberg@nokia.com>
Thu, 4 Dec 2008 13:51:04 +0000 (15:51 +0200)
committerJohan Hedberg <johan.hedberg@nokia.com>
Thu, 4 Dec 2008 13:51:04 +0000 (15:51 +0200)
doc/device-api.txt
src/dbus-hci.c
src/device.c

index 980df62..e17be85 100644 (file)
@@ -174,3 +174,10 @@ Properties string Address [readonly]
                object Adapter [readonly]
 
                        The object path of the adpater the device belongs to.
+
+               object LegacyPairing [readonly]
+
+                       Set to true if the device only supports the pre-2.1
+                       pairing mechanism. This property is useful in the
+                       Adapter.DeviceFound to anticipate whether legacy or
+                       secure simple pairing will occur.
index 0ea3ad1..9725010 100644 (file)
@@ -894,6 +894,7 @@ void hcid_dbus_inquiry_result(bdaddr_t *local, bdaddr_t *peer, uint32_t class,
        const char *path, *icon, *paddr = peer_addr;
        struct remote_dev_info *dev, match;
        dbus_int16_t tmp_rssi = rssi;
+       dbus_bool_t legacy = TRUE;
        uint8_t name_type = 0x00;
        name_status_t name_status;
        int state;
@@ -909,8 +910,10 @@ void hcid_dbus_inquiry_result(bdaddr_t *local, bdaddr_t *peer, uint32_t class,
 
        write_remote_class(local, peer, class);
 
-       if (data)
+       if (data) {
                write_remote_eir(local, peer, data);
+               legacy = FALSE;
+       }
 
        /*
         * workaround to identify situation when the daemon started and
@@ -984,7 +987,9 @@ void hcid_dbus_inquiry_result(bdaddr_t *local, bdaddr_t *peer, uint32_t class,
                                "Icon", DBUS_TYPE_STRING, &icon,
                                "RSSI", DBUS_TYPE_INT16, &tmp_rssi,
                                "Name", DBUS_TYPE_STRING, &name,
-                               "Alias", DBUS_TYPE_STRING, &alias, NULL);
+                               "Alias", DBUS_TYPE_STRING, &alias,
+                               "LegacyPairing", DBUS_TYPE_BOOLEAN, &legacy,
+                               NULL);
 
        if (name && name_type != 0x08)
                name_status = NAME_SENT;
@@ -1059,12 +1064,18 @@ void hcid_dbus_remote_name(bdaddr_t *local, bdaddr_t *peer, uint8_t status,
                const char *icon = class_to_icon(dev_info->class);
                const char *alias, *paddr = dstaddr;
                dbus_int16_t rssi = dev_info->rssi;
+               dbus_bool_t legacy;
 
                if (dev_info->alias)
                        alias = dev_info->alias;
                else
                        alias = name;
 
+               if (read_remote_eir(local, peer, NULL) < 0)
+                       legacy = TRUE;
+               else
+                       legacy = FALSE;
+
                emit_device_found(adapter_path, dstaddr,
                                "Address", DBUS_TYPE_STRING, &paddr,
                                "Class", DBUS_TYPE_UINT32, &dev_info->class,
@@ -1072,6 +1083,7 @@ void hcid_dbus_remote_name(bdaddr_t *local, bdaddr_t *peer, uint8_t status,
                                "RSSI", DBUS_TYPE_INT16, &rssi,
                                "Name", DBUS_TYPE_STRING, &name,
                                "Alias", DBUS_TYPE_STRING, &alias,
+                               "LegacyPairing", DBUS_TYPE_BOOLEAN, &legacy,
                                NULL);
        }
 
index f8014e0..b385814 100644 (file)
@@ -254,6 +254,13 @@ static DBusMessage *get_properties(DBusConnection *conn,
        ptr = adapter_get_path(adapter);
        dict_append_entry(&dict, "Adapter", DBUS_TYPE_OBJECT_PATH, &ptr);
 
+       if (read_remote_eir(&src, &device->bdaddr, NULL) < 0)
+               boolean = TRUE;
+       else
+               boolean = FALSE;
+
+       dict_append_entry(&dict, "LegacyPairing", DBUS_TYPE_BOOLEAN, &boolean);
+
        dbus_message_iter_close_container(&iter, &dict);
 
        return reply;