*/
typedef void *stc_restriction_rule_h;
-/**
- * @brief The restriction information handle.
- * @since_tizen 4.0
- */
-typedef void *stc_restriction_info_h;
-
/**
* @}
*/
*/
/**
- * @brief Called for enumerate restriction information.
- * @since_tizen 4.0
+ * @brief Called for enumerate restriction rule.
+ * @since_tizen 5.0
*
* @param[in] result The result
- * @param[in] info The restriction information handle
+ * @param[in] rule The restriction rule handle
* @param[in] user_data The user data passed from the callback registration function
* @return @c STC_CALLBACK_CONTINUE to continue with the next iteration of the loop,
* otherwise @c STC_CALLBACK_CANCEL to break out of the loop
*
* @pre stc_get_restriction() will invoke this callback.
* @pre stc_foreach_restriction() will invoke this callback.
- * @see stc_restriction_info_get_app_id()
- * @see stc_restriction_info_get_iface_name()
- * @see stc_restriction_info_get_subscriber_id()
- * @see stc_restriction_info_get_type()
- * @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_roaming_type()
+ * @see stc_restriction_rule_get_app_id()
+ * @see stc_restriction_rule_get_iface_name()
+ * @see stc_restriction_rule_get_subscriber_id()
+ * @see stc_restriction_rule_get_type()
+ * @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_roaming_type()
* @see stc_get_restriction()
* @see stc_foreach_restriction()
*/
-typedef stc_callback_ret_e (*stc_restriction_info_cb)(stc_error_e result,
- stc_restriction_info_h info, void *user_data);
+typedef stc_callback_ret_e (*stc_restriction_rule_cb)(stc_error_e result,
+ stc_restriction_rule_h rule, void *user_data);
-typedef void (*stc_threshold_crossed_cb)(stc_restriction_info_h info,
+typedef void (*stc_threshold_crossed_cb)(stc_restriction_rule_h rule,
void *user_data);
/**
*/
/**
- * @brief Resets stats information..
+ * @brief Resets stats information.
* @since_tizen 4.0
* @privlevel platform
* @privilege %http://tizen.org/privilege/network.get
* @see stc_foreach_restriction()
* @see stc_get_restriction_type()
* @see stc_unset_restriction()
- * @see stc_exclude_restriction()
*/
int stc_set_restriction(stc_h stc, stc_restriction_rule_h rule);
-/**
- * @brief Excludes the application from network restriction.
- * @details Excluded application will be granted to
- * internet access, in case of whole network restriction.
- * @since_tizen 4.0
- * @privlevel platform
- * @privilege %http://tizen.org/privilege/network.get
- *
- * @param[in] stc The stc handle
- * @param[in] rule The restriction rule handle
- *
- * @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_h
- * @see #stc_restriction_rule_h
- * @see stc_initialize()
- * @see stc_restriction_rule_create()
- * @see stc_restriction_rule_destroy()
- * @see stc_restriction_rule_set_app_id()
- * @see stc_restriction_rule_set_iface_name()
- * @see stc_restriction_rule_set_iface_type()
- * @see stc_restriction_rule_set_limit()
- * @see stc_restriction_rule_set_warning_limit()
- * @see stc_restriction_rule_set_roaming_type()
- * @see stc_restriction_rule_set_subscriber_id()
- * @see stc_restriction_rule_get_app_id()
- * @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_roaming_type()
- * @see stc_restriction_rule_get_subscriber_id()
- * @see stc_restriction_rule_get_process_state()
- * @see stc_set_restriction()
- * @see stc_get_restriction()
- * @see stc_foreach_restriction()
- * @see stc_get_restriction_type()
- * @see stc_unset_restriction()
- */
-int stc_exclude_restriction(stc_h stc, stc_restriction_rule_h rule);
-
/**
* @brief Unsets the existing restriction for application.
* @details Unsets the existing restriction for application.
* @see stc_get_restriction()
* @see stc_foreach_restriction()
* @see stc_get_restriction_type()
- * @see stc_exclude_restriction()
*/
int stc_unset_restriction(stc_h stc, stc_restriction_rule_h rule);
/**
- * @brief Gets the restriction information per application.
+ * @brief Gets the restriction rule per application.
* @details The callback is called for each application that applied restriction.
* @since_tizen 4.0
* @privlevel platform
*
* @param[in] stc The stc handle
* @param[in] rule The restriction rule handle
- * @param[in] info_cb The callback is called for each application
+ * @param[in] rule_cb The callback is called for each application
* that applied restriction in interface specified
* @param[in] user_data User data will be passed to the callback function
*
* @see stc_restriction_rule_get_roaming_type()
* @see stc_restriction_rule_get_subscriber_id()
* @see stc_restriction_rule_get_process_state()
- * @see stc_restriction_info_cb()
+ * @see stc_restriction_rule_cb()
* @see stc_set_restriction()
* @see stc_foreach_restriction()
* @see stc_get_restriction_type()
* @see stc_unset_restriction()
- * @see stc_exclude_restriction()
*/
int stc_get_restriction(stc_h stc, stc_restriction_rule_h rule,
- stc_restriction_info_cb info_cb, void *user_data);
+ stc_restriction_rule_cb rule_cb, void *user_data);
int stc_set_restriction_threshold_crossed_cb(stc_h stc,
stc_threshold_crossed_cb crossed_cb, void *user_data);
int stc_unset_warn_threshold_crossed_cb(stc_h stc);
/**
- * @brief Gets the restriction information of all application.
+ * @brief Gets the restriction rule of all application.
* @details The callback is called for each application that applied restriction.
* @since_tizen 4.0
* @privlevel platform
*
* @param[in] stc The stc handle
* @param[in] rule The restriction rule handle
- * @param[in] info_cb The callback is called for each application
+ * @param[in] rule_cb The callback is called for each application
* that applied restriction in interface specified
* @param[in] user_data User data will be passed to the callback function
*
* @see stc_restriction_rule_get_roaming_type()
* @see stc_restriction_rule_get_subscriber_id()
* @see stc_restriction_rule_get_process_state()
- * @see stc_restriction_info_cb()
+ * @see stc_restriction_rule_cb()
* @see stc_set_restriction()
* @see stc_get_restriction()
* @see stc_get_restriction_type()
* @see stc_unset_restriction()
- * @see stc_exclude_restriction()
*/
int stc_foreach_restriction(stc_h stc, stc_restriction_rule_h rule,
- stc_restriction_info_cb info_cb, void *user_data);
+ stc_restriction_rule_cb rule_cb, void *user_data);
/**
- * @brief Gets the restriction type information.
+ * @brief Gets the restriction type.
* @since_tizen 4.0
* @privlevel platform
* @privilege %http://tizen.org/privilege/network.get
* @see stc_get_restriction()
* @see stc_foreach_restriction()
* @see stc_unset_restriction()
- * @see stc_exclude_restriction()
*/
int stc_get_restriction_type(stc_h stc, stc_restriction_rule_h rule,
stc_restriction_type_e *type);
int stc_restriction_rule_set_iface_type(stc_restriction_rule_h rule,
stc_iface_type_e iface_type);
+/**
+ * @brief Sets the type 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] type The restriction type
+ *
+ * @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_type_e
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_get_type()
+ */
+int stc_restriction_rule_set_type(stc_restriction_rule_h rule,
+ stc_restriction_type_e type);
+
/**
* @brief Sets the limit for restriction rule.
* @since_tizen 4.0
int stc_restriction_rule_get_iface_type(stc_restriction_rule_h rule,
stc_iface_type_e *iface_type);
+/**
+ * @brief Gets the type 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] type The restriction type
+ *
+ * @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_type_e
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_set_type()
+ */
+int stc_restriction_rule_get_type(stc_restriction_rule_h rule,
+ stc_restriction_type_e *type);
+
/**
* @brief Gets the limit for restriction rule.
* @since_tizen 4.0
*/
int stc_stats_info_get_subscriber_id(stc_stats_info_h info, char **subscriber_id);
-/**
- * @brief Gets the application ID for restriction information.
- * @since_tizen 4.0
- * @privlevel platform
- * @privilege %http://tizen.org/privilege/network.get
- *
- * @param[in] info The restriction information handle
- * @param[out] app_id The application ID
- *
- * @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_app_id(stc_restriction_info_h info, char **app_id);
-
-/**
- * @brief Gets the interface name for restriction information.
- * @since_tizen 4.0
- * @privlevel platform
- * @privilege %http://tizen.org/privilege/network.get
- *
- * @param[in] info The restriction information handle
- * @param[out] iface_name The interface name
- *
- * @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_iface_name(stc_restriction_info_h info,
- char **iface_name);
-
-/**
- * @brief Gets the subscriber ID for restriction information.
- * @since_tizen 4.0
- * @privlevel platform
- * @privilege %http://tizen.org/privilege/network.get
- *
- * @param[in] info The restriction information handle
- * @param[out] subscriber_id The subscriber ID
- *
- * @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_subscriber_id(stc_restriction_info_h info, char **subscriber_id);
-
-/**
- * @brief Gets the restriction type 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] type The restriction type
- *
- * @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_type_e
- * @see stc_restriction_info_cb()
- */
-int stc_restriction_info_get_type(stc_restriction_info_h info,
- stc_restriction_type_e *type);
-
-
-/**
- * @brief Gets the interface type for restriction information.
- * @since_tizen 4.0
- * @privlevel platform
- * @privilege %http://tizen.org/privilege/network.get
- *
- * @param[in] info The restriction information handle
- * @param[out] iface_type The interface type
- *
- * @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_iface_type_e
- * @see stc_restriction_info_cb()
- */
-int stc_restriction_info_get_iface_type(stc_restriction_info_h info,
- stc_iface_type_e *iface_type);
-
-/**
- * @brief Gets the limit for restriction information.
- * @since_tizen 4.0
- * @privlevel platform
- * @privilege %http://tizen.org/privilege/network.get
- *
- * @param[in] info The restriction information handle
- * @param[out] data_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_info_h
- * @see stc_restriction_info_cb()
- */
-int stc_restriction_info_get_limit(stc_restriction_info_h info,
- int64_t *data_limit);
-
-/**
- * @brief Gets the warning limit for restriction information.
- * @since_tizen 4.0
- * @privlevel platform
- * @privilege %http://tizen.org/privilege/network.get
- *
- * @param[in] info The restriction information handle
- * @param[out] data_warn_limit The data warning 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_warning_limit(stc_restriction_info_h info,
- int64_t *data_warn_limit);
-
-/**
- * @brief Gets the roaming type for restriction information.
- * @since_tizen 4.0
- * @privlevel platform
- * @privilege %http://tizen.org/privilege/network.get
- *
- * @param[in] info The restriction information handle
- * @param[out] roaming The roaming type
- *
- * @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_roaming_type_e
- * @see stc_restriction_info_cb()
- */
-int stc_restriction_info_get_roaming_type(stc_restriction_info_h info,
- stc_roaming_type_e *roaming_type);
-
/**
* @}
*/
Name: capi-network-stc
Summary: A Smart Traffic Control (STC) libraries in Native API
-Version: 0.0.26
+Version: 0.0.27
Release: 1
Group: Network & Connectivity/API
License: Apache-2.0
#define STC_STATS_INFO_PROTOCOL_TYPE "hw_net_protocol_type"
#define STC_STATS_INFO_PROCESS_STATE "ground"
-#define STC_RESTRICTION_INFO_APP_ID "app_id"
-#define STC_RESTRICTION_INFO_IFTYPE "iftype"
-#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_RSTN_TYPE "type"
-#define STC_RESTRICTION_INFO_ROAMING "roaming"
-#define STC_RESTRICTION_INFO_SUBSCRIBER_ID "subscriber_id"
-
typedef struct {
int64_t incoming_bytes; /** <incoming_bytes is the Total bytes = Incoming + outgoing */
int64_t outgoing_bytes; /** Actual outgoing bytes */
stc_process_state_e process_state;
} stc_stats_info_s;
-typedef struct {
- char app_id[STC_APP_ID_LEN];
- char iface_name[STC_IFNAME_LEN];
- char subscriber_id[STC_SUBSCRIBER_ID_LEN];
- stc_iface_type_e iface_type;
- stc_restriction_type_e rstn_type;
- int64_t data_limit;
- int64_t data_warn_limit;
- stc_roaming_type_e roaming_type;
-} stc_restriction_info_s;
-
/*****************************************************************************
* Global Variables
*****************************************************************************/
#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_SUBSCRIBER_ID "subscriber_id"
#define STC_RESTRICTION_RULE_DATA_LIMIT "data_limit"
-#define STC_RESTRICTION_RULE_DATA_WARN_LIMIT "data_warn_limit"
-
-typedef enum {
- STC_RSTN_TYPE_UNDEF,
- STC_RSTN_TYPE_SET,
- STC_RSTN_TYPE_UNSET,
- STC_RSTN_TYPE_EXCLUDE,
- STC_RSTN_TYPE_MAX_VALUE,
-} stc_rstn_type_e;
+#define STC_RESTRICTION_RULE_DATA_WARN_LIMIT "data_warn_limit"
typedef struct {
char app_id[STC_APP_ID_LEN];
char iface_name[STC_IFNAME_LEN];
char subscriber_id[STC_SUBSCRIBER_ID_LEN];
stc_iface_type_e iface_type;
- stc_rstn_type_e rstn_type;
+ stc_restriction_type_e rstn_type;
int64_t data_limit;
int64_t data_warn_limit;
stc_roaming_type_e roaming_type;
*****************************************************************************/
stc_error_e _stc_restriction_validate_rule(
- stc_restriction_rule_h rule, stc_rstn_type_e rstn_type);
+ stc_restriction_rule_h rule);
stc_error_e _stc_restriction_check_get_rule(stc_restriction_rule_h rule);
stc_error_e _stc_restriction_check_get_all_rule(
stc_restriction_rule_h rule);
#define STC_MANAGER_METHOD_RESTRICTION_GET_PER_APP_ID "Get"
#define STC_MANAGER_METHOD_RESTRICTION_GET_ALL "GetAll"
#define STC_MANAGER_METHOD_RESTRICTION_UNSET "Unset"
-#define STC_MANAGER_METHOD_RESTRICTION_EXCLUDE "Exclude"
#define STC_MANAGER_METHOD_IPTABLES_COMMIT "CommitIptables"
stc_stats_info_cb stats_total_cb;
void *stats_total_user_data;
- stc_restriction_info_cb restriction_cb;
+ stc_restriction_rule_cb restriction_cb;
void *restriction_user_data;
- stc_restriction_info_cb restriction_all_cb;
+ stc_restriction_rule_cb restriction_all_cb;
void *restriction_all_user_data;
stc_threshold_crossed_cb restriction_crossed_cb;
void _stc_callback_set_stats_total_info(stc_h stc,
stc_stats_info_cb user_cb, void *user_data);
-void _stc_callback_set_restriction_info(stc_h stc,
- stc_restriction_info_cb user_cb, void *user_data);
-void _stc_callback_set_restriction_all_info(stc_h stc,
- stc_restriction_info_cb user_cb, void *user_data);
+void _stc_callback_set_restriction_rule(stc_h stc,
+ stc_restriction_rule_cb user_cb, void *user_data);
+void _stc_callback_set_restriction_all_rule(stc_h stc,
+ stc_restriction_rule_cb user_cb, void *user_data);
void _stc_callback_set_restriction_threshold_crossed(stc_h stc,
stc_threshold_crossed_cb user_cb, void *user_data);
if (err == STC_ERROR_NONE) {
if (info_data != NULL) {
for (data = info_data; data; data = data->next) {
- stc_restriction_info_h info = data->data;
+ stc_restriction_rule_h rule = data->data;
ret = handle->restriction_cb(err,
- info, handle->restriction_user_data);
+ rule, handle->restriction_user_data);
if (ret == STC_CALLBACK_CANCEL)
break;
if (err == STC_ERROR_NONE) {
if (info_data != NULL) {
for (data = info_data; data; data = data->next) {
- stc_restriction_info_h info = data->data;
+ stc_restriction_rule_h rule = data->data;
ret = handle->restriction_all_cb(err,
- info, handle->restriction_all_user_data);
+ rule, handle->restriction_all_user_data);
if (ret == STC_CALLBACK_CANCEL)
break;
switch (e) {
case STC_EVENT_WARN_THRESHOLD_CROSSED_RSP:
if (handle->warn_crossed_cb)
- handle->warn_crossed_cb((stc_restriction_info_h)info_data,
+ handle->warn_crossed_cb((stc_restriction_rule_h)info_data,
handle->warn_crossed_user_data);
break;
case STC_EVENT_RESTRICTION_THRESHOLD_CROSSED_RSP:
if (handle->restriction_crossed_cb)
- handle->restriction_crossed_cb((stc_restriction_info_h)info_data,
+ handle->restriction_crossed_cb((stc_restriction_rule_h)info_data,
handle->restriction_crossed_user_data);
break;
default:
}
//LCOV_EXCL_START
-void _stc_callback_set_restriction_info(stc_h stc,
- stc_restriction_info_cb user_cb, void *user_data)
+void _stc_callback_set_restriction_rule(stc_h stc,
+ stc_restriction_rule_cb user_cb, void *user_data)
{
stc_handle_s *handle = (stc_handle_s *)stc;
handle->restriction_user_data = user_data;
}
-void _stc_callback_set_restriction_all_info(stc_h stc,
- stc_restriction_info_cb user_cb, void *user_data)
+void _stc_callback_set_restriction_all_rule(stc_h stc,
+ stc_restriction_rule_cb user_cb, void *user_data)
{
stc_handle_s *handle = (stc_handle_s *)stc;
#include "stc-util.h"
#include "stc-event.h"
#include "stc-info.h"
+#include "stc-restriction.h"
#include "stc-signal.h"
const char *app_id = NULL;
stc_iface_type_e iftype = STC_IFACE_UNKNOWN;
stc_event_info_s event_data = { 0, };
- stc_restriction_info_s *info = NULL;
+ stc_restriction_rule_s *rule = NULL;
g_variant_get(param, "(&si)", &app_id, iftype);
- info = g_try_malloc0(sizeof(stc_restriction_info_s));
- if (info != NULL) {
- g_strlcpy(info->app_id, app_id, STC_APP_ID_LEN);
- info->iface_type = iftype;
+ rule = g_try_malloc0(sizeof(stc_restriction_rule_s));
+ if (rule != NULL) {
+ g_strlcpy(rule->app_id, app_id, STC_APP_ID_LEN);
+ rule->iface_type = iftype;
event_data.event = STC_EVENT_WARN_THRESHOLD_CROSSED_RSP;
- event_data.info_data = (stc_restriction_info_h)info;
+ event_data.info_data = (stc_restriction_rule_h)rule;
_stc_event_add_client_idle_cb(&event_data, NULL);
}
const char *app_id = NULL;
stc_iface_type_e iftype = STC_IFACE_UNKNOWN;
stc_event_info_s event_data = { 0, };
- stc_restriction_info_s *info = NULL;
+ stc_restriction_rule_s *rule = NULL;
g_variant_get(param, "(&si)", &app_id, iftype);
- info = g_try_malloc0(sizeof(stc_restriction_info_s));
- if (info != NULL) {
- g_strlcpy(info->app_id, app_id, STC_APP_ID_LEN);
- info->iface_type = iftype;
+ rule = g_try_malloc0(sizeof(stc_restriction_rule_s));
+ if (rule != NULL) {
+ g_strlcpy(rule->app_id, app_id, STC_APP_ID_LEN);
+ rule->iface_type = iftype;
event_data.event = STC_EVENT_RESTRICTION_THRESHOLD_CROSSED_RSP;
- event_data.info_data = (stc_restriction_info_h)info;
+ event_data.info_data = (stc_restriction_rule_h)rule;
_stc_event_add_client_idle_cb(&event_data, NULL);
}
return STC_ERROR_NONE;
}
-
-//LCOV_EXCL_START
-EXPORT_API int stc_restriction_info_get_app_id(stc_restriction_info_h info, char **app_id)
-{
- CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
-
- if (info == NULL || app_id == NULL) {
- STC_LOGE("Invalid parameter");
- return STC_ERROR_INVALID_PARAMETER;
- }
-
- stc_restriction_info_s *restriction_info =
- (stc_restriction_info_s *)info;
-
- *app_id = g_strdup(restriction_info->app_id);
- if (*app_id == NULL)
- return STC_ERROR_OUT_OF_MEMORY;
-
- STC_LOGI("App id [%s]", *app_id);
-
- return STC_ERROR_NONE;
-}
-
-EXPORT_API int stc_restriction_info_get_iface_name(stc_restriction_info_h info,
- char **iface_name)
-{
- CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
-
- if (info == NULL || iface_name == NULL) {
- STC_LOGE("Invalid parameter");
- return STC_ERROR_INVALID_PARAMETER;
- }
-
- stc_restriction_info_s *restriction_info =
- (stc_restriction_info_s *)info;
-
- *iface_name = g_strdup(restriction_info->iface_name);
- if (*iface_name == NULL)
- return STC_ERROR_OUT_OF_MEMORY;
-
- STC_LOGI("Ifname [%s]", *iface_name);
-
- return STC_ERROR_NONE;
-}
-
-EXPORT_API int stc_restriction_info_get_subscriber_id(stc_restriction_info_h info,
- char **subscriber_id)
-{
- CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
-
- if (info == NULL || subscriber_id == NULL) {
- STC_LOGE("Invalid parameter");
- return STC_ERROR_INVALID_PARAMETER;
- }
-
- stc_restriction_info_s *restriction_info =
- (stc_restriction_info_s *)info;
-
- *subscriber_id = g_strdup(restriction_info->subscriber_id);
- if (*subscriber_id == NULL)
- return STC_ERROR_OUT_OF_MEMORY;
-
- STC_LOGI("Subscriber ID [%s]", *subscriber_id);
-
- return STC_ERROR_NONE;
-}
-
-EXPORT_API int stc_restriction_info_get_type(stc_restriction_info_h info,
- stc_restriction_type_e *type)
-{
- CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
-
- if (info == NULL) {
- STC_LOGE("Invalid parameter");
- return STC_ERROR_INVALID_PARAMETER;
- }
-
- stc_restriction_info_s *restriction_info =
- (stc_restriction_info_s *)info;
-
- *type = restriction_info->rstn_type;
-
- STC_LOGI("Type [%s]",
- _stc_convert_rstn_type_to_string(*type));
-
- return STC_ERROR_NONE;
-}
-
-EXPORT_API int stc_restriction_info_get_iface_type(stc_restriction_info_h info,
- stc_iface_type_e *iface_type)
-{
- CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
-
- if (info == NULL) {
- STC_LOGE("Invalid parameter");
- return STC_ERROR_INVALID_PARAMETER;
- }
-
- stc_restriction_info_s *restriction_info =
- (stc_restriction_info_s *)info;
-
- *iface_type = restriction_info->iface_type;
-
- STC_LOGI("Iftype [%s]",
- _stc_convert_iface_type_to_string(*iface_type));
-
- return STC_ERROR_NONE;
-}
-
-EXPORT_API int stc_restriction_info_get_limit(stc_restriction_info_h info,
- int64_t *data_limit)
-{
- CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
-
- if (info == NULL || data_limit == NULL) {
- STC_LOGE("Invalid parameter");
- return STC_ERROR_INVALID_PARAMETER;
- }
-
- stc_restriction_info_s *restriction_info =
- (stc_restriction_info_s *)info;
-
- *data_limit = restriction_info->data_limit;
-
- STC_LOGI("Data limit [%lld] bytes", *data_limit);
-
- return STC_ERROR_NONE;
-}
-
-EXPORT_API int stc_restriction_info_get_warning_limit(stc_restriction_info_h info,
- int64_t *data_warn_limit)
-{
- CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
-
- if (info == NULL || data_warn_limit == NULL) {
- STC_LOGE("Invalid parameter");
- return STC_ERROR_INVALID_PARAMETER;
- }
-
- stc_restriction_info_s *restriction_info =
- (stc_restriction_info_s *)info;
-
- *data_warn_limit = restriction_info->data_warn_limit;
-
- STC_LOGI("Data warn limit [%lld] bytes", *data_warn_limit);
-
- return STC_ERROR_NONE;
-}
-
-EXPORT_API int stc_restriction_info_get_roaming_type(stc_restriction_info_h info,
- stc_roaming_type_e *roaming_type)
-{
- CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
-
- if (info == NULL) {
- STC_LOGE("Invalid parameter");
- return STC_ERROR_INVALID_PARAMETER;
- }
-
- stc_restriction_info_s *restriction_info =
- (stc_restriction_info_s *)info;
-
- *roaming_type = restriction_info->roaming_type;
-
- STC_LOGI("Roaming type [%s]",
- _stc_convert_roaming_to_string(*roaming_type));
-
- return STC_ERROR_NONE;
-}
-//LCOV_EXCL_STOP
return STC_ERROR_INVALID_PARAMETER;
}
- ret = _stc_restriction_validate_rule(rule, STC_RSTN_TYPE_SET);
+ ret = _stc_restriction_validate_rule(rule);
if (ret != STC_ERROR_NONE) {
STC_LOGE("Invalid restriction rule [%s]",
_stc_convert_error_type_to_string(ret));
return STC_ERROR_NONE;
}
-EXPORT_API int stc_exclude_restriction(stc_h stc, stc_restriction_rule_h rule)
-{
- int ret = STC_ERROR_NONE;
-
- CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
-
- if (!(_stc_handle_check_validity(stc))) {
- STC_LOGE("Invalid parameter");
- return STC_ERROR_INVALID_PARAMETER;
- }
-
- ret = _stc_restriction_validate_rule(rule, STC_RSTN_TYPE_EXCLUDE);
- if (ret != STC_ERROR_NONE) {
- STC_LOGE("Invalid restriction rule [%s]",
- _stc_convert_error_type_to_string(ret));
- return ret;
- }
-
- ret = _stc_restriction_exclude(rule);
- if (ret != STC_ERROR_NONE) {
- STC_LOGE("Failed to exclude restriction [%s]",
- _stc_convert_error_type_to_string(ret));
- return ret;
- }
-
- return STC_ERROR_NONE;
-}
-
EXPORT_API int stc_unset_restriction(stc_h stc, stc_restriction_rule_h rule)
{
int ret = STC_ERROR_NONE;
return STC_ERROR_INVALID_PARAMETER;
}
- ret = _stc_restriction_validate_rule(rule, STC_RSTN_TYPE_UNSET);
+ ret = _stc_restriction_validate_rule(rule);
if (ret != STC_ERROR_NONE) {
STC_LOGE("Invalid restriction rule [%s]",
_stc_convert_error_type_to_string(ret));
}
EXPORT_API int stc_get_restriction(stc_h stc, stc_restriction_rule_h rule,
- stc_restriction_info_cb info_cb, void *user_data)
+ stc_restriction_rule_cb rule_cb, void *user_data)
{
int ret = STC_ERROR_NONE;
return STC_ERROR_INVALID_PARAMETER;
}
- if (info_cb == NULL) {
+ if (rule_cb == NULL) {
STC_LOGE("Invalid parameter");
return STC_ERROR_INVALID_PARAMETER;
}
return ret;
}
- _stc_callback_set_restriction_info(stc,
- info_cb, user_data);
+ _stc_callback_set_restriction_rule(stc,
+ rule_cb, user_data);
ret = _stc_restriction_get(rule);
if (ret != STC_ERROR_NONE) {
- STC_LOGE("Failed to request restriction info [%s]",
+ STC_LOGE("Failed to request restriction rule [%s]",
_stc_convert_error_type_to_string(ret));
return ret;
}
}
EXPORT_API int stc_foreach_restriction(stc_h stc, stc_restriction_rule_h rule,
- stc_restriction_info_cb info_cb, void *user_data)
+ stc_restriction_rule_cb rule_cb, void *user_data)
{
int ret = STC_ERROR_NONE;
return STC_ERROR_INVALID_PARAMETER;
}
- if (info_cb == NULL) {
+ if (rule_cb == NULL) {
STC_LOGE("Invalid parameter");
return STC_ERROR_INVALID_PARAMETER;
}
return ret;
}
- _stc_callback_set_restriction_all_info(stc,
- info_cb, user_data);
+ _stc_callback_set_restriction_all_rule(stc,
+ rule_cb, user_data);
ret = _stc_restriction_get_all(rule);
if (ret != STC_ERROR_NONE) {
- STC_LOGE("Failed to request restriction all info [%s]",
+ STC_LOGE("Failed to request restriction all rule [%s]",
_stc_convert_error_type_to_string(ret));
return ret;
}
#include "stc-util.h"
#include "stc-event.h"
-#include "stc-info.h"
#include "stc-restriction.h"
/*****************************************************************************
STC_RESTRICTION_RULE_SUBSCRIBER_ID,
g_variant_new_string(restriction_rule->subscriber_id));
+ g_variant_builder_add(builder, "{sv}",
+ STC_RESTRICTION_RULE_RSTN_TYPE,
+ g_variant_new_uint16(restriction_rule->rstn_type));
+
g_variant_builder_add(builder, "{sv}",
STC_RESTRICTION_RULE_DATA_LIMIT,
g_variant_new_int64(restriction_rule->data_limit));
restriction_rule->app_id, restriction_rule->iface_type);
}
-static void __stc_restriction_extract_info_cb(const char *key,
+static void __stc_restriction_extract_rule_cb(const char *key,
GVariant *value, void *user_data)
{
- stc_restriction_info_s *restriction_info =
- (stc_restriction_info_s *)user_data;
+ stc_restriction_rule_s *restriction_rule =
+ (stc_restriction_rule_s *)user_data;
- if (restriction_info == NULL)
+ if (restriction_rule == NULL)
return;
- if (!g_strcmp0(key, STC_RESTRICTION_INFO_APP_ID)) {
+ if (!g_strcmp0(key, STC_RESTRICTION_RULE_APP_ID)) {
const char *app_id = g_variant_get_string(value, NULL);
if (app_id != NULL)
- g_strlcpy(restriction_info->app_id, app_id, STC_APP_ID_LEN);
+ g_strlcpy(restriction_rule->app_id, app_id, STC_APP_ID_LEN);
- } else if (!g_strcmp0(key, STC_RESTRICTION_INFO_IFNAME)) {
+ } else if (!g_strcmp0(key, STC_RESTRICTION_RULE_IFNAME)) {
const char *iface_name = g_variant_get_string(value, NULL);
if (iface_name != NULL)
- g_strlcpy(restriction_info->iface_name, iface_name, STC_IFNAME_LEN);
+ g_strlcpy(restriction_rule->iface_name, iface_name, STC_IFNAME_LEN);
- } else if (!g_strcmp0(key, STC_RESTRICTION_INFO_SUBSCRIBER_ID)) {
+ } else if (!g_strcmp0(key, STC_RESTRICTION_RULE_SUBSCRIBER_ID)) {
const char *subscriber_id = g_variant_get_string(value, NULL);
if (subscriber_id != NULL)
- g_strlcpy(restriction_info->subscriber_id, subscriber_id, STC_SUBSCRIBER_ID_LEN);
+ g_strlcpy(restriction_rule->subscriber_id, subscriber_id, STC_SUBSCRIBER_ID_LEN);
- } else if (!g_strcmp0(key, STC_RESTRICTION_INFO_IFTYPE)) {
- restriction_info->iface_type =
+ } else if (!g_strcmp0(key, STC_RESTRICTION_RULE_IFTYPE)) {
+ restriction_rule->iface_type =
(stc_iface_type_e)g_variant_get_uint16(value);
- } else if (!g_strcmp0(key, STC_RESTRICTION_INFO_RSTN_TYPE)) {
- restriction_info->rstn_type =
+ } else if (!g_strcmp0(key, STC_RESTRICTION_RULE_RSTN_TYPE)) {
+ restriction_rule->rstn_type =
(stc_restriction_type_e)g_variant_get_uint16(value);
- } else if (!g_strcmp0(key, STC_RESTRICTION_INFO_DATA_LIMIT)) {
- restriction_info->data_limit = g_variant_get_int64(value);
+ } else if (!g_strcmp0(key, STC_RESTRICTION_RULE_DATA_LIMIT)) {
+ restriction_rule->data_limit = g_variant_get_int64(value);
- } 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_RULE_DATA_WARN_LIMIT)) {
+ restriction_rule->data_warn_limit = g_variant_get_int64(value);
- } else if (!g_strcmp0(key, STC_RESTRICTION_INFO_ROAMING)) {
- restriction_info->roaming_type =
+ } else if (!g_strcmp0(key, STC_RESTRICTION_RULE_ROAMING)) {
+ restriction_rule->roaming_type =
(stc_roaming_type_e)g_variant_get_uint16(value);
}
}
-static void __stc_restriction_print_info(
- stc_restriction_info_s *info)
+static void __stc_restriction_print_rule(
+ stc_restriction_rule_s *rule)
{
STC_LOGD(STC_HR_SINGLE);
- STC_LOGD("App_id: [%s]", (info->app_id[0] != '\0') ? info->app_id : "NULL");
- STC_LOGD("Ifname: [%s]", (info->iface_name[0] != '\0') ? info->iface_name : "NULL");
+ STC_LOGD("App_id: [%s]", (rule->app_id[0] != '\0') ? rule->app_id : "NULL");
+ STC_LOGD("Ifname: [%s]", (rule->iface_name[0] != '\0') ? rule->iface_name : "NULL");
- if (info->iface_type != STC_IFACE_UNKNOWN)
- STC_LOGD("Iftype: [%s]", _stc_convert_iface_type_to_string(info->iface_type));
+ if (rule->iface_type != STC_IFACE_UNKNOWN)
+ STC_LOGD("Iftype: [%s]", _stc_convert_iface_type_to_string(rule->iface_type));
- if (info->subscriber_id[0] != '\0')
- STC_LOGD("Sub_id: [%s]", info->subscriber_id);
+ if (rule->subscriber_id[0] != '\0')
+ STC_LOGD("Sub_id: [%s]", rule->subscriber_id);
- if (info->roaming_type != STC_ROAMING_UNKNOWN)
- STC_LOGD("Roaming: [%s]", _stc_convert_roaming_to_string(info->roaming_type));
+ if (rule->roaming_type != STC_ROAMING_UNKNOWN)
+ STC_LOGD("Roaming: [%s]", _stc_convert_roaming_to_string(rule->roaming_type));
- if (info->rstn_type != STC_RSTN_TYPE_UNKNOWN)
- STC_LOGD("Type: [%s]", _stc_convert_rstn_type_to_string(info->rstn_type));
+ 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", info->data_limit);
- STC_LOGD("Warning: [%lld] bytes", info->data_warn_limit);
+ STC_LOGD("Limit: [%lld] bytes", rule->data_limit);
+ STC_LOGD("Warning: [%lld] bytes", rule->data_warn_limit);
STC_LOGD(STC_HR_SINGLE);
}
GVariantIter *iter = NULL;
stc_error_e dbus_result = STC_ERROR_NONE;
stc_error_e error = STC_ERROR_NONE;
- stc_restriction_info_s *restriction_info = NULL;
+ stc_restriction_rule_s *restriction_rule = NULL;
GSList *restriction_list = NULL;
stc_event_info_s event_data = { 0, };
g_variant_get(dbus_data, "(ia{sv})", &dbus_result, &iter);
if (iter != NULL) {
- restriction_info = g_try_malloc0(
- sizeof(stc_restriction_info_s));
+ restriction_rule = g_try_malloc0(
+ sizeof(stc_restriction_rule_s));
_stc_dbus_dictionary_foreach(iter,
- __stc_restriction_extract_info_cb, restriction_info);
+ __stc_restriction_extract_rule_cb, restriction_rule);
- __stc_restriction_print_info(restriction_info);
+ __stc_restriction_print_rule(restriction_rule);
restriction_list = g_slist_append(restriction_list,
- (stc_restriction_info_s *)restriction_info);
+ (stc_restriction_rule_s *)restriction_rule);
g_variant_iter_free(iter);
}
GVariantIter *iter_row = NULL;
stc_error_e dbus_result = STC_ERROR_NONE;
stc_error_e error = STC_ERROR_NONE;
- stc_restriction_info_s *restriction_info = NULL;
+ stc_restriction_rule_s *restriction_rule = NULL;
GSList *restriction_list = NULL;
stc_event_info_s event_data = { 0, };
g_variant_get(dbus_data, "(iaa{sv})", &dbus_result, &iter);
while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
- restriction_info = g_try_malloc0(
- sizeof(stc_restriction_info_s));
+ restriction_rule = g_try_malloc0(
+ sizeof(stc_restriction_rule_s));
_stc_dbus_dictionary_foreach(iter_row,
- __stc_restriction_extract_info_cb, restriction_info);
+ __stc_restriction_extract_rule_cb, restriction_rule);
- __stc_restriction_print_info(restriction_info);
+ __stc_restriction_print_rule(restriction_rule);
restriction_list = g_slist_append(restriction_list,
- (stc_restriction_info_s *)restriction_info);
+ (stc_restriction_rule_s *)restriction_rule);
g_variant_iter_free(iter_row);
}
}
stc_error_e _stc_restriction_validate_rule(
- stc_restriction_rule_h rule, stc_rstn_type_e rstn_type)
+ stc_restriction_rule_h rule)
{
stc_restriction_rule_s *restriction_rule = rule;
STC_ERROR_INVALID_PARAMETER,
"Restriction rule should be set");
- STC_RETURN_VAL_IF(rstn_type <= STC_RSTN_TYPE_UNDEF ||
- rstn_type >= STC_RSTN_TYPE_MAX_VALUE,
+ STC_RETURN_VAL_IF(restriction_rule->rstn_type < STC_RSTN_TYPE_UNKNOWN ||
+ restriction_rule->rstn_type >= STC_RSTN_TYPE_LAST_ELEM,
STC_ERROR_INVALID_PARAMETER,
"Invalid restriction type");
"Invalid restriction network interface type [%s]",
_stc_convert_iface_type_to_string(restriction_rule->iface_type));
- if (rstn_type == STC_RSTN_TYPE_SET) {
+ if (restriction_rule->rstn_type == STC_RSTN_TYPE_DROP) {
STC_RETURN_VAL_IF(restriction_rule->data_limit < 0,
STC_ERROR_INVALID_PARAMETER,
"Invalid tx limit [%lld] bytes",
return STC_ERROR_NONE;
}
-stc_error_e _stc_restriction_exclude(
- stc_restriction_rule_h rule)
-{
- GVariant *message = NULL;
- GVariant *params = NULL;
- stc_error_e error = STC_ERROR_NONE;
- int result = 0;
-
- __stc_restriction_rule_make_params(rule, ¶ms);
-
- message = _stc_dbus_invoke_method(
- STC_MANAGER_SERVICE,
- STC_MANAGER_RESTRICTION_PATH,
- STC_MANAGER_RESTRICTION_INTERFACE,
- STC_MANAGER_METHOD_RESTRICTION_EXCLUDE,
- params,
- &error);
-
- STC_RETURN_VAL_IF(message == NULL,
- error, "Failed to invoke dbus method");
-
- g_variant_get(message, "(i)", &result);
- STC_LOGI("Successfully exclude restriction [%d]", result);
- g_variant_unref(message);
-
- return STC_ERROR_NONE;
-}
-
stc_error_e _stc_restriction_unset(
stc_restriction_rule_h rule)
{
return STC_ERROR_NONE;
}
+EXPORT_API int stc_restriction_rule_set_type(stc_restriction_rule_h rule,
+ stc_restriction_type_e type)
+{
+ 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;
+
+ switch (type) {
+ case STC_RSTN_TYPE_UNKNOWN:
+ case STC_RSTN_TYPE_ACCEPT:
+ case STC_RSTN_TYPE_DROP:
+ restriction_rule->rstn_type = type;
+ break;
+ default:
+ STC_LOGE("Invalid parameter");
+ return STC_ERROR_INVALID_PARAMETER;
+ }
+
+ STC_LOGI("Type [%s]",
+ _stc_convert_rstn_type_to_string(restriction_rule->rstn_type));
+
+ return STC_ERROR_NONE;
+}
+
EXPORT_API int stc_restriction_rule_set_limit(stc_restriction_rule_h rule,
int64_t data_limit)
{
return STC_ERROR_NONE;
}
+EXPORT_API int stc_restriction_rule_get_type(stc_restriction_rule_h rule,
+ stc_restriction_type_e *type)
+{
+ 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;
+
+ *type = restriction_rule->rstn_type;
+
+ STC_LOGI("Type [%s]", _stc_convert_rstn_type_to_string(*type));
+
+ return STC_ERROR_NONE;
+}
+
EXPORT_API int stc_restriction_rule_get_limit(stc_restriction_rule_h rule,
int64_t *data_limit)
{
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";
extern stc_h g_stc;
static stc_restriction_rule_h g_restriction_rule = NULL;
-static stc_callback_ret_e __test_stc_restriction_info_cb(
- stc_error_e result, stc_restriction_info_h info, void *user_data)
+static stc_callback_ret_e __test_stc_restriction_rule_cb(
+ stc_error_e result, stc_restriction_rule_h rule, void *user_data)
{
if (result != STC_ERROR_NONE) {
- msg("Response restriction info error " LOG_RED "[%s]" LOG_END,
+ msg("Response restriction rule error " LOG_RED "[%s]" LOG_END,
test_stc_convert_error_type_to_string(result));
return STC_CALLBACK_CANCEL;
}
msg(HR_SINGLE);
- ret = stc_restriction_info_get_app_id(info, &app_id);
+ ret = stc_restriction_rule_get_app_id(rule, &app_id);
if (ret == STC_ERROR_NONE)
msg("App_id: " LOG_CYAN "[%s]" LOG_END, app_id);
- ret = stc_restriction_info_get_iface_name(info, &iface_name);
+ ret = stc_restriction_rule_get_iface_name(rule, &iface_name);
if (ret == STC_ERROR_NONE)
msg("Ifname: [%s]", iface_name);
- ret = stc_restriction_info_get_subscriber_id(info, &subscriber_id);
+ ret = stc_restriction_rule_get_subscriber_id(rule, &subscriber_id);
if (ret == STC_ERROR_NONE)
msg("Sub_id: [%s]", subscriber_id);
- ret = stc_restriction_info_get_type(info, &rstn_type);
+ ret = stc_restriction_rule_get_type(rule, &rstn_type);
if (ret == STC_ERROR_NONE)
msg("Type: [%s]", test_stc_convert_rstn_type_to_string(rstn_type));
- ret = stc_restriction_info_get_iface_type(info, &iface_type);
+ ret = stc_restriction_rule_get_iface_type(rule, &iface_type);
if (ret == STC_ERROR_NONE)
msg("Iftype: [%s]", test_stc_convert_iface_type_to_string(iface_type));
- ret = stc_restriction_info_get_roaming_type(info, &roaming);
+ ret = stc_restriction_rule_get_roaming_type(rule, &roaming);
if (ret == STC_ERROR_NONE)
msg("Roaming: [%s]", test_stc_convert_roaming_to_string(roaming));
- ret = stc_restriction_info_get_limit(info, &data_limit);
+ ret = stc_restriction_rule_get_limit(rule, &data_limit);
if (ret == STC_ERROR_NONE)
msg("Data_limit: [%lld]", data_limit);
- ret = stc_restriction_info_get_warning_limit(info, &data_warn_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);
return STC_CALLBACK_CONTINUE;
}
-static void __test_stc_warn_threshold_crossed_cb(stc_restriction_info_h info,
+static void __test_stc_warn_threshold_crossed_cb(stc_restriction_rule_h rule,
void *user_data)
{
int ret = STC_ERROR_NONE;
msg(HR_SINGLE);
- ret = stc_restriction_info_get_app_id(info, &app_id);
+ ret = stc_restriction_rule_get_app_id(rule, &app_id);
if (ret == STC_ERROR_NONE)
msg("Warn threshold crossed app_id: " LOG_CYAN "[%s]" LOG_END, app_id);
msg(HR_SINGLE);
}
-static void __test_stc_restriction_threshold_crossed_cb(stc_restriction_info_h info,
+static void __test_stc_restriction_threshold_crossed_cb(stc_restriction_rule_h rule,
void *user_data)
{
int ret = STC_ERROR_NONE;
msg(HR_SINGLE);
- ret = stc_restriction_info_get_app_id(info, &app_id);
+ ret = stc_restriction_rule_get_app_id(rule, &app_id);
if (ret == STC_ERROR_NONE)
msg("Restriction threshold crossed app_id: " LOG_CYAN "[%s]" LOG_END, app_id);
char *app_id = NULL;
char *subscriber_id = NULL;
char *iface_name = NULL;
+ stc_restriction_type_e type = (int)strtol(g_type, NULL, 10);
int ret = STC_ERROR_NONE;
ret = stc_restriction_rule_set_app_id(g_restriction_rule, g_app_id);
}
}
+ 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)
+ msg(LOG_GREEN "Success to set type" LOG_END);
+ else {
+ msg("Fail to set type " 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);
msg("Roaming: " LOG_CYAN "[%s]" LOG_END,
test_stc_convert_roaming_to_string(roaming));
+ ret = stc_restriction_rule_get_type(g_restriction_rule, &type);
+ if (ret == STC_ERROR_NONE)
+ msg("Type: " LOG_CYAN "[%s]" LOG_END,
+ test_stc_convert_rstn_type_to_string(type));
+
data_limit = 0;
ret = stc_restriction_rule_get_limit(g_restriction_rule, &data_limit);
if (ret == STC_ERROR_NONE)
ret = stc_get_restriction(g_stc,
g_restriction_rule,
- __test_stc_restriction_info_cb,
+ __test_stc_restriction_rule_cb,
NULL);
if (ret == STC_ERROR_NONE)
- msg(LOG_GREEN "Success to request restriction info" LOG_END);
+ msg(LOG_GREEN "Success to request restriction rule" LOG_END);
else
- msg("Fail to request restriction info " LOG_RED "[%s]" LOG_END,
+ msg("Fail to request restriction rule " LOG_RED "[%s]" LOG_END,
test_stc_convert_error_type_to_string(ret));
return ret;
ret = stc_foreach_restriction(g_stc,
g_restriction_rule,
- __test_stc_restriction_info_cb,
+ __test_stc_restriction_rule_cb,
NULL);
if (ret == STC_ERROR_NONE)
- msg(LOG_GREEN "Success to request restriction all info" LOG_END);
+ msg(LOG_GREEN "Success to request restriction all rule" LOG_END);
else
- msg("Fail to request restriction all info " LOG_RED "[%s]" LOG_END,
+ msg("Fail to request restriction all rule " LOG_RED "[%s]" LOG_END,
test_stc_convert_error_type_to_string(ret));
return ret;
return ret;
}
-static int __test_stc_restriction_exclude(MManager *mm, struct menu_data *menu)
-{
- int ret = STC_ERROR_NONE;
-
- ret = stc_exclude_restriction(g_stc, g_restriction_rule);
-
- if (ret == STC_ERROR_NONE)
- msg(LOG_GREEN "Success to exclude restriction" LOG_END);
- else
- msg("Fail to exclude restriction " LOG_RED "[%s]" LOG_END,
- test_stc_convert_error_type_to_string(ret));
-
- return ret;
-}
-
int test_stc_restriction_rule_create(void)
{
int ret = stc_restriction_rule_create(g_stc, &g_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", "Data limit", NULL, NULL, g_data_limit},
- { "7", "Data warn limit", NULL, NULL, g_data_warn_limit},
+ { "6", "Type(1.Accept/2.Drop)", NULL, NULL, g_type},
+ { "7", "Data limit", NULL, NULL, g_data_limit},
+ { "8", "Data warn limit", NULL, NULL, g_data_warn_limit},
{ "s", LOG_LIGHTMAGENTA "[Set]" LOG_END, NULL, __test_stc_set_restriction_rule, NULL},
{ NULL, NULL, },
};
{ "3", LOG_LIGHTBLUE "[Get]" LOG_END " all restrictions", NULL, __test_stc_restriction_get_all, NULL},
{ "4", LOG_LIGHTBLUE "[Get]" LOG_END " restriction type", NULL, __test_stc_restriction_get_type, NULL},
{ "5", LOG_LIGHTMAGENTA "[Set]" LOG_END " restriction", NULL, __test_stc_restriction_set, NULL},
- { "6", LOG_LIGHTMAGENTA "[Remove]" LOG_END " restriction", NULL, __test_stc_restriction_unset, NULL},
- { "7", LOG_LIGHTMAGENTA "[Exlcude]" LOG_END " restriction", NULL, __test_stc_restriction_exclude, NULL},
+ { "6", LOG_LIGHTMAGENTA "[Unset]" LOG_END " restriction", NULL, __test_stc_restriction_unset, NULL},
{ NULL, NULL, },
};