static void _toolbar_item_click(void *data, Evas_Object *toolbar,
void *event_info)
{
- SETTING_TRACE_BEGIN;
SmartMgrData *ad = data;
Evas_Object *genlist_to_set = NULL;
Evas_Object *genlist_to_unset = NULL;
genlist_to_set);
evas_object_show(genlist_to_set);
elm_toolbar_item_selected_set(event_info, EINA_TRUE);
-
- SETTING_TRACE_END;
}
static void _data_usage_sett_click_cb(void *data, Evas_Object *obj,
void *event_info)
{
- SETTING_TRACE_BEGIN;
SmartMgrData *ad = data;
ret_if(!data);
if (event_info == ad->item_wifi_data_usage_set)
setting_view_change(&smartmanager_view_data_main, ad->wifi_view, ad);
-
- SETTING_TRACE_END;
}
static void _set_warning_limit_value(Evas_Object *layout, float warn, float limit)
{
- SETTING_TRACE_BEGIN;
-
Edje_Message_Float_Set *msg = calloc(1, sizeof(Edje_Message_Float_Set) + sizeof(double));
+
+ if (!msg)
+ return;
+
msg->count = 2;
msg->val[0] = warn;
msg->val[1] = limit;
- SETTING_TRACE("SENDING");
-
edje_object_message_send(elm_layout_edje_get(layout), EDJE_MESSAGE_FLOAT_SET, MSG_ID_LIMITS, msg);
free(msg);
-
- SETTING_TRACE("SEND");
-
- SETTING_TRACE_END;
}
static void _set_progress_value(Evas_Object *layout, float value)
{
- SETTING_TRACE_BEGIN;
-
Edje_Message_Float msg = {
.val = value,
};
- SETTING_TRACE("SENDING");
-
edje_object_message_send(elm_layout_edje_get(layout), EDJE_MESSAGE_FLOAT, MSG_ID_BAR_VALUES, &msg);
-
- SETTING_TRACE("SEND");
-
- SETTING_TRACE_END;
}
static void _graph_layout_fill(SmartMgrData *ad, Evas_Object *layout,
static char *_apps_header_text_get(void *data, Evas_Object *genlist,
const char *part)
{
- SETTING_TRACE_BEGIN;
- SETTING_TRACE_END;
if (!strcmp("elm.text", part))
return strdup("Data Usage Details");
return NULL;
static Evas_Object *_aplication_item_get(
void *data, Evas_Object *genlist, const char *part)
{
- SETTING_TRACE_BEGIN;
Evas_Object *layout = NULL;
data_usage_app_item_t *app_item = data;
Evas_Object *progress_bar = NULL;
get_data_amount_str("", app_item->data_usage_bytes, buff, sizeof(buff));
elm_object_part_text_set(layout, "elm.text.sub", buff);
- SETTING_TRACE_END;
return layout;
}
Elm_Genlist_Item_Class *header_itc,
Elm_Genlist_Item_Class *app_item_itc)
{
- SETTING_TRACE_BEGIN;
Elm_Object_Item *it = NULL;
data_usage_app_item_t *app_info = NULL;
if (!genlist || !ad || !model_list) {
- SETTING_TRACE_ERROR("NULL argument");
+ SETTING_TRACE_ERROR("appending app ui item: NULL argument");
return;
}
if (!(*first_app_item))
*first_app_item = it;
-
- SETTING_TRACE_END;
}
void init_main_view(SmartMgrData *ad)
static Eina_Bool _hw_back_cb(void *data, Elm_Object_Item *it)
{
- SETTING_TRACE_BEGIN;
- retv_if(data == NULL, EINA_TRUE);
-
ui_app_exit();
- SETTING_TRACE_END;
return EINA_FALSE;
}
static void _softkey_back_cb(void *data, Evas_Object *obj, void *event_info)
{
- SETTING_TRACE_BEGIN;
SmartMgrData *ad = data;
ret_if(!ad);
elm_naviframe_item_pop(ad->md.naviframe);
- SETTING_TRACE_END;
}
static void _redraw_toolbar_buttons(SmartMgrData *ad)
{
- SETTING_TRACE_BEGIN;
elm_object_item_del(ad->toolbar_item_sim_1);
ad->toolbar_item_sim_1 = NULL;
elm_object_item_del(ad->toolbar_item_sim_2);
ad->toolbar_item_wifi = elm_toolbar_item_append(ad->toolbar, NULL, "Wi-Fi",
_toolbar_item_click, ad);
-
- SETTING_TRACE_END;
}
static void _get_data_amount_str(const char *prefix, int num_bytes,
char *txt_out, int len_max)
{
- SETTING_TRACE_BEGIN;
float amount = 0.0;
if (num_bytes < 1024) {
} else {
snprintf(txt_out, len_max, "%s%0.2fKB", prefix, amount);
}
-
- SETTING_TRACE_END;
}
static void _get_time_interval_str(const time_t from, const time_t to,
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 bool _get_total_stats(stc_iface_type_e iface_type);
static stc_callback_ret_e _get_restrictions_cb(stc_error_e result,
stc_restriction_info_h info, void *user_data);
-static void _get_restrictions(SmartMgrData *ad);
-static void _create_stats_list(stc_iface_type_e iface);
+static bool _get_restrictions(stc_iface_type_e iface_type);
+static bool _create_stats_list(stc_iface_type_e iface);
+static Eina_Bool _delayed_timer_cb(void *data);
static SmartMgrData ad = {0,};
int64_t outgoing = 0;
stc_iface_type_e iface = STC_IFACE_UNKNOWN;
+ SETTING_TRACE_DEBUG("per app cb");
+
if (STC_ERROR_NONE != result) {
SETTING_TRACE_ERROR("Error in callback: %s", get_error_message(result));
return STC_CALLBACK_CONTINUE;
get_error_message(ret));
return STC_CALLBACK_CONTINUE;
}
+ SETTING_TRACE_DEBUG("App name: %s", app_id);
ret = stc_stats_info_get_counter(info, &incoming, &outgoing);
if (ret != STC_ERROR_NONE) {
return STC_CALLBACK_CONTINUE;
}
-//Test only
-void _dbg_app_list(Eina_List *list, char *title)
-{
- SETTING_TRACE_BEGIN;
- Eina_List *l;
- data_usage_app_item_t *test_dua;
-
- SETTING_TRACE("=============================== %s: [%p] %d ===============================", title, list, eina_list_count(list));
-
- EINA_LIST_FOREACH(list, l, test_dua)
- {
- if (!test_dua) {
- SETTING_TRACE_ERROR("[%s:%d] test_dua == NULL");
- continue;
- }
-
- SETTING_TRACE("APP: %s PKG: %s icon: %s label: %s data: %lld",
- test_dua->appid, test_dua->pkgid, test_dua->icon, test_dua->label, test_dua->data_usage_bytes);
- }
-
- SETTING_TRACE("===============================-------------===============================");
-
- SETTING_TRACE_END;
-}
-
static stc_callback_ret_e _get_restrictions_cb(stc_error_e result,
stc_restriction_info_h info, void *user_data)
{
stc_iface_type_e iface_type = STC_IFACE_UNKNOWN;
stc_restriction_status_e status = STC_RESTRICTION_UNKNOWN;
+ SETTING_TRACE_DEBUG("restriction cb:");
if (STC_ERROR_NONE != result) {
SETTING_TRACE_ERROR("_get_restrictions_cb error: %s",
get_error_message(result));
}
(void)stc_restriction_info_get_app_id(info, &app_id);
-
if (!app_id ||
(strcmp("TOTAL_DATACALL", app_id) && strcmp("TOTAL_WIFI", app_id))) {
free(app_id);
return STC_CALLBACK_CONTINUE;
}
- SETTING_TRACE("Obtaining restrictions for: %s", app_id);
+ SETTING_TRACE_DEBUG("Obtaining restrictions for: %s", app_id);
free(app_id);
ret = stc_restriction_info_get_status(info, &status);
get_error_message(ret));
return STC_CALLBACK_CONTINUE;
}
-
+/*
if (STC_RESTRICTION_ACTIVATED != status) {
SETTING_TRACE("Restriction inactive %d", status);
return STC_CALLBACK_CONTINUE;
}
-
+*/
(void)stc_restriction_info_get_iface_type(info, &iface_type);
if (iface_type == STC_IFACE_DATACALL) {
return STC_CALLBACK_CONTINUE;
}
-static void _get_restrictions(SmartMgrData *ad)
+static bool _get_restrictions(stc_iface_type_e iface_type)
{
int ret = STC_ERROR_NONE;
stc_restriction_rule_h rule = NULL;
- ad->sim_1_limits.warning = 0;
- ad->sim_1_limits.limit = 0;
- ad->sim_2_limits.warning = 0;
- ad->sim_2_limits.limit = 0;
- ad->wifi_limits.warning = 0;
- ad->wifi_limits.limit = 0;
-
- ret = stc_restriction_rule_create(ad->stc, &rule);
+ ret = stc_restriction_rule_create(ad.stc, &rule);
if (STC_ERROR_NONE != ret) {
SETTING_TRACE_ERROR("stc_restriction_rule_create() error: %s",
get_error_message(ret));
- return;
+ return true;
}
- /* SIMs: */
- ret = stc_restriction_rule_set_app_id(rule, "TOTAL_DATACALL");
+
+ if (STC_IFACE_DATACALL == iface_type)
+ ret = stc_restriction_rule_set_app_id(rule, "TOTAL_DATACALL");
+ if (STC_IFACE_WIFI == iface_type)
+ ret = stc_restriction_rule_set_app_id(rule, "TOTAL_WIFI");
+
if (STC_ERROR_NONE != ret) {
SETTING_TRACE_ERROR("stc_restriction_rule_set_app_id() error: %s",
get_error_message(ret));
stc_restriction_rule_destroy(rule);
- return;
+ return true;
}
- ret = stc_restriction_rule_set_iface_type(rule, STC_IFACE_DATACALL);
+
+ ret = stc_restriction_rule_set_iface_type(rule, iface_type);
if (STC_ERROR_NONE != ret) {
SETTING_TRACE_ERROR("stc_restriction_rule_get_iface_type() error: %s",
get_error_message(ret));
stc_restriction_rule_destroy(rule);
- return;
+ return true;
}
- ret = stc_foreach_restriction(ad->stc, rule, _get_restrictions_cb, ad);
- if (STC_ERROR_NONE != ret)
- SETTING_TRACE_ERROR("SIM stc_foreach_restriction() error: %s",
- get_error_message(ret));
- /* Wifi: */
- ret = stc_restriction_rule_set_app_id(rule, "TOTAL_WIFI");
- if (STC_ERROR_NONE != ret) {
- SETTING_TRACE_ERROR("stc_restriction_rule_set_app_id() error: %s",
- get_error_message(ret));
- stc_restriction_rule_destroy(rule);
- return;
- }
- ret = stc_restriction_rule_set_iface_type(rule, STC_IFACE_WIFI);
+ SETTING_TRACE_DEBUG("Obtaining restrictions for ifce: %d", iface_type);
+ ret = stc_foreach_restriction(ad.stc, rule, _get_restrictions_cb, &ad);
if (STC_ERROR_NONE != ret) {
- SETTING_TRACE_ERROR("stc_restriction_rule_get_iface_type() error: %s",
+ SETTING_TRACE_ERROR("SIM stc_foreach_restriction() error: %s",
get_error_message(ret));
- stc_restriction_rule_destroy(rule);
- return;
+ (void)stc_restriction_rule_destroy(rule);
+ if (STC_ERROR_IN_PROGRESS == ret)
+ return false;
+ return true;
}
- ret = stc_foreach_restriction(ad->stc, rule, _get_restrictions_cb, ad);
- if (STC_ERROR_NONE != ret)
- SETTING_TRACE_ERROR("WiFi stc_foreach_restriction() error: %s",
- get_error_message(ret));
-
(void)stc_restriction_rule_destroy(rule);
+
+ return true;
}
-static void _create_stats_list(stc_iface_type_e iface)
+static bool _create_stats_list(stc_iface_type_e iface)
{
- SETTING_TRACE_BEGIN;
-
stc_stats_rule_h rule = NULL;
int 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;
+ return true;
}
if (iface == STC_IFACE_DATACALL) {
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));
- return;
+ return true;
}
ret = stc_stats_rule_set_iface_type(rule, iface);
if (ret != STC_ERROR_NONE) {
SETTING_TRACE_ERROR("stc_stats_rule_set_iface_type() error: %s", get_error_message(ret));
- return;
+ return true;
}
+ SETTING_TRACE_DEBUG("Obtaining per app data usage for ifce: %d", iface);
ret = stc_foreach_stats(ad.stc, rule, _stc_stats_info_cb, NULL);
if (ret != STC_ERROR_NONE) {
SETTING_TRACE_ERROR("stc_get_stats() error: %s", get_error_message(ret));
- return;
+ if (STC_ERROR_IN_PROGRESS == ret)
+ return false;
+ return true;
}
(void)stc_stats_rule_destroy(rule);
- SETTING_TRACE_END;
+ return true;
}
-static Eina_Bool _timer_cb(void *data)
+static Eina_Bool _delayed_timer_cb(void *data)
{
- SETTING_TRACE_BEGIN;
+ static bool wifi_stats_checked = false;
+ static bool sim_stats_checked = false;
+ static bool wifi_total_stats_checked = false;
+ static bool sim_total_stats_checked = false;
+ static bool wifi_restrictions_checked = false;
+ static bool sim_restrictions_checked = false;
+ bool tmp = false;
- _dbg_app_list(ad.wifi_apps, "WIFI APPS");
- _dbg_app_list(ad.sim_1_apps, "SIM APPS");
+ if (!wifi_stats_checked) {
+ tmp = _create_stats_list(STC_IFACE_WIFI);
+ if (tmp)
+ wifi_stats_checked = true;
+ return ECORE_CALLBACK_RENEW;
+ }
- SETTING_TRACE_END;
+ if (!sim_stats_checked) {
+ tmp = _create_stats_list(STC_IFACE_DATACALL);
+ if (tmp)
+ sim_stats_checked = true;
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ if (!wifi_total_stats_checked) {
+ tmp = _get_total_stats(STC_IFACE_WIFI);
+ if (tmp)
+ wifi_total_stats_checked = true;
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ if (!sim_total_stats_checked) {
+ tmp = _get_total_stats(STC_IFACE_DATACALL);
+ if (tmp)
+ sim_total_stats_checked = true;
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ if (!wifi_restrictions_checked) {
+ tmp = _get_restrictions(STC_IFACE_WIFI);
+ if (tmp)
+ wifi_restrictions_checked = true;
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ if (!sim_restrictions_checked) {
+ tmp = _get_restrictions(STC_IFACE_DATACALL);
+ if (tmp)
+ sim_restrictions_checked = true;
+ return ECORE_CALLBACK_RENEW;
+ }
return ECORE_CALLBACK_CANCEL;
}
SETTING_TRACE("_create_app");
-
bindtextdomain(SETTING_PACKAGE, SETTING_LOCALEDIR);
ret = telephony_init(&ad->telephony_handles);
ad->main_view_update_type = MV_UPDATE_CLEAR_ALL_WIFI_APPS;
setting_view_update(ad->main_view, ad);
- _create_stats_list(STC_IFACE_WIFI);
ad->main_view_update_type = MV_UPDATE_CLEAR_ALL_SIM_1_APPS;
setting_view_update(ad->main_view, ad);
ad->main_view_update_type = MV_UPDATE_CLEAR_ALL_SIM_2_APPS;
setting_view_update(ad->main_view, ad);
- _create_stats_list(STC_IFACE_DATACALL);
- _get_total_stats(ad);
- _get_restrictions(ad);
- ecore_timer_add(3.0, _timer_cb, NULL);
+ if (!ecore_timer_add(1.0, _delayed_timer_cb, NULL))
+ SETTING_TRACE_ERROR("delayed_timer creation failure");
SETTING_TRACE_END;
return true;
data_usage_app_item_t *dua = calloc(1, sizeof(data_usage_app_item_t));
app_info_h app_info = NULL;
+ if (!dua)
+ return false;
+
int ret = app_info_create(app_id, &app_info);
if (ret != APP_MANAGER_ERROR_NONE) {
- SETTING_TRACE_ERROR("app_info_create() error: %s", get_error_message(ret));
+ SETTING_TRACE_ERROR("app_info_create() for %s error: %s",
+ app_id, get_error_message(ret));
_delete_stat_item(dua);
return false;
}
int64_t outgoing = 0;
int ret = STC_ERROR_NONE;
stc_iface_type_e iface_type = STC_IFACE_UNKNOWN;
- SETTING_TRACE("Obtaining total stats");
+
+ SETTING_TRACE_DEBUG("total stats cb");
if (STC_ERROR_NONE != result) {
SETTING_TRACE_ERROR("Error in cb: %s", get_error_message(result));
return STC_CALLBACK_CONTINUE;
}
-static void _get_total_stats(SmartMgrData *ad)
+static bool _get_total_stats(stc_iface_type_e iface_type)
{
stc_stats_rule_h rule = NULL;
time_t now = time(NULL);
int ret = STC_ERROR_NONE;
- ret = stc_stats_rule_create(ad->stc, &rule);
+ 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;
+ return true;
}
ret = stc_stats_rule_set_time_interval(rule,
SETTING_TRACE_ERROR("stc_stats_rule_set_time_interval() error: %s",
get_error_message(ret));
(void)stc_stats_rule_destroy(rule);
- return;
+ return true;
}
- ret = stc_stats_rule_set_iface_type(rule, STC_IFACE_DATACALL);
+ ret = stc_stats_rule_set_iface_type(rule, iface_type);
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;
+ return true;
}
- (void)stc_get_total_stats(ad->stc, rule, _total_stats_cb, ad);
- ret = stc_stats_rule_set_iface_type(rule, STC_IFACE_WIFI);
+ SETTING_TRACE_DEBUG("Obtaining total stats for ifce: %d", iface_type);
+ ret = stc_get_total_stats(ad.stc, rule, _total_stats_cb, &ad);
if (ret != STC_ERROR_NONE) {
- SETTING_TRACE_ERROR("stc_stats_rule_set_iface_type() error: %s",
- get_error_message(ret));
+ SETTING_TRACE_ERROR("stc_get_total_stats() error: %s",
+ get_error_message(ret));
(void)stc_stats_rule_destroy(rule);
- return;
+ if (STC_ERROR_IN_PROGRESS == ret)
+ return false;
+ return true;
}
- (void)stc_get_total_stats(ad->stc, rule, _total_stats_cb, ad);
(void)stc_stats_rule_destroy(rule);
+
+ return true;
}