Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH v2 11/15] device: Store SDP records in new storage
From: Frédéric Danis @ 2012-12-13 20:39 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1355431170-12897-1-git-send-email-frederic.danis@linux.intel.com>

Store SDP records in device file located in cache directory.

Update attributes file with primary services retrieved from attributes
entry in SDP records.

Remove store_record() from storage.[ch].
---
 src/device.c  |  123 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 src/storage.c |   33 ----------------
 src/storage.h |    2 -
 3 files changed, 122 insertions(+), 36 deletions(-)

diff --git a/src/device.c b/src/device.c
index 36840a6..d49b397 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2461,6 +2461,77 @@ static void uuids_changed(struct btd_device *device)
 	g_free(uuids);
 }
 
+static void store_sdp_record(GKeyFile *key_file, sdp_record_t *rec)
+{
+	char handle_str[11];
+	sdp_buf_t buf;
+	int size, i;
+	char *str;
+
+	sprintf(handle_str, "0x%8.8X", rec->handle);
+
+	if (sdp_gen_record_pdu(rec, &buf) < 0)
+		return;
+
+	size = buf.data_size;
+
+	str = g_malloc0(size*2+1);
+
+	for (i = 0; i < size; i++)
+		sprintf(str + (i * 2), "%02X", buf.data[i]);
+
+	g_key_file_set_string(key_file, "ServiceRecords", handle_str, str);
+
+	free(buf.data);
+	g_free(str);
+}
+
+static void store_primaries_from_sdp_record(GKeyFile *key_file,
+						sdp_record_t *rec)
+{
+	uuid_t uuid;
+	char *att_uuid, *prim_uuid;
+	uint16_t start = 0, end = 0, psm = 0;
+	char handle[6], uuid_str[33];
+	int i;
+
+	sdp_uuid16_create(&uuid, ATT_UUID);
+	att_uuid = bt_uuid2string(&uuid);
+
+	sdp_uuid16_create(&uuid, GATT_PRIM_SVC_UUID);
+	prim_uuid = bt_uuid2string(&uuid);
+
+	if (!record_has_uuid(rec, att_uuid))
+		goto done;
+
+	if (!gatt_parse_record(rec, &uuid, &psm, &start, &end))
+		goto done;
+
+	sprintf(handle, "%hu", start);
+	switch (uuid.type) {
+	case SDP_UUID16:
+		sprintf(uuid_str, "%4.4X", uuid.value.uuid16);
+		break;
+	case SDP_UUID32:
+		sprintf(uuid_str, "%8.8X", uuid.value.uuid32);
+		break;
+	case SDP_UUID128:
+		for (i = 0; i < 16; i++)
+			sprintf(uuid_str + (i * 2), "%2.2X",
+					uuid.value.uuid128.data[i]);
+		break;
+	default:
+		uuid_str[0] = '\0';
+	}
+
+	g_key_file_set_string(key_file, handle, "UUID", prim_uuid);
+	g_key_file_set_string(key_file, handle, "Value", uuid_str);
+
+done:
+	g_free(prim_uuid);
+	g_free(att_uuid);
+}
+
 static int rec_cmp(const void *a, const void *b)
 {
 	const sdp_record_t *r1 = a;
@@ -2474,10 +2545,32 @@ static void update_bredr_services(struct browse_req *req, sdp_list_t *recs)
 	struct btd_device *device = req->device;
 	sdp_list_t *seq;
 	char srcaddr[18], dstaddr[18];
+	char sdp_file[PATH_MAX + 1];
+	char att_file[PATH_MAX + 1];
+	GKeyFile *sdp_key_file = NULL;
+	GKeyFile *att_key_file = NULL;
+	char *data;
+	gsize length = 0;
 
 	ba2str(adapter_get_address(device->adapter), srcaddr);
 	ba2str(&device->bdaddr, dstaddr);
 
+	if (!device->temporary) {
+		snprintf(sdp_file, PATH_MAX, STORAGEDIR "/%s/cache/%s",
+							srcaddr, dstaddr);
+		sdp_file[PATH_MAX] = '\0';
+
+		sdp_key_file = g_key_file_new();
+		g_key_file_load_from_file(sdp_key_file, sdp_file, 0, NULL);
+
+		snprintf(att_file, PATH_MAX, STORAGEDIR "/%s/%s/attributes",
+							srcaddr, dstaddr);
+		att_file[PATH_MAX] = '\0';
+
+		att_key_file = g_key_file_new();
+		g_key_file_load_from_file(att_key_file, att_file, 0, NULL);
+	}
+
 	for (seq = recs; seq; seq = seq->next) {
 		sdp_record_t *rec = (sdp_record_t *) seq->data;
 		sdp_list_t *svcclass = NULL;
@@ -2531,7 +2624,11 @@ static void update_bredr_services(struct browse_req *req, sdp_list_t *recs)
 			continue;
 		}
 
-		store_record(srcaddr, dstaddr, device->bdaddr_type, rec);
+		if (sdp_key_file)
+			store_sdp_record(sdp_key_file, rec);
+
+		if (att_key_file)
+			store_primaries_from_sdp_record(att_key_file, rec);
 
 		/* Copy record */
 		req->records = sdp_list_append(req->records,
@@ -2552,6 +2649,30 @@ static void update_bredr_services(struct browse_req *req, sdp_list_t *recs)
 
 		sdp_list_free(svcclass, free);
 	}
+
+	if (sdp_key_file) {
+		data = g_key_file_to_data(sdp_key_file, &length, NULL);
+		if (length > 0) {
+			create_file(sdp_file, S_IRUSR | S_IWUSR |
+						S_IRGRP | S_IROTH);
+			g_file_set_contents(sdp_file, data, length, NULL);
+		}
+
+		g_free(data);
+		g_key_file_free(sdp_key_file);
+	}
+
+	if (att_key_file) {
+		data = g_key_file_to_data(att_key_file, &length, NULL);
+		if (length > 0) {
+			create_file(att_file, S_IRUSR | S_IWUSR |
+						S_IRGRP | S_IROTH);
+			g_file_set_contents(att_file, data, length, NULL);
+		}
+
+		g_free(data);
+		g_key_file_free(att_key_file);
+	}
 }
 
 static gint primary_cmp(gconstpointer a, gconstpointer b)
diff --git a/src/storage.c b/src/storage.c
index d4516ed..180946f 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -245,39 +245,6 @@ ssize_t read_pin_code(const bdaddr_t *local, const bdaddr_t *peer, char *pin)
 	return len;
 }
 
-int store_record(const gchar *src, const gchar *dst, uint8_t dst_type,
-							sdp_record_t *rec)
-{
-	char filename[PATH_MAX + 1], key[30];
-	sdp_buf_t buf;
-	int err, size, i;
-	char *str;
-
-	create_name(filename, PATH_MAX, STORAGEDIR, src, "sdp");
-
-	create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-
-	snprintf(key, sizeof(key), "%17s#%hhu#%08X", dst, dst_type,
-								rec->handle);
-
-	if (sdp_gen_record_pdu(rec, &buf) < 0)
-		return -1;
-
-	size = buf.data_size;
-
-	str = g_malloc0(size*2+1);
-
-	for (i = 0; i < size; i++)
-		sprintf(str + (i * 2), "%02X", buf.data[i]);
-
-	err = textfile_put(filename, key, str);
-
-	free(buf.data);
-	g_free(str);
-
-	return err;
-}
-
 sdp_record_t *record_from_string(const gchar *str)
 {
 	sdp_record_t *rec;
diff --git a/src/storage.h b/src/storage.h
index ffc6deb..262a594 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -35,8 +35,6 @@ int read_remote_appearance(const bdaddr_t *local, const bdaddr_t *peer,
 int write_lastused_info(const bdaddr_t *local, const bdaddr_t *peer,
 					uint8_t peer_type, struct tm *tm);
 ssize_t read_pin_code(const bdaddr_t *local, const bdaddr_t *peer, char *pin);
-int store_record(const gchar *src, const gchar *dst, uint8_t dst_type,
-							sdp_record_t *rec);
 sdp_record_t *record_from_string(const gchar *str);
 sdp_record_t *fetch_record(const gchar *src, const gchar *dst,
 			   uint8_t dst_type, const uint32_t handle);
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH v2 12/15] adapter: Convert device primaries list
From: Frédéric Danis @ 2012-12-13 20:39 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1355431170-12897-1-git-send-email-frederic.danis@linux.intel.com>

---
 src/adapter.c |   95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)

diff --git a/src/adapter.c b/src/adapter.c
index 02d54a3..64d8ed3 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2762,6 +2762,88 @@ failed:
 	g_free(att_uuid);
 }
 
+static void convert_primaries_entry(char *key, char *value, void *user_data)
+{
+	char *address = user_data;
+	char device_type = -1;
+	uuid_t uuid;
+	char **services, **service, *prim_uuid;
+	char filename[PATH_MAX + 1];
+	GKeyFile *key_file;
+	int ret;
+	uint16_t start, end;
+	char uuid_str[MAX_LEN_UUID_STR + 1];
+	char *data;
+	gsize length = 0;
+
+	if (key[17] == '#') {
+		key[17] = '\0';
+		device_type = key[18] - '0';
+	}
+
+	if (bachk(key) != 0)
+		return;
+
+	services = g_strsplit(value, " ", 0);
+	if (services == NULL)
+		return;
+
+	sdp_uuid16_create(&uuid, GATT_PRIM_SVC_UUID);
+	prim_uuid = bt_uuid2string(&uuid);
+
+	snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s/attributes", address,
+									key);
+	filename[PATH_MAX] = '\0';
+
+	key_file = g_key_file_new();
+	g_key_file_load_from_file(key_file, filename, 0, NULL);
+
+	for (service = services; *service; service++) {
+		ret = sscanf(*service, "%04hX#%04hX#%s", &start, &end,
+								uuid_str);
+		if (ret < 3)
+			continue;
+
+		bt_string2uuid(&uuid, uuid_str);
+		sdp_uuid128_to_uuid(&uuid);
+
+		store_attribute_uuid(key_file, start, prim_uuid, uuid);
+	}
+
+	g_strfreev(services);
+
+	data = g_key_file_to_data(key_file, &length, NULL);
+	if (length == 0)
+		goto end;
+
+	create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+	g_file_set_contents(filename, data, length, NULL);
+
+	if (device_type < 0)
+		goto end;
+
+	g_free(data);
+	g_key_file_free(key_file);
+
+	snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s/info", address, key);
+	filename[PATH_MAX] = '\0';
+
+	key_file = g_key_file_new();
+	g_key_file_load_from_file(key_file, filename, 0, NULL);
+	set_device_type(key_file, device_type);
+
+	data = g_key_file_to_data(key_file, &length, NULL);
+	if (length > 0) {
+		create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+		g_file_set_contents(filename, data, length, NULL);
+	}
+
+end:
+	g_free(data);
+	g_free(prim_uuid);
+	g_key_file_free(key_file);
+}
+
 static void convert_device_storage(struct btd_adapter *adapter)
 {
 	char filename[PATH_MAX + 1];
@@ -2795,6 +2877,19 @@ static void convert_device_storage(struct btd_adapter *adapter)
 	/* Convert profiles */
 	convert_file("profiles", address, convert_profiles_entry, TRUE);
 
+	/* Convert primaries */
+	snprintf(filename, PATH_MAX, STORAGEDIR "/%s/primaries", address);
+	filename[PATH_MAX] = '\0';
+
+	str = textfile_get(filename, "converted");
+	if (str && strcmp(str, "yes") == 0) {
+		DBG("Legacy %s file already converted", filename);
+	} else {
+		textfile_foreach(filename, convert_primaries_entry, address);
+		textfile_put(filename, "converted", "yes");
+	}
+	free(str);
+
 	/* Convert linkkeys */
 	convert_file("linkkeys", address, convert_linkkey_entry, TRUE);
 
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH v2 13/15] adapter: Remove create_stored_device_from_primaries
From: Frédéric Danis @ 2012-12-13 20:39 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1355431170-12897-1-git-send-email-frederic.danis@linux.intel.com>

