From: Bartosz Szatkowski <bulislaw@linux.com>
To: linux-bluetooth@vger.kernel.org
Cc: Bartosz Szatkowski <bulislaw@linux.com>
Subject: [PATCH BlueZ 3/3] Add support for name in OOB SetRemoteProperties
Date: Thu, 11 Aug 2011 13:14:57 +0200 [thread overview]
Message-ID: <1313061297-16884-3-git-send-email-bulislaw@linux.com> (raw)
In-Reply-To: <1313061297-16884-1-git-send-email-bulislaw@linux.com>
---
doc/oob-api.txt | 1 +
plugins/dbusoob.c | 37 +++++++++++++++++++++++++++++++++++++
src/storage.c | 2 +-
src/storage.h | 2 +-
4 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/doc/oob-api.txt b/doc/oob-api.txt
index 500ef15..2d0d096 100644
--- a/doc/oob-api.txt
+++ b/doc/oob-api.txt
@@ -49,6 +49,7 @@ Methods array{byte} hash, array{byte} randomizer ReadLocalData()
Class uint32
Hash array{byte}
Randomizer array{byte}
+ Name String
Possible errors: org.bluez.Error.Failed
org.bluez.Error.InvalidArguments
diff --git a/plugins/dbusoob.c b/plugins/dbusoob.c
index c6237f9..d83c982 100644
--- a/plugins/dbusoob.c
+++ b/plugins/dbusoob.c
@@ -59,6 +59,7 @@ struct oob_remote_parameters {
uint32_t class;
uint8_t *hash;
uint8_t *randomizer;
+ const char *name;
};
static GSList *oob_requests = NULL;
@@ -190,6 +191,10 @@ static void emit_device_found(const char *path,
dict_append_entry(&dict, "Class", DBUS_TYPE_UINT32,
¶ms->class);
+ if (params->name != NULL)
+ dict_append_entry(&dict, "Name", DBUS_TYPE_STRING,
+ ¶ms->name);
+
dbus_message_iter_close_container(&iter, &dict);
g_dbus_send_message(connection, signal);
@@ -263,6 +268,32 @@ static void set_oob_data(struct btd_adapter *adapter,
}
}
+static DBusMessage *parse_name(DBusMessageIter *value,
+ struct oob_remote_parameters *params, DBusMessage *msg)
+{
+ if (dbus_message_iter_get_arg_type(value) != DBUS_TYPE_STRING)
+ return btd_error_invalid_args(msg);
+
+ dbus_message_iter_get_basic(value, ¶ms->name);
+
+ return NULL;
+}
+
+static gboolean set_name(struct oob_remote_parameters *params)
+{
+ if (params->name == NULL)
+ return FALSE;
+
+ if (write_device_name(¶ms->local, ¶ms->peer,
+ params->name) < 0) {
+ error("Setting device name failed");
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
static DBusMessage *parse_property(const char *property,
DBusMessageIter *value, DBusMessage *msg,
struct oob_remote_parameters *params)
@@ -270,6 +301,9 @@ static DBusMessage *parse_property(const char *property,
if (g_str_equal("Class", property))
return parse_class(value, params, msg);
+ if (g_str_equal("Name", property))
+ return parse_name(value, params, msg);
+
if (g_str_equal("Hash", property))
return parse_oob_data(value, ¶ms->hash, msg);
@@ -287,6 +321,9 @@ static void set_properties(struct btd_adapter *adapter, DBusMessage *msg,
if (set_class(params))
device_found = TRUE;
+ if (set_name(params))
+ device_found = TRUE;
+
set_oob_data(adapter, params);
if (device_found)
diff --git a/src/storage.c b/src/storage.c
index 1f3da6e..414d158 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -321,7 +321,7 @@ int read_remote_class(bdaddr_t *local, bdaddr_t *peer, uint32_t *class)
return 0;
}
-int write_device_name(bdaddr_t *local, bdaddr_t *peer, char *name)
+int write_device_name(bdaddr_t *local, bdaddr_t *peer, const char *name)
{
char filename[PATH_MAX + 1], addr[18], str[249];
int i;
diff --git a/src/storage.h b/src/storage.h
index bb64727..78513ac 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -38,7 +38,7 @@ int write_local_class(bdaddr_t *bdaddr, uint8_t *class);
int read_local_class(bdaddr_t *bdaddr, uint8_t *class);
int write_remote_class(bdaddr_t *local, bdaddr_t *peer, uint32_t class);
int read_remote_class(bdaddr_t *local, bdaddr_t *peer, uint32_t *class);
-int write_device_name(bdaddr_t *local, bdaddr_t *peer, char *name);
+int write_device_name(bdaddr_t *local, bdaddr_t *peer, const char *name);
int read_device_name(const char *src, const char *dst, char *name);
int write_remote_eir(bdaddr_t *local, bdaddr_t *peer, uint8_t *data);
int read_remote_eir(bdaddr_t *local, bdaddr_t *peer, uint8_t *data);
--
1.7.4.1
next prev parent reply other threads:[~2011-08-11 11:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-11 11:14 [PATCH BlueZ 1/3] Add SetRemoteProperties method for OOB COD setting Bartosz Szatkowski
2011-08-11 11:14 ` [PATCH BlueZ 2/3] Add support for OOB data in SetRemoteProperties Bartosz Szatkowski
2011-08-11 11:14 ` Bartosz Szatkowski [this message]
2011-08-11 16:51 ` [PATCH BlueZ 1/3] Add SetRemoteProperties method for OOB COD setting Vinicius Costa Gomes
2011-08-11 19:16 ` Bartosz Szatkowski
2011-08-12 7:15 ` [PATCH " Bartosz Szatkowski
2011-08-22 7:22 ` Johan Hedberg
2011-08-22 8:12 ` Bartosz Szatkowski
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=1313061297-16884-3-git-send-email-bulislaw@linux.com \
--to=bulislaw@linux.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 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.