All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] doc: Update settings-storage.txt
@ 2012-11-21 13:49 Frédéric Danis
  2012-11-21 13:49 ` [PATCH 2/5] adapter: Convert storage device blocked Frédéric Danis
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Frédéric Danis @ 2012-11-21 13:49 UTC (permalink / raw)
  To: linux-bluetooth

Remote features are not available from user space,
so replace Features entry by SupportedTechnologies.

Device blocked should be saved in device info file.
---
 doc/settings-storage.txt |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/doc/settings-storage.txt b/doc/settings-storage.txt
index 1174d44..3fdcb03 100644
--- a/doc/settings-storage.txt
+++ b/doc/settings-storage.txt
@@ -139,13 +139,16 @@ Long term key) related to a remote device.
   Class			String		Device class in hexadecimal,
 					i.e. 0x000000
 
-  Features		String		Bluetooth device features in
-					hexadecimal, i.e. 0x0000000000000000
+  SupportedTechnologies	List of		List of technologies supported by
+			strings		device, separated by ";"
+					Technologies can be BR/EDR or LE
 
   AddressType		String		An address can be "static" or "public"
 
   Trusted		Boolean		True if the remote device is trusted
 
+  Blocked		Boolean		True if the remote device is blocked
+
   Profiles		List of		List of profiles advertised by remote,
 			strings		in 128-bits UUID format, separated by
 					";"
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/5] adapter: Convert storage device blocked
  2012-11-21 13:49 [PATCH 1/5] doc: Update settings-storage.txt Frédéric Danis
@ 2012-11-21 13:49 ` Frédéric Danis
  2012-11-21 13:49 ` [PATCH 3/5] device: Retrieve device blocked from storage Frédéric Danis
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Frédéric Danis @ 2012-11-21 13:49 UTC (permalink / raw)
  To: linux-bluetooth

An entry exists in blocked file only when a device is blocked.
So, we do not need to check entry value and set device (entry key) as
blocked.
---
 src/adapter.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/adapter.c b/src/adapter.c
index 0f6a078..3dafacb 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2543,6 +2543,11 @@ static void convert_classes_entry(GKeyFile *key_file, void *value)
 	g_key_file_set_string(key_file, "General", "Class", value);
 }
 
+static void convert_blocked_entry(GKeyFile *key_file, void *value)
+{
+	g_key_file_set_boolean(key_file, "General", "Blocked", TRUE);
+}
+
 static void convert_entry(char *key, char *value, void *user_data)
 {
 	struct device_converter *converter = user_data;
@@ -2625,6 +2630,9 @@ static void convert_device_storage(struct btd_adapter *adapter)
 
 	/* Convert classes */
 	convert_file("classes", address, convert_classes_entry);
+
+	/* Convert blocked */
+	convert_file("blocked", address, convert_blocked_entry);
 }
 
 static void convert_config(struct btd_adapter *adapter, const char *filename,
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/5] device: Retrieve device blocked from storage
  2012-11-21 13:49 [PATCH 1/5] doc: Update settings-storage.txt Frédéric Danis
  2012-11-21 13:49 ` [PATCH 2/5] adapter: Convert storage device blocked Frédéric Danis
@ 2012-11-21 13:49 ` Frédéric Danis
  2012-11-21 13:49 ` [PATCH 4/5] adapter: Convert storage did file Frédéric Danis
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Frédéric Danis @ 2012-11-21 13:49 UTC (permalink / raw)
  To: linux-bluetooth

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

diff --git a/src/device.c b/src/device.c
index 915b0f8..d4a553d 100644
--- a/src/device.c
+++ b/src/device.c
@@ -233,6 +233,9 @@ static gboolean store_device_info_cb(gpointer user_data)
 	g_key_file_set_boolean(key_file, "General", "Trusted",
 							device->trusted);
 
+	g_key_file_set_boolean(key_file, "General", "Blocked",
+							device->blocked);
+
 	ba2str(adapter_get_address(device->adapter), adapter_addr);
 	ba2str(&device->bdaddr, device_addr);
 	snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s/info", adapter_addr,
