Add API to remove device
[platform/core/connectivity/ua-plugin-wifi-location.git] / src / wifi-location-plugin.c
index c818c17..5f0ac9b 100755 (executable)
@@ -211,6 +211,37 @@ static int add_device(uas_device_info_t *device)
        return UAS_STATUS_SUCCESS;
 }
 
+static int remove_device(uas_device_info_t *device)
+{
+       FUNC_ENTER;
+       int ret = UAS_STATUS_SUCCESS;
+       GSList *l;
+       uas_wifi_location_info_t *wifi_location_info = NULL;
+
+       retv_if(NULL == device, UAS_STATUS_FAIL);
+       retv_if(NULL == uas_cbs, UAS_STATUS_NOT_READY);
+
+       for (l = dev_list; NULL != l; l = g_slist_next(l)) {
+               wifi_location_info = l->data;
+
+               if (!wifi_location_info) {
+                       UA_WIFI_LOCATION_ERR("data in dev list is NULL");
+                       continue;
+               }
+
+               if (!strncasecmp(wifi_location_info->device_id, device->device_id,
+                               UAS_DEVICE_ID_MAX_LEN))
+                       break;
+       }
+       retv_if(NULL == l, UAS_STATUS_ALREADY_DONE);
+
+       dev_list = g_slist_remove(dev_list, wifi_location_info);
+       g_free(wifi_location_info);
+
+       FUNC_EXIT;
+       return ret;
+}
+
 static int start_detection(unsigned int detection_type, int scan_mode)
 {
        FUNC_ENTER;
@@ -287,7 +318,7 @@ static uas_api_t wifi_location_api = {
        .get_capability = get_capability,
        .set_registered_devices = NULL,
        .add_device = add_device,
-       .remove_device = NULL,
+       .remove_device = remove_device,
        .start_detection = start_detection,
        .stop_detection = stop_detection,
        .set_low_power_mode = NULL,