Moved exception list to plugin 63/171663/1
authorhyunuktak <hyunuk.tak@samsung.com>
Tue, 6 Mar 2018 09:02:11 +0000 (18:02 +0900)
committerhyunuktak <hyunuk.tak@samsung.com>
Tue, 6 Mar 2018 09:02:24 +0000 (18:02 +0900)
Change-Id: I775492727b3ee719d1d4543005a9e0ed373f1e93
Signed-off-by: hyunuktak <hyunuk.tak@samsung.com>
14 files changed:
include/stc-manager-plugin.h
include/stc-plugin.h
packaging/stc-manager.spec
plugin/CMakeLists.txt
plugin/stc-plugin-appstatus.c [new file with mode: 0755]
plugin/stc-plugin-exception.c [new file with mode: 0755]
plugin/stc-plugin-popup.c [new file with mode: 0755]
plugin/stc-plugin.c
src/monitor/include/stc-monitor.h
src/monitor/stc-app-lifecycle.c
src/monitor/stc-monitor.c
src/stc-manager-gdbus.c
src/stc-manager-plugin.c
src/stc-manager.c

index f4233da..f0409b2 100755 (executable)
 
 #include "stc-plugin.h"
 
-void stc_manager_plugin_init(void);
-void stc_manager_plugin_deinit(void);
+int stc_manager_plugin_init(void);
+int stc_manager_plugin_deinit(void);
 
