From: "Frédéric Danis" <frederic.danis@linux.intel.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH v2 4/5] device: Use new storage for device trust
Date: Wed, 14 Nov 2012 12:28:52 +0100 [thread overview]
Message-ID: <1352892533-15154-4-git-send-email-frederic.danis@linux.intel.com> (raw)
In-Reply-To: <1352892533-15154-1-git-send-email-frederic.danis@linux.intel.com>
As set_trust() changes value in device structure and write to
storage is deferred, property set could not return failure.
---
src/device.c | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/src/device.c b/src/device.c
index c508d18..792fe3d 100644
--- a/src/device.c
+++ b/src/device.c
@@ -226,6 +226,9 @@ static gboolean store_device_info_cb(gpointer user_data)
g_key_file_set_string(key_file, "General", "Alias",
device->alias);
+ g_key_file_set_boolean(key_file, "General", "Trusted",
+ device->trusted);
+
ba2str(adapter_get_address(device->adapter), adapter_addr);
ba2str(&device->bdaddr, device_addr);
snprintf(filename, PATH_MAX, INFO_PATH, adapter_addr, device_addr);
@@ -713,23 +716,14 @@ static gboolean dev_property_get_trusted(const GDBusPropertyTable *property,
static void set_trust(GDBusPendingPropertySet id, gboolean value, void *data)
{
struct btd_device *device = data;
- struct btd_adapter *adapter = device->adapter;
- char srcaddr[18], dstaddr[18];
- int err;
if (device->trusted == value)
return g_dbus_pending_property_success(id);
- ba2str(adapter_get_address(adapter), srcaddr);
- ba2str(&device->bdaddr, dstaddr);
-
- err = write_trust(srcaddr, dstaddr, device->bdaddr_type, value);
- if (err < 0)
- return g_dbus_pending_property_error(id,
- ERROR_INTERFACE ".Failed", strerror(-err));
-
device->trusted = value;
+ store_device_info(device);
+
g_dbus_emit_property_changed(btd_get_dbus_connection(),
device->path, DEVICE_INTERFACE, "Trusted");
@@ -1743,6 +1737,10 @@ static void load_info(struct btd_device *device, const gchar *local,
device->alias = g_key_file_get_string(key_file, "General", "Alias",
NULL);
+ /* Load trust */
+ device->trusted = g_key_file_get_boolean(key_file, "General",
+ "Trusted", NULL);
+
if (store_needed)
store_device_info(device);
@@ -1787,8 +1785,6 @@ struct btd_device *device_create(struct btd_adapter *adapter,
load_info(device, srcaddr, address);
- device->trusted = read_trust(src, address, device->bdaddr_type);
-
if (read_blocked(src, &device->bdaddr, device->bdaddr_type))
device_block(device, FALSE);
--
1.7.9.5
next prev parent reply other threads:[~2012-11-14 11:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-14 11:28 [PATCH v2 1/5] adapter: Convert storage aliases Frédéric Danis
2012-11-14 11:28 ` [PATCH v2 2/5] device: Use new storage for device alias Frédéric Danis
2012-11-14 11:28 ` [PATCH v2 3/5] adapter: Convert storage trusts Frédéric Danis
2012-11-14 11:28 ` Frédéric Danis [this message]
2012-11-14 11:28 ` [PATCH v2 5/5] adapter: Remove storage path #defines Frédéric Danis
2012-11-14 11:54 ` [PATCH v2 1/5] adapter: Convert storage aliases Johan Hedberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1352892533-15154-4-git-send-email-frederic.danis@linux.intel.com \
--to=frederic.danis@linux.intel.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).