--- src/adapter.c | 51 --------------------------- src/storage.c | 110 ---------------------------------------------------------- src/storage.h | 4 --- 3 files changed, 165 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index c24432125..ff8f64300 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -423,18 +423,6 @@ void btd_adapter_set_class(struct btd_adapter *adapter, uint8_t major, set_dev_class(adapter); } -static uint8_t get_mode(const char *mode) -{ - if (strcasecmp("off", mode) == 0) - return MODE_OFF; - else if (strcasecmp("connectable", mode) == 0) - return MODE_CONNECTABLE; - else if (strcasecmp("discoverable", mode) == 0) - return MODE_DISCOVERABLE; - else - return MODE_UNKNOWN; -} - const char *btd_adapter_get_storage_dir(struct btd_adapter *adapter) { static char dir[25]; @@ -5639,44 +5627,6 @@ static void convert_device_storage(struct btd_adapter *adapter) textfile_foreach(filename, convert_proximity_entry, address); } -static void convert_config(struct btd_adapter *adapter, const char *filename, - GKeyFile *key_file) -{ - char address[18]; - char str[MAX_NAME_LENGTH + 1]; - char config_path[PATH_MAX]; - int timeout; - uint8_t mode; - char *data; - gsize length = 0; - - ba2str(&adapter->bdaddr, address); - snprintf(config_path, PATH_MAX, STORAGEDIR "/%s/config", address); - - if (read_pairable_timeout(address, &timeout) == 0) - g_key_file_set_integer(key_file, "General", - "PairableTimeout", timeout); - - if (read_discoverable_timeout(address, &timeout) == 0) - g_key_file_set_integer(key_file, "General", - "DiscoverableTimeout", timeout); - - if (read_on_mode(address, str, sizeof(str)) == 0) { - mode = get_mode(str); - g_key_file_set_boolean(key_file, "General", "Discoverable", - mode == MODE_DISCOVERABLE); - } - - if (read_local_name(&adapter->bdaddr, str) == 0) - g_key_file_set_string(key_file, "General", "Alias", str); - - create_file(filename, S_IRUSR | S_IWUSR); - - data = g_key_file_to_data(key_file, &length, NULL); - g_file_set_contents(filename, data, length, NULL); - g_free(data); -} - static void fix_storage(struct btd_adapter *adapter) { char filename[PATH_MAX]; @@ -5753,7 +5703,6 @@ static void load_config(struct btd_adapter *adapter) btd_adapter_get_storage_dir(adapter)); if (stat(filename, &st) < 0) { - convert_config(adapter, filename, key_file); convert_device_storage(adapter); } diff --git a/src/storage.c b/src/storage.c index 734a9e08e..6317d7cf5 100644 --- a/src/storage.c +++ b/src/storage.c @@ -22,128 +22,18 @@ * */ -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <stdio.h> -#include <errno.h> -#include <ctype.h> -#include <fcntl.h> -#include <unistd.h> #include <stdlib.h> -#include <time.h> -#include <sys/file.h> -#include <sys/stat.h> #include <glib.h> #include "lib/bluetooth.h" #include "lib/sdp.h" #include "lib/sdp_lib.h" -#include "lib/uuid.h" #include "textfile.h" #include "uuid-helper.h" #include "storage.h" -/* When all services should trust a remote device */ -#define GLOBAL_TRUST "[all]" - -struct match { - GSList *keys; - char *pattern; -}; - -static inline int create_filename(char *buf, size_t size, - const bdaddr_t *bdaddr, const char *name) -{ - char addr[18]; - - ba2str(bdaddr, addr); - - return create_name(buf, size, STORAGEDIR, addr, name); -} - -int read_discoverable_timeout(const char *src, int *timeout) -{ - char filename[PATH_MAX], *str; - - create_name(filename, PATH_MAX, STORAGEDIR, src, "config"); - - str = textfile_get(filename, "discovto"); - if (!str) - return -ENOENT; - - if (sscanf(str, "%d", timeout) != 1) { - free(str); - return -ENOENT; - } - - free(str); - - return 0; -} - -int read_pairable_timeout(const char *src, int *timeout) -{ - char filename[PATH_MAX], *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 read_on_mode(const char *src, char *mode, int length) -{ - char filename[PATH_MAX], *str; - - create_name(filename, PATH_MAX, STORAGEDIR, src, "config"); - - str = textfile_get(filename, "onmode"); - if (!str) - return -ENOENT; - - strncpy(mode, str, length); - mode[length - 1] = '\0'; - - free(str); - - return 0; -} - -int read_local_name(const bdaddr_t *bdaddr, char *name) -{ - char filename[PATH_MAX], *str; - int len; - - create_filename(filename, PATH_MAX, bdaddr, "config"); - - str = textfile_get(filename, "name"); - if (!str) - return -ENOENT; - - len = strlen(str); - if (len > HCI_MAX_NAME_LENGTH) - str[HCI_MAX_NAME_LENGTH] = '\0'; - strcpy(name, str); - - free(str); - - return 0; -} - sdp_record_t *record_from_string(const char *str) { sdp_record_t *rec; diff --git a/src/storage.h b/src/storage.h index 1c0ad57ec..8b7d9aa30 100644 --- a/src/storage.h +++ b/src/storage.h @@ -21,9 +21,5 @@ * */ -int read_discoverable_timeout(const char *src, int *timeout); -int read_pairable_timeout(const char *src, int *timeout); -int read_on_mode(const char *src, char *mode, int length); -int read_local_name(const bdaddr_t *bdaddr, char *name); sdp_record_t *record_from_string(const char *str); sdp_record_t *find_record_in_list(sdp_list_t *recs, const char *uuid); -- 2.11.0