use .accept and .disconnect 12/145712/3 accepted/tizen/unified/20170828.163917 submit/tizen/20170824.001548
authorh.sandeep <h.sandeep@samsung.com>
Wed, 23 Aug 2017 10:18:49 +0000 (15:48 +0530)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Wed, 23 Aug 2017 23:20:55 +0000 (08:20 +0900)
Remove the dependency of btd_device_attio function
and use .accept and .disconnect instead

Change-Id: I0ddfaed823e7061a0171dde28c0e87d785677f70
Signed-off-by: h.sandeep <h.sandeep@samsung.com>
profiles/proximity/immalert.c [changed mode: 0755->0644]
profiles/proximity/immalert.h [changed mode: 0755->0644]
profiles/proximity/linkloss.c [changed mode: 0755->0644]
profiles/proximity/linkloss.h [changed mode: 0755->0644]
profiles/proximity/manager.c [changed mode: 0755->0644]
profiles/proximity/monitor.c [changed mode: 0755->0644]
profiles/proximity/monitor.h [changed mode: 0755->0644]
src/device.c

old mode 100755 (executable)
new mode 100644 (file)
index adf9140..d69eae4
@@ -192,9 +192,11 @@ static void imm_alert_remove_condev(struct connected_device *condev)
 
        ia = condev->adapter;
 
+#ifndef TIZEN_FEATURE_BLUEZ_MODIFY
        if (condev->callback_id && condev->device)
                btd_device_remove_attio_callback(condev->device,
                                                        condev->callback_id);
+#endif
 
        if (condev->device)
                btd_device_unref(condev->device);
