summaryrefslogtreecommitdiff
path: root/profiles
diff options
context:
space:
mode:
authorFrédéric Danis <frederic.danis@linux.intel.com>2012-12-13 21:39:30 +0100
committerJohan Hedberg <johan.hedberg@intel.com>2012-12-13 23:00:32 +0200
commitc5bd27258c175dc80ef842f71ef222a876ff646f (patch)
tree5817015222985efd1cfb52f39a270cc3549387c9 /profiles
parentb99ee4ad4bfa2f53edf7f1326476251f14c8bbad (diff)
downloadbluez-c5bd27258c175dc80ef842f71ef222a876ff646f.tar.gz
input: Use new storage architecture
Retrieve HID record from device file located in cache directory. Remove no more used fetch_record().
Diffstat (limited to 'profiles')
-rw-r--r--profiles/input/device.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/profiles/input/device.c b/profiles/input/device.c
index 2d8077a86..9cea02857 100644
--- a/profiles/input/device.c
+++ b/profiles/input/device.c
@@ -316,9 +316,11 @@ static gboolean encrypt_notify(GIOChannel *io, GIOCondition condition,
static int hidp_add_connection(struct input_device *idev)
{
struct hidp_connadd_req *req;
- uint8_t dst_type;
sdp_record_t *rec;
char src_addr[18], dst_addr[18];
+ char filename[PATH_MAX + 1];
+ GKeyFile *key_file;
+ char handle[11], *str;
GError *gerr = NULL;
int err;
@@ -331,15 +333,25 @@ static int hidp_add_connection(struct input_device *idev)
ba2str(&idev->src, src_addr);
ba2str(&idev->dst, dst_addr);
- dst_type = device_get_addr_type(idev->device);
+ snprintf(filename, PATH_MAX, STORAGEDIR "/%s/cache/%s", src_addr,
+ dst_addr);
+ filename[PATH_MAX] = '\0';
+ sprintf(handle, "0x%8.8X", idev->handle);
- rec = fetch_record(src_addr, dst_addr, dst_type, idev->handle);
- if (!rec) {
+ key_file = g_key_file_new();
+ g_key_file_load_from_file(key_file, filename, 0, NULL);
+ str = g_key_file_get_string(key_file, "ServiceRecords", handle, NULL);
+ g_key_file_free(key_file);
+
+ if (!str) {
error("Rejected connection from unknown device %s", dst_addr);
err = -EPERM;
goto cleanup;
}
+ rec = record_from_string(str);
+ g_free(str);
+
extract_hid_record(rec, req);
sdp_record_free(rec);