Add Monthly/Weekly/Daily limit APIs 60/172160/4 accepted/tizen/4.0/unified/20180326.075154 submit/tizen_4.0/20180323.083051
authorNishant Chaprana <n.chaprana@samsung.com>
Mon, 12 Mar 2018 08:46:37 +0000 (14:16 +0530)
committerNishant Chaprana <n.chaprana@samsung.com>
Tue, 20 Mar 2018 14:43:50 +0000 (20:13 +0530)
Change-Id: I30da78194ca2693aeaa074361a6341576a46bead
Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
include/stc_internal.h
packaging/capi-network-stc.spec
src/include/stc-info.h
src/include/stc-restriction.h
src/stc-info.c
src/stc-restriction.c
test/restriction.c

index d529a4d022bb14e70eab766254d961c9457590be..7d96ea1766ecc4da78dd2c9b8b408df94a45680d 100755 (executable)
@@ -130,6 +130,10 @@ typedef enum {
  * @see stc_restriction_info_get_iface_type()
  * @see stc_restriction_info_get_limit()
  * @see stc_restriction_info_get_warning_limit()
+ * @see stc_restriction_info_get_monthly_limit()
+ * @see stc_restriction_info_get_weekly_limit()
+ * @see stc_restriction_info_get_daily_limit()
+ * @see stc_restriction_info_get_month_start_date()
  * @see stc_restriction_info_get_roaming_type()
  * @see        stc_get_restriction()
  * @see        stc_foreach_restriction()
@@ -968,6 +972,114 @@ int stc_restriction_rule_set_limit(stc_restriction_rule_h rule,
 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,
+                                             int64_t month_start_date);
+
 /**
  * @brief Sets the roaming type for restriction rule.
  * @since_tizen 4.0
@@ -1158,6 +1270,114 @@ int stc_restriction_rule_get_limit(stc_restriction_rule_h rule,
 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,
+                                             int64_t *month_start_date);
+
 /**
  * @brief Gets the roaming type for restriction rule.
  * @since_tizen 4.0
@@ -1410,6 +1630,106 @@ int stc_restriction_info_get_limit(stc_restriction_info_h info,
 int stc_restriction_info_get_warning_limit(stc_restriction_info_h info,
                                           int64_t *data_warn_limit);
 
+/**
+ * @brief Gets the monthly data limit for restriction information.
+ * @since_tizen 5.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.get
+ *
+ * @param[in] info The restriction information handle
+ * @param[out] limit The monthly 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_info_h
+ * @see stc_restriction_info_cb()
+ */
+int stc_restriction_info_get_monthly_limit(stc_restriction_info_h info,
+                                          int64_t *limit);
+
+/**
+ * @brief Gets the weekly data limit for restriction information.
+ * @since_tizen 5.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.get
+ *
+ * @param[in] info The restriction information handle
+ * @param[out] limit The weekly 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_info_h
+ * @see stc_restriction_info_cb()
+ */
+int stc_restriction_info_get_weekly_limit(stc_restriction_info_h info,
+                                         int64_t *limit);
+
+/**
+ * @brief Gets the daily data limit for restriction information.
+ * @since_tizen 5.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.get
+ *
+ * @param[in] info The restriction information handle
+ * @param[out] limit The daily 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_info_h
+ * @see stc_restriction_info_cb()
+ */
+int stc_restriction_info_get_daily_limit(stc_restriction_info_h info,
+                                        int64_t *limit);
+
+/**
+ * @brief Gets the month start date for restriction information.
+ * @since_tizen 5.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.get
+ *
+ * @param[in] info The restriction information 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_info_h
+ * @see stc_restriction_info_cb()
+ */
+int stc_restriction_info_get_month_start_date(stc_restriction_info_h info,
+                                             int64_t *month_start_date);
+
 /**
  * @brief Gets the roaming type for restriction information.
  * @since_tizen 4.0
index 443629be637ab1d07c461ed9ce59d5b85ee932a2..5767c55fe2cc470849eebc3ba15bd1a4b78a00a7 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-network-stc
 Summary:    A Smart Traffic Control (STC) libraries in Native API
-Version:    0.0.23
+Version:    0.0.24
 Release:    1
 Group:      Network & Connectivity/API
 License:    Apache-2.0
index b5d4ac9cea66db1abbbcb14a296efaca7edd7d0b..c9b3c5e8072a21359d97d2b21476bc217ec18d2b 100755 (executable)
@@ -68,6 +68,10 @@ extern "C" {
 #define STC_RESTRICTION_INFO_IFNAME                            "ifname"
 #define STC_RESTRICTION_INFO_DATA_LIMIT                        "data_limit"
 #define STC_RESTRICTION_INFO_DATA_WARN_LIMIT   "data_warn_limit"
+#define STC_RESTRICTION_INFO_MONTHLY_LIMIT     "monthly_limit"
+#define STC_RESTRICTION_INFO_WEEKLY_LIMIT      "weekly_limit"
+#define STC_RESTRICTION_INFO_DAILY_LIMIT       "daily_limit"
+#define STC_RESTRICTION_INFO_MONTH_START_DATE  "month_start_date"
 #define STC_RESTRICTION_INFO_RST_STATUS                        "rst_state"
 #define STC_RESTRICTION_INFO_ROAMING                   "roaming"
 #define STC_RESTRICTION_INFO_SUBSCRIBER_ID             "subscriber_id"
@@ -97,6 +101,10 @@ typedef struct {
        stc_restriction_status_e rst_status;
        int64_t data_limit;
        int64_t data_warn_limit;
+       int64_t monthly_limit;
+       int64_t weekly_limit;
+       int64_t daily_limit;
+       int64_t month_start_date;
        stc_roaming_type_e roaming_type;
 } stc_restriction_info_s;
 
index 1821b635854e9ddda50a7fb7cb7a0fcb9e38fa4a..f7f0c59c85f3f9e9d3d37e0ddc19bbbe5375b3ef 100755 (executable)
@@ -55,6 +55,10 @@ extern "C" {
 #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 enum {
        STC_RST_TYPE_UNDEF,
@@ -72,6 +76,10 @@ typedef struct {
        stc_restriction_status_e rst_state;
        int64_t data_limit;
        int64_t data_warn_limit;
+       int64_t monthly_limit;
+       int64_t weekly_limit;
+       int64_t daily_limit;
+       int64_t month_start_date;
        stc_roaming_type_e roaming_type;
 } stc_restriction_rule_s;
 
index e0797575575b8d327d3d4ec048a87d602b74eea6..96df5ecef5e6bb2e7718e6f16ad682141506ffa8 100755 (executable)
@@ -403,6 +403,86 @@ EXPORT_API int stc_restriction_info_get_warning_limit(stc_restriction_info_h inf
        return STC_ERROR_NONE;
 }
 
+EXPORT_API int stc_restriction_info_get_monthly_limit(stc_restriction_info_h info,
+                                                     int64_t *limit)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (info == NULL || limit == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_info_s *restriction_info =
+               (stc_restriction_info_s *)info;
+
+       *limit = restriction_info->monthly_limit;
+
+       STC_LOGI("Monthly limit [%lld] bytes", *limit);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_info_get_weekly_limit(stc_restriction_info_h info,
+                                                    int64_t *limit)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (info == NULL || limit == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_info_s *restriction_info =
+               (stc_restriction_info_s *)info;
+
+       *limit = restriction_info->weekly_limit;
+
+       STC_LOGI("Weekly data limit [%lld] bytes", *limit);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_info_get_daily_limit(stc_restriction_info_h info,
+                                                   int64_t *limit)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (info == NULL || limit == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_info_s *restriction_info =
+               (stc_restriction_info_s *)info;
+
+       *limit = restriction_info->daily_limit;
+
+       STC_LOGI("Daily data limit [%lld] bytes", *limit);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_info_get_month_start_date(stc_restriction_info_h info,
+                                                        int64_t *date)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (info == NULL || date == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_info_s *restriction_info =
+               (stc_restriction_info_s *)info;
+
+       *date = restriction_info->month_start_date;
+
+       STC_LOGI("Month start date [%lld]", *date);
+
+       return STC_ERROR_NONE;
+}
+
 EXPORT_API int stc_restriction_info_get_roaming_type(stc_restriction_info_h info,
                stc_roaming_type_e *roaming_type)
 {
index 45c4c1d3785f416eea0b5c1c35efc576ca523ccf..edb794934aac3c7f9dba67e8bd2ddc4e8d604366 100755 (executable)
@@ -69,8 +69,12 @@ static void __stc_restriction_init_rule(stc_restriction_rule_s *rule)
        rule->iface_name[0] = '\0';
        rule->iface_type = STC_IFACE_ALL;
        rule->rst_state = STC_RESTRICTION_REMOVED;
-       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';
 }
@@ -117,6 +121,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_int64(restriction_rule->month_start_date));
+
        *params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
        g_variant_builder_unref(builder);
 }
@@ -177,6 +197,18 @@ static void __stc_restriction_extract_info_cb(const char *key,
        } else if (!g_strcmp0(key, STC_RESTRICTION_INFO_DATA_WARN_LIMIT)) {
                restriction_info->data_warn_limit = g_variant_get_int64(value);
 
+       } else if (!g_strcmp0(key, STC_RESTRICTION_INFO_MONTHLY_LIMIT)) {
+               restriction_info->monthly_limit = g_variant_get_int64(value);
+
+       } else if (!g_strcmp0(key, STC_RESTRICTION_INFO_WEEKLY_LIMIT)) {
+               restriction_info->weekly_limit = g_variant_get_int64(value);
+
+       } else if (!g_strcmp0(key, STC_RESTRICTION_INFO_DAILY_LIMIT)) {
+               restriction_info->daily_limit = g_variant_get_int64(value);
+
+       } else if (!g_strcmp0(key, STC_RESTRICTION_INFO_MONTH_START_DATE)) {
+               restriction_info->month_start_date = g_variant_get_int64(value);
+
        } else if (!g_strcmp0(key, STC_RESTRICTION_INFO_ROAMING)) {
                restriction_info->roaming_type =
                        (stc_roaming_type_e)g_variant_get_uint16(value);
@@ -428,15 +460,35 @@ stc_error_e _stc_restriction_validate_rule(
                _stc_convert_iface_type_to_string(restriction_rule->iface_type));
 
        if (rst_type == STC_RST_TYPE_SET) {
-               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 [%lld]",
+                       restriction_rule->month_start_date);
        }
 
        STC_RETURN_VAL_IF(restriction_rule->roaming_type <= STC_ROAMING_UNKNOWN ||
@@ -467,15 +519,35 @@ 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_ERROR_INVALID_PARAMETER,
-               "Invalid tx limit [%lld] bytes",
-               restriction_rule->data_limit);
+       STC_RETURN_VAL_IF(restriction_rule->data_limit < -1,
+                         STC_ERROR_INVALID_PARAMETER,
+                         "Invalid data limit [%lld] bytes",
+                         restriction_rule->data_limit);
 
-       STC_RETURN_VAL_IF(restriction_rule->data_warn_limit < 0,
-               STC_ERROR_INVALID_PARAMETER,
-               "Invalid rx limit [%lld] bytes",
-               restriction_rule->data_warn_limit);
+       STC_RETURN_VAL_IF(restriction_rule->data_warn_limit < -1,
+                         STC_ERROR_INVALID_PARAMETER,
+                         "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 [%lld]",
+                         restriction_rule->month_start_date);
 
        STC_RETURN_VAL_IF(restriction_rule->roaming_type <= STC_ROAMING_UNKNOWN ||
                restriction_rule->roaming_type > STC_ROAMING_DISABLED,
@@ -934,6 +1006,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,
+                                                        int64_t 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 [%lld]",
+                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)
 {
@@ -1090,6 +1246,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,
+                                                        int64_t *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 [%lld]", *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 1cb93f1f327ca8ffa70fb5b527d162e3fea121d0..089459f725799510a8ba70cec9f642ab4c16aa63 100755 (executable)
@@ -47,8 +47,12 @@ static char g_iface_name[MENU_DATA_SIZE] = "";
 static char g_iface_type[MENU_DATA_SIZE] = "0";
 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_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] = "0";
 
 extern stc_h g_stc;
 static stc_restriction_rule_h g_restriction_rule = NULL;
@@ -70,6 +74,10 @@ static stc_callback_ret_e __test_stc_restriction_info_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;
+       int64_t month_start_date;
        stc_roaming_type_e roaming;
 
        msg(HR_SINGLE);
@@ -106,6 +114,22 @@ static stc_callback_ret_e __test_stc_restriction_info_cb(
        if (ret == STC_ERROR_NONE)
                msg("Data_warn_limit: [%lld]", data_warn_limit);
 
+       ret = stc_restriction_info_get_monthly_limit(info, &monthly_limit);
+       if (ret == STC_ERROR_NONE)
+               msg("Monthly_limit: [%lld]", monthly_limit);
+
+       ret = stc_restriction_info_get_weekly_limit(info, &weekly_limit);
+       if (ret == STC_ERROR_NONE)
+               msg("Weekly_limit: [%lld]", weekly_limit);
+
+       ret = stc_restriction_info_get_daily_limit(info, &daily_limit);
+       if (ret == STC_ERROR_NONE)
+               msg("Daily_limit: [%lld]", daily_limit);
+
+       ret = stc_restriction_info_get_month_start_date(info, &month_start_date);
+       if (ret == STC_ERROR_NONE)
+               msg("Month_star_date: [%lld]", month_start_date);
+
        msg(HR_SINGLE);
 
        g_free(app_id);
@@ -153,6 +177,10 @@ 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);
+       int64_t month_start_date = (int64_t)strtol(g_month_start_date, NULL, 10);
        char *app_id = NULL;
        char *subscriber_id = NULL;
        char *iface_name = NULL;
@@ -231,6 +259,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 < G_MAXINT64) {
+               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;
+               }
+       }
+
        msg(HR_SINGLE);
 
        ret = stc_restriction_rule_get_app_id(g_restriction_rule, &app_id);
@@ -272,6 +348,30 @@ static int __test_stc_set_restriction_rule(MManager *mm, struct menu_data *menu)
        if (ret == STC_ERROR_NONE)
                msg("Data_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 "[%lld]" LOG_END, month_start_date);
+
        msg(HR_SINGLE);
 
        return STC_ERROR_NONE;
@@ -459,6 +559,10 @@ static struct menu_data menu_restriction_rule[] = {
        { "5", "Roaming(1.Enable/2.Disable)", NULL, NULL, g_roaming},
        { "6", "Data limit", NULL, NULL, g_data_limit},
        { "7", "Data warn limit", NULL, NULL, g_data_warn_limit},
+       { "8", "Monthly limit", NULL, NULL, g_monthly_limit},
+       { "9", "Weekly limit", NULL, NULL, g_weekly_limit},
+       { "10", "Daily limit", NULL, NULL, g_daily_limit},
+       { "11", "Month start date", NULL, NULL, g_month_start_date},
        { "s", LOG_LIGHTMAGENTA "[Set]" LOG_END, NULL, __test_stc_set_restriction_rule, NULL},
        { NULL, NULL, },
 };