summaryrefslogtreecommitdiffstats
path: root/audio/device.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-03-28 13:00:18 +0000
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-03-28 13:00:18 +0000
commit2fff5cdc8c0d7a626890ee8f0dd82d464e4fd375 (patch)
tree15e3c50922d2359d047ddd2c589553b1f841362e /audio/device.c
parent7299869ac79b76564cd68411acb18f4233ddbbb7 (diff)
Remove blocking calls to GetRemoteName.
Diffstat (limited to 'audio/device.c')
-rw-r--r--audio/device.c43
1 files changed, 8 insertions, 35 deletions
diff --git a/audio/device.c b/audio/device.c
index 7e25fe90..0debe220 100644
--- a/audio/device.c
+++ b/audio/device.c
@@ -73,44 +73,17 @@ static DBusHandlerResult device_get_address(DBusConnection *conn,
return send_message_and_unref(conn, reply);
}
-static char *get_dev_name(DBusConnection *conn, const char *adapter_path,
- bdaddr_t *bda)
+static char *get_dev_name(DBusConnection *conn, bdaddr_t *src, bdaddr_t *bda)
{
- DBusMessage *msg, *reply;
- DBusError derr;
- const char *name;
- char address[18], *addr_ptr = address, *ret;
-
- msg = dbus_message_new_method_call("org.bluez", adapter_path,
- "org.bluez.Adapter", "GetRemoteName");
- if (!msg)
- return NULL;
-
- ba2str(bda, address);
- dbus_message_append_args(msg, DBUS_TYPE_STRING, &addr_ptr,
- DBUS_TYPE_INVALID);
-
- dbus_error_init(&derr);
- reply = dbus_connection_send_with_reply_and_block(conn, msg, -1,
- &derr);
- dbus_message_unref(msg);
+ char address[18], filename[PATH_MAX + 1];
- if (dbus_error_is_set(&derr)) {
- error("%s GetRemoteName(): %s", adapter_path, derr.message);
- dbus_error_free(&derr);
- return NULL;
- }
-
- if (!dbus_message_get_args(reply, NULL,
- DBUS_TYPE_STRING, &name,
- DBUS_TYPE_INVALID))
- return NULL;
-
- ret = g_strdup(name);
+ ba2str(src, address);
- dbus_message_unref(reply);
+ /* check if it is in the cache */
+ create_name(filename, PATH_MAX, STORAGEDIR, address, "names");
- return ret;
+ ba2str(bda, address);
+ return textfile_caseget(filename, address);
}
static DBusHandlerResult device_get_name(DBusConnection *conn,
@@ -257,7 +230,7 @@ struct device *device_register(DBusConnection *conn,
return NULL;
}
- dev->name = get_dev_name(conn, dev->adapter_path, bda);
+ dev->name = get_dev_name(conn, &src, bda);
dev->path = g_strdup(path);
bacpy(&dev->dst, bda);
bacpy(&dev->src, &src);