static void _clear_all_stat_lists(SmartMgrData *ad);
static void _delete_stat_item(data_usage_app_item_t *item);
+static void _get_total_stats(SmartMgrData *ad);
+
static SmartMgrData ad = {0,};
static void _lang_changed(app_event_info_h event_info, void *data)
}
if (iface == STC_IFACE_WIFI) {
- ad.total_data_wifi += incoming + outgoing;
if (_append_stats_list_item(&ad.wifi_apps, app_id, incoming + outgoing)
) {
ad.main_view_update_type = MV_UPDATE_APPEND_WIFI_APP;
setting_view_update(ad.main_view, &ad);
}
} else if (iface == STC_IFACE_DATACALL) {
- ad.total_data_sim += incoming + outgoing;
if (_append_stats_list_item(&ad.sim_1_apps, app_id, incoming + outgoing)
) {
ad.main_view_update_type = MV_UPDATE_APPEND_SIM_1_APP;
ad->main_view_update_type = MV_UPDATE_CLEAR_ALL_SIM_1_APPS;
setting_view_update(ad->main_view, ad);
_create_stats_list(STC_IFACE_DATACALL);
+ _get_total_stats(ad);
ecore_timer_add(3.0, _timer_cb, NULL);
if (setting_view_node_get_cur_view() == ad->main_view) {
SETTING_TRACE_DEBUG("_sim_state_change_cb: updating main view");
- setting_view_update(setting_view_node_get_cur_view(), ad);
+ setting_view_update(ad->main_view, ad);
} else {
SETTING_TRACE_DEBUG("_sim_state_change_cb: going back to main view");
setting_view_change(setting_view_node_get_cur_view(), ad->main_view,
free(item->label);
free(item);
}
+
+static stc_callback_ret_e _total_stats_cb(stc_error_e result,
+ stc_stats_info_h info, void *user_data)
+{
+ SmartMgrData *ad = user_data;
+ int64_t incoming = 0;
+ int64_t outgoing = 0;
+ int ret = STC_ERROR_NONE;
+ stc_iface_type_e iface_type = STC_IFACE_UNKNOWN;
+ SETTING_TRACE("Obtaining total stats");
+
+ ret = stc_stats_info_get_iface_type(info, &iface_type);
+ if (STC_ERROR_NONE != ret) {
+ SETTING_TRACE_ERROR("get interface error: %s", get_error_message(ret));
+ return STC_CALLBACK_CANCEL;
+ }
+
+ ret = stc_stats_info_get_counter(info, &incoming, &outgoing);
+
+ if (STC_ERROR_NONE == ret) {
+ if (iface_type == STC_IFACE_DATACALL) {
+ ad->main_view_update_type = MV_UPDATE_SIM_1_TOTAL_DATA_USAGE;
+ ad->total_data_sim = incoming + outgoing;
+ SETTING_TRACE("SIM total in: %lld out: %lld", incoming, outgoing);
+ }
+ if (iface_type == STC_IFACE_WIFI) {
+ ad->main_view_update_type = MV_UPDATE_WIFI_TOTAL_DATA_USAGE;
+ ad->total_data_wifi = incoming + outgoing;
+ SETTING_TRACE("WIFI total in: %lld out: %lld", incoming, outgoing);
+ }
+ setting_view_update(ad->main_view, ad);
+ } else {
+ SETTING_TRACE_ERROR("get counter error: %s", get_error_message(ret));
+ return STC_CALLBACK_CANCEL;
+ }
+ return STC_CALLBACK_CONTINUE;
+}
+
+static void _get_total_stats(SmartMgrData *ad)
+{
+ stc_stats_rule_h rule = NULL;
+ time_t now = time(NULL);
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_stats_rule_create(ad->stc, &rule);
+ if (ret != STC_ERROR_NONE) {
+ SETTING_TRACE_ERROR("stc_stats_rule_create() error: %s",
+ get_error_message(ret));
+ return;
+ }
+
+ ret = stc_stats_rule_set_time_interval(rule,
+ now - STC_TIME_PERIOD_MONTH, now);
+ if (ret != STC_ERROR_NONE) {
+ SETTING_TRACE_ERROR("stc_stats_rule_set_time_interval() error: %s",
+ get_error_message(ret));
+ (void)stc_stats_rule_destroy(rule);
+ return;
+ }
+
+ ret = stc_stats_rule_set_iface_type(rule, STC_IFACE_DATACALL);
+ if (ret != STC_ERROR_NONE) {
+ SETTING_TRACE_ERROR("stc_stats_rule_set_iface_type() error: %s",
+ get_error_message(ret));
+ (void)stc_stats_rule_destroy(rule);
+ return;
+ }
+ (void)stc_get_total_stats(ad->stc, rule, _total_stats_cb, ad);
+
+ ret = stc_stats_rule_set_iface_type(rule, STC_IFACE_WIFI);
+ if (ret != STC_ERROR_NONE) {
+ SETTING_TRACE_ERROR("stc_stats_rule_set_iface_type() error: %s",
+ get_error_message(ret));
+ (void)stc_stats_rule_destroy(rule);
+ return;
+ }
+ (void)stc_get_total_stats(ad->stc, rule, _total_stats_cb, ad);
+
+ (void)stc_stats_rule_destroy(rule);
+}