static int _cleanup(void *data);
/* Widget interaction callbacks: */
-static void _custom_cycle_dayes_popup_cancel_click_cb(void *data,
+static void _custom_cycle_days_popup_cancel_click_cb(void *data,
Evas_Object *button, void *event_info);
-static void _custom_cycle_dayes_popup_done_click_cb(void *data,
+static void _custom_cycle_days_popup_done_click_cb(void *data,
Evas_Object *button, void *event_info);
static void _cycle_item_click_cb(void *data, Evas_Object *obj,
void *event_info);
return EINA_TRUE;
}
-static void _custom_cycle_dayes_popup_cancel_click_cb(void *data,
+static void _custom_cycle_days_popup_cancel_click_cb(void *data,
Evas_Object *button, void *event_info)
{
Evas_Object *popup = evas_object_data_get(button, "popup");
evas_object_del(popup);
}
-static void _custom_cycle_dayes_popup_done_click_cb(void *data,
+static void _custom_cycle_days_popup_done_click_cb(void *data,
Evas_Object *button, void *event_info)
{
SmartMgrData *smd = data;
elm_object_part_content_set(popup, "button1", button);
evas_object_data_set(button, "popup", popup);
evas_object_smart_callback_add(button, "clicked",
- _custom_cycle_dayes_popup_cancel_click_cb, smd);
+ _custom_cycle_days_popup_cancel_click_cb, smd);
button = elm_button_add(popup);
evas_object_data_set(button, "entry", entry);
elm_object_text_set(button, _("Done"));
elm_object_part_content_set(popup, "button2", button);
evas_object_smart_callback_add(button, "clicked",
- _custom_cycle_dayes_popup_done_click_cb, smd);
+ _custom_cycle_days_popup_done_click_cb, smd);
return popup;
}
struct tm start_date = {0};
Eina_Bool time_res = EINA_FALSE;
SmartMgrData *smd = data;
+ double time_delta = 0.0;
+ time_t now = time(NULL);
+ struct tm *now_tm = NULL;
+ time_t past_max = now - (3600.0 * 24.0 * 90.0);
+ struct tm *past_max_tm = NULL;
+ char txt_buff[256] = {'\0',};
+ char past_date_txt_buff[80] = {'\0',};
+
+ /* set'now' to second past midnight: */
+ now_tm = localtime(&now);
+ now_tm->tm_sec = 1;
+ now_tm->tm_min = 0;
+ now_tm->tm_hour = 0;
+ now = mktime(now_tm);
+ now_tm = NULL;
smd->wifi_limits.cycle_start = 1;
if (CYCLE_MODE_CUSTOM == smd->wifi_limits.cycle_mode) {
time_res = elm_datetime_value_get(start_date_popup_datetime,
&start_date);
+ start_date.tm_sec = 1;
+ start_date.tm_min = 0;
+ start_date.tm_hour = 0;
if (EINA_TRUE == time_res) {
smd->wifi_limits.cycle_start = mktime(&start_date);
+ time_delta = difftime(smd->wifi_limits.cycle_start, now);
+
+ if (time_delta > 1.0) {
+ setting_create_toast_popup(_("Start date can't be after "\
+ "current date. Start date changed to current date."),
+ smd->md.window);
+ smd->wifi_limits.cycle_start = now;
+ }
+
+ if (time_delta < -(3600.0 * 24.0 * 90.0)) {
+ past_max_tm = localtime(&past_max);
+ strftime(past_date_txt_buff, sizeof(past_date_txt_buff),
+ "%a, %d/%m/%Y", past_max_tm);
+ snprintf(txt_buff, sizeof(txt_buff), "%s %s. %s",
+ _("Start date can't be before"), past_date_txt_buff,
+ _("Start date changed to current date."));
+ setting_create_toast_popup(txt_buff, smd->md.window);
+ smd->wifi_limits.cycle_start = now;
+ }
+
} else {
SETTING_TRACE_ERROR("Failed to obtain data from datetime %p",
start_date_popup_datetime);
start_date_popup_datetime = elm_datetime_add(start_date_popup);
elm_object_style_set(start_date_popup_datetime, "date_layout");
elm_datetime_format_set(start_date_popup_datetime, "%d/%b/%Y");
- elm_datetime_value_set(start_date_popup_datetime,
+ if (smd->wifi_limits.cycle_start <= 0) {
+ elm_datetime_value_set(start_date_popup_datetime,
(Elm_Datetime_Time *)localtime(&now));
+ } else {
+ elm_datetime_value_set(start_date_popup_datetime,
+ (Elm_Datetime_Time *)localtime((time_t *)(
+ &(smd->wifi_limits.cycle_start))
+ )
+ );
+
+ }
elm_object_content_set(start_date_popup, start_date_popup_datetime);
}
static char *_cycle_item_text_get(void *data, Evas_Object *genlist,
const char *part)
{
- if (!data)
+ SmartMgrData *ad = data;
+ char txt_buff[256] = {'\0',};
+
+ if (!ad)
return NULL;
- if (!safeStrCmp(part, "elm.text"))
+ if (!safeStrCmp(part, "elm.text")) {
+ if (CYCLE_MODE_CUSTOM == ad->wifi_limits.cycle_mode) {
+
+ snprintf(txt_buff, sizeof(txt_buff), "%d %s",
+ ad->wifi_limits.custom_mode_interval, _("Days"));
+ return strdup(txt_buff);
+ }
return strdup(
- cycle_names[((SmartMgrData *)data)->wifi_limits.cycle_mode]
+ cycle_names[ad->wifi_limits.cycle_mode]
);
+ }
if (!safeStrCmp(part, "elm.text.sub"))
return strdup(_("Cycle"));