diff options
author | Matt Ranostay <matt.ranostay@konsulko.com> | 2019-04-10 13:57:02 -0700 |
---|---|---|
committer | Matt Ranostay <matt.ranostay@konsulko.com> | 2019-04-10 19:28:43 -0700 |
commit | 10563449b9c9a01f9b1d25d13a19dbf5fa0ee501 (patch) | |
tree | a2be6828b25d1b81516f7a0c53e7322ead7b408f | |
parent | c69f4875cf165c9cd71d6c6531b04bc6f4eb230b (diff) |
binding: bluetooth-pbap: save cached contacts by per device
Use the respective device's MAC address as an key for caching
of contacts. This allows multiple devices to be paired with
each having their own cached results.
Bug-AGL: SPEC-2311
Change-Id: Iadc4da383a5e0860866414c9228e2e10ba238395
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
-rw-r--r-- | binding/bluetooth-pbap-binding.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/binding/bluetooth-pbap-binding.c b/binding/bluetooth-pbap-binding.c index 1493c16..76ee9ad 100644 --- a/binding/bluetooth-pbap-binding.c +++ b/binding/bluetooth-pbap-binding.c @@ -46,6 +46,7 @@ static GMutex xfer_complete_mutex; static GCond xfer_complete_cond; static GMutex connected_mutex; static gboolean connected = FALSE; +static gchar *connected_address = NULL; static afb_event_t status_event; #define PBAP_UUID "0000112f-0000-1000-8000-00805f9b34fb" @@ -366,7 +367,7 @@ void contacts(afb_req_t request) if (!parse_max_entries_parameter(request, &max_entries)) return; - if (max_entries == -1 && !read_cached_value("default", &cached)) { + if (max_entries == -1 && !read_cached_value(connected_address, &cached)) { jresp = json_tokener_parse(cached); } else { org_bluez_obex_phonebook_access1_call_select_sync( @@ -649,6 +650,10 @@ static gboolean is_pbap_dev_and_init(struct json_object *dev) jresp = json_object_new_object(); g_mutex_lock(&connected_mutex); + if (connected_address) + g_free(connected_address); + connected_address = g_strdup(address); + connected = TRUE; json_object_object_add(jresp, "connected", json_object_new_boolean(connected)); @@ -662,7 +667,7 @@ static gboolean is_pbap_dev_and_init(struct json_object *dev) /* probably should be made async */ org_bluez_obex_phonebook_access1_call_select_sync( phonebook, INTERNAL, CONTACTS, NULL, NULL); - update_or_insert("default", + update_or_insert(address, json_object_to_json_string_ext(get_vcards(-1), JSON_C_TO_STRING_PLAIN)); |