summaryrefslogtreecommitdiffstats
path: root/src/storage.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-11-27 16:46:45 -0300
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-11-27 16:46:45 -0300
commit3ee81cab2ed66b7f3d4fbd6ba6676d5d9448d6dc (patch)
tree459dc5218f3b944a638a16361a422e5ba3d7857d /src/storage.c
parent395c910980394868a3c2d14e90e4f55988c7663d (diff)
Introduce PairableTimeout Property and fix use of g_timeout_add.
PairableTimeout work similarly to DiscoverableTimeout where the user application can set the amount of time to stay in Pairable. It also fixes the use of g_timeout_add to g_timeout_add_seconds for both PairableTimeout and DiscoverableTimeout.
Diffstat (limited to 'src/storage.c')
-rw-r--r--src/storage.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/storage.c b/src/storage.c
index 212f7ce2..a97a9992 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -120,6 +120,39 @@ int read_discoverable_timeout(const char *src, int *timeout)
return 0;
}
+int write_pairable_timeout(bdaddr_t *bdaddr, int timeout)
+{
+ char filename[PATH_MAX + 1], str[32];
+
+ snprintf(str, sizeof(str), "%d", timeout);
+
+ create_filename(filename, PATH_MAX, bdaddr, "config");
+
+ create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+
+ return textfile_put(filename, "pairto", str);
+}
+
+int read_pairable_timeout(const char *src, int *timeout)
+{
+ char filename[PATH_MAX + 1], *str;
+
+ create_name(filename, PATH_MAX, STORAGEDIR, src, "config");
+
+ str = textfile_get(filename, "pairto");
+ if (!str)
+ return -ENOENT;
+
+ if (sscanf(str, "%d", timeout) != 1) {
+ free(str);
+ return -ENOENT;
+ }
+
+ free(str);
+
+ return 0;
+}
+
int write_device_mode(bdaddr_t *bdaddr, const char *mode)
{
char filename[PATH_MAX + 1];