aa0e1c713d528142d30f66386a5dfeda6342a8d9
[apps/core/preloaded/settings.git] / setting-security / include / setting-security.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_SECURITY_H__
22 #define __SETTING_SECURITY_H__
23
24 #include <glib.h>
25 #include <stdio.h>
26 #include <Elementary.h>
27 #include <Ecore_IMF.h>
28
29 #include <ITapiSim.h>
30 #include <TelSim.h>
31 #include <TelErr.h>
32 #include <TapiUtility.h>
33 #include <ITapiModem.h>
34
35 #include <glib-object.h>
36
37 #include <setting-common-draw-widget.h>
38 #include <setting-common-view.h>
39 #include <setting-debug.h>
40 #ifdef SUPPORT_MDM
41 #include <mdm.h>
42 #endif
43
44 #define Keystr_FDN      "IDS_ST_BODY_FIXED_DIALLING_MODE"
45
46 #if SUPPORT_ENCRYPTION
47 #define keystr_DeviceDecryption         "Device decryption"
48 #define DEVICE_ENCRYPTION_DESC  "IDS_ST_BODY_PASSWORD_REQUIRED_TO_DECRYPT_DEVICE_EACH_TIME_YOU_TURN_IT_ON"
49 #define DEVICE_DECRYPTION_DESC  "IDS_ST_BODY_DEVICE_ENCRYPTED"
50
51 #define Keystr_ConfirmEncryption        "Confirm encryption"
52 #define Keystr_ConfirmDecryption        "Confirm decryption"
53 #endif
54
55 #define USELESS_SIM_CARD "Not useful SIM card"
56
57 #if SUPPORT_SCREEN_SECURITY
58 #define Keystr_ScreenLockType   "IDS_ST_BODY_SCREEN_LOCK_TYPE"
59 #define Keystr_LockScreenOptions        "IDS_ST_BODY_LOCK_SCREEN_OPTIONS"
60 #define Keystr_Swipe                            "IDS_ST_MBODY_SWIPE"
61 #define Keystr_FaceAndVoice                     "IDS_ST_BODY_FACE_AND_VOICE"
62 #endif
63
64 #if SUPPORT_PARENTAL_MODE
65 #define Keystr_ParentalMode             "Parental mode"
66 #endif
67
68 typedef struct _SettingSecurityUG SettingSecurityUG;
69
70 typedef enum {
71         SETTING_SEC_PW_PASSWORD,
72         SETTING_SEC_PW_SIMPLE_PASSWD,
73         SETTING_SEC_PW_CHANGE_PASSWD,
74         SETTING_SEC_PW_CHANGE_SIMPLE_PASSWD,
75         SETTING_SEC_PW_ENTER_LOCK_TYPE,
76         SETTING_SEC_PW_SIM_LOCK_ON,
77         SETTING_SEC_PW_SIM_LOCK_OFF,
78         SETTING_SEC_PW_SIM_LOCK_DISABLED,
79         SETTING_SEC_PW_PIN_LOCK_ON,
80         SETTING_SEC_PW_PIN_LOCK_OFF,
81         SETTING_SEC_PW_CHANGE_PIN1,
82 #if SUPPORT_FDN
83         SETTING_SEC_PW_FDN_MODE_ON,
84         SETTING_SEC_PW_FDN_MODE_OFF,
85 #endif
86         SETTING_SEC_PW_CHANGE_PIN2,
87         SETTING_SEC_PW_PIN1_BLOCKED,
88         SETTING_SEC_PW_PIN2_BLOCKED,
89         SETTING_SEC_PW_MAX
90 } setting_sec_pw_type;
91
92 struct _security_item {
93         int pw_type_num;
94         char *pw_type_string;
95         int (*passwd_handler)(SettingSecurityUG *ad, void* data);
96 };
97
98 /**
99  * Setting Security UG context
100  * all UG function has void* as an agument. this is casted back to SettingSecurityUG
101  * and the functions access app context.
102  */
103 struct _SettingSecurityUG {
104         ui_gadget_h ug;
105         TapiHandle *handle;
106         TelSimFacilityStatus_t sim_status;
107         TelSimFacilityStatus_t pin1_status;
108         TelSimFacilityStatus_t pin2_status;//it indicates fdn status too
109
110         /* add more variables here (move your appdata to here) */
111         Evas *evas;
112         Evas_Object *win_main_layout;
113         Evas_Object *win_get;
114         Evas_Object *notify;
115
116         Evas_Object *ly_main;
117         Evas_Object *navi_bar;
118         ui_gadget_h ug_passwd;
119         ui_gadget_h ug_mt;
120
121         Setting_GenGroupItem_Data *data_phone_lk;
122         Setting_GenGroupItem_Data *data_mb;
123         Setting_GenGroupItem_Data *data_sim_lk;
124         Setting_GenGroupItem_Data *data_pin_lk;
125         Setting_GenGroupItem_Data *data_parental_md;
126         Setting_GenGroupItem_Data *data_simple_pw;
127         Setting_GenGroupItem_Data *data_change_pin1;
128         /* for simple password */
129
130         Setting_GenGroupItem_Data *data_cng_pw;
131 #if SUPPORT_ENCRYPTION
132         Setting_GenGroupItem_Data *data_device_enc;
133         Setting_GenGroupItem_Data *data_mmc_enc;
134 #endif
135         Elm_Genlist_Item_Class itc_1text;
136         Elm_Genlist_Item_Class itc_1text_1icon;
137         Elm_Genlist_Item_Class itc_seperator;
138         Elm_Genlist_Item_Class itc_2text_2;
139
140
141 #if SUPPORT_FDN
142         Setting_GenGroupItem_Data *data_fdn;
143         Evas_Object *chk_fdn;
144 #endif
145
146         setting_sec_pw_type pw_type;
147
148 #ifdef SUPPORT_MDM
149         mdm_data_t *mdm_data;
150         mdm_password_policy_t *mdm_policy;
151         mdm_result_t mdm_status;
152         policy_receiver_handle mdm_handle;
153
154         Ecore_Pipe *pipe;
155         pid_t child_pid;
156 #endif
157
158 #if SUPPORT_SCREEN_SECURITY
159         Setting_GenGroupItem_Data *data_screen_lock_type;
160         Evas_Object *lock_type_rd;
161         Setting_GenGroupItem_Data *data_sl_simple_pw;
162         Setting_GenGroupItem_Data *data_sl_pw;
163         ui_gadget_h ug_lockscreen;
164 #endif
165
166         char *input_pwd;
167
168         int sel_item; /**< It's used to check PIN1, PIN2 _BLOCKED. 0:click pin lock, 1:change pin1 code, 2:fdn, 3: change pin2 code */
169         Ecore_Timer *update_view_timer;
170 };
171
172 extern setting_view setting_view_security_main;
173 extern setting_view setting_view_security_encryption;
174 extern setting_view setting_view_security_screen_lock_type;
175 extern setting_view setting_view_security_sim_settings;
176
177 SettingSecurityUG *g_ad;        /* for tapi callback */
178
179 char *get_screen_lock_type_str(void * priv);
180 char *get_find_my_mobile_on_off_str(void *priv);
181 void setting_security_result_password_ug_cb(ui_gadget_h ug,
182                                             service_h service, void *priv);
183 void setting_security_sim_get_facility_cb(TapiHandle *handle, int result, void *data, void *user_data);
184
185 gboolean setting_security_create_password_sg(void *data);
186 void setting_security_create_find_my_mobile_sg(void *cb, int argc, char **argv);
187 void setting_security_destroy_find_my_mobile_ug_cb(ui_gadget_h ug,
188                                                    void *priv);
189
190 #ifdef TEST_MDM
191 void setting_security_destroy_password_ug_cb(ui_gadget_h ug,
192                                                     void *priv);
193 void setting_security_layout_passwd_ug_cb(ui_gadget_h ug,
194                                                  enum ug_mode mode, void *priv);
195 #endif
196
197 #ifdef SUPPORT_MDM
198 void setting_security_disable_items_for_mdm(void *data);
199 #endif
200
201 gboolean setting_security_create_lockscreen_options_sg(void *data);
202
203 #endif