Modified to send message to net popup 80/183880/1
authorhyunuktak <hyunuk.tak@samsung.com>
Thu, 12 Jul 2018 05:38:00 +0000 (14:38 +0900)
committerhyunuktak <hyunuk.tak@samsung.com>
Thu, 12 Jul 2018 05:38:06 +0000 (14:38 +0900)
Change-Id: I0ffbc76a3fc0ecee7eb9ba295a32f32f6f8391c4
Signed-off-by: hyunuktak <hyunuk.tak@samsung.com>
include/stc-manager-plugin-appstatus.h [changed mode: 0644->0755]
packaging/stc-manager.spec
plugin/appstatus/include/stc-plugin-appstatus.h [changed mode: 0644->0755]
plugin/appstatus/stc-plugin-appstatus.c [changed mode: 0644->0755]
src/monitor/stc-monitor.c
src/stc-manager-plugin-appstatus.c [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index b177bd7..1140199
@@ -24,9 +24,7 @@
 int stc_plugin_appstatus_init(void);
 int stc_plugin_appstatus_deinit(void);
 
-int stc_plugin_appstatus_send_warn_message(const char *content,
-               const char *type, const char *app_id, const char *iftype, const char *warn);
-int stc_plugin_appstatus_send_restriction_message(const char *content,
+int stc_plugin_appstatus_send_message(const char *content,
                const char *type, const char *app_id, const char *iftype, const char *limit);
 
 int stc_plugin_appstatus_register_state_changed_cb(stc_s *stc,
index bcad233..6b837c0 100644 (file)
@@ -1,6 +1,6 @@
 Name:       stc-manager
 Summary:    STC(Smart Traffic Control) manager
-Version:    0.0.70
+Version:    0.0.71
 Release:    0
 Group:      Network & Connectivity/Other
 License:    Apache-2.0
old mode 100644 (file)
new mode 100755 (executable)
index ed4a7b4..45025be
@@ -29,19 +29,15 @@ typedef stc_error_e (*stc_plugin_app_state_changed_cb)(stc_cmd_type_e cmd,
 
 typedef struct {
        /* popup */
-       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 *,
-                       const char *, const char *, const char *, const char *);
+       int (*send_message_to_net_popup) (const char *, const char *,
+                       const char *, const char *, const char *);
        /* app status */
        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);
 } stc_plugin_appstatus_s;
 
-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_popup_send_restriction_message(const char *content,
+int stc_plugin_popup_send_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,
old mode 100644 (file)
new mode 100755 (executable)
index d9764b4..672eb8c
@@ -183,42 +183,26 @@ int stc_plugin_appstatus_deregister_changed_cb(stc_s *stc)
        return 0;
 }
 
-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,
+int stc_plugin_popup_send_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);
+
+       if (g_strcmp0(type, "warning_noti") == 0) {
+               bundle_add(b, "_WARN_LIMIT_", limit);
+               STC_LOGD("Warn message : content[%s] type[%s] app_id[%s] limit[%s]",
+                       content, type, app_id, limit);
+       } else {
+               bundle_add(b, "_RESTRICTION_LIMIT_", limit);
+               STC_LOGD("Restriction message : content[%s] type[%s] app_id[%s] limit[%s]",
+                       content, type, app_id, limit);
+       }
 
        ret = syspopup_launch("net-popup", b);
 
@@ -228,10 +212,8 @@ int stc_plugin_popup_send_restriction_message(const char *content,
 }
 
 API stc_plugin_appstatus_s stc_plugin_appstatus = {
-       .send_warn_message_to_net_popup =
-               stc_plugin_popup_send_warn_message,
-       .send_restriction_message_to_net_popup =
-               stc_plugin_popup_send_restriction_message,
+       .send_message_to_net_popup =
+               stc_plugin_popup_send_message,
        .register_state_changed_cb =
                stc_plugin_appstatus_register_changed_cb,
        .deregister_state_changed_cb =
index 4210441..5885fc9 100755 (executable)
@@ -894,6 +894,8 @@ static void __action_when_rstn_limit_exceeded(stc_rstn_limit_type_e limit_type,
        char iftype[MAX_INT_LENGTH];
        char byte[MAX_INT_LENGTH];
        const char *signal_name;
+       const char *net_popup_content;
+       const char *net_popup_type;
        stc_s *stc = (stc_s *)stc_get_manager();
 
        if (stc == NULL) {
@@ -905,13 +907,8 @@ static void __action_when_rstn_limit_exceeded(stc_rstn_limit_type_e limit_type,
        case STC_RSTN_LIMIT_TYPE_DATA_WARN:
        {
                signal_name = "WarnThresholdCrossed";
-
-               snprintf(iftype, MAX_INT_LENGTH, "%d", rstn_key->iftype);
-               snprintf(byte, MAX_INT_LENGTH, "%lld", rstn_value->limit[limit_type]);
-               stc_plugin_appstatus_send_warn_message("warn threshold crossed",
-                                                                               "warning_noti",
-                                                                               rstn_key->app_id,
-                                                                               iftype, byte);
+               net_popup_content = "warn threshold crossed";
+               net_popup_type = "warning_noti";
        }
        break;
        case STC_RSTN_LIMIT_TYPE_DATA:
@@ -920,6 +917,8 @@ static void __action_when_rstn_limit_exceeded(stc_rstn_limit_type_e limit_type,
        case STC_RSTN_LIMIT_TYPE_DAILY:
        {
                signal_name = "RestrictionThresholdCrossed";
+               net_popup_content = "restriction threshold crossed";
+               net_popup_type = "restriction_noti";
 
                /* block immediately */
                context->counter->intend = NFACCT_BLOCK;
@@ -935,13 +934,6 @@ static void __action_when_rstn_limit_exceeded(stc_rstn_limit_type_e limit_type,
                context->counter->intend = NFACCT_COUNTER;
 
                rstn_value->limit_exceeded |= (1 << limit_type);
-
-               snprintf(iftype, MAX_INT_LENGTH, "%d", rstn_key->iftype);
-               snprintf(byte, MAX_INT_LENGTH, "%lld", rstn_value->limit[limit_type]);
-               stc_plugin_appstatus_send_restriction_message("restriction threshold crossed",
-                                                                               "restriction_noti",
-                                                                               rstn_key->app_id,
-                                                                               iftype, byte);
        }
        break;
        default:
@@ -959,6 +951,11 @@ static void __action_when_rstn_limit_exceeded(stc_rstn_limit_type_e limit_type,
 
        if (rv == TRUE)
                rstn_value->limit_notified |= (1 << limit_type);
+
+       snprintf(iftype, MAX_INT_LENGTH, "%d", rstn_key->iftype);
+       snprintf(byte, MAX_INT_LENGTH, "%lld", rstn_value->limit[limit_type]);
+       stc_plugin_appstatus_send_message(net_popup_content,
+                       net_popup_type, rstn_key->app_id, iftype, byte);
 }
 
 static gboolean __rstn_counter_update(stc_rstn_key_s *rstn_key,
old mode 100644 (file)
new mode 100755 (executable)
index 8bc067b..cab52ad
@@ -64,29 +64,7 @@ int stc_plugin_appstatus_deinit(void)
        return STC_ERROR_NONE;
 }
 
-int stc_plugin_appstatus_send_warn_message(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 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->send_warn_message_to_net_popup(content,
-                                                       type, app_id, iftype, warn);
-}
-
-int stc_plugin_appstatus_send_restriction_message(const char *content,
+int stc_plugin_appstatus_send_message(const char *content,
                const char *type, const char *app_id, const char *iftype, const char *limit)
 {
        __STC_LOG_FUNC_ENTER__;
@@ -104,8 +82,8 @@ int stc_plugin_appstatus_send_restriction_message(const char *content,
        }
 
        __STC_LOG_FUNC_EXIT__;
-       return stc_plugin->send_restriction_message_to_net_popup(content,
-                                                       type, app_id, iftype, limit);
+       return stc_plugin->send_message_to_net_popup(content,
+                                               type, app_id, iftype, limit);
 }
 
 int stc_plugin_appstatus_register_state_changed_cb(stc_s *stc,