Add function to stop reacher and get state 06/190106/1
authorYu <jiung.yu@samsung.com>
Wed, 19 Sep 2018 06:11:42 +0000 (15:11 +0900)
committerYu <jiung.yu@samsung.com>
Wed, 19 Sep 2018 06:11:47 +0000 (15:11 +0900)
Change-Id: Ia219d585d1826b4f5fd268fbed3adff0b9c10451
Signed-off-by: Yu Jiung <jiung.yu@samsung.com>
include/inm-reacher.h
src/inm-reacher.c

index 006f05145d583599d5c127bdf22426ab0349e157..6cbb91ce9e42783f6797b5be4e6c787b705c31ad 100644 (file)
@@ -74,6 +74,8 @@ int inm_reacher_start(inm_reacher_check_type_e type,
                gboolean once,
                reacher_callback cb,
                gpointer user_data);
+int inm_reacher_stop(inm_reacher_check_type_e type);
+int inm_reacher_is_running(gboolean *is_running);
 
 #ifdef __cplusplus
 }
index ffb48d84af5c6b7f5ab441a8da1557746db54f69..a0c2d9333486d1839c6d05d92e345c769c1308ca 100644 (file)
@@ -621,6 +621,17 @@ int inm_reacher_deinit(void)
        g_slist_free_full(g_reacher->user_added_url, g_free);
        g_reacher->user_added_url = NULL;
 
+       if (g_reacher->running) {
+               __clear_running_mult_data(g_reacher);
+
+               if (__deinit_curl_multi_handle(g_reacher) != 0) {
+                       __INM_FUNC_EXIT__;
+                       return INM_REACHER_ERROR_OPERATION_FAILED;
+               }
+
+               g_reacher->running = FALSE;
+       }
+
        g_reacher->active_connection = 0;
        g_reacher->cb = NULL;
        g_reacher->cb_user_data = NULL;
@@ -750,3 +761,47 @@ int inm_reacher_start(inm_reacher_check_type_e type,
        __INM_FUNC_EXIT__;
        return INM_REACHER_ERROR_NONE;
 }
+
+int inm_reacher_stop(inm_reacher_check_type_e type)
+{
+       gint ret = INM_REACHER_ERROR_NONE;
+
+       __INM_FUNC_ENTER__;
+
+       RET_ERR_IF_NOT_INIT();
+       if (!g_reacher->running) {
+               __INM_FUNC_EXIT__;
+               return ret;
+       }
+
+       g_reacher->cb = NULL;
+       g_reacher->cb_user_data = NULL;
+
+       __clear_running_mult_data(g_reacher);
+
+       if (__deinit_curl_multi_handle(g_reacher) != 0) {
+               __INM_FUNC_EXIT__;
+               return INM_REACHER_ERROR_OPERATION_FAILED;
+       }
+
+       g_reacher->running = FALSE;
+       __INM_FUNC_EXIT__;
+       return ret;
+}
+
+int inm_reacher_is_running(gboolean *is_running)
+{
+       gint ret = INM_REACHER_ERROR_NONE;
+
+       __INM_FUNC_ENTER__;
+
+       RET_ERR_IF_NOT_INIT();
+       if (!g_reacher->running) {
+               __INM_FUNC_EXIT__;
+               return ret;
+       }
+
+       *is_running = g_reacher->running;
+
+       return INM_REACHER_ERROR_NONE;
+}