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.
25 #define EDJ_PATH "/usr/apps/" PACKAGE "/res/" PACKAGE ".edj"
26 #define IMAGE_PATH "/usr/apps/" PACKAGE "/res/images/HD/"
28 static Evas_Object *win, *conform, *layout, *progress_layout;
29 static char key[PATH_MAX] = "";
32 static void set_progress_percentage(int value)
34 Evas_Object *text_block = NULL;
35 char percentage[PATH_MAX] = "";
37 snprintf(percentage, sizeof(percentage), "%d%%", value);
38 text_block = _create_textblock(progress_layout, percentage, SUB_CONTENT_STYLE_W);
39 elm_object_part_content_set(progress_layout, "progress_percentage", text_block);
43 static Eina_Bool progressbar_timer_cb(void *data)
45 Evas_Object *progressbar = (Evas_Object *)data;
46 char *progress = NULL;
51 return ECORE_CALLBACK_DONE;
54 progress = vconf_get_str(key);
56 percentage = atoi(progress);
58 elm_progressbar_value_set(progressbar, (double)(percentage / 100.0));
59 set_progress_percentage(percentage);
61 if (percentage == 100) {
63 return ECORE_CALLBACK_PASS_ON;
66 return ECORE_CALLBACK_PASS_ON;
69 void create_base_window()
71 /* Create main UI widget */
72 win = _create_win(PACKAGE);
73 conform = _create_conformant(win);
74 layout = _create_layout(conform, NULL, NULL);
75 elm_object_content_set(conform, layout);
77 evas_object_show(win);
81 static void set_internal_progress_layout(int state)
83 Evas_Object *text_block = NULL, *image = NULL;
84 char string[PATH_MAX] = "";
85 char image_path[PATH_MAX] = "";
86 char *internal_text[2][3] = {
88 "IDS_ST_NPBODY_ENCRYPTING_DEVICE_ING",
89 "IDS_ST_BODY_PLEASE_WAIT",
90 "IDS_ST_BODY_ONCE_THE_DEVICE_IS_ENCRYPTED_IT_WILL_RESTART"
93 "IDS_ST_BODY_DECRYPTING_DEVICE_ING",
95 "IDS_ST_BODY_PLEASE_WAIT_NONCE_THE_DEVICE_IS_DECRYPTED_IT_WILL_RESTART"
98 char *icon_path[2] = {
100 "icon_security_off.png"
104 text = internal_text[state];
105 snprintf(image_path, sizeof(image_path), IMAGE_PATH"%s", icon_path[state]);
107 image = elm_image_add(progress_layout);
108 elm_image_file_set(image, image_path, NULL);
109 elm_image_resizable_set(image, EINA_TRUE, EINA_TRUE);
110 elm_object_part_content_set(progress_layout, "icon", image);
112 snprintf(string, sizeof(string), "%s", __(text[0]));
113 text_block = _create_textblock(progress_layout, string, SUB_TITLE_STYLE_W);
114 elm_object_part_content_set(progress_layout, "message_title", text_block);
116 set_progress_percentage(0);
118 if (strcmp(text[1], ""))
119 snprintf(string, sizeof(string), "%s<br>%s", __(text[1]), __(text[2]));
121 snprintf(string, sizeof(string), "%s", __(text[2]));
122 text_block = _create_textblock(progress_layout, string, SUB_CONTENT_STYLE_W);
123 elm_object_part_content_set(progress_layout, "message_content", text_block);
126 static void set_external_progress_layout(int state)
128 Evas_Object *text_block = NULL, *image = NULL;
129 char string[PATH_MAX] = "";
130 char image_path[PATH_MAX] = "";
131 char *external_text[2][4] = {
133 "IDS_ST_BODY_ENCRYPTING_SD_CARD_ING",
134 "IDS_ST_BODY_PLEASE_WAIT",
135 "IDS_ST_BODY_ENCRYPT_ALL_NEW_FILES_SAVED_ON_THIS_SD_CARD_EXISTING_FILES_WILL_NOT_BE_ENCRYPTED",
136 "IDS_ST_BODY_THE_SD_CARD_CANT_BE_USED_UNTIL_IT_HAS_BEEN_ENCRYPTED"
139 "IDS_ST_BODY_DECRYPTING_SD_CARD_ING",
140 "IDS_ST_BODY_PLEASE_WAIT",
142 "IDS_ST_BODY_THE_SD_CARD_CANT_BE_USED_UNTIL_IT_HAS_BEEN_DECRYPTED"
145 char *icon_path[2] = {
146 "icon_security_sdcard.png",
147 "icon_security_off_sdcard.png"
151 text = external_text[state];
152 snprintf(image_path, sizeof(image_path), IMAGE_PATH"%s", icon_path[state]);
154 image = elm_image_add(progress_layout);
155 elm_image_file_set(image, image_path, NULL);
156 elm_image_resizable_set(image, EINA_TRUE, EINA_TRUE);
157 elm_object_part_content_set(progress_layout, "icon", image);
159 snprintf(string, sizeof(string), "%s", __(text[0]));
160 text_block = _create_textblock(progress_layout, string, SUB_TITLE_STYLE_W);
161 elm_object_part_content_set(progress_layout, "message_title", text_block);
163 set_progress_percentage(0);
165 snprintf(string, sizeof(string), "%s<br>%s", __(text[1]), __(text[2]));
166 text_block = _create_textblock(progress_layout, string, SUB_CONTENT_STYLE_W);
167 elm_object_part_content_set(progress_layout, "message_content", text_block);
169 snprintf(string, sizeof(string), "%s", __(text[3]));
170 text_block = _create_textblock(progress_layout, string, SUB_CONTENT_STYLE_W);
171 elm_object_part_content_set(progress_layout, "message_bottom", text_block);
174 void create_progress_view(const char *type, const char *target)
176 Evas_Object *progressbar = NULL;
181 if (!strcmp(type, "Encrypting")) {
187 progress_layout = _create_layout(layout, EDJ_PATH, "progress_layout");
189 if (!strcmp(target, "Internal")) {
190 snprintf(key, PATH_MAX, "%s", VCONFKEY_ODE_ENCRYPT_PROGRESS);
191 set_internal_progress_layout(state);
192 } else if (!strcmp(target, "External")) {
193 snprintf(key, PATH_MAX, "%s", VCONFKEY_SDE_ENCRYPT_PROGRESS);
194 set_external_progress_layout(state);
197 progressbar = _create_progressbar(progress_layout, "default");
198 elm_object_part_content_set(progress_layout, "progress_indicator", progressbar);
200 elm_object_part_content_set(layout, "elm.swallow.content", progress_layout);
202 elm_progressbar_value_set(progressbar, 0.0);
203 ecore_timer_add(1, progressbar_timer_cb, progressbar);