#include <ode/external-encryption.h>
#include "ode-password.h"
-#define PASSWORD_TITLE_STYLE_B "DEFAULT='font=Tizen:style=Regular font_size=38 color=#000000 wrap=mixed align=center'"
-#define PASSWORD_CONTENT_STYLE_B "DEFAULT='font=Tizen:style=Regular font_size=32 color=#000000 wrap=mixed'"
#define EDJ_PATH "/usr/apps/" PACKAGE "/res/" PACKAGE ".edj"
+static Ecore_Timer *timer = NULL;
+static Evas_Object *confirm_layout = NULL;
+static Evas_Object *next_button = NULL;
static Evas_Object *confirm_entry = NULL;
+static int limit_count = 0;
+static int limit_time = 0;
+
+static void update_title_text(void)
+{
+ char text[PATH_MAX] = "";
+ const char *time_text = NULL;
+
+ if (limit_time != 0) {
+ time_text = __("IDS_ST_BODY_ENTER_PASSWORD_IN_PD_SECONDS");
+ snprintf(text, PATH_MAX, time_text, 6-limit_time);
+ elm_object_part_text_set(confirm_layout, "title", text);
+ } else {
+ elm_object_part_text_set(confirm_layout, "title", __("IDS_LCKSCN_NPBODY_ENTER_PASSWORD"));
+ }
+ return;
+}
+
+static Eina_Bool limit_count_timer_cb(void *data)
+{
+ limit_time++;
+ update_title_text();
+
+ if (limit_time == 6) {
+ limit_time = 0;
+ ecore_timer_del(timer);
+ timer = NULL;
+ update_title_text();
+ elm_object_disabled_set(next_button, EINA_FALSE);
+ return ECORE_CALLBACK_DONE;
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static void update_content_text(void)
+{
+ char text[PATH_MAX] = "";
+ char count_text[PATH_MAX] = "";
+ const char *pd_text = NULL;
+ int count = 15-limit_count;
+
+ if (count == 0) {
+ return;
+ }
+
+ if (limit_count < 10) {
+ pd_text = __("IDS_ST_BODY_YOU_HAVE_PD_ATTEMPTS_LEFT");
+ snprintf(count_text, PATH_MAX, pd_text, count);
+ snprintf(text, PATH_MAX, "%s<br>%s", __("IDS_LCKSCN_NPBODY_INCORRECT_PASSWORD_ENTERED"), count_text);
+ } else {
+ pd_text = __("IDS_ST_BODY_IF_AN_INCORRECT_PASSWORD_IS_ENTERED_PD_MORE_TIMES_YOU_WILL_NO_LONGER_BE_ABLE_MSG");
+ snprintf(count_text, PATH_MAX, pd_text, count);
+ snprintf(text, PATH_MAX, "%s<br>%s", __("IDS_LCKSCN_NPBODY_INCORRECT_PASSWORD_ENTERED"), count_text);
+ }
+
+ elm_object_part_text_set(confirm_layout, "content", text);
+
+ if (limit_count > 5) {
+ elm_object_disabled_set(next_button, EINA_TRUE);
+ timer = ecore_timer_add(1, limit_count_timer_cb, NULL);
+ }
+
+ return;
+}
+
static void key_event_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
}
if (!result) {
- /* error */
dlog_print(DLOG_ERROR, LOG_TAG, "password not matched");
+ limit_count++;
+ if (limit_count == 15) {
+ evas_object_del(popup_data->popup);
+ create_reset_sdcard_popup(popup_data);
+ }
+ update_content_text();
return;
}
void create_confirm_password_popup(popup_data_s *data)
{
- Evas_Object *layout = NULL, *textblock = NULL;
- Evas_Object *cancel_button = NULL, *next_button = NULL;
+ Evas_Object *cancel_button = NULL;
+
+ limit_count = 0;
+ limit_time = 0;
if (data->mode == INSERT_SD_CARD)
data->popup = ode_create_popup(data->parent, __("IDS_ST_HEADER_USE_ENCRYPTED_SD_CARD"), NULL);
else
data->popup = ode_create_popup(data->parent, __("IDS_ST_BODY_PASSWORD"), NULL);
- layout = ode_create_layout(data->popup, EDJ_PATH, "entry_popup");
- elm_object_part_content_set(data->popup, "elm.swallow.content", layout);
+ confirm_layout = ode_create_layout(data->popup, EDJ_PATH, "entry_popup");
+ elm_object_part_content_set(data->popup, "elm.swallow.content", confirm_layout);
- textblock = ode_create_textblock(layout, __("IDS_LCKSCN_NPBODY_ENTER_PASSWORD"), PASSWORD_TITLE_STYLE_B);
- elm_object_part_content_set(layout, "title", textblock);
+ update_title_text();
- confirm_entry = ode_create_entry(layout);
- elm_object_part_content_set(layout, "entry", confirm_entry);
+ confirm_entry = ode_create_entry(confirm_layout);
+ elm_object_part_content_set(confirm_layout, "entry", confirm_entry);
cancel_button = ode_create_popup_button(data->popup, __("IDS_ST_BUTTON_CANCEL"),
confirm_password_popup_cancel_cb, data);