Merge "Removed unwanted function send_net_restriction() and its related code." into...
[platform/core/connectivity/stc-manager.git] / src / monitor / stc-monitor.c
index 1dac02f..2674ae5 100755 (executable)
@@ -25,6 +25,9 @@
 #include "table-statistics.h"
 #include "table-counters.h"
 #include "stc-monitor.h"
+#include "stc-manager-plugin.h"
+
+#define MAX_INT_LENGTH 128
 
 typedef struct {
        stc_app_key_s *app_key;
@@ -547,6 +550,8 @@ static gboolean __rstn_counter_update_foreach_classid(gpointer key,
                if (rstn_value->counter.in_bytes >= rstn_value->warn_limit.in_bytes
                    && rstn_value->warn_limit_crossed_notified == FALSE) {
                        gboolean rv = FALSE;
+                       char iftype[MAX_INT_LENGTH];
+                       char byte[MAX_INT_LENGTH];
                        stc_s *stc = (stc_s *)stc_get_manager();
                        ret_value_msg_if(stc == NULL, FALSE, "failed to get stc data");
 
@@ -557,6 +562,11 @@ static gboolean __rstn_counter_update_foreach_classid(gpointer key,
                                                          g_variant_new("(s)", rstn_key->app_id));
                        if (rv == TRUE)
                                rstn_value->warn_limit_crossed_notified = TRUE;
+
+                       snprintf(iftype, MAX_INT_LENGTH, "%d", rstn_key->iftype);
+                       snprintf(byte, MAX_INT_LENGTH, "%lld", rstn_value->limit.in_bytes);
+                       stc_send_warn_message_to_net_popup("warn threshold crossed",
+                               "warning_noti", rstn_key->app_id, iftype, byte);
                }
 
                /* block immediately */
@@ -569,6 +579,9 @@ static gboolean __rstn_counter_update_foreach_classid(gpointer key,
 
                        if (rstn_value->rstn_limit_crossed_notified == FALSE) {
                                gboolean rv = FALSE;
+                               int ret = 0;
+                               char iftype[MAX_INT_LENGTH];
+                               char byte[MAX_INT_LENGTH];
                                stc_s *stc = (stc_s *)stc_get_manager();
                                ret_value_msg_if(stc == NULL, FALSE, "failed to get stc data");
 
@@ -579,6 +592,11 @@ static gboolean __rstn_counter_update_foreach_classid(gpointer key,
                                                                  g_variant_new("(s)", rstn_key->app_id));
                                if (rv == TRUE)
                                        rstn_value->rstn_limit_crossed_notified = TRUE;
+
+                               snprintf(iftype, MAX_INT_LENGTH, "%d", rstn_key->iftype);
+                               snprintf(byte, MAX_INT_LENGTH, "%lld", rstn_value->limit.in_bytes);
+                               stc_send_restriction_message_to_net_popup("restriction threshold crossed",
+                                       "restriction_noti", rstn_key->app_id, iftype, byte);
                        }
                }
 
@@ -591,6 +609,8 @@ static gboolean __rstn_counter_update_foreach_classid(gpointer key,
                if (rstn_value->counter.out_bytes >= rstn_value->limit.out_bytes
                    && rstn_value->warn_limit_crossed_notified == FALSE) {
                        gboolean rv = FALSE;
+                       char iftype[MAX_INT_LENGTH];
+                       char byte[MAX_INT_LENGTH];
                        stc_s *stc = (stc_s *)stc_get_manager();
                        ret_value_msg_if(stc == NULL, FALSE, "failed to get stc data");
 
@@ -601,6 +621,11 @@ static gboolean __rstn_counter_update_foreach_classid(gpointer key,
                                                          g_variant_new("(s)", rstn_key->app_id));
                        if (rv == TRUE)
                                rstn_value->warn_limit_crossed_notified = TRUE;
+
+                       snprintf(iftype, MAX_INT_LENGTH, "%d", rstn_key->iftype);
+                       snprintf(byte, MAX_INT_LENGTH, "%lld", rstn_value->limit.out_bytes);
+                       stc_send_warn_message_to_net_popup("warn threshold crossed",
+                               "warning_noti", rstn_key->app_id, iftype, byte);
                }
 
                /* block immediately */
@@ -613,6 +638,8 @@ static gboolean __rstn_counter_update_foreach_classid(gpointer key,
 
                        if (rstn_value->rstn_limit_crossed_notified == FALSE) {
                                gboolean rv = FALSE;
+                               char iftype[MAX_INT_LENGTH];
+                               char byte[MAX_INT_LENGTH];
                                stc_s *stc = (stc_s *)stc_get_manager();
                                ret_value_msg_if(stc == NULL, FALSE, "failed to get stc data");
 
@@ -623,6 +650,11 @@ static gboolean __rstn_counter_update_foreach_classid(gpointer key,
                                                                  g_variant_new("(s)", rstn_key->app_id));
                                if (rv == TRUE)
                                        rstn_value->rstn_limit_crossed_notified = TRUE;
+
+                               snprintf(iftype, MAX_INT_LENGTH, "%d", rstn_key->iftype);
+                               snprintf(byte, MAX_INT_LENGTH, "%lld", rstn_value->limit.out_bytes);
+                               stc_send_restriction_message_to_net_popup("restriction threshold crossed",
+                                       "restriction_noti", rstn_key->app_id, iftype, byte);
                        }
                }