summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2019-04-10 13:57:02 -0700
committerMatt Ranostay <matt.ranostay@konsulko.com>2019-04-10 19:28:43 -0700
commit10563449b9c9a01f9b1d25d13a19dbf5fa0ee501 (patch)
treea2be6828b25d1b81516f7a0c53e7322ead7b408f
parentc69f4875cf165c9cd71d6c6531b04bc6f4eb230b (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.c9
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));
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340