[nfacct-rule] Use heap instead of stack, to aviod large stack usage issue.
[platform/core/connectivity/stc-manager.git] / src / stc-manager-plugin.c
index d25b1a8..d1e6d30 100755 (executable)
@@ -31,6 +31,7 @@ void stc_manager_plugin_init(void)
        handle_plugin = dlopen(STC_PLUGIN_FILEPATH, RTLD_NOW);
        if (!handle_plugin) {
                STC_LOGE("Can't load %s: %s", STC_PLUGIN_FILEPATH, dlerror());
+               __STC_LOG_FUNC_EXIT__;
                return;
        }
 
@@ -38,11 +39,11 @@ void stc_manager_plugin_init(void)
        if (!stc_plugin) {
                STC_LOGE("Can't load symbol: %s", dlerror());
                dlclose(handle_plugin);
+               __STC_LOG_FUNC_EXIT__;
                return;
        }
 
        stc_plugin_enabled = TRUE;
-
        __STC_LOG_FUNC_EXIT__;
 }
 
@@ -50,48 +51,102 @@ void stc_manager_plugin_deinit(void)
 {
        __STC_LOG_FUNC_ENTER__;
 
-       if (!stc_plugin_enabled)
+       if (!stc_plugin_enabled) {
+               __STC_LOG_FUNC_EXIT__;
                return;
+       }
 
        stc_plugin_enabled = FALSE;
        dlclose(handle_plugin);
-
        __STC_LOG_FUNC_EXIT__;
 }
 
-int stc_send_warn_message_to_net_popup(const char *content,
-               const char *type, const char *app_id, const char *iftype, const char *warn)
+int stc_send_warn_message_to_net_popup(const char *content, const char *type,
+                                      const char *app_id, const char *iftype,
+                                      const char *warn)
 {
        __STC_LOG_FUNC_ENTER__;
 
        if (!stc_plugin_enabled) {
                STC_LOGE("Plugin wasn't enabled");
+               __STC_LOG_FUNC_EXIT__;
                return 0;
        }
 
        if (!stc_plugin) {
                STC_LOGE("Plugin wasn't loaded");
+               __STC_LOG_FUNC_EXIT__;
                return 0;
        }
 
-       return stc_plugin->send_warn_message_to_net_popup(content, type, app_id, iftype, warn);
+       __STC_LOG_FUNC_EXIT__;
+       return stc_plugin->send_warn_message_to_net_popup(content, type, app_id,
+                                                         iftype, warn);
 }
 
 int stc_send_restriction_message_to_net_popup(const char *content,
-               const char *type, const char *app_id, const char *iftype, const char *limit)
+                                             const char *type,
+                                             const char *app_id,
+                                             const char *iftype,
+                                             const char *limit)
+{
+       __STC_LOG_FUNC_ENTER__;
+
+       if (!stc_plugin_enabled) {
+               STC_LOGE("Plugin wasn't enabled");
+               __STC_LOG_FUNC_EXIT__;
+               return 0;
+       }
+
+       if (!stc_plugin) {
+               STC_LOGE("Plugin wasn't loaded");
+               __STC_LOG_FUNC_EXIT__;
+               return 0;
+       }
+
+       __STC_LOG_FUNC_EXIT__;
+       return stc_plugin->send_restriction_message_to_net_popup(content, type,
+                                                                app_id, iftype,
+                                                                limit);
+}
+
+int stc_register_state_changed_cb(stc_s *stc,
+                                 stc_plugin_app_state_changed_cb cb,
+                                 void *data)
 {
        __STC_LOG_FUNC_ENTER__;
 
        if (!stc_plugin_enabled) {
                STC_LOGE("Plugin wasn't enabled");
+               __STC_LOG_FUNC_EXIT__;
                return 0;
        }
 
        if (!stc_plugin) {
                STC_LOGE("Plugin wasn't loaded");
+               __STC_LOG_FUNC_EXIT__;
                return 0;
        }
 
-       return stc_plugin->send_restriction_message_to_net_popup(content, type, app_id, iftype, limit);
+       __STC_LOG_FUNC_EXIT__;
+       return stc_plugin->register_state_changed_cb(stc, cb, data);
 }
+int stc_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;
+       }
 
+       if (!stc_plugin) {
+               STC_LOGE("Plugin wasn't loaded");
+               __STC_LOG_FUNC_EXIT__;
+               return 0;
+       }
+
+       __STC_LOG_FUNC_EXIT__;
+       return stc_plugin->deregister_state_changed_cb(stc);
+}