tizen 2.3 release
[apps/home/settings.git] / setting-password / include / setting-password.h
1 /*
2  * setting
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
5  *
6  * Contact: MyoungJune Park <mj2004.park@samsung.com>
7  *
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
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  *
20  */
21 #ifndef _SETTING_PASSWORD_H_
22 #define _SETTING_PASSWORD_H_
23
24 #include <glib.h>
25 #include <Elementary.h>
26 #include <Ecore_IMF.h>
27 #include <ITapiSim.h>
28 #include <TelSim.h>
29 #include <TapiUtility.h>
30 #include <glib-object.h>
31 #include <security-server.h>
32 #include <dlog.h>
33
34 #include <setting-common-draw-widget.h>
35 #include <setting-common-view.h>
36 #include <setting-debug.h>
37 #include <setting-password-strings.h>
38
39 //#include <ckmc/ckmc-control.h>
40 //#include <ckmc/ckmc-type.h>
41
42 #define SETTING_PW_UG_NORMAL_PASSWORD_MIN_LENGTH 4
43 #define SETTING_PW_UG_NORMAL_PASSWORD_MAX_LENGTH 16
44 #define SETTING_PW_UG_PRIVACY_PASSWORD_MIN_LENGTH 4
45 #define SETTING_PW_UG_PRIVACY_PASSWORD_MAX_LENGTH 16
46 #define SETTING_PW_UG_SIM_MIN_LENGTH 4
47 #define SETTING_PW_UG_SIM_MAX_LENGTH 8
48 #define SETTING_PW_UG_PIN_MIN_LENGTH 4
49 #define SETTING_PW_UG_PIN_MAX_LENGTH 8
50 #define SETTING_PW_UG_PUK_MIN_LENGTH 4
51 #define SETTING_PW_UG_PUK_MAX_LENGTH 8
52 #define SETTING_PW_MAX_TITLE_LENGTH MAX_DISPLAY_NAME_LEN_ON_UI
53
54 #define PW_NORMAL_CONTAIN_ALPHANUMERIC 4
55 #define PW_ERR_DELAY_TIME       30
56 #define ATTEMPT_INFINITE        999999
57
58 typedef enum {
59         SETTING_PW_TYPE_PASSWORD = 1,                   /* Final type to verify current password */
60         SETTING_PW_TYPE_SET_PASSWORD,           /* This view type is used when click "password" and "change password" items in screen lock type view */
61         SETTING_PW_TYPE_SIMPLE_PASSWORD,        /* Final type to verify current simple password */
62         SETTING_PW_TYPE_SET_SIMPLE_PASSWORD, /* This view type is used when click "simple password" and "change simple password" items in screen lock type view */
63         SETTING_PW_TYPE_ENTER_LOCK_TYPE,        /* This view type is used when enter screen lock type menu to verify current password lock type */
64         SETTING_PW_TYPE_SIM_LOCK_ON = 6,                /* No use : Do not support SIM LOCK */
65         SETTING_PW_TYPE_SIM_LOCK_OFF,           /* No use : Do not support SIM LOCK */
66         SETTING_PW_TYPE_PIN_LOCK_ON,            /* This view type is used when try to turn PIN LOCK on */
67         SETTING_PW_TYPE_PIN_LOCK_OFF,           /* This view type is used when try to turn PIN LOCK off */
68         SETTING_PW_TYPE_CHANGE_PIN,
69         SETTING_PW_TYPE_CHANGE_PIN2 = 11,
70         SETTING_PW_TYPE_PIN_BLOCKED,    /* No use : PIN1 must be unblocked through pwlock app */
71         SETTING_PW_TYPE_PIN2_BLOCKED,
72         SETTING_PW_TYPE_MAX,
73 } setting_pw_type;
74
75 typedef enum {
76         SETTING_PW_ERROR_INVALID_LENGTH = -1,                   /* if length of password is wrong, */
77         SETTING_PW_ERROR_INCLUDE_NO_LETTER = -2,                /* if password that user enter has no letter, */
78         SETTING_PW_ERROR_NO_MATCH_WITH_POLICY = -3,             /* if password that user enter does not match with policy, */
79         SETTING_PW_ERROR_NO_MATCH_MIN_COMPLEX = -4,             /* if password that user enter has no letter, */
80         SETTING_PW_ERROR_EXIST_FORBIDDEN_STRING = -5,
81         SETTING_PW_ERROR_NO_MATCH_MAX_REPEAT_COUNT = -6,
82         SETTING_PW_ERROR_NO_MATCH_CUR_PASSWORD = -7,
83         SETTING_PW_ERROR_SIMPLE_STYLE = -8,
84         SETTING_PW_ERROR_REUSED = -9,
85         SETTING_PW_ERROR_INCLUDE_DIGIT = -10,
86         SETTING_PW_ERROR_NO_MATCH_WITH_PATTERN = -11,
87         SETTING_PW_ERROR_NO_DIGIT = -12,
88         SETTING_PW_ERROR_DO_NOT_MATCH = -13,
89         SETTING_PW_ERROR_UNKNOWN = -50,
90 } setting_pw_errors;
91
92 typedef enum {
93         SETTING_PW_STATUS_OK = 0,
94         SETTING_PW_STATUS_EXPIRED,
95         SETTING_PW_STATUS_MAX_FAILED,
96         SETTING_PW_STATUS_EMPTY,
97         SETTING_PW_STATUS_DEFAULT,
98         SETTING_PW_STATUS_NON_PW_TYPE,
99         SETTING_PW_STATUS_MAX,
100 } setting_pw_status;
101
102 enum {
103         SETTING_PW_CATEGORY_LOCK = 0x100,
104         SETTING_PW_CATEGORY_SIM = 0x200,
105         SETTING_PW_CATEGORY_MAX,
106 };
107
108 enum {
109         SETTING_PW_SUB_CATEGORY_SIMPLE = 0x01,
110         SETTING_PW_SUB_CATEGORY_MAX,
111 };
112
113
114 struct _pw_item {
115         int pw_type_num;
116         char *pw_type_string;
117         int category;
118         int step;
119 };
120
121 /* For Tapi */
122 typedef enum {
123         SIM_OPERATION_OK,
124         SIM_ERROR,
125         SIM_REQ_PIN,
126         SIM_OPERATION_OFF,
127         SIM_LOCK_ON_SUCCESS,
128         SIM_LOCK_OFF_SUCCESS,
129         SIM_PIN_LOCK_ON_SUCCESS,
130         SIM_PIN_LOCK_OFF_SUCCESS,
131         SIM_LOCK_ON_FAIL,
132         SIM_LOCK_INCORRECT_PASSWORD,
133         SIM_INCORRECT_PIN1_CODE,
134         SIM_INCORRECT_PIN2_CODE,
135         SIM_INCORRECT_PUK1_CODE,
136         SIM_INCORRECT_PUK2_CODE,
137         SIM_PIN1_CHANGE_SUCCESS,
138         SIM_PIN2_CHANGE_SUCCESS,
139         SIM_PIN1_CHANGE_FAIL,
140         SIM_PIN2_CHANGE_FAIL,
141         SIM_PIN1_BLOCKED,
142         SIM_PIN2_BLOCKED,
143         SIM_PIN1_UNBLOCKED,
144         SIM_PIN2_UNBLOCKED,
145         SIM_PUK1_BLOCKED,
146         SIM_PUK2_BLOCKED,
147         SIM_REQUIRED_PUK_CODE,
148         SIM_OPERATION_UNAVAILABLE,
149         SIM_UNKNOWN_ERROR,
150 } sim_stat_value;
151
152 typedef enum {
153         SETTING_PW_NAVIBAR_WITH_NO_BTN,
154         SETTING_PW_NAVIBAR_WITH_LEFT_BTN,
155         SETTING_PW_NAVIBAR_WITH_RIGHT_BTN,
156         SETTING_PW_NAVIBAR_WITH_BOTH_BTN,
157 } setting_pw_navibar_style_t;
158
159 typedef struct _tapi_request_event {
160         unsigned int sid;
161         int event;
162 } tapi_request_event;
163
164 typedef struct _tapi_receive_info {
165         sim_stat_value stat;
166         int retry_cnt;
167 } tapi_receive_info;
168
169 typedef struct _tapi_request_tapi_info {
170         tapi_request_event *evt;
171         int evt_sz;
172
173         void *cb_data;
174         void (*cb) (tapi_receive_info *, void *);
175 } tapi_request_tapi_info;
176
177 struct _word_repeat_info {
178         char name[SETTING_PW_UG_NORMAL_PASSWORD_MAX_LENGTH+1];
179         unsigned int count;
180         struct _word_repeat_info *next;
181 };
182
183 typedef struct _pw_quality {
184         int quality;
185         int complex;
186         int length;
187 } setting_pw_quality;
188
189 /**
190  * Setting Password UG context
191  * all UG function has void* as an agument. this is casted back to SettingPasswordUG
192  * and the functions access app context.
193  */
194 typedef struct _SettingPasswordUG {
195         ui_gadget_h ug;
196         TapiHandle *handle;
197         TelSimSecResult_t *verify_puks_result;
198
199         /* add more variables here (move your appdata to here) */
200         Evas *evas;
201         Evas_Object *win_main_layout;
202         Evas_Object *win_get;
203         Evas_Object *ly_main;
204
205         setting_pw_type view_type;
206         char *view_type_string;
207         int step;
208
209         Evas_Object *bottom_btn;        /* Instead of Toolbar btn */
210         Setting_GenGroupItem_Data *ed_pw1;
211         Setting_GenGroupItem_Data *ed_pw2;
212         Setting_GenGroupItem_Data *ed_pw3;
213         Setting_GenGroupItem_Data *focus_data;
214         Evas_Object *setpw_notify;
215         Evas_Object *notify;
216
217         //Elm_Object_Item *err_desc;
218         Setting_GenGroupItem_Data *err_desc;
219         Elm_Genlist_Item_Class itc_err_desc;
220
221         Elm_Object_Item *navi_it;
222         Evas_Object *controllbar;
223         tapi_request_tapi_info *t_info;
224         Evas_Object *navi_bar;
225         Elm_Genlist_Item_Class itc_variable_height;
226         Elm_Genlist_Item_Class itc_layout;
227         Elm_Genlist_Item_Class itc_group_item;
228         Evas_Object *scroller;
229         int disable_item_type;
230
231         unsigned int remain_attempt;
232         unsigned int valid_sec;
233
234         setting_pw_quality pw_quality_info;
235
236         char *step1_str;
237
238         /* for simple password */
239         Elm_Genlist_Item_Class itc_title;
240         Elm_Genlist_Item_Class itc_sp_bg_1icon;
241         Elm_Object_Item *sp_item;
242         Evas_Object *sp_entry1;
243         Evas_Object *sp_entry2;
244         Evas_Object *sp_entry3;
245         Evas_Object *sp_entry4;
246         Evas_Object *sp_focused;
247         int sp_focused_num;
248         char sp_chars[5];
249
250         int sp_title_index;
251         char *cur_pwd;
252
253         //int is_simple_password_on;
254         int screen_lock_type;
255         int is_description;
256         int pw_status; //int is_empty;
257         int rotated;
258
259         bool puk_verified_flag;
260         bool update_change_pin1_flag;
261         bool incorrect_pin1_flag;
262         bool incorrect_pin2_flag;
263         bool destroy;
264         Ecore_Timer *remove_timer;
265         Ecore_Timer *set_history_timer;
266         Ecore_Timer *focus_timer;
267         /* end */
268
269         Evas_Object *simple_layout;
270         Ecore_IMF_Context *imf_context;
271         Ecore_Event_Handler *imf_handler;
272         Evas_Object *sp_entry[5];
273         Ecore_Timer *simple_done_timer;
274
275         /* fingerprint's alternative password */
276         int cur_step;
277
278 } SettingPasswordUG;
279
280
281 extern setting_view setting_view_password_sim;
282 extern setting_view setting_view_password_simple;
283 extern setting_view setting_view_password_main;
284
285 void setting_password_ug_popup_resp_cb(void *data, Evas_Object *obj, void *event_info);
286 void setting_password_ug_create_popup_notitle_nobtn(void *data, char *str, int destroy);
287
288 void setting_password_ug_display_desc(void *data, char *desc, int destroy);
289
290
291 extern void setting_password_ug_check_attemps_left(void *data);
292
293 int setting_password_check_password(const char *challenge,  unsigned int *remain_attempt, unsigned int *valid_sec);
294 int setting_password_set_password(const char *cur_pwd, const char *new_pwd, void *data);
295
296 #endif