elm_popup_timeout_set(popup, 3.5);
}
+static stc_callback_ret_e _get_and_unset_limit_restrictions_cb(stc_error_e result,
+ stc_restriction_info_h info, void *user_data)
+{
+ int ret = STC_ERROR_NONE;
+ char *app_id = NULL;
+ char *imsi = NULL;
+ int64_t limit = 0;
+ int64_t warning_limit = 0;
+ stc_iface_type_e iface_type = STC_IFACE_UNKNOWN;
+ stc_restriction_status_e status = STC_RESTRICTION_UNKNOWN;
+ stc_restriction_rule_h rule = NULL;
+ restrictions_result restrictions_res = RESTRICTIONS_OTHER_ERROR;
+ SmartMgrData *smd = (SmartMgrData *)user_data;
+
+ SETTING_TRACE_DEBUG("_get_restrictions_to_unset_cb:");
+ if (STC_ERROR_NONE != result) {
+ SETTING_TRACE_ERROR("_get_restrictions_to_unset_cb error: %s",
+ get_error_message(result));
+ return STC_CALLBACK_CONTINUE;
+ }
+
+ ret = stc_restriction_info_get_app_id(info, &app_id);
+ if (STC_ERROR_NONE != ret || !app_id || !(strcmp("TOTAL_DATACALL", app_id))) {
+ free(app_id);
+ return STC_CALLBACK_CONTINUE;
+ }
+
+ free(app_id);
+
+ ret = stc_restriction_info_get_status(info, &status);
+ if (STC_ERROR_NONE != ret) {
+ SETTING_TRACE_ERROR("stc_restriction_info_get_status error: %s",
+ get_error_message(ret));
+ return STC_CALLBACK_CONTINUE;
+ }
+
+ ret = stc_restriction_info_get_iface_type(info, &iface_type);
+ if (STC_ERROR_NONE != ret) {
+ SETTING_TRACE_ERROR("stc_restriction_info_get_iface_type error: %s",
+ get_error_message(ret));
+ return STC_CALLBACK_CONTINUE;
+ }
+
+ if (iface_type != STC_IFACE_DATACALL) {
+ return STC_CALLBACK_CONTINUE;
+ }
+
+ ret = stc_restriction_info_get_imsi(info, &imsi);
+ if (STC_ERROR_NONE != ret) {
+ SETTING_TRACE_ERROR("stc_restriction_info_get_imsi error: %s",
+ get_error_message(ret));
+ return STC_CALLBACK_CONTINUE;
+ }
+
+ if (compare_imsis(smd->selected_sim_imsi, imsi)) {
+ ret = stc_restriction_info_get_limit(info, &limit);
+ if (STC_ERROR_NONE != ret) {
+ SETTING_TRACE_ERROR("stc_restriction_info_get_limit() error: %s",
+ get_error_message(ret));
+ return STC_CALLBACK_CONTINUE;
+ }
+
+ ret = stc_restriction_info_get_warning_limit(info, &warning_limit);
+ if (STC_ERROR_NONE != ret) {
+ SETTING_TRACE_ERROR("stc_restriction_info_get_warning_limit() error: %s",
+ get_error_message(ret));
+ return STC_CALLBACK_CONTINUE;
+ }
+
+ ret = stc_restriction_rule_create(smd->stc, &rule);
+ if (STC_ERROR_NONE != ret) {
+ SETTING_TRACE_ERROR("stc_restriction_rule_create() error: %s",
+ get_error_message(ret));
+ return STC_CALLBACK_CONTINUE;
+ }
+
+ restrictions_res = set_mobile_restriction_rule_parameters(rule, imsi, limit, warning_limit);
+ if (restrictions_res != RESTRICTIONS_OK) {
+ SETTING_TRACE_ERROR("set_mobile_restriction_rule_parameters() error");
+ return STC_CALLBACK_CONTINUE;
+ }
+
+ ret = stc_unset_restriction(smd->stc, rule);
+ if (STC_ERROR_NONE != ret) {
+ SETTING_TRACE_ERROR("stc_unset_restriction() error: %s",
+ get_error_message(ret));
+ return STC_CALLBACK_CONTINUE;
+ }
+
+ free(imsi);
+ }
+
+ SETTING_TRACE_ERROR("stc_unset_restriction() successful unset restriction");
+ return STC_CALLBACK_CONTINUE;
+}
+
+
static void _popup_done_cb(void *data, Evas_Object *obj, void *event_info)
{
SETTING_TRACE_BEGIN;
}
restrictions_result res = RESTRICTIONS_OTHER_ERROR;
+
if (limit_popup_data->element_type == ELEMENT_TYPE_WARNING) {
- res = set_mobile_limit_restrictions(
- limit_popup_data->smd->stc,
- limit_popup_data->smd->selected_sim_imsi,
- limit_popup_data->smd->selected_sim_limits->limit,
- (int64_t)value);
+ if (limit_popup_data->smd->selected_sim_limits->limit == 0 || value == 0) {
+ unset_mobile_limit_restrictions(limit_popup_data->smd->stc, _get_and_unset_limit_restrictions_cb, limit_popup_data->smd);
+ } else {
+ res = set_mobile_limit_restrictions(
+ limit_popup_data->smd->stc,
+ limit_popup_data->smd->selected_sim_imsi,
+ limit_popup_data->smd->selected_sim_limits->limit,
+ (int64_t)value);
+ }
} else if (limit_popup_data->element_type == ELEMENT_TYPE_LIMIT) {
- res = set_mobile_limit_restrictions(
- limit_popup_data->smd->stc,
- limit_popup_data->smd->selected_sim_imsi,
- (int64_t)value,
- limit_popup_data->smd->selected_sim_limits->warning);
+ if (limit_popup_data->smd->selected_sim_limits->warning == 0 || value == 0) {
+ unset_mobile_limit_restrictions(limit_popup_data->smd->stc, _get_and_unset_limit_restrictions_cb, limit_popup_data->smd);
+ } else {
+ res = set_mobile_limit_restrictions(
+ limit_popup_data->smd->stc,
+ limit_popup_data->smd->selected_sim_imsi,
+ (int64_t)value,
+ limit_popup_data->smd->selected_sim_limits->warning);
+ }
+
} else {
SETTING_TRACE_ERROR("Wrong type used: %d", limit_popup_data->element_type);
}
static bool _get_total_stats(stc_h stc, stc_iface_type_e iface_type,
stc_stats_info_cb stats_cb);
static bool _get_restrictions(stc_h stc, stc_iface_type_e iface_type,
- stc_restriction_info_cb restrictions_cb);
+ stc_restriction_info_cb restrictions_cb,
+ void *restriction_info_cb_data);
void get_data_amount_str(const char *prefix, int64_t num_bytes, char *txt_out, int len_max)
{
bool get_sim_restrictions(stc_h stc, stc_restriction_info_cb restrictions_cb)
{
- return _get_restrictions(stc, STC_IFACE_DATACALL, restrictions_cb);
+ return _get_restrictions(stc, STC_IFACE_DATACALL, restrictions_cb, NULL);
}
bool get_wifi_restrictions(stc_h stc, stc_restriction_info_cb restrictions_cb)
{
- return _get_restrictions(stc, STC_IFACE_WIFI, restrictions_cb);
+ return _get_restrictions(stc, STC_IFACE_WIFI, restrictions_cb, NULL);
}
static bool _create_stats_list(stc_h stc, stc_iface_type_e iface,
}
static bool _get_restrictions(stc_h stc, stc_iface_type_e iface_type,
- stc_restriction_info_cb restrictions_cb)
+ stc_restriction_info_cb restrictions_cb,
+ void *restriction_info_cb_data)
{
int ret = STC_ERROR_NONE;
stc_restriction_rule_h rule = NULL;
return (0 == safeStrNCmp(imsi_a, imsi_b, 15));
}
-restrictions_result set_mobile_limit_restrictions(stc_h stc_handle, const char *imsi, int64_t limit, int64_t warning_limit)
+restrictions_result set_mobile_restriction_rule_parameters(
+ stc_restriction_rule_h rule,
+ const char *imsi, int64_t limit,
+ int64_t warning_limit)
{
SETTING_TRACE_BEGIN;
int ret = STC_ERROR_NONE;
- stc_restriction_rule_h rule = NULL;
-
- ret = stc_restriction_rule_create(stc_handle, &rule);
- if (STC_ERROR_NONE != ret) {
- SETTING_TRACE_ERROR("stc_restriction_rule_create() error: %s",
- get_error_message(ret));
- return RESTRICTIONS_OTHER_ERROR;
- }
ret = stc_restriction_rule_set_app_id(rule, "TOTAL_DATACALL");
if (STC_ERROR_NONE != ret) {
return RESTRICTIONS_OTHER_ERROR;
}
+ SETTING_TRACE_END;
+ return RESTRICTIONS_OK;
+}
+
+restrictions_result set_mobile_limit_restrictions(stc_h stc_handle, const char *imsi, int64_t limit, int64_t warning_limit)
+{
+ SETTING_TRACE_BEGIN;
+ int ret = STC_ERROR_NONE;
+ stc_restriction_rule_h rule = NULL;
+ restrictions_result result = RESTRICTIONS_OK;
+
+ ret = stc_restriction_rule_create(stc_handle, &rule);
+ if (STC_ERROR_NONE != ret) {
+ SETTING_TRACE_ERROR("stc_restriction_rule_create() error: %s",
+ get_error_message(ret));
+ return RESTRICTIONS_OTHER_ERROR;
+ }
+
+ result = set_mobile_restriction_rule_parameters(rule, imsi, limit, warning_limit);
+ if (RESTRICTIONS_OK != result) {
+ (void)stc_restriction_rule_destroy(rule);
+ SETTING_TRACE_ERROR("set_restriction_rule_parameters() error");
+ return result;
+ }
+
ret = stc_set_restriction(stc_handle, rule);
if (STC_ERROR_NONE != ret) {
(void)stc_restriction_rule_destroy(rule);
SETTING_TRACE_END;
return RESTRICTIONS_OK;
}
+
+bool unset_mobile_limit_restrictions(stc_h stc_handle, stc_restriction_info_cb _get_and_unset_limit_restrictions_cb, void *data)
+{
+ SETTING_TRACE_BEGIN;
+ return _get_restrictions(stc_handle, STC_IFACE_DATACALL, _get_and_unset_limit_restrictions_cb, data);
+ SETTING_TRACE_END;
+}