From a9584f072945bfda5d7741d43cb870dcb291fd70 Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Thu, 13 Jun 2019 14:03:25 -0700 Subject: binding: bluetooth-map: add notification check on org.bluez.obex.Message1 interfaces Preventing of broadcasting of sent, and previously received messages over the notification event. This happens because a ListMessage call to the org.bluez.obex.MessageAccess1 interface will cause message interfaces to be created. Bug-AGL: SPEC-2512 Change-Id: I291b36be732c394c116db0d2e82cb8d4c0ce759a Signed-off-by: Matt Ranostay --- binding/bluetooth-map-api.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'binding') diff --git a/binding/bluetooth-map-api.c b/binding/bluetooth-map-api.c index 5023c5a..a52df61 100644 --- a/binding/bluetooth-map-api.c +++ b/binding/bluetooth-map-api.c @@ -408,6 +408,21 @@ static void map_notification_event(struct map_state *ns, gchar *filename) g_free(buf); } +static gboolean map_notification_check(GVariant *var) +{ + GVariantIter *array = g_variant_iter_new(var); + const char *name = NULL; + GVariant *val = NULL; + + while (g_variant_iter_next(array, "{&sv}", &name, &val)) { + if (g_strcmp0("Status", name)) + continue; + return !g_strcmp0("notification", g_variant_get_string(val, NULL)); + } + + return FALSE; +} + static void bluez_map_signal_callback( GDBusConnection *connection, const gchar *sender_name, @@ -437,6 +452,13 @@ static void bluez_map_signal_callback( GVariant *val = NULL; if (!g_strcmp0(key, BLUEZ_OBEX_MESSAGE_INTERFACE)) { + + /* ListMessages will send all messages as events + * if notification status isn't checked + */ + if (!map_notification_check(var)) + return; + map_request_message(ns, path); continue; } -- cgit 1.2.3-korg