diff options
author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2012-07-27 16:43:15 -0300 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2012-07-29 20:06:31 +0200 |
commit | cb453953f06ee47a124d9710fd25b4607db947a7 (patch) | |
tree | 2448b5ae45ae1b4ee89067601a4ec057c9043d33 /src/storage.c | |
parent | fca77266e31365de3a21d855d59a59613d17630f (diff) |
storage: Store address type in "blocked" file
Diffstat (limited to 'src/storage.c')
-rw-r--r-- | src/storage.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/src/storage.c b/src/storage.c index df876b47..252b383b 100644 --- a/src/storage.c +++ b/src/storage.c @@ -1177,38 +1177,49 @@ int read_device_pairable(bdaddr_t *bdaddr, gboolean *mode) return 0; } -gboolean read_blocked(const bdaddr_t *local, const bdaddr_t *remote) +gboolean read_blocked(const bdaddr_t *local, const bdaddr_t *remote, + uint8_t remote_type) { - char filename[PATH_MAX + 1], *str, addr[18]; + char filename[PATH_MAX + 1], *str, key[20]; create_filename(filename, PATH_MAX, local, "blocked"); - ba2str(remote, addr); + ba2str(remote, key); + sprintf(&key[17], "#%hhu", remote_type); - str = textfile_caseget(filename, addr); - if (!str) + str = textfile_caseget(filename, key); + if (str != NULL) + goto done; + + /* Try old format (address only) */ + key[17] = '\0'; + + str = textfile_caseget(filename, key); + if (str == NULL) return FALSE; +done: free(str); return TRUE; } int write_blocked(const bdaddr_t *local, const bdaddr_t *remote, - gboolean blocked) + uint8_t remote_type, gboolean blocked) { - char filename[PATH_MAX + 1], addr[18]; + char filename[PATH_MAX + 1], key[20]; create_filename(filename, PATH_MAX, local, "blocked"); create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); - ba2str(remote, addr); + ba2str(remote, key); + sprintf(&key[17], "#%hhu", remote_type); if (blocked == FALSE) - return textfile_casedel(filename, addr); + return textfile_casedel(filename, key); - return textfile_caseput(filename, addr, ""); + return textfile_caseput(filename, key, ""); } int write_device_services(const bdaddr_t *sba, const bdaddr_t *dba, |