Apply GUI resource and layout to progressbar
[platform/core/security/ode.git] / tools / apps / ode / src / ode-app-main.c
1 /*
2  *
3  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4  *
5  * Licensed under the Apache License, Version 2.0 (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://www.apache.org/licenses/LICENSE-2.0
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  */
18
19 #include "ode-app.h"
20
21 #define APP_SETTING_LOCKTYPE "org.tizen.setting-locktype"
22 #define APP_SETTING_PASSWORD "org.tizen.setting-password"
23
24 static void update_next_button_status(appdata_s* ad)
25 {
26         dlog_print(DLOG_DEBUG, LOG_TAG, "update_next_button_status start");
27         if (ad->device_info.next_button == NULL) {
28                 dlog_print(DLOG_ERROR, LOG_TAG, "[Encrypt Device] next button is null");
29                 return;
30         }
31
32         if (ad->view_type == ENCRYPT_DEVICE) {
33                 if (ad->device_info.battery_status && ad->device_info.charger_status && ad->device_info.locktype_status) {
34                         elm_object_disabled_set(ad->device_info.next_button, EINA_FALSE);
35                 } else {
36                         elm_object_disabled_set(ad->device_info.next_button, EINA_TRUE);
37                 }
38         } else if (ad->view_type == DECRYPT_DEVICE) {
39                 if (ad->device_info.battery_status && ad->device_info.charger_status) {
40                         elm_object_disabled_set(ad->device_info.next_button, EINA_FALSE);
41                 } else {
42                         elm_object_disabled_set(ad->device_info.next_button, EINA_TRUE);
43                 }
44         } else if (ad->view_type == ENCRYPT_SD_CARD) {
45                 if (ad->device_info.sdcard_status) {
46                         elm_object_disabled_set(ad->device_info.next_button, EINA_FALSE);
47                 } else {
48                         elm_object_disabled_set(ad->device_info.next_button, EINA_TRUE);
49                 }
50         }
51 }
52
53 static void _next_btn_clicked_cb(void* data, Evas_Object* obj, void* event_info)
54 {
55         dlog_print(DLOG_DEBUG, LOG_TAG, "_next_btn_clicked_cb start");
56
57         appdata_s* ad = (appdata_s*) data;
58
59         switch (ad->view_type) {
60         case ENCRYPT_DEVICE:
61                 dpm_encryption_device_confirm_create_view(ad);
62                 break;
63         case DECRYPT_DEVICE:
64                 dpm_decryption_device_confirm_create_view(ad);
65                 break;
66         case ENCRYPT_SD_CARD:
67                 dpm_encryption_sd_card_confirm_create_view(ad);
68                 break;
69         case DECRYPT_SD_CARD:
70                 dpm_decryption_sd_card_confirm_create_view(ad);
71                 break;
72         }
73 }
74
75 static void set_next_btn_layout(Evas_Object* layout, appdata_s* ad, const char* btn_text)
76 {
77         Evas_Object* btn_layout;
78         Evas_Object* next_btn;
79
80         btn_layout = dpm_encryption_create_layout(layout, ad->edj_path, "next_button_layout");
81
82         next_btn = dpm_encryption_create_button(btn_layout, btn_text, "bottom");
83         ad->device_info.next_button = next_btn;
84         elm_object_part_content_set(btn_layout, "next_button", next_btn);
85
86         update_next_button_status(ad);
87         evas_object_smart_callback_add(next_btn, "clicked", _next_btn_clicked_cb, ad);
88
89         elm_object_part_content_set(layout, "bottom_layout", btn_layout);
90         return;
91 }
92
93 static void _launch_password_ug_cb(app_control_h ug, app_control_h reply, app_control_result_e result, void* data)
94 {
95         if (!result) {
96                 char* string_result = NULL;
97                 char* current = NULL;
98                 app_control_get_extra_data(reply, "result", &string_result);
99                 if (string_result == NULL)
100                         return;
101
102                 int ret_int = 0;
103                 if (strcmp(string_result, "Cancel") == 0)
104                         ret_int = 0;
105                 else if (strcmp(string_result, "SETTING_PW_TYPE_ENTER_LOCK_TYPE") == 0 || strcmp(string_result, "SETTING_PW_TYPE_VERIFY_FP_ALT_PASSWORD") == 0)
106                         ret_int = 1;
107
108                 free(string_result);
109
110                 if (ret_int == 1) {
111                         app_control_h app_ctl;
112                         if (app_control_create(&app_ctl)) {
113                                 dlog_print(DLOG_ERROR, LOG_TAG, "app_control_create failed");
114                                 return;
115                         }
116                         app_control_get_extra_data(reply, "current", &current);
117                         if (current) {
118                                 app_control_add_extra_data(app_ctl, "current", current);
119                                 free(current);
120                         }
121                         app_control_set_app_id(app_ctl, APP_SETTING_LOCKTYPE);
122                         app_control_set_launch_mode(app_ctl, APP_CONTROL_LAUNCH_MODE_GROUP);
123                         app_control_send_launch_request(app_ctl, NULL, NULL);
124                         app_control_destroy(app_ctl);
125                 }
126         }
127 }
128
129 static void _locktype_btn_clicked_cb(void* data, Evas_Object* obj, void* event_info)
130 {
131         /* launch lock type menu */
132         dlog_print(DLOG_DEBUG, LOG_TAG, "locktype button clicked");
133         appdata_s*ad = (appdata_s*) data;
134
135         app_control_h app_ctl = NULL;
136         int ret;
137         int lock_type = 0;
138
139         ret = app_control_create(&app_ctl);
140         if (ret != APP_CONTROL_ERROR_NONE) {
141                 dlog_print(DLOG_DEBUG, LOG_TAG, "app_control_create failed");
142                 return;
143         }
144
145         vconf_get_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &lock_type);
146
147         if (lock_type == SETTING_SCREEN_LOCK_TYPE_PASSWORD || lock_type == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD) {
148                 app_control_add_extra_data(app_ctl, "viewtype", "SETTING_PW_TYPE_ENTER_LOCK_TYPE");
149                 app_control_set_app_id(app_ctl, APP_SETTING_PASSWORD);
150                 app_control_set_launch_mode(app_ctl, APP_CONTROL_LAUNCH_MODE_GROUP);
151                 app_control_send_launch_request(app_ctl, _launch_password_ug_cb, NULL);
152                 app_control_destroy(app_ctl);
153
154         } else {
155                 app_control_set_app_id(app_ctl, APP_SETTING_LOCKTYPE);
156                 app_control_set_launch_mode(app_ctl, APP_CONTROL_LAUNCH_MODE_GROUP);
157                 app_control_send_launch_request(app_ctl, NULL, NULL);
158                 app_control_destroy(app_ctl);
159         }
160
161         update_next_button_status(ad);
162 }
163
164 static void _sdcardpw_create_btn_clicked_cb(void* data, Evas_Object* obj, void* event_info)
165 {
166         dlog_print(DLOG_ERROR, LOG_TAG, "sdcardpw create btn cb start");
167 }
168
169 static void _sdcardpw_change_btn_clicked_cb(void* data, Evas_Object* obj, void* event_info)
170 {
171         dlog_print(DLOG_ERROR, LOG_TAG, "sdcardpw change btn cb start");
172 }
173
174 static void _sdcardpw_delete_btn_clicked_cb(void* data, Evas_Object* obj, void* event_info)
175 {
176         dlog_print(DLOG_ERROR, LOG_TAG, "sdcardpw delete btn cb start");
177 }
178
179 static void set_locktype_btn_layout(Evas_Object* layout, appdata_s* ad, const char* btn_text)
180 {
181         Evas_Object* btn_layout;
182         Evas_Object* locktype_btn;
183
184         btn_layout = dpm_encryption_create_layout(layout, ad->edj_path, "locktype_button_layout");
185
186         locktype_btn = dpm_encryption_create_button(btn_layout, btn_text, "default");
187         elm_object_part_content_set(btn_layout, "locktype_button", locktype_btn);
188         evas_object_smart_callback_add(locktype_btn, "clicked", _locktype_btn_clicked_cb, ad);
189
190         elm_object_part_content_set(layout, "locktype_button_content", btn_layout);
191         return;
192 }
193
194 static void set_sdcard_pw_btn_layout(Evas_Object* layout, appdata_s* ad)
195 {
196         Evas_Object* btn_layout;
197         Evas_Object* createpw_btn, *changepw_btn, *deletepw_btn;
198
199         btn_layout = dpm_encryption_create_layout(layout, ad->edj_path, "sdcard_pw_button_layout");
200
201         createpw_btn = dpm_encryption_create_button(btn_layout, IDS_ST_BUTTON_CREATE_PASSWORD, "default");
202         changepw_btn = dpm_encryption_create_button(btn_layout, IDS_ST_BUTTON_CHANGE_PW_ABB, "default");
203         deletepw_btn = dpm_encryption_create_button(btn_layout, IDS_ST_BUTTON_DELETE_PW_ABB, "default");
204
205         elm_object_part_content_set(btn_layout, "create_pw_button", btn_layout);
206         elm_object_part_content_set(btn_layout, "change_pw_button", btn_layout);
207         elm_object_part_content_set(btn_layout, "delete_pw_button", btn_layout);
208
209         evas_object_smart_callback_add(createpw_btn, "clicked", _sdcardpw_create_btn_clicked_cb, NULL);
210         evas_object_smart_callback_add(changepw_btn, "clicked", _sdcardpw_change_btn_clicked_cb, NULL);
211         evas_object_smart_callback_add(deletepw_btn, "clicked", _sdcardpw_delete_btn_clicked_cb, NULL);
212
213         elm_object_part_content_set(layout, "sd_card_btn", btn_layout);
214         return;
215 }
216
217 static void set_icon(appdata_s* ad, int type, char* part)
218 {
219         Evas_Object* icon_check, *icon_bar = NULL;
220         int ret;
221         if (ad->dpm_encryption_layout == NULL || ad->icon_check_path == NULL || ad->icon_bar_path == NULL) {
222                 dlog_print(DLOG_ERROR, LOG_TAG, "invalid parameter");
223                 return;
224         }
225         if (type == ICON_CHECK) {
226                 icon_check = elm_image_add(ad->dpm_encryption_layout);
227                 if (icon_check == NULL) {
228                         dlog_print(DLOG_ERROR, LOG_TAG, "elm_image_add failed");
229                         return;
230                 }
231                 elm_image_file_set(icon_check, ad->icon_check_path, NULL);
232                 evas_object_color_set(icon_check, 153, 153, 153, 255);
233                 evas_object_size_hint_align_set(icon_check, EVAS_HINT_FILL, EVAS_HINT_FILL);
234                 evas_object_size_hint_weight_set(icon_check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
235
236                 ret = elm_layout_content_set(ad->dpm_encryption_layout, part, icon_check);
237                 if (!ret) {
238                         dlog_print(DLOG_ERROR, LOG_TAG, "elm_layout_content_set failed");
239                         return;
240                 }
241                 evas_object_show(icon_check);
242         } else if (type == ICON_BAR) {
243                 icon_bar = elm_image_add(ad->dpm_encryption_layout);
244                 if (icon_bar == NULL) {
245                         dlog_print(DLOG_ERROR, LOG_TAG, "elm_image_add failed");
246                         return;
247                 }
248                 elm_image_file_set(icon_bar, ad->icon_bar_path, NULL);
249                 evas_object_color_set(icon_bar, 0, 0, 0, 255);
250                 evas_object_size_hint_align_set(icon_bar, EVAS_HINT_FILL, EVAS_HINT_FILL);
251                 evas_object_size_hint_weight_set(icon_bar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
252
253                 ret = elm_layout_content_set(ad->dpm_encryption_layout, part, icon_bar);
254                 if (!ret) {
255                         dlog_print(DLOG_ERROR, LOG_TAG, "elm_layout_content_set failed");
256                         return;
257                 }
258                 evas_object_show(icon_bar);
259         }
260 }
261
262 static int battery_status_update(appdata_s* ad)
263 {
264         bool connected;
265         int battery_pct, ret;
266         dlog_print(DLOG_DEBUG, LOG_TAG, "battery_status_update start ");
267
268         if (ad->dpm_encryption_layout == NULL) {
269                 dlog_print(DLOG_ERROR, LOG_TAG, "encrypt layout is null");
270                 return -1;
271         }
272
273         /* get battery percent info */
274         ret = device_battery_get_percent(&battery_pct);
275         if (ret != DEVICE_ERROR_NONE) {
276                 dlog_print(DLOG_ERROR, LOG_TAG, "device_battery_get_percent failed %d", ret);
277                 return -1;
278         }
279
280         if (battery_pct > NEEDED_BATTERY_PERCENT) {
281                 set_icon(ad, ICON_CHECK, "battery_icon");
282                 ad->device_info.battery_status = 1;
283         } else {
284                 set_icon(ad, ICON_BAR, "battery_icon");
285                 ad->device_info.battery_status = 0;
286         }
287
288         /* get charger connected info */
289         ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_CHARGER_CONNECTED, &connected);
290         if (ret != RUNTIME_INFO_ERROR_NONE) {
291                 dlog_print(DLOG_ERROR, LOG_TAG, "get runtime info fail");
292                 return -1;
293         }
294         if (connected) {
295                 set_icon(ad, ICON_CHECK, "charge_icon");
296                 ad->device_info.charger_status = 1;
297         } else {
298                 set_icon(ad, ICON_BAR, "charge_icon");
299                 ad->device_info.charger_status = 0;
300         }
301
302         update_next_button_status(ad);
303         return 0;
304 }
305
306 static int sdcard_status_update(appdata_s* ad)
307 {
308         int sdcard_status;
309
310         if (ad->dpm_encryption_layout == NULL) {
311                 dlog_print(DLOG_ERROR, LOG_TAG, "encrypt layout is null");
312                 return -1;
313         }
314
315         vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &sdcard_status);
316         if (sdcard_status != VCONFKEY_SYSMAN_MMC_MOUNTED) {
317                 set_icon(ad, ICON_BAR, "sd_card_icon");
318                 ad->device_info.sdcard_status = 0;
319         } else {
320                 /* available */
321                 set_icon(ad, ICON_CHECK, "sd_card_icon");
322                 ad->device_info.sdcard_status = 1;
323         }
324
325         update_next_button_status(ad);
326         return 0;
327 }
328
329 static int locktype_status_update(appdata_s* ad)
330 {
331         int lock_type;
332
333         if (ad->dpm_encryption_layout == NULL) {
334                 dlog_print(DLOG_ERROR, LOG_TAG, "encrypt layout is null");
335                 return -1;
336         }
337
338         vconf_get_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &lock_type);
339         if (lock_type == SETTING_SCREEN_LOCK_TYPE_PASSWORD || lock_type == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD) {
340                 /* available */
341                 set_icon(ad, ICON_CHECK, "locktype_icon");
342                 ad->device_info.locktype_status = 1;
343         } else {
344                 /* unavailable */
345                 set_icon(ad, ICON_BAR, "locktype_icon");
346                 ad->device_info.locktype_status = 0;
347         }
348         update_next_button_status(ad);
349         return 0;
350 }
351
352 static void battery_charger_changed_cb(runtime_info_key_e key, void* data)
353 {
354         appdata_s* ad = (appdata_s*) data;
355         if (key == RUNTIME_INFO_KEY_CHARGER_CONNECTED)
356                 battery_status_update(ad);
357 }
358
359 void battery_changed_cb(device_callback_e type, void* value, void* user_data)
360 {
361         appdata_s* ad = (appdata_s*) user_data;
362         if (type == DEVICE_CALLBACK_BATTERY_CAPACITY)
363                 battery_status_update(ad);
364 }
365
366 void sdcard_status_changed_cb(keynode_t* node, void* data)
367 {
368         appdata_s* ad = (appdata_s*) data;
369         sdcard_status_update(ad);
370 }
371
372 void locktype_status_changed_cb(keynode_t* node, void* data)
373 {
374         appdata_s* ad = (appdata_s*) data;
375         locktype_status_update(ad);
376 }
377
378 static int battery_cb_register(appdata_s* ad)
379 {
380         int ret;
381
382         /* register runtime callback : connected charger */
383         ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_CHARGER_CONNECTED, battery_charger_changed_cb, ad);
384         if (ret != RUNTIME_INFO_ERROR_NONE) {
385                 dlog_print(DLOG_ERROR, LOG_TAG, "runtime_info_set_changed_cb failed: %d", ret);
386                 return -1;
387         }
388
389         /* register runtime callback : battery percent */
390         ret = device_add_callback(DEVICE_CALLBACK_BATTERY_CAPACITY, battery_changed_cb, ad);
391         if (ret != DEVICE_ERROR_NONE) {
392                 dlog_print(DLOG_ERROR, LOG_TAG, "device_add_callback failed: %d", ret);
393                 return -1;
394         }
395
396         return 0;
397 }
398
399 static int locktype_cb_register(appdata_s* ad)
400 {
401         int ret;
402
403         /* register vconf notify for locktype */
404         ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, locktype_status_changed_cb, ad);
405         if (ret != 0) {
406                 dlog_print(DLOG_ERROR, LOG_TAG, "runtime_info_set_changed_cb failed: %d", ret);
407                 return -1;
408         }
409
410         return 0;
411 }
412
413 void _back_btn_clicked_cb(void* data, Evas_Object* obj, void* event_info)
414 {
415         ui_app_exit();
416 }
417
418 static Eina_Bool _pop_cb(void* data, Elm_Object_Item* it)
419 {
420         ui_app_exit();
421         return EINA_FALSE;
422 }
423
424 void sw_back_btn_set(Evas_Object* obj, const char* title_label, Evas_Object* content)
425 {
426         Evas_Object* back_btn = NULL;
427
428         back_btn = elm_button_add(obj);
429         elm_object_style_set(back_btn, "naviframe/back_btn/default");
430         evas_object_smart_callback_add(back_btn, "clicked", _back_btn_clicked_cb, obj);
431
432         Elm_Object_Item *nf_it = elm_naviframe_item_push(obj, title_label, back_btn, NULL, content, NULL);
433         elm_naviframe_item_pop_cb_set(nf_it, _pop_cb, NULL);
434 }
435
436 void dpm_encryption_create_view(appdata_s* ad)
437 {
438         Evas_Object* navi_bar = ad->navi_bar;
439         Evas_Object* base_layout = NULL;
440         Evas_Object* encrypt_msg1, *encrypt_msg2, *encrypt_msg3 = NULL;
441         Evas_Object* battery_txt, *charge_txt, *locktype_txt = NULL;
442         Evas_Object* encryption_layout = NULL;
443         Evas_Textblock_Style* text_st;
444
445         int ret;
446
447         dlog_print(DLOG_DEBUG, LOG_TAG, "start dpm_encryption_create_view");
448
449         if (navi_bar == NULL) {
450                 dlog_print(DLOG_ERROR, LOG_TAG, "navi_bar is null");
451                 return;
452         }
453
454         base_layout = dpm_encryption_create_layout(navi_bar, ad->edj_path, "base_layout");
455         encryption_layout = dpm_encryption_create_layout(base_layout, ad->edj_path, "Encrypt_device_layout");
456         ad->dpm_encryption_layout = encryption_layout;
457
458         text_st = evas_textblock_style_new();
459         evas_textblock_style_set(text_st, MSG_TEXT_STYLE);
460
461         encrypt_msg1 = dpm_encryption_create_textblock(encryption_layout, IDS_ST_BODY_ENCRYPTING_MSG_1, text_st);
462         elm_object_part_content_set(encryption_layout, "msg_content_1", encrypt_msg1);
463         encrypt_msg2 = dpm_encryption_create_textblock(encryption_layout, IDS_ST_BODY_ENCRYPTING_MSG_2, text_st);
464         elm_object_part_content_set(encryption_layout, "msg_content_2", encrypt_msg2);
465         encrypt_msg3 = dpm_encryption_create_textblock(encryption_layout, IDS_ST_BODY_TO_ENCRYPTION_YOUR_DEVICE_C_ABB, text_st);
466         elm_object_part_content_set(encryption_layout, "msg_content_3", encrypt_msg3);
467
468         set_next_btn_layout(base_layout, ad, IDS_ST_BUTTON_NEXT);
469
470         /* get battery info */
471         ret = battery_status_update(ad);
472         if (ret != 0) {
473                 dlog_print(DLOG_ERROR, LOG_TAG, "battery_status_update failed");
474                 return;
475         }
476
477         ret = battery_cb_register(ad);
478         if (ret != 0) {
479                 dlog_print(DLOG_ERROR, LOG_TAG, "battery_cb_register failed");
480                 return;
481         }
482
483         /* get locktype */
484         ret = locktype_status_update(ad);
485         if (ret != 0) {
486                 dlog_print(DLOG_ERROR, LOG_TAG, "locktype_status_update failed");
487                 return;
488         }
489
490         ret = locktype_cb_register(ad);
491         if (ret != 0) {
492                 dlog_print(DLOG_ERROR, LOG_TAG, "locktype_cb_register failed");
493                 return;
494         }
495
496         /* set layout text */
497         battery_txt = dpm_encryption_create_textblock(encryption_layout, IDS_ST_BODY_CHARGE_THE_BATTERY_TO_AT_LEAST_PDP, text_st);
498         elm_object_part_content_set(encryption_layout, "battery_text", battery_txt);
499         charge_txt = dpm_encryption_create_textblock(encryption_layout, IDS_ST_BODY_CONNECT_THE_DEVICE_TO_A_CHARGER, text_st);
500         evas_object_size_hint_weight_set(charge_txt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
501         elm_object_part_content_set(encryption_layout, "charge_text", charge_txt);
502         locktype_txt = dpm_encryption_create_textblock(encryption_layout, IDS_ST_BODY_SET_THE_SCREEN_LOCK_TYPE_AS_PATTERN_PIN_OR_PASSWORD, text_st);
503         elm_object_part_content_set(encryption_layout, "locktype_text", locktype_txt);
504
505         evas_textblock_style_free(text_st);
506
507         set_locktype_btn_layout(encryption_layout, ad, IDS_ST_BUTTON_SCREEN_LOCK_TYPE_ABB);
508
509         elm_object_part_content_set(base_layout, "content_layout", encryption_layout);
510
511         sw_back_btn_set(navi_bar, IDS_ST_HEADER_ENCRYPT_DEVICE, base_layout);
512 }
513
514 void dpm_decryption_create_view(appdata_s* ad)
515 {
516         Evas_Object* navi_bar = ad->navi_bar;
517         Evas_Object* base_layout = NULL;
518         Evas_Object* decrypt_msg1, *decrypt_msg2, *decrypt_msg3 = NULL;
519         Evas_Object* battery_txt, *charge_txt = NULL;
520         Evas_Object* decryption_layout = NULL;
521         Evas_Textblock_Style* text_st;
522
523         int ret;
524
525         dlog_print(DLOG_DEBUG, LOG_TAG, "start dpm_decryption_create_view");
526
527         if (navi_bar == NULL) {
528                 dlog_print(DLOG_ERROR, LOG_TAG, "navi_bar is null");
529                 return;
530         }
531
532         base_layout = dpm_encryption_create_layout(navi_bar, ad->edj_path, "base_layout");
533         decryption_layout = dpm_encryption_create_layout(base_layout, ad->edj_path, "Decrypt_device_layout");
534         ad->dpm_encryption_layout = decryption_layout;
535
536         text_st = evas_textblock_style_new();
537         evas_textblock_style_set(text_st, MSG_TEXT_STYLE);
538
539         decrypt_msg1 = dpm_encryption_create_textblock(decryption_layout, IDS_ST_BODY_DECRYPTING_MSG_1, text_st);
540         elm_object_part_content_set(decryption_layout, "msg_content_1", decrypt_msg1);
541         decrypt_msg2 = dpm_encryption_create_textblock(decryption_layout, IDS_ST_BODY_DECRYPTING_MSG_2, text_st);
542         elm_object_part_content_set(decryption_layout, "msg_content_2", decrypt_msg2);
543         decrypt_msg3 = dpm_encryption_create_textblock(decryption_layout, IDS_ST_HEADER_TO_DECRYPT_YOUR_DEVICE_C_ABB, text_st);
544         elm_object_part_content_set(decryption_layout, "msg_content_3", decrypt_msg3);
545
546         set_next_btn_layout(base_layout, ad, IDS_ST_BUTTON_NEXT);
547
548         /* get battery info */
549         ret = battery_status_update(ad);
550         if (ret != 0) {
551                 dlog_print(DLOG_ERROR, LOG_TAG, "battery_status_update failed");
552                 return;
553         }
554
555         ret = battery_cb_register(ad);
556         if (ret != 0) {
557                 dlog_print(DLOG_ERROR, LOG_TAG, "battery_cb_register failed");
558                 return;
559         }
560
561         /* set layout text */
562         battery_txt = dpm_encryption_create_textblock(decryption_layout, IDS_ST_BODY_CHARGE_THE_BATTERY_TO_AT_LEAST_PDP, text_st);
563         elm_object_part_content_set(decryption_layout, "battery_text", battery_txt);
564         charge_txt = dpm_encryption_create_textblock(decryption_layout, IDS_ST_BODY_CONNECT_THE_DEVICE_TO_A_CHARGER, text_st);
565         elm_object_part_content_set(decryption_layout, "charge_text", charge_txt);
566
567         evas_textblock_style_free(text_st);
568
569         elm_object_part_content_set(base_layout, "content_layout", decryption_layout);
570
571         sw_back_btn_set(navi_bar, IDS_ST_HEADER_DECRYPT_DEVICE, base_layout);
572 }
573
574 void dpm_encryption_sd_card_create_view(appdata_s* ad)
575 {
576         Evas_Object* navi_bar = ad->navi_bar;
577         Evas_Object* base_layout = NULL;
578         Evas_Object* encrypt_msg1, *encrypt_msg2, *encrypt_msg3, *encrypt_msg4 = NULL;
579         Evas_Object* sdcard_txt = NULL;
580         /* Evas_Object* password_txt = NULL; */
581         Evas_Object* encryption_layout = NULL;
582         Evas_Textblock_Style* text_st;
583
584         int ret;
585
586         dlog_print(DLOG_DEBUG, LOG_TAG, "start dpm_encryption_create_view");
587
588         if (navi_bar == NULL) {
589                 dlog_print(DLOG_ERROR, LOG_TAG, "navi_bar is null");
590                 return;
591         }
592
593         base_layout = dpm_encryption_create_layout(navi_bar, ad->edj_path, "base_layout");
594         encryption_layout = dpm_encryption_create_layout(base_layout, ad->edj_path, "Encrypt_sd_card_layout");
595         ad->dpm_encryption_layout = encryption_layout;
596
597         text_st = evas_textblock_style_new();
598         evas_textblock_style_set(text_st, MSG_TEXT_STYLE);
599
600         encrypt_msg1 = dpm_encryption_create_textblock(encryption_layout, IDS_ST_BODY_SD_CARD_ENCRYPTING_MSG_1, text_st);
601         elm_object_part_content_set(encryption_layout, "msg_content_1", encrypt_msg1);
602         encrypt_msg2 = dpm_encryption_create_textblock(encryption_layout, IDS_ST_BODY_SD_CARD_ENCRYPTING_MSG_2, text_st);
603         elm_object_part_content_set(encryption_layout, "msg_content_2", encrypt_msg2);
604         encrypt_msg3 = dpm_encryption_create_textblock(encryption_layout, IDS_ST_BODY_SD_CARD_ENCRYPTING_MSG_3, text_st);
605         elm_object_part_content_set(encryption_layout, "msg_content_3", encrypt_msg3);
606         encrypt_msg4 = dpm_encryption_create_textblock(encryption_layout, IDS_ST_BODY_TO_ENCRYPT_YOUR_SD_CARD_C, text_st);
607         elm_object_part_content_set(encryption_layout, "msg_content_4", encrypt_msg4);
608
609         set_next_btn_layout(base_layout, ad, IDS_ST_BUTTON_NEXT);
610
611         /* get sdcard info */
612         ret = sdcard_status_update(ad);
613         if (ret != 0) {
614                 dlog_print(DLOG_ERROR, LOG_TAG, "sdcard_status_update failed");
615                 return;
616         }
617
618         /* register vconf notify callback : sdcard status */
619         ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, sdcard_status_changed_cb, ad);
620         if (ret != 0) {
621                 dlog_print(DLOG_ERROR, LOG_TAG, "runtime_info_set_changed_cb failed: %d", ret);
622                 return;
623         }
624
625         /* set layout text */
626         sdcard_txt = dpm_encryption_create_textblock(encryption_layout, IDS_ST_BODY_INSERT_THE_SD_CARD_ABB, text_st);
627         elm_object_part_content_set(encryption_layout, "sd_card_text", sdcard_txt);
628         /*password_txt = dpm_encryption_create_textblock(encryption_layout, IDS_ST_BODY_CREATE_AN_SD_CARD_PASSWORD, text_st);
629            elm_object_part_content_set(encryption_layout, "charge_text", password_txt); */
630
631         evas_textblock_style_free(text_st);
632
633         set_sdcard_pw_btn_layout(encryption_layout, ad);
634
635         /* to do : set password button */
636
637         elm_object_part_content_set(base_layout, "content_layout", encryption_layout);
638
639         sw_back_btn_set(navi_bar, IDS_ST_HEADER_ENCRYPT_SD_CARD, base_layout);
640 }
641
642 void dpm_decryption_sd_card_create_view(appdata_s* ad)
643 {
644         Evas_Object* navi_bar = ad->navi_bar;
645         Evas_Object* base_layout = NULL;
646         Evas_Object* decrypt_msg = NULL;
647         Evas_Object* decryption_layout = NULL;
648         Evas_Textblock_Style* text_st;
649
650         dlog_print(DLOG_DEBUG, LOG_TAG, "start dpm_decryption_sd_card_create_view");
651
652         if (navi_bar == NULL) {
653                 dlog_print(DLOG_ERROR, LOG_TAG, "navi_bar is null");
654                 return;
655         }
656
657         base_layout = dpm_encryption_create_layout(navi_bar, ad->edj_path, "base_layout");
658         decryption_layout = dpm_encryption_create_layout(base_layout, ad->edj_path, "Decrypt_sd_card_layout");
659         ad->dpm_encryption_layout = decryption_layout;
660
661         text_st = evas_textblock_style_new();
662         evas_textblock_style_set(text_st, MSG_TEXT_STYLE);
663
664         decrypt_msg = dpm_encryption_create_textblock(decryption_layout, IDS_ST_BODY_SD_CARD_DECRYPTION_MSG, text_st);
665         elm_object_part_content_set(decryption_layout, "msg_content", decrypt_msg);
666
667         evas_textblock_style_free(text_st);
668
669         /* to do : set change password button */
670
671         elm_object_part_content_set(base_layout, "content_layout", decryption_layout);
672
673         set_next_btn_layout(base_layout, ad, IDS_ST_BUTTON_NEXT);
674         sw_back_btn_set(navi_bar, IDS_ST_HEADER_ENCRYPT_SD_CARD, base_layout);
675 }