-int stc_send_warn_message_to_net_popup(const char *content,
+int stc_manager_plugin_send_warn_message(const char *content,
                const char *type, const char *app_id, const char *iftype, const char *warn);
-int stc_send_restriction_message_to_net_popup(const char *content,
+int stc_manager_plugin_send_restriction_message(const char *content,
                const char *type, const char *app_id, const char *iftype, const char *limit);
 
-int stc_register_state_changed_cb(stc_s *stc,
+int stc_manager_plugin_register_state_changed_cb(stc_s *stc,
                                  stc_plugin_app_state_changed_cb cb,
                                  void *data);
-int stc_deregister_state_changed_cb(stc_s *stc);
+int stc_manager_plugin_deregister_state_changed_cb(stc_s *stc);
+
+int stc_manager_plugin_fill_exception_list(void);
+int stc_manager_plugin_update_exception_list(void);
+int stc_manager_plugin_check_exception_by_cmdline(char *cmdline);
 
 #endif /* __STC_MANAGER_PLUGIN_H__ */
index 4d843b8..d24b042 100755 (executable)
@@ -28,20 +28,43 @@ typedef stc_error_e (*stc_plugin_app_state_changed_cb)(stc_cmd_type_e cmd,
                                                       stc_app_type_e app_type);
 
 typedef struct {
-       int(*send_restriction_message_to_net_popup) (const char *,
+       void (*initialize_plugin) (void);
+       void (*deinitialize_plugin) (void);
+
+       int (*send_restriction_message_to_net_popup) (const char *,
                                                     const char *,
                                                     const char *,
                                                     const char *,
                                                     const char *);
-       int(*send_warn_message_to_net_popup) (const char *,
+       int (*send_warn_message_to_net_popup) (const char *,
                                              const char *,
                                              const char *,
                                              const char *,
                                              const char *);
+
        int (*register_state_changed_cb) (stc_s *stc,
                                          stc_plugin_app_state_changed_cb cb,
                                          void *data);
        int (*deregister_state_changed_cb) (stc_s *stc);
+
+       int (*fill_exception_list) (void);
+       int (*update_exception_list) (void);
+       int (*check_exception_by_cmdline) (char *cmdline);
 } stc_plugin_s;
 
+void stc_plugin_initialize(void);
+void stc_plugin_deinitialize(void);
+int stc_plugin_popup_send_warn_message(const char *content,
+               const char *type, const char *app_id, const char *iftype, const char *limit);
+int stc_plugin_popup_send_restriction_message(const char *content,
+               const char *type, const char *app_id, const char *iftype, const char *limit);
+int stc_plugin_appstatus_register_changed_cb(stc_s *stc,
+               stc_plugin_app_state_changed_cb cb, void *data);
+int stc_plugin_appstatus_deregister_changed_cb(stc_s *stc);
+int stc_plugin_exception_init(void);
+int stc_plugin_exception_deinit(void);
+int stc_plugin_exception_fill_list(void);
+int stc_plugin_exception_update_list(void);
+int stc_plugin_exception_check_by_cmdline(char *cmdline);
+
 #endif /* __STC_PLUGIN_H__ */
index b67e5ea..bd37172 100644 (file)
@@ -1,6 +1,6 @@
 Name:       stc-manager
 Summary:    STC(Smart Traffic Control) manager
-Version:    0.0.41
+Version:    0.0.42
 Release:    0
 Group:      Network & Connectivity/Other
 License:    Apache-2.0
index afde5f4..bad6651 100755 (executable)
@@ -28,6 +28,9 @@ ADD_DEFINITIONS("-DUSE_DLOG")
 
 SET(SRCS_PLUGIN
        stc-plugin.c
+       stc-plugin-popup.c
+       stc-plugin-appstatus.c
+       stc-plugin-exception.c
        )
 
 # library build
diff --git a/plugin/stc-plugin-appstatus.c b/plugin/stc-plugin-appstatus.c
new file mode 100755 (executable)
index 0000000..d642cd6
--- /dev/null
@@ -0,0 +1,186 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <syspopup_caller.h>
+#include <bundle.h>
+#include <bundle_internal.h>
+#include <dlog.h>
+#include <gio/gio.h>
+
+#include "stc-plugin.h"
+
+//LCOV_EXCL_START
+#define AUL_APP_STATUS_DBUS_PATH                   "/Org/Tizen/Aul/AppStatus"
+#define AUL_APP_STATUS_DBUS_SIGNAL_INTERFACE       "org.tizen.aul.AppStatus"
+#define AUL_APP_STATUS_BUS_NAME                    AUL_APP_STATUS_DBUS_SIGNAL_INTERFACE
+
+#define AUL_APP_STATUS_DBUS_STATUS_CHANGE          "AppStatusChange"
+#define AUL_APP_STATUS_DBUS_STATUS_CHANGE_TYPE     "(issss)"
+
+typedef struct {
+       guint sub_id;
+       const gchar *path;
+       const gchar *interface;
+       const gchar *member;
+       const gchar *param_type;
+       GDBusSignalCallback callback;
+       gpointer user_data;
+} signal_map_s;
+
+stc_error_e(*state_changed_cb)(stc_cmd_type_e cmd, pid_t pid,
+                              const gchar *app_id, const gchar *pkg_id,
+                              stc_app_type_e app_type);
+
+static void __stc_gdbus_handle_aul_changestate(GDBusConnection *connection,
+                                              const gchar *sender_name,
+                                              const gchar *object_path,
+                                              const gchar *interface_name,
+                                              const gchar *signal_name,
+                                              GVariant *parameters,
+                                              gpointer user_data)
+{
+       pid_t pid;
+       stc_cmd_type_e status;
+       stc_app_type_e apptype;
+       gchar *appid, *pkgid, *statstr, *pkgtype;
+
+       if (g_strcmp0(g_variant_get_type_string(parameters),
+                     AUL_APP_STATUS_DBUS_STATUS_CHANGE_TYPE)) {
+               STC_LOGE("Dbus type not matching, do not process");
+               return;
+       }
+
+       g_variant_get(parameters, AUL_APP_STATUS_DBUS_STATUS_CHANGE_TYPE,
+                     &pid, &appid, &pkgid, &statstr, &pkgtype);
+
+       if (!strncmp(statstr, "fg", 2)) {
+               status = STC_CMD_SET_FOREGRD;
+       } else if (!strncmp(statstr, "bg", 2)) {
+               status = STC_CMD_SET_BACKGRD;
+       } else {
+               goto out;
+       }
+
+       if (!strncmp(pkgtype, "svc", 3))
+               apptype = STC_APP_TYPE_SERVICE;
+       else if (!strncmp(pkgtype, "widget", 6))
+               apptype = STC_APP_TYPE_WIDGET;
+       else if (!strncmp(pkgtype, "watch", 5))
+               apptype = STC_APP_TYPE_WATCH;
+       else
+               apptype = STC_APP_TYPE_GUI;
+
+       if (STC_DEBUG_LOG) {
+               STC_LOGD("\033[1;36mAPP STATUS\033[0;m: Pkg ID [\033[0;34m%s\033[0;m], "
+                       "App ID [\033[0;32m%s\033[0;m], PID [\033[1;33m%d\033[0;m], Status [%s], Type [%s]",
+                       pkgid, appid, pid, statstr, pkgtype);
+       }
+
+       if (state_changed_cb)
+               state_changed_cb(status, pid, appid, pkgid, apptype);
+
+out:
+       FREE(appid);
+       FREE(pkgid);
+       FREE(statstr);
+       FREE(pkgtype);
+}
+
+signal_map_s signal_map[] = {
+
+       /* AMD DBUS */
+       {
+               0,
+               AUL_APP_STATUS_DBUS_PATH,
+               AUL_APP_STATUS_DBUS_SIGNAL_INTERFACE,
+               AUL_APP_STATUS_DBUS_STATUS_CHANGE,
+               AUL_APP_STATUS_DBUS_STATUS_CHANGE_TYPE,
+               __stc_gdbus_handle_aul_changestate,
+               NULL
+       },
+       {
+               0,
+               NULL,
+               NULL,
+               NULL,
+               NULL
+       }
+};
+
+
+static stc_error_e __ground_status_monitor_init(stc_s *stc)
+{
+       guint i = 0;
+
+       ret_value_msg_if(stc == NULL, STC_ERROR_INVALID_PARAMETER, "failed to get stc data");
+
+       for (i = 0; signal_map[i].member != NULL; i++) {
+               signal_map[i].sub_id =
+                       g_dbus_connection_signal_subscribe(stc->connection,
+                                                          NULL,
+                                                          signal_map[i].interface,
+                                                          signal_map[i].member,
+                                                          signal_map[i].path,
+                                                          NULL,
+                                                          G_DBUS_SIGNAL_FLAGS_NONE,
+                                                          signal_map[i].callback,
+                                                          signal_map[i].user_data,
+                                                          NULL);
+               STC_LOGI("Successfully subscribed [%s] signal",
+                        signal_map[i].member);
+       }
+
+       return STC_ERROR_NONE;
+}
+
+static stc_error_e __ground_status_monitor_deinit(stc_s *stc)
+{
+       guint i = 0;
+
+       ret_value_msg_if(stc == NULL, STC_ERROR_INVALID_PARAMETER, "failed to get stc data");
+
+       for (i = 0; signal_map[i].member != NULL; i++) {
+               g_dbus_connection_signal_unsubscribe(stc->connection,
+                                                    signal_map[i].sub_id);
+               signal_map[i].sub_id = 0;
+               STC_LOGD("Successfully unsubscribed [%s] signal",
+                        signal_map[i].member);
+       }
+
+       return STC_ERROR_NONE;
+}
+
+int stc_plugin_appstatus_register_changed_cb(stc_s *stc,
+                                      stc_plugin_app_state_changed_cb cb,
+                                      void *data)
+{
+       state_changed_cb = cb;
+       __ground_status_monitor_init(stc);
+
+       return 0;
+}
+
+int stc_plugin_appstatus_deregister_changed_cb(stc_s *stc)
+{
+       state_changed_cb = NULL;
+       __ground_status_monitor_deinit(stc);
+       return 0;
+}
+//LCOV_EXCL_STOP
diff --git a/plugin/stc-plugin-exception.c b/plugin/stc-plugin-exception.c
new file mode 100755 (executable)
index 0000000..b4f8f9e
--- /dev/null
@@ -0,0 +1,290 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <syspopup_caller.h>
+#include <bundle.h>
+#include <bundle_internal.h>
+#include <dlog.h>
+#include <gio/gio.h>
+#include <pkgmgr-info.h>
+
+#include "stc-plugin.h"
+
+//LCOV_EXCL_START
+#define EXE_TYPE_APPLICATION "app"
+#define EXE_TYPE_INSTRUCTION "inst"
+#define EXE_TYPE_SYSTEM      "sys"
+#define EXE_TYPE_SCRIPT      "script"
+
+/* 1 day */
+#define EXCNS_TIMER_INTERVAL 86400
+
+#define EXCEPTION_BUF_MAX   64
+#define EXCEPTION_STORAGE   "/var/lib/stc/exceptions"
+
+#define INTERNET_PRIVILEGE  "http://tizen.org/privilege/internet"
+
+typedef struct {
+       char *process_name;
+       char *exe_type;
+} stc_exceptions_info;
+
+typedef stc_cb_ret_e
+(*stc_exceptions_info_cb)(const stc_exceptions_info *info,
+                             void *user_data);
+
+static GHashTable *g_excns_hash;  /**< exception hash table */
+static GHashTable *g_pkginfo_filter_hash;
+static guint g_excns_timer_id;
+
+static int __pkginfo_filter_list_cb(pkgmgrinfo_pkginfo_h handle, void *user_data)
+{
+       int ret = 0;
+       char *pkgname = NULL;
+
+       ret = pkgmgrinfo_pkginfo_get_pkgname(handle, &pkgname);
+       if (ret == PMINFO_R_OK) {
+               if (g_hash_table_insert(g_pkginfo_filter_hash,
+                               g_strdup(pkgname), g_strdup(EXE_TYPE_APPLICATION)) != TRUE)
+                       STC_LOGE("Failed to insert hash table");
+       }
+
+       return STC_CONTINUE;
+}
+
+static int __pkginfo_pkg_list_cb(pkgmgrinfo_pkginfo_h handle, void *user_data)
+{
+       int ret = 0;
+       char *pkgname = NULL;
+       char *exe_type = NULL;
+       stc_exceptions_info data;
+       const stc_exceptions_info_cb excn_cb = user_data;
+
+       ret = pkgmgrinfo_pkginfo_get_pkgname(handle, &pkgname);
+       if (ret == PMINFO_R_OK) {
+               exe_type = g_hash_table_lookup(g_pkginfo_filter_hash, pkgname);
+               if (exe_type)
+                       return STC_CONTINUE;
+
+               data.process_name = pkgname;
+               data.exe_type = EXE_TYPE_APPLICATION;
+
+               if (excn_cb(&data, NULL) == STC_CANCEL)
+                       STC_LOGE("Failed to insert hash table");
+       }
+
+       return STC_CONTINUE;
+}
+
+static void __excn_hash_foreach_print(gpointer key, gpointer value,
+                                         gpointer data)
+{
+       const char *process_name = key;
+       const char *exe_type = value;
+
+       STC_LOGI("excn info => process_name [%s] exe_type [%s]",
+               process_name, exe_type);
+}
+
+static void __excn_hash_printall(void)
+{
+       g_hash_table_foreach(g_excns_hash,
+               __excn_hash_foreach_print, NULL);
+}
+
+static gboolean __remove_exception_app(gpointer key, gpointer value,
+                                       gpointer data)
+{
+       const char *exe_type = value;
+
+       if (g_strcmp0(exe_type, EXE_TYPE_APPLICATION) == 0)
+               return TRUE;
+
+       return FALSE;
+}
+
+static void __remove_exception_appall(void)
+{
+       g_hash_table_foreach_remove(g_excns_hash,
+               __remove_exception_app, NULL);
+}
+
+static stc_cb_ret_e __insert_exception_cb(const stc_exceptions_info *info,
+                                           void *user_data)
+{
+       stc_cb_ret_e ret = STC_CONTINUE;
+
+       if (g_hash_table_insert(g_excns_hash,
+                       g_strdup(info->process_name),
+                       g_strdup(info->exe_type)) != TRUE)
+               ret = STC_CANCEL;
+
+       return ret;
+}
+
+static gboolean __update_exceptions_app_list(void *user_data)
+{
+       stc_plugin_exception_update_list();
+       return TRUE;
+}
+
+static stc_error_e pkginfo_exceptions_foreach(const stc_exceptions_info_cb exception_cb,
+                                      void *user_data)
+{
+       int ret = 0;
+       int err = STC_ERROR_NONE;
+       pkgmgrinfo_pkginfo_filter_h handle;
+
+       g_pkginfo_filter_hash = g_hash_table_new_full(g_str_hash,
+                                               g_str_equal, g_free, g_free);
+
+       ret = pkgmgrinfo_pkginfo_filter_create(&handle);
+       ret_value_msg_if(ret != PMINFO_R_OK, STC_ERROR_FAIL,
+                       "Failed to create pkginfo filter");
+
+       ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
+                       PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE,
+                       INTERNET_PRIVILEGE);
+       if (ret != PMINFO_R_OK) {
+               STC_LOGE("Failed to add pkginfo filter string");
+               err = STC_ERROR_FAIL;
+               goto out;
+       }
+
+       ret = pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle,
+                       __pkginfo_filter_list_cb, NULL);
+       if (ret != PMINFO_R_OK) {
+               STC_LOGE("Failed to foreach pkginfo filter");
+               err = STC_ERROR_FAIL;
+               goto out;
+       }
+
+       ret = pkgmgrinfo_pkginfo_get_list(__pkginfo_pkg_list_cb, exception_cb);
+       if (ret != PMINFO_R_OK) {
+               STC_LOGE("Failed to get pkginfo list");
+               err = STC_ERROR_FAIL;
+               goto out;
+       }
+
+out:
+       if (g_pkginfo_filter_hash) {
+               g_hash_table_destroy(g_pkginfo_filter_hash);
+               g_pkginfo_filter_hash = NULL;
+       }
+
+       if (handle)
+               pkgmgrinfo_pkginfo_filter_destroy(handle);
+
+       return err;
+}
+
+static stc_error_e table_exceptions_foreach(const stc_exceptions_info_cb exception_cb,
+                                      void *user_data)
+{
+       stc_error_e error_code = STC_ERROR_NONE;
+       stc_exceptions_info data;
+
+       FILE *fp = NULL;
+       char buf[EXCEPTION_BUF_MAX] = {0, };
+
+       fp = fopen(EXCEPTION_STORAGE, "r");
+       ret_value_msg_if(!fp, STC_ERROR_FAIL, "Failed to open %s file");
+
+       while (fgets(buf, sizeof(buf), fp) != NULL) {
+               char *process_name, *exe_type;
+               char *save_ptr = NULL;
+
+               process_name = strtok_r(buf, ":", &save_ptr);
+               if (process_name != NULL)
+                       data.process_name = process_name;
+               else
+                       data.process_name = "none";
+
+               exe_type = strtok_r(NULL, "\n", &save_ptr);
+               if (exe_type != NULL)
+                       data.exe_type = exe_type;
+               else
+                       data.exe_type = "none";
+
+               if (exception_cb(&data, user_data) == STC_CANCEL)
+                       break;
+       }
+       fclose(fp);
+
+       return error_code;
+}
+
+int stc_plugin_exception_initialize(void)
+{
+       g_excns_hash = g_hash_table_new_full(g_str_hash,
+                                       g_str_equal, g_free, g_free);
+
+       return STC_ERROR_NONE;
+}
+
+int stc_plugin_exception_deinitialize(void)
+{
+       if (g_excns_timer_id > 0) {
+               g_source_remove(g_excns_timer_id);
+               g_excns_timer_id = 0;
+       }
+
+       g_hash_table_destroy(g_excns_hash);
+
+       return STC_ERROR_NONE;
+}
+
+int stc_plugin_exception_fill_list(void)
+{
+       table_exceptions_foreach(__insert_exception_cb, NULL);
+       pkginfo_exceptions_foreach(__insert_exception_cb, NULL);
+
+       if (STC_DEBUG_LOG)
+               __excn_hash_printall();
+
+       g_excns_timer_id = g_timeout_add_seconds(EXCNS_TIMER_INTERVAL,
+                       __update_exceptions_app_list,
+                       NULL);
+
+       return STC_ERROR_NONE;
+}
+
+int stc_plugin_exception_update_list(void)
+{
+       __remove_exception_appall();
+       pkginfo_exceptions_foreach(__insert_exception_cb, NULL);
+
+       if (STC_DEBUG_LOG)
+               __excn_hash_printall();
+
+       return STC_ERROR_NONE;
+}
+
+int stc_plugin_exception_check_by_cmdline(char *cmdline)
+{
+       char *exe_type = NULL;
+
+       exe_type = g_hash_table_lookup(g_excns_hash, cmdline);
+       if (!exe_type)
+               return STC_ERROR_NO_DATA;
+
+       return STC_ERROR_NONE;
+}
+//LCOV_EXCL_STOP
diff --git a/plugin/stc-plugin-popup.c b/plugin/stc-plugin-popup.c
new file mode 100755 (executable)
index 0000000..409c890
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <syspopup_caller.h>
+#include <bundle.h>
+#include <bundle_internal.h>
+#include <dlog.h>
+#include <gio/gio.h>
+
+#include "stc-plugin.h"
+
+//LCOV_EXCL_START
+int stc_plugin_popup_send_warn_message(const char *content,
+               const char *type, const char *app_id, const char *iftype, const char *warn)
+{
+       int ret = 0;
+       bundle *b = bundle_create();
+
+       STC_LOGD("Warn message : content[%s] type[%s] app_id[%s] warn[%s]",
+               content, type, app_id, warn);
+
+       bundle_add(b, "_SYSPOPUP_CONTENT_", content);
+       bundle_add(b, "_SYSPOPUP_TYPE_", type);
+       bundle_add(b, "_APP_ID_", app_id);
+       bundle_add(b, "_IF_TYPE_", iftype);
+       bundle_add(b, "_WARN_LIMIT_", warn);
+
+       ret = syspopup_launch("net-popup", b);
+
+       bundle_free(b);
+
+       return ret;
+}
+
+int stc_plugin_popup_send_restriction_message(const char *content,
+               const char *type, const char *app_id, const char *iftype, const char *limit)
+{
+       int ret = 0;
+       bundle *b = bundle_create();
+
+       STC_LOGD("Restriction message : content[%s] type[%s] app_id[%s] limit[%s]",
+               content, type, app_id, limit);
+
+       bundle_add(b, "_SYSPOPUP_CONTENT_", content);
+       bundle_add(b, "_SYSPOPUP_TYPE_", type);
+       bundle_add(b, "_APP_ID_", app_id);
+       bundle_add(b, "_IF_TYPE_", iftype);
+       bundle_add(b, "_RESTRICTION_LIMIT_", limit);
+
+       ret = syspopup_launch("net-popup", b);
+
+       bundle_free(b);
+
+       return ret;
+}
+//LCOV_EXCL_STOP
index 916a75e..9c8dd40 100755 (executable)
 #include <gio/gio.h>
 
 #include "stc-plugin.h"
-#include "stc-manager.h"
-#include "stc-manager-util.h"
 
-/*
- * AUL
- */
-#define AUL_APP_STATUS_DBUS_PATH                   "/Org/Tizen/Aul/AppStatus"
-#define AUL_APP_STATUS_DBUS_SIGNAL_INTERFACE       "org.tizen.aul.AppStatus"
-#define AUL_APP_STATUS_BUS_NAME                    AUL_APP_STATUS_DBUS_SIGNAL_INTERFACE
-
-#define AUL_APP_STATUS_DBUS_STATUS_CHANGE          "AppStatusChange"
-#define AUL_APP_STATUS_DBUS_STATUS_CHANGE_TYPE     "(issss)"
-
-typedef struct {
-       guint sub_id;
-       const gchar *path;
-       const gchar *interface;
-       const gchar *member;
-       const gchar *param_type;
-       GDBusSignalCallback callback;
-       gpointer user_data;
-} signal_map_s;
-
-stc_error_e(*state_changed_cb)(stc_cmd_type_e cmd, pid_t pid,
-                              const gchar *app_id, const gchar *pkg_id,
-                              stc_app_type_e app_type);
-
-static void __stc_gdbus_handle_aul_changestate(GDBusConnection *connection,
-                                              const gchar *sender_name,
-                                              const gchar *object_path,
-                                              const gchar *interface_name,
-                                              const gchar *signal_name,
-                                              GVariant *parameters,
-                                              gpointer user_data)
-{
-       pid_t pid;
-       stc_cmd_type_e status;
-       stc_app_type_e apptype;
-       gchar *appid, *pkgid, *statstr, *pkgtype;
-
-       if (g_strcmp0(g_variant_get_type_string(parameters),
-                     AUL_APP_STATUS_DBUS_STATUS_CHANGE_TYPE)) {
-               STC_LOGE("Dbus type not matching, do not process");
-               return;
-       }
-
-       g_variant_get(parameters, AUL_APP_STATUS_DBUS_STATUS_CHANGE_TYPE,
-                     &pid, &appid, &pkgid, &statstr, &pkgtype);
-
-       if (!strncmp(statstr, "fg", 2)) {
-               status = STC_CMD_SET_FOREGRD;
-       } else if (!strncmp(statstr, "bg", 2)) {
-               status = STC_CMD_SET_BACKGRD;
-       } else {
-               goto out;
-       }
-
-       if (!strncmp(pkgtype, "svc", 3))
-               apptype = STC_APP_TYPE_SERVICE;
-       else if (!strncmp(pkgtype, "widget", 6))
-               apptype = STC_APP_TYPE_WIDGET;
-       else if (!strncmp(pkgtype, "watch", 5))
-               apptype = STC_APP_TYPE_WATCH;
-       else
-               apptype = STC_APP_TYPE_GUI;
-
-       if (STC_DEBUG_LOG) {
-               STC_LOGD("\033[1;36mAPP STATUS\033[0;m: Pkg ID [\033[0;34m%s\033[0;m], "
-                       "App ID [\033[0;32m%s\033[0;m], PID [\033[1;33m%d\033[0;m], Status [%s], Type [%s]",
-                       pkgid, appid, pid, statstr, pkgtype);
-       }
-
-       if (state_changed_cb)
-               state_changed_cb(status, pid, appid, pkgid, apptype);
-
-out:
-       FREE(appid);
-       FREE(pkgid);
-       FREE(statstr);
-       FREE(pkgtype);
-}
-
-signal_map_s signal_map[] = {
-
-       /* AMD DBUS */
-       {
-               0,
-               AUL_APP_STATUS_DBUS_PATH,
-               AUL_APP_STATUS_DBUS_SIGNAL_INTERFACE,
-               AUL_APP_STATUS_DBUS_STATUS_CHANGE,
-               AUL_APP_STATUS_DBUS_STATUS_CHANGE_TYPE,
-               __stc_gdbus_handle_aul_changestate,
-               NULL
-       },
-       {
-               0,
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       }
-};
-
-
-static stc_error_e __ground_status_monitor_init(stc_s *stc)
-{
-       guint i = 0;
-
-       ret_value_msg_if(stc == NULL, STC_ERROR_INVALID_PARAMETER, "failed to get stc data");
-
-       for (i = 0; signal_map[i].member != NULL; i++) {
-               signal_map[i].sub_id =
-                       g_dbus_connection_signal_subscribe(stc->connection,
-                                                          NULL,
-                                                          signal_map[i].interface,
-                                                          signal_map[i].member,
-                                                          signal_map[i].path,
-                                                          NULL,
-                                                          G_DBUS_SIGNAL_FLAGS_NONE,
-                                                          signal_map[i].callback,
-                                                          signal_map[i].user_data,
-                                                          NULL);
-               STC_LOGI("Successfully subscribed [%s] signal",
-                        signal_map[i].member);
-       }
-
-       return STC_ERROR_NONE;
-}
-
-static stc_error_e __ground_status_monitor_deinit(stc_s *stc)
+void stc_plugin_initialize(void)
 {
-       guint i = 0;
-
-       ret_value_msg_if(stc == NULL, STC_ERROR_INVALID_PARAMETER, "failed to get stc data");
-
-       for (i = 0; signal_map[i].member != NULL; i++) {
-               g_dbus_connection_signal_unsubscribe(stc->connection,
-                                                    signal_map[i].sub_id);
-               signal_map[i].sub_id = 0;
-               STC_LOGD("Successfully unsubscribed [%s] signal",
-                        signal_map[i].member);
-       }
-
-       return STC_ERROR_NONE;
+       stc_plugin_exception_init();
 }
 
-static int __stc_send_warn_message_to_net_popup(const char *content,
-               const char *type, const char *app_id, const char *iftype, const char *warn)
+void stc_plugin_deinitialize(void)
 {
-       int ret = 0;
-       bundle *b = bundle_create();
-
-       STC_LOGD("Warn message : content[%s] type[%s] app_id[%s] warn[%s]",
-               content, type, app_id, warn);
-
-       bundle_add(b, "_SYSPOPUP_CONTENT_", content);
-       bundle_add(b, "_SYSPOPUP_TYPE_", type);
-       bundle_add(b, "_APP_ID_", app_id);
-       bundle_add(b, "_IF_TYPE_", iftype);
-       bundle_add(b, "_WARN_LIMIT_", warn);
-
-       ret = syspopup_launch("net-popup", b);
-
-       bundle_free(b);
-
-       return ret;
-}
-
-static int __stc_send_restriction_message_to_net_popup(const char *content,
-               const char *type, const char *app_id, const char *iftype, const char *limit)
-{
-       int ret = 0;
-       bundle *b = bundle_create();
-
-       STC_LOGD("Restriction message : content[%s] type[%s] app_id[%s] limit[%s]",
-               content, type, app_id, limit);
-
-       bundle_add(b, "_SYSPOPUP_CONTENT_", content);
-       bundle_add(b, "_SYSPOPUP_TYPE_", type);
-       bundle_add(b, "_APP_ID_", app_id);
-       bundle_add(b, "_IF_TYPE_", iftype);
-       bundle_add(b, "_RESTRICTION_LIMIT_", limit);
-
-       ret = syspopup_launch("net-popup", b);
-
-       bundle_free(b);
-
-       return ret;
-}
-
-static int __register_state_changed_cb(stc_s *stc,
-                                      stc_plugin_app_state_changed_cb cb,
-                                      void *data)
-{
-       state_changed_cb = cb;
-       __ground_status_monitor_init(stc);
-
-       return 0;
-}
-
-int __deregister_state_changed_cb(stc_s *stc)
-{
-       state_changed_cb = NULL;
-       __ground_status_monitor_deinit(stc);
-       return 0;
+       stc_plugin_exception_deinit();
 }
 
 API stc_plugin_s stc_plugin = {
+       .initialize_plugin =
+               stc_plugin_initialize,
+       .deinitialize_plugin =
+               stc_plugin_deinitialize,
        .send_warn_message_to_net_popup =
-               __stc_send_warn_message_to_net_popup,
+               stc_plugin_popup_send_restriction_message,
        .send_restriction_message_to_net_popup =
-               __stc_send_restriction_message_to_net_popup,
-       .register_state_changed_cb = __register_state_changed_cb,
-       .deregister_state_changed_cb = __deregister_state_changed_cb
+               stc_plugin_popup_send_restriction_message,
+       .register_state_changed_cb =
+               stc_plugin_appstatus_register_changed_cb,
+       .deregister_state_changed_cb =
+               stc_plugin_appstatus_deregister_changed_cb,
+       .fill_exception_list =
+               stc_plugin_exception_fill_list,
+       .update_exception_list =
+               stc_plugin_exception_update_list,
+       .check_exception_by_cmdline =
+               stc_plugin_exception_check_by_cmdline
 };
-
index 0ecce65..b8a7357 100755 (executable)
@@ -28,9 +28,6 @@
 /* 1 seconds */
 #define CONTR_TIMER_INTERVAL 1
 
-/* 1 day */
-#define EXCNS_TIMER_INTERVAL 86400
-
 /**
  * @brief key for processes tree
  */
@@ -102,8 +99,6 @@ typedef struct {
        gboolean rstns_tree_updated;
        GTree *apps;  /**< monitored applications */
        gboolean apps_tree_updated;
-       GHashTable *excns_hash;  /**< exception hash table */
-       guint excns_timer_id;
        guint background_state;
 } stc_system_s;
 
index 1cd8e9d..2aeef79 100755 (executable)
@@ -206,7 +206,8 @@ static gboolean __check_excn(char *cmdline)
                return TRUE;
 
        ret = stc_monitor_check_excn_by_cmdline(cmdline);
-       if (ret == STC_ERROR_NO_DATA)
+       if (ret == STC_ERROR_UNINITIALIZED ||
+               ret == STC_ERROR_NO_DATA)
                return FALSE;
        else
                return TRUE;
index 8b18657..26db273 100755 (executable)
@@ -26,7 +26,6 @@
 #include "counter.h"
 #include "table-statistics.h"
 #include "table-counters.h"
-#include "stc-exception.h"
 #include "stc-monitor.h"
 #include "stc-manager-plugin.h"
 
@@ -545,7 +544,6 @@ static void __process_restriction(enum traffic_restriction_type rst_type,
                        g_strlcpy(counter.ifname, default_ifname,
                                  MAX_IFACE_LENGTH);
 
-                       generate_counter_name(&counter);
                        g_free(default_ifname);
 
                        /* iptables rule */
@@ -587,7 +585,6 @@ static void __process_restriction(enum traffic_restriction_type rst_type,
                        g_strlcpy(counter.ifname, default_ifname,
                                  MAX_IFACE_LENGTH);
 
-                       generate_counter_name(&counter);
                        g_free(default_ifname);
 
                        /* iptables rule */
@@ -758,7 +755,7 @@ static gboolean __rstn_counter_update(stc_rstn_key_s *rstn_key,
 
                        snprintf(iftype, MAX_INT_LENGTH, "%d", rstn_key->iftype);
                        snprintf(byte, MAX_INT_LENGTH, "%lld", rstn_value->data_warn_limit);
-                       stc_send_warn_message_to_net_popup("warn threshold crossed",
+                       stc_manager_plugin_send_warn_message("warn threshold crossed",
                                                           "warning_noti",
                                                           rstn_key->app_id,
                                                           iftype, byte);
@@ -799,7 +796,7 @@ static gboolean __rstn_counter_update(stc_rstn_key_s *rstn_key,
 
                        snprintf(iftype, MAX_INT_LENGTH, "%d", rstn_key->iftype);
                        snprintf(byte, MAX_INT_LENGTH, "%lld", rstn_value->data_limit);
-                       stc_send_restriction_message_to_net_popup("restriction threshold crossed",
+                       stc_manager_plugin_send_restriction_message("restriction threshold crossed",
                                                                  "restriction_noti", rstn_key->app_id,
                                                                  iftype, byte);
                }
@@ -1515,70 +1512,9 @@ static stc_error_e __process_update_background(void)
        return STC_ERROR_NONE;
 }
 
-#if 0
-static void __excn_hash_foreach_print(gpointer key, gpointer value,
-                                         gpointer data)
-{
-       const char *process_name = key;
-       const char *exe_type = value;
-
-       STC_LOGI("excn info => process_name [%s] exe_type [%s]",
-               process_name, exe_type);
-}
-
-static void __excn_hash_printall(void)
-{
-       g_hash_table_foreach(g_system->excns_hash,
-               __excn_hash_foreach_print, NULL);
-}
-#endif
-
-static gboolean __remove_exception_app(gpointer key, gpointer value,
-                                       gpointer data)
-{
-       const char *exe_type = value;
-
-       if (g_strcmp0(exe_type, EXE_TYPE_APPLICATION) == 0)
-               return TRUE;
-
-       return FALSE;
-}
-
-static void __remove_exception_appall(void)
-{
-       g_hash_table_foreach_remove(g_system->excns_hash,
-               __remove_exception_app, NULL);
-}
-
-static stc_cb_ret_e __insert_exception_cb(const stc_exceptions_info *info,
-                                           void *user_data)
-{
-       stc_cb_ret_e ret = STC_CONTINUE;
-
-       if (g_hash_table_insert(g_system->excns_hash,
-                       g_strdup(info->process_name),
-                       g_strdup(info->exe_type)) != TRUE)
-               ret = STC_CANCEL;
-
-       return ret;
-}
-
 static void __fill_exceptions_list(void)
 {
-       table_exceptions_foreach(__insert_exception_cb, NULL);
-       pkginfo_exceptions_foreach(__insert_exception_cb, NULL);
-
-       /* __excn_hash_printall(); */
-}
-
-static gboolean __update_exceptions_app_list(void *user_data)
-{
-       __remove_exception_appall();
-       pkginfo_exceptions_foreach(__insert_exception_cb, NULL);
-
-       /* __excn_hash_printall(); */
-
-       return TRUE;
+       stc_manager_plugin_fill_exception_list();
 }
 
 stc_error_e stc_monitor_init(void)
@@ -1603,9 +1539,6 @@ stc_error_e stc_monitor_init(void)
                                        __rstns_tree_key_free,
                                        __rstns_tree_value_free);
 
-       system->excns_hash = g_hash_table_new_full(g_str_hash,
-                                       g_str_equal, g_free, g_free);
-
        /* create netlink socket for updating kernel counters */
        system->contr_sock = create_netlink(NETLINK_NETFILTER, 0);
        if (system->contr_sock < 0) {
@@ -1648,10 +1581,6 @@ stc_error_e stc_monitor_init(void)
        __fill_exceptions_list();
        __fill_restritions_list();
 
-       g_system->excns_timer_id = g_timeout_add_seconds(EXCNS_TIMER_INTERVAL,
-                                                        __update_exceptions_app_list,
-                                                        NULL);
-
        return STC_ERROR_NONE;
 }
 
@@ -1668,12 +1597,6 @@ stc_error_e stc_monitor_deinit(void)
                g_system->contr_timer_id = 0;
        }
 
-       /* remove exceptions app list update timer */
-       if (g_system->excns_timer_id > 0) {
-               g_source_remove(g_system->excns_timer_id);
-               g_system->excns_timer_id = 0;
-       }
-
        /* destroy monitored application tree */
        g_tree_destroy(g_system->apps);
        g_system->apps = NULL;
@@ -1682,10 +1605,6 @@ stc_error_e stc_monitor_deinit(void)
        g_tree_destroy(g_system->rstns);
        g_system->rstns = NULL;
 
-       /* destroy exception hash table */
-       g_hash_table_destroy(g_system->excns_hash);
-       g_system->excns_hash = NULL;
-
        FREE(g_system);
 
        return STC_ERROR_NONE;
@@ -1963,15 +1882,7 @@ stc_error_e stc_monitor_rstns_tree_remove(const table_restrictions_info *info)
 
 stc_error_e stc_monitor_check_excn_by_cmdline(char *cmdline)
 {
-       ret_value_msg_if(g_system == NULL, STC_ERROR_FAIL, "stc monitor not initialized!");
-
-       char *exe_type = NULL;
-
-       exe_type = g_hash_table_lookup(g_system->excns_hash, cmdline);
-       if (!exe_type)
-               return STC_ERROR_NO_DATA;
-
-       return STC_ERROR_NONE;
+       return stc_manager_plugin_check_exception_by_cmdline(cmdline);
 }
 
 int stc_monitor_get_counter_socket(void)
index aee4c9e..93a18d1 100755 (executable)
@@ -155,7 +155,7 @@ static void __stc_manager_gdbus_on_bus_acquired(GDBusConnection *connection,
                                                    stc->connection);
 
        stc_default_connection_monitor_init(stc);
-       stc_register_state_changed_cb(stc, stc_manager_app_status_changed, NULL);
+       stc_manager_plugin_register_state_changed_cb(stc, stc_manager_app_status_changed, NULL);
 
        __STC_LOG_FUNC_EXIT__;
 }
@@ -196,7 +196,7 @@ void stc_manager_gdbus_deinit(gpointer stc_data)
        __STC_LOG_FUNC_ENTER__;
        stc_s *stc = (stc_s *)stc_data;
 
-       stc_deregister_state_changed_cb(stc);
+       stc_manager_plugin_deregister_state_changed_cb(stc);
        stc_default_connection_monitor_deinit(stc);
 
        g_bus_unown_name(stc->gdbus_owner_id);
index d1e6d30..c627499 100755 (executable)
 #include <dlfcn.h>
 
 #include "stc-manager.h"
-#include "stc-plugin.h"
 #include "stc-manager-plugin.h"
 
 static gboolean stc_plugin_enabled = FALSE;
 static void *handle_plugin;
 static stc_plugin_s *stc_plugin;
 
-void stc_manager_plugin_init(void)
+int stc_manager_plugin_init(void)
 {
        __STC_LOG_FUNC_ENTER__;
 
@@ -32,7 +31,7 @@ void stc_manager_plugin_init(void)
        if (!handle_plugin) {
                STC_LOGE("Can't load %s: %s", STC_PLUGIN_FILEPATH, dlerror());
                __STC_LOG_FUNC_EXIT__;
-               return;
+               return STC_ERROR_UNINITIALIZED;
        }
 
        stc_plugin = dlsym(handle_plugin, "stc_plugin");
@@ -40,28 +39,34 @@ void stc_manager_plugin_init(void)
                STC_LOGE("Can't load symbol: %s", dlerror());
                dlclose(handle_plugin);
                __STC_LOG_FUNC_EXIT__;
-               return;
+               return STC_ERROR_UNINITIALIZED;
        }
 
        stc_plugin_enabled = TRUE;
+       stc_plugin->initialize_plugin();
+
        __STC_LOG_FUNC_EXIT__;
+       return STC_ERROR_NONE;
 }
 
-void stc_manager_plugin_deinit(void)
+int stc_manager_plugin_deinit(void)
 {
        __STC_LOG_FUNC_ENTER__;
 
        if (!stc_plugin_enabled) {
                __STC_LOG_FUNC_EXIT__;
-               return;
+               return STC_ERROR_UNINITIALIZED;
        }
 
+       stc_plugin->deinitialize_plugin();
+
        stc_plugin_enabled = FALSE;
        dlclose(handle_plugin);
        __STC_LOG_FUNC_EXIT__;
+       return STC_ERROR_NONE;
 }
 
-int stc_send_warn_message_to_net_popup(const char *content, const char *type,
+int stc_manager_plugin_send_warn_message(const char *content, const char *type,
                                       const char *app_id, const char *iftype,
                                       const char *warn)
 {
@@ -70,13 +75,13 @@ int stc_send_warn_message_to_net_popup(const char *content, const char *type,
        if (!stc_plugin_enabled) {
                STC_LOGE("Plugin wasn't enabled");
                __STC_LOG_FUNC_EXIT__;
-               return 0;
+               return STC_ERROR_UNINITIALIZED;
        }
 
        if (!stc_plugin) {
                STC_LOGE("Plugin wasn't loaded");
                __STC_LOG_FUNC_EXIT__;
-               return 0;
+               return STC_ERROR_UNINITIALIZED;
        }
 
        __STC_LOG_FUNC_EXIT__;
@@ -84,7 +89,7 @@ int stc_send_warn_message_to_net_popup(const char *content, const char *type,
                                                          iftype, warn);
 }
 
-int stc_send_restriction_message_to_net_popup(const char *content,
+int stc_manager_plugin_send_restriction_message(const char *content,
                                              const char *type,
                                              const char *app_id,
                                              const char *iftype,
@@ -95,13 +100,13 @@ int stc_send_restriction_message_to_net_popup(const char *content,
        if (!stc_plugin_enabled) {
                STC_LOGE("Plugin wasn't enabled");
                __STC_LOG_FUNC_EXIT__;
-               return 0;
+               return STC_ERROR_UNINITIALIZED;
        }
 
        if (!stc_plugin) {
                STC_LOGE("Plugin wasn't loaded");
                __STC_LOG_FUNC_EXIT__;
-               return 0;
+               return STC_ERROR_UNINITIALIZED;
        }
 
        __STC_LOG_FUNC_EXIT__;
@@ -110,7 +115,7 @@ int stc_send_restriction_message_to_net_popup(const char *content,
                                                                 limit);
 }
 
-int stc_register_state_changed_cb(stc_s *stc,
+int stc_manager_plugin_register_state_changed_cb(stc_s *stc,
                                  stc_plugin_app_state_changed_cb cb,
                                  void *data)
 {
@@ -119,34 +124,85 @@ int stc_register_state_changed_cb(stc_s *stc,
        if (!stc_plugin_enabled) {
                STC_LOGE("Plugin wasn't enabled");
                __STC_LOG_FUNC_EXIT__;
-               return 0;
+               return STC_ERROR_UNINITIALIZED;
        }
 
        if (!stc_plugin) {
                STC_LOGE("Plugin wasn't loaded");
                __STC_LOG_FUNC_EXIT__;
-               return 0;
+               return STC_ERROR_UNINITIALIZED;
        }
 
        __STC_LOG_FUNC_EXIT__;
        return stc_plugin->register_state_changed_cb(stc, cb, data);
 }
-int stc_deregister_state_changed_cb(stc_s *stc)
+int stc_manager_plugin_deregister_state_changed_cb(stc_s *stc)
 {
        __STC_LOG_FUNC_ENTER__;
 
        if (!stc_plugin_enabled) {
                STC_LOGE("Plugin wasn't enabled");
                __STC_LOG_FUNC_EXIT__;
-               return 0;
+               return STC_ERROR_UNINITIALIZED;
        }
 
        if (!stc_plugin) {
                STC_LOGE("Plugin wasn't loaded");
                __STC_LOG_FUNC_EXIT__;
-               return 0;
+               return STC_ERROR_UNINITIALIZED;
        }
 
        __STC_LOG_FUNC_EXIT__;
        return stc_plugin->deregister_state_changed_cb(stc);
 }
+
+int stc_manager_plugin_fill_exception_list(void)
+{
+       __STC_LOG_FUNC_ENTER__;
+
+       if (!stc_plugin_enabled) {
+               STC_LOGE("Plugin wasn't enabled");
+               __STC_LOG_FUNC_EXIT__;
+               return STC_ERROR_UNINITIALIZED;
+       }
+
+       if (!stc_plugin) {
+               STC_LOGE("Plugin wasn't loaded");
+               __STC_LOG_FUNC_EXIT__;
+               return STC_ERROR_UNINITIALIZED;
+       }
+
+       __STC_LOG_FUNC_EXIT__;
+       return stc_plugin->fill_exception_list();
+}
+
+int stc_manager_plugin_update_exception_list(void)
+{
+       __STC_LOG_FUNC_ENTER__;
+
+       if (!stc_plugin_enabled) {
+               STC_LOGE("Plugin wasn't enabled");
+               __STC_LOG_FUNC_EXIT__;
+               return STC_ERROR_UNINITIALIZED;
+       }
+
+       if (!stc_plugin) {
+               STC_LOGE("Plugin wasn't loaded");
+               __STC_LOG_FUNC_EXIT__;
+               return STC_ERROR_UNINITIALIZED;
+       }
+
+       __STC_LOG_FUNC_EXIT__;
+       return stc_plugin->update_exception_list();
+}
+
+int stc_manager_plugin_check_exception_by_cmdline(char *cmdline)
+{
+       if (!stc_plugin_enabled)
+               return STC_ERROR_UNINITIALIZED;
+
+       if (!stc_plugin)
+               return STC_ERROR_UNINITIALIZED;
+
+       return stc_plugin->check_exception_by_cmdline(cmdline);
+}
index fb5d75a..e4b3d2f 100755 (executable)
@@ -29,6 +29,7 @@
 
 static stc_s *g_stc = NULL;
 
+/*
 static gboolean __validate_ident(const char *ident)
 {
        unsigned int i;
@@ -42,6 +43,7 @@ static gboolean __validate_ident(const char *ident)
 
        return TRUE;
 }
+*/
 
 static void __stc_manager_deinit(void)
 {
@@ -83,12 +85,12 @@ static stc_s *__stc_manager_init(void)
        cgroup_set_release_agent(NET_CLS_SUBSYS, NET_RELEASE_AGENT);
 
        EXEC(STC_ERROR_NONE, stc_db_initialize());
+       stc_manager_plugin_init();
 
        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);