client: Introduce ad_disable_{uuids,service,manufacturer} 11/204911/1
authorERAMOTO Masaya <eramoto.masaya@jp.fujitsu.com>
Fri, 16 Feb 2018 05:51:37 +0000 (14:51 +0900)
committerAmit Purwar <amit.purwar@samsung.com>
Mon, 15 Apr 2019 03:29:46 +0000 (08:59 +0530)
Change-Id: Id0555a1433d234f42dd1d0faa08f3274b30a1cc8
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
client/advertising.c
client/advertising.h

index 7ebd40d..08cd468 100644 (file)
@@ -507,6 +507,13 @@ void ad_unregister(DBusConnection *conn, GDBusProxy *manager)
        }
 }
 
+static void ad_clear_uuids(void)
+{
+       g_strfreev(ad.uuids);
+       ad.uuids = NULL;
+       ad.uuids_len = 0;
+}
+
 void ad_advertise_uuids(DBusConnection *conn, int argc, char *argv[])
 {
        if (argc < 2 || !strlen(argv[1])) {
@@ -519,9 +526,7 @@ void ad_advertise_uuids(DBusConnection *conn, int argc, char *argv[])
                return;
        }
 
-       g_strfreev(ad.uuids);
-       ad.uuids = NULL;
-       ad.uuids_len = 0;
+       ad_clear_uuids();
 
        ad.uuids = g_strdupv(&argv[1]);
        if (!ad.uuids) {
@@ -534,6 +539,15 @@ void ad_advertise_uuids(DBusConnection *conn, int argc, char *argv[])
        g_dbus_emit_property_changed(conn, AD_PATH, AD_IFACE, "ServiceUUIDs");
 }
 
+void ad_disable_uuids(DBusConnection *conn)
+{
+       if (!ad.uuids)
+               return;
+
+       ad_clear_uuids();
+       g_dbus_emit_property_changed(conn, AD_PATH, AD_IFACE, "ServiceUUIDs");
+}
+
 static void ad_clear_service(void)
 {
        g_free(ad.service.uuid);
@@ -583,6 +597,15 @@ void ad_advertise_service(DBusConnection *conn, int argc, char *argv[])
        g_dbus_emit_property_changed(conn, AD_PATH, AD_IFACE, "ServiceData");
 }
 
+void ad_disable_service(DBusConnection *conn)
+{
+       if (!ad.service.uuid)
+               return;
+
+       ad_clear_service();
+       g_dbus_emit_property_changed(conn, AD_PATH, AD_IFACE, "ServiceData");
+}
+
 static void ad_clear_manufacturer(void)
 {
        memset(&ad.manufacturer, 0, sizeof(ad.manufacturer));
@@ -639,6 +662,16 @@ void ad_advertise_manufacturer(DBusConnection *conn, int argc, char *argv[])
                                                        "ManufacturerData");
 }
 
+void ad_disable_manufacturer(DBusConnection *conn)
+{
+       if (!ad.manufacturer.id && !ad.manufacturer.data.len)
+               return;
+
+       ad_clear_manufacturer();
+       g_dbus_emit_property_changed(conn, AD_PATH, AD_IFACE,
+                                                       "ManufacturerData");
+}
+
 void ad_advertise_tx_power(DBusConnection *conn, dbus_bool_t *value)
 {
        if (!value) {
index 13e0764..b73d33b 100755 (executable)
@@ -25,8 +25,11 @@ void ad_register(DBusConnection *conn, GDBusProxy *manager, const char *type);
 void ad_unregister(DBusConnection *conn, GDBusProxy *manager);
 
 void ad_advertise_uuids(DBusConnection *conn, int argc, char *argv[]);
+void ad_disable_uuids(DBusConnection *conn);
 void ad_advertise_service(DBusConnection *conn, int argc, char *argv[]);
+void ad_disable_service(DBusConnection *conn);
 void ad_advertise_manufacturer(DBusConnection *conn, int argc, char *argv[]);
+void ad_disable_manufacturer(DBusConnection *conn);
 void ad_advertise_tx_power(DBusConnection *conn, dbus_bool_t *value);
 void ad_advertise_name(DBusConnection *conn, bool value);
 void ad_advertise_appearance(DBusConnection *conn, bool value);