Loading of primaries list is done by device_create_from_storage().

As all device load during start-up has been converted, we can remove
temporary hack in device_create().
---
 src/adapter.c |   80 ++-------------------------------------------------------
 src/device.c  |   22 +++++-----------
 2 files changed, 8 insertions(+), 94 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 64d8ed3..80dbc77 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1725,80 +1725,6 @@ failed:
 	return ltk;
 }
 
-static GSList *string_to_primary_list(char *str)
-{
-	GSList *l = NULL;
-	char **services;
-	int i;
-
-	if (str == NULL)
-		return NULL;
-
-	services = g_strsplit(str, " ", 0);
-	if (services == NULL)
-		return NULL;
-
-	for (i = 0; services[i]; i++) {
-		struct gatt_primary *prim;
-		int ret;
-
-		prim = g_new0(struct gatt_primary, 1);
-
-		ret = sscanf(services[i], "%04hX#%04hX#%s", &prim->range.start,
-							&prim->range.end, prim->uuid);
-
-		if (ret < 3) {
-			g_free(prim);
-			continue;
-		}
-
-		l = g_slist_append(l, prim);
-	}
-
-	g_strfreev(services);
-
-	return l;
-}
-
-static void create_stored_device_from_primaries(char *key, char *value,
-							void *user_data)
-{
-	struct btd_adapter *adapter = user_data;
-	struct btd_device *device;
-	GSList *services, *uuids, *l;
-	char address[18];
-	uint8_t bdaddr_type;
-
-	if (sscanf(key, "%17s#%hhu", address, &bdaddr_type) < 2)
-		return;
-
-	if (g_slist_find_custom(adapter->devices,
-			address, (GCompareFunc) device_address_cmp))
-		return;
-
-	device = device_create(adapter, address, bdaddr_type);
-	if (!device)
-		return;
-
-	device_set_temporary(device, FALSE);
-	adapter->devices = g_slist_append(adapter->devices, device);
-
-	services = string_to_primary_list(value);
-	if (services == NULL)
-		return;
-
-	for (l = services, uuids = NULL; l; l = l->next) {
-		struct gatt_primary *prim = l->data;
-		uuids = g_slist_append(uuids, prim->uuid);
-	}
-
-	device_register_primaries(device, services, -1);
-
-	device_probe_profiles(device, uuids);
-
-	g_slist_free(uuids);
-}
-
 static void load_devices(struct btd_adapter *adapter)
 {
 	char filename[PATH_MAX + 1];
@@ -1811,10 +1737,6 @@ static void load_devices(struct btd_adapter *adapter)
 
 	ba2str(&adapter->bdaddr, srcaddr);
 
-	create_name(filename, PATH_MAX, STORAGEDIR, srcaddr, "primaries");
-	textfile_foreach(filename, create_stored_device_from_primaries,
-								adapter);
-
 	snprintf(filename, PATH_MAX, STORAGEDIR "/%s", srcaddr);
 	filename[PATH_MAX] = '\0';
 
@@ -1864,6 +1786,8 @@ static void load_devices(struct btd_adapter *adapter)
 		device_set_temporary(device, FALSE);
 		adapter->devices = g_slist_append(adapter->devices, device);
 
+		/* TODO: register services from pre-loaded list of primaries */
+
 		l = device_get_uuids(device);
 		if (l)
 			device_probe_profiles(device, l);
diff --git a/src/device.c b/src/device.c
index d49b397..fc37e51 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2013,8 +2013,7 @@ struct btd_device *device_create(struct btd_adapter *adapter,
 	struct btd_device *device;
 	const bdaddr_t *src;
 	char srcaddr[18];
-	char filename[PATH_MAX + 1];
-	GKeyFile *key_file;
+	char *str;
 
 	device = device_new(adapter, address);
 	if (device == NULL)
@@ -2024,20 +2023,11 @@ struct btd_device *device_create(struct btd_adapter *adapter,
 	src = adapter_get_address(adapter);
 	ba2str(src, srcaddr);
 
-	/*TODO: after all device load during start-up has been converted to
-	 * new key file structure, this should be replaced by :
-	 *	str = load_cached_name(device, srcaddr, address);
-	 *	if (str) {
-	 *		strcpy(device->name, str);
-	 *		g_free(str);
-	 *	}
-	 */
-	snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s/info", srcaddr,
-			address);
-	key_file = g_key_file_new();
-	g_key_file_load_from_file(key_file, filename, 0, NULL);
-	load_info(device, srcaddr, address, key_file);
-	g_key_file_free(key_file);
+	str = load_cached_name(device, srcaddr, address);
+	if (str) {
+		strcpy(device->name, str);
+		g_free(str);
+	}
 
 	return btd_device_ref(device);
 }
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH v2 14/15] device: Update btd_device_get_record to use new storage
From: Frédéric Danis @ 2012-12-13 20:39 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1355431170-12897-1-git-send-email-frederic.danis@linux.intel.com>

Remove no more used functions from storage.[ch].
---
 src/device.c  |   40 ++++++++++++++++++++++++++++++++++++++--
 src/storage.c |   38 --------------------------------------
 src/storage.h |    1 -
 3 files changed, 38 insertions(+), 41 deletions(-)

diff --git a/src/device.c b/src/device.c
index fc37e51..96b226f 100644
--- a/src/device.c
+++ b/src/device.c
@@ -4051,6 +4051,43 @@ void btd_device_add_uuid(struct btd_device *device, const char *uuid)
 	uuids_changed(device);
 }
 
+static sdp_list_t *read_device_records(struct btd_device *device)
+{
+	char local[18], peer[18];
+	char filename[PATH_MAX + 1];
+	GKeyFile *key_file;
+	char **keys, **handle;
+	char *str;
+	sdp_list_t *recs = NULL;
+	sdp_record_t *rec;
+
+	ba2str(adapter_get_address(device->adapter), local);
+	ba2str(&device->bdaddr, peer);
+
+	snprintf(filename, PATH_MAX, STORAGEDIR "/%s/cache/%s", local, peer);
+	filename[PATH_MAX] = '\0';
+
+	key_file = g_key_file_new();
+	g_key_file_load_from_file(key_file, filename, 0, NULL);
+	keys = g_key_file_get_keys(key_file, "ServiceRecords", NULL, NULL);
+
+	for (handle = keys; *handle; handle++) {
+		str = g_key_file_get_string(key_file, "ServiceRecords",
+						*handle, NULL);
+		if (!str)
+			continue;
+
+		rec = record_from_string(str);
+		recs = sdp_list_append(recs, rec);
+		g_free(str);
+	}
+
+	g_strfreev(keys);
+	g_key_file_free(key_file);
+
+	return recs;
+}
+
 const sdp_record_t *btd_device_get_record(struct btd_device *device,
 							const char *uuid)
 {
@@ -4066,8 +4103,7 @@ const sdp_record_t *btd_device_get_record(struct btd_device *device,
 		device->tmp_records = NULL;
 	}
 
-	device->tmp_records = read_records(adapter_get_address(device->adapter),
-							&device->bdaddr);
+	device->tmp_records = read_device_records(device);
 	if (!device->tmp_records)
 		return NULL;
 
diff --git a/src/storage.c b/src/storage.c
index 180946f..d3cbc8f 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -319,44 +319,6 @@ int delete_record(const gchar *src, const gchar *dst, uint8_t dst_type,
 	return err;
 }
 
-struct record_list {
-	sdp_list_t *recs;
-	const gchar *addr;
-};
-
-static void create_stored_records_from_keys(char *key, char *value,
-							void *user_data)
-{
-	struct record_list *rec_list = user_data;
-	const gchar *addr = rec_list->addr;
-	sdp_record_t *rec;
-
-	if (strncmp(key, addr, 17))
-		return;
-
-	rec = record_from_string(value);
-
-	rec_list->recs = sdp_list_append(rec_list->recs, rec);
-}
-
-sdp_list_t *read_records(const bdaddr_t *src, const bdaddr_t *dst)
-{
-	char filename[PATH_MAX + 1];
-	struct record_list rec_list;
-	char srcaddr[18], dstaddr[18];
-
-	ba2str(src, srcaddr);
-	ba2str(dst, dstaddr);
-
-	rec_list.addr = dstaddr;
-	rec_list.recs = NULL;
-
-	create_name(filename, PATH_MAX, STORAGEDIR, srcaddr, "sdp");
-	textfile_foreach(filename, create_stored_records_from_keys, &rec_list);
-
-	return rec_list.recs;
-}
-
 sdp_record_t *find_record_in_list(sdp_list_t *recs, const char *uuid)
 {
 	sdp_list_t *seq;
diff --git a/src/storage.h b/src/storage.h
index 262a594..4c99693 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -40,7 +40,6 @@ sdp_record_t *fetch_record(const gchar *src, const gchar *dst,
 			   uint8_t dst_type, const uint32_t handle);
 int delete_record(const gchar *src, const gchar *dst, uint8_t dst_type,
 							const uint32_t handle);
-sdp_list_t *read_records(const bdaddr_t *src, const bdaddr_t *dst);
 sdp_record_t *find_record_in_list(sdp_list_t *recs, const char *uuid);
 int read_device_pairable(const bdaddr_t *local, gboolean *mode);
 int write_device_services(const bdaddr_t *sba, const bdaddr_t *dba,
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH v2 15/15] input: Use new storage architecture
From: Frédéric Danis @ 2012-12-13 20:39 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1355431170-12897-1-git-send-email-frederic.danis@linux.intel.com>

Retrieve HID record from device file located in cache directory.

Remove no more used fetch_record().
---
 profiles/input/device.c |   20 ++++++++++++++++----
 src/storage.c           |   27 ---------------------------
 src/storage.h           |    2 --
 3 files changed, 16 insertions(+), 33 deletions(-)

diff --git a/profiles/input/device.c b/profiles/input/device.c
index 2d8077a..9cea028 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);
 
diff --git a/src/storage.c b/src/storage.c
index d3cbc8f..33da2cb 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -268,33 +268,6 @@ sdp_record_t *record_from_string(const gchar *str)
 }
 
 
