Moved application ground status monitor to plugin.
[platform/core/connectivity/stc-manager.git] / src / stc-manager.c
index 69349ae..cfee380 100755 (executable)
@@ -14,9 +14,9 @@
  * limitations under the License.
  */
 
+#include <signal.h>
 #include "stc-manager.h"
-#include "stc-statistics.h"
-#include "stc-restriction.h"
+#include "stc-emulator.h"
 #include "stc-manager-gdbus.h"
 #include "stc-db.h"
 #include "counter.h"
@@ -25,6 +25,7 @@
 #include "helper-nfacct-rule.h"
 #include "stc-monitor.h"
 #include "stc-manager-plugin.h"
+#include "stc-app-lifecycle.h"
 
 static stc_s *g_stc = NULL;
 
@@ -40,7 +41,9 @@ static void __stc_manager_deinit(void)
        stc_monitor_deinit();
        stc_deinit_db_guard();
        stc_db_deinitialize();
+
        stc_manager_gdbus_deinit((gpointer)g_stc);
+       stc_app_lifecycle_monitor_deinit();
        stc_manager_plugin_deinit();
 
        STC_LOGI("stc manager deinitialized");
@@ -52,6 +55,7 @@ static stc_s *__stc_manager_init(void)
 {
        __STC_LOG_FUNC_ENTER__;
        stc_s *stc;
+       stc_error_e err = STC_ERROR_NONE;
 
        stc = MALLOC0(stc_s, 1);
        if (!stc) {
@@ -64,9 +68,13 @@ static stc_s *__stc_manager_init(void)
 
        EXEC(STC_ERROR_NONE, stc_db_initialize());
 
-       stc_monitor_init();
-       stc_manager_gdbus_init((gpointer)stc);
+       err = stc_monitor_init();
+       if (err != STC_ERROR_NONE)
+               goto handle_error;
+
        stc_manager_plugin_init();
+       stc_app_lifecycle_monitor_init();
+       stc_manager_gdbus_init((gpointer)stc);
 
        STC_LOGI("stc manager initialized");
        __STC_LOG_FUNC_EXIT__;
@@ -98,13 +106,16 @@ gint32 main(gint32 argc, gchar *argv[])
        g_type_init();
 #endif
 
-       g_stc = __stc_manager_init();
-       if (!g_stc)
-               goto fail;
-
        /* Crate the GLIB main loop */
        main_loop = g_main_loop_new(NULL, FALSE);
-       g_stc->main_loop = main_loop;
+
+       stc_emulator_check_environment();
+       if (stc_emulator_is_emulated() == FALSE) {
+               g_stc = __stc_manager_init();
+               if (!g_stc)
+                       goto fail;
+               g_stc->main_loop = main_loop;
+       }
 
        /* Run the main loop */
        g_main_loop_run(main_loop);
@@ -112,7 +123,8 @@ gint32 main(gint32 argc, gchar *argv[])
        ret = 0;
 
 fail:
-       __stc_manager_deinit();
+       if (stc_emulator_is_emulated() == FALSE)
+               __stc_manager_deinit();
 
        if (main_loop)
                g_main_loop_unref(main_loop);