Change file mode into 644
[platform/core/connectivity/stc-manager.git] / src / monitor / stc-monitor.c
old mode 100755 (executable)
new mode 100644 (file)
index 4210441..3abebef
@@ -891,9 +891,11 @@ static void __action_when_rstn_limit_exceeded(stc_rstn_limit_type_e limit_type,
                                                classid_bytes_context_s *context)
 {
        gboolean rv;
-       char iftype[MAX_INT_LENGTH];
-       char byte[MAX_INT_LENGTH];
-       const char *signal_name;
+       char iftype[MAX_INT_LENGTH] = { 0, };
+       char byte[MAX_INT_LENGTH] = { 0, };
+       const char *signal_name = NULL;
+       const char *net_popup_content = NULL;
+       const char *net_popup_type = NULL;
        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,19 +934,17 @@ 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:
                break;
        }
 
+       if (signal_name == NULL) {
+               STC_LOGE("Invalid parameter: limit_type");
+               return;
+       }
+
        /* emit signal */
        rv = stc_manager_dbus_emit_signal(stc->connection,
                                                  STC_DBUS_SERVICE_RESTRICTION_PATH,
@@ -959,6 +956,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,