summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-02-01 12:22:09 +0000
committerMarcel Holtmann <marcel@holtmann.org>2008-02-01 12:22:09 +0000
commit1842b2b6e3b2c96a95c4c579d41d0a0d14032bee (patch)
tree16f5e30ae15f2d91ce846ffb87949e6fe1492e39
parent4b79bd99c84b3c4ed01366791e9de1f52e858c84 (diff)
Allow GetInfo and GetAddress to fail
-rw-r--r--hcid/adapter.c9
-rw-r--r--hcid/dbus-api.txt4
2 files changed, 11 insertions, 2 deletions
diff --git a/hcid/adapter.c b/hcid/adapter.c
index 08fecda7..186fae3b 100644
--- a/hcid/adapter.c
+++ b/hcid/adapter.c
@@ -283,7 +283,7 @@ static DBusHandlerResult adapter_get_info(DBusConnection *conn,
DBusMessage *msg, void *data)
{
struct adapter *adapter = data;
- const char *property = adapter->address;
+ const char *property;
DBusMessage *reply;
DBusMessageIter iter;
DBusMessageIter dict;
@@ -291,6 +291,9 @@ static DBusHandlerResult adapter_get_info(DBusConnection *conn,
char str[249];
uint8_t cls[3];
+ if (check_address(adapter->address) < 0)
+ return error_not_ready(conn, msg);
+
reply = dbus_message_new_method_return(msg);
if (!reply)
return DBUS_HANDLER_RESULT_NEED_MEMORY;
@@ -302,6 +305,7 @@ static DBusHandlerResult adapter_get_info(DBusConnection *conn,
DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
+ property = adapter->address;
dbus_message_iter_append_dict_entry(&dict, "address",
DBUS_TYPE_STRING, &property);
@@ -368,6 +372,9 @@ static DBusHandlerResult adapter_get_address(DBusConnection *conn,
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
return error_invalid_arguments(conn, msg, NULL);
+ if (check_address(paddr) < 0)
+ return error_not_ready(conn, msg);
+
reply = dbus_message_new_method_return(msg);
if (!reply)
return DBUS_HANDLER_RESULT_NEED_MEMORY;
diff --git a/hcid/dbus-api.txt b/hcid/dbus-api.txt
index feeb8130..9372ab21 100644
--- a/hcid/dbus-api.txt
+++ b/hcid/dbus-api.txt
@@ -329,13 +329,15 @@ Methods dict GetInfo()
Returns the properties of the local adapter.
+ Possible errors: org.bluez.Error.NotReady
+
string GetAddress()
Returns the device address for a given path.
Example: "00:11:22:33:44:55"
- Possible errors: none
+ Possible errors: org.bluez.Error.NotReady
string GetVersion()