summaryrefslogtreecommitdiffstats
path: root/hcid
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2008-03-10 20:54:28 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2008-03-10 20:54:28 +0000
commit436b2217f66a04970b3e1b78445d0c86e0513731 (patch)
treeb5a90df7351cf8e00d4be706627ac0eb8f339051 /hcid
parentb0566c457e956e03ae5ff3fe4ae15a9176b0ae24 (diff)
Storing device's profiles
Diffstat (limited to 'hcid')
-rw-r--r--hcid/adapter.c12
-rw-r--r--hcid/hcid.h1
-rw-r--r--hcid/storage.c15
3 files changed, 28 insertions, 0 deletions
diff --git a/hcid/adapter.c b/hcid/adapter.c
index 83a575b6..2cd526e2 100644
--- a/hcid/adapter.c
+++ b/hcid/adapter.c
@@ -3235,6 +3235,7 @@ static void discover_services_cb(gpointer user_data, sdp_list_t *recs, int err)
DBusMessage *reply;
GSList *uuids;
const char *path;
+ bdaddr_t src, dst;
if (err < 0) {
error_connection_attempt_failed(adapter->create->conn,
@@ -3267,6 +3268,7 @@ static void discover_services_cb(gpointer user_data, sdp_list_t *recs, int err)
if (!path)
goto failed;
+ /* Reply create device request */
reply = dbus_message_new_method_return(adapter->create->msg);
if (!reply)
goto failed;
@@ -3277,6 +3279,16 @@ static void discover_services_cb(gpointer user_data, sdp_list_t *recs, int err)
adapter->devices = g_slist_append(adapter->devices, g_strdup(path));
+ /* Store the device's profiles in the filesystem */
+ str2ba(adapter->address, &src);
+ str2ba(adapter->create->address, &dst);
+ if (uuids) {
+ char *str = bt_list2string(uuids);
+ write_device_profiles(&src, &dst, str);
+ g_free(str);
+ } else
+ write_device_profiles(&src, &dst, "");
+
failed:
dbus_connection_unref(adapter->create->conn);
dbus_message_unref(adapter->create->msg);
diff --git a/hcid/hcid.h b/hcid/hcid.h
index 48ad55a2..19a94b69 100644
--- a/hcid/hcid.h
+++ b/hcid/hcid.h
@@ -209,3 +209,4 @@ int read_pin_code(bdaddr_t *local, bdaddr_t *peer, char *pin);
gboolean read_trust(bdaddr_t *local, const char *addr, const char *service);
int write_trust(bdaddr_t *local, const char *addr, const char *service, gboolean trust);
GSList *list_trusts(bdaddr_t *local, const char *service);
+int write_device_profiles(bdaddr_t *src, bdaddr_t *dst, const char *profiles);
diff --git a/hcid/storage.c b/hcid/storage.c
index f811bca7..586d73f0 100644
--- a/hcid/storage.c
+++ b/hcid/storage.c
@@ -676,3 +676,18 @@ GSList *list_trusts(bdaddr_t *local, const char *service)
return list.trusts;
}
+
+int write_device_profiles(bdaddr_t *src, bdaddr_t *dst, const char *profiles)
+{
+ char filename[PATH_MAX + 1], addr[18];
+
+ if (!profiles)
+ return -EINVAL;
+
+ create_filename(filename, PATH_MAX, src, "profiles");
+
+ create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+
+ ba2str(dst, addr);
+ return textfile_put(filename, addr, profiles);
+}