3 * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
24 #define EDJ_PATH "/usr/apps/" PACKAGE "/res/" PACKAGE ".edj"
25 #define IMAGE_PATH "/usr/apps/" PACKAGE "/res/images/"
27 static Evas_Object *win, *conform, *layout, *progress_layout;
28 static char key[PATH_MAX] = "";
31 static void set_progress_percentage(int value)
33 Evas_Object *text_block = NULL;
34 char percentage[PATH_MAX] = "";
36 snprintf(percentage, sizeof(percentage), "%d%%", value);
37 text_block = _create_textblock(progress_layout, percentage, SUB_CONTENT_STYLE_W);
38 elm_object_part_content_set(progress_layout, "progress_percentage", text_block);
42 static Eina_Bool progressbar_timer_cb(void *data)
44 Evas_Object *progressbar = (Evas_Object *)data;
45 char *progress = NULL;
50 return ECORE_CALLBACK_DONE;
53 progress = vconf_get_str(key);
55 percentage = atoi(progress);
57 elm_progressbar_value_set(progressbar, (double)(percentage / 100.0));
58 set_progress_percentage(percentage);
60 if (percentage == 100) {
62 return ECORE_CALLBACK_PASS_ON;
65 return ECORE_CALLBACK_PASS_ON;
68 void create_base_window()
70 /* Create main UI widget */
71 win = _create_win(PACKAGE);
72 conform = _create_conformant(win);
73 layout = _create_layout(conform, NULL, NULL);
74 elm_object_content_set(conform, layout);
76 evas_object_show(win);
80 static void set_internal_progress_layout(int state)
82 Evas_Object *text_block = NULL, *image = NULL;
83 char string[PATH_MAX] = "";
84 char image_path[PATH_MAX] = "";
85 char *internal_text[2][3] = {
87 "IDS_ST_NPBODY_ENCRYPTING_DEVICE_ING",
88 "IDS_ST_BODY_PLEASE_WAIT",
89 "IDS_ST_BODY_ONCE_THE_DEVICE_IS_ENCRYPTED_IT_WILL_RESTART"
92 "IDS_ST_BODY_DECRYPTING_DEVICE_ING",
94 "IDS_ST_BODY_PLEASE_WAIT_NONCE_THE_DEVICE_IS_DECRYPTED_IT_WILL_RESTART"
97 char *icon_path[2] = {
99 "icon_security_off.png"
103 text = internal_text[state];
104 snprintf(image_path, sizeof(image_path), IMAGE_PATH"%s", icon_path[state]);
106 image = elm_image_add(progress_layout);
107 elm_image_file_set(image, image_path, NULL);
108 elm_image_resizable_set(image, EINA_TRUE, EINA_TRUE);
109 elm_object_part_content_set(progress_layout, "icon", image);
111 snprintf(string, sizeof(string), "%s", __(text[0]));
112 text_block = _create_textblock(progress_layout, string, SUB_TITLE_STYLE_W);
113 elm_object_part_content_set(progress_layout, "message_title", text_block);
115 set_progress_percentage(0);
117 if (strcmp(text[1], ""))
118 snprintf(string, sizeof(string), "%s<br>%s", __(text[1]), __(text[2]));
120 snprintf(string, sizeof(string), "%s", __(text[2]));
121 text_block = _create_textblock(progress_layout, string, SUB_CONTENT_STYLE_W);
122 elm_object_part_content_set(progress_layout, "message_content", text_block);
125 static void set_external_progress_layout(int state)
127 Evas_Object *text_block = NULL, *image = NULL;
128 char string[PATH_MAX] = "";
129 char image_path[PATH_MAX] = "";
130 char *external_text[2][4] = {
132 "IDS_ST_BODY_ENCRYPTING_SD_CARD_ING",
133 "IDS_ST_BODY_PLEASE_WAIT",
134 "IDS_ST_BODY_ENCRYPT_ALL_NEW_FILES_SAVED_ON_THIS_SD_CARD_EXISTING_FILES_WILL_NOT_BE_ENCRYPTED",
135 "IDS_ST_BODY_THE_SD_CARD_CANT_BE_USED_UNTIL_IT_HAS_BEEN_ENCRYPTED"
138 "IDS_ST_BODY_DECRYPTING_SD_CARD_ING",
139 "IDS_ST_BODY_PLEASE_WAIT",
141 "IDS_ST_BODY_THE_SD_CARD_CANT_BE_USED_UNTIL_IT_HAS_BEEN_DECRYPTED"
144 char *icon_path[2] = {
145 "icon_security_sdcard.png",
146 "icon_security_off_sdcard.png"
150 text = external_text[state];
151 snprintf(image_path, sizeof(image_path), IMAGE_PATH"%s", icon_path[state]);
153 image = elm_image_add(progress_layout);
154 elm_image_file_set(image, image_path, NULL);
155 elm_image_resizable_set(image, EINA_TRUE, EINA_TRUE);
156 elm_object_part_content_set(progress_layout, "icon", image);
158 snprintf(string, sizeof(string), "%s", __(text[0]));
159 text_block = _create_textblock(progress_layout, string, SUB_TITLE_STYLE_W);
160 elm_object_part_content_set(progress_layout, "message_title", text_block);
162 set_progress_percentage(0);
164 snprintf(string, sizeof(string), "%s<br>%s", __(text[1]), __(text[2]));
165 text_block = _create_textblock(progress_layout, string, SUB_CONTENT_STYLE_W);
166 elm_object_part_content_set(progress_layout, "message_content", text_block);
168 snprintf(string, sizeof(string), "%s", __(text[3]));
169 text_block = _create_textblock(progress_layout, string, SUB_CONTENT_STYLE_W);
170 elm_object_part_content_set(progress_layout, "message_bottom", text_block);
173 void create_progress_view(const char *type, const char *target)
175 Evas_Object *progressbar = NULL;
180 if (!strcmp(type, "Encrypting")) {
186 progress_layout = _create_layout(layout, EDJ_PATH, "progress_layout");
188 if (!strcmp(target, "Internal")) {
189 snprintf(key, PATH_MAX, "%s", VCONFKEY_ODE_ENCRYPT_PROGRESS);
190 set_internal_progress_layout(state);
191 } else if (!strcmp(target, "External")) {
192 snprintf(key, PATH_MAX, "%s", VCONFKEY_SDE_ENCRYPT_PROGRESS);
193 set_external_progress_layout(state);
196 progressbar = _create_progressbar(progress_layout, "default");
197 elm_object_part_content_set(progress_layout, "progress_indicator", progressbar);
199 elm_object_part_content_set(layout, "elm.swallow.content", progress_layout);
201 elm_progressbar_value_set(progressbar, 0.0);
202 ecore_timer_add(1, progressbar_timer_cb, progressbar);