diff options
Diffstat (limited to 'lock_pwd')
25 files changed, 3953 insertions, 0 deletions
diff --git a/lock_pwd/include/lock_pwd_complex.h b/lock_pwd/include/lock_pwd_complex.h new file mode 100644 index 0000000..bb92dca --- /dev/null +++ b/lock_pwd/include/lock_pwd_complex.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __LOCK_PWD_COMPLEX_H__ +#define __LOCK_PWD_COMPLEX_H__ + +#include "lock_pwd_verification.h" + +Eina_Bool lock_pwd_complex_is_blocked_get(void); +void lock_pwd_complex_event(lock_pwd_event_e event); +Evas_Object *lock_pwd_complex_layout_create(void *data); +void lock_pwd_complex_layout_destroy(void); +void lock_pwd_complex_view_init(void); + +#endif diff --git a/lock_pwd/include/lock_pwd_control_panel.h b/lock_pwd/include/lock_pwd_control_panel.h new file mode 100644 index 0000000..9c65e80 --- /dev/null +++ b/lock_pwd/include/lock_pwd_control_panel.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __LOCK_PWD_CONTROL_PANEL_H__ +#define __LOCK_PWD_CONTROL_PANEL_H__ + +void lock_pwd_control_panel_cancel_btn_enable_set(Eina_Bool enable); + +Evas_Object *lock_pwd_control_panel_create(Evas_Object *parent); +void lock_pwd_control_panel_del(void); + +#endif diff --git a/lock_pwd/include/lock_pwd_simple.h b/lock_pwd/include/lock_pwd_simple.h new file mode 100755 index 0000000..b820003 --- /dev/null +++ b/lock_pwd/include/lock_pwd_simple.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __LOCK_PWD_SIMPLE_H__ +#define __LOCK_PWD_SIMPLE_H__ + +#include <Elementary.h> + +#include "lock_pwd_verification.h" + +Eina_Bool lock_pwd_simple_is_blocked_get(void); +Evas_Object *lock_pwd_simple_layout_create(void *data); +void lock_pwd_simple_layout_destroy(void); +void lock_pwd_simple_event(lock_pwd_event_e event); +void lock_pwd_simple_view_init(void); + +#endif diff --git a/lock_pwd/include/lock_pwd_util.h b/lock_pwd/include/lock_pwd_util.h new file mode 100644 index 0000000..cd53bfa --- /dev/null +++ b/lock_pwd/include/lock_pwd_util.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __LOCK_PWD_UTIL_H__ +#define __LOCK_PWD_UTIL_H__ + +#define LOCK_PWD_EDJE_FILE "/usr/share/starter/lock_pwd/res/edje/lock_pwd.edj" +#define LOCK_PWD_BTN_EDJE_FILE "/usr/share/starter/lock_pwd/res/edje/lock_btn.edj" + +int lock_pwd_util_win_width_get(void); +int lock_pwd_util_win_height_get(void); + +void lock_pwd_util_create(Eina_Bool is_show); +void lock_pwd_util_destroy(void); + +void lock_pwd_util_popup_create(char *title, char *text, Evas_Smart_Cb func, double timeout); + +void lock_pwd_util_view_init(void); +void lock_pwd_util_back_key_relased(void); +Evas_Object *lock_pwd_util_win_get(void); +Eina_Bool lock_pwd_util_win_visible_get(void); +void lock_pwd_util_win_show(void); +void lock_pwd_util_win_hide(void); + +#endif diff --git a/lock_pwd/include/lock_pwd_verification.h b/lock_pwd/include/lock_pwd_verification.h new file mode 100755 index 0000000..5d3b15b --- /dev/null +++ b/lock_pwd/include/lock_pwd_verification.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __LOCK_PWD_VERIFICATION_H__ +#define __LOCK_PWD_VERIFICATION_H__ + +#include <vconf.h> + +#define PASSWORD_ATTEMPTS_MAX_NUM 5 +#define MAX_SIMPLE_PASSWORD_NUM 4 +#define INFINITE_ATTEMPT 0 +#define PASSWORD_BLOCK_SECONDS 30 +#define PASSWORD_TIMESTAMP_STR_LENGTH 512 +#define VCONFKEY_SETAPPL_PASSWORD_TIMESTAMP_STR VCONFKEY_SETAPPL_PREFIX"/phone_lock_timestamp" + +typedef enum { + PWD_EVENT_CORRECT = 0, + PWD_EVENT_INCORRECT_WARNING = 1, + PWD_EVENT_INCORRECT, + PWD_EVENT_INPUT_BLOCK_WARNING, + PWD_EVENT_INPUT_BLOCK, + PWD_EVENT_EMPTY, + PWD_EVENT_OVER, +} lock_pwd_event_e; + +typedef struct { + unsigned int current_attempt; + unsigned int block_attempt; + unsigned int max_attempt; + unsigned int expire_sec; + unsigned int incorrect_count; + void *data; +} lock_pwd_policy; + +int lock_pwd_verification_current_attempt_get(void); +int lock_pwd_verification_remain_attempt_get(void); + +lock_pwd_event_e lock_pwd_verification_verify(const char *password); +void lock_pwd_verification_policy_create(void); + +void lock_pwd_verification_popup_create(lock_pwd_event_e event); + +#endif diff --git a/lock_pwd/res/CMakeLists.txt b/lock_pwd/res/CMakeLists.txt new file mode 100755 index 0000000..2ab7c7b --- /dev/null +++ b/lock_pwd/res/CMakeLists.txt @@ -0,0 +1 @@ +ADD_SUBDIRECTORY(edje) diff --git a/lock_pwd/res/edje/CMakeLists.txt b/lock_pwd/res/edje/CMakeLists.txt new file mode 100755 index 0000000..23de665 --- /dev/null +++ b/lock_pwd/res/edje/CMakeLists.txt @@ -0,0 +1,23 @@ +ADD_CUSTOM_TARGET(lock_btn.edj + COMMAND edje_cc -id ${CMAKE_CURRENT_SOURCE_DIR}/images + ${CMAKE_CURRENT_SOURCE_DIR}/lock_btn.edc ${CMAKE_BINARY_DIR}/lock_pwd/res/edje/lock_btn.edj + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lock_btn.edc +) +ADD_DEPENDENCIES(${PROJECT_NAME} lock_btn.edj) +INSTALL(FILES lock_btn.edj DESTINATION /usr/share/starter/lock_pwd/res/edje) + +ADD_CUSTOM_TARGET(lock_entry.edj + COMMAND edje_cc -id ${CMAKE_CURRENT_SOURCE_DIR}/images + ${CMAKE_CURRENT_SOURCE_DIR}/lock_entry.edc ${CMAKE_BINARY_DIR}/lock_pwd/res/edje/lock_entry.edj + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lock_entry.edc +) +ADD_DEPENDENCIES(${PROJECT_NAME} lock_entry.edj) +INSTALL(FILES lock_entry.edj DESTINATION /usr/share/starter/lock_pwd/res/edje) + +ADD_CUSTOM_TARGET(lock_pwd.edj + COMMAND edje_cc -id ${CMAKE_CURRENT_SOURCE_DIR}/images + ${CMAKE_CURRENT_SOURCE_DIR}/lock_pwd.edc ${CMAKE_BINARY_DIR}/lock_pwd/res/edje/lock_pwd.edj + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lock_pwd.edc +) +ADD_DEPENDENCIES(${PROJECT_NAME} lock_pwd.edj) +INSTALL(FILES lock_pwd.edj DESTINATION /usr/share/starter/lock_pwd/res/edje) diff --git a/lock_pwd/res/edje/images/enter_pin_dot.png b/lock_pwd/res/edje/images/enter_pin_dot.png Binary files differnew file mode 100644 index 0000000..467db33 --- /dev/null +++ b/lock_pwd/res/edje/images/enter_pin_dot.png diff --git a/lock_pwd/res/edje/images/event_close_bg.#.png b/lock_pwd/res/edje/images/event_close_bg.#.png Binary files differnew file mode 100644 index 0000000..047d7ca --- /dev/null +++ b/lock_pwd/res/edje/images/event_close_bg.#.png diff --git a/lock_pwd/res/edje/images/ls_back_02_nor.png b/lock_pwd/res/edje/images/ls_back_02_nor.png Binary files differnew file mode 100644 index 0000000..7a8f607 --- /dev/null +++ b/lock_pwd/res/edje/images/ls_back_02_nor.png diff --git a/lock_pwd/res/edje/images/ls_back_02_press.png b/lock_pwd/res/edje/images/ls_back_02_press.png Binary files differnew file mode 100644 index 0000000..7426dfc --- /dev/null +++ b/lock_pwd/res/edje/images/ls_back_02_press.png diff --git a/lock_pwd/res/edje/images/ls_icon_call.png b/lock_pwd/res/edje/images/ls_icon_call.png Binary files differnew file mode 100644 index 0000000..18bf92a --- /dev/null +++ b/lock_pwd/res/edje/images/ls_icon_call.png diff --git a/lock_pwd/res/edje/images/ls_password_underline.#.png b/lock_pwd/res/edje/images/ls_password_underline.#.png Binary files differnew file mode 100644 index 0000000..9b6944b --- /dev/null +++ b/lock_pwd/res/edje/images/ls_password_underline.#.png diff --git a/lock_pwd/res/edje/images/ls_pin_dot.png b/lock_pwd/res/edje/images/ls_pin_dot.png Binary files differnew file mode 100644 index 0000000..c01ca7c --- /dev/null +++ b/lock_pwd/res/edje/images/ls_pin_dot.png diff --git a/lock_pwd/res/edje/lock_btn.edc b/lock_pwd/res/edje/lock_btn.edc new file mode 100755 index 0000000..20ecbbb --- /dev/null +++ b/lock_pwd/res/edje/lock_btn.edc @@ -0,0 +1,395 @@ +/* + * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +styles { + style { + name: "unlock_text"; + base: "font=Tizen:style=Regular color=#FFFFFFFF color_class=ATO017 font_size=10 text_class=ATO017 style=shadow shadow_color=#000000bf align: 0.5 0.0 wrap=word"; + } +} + +#define TEXT_BUTTON_CLASS "ATO007" + + +collections { + base_scale: 2.6; + group { + name: "elm/button/base/emg_cal_btn"; + parts { + part { + name: "elm.swallow.content"; + type: RECT; + mouse_events: 1; + repeat_events: 1; + description { + state: "default" 0.0; + color: 0 0 0 0; + visible: 1; + rel1.relative: 0.0 0.0; + rel2.relative: 1.0 1.0; + align: 0.0 0.0; + } + } + part { + name: "elm.text"; + type: TEXT; + effect: "SHADOW"; + mouse_events: 1; + repeat_events: 1; + description { + state: "default" 0.0; + fixed: 1 1; + color: 255 255 255 255; + visible: 1; + rel1.relative: 0.0 0.0; + rel2.relative: 1.0 1.0; + text { + align: 0.0 0.5; + size: 28; + text_class: TEXT_BUTTON_CLASS; + } + } + description { + state: "pressed" 0.0; + inherit: "default" 0.0; + color: 255 255 255 120; + } + } + } + programs { + program { + name: "mouse,clicked"; + signal: "mouse,clicked,1"; + source: "elm.swallow.content"; + action: SIGNAL_EMIT "elm,action,click" ""; + } + program { + name: "button,pressed"; + signal: "mouse,down,1"; + action: STATE_SET "pressed" 0.0; + source: "elm.swallow.content"; + target: "elm.text"; + } + program { + name: "button,unpressed"; + signal: "mouse,up,1"; + action: STATE_SET "default" 0.0; + source: "elm.swallow.content"; + target: "elm.text"; + } + } + } + + group { + name: "elm/button/base/tizen_account_btn"; + parts { + part { + name: "elm.swallow.content"; + type: RECT; + mouse_events: 1; + repeat_events: 1; + description { + state: "default" 0.0; + color: 0 0 0 0; + visible: 1; + rel1.relative: 0.0 0.0; + rel2.relative: 1.0 1.0; + align: 0.0 0.0; + } + } + part { + name: "elm.text"; + type: TEXTBLOCK; + effect: "SHADOW"; + mouse_events: 1; + repeat_events: 1; + description { + state: "default" 0.0; + fixed: 1 1; + color: 255 255 255 255; + visible: 1; + rel1.relative: 0.0 0.0; + rel2.relative: 1.0 1.0; + text { + style: "unlock_text"; + } + } + description { + state: "pressed" 0.0; + inherit: "default" 0.0; + color: 255 255 255 120; + } + } + } + programs { + program { + name: "mouse,clicked"; + signal: "mouse,clicked,1"; + source: "elm.swallow.content"; + action: SIGNAL_EMIT "elm,action,click" ""; + } + program { + name: "button,pressed"; + signal: "mouse,down,1"; + action: STATE_SET "pressed" 0.0; + source: "elm.swallow.content"; + target: "elm.text"; + } + program { + name: "button,unpressed"; + signal: "mouse,up,1"; + action: STATE_SET "default" 0.0; + source: "elm.swallow.content"; + target: "elm.text"; + } + } + } + + group { + name: "elm/button/base/right_button"; + parts { + part { + name: "elm.swallow.content"; + type: RECT; + mouse_events: 1; + repeat_events: 1; + description { + state: "default" 0.0; + color: 0 0 0 0; + visible: 1; + rel1.relative: 0.0 0.0; + rel2.relative: 1.0 1.0; + align: 1.0 0.0; + } + } + part { + name: "effect"; + type: RECT; + mouse_events: 1; + repeat_events: 1; + description { + state: "default" 0.0; + visible: 0; + } + description { + state: "pressed" 0.0; + //color_class: AO018; + visible: 1; + rel1.to: "elm.text"; + rel1.offset: -3 0; + rel2.to: "elm.text"; + rel2.offset: 3 0; + } + } + part { + name: "elm.text"; + type: TEXT; + effect: "SHADOW"; + mouse_events: 1; + repeat_events: 1; + description { + state: "default" 0.0; + color: 255 255 255 255; + visible: 1; + rel1.relative: 1.0 0.0; + rel2.relative: 1.0 1.0; + align: 1.0 0.5; + text { + align: 1.0 0.5; + size: 32; + //text_class: "ATO007"; + min: 1 0; + ellipsis: -1; + } + } + } + } + programs { + program { + name: "mouse,clicked"; + signal: "mouse,clicked,1"; + source: "elm.swallow.content"; + action: SIGNAL_EMIT "elm,action,click" ""; + } + program { + name: "button,pressed"; + signal: "mouse,down,1"; + action: STATE_SET "pressed" 0.0; + source: "elm.swallow.content"; + target: "effect"; + } + program { + name: "button,unpressed"; + signal: "mouse,up,1"; + action: STATE_SET "default" 0.0; + source: "elm.swallow.content"; + target: "effect"; + } + } + } + + group { + name: "elm/button/base/left_button"; + parts { + part { + name: "elm.swallow.content"; + type: RECT; + mouse_events: 1; + repeat_events: 1; + description { + state: "default" 0.0; + color: 0 0 0 0; + visible: 1; + rel1.relative: 0.0 0.0; + rel2.relative: 1.0 1.0; + align: 0.0 0.0; + } + } + part { + name: "effect"; + type: RECT; + mouse_events: 1; + repeat_events: 1; + description { + state: "default" 0.0; + visible: 0; + } + description { + state: "pressed" 0.0; + color_class: AO018; + visible: 1; + rel1.to: "elm.text"; + rel1.offset: -3 -3; + rel2.to: "elm.text"; + rel2.offset: 3 3; + } + } + part { + name: "elm.text"; + type: TEXT; + effect: "SHADOW"; + mouse_events: 1; + repeat_events: 1; + description { + state: "default" 0.0; + fixed: 1 1; + color: 255 255 255 255; + visible: 1; + rel1.relative: 0.0 0.0; + rel2.relative: 0.0 1.0; + align: 0.0 0.5; + text { + align: 0.0 0.5; + size: 28; + //text_class: "ATO007"; + min: 1 0; + ellipsis: -1; + } + } + } + } + programs { + program { + name: "mouse,clicked"; + signal: "mouse,clicked,1"; + source: "elm.text"; + action: SIGNAL_EMIT "elm,action,click" ""; + } + program { + name: "button,pressed"; + signal: "mouse,down,1"; + action: STATE_SET "pressed" 0.0; + source: "elm.text"; + target: "effect"; + } + program { + name: "button,unpressed"; + signal: "mouse,up,1"; + action: STATE_SET "default" 0.0; + source: "elm.text"; + target: "effect"; + } + } + } + + group { + name: "elm/button/base/center_button"; + parts { + part { + name: "elm.swallow.content"; + type: RECT; + mouse_events: 1; + repeat_events: 1; + description { + state: "default" 0.0; + color: 0 0 0 0; + visible: 1; + rel1.relative: 0.0 0.0; + rel2.relative: 1.0 1.0; + align: 0.0 0.0; + } + } + part { + name: "elm.text"; + type: TEXT; + effect: "SHADOW"; + mouse_events: 1; + repeat_events: 1; + description { + state: "default" 0.0; + fixed: 1 1; + color: 255 255 255 255; + visible: 1; + rel1.relative: 0.0 0.0; + rel2.relative: 1.0 1.0; + text { + align: 0.5 0.5; + size: 28; + //text_class: "ATO007"; + } + } + description { + state: "pressed" 0.0; + inherit: "default" 0.0; + color: 255 255 255 128; + } + } + } + programs { + program { + name: "mouse,clicked"; + signal: "mouse,clicked,1"; + source: "elm.swallow.content"; + action: SIGNAL_EMIT "elm,action,click" ""; + } + program { + name: "button,pressed"; + signal: "mouse,down,1"; + action: STATE_SET "pressed" 0.0; + source: "elm.swallow.content"; + target: "elm.text"; + } + program { + name: "button,unpressed"; + signal: "mouse,up,1"; + action: STATE_SET "default" 0.0; + source: "elm.swallow.content"; + target: "elm.text"; + } + } + } +} diff --git a/lock_pwd/res/edje/lock_entry.edc b/lock_pwd/res/edje/lock_entry.edc new file mode 100755 index 0000000..f4b3cca --- /dev/null +++ b/lock_pwd/res/edje/lock_entry.edc @@ -0,0 +1,486 @@ +/* + * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +collections { + base_scale : 2.6; + + group { + name: "elm/entry/base-single/default"; + data.item: "default_font_size" "43"; + data.item: "min_font_size" "8"; + data.item: "max_font_size" "60"; + styles { + style { name: "entry_single_textblock_style"; + base: "font=Tizen:style=Roman font_size=43 align=center color=#FFFFFFFF wrap=none left_margin=1 right_margin=3 text_class=Tizen style=shadow shadow_color=#000000bf"; + tag: "br" "\n"; + tag: "ps" "ps"; + tag: "tab" "\t"; + tag: "em" "+ font=Tizen:style=Oblique"; + tag: "b" "+ font=Tizen:style=Bold"; + tag: "link" "+ color=#800 underline=on underline_color=#8008"; + tag: "hilight" "+ font=Tizen:style=Bold"; + tag: "preedit" "+ underline=on underline_color="ENTRY_PREEDIT_UNDERLINE_COLOR_INC; + tag: "preedit_sel" "+ backing=on backing_color="ENTRY_PREEDIT_BACKGROUND_COLOR_INC" color="ENTRY_PREEDIT_TEXT_COLOR_INC" underline=on underline_color="ENTRY_PREEDIT_TEXT_COLOR_INC; + tag: "preedit_sub1" "+ backing=on backing_color="ENTRY_PREEDIT_SUB1_COLOR_INC" underline=on underline_color="ENTRY_PREEDIT_UNDERLINE_COLOR_INC; + tag: "preedit_sub2" "+ backing=on backing_color="ENTRY_PREEDIT_SUB2_COLOR_INC" underline=on underline_color="ENTRY_PREEDIT_UNDERLINE_COLOR_INC; + tag: "preedit_sub3" "+ backing=on backing_color="ENTRY_PREEDIT_SUB3_COLOR_INC" underline=on underline_color="ENTRY_PREEDIT_UNDERLINE_COLOR_INC; + tag: "preedit_sub4" "+ backing=on backing_color="ENTRY_PREEDIT_SUB4_COLOR_INC" underline=on underline_color="ENTRY_PREEDIT_UNDERLINE_COLOR_INC; + } + style { name: "entry_single_textblock_disabled_style"; + base: "font=Tizen:style=Roman font_size=43 color=00000080 wrap=none left_margin=1 right_margin=3 text_class=Tizen"; + tag: "br" "\n"; + tag: "ps" "ps"; + tag: "tab" "\t"; + tag: "em" "+ font=Tizen:style=Oblique"; + tag: "b" "+ font=Tizen:style=Bold"; + tag: "link " "+ color=#00000080 underline=on underline_color=#00000080"; + tag: "hilight" "+ font=Tizen:style=Bold"; + tag: "preedit" "+ underline=on underline_color="ENTRY_PREEDIT_UNDERLINE_COLOR_INC; + tag: "preedit_sel" "+ backing=on backing_color="ENTRY_PREEDIT_BACKGROUND_COLOR_INC" color="ENTRY_PREEDIT_TEXT_COLOR_INC" underline=on underline_color="ENTRY_PREEDIT_TEXT_COLOR_INC; + tag: "preedit_sub1" "+ backing=on backing_color="ENTRY_PREEDIT_SUB1_COLOR_INC" underline=on underline_color="ENTRY_PREEDIT_UNDERLINE_COLOR_INC; + tag: "preedit_sub2" "+ backing=on backing_color="ENTRY_PREEDIT_SUB2_COLOR_INC" underline=on underline_color="ENTRY_PREEDIT_UNDERLINE_COLOR_INC; + tag: "preedit_sub3" "+ backing=on backing_color="ENTRY_PREEDIT_SUB3_COLOR_INC" underline=on underline_color="ENTRY_PREEDIT_UNDERLINE_COLOR_INC; + tag: "preedit_sub4" "+ backing=on backing_color="ENTRY_PREEDIT_SUB4_COLOR_INC" underline=on underline_color="ENTRY_PREEDIT_UNDERLINE_COLOR_INC; + } + } + data { + item: context_menu_orientation "horizontal"; + } + parts { + part { + name: "entry.swallow.background"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + visible: 1; + rel1 { relative: 0 0; to: "elm.text"; } + rel2 { relative: 1 1; to: "elm.text"; } + } + } + } + parts { + part { + name: "elm.text"; + type: TEXTBLOCK; + mouse_events: 1; + scale: 1; + entry_mode: EDITABLE; + select_mode: BLOCK_HANDLE; + multiline: 0; + source: "elm/entry/selection/default"; + source2: "elm/entry/selection/block_handle"; + source3: "elm/entry/selection/block_handle_top"; + source4: "elm/entry/cursor/default"; + source5: "elm/entry/anchor/default"; + description { + state: "default" 0.0; + text { + style: "entry_single_textblock_style"; + min: 1 1; + max: 0 1; + ellipsis: -1; + } + } + description { + state: "disabled" 0.0; + inherit: "default" 0.0; + text { + style: "entry_single_textblock_disabled_style"; + } + } + } + } + programs { + program { + name: "focus"; + signal: "load"; + source: ""; + action: FOCUS_SET; + target: "elm.text"; + } + program { + name: "disable"; + signal: "elm,state,disabled"; + source: "elm"; + action: STATE_SET "disabled" 0.0; + target: "elm.text"; + } + program { + name: "enable"; + signal: "elm,state,enabled"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "elm.text"; + } + } + } + group { + name: "elm/entry/base-password/lockscreen_complex_password_style"; + data.item: "default_font_size" "43"; + data.item: "min_font_size" "8"; + data.item: "max_font_size" "60"; + data { + item: context_menu_orientation "horizontal"; + } + parts { + part { + name: "entry.swallow.background"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + visible: 1; + rel1 { relative: 0 0; to: "elm.text"; } + rel2 { relative: 1 1; to: "elm.text"; } + } + } + } + parts { + part { + name: "elm.text"; + type: TEXTBLOCK; + mouse_events: 1; + scale: 1; + entry_mode: PASSWORD; + select_mode: BLOCK_HANDLE; + multiline: 0; + source: "elm/entry/selection/default"; + source2: "elm/entry/selection/block_handle"; + source3: "elm/entry/selection/block_handle_top"; + source4: "elm/entry/cursor/default"; + source5: "elm/entry/anchor/default"; + description { + state: "default" 0.0; + text { + style: "entry_single_textblock_style"; + repch: "•"; + min: 1 1; + max: 0 0; + ellipsis: -1; + } + } + description { + state: "disabled" 0.0; + inherit: "default" 0.0; + text { + style: "entry_single_textblock_disabled_style"; + } + } + } + } + programs { + program { + name: "focus"; + signal: "load"; + source: ""; + action: FOCUS_SET; + target: "elm.text"; + } + program { + name: "disable"; + signal: "elm,state,disabled"; + source: "elm"; + action: STATE_SET "disabled" 0.0; + target: "elm.text"; + } + program { + name: "enable"; + signal: "elm,state,enabled"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "elm.text"; + } + } + } + group { + name: "elm/entry/cursor/default"; + parts { + part { + name: "clip2"; + type: RECT; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + rel1.to: "clip"; + rel2.to: "clip"; + visible: 0; + } + description { + state: "focused" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } + part { + name: "clip"; + type: RECT; + mouse_events: 0; + scale: 1; + clip_to: "clip2"; + description { + state: "default" 0.0; + rel1.offset: -10 0; + rel2.offset: 9 9; + } + description { + state: "hidden" 0.0; + inherit: "default" 0.0; + visible: 0; + } + } + part { + name: "base"; + mouse_events: 0; + scale: 1; + clip_to: "clip"; + description { + state: "default" 0.0; + min: 2 2; + align: 0.5 1.0; + color: 0 0 0 0; + } + } + part { + name: "glow"; + type: RECT; + mouse_events: 0; + scale: 1; + clip_to: "clip2"; + description { + state: "default" 0.0; + min: 4 0; + fixed: 1 0; + align: 0.5 0.5; + rel1 { + relative: 0.0 0.0; + offset: 0 2; + } + rel2 { + relative: 0.0 1.0; + offset: 0 -2; + } + color: 42 137 194 255; + } + description { + state: "hidden" 0.0; + inherit: "default" 0.0; + color: 0 0 0 0; + } + } + } + programs { + program { + name: "show"; + action: STATE_SET "hidden" 0.0; + in: 0.6 0.0; + target: "glow"; + after: "show4"; + } + program { + name: "show4"; + action: STATE_SET "default" 0.0; + in: 0.6 0.0; + target: "glow"; + after: "show"; + } + program { + name: "focused"; + signal: "elm,action,focus"; + source: "elm"; + action: STATE_SET "focused" 0.0; + target: "clip2"; + after: "show4"; + } + program { + name: "unfocused"; + signal: "elm,action,unfocus"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "clip2"; + after: "stop_glow"; + } + program { + name: "stop_glow"; + action: ACTION_STOP; + target: "show"; + target: "show4"; + } + } + } + group { name: "elm/entry/selection/default"; + parts { + part { + name: "bg"; + type: RECT; + scale: 1; + mouse_events: 0; + description { + state: "default" 0.0; + color: 138 183 223 128; + } + } + } + } + group { + name: "elm/entry/selection/block_handle"; + data.item: "position" "BOTH"; + parts { + part { + name: "bg"; + type: RECT; + scale: 1; + mouse_events: 1; + description { + state: "default" 0.0; + visible: 1; + fixed: 1 1; + align: 0.5 0.25; + min: 50 80; + color: 0 0 0 0; + } + } + part { + name: "handle"; + mouse_events: 1; + scale: 1; + description { + state: "default" 0.0; + visible: 0; + fixed: 1 1; + align: 0.5 0.0; + min: 48 66; + rel1 { + relative: 0.0 0.0; + offset: 0 0; + } + rel2 { + relative: 0.0 0.0; + offset: 0 0; + } + image { + border: 0 0 0 0; + } + image.middle: SOLID; + fill.smooth: 0; + } + description { + state: "show" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } + } + programs { + program { + name: "focused"; + signal: "elm,action,focus"; + source: "elm"; + action: STATE_SET "show" 0.0; + target: "handle"; + } + program { + name: "unfocused"; + signal: "elm,action,unfocus"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "handle"; + } + } + } + group { + name: "elm/entry/selection/block_handle_top"; + data.item: "position" "BOTH"; + parts { + part { + name: "bg"; + type: RECT; + scale: 1; + mouse_events: 1; + description { + state: "default" 0.0; + visible: 1; + fixed: 1 1; + align: 0.5 0.75; + min: 50 80; + color: 0 0 0 0; + } + } + part { + name: "handle"; + mouse_events: 1; + scale: 1; + description { + state: "default" 0.0; + visible: 0; + fixed: 1 1; + align: 0.5 1.0; + min: 48 66; + rel1 { + relative: 0.0 0.0; + offset: 0 0; + } + rel2 { + relative: 0.0 0.0; + offset: 0 0; + } + image { + border: 0 0 0 0; + } + image.middle: SOLID; + fill.smooth: 0; + } + description { + state: "show" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } + } + programs { + program { + name: "focused"; + signal: "elm,action,focus"; + source: "elm"; + action: STATE_SET "show" 0.0; + target: "handle"; + } + program { + name: "unfocused"; + signal: "elm,action,unfocus"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "handle"; + } + } + } + group { + name: "elm/entry/anchor/default"; + parts { + part { + name: "bg"; + type: RECT; + scale: 1; + mouse_events: 0; + description { + state: "default" 0.0; + color: 128 0 0 64; + } + } + } + } +} diff --git a/lock_pwd/res/edje/lock_pwd.edc b/lock_pwd/res/edje/lock_pwd.edc new file mode 100755 index 0000000..0f974f3 --- /dev/null +++ b/lock_pwd/res/edje/lock_pwd.edc @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define WIN_WIDTH 720 +#define WIN_HEIGHT 1280 + +#define INDICATOR_HEIGHT 52 + +/* simple password */ +#define HELP_TEXT_AREA_HEIGHT 398 +#define KEYPAD_AREA_HEIGHT 592 +#define CONTROL_AREA_HEIGHT 184 + +#define NUMBER_PANEL_DOT_WIDTH 32 +#define NUMBER_PANEL_DOT_HEIGHT NUMBER_PANEL_DOT_WIDTH +#define NUMBER_PANEL_PADDING_LEFT 144 +#define NUMBER_PANEL_PADDING_RIGHT NUMBER_PANEL_PADDING_LEFT +#define NUMBER_PANEL_WIDTH 96 +#define NUMBER_PANEL_HEIGHT NUMBER_PANEL_WIDTH +#define NUMBER_PANEL_PADDING 16 + +#define NUMBER_KEYPAD_PANEL_WIDTH WIN_WIDTH +#define NUMBER_KEYPAD_PANEL_HEIGHT WIN_HEIGHT +#define NUMBER_KEYPAD_BUTTON_WIDTH (WIN_WIDTH/3) +#define NUMBER_KEYPAD_BUTTON_HEIGHT (KEYPAD_AREA_HEIGHT/4) +#define NUMBER_KEYPAD_BUTTON_PAD_Y 10 + +#define NUMBER_KEYPAD_REL_W(x) ((x)/NUMBER_KEYPAD_PANEL_WIDTH) +#define NUMBER_KEYPAD_REL_H(y) ((y)/NUMBER_KEYPAD_PANEL_HEIGHT) +#define NUMBER_KEYPAD_BUTTON_REL_W(x) ((x)/NUMBER_KEYPAD_BUTTON_WIDTH) +#define NUMBER_KEYPAD_BUTTON_REL_H(y) ((y)/NUMBER_KEYPAD_BUTTON_HEIGHT) + +#define NUMBER_KEYPAD_NUM_SIZE 72 +#define NUMBER_KEYPAD_NUM_TEXT_SIZE 29 + +/* simple password - button pressed color */ +#define LOCK_TEXT_COLOR 245 245 245 255 +#define LOCK_TEXT_COLOR2 0 0 0 0 +#define LOCK_TEXT_COLOR3 0 0 0 178 +#define BUTTON_PRESSED_COLOR 179 179 179 179 + +/* complex password */ +#define LINE_COLOR "AO021" +#define LINE_SHADOW_COLOR "AO017" +#define INFO_FONT_COLOR "ATO033" +#define PASS_FONT_COLOR "ATO035" +#define PASS_FONT_SIZE 43 +#define INFO_FONT_SIZE 30 + +#define IME_RESIZED 1 +#define IME_DOWN 2 + +#define RETURN_TO_CALL_HEIGHT 46 +#define RETURN_TO_CALL_ICON_SIZE 46 + + +collections { + base_scale: 2.6; + +#include "lock_pwd_simple.edc" +#include "lock_pwd_complex.edc" +#include "lock_pwd_control_panel.edc" + + group { + name: "lock_pwd"; + parts { + part { + name: "bg"; + type: SPACER; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0; } + rel2 { relative: 1.0 1.0; } + } + } + part { + name: "sw.bg"; + type: SWALLOW; + description { + state: "default" 0.0; + rel1 { to: "bg"; } + rel2 { to: "bg"; } + } + } + part { + name: "dim.bg"; + type: RECT; + description { + state: "default" 0.0; + color: 20 20 20 100; + rel1 { to: "bg"; } + rel2 { to: "bg"; } + } + } + part { + name: "sw.lock_pwd"; + type: SWALLOW; + description { + state: "default" 0.0; + rel1 { to: "bg"; } + rel2 { to: "bg"; } + } + } + } + } + +} diff --git a/lock_pwd/res/edje/lock_pwd_complex.edc b/lock_pwd/res/edje/lock_pwd_complex.edc new file mode 100755 index 0000000..f484c47 --- /dev/null +++ b/lock_pwd/res/edje/lock_pwd_complex.edc @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +styles { + style { + name: "style_complex_title"; + base: "font=Tizen:style=Regular color=#ffffffff color_class=ATO033 font_size=40 wrap=mixed align=center style=shadow shadow_color=#000000bf text_class=ATO033"; + tag: "br" "\n"; + tag: "hilight" "+ color=#ffff"; + tag: "b" "+ color=#ffff"; + tag: "tab" "\t"; + } +} + + group { + name: "lock-complex-password"; + images { + image: "ls_password_underline.#.png" COMP; + } + parts { + part { + name: "bg"; + type: SPACER; + description { + state: "default" 0.0; + } + } + part { + name: "padding.top.title"; + type: SPACER; + scale: 1; + description { + state: "default" 0.0; + min: WIN_WIDTH 153; + max: WIN_WIDTH 153; + fixed: 1 1; + align: 0.5 0.0; + } + } + part { + name: "title"; + type: TEXTBLOCK; + scale: 1; + effect: "SHADOW"; + description { + state: "default" 0.0; + rel1 { relative: 0.0 1.0; to: "padding.top.title"; } + rel2 { relative: 1.0 1.0; to: "padding.top.title"; } + align: 0.5 0.0; + fixed: 1 1; + color_class: "ATO033"; + text { + style: "style_simple_title"; + min: 0 1; + align: 0.5 0.5; + text: "Enter PIN"; + } + } + description { + state: "show_title" 0.0; + inherit: "default" 0.0; + visible: 1; + } + description { + state: "hide_title" 0.0; + inherit: "default" 0.0; + visible: 0; + } + } + part { + name: "padding.top.entry"; + type: SPACER; + scale: 1; + description { + state: "default" 0.0; + align: 0.5 0.0; + rel1 { relative: 0.0 0.0; to: "bg"; } + rel2 { relative: 1.0 0.0; to: "bg"; } + min: WIN_WIDTH (INDICATOR_HEIGHT+232); + max: WIN_WIDTH (INDICATOR_HEIGHT+232); + fixed: 1 1; + } + } + part { + name: "entry"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + rel1 { relative: 0.0 1.0; to : "padding.top.entry"; } + rel2 { relative: 1.0 1.0; to : "padding.top.entry"; } + min: (WIN_WIDTH-32-32) 70; + max: (WIN_WIDTH-32-32) 70; + fixed: 1 1; + align: 0.5 0.0; + } + } + part { + name: "underline"; + type: IMAGE; + scale: 1; + description { + state: "default" 0.0; + fixed: 1 1; + rel1 { relative: 0.0 1.0; to: "entry"; offset: 0 10;} + rel2 { relative: 1.0 1.0; to: "entry"; offset: 0 10;} + min: 0 4; + max: -1 4; + image.normal: "ls_password_underline.#.png"; + } + } + /* Bottom : changed by IME height */ + part { + name: "spacer.bottom"; + type: SPACER; + scale: 1; + description { + state: "default" 0.0; + min: WIN_WIDTH CONTROL_AREA_HEIGHT; + max: WIN_WIDTH CONTROL_AREA_HEIGHT; + fixed: 1 1; + align: 0.5 1.0; + rel1 { relative: 0.0 1.0; to: "bg"; } + rel2 { relative: 1.0 1.0; to: "bg"; } + } + } + part { + name: "control_panel"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + align: 0.5 0.0; + rel1 { relative: 0.0 0.0; to: "spacer.bottom"; } + rel2 { relative: 1.0 1.0; to: "spacer.bottom"; } + } + } + } //parts + programs { + program { + name: "show.title"; + signal: "show_title"; + action: STATE_SET "show_title" 0.0; + source: "title"; + target: "title"; + } + program { + name: "hide.title"; + signal: "hide_title"; + action: STATE_SET "hide_title" 0.0; + source: "title"; + target: "title"; + } + } //programs + } //gorup diff --git a/lock_pwd/res/edje/lock_pwd_control_panel.edc b/lock_pwd/res/edje/lock_pwd_control_panel.edc new file mode 100644 index 0000000..c4415a5 --- /dev/null +++ b/lock_pwd/res/edje/lock_pwd_control_panel.edc @@ -0,0 +1,329 @@ +/* + * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + styles { + style { + name: "btn_text_style"; + base: "font=Tizen:style=Regular color=#FFFFFF font_size=32 wrap=none align=center"; + } + } + + group { + name: "lock-control-panel"; + images { + image: "event_close_bg.#.png" COMP; + } + parts { + part { + name: "bg"; + type: SPACER; + description { + state: "default" 0.0; + } + } + part { + name: "padding.top"; + type: SPACER; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0; to: "bg"; } + rel2 { relative: 1.0 0.0; to: "bg"; } + } + } + part { + name: "padding.left"; + type: SPACER; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0; to: "bg"; } + rel2 { relative: 38/WIN_WIDTH 1.0; to: "bg"; } + } + } + part { + name: "padding.right"; + type: SPACER; + description { + state: "default" 0.0; + rel1 { relative: (WIN_WIDTH-50)/WIN_WIDTH 0.0; to: "bg"; } + rel2 { relative: 1.0 1.0; to: "bg"; } + } + } + part { + name: "padding.bottom"; + type: SPACER; + description { + state: "default" 0.0; + rel1 { relative: 0.0 (CONTROL_AREA_HEIGHT-42)/CONTROL_AREA_HEIGHT; to: "bg"; } + rel2 { relative: 1.0 1.0; to: "bg"; } + } + } + + /* Return to Call*/ + part { + name: "sw.btn.return_to_call"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + align: 0.0 1.0; + min: 1 46; + rel1 { relative: 1.0 0.0; to_x: "padding.left"; to_y: "padding.btn"; } + rel2 { relative: 0.0 0.0; to_x: "btn.cancel"; to_y: "padding.btn"; } + } + } + + part { + name: "padding.btn"; + type: SPACER; + scale: 1; + description { + state: "default" 0.0; + align: 0.0 1.0; + min: WIN_WIDTH 16; + max: WIN_WIDTH 16; + rel1 { relative: 0.0 0.0; to_x: "bg"; to_y: "sw.btn.plmn"; } + rel2 { relative: 1.0 0.0; to_x: "bg"; to_y: "sw.btn.plmn"; } + } + } + + /* PLMN-SPN */ + part { + name: "sw.btn.plmn"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + align: 0.0 1.0; + min: 1 46; + rel1 { relative: 1.0 0.0; to_x: "padding.left"; to_y: "padding.bottom"; } + rel2 { relative: 0.0 0.0; to_x: "btn.cancel"; to_y: "padding.bottom"; } + } + } + + /* Cancel */ + part { + name: "rect.cancel.btn"; + type: SPACER; + description { + state: "default" 0.0; + align: 1.0 1.0; + rel1 { to: "txt.cancel"; } + rel2 { to: "txt.cancel"; } + } + } + part { + name: "txt.cancel"; + type: TEXTBLOCK; + scale: 1; + repeat_events: 1; + description { + state: "default" 0.0; + align: 1.0 1.0; + rel1 { relative: 0.0 0.0; to_x: "padding.right"; to_y: "padding.bottom"; } + rel2 { relative: 0.0 0.0; to_x: "padding.right"; to_y: "padding.bottom"; } + text { + style: "btn_text_style"; + min: 1 1; + ellipsis: -1; + align: 0.5 0.5; + text: "CANCEL"; + } + } + } + part { + name: "btn.cancel"; + type: IMAGE; + description { + state: "default" 0.0; + align: 1.0 0.0; + rel1 { to: "txt.cancel"; offset: -10 0; } + rel2 { to: "txt.cancel"; offset: 10 0; } + image { + normal: "event_close_bg.#.png"; + } + color: 100 100 100 100; + } + description { + state: "press" 0.0; + inherit: "default" 0.0; + color: 50 50 50 50; + } + description { + state: "show" 0.0; + inherit: "default" 0.0; + color: 178 178 178 178; + } + } + part { + name: "btn.cancel.block"; + type: RECT; + mouse_events: 1; + repeat_events: 0; + description { + state: "default" 0.0; + rel1 { to: "btn.cancel"; } + rel2 { to: "btn.cancel"; } + color: 0 0 0 0; + visible: 0; + } + description { + state: "show" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } + } + programs { + program { + signal: "btn,cancel,enable"; + source: "prog"; + action: STATE_SET "default" 0.0; + target: "btn.cancel.block"; + target: "btn.cancel"; + } + program { + signal: "btn,cancel,disable"; + source: "prog"; + action: STATE_SET "show" 0.0; + target: "btn.cancel.block"; + target: "btn.cancel"; + } + program { + name: "btn,cancel,press"; + signal: "mouse,down,1"; + source: "btn.cancel"; + action: STATE_SET "press" 0.0; + target: "btn.cancel"; + } + program { + name: "btn,cancel,release"; + signal: "mouse,up,1"; + source: "btn.cancel"; + action: STATE_SET "default" 0.0; + target: "btn.cancel"; + } + program { + name: "btn,cancel,clicked"; + signal: "mouse,clicked,1"; + source: "btn.cancel"; + action: SIGNAL_EMIT "btn,cancel,clicked" "btn.cancel"; + } + } + } + + group { + name: "btn-return-to-call"; + images { + image: "ls_icon_call.png" COMP; + } + parts { + part { + name: "bg"; + type: SPACER; + description { + state: "default" 0.0; + } + } + part { + name: "img.call.icon"; + type: IMAGE; + scale: 1; + description { + state: "default" 0.0; + align: 0.0 0.0; + min: RETURN_TO_CALL_ICON_SIZE RETURN_TO_CALL_ICON_SIZE; + max: RETURN_TO_CALL_ICON_SIZE RETURN_TO_CALL_ICON_SIZE; + rel1 { relative: 0.0 0.0; to: "bg"; } + rel2 { relative: 0.0 0.0; to: "bg"; } + image { + normal: "ls_icon_call.png"; + } + } + } + part { + name: "padding.icon"; + type: SPACER; + scale: 1; + description { + state: "default" 0.0; + align: 0.0 0.0; + min: 10 RETURN_TO_CALL_HEIGHT; + max: 10 RETURN_TO_CALL_HEIGHT; + rel1 { relative: 1.0 0.0; to_x: "img.call.icon"; to_y: "bg"; } + rel2 { relative: 1.0 1.0; to_x: "img.call.icon"; to_y: "bg"; } + } + } + part { + name: "txt.return_to_call"; + type: TEXTBLOCK; + scale: 1; + description { + state: "default" 0.0; + align: 0.0 0.0; + rel1 { relative: 1.0 0.0; to_x: "padding.icon"; to_y: "bg"; } + rel2 { relative: 1.0 1.0; to_x: "padding.icon"; to_y: "bg"; } + text { + style: "btn_text_style"; + min: 1 1; + ellipsis: -1; + align: 0.0 0.5; + text: "Return to call"; + } + } + } + part { + name: "btn.return_to_call"; + type: RECT; + mouse_events: 1; + scale: 1; + description { + state: "default" 0.0; + align: 0.0 0.0; + color: 0 0 0 0; + rel1 { relative: 0.0 0.0; to_x: "img.call.icon"; to_y: "bg"; } + rel2 { relative: 1.0 1.0; to_x: "txt.return_to_call"; to_y: "bg"; } + } + description { + state: "press" 0.0; + inherit: "default" 0.0; + color: 50 50 50 50; + } + } + } + programs { + program { + name: "btn,return_to_call,press"; + signal: "mouse,down,1"; + source: "btn.return_to_call"; + action: STATE_SET "press" 0.0; + target: "btn.return_to_call"; + } + program { + name: "btn,return_to_call,release"; + signal: "mouse,up,1"; + source: "btn.return_to_call"; + action: STATE_SET "default" 0.0; + target: "btn.return_to_call"; + } + program { + name: "btn,return_to_call,clicked"; + signal: "mouse,clicked,1"; + source: "btn.return_to_call"; + action: SIGNAL_EMIT "btn,return_to_call,clicked" "btn.return_to_call"; + } + } + } diff --git a/lock_pwd/res/edje/lock_pwd_simple.edc b/lock_pwd/res/edje/lock_pwd_simple.edc new file mode 100755 index 0000000..759435b --- /dev/null +++ b/lock_pwd/res/edje/lock_pwd_simple.edc @@ -0,0 +1,452 @@ +/* + * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define PART_KEYPAD_BUTTON_NUMBER(keypad_button, offx, offy, button_number, button_text) \ + part { \ + name: keypad_button; \ + type: RECT; \ + mouse_events: 1; \ + repeat_events: 1; \ + description { \ + state: "default" 0.0; \ + color: 0 0 0 0; \ + fixed: 1 1; \ + rel1 { relative: NUMBER_KEYPAD_REL_W(offx) NUMBER_KEYPAD_REL_H(WIN_HEIGHT-CONTROL_AREA_HEIGHT-KEYPAD_AREA_HEIGHT+offy); to:"bg";} \ + rel2 { relative: NUMBER_KEYPAD_REL_W(offx+NUMBER_KEYPAD_BUTTON_WIDTH) NUMBER_KEYPAD_REL_H(WIN_HEIGHT-CONTROL_AREA_HEIGHT-KEYPAD_AREA_HEIGHT+offy+NUMBER_KEYPAD_BUTTON_HEIGHT); to:"bg"; } \ + } \ + description { \ + state: "pressed" 0.0; \ + inherit: "default" 0.0; \ + color: BUTTON_PRESSED_COLOR; \ + } \ + description { \ + state: "hide" 0.0; \ + visible: 0; \ + } \ + } \ + part { \ + name: keypad_button"_feedback"; \ + type: RECT; \ + repeat_events: 1; \ + description { \ + state: "default" 0.0; \ + fixed: 1 1; \ + color: BUTTON_PRESSED_COLOR; \ + visible: 0; \ + rel1.to: keypad_button; \ + rel2.to: keypad_button; \ + } \ + description { \ + state: "pressed" 0.0; \ + inherit: "default" 0.0; \ + visible: 1; \ + } \ + } \ + part { \ + name: keypad_button"_number"; \ + type: TEXT; \ + scale: 1; \ + effect: "SHADOW"; \ + mouse_events: 0; \ + repeat_events: 1; \ + description { \ + state: "default" 0.0; \ + fixed: 1 1; \ + align: 0.5 0.5; \ + color_class: PASS_KEY_NUM_COLOR; \ + visible: 1; \ + rel1 { relative: 0.0 (17)/NUMBER_KEYPAD_BUTTON_HEIGHT; to: keypad_button;} \ + rel2 { relative: 1.0 (17+81)/NUMBER_KEYPAD_BUTTON_HEIGHT; to: keypad_button;} \ + text { \ + align: 0.5 0.5; \ + size: NUMBER_KEYPAD_NUM_SIZE; \ + text: button_number; \ + font: "Tizen:style=SNum-3L"; \ + text_class: "tizen"; \ + } \ + } \ + description { \ + state: "hide" 0.0; \ + inherit: "default" 0.0; \ + visible: 0; \ + } \ + description { \ + state: "center" 0.0; \ + inherit: "default" 0.0; \ + align: 0.5 0.5; \ + rel1 { relative: 0.0 0.0; to: keypad_button;} \ + rel2 { relative: 1.0 1.0; to: keypad_button;} \ + text { \ + align: 0.5 0.5; \ + size: NUMBER_KEYPAD_NUM_SIZE; \ + text: button_number; \ + font: "Tizen:style=SNum-3L"; \ + text_class: "tizen"; \ + } \ + } \ + } \ + part { \ + name: keypad_button"_text"; \ + type: TEXT; \ + scale: 1; \ + effect: "SHADOW"; \ + mouse_events: 0; \ + repeat_events: 1; \ + description { \ + state: "default" 0.0; \ + visible: 1; \ + fixed: 1 1; \ + align: 0.5 0.5; \ + color_class: PASS_KEY_SUB_COLOR; \ + rel1 { relative: 0.0 (17+81)/NUMBER_KEYPAD_BUTTON_HEIGHT; to: keypad_button;} \ + rel2 { relative: 1.0 (17+81+24)/NUMBER_KEYPAD_BUTTON_HEIGHT; to: keypad_button;} \ + text { \ + size: NUMBER_KEYPAD_NUM_TEXT_SIZE; \ + text: button_text; \ + align: 0.5 0.5; \ + font: "Tizen:style=Regular"; \ + text_class: "tizen"; \ + } \ + } \ + description { \ + state: "hide" 0.0; \ + inherit: "default" 0.0; \ + visible: 0; \ + } \ + } + +#define PROG_KEYPAD_BUTTON(keypad_button) \ + program { \ + name: "down_"keypad_button; \ + signal: "mouse,down,*"; \ + source: keypad_button; \ + script { \ + set_state(PART:keypad_button"_feedback", "pressed", 0.0); \ + emit("keypad_down", keypad_button); \ + } \ + } \ + program { \ + name: "multi_down_"keypad_button; \ + signal: "multi_down_"keypad_button; \ + source: keypad_button; \ + script { \ + set_state(PART:keypad_button"_feedback", "pressed", 0.0); \ + emit("keypad_down", keypad_button); \ + } \ + } \ + program { \ + name: "ani_"keypad_button; \ + signal: "ani"; \ + source: keypad_button; \ + action: STATE_SET "default" 0.0; \ + transition: SINUSOIDAL 0.05; \ + target: keypad_button"_feedback"; \ + } \ + program { \ + name: "up_"keypad_button; \ + signal: "mouse,up,1"; \ + source: keypad_button; \ + script { \ + emit("keypad_down_up", keypad_button); \ + emit("ani", keypad_button); \ + } \ + } \ + program { \ + name: "multi_up_"keypad_button; \ + signal: "multi_up_"keypad_button; \ + source: keypad_button; \ + script { \ + emit("keypad_down_up", keypad_button); \ + emit("ani", keypad_button); \ + } \ + } \ + program { \ + name: "clicked_"keypad_button; \ + signal: "mouse,clicked,1"; \ + source: keypad_button; \ + script { \ + emit("keypad_down_clicked", keypad_button); \ + } \ + } \ + program { \ + name: "multi_clicked_"keypad_button; \ + signal: "multi_clicked_"keypad_button; \ + source: keypad_button; \ + script { \ + emit("keypad_down_clicked", keypad_button); \ + } \ + } \ + +#define PANEL_PART(idx) \ + part { \ + name: "panel"idx; \ + type: TEXT; \ + scale: 1; \ + effect: "SHADOW"; \ + description { \ + state: "default" 0.0; \ + fixed: 1 1; \ + rel1 { relative: NUMBER_KEYPAD_REL_W(NUMBER_PANEL_PADDING_LEFT+(idx*(NUMBER_PANEL_WIDTH+NUMBER_PANEL_PADDING))) NUMBER_KEYPAD_REL_H(INDICATOR_HEIGHT+HELP_TEXT_AREA_HEIGHT-166+35); to: "bg"; } \ + rel2 { relative: NUMBER_KEYPAD_REL_W(NUMBER_PANEL_PADDING_LEFT+(idx*(NUMBER_PANEL_WIDTH+NUMBER_PANEL_PADDING))+NUMBER_PANEL_WIDTH) NUMBER_KEYPAD_REL_H(INDICATOR_HEIGHT+HELP_TEXT_AREA_HEIGHT-166+35+NUMBER_PANEL_HEIGHT); to: "bg"; } \ + text { \ + size: 90; \ + font: "Tizen:style=SNum-3L"; \ + text_class: "tizen"; \ + } \ + visible: 0; \ + } \ + description { \ + state: "show" 0.0; \ + inherit: "default" 0.0; \ + visible: 1; \ + } \ + } \ + part { \ + name: "dot"idx; \ + type: IMAGE; \ + scale: 1; \ + description { \ + state: "default" 0.0; \ + fixed: 1 1; \ + min: NUMBER_PANEL_DOT_WIDTH NUMBER_PANEL_DOT_HEIGHT; \ + max: NUMBER_PANEL_DOT_WIDTH NUMBER_PANEL_DOT_HEIGHT; \ + rel1 { to: "panel"idx; } \ + rel2 { to: "panel"idx; } \ + image { \ + normal: "ls_pin_dot.png"; \ + } \ + visible: 0; \ + } \ + description { \ + state: "show" 0.0; \ + inherit: "default" 0.0; \ + visible: 1; \ + } \ + } \ + +#define INPUT_PROGRAM(idx) \ + program { \ + name: "input_show"idx; \ + action: STATE_SET "show" 0.0; \ + source: "keyboard"; \ + signal: "input_show"idx; \ + target: "panel"idx; \ + } \ + program { \ + name: "input_hide"idx; \ + action: STATE_SET "default" 0.0; \ + source: "keyboard"; \ + signal: "input_hide"idx; \ + target: "panel"idx; \ + } \ + program { \ + name: "dot_show"idx; \ + action: STATE_SET "show" 0.0; \ + source: "keyboard"; \ + signal: "dot_show"idx; \ + target: "dot"idx; \ + after: "input_hide"idx; \ + } \ + program { \ + name: "dot_hide"idx; \ + action: STATE_SET "default" 0.0; \ + source: "keyboard"; \ + signal: "dot_hide"idx; \ + target: "dot"idx; \ + after: "input_hide"idx; \ + } \ + + +#define PART_DBG(part_name, R, G, B, A) \ + part { \ + name: part_name",dbg"; \ + type: RECT; \ + mouse_events: 1; \ + repeat_events: 1; \ + description { \ + state: "default" 0.0; \ + rel1 { relative: 0.0 0.0; to: part_name; } \ + rel2 { relative: 1.0 1.0; to: part_name; } \ + color: R G B A; \ + } \ + } \ + +styles { + style { + name: "style_simple_title"; + base: "font=Tizen:style=Regular color=#ffffffff color_class=ATO030 font_size=40 wrap=mixed align=center style=shadow shadow_color=#000000bf text_class=ATO030"; + tag: "br" "\n"; + tag: "hilight" "+ color=#ffff"; + tag: "b" "+ color=#ffff"; + tag: "tab" "\t"; + } +} + + group { + name: "lock-simple-password"; + images { + image: "ls_pin_dot.png" COMP; + image: "ls_back_02_nor.png" COMP; + image: "ls_back_02_press.png" COMP; + } + parts { + part { + name: "bg"; + type: SPACER; + description { + state: "default" 0.0; + } + } + part { + name: "title"; + type: TEXTBLOCK; + scale: 1; + effect: "SHADOW"; + description { + state: "default" 0.0; + rel1 { relative: 0.0 (INDICATOR_HEIGHT+HELP_TEXT_AREA_HEIGHT-166-25-54)/WIN_HEIGHT; to: "bg"; } + rel2 { relative: 1.0 (INDICATOR_HEIGHT+HELP_TEXT_AREA_HEIGHT-166-25)/WIN_HEIGHT; to: "bg"; } + fixed: 1 1; + color_class: "ATO033"; + text { + style: "style_simple_title"; + min: 0 1; + align: 0.5 0.5; + text: "Enter PIN"; + } + } + description { + state: "show_title" 0.0; + inherit: "default" 0.0; + visible: 1; + } + description { + state: "hide_title" 0.0; + inherit: "default" 0.0; + visible: 0; + } + } + + PANEL_PART(0) + PANEL_PART(1) + PANEL_PART(2) + PANEL_PART(3) + + PART_KEYPAD_BUTTON_NUMBER("1", 0, 0, "1", ""); + PART_KEYPAD_BUTTON_NUMBER("2", NUMBER_KEYPAD_BUTTON_WIDTH, 0, "2", "ABC"); + PART_KEYPAD_BUTTON_NUMBER("3", 2*(NUMBER_KEYPAD_BUTTON_WIDTH), 0, "3", "DEF"); + PART_KEYPAD_BUTTON_NUMBER("4", 0, NUMBER_KEYPAD_BUTTON_HEIGHT, "4", "GHI"); + PART_KEYPAD_BUTTON_NUMBER("5", NUMBER_KEYPAD_BUTTON_WIDTH, NUMBER_KEYPAD_BUTTON_HEIGHT, "5", "JKL"); + PART_KEYPAD_BUTTON_NUMBER("6", 2*(NUMBER_KEYPAD_BUTTON_WIDTH), NUMBER_KEYPAD_BUTTON_HEIGHT, "6", "MNO"); + PART_KEYPAD_BUTTON_NUMBER("7", 0, 2*(NUMBER_KEYPAD_BUTTON_HEIGHT), "7", "PQRS"); + PART_KEYPAD_BUTTON_NUMBER("8", NUMBER_KEYPAD_BUTTON_WIDTH, 2*(NUMBER_KEYPAD_BUTTON_HEIGHT), "8", "TUV"); + PART_KEYPAD_BUTTON_NUMBER("9", 2*(NUMBER_KEYPAD_BUTTON_WIDTH), 2*(NUMBER_KEYPAD_BUTTON_HEIGHT), "9", "WXYZ"); + PART_KEYPAD_BUTTON_NUMBER("0", NUMBER_KEYPAD_BUTTON_WIDTH, 3*(NUMBER_KEYPAD_BUTTON_HEIGHT), "0", ""); + + part { + name: "Backspace"; + type: IMAGE; + repeat_events: 1; + description { + state: "default" 0.0; + rel1 { relative: NUMBER_KEYPAD_REL_W(2*(NUMBER_KEYPAD_BUTTON_WIDTH)) NUMBER_KEYPAD_REL_H(WIN_HEIGHT-CONTROL_AREA_HEIGHT-KEYPAD_AREA_HEIGHT+3*(NUMBER_KEYPAD_BUTTON_HEIGHT)); to: "bg"; } + rel2 { relative: NUMBER_KEYPAD_REL_W(2*(NUMBER_KEYPAD_BUTTON_WIDTH)+NUMBER_KEYPAD_BUTTON_WIDTH) NUMBER_KEYPAD_REL_H(WIN_HEIGHT-CONTROL_AREA_HEIGHT-KEYPAD_AREA_HEIGHT+3*(NUMBER_KEYPAD_BUTTON_HEIGHT)+NUMBER_KEYPAD_BUTTON_HEIGHT); to: "bg"; } + fixed: 1 1; + image.normal: "ls_back_02_nor.png"; + align: 0.5 0.5; + } + description { + state: "pressed" 0.0; + inherit: "default" 0.0; + image.normal: "ls_back_02_press.png"; + } + } + part { + name: "Backspace_feedback"; + type: RECT; + mouse_events: 1; + repeat_events: 1; + description { + state: "default" 0.0; + rel1 { to: "Backspace"; } + rel2 { to: "Backspace"; } + visible: 0; + color: BUTTON_PRESSED_COLOR; + } + description { + state: "pressed" 0.0; + inherit: "default" 0.0; + visible: 1; + } + description { + state: "hide" 0.0; + inherit: "default" 0.0; + } + } + /* Bottom */ + part { + name: "control_panel"; + type: SWALLOW; + description { + state: "default" 0.0; + rel1 { relative: 0.0 (WIN_HEIGHT-CONTROL_AREA_HEIGHT)/WIN_HEIGHT; to: "bg"; } + rel2 { relative: 1.0 1.0; to: "bg"; } + } + } + } + programs { + program { + name: "init.layout"; + signal: "load"; + source: ""; + script { + set_state(PART:"0_number", "center", 0.0); + } + } + + INPUT_PROGRAM(0) + INPUT_PROGRAM(1) + INPUT_PROGRAM(2) + INPUT_PROGRAM(3) + + PROG_KEYPAD_BUTTON("1") + PROG_KEYPAD_BUTTON("2") + PROG_KEYPAD_BUTTON("3") + PROG_KEYPAD_BUTTON("4") + PROG_KEYPAD_BUTTON("5") + PROG_KEYPAD_BUTTON("6") + PROG_KEYPAD_BUTTON("7") + PROG_KEYPAD_BUTTON("8") + PROG_KEYPAD_BUTTON("9") + PROG_KEYPAD_BUTTON("0") + PROG_KEYPAD_BUTTON("Backspace") + } + program { + name: "show.title"; + signal: "show_title"; + action: STATE_SET "show_title" 0.0; + source: "title"; + target: "title"; + } + program { + name: "hide.title"; + signal: "hide_title"; + action: STATE_SET "hide_title" 0.0; + source: "title"; + target: "title"; + } + } + diff --git a/lock_pwd/src/lock_pwd_complex.c b/lock_pwd/src/lock_pwd_complex.c new file mode 100644 index 0000000..dd70267 --- /dev/null +++ b/lock_pwd/src/lock_pwd_complex.c @@ -0,0 +1,397 @@ +/* + * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <Elementary.h> +#include <Ecore.h> + +#include "lock_mgr.h" +#include "util.h" +#include "lock_pwd_util.h" +#include "lock_pwd_complex.h" +#include "lock_pwd_control_panel.h" + +#define MAX_COMPLEX_PASSWORD_NUM 16 +#define LOCK_PWD_ENTRY_EDJE_FILE "/usr/share/starter/lock_pwd/res/edje/lock_entry.edj" + +static struct _s_lock_pwd_complex { + Evas_Object *pwd_complex_layout; + Evas_Object *pwd_complex_entry; + + Eina_Bool is_blocked; + Ecore_Timer *timer_pin; + Elm_Theme *entry_theme; + int pin_time_remain; +} s_lock_pwd_complex = { + .pwd_complex_layout = NULL, + .pwd_complex_entry = NULL, + + .is_blocked = EINA_FALSE, + .timer_pin = NULL, + .entry_theme = NULL, + .pin_time_remain = PASSWORD_BLOCK_SECONDS, +}; + + + + +Eina_Bool lock_pwd_complex_is_blocked_get(void) +{ + return s_lock_pwd_complex.is_blocked; +} + +static void _pwd_complex_layout_title_set(const char *title) +{ + ret_if(!s_lock_pwd_complex.pwd_complex_layout); + ret_if(!title); + + elm_object_part_text_set(s_lock_pwd_complex.pwd_complex_layout, "title", title); +} + + + +void lock_pwd_complex_entry_clear(void) +{ + ret_if(!s_lock_pwd_complex.pwd_complex_entry); + + elm_entry_entry_set(s_lock_pwd_complex.pwd_complex_entry, ""); +} + + + +static Eina_Bool _pwd_complex_entry_clear(void *data) +{ + lock_pwd_complex_entry_clear(); + return ECORE_CALLBACK_CANCEL; +} + + + +static void _pwd_complex_lock_time_init(void) +{ + if (vconf_set_str(VCONFKEY_SETAPPL_PASSWORD_TIMESTAMP_STR, "") < 0) { + _E("Failed to set vconfkey : %s", VCONFKEY_SETAPPL_PASSWORD_TIMESTAMP_STR); + } +} + + + +static void _pwd_complex_lock_time_save(void) +{ + time_t cur_time = time(NULL); + char buf[64] = { 0, }; + snprintf(buf, sizeof(buf), "%ld", cur_time); + if (vconf_set_str(VCONFKEY_SETAPPL_PASSWORD_TIMESTAMP_STR, buf) < 0) { + _E("Failed to set vconfkey : %s", VCONFKEY_SETAPPL_PASSWORD_TIMESTAMP_STR); + } +} + + + +static void _pwd_complex_event_correct(lock_pwd_event_e event) +{ + _D("%s", __func__); + + lock_pwd_util_win_hide(); + lock_pwd_complex_entry_clear(); + _pwd_complex_layout_title_set(_("IDS_COM_BODY_ENTER_PASSWORD")); + + lock_mgr_idle_lock_state_set(VCONFKEY_IDLE_UNLOCK); + lock_mgr_sound_play(LOCK_SOUND_UNLOCK); +} + + + +static void _pwd_complex_event_incorrect(lock_pwd_event_e event) +{ + char temp_str[BUF_SIZE_256] = { 0, }; + char temp_left[BUF_SIZE_256] = { 0, }; + int remain_attempt = 0; + + remain_attempt = lock_pwd_verification_remain_attempt_get(); + _D("remain_attempt(%d)", remain_attempt); + + if (remain_attempt == 1) { + strncpy(temp_left, _("IDS_IDLE_BODY_1_ATTEMPT_LEFT"), sizeof(temp_left)); + temp_left[sizeof(temp_left) - 1] = '\0'; + } else { + snprintf(temp_left, sizeof(temp_left), _("IDS_IDLE_BODY_PD_ATTEMPTS_LEFT"), remain_attempt); + } + snprintf(temp_str, sizeof(temp_str), "%s<br>%s", _("IDS_IDLE_BODY_INCORRECT_PASSWORD"), temp_left); + _pwd_complex_layout_title_set(temp_str); + + ecore_timer_add(0.1, _pwd_complex_entry_clear, NULL); + + lock_pwd_verification_popup_create(event); +} + + + +static Eina_Bool _wrong_pwd_wait_timer_cb(void *data) +{ + char try_again_buf[BUF_SIZE_256] = { 0, }; + char incorrect_pass_buf[BUF_SIZE_256] = { 0, }; + + retv_if(!s_lock_pwd_complex.pwd_complex_layout, ECORE_CALLBACK_CANCEL); + + snprintf(try_again_buf, sizeof(try_again_buf), _("IDS_LCKSCN_POP_TRY_AGAIN_IN_PD_SECONDS"), s_lock_pwd_complex.pin_time_remain); + snprintf(incorrect_pass_buf, sizeof(incorrect_pass_buf), "%s<br>%s", _("IDS_IDLE_BODY_INCORRECT_PASSWORD"), try_again_buf); + _pwd_complex_layout_title_set(incorrect_pass_buf); + + if (s_lock_pwd_complex.pin_time_remain == PASSWORD_BLOCK_SECONDS || + s_lock_pwd_complex.pin_time_remain > 0) { + s_lock_pwd_complex.pin_time_remain--; + return ECORE_CALLBACK_RENEW; + } else { + lock_pwd_complex_view_init(); + + int lcd_state = lock_mgr_lcd_state_get(); + if (lcd_state == LCD_STATE_OFF) { + if (!lock_mgr_lockscreen_launch()) { + _E("Failed to launch lockscreen"); + } + } + } + + return ECORE_CALLBACK_CANCEL; +} + + + +static void _pwd_complex_event_input_block(lock_pwd_event_e event) +{ + _D("%s", __func__); + + int block_sec = PASSWORD_BLOCK_SECONDS; + char try_again_buf[BUF_SIZE_256] = { 0, }; + char incorrect_pass_buf[BUF_SIZE_256] = { 0, }; + + ret_if(!s_lock_pwd_complex.pwd_complex_layout); + + _pwd_complex_lock_time_save(); + + snprintf(try_again_buf, sizeof(try_again_buf), _("IDS_LCKSCN_POP_TRY_AGAIN_IN_PD_SECONDS"), block_sec); + snprintf(incorrect_pass_buf, sizeof(incorrect_pass_buf), "%s<br>%s", _("IDS_IDLE_BODY_INCORRECT_PASSWORD"), try_again_buf); + _pwd_complex_layout_title_set(incorrect_pass_buf); + + s_lock_pwd_complex.is_blocked = EINA_TRUE; + + if (s_lock_pwd_complex.timer_pin) { + ecore_timer_del(s_lock_pwd_complex.timer_pin); + s_lock_pwd_complex.timer_pin = NULL; + } + + s_lock_pwd_complex.timer_pin = ecore_timer_add(1.0, _wrong_pwd_wait_timer_cb, NULL); + + ecore_timer_add(0.1, _pwd_complex_entry_clear, NULL); + + lock_pwd_verification_popup_create(event); + + lock_pwd_control_panel_cancel_btn_enable_set(EINA_FALSE); +} + + + +void lock_pwd_complex_event(lock_pwd_event_e event) +{ + switch(event) { + case PWD_EVENT_CORRECT: + _pwd_complex_event_correct(event); + break; + case PWD_EVENT_INCORRECT_WARNING: + case PWD_EVENT_INCORRECT: + _pwd_complex_event_incorrect(event); + break; + case PWD_EVENT_INPUT_BLOCK_WARNING: + case PWD_EVENT_INPUT_BLOCK: + _pwd_complex_event_input_block(event); + break; + case PWD_EVENT_EMPTY: + break; + case PWD_EVENT_OVER: + break; + default: + break; + } +} + + + +static void _pwd_complex_enter_cb(void *data, Evas_Object *obj, void *event_info) +{ + char buf[BUF_SIZE_256] = { 0, }; + char *markup_txt = NULL; + + ret_if(!obj); + + const char *password = elm_entry_entry_get(obj); + ret_if(!password); + + markup_txt = elm_entry_utf8_to_markup(password); + snprintf(buf, sizeof(buf), "%s", markup_txt); + free(markup_txt); + + lock_pwd_event_e pwd_event = lock_pwd_verification_verify(buf); + lock_pwd_complex_event(pwd_event); +} + + + +static void _pwd_complex_entry_customize(Evas_Object *entry) +{ + static Elm_Entry_Filter_Limit_Size limit_filter_data_alpha; + Elm_Theme *th = elm_theme_new(); + ret_if(!th); + + elm_theme_ref_set(th, NULL); + elm_theme_extension_add(th, LOCK_PWD_ENTRY_EDJE_FILE); + elm_object_theme_set(entry, th); + elm_object_style_set(entry, "lockscreen_complex_password_style"); + limit_filter_data_alpha.max_char_count = MAX_COMPLEX_PASSWORD_NUM; + limit_filter_data_alpha.max_byte_count = 0; + elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, &limit_filter_data_alpha); + + s_lock_pwd_complex.entry_theme = th; +} + + + +Evas_Object *_pwd_complex_entry_create(void *data) +{ + Evas_Object *parent = NULL; + Evas_Object *entry = NULL; + + parent = (Evas_Object *)data; + retv_if(!parent, NULL); + + entry = elm_entry_add(parent); + retv_if(!entry, NULL); + + _pwd_complex_entry_customize(entry); + + elm_entry_single_line_set(entry, EINA_TRUE); + elm_entry_password_set(entry, EINA_TRUE); + elm_entry_entry_set(entry, ""); + elm_entry_cursor_end_set(entry); + elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT); + elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_PASSWORD); + elm_entry_input_panel_imdata_set(entry, "type=lockscreen", 15); + elm_entry_input_panel_return_key_type_set(entry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE); + + evas_object_smart_callback_add(entry, "activated", _pwd_complex_enter_cb, NULL); + + evas_object_show(entry); + + return entry; +} + + + +Evas_Object *lock_pwd_complex_layout_create(void *data) +{ + Evas_Object *parent = NULL; + Evas_Object *pwd_complex_layout = NULL; + Evas_Object *pwd_complex_entry = NULL; + Evas_Object *pwd_control_panel = NULL; + + lock_pwd_verification_policy_create(); + + parent = (Evas_Object *)data; + retv_if(!parent, NULL); + + pwd_complex_layout = elm_layout_add(parent); + goto_if(!pwd_complex_layout, ERROR); + s_lock_pwd_complex.pwd_complex_layout = pwd_complex_layout; + + if (!elm_layout_file_set(pwd_complex_layout, LOCK_PWD_EDJE_FILE, "lock-complex-password")) { + _E("Failed to set edje file : %s", LOCK_PWD_EDJE_FILE); + goto ERROR; + } + + evas_object_size_hint_weight_set(pwd_complex_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(pwd_complex_layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(pwd_complex_layout); + + /* create entry */ + pwd_complex_entry = _pwd_complex_entry_create(pwd_complex_layout); + goto_if(!pwd_complex_entry, ERROR); + s_lock_pwd_complex.pwd_complex_entry = pwd_complex_entry; + + elm_object_part_content_set(pwd_complex_layout, "entry", pwd_complex_entry); + + _pwd_complex_layout_title_set(_("IDS_COM_BODY_ENTER_PASSWORD")); + + /* create control panel */ + pwd_control_panel = lock_pwd_control_panel_create(pwd_complex_layout); + if (pwd_control_panel) { + elm_object_part_content_set(pwd_complex_layout, "control_panel", pwd_control_panel); + } else { + _E("Failed to create password control panel"); + } + + evas_object_show(pwd_complex_layout); + + return pwd_complex_layout; + +ERROR: + _E("Failed to create complex password layout"); + + if (pwd_complex_layout) { + evas_object_del(pwd_complex_layout); + s_lock_pwd_complex.pwd_complex_layout = NULL; + } + + return NULL; +} + + +void lock_pwd_complex_layout_destroy(void) +{ + if (s_lock_pwd_complex.timer_pin) { + ecore_timer_del(s_lock_pwd_complex.timer_pin); + s_lock_pwd_complex.timer_pin = NULL; + } + + if (s_lock_pwd_complex.entry_theme) { + elm_theme_free(s_lock_pwd_complex.entry_theme); + s_lock_pwd_complex.entry_theme = NULL; + } + + if (s_lock_pwd_complex.pwd_complex_entry) { + evas_object_del(s_lock_pwd_complex.pwd_complex_entry); + s_lock_pwd_complex.pwd_complex_entry = NULL; + } + + if (s_lock_pwd_complex.pwd_complex_layout) { + evas_object_del(s_lock_pwd_complex.pwd_complex_layout); + s_lock_pwd_complex.pwd_complex_layout = NULL; + } +} + + + +void lock_pwd_complex_view_init(void) +{ + _D("initialize complex password values"); + _pwd_complex_layout_title_set(_("IDS_COM_BODY_ENTER_PASSWORD")); + elm_object_signal_emit(s_lock_pwd_complex.pwd_complex_layout, "show_title", "title"); + s_lock_pwd_complex.is_blocked = EINA_FALSE; + + lock_pwd_complex_entry_clear(); + + _pwd_complex_lock_time_init(); + + lock_pwd_control_panel_cancel_btn_enable_set(EINA_TRUE); +} diff --git a/lock_pwd/src/lock_pwd_control_panel.c b/lock_pwd/src/lock_pwd_control_panel.c new file mode 100644 index 0000000..52a6675 --- /dev/null +++ b/lock_pwd/src/lock_pwd_control_panel.c @@ -0,0 +1,263 @@ +/* + * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <app_control.h> +#include <utilX.h> +#include <ui-gadget.h> +#include <call-manager.h> + +#include "lock_mgr.h" +#include "util.h" +#include "lock_pwd_util.h" +#include "lock_pwd_control_panel.h" + +static struct _s_lock_pwd_control_panel { + Evas_Object *control_panel_layout; + Evas_Object *btn_cancel; + Evas_Object *btn_return_to_call; + Evas_Object *btn_plmn; + cm_client_h cm_handle; +} s_lock_pwd_control_panel = { + .control_panel_layout = NULL, + .btn_cancel = NULL, + .btn_return_to_call = NULL, + .btn_plmn = NULL, + .cm_handle = NULL, +}; + + + + +void lock_pwd_control_panel_cancel_btn_enable_set(Eina_Bool enable) +{ + ret_if(!s_lock_pwd_control_panel.control_panel_layout); + + if (enable) { + elm_object_signal_emit(s_lock_pwd_control_panel.control_panel_layout, "btn,cancel,enable", "prog"); + } else { + elm_object_signal_emit(s_lock_pwd_control_panel.control_panel_layout, "btn,cancel,disable", "prog"); + } +} + + + +static void _btn_cancel_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source) +{ + _D("Cancel button is clicked"); + + lock_mgr_sound_play(LOCK_SOUND_TAP); + + if (!lock_mgr_lockscreen_launch()) { + _E("Failed to launch lockscreen"); + } + + lock_pwd_util_view_init(); +} + + + +static void _btn_return_to_call_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source) +{ + _D("'Return to call' button is clicked"); + + ret_if(!s_lock_pwd_control_panel.cm_handle); + + cm_activate_ui(s_lock_pwd_control_panel.cm_handle); +} + + + +static Evas_Object *_create_btn_return_to_call(Evas_Object *parent) +{ + Evas_Object *layout = NULL; + + retv_if(!parent, NULL); + + layout = elm_layout_add(parent); + retv_if(!layout, NULL); + + if (!elm_layout_file_set(layout, LOCK_PWD_EDJE_FILE, "btn-return-to-call")) { + _E("Failed to set edje file : %s", LOCK_PWD_EDJE_FILE); + goto error; + } + + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + + elm_object_signal_callback_add(layout, "btn,return_to_call,clicked", "btn.return_to_call", _btn_return_to_call_clicked_cb, NULL); + + evas_object_show(layout); + + return layout; + +error: + if (layout) { + evas_object_del(layout); + } + + return NULL; +} + + + +static void _destroy_btn_return_to_call(void) +{ + if (s_lock_pwd_control_panel.btn_return_to_call) { + elm_object_signal_callback_del(s_lock_pwd_control_panel.btn_return_to_call, "btn,return_to_call,clicked", "btn.return_to_call", _btn_return_to_call_clicked_cb); + evas_object_del(s_lock_pwd_control_panel.btn_return_to_call); + s_lock_pwd_control_panel.btn_return_to_call = NULL; + } +} + + + +#if 0 +static Evas_Object *_create_btn_plmn(Evas_Object *parent) +{ + Evas_Object *plmn = NULL; + + return plmn; +} +#endif + + +static void _destroy_btn_plmn(void) +{ + if (s_lock_pwd_control_panel.btn_plmn) { + evas_object_del(s_lock_pwd_control_panel.btn_plmn); + s_lock_pwd_control_panel.btn_plmn = NULL; + } +} + + + +static void _call_status_changed_cb(cm_call_status_e call_status, const char *call_num, void *user_data) +{ + Evas_Object *control_panel_layout = NULL; + Evas_Object *btn_return_to_call = NULL; + + control_panel_layout = user_data; + ret_if(!control_panel_layout); + + btn_return_to_call = elm_object_part_content_get(control_panel_layout, "sw.btn.return_to_call"); + + switch (call_status) { + case CM_CALL_STATUS_IDLE: + if (btn_return_to_call) { + _D("remove 'Return to call' button"); + _destroy_btn_return_to_call(); + } + break; + case CM_CALL_STATUS_RINGING: + case CM_CALL_STATUS_OFFHOOK: + if (!btn_return_to_call) { + _D("create 'Return to call' button"); + btn_return_to_call = _create_btn_return_to_call(control_panel_layout); + if (btn_return_to_call) { + elm_object_part_content_set(control_panel_layout, "sw.btn.return_to_call", btn_return_to_call); + s_lock_pwd_control_panel.btn_return_to_call = btn_return_to_call; + } else { + _E("Failed to add a button for Return to call"); + } + } + break; + default: + _E("call status error : %d", call_status); + break; + } +} + + + +Evas_Object *lock_pwd_control_panel_create(Evas_Object *parent) +{ + Evas_Object *control_panel_layout = NULL; + int ret = 0; + + /* Initialize callmgr-client */ + cm_init(&s_lock_pwd_control_panel.cm_handle); + + retv_if(!parent, NULL); + + control_panel_layout = elm_layout_add(parent); + retv_if(!control_panel_layout, NULL); + + if (!elm_layout_file_set(control_panel_layout, LOCK_PWD_EDJE_FILE, "lock-control-panel")) { + _E("Failed to set edje file : %s", LOCK_PWD_EDJE_FILE); + goto ERROR; + } + s_lock_pwd_control_panel.control_panel_layout = control_panel_layout; + + evas_object_size_hint_weight_set(control_panel_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(control_panel_layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + +#if 0 + /* plmn button */ + Evas_Object *btn_plmn = NULL; + btn_plmn = _create_btn_plmn(control_panel_layout); + if (btn_plmn) { + elm_object_part_content_set(control_panel_layout, "sw.btn.plmn", btn_plmn); + s_lock_pwd_control_panel.btn_plmn = btn_plmn; + } else { + _E("Failed to add a button for PLMN"); + } +#endif + + /* cancel button */ + elm_object_part_text_set(control_panel_layout, "txt.cancel", _("IDS_COM_BUTTON_CANCEL")); + elm_object_signal_callback_add(control_panel_layout, "btn,cancel,clicked", "btn.cancel", _btn_cancel_clicked_cb, NULL); + + evas_object_show(control_panel_layout); + + ret = cm_set_call_status_cb(s_lock_pwd_control_panel.cm_handle, _call_status_changed_cb, control_panel_layout); + if (ret != CM_ERROR_NONE) { + _E("Failed to register call status callback"); + } + + return control_panel_layout; + +ERROR: + _E("Failed to create password control panel"); + + if (control_panel_layout) { + evas_object_del(control_panel_layout); + s_lock_pwd_control_panel.control_panel_layout = NULL; + } + + return NULL; +} + +void lock_pwd_control_panel_del(void) +{ + _destroy_btn_return_to_call(); + _destroy_btn_plmn(); + + if (s_lock_pwd_control_panel.btn_cancel) { + elm_object_signal_callback_del(s_lock_pwd_control_panel.control_panel_layout, "btn,cancel,clicked", "btn.cancel", _btn_cancel_clicked_cb); + evas_object_del(s_lock_pwd_control_panel.btn_cancel); + s_lock_pwd_control_panel.btn_cancel= NULL; + } + + if (s_lock_pwd_control_panel.control_panel_layout) { + evas_object_del(s_lock_pwd_control_panel.control_panel_layout); + s_lock_pwd_control_panel.control_panel_layout = NULL; + } + + /* Deinitialize callmgr-client */ + cm_unset_call_status_cb(s_lock_pwd_control_panel.cm_handle); + cm_deinit(s_lock_pwd_control_panel.cm_handle); + s_lock_pwd_control_panel.cm_handle = NULL; +} diff --git a/lock_pwd/src/lock_pwd_simple.c b/lock_pwd/src/lock_pwd_simple.c new file mode 100755 index 0000000..b737464 --- /dev/null +++ b/lock_pwd/src/lock_pwd_simple.c @@ -0,0 +1,450 @@ +/* + * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <Elementary.h> +#include <Ecore_X.h> +#include <app_control.h> +#include <bundle.h> +#include <aul.h> +#include <security-server.h> +#include <vconf.h> + +#include "lock_mgr.h" +#include "util.h" +#include "status.h" +#include "lock_pwd_util.h" +#include "lock_pwd_simple.h" +#include "lock_pwd_control_panel.h" + +#define DOT_TIME 1.5 +#define CORRECT_TIME 0.2 + +static struct _s_lock_pwd_simple { + Evas_Object *pwd_simple_layout; + Ecore_Timer *timer_dot; + + Eina_Bool is_blocked; + + char pwd_simple[MAX_SIMPLE_PASSWORD_NUM +1]; + int pwd_simple_length; + + Ecore_Timer *timer_correct; + Ecore_Timer *timer_pin; + int pin_time_remain; +} s_lock_pwd_simple = { + .pwd_simple_layout = NULL, + .timer_dot = NULL, + + .is_blocked = EINA_FALSE, + + .pwd_simple = { 0, }, + .pwd_simple_length = 0, + + .timer_correct = NULL, + .timer_pin = NULL, + .pin_time_remain = PASSWORD_BLOCK_SECONDS, +}; + + + +Eina_Bool lock_pwd_simple_is_blocked_get(void) +{ + return s_lock_pwd_simple.is_blocked; +} + + + + +static void _pwd_simple_layout_title_set(const char *title) +{ + ret_if(!s_lock_pwd_simple.pwd_simple_layout); + ret_if(!title); + elm_object_part_text_set(s_lock_pwd_simple.pwd_simple_layout, "title", title); +} + + + +static void _pwd_simple_backspace(int length) +{ + char buf[BUF_SIZE_32] = { 0, }; + ret_if(!s_lock_pwd_simple.pwd_simple_layout); + + snprintf(buf, sizeof(buf), "dot_hide%d", length); + elm_object_signal_emit(s_lock_pwd_simple.pwd_simple_layout, buf, "keyboard"); + if (s_lock_pwd_simple.timer_dot) { + ecore_timer_del(s_lock_pwd_simple.timer_dot); + s_lock_pwd_simple.timer_dot = NULL; + } +} + + + +static Eina_Bool _hide_dot_cb(void *data) +{ + char buf[BUF_SIZE_32] = { 0, }; + retv_if(!s_lock_pwd_simple.pwd_simple_layout, ECORE_CALLBACK_CANCEL); + + snprintf(buf, sizeof(buf), "dot_show%d", (int)data); + elm_object_signal_emit(s_lock_pwd_simple.pwd_simple_layout, buf, "keyboard"); + s_lock_pwd_simple.timer_dot = NULL; + + return ECORE_CALLBACK_CANCEL; +} + + + +static void _pwd_simple_input(int length, const char *text) +{ + char part_buf[BUF_SIZE_32] = { 0, }; + char signal_buf[BUF_SIZE_32] = { 0, }; + ret_if(!s_lock_pwd_simple.pwd_simple_layout); + + lock_mgr_sound_play(LOCK_SOUND_BTN_KEY); + + snprintf(part_buf, sizeof(part_buf), "panel%d", length); + elm_object_part_text_set(s_lock_pwd_simple.pwd_simple_layout, part_buf, text); + + snprintf(signal_buf, sizeof(signal_buf), "input_show%d", length); + elm_object_signal_emit(s_lock_pwd_simple.pwd_simple_layout, signal_buf, "keyboard"); + + if (length > 0) { + snprintf(signal_buf, sizeof(signal_buf), "dot_show%d", length-1); + elm_object_signal_emit(s_lock_pwd_simple.pwd_simple_layout, signal_buf, "keyboard"); + } + + if (s_lock_pwd_simple.timer_dot) { + ecore_timer_del(s_lock_pwd_simple.timer_dot); + s_lock_pwd_simple.timer_dot = NULL; + } + + if (length < MAX_SIMPLE_PASSWORD_NUM-1) { + s_lock_pwd_simple.timer_dot = ecore_timer_add(DOT_TIME, _hide_dot_cb, (void *)length); + } +} + + + +static void _pwd_simple_keypad_process(void *data, Evas_Object *obj, const char *emission, const char *source) +{ + _D("%s", __func__); + + if (s_lock_pwd_simple.is_blocked) { + _E("blocked"); + lock_mgr_sound_play(LOCK_SOUND_BTN_KEY); + return; + } + + if (!strncmp("Backspace", source, strlen("Backspace"))) { + _E("Backspace"); + lock_mgr_sound_play(LOCK_SOUND_BTN_KEY); + ret_if(s_lock_pwd_simple.pwd_simple_length <= 0); + _pwd_simple_backspace(--s_lock_pwd_simple.pwd_simple_length); + } else { + if (s_lock_pwd_simple.pwd_simple_length >= MAX_SIMPLE_PASSWORD_NUM) { + _E("Too long"); + return; + } else { + s_lock_pwd_simple.pwd_simple[s_lock_pwd_simple.pwd_simple_length] = *source; + _pwd_simple_input(s_lock_pwd_simple.pwd_simple_length++, source); + } + } + + if (s_lock_pwd_simple.pwd_simple_length == MAX_SIMPLE_PASSWORD_NUM) { + lock_pwd_event_e pwd_event = lock_pwd_verification_verify(s_lock_pwd_simple.pwd_simple); + lock_pwd_simple_event(pwd_event); + } +} + + + +Evas_Object *lock_pwd_simple_layout_create(void *data) +{ + Evas_Object *parent = NULL; + Evas_Object *pwd_simple_layout = NULL; + Evas_Object *pwd_control_panel = NULL; + + lock_pwd_verification_policy_create(); + + parent = (Evas_Object *)data; + retv_if(!parent, NULL); + + pwd_simple_layout = elm_layout_add(parent); + goto_if(!pwd_simple_layout, ERROR); + s_lock_pwd_simple.pwd_simple_layout = pwd_simple_layout; + + if (!elm_layout_file_set(pwd_simple_layout, LOCK_PWD_EDJE_FILE, "lock-simple-password")) { + _E("Failed to set edje file : %s", LOCK_PWD_EDJE_FILE); + goto ERROR; + } + + evas_object_size_hint_weight_set(pwd_simple_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(pwd_simple_layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(pwd_simple_layout); + + elm_object_signal_callback_add(pwd_simple_layout, "keypad_down_clicked", "*", _pwd_simple_keypad_process, NULL); + _pwd_simple_layout_title_set(_("IDS_COM_BODY_ENTER_PIN")); + + /* create control panel */ + pwd_control_panel = lock_pwd_control_panel_create(pwd_simple_layout); + if (!pwd_control_panel) { + _E("Failed to create password control panel"); + } else { + elm_object_part_content_set(pwd_simple_layout, "control_panel", pwd_control_panel); + } + + return pwd_simple_layout; + +ERROR: + _E("Failed to create simple password layout"); + + if (pwd_simple_layout) { + evas_object_del(pwd_simple_layout); + s_lock_pwd_simple.pwd_simple_layout = NULL; + } + + return NULL; +} + + + +void lock_pwd_simple_layout_destroy(void) +{ + if (s_lock_pwd_simple.pwd_simple_layout) { + evas_object_del(s_lock_pwd_simple.pwd_simple_layout); + s_lock_pwd_simple.pwd_simple_layout = NULL; + } + + if (s_lock_pwd_simple.timer_dot) { + ecore_timer_del(s_lock_pwd_simple.timer_dot); + s_lock_pwd_simple.timer_dot = NULL; + } + + if (s_lock_pwd_simple.timer_pin) { + ecore_timer_del(s_lock_pwd_simple.timer_pin); + s_lock_pwd_simple.timer_pin = NULL; + } +} + + + +void lock_pwd_simple_entry_clear(void) +{ + int i = 0; + char buf[BUF_SIZE_32] = { 0, }; + + ret_if(!s_lock_pwd_simple.pwd_simple_layout); + + if (s_lock_pwd_simple.timer_dot) { + ecore_timer_del(s_lock_pwd_simple.timer_dot); + s_lock_pwd_simple.timer_dot = NULL; + } + + for (i = 0; i <= 3; i++) { + snprintf(buf, sizeof(buf), "dot_hide%d", i); + elm_object_signal_emit(s_lock_pwd_simple.pwd_simple_layout, buf, "keyboard"); + } + s_lock_pwd_simple.pwd_simple_length = 0; +} + + + +static Eina_Bool _pwd_simple_entry_clear(void *data) +{ + lock_pwd_simple_entry_clear(); + return ECORE_CALLBACK_CANCEL; +} + + + +static void _pwd_simple_event_incorrect(lock_pwd_event_e event) +{ + char temp_str[BUF_SIZE_256] = { 0, }; + char temp_left[BUF_SIZE_256] = { 0, }; + int remain_attempt = 0; + + remain_attempt = lock_pwd_verification_remain_attempt_get(); + _D("remain_attempt(%d)", remain_attempt); + + if (remain_attempt == 1) { + strncpy(temp_left, _("IDS_IDLE_BODY_1_ATTEMPT_LEFT"), sizeof(temp_left)); + temp_left[sizeof(temp_left) - 1] = '\0'; + } else { + snprintf(temp_left, sizeof(temp_left), _("IDS_IDLE_BODY_PD_ATTEMPTS_LEFT"), remain_attempt); + } + snprintf(temp_str, sizeof(temp_str), "%s<br>%s", _("IDS_COM_BODY_INCORRECT_PIN"), temp_left); + _pwd_simple_layout_title_set(temp_str); + + ecore_timer_add(0.1, _pwd_simple_entry_clear, NULL); + + lock_pwd_verification_popup_create(event); +} + + + +static Eina_Bool _pwd_correct_timer_cb(void *data) +{ + lock_pwd_util_win_hide(); + lock_pwd_simple_entry_clear(); + _pwd_simple_layout_title_set(_("IDS_COM_BODY_ENTER_PIN")); + + lock_mgr_idle_lock_state_set(VCONFKEY_IDLE_UNLOCK); + lock_mgr_sound_play(LOCK_SOUND_UNLOCK); + + s_lock_pwd_simple.timer_correct = NULL; + + return ECORE_CALLBACK_CANCEL; +} + + + +static void _pwd_simple_event_correct(lock_pwd_event_e event) +{ + if (s_lock_pwd_simple.timer_correct) { + ecore_timer_del(s_lock_pwd_simple.timer_correct); + } + + s_lock_pwd_simple.timer_correct = ecore_timer_add(CORRECT_TIME, _pwd_correct_timer_cb, NULL); + if(!s_lock_pwd_simple.timer_correct) { + _E("Failed to add tiemr for correct password event"); + } +} + + + +static void _pwd_simple_lock_time_init(void) +{ + if (vconf_set_str(VCONFKEY_SETAPPL_PASSWORD_TIMESTAMP_STR, "") < 0) { + _E("Failed to set vconfkey : %s", VCONFKEY_SETAPPL_PASSWORD_TIMESTAMP_STR); + } +} + + + +static void _pwd_simple_lock_time_save(void) +{ + time_t cur_time = time(NULL); + char buf[64] = { 0, }; + snprintf(buf, sizeof(buf), "%ld", cur_time); + if (vconf_set_str(VCONFKEY_SETAPPL_PASSWORD_TIMESTAMP_STR, buf) < 0) { + _E("Failed to set vconfkey : %s", VCONFKEY_SETAPPL_PASSWORD_TIMESTAMP_STR); + } +} + + + +static Eina_Bool _wrong_pwd_wait_timer_cb(void *data) +{ + char try_again_buf[BUF_SIZE_256] = { 0, }; + char incorrect_pass_buf[BUF_SIZE_256] = { 0, }; + + retv_if(!s_lock_pwd_simple.pwd_simple_layout, ECORE_CALLBACK_CANCEL); + + snprintf(try_again_buf, sizeof(try_again_buf), _("IDS_LCKSCN_POP_TRY_AGAIN_IN_PD_SECONDS"), s_lock_pwd_simple.pin_time_remain); + snprintf(incorrect_pass_buf, sizeof(incorrect_pass_buf), "%s<br>%s", _("IDS_COM_BODY_INCORRECT_PIN"), try_again_buf); + _pwd_simple_layout_title_set(incorrect_pass_buf); + + if (s_lock_pwd_simple.pin_time_remain == PASSWORD_BLOCK_SECONDS || + s_lock_pwd_simple.pin_time_remain > 0) { + s_lock_pwd_simple.pin_time_remain--; + return ECORE_CALLBACK_RENEW; + } else { + lock_pwd_simple_view_init(); + + int lcd_state = lock_mgr_lcd_state_get(); + if (lcd_state == LCD_STATE_OFF) { + if (!lock_mgr_lockscreen_launch()) { + _E("Failed to launch lockscreen"); + } + } + } + + return ECORE_CALLBACK_CANCEL; +} + + + +static void _pwd_simple_event_input_block(lock_pwd_event_e event) +{ + _D("%s", __func__); + + int block_sec = PASSWORD_BLOCK_SECONDS; + char try_again_buf[200] = { 0, }; + char incorrect_pass_buf[200] = { 0, }; + + ret_if(!s_lock_pwd_simple.pwd_simple_layout); + + _pwd_simple_lock_time_save(); + + snprintf(try_again_buf, sizeof(try_again_buf), _("IDS_LCKSCN_POP_TRY_AGAIN_IN_PD_SECONDS"), block_sec); + snprintf(incorrect_pass_buf, sizeof(incorrect_pass_buf), "%s<br>%s", _("IDS_COM_BODY_INCORRECT_PIN"), try_again_buf); + _pwd_simple_layout_title_set(incorrect_pass_buf); + + s_lock_pwd_simple.is_blocked = EINA_TRUE; + + if (s_lock_pwd_simple.timer_pin) { + ecore_timer_del(s_lock_pwd_simple.timer_pin); + s_lock_pwd_simple.timer_pin = NULL; + } + + s_lock_pwd_simple.timer_pin = ecore_timer_add(1.0, _wrong_pwd_wait_timer_cb, NULL); + + ecore_timer_add(0.1, _pwd_simple_entry_clear, NULL); + + lock_pwd_verification_popup_create(event); + + lock_pwd_control_panel_cancel_btn_enable_set(EINA_FALSE); +} + + + +void lock_pwd_simple_event(lock_pwd_event_e event) +{ + switch(event) { + case PWD_EVENT_CORRECT: + _pwd_simple_event_correct(event); + break; + case PWD_EVENT_INCORRECT_WARNING: + case PWD_EVENT_INCORRECT: + _pwd_simple_event_incorrect(event); + break; + case PWD_EVENT_INPUT_BLOCK_WARNING: + case PWD_EVENT_INPUT_BLOCK: + _pwd_simple_event_input_block(event); + break; + case PWD_EVENT_EMPTY: + break; + case PWD_EVENT_OVER: + break; + default: + break; + } +} + +void lock_pwd_simple_view_init(void) +{ + _D("initialize simpel password values"); + s_lock_pwd_simple.pin_time_remain = PASSWORD_BLOCK_SECONDS; + + _pwd_simple_layout_title_set(_("IDS_COM_BODY_ENTER_PIN")); + elm_object_signal_emit(s_lock_pwd_simple.pwd_simple_layout, "show_title", "title"); + s_lock_pwd_simple.is_blocked = EINA_FALSE; + + lock_pwd_simple_entry_clear(); + + _pwd_simple_lock_time_init(); + + lock_pwd_control_panel_cancel_btn_enable_set(EINA_TRUE); +} diff --git a/lock_pwd/src/lock_pwd_util.c b/lock_pwd/src/lock_pwd_util.c new file mode 100644 index 0000000..0a2b872 --- /dev/null +++ b/lock_pwd/src/lock_pwd_util.c @@ -0,0 +1,485 @@ +/* + * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <system_settings.h> +#include <efl_extension.h> + +#include "lock_mgr.h" +#include "util.h" +#include "status.h" +#include "status.h" +#include "lock_pwd_util.h" +#include "lock_pwd_simple.h" +#include "lock_pwd_complex.h" + +static struct _s_lock_pwd_util { + Evas_Object *lock_pwd_win; + Evas_Object *conformant; + Evas_Object *layout; + Evas_Object *bg; + + int win_w; + int win_h; +} s_lock_pwd_util = { + .lock_pwd_win = NULL, + .conformant = NULL, + .layout = NULL, + .bg = NULL, + + .win_w = 0, + .win_h = 0, +}; + + + +int lock_pwd_util_win_width_get(void) +{ + return s_lock_pwd_util.win_w; +} + + + +int lock_pwd_util_win_height_get(void) +{ + return s_lock_pwd_util.win_h; +} + + + +Evas_Object *lock_pwd_util_win_get(void) +{ + return s_lock_pwd_util.lock_pwd_win; +} + + + +Eina_Bool lock_pwd_util_win_visible_get(void) +{ + retv_if(!s_lock_pwd_util.lock_pwd_win, EINA_FALSE); + return evas_object_visible_get(s_lock_pwd_util.lock_pwd_win); +} + + + +static Evas_Object *_pwd_conformant_add(Evas_Object *parent) +{ + Evas_Object *conformant = NULL; + + retv_if(!parent, NULL); + + conformant = elm_conformant_add(parent); + retv_if(!conformant, NULL); + + evas_object_size_hint_weight_set(conformant, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(parent, conformant); + + elm_object_signal_emit(conformant, "elm,state,indicator,overlap", "elm"); + + evas_object_show(conformant); + + return conformant; +} + + +void lock_pwd_util_bg_image_set(Evas_Object *bg, char *file) +{ + const char *old_filename = NULL; + char *lock_bg = NULL; + int ret = 0; + + ret_if(!bg); + + elm_image_file_get(bg, &old_filename, NULL); + if (!old_filename) { + old_filename = LOCK_MGR_DEFAULT_BG_PATH; + } + _D("old file name : %s", old_filename); + + if (file) { + if (!elm_image_file_set(bg, file, NULL)) { + _E("Failed to set image file : %s", file); + goto ERROR; + } + } else { + ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, &lock_bg); + if (SYSTEM_SETTINGS_ERROR_NONE != ret) { + _E("Failed to get system setting value : %d", SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN); + goto ERROR; + } + goto_if(!lock_bg, ERROR); + + _D("lock_bg : %s", lock_bg); + + if (!elm_image_file_set(bg, lock_bg, NULL)) { + _E("Failed to set image file : %s", lock_bg); + goto ERROR; + } + + free(lock_bg); + } + + return; + +ERROR: + + if (!elm_bg_file_set(bg, old_filename, NULL)) { + _E("Failed to set old BG file : %s / Retry to set default BG.", old_filename); + if (!elm_bg_file_set(bg, LOCK_MGR_DEFAULT_BG_PATH, NULL)) { + _E("Failed to set default BG : %s", LOCK_MGR_DEFAULT_BG_PATH); + return; + } + } + + return; +} + + + +static void _wallpaper_lock_screen_changed_cb(system_settings_key_e key, void *data) +{ + Evas_Object *bg = (Evas_Object *)data; + ret_if(!bg); + + lock_pwd_util_bg_image_set(bg, NULL); +} + + + +static Evas_Object *_pwd_bg_add(void *data) +{ + Evas_Object *bg = NULL; + Evas_Object *parent = NULL; + int ret = 0; + + parent = (Evas_Object *)data; + retv_if(!parent, NULL); + + bg = elm_image_add(parent); + retv_if(!bg, NULL); + + elm_image_aspect_fixed_set(bg, EINA_TRUE); + elm_image_fill_outside_set(bg, EINA_TRUE); + elm_image_preload_disabled_set(bg, EINA_TRUE); + + lock_pwd_util_bg_image_set(bg, NULL); + evas_object_show(bg); + + ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, _wallpaper_lock_screen_changed_cb, bg); + if (SYSTEM_SETTINGS_ERROR_NONE != ret) { + _E("Failed to register settings changed cb : %d", SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN); + } + + return bg; +} + + + +static Evas_Object *_pwd_layout_create(Evas_Object *parent) +{ + Evas_Object *layout = NULL; + + retv_if(!parent, NULL); + + layout = elm_layout_add(parent); + retv_if(!layout, NULL); + + if (!elm_layout_file_set(layout, LOCK_PWD_EDJE_FILE, "lock_pwd")) { + _E("Failed to set edje file : %s", LOCK_PWD_EDJE_FILE); + goto ERROR; + } + + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + + evas_object_show(layout); + + return layout; + +ERROR: + _E("Failed to create password layout"); + + if (layout) { + evas_object_del(layout); + layout = NULL; + } + + return NULL; +} + + + +void lock_pwd_util_back_key_relased(void) +{ + _D("%s", __func__); + + ret_if(lock_pwd_simple_is_blocked_get()); + + lock_mgr_sound_play(LOCK_SOUND_TAP); + + if (!lock_mgr_lockscreen_launch()) { + _E("Failed to launch lockscreen"); + } + + lock_pwd_util_view_init(); +} + + + +static void __win_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + Evas_Coord x = 0; + Evas_Coord y = 0; + Evas_Coord w = 0; + Evas_Coord h = 0; + + ret_if(!obj); + + evas_object_geometry_get(obj, &x, &y, &w, &h); + _D("win resize : %d, %d(%d*%d)", x, y, w, h); +} + + + +static void __conformant_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + Evas_Coord x = 0; + Evas_Coord y = 0; + Evas_Coord w = 0; + Evas_Coord h = 0; + + ret_if(!obj); + + evas_object_geometry_get(obj, &x, &y, &w, &h); + _D("conformant resize : %d, %d(%d*%d)", x, y, w, h); +} + + + +static void __layout_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + Evas_Coord x = 0; + Evas_Coord y = 0; + Evas_Coord w = 0; + Evas_Coord h = 0; + + ret_if(!obj); + + evas_object_geometry_get(obj, &x, &y, &w, &h); + _D("layout resize : %d, %d(%d*%d)", x, y, w, h); +} + + + +void lock_pwd_util_create(Eina_Bool is_show) +{ + Evas_Object *win = NULL; + Evas_Object *conformant = NULL; + Evas_Object *bg = NULL; + Evas_Object *layout = NULL; + Evas_Object *pwd_layout = NULL; + int lock_type = 0; + int x = 0, y = 0, w = 0, h = 0; + + if (!s_lock_pwd_util.lock_pwd_win) { + win = window_mgr_pwd_lock_win_create(); + ret_if(!win); + s_lock_pwd_util.lock_pwd_win = win; + + elm_win_screen_size_get(win, &x, &y, &w, &h); + _D("win size : %dx%d(%d, %d)", w, h, x, y); + s_lock_pwd_util.win_w = w; + s_lock_pwd_util.win_h = h; + } + + conformant = _pwd_conformant_add(win); + goto_if(!conformant, ERROR); + s_lock_pwd_util.conformant = conformant; + + layout = _pwd_layout_create(conformant); + goto_if(!layout, ERROR); + s_lock_pwd_util.layout = layout; + + evas_object_event_callback_add(s_lock_pwd_util.lock_pwd_win, EVAS_CALLBACK_RESIZE, __win_resize_cb, NULL); + evas_object_event_callback_add(conformant, EVAS_CALLBACK_RESIZE, __conformant_resize_cb, NULL); + evas_object_event_callback_add(conformant, EVAS_CALLBACK_RESIZE, __layout_resize_cb, NULL); + + elm_object_content_set(conformant, layout); + + bg = _pwd_bg_add(win); + goto_if(!bg, ERROR); + s_lock_pwd_util.bg = bg; + + elm_object_part_content_set(layout, "sw.bg", bg); + + lock_type = status_active_get()->setappl_screen_lock_type_int; + _D("lock type : %d", lock_type); + + switch(lock_type) { + case SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD: + pwd_layout = lock_pwd_simple_layout_create(layout); + break; + case SETTING_SCREEN_LOCK_TYPE_PASSWORD: + pwd_layout = lock_pwd_complex_layout_create(layout); + break; + default: + _E("lock type is not password : %d", lock_type); + goto ERROR; + } + goto_if(!pwd_layout, ERROR); + + elm_object_part_content_set(layout, "sw.lock_pwd", pwd_layout); + + if (is_show) { + evas_object_show(win); + } + + return; + +ERROR: + _E("Failed to launch password lockscreen"); + + lock_pwd_util_destroy(); + + return; +} + + + +void lock_pwd_util_destroy(void) +{ + int lock_type = status_active_get()->setappl_screen_lock_type_int; + _D("lock type : %d", lock_type); + + if (lock_type == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD) { + lock_pwd_simple_layout_destroy(); + } else if (lock_type == SETTING_SCREEN_LOCK_TYPE_PASSWORD) { + lock_pwd_complex_layout_destroy(); + } + + if (s_lock_pwd_util.layout) { + evas_object_del(s_lock_pwd_util.layout); + s_lock_pwd_util.layout = NULL; + } + + if (s_lock_pwd_util.conformant) { + evas_object_del(s_lock_pwd_util.conformant); + s_lock_pwd_util.conformant = NULL; + } + + if (s_lock_pwd_util.bg) { + system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN); + evas_object_del(s_lock_pwd_util.bg); + s_lock_pwd_util.bg = NULL; + } + + if (s_lock_pwd_util.lock_pwd_win) { + evas_object_del(s_lock_pwd_util.lock_pwd_win); + s_lock_pwd_util.lock_pwd_win = NULL; + } +} + + + + +static void _pwd_popup_cb(void *data, Evas_Object *obj, void *event_info) +{ + ret_if(!data); + + evas_object_del((Evas_Object *)data); +} + + + +void lock_pwd_util_popup_create(char *title, char *text, Evas_Smart_Cb func, double timeout) +{ + Evas_Object *popup = NULL; + Evas_Object *btn = NULL; + + ret_if(!s_lock_pwd_util.lock_pwd_win); + + popup = elm_popup_add(s_lock_pwd_util.lock_pwd_win); + ret_if(!popup); + + elm_popup_orient_set(popup, ELM_POPUP_ORIENT_BOTTOM); + evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + if (title) { + elm_object_part_text_set(popup, "title,text", title); + } + + if (text) { + elm_object_text_set(popup, text); + } + + btn = elm_button_add(popup); + if (!btn) { + _E("Failed to create lock popup button"); + evas_object_del(popup); + return; + } + + elm_object_style_set(btn, "popup"); + elm_object_text_set(btn, _("IDS_COM_BUTTON_OK_ABB")); + elm_object_part_content_set(popup, "button1", btn); + + if (timeout > 0.0) { + elm_popup_timeout_set(popup, timeout); + } + + if (func) { + evas_object_smart_callback_add(btn, "clicked", func, popup); + eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, func, popup); + } else { + evas_object_smart_callback_add(btn, "clicked", _pwd_popup_cb, popup); + eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, _pwd_popup_cb, popup); + } + + evas_object_show(popup); + + return; +} + + + +void lock_pwd_util_view_init(void) +{ + _D("initialize password lock values"); + int lock_type = 0; + + /* clear pwd lockscreen */ + lock_type = status_active_get()->setappl_screen_lock_type_int; + if (lock_type == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD) { + lock_pwd_simple_view_init(); + } else if (lock_type == SETTING_SCREEN_LOCK_TYPE_PASSWORD) { + lock_pwd_complex_view_init(); + } +} + + + +void lock_pwd_util_win_show(void) +{ + ret_if(!s_lock_pwd_util.lock_pwd_win); + evas_object_show(s_lock_pwd_util.lock_pwd_win); +} + + + +void lock_pwd_util_win_hide(void) +{ + ret_if(!s_lock_pwd_util.lock_pwd_win); + evas_object_hide(s_lock_pwd_util.lock_pwd_win); +} diff --git a/lock_pwd/src/lock_pwd_verification.c b/lock_pwd/src/lock_pwd_verification.c new file mode 100755 index 0000000..df64b1c --- /dev/null +++ b/lock_pwd/src/lock_pwd_verification.c @@ -0,0 +1,207 @@ +/* + * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <Elementary.h> +#include <security-server.h> +#include <vconf.h> +#include <vconf-keys.h> +#include <sys/socket.h> +#include <sys/un.h> + +#include "util.h" +#include "status.h" +#include "lock_mgr.h" +#include "lock_pwd_util.h" +#include "lock_pwd_verification.h" +#include "lock_pwd_simple.h" + +#define PASSWORD_LENGTH_MIN 4 +#define PASSWORD_LENGTH_MAX 16 + +typedef enum { + NORMAL_PWD = 0, + EMPTY_PWD = 1, + OVERLENGTH_PWD = 2, +} lock_pwd_type; + +static struct _s_lock_pwd_verification { + unsigned int current_attempt; + unsigned int remain_attempt; + unsigned int max_attempt; + unsigned int expire_sec; + unsigned int incorrect_count; +} s_lock_pwd_verification = { + .current_attempt = 0, + .remain_attempt = 0, + .max_attempt = 0, + .expire_sec = 0, + .incorrect_count = 0, +}; + + + +int lock_pwd_verification_current_attempt_get(void) +{ + return s_lock_pwd_verification.current_attempt; +} + + +int lock_pwd_verification_remain_attempt_get(void) +{ + return s_lock_pwd_verification.remain_attempt; +} + + +static Eina_Bool _pwd_verification_check_pwd(const char *str) +{ + int ret = SECURITY_SERVER_API_ERROR_PASSWORD_MISMATCH; + unsigned int current_attempt = 0; + unsigned int max_attempt = 0; + unsigned int expire_sec = 0; + + ret = security_server_chk_pwd(str, ¤t_attempt, &max_attempt, &expire_sec); + _D("ret(%d), current_attempt(%d), max_attempt(%d), valid_sec(%d)", ret, current_attempt, max_attempt, expire_sec); + + s_lock_pwd_verification.current_attempt = current_attempt; + s_lock_pwd_verification.max_attempt = max_attempt; + s_lock_pwd_verification.expire_sec = expire_sec; + + switch(ret) { + case SECURITY_SERVER_API_SUCCESS: + case SECURITY_SERVER_API_ERROR_PASSWORD_EXPIRED: + _E("Correct password"); + return EINA_TRUE; + case SECURITY_SERVER_API_ERROR_PASSWORD_RETRY_TIMER: + _E("Timer set! : not saved"); + break; + default: + _E("Incorrect password"); + break; + } + + return EINA_FALSE; +} + + +static lock_pwd_type _pwd_verification_check_length(const char *str, int min, int max) +{ + int len = 0; + + retv_if(!str, EMPTY_PWD); + + len = strlen(str); + retv_if(len == 0, EMPTY_PWD); + + retv_if(len < min || len > max, OVERLENGTH_PWD); + + return NORMAL_PWD; +} + +static void _pwd_values_init(void) +{ + s_lock_pwd_verification.current_attempt = 0; + s_lock_pwd_verification.remain_attempt = PASSWORD_ATTEMPTS_MAX_NUM; + s_lock_pwd_verification.max_attempt = PASSWORD_ATTEMPTS_MAX_NUM; + s_lock_pwd_verification.incorrect_count = 0; +} + +lock_pwd_event_e lock_pwd_verification_verify(const char *password) +{ + lock_pwd_type pwd_type = NORMAL_PWD; + + retv_if(!password, PWD_EVENT_EMPTY); + + pwd_type = _pwd_verification_check_length(password, PASSWORD_LENGTH_MIN, PASSWORD_LENGTH_MAX); + switch(pwd_type) { + case NORMAL_PWD: + if (_pwd_verification_check_pwd(password)) { + _D("Correct Password"); + _pwd_values_init(); + return PWD_EVENT_CORRECT; + } else { + s_lock_pwd_verification.incorrect_count++; + s_lock_pwd_verification.remain_attempt--; + _D("incorrect_count(%d), remain_attempt(%d)", s_lock_pwd_verification.incorrect_count, s_lock_pwd_verification.remain_attempt); + + if (s_lock_pwd_verification.remain_attempt == 0) { + _pwd_values_init(); + return PWD_EVENT_INPUT_BLOCK; + } else { + return PWD_EVENT_INCORRECT; + } + } + break; + case EMPTY_PWD: + return PWD_EVENT_EMPTY; + break; + case OVERLENGTH_PWD: + return PWD_EVENT_OVER; + break; + } + + return PWD_EVENT_INCORRECT; +} + +void lock_pwd_verification_policy_create(void) +{ + int ret = 0; + unsigned int current_attempt = 0; + unsigned int max_attempt = 0; + unsigned int expire_sec = 0; + + ret = security_server_is_pwd_valid(¤t_attempt, &max_attempt, &expire_sec); + _D("policy status(%d), current_attempt(%d), max_attempt(%d)", ret, current_attempt, max_attempt); + + if (ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD || + ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST) { + s_lock_pwd_verification.current_attempt = current_attempt; + s_lock_pwd_verification.max_attempt = max_attempt; + s_lock_pwd_verification.expire_sec = expire_sec; + } + + s_lock_pwd_verification.remain_attempt = PASSWORD_ATTEMPTS_MAX_NUM; + s_lock_pwd_verification.incorrect_count = 0; + + return; +} + +void lock_pwd_verification_popup_create(lock_pwd_event_e event) +{ + char popup_text[BUF_SIZE_512] = { 0, }; + int remain_attempt = 0; + int current_attempt = 0; + + current_attempt = lock_pwd_verification_current_attempt_get(); + remain_attempt = lock_pwd_verification_remain_attempt_get(); + _D("current_attemp(%d), remain_attempt(%d)", current_attempt, remain_attempt); + + switch(event) { + case PWD_EVENT_INCORRECT_WARNING: + snprintf(popup_text, sizeof(popup_text), _("IDS_LCKSCN_POP_YOU_HAVE_ATTEMPTED_TO_UNLOCK_THE_DEVICE_INCORRECTLY_P1SD_P1SD_TIMES_YOU_HAVE_P2SD_ATTEMPTS_LEFT_BEFORE_THE_DEVICE_IS_RESET_THE_DEVICE_IS_RESET_TO_FACTORY_MSG"), current_attempt, remain_attempt); + lock_pwd_util_popup_create(NULL, popup_text, NULL, 0.0); + break; + case PWD_EVENT_INPUT_BLOCK: + snprintf(popup_text, sizeof(popup_text), _("IDS_LCKSCN_POP_YOU_HAVE_MADE_P1SD_UNSUCCESSFUL_ATTEMPTS_TO_UNLOCK_YOUR_DEVICE_TRY_AGAIN_IN_P2SD_SECONDS"), PASSWORD_ATTEMPTS_MAX_NUM, PASSWORD_BLOCK_SECONDS); + lock_pwd_util_popup_create(_("IDS_LCKSCN_HEADER_UNABLE_TO_UNLOCK_SCREEN_ABB"), popup_text, NULL, 15.0); + break; + case PWD_EVENT_INPUT_BLOCK_WARNING: + snprintf(popup_text, sizeof(popup_text), _("IDS_LCKSCN_POP_YOU_HAVE_ATTEMPTED_TO_UNLOCK_THE_DEVICE_INCORRECTLY_P1SD_TIMES_YOU_HAVE_P2SD_ATTEMPTS_LEFT_BEFORE_THE_DEVICE_IS_RESET_TO_FACTORY_MSG"), current_attempt, remain_attempt); + lock_pwd_util_popup_create(NULL, popup_text, NULL, 0.0); + break; + default: + break; + } +} |