@@ -920,10 +923,7 @@ int device_block(struct btd_device *device, gboolean update_only)
 
 	device->blocked = TRUE;
 
-	err = write_blocked(adapter_get_address(device->adapter),
-				&device->bdaddr, device->bdaddr_type, TRUE);
-	if (err < 0)
-		error("write_blocked(): %s (%d)", strerror(-err), -err);
+	store_device_info(device);
 
 	device_set_temporary(device, FALSE);
 
@@ -950,10 +950,7 @@ int device_unblock(struct btd_device *device, gboolean silent,
 
 	device->blocked = FALSE;
 
-	err = write_blocked(adapter_get_address(device->adapter),
-				&device->bdaddr, device->bdaddr_type, FALSE);
-	if (err < 0)
-		error("write_blocked(): %s (%d)", strerror(-err), -err);
+	store_device_info(device);
 
 	if (!silent) {
 		g_dbus_emit_property_changed(btd_get_dbus_connection(),
@@ -1768,6 +1765,7 @@ static void load_info(struct btd_device *device, const gchar *local,
 	GKeyFile *key_file;
 	char *str;
 	gboolean store_needed = FALSE;
+	gboolean blocked;
 
 	snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s/info", local, peer);
 	filename[PATH_MAX] = '\0';
@@ -1808,6 +1806,11 @@ static void load_info(struct btd_device *device, const gchar *local,
 	device->trusted = g_key_file_get_boolean(key_file, "General",
 							"Trusted", NULL);
 
+	/* Load device blocked */
+	blocked = g_key_file_get_boolean(key_file, "General", "Blocked", NULL);
+	if (blocked)
+		device_block(device, FALSE);
+
 	if (store_needed)
 		store_device_info(device);
 
@@ -1852,9 +1855,6 @@ struct btd_device *device_create(struct btd_adapter *adapter,
 
 	load_info(device, srcaddr, address);
 
-	if (read_blocked(src, &device->bdaddr, device->bdaddr_type))
-		device_block(device, FALSE);
-
 	if (read_link_key(src, &device->bdaddr, device->bdaddr_type, NULL,
 								NULL) == 0) {
 		device_set_paired(device, TRUE);
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/5] adapter: Convert storage did file
  2012-11-21 13:49 [PATCH 1/5] doc: Update settings-storage.txt Frédéric Danis
  2012-11-21 13:49 ` [PATCH 2/5] adapter: Convert storage device blocked Frédéric Danis
  2012-11-21 13:49 ` [PATCH 3/5] device: Retrieve device blocked from storage Frédéric Danis
@ 2012-11-21 13:49 ` Frédéric Danis
  2012-11-21 13:49 ` [PATCH 5/5] device: Retrieve device pnp ids from storage Frédéric Danis
  2012-11-21 18:46 ` [PATCH 1/5] doc: Update settings-storage.txt Johan Hedberg
  4 siblings, 0 replies; 6+ messages in thread
From: Frédéric Danis @ 2012-11-21 13:49 UTC (permalink / raw)
  To: linux-bluetooth

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

diff --git a/src/adapter.c b/src/adapter.c
index 3dafacb..0d1dfea 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2548,6 +2548,45 @@ static void convert_blocked_entry(GKeyFile *key_file, void *value)
 	g_key_file_set_boolean(key_file, "General", "Blocked", TRUE);
 }
 
+static void convert_did_entry(GKeyFile *key_file, void *value)
+{
+	char *vendor_str, *product_str, *version_str;
+	uint16_t val;
+
+	vendor_str = strchr(value, ' ');
+	if (!vendor_str)
+		return;
+
+	*(vendor_str++) = 0;
+
+	if (g_str_equal(value, "FFFF"))
+		return;
+
+	product_str = strchr(vendor_str, ' ');
+	if (!product_str)
+		return;
+
+	*(product_str++) = 0;
+
+	version_str = strchr(product_str, ' ');
+	if (!version_str)
+		return;
+
+	*(version_str++) = 0;
+
+	val = (uint16_t) strtol(value, NULL, 16);
+	g_key_file_set_integer(key_file, "DeviceID", "Source", val);
+
+	val = (uint16_t) strtol(vendor_str, NULL, 16);
+	g_key_file_set_integer(key_file, "DeviceID", "Vendor", val);
+
+	val = (uint16_t) strtol(product_str, NULL, 16);
+	g_key_file_set_integer(key_file, "DeviceID", "Product", val);
+
+	val = (uint16_t) strtol(version_str, NULL, 16);
+	g_key_file_set_integer(key_file, "DeviceID", "Version", val);
+}
+
 static void convert_entry(char *key, char *value, void *user_data)
 {
 	struct device_converter *converter = user_data;
@@ -2633,6 +2672,9 @@ static void convert_device_storage(struct btd_adapter *adapter)
 
 	/* Convert blocked */
 	convert_file("blocked", address, convert_blocked_entry);
+
+	/* Convert device ids */
+	convert_file("did", address, convert_did_entry);
 }
 
 static void convert_config(struct btd_adapter *adapter, const char *filename,
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 5/5] device: Retrieve device pnp ids from storage
  2012-11-21 13:49 [PATCH 1/5] doc: Update settings-storage.txt Frédéric Danis
                   ` (2 preceding siblings ...)
  2012-11-21 13:49 ` [PATCH 4/5] adapter: Convert storage did file Frédéric Danis
@ 2012-11-21 13:49 ` Frédéric Danis
  2012-11-21 18:46 ` [PATCH 1/5] doc: Update settings-storage.txt Johan Hedberg
  4 siblings, 0 replies; 6+ messages in thread
From: Frédéric Danis @ 2012-11-21 13:49 UTC (permalink / raw)
  To: linux-bluetooth

When device pnp ids are updated, save them and emit property
changed signals.
---
 src/device.c |   51 ++++++++++++++++++++++++++++++++++-----------------
 1 file changed, 34 insertions(+), 17 deletions(-)

diff --git a/src/device.c b/src/device.c
index d4a553d..4559674 100644
--- a/src/device.c
+++ b/src/device.c
@@ -236,6 +236,17 @@ static gboolean store_device_info_cb(gpointer user_data)
 	g_key_file_set_boolean(key_file, "General", "Blocked",
 							device->blocked);
 
+	if (device->vendor_src) {
+		g_key_file_set_integer(key_file, "DeviceID", "Source",
+					device->vendor_src);
+		g_key_file_set_integer(key_file, "DeviceID", "Vendor",
+					device->vendor);
+		g_key_file_set_integer(key_file, "DeviceID", "Product",
+					device->product);
+		g_key_file_set_integer(key_file, "DeviceID", "Version",
+					device->version);
+	}
+
 	ba2str(adapter_get_address(device->adapter), adapter_addr);
 	ba2str(&device->bdaddr, device_addr);
 	snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s/info", adapter_addr,
@@ -1766,6 +1777,7 @@ static void load_info(struct btd_device *device, const gchar *local,
 	char *str;
 	gboolean store_needed = FALSE;
 	gboolean blocked;
+	int source, vendor, product, version;
 
 	snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s/info", local, peer);
 	filename[PATH_MAX] = '\0';
@@ -1811,6 +1823,24 @@ static void load_info(struct btd_device *device, const gchar *local,
 	if (blocked)
 		device_block(device, FALSE);
 
+	/* Load device id */
+	source = g_key_file_get_integer(key_file, "DeviceID", "Source", NULL);
+	if (source) {
+		device_set_vendor_src(device, source);
+
+		vendor = g_key_file_get_integer(key_file, "DeviceID",
+							"Vendor", NULL);
+		device_set_vendor(device, vendor);
+
+		product = g_key_file_get_integer(key_file, "DeviceID",
+							"Product", NULL);
+		device_set_product(device, product);
+
+		version = g_key_file_get_integer(key_file, "DeviceID",
+							"Version", NULL);
+		device_set_version(device, version);
+	}
+
 	if (store_needed)
 		store_device_info(device);
 
@@ -1825,7 +1855,6 @@ struct btd_device *device_create(struct btd_adapter *adapter,
 	const gchar *adapter_path = adapter_get_path(adapter);
 	const bdaddr_t *src;
 	char srcaddr[18];
-	uint16_t vendor, product, version;
 
 	device = g_try_malloc0(sizeof(struct btd_device));
 	if (device == NULL)
@@ -1867,13 +1896,6 @@ struct btd_device *device_create(struct btd_adapter *adapter,
 		device_set_bonded(device, TRUE);
 	}
 
-	if (read_device_id(srcaddr, address, bdaddr_type, NULL, &vendor,
-						&product, &version) == 0) {
-		device_set_vendor(device, vendor);
-		device_set_product(device, product);
-		device_set_version(device, version);
-	}
-
 	return btd_device_ref(device);
 }
 
@@ -2320,22 +2342,15 @@ static void update_bredr_services(struct browse_req *req, sdp_list_t *recs)
 			pdlist = sdp_data_get(rec, SDP_ATTR_VENDOR_ID);
 			vendor = pdlist ? pdlist->val.uint16 : 0x0000;
 
-			device_set_vendor(device, vendor);
-
 			pdlist = sdp_data_get(rec, SDP_ATTR_PRODUCT_ID);
 			product = pdlist ? pdlist->val.uint16 : 0x0000;
 
-			device_set_product(device, product);
-
 			pdlist = sdp_data_get(rec, SDP_ATTR_VERSION);
 			version = pdlist ? pdlist->val.uint16 : 0x0000;
 
-			device_set_version(device, version);
-
 			if (source || vendor || product || version)
-				store_device_id(srcaddr, dstaddr,
-						device->bdaddr_type, source,
-						vendor, product, version);
+				device_set_pnpid(device, source, vendor,
+							product, version);
 		}
 
 		/* Check for duplicates */
@@ -4094,4 +4109,6 @@ void device_set_pnpid(struct btd_device *device, uint8_t vendor_id_src,
 	device_set_vendor_src(device, vendor_id_src);
 	device_set_product(device, product_id);
 	device_set_version(device, product_ver);
+
+	store_device_info(device);
 }
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/5] doc: Update settings-storage.txt
  2012-11-21 13:49 [PATCH 1/5] doc: Update settings-storage.txt Frédéric Danis
                   ` (3 preceding siblings ...)
  2012-11-21 13:49 ` [PATCH 5/5] device: Retrieve device pnp ids from storage Frédéric Danis
@ 2012-11-21 18:46 ` Johan Hedberg
  4 siblings, 0 replies; 6+ messages in thread
From: Johan Hedberg @ 2012-11-21 18:46 UTC (permalink / raw)
  To: Frédéric Danis; +Cc: linux-bluetooth

Hi Frederic,

On Wed, Nov 21, 2012, Frédéric Danis wrote:
> Remote features are not available from user space,
> so replace Features entry by SupportedTechnologies.
> 
> Device blocked should be saved in device info file.
> ---
>  doc/settings-storage.txt |    7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)

All five patches have been applied. Thanks.

Johan

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-11-21 18:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-21 13:49 [PATCH 1/5] doc: Update settings-storage.txt Frédéric Danis
2012-11-21 13:49 ` [PATCH 2/5] adapter: Convert storage device blocked Frédéric Danis
2012-11-21 13:49 ` [PATCH 3/5] device: Retrieve device blocked from storage Frédéric Danis
2012-11-21 13:49 ` [PATCH 4/5] adapter: Convert storage did file Frédéric Danis
2012-11-21 13:49 ` [PATCH 5/5] device: Retrieve device pnp ids from storage Frédéric Danis
2012-11-21 18:46 ` [PATCH 1/5] doc: Update settings-storage.txt Johan Hedberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.