Initialize Tizen 2.3
[apps/home/settings.git] / setting-password / include / setting-password.h
1 /*
2  * setting
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Flora License, Version 1.1 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://floralicense.org/license/
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an AS IS BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #ifndef _SETTING_PASSWORD_H_
18 #define _SETTING_PASSWORD_H_
19
20 #include <glib.h>
21 #include <Elementary.h>
22 #include <Ecore_IMF.h>
23
24 #include <ITapiSim.h>
25 #include <TelSim.h>
26 #include <TelErr.h>
27 #include <TapiUtility.h>
28
29 #include <glib-object.h>
30
31 #include <setting-common-draw-widget.h>
32 #include <setting-common-view.h>
33 #include <setting-debug.h>
34
35 //#include <security-server.h>
36
37 #define SETTING_PW_UG_NORMAL_PASSWORD_MIN_LENGTH 4
38 #define SETTING_PW_UG_NORMAL_PASSWORD_MAX_LENGTH 16
39 #define SETTING_PW_UG_PRIVACY_PASSWORD_MIN_LENGTH 4
40 #define SETTING_PW_UG_PRIVACY_PASSWORD_MAX_LENGTH 16
41 #define SETTING_PW_UG_SIM_MIN_LENGTH 4
42 #define SETTING_PW_UG_SIM_MAX_LENGTH 8
43 #define SETTING_PW_UG_PIN_MIN_LENGTH 4
44 #define SETTING_PW_UG_PIN_MAX_LENGTH 8
45 #define SETTING_PW_UG_PUK_MIN_LENGTH 4
46 #define SETTING_PW_UG_PUK_MAX_LENGTH 8
47 #define SETTING_PW_MAX_TITLE_LENGTH MAX_DISPLAY_NAME_LEN_ON_UI
48
49 #define PASSWORD_EMPTY  _("IDS_ST_BODY_PASSWORD_EMPTY")
50 #define ATTEMPT_DESC    _("IDS_ST_POP_PD_ATTEMPT_LEFT")                 /* "%d attempt left" */
51 #define ATTEMPTS_DESC   _("IDS_ST_POP_PD_ATTEMPTS_LEFT")                /* "%d attempts left" */
52 #define PIN_ERR_DESC    _("IDS_ST_POP_INCORRECT_PIN_PD_ATTEMPTS_LEFT") /* "Incorrect PIN. %d attempts left" */
53 #define PUK1_ERR_DESC   _("IDS_ST_POP_INCORRECT_PUK1_PD_ATTEMPTS_LEFT") /* "Incorrect PUK1. %d attempts left" */
54 #define PUK2_ERR_DESC   _("IDS_ST_POP_INCORRECT_PUK2_PD_ATTEMPTS_LEFT") /* "Incorrect PUK2. %d attempts left" */
55 #define PW_ERR_DESC     _("IDS_ST_POP_INCORRECT_PASSWORD")      /* "Incorrect password" */
56 #define PW_ERR_DELAY_DESC _("IDS_ST_BODY_ENTER_PASSWORD_AGAIN_AFTER_PD_SECONDS") /* "Please enter password again after %d seconds" */
57 #define PW_ERR_DELAY_TIME       30
58 #define ATTEMPT_INFINITE        999999
59
60 #define PW_SHORT_GUIDE_CURRENT          "IDS_ST_BODY_CURRENT"
61 #define PW_SHORT_GUIDE_NEW                      "IDS_ST_BODY_NEW"
62 #define PW_SHORT_GUIDE_CONFIRM          "IDS_ST_BODY_CONFIRM"
63
64 typedef enum {
65         SETTING_PW_TYPE_SIM_LOCK_ON, 
66         SETTING_PW_TYPE_SIM_LOCK_OFF,
67         SETTING_PW_TYPE_PIN_LOCK_ON,
68         SETTING_PW_TYPE_PIN_LOCK_OFF,
69         SETTING_PW_TYPE_CHANGE_PIN1,
70         SETTING_PW_TYPE_CHANGE_PIN2,
71         SETTING_PW_TYPE_PIN1_BLOCKED,
72         SETTING_PW_TYPE_PIN2_BLOCKED,
73         SETTING_PW_TYPE_RESET, 
74         SETTING_PW_TYPE_MAX,
75 } setting_pw_type;
76
77 struct _pw_item {
78         int pw_type_num;
79         char *pw_type_string;
80 };
81
82 /* For Tapi */
83 typedef enum {
84         SIM_OPERATION_OK,
85         SIM_ERROR,
86         SIM_REQ_PIN,
87         SIM_OPERATION_OFF,
88         SIM_LOCK_ON_SUCCESS,
89         SIM_LOCK_OFF_SUCCESS,
90         SIM_PIN_LOCK_ON_SUCCESS,
91         SIM_PIN_LOCK_OFF_SUCCESS,
92         SIM_LOCK_ON_FAIL,
93         SIM_LOCK_INCORRECT_PASSWORD,
94         SIM_INCORRECT_PIN1_CODE,
95         SIM_INCORRECT_PIN2_CODE,
96         SIM_INCORRECT_PUK1_CODE,
97         SIM_INCORRECT_PUK2_CODE,
98         SIM_PIN1_CHANGE_SUCCESS,
99         SIM_PIN2_CHANGE_SUCCESS,
100         SIM_PIN1_CHANGE_FAIL,
101         SIM_PIN2_CHANGE_FAIL,
102         SIM_PIN1_BLOCKED,
103         SIM_PIN2_BLOCKED,
104         SIM_PIN1_UNBLOCKED,
105         SIM_PIN2_UNBLOCKED,
106         SIM_PUK1_BLOCKED,
107         SIM_PUK2_BLOCKED,
108         SIM_REQUIRED_PUK_CODE,
109         SIM_OPERATION_UNAVAILABLE,
110         SIM_UNKNOWN_ERROR,
111 } sim_stat_value;
112
113 typedef enum {
114         SETTING_PW_NAVIBAR_WITH_NO_BTN,
115         SETTING_PW_NAVIBAR_WITH_LEFT_BTN,
116         SETTING_PW_NAVIBAR_WITH_RIGHT_BTN,
117         SETTING_PW_NAVIBAR_WITH_BOTH_BTN,
118 } setting_pw_navibar_style_t;
119
120 typedef struct _tapi_request_event {
121         unsigned int sid;
122         int event;
123 } tapi_request_event;
124
125 typedef struct _tapi_receive_info {
126         sim_stat_value stat;
127         int retry_cnt;
128 } tapi_receive_info;
129
130 typedef struct _tapi_request_tapi_info {
131         tapi_request_event *evt;
132         int evt_sz;
133
134         void *cb_data;
135         void (*cb) (tapi_receive_info *, void *);
136 } tapi_request_tapi_info;
137
138 /**
139  * Setting Password UG context
140  * all UG function has void* as an agument. this is casted back to SettingPasswordUG
141  * and the functions access app context.
142  */
143 typedef struct _SettingPasswordUG {
144         ui_gadget_h ug;
145         TapiHandle *handle;
146         TelSimSecResult_t *verify_puks_result;
147
148         /* add more variables here (move your appdata to here) */
149         Evas *evas;
150         Evas_Object *win_main_layout;
151         Evas_Object *win_get;
152         Evas_Object *ly_main;
153
154         setting_pw_type view_type;
155         char *view_type_string;
156
157         Setting_GenGroupItem_Data *ed_pw1;
158         Setting_GenGroupItem_Data *ed_pw2;
159         Setting_GenGroupItem_Data *ed_pw3;
160         Setting_GenGroupItem_Data *focus_data;
161         Evas_Object *setpw_notify;
162         Evas_Object *notify;
163
164         Elm_Object_Item *err_desc;
165         Elm_Genlist_Item_Class itc_err_desc;
166
167         Elm_Object_Item *navi_it;
168         Evas_Object *controllbar;
169         tapi_request_tapi_info *t_info;
170         Evas_Object *navi_bar;
171         Elm_Genlist_Item_Class itc_variable_height;
172         Elm_Genlist_Item_Class itc_seperator;
173         Elm_Genlist_Item_Class itc_layout;
174         Elm_Genlist_Item_Class itc_group_item;
175         Evas_Object *scroller;
176         int disable_item_type;
177
178         Elm_Genlist_Item_Class itc_title;
179
180         int is_description;
181         int is_empty;
182         int rotated;
183
184         bool destroy;
185         Ecore_Timer *remove_timer;
186         Ecore_Timer *set_history_timer;
187         Ecore_Timer *focus_timer;
188         /* end */
189
190 } SettingPasswordUG;
191
192 extern setting_view setting_view_password_main;
193
194 void setting_get_pin_lock_info_cb(TapiHandle *handle, int result, void *data, void *user_data);
195 void setting_get_sim_lock_info_cb(TapiHandle *handle, int result, void *data, void *user_data);
196
197 void setting_sim_change_pins_cb(TapiHandle *handle, int result, void *data, void *user_data);
198 void setting_sim_verify_puks_cb(TapiHandle *handle, int result, void *data, void *user_data);
199 void setting_sim_facility_enable_cb(TapiHandle *handle, int result, void *data, void *user_data);
200 void setting_sim_facility_disable_cb(TapiHandle *handle, int result, void *data, void *user_data);
201
202 void setting_password_ug_popup_resp_cb(void *data, Evas_Object *obj, void *event_info);
203 void setting_password_ug_create_popup_notitle_nobtn(void *data, char *str, int destroy);
204
205 void setting_password_ug_display_desc(void *data, char *desc, int destroy);
206
207
208 #endif