[SM][Mob]Genlist and restrictions refactoring 52/155252/4
authorPawel Aksiutowicz <p.aksiutowic@partner.samsung.com>
Thu, 12 Oct 2017 11:56:56 +0000 (13:56 +0200)
committerPawel Aksiutowicz <p.aksiutowic@partner.samsung.com>
Fri, 13 Oct 2017 09:26:34 +0000 (11:26 +0200)
Change-Id: I2cde59a39e8a3305cc9858afd9d9427b46e2a41e
Signed-off-by: Pawel Aksiutowicz <p.aksiutowic@partner.samsung.com>
setting-smartmanager/smartmanager-data/include/smartmanager-utils.h
setting-smartmanager/smartmanager-data/src/smartmanager-data-usage-mobile-settings.c
setting-smartmanager/smartmanager-data/src/smartmanager-utils.c

index 9de3f3738db93b0f7f796961face8111426c6898..842ae2953709a5682e51a9c62a2ad7068aeb0b8b 100644 (file)
@@ -25,8 +25,6 @@
 #include <stdbool.h>
 #include <telephony.h>
 
-#define MAX_LIMIT_IN_BYTES (((int64_t)LONG_MAX+1)*50)
-
 typedef enum {
        DATA_RESTRICTION_LIMIT,
        DATA_RESTRICTION_WARNING_LIMIT
@@ -34,9 +32,7 @@ typedef enum {
 
 typedef enum {
        RESTRICTIONS_OK = 0,
-       RESTRICTIONS_VALUE_HIGHER_THAN_LIMIT = 1,
-       RESTRICTIONS_VALUE_HIGHTER_THAN_MAX = 2,
-       RESTRICTIONS_OTHER_ERROR = 3
+       RESTRICTIONS_ERROR = 1
 } restrictions_result;
 
 void get_data_amount_str(const char *prefix, int64_t num_bytes, char *txt_out,
index 3ae37c83e50801104c3a62c0a2b61953aa15fa84..b8a4af0ff06731eb2b4d5c75577adab2e16aeac5 100755 (executable)
@@ -6,38 +6,35 @@
 #include <efl_extension_events.h>
 #include <math.h>
 
+#define MAX_LIMIT_IN_BYTES (((int64_t)LONG_MAX+1)*50)
+
 static int _create(void *data);
 static int _destroy(void *data);
 static int _update(void* data);
 static int _cleanup();
 
-void complement_data_usage_mobile_genlist(Evas_Object *mobile_genlist,
-               SmartMgrData *smd);
-
-static void _update_genlist_warning_item(SmartMgrData *smd);
-static void _update_genlist_limit_item(SmartMgrData *smd);
-static void _update_genlist_cycle_item(SmartMgrData *smd);
-static void _update_genlist_start_date_item(SmartMgrData *smd);
-static void _update_genlist_info_item(SmartMgrData *smd);
-
 static void _create_warning_popup(void *data, Evas_Object *obj, void *event_info);
 static void _create_limit_popup(void *data, Evas_Object *obj, void *event_info);
 static void _create_cycle_list_popup(void *data, Evas_Object *obj, void *event_info);
 
 static void _create_monthly_start_date_popup(void *data, Evas_Object *obj, void *event_info);
-static void _create_start_date_list_popup(void *data, Evas_Object *obj, void *event_info);
+static void _create_start_weekday_list_popup(void *data, Evas_Object *obj, void *event_info);
 static void create_custom_start_date_popup(void *data, Evas_Object *obj, void *event_info);
 
 static Evas_Object *_genlist_cycle_radio_content_get(void *data, Evas_Object *obj, const char *part);
-static Evas_Object *_genlist_start_date_radio_content_get(void *data, Evas_Object *obj, const char *part);
+static Evas_Object *_genlist_start_weekday_radio_content_get(void *data, Evas_Object *obj, const char *part);
 static char *_genlist_radio_text_get(void *data, Evas_Object *obj, const char *part);
 static void _genlist_radio_del(void *data, Evas_Object *obj);
 
 static void _softkey_back_cb(void *data, Evas_Object *obj,
                void *event_info);
 static Eina_Bool _pop_view_cb(void *data, Elm_Object_Item *it);
-static char *_item_label_get(void *data, Evas_Object *obj, const char *part);
-static char *_last_item_label_get(void *data, Evas_Object *obj, const char *part);
+
+static char *_warning_item_label_get(void *data, Evas_Object *obj, const char *part);
+static char *_limit_item_label_get(void *data, Evas_Object *obj, const char *part);
+static char *_cycle_item_label_get(void *data, Evas_Object *obj, const char *part);
+static char *_start_date_item_label_get(void *data, Evas_Object *obj, const char *part);
+static char *_description_item_label_get(void *data, Evas_Object *obj, const char *part);
 
 setting_view sm_view_data_usage_mobile;
 
@@ -53,14 +50,6 @@ typedef enum {
        DATA_UNIT_TYPE_GB = 3,
 } Data_Unit_Type_E;
 
-typedef enum {
-       ELEMENT_TYPE_WARNING = 0,
-       ELEMENT_TYPE_LIMIT,
-       ELEMENT_TYPE_CYCLE,
-       ELEMENT_TYPE_START_DATE,
-       ELEMENT_TYPE_INFO
-} Element_Type_E;
-
 typedef enum {
        DATE_MIN = 0,
        DATE_MAX,
@@ -73,27 +62,12 @@ typedef struct {
        int radio_value;
 } Radio_List_Item_T;
 
-typedef struct {
-       const char *name;
-       char *value;
-       Evas_Smart_Cb function;
-       SmartMgrData *smd;
-} Element;
-
 typedef struct {
        Evas_Object *popup;
        Evas_Object *content;
        Data_Unit_Type_E unit;
 } Popup_Info;
 
-static char *elements_initial_values[] = {
-               "None",
-               "None",
-               "Monthly",
-               "1",
-               "The data usage info will be reset on the 1st day of every month."
-};
-
 static char *elements_info_initial_values[] = {
                "The data usage info will be reset on the 1st day of every month.",
                "The data usage info will be reset every %s.",
@@ -118,42 +92,42 @@ static char *elements_cycle_day_of_week[] = {
                "Sunday"
 };
 
-static char *elements_start_time_initial_values[] = {
-               "1",
-               "Monday",
-               NULL,
-               "Mon, 01/01/2016"
-};
-
 static Evas_Smart_Cb create_start_popup_functions[] = {
                _create_monthly_start_date_popup,
-               _create_start_date_list_popup,
+               _create_start_weekday_list_popup,
                NULL,
                create_custom_start_date_popup
 };
 
-static Element elements[] = {
-               {"Warning level",       NULL, _create_warning_popup,    NULL},
-               {"Limit",                       NULL, _create_limit_popup,      NULL},
-               {"Cycle",                       NULL, _create_cycle_list_popup, NULL},
-               {"Start date",          NULL, NULL,     NULL},
-               {"",                            NULL, NULL,     NULL}
-};
-
 static Popup_Info popup_info = {0,};
 
-static Evas_Object *mobile_data_setting_genlist = NULL;
+static Evas_Object *mobile_genlist = NULL;
 static Evas_Object *cycle_mode_radio_group = NULL;
 static Evas_Object *start_weekday_radio_group = NULL;
 
-static Elm_Genlist_Item_Class itc_genlist_element = {
+static Elm_Genlist_Item_Class itc_warning_element = {
+       .item_style = "type2",
+       .func.text_get = _warning_item_label_get
+};
+
+static Elm_Genlist_Item_Class itc_limit_element = {
+       .item_style = "type2",
+       .func.text_get = _limit_item_label_get
+};
+
+static Elm_Genlist_Item_Class itc_cycle_element = {
        .item_style = "type2",
-       .func.text_get = _item_label_get
+       .func.text_get = _cycle_item_label_get
 };
 
-static Elm_Genlist_Item_Class itc_genlist_last_element = {
+static Elm_Genlist_Item_Class itc_start_date_element = {
+       .item_style = "type2",
+       .func.text_get = _start_date_item_label_get
+};
+
+static Elm_Genlist_Item_Class itc_description_element = {
                .item_style = "multiline",
-               .func.text_get = _last_item_label_get
+               .func.text_get = _description_item_label_get
 };
 
 static Elm_Genlist_Item_Class itc_cycle_list = {
@@ -163,9 +137,9 @@ static Elm_Genlist_Item_Class itc_cycle_list = {
                .func.del = _genlist_radio_del
 };
 
-static Elm_Genlist_Item_Class itc_start_date_list = {
+static Elm_Genlist_Item_Class itc_start_weekday_list = {
                .item_style = "type1",
-               .func.content_get = _genlist_start_date_radio_content_get,
+               .func.content_get = _genlist_start_weekday_radio_content_get,
                .func.text_get = _genlist_radio_text_get,
                .func.del = _genlist_radio_del
 };
@@ -179,40 +153,28 @@ static Elm_Entry_Filter_Limit_Size limit_size = {
                .max_char_count = 9
 };
 
-void complement_data_usage_mobile_genlist(Evas_Object *mobile_genlist, SmartMgrData *smd)
+void generate_list(Evas_Object *genlist, SmartMgrData *smd)
 {
-       int i = 0;
        Elm_Object_Item *last_item = NULL;
 
-       elm_genlist_mode_set(mobile_genlist, ELM_LIST_COMPRESS);
-       elm_genlist_clear(mobile_genlist);
-
-       _update_genlist_warning_item(smd);
-       _update_genlist_limit_item(smd);
-       _update_genlist_cycle_item(smd);
-       _update_genlist_start_date_item(smd);
-
-       elements[ELEMENT_TYPE_START_DATE].function = create_start_popup_functions[smd->selected_sim_limits->cycle_mode];
-
-       for (i = 0; i < EINA_C_ARRAY_LENGTH(elements)-1; i++) {
-               elements[i].smd = smd;
-               if (elements[i].value) {
-                       elm_genlist_item_append(mobile_genlist, &itc_genlist_element,
-                               &elements[i], NULL, ELM_GENLIST_ITEM_NONE, elements[i].function,
-                               smd);
-               }
-       }
+       elm_genlist_clear(genlist);
+       elm_genlist_item_append(genlist, &itc_warning_element,
+                       smd, NULL, ELM_GENLIST_ITEM_NONE, _create_warning_popup , smd);
+       elm_genlist_item_append(genlist, &itc_limit_element,
+                       smd, NULL, ELM_GENLIST_ITEM_NONE, _create_limit_popup, smd);
+       elm_genlist_item_append(genlist, &itc_cycle_element,
+                       smd, NULL, ELM_GENLIST_ITEM_NONE, _create_cycle_list_popup, smd);
 
-       _update_genlist_info_item(smd);
-       elements[EINA_C_ARRAY_LENGTH(elements)-1].smd = smd;
+       if (smd->selected_sim_limits->cycle_mode != CYCLE_MODE_DAILY)
+               elm_genlist_item_append(genlist, &itc_start_date_element,
+                       smd, NULL, ELM_GENLIST_ITEM_NONE, create_start_popup_functions[smd->selected_sim_limits->cycle_mode], smd);
 
-       last_item = elm_genlist_item_append(mobile_genlist,
-               &itc_genlist_last_element, &elements[EINA_C_ARRAY_LENGTH(elements)-1],
-               NULL, ELM_GENLIST_ITEM_NONE, NULL,
-               &elements[EINA_C_ARRAY_LENGTH(elements)-1]);
+       last_item = elm_genlist_item_append(genlist, &itc_description_element,
+                       smd, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
        elm_genlist_item_select_mode_set(last_item, ELM_OBJECT_SELECT_MODE_NONE);
 
        evas_object_show(mobile_genlist);
+
 }
 
 static Evas_Object *_create_popup_button(Evas_Object *parent, char *part, char *title, float weight_x, float weight_y, Evas_Smart_Cb cb, void *callback_data)
@@ -270,7 +232,7 @@ static stc_callback_ret_e _get_and_unset_limit_restrictions_cb(stc_error_e resul
        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;
+       restrictions_result restrictions_res = RESTRICTIONS_ERROR;
        SmartMgrData *smd = (SmartMgrData *)user_data;
 
        SETTING_TRACE_DEBUG("_get_restrictions_to_unset_cb:");
@@ -439,6 +401,26 @@ void write_cycle_interval(SmartMgrData *smd)
        }
 }
 
+void write_cycle_mode(SmartMgrData *smd)
+{
+       if (smd->selected_sim_subscriber_id == smd->subscriber_id_1)  {
+               write_sim_1_cycle_mode(smd->selected_sim_limits->cycle_mode);
+       }
+       if (smd->selected_sim_subscriber_id == smd->subscriber_id_2) {
+               write_sim_2_cycle_mode(smd->selected_sim_limits->cycle_mode);
+       }
+}
+
+void write_cycle_start(SmartMgrData *smd)
+{
+       if (smd->selected_sim_subscriber_id == smd->subscriber_id_1)  {
+               write_sim_1_cycle_start(smd->selected_sim_limits->cycle_start);
+       }
+       if (smd->selected_sim_subscriber_id == smd->subscriber_id_2)  {
+               write_sim_2_cycle_start(smd->selected_sim_limits->cycle_start);
+       }
+}
+
 static void _custom_cycle_popup_ok_cb(void *data, Evas_Object *obj,
                void *event_info)
 {
@@ -463,9 +445,7 @@ static void _custom_cycle_popup_ok_cb(void *data, Evas_Object *obj,
                }
                if (value >= 1 && value <= 90) {
                        smd->selected_sim_limits->custom_mode_interval = value;
-                       complement_data_usage_mobile_genlist(
-                                                       mobile_data_setting_genlist,
-                                                       smd);
+                       elm_genlist_realized_items_update(mobile_genlist);
 
                        write_cycle_interval(smd);
 
@@ -515,26 +495,6 @@ static struct tm _get_margin_date(margin_date_type date_type)
        return time_tm;
 }
 
-void write_cycle_mode(SmartMgrData *smd)
-{
-       if (smd->selected_sim_subscriber_id == smd->subscriber_id_1)  {
-               write_sim_1_cycle_mode(smd->selected_sim_limits->cycle_mode);
-       }
-       if (smd->selected_sim_subscriber_id == smd->subscriber_id_2) {
-               write_sim_2_cycle_mode(smd->selected_sim_limits->cycle_mode);
-       }
-}
-
-void write_cycle_start(SmartMgrData *smd)
-{
-       if (smd->selected_sim_subscriber_id == smd->subscriber_id_1)  {
-               write_sim_1_cycle_start(smd->selected_sim_limits->cycle_start);
-       }
-       if (smd->selected_sim_subscriber_id == smd->subscriber_id_2)  {
-               write_sim_2_cycle_start(smd->selected_sim_limits->cycle_start);
-       }
-}
-
 static void _custom_start_date_popup_ok_cb(void *data, Evas_Object *obj,
                void *event_info)
 {
@@ -571,7 +531,7 @@ static void _custom_start_date_popup_ok_cb(void *data, Evas_Object *obj,
        }
        if (set_date >= min_date_time_t && set_date <= max_date_time_t) {
                smd->selected_sim_limits->cycle_start = set_date;
-               complement_data_usage_mobile_genlist(mobile_data_setting_genlist, smd);
+               elm_genlist_realized_items_update(mobile_genlist);
 
                write_cycle_mode(smd);
                write_cycle_start(smd);
@@ -580,26 +540,6 @@ static void _custom_start_date_popup_ok_cb(void *data, Evas_Object *obj,
        }
 }
 
-static void handle_limit_warning_set_result(restrictions_result result,
-               int64_t *limit_to_set, int64_t value)
-{
-       switch (result) {
-       case RESTRICTIONS_VALUE_HIGHTER_THAN_MAX:
-               create_toast_popup(popup_info.popup,
-                       "Maximum value allowed is 100GB. Value changed to 100GB");
-               *limit_to_set = MAX_LIMIT_IN_BYTES;
-               break;
-       case RESTRICTIONS_VALUE_HIGHER_THAN_LIMIT:
-               create_toast_popup(popup_info.popup,
-                       "Value must be lower than limit value");
-               break;
-       default:
-               *limit_to_set = (int64_t)value;
-               evas_object_del(popup_info.popup);
-               break;
-       }
-}
-
 static void _warning_popup_done_cb(void *data, Evas_Object *obj, void *event_info)
 {
        SmartMgrData *smd = (SmartMgrData *)data;
@@ -612,21 +552,33 @@ static void _warning_popup_done_cb(void *data, Evas_Object *obj, void *event_inf
        value *= pow(1024, popup_info.unit);
        strncpy(unit_name, popup_info.unit == DATA_UNIT_TYPE_MB ? "MB" : "GB", sizeof(unit_name));
 
-       restrictions_result res = RESTRICTIONS_OTHER_ERROR;
-
-       if (value == 0) {
-               unset_mobile_limit_restrictions(smd->stc, _get_and_unset_limit_restrictions_cb, smd);
+       if (value > 0) {
+               if (value <= MAX_LIMIT_IN_BYTES) {
+                       if (value <= smd->selected_sim_limits->limit) {
+                               if (set_mobile_limit_restrictions(smd->stc,
+                                                               smd->selected_sim_subscriber_id,
+                                                               smd->selected_sim_limits->limit,
+                                                               (int64_t)value) == RESTRICTIONS_ERROR)
+                                       SETTING_TRACE_ERROR("Warning limit not writen to stc.");
+
+                               smd->selected_sim_limits->warning = (int64_t)value;
+                               evas_object_del(popup_info.popup);
+                       } else {
+                               create_toast_popup(popup_info.popup,
+                                       "Value must be lower than limit value");
+                       }
+               } else {
+                       create_toast_popup(popup_info.popup,
+                               "Maximum value allowed is 100GB. Value changed to 100GB");
+                               smd->selected_sim_limits->warning = MAX_LIMIT_IN_BYTES;
+                               _entry_set_displayed_value(smd->selected_sim_limits->warning, popup_info.unit);
+               }
        } else {
-               res = set_mobile_limit_restrictions(
-                                       smd->stc,
-                                       smd->selected_sim_subscriber_id,
-                                       smd->selected_sim_limits->limit,
-                                       (int64_t)value);
+               unset_mobile_limit_restrictions(smd->stc, _get_and_unset_limit_restrictions_cb, smd);
+               evas_object_del(popup_info.popup);
        }
 
-       handle_limit_warning_set_result(res, &smd->selected_sim_limits->warning, value);
-
-       _update_genlist_warning_item(smd);
+       elm_genlist_realized_items_update(mobile_genlist);
 }
 
 static void _create_warning_popup(void *data, Evas_Object *obj, void *event_info)
@@ -668,21 +620,28 @@ static void _limit_popup_done_cb(void *data, Evas_Object *obj, void *event_info)
        value *= pow(1024, popup_info.unit);
        strncpy(unit_name, popup_info.unit == DATA_UNIT_TYPE_MB ? "MB" : "GB", sizeof(unit_name));
 
-       restrictions_result res = RESTRICTIONS_OTHER_ERROR;
+       if (value > 0) {
+               if (value <= MAX_LIMIT_IN_BYTES) {
+                       if (set_mobile_limit_restrictions(smd->stc,
+                                               smd->selected_sim_subscriber_id,
+                                               (int64_t)value,
+                                               smd->selected_sim_limits->warning) == RESTRICTIONS_ERROR)
+                               SETTING_TRACE_ERROR("Limit not writen to stc.");
+                       smd->selected_sim_limits->limit = (int64_t)value;
+                       evas_object_del(popup_info.popup);
+               } else {
+                       create_toast_popup(popup_info.popup,
+                               "Maximum value allowed is 100GB. Value changed to 100GB");
+                               smd->selected_sim_limits->limit = MAX_LIMIT_IN_BYTES;
+                       _entry_set_displayed_value(smd->selected_sim_limits->limit, popup_info.unit);
+               }
 
-       if (value == 0) {
-               unset_mobile_limit_restrictions(smd->stc, _get_and_unset_limit_restrictions_cb, smd);
        } else {
-               res = set_mobile_limit_restrictions(
-                                       smd->stc,
-                                       smd->selected_sim_subscriber_id,
-                                       (int64_t)value,
-                                       smd->selected_sim_limits->warning);
+               unset_mobile_limit_restrictions(smd->stc, _get_and_unset_limit_restrictions_cb, smd);
+               evas_object_del(popup_info.popup);
        }
 
-       handle_limit_warning_set_result(res, &smd->selected_sim_limits->limit, value);
-
-       _update_genlist_limit_item(smd);
+       elm_genlist_realized_items_update(mobile_genlist);
 }
 
 static void _create_limit_popup(void *data, Evas_Object *obj, void *event_info)
@@ -740,7 +699,8 @@ void _radio_cycle_list_item_selected_cb(void *data, Evas_Object *obj, void *even
                elm_radio_value_set(cycle_mode_radio_group, item_data->smd->selected_sim_limits->cycle_mode);
        }
 
-       complement_data_usage_mobile_genlist(mobile_data_setting_genlist, item_data->smd);
+       generate_list(mobile_genlist, item_data->smd);
+       elm_genlist_realized_items_update(mobile_genlist);
 
        if (item_data->smd->selected_sim_limits->cycle_mode == CYCLE_MODE_CUSTOM)
                _create_custom_cycle_popup(item_data->smd, "Set data usage cycle", item_data->smd->selected_sim_limits->custom_mode_interval);
@@ -784,7 +744,8 @@ static void _radio_cycle_selected_cb(void *data, Evas_Object *obj, void *event_i
                elm_radio_value_set(cycle_mode_radio_group, item_data->smd->selected_sim_limits->cycle_mode);
        }
 
-       complement_data_usage_mobile_genlist(mobile_data_setting_genlist, item_data->smd);
+       generate_list(mobile_genlist, item_data->smd);
+       elm_genlist_realized_items_update(mobile_genlist);
 
        if (item_data->smd->selected_sim_limits->cycle_mode == CYCLE_MODE_CUSTOM)
                _create_custom_cycle_popup(item_data->smd, "Set data usage cycle", item_data->smd->selected_sim_limits->custom_mode_interval);
@@ -840,19 +801,11 @@ static void _create_cycle_list_popup(void *data, Evas_Object *obj, void *event_i
 
 static void _monthly_start_date_popup_done_cb(void *data, Evas_Object *obj, void *event_info)
 {
-       char buf[256];
        SmartMgrData *smd = (SmartMgrData *)data;
 
        smd->selected_sim_limits->cycle_start =
                        elm_spinner_value_get(popup_info.content);
-
-       free(elements[ELEMENT_TYPE_START_DATE].value);
-
-       snprintf(buf, sizeof(buf), "%d",
-                       smd->selected_sim_limits->cycle_start);
-       elements[ELEMENT_TYPE_START_DATE].value = strdup(buf);
-       elm_genlist_realized_items_update(
-                       mobile_data_setting_genlist);
+       elm_genlist_realized_items_update(mobile_genlist);
 
        write_cycle_mode(smd);
        write_cycle_start(smd);
@@ -888,13 +841,13 @@ static void _create_monthly_start_date_popup(void *data, Evas_Object *obj, void
        evas_object_show(popup_info.popup);
 }
 
-void _radio_start_date_list_item_selected_cb(void *data, Evas_Object *obj, void *event_info)
+void _radio_start_weekday_list_item_selected_cb(void *data, Evas_Object *obj, void *event_info)
 {
        Radio_List_Item_T *item_data = (Radio_List_Item_T *)data;
        item_data->smd->selected_sim_limits->cycle_start = item_data->radio_value;
        elm_radio_value_set(start_weekday_radio_group, item_data->smd->selected_sim_limits->cycle_start);
 
-       _update_genlist_start_date_item(item_data->smd);
+       elm_genlist_realized_items_update(mobile_genlist);
 
        evas_object_del(item_data->popup);
 
@@ -902,19 +855,19 @@ void _radio_start_date_list_item_selected_cb(void *data, Evas_Object *obj, void
        write_cycle_start(item_data->smd);
 }
 
-static void _radio_start_date_selected_cb(void *data, Evas_Object *obj, void *event_info)
+static void _radio_start_weekday_selected_cb(void *data, Evas_Object *obj, void *event_info)
 {
        Radio_List_Item_T *item_data = (Radio_List_Item_T *)data;
 
        item_data->smd->selected_sim_limits->cycle_start = item_data->radio_value;
        elm_radio_value_set(start_weekday_radio_group, item_data->smd->selected_sim_limits->cycle_start);
 
-       complement_data_usage_mobile_genlist(mobile_data_setting_genlist, item_data->smd);
+       elm_genlist_realized_items_update(mobile_genlist);
 
        evas_object_del(item_data->popup);
 }
 
-static Evas_Object *_genlist_start_date_radio_content_get(void *data, Evas_Object *obj, const char *part)
+static Evas_Object *_genlist_start_weekday_radio_content_get(void *data, Evas_Object *obj, const char *part)
 {
        int len = strlen("elm.swallow.end");
        Evas_Object *radio = NULL;
@@ -928,7 +881,7 @@ static Evas_Object *_genlist_start_date_radio_content_get(void *data, Evas_Objec
 
        elm_radio_group_add(radio, start_weekday_radio_group);
        elm_radio_state_value_set(radio, item_data->radio_value);
-       evas_object_smart_callback_add(radio, "changed", _radio_start_date_selected_cb, data);
+       evas_object_smart_callback_add(radio, "changed", _radio_start_weekday_selected_cb, data);
        if (item_data->radio_value == item_data->smd->selected_sim_limits->cycle_start)
                elm_radio_value_set(start_weekday_radio_group, item_data->smd->selected_sim_limits->cycle_start);
 
@@ -938,7 +891,7 @@ static Evas_Object *_genlist_start_date_radio_content_get(void *data, Evas_Objec
        return radio;
 }
 
-static void _create_start_date_list_popup(void *data, Evas_Object *obj, void *event_info)
+static void _create_start_weekday_list_popup(void *data, Evas_Object *obj, void *event_info)
 {
        SmartMgrData *smd = (SmartMgrData *)data;
        Elm_Object_Item *item = (Elm_Object_Item *)event_info;
@@ -952,8 +905,8 @@ static void _create_start_date_list_popup(void *data, Evas_Object *obj, void *ev
        elm_radio_value_set(start_weekday_radio_group, smd->selected_sim_limits->cycle_mode);
 
        for (i = 0; i < EINA_C_ARRAY_LENGTH(elements_cycle_day_of_week); ++i) {
-               _append_item_to_radio_list(smd, popup, genlist, &itc_start_date_list, elements_cycle_day_of_week[i],
-                               i+1, !i, _radio_start_date_list_item_selected_cb);
+               _append_item_to_radio_list(smd, popup, genlist, &itc_start_weekday_list, elements_cycle_day_of_week[i],
+                               i+1, !i, _radio_start_weekday_list_item_selected_cb);
        }
 }
 
@@ -978,103 +931,6 @@ static void create_custom_start_date_popup(void *data, Evas_Object *obj, void *e
        evas_object_show(popup_info.popup);
 }
 
-static void _update_genlist_warning_item(SmartMgrData *smd)
-{
-       char buf[256] = {0};
-
-       if (smd->selected_sim_limits->warning > 0) {
-               get_data_amount_str("", smd->selected_sim_limits->warning, buf, sizeof(buf));
-               elements[ELEMENT_TYPE_WARNING].value = strdup(buf);
-       } else {
-               elements[ELEMENT_TYPE_WARNING].value = elements_initial_values[ELEMENT_TYPE_WARNING];
-       }
-
-       elm_genlist_realized_items_update(mobile_data_setting_genlist);
-}
-
-static void _update_genlist_limit_item(SmartMgrData *smd)
-{
-       char buf[256] = {0};
-
-       if (smd->selected_sim_limits->limit > 0) {
-               get_data_amount_str("", smd->selected_sim_limits->limit, buf, sizeof(buf));
-               elements[ELEMENT_TYPE_LIMIT].value = strdup(buf);
-       } else {
-               elements[ELEMENT_TYPE_LIMIT].value = elements_initial_values[ELEMENT_TYPE_LIMIT];
-       }
-
-       elm_genlist_realized_items_update(mobile_data_setting_genlist);
-}
-
-static void _update_genlist_cycle_item(SmartMgrData *smd)
-{
-       char buf[256] = {0};
-
-       free(elements[ELEMENT_TYPE_CYCLE].value);
-
-       if (smd->selected_sim_limits->custom_mode_interval && smd->selected_sim_limits->cycle_mode == CYCLE_MODE_CUSTOM) {
-               snprintf(buf, sizeof(buf), "%d Days", smd->selected_sim_limits->custom_mode_interval);
-               elements[ELEMENT_TYPE_CYCLE].value = strdup(buf);
-       } else {
-               elements[ELEMENT_TYPE_CYCLE].value = strdup(elements_cycle_initial_values[smd->selected_sim_limits->cycle_mode]);
-       }
-
-       elm_genlist_realized_items_update(mobile_data_setting_genlist);
-}
-
-static void _update_genlist_start_date_item(SmartMgrData *smd)
-{
-       char buf[256] = {0};
-       struct tm min_date = {0};
-       struct tm *time = {0};
-
-       free(elements[ELEMENT_TYPE_START_DATE].value);
-
-       if (smd->selected_sim_limits->cycle_start > 1) {
-               switch (smd->selected_sim_limits->cycle_mode) {
-               case CYCLE_MODE_MONTHLY:
-                       snprintf(buf, sizeof(buf), "%d", smd->selected_sim_limits->cycle_start);
-                       elements[ELEMENT_TYPE_START_DATE].value = strdup(buf);
-                       break;
-               case CYCLE_MODE_WEEKLY:
-                       elements[ELEMENT_TYPE_START_DATE].value =
-                       strdup(elements_cycle_day_of_week[smd->selected_sim_limits->cycle_start-1]);
-                       break;
-               case CYCLE_MODE_DAILY:
-                       break;
-               case CYCLE_MODE_CUSTOM:
-                       time = localtime((time_t*)&smd->selected_sim_limits->cycle_start);
-                       strftime(buf, sizeof(buf), date_format, time);
-                       elements[ELEMENT_TYPE_START_DATE].value = strdup(buf);
-                       break;
-               }
-       } else {
-               if (smd->selected_sim_limits->cycle_mode == CYCLE_MODE_CUSTOM) {
-                       min_date = _get_margin_date(DATE_MIN);
-                       smd->selected_sim_limits->cycle_start = (int)mktime(&min_date);
-                       strftime(buf, sizeof(buf), date_format, &min_date);
-                       elements[ELEMENT_TYPE_START_DATE].value = strdup(buf);
-               } else {
-                       if (elements_start_time_initial_values[smd->selected_sim_limits->cycle_mode]) {
-                               elements[ELEMENT_TYPE_START_DATE].value = strdup(elements_start_time_initial_values[smd->selected_sim_limits->cycle_mode]);
-                       } else {
-                               elements[ELEMENT_TYPE_START_DATE].value = NULL;
-                       }
-               }
-       }
-
-       elm_genlist_realized_items_update(mobile_data_setting_genlist);
-}
-
-static void _update_genlist_info_item(SmartMgrData *smd)
-{
-       free(elements[ELEMENT_TYPE_INFO].value);
-
-       elements[ELEMENT_TYPE_INFO].value = strdup(elements_info_initial_values[smd->selected_sim_limits->cycle_mode]);
-
-       elm_genlist_realized_items_update(mobile_data_setting_genlist);
-}
-
 static int _create(void *data)
 {
        SmartMgrData *smd = (SmartMgrData *)data;
@@ -1085,10 +941,10 @@ static int _create(void *data)
        elm_object_style_set(back_btn, NAVI_BACK_ARROW_BUTTON_STYLE);
        evas_object_smart_callback_add(back_btn, "clicked", _softkey_back_cb, smd);
 
-       mobile_data_setting_genlist = elm_genlist_add(smd->md.naviframe);
-       complement_data_usage_mobile_genlist(mobile_data_setting_genlist, smd);
+       mobile_genlist = elm_genlist_add(smd->md.naviframe);
+       generate_list(mobile_genlist, smd);
 
-       nf_it = elm_naviframe_item_push(smd->md.naviframe, data_usage_mobile_strings[0], back_btn, NULL, mobile_data_setting_genlist, NULL);
+       nf_it = elm_naviframe_item_push(smd->md.naviframe, data_usage_mobile_strings[0], back_btn, NULL, mobile_genlist, NULL);
        elm_naviframe_item_style_set(nf_it, "tabbar");
        elm_naviframe_item_pop_cb_set(nf_it, _pop_view_cb, smd);
 
@@ -1110,7 +966,7 @@ static int _update(void* data)
        SmartMgrData *smd = (SmartMgrData *)data;
        retv_if(NULL == smd, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
 
-       complement_data_usage_mobile_genlist(mobile_data_setting_genlist, smd);
+       generate_list(mobile_genlist, smd);
 
        return 0;
 }
@@ -1155,25 +1011,125 @@ static Eina_Bool _pop_view_cb(void *data, Elm_Object_Item *it)
        return EINA_TRUE;
 }
 
-static char *_item_label_get(void *data, Evas_Object *obj, const char *part)
+static char *_warning_item_label_get(void *data, Evas_Object *obj, const char *part)
 {
-       Element *element = (Element*)data;
-       retv_if(!element, NULL);
+       char buf[256] = {0};
+       SmartMgrData *smd = (SmartMgrData *)data;
+       retv_if(!smd, NULL);
+
+       if (!strcmp(part, "elm.text")) {
+               if (smd->selected_sim_limits->warning > 0) {
+                       get_data_amount_str("", smd->selected_sim_limits->warning, buf, sizeof(buf));
+               } else {
+                       snprintf(buf, sizeof(buf), "%s", "None");
+               }
+
+               return strdup(buf);
+       }
+       if (!strcmp(part, "elm.text.sub")) {
+               return strdup(_("Warning level"));
+       }
+
+       return NULL;
+}
+
+static char *_limit_item_label_get(void *data, Evas_Object *obj, const char *part)
+{
+       char buf[256] = {0};
+       SmartMgrData *smd = (SmartMgrData *)data;
+       retv_if(!smd, NULL);
 
-       if (!strcmp(part, "elm.text"))
-               return strdup(element->value);
+       if (!strcmp(part, "elm.text")) {
+               if (smd->selected_sim_limits->limit > 0) {
+                       get_data_amount_str("", smd->selected_sim_limits->limit, buf, sizeof(buf));
+               } else {
+                       snprintf(buf, sizeof(buf), "%s", "None");
+               }
+               return strdup(buf);
+       }
        if (!strcmp(part, "elm.text.sub"))
-               return strdup(element->name);
+               return strdup(_("Limit"));
        return NULL;
 }
 
-static char *_last_item_label_get(void *data, Evas_Object *obj,
+static char *_cycle_item_label_get(void *data, Evas_Object *obj, const char *part)
+{
+       char buf[256] = {0};
+       SmartMgrData *smd = (SmartMgrData *)data;
+       retv_if(!smd, NULL);
+
+       if (!strcmp(part, "elm.text")) {
+               if (smd->selected_sim_limits->custom_mode_interval && smd->selected_sim_limits->cycle_mode == CYCLE_MODE_CUSTOM) {
+                       snprintf(buf, sizeof(buf), "%d Days", smd->selected_sim_limits->custom_mode_interval);
+               } else {
+                       snprintf(buf, sizeof(buf), "%s", elements_cycle_initial_values[smd->selected_sim_limits->cycle_mode]);
+               }
+
+               return strdup(buf);
+       }
+       if (!strcmp(part, "elm.text.sub"))
+               return strdup(_("Cycle"));
+       return NULL;
+}
+
+static char *_start_date_item_label_get(void *data, Evas_Object *obj, const char *part)
+{
+       SmartMgrData *smd = (SmartMgrData *)data;
+       retv_if(!smd, NULL);
+
+       char buf[256] = {0};
+       struct tm min_date = {0};
+       struct tm *time = {0};
+
+       if (!strcmp(part, "elm.text")) {
+               if (smd->selected_sim_limits->cycle_start > 1) {
+                               switch (smd->selected_sim_limits->cycle_mode) {
+                               case CYCLE_MODE_MONTHLY:
+                                       snprintf(buf, sizeof(buf), "%d", smd->selected_sim_limits->cycle_start);
+                                       break;
+                               case CYCLE_MODE_WEEKLY:
+                                       snprintf(buf, sizeof(buf), "%s", elements_cycle_day_of_week[smd->selected_sim_limits->cycle_start-1]);
+                                       break;
+                               case CYCLE_MODE_DAILY:
+                                       break;
+                               case CYCLE_MODE_CUSTOM:
+                                       time = localtime((time_t*)&smd->selected_sim_limits->cycle_start);
+                                       strftime(buf, sizeof(buf), date_format, time);
+                                       break;
+                               }
+                       } else {
+                               switch (smd->selected_sim_limits->cycle_mode) {
+                               case CYCLE_MODE_MONTHLY:
+                                       snprintf(buf, sizeof(buf), "%d", smd->selected_sim_limits->cycle_start);
+                                       break;
+                               case CYCLE_MODE_WEEKLY:
+                                       snprintf(buf, sizeof(buf), "%s", elements_cycle_day_of_week[0]);
+                                       break;
+                               case CYCLE_MODE_DAILY:
+                                       break;
+                               case CYCLE_MODE_CUSTOM:
+                                       min_date = _get_margin_date(DATE_MIN);
+                                       smd->selected_sim_limits->cycle_start = (int)mktime(&min_date);
+                                       strftime(buf, sizeof(buf), date_format, &min_date);
+                                       break;
+                               }
+                       }
+
+               return strdup(buf);
+       }
+
+       if (!strcmp(part, "elm.text.sub"))
+               return strdup(_("Start date"));
+       return NULL;
+}
+
+static char *_description_item_label_get(void *data, Evas_Object *obj,
                const char *part)
 {
-       Element *element = (Element*)data;
-       retv_if(!element, NULL);
+       SmartMgrData *smd = (SmartMgrData *)data;
+       retv_if(!smd, NULL);
 
        if (!strcmp(part, "elm.text.multiline"))
-               return strdup(element->value);
+               return strdup(elements_info_initial_values[smd->selected_sim_limits->cycle_mode]);
        return NULL;
 }
index 883bb59dda4f1acc7c150652b6637a83e8ba4b3e..6465ffa78c736e35570c6d3ee86a3c73cf25b671 100755 (executable)
@@ -252,7 +252,7 @@ restrictions_result set_mobile_restriction_rule_parameters(
                (void)stc_restriction_rule_destroy(rule);
                SETTING_TRACE_ERROR("stc_restriction_rule_set_app_id() error: %s",
                                                                                        get_error_message(ret));
-               return RESTRICTIONS_OTHER_ERROR;
+               return RESTRICTIONS_ERROR;
        }
 
        ret = stc_restriction_rule_set_iface_type(rule, STC_IFACE_DATACALL);
@@ -260,19 +260,16 @@ restrictions_result set_mobile_restriction_rule_parameters(
                (void)stc_restriction_rule_destroy(rule);
                SETTING_TRACE_ERROR("stc_restriction_rule_set_iface_type() error: %s",
                                                                                        get_error_message(ret));
-               return RESTRICTIONS_OTHER_ERROR;
+               return RESTRICTIONS_ERROR;
        }
 
-       if (limit > MAX_LIMIT_IN_BYTES)
-               return RESTRICTIONS_VALUE_HIGHTER_THAN_MAX;
-
        ret = stc_restriction_rule_set_subscriber_id(rule, subscriber_id);
        if (STC_ERROR_NONE != ret) {
                (void)stc_restriction_rule_destroy(rule);
                SETTING_TRACE_ERROR("stc_restriction_rule_set_subscriber_id() error:"\
                                                        "%s", get_error_message(ret));
 
-               return RESTRICTIONS_OTHER_ERROR;
+               return RESTRICTIONS_ERROR;
        }
 
        ret = stc_restriction_rule_set_limit(rule, limit);
@@ -280,20 +277,15 @@ restrictions_result set_mobile_restriction_rule_parameters(
                (void)stc_restriction_rule_destroy(rule);
                SETTING_TRACE_ERROR("stc_restriction_rule_set_limit() error: %s",
                                                                                        get_error_message(ret));
-               return RESTRICTIONS_OTHER_ERROR;
+               return RESTRICTIONS_ERROR;
        }
 
-       if (warning_limit > MAX_LIMIT_IN_BYTES)
-               return RESTRICTIONS_VALUE_HIGHTER_THAN_MAX;
-       else if (warning_limit > limit)
-               return RESTRICTIONS_VALUE_HIGHER_THAN_LIMIT;
-
        ret = stc_restriction_rule_set_warning_limit(rule, warning_limit);
        if (STC_ERROR_NONE != ret) {
                (void)stc_restriction_rule_destroy(rule);
                SETTING_TRACE_ERROR("stc_restriction_rule_set_warning_limit() error: %s",
                                                                                        get_error_message(ret));
-               return RESTRICTIONS_OTHER_ERROR;
+               return RESTRICTIONS_ERROR;
        }
 
        SETTING_TRACE_END;
@@ -312,7 +304,7 @@ restrictions_result set_mobile_limit_restrictions(stc_h stc_handle,
        if (STC_ERROR_NONE != ret) {
                SETTING_TRACE_ERROR("stc_restriction_rule_create() error: %s",
                                                                        get_error_message(ret));
-               return RESTRICTIONS_OTHER_ERROR;
+               return RESTRICTIONS_ERROR;
        }
 
        result = set_mobile_restriction_rule_parameters(rule, subscriber_id, limit,
@@ -328,7 +320,7 @@ restrictions_result set_mobile_limit_restrictions(stc_h stc_handle,
                (void)stc_restriction_rule_destroy(rule);
                SETTING_TRACE_ERROR("stc_set_restriction() error: %s",
                                                                                        get_error_message(ret));
-               return RESTRICTIONS_OTHER_ERROR;
+               return RESTRICTIONS_ERROR;
        }
 
        (void)stc_restriction_rule_destroy(rule);