Added some APIs for daily, weekly and monthly limits 29/183829/1 accepted/tizen/unified/20180717.063036 submit/tizen/20180713.100308
authorhyunuktak <hyunuk.tak@samsung.com>
Wed, 11 Jul 2018 09:17:07 +0000 (18:17 +0900)
committerhyunuktak <hyunuk.tak@samsung.com>
Wed, 11 Jul 2018 09:17:09 +0000 (18:17 +0900)
Change-Id: I4db5f71722f6e7d19a0fb52cc7e16db1340f407d
Signed-off-by: hyunuktak <hyunuk.tak@samsung.com>
include/stc_internal.h
packaging/capi-network-stc.spec
src/include/stc-restriction.h
src/stc-restriction.c
test/restriction.c

index 31930ce..9d688bc 100755 (executable)
@@ -233,6 +233,10 @@ typedef enum {
  * @see stc_restriction_rule_get_iface_type()
  * @see stc_restriction_rule_get_limit()
  * @see stc_restriction_rule_get_warning_limit()
+ * @see stc_restriction_rule_get_monthly_limit()
+ * @see stc_restriction_rule_get_weekly_limit()
+ * @see stc_restriction_rule_get_daily_limit()
+ * @see stc_restriction_rule_get_month_start_date()
  * @see stc_restriction_rule_get_roaming_type()
  * @see        stc_get_restriction()
  * @see        stc_foreach_restriction()
@@ -1102,6 +1106,114 @@ int stc_restriction_rule_set_warning_limit(stc_restriction_rule_h rule,
                                           int64_t data_warn_limit);
 
 /**
+ * @brief Sets the monthly data limit for restriction rule.
+ * @since_tizen 5.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.get
+ *
+ * @param[in] rule The restriction rule handle
+ * @param[in] limit The data limit
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_rule_h
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_get_monthly_limit()
+ */
+int stc_restriction_rule_set_monthly_limit(stc_restriction_rule_h rule,
+                                          int64_t limit);
+
+/**
+ * @brief Sets the weekly data limit for restriction rule.
+ * @since_tizen 5.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.get
+ *
+ * @param[in] rule The restriction rule handle
+ * @param[in] limit The data limit
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_rule_h
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_get_weekly_limit()
+ */
+int stc_restriction_rule_set_weekly_limit(stc_restriction_rule_h rule,
+                                         int64_t limit);
+
+/**
+ * @brief Sets the daily data limit for restriction rule.
+ * @since_tizen 5.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.get
+ *
+ * @param[in] rule The restriction rule handle
+ * @param[in] limit The data limit
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_rule_h
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_get_daily_limit()
+ */
+int stc_restriction_rule_set_daily_limit(stc_restriction_rule_h rule,
+                                        int64_t limit);
+
+/**
+ * @brief Sets the month start date for restriction rule.
+ * @since_tizen 5.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.get
+ *
+ * @param[in] rule The restriction rule handle
+ * @param[in] month_start_date The month start date
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_rule_h
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_get_month_start_date()
+ */
+int stc_restriction_rule_set_month_start_date(stc_restriction_rule_h rule,
+                                             int month_start_date);
+
+/**
  * @brief Sets the roaming type for restriction rule.
  * @since_tizen 4.0
  * @privlevel platform
@@ -1320,6 +1432,114 @@ int stc_restriction_rule_get_warning_limit(stc_restriction_rule_h rule,
                                           int64_t *data_warn_limit);
 
 /**
+ * @brief Gets the montlhy data limit for restriction rule.
+ * @since_tizen 5.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.get
+ *
+ * @param[in] rule The restriction rule handle
+ * @param[out] limit The data limit
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_rule_h
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_set_monthly_limit()
+ */
+int stc_restriction_rule_get_monthly_limit(stc_restriction_rule_h rule,
+                                          int64_t *limit);
+
+/**
+ * @brief Gets the weekly data limit for restriction rule.
+ * @since_tizen 5.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.get
+ *
+ * @param[in] rule The restriction rule handle
+ * @param[out] limit The data limit
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_rule_h
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_set_weekly_limit()
+ */
+int stc_restriction_rule_get_weekly_limit(stc_restriction_rule_h rule,
+                                         int64_t *limit);
+
+/**
+ * @brief Gets the daily data limit for restriction rule.
+ * @since_tizen 5.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.get
+ *
+ * @param[in] rule The restriction rule handle
+ * @param[out] limit The data limit
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_rule_h
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_set_daily_limit()
+ */
+int stc_restriction_rule_get_daily_limit(stc_restriction_rule_h rule,
+                                        int64_t *limit);
+
+/**
+ * @brief Gets the month start date for restriction rule.
+ * @since_tizen 5.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.get
+ *
+ * @param[in] rule The restriction rule handle
+ * @param[out] month_start_date The month start date
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_rule_h
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_set_month_start_date()
+ */
+int stc_restriction_rule_get_month_start_date(stc_restriction_rule_h rule,
+                                             int *month_start_date);
+
+/**
  * @brief Gets the roaming type for restriction rule.
  * @since_tizen 4.0
  * @privlevel platform
index 3de3cb1..dac4323 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-network-stc
 Summary:    A Smart Traffic Control (STC) libraries in Native API
-Version:    0.0.30
+Version:    0.0.31
 Release:    1
 Group:      Network & Connectivity/API
 License:    Apache-2.0
index 3b3e558..2e9119f 100755 (executable)
@@ -52,10 +52,14 @@ extern "C" {
 #define STC_RESTRICTION_RULE_IFNAME                            "ifname"
 #define STC_RESTRICTION_RULE_IFTYPE                            "iftype"
 #define STC_RESTRICTION_RULE_ROAMING                   "roaming"
-#define STC_RESTRICTION_RULE_RSTN_TYPE                 "type"
+#define STC_RESTRICTION_RULE_RSTN_TYPE                 "rstn_type"
 #define STC_RESTRICTION_RULE_SUBSCRIBER_ID             "subscriber_id"
 #define STC_RESTRICTION_RULE_DATA_LIMIT                        "data_limit"
 #define STC_RESTRICTION_RULE_DATA_WARN_LIMIT   "data_warn_limit"
+#define STC_RESTRICTION_RULE_MONTHLY_LIMIT             "monthly_limit"
+#define STC_RESTRICTION_RULE_WEEKLY_LIMIT              "weekly_limit"
+#define STC_RESTRICTION_RULE_DAILY_LIMIT               "daily_limit"
+#define STC_RESTRICTION_RULE_MONTH_START_DATE  "month_start_date"
 
 typedef struct {
        char app_id[STC_APP_ID_LEN];
@@ -65,6 +69,10 @@ typedef struct {
        stc_restriction_type_e rstn_type;
        int64_t data_limit;
        int64_t data_warn_limit;
+       int64_t monthly_limit;
+       int64_t weekly_limit;
+       int64_t daily_limit;
+       int month_start_date;
        stc_roaming_type_e roaming_type;
 } stc_restriction_rule_s;
 
index b6056ae..b5ad9c3 100755 (executable)
@@ -68,8 +68,12 @@ static void __stc_restriction_init_rule(stc_restriction_rule_s *rule)
        rule->iface_name[0] = '\0';
        rule->iface_type = 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->month_start_date = 0;
        rule->roaming_type = STC_ROAMING_DISABLED;
        rule->subscriber_id[0] = '\0';
 }
@@ -120,6 +124,22 @@ static void __stc_restriction_rule_make_params(
                STC_RESTRICTION_RULE_DATA_WARN_LIMIT,
                g_variant_new_int64(restriction_rule->data_warn_limit));
 
+       g_variant_builder_add(builder, "{sv}",
+               STC_RESTRICTION_RULE_MONTHLY_LIMIT,
+               g_variant_new_int64(restriction_rule->monthly_limit));
+
+       g_variant_builder_add(builder, "{sv}",
+               STC_RESTRICTION_RULE_WEEKLY_LIMIT,
+               g_variant_new_int64(restriction_rule->weekly_limit));
+
+       g_variant_builder_add(builder, "{sv}",
+               STC_RESTRICTION_RULE_DAILY_LIMIT,
+               g_variant_new_int64(restriction_rule->daily_limit));
+
+       g_variant_builder_add(builder, "{sv}",
+               STC_RESTRICTION_RULE_MONTH_START_DATE,
+               g_variant_new_int32(restriction_rule->month_start_date));
+
        *params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
        g_variant_builder_unref(builder);
 }
@@ -180,6 +200,18 @@ static void __stc_restriction_extract_rule_cb(const char *key,
        } else if (!g_strcmp0(key, STC_RESTRICTION_RULE_DATA_WARN_LIMIT)) {
                restriction_rule->data_warn_limit = g_variant_get_int64(value);
 
+       } else if (!g_strcmp0(key, STC_RESTRICTION_RULE_MONTHLY_LIMIT)) {
+               restriction_rule->monthly_limit = g_variant_get_int64(value);
+
+       } else if (!g_strcmp0(key, STC_RESTRICTION_RULE_WEEKLY_LIMIT)) {
+               restriction_rule->weekly_limit = g_variant_get_int64(value);
+
+       } else if (!g_strcmp0(key, STC_RESTRICTION_RULE_DAILY_LIMIT)) {
+               restriction_rule->daily_limit = g_variant_get_int64(value);
+
+       } else if (!g_strcmp0(key, STC_RESTRICTION_RULE_MONTH_START_DATE)) {
+               restriction_rule->month_start_date = g_variant_get_int32(value);
+
        } else if (!g_strcmp0(key, STC_RESTRICTION_RULE_ROAMING)) {
                restriction_rule->roaming_type =
                        (stc_roaming_type_e)g_variant_get_uint16(value);
@@ -208,8 +240,22 @@ static void __stc_restriction_print_rule(
        if (rule->rstn_type != STC_RSTN_TYPE_UNKNOWN)
                STC_LOGD("Type:      [%s]", _stc_convert_rstn_type_to_string(rule->rstn_type));
 
-       STC_LOGD("Limit:     [%lld] bytes", rule->data_limit);
-       STC_LOGD("Warning:   [%lld] bytes", rule->data_warn_limit);
+       if (rule->data_limit >= 0)
+               STC_LOGD("Limit:     [%lld] bytes", rule->data_limit);
+
+       if (rule->data_warn_limit >= 0)
+               STC_LOGD("Warning:   [%lld] bytes", rule->data_warn_limit);
+
+       if (rule->monthly_limit >= 0)
+               STC_LOGD("Monthly:   [%lld] bytes", rule->monthly_limit);
+
+       if (rule->weekly_limit >= 0)
+               STC_LOGD("Weekly:    [%lld] bytes", rule->weekly_limit);
+
+       if (rule->daily_limit >= 0)
+               STC_LOGD("Daily:     [%lld] bytes", rule->daily_limit);
+
+       STC_LOGD("Month start date: [%d]", rule->month_start_date);
 
        STC_LOGD(STC_HR_SINGLE);
 }
@@ -431,15 +477,35 @@ stc_error_e _stc_restriction_validate_rule(
                _stc_convert_iface_type_to_string(restriction_rule->iface_type));
 
        if (restriction_rule->rstn_type == STC_RSTN_TYPE_DROP) {
-               STC_RETURN_VAL_IF(restriction_rule->data_limit < 0,
+               STC_RETURN_VAL_IF(restriction_rule->data_limit < -1,
                        STC_ERROR_INVALID_PARAMETER,
-                       "Invalid tx limit [%lld] bytes",
+                       "Invalid data limit [%lld] bytes",
                        restriction_rule->data_limit);
 
-               STC_RETURN_VAL_IF(restriction_rule->data_warn_limit < 0,
+               STC_RETURN_VAL_IF(restriction_rule->data_warn_limit < -1,
                        STC_ERROR_INVALID_PARAMETER,
-                       "Invalid rx limit [%lld] bytes",
+                       "Invalid data warn limit [%lld] bytes",
                        restriction_rule->data_warn_limit);
+
+               STC_RETURN_VAL_IF(restriction_rule->monthly_limit < -1,
+                       STC_ERROR_INVALID_PARAMETER,
+                       "Invalid monthly limit [%lld] bytes",
+                       restriction_rule->monthly_limit);
+
+               STC_RETURN_VAL_IF(restriction_rule->weekly_limit < -1,
+                       STC_ERROR_INVALID_PARAMETER,
+                       "Invalid weekly limit [%lld] bytes",
+                       restriction_rule->weekly_limit);
+
+               STC_RETURN_VAL_IF(restriction_rule->daily_limit < -1,
+                       STC_ERROR_INVALID_PARAMETER,
+                       "Invalid daily limit [%lld] bytes",
+                       restriction_rule->daily_limit);
+
+               STC_RETURN_VAL_IF(restriction_rule->month_start_date < 0,
+                       STC_ERROR_INVALID_PARAMETER,
+                       "Invalid month start date [%d]",
+                       restriction_rule->month_start_date);
        }
 
        STC_RETURN_VAL_IF(restriction_rule->roaming_type <= STC_ROAMING_UNKNOWN ||
@@ -470,16 +536,36 @@ stc_error_e _stc_restriction_check_set_rule(
                "Invalid restriction network interface type [%s]",
                _stc_convert_iface_type_to_string(restriction_rule->iface_type));
 
-       STC_RETURN_VAL_IF(restriction_rule->data_limit < 0,
+       STC_RETURN_VAL_IF(restriction_rule->data_limit < -1,
                STC_ERROR_INVALID_PARAMETER,
-               "Invalid tx limit [%lld] bytes",
+               "Invalid data limit [%lld] bytes",
                restriction_rule->data_limit);
 
-       STC_RETURN_VAL_IF(restriction_rule->data_warn_limit < 0,
+       STC_RETURN_VAL_IF(restriction_rule->data_warn_limit < -1,
                STC_ERROR_INVALID_PARAMETER,
-               "Invalid rx limit [%lld] bytes",
+               "Invalid data warn limit [%lld] bytes",
                restriction_rule->data_warn_limit);
 
+       STC_RETURN_VAL_IF(restriction_rule->monthly_limit < -1,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid monthly limit [%lld] bytes",
+               restriction_rule->monthly_limit);
+
+       STC_RETURN_VAL_IF(restriction_rule->weekly_limit < -1,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid weekly limit [%lld] bytes",
+               restriction_rule->weekly_limit);
+
+       STC_RETURN_VAL_IF(restriction_rule->daily_limit < -1,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid daily limit [%lld] bytes",
+               restriction_rule->daily_limit);
+
+       STC_RETURN_VAL_IF(restriction_rule->month_start_date < 0,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid month start date [%d]",
+               restriction_rule->month_start_date);
+
        STC_RETURN_VAL_IF(restriction_rule->roaming_type <= STC_ROAMING_UNKNOWN ||
                restriction_rule->roaming_type > STC_ROAMING_DISABLED,
                STC_ERROR_INVALID_PARAMETER,
@@ -939,6 +1025,90 @@ EXPORT_API int stc_restriction_rule_set_warning_limit(stc_restriction_rule_h rul
        return STC_ERROR_NONE;
 }
 
+EXPORT_API int stc_restriction_rule_set_monthly_limit(stc_restriction_rule_h rule,
+                                                     int64_t limit)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_rule_s *restriction_rule =
+               (stc_restriction_rule_s *)rule;
+
+       restriction_rule->monthly_limit = limit;
+
+       STC_LOGI("Monthly limit [%lld] bytes",
+                restriction_rule->monthly_limit);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_rule_set_weekly_limit(stc_restriction_rule_h rule,
+                                                    int64_t limit)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_rule_s *restriction_rule =
+               (stc_restriction_rule_s *)rule;
+
+       restriction_rule->weekly_limit = limit;
+
+       STC_LOGI("Weekly data limit [%lld] bytes",
+                restriction_rule->weekly_limit);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_rule_set_daily_limit(stc_restriction_rule_h rule,
+                                                   int64_t limit)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_rule_s *restriction_rule =
+               (stc_restriction_rule_s *)rule;
+
+       restriction_rule->daily_limit = limit;
+
+       STC_LOGI("Daily data limit [%lld] bytes",
+                restriction_rule->daily_limit);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_rule_set_month_start_date(stc_restriction_rule_h rule,
+                                                        int date)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_rule_s *restriction_rule =
+               (stc_restriction_rule_s *)rule;
+
+       restriction_rule->month_start_date = date;
+
+       STC_LOGI("Month start date [%d]",
+                restriction_rule->month_start_date);
+
+       return STC_ERROR_NONE;
+}
+
 EXPORT_API int stc_restriction_rule_set_roaming_type(stc_restriction_rule_h rule,
                stc_roaming_type_e roaming_type)
 {
@@ -1115,6 +1285,86 @@ EXPORT_API int stc_restriction_rule_get_warning_limit(stc_restriction_rule_h rul
        return STC_ERROR_NONE;
 }
 
+EXPORT_API int stc_restriction_rule_get_monthly_limit(stc_restriction_rule_h rule,
+                                                     int64_t *limit)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL || limit == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_rule_s *restriction_rule =
+               (stc_restriction_rule_s *)rule;
+
+       *limit = restriction_rule->monthly_limit;
+
+       STC_LOGI("Monthly data limit [%lld] bytes", *limit);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_rule_get_weekly_limit(stc_restriction_rule_h rule,
+                                                    int64_t *limit)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL || limit == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_rule_s *restriction_rule =
+               (stc_restriction_rule_s *)rule;
+
+       *limit = restriction_rule->weekly_limit;
+
+       STC_LOGI("Weekly data limit [%lld] bytes", *limit);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_rule_get_daily_limit(stc_restriction_rule_h rule,
+                                                   int64_t *limit)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL || limit == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_rule_s *restriction_rule =
+               (stc_restriction_rule_s *)rule;
+
+       *limit = restriction_rule->daily_limit;
+
+       STC_LOGI("Daily data limit [%lld] bytes", *limit);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_rule_get_month_start_date(stc_restriction_rule_h rule,
+                                                        int *date)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL || date == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_rule_s *restriction_rule =
+               (stc_restriction_rule_s *)rule;
+
+       *date = restriction_rule->month_start_date;
+
+       STC_LOGI("Month start date [%d]", *date);
+
+       return STC_ERROR_NONE;
+}
+
 EXPORT_API int stc_restriction_rule_get_roaming_type(stc_restriction_rule_h rule,
                stc_roaming_type_e *roaming_type)
 {
index 4678fc2..201533d 100755 (executable)
 #include "stc_test.h"
 #include "stc_menu.h"
 
-static char g_app_id[MENU_DATA_SIZE] = "";
+static char g_app_id[MENU_DATA_SIZE] = "TOTAL_DATACALL";
 static char g_iface_name[MENU_DATA_SIZE] = "";
-static char g_iface_type[MENU_DATA_SIZE] = "0";
+static char g_iface_type[MENU_DATA_SIZE] = "1";
 static char g_roaming[MENU_DATA_SIZE] = "0";
 static char g_subscriber_id[MENU_DATA_SIZE] = "";
-static char g_data_limit[MENU_DATA_SIZE] = "0";
-static char g_data_warn_limit[MENU_DATA_SIZE] = "0";
-static char g_type[MENU_DATA_SIZE] = "1";
+static char g_data_limit[MENU_DATA_SIZE] = "-1";
+static char g_data_warn_limit[MENU_DATA_SIZE] = "-1";
+static char g_monthly_limit[MENU_DATA_SIZE] = "-1";
+static char g_weekly_limit[MENU_DATA_SIZE] = "-1";
+static char g_daily_limit[MENU_DATA_SIZE] = "-1";
+static char g_month_start_date[MENU_DATA_SIZE] = "1";
+static char g_rstn_type[MENU_DATA_SIZE] = "1";
 
 extern stc_h g_stc;
 static stc_restriction_rule_h g_restriction_rule = NULL;
@@ -71,6 +75,10 @@ static stc_callback_ret_e __test_stc_restriction_rule_cb(
        stc_iface_type_e iface_type;
        int64_t data_limit;
        int64_t data_warn_limit;
+       int64_t monthly_limit;
+       int64_t weekly_limit;
+       int64_t daily_limit;
+       int month_start_date;
        stc_roaming_type_e roaming;
 
        msg(HR_SINGLE);
@@ -101,11 +109,27 @@ static stc_callback_ret_e __test_stc_restriction_rule_cb(
 
        ret = stc_restriction_rule_get_limit(rule, &data_limit);
        if (ret == STC_ERROR_NONE)
-               msg("Data_limit: [%lld]", data_limit);
+               msg("Data limit: [%lld]", data_limit);
 
        ret = stc_restriction_rule_get_warning_limit(rule, &data_warn_limit);
        if (ret == STC_ERROR_NONE)
-               msg("Data_warn_limit: [%lld]", data_warn_limit);
+               msg("Warn limit: [%lld]", data_warn_limit);
+
+       ret = stc_restriction_rule_get_monthly_limit(rule, &monthly_limit);
+       if (ret == STC_ERROR_NONE)
+               msg("Monthly limit: [%lld]", monthly_limit);
+
+       ret = stc_restriction_rule_get_weekly_limit(rule, &weekly_limit);
+       if (ret == STC_ERROR_NONE)
+               msg("Weekly limit:  [%lld]", weekly_limit);
+
+       ret = stc_restriction_rule_get_daily_limit(rule, &daily_limit);
+       if (ret == STC_ERROR_NONE)
+               msg("Daily limit:   [%lld]", weekly_limit);
+
+       ret = stc_restriction_rule_get_month_start_date(rule, &month_start_date);
+       if (ret == STC_ERROR_NONE)
+               msg("Month start date: [%d]", month_start_date);
 
        msg(HR_SINGLE);
 
@@ -154,10 +178,14 @@ static int __test_stc_set_restriction_rule(MManager *mm, struct menu_data *menu)
        stc_roaming_type_e roaming = (int)strtol(g_roaming, NULL, 10);
        int64_t data_limit = (int64_t)strtol(g_data_limit, NULL, 10);
        int64_t data_warn_limit = (int64_t)strtol(g_data_warn_limit, NULL, 10);
+       int64_t monthly_limit = (int64_t)strtol(g_monthly_limit, NULL, 10);
+       int64_t weekly_limit = (int64_t)strtol(g_weekly_limit, NULL, 10);
+       int64_t daily_limit = (int64_t)strtol(g_daily_limit, NULL, 10);
+       int month_start_date = (int)strtol(g_month_start_date, NULL, 10);
        char *app_id = NULL;
        char *subscriber_id = NULL;
        char *iface_name = NULL;
-       stc_restriction_type_e type = (int)strtol(g_type, NULL, 10);
+       stc_restriction_type_e type = (int)strtol(g_rstn_type, NULL, 10);
        int ret = STC_ERROR_NONE;
 
        ret = stc_restriction_rule_set_app_id(g_restriction_rule, g_app_id);
@@ -233,6 +261,54 @@ static int __test_stc_set_restriction_rule(MManager *mm, struct menu_data *menu)
                }
        }
 
+       if (monthly_limit >= 0 && monthly_limit < G_MAXINT64) {
+               ret = stc_restriction_rule_set_monthly_limit(g_restriction_rule,
+                                                    monthly_limit);
+               if (ret == STC_ERROR_NONE) {
+                       msg(LOG_GREEN "Success to set monthly limit" LOG_END);
+               } else {
+                       msg("Fail to set monthly limit " LOG_RED "[%s]" LOG_END,
+                               test_stc_convert_error_type_to_string(ret));
+                       return ret;
+               }
+       }
+
+       if (weekly_limit >= 0 && weekly_limit < G_MAXINT64) {
+               ret = stc_restriction_rule_set_weekly_limit(g_restriction_rule,
+                                                    weekly_limit);
+               if (ret == STC_ERROR_NONE) {
+                       msg(LOG_GREEN "Success to set weekly limit" LOG_END);
+               } else {
+                       msg("Fail to set weekly limit " LOG_RED "[%s]" LOG_END,
+                               test_stc_convert_error_type_to_string(ret));
+                       return ret;
+               }
+       }
+
+       if (daily_limit >= 0 && daily_limit < G_MAXINT64) {
+               ret = stc_restriction_rule_set_daily_limit(g_restriction_rule,
+                                                    daily_limit);
+               if (ret == STC_ERROR_NONE) {
+                       msg(LOG_GREEN "Success to set daily limit" LOG_END);
+               } else {
+                       msg("Fail to set daily limit " LOG_RED "[%s]" LOG_END,
+                               test_stc_convert_error_type_to_string(ret));
+                       return ret;
+               }
+       }
+
+       if (month_start_date >= 0 && month_start_date < 32) {
+               ret = stc_restriction_rule_set_month_start_date(g_restriction_rule,
+                                                    month_start_date);
+               if (ret == STC_ERROR_NONE) {
+                       msg(LOG_GREEN "Success to set month start date" LOG_END);
+               } else {
+                       msg("Fail to set month start date " LOG_RED "[%s]" LOG_END,
+                               test_stc_convert_error_type_to_string(ret));
+                       return ret;
+               }
+       }
+
        if (type > STC_RSTN_TYPE_UNKNOWN && type < STC_RSTN_TYPE_LAST_ELEM) {
                ret = stc_restriction_rule_set_type(g_restriction_rule, type);
                if (ret == STC_ERROR_NONE)
@@ -282,13 +358,33 @@ static int __test_stc_set_restriction_rule(MManager *mm, struct menu_data *menu)
        data_limit = 0;
        ret = stc_restriction_rule_get_limit(g_restriction_rule, &data_limit);
        if (ret == STC_ERROR_NONE)
-               msg("Data_limit: " LOG_CYAN "[%lld]" LOG_END, data_limit);
+               msg("Data limit: " LOG_CYAN "[%lld]" LOG_END, data_limit);
 
        data_warn_limit = 0;
        ret = stc_restriction_rule_get_warning_limit(g_restriction_rule,
                                                     &data_warn_limit);
        if (ret == STC_ERROR_NONE)
-               msg("Data_warn_limit: " LOG_CYAN "[%lld]" LOG_END, data_warn_limit);
+               msg("Warn limit: " LOG_CYAN "[%lld]" LOG_END, data_warn_limit);
+
+       monthly_limit = 0;
+       ret = stc_restriction_rule_get_monthly_limit(g_restriction_rule, &monthly_limit);
+       if (ret == STC_ERROR_NONE)
+               msg("Monthly limit: " LOG_CYAN "[%lld]" LOG_END, monthly_limit);
+
+       weekly_limit = 0;
+       ret = stc_restriction_rule_get_weekly_limit(g_restriction_rule, &weekly_limit);
+       if (ret == STC_ERROR_NONE)
+               msg("Weekly limit:  " LOG_CYAN "[%lld]" LOG_END, weekly_limit);
+
+       daily_limit = 0;
+       ret = stc_restriction_rule_get_daily_limit(g_restriction_rule, &daily_limit);
+       if (ret == STC_ERROR_NONE)
+               msg("Daily limit:   " LOG_CYAN "[%lld]" LOG_END, daily_limit);
+
+       month_start_date = 0;
+       ret = stc_restriction_rule_get_month_start_date(g_restriction_rule, &month_start_date);
+       if (ret == STC_ERROR_NONE)
+               msg("Month start date: " LOG_CYAN "[%d]" LOG_END, month_start_date);
 
        msg(HR_SINGLE);
 
@@ -460,9 +556,13 @@ static struct menu_data menu_restriction_rule[] = {
        { "3", "Interface type(1.Tel/2.Wifi/3.Wired/4.BT/5.All)", NULL, NULL, g_iface_type},
        { "4", "Interface name", NULL, NULL, g_iface_name},
        { "5", "Roaming(1.Enable/2.Disable)", NULL, NULL, g_roaming},
-       { "6", "Type(1.Accept/2.Drop)", NULL, NULL, g_type},
+       { "6", "Type(1.Accept/2.Drop)", NULL, NULL, g_rstn_type},
        { "7", "Data limit", NULL, NULL, g_data_limit},
-       { "8", "Data warn limit", NULL, NULL, g_data_warn_limit},
+       { "8", "Warn limit", NULL, NULL, g_data_warn_limit},
+       { "9", "Monthly limit", NULL, NULL, g_monthly_limit},
+       { "10", "Weekly limit", NULL, NULL, g_weekly_limit},
+       { "11", "Daily limit", NULL, NULL, g_daily_limit},
+       { "12", "Month start date", NULL, NULL, g_month_start_date},
        { "s", LOG_LIGHTMAGENTA "[Set]" LOG_END, NULL, __test_stc_set_restriction_rule, NULL},
        { NULL, NULL, },
 };