From 6d7586ee12d4bbf0cc47c5b9bf8d300d64783e3b Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Mon, 8 Jul 2019 22:38:25 -0700 Subject: binding: bluetooth-map: add 'downloaded' field to list_messages results Signal that all the message is downloaded which is usually if the subject/message is under 256 characters with a 'downloaded' boolean parameter. This avoids libqtappfw from doing a OBEX transfer per message that under this threshold. Bug-AGL: SPEC-2512 Change-Id: I9f59337b2b4995a0359587c22e2efeee19bdae8e Signed-off-by: Matt Ranostay --- binding/bluetooth-map-api.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'binding') diff --git a/binding/bluetooth-map-api.c b/binding/bluetooth-map-api.c index efe2cdf..2784243 100644 --- a/binding/bluetooth-map-api.c +++ b/binding/bluetooth-map-api.c @@ -503,7 +503,8 @@ static void list_msgs(afb_req_t request) while (g_variant_iter_loop(iter, "{oa{sv}}", &path, &iter2)) { const char *key = NULL; GVariant *val = NULL; - json_object *msg = json_object_new_object(); + json_object *msg = json_object_new_object(), *val1; + size_t size = 0; while (g_variant_iter_loop(iter2, "{sv}", &key, &val)) { GError *error = NULL; @@ -519,6 +520,13 @@ static void list_msgs(afb_req_t request) g_clear_error(&error); } } + + if (json_object_object_get_ex(msg, "size", &val1)) + size = json_object_get_int(val1); + if (json_object_object_get_ex(msg, "subject", &val1)) + size -= strlen(json_object_get_string(val1)); + + json_object_object_add(msg, "downloaded", json_object_new_boolean(!size)); json_object_object_add(jmessage, path + strlen(session) + 1, msg); } -- cgit 1.2.3-korg