rule->ifname = NULL;
rule->iftype = STC_IFACE_ALL;
rule->rstn_type = STC_RSTN_TYPE_UNKNOWN;
- rule->data_limit = 0;
- rule->data_warn_limit = 0;
+ rule->data_limit = -1;
+ rule->data_warn_limit = -1;
+ rule->monthly_limit = -1;
+ rule->weekly_limit = -1;
+ rule->daily_limit = -1;
rule->roaming = STC_ROAMING_DISABLE;
rule->subscriber_id = NULL;
}
-gboolean __validate_rstn_rule(table_restrictions_info *rule,
- enum traffic_restriction_type rstn_type)
+gboolean __validate_rstn_rule(table_restrictions_info *rule)
{
__STC_LOG_FUNC_ENTER__;
return FALSE; //LCOV_EXCL_LINE
}
- if (rstn_type <= RST_UNDEFINDED || rstn_type >= RST_MAX_VALUE) {
- __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
- return FALSE; //LCOV_EXCL_LINE
- }
-
if (rule->iftype <= STC_IFACE_UNKNOWN ||
rule->iftype >= STC_IFACE_LAST_ELEM) {
__STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
g_variant_builder_add(builder, "{sv}", "data_warn_limit",
g_variant_new_int64(info->data_warn_limit));
+ g_variant_builder_add(builder, "{sv}", "month_start_date",
+ g_variant_new_int32(info->month_start_date));
+
+ g_variant_builder_add(builder, "{sv}", "monthly_limit",
+ g_variant_new_int64(info->monthly_limit));
+
+ g_variant_builder_add(builder, "{sv}", "weekly_limit",
+ g_variant_new_int64(info->weekly_limit));
+
+ g_variant_builder_add(builder, "{sv}", "daily_limit",
+ g_variant_new_int64(info->daily_limit));
+
g_variant_builder_add(builder, "{sv}", "roaming",
g_variant_new_uint16(info->roaming));
static void __stc_extract_restriction_rule(const char *key, GVariant *value,
void *user_data)
{
- __STC_LOG_FUNC_ENTER__;
-
table_restrictions_info *rule =
(table_restrictions_info *) user_data;
if (rule == NULL) {
guint str_length;
const gchar *str = g_variant_get_string(value, &str_length);
rule->app_id = g_strdup(str);
- STC_LOGD("app_id: [%s]", (unsigned int) rule->app_id);
+ STC_LOGD("app_id: [%s]", rule->app_id);
} else if (!g_strcmp0(key, "ifname")) {
guint str_length;
rule->data_warn_limit = g_variant_get_int64(value);
STC_LOGD("data_warn_limit: [%lld]", rule->data_warn_limit);
+ } else if (!g_strcmp0(key, "month_start_date")) {
+ rule->month_start_date = g_variant_get_int32(value);
+ STC_LOGD("month_start_date: [%d]", rule->month_start_date);
+
+ } else if (!g_strcmp0(key, "monthly_limit")) {
+ rule->monthly_limit = g_variant_get_int64(value);
+ STC_LOGD("monthly_limit: [%lld]", rule->monthly_limit);
+
+ } else if (!g_strcmp0(key, "weekly_limit")) {
+ rule->weekly_limit = g_variant_get_int64(value);
+ STC_LOGD("weekly_limit: [%lld]", rule->weekly_limit);
+
+ } else if (!g_strcmp0(key, "daily_limit")) {
+ rule->daily_limit = g_variant_get_int64(value);
+ STC_LOGD("daily_limit: [%lld]", rule->daily_limit);
+
} else if (!g_strcmp0(key, "roaming")) {
rule->roaming = g_variant_get_uint16(value);
STC_LOGD("roaming: [%u]", rule->roaming);
rule->subscriber_id = g_strdup(str);
STC_LOGD("subscriber_id: [%s]", rule->subscriber_id);
+ } else if (!g_strcmp0(key, "rstn_type")) {
+ rule->rstn_type = g_variant_get_uint16(value);
+ STC_LOGD("type: [%u]", (unsigned int) rule->rstn_type);
+
} else {
STC_LOGD("Unknown select rule"); //LCOV_EXCL_LINE
}
-
- __STC_LOG_FUNC_EXIT__;
}
gboolean handle_restriction_set(StcRestriction *object,
g_variant_iter_free(iter);
}
- rule.rstn_type = STC_RSTN_TYPE_DROP;
-
- if (__validate_rstn_rule(&rule, RST_SET) == FALSE) {
- STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, //LCOV_EXCL_LINE
- STC_ERROR_INVALID_PARAMETER);
- __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
- return TRUE;
- }
-
- table_restrictions_update(&rule);
- /* update restriction rule in runtime structure */
- stc_monitor_rstns_tree_add(&rule);
-
- STC_DBUS_REPLY_ERROR_NONE(invocation);
- __STC_LOG_FUNC_EXIT__;
- return TRUE;
-}
-
-gboolean handle_restriction_exclude(StcRestriction *object,
- GDBusMethodInvocation *invocation,
- GVariant *parameters,
- void *user_data)
-{
- __STC_LOG_FUNC_ENTER__;
- GVariantIter *iter = NULL;
- table_restrictions_info rule;
-
- memset(&rule, 0, sizeof(table_restrictions_info));
- __initialize_rstn_rule(&rule);
-
- g_variant_get(parameters, "a{sv}", &iter);
- if (iter != NULL) {
- stc_manager_gdbus_dict_foreach(iter,
- __stc_extract_restriction_rule,
- &rule);
- g_variant_iter_free(iter);
- }
-
- rule.rstn_type = STC_RSTN_TYPE_ACCEPT;
-
- if (__validate_rstn_rule(&rule, RST_EXCLUDE) == FALSE) {
+ if (__validate_rstn_rule(&rule) == FALSE) {
STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, //LCOV_EXCL_LINE
STC_ERROR_INVALID_PARAMETER);
__STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
g_variant_iter_free(iter);
}
- if (__validate_rstn_rule(&rule, RST_UNSET) == FALSE) {
+ if (__validate_rstn_rule(&rule) == FALSE) {
STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, //LCOV_EXCL_LINE
STC_ERROR_INVALID_PARAMETER);
__STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE