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.
19 #include <ode/external-encryption.h>
20 #include <ode/internal-encryption.h>
21 #include "ode-password.h"
23 static popup_data_s popup_data = {0,};
25 void on_create_password_popup(Evas_Object *parent)
27 popup_data.parent = parent;
28 popup_data.mode = CREATE_PASSWORD;
29 create_password_message_popup(&popup_data);
33 void on_change_password_popup(Evas_Object *parent)
35 popup_data.parent = parent;
36 popup_data.mode = CHANGE_PASSWORD;
37 create_confirm_password_popup(&popup_data);
41 void on_delete_password_popup(Evas_Object *parent)
43 popup_data.parent = parent;
44 popup_data.mode = DELETE_PASSWORD;
45 create_password_message_popup(&popup_data);
49 void on_insert_sdcard_popup(Evas_Object *parent)
51 popup_data.parent = parent;
52 popup_data.mode = INSERT_SD_CARD;
53 popup_data.callback = NULL;
54 create_insert_sdcard_popup(&popup_data);
58 void password_popup_set_result_callback(void (*callback)(void *), void *user_data)
60 popup_data.callback = callback;
61 popup_data.callback_data = user_data;
64 void password_result_callback(popup_data_s *data, const char *result)
69 if (!strcmp(result, "fail")) {
73 if (data->callback_data)
74 ad = (appdata_s *)data->callback_data;
78 ret = ode_external_encryption_init_password(data->entry_data);
79 if (ret != ODE_ERROR_NONE) {
80 dlog_print(DLOG_ERROR, LOG_TAG, "failed to create external data");
83 ad->entry_data = data->entry_data;
84 ad->device_info.sdcard_pw_status = 1;
87 ret = ode_external_encryption_change_password(data->entry_data_old, data->entry_data);
88 if (ret != ODE_ERROR_NONE) {
89 dlog_print(DLOG_ERROR, LOG_TAG, "failed to change external data");
92 ad->entry_data = data->entry_data;
93 ad->device_info.sdcard_pw_status = 1;
96 ret = ode_external_encryption_clean_password(data->entry_data);
97 if (ret != ODE_ERROR_NONE) {
98 dlog_print(DLOG_ERROR, LOG_TAG, "failed to delete external data");
101 ad->entry_data = NULL;
102 ad->device_info.sdcard_pw_status = 0;
105 ret = ode_external_encryption_mount(data->entry_data);
106 if (ret != ODE_ERROR_NONE) {
107 dlog_print(DLOG_ERROR, LOG_TAG, "failed to mount external storage");
111 /* for temporary start */
112 case INTERNAL_ENCRYPT_PASSWORD:
113 ret = ode_internal_encryption_init_password(data->entry_data);
114 if (ret != ODE_ERROR_NONE) {
115 dlog_print(DLOG_ERROR, LOG_TAG, "failed to create internal data");
118 ret = ode_internal_encryption_encrypt(data->entry_data, ad->device_info.device_option);
120 dlog_print(DLOG_DEBUG, LOG_TAG, "failed to encrypt internal storage");
124 case INTERNAL_DECRYPT_PASSWORD:
125 ret = ode_internal_encryption_decrypt(data->entry_data);
127 dlog_print(DLOG_DEBUG, LOG_TAG, "failed to decrypt internal storage");
131 /* for temporary end */
137 data->callback(data->callback_data);