From 3ee81cab2ed66b7f3d4fbd6ba6676d5d9448d6dc Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Thu, 27 Nov 2008 16:46:45 -0300 Subject: 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. --- src/storage.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/storage.c') 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]; -- cgit