#include "sys_lock.h"
#include "log.h"
+/* This application, password and UI are just examples for lazy-mount process */
+
#define STR_PASSWORD "0430"
-static bool isUnlocked = false;
+#define BUF_SIZE 10
+static bool isUnlocked;
+static char buf[BUF_SIZE];
+static int now;
+
+void _input_password(Evas_Object *ly, const char *txt)
+{
+ char tmp[BUF_SIZE] = { 0, };
+
+ if (now >= 4 || isUnlocked)
+ return;
+
+ snprintf(tmp, BUF_SIZE, "%s%s", buf, txt);
+ strncpy(buf,tmp,BUF_SIZE);
+ now++;
+
+ if (!strcmp(STR_PASSWORD, buf)) {
+ _dbus_send_sys_lock_unlock_signal();
+ isUnlocked = true;
+ _update_password_view(ly, 5);
+ } else {
+ _update_password_view(ly, now);
+ }
+}
+
+void _clear_password(Evas_Object *ly)
+{
+ if (now <= 0)
+ return;
+
+ now--;
+ buf[now] = '\0';
+
+ _update_password_view(ly, now);
+}
+
+void _clear_all_password(Evas_Object *ly)
+{
+ memset(buf, 0, BUF_SIZE);
+ now = 0;
+
+ _update_password_view(ly, now);
+}
+
+void _update_password_view(Evas_Object *ly, int num)
+{
+ if (num == 0)
+ elm_object_part_text_set(ly, "sw.entry", "_ _ _ _");
+ else if (num == 1)
+ elm_object_part_text_set(ly, "sw.entry", "* _ _ _");
+ else if (num == 2)
+ elm_object_part_text_set(ly, "sw.entry", "* * _ _");
+ else if (num == 3)
+ elm_object_part_text_set(ly, "sw.entry", "* * * _");
+ else if (num == 4)
+ elm_object_part_text_set(ly, "sw.entry", "* * * *");
+ else if (num == 5)
+ elm_object_part_text_set(ly, "sw.entry", "= Password OK! =");
+}
void _dbus_send_sys_lock_unlock_signal(void)
{
elm_win_borderless_set(win, EINA_TRUE);
elm_win_autodel_set(win, EINA_TRUE);
elm_win_fullscreen_set(win, EINA_TRUE);
-// efl_util_set_window_opaque_state(win, 1);
Evas_Object *ly = elm_layout_add(win);
{
if (isUnlocked) return; //Disable key input after unlocked.
- Evas_Object *entry = elm_object_part_content_get(data, "sw.entry");
- elm_object_focus_set(entry, EINA_TRUE);
- elm_entry_entry_set(entry, "");
-// ui_app_exit();
+ _clear_all_password(data);
}
static void
if (isUnlocked) return; //Disable key input after unlocked.
const char *txt = edje_object_part_text_get(obj, "text.number");
- Evas_Object *entry = elm_object_part_content_get(data, "sw.entry");
- elm_object_focus_set(entry, EINA_TRUE);
- DBG("_pin_button_clicked [%s]", txt);
-
- elm_entry_entry_append(entry, txt);
- elm_entry_cursor_next(entry);
+ DBG("_pin_button_clicked!! [%s]", txt);
- const char* old_entry_text = elm_entry_entry_get(entry);
-
- if (!strcmp(STR_PASSWORD, old_entry_text)) {
- _dbus_send_sys_lock_unlock_signal();
- elm_entry_password_set(entry, EINA_FALSE);
- elm_entry_text_style_user_push(entry, "DEFAULT='font=Sans style=Regular color=#FF0000 font_size=55 wrap=none align=center'");
- elm_entry_entry_set(entry, "= Password OK! =");
- elm_object_focus_set(entry, EINA_FALSE);
- isUnlocked = true;
-// ui_app_exit();
- }
+ _input_password(data, txt);
}
static void
{
if (isUnlocked) return; //Disable key input after unlocked.
- Evas_Object *entry = elm_object_part_content_get(data, "sw.entry");
- elm_object_focus_set(entry, EINA_TRUE);
-
- char *new_entry_text;
- const char* old_entry_text = elm_entry_entry_get(entry);
- new_entry_text = strdup(old_entry_text);
-
- if (new_entry_text) {
- new_entry_text[strlen(old_entry_text) - 1] = '\0';
- elm_entry_entry_set(entry, new_entry_text);
- free(new_entry_text);
- }
-}
-
-static void
-_pin_entry_activated(void *data, Evas_Object *obj, void *event_info)
-{
- const char *content = elm_entry_entry_get(obj);
-
- if (!strcmp(STR_PASSWORD, content)) {
- _dbus_send_sys_lock_unlock_signal();
- elm_entry_password_set(obj, EINA_FALSE);
- elm_entry_text_style_user_push(obj, "DEFAULT='font=Sans style=Regular color=#FF0000 font_size=55 wrap=none align=center'");
- elm_entry_entry_set(obj, "= Password OK! =");
- elm_object_focus_set(obj, EINA_FALSE);
- isUnlocked = true;
-// ui_app_exit();
- }
+ _clear_password(data);
}
static Evas_Object *_view_create(Evas_Object *win)
evas_object_show(btn);
evas_object_show(layout);
- Evas_Object *entry = elm_entry_add(layout);
- elm_entry_password_set(entry, EINA_TRUE);
- elm_object_part_content_set(layout, "sw.entry", entry);
- elm_entry_input_panel_enabled_set(entry, EINA_FALSE);
- evas_object_pass_events_set(entry, EINA_TRUE);
- evas_object_show(entry);
-
// Setup PIN pad
_pin_button_setup(layout, 1, 1, "1", NULL, _pin_button_clicked);
_pin_button_setup(layout, 1, 2, "2", "ABC" , _pin_button_clicked);
_pin_button_setup(layout, 4, 1, NULL, NULL , NULL);
elm_object_signal_emit(layout, "layout,pinpad,show", "lockscreen");
- elm_entry_text_style_user_push(entry, "DEFAULT='font=Sans style=Regular color=#FFFFFF font_size=110 wrap=none align=center'");
- evas_object_smart_callback_add(entry, "changed,user", _pin_entry_activated, layout);
return layout;
}
DBG("Syslock launch request.");
elm_config_scale_set(2.6);
-// elm_config_accel_preference_set("opengl");
DBG("base scale : %f", elm_app_base_scale_get());
DBG("edje scale : %f", edje_scale_get());