Add basic plugin API's 88/260588/2
authorAbhay Agarwal <ay.agarwal@samsung.com>
Wed, 6 Jan 2021 09:16:50 +0000 (14:46 +0530)
committerAbhay Agarwal <ay.agarwal@samsung.com>
Thu, 1 Jul 2021 06:31:12 +0000 (12:01 +0530)
This patch implements below interface
- init()
- deinit()
- get_state()
- get_capability()

Change-Id: I7a4c05df3d62bbcc85013d939e03bb9052d1d2f9
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
src/wifi-location-plugin.c

index 27ada1a..a14a56c 100755 (executable)
 
 #define DETECTION_WINDOW_DEFAULT       55 /* 55 seconds */
 
+static const uas_callbacks_t *uas_cbs = NULL;
+static GSList *dev_list = NULL;
+
+static int init(const uas_callbacks_t *callbacks)
+{
+       FUNC_ENTER;
+       int ret = UAS_STATUS_SUCCESS;
+
+       if (!callbacks)
+               return UAS_STATUS_FAIL;
+
+       retv_if(NULL != uas_cbs, UAS_STATUS_ALREADY_DONE);
+
+       /* TODO: Check wifi location system support */
+
+       /* TODO: Initialize wifi-location */
+
+       uas_cbs = callbacks;
+
+       FUNC_EXIT;
+       return ret;
+}
+
+static int deinit(void)
+{
+       FUNC_ENTER;
+       int ret = UAS_STATUS_SUCCESS;
+
+       if (dev_list) {
+               g_slist_free_full(dev_list, g_free);
+               dev_list = NULL;
+       }
+
+       /* TODO: Deinitialize wifi-location */
+       uas_cbs = NULL;
+
+       FUNC_EXIT;
+       return ret;
+}
+
+static int get_state(int *state)
+{
+       FUNC_ENTER;
+       int ret = UAS_STATUS_SUCCESS;
+
+       retv_if(NULL == uas_cbs, UAS_STATUS_NOT_READY);
+       retv_if(NULL == state, UAS_STATUS_FAIL);
+
+       /* TODO: Get wifi-location state */
+       *state = UAS_STATE_READY;
+
+       FUNC_EXIT;
+       return ret;
+}
+
+static int get_capability(uas_capability_e *capability)
+{
+       FUNC_ENTER;
+
+       retv_if(NULL == uas_cbs, UAS_STATUS_NOT_READY);
+       retv_if(NULL == capability, UAS_STATUS_FAIL);
+
+       *capability = UAS_SUPPORT_USER;
+
+       FUNC_EXIT;
+       return UAS_STATUS_SUCCESS;
+}
+
 static uas_api_t wifi_location_api = {
-       .init = NULL,
-       .deinit = NULL,
-       .get_state = NULL,
-       .get_capability = NULL,
+       .init = init,
+       .deinit = deinit,
+       .get_state = get_state,
+       .get_capability = get_capability,
        .set_registered_devices = NULL,
        .add_device = NULL,
        .remove_device = NULL,