-sdp_record_t *fetch_record(const gchar *src, const gchar *dst,
-			   uint8_t dst_type, const uint32_t handle)
-{
-	char filename[PATH_MAX + 1], old_key[28], key[30], *str;
-	sdp_record_t *rec;
-
-	create_name(filename, PATH_MAX, STORAGEDIR, src, "sdp");
-
-	snprintf(key, sizeof(key), "%17s#%hhu#%08X", dst, dst_type, handle);
-	snprintf(old_key, sizeof(old_key), "%17s#%08X", dst, handle);
-
-	str = textfile_get(filename, key);
-	if (str != NULL)
-		goto done;
-
-	/* Try old format (address#handle) */
-	str = textfile_get(filename, old_key);
-	if (str == NULL)
-		return NULL;
-
-done:
-	rec = record_from_string(str);
-	free(str);
-
-	return rec;
-}
-
 int delete_record(const gchar *src, const gchar *dst, uint8_t dst_type,
 							const uint32_t handle)
 {
diff --git a/src/storage.h b/src/storage.h
index 4c99693..b125818 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -36,8 +36,6 @@ int write_lastused_info(const bdaddr_t *local, const bdaddr_t *peer,
 					uint8_t peer_type, struct tm *tm);
 ssize_t read_pin_code(const bdaddr_t *local, const bdaddr_t *peer, char *pin);
 sdp_record_t *record_from_string(const gchar *str);
-sdp_record_t *fetch_record(const gchar *src, const gchar *dst,
-			   uint8_t dst_type, const uint32_t handle);
 int delete_record(const gchar *src, const gchar *dst, uint8_t dst_type,
 							const uint32_t handle);
 sdp_record_t *find_record_in_list(sdp_list_t *recs, const char *uuid);
-- 
1.7.9.5


^ permalink raw reply related

* Re: [PATCH v2 01/15] device: Retrieve device technology from storage
From: Johan Hedberg @ 2012-12-14  8:31 UTC (permalink / raw)
  To: Frédéric Danis; +Cc: linux-bluetooth
In-Reply-To: <1355431170-12897-1-git-send-email-frederic.danis@linux.intel.com>

Hi Frédéric,

On Thu, Dec 13, 2012, Frédéric Danis wrote:
> ---
>  src/device.c |   68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 68 insertions(+)

All patches in this set have been applied. I also applied one extra
patch to convert "Profiles" to "Services" since the value consists of
service UUIDs and not profile UUIDs.

Johan

^ permalink raw reply

* [PATCH BlueZ 01/13] network: Append version to Network and NetworkServer interfaces
From: Luiz Augusto von Dentz @ 2012-12-14  9:12 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 doc/network-api.txt           | 4 ++--
 profiles/network/connection.c | 2 +-
 profiles/network/server.c     | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/doc/network-api.txt b/doc/network-api.txt
index b640b9a..1c9d889 100644
--- a/doc/network-api.txt
+++ b/doc/network-api.txt
@@ -8,7 +8,7 @@ Network hierarchy
 =================
 
 Service		org.bluez
-Interface	org.bluez.Network
+Interface	org.bluez.Network1
 Object path	[variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX
 
 Properties	boolean Connected [readonly]
@@ -28,7 +28,7 @@ Network server hierarchy
 ========================
 
 Service		org.bluez
-Interface	org.bluez.NetworkServer
+Interface	org.bluez.NetworkServer1
 Object path	/org/bluez/{hci0,hci1,...}
 
 Methods		void Register(string uuid, string bridge)
diff --git a/profiles/network/connection.c b/profiles/network/connection.c
index 3157e31..5fa3e1b 100644
--- a/profiles/network/connection.c
+++ b/profiles/network/connection.c
@@ -49,7 +49,7 @@
 #include "manager.h"
 #include "connection.h"
 
-#define NETWORK_PEER_INTERFACE "org.bluez.Network"
+#define NETWORK_PEER_INTERFACE "org.bluez.Network1"
 #define CON_SETUP_RETRIES      3
 #define CON_SETUP_TO           9
 
diff --git a/profiles/network/server.c b/profiles/network/server.c
index e32e51d..2869c28 100644
--- a/profiles/network/server.c
+++ b/profiles/network/server.c
@@ -51,7 +51,7 @@
 #include "common.h"
 #include "server.h"
 
-#define NETWORK_SERVER_INTERFACE "org.bluez.NetworkServer"
+#define NETWORK_SERVER_INTERFACE "org.bluez.NetworkServer1"
 #define SETUP_TIMEOUT		1
 
 /* Pending Authorization */
-- 
1.7.11.7


^ permalink raw reply related

* [PATCH BlueZ 02/13] audio: Append version to Control interface
From: Luiz Augusto von Dentz @ 2012-12-14  9:12 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1355476387-2165-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 doc/control-api.txt      | 2 +-
 profiles/audio/control.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/control-api.txt b/doc/control-api.txt
index 55cebe8..5fc8991 100644
--- a/doc/control-api.txt
+++ b/doc/control-api.txt
@@ -9,7 +9,7 @@ Control hierarchy
 =================
 
 Service		org.bluez
-Interface	org.bluez.Control
+Interface	org.bluez.Control1
 Object path	[variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX
 
 Methods		void Play()
diff --git a/profiles/audio/control.h b/profiles/audio/control.h
index 800a151..878dd1e 100644
--- a/profiles/audio/control.h
+++ b/profiles/audio/control.h
@@ -22,7 +22,7 @@
  *
  */
 
-#define AUDIO_CONTROL_INTERFACE "org.bluez.Control"
+#define AUDIO_CONTROL_INTERFACE "org.bluez.Control1"
 
 struct control *control_init(struct audio_device *dev, GSList *uuids);
 void control_update(struct control *control, GSList *uuids);
-- 
1.7.11.7


^ permalink raw reply related

* [PATCH BlueZ 03/13] heartrate: Append version to HeartRate interfaces
From: Luiz Augusto von Dentz @ 2012-12-14  9:12 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1355476387-2165-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 doc/heartrate-api.txt          |  6 +++---
 profiles/heartrate/heartrate.c |  6 +++---
 src/bluetooth.conf             |  2 +-
 test/test-heartrate            | 19 ++++++++++++-------
 4 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/doc/heartrate-api.txt b/doc/heartrate-api.txt
index d1d5191..0f202bd 100644
--- a/doc/heartrate-api.txt
+++ b/doc/heartrate-api.txt
@@ -8,7 +8,7 @@ Heart Rate Manager hierarchy
 ============================
 
 Service		org.bluez
-Interface	org.bluez.HeartRateManager
+Interface	org.bluez.HeartRateManager1
 Object path	[variable prefix]/{hci0,hci1,...}
 
 Methods		RegisterWatcher(object agent)
@@ -25,7 +25,7 @@ Heart Rate Profile hierarchy
 ============================
 
 Service		org.bluez
-Interface	org.bluez.HeartRate
+Interface	org.bluez.HeartRate1
 Object path	[variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX
 
 Methods		Reset()
@@ -47,7 +47,7 @@ Heart Rate Watcher hierarchy
 ============================
 
 Service		unique name
-Interface	org.bluez.HeartRateWatcher
+Interface	org.bluez.HeartRateWatcher1
 Object path	freely definable
 
 Methods		void MeasurementReceived(object device, dict measurement)
diff --git a/profiles/heartrate/heartrate.c b/profiles/heartrate/heartrate.c
index 155100e..f4edf09 100644
--- a/profiles/heartrate/heartrate.c
+++ b/profiles/heartrate/heartrate.c
@@ -41,9 +41,9 @@
 #include "log.h"
 #include "heartrate.h"
 
-#define HEART_RATE_INTERFACE		"org.bluez.HeartRate"
-#define HEART_RATE_MANAGER_INTERFACE	"org.bluez.HeartRateManager"
-#define HEART_RATE_WATCHER_INTERFACE	"org.bluez.HeartRateWatcher"
+#define HEART_RATE_INTERFACE		"org.bluez.HeartRate1"
+#define HEART_RATE_MANAGER_INTERFACE	"org.bluez.HeartRateManager1"
+#define HEART_RATE_WATCHER_INTERFACE	"org.bluez.HeartRateWatcher1"
 
 #define HR_VALUE_FORMAT		0x01
 #define SENSOR_CONTACT_DETECTED	0x02
diff --git a/src/bluetooth.conf b/src/bluetooth.conf
index 6111fdb..72d4248 100644
--- a/src/bluetooth.conf
+++ b/src/bluetooth.conf
@@ -18,7 +18,7 @@
     <allow send_interface="org.bluez.ThermometerWatcher"/>
     <allow send_interface="org.bluez.AlertAgent"/>
     <allow send_interface="org.bluez.Profile1"/>
-    <allow send_interface="org.bluez.HeartRateWatcher"/>
+    <allow send_interface="org.bluez.HeartRateWatcher1"/>
     <allow send_interface="org.bluez.CyclingSpeedWatcher"/>
   </policy>
 
diff --git a/test/test-heartrate b/test/test-heartrate
index 47dd012..f26b3db 100755
--- a/test/test-heartrate
+++ b/test/test-heartrate
@@ -15,8 +15,13 @@ import dbus.mainloop.glib
 from optparse import OptionParser, make_option
 import bluezutils
 
+BUS_NAME = 'org.bluez'
+HEARTRATE_MANAGER_INTERFACE = 'org.bluez.HeartRateManager1'
+HEARTRATE_WATCHER_INTERFACE = 'org.bluez.HeartRateWatcher1'
+HEARTRATE_INTERFACE = 'org.bluez.HeartRate1'
+
 class Watcher(dbus.service.Object):
-	@dbus.service.method("org.bluez.HeartRateWatcher",
+	@dbus.service.method(HEARTRATE_WATCHER_INTERFACE,
 					in_signature="oa{sv}", out_signature="")
 	def MeasurementReceived(self, device, measure):
 		print("Measurement received from %s" % device)
@@ -59,8 +64,8 @@ if __name__ == "__main__":
 								options.adapter)
 	adapter_path = adapter.object_path
 
-	heartrateManager = dbus.Interface(bus.get_object("org.bluez",
-				adapter_path), "org.bluez.HeartRateManager")
+	heartrateManager = dbus.Interface(bus.get_object(BUS_NAME,
+				adapter_path), HEARTRATE_MANAGER_INTERFACE)
 
 	path = "/test/watcher"
 	heartrateManager.RegisterWatcher(path)
@@ -70,15 +75,15 @@ if __name__ == "__main__":
 								options.adapter)
 	device_path = device.object_path
 
-	heartrate = dbus.Interface(bus.get_object("org.bluez",
-					device_path), "org.bluez.HeartRate")
+	heartrate = dbus.Interface(bus.get_object(BUS_NAME, device_path),
+							HEARTRATE_INTERFACE)
 
 	watcher = Watcher(bus, path)
 
-	dev_prop = dbus.Interface(bus.get_object("org.bluez", device_path),
+	dev_prop = dbus.Interface(bus.get_object(BUS_NAME, device_path),
 					"org.freedesktop.DBus.Properties")
 
-	properties = dev_prop.GetAll("org.bluez.HeartRate")
+	properties = dev_prop.GetAll(HEARTRATE_INTERFACE)
 
 	if "Location" in properties:
 		print("Sensor location: %s" % properties["Location"])
-- 
1.7.11.7


^ permalink raw reply related

* [PATCH BlueZ 04/13] cyclingspeed: Append version to CyclingSpeed interfaces
From: Luiz Augusto von Dentz @ 2012-12-14  9:12 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1355476387-2165-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 doc/cyclingspeed-api.txt             |  6 +++---
 profiles/cyclingspeed/cyclingspeed.c |  6 +++---
 src/bluetooth.conf                   |  2 +-
 test/test-cyclingspeed               | 23 ++++++++++++++---------
 4 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/doc/cyclingspeed-api.txt b/doc/cyclingspeed-api.txt
index 08e11c8..1a2dfee 100644
--- a/doc/cyclingspeed-api.txt
+++ b/doc/cyclingspeed-api.txt
@@ -7,7 +7,7 @@ Cycling Speed and Cadence Manager hierarchy
 ===========================================
 
 Service		org.bluez
-Interface	org.bluez.CyclingSpeedManager
+Interface	org.bluez.CyclingSpeedManager1
 Object path	[variable prefix]/{hci0,hci1,...}
 
 Methods		RegisterWatcher(object agent)
@@ -25,7 +25,7 @@ Cycling Speed and Cadence Profile hierarchy
 ===========================================
 
 Service		org.bluez
-Interface	org.bluez.CyclingSpeed
+Interface	org.bluez.CyclingSpeed1
 Object path	[variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX
 
 Methods		SetCumulativeWheelRevolutions(uint32 value)
@@ -68,7 +68,7 @@ Cycling Speed and Cadence Watcher hierarchy
 ===========================================
 
 Service		unique name
-Interface	org.bluez.CyclingSpeedWatcher
+Interface	org.bluez.CyclingSpeedWatcher1
 Object path	freely definable
 
 Methods		void MeasurementReceived(object device, dict measurement)
diff --git a/profiles/cyclingspeed/cyclingspeed.c b/profiles/cyclingspeed/cyclingspeed.c
index e236ff7..e0ba4d2 100644
--- a/profiles/cyclingspeed/cyclingspeed.c
+++ b/profiles/cyclingspeed/cyclingspeed.c
@@ -47,9 +47,9 @@
 
 #define ATT_TIMEOUT 30
 
-#define CYCLINGSPEED_INTERFACE		"org.bluez.CyclingSpeed"
-#define CYCLINGSPEED_MANAGER_INTERFACE	"org.bluez.CyclingSpeedManager"
-#define CYCLINGSPEED_WATCHER_INTERFACE	"org.bluez.CyclingSpeedWatcher"
+#define CYCLINGSPEED_INTERFACE		"org.bluez.CyclingSpeed1"
+#define CYCLINGSPEED_MANAGER_INTERFACE	"org.bluez.CyclingSpeedManager1"
+#define CYCLINGSPEED_WATCHER_INTERFACE	"org.bluez.CyclingSpeedWatcher1"
 
 #define WHEEL_REV_SUPPORT		0x01
 #define CRANK_REV_SUPPORT		0x02
diff --git a/src/bluetooth.conf b/src/bluetooth.conf
index 72d4248..137e4e4 100644
--- a/src/bluetooth.conf
+++ b/src/bluetooth.conf
@@ -19,7 +19,7 @@
     <allow send_interface="org.bluez.AlertAgent"/>
     <allow send_interface="org.bluez.Profile1"/>
     <allow send_interface="org.bluez.HeartRateWatcher1"/>
-    <allow send_interface="org.bluez.CyclingSpeedWatcher"/>
+    <allow send_interface="org.bluez.CyclingSpeedWatcher1"/>
   </policy>
 
   <policy at_console="true">
diff --git a/test/test-cyclingspeed b/test/test-cyclingspeed
index 10a16aa..533120a 100755
--- a/test/test-cyclingspeed
+++ b/test/test-cyclingspeed
@@ -14,6 +14,11 @@ import dbus.service
 import dbus.mainloop.glib
 from optparse import OptionParser, make_option
 
+BUS_NAME = 'org.bluez'
+CYCLINGSPEED_MANAGER_INTERFACE = 'org.bluez.CyclingSpeedManager1'
+CYCLINGSPEED_WATCHER_INTERFACE = 'org.bluez.CyclingSpeedWatcher1'
+CYCLINGSPEED_INTERFACE = 'org.bluez.CyclingSpeed1'
+
 class MeasurementQ:
 	def __init__(self, wrap_v):
 		self._now = [None, None]
@@ -50,7 +55,7 @@ class Watcher(dbus.service.Object):
 	def enable_calc(self, v):
 		self._circumference = v
 
-	@dbus.service.method("org.bluez.CyclingSpeedWatcher",
+	@dbus.service.method(CYCLINGSPEED_WATCHER_INTERFACE,
 					in_signature="oa{sv}", out_signature="")
 	def MeasurementReceived(self, device, measure):
 		print("Measurement received from %s" % device)
@@ -135,8 +140,8 @@ if __name__ == "__main__":
 								options.adapter)
 	device_path = device.object_path
 
-	cscmanager = dbus.Interface(bus.get_object("org.bluez", adapter_path),
-						"org.bluez.CyclingSpeedManager")
+	cscmanager = dbus.Interface(bus.get_object(BUS_NAME, adapter_path),
+						CYCLINGSPEED_WATCHER_INTERFACE)
 
 	watcher_path = "/test/watcher"
 	watcher = Watcher(bus, watcher_path)
@@ -144,18 +149,18 @@ if __name__ == "__main__":
 		watcher.enable_calc(options.circumference)
 	cscmanager.RegisterWatcher(watcher_path)
 
-	csc = dbus.Interface(bus.get_object("org.bluez", device_path),
-						"org.bluez.CyclingSpeed")
+	csc = dbus.Interface(bus.get_object(BUS_NAME, device_path),
+							CYCLINGSPEED_INTERFACE)
 
-	bus.add_signal_receiver(properties_changed, bus_name="org.bluez",
+	bus.add_signal_receiver(properties_changed, bus_name=BUS_NAME,
 				path=device_path,
 				dbus_interface="org.freedesktop.DBus.Properties",
 				signal_name="PropertiesChanged")
 
-	device_prop = dbus.Interface(bus.get_object("org.bluez", device_path),
+	device_prop = dbus.Interface(bus.get_object(BUS_NAME, device_path),
 					"org.freedesktop.DBus.Properties")
 
-	properties = device_prop.GetAll("org.bluez.CyclingSpeed")
+	properties = device_prop.GetAll(CYCLINGSPEED_INTERFACE)
 
 	if "Location" in properties:
 		print("Sensor location: %s" % properties["Location"])
@@ -171,7 +176,7 @@ if __name__ == "__main__":
 
 		elif args[0] == "SetLocation":
 			if properties["MultipleSensorLocationsSupported"]:
-				device_prop.Set("org.bluez.CyclingSpeed", "Location", args[1])
+				device_prop.Set(CYCLINGSPEED_INTERFACE, "Location", args[1])
 			else:
 				print("Multiple sensor locations not supported")
 
-- 
1.7.11.7


^ permalink raw reply related

* [PATCH BlueZ 05/13] thermometer: Append version to Thermometer interfaces
From: Luiz Augusto von Dentz @ 2012-12-14  9:12 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1355476387-2165-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 doc/thermometer-api.txt            |  6 +++---
 profiles/thermometer/thermometer.c |  6 +++---
 src/bluetooth.conf                 |  2 +-
 test/test-thermometer              | 15 ++++++++++-----
 4 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/doc/thermometer-api.txt b/doc/thermometer-api.txt
index cab115f..c7c8a5d 100644
--- a/doc/thermometer-api.txt
+++ b/doc/thermometer-api.txt
@@ -7,7 +7,7 @@ Health Thermometer Manager hierarchy
 ====================================
 
 Service		org.bluez
-Interface	org.bluez.ThermometerManager
+Interface	org.bluez.ThermometerManager1
 Object path	[variable prefix]/{hci0,hci1,...}
 
 Methods		RegisterWatcher(object agent)
@@ -44,7 +44,7 @@ Health Thermometer Profile hierarchy
 ====================================
 
 Service		org.bluez
-Interface	org.bluez.Thermometer
+Interface	org.bluez.Thermometer1
 Object path	[variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX
 
 
@@ -77,7 +77,7 @@ Health Thermometer Watcher hierarchy
 ====================================
 
 Service		unique name
-Interface	org.bluez.ThermometerWatcher
+Interface	org.bluez.ThermometerWatcher1
 Object path	freely definable
 
 Methods		void MeasurementReceived(dict measurement)
diff --git a/profiles/thermometer/thermometer.c b/profiles/thermometer/thermometer.c
index 537db99..15db33e 100644
--- a/profiles/thermometer/thermometer.c
+++ b/profiles/thermometer/thermometer.c
@@ -42,9 +42,9 @@
 #include "attrib/gatt.h"
 #include "thermometer.h"
 
-#define THERMOMETER_INTERFACE		"org.bluez.Thermometer"
-#define THERMOMETER_MANAGER_INTERFACE	"org.bluez.ThermometerManager"
-#define THERMOMETER_WATCHER_INTERFACE	"org.bluez.ThermometerWatcher"
+#define THERMOMETER_INTERFACE		"org.bluez.Thermometer1"
+#define THERMOMETER_MANAGER_INTERFACE	"org.bluez.ThermometerManager1"
+#define THERMOMETER_WATCHER_INTERFACE	"org.bluez.ThermometerWatcher1"
 
 /* Temperature measurement flag fields */
 #define TEMP_UNITS		0x01
diff --git a/src/bluetooth.conf b/src/bluetooth.conf
index 137e4e4..5750f49 100644
--- a/src/bluetooth.conf
+++ b/src/bluetooth.conf
@@ -15,7 +15,7 @@
     <allow send_interface="org.bluez.MediaEndpoint1"/>
     <allow send_interface="org.bluez.MediaPlayer1"/>
     <allow send_interface="org.bluez.Watcher"/>
-    <allow send_interface="org.bluez.ThermometerWatcher"/>
+    <allow send_interface="org.bluez.ThermometerWatcher1"/>
     <allow send_interface="org.bluez.AlertAgent"/>
     <allow send_interface="org.bluez.Profile1"/>
     <allow send_interface="org.bluez.HeartRateWatcher1"/>
diff --git a/test/test-thermometer b/test/test-thermometer
index fdb772f..6c143be 100755
--- a/test/test-thermometer
+++ b/test/test-thermometer
@@ -15,8 +15,13 @@ import dbus.mainloop.glib
 from optparse import OptionParser, make_option
 import bluezutils
 
+BUS_NAME = 'org.bluez'
+THERMOMETER_MANAGER_INTERFACE = 'org.bluez.ThermometerManager1'
+THERMOMETER_WATCHER_INTERFACE = 'org.bluez.ThermometerWatcher1'
+THERMOMETER_INTERFACE = 'org.bluez.Thermometer1'
+
 class Watcher(dbus.service.Object):
-	@dbus.service.method("org.bluez.ThermometerWatcher",
+	@dbus.service.method(THERMOMETER_WATCHER_INTERFACE,
 					in_signature="oa{sv}", out_signature="")
 	def MeasurementReceived(self, device, measure):
 		print("%s measurement received from %s" % (measure["Measurement"], device))
@@ -31,7 +36,7 @@ class Watcher(dbus.service.Object):
 			print("Type: ", measure["Type"])
 
 def properties_changed(interface, changed, invalidated):
-	if interface != "org.bluez.Thermometer":
+	if interface != THERMOMETER_INTERFACE:
 		return
 	for name, value in changed.iteritems():
 		print("Property %s changed:  %s" % (name, str(value)))
@@ -63,15 +68,15 @@ if __name__ == "__main__":
 								options.adapter)
 	adapter_path = adapter.object_path
 
-	thermometer_manager = dbus.Interface(bus.get_object("org.bluez",
-				adapter_path), "org.bluez.ThermometerManager")
+	thermometer_manager = dbus.Interface(bus.get_object(BUS_NAME,
+				adapter_path), THERMOMETER_MANAGER_INTERFACE)
 
 	device = bluezutils.find_device_in_objects(managed_objects,
 								options.address,
 								options.adapter)
 	device_path = device.object_path
 
-	bus.add_signal_receiver(properties_changed, bus_name="org.bluez",
+	bus.add_signal_receiver(properties_changed, bus_name=BUS_NAME,
 			path=device_path,
 			dbus_interface="org.freedesktop.DBus.Properties",
 			signal_name="PropertiesChanged")
-- 
1.7.11.7


^ permalink raw reply related

* [PATCH BlueZ 06/13] alert: Append version to Alert interfaces
From: Luiz Augusto von Dentz @ 2012-12-14  9:13 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1355476387-2165-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 doc/alert-api.txt       | 4 ++--
 profiles/alert/server.c | 4 ++--
 src/bluetooth.conf      | 2 +-
 test/test-alert         | 4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/doc/alert-api.txt b/doc/alert-api.txt
index bcaaaf3..65c065e 100644
--- a/doc/alert-api.txt
+++ b/doc/alert-api.txt
@@ -19,7 +19,7 @@ Alert hierarchy
 ===============
 
 Service		org.bluez
-Interface	org.bluez.Alert
+Interface	org.bluez.Alert1
 Object path	/org/bluez
 
 Methods		void RegisterAlert(string category, object agent)
@@ -79,7 +79,7 @@ Alert Agent hierarchy
 =====================
 
 Service		org.bluez
-Interface	org.bluez.AlertAgent
+Interface	org.bluez.AlertAgent1
 Object path	freely definable
 
 Methods		void MuteOnce()
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 20eb5fc..2e8c452 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -63,8 +63,8 @@
 #define SUPP_UNREAD_ALERT_CAT_CHR_UUID	0x2A48
 
 #define ALERT_OBJECT_PATH		"/org/bluez"
-#define ALERT_INTERFACE			"org.bluez.Alert"
-#define ALERT_AGENT_INTERFACE		"org.bluez.AlertAgent"
+#define ALERT_INTERFACE			"org.bluez.Alert1"
+#define ALERT_AGENT_INTERFACE		"org.bluez.AlertAgent1"
 
 /* Maximum length for "Text String Information" */
 #define NEW_ALERT_MAX_INFO_SIZE		18
diff --git a/src/bluetooth.conf b/src/bluetooth.conf
index 5750f49..0e45935 100644
--- a/src/bluetooth.conf
+++ b/src/bluetooth.conf
@@ -16,7 +16,7 @@
     <allow send_interface="org.bluez.MediaPlayer1"/>
     <allow send_interface="org.bluez.Watcher"/>
     <allow send_interface="org.bluez.ThermometerWatcher1"/>
-    <allow send_interface="org.bluez.AlertAgent"/>
+    <allow send_interface="org.bluez.AlertAgent1"/>
     <allow send_interface="org.bluez.Profile1"/>
     <allow send_interface="org.bluez.HeartRateWatcher1"/>
     <allow send_interface="org.bluez.CyclingSpeedWatcher1"/>
diff --git a/test/test-alert b/test/test-alert
index 1e241a3..066e537 100755
--- a/test/test-alert
+++ b/test/test-alert
@@ -9,8 +9,8 @@ import sys
 import os
 
 BUS_NAME = 'org.bluez'
-ALERT_INTERFACE = 'org.bluez.Alert'
-ALERT_AGENT_INTERFACE = 'org.bluez.AlertAgent'
+ALERT_INTERFACE = 'org.bluez.Alert1'
+ALERT_AGENT_INTERFACE = 'org.bluez.AlertAgent1'
 BLUEZ_OBJECT_PATH = '/org/bluez'
 TEST_OBJECT_PATH = '/org/bluez/test'
 
-- 
1.7.11.7


^ permalink raw reply related

* [PATCH BlueZ 07/13] core: Append version to Agent interface
From: Luiz Augusto von Dentz @ 2012-12-14  9:13 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1355476387-2165-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 doc/agent-api.txt  |  2 +-
 src/agent.c        | 19 ++++++++++---------
 src/bluetooth.conf |  2 +-
 test/simple-agent  | 24 ++++++++++++++----------
 4 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/doc/agent-api.txt b/doc/agent-api.txt
index caed7f8..a1a8969 100644
--- a/doc/agent-api.txt
+++ b/doc/agent-api.txt
@@ -9,7 +9,7 @@ Agent hierarchy
 ===============
 
 Service		unique name
-Interface	org.bluez.Agent
+Interface	org.bluez.Agent1
 Object path	freely definable
 
 Methods		void Release()
diff --git a/src/agent.c b/src/agent.c
index ec183c0..b36738d 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -48,6 +48,7 @@
 #include "agent.h"
 
 #define REQUEST_TIMEOUT (60 * 1000)		/* 60 seconds */
+#define AGENT_INTERFACE "org.bluez.Agent1"
 
 typedef enum {
 	AGENT_REQUEST_PASSKEY,
@@ -91,7 +92,7 @@ static void agent_release(struct agent *agent)
 		agent_cancel(agent);
 
 	message = dbus_message_new_method_call(agent->name, agent->path,
-			"org.bluez.Agent", "Release");
+						AGENT_INTERFACE, "Release");
 	if (message == NULL) {
 		error("Couldn't allocate D-Bus message");
 		return;
@@ -108,7 +109,7 @@ static int send_cancel_request(struct agent_request *req)
 							req->agent->path);
 
 	message = dbus_message_new_method_call(req->agent->name, req->agent->path,
-						"org.bluez.Agent", "Cancel");
+						AGENT_INTERFACE, "Cancel");
 	if (message == NULL) {
 		error("Couldn't allocate D-Bus message");
 		return -ENOMEM;
@@ -301,7 +302,7 @@ static int agent_call_authorize_service(struct agent_request *req,
 	struct agent *agent = req->agent;
 
 	req->msg = dbus_message_new_method_call(agent->name, agent->path,
-				"org.bluez.Agent", "AuthorizeService");
+					AGENT_INTERFACE, "AuthorizeService");
 	if (!req->msg) {
 		error("Couldn't allocate D-Bus message");
 		return -ENOMEM;
@@ -413,7 +414,7 @@ static int pincode_request_new(struct agent_request *req, const char *device_pat
 		secure pin. */
 
 	req->msg = dbus_message_new_method_call(agent->name, agent->path,
-					"org.bluez.Agent", "RequestPinCode");
+					AGENT_INTERFACE, "RequestPinCode");
 	if (req->msg == NULL) {
 		error("Couldn't allocate D-Bus message");
 		return -ENOMEM;
@@ -507,7 +508,7 @@ static int passkey_request_new(struct agent_request *req,
 	struct agent *agent = req->agent;
 
 	req->msg = dbus_message_new_method_call(agent->name, agent->path,
-					"org.bluez.Agent", "RequestPasskey");
+					AGENT_INTERFACE, "RequestPasskey");
 	if (req->msg == NULL) {
 		error("Couldn't allocate D-Bus message");
 		return -ENOMEM;
@@ -563,7 +564,7 @@ static int confirmation_request_new(struct agent_request *req,
 	struct agent *agent = req->agent;
 
 	req->msg = dbus_message_new_method_call(agent->name, agent->path,
-				"org.bluez.Agent", "RequestConfirmation");
+				AGENT_INTERFACE, "RequestConfirmation");
 	if (req->msg == NULL) {
 		error("Couldn't allocate D-Bus message");
 		return -ENOMEM;
@@ -621,7 +622,7 @@ static int authorization_request_new(struct agent_request *req,
 	struct agent *agent = req->agent;
 
 	req->msg = dbus_message_new_method_call(agent->name, agent->path,
-				"org.bluez.Agent", "RequestAuthorization");
+				AGENT_INTERFACE, "RequestAuthorization");
 	if (req->msg == NULL) {
 		error("Couldn't allocate D-Bus message");
 		return -ENOMEM;
@@ -679,7 +680,7 @@ int agent_display_passkey(struct agent *agent, struct btd_device *device,
 	const gchar *dev_path = device_get_path(device);
 
 	message = dbus_message_new_method_call(agent->name, agent->path,
-				"org.bluez.Agent", "DisplayPasskey");
+					AGENT_INTERFACE, "DisplayPasskey");
 	if (!message) {
 		error("Couldn't allocate D-Bus message");
 		return -1;
@@ -754,7 +755,7 @@ static int display_pincode_request_new(struct agent_request *req,
 	struct agent *agent = req->agent;
 
 	req->msg = dbus_message_new_method_call(agent->name, agent->path,
-					"org.bluez.Agent", "DisplayPinCode");
+					AGENT_INTERFACE, "DisplayPinCode");
 	if (req->msg == NULL) {
 		error("Couldn't allocate D-Bus message");
 		return -ENOMEM;
diff --git a/src/bluetooth.conf b/src/bluetooth.conf
index 0e45935..8dfdc77 100644
--- a/src/bluetooth.conf
+++ b/src/bluetooth.conf
@@ -10,7 +10,7 @@
   <policy user="root">
     <allow own="org.bluez"/>
     <allow send_destination="org.bluez"/>
-    <allow send_interface="org.bluez.Agent"/>
+    <allow send_interface="org.bluez.Agent1"/>
     <allow send_interface="org.bluez.HandsfreeAgent"/>
     <allow send_interface="org.bluez.MediaEndpoint1"/>
     <allow send_interface="org.bluez.MediaPlayer1"/>
diff --git a/test/simple-agent b/test/simple-agent
index 15f2a32..312202a 100755
--- a/test/simple-agent
+++ b/test/simple-agent
@@ -11,6 +11,10 @@ import dbus.mainloop.glib
 from optparse import OptionParser
 import bluezutils
 
+BUS_NAME = 'org.bluez'
+AGENT_INTERFACE = 'org.bluez.Agent1'
+AGENT_PATH = "/test/agent"
+
 bus = None
 device_obj = None
 dev_path = None
@@ -40,14 +44,14 @@ class Agent(dbus.service.Object):
 	def set_exit_on_release(self, exit_on_release):
 		self.exit_on_release = exit_on_release
 
-	@dbus.service.method("org.bluez.Agent",
+	@dbus.service.method(AGENT_INTERFACE,
 					in_signature="", out_signature="")
 	def Release(self):
 		print("Release")
 		if self.exit_on_release:
 			mainloop.quit()
 
-	@dbus.service.method("org.bluez.Agent",
+	@dbus.service.method(AGENT_INTERFACE,
 					in_signature="os", out_signature="")
 	def AuthorizeService(self, device, uuid):
 		print("AuthorizeService (%s, %s)" % (device, uuid))
@@ -56,14 +60,14 @@ class Agent(dbus.service.Object):
 			return
 		raise Rejected("Connection rejected by user")
 
-	@dbus.service.method("org.bluez.Agent",
+	@dbus.service.method(AGENT_INTERFACE,
 					in_signature="o", out_signature="s")
 	def RequestPinCode(self, device):
 		print("RequestPinCode (%s)" % (device))
 		set_trusted(device)
 		return ask("Enter PIN Code: ")
 
-	@dbus.service.method("org.bluez.Agent",
+	@dbus.service.method(AGENT_INTERFACE,
 					in_signature="o", out_signature="u")
 	def RequestPasskey(self, device):
 		print("RequestPasskey (%s)" % (device))
@@ -71,18 +75,18 @@ class Agent(dbus.service.Object):
 		passkey = ask("Enter passkey: ")
 		return dbus.UInt32(passkey)
 
-	@dbus.service.method("org.bluez.Agent",
+	@dbus.service.method(AGENT_INTERFACE,
 					in_signature="ouq", out_signature="")
 	def DisplayPasskey(self, device, passkey, entered):
 		print("DisplayPasskey (%s, %06u entered %u)" %
 						(device, passkey, entered))
 
-	@dbus.service.method("org.bluez.Agent",
+	@dbus.service.method(AGENT_INTERFACE,
 					in_signature="os", out_signature="")
 	def DisplayPinCode(self, device, pincode):
 		print("DisplayPinCode (%s, %s)" % (device, pincode))
 
-	@dbus.service.method("org.bluez.Agent",
+	@dbus.service.method(AGENT_INTERFACE,
 					in_signature="ou", out_signature="")
 	def RequestConfirmation(self, device, passkey):
 		print("RequestConfirmation (%s, %06d)" % (device, passkey))
@@ -92,7 +96,7 @@ class Agent(dbus.service.Object):
 			return
 		raise Rejected("Passkey doesn't match")
 
-	@dbus.service.method("org.bluez.Agent",
+	@dbus.service.method(AGENT_INTERFACE,
 					in_signature="o", out_signature="")
 	def RequestAuthorization(self, device):
 		print("RequestAuthorization (%s)" % (device))
@@ -101,7 +105,7 @@ class Agent(dbus.service.Object):
 			return
 		raise Rejected("Pairing rejected")
 
-	@dbus.service.method("org.bluez.Agent",
+	@dbus.service.method(AGENT_INTERFACE,
 					in_signature="s", out_signature="")
 	def ConfirmModeChange(self, mode):
 		print("ConfirmModeChange (%s)" % (mode))
@@ -110,7 +114,7 @@ class Agent(dbus.service.Object):
 			return
 		raise Rejected("Mode change by user")
 
-	@dbus.service.method("org.bluez.Agent",
+	@dbus.service.method(AGENT_INTERFACE,
 					in_signature="", out_signature="")
 	def Cancel(self):
 		print("Cancel")
-- 
1.7.11.7


^ permalink raw reply related

* [PATCH BlueZ 08/13] health: Append version to Health interfaces
From: Luiz Augusto von Dentz @ 2012-12-14  9:13 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1355476387-2165-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 doc/health-api.txt          |  6 +++---
 profiles/health/hdp_types.h |  6 +++---
 test/test-health            | 25 +++++++++++++++----------
 test/test-health-sink       | 22 ++++++++++++++--------
 4 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/doc/health-api.txt b/doc/health-api.txt
index 7639cd2..193fbce 100644
--- a/doc/health-api.txt
+++ b/doc/health-api.txt
@@ -9,7 +9,7 @@ HealthManager hierarchy
 =======================
 
 Service		org.bluez
-Interface	org.bluez.HealthManager
+Interface	org.bluez.HealthManager1
 Object path	/org/bluez/
 
 Methods		object CreateApplication(dict config)
@@ -54,7 +54,7 @@ HealthDevice hierarchy
 ======================
 
 Service		org.bluez
-Interface	org.bluez.HealthDevice
+Interface	org.bluez.HealthDevice1
 Object path	[variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX
 
 Methods		boolean Echo()
@@ -112,7 +112,7 @@ HealthChannel hierarchy
 =======================
 
 Service		org.bluez
-Interface	org.bluez.HealthChannel
+Interface	org.bluez.HealthChannel1
 Object path	[variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/chanZZZ
 
 Only the process that created the data channel or the creator of the
diff --git a/profiles/health/hdp_types.h b/profiles/health/hdp_types.h
index 7e4d00f..aff16df 100644
--- a/profiles/health/hdp_types.h
+++ b/profiles/health/hdp_types.h
@@ -25,9 +25,9 @@
 
 #define MANAGER_PATH		"/org/bluez"
 
-#define HEALTH_MANAGER		"org.bluez.HealthManager"
-#define HEALTH_DEVICE		"org.bluez.HealthDevice"
-#define HEALTH_CHANNEL		"org.bluez.HealthChannel"
+#define HEALTH_MANAGER		"org.bluez.HealthManager1"
+#define HEALTH_DEVICE		"org.bluez.HealthDevice1"
+#define HEALTH_CHANNEL		"org.bluez.HealthChannel1"
 
 #define HDP_VERSION		0x0100
 
diff --git a/test/test-health b/test/test-health
index e0f95a6..666972c 100755
--- a/test/test-health
+++ b/test/test-health
@@ -9,6 +9,12 @@ import gobject
 from dbus.mainloop.glib import DBusGMainLoop
 import sys
 
+BUS_NAME = 'org.bluez'
+PATH = '/org/bluez'
+ADAPTER_INTERFACE = 'org.bluez.Adapter1'
+HEALTH_MANAGER_INTERFACE = 'org.bluez.HealthManager1'
+HEALTH_DEVICE_INTERFACE = 'org.bluez.HealthDevice1'
+
 DBusGMainLoop(set_as_default=True)
 loop = gobject.MainLoop()
 
@@ -33,8 +39,8 @@ def sig_received(*args, **kwargs):
 
 
 def enter_mainloop():
-	bus.add_signal_receiver(sig_received, bus_name="org.bluez",
-				dbus_interface = "org.bluez.HealthDevice",
+	bus.add_signal_receiver(sig_received, bus_name=BUS_NAME,
+				dbus_interface=HEALTH_DEVICE_INTERFACE,
 				path_keyword="path",
 				member_keyword="member",
 				interface_keyword="interface")
@@ -49,8 +55,8 @@ def enter_mainloop():
 	finally:
 		print("Exiting, bye")
 
-hdp_manager = dbus.Interface(bus.get_object("org.bluez", "/org/bluez"),
-						"org.bluez.HealthManager")
+hdp_manager = dbus.Interface(bus.get_object(BUS_NAME, PATH),
+						HEALTH_MANAGER_INTERFACE)
 
 role = None
 while role == None:
@@ -131,14 +137,14 @@ if not con:
 	enter_mainloop()
 	sys.exit()
 
-manager = dbus.Interface(bus.get_object("org.bluez", "/"),
+manager = dbus.Interface(bus.get_object(BUS_NAME, "/"),
 					"org.freedesktop.DBus.ObjectManager")
 
 objects = manager.GetManagedObjects()
 adapters = []
 
 for path, ifaces in objects.iteritems():
-	if ifaces.has_key("org.bluez.Adapter1"):
+	if ifaces.has_key(ADAPTER_INTERFACE):
 		adapters.append(path)
 
 i = 1
@@ -159,8 +165,7 @@ while select == None:
 	except KeyboardInterrupt:
 		sys.exit()
 
-adapter =  dbus.Interface(bus.get_object("org.bluez", select),
-						"org.bluez.Adapter1")
+adapter = dbus.Interface(bus.get_object(BUS_NAME, select), ADAPTER_INTERFACE)
 
 devices = adapter.GetProperties()["Devices"]
 
@@ -186,8 +191,8 @@ while select == None:
 	except KeyboardInterrupt:
 		sys.exit()
 
-device = dbus.Interface(bus.get_object("org.bluez", select),
-					"org.bluez.HealthDevice")
+device = dbus.Interface(bus.get_object(BUS_NAME, select),
+					HEALTH_DEVICE_INTERFACE)
 
 echo = None
 while echo == None:
diff --git a/test/test-health-sink b/test/test-health-sink
index a14f16b..32afd71 100755
--- a/test/test-health-sink
+++ b/test/test-health-sink
@@ -9,26 +9,32 @@ import gobject
 from dbus.mainloop.glib import DBusGMainLoop
 import sys
 
+BUS_NAME = 'org.bluez'
+PATH = '/org/bluez'
+ADAPTER_INTERFACE = 'org.bluez.Adapter1'
+HEALTH_MANAGER_INTERFACE = 'org.bluez.HealthManager1'
+HEALTH_DEVICE_INTERFACE = 'org.bluez.HealthDevice1'
+
 DBusGMainLoop(set_as_default=True)
 loop = gobject.MainLoop()
 
 bus = dbus.SystemBus()
 
-hdp_manager = dbus.Interface(bus.get_object("org.bluez", "/org/bluez"),
-						"org.bluez.HealthManager")
+hdp_manager = dbus.Interface(bus.get_object(BUS_NAME, PATH),
+						HEALTH_MANAGER_INTERFACE)
 app_path = hdp_manager.CreateApplication({"DataType": dbus.types.UInt16(4103),
 					"Role": "sink"})
 
 print(app_path)
 
-manager = dbus.Interface(bus.get_object("org.bluez", "/"),
+manager = dbus.Interface(bus.get_object(BUS_NAME, "/"),
 					"org.freedesktop.DBus.ObjectManager")
 
 objects = manager.GetManagedObjects()
 adapters = []
 
 for path, ifaces in objects.iteritems():
-	if ifaces.has_key("org.bluez.Adapter1"):
+	if ifaces.has_key(ADAPTER_INTERFACE):
 		adapters.append(path)
 
 i = 1
@@ -49,8 +55,8 @@ while select == None:
 	except KeyboardInterrupt:
 		sys.exit()
 
-adapter =  dbus.Interface(bus.get_object("org.bluez", select),
-						"org.bluez.Adapter1")
+adapter =  dbus.Interface(bus.get_object(BUS_NAME, select),
+						ADAPTER_INTERFACE)
 
 devices = adapter.GetProperties()["Devices"]
 
@@ -77,8 +83,8 @@ while select == None:
 		sys.exit()
 
 print("Connecting to %s" % (select))
-device = dbus.Interface(bus.get_object("org.bluez", select),
-					"org.bluez.HealthDevice")
+device = dbus.Interface(bus.get_object(BUS_NAME, select),
+						HEALTH_DEVICE_INTERFACE)
 
 chan = device.CreateChannel(app_path, "Any")
 
-- 
1.7.11.7


^ permalink raw reply related

* [PATCH BlueZ 09/13] dbusoob: Append version to OutOfBand interface
From: Luiz Augusto von Dentz @ 2012-12-14  9:13 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1355476387-2165-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 doc/oob-api.txt   |  2 +-
 plugins/dbusoob.c |  2 +-
 test/test-oob     | 11 +++++++----
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/doc/oob-api.txt b/doc/oob-api.txt
index d54f612..a196442 100644
--- a/doc/oob-api.txt
+++ b/doc/oob-api.txt
@@ -11,7 +11,7 @@ Out Of Band hierarchy
 =====================
 
 Service		org.bluez
-Interface	org.bluez.OutOfBand
+Interface	org.bluez.OutOfBand1
 Object path	[variable prefix]/{hci0,hci1,...}
 
 Methods		dict ReadLocalData()
diff --git a/plugins/dbusoob.c b/plugins/dbusoob.c
index 77563f1..887a610 100644
--- a/plugins/dbusoob.c
+++ b/plugins/dbusoob.c
@@ -45,7 +45,7 @@
 #include "error.h"
 #include "storage.h"
 
-#define OOB_INTERFACE	"org.bluez.OutOfBand"
+#define OOB_INTERFACE	"org.bluez.OutOfBand1"
 
 struct oob_data {
 	char *addr;
diff --git a/test/test-oob b/test/test-oob
index 87c558f..681540b 100755
--- a/test/test-oob
+++ b/test/test-oob
@@ -7,6 +7,9 @@ import gobject
 import dbus.mainloop.glib
 import bluezutils
 
+BUS_NAME = 'org.bluez'
+OOB_INTERFACE = 'org.bluez.OutOfBand1'
+
 def create_device_reply(device):
 	print("Pairing succeed!")
 	mainloop.quit()
@@ -61,10 +64,10 @@ if __name__ == '__main__':
 	print()
 	print("Reading local Out of Band data...")
 
-	oob_adapter0 = dbus.Interface(bus.get_object("org.bluez",
-					adapter0_path), "org.bluez.OutOfBand")
-	oob_adapter1 = dbus.Interface(bus.get_object("org.bluez",
-					adapter1_path), "org.bluez.OutOfBand")
+	oob_adapter0 = dbus.Interface(bus.get_object(BUS_NAME,
+					adapter0_path), OOB_INTERFACE)
+	oob_adapter1 = dbus.Interface(bus.get_object(BUS_NAME,
+					adapter1_path), OOB_INTERFACE)
 
 	oob0 = oob_adapter0.ReadLocalData()
 	oob1 = oob_adapter1.ReadLocalData()
-- 
1.7.11.7


^ permalink raw reply related

* [PATCH BlueZ 10/13] proximity: Append version to Proximity interfaces
From: Luiz Augusto von Dentz @ 2012-12-14  9:13 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1355476387-2165-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 doc/proximity-api.txt         |  4 ++--
 profiles/proximity/monitor.c  |  2 +-
 profiles/proximity/reporter.h |  2 +-
 test/test-proximity           | 15 +++++++++------
 4 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/doc/proximity-api.txt b/doc/proximity-api.txt
index b68a4fe..4719428 100644
--- a/doc/proximity-api.txt
+++ b/doc/proximity-api.txt
@@ -8,7 +8,7 @@ Proximity Monitor hierarchy
 ===========================
 
 Service		org.bluez
-Interface	org.bluez.ProximityMonitor
+Interface	org.bluez.ProximityMonitor1
 Object path	[variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX
 
 Properties	string SignalLevel [readonly]
@@ -40,7 +40,7 @@ Shared service used by Proximity Path Loss and Find Me. Allows per device
 alert level handling.
 
 Service		org.bluez
-Interface	org.bluez.ProximityReporter
+Interface	org.bluez.ProximityReporter1
 Object path	[variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX
 
 Properties	string ImmediateAlertLevel [readonly]
diff --git a/profiles/proximity/monitor.c b/profiles/proximity/monitor.c
index 023de72..d9ed3ff 100644
--- a/profiles/proximity/monitor.c
+++ b/profiles/proximity/monitor.c
@@ -50,7 +50,7 @@
 #include "monitor.h"
 #include "textfile.h"
 
-#define PROXIMITY_INTERFACE "org.bluez.ProximityMonitor"
+#define PROXIMITY_INTERFACE "org.bluez.ProximityMonitor1"
 
 #define ALERT_LEVEL_CHR_UUID 0x2A06
 #define POWER_LEVEL_CHR_UUID 0x2A07
diff --git a/profiles/proximity/reporter.h b/profiles/proximity/reporter.h
index 480c668..6a7066d 100644
--- a/profiles/proximity/reporter.h
+++ b/profiles/proximity/reporter.h
@@ -22,7 +22,7 @@
  *
  */
 
-#define PROXIMITY_REPORTER_INTERFACE "org.bluez.ProximityReporter"
+#define PROXIMITY_REPORTER_INTERFACE "org.bluez.ProximityReporter1"
 
 #define IMMEDIATE_ALERT_SVC_UUID	0x1802
 #define LINK_LOSS_SVC_UUID		0x1803
diff --git a/test/test-proximity b/test/test-proximity
index d6862de..0cbf315 100755
--- a/test/test-proximity
+++ b/test/test-proximity
@@ -14,8 +14,11 @@ import dbus.mainloop.glib
 from optparse import OptionParser, make_option
 import bluezutils
 
+BUS_NAME = 'org.bluez'
+PROXIMITY_MONITOR_INTERFACE = 'org.bluez.ProxymityMonitor1'
+
 def properties_changed(interface, changed, invalidated):
-	if interface != "org.bluez.ProximityMonitor":
+	if interface != PROXIMITY_MONITOR_INTERFACE:
 		return
 
 	for name, value in changed.iteritems():
@@ -45,19 +48,19 @@ if __name__ == "__main__":
 	device = bluezutils.find_device(options.address, options.dev_id)
 	device_path = device.object_path
 
-	bus.add_signal_receiver(properties_changed, bus_name="org.bluez",
+	bus.add_signal_receiver(properties_changed, bus_name=BUS_NAME,
 			path=device_path,
 			dbus_interface="org.freedesktop.DBus.Properties",
 			signal_name="PropertiesChanged")
 
-	proximity = dbus.Interface(bus.get_object("org.bluez",
-					device_path), "org.bluez.ProximityMonitor")
+	proximity = dbus.Interface(bus.get_object(BUS_NAME, device_path),
+						PROXIMITY_MONITOR_INTERFACE)
 
-	device_prop = dbus.Interface(bus.get_object("org.bluez", device_path),
+	device_prop = dbus.Interface(bus.get_object(BUS_NAME, device_path),
 					"org.freedesktop.DBus.Properties")
 
 	print("Proximity SetProperty('%s', '%s')" % (args[0], args[1]))
-	device_prop.Set("org.bluez.ProximityMonitor", args[0], args[1])
+	device_prop.Set(PROXIMITY_MONITOR_INTERFACE, args[0], args[1])
 
 	mainloop = gobject.MainLoop()
 	mainloop.run()
-- 
1.7.11.7


^ permalink raw reply related

* [PATCH BlueZ 11/13] sap: Append version to SimAccess interfaces
From: Luiz Augusto von Dentz @ 2012-12-14  9:13 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1355476387-2165-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 doc/sap-api.txt          | 2 +-
 profiles/sap/sap-dummy.c | 2 +-
 profiles/sap/server.c    | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/doc/sap-api.txt b/doc/sap-api.txt
index 92bdd9e..6bd8034 100644
--- a/doc/sap-api.txt
+++ b/doc/sap-api.txt
@@ -8,7 +8,7 @@ Sim Access Profile hierarchy
 ============================
 
 Service		org.bluez
-Interface	org.bluez.SimAccess
+Interface	org.bluez.SimAccess1
 Object path	[variable prefix]/{hci0,hci1,...}
 
 Methods		void Disconnect()
diff --git a/profiles/sap/sap-dummy.c b/profiles/sap/sap-dummy.c
index 6c717dc..ffaf847 100644
--- a/profiles/sap/sap-dummy.c
+++ b/profiles/sap/sap-dummy.c
@@ -34,7 +34,7 @@
 #include "log.h"
 #include "sap.h"
 
-#define SAP_DUMMY_IFACE "org.bluez.SimAccessTest"
+#define SAP_DUMMY_IFACE "org.bluez.SimAccessTest1"
 #define SAP_DUMMY_PATH "/org/bluez/test"
 
 enum {
diff --git a/profiles/sap/server.c b/profiles/sap/server.c
index d075e40..01caa33 100644
--- a/profiles/sap/server.c
+++ b/profiles/sap/server.c
@@ -43,7 +43,7 @@
 #include "sap.h"
 #include "server.h"
 
-#define SAP_SERVER_INTERFACE	"org.bluez.SimAccess"
+#define SAP_SERVER_INTERFACE	"org.bluez.SimAccess1"
 #define SAP_SERVER_CHANNEL	8
 
 #define PADDING4(x) ((4 - ((x) & 0x03)) & 0x03)
-- 
1.7.11.7


^ permalink raw reply related

* [PATCH BlueZ 12/13] core: Remove another left over of HFP removal
From: Luiz Augusto von Dentz @ 2012-12-14  9:13 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1355476387-2165-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 src/bluetooth.conf | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/bluetooth.conf b/src/bluetooth.conf
index 8dfdc77..e5da643 100644
--- a/src/bluetooth.conf
+++ b/src/bluetooth.conf
@@ -11,7 +11,6 @@
     <allow own="org.bluez"/>
     <allow send_destination="org.bluez"/>
     <allow send_interface="org.bluez.Agent1"/>
-    <allow send_interface="org.bluez.HandsfreeAgent"/>
     <allow send_interface="org.bluez.MediaEndpoint1"/>
     <allow send_interface="org.bluez.MediaPlayer1"/>
     <allow send_interface="org.bluez.Watcher"/>
-- 
1.7.11.7


^ permalink raw reply related

* [PATCH BlueZ 13/13] core: Remove org.bluez.Watcher from bluetooth.conf
From: Luiz Augusto von Dentz @ 2012-12-14  9:13 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1355476387-2165-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This interface is not used anywhere
---
 src/bluetooth.conf | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/bluetooth.conf b/src/bluetooth.conf
index e5da643..0495200 100644
--- a/src/bluetooth.conf
+++ b/src/bluetooth.conf
@@ -13,7 +13,6 @@
     <allow send_interface="org.bluez.Agent1"/>
     <allow send_interface="org.bluez.MediaEndpoint1"/>
     <allow send_interface="org.bluez.MediaPlayer1"/>
-    <allow send_interface="org.bluez.Watcher"/>
     <allow send_interface="org.bluez.ThermometerWatcher1"/>
     <allow send_interface="org.bluez.AlertAgent1"/>
     <allow send_interface="org.bluez.Profile1"/>
-- 
1.7.11.7


^ permalink raw reply related

* Re: [PATCH BlueZ 01/13] network: Append version to Network and NetworkServer interfaces
From: Johan Hedberg @ 2012-12-14  9:25 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1355476387-2165-1-git-send-email-luiz.dentz@gmail.com>

Hi Luiz,

On Fri, Dec 14, 2012, Luiz Augusto von Dentz wrote:
> ---
>  doc/network-api.txt           | 4 ++--
>  profiles/network/connection.c | 2 +-
>  profiles/network/server.c     | 2 +-
>  3 files changed, 4 insertions(+), 4 deletions(-)

All patches in this set have been applied. Thanks.

Johan

^ permalink raw reply

* [PATCH] device: Fix memory leak in load_att_info()
From: Frédéric Danis @ 2012-12-14  9:43 UTC (permalink / raw)
  To: linux-bluetooth

---
 src/device.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/device.c b/src/device.c
index 7bde970..bb0db30 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1903,15 +1903,18 @@ static void load_att_info(struct btd_device *device, const gchar *local,
 	groups = g_key_file_get_groups(key_file, NULL);
 
 	for (handle = groups; *handle; handle++) {
+		gboolean uuid_ok;
+
 		str = g_key_file_get_string(key_file, *handle, "UUID", NULL);
 		if (!str)
 			continue;
 
-		if (!g_str_equal(str, prim_uuid))
-			continue;
-
+		uuid_ok = g_str_equal(str, prim_uuid);
 		g_free(str);
 
+		if (!uuid_ok)
+			continue;
+
 		str = g_key_file_get_string(key_file, *handle, "Value", NULL);
 		if (!str)
 			continue;
@@ -1938,6 +1941,8 @@ static void load_att_info(struct btd_device *device, const gchar *local,
 			}
 			break;
 		default:
+			g_free(str);
+			g_free(prim);
 			continue;
 		}
 
-- 
1.7.9.5


^ permalink raw reply related

* Re: [PATCH BlueZ 01/13] network: Append version to Network and NetworkServer interfaces
From: Santiago Carot @ 2012-12-14 10:18 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <20121214092515.GA1521@x220>

Hi,

2012/12/14 Johan Hedberg <johan.hedberg@gmail.com>:
> Hi Luiz,
>
> On Fri, Dec 14, 2012, Luiz Augusto von Dentz wrote:
>> ---
>>  doc/network-api.txt           | 4 ++--
>>  profiles/network/connection.c | 2 +-
>>  profiles/network/server.c     | 2 +-
>>  3 files changed, 4 insertions(+), 4 deletions(-)
>
> All patches in this set have been applied. Thanks.
>

just a few comments, Wouldn't it have been better to add an
API_VERSION macro and stick it besides each interface?, I haven't gone
deept through each patch but it just looks like you are only adding
the version number to each interface. In the future it could be
annoying to have to go through all the source code to increment just
the version number.

Regards.

^ permalink raw reply

* Re: [PATCH BlueZ 01/13] network: Append version to Network and NetworkServer interfaces
From: Luiz Augusto von Dentz @ 2012-12-14 10:37 UTC (permalink / raw)
  To: Santiago Carot; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <CACLukzKV27rWzLNo9BeNYqBxBgZ2jW_x6z4dRZbAMZBk3ehVPA@mail.gmail.com>

Hi,

On Fri, Dec 14, 2012 at 12:18 PM, Santiago Carot <sancane@gmail.com> wrote:
> Hi,
>
> 2012/12/14 Johan Hedberg <johan.hedberg@gmail.com>:
>> Hi Luiz,
>>
>> On Fri, Dec 14, 2012, Luiz Augusto von Dentz wrote:
>>> ---
>>>  doc/network-api.txt           | 4 ++--
>>>  profiles/network/connection.c | 2 +-
>>>  profiles/network/server.c     | 2 +-
>>>  3 files changed, 4 insertions(+), 4 deletions(-)
>>
>> All patches in this set have been applied. Thanks.
>>
>
> just a few comments, Wouldn't it have been better to add an
> API_VERSION macro and stick it besides each interface?, I haven't gone
> deept through each patch but it just looks like you are only adding
> the version number to each interface. In the future it could be
> annoying to have to go through all the source code to increment just
> the version number.

Each interface is independent, so if you break lets say
org.bluez.Network1 API you just change it not everything.

--
Luiz Augusto von Dentz

^ permalink raw reply

* Re: [PATCH] device: Fix memory leak in load_att_info()
From: Johan Hedberg @ 2012-12-14 11:20 UTC (permalink / raw)
  To: Frédéric Danis; +Cc: linux-bluetooth
In-Reply-To: <1355478202-10022-1-git-send-email-frederic.danis@linux.intel.com>

Hi Frederic,

On Fri, Dec 14, 2012, Frédéric Danis wrote:
> ---
>  src/device.c |   11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)

Applied. Thanks.

Johan

^ permalink raw reply

* [PATCH BlueZ 1/2] core: Fix leftover signal for UUIDs property
From: Lucas De Marchi @ 2012-12-14 14:13 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Lucas De Marchi

---
 src/device.c | 28 ++++++++--------------------
 1 file changed, 8 insertions(+), 20 deletions(-)

diff --git a/src/device.c b/src/device.c
index 01c40a7..714fc72 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2442,23 +2442,6 @@ static void device_remove_profiles(struct btd_device *device, GSList *uuids)
 	}
 }
 
-static void uuids_changed(struct btd_device *device)
-{
-	char **uuids;
-	GSList *l;
-	int i;
-
-	uuids = g_new0(char *, g_slist_length(device->uuids) + 1);
-	for (i = 0, l = device->uuids; l; l = l->next, i++)
-		uuids[i] = l->data;
-
-	emit_array_property_changed(device->path,
-					DEVICE_INTERFACE, "UUIDs",
-					DBUS_TYPE_STRING, &uuids, i);
-
-	g_free(uuids);
-}
-
 static void store_sdp_record(GKeyFile *key_file, sdp_record_t *rec)
 {
 	char handle_str[11];
@@ -2803,7 +2786,9 @@ static void search_cb(sdp_list_t *recs, int err, gpointer user_data)
 		device_remove_profiles(device, req->profiles_removed);
 
 	/* Propagate services changes */
-	uuids_changed(req->device);
+	g_dbus_emit_property_changed(btd_get_dbus_connection(),
+					req->device->path, DEVICE_INTERFACE,
+					"UUIDs");
 
 send_reply:
 	device_svc_resolved(device, err);
@@ -2966,7 +2951,8 @@ static void register_all_services(struct browse_req *req, GSList *services)
 	if (device->attios == NULL && device->attios_offline == NULL)
 		attio_cleanup(device);
 
-	uuids_changed(device);
+	g_dbus_emit_property_changed(btd_get_dbus_connection(), device->path,
+						DEVICE_INTERFACE, "UUIDs");
 
 	device_svc_resolved(device, 0);
 
@@ -4057,7 +4043,9 @@ void btd_device_add_uuid(struct btd_device *device, const char *uuid)
 	g_slist_free(uuid_list);
 
 	store_device_info(device);
-	uuids_changed(device);
+
+	g_dbus_emit_property_changed(btd_get_dbus_connection(), device->path,
+						DEVICE_INTERFACE, "UUIDs");
 }
 
 static sdp_list_t *read_device_records(struct btd_device *device)
-- 
1.8.0.2


^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox