capi: Register device monitor result callback
authorSaurav Babu <saurav.babu@samsung.com>
Fri, 20 Apr 2018 06:03:16 +0000 (11:33 +0530)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 2 Jul 2018 10:38:50 +0000 (19:38 +0900)
Signed-off-by: Saurav Babu <saurav.babu@samsung.com>
capi/src/companion_dbus.c

index 8d4924f..25e152d 100755 (executable)
@@ -299,6 +299,29 @@ static void __request_result_cb(Group *object, gchar *cmd, gchar *device_id,
 
        g_free(data);
 }
+
+static void __monitor_result_cb(Group *object, gchar *uuid, gchar *group_name,
+                                       gchar *status, gpointer user_data)
+{
+       companion_device_status_e device_status;
+       comp_manager_s *handle = user_data;
+       companion_check_null_ret("user_data", user_data);
+
+       _DBG("Received Monitor Result uuid %s group name %s status %s", uuid,
+                group_name, status);
+
+       if (g_strcmp0(status, "Added") == 0)
+               device_status = COMPANION_DEVICE_ADDED;
+       else if (g_strcmp0(status, "Removed") == 0)
+               device_status = COMPANION_DEVICE_REMOVED;
+       else
+               return;
+
+       if (handle->monitor_result_cb.cb)  {
+               handle->monitor_result_cb.cb(uuid, group_name, device_status,
+                                                        handle->monitor_result_cb.user_data);
+       }
+}
 /* LCOV_EXCL_STOP */
 
 
@@ -418,6 +441,8 @@ static int _group_proxy_init(comp_manager_s *handle)
                "send-data-finish", G_CALLBACK(__send_data_finish_cb), handle);
        g_signal_connect(handle->group_proxy,
                "request-result", G_CALLBACK(__request_result_cb), handle);
+       g_signal_connect(handle->group_proxy,
+               "device-monitor-result", G_CALLBACK(__monitor_result_cb), handle);
 
        return COMP_ERROR_NONE;
 }