summaryrefslogtreecommitdiffstats
path: root/src/storage.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-11-20 16:33:30 -0300
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-11-20 16:33:30 -0300
commit0c561f77956654c654f14daea35e90ad0ba20164 (patch)
tree9d7b21d086aa161c321a3d4c187c63c16cf1781d /src/storage.c
parent99b4f5685edd040b4782341bfb0f2da889264888 (diff)
Introduce Pairable property.
As the name suggest it tells when an adapter enter or leaves bondable mode, it works as follow: Pairable=true & Discoverable=true: limited IAC Pairable=true & Discoverable=false: pairable but inquiry scan disabled Pairable=false & Discoverable=true: inquiry scan enabled (with Generic IAC) but new pairings cannot be created (same as if there was no agent) Pairable=false & Discoverable=false: inquiry scan disabled & non-pairable (as if there was no agent)
Diffstat (limited to 'src/storage.c')
-rw-r--r--src/storage.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/storage.c b/src/storage.c
index ac1ec5bd..212f7ce2 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -1028,3 +1028,33 @@ int read_device_id(const gchar *srcaddr, const gchar *dstaddr,
return 0;
}
+
+int write_device_pairable(bdaddr_t *bdaddr, gboolean mode)
+{
+ char filename[PATH_MAX + 1];
+
+ create_filename(filename, PATH_MAX, bdaddr, "config");
+
+ create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+
+ return textfile_put(filename, "pairable", mode ? "yes" : "no");
+}
+
+int read_device_pairable(bdaddr_t *bdaddr, gboolean *mode)
+{
+ char filename[PATH_MAX + 1], *str;
+
+ create_filename(filename, PATH_MAX, bdaddr, "config");
+
+ create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+
+ str = textfile_get(filename, "pairable");
+ if (!str)
+ return -ENOENT;
+
+ *mode = strcmp(str, "yes") == 0 ? TRUE : FALSE;
+
+ free(str);
+
+ return 0;
+}