@@ -266,8 +268,6 @@ static void imm_alert_alert_lvl_write(struct gatt_db_attribute *attrib,
                condev = g_new0(struct connected_device, 1);
                condev->device = btd_device_ref(device);
                condev->adapter = ia;
-               condev->callback_id = btd_device_add_attio_callback(device,
-                                       NULL, imm_alert_disc_cb, condev);
                ia->connected_devices = g_slist_append(ia->connected_devices,
                                                                condev);
                DBG("added connected dev %p", device);
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 60b1064..0b1264c
@@ -270,9 +270,11 @@ static void link_loss_remove_condev(struct connected_device *condev)
 
        la = condev->adapter;
 
+#ifndef TIZEN_FEATURE_BLUEZ_MODIFY
        if (condev->callback_id && condev->device)
                btd_device_remove_attio_callback(condev->device,
                                                        condev->callback_id);
+#endif
 
        if (condev->local_disc_id && condev->device)
                device_remove_disconnect_watch(condev->device,
@@ -285,6 +287,7 @@ static void link_loss_remove_condev(struct connected_device *condev)
        g_free(condev);
 }
 
+#ifndef TIZEN_FEATURE_BLUEZ_MODIFY
 static void link_loss_disc_cb(gpointer user_data)
 {
        struct connected_device *condev = user_data;
@@ -298,6 +301,7 @@ static void link_loss_disc_cb(gpointer user_data)
        /* we are open for more changes now */
        link_loss_remove_condev(condev);
 }
+#endif
 
 static void link_loss_local_disc(struct btd_device *device,
                                        gboolean removal, void *user_data)
@@ -359,8 +363,6 @@ static void link_loss_alert_lvl_write(struct gatt_db_attribute *attrib,
                condev = g_new0(struct connected_device, 1);
                condev->device = btd_device_ref(device);
                condev->adapter = la;
-               condev->callback_id = btd_device_add_attio_callback(device,
-                                       NULL, link_loss_disc_cb, condev);
                condev->local_disc_id = device_add_disconnect_watch(device,
                                        link_loss_local_disc, condev, NULL);
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index dbb3bda..dabfbec
@@ -53,6 +53,31 @@ static struct enabled enabled  = {
        .findme = TRUE,
 };
 
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+static int pxp_profile_accept(struct btd_service *service)
+{
+       struct btd_device *device = btd_service_get_device(service);
+       GAttrib *attrib = btd_device_get_attrib(device);
+
+       pxp_monitor_connected(attrib, device);
+
+       btd_service_connecting_complete(service, 0);
+
+       return 0;
+}
+
+static int pxp_profile_disconnected(struct btd_service *service)
+{
+       struct btd_device *device = btd_service_get_device(service);
+
+       pxp_monitor_disconnected(device);
+
+       btd_service_disconnecting_complete(service, 0);
+
+       return 0;
+}
+#endif
+
 static int monitor_linkloss_probe(struct btd_service *service)
 {
        struct btd_device *device = btd_service_get_device(service);
@@ -115,6 +140,10 @@ static struct btd_profile pxp_monitor_linkloss_profile = {
        .remote_uuid    = LINK_LOSS_UUID,
        .device_probe   = monitor_linkloss_probe,
        .device_remove  = monitor_linkloss_remove,
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       .accept         = pxp_profile_accept,
+       .disconnect     = pxp_profile_disconnected,
+#endif
 };
 
 static struct btd_profile pxp_monitor_immediate_profile = {
@@ -122,6 +151,10 @@ static struct btd_profile pxp_monitor_immediate_profile = {
        .remote_uuid    = IMMEDIATE_ALERT_UUID,
        .device_probe   = monitor_immediate_probe,
        .device_remove  = monitor_immediate_remove,
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       .accept         = pxp_profile_accept,
+       .disconnect     = pxp_profile_disconnected,
+#endif
 };
 
 static struct btd_profile pxp_monitor_txpower_profile = {
@@ -129,6 +162,10 @@ static struct btd_profile pxp_monitor_txpower_profile = {
        .remote_uuid    = TX_POWER_UUID,
        .device_probe   = monitor_txpower_probe,
        .device_remove  = monitor_txpower_remove,
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       .accept         = pxp_profile_accept,
+       .disconnect     = pxp_profile_disconnected,
+#endif
 };
 
 static struct btd_profile pxp_reporter_profile = {
old mode 100755 (executable)
new mode 100644 (file)
index a583eb7..a70d475
@@ -382,6 +382,7 @@ static void discover_immediate_handle(struct monitor *monitor)
                                        &uuid, immediate_handle_cb, monitor);
 }
 
+#ifndef TIZEN_FEATURE_BLUEZ_MODIFY
 static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
 {
        struct monitor *monitor = user_data;
@@ -424,6 +425,58 @@ static void attio_disconnected_cb(gpointer user_data)
        g_dbus_emit_property_changed(btd_get_dbus_connection(), path,
                                PROXIMITY_INTERFACE, "ImmediateAlertLevel");
 }
+#else
+void pxp_monitor_connected(GAttrib *attrib, struct btd_device *device)
+{
+       struct monitor *monitor;
+
+       monitor = find_monitor(device);
+       if (monitor == NULL)
+               return;
+
+       monitor->attrib = g_attrib_ref(attrib);
+
+       if (monitor->enabled.linkloss)
+               write_alert_level(monitor);
+
+       if (monitor->enabled.pathloss)
+               read_tx_power(monitor);
+
+       if (monitor->immediatehandle == 0) {
+               if(monitor->enabled.pathloss || monitor->enabled.findme)
+                       discover_immediate_handle(monitor);
+       } else if (monitor->fallbacklevel)
+               write_immediate_alert(monitor);
+}
+
+void pxp_monitor_disconnected(struct btd_device *device)
+{
+       struct monitor *monitor;
+       const char *path = device_get_path(device);
+
+       monitor = find_monitor(device);
+       if (monitor == NULL)
+               return;
+
+       g_attrib_unref(monitor->attrib);
+       monitor->attrib = NULL;
+
+       if (monitor->immediateto == 0)
+               return;
+
+       g_source_remove(monitor->immediateto);
+       monitor->immediateto = 0;
+
+       if (g_strcmp0(monitor->immediatelevel, "none") == 0)
+               return;
+
+       g_free(monitor->immediatelevel);
+       monitor->immediatelevel = g_strdup("none");
+
+       g_dbus_emit_property_changed(btd_get_dbus_connection(), path,
+                               PROXIMITY_INTERFACE, "ImmediateAlertLevel");
+}
+#endif
 
 static gboolean level_is_valid(const char *level)
 {
@@ -547,12 +600,16 @@ static void property_set_immediate_alert_level(
         * If enabled, Path Loss always registers a connection callback
         * when the Proximity Monitor starts.
         */
+#ifndef TIZEN_FEATURE_BLUEZ_MODIFY
        if (monitor->attioid == 0)
                monitor->attioid = btd_device_add_attio_callback(device,
                                                        attio_connected_cb,
                                                        attio_disconnected_cb,
                                                        monitor);
        else if (monitor->attrib)
+#else
+       if (monitor->attrib)
+#endif
                write_immediate_alert(monitor);
 
 done:
@@ -668,6 +725,7 @@ static void update_monitor(struct monitor *monitor)
        if (!monitor->enabled.linkloss && !monitor->enabled.pathloss)
                return;
 
+#ifndef TIZEN_FEATURE_BLUEZ_MODIFY
        if (monitor->attioid != 0)
                return;
 
@@ -675,6 +733,7 @@ static void update_monitor(struct monitor *monitor)
                                                        attio_connected_cb,
                                                        attio_disconnected_cb,
                                                        monitor);
+#endif
 }
 
 int monitor_register_linkloss(struct btd_device *device,
@@ -761,10 +820,12 @@ static void cleanup_monitor(struct monitor *monitor)
        if (monitor->linkloss != NULL)
                return;
 
+#ifndef TIZEN_FEATURE_BLUEZ_MODIFY
        if (monitor->attioid != 0) {
                btd_device_remove_attio_callback(device, monitor->attioid);
                monitor->attioid = 0;
        }
+#endif
 
        if (monitor->attrib != NULL) {
                g_attrib_unref(monitor->attrib);
old mode 100755 (executable)
new mode 100644 (file)
index d9a40c6..d15b5d2
@@ -38,6 +38,11 @@ int monitor_register_immediate(struct btd_device *device,
                                                struct enabled *enabled,
                                                struct gatt_primary *immediate);
 
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+void pxp_monitor_connected(GAttrib *attrib, struct btd_device *device);
+void pxp_monitor_disconnected(struct btd_device *device);
+#endif
+
 void monitor_unregister_linkloss(struct btd_device *device);
 void monitor_unregister_txpower(struct btd_device *device);
 void monitor_unregister_immediate(struct btd_device *device);
index 6b5fbe0..30ec1b2 100644 (file)
@@ -6850,8 +6850,14 @@ static void register_gatt_services(struct btd_device *device)
                update_gatt_uuids(req, device->primaries, services);
 #endif
 
+#ifndef TIZEN_FEATURE_BLUEZ_MODIFY
+       /* do not delete existing primary list,
+        * just append the new primary uuids,
+        * the list will be modifed when service changed
+        * indication is received during connection */
        g_slist_free_full(device->primaries, g_free);
        device->primaries = NULL;
+#endif
 
        device_register_primaries(device, services, -1);
 
@@ -6872,9 +6878,17 @@ static void gatt_client_ready_cb(bool success, uint8_t att_ecode,
                return;
        }
 
+#ifndef TIZEN_FEATURE_BLUEZ_MODIFY
+       /* Register the services after setting the client is ready
+        * and exporting all the services and characteristics paths.
+        */
        register_gatt_services(device);
+#endif
 
        btd_gatt_client_ready(device->client_dbus);
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       register_gatt_services(device);
+#endif
 
        device_svc_resolved(device, device->bdaddr_type, 0);