4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
6 * Contact: MyoungJune Park <mj2004.park@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
21 #ifndef _SETTING_PASSWORD_H_
22 #define _SETTING_PASSWORD_H_
25 #include <Elementary.h>
26 #include <Ecore_IMF.h>
31 #include <TapiUtility.h>
33 #include <glib-object.h>
35 #include <setting-common-draw-widget.h>
36 #include <setting-common-view.h>
37 #include <setting-debug.h>
39 #include <security-server.h>
43 #define MAX_DESC_BUF_SIZE 2048
44 #define DESC_BUF1_SIZE 256
45 #define DESC_BUF2_SIZE 128
47 #define NEW_PASSWORD_NECESSARY "New password is necessary because of new security policy."
48 #define PASSWORD_MUST_DIGITS "Password must consist of at least %d digit(s)."
49 #define PASSWORD_MUST_ALPHANUMERIC "Password must consist of at least %d alphanumeric character(s)."
50 #define PASSWORD_MUST_NOT_MATCH_PREV "Password must not match previous passwords."
51 #define ENTER_ANOTHER_PASSWORD "Enter another password."
52 #define PASSWORD_EXPIRED "Password expired."
53 #define MAX_NUM_REACHED "Maxinum number of password entry attempts reached."
56 #define SETTING_PW_UG_NORMAL_PASSWORD_MIN_LENGTH 4
57 #define SETTING_PW_UG_NORMAL_PASSWORD_MAX_LENGTH 16
58 #define SETTING_PW_UG_PRIVACY_PASSWORD_MIN_LENGTH 4
59 #define SETTING_PW_UG_PRIVACY_PASSWORD_MAX_LENGTH 16
60 #define SETTING_PW_UG_SIM_MIN_LENGTH 4
61 #define SETTING_PW_UG_SIM_MAX_LENGTH 8
62 #define SETTING_PW_UG_PIN_MIN_LENGTH 4
63 #define SETTING_PW_UG_PIN_MAX_LENGTH 8
64 #define SETTING_PW_UG_PUK_MIN_LENGTH 4
65 #define SETTING_PW_UG_PUK_MAX_LENGTH 8
66 #define SETTING_PW_MAX_TITLE_LENGTH MAX_DISPLAY_NAME_LEN_ON_UI
68 #define PASSWORD_EMPTY _("IDS_ST_BODY_PASSWORD_EMPTY")
69 #define ATTEMPT_DESC _("IDS_ST_POP_PD_ATTEMPT_LEFT") /* "%d attempt left" */
70 #define ATTEMPTS_DESC _("IDS_ST_POP_PD_ATTEMPTS_LEFT") /* "%d attempts left" */
71 #define PIN_ERR_DESC _("IDS_ST_POP_INCORRECT_PIN_PD_ATTEMPTS_LEFT") /* "Incorrect PIN. %d attempts left" */
72 #define PUK1_ERR_DESC _("IDS_ST_POP_INCORRECT_PUK1_PD_ATTEMPTS_LEFT") /* "Incorrect PUK1. %d attempts left" */
73 #define PUK2_ERR_DESC _("IDS_ST_POP_INCORRECT_PUK2_PD_ATTEMPTS_LEFT") /* "Incorrect PUK2. %d attempts left" */
74 #define PW_ERR_DESC _("IDS_ST_POP_INCORRECT_PASSWORD") /* "Incorrect password" */
75 #define PW_ERR_DELAY_DESC _("IDS_ST_BODY_ENTER_PASSWORD_AGAIN_AFTER_PD_SECONDS") /* "Please enter password again after %d seconds" */
76 #define PW_ERR_DELAY_TIME 30
77 #define ATTEMPT_INFINITE 999999
79 #define PW_SHORT_GUIDE_CURRENT "IDS_ST_BODY_CURRENT"
80 #define PW_SHORT_GUIDE_NEW "IDS_ST_BODY_NEW"
81 #define PW_SHORT_GUIDE_CONFIRM "IDS_ST_BODY_CONFIRM"
84 SETTING_PW_TYPE_PASSWORD,
85 SETTING_PW_TYPE_SET_PASSWORD,
86 SETTING_PW_TYPE_CHANGE_PASSWORD,
87 SETTING_PW_TYPE_SIMPLE_PASSWORD,
88 SETTING_PW_TYPE_SET_SIMPLE_PASSWORD,
89 SETTING_PW_TYPE_CHANGE_SIMPLE_PASSWORD,
90 SETTING_PW_TYPE_ENTER_LOCK_TYPE,
91 SETTING_PW_TYPE_SIM_LOCK_ON,
92 SETTING_PW_TYPE_SIM_LOCK_OFF,
93 SETTING_PW_TYPE_PIN_LOCK_ON,
94 SETTING_PW_TYPE_PIN_LOCK_OFF,
95 SETTING_PW_TYPE_CHANGE_PIN1,
96 SETTING_PW_TYPE_CHANGE_PIN2,
97 SETTING_PW_TYPE_PIN1_BLOCKED,
98 SETTING_PW_TYPE_PIN2_BLOCKED,
99 SETTING_PW_TYPE_RESET,
101 SETTING_PW_TYPE_MDM_NEW_POLICY, /* for setting password according to new policy */
102 SETTING_PW_TYPE_MDM_CHANGE_PASSWORD, /* for changing password by force : mdm_enforce_password_change() */
103 SETTING_PW_TYPE_MDM_TO_SIMPLE,
111 SETTING_PW_ERROR_INVALID_LENGTH = -1, /* if length of password is wrong, */
112 SETTING_PW_ERROR_INCLUDE_NO_LETTER = -2, /* if password that user enter has no letter, */
113 SETTING_PW_ERROR_NO_MATCH_WITH_POLICY = -3, /* if password that user enter does not match with policy, */
114 SETTING_PW_ERROR_NO_MATCH_MIN_COMPLEX = -4, /* if password that user enter has no letter, */
115 } setting_pw_errors_for_mdm;
118 SETTING_PW_STATUS_OK = 0,
119 SETTING_PW_STATUS_EXPIRED,
120 SETTING_PW_STATUS_MAX_FAILED,
121 SETTING_PW_STATUS_MAX,
122 } setting_pw_status_for_mdm;
127 char *pw_type_string;
137 SIM_LOCK_OFF_SUCCESS,
138 SIM_PIN_LOCK_ON_SUCCESS,
139 SIM_PIN_LOCK_OFF_SUCCESS,
141 SIM_LOCK_INCORRECT_PASSWORD,
142 SIM_INCORRECT_PIN1_CODE,
143 SIM_INCORRECT_PIN2_CODE,
144 SIM_INCORRECT_PUK1_CODE,
145 SIM_INCORRECT_PUK2_CODE,
146 SIM_PIN1_CHANGE_SUCCESS,
147 SIM_PIN2_CHANGE_SUCCESS,
148 SIM_PIN1_CHANGE_FAIL,
149 SIM_PIN2_CHANGE_FAIL,
156 SIM_REQUIRED_PUK_CODE,
157 SIM_OPERATION_UNAVAILABLE,
162 SETTING_PW_NAVIBAR_WITH_NO_BTN,
163 SETTING_PW_NAVIBAR_WITH_LEFT_BTN,
164 SETTING_PW_NAVIBAR_WITH_RIGHT_BTN,
165 SETTING_PW_NAVIBAR_WITH_BOTH_BTN,
166 } setting_pw_navibar_style_t;
168 typedef struct _tapi_request_event {
171 } tapi_request_event;
173 typedef struct _tapi_receive_info {
178 typedef struct _tapi_request_tapi_info {
179 tapi_request_event *evt;
183 void (*cb) (tapi_receive_info *, void *);
184 } tapi_request_tapi_info;
187 * Setting Password UG context
188 * all UG function has void* as an agument. this is casted back to SettingPasswordUG
189 * and the functions access app context.
191 typedef struct _SettingPasswordUG {
194 TelSimSecResult_t *verify_puks_result;
196 /* add more variables here (move your appdata to here) */
198 Evas_Object *win_main_layout;
199 Evas_Object *win_get;
200 Evas_Object *ly_main;
202 setting_pw_type view_type;
203 char *view_type_string;
205 Setting_GenGroupItem_Data *ed_pw1;
206 Setting_GenGroupItem_Data *ed_pw2;
207 Setting_GenGroupItem_Data *ed_pw3;
208 Setting_GenGroupItem_Data *focus_data;
209 Evas_Object *setpw_notify;
212 Elm_Object_Item *err_desc;
213 Elm_Genlist_Item_Class itc_err_desc;
215 Elm_Object_Item *navi_it;
216 Evas_Object *controllbar;
217 tapi_request_tapi_info *t_info;
218 Evas_Object *navi_bar;
219 Elm_Genlist_Item_Class itc_variable_height;
220 Elm_Genlist_Item_Class itc_seperator;
221 Elm_Genlist_Item_Class itc_layout;
222 Elm_Genlist_Item_Class itc_group_item;
223 Evas_Object *scroller;
224 int disable_item_type;
228 Elm_Object_Item *mdm_desc;
229 Elm_Genlist_Item_Class itc_mdm_desc;
230 /* for support mdm policy */
231 mdm_result_t mdm_status;
232 mdm_data_t *mdm_data;
233 mdm_password_policy_t *mdm_policy;
234 Ecore_Event_Handler *event_handler;
239 /* for simple password */
240 Elm_Genlist_Item_Class itc_title;
241 Elm_Genlist_Item_Class itc_sp_bg_1icon;
242 Elm_Object_Item *sp_item;
243 Evas_Object *sp_entry1;
244 Evas_Object *sp_entry2;
245 Evas_Object *sp_entry3;
246 Evas_Object *sp_entry4;
247 Evas_Object *sp_focused;
252 //int is_simple_password_on;
253 int screen_lock_type;
258 Ecore_Timer *remove_timer;
259 Ecore_Timer *set_history_timer;
264 extern setting_view setting_view_password_main;
266 void setting_sim_change_pins_cb(TapiHandle *handle, int result, void *data, void *user_data);
267 void setting_sim_verify_puks_cb(TapiHandle *handle, int result, void *data, void *user_data);
268 void setting_sim_facility_enable_cb(TapiHandle *handle, int result, void *data, void *user_data);
269 void setting_sim_facility_disable_cb(TapiHandle *handle, int result, void *data, void *user_data);
271 void setting_password_ug_popup_resp_cb(void *data, Evas_Object *obj, void *event_info);
272 void setting_password_ug_create_popup_notitle_nobtn(void *data, char *str, int destroy);
274 void setting_password_ug_display_desc(void *data, char *desc, int destroy);
276 void setting_password_ug_display_mdm_desc(void *data, const char* guide_text);
279 extern void setting_password_ug_check_attemps_left(void *data);
281 int setting_password_is_password_empty();
282 int setting_password_check_password(const char *challenge, unsigned int *remain_attempt, unsigned int *valid_sec);
283 int setting_password_set_password(const char *cur_pwd, const char *new_pwd, void *data);