From: s414kim Date: Sat, 8 Jul 2017 12:36:19 +0000 (+0900) Subject: Add external retry interface X-Git-Tag: submit/tizen/20170730.224646~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4d127f117bb6bf6f9ca7a522ad9af01db144191d;p=platform%2Fcore%2Fsecurity%2Fode.git Add external retry interface Change-Id: Ie7a575d8c023e75d3b7a71c3c4e0aac229cf32e6 Signed-off-by: s414kim --- diff --git a/tools/apps/ode/CMakeLists.txt b/tools/apps/ode/CMakeLists.txt index f66a600..942a9cf 100755 --- a/tools/apps/ode/CMakeLists.txt +++ b/tools/apps/ode/CMakeLists.txt @@ -51,7 +51,8 @@ SET(REWORK_SRC ./rework/interface/external/encrypt-sdcard.cpp ./rework/interface/external/decrypt-sdcard.cpp ./rework/interface/external/insert-sdcard.cpp - ./rework/interface/external/password-sdcard.cpp) + ./rework/interface/external/password-sdcard.cpp + ./rework/interface/external/retry-sdcard.cpp) SET(EXTERNAL_LOCKTYPE_SRC ./rework/interface/external-locktype/password.cpp diff --git a/tools/apps/ode/rework/interface/external/password-sdcard.cpp b/tools/apps/ode/rework/interface/external/password-sdcard.cpp index 4b6b31a..77a262e 100644 --- a/tools/apps/ode/rework/interface/external/password-sdcard.cpp +++ b/tools/apps/ode/rework/interface/external/password-sdcard.cpp @@ -45,7 +45,27 @@ void PasswordSDCard::dispose() void PasswordSDCard::retryCrypto(const std::string &data) { - /* TBD : Retry Encrypt/Decrypt */ + Vconf cryptoType(VCONFKEY_SDE_CRYPTO_TYPE); + Vconf cryptoState(VCONFKEY_SDE_CRYPTO_STATE); + + std::string type(cryptoType.getString()); + passwordConfirm.dispose(); + + if (!type.compare("encrypt")) { + Vconf option(VCONFKEY_SDE_ENCRYPT_NEWFILE); + cryptoState.setString("unencrypted"); + encryption.encrypt(data, option.getBool()); + progress.reset(new ExternalEncryptProgress(window)); + } else if (!type.compare("decrypt")) { + cryptoState.setString("encrypted"); + encryption.decrypt(data); + progress.reset(new ExternalDecryptProgress(window)); + } + + if (progress) { + setFullContent(progress.get()); + progress->start(); + } } void PasswordSDCard::onResultCallback(int result, const std::string &data) diff --git a/tools/apps/ode/rework/interface/external/retry-sdcard.cpp b/tools/apps/ode/rework/interface/external/retry-sdcard.cpp new file mode 100644 index 0000000..dfab39f --- /dev/null +++ b/tools/apps/ode/rework/interface/external/retry-sdcard.cpp @@ -0,0 +1,190 @@ +/* + * + * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "retry-sdcard.h" + +RetryPopup::RetryPopup(Widget *parent) + : MobileDefaultPopup(parent), + appControl("org.tizen.ode") +{ +} + +RetryPopup::~RetryPopup() +{ +} + +void RetryPopup::setPartContent(const std::string &title, const std::string &content) +{ + setTitleText(dgetText(title)); + setContentText(dgetText(content)); + setButton(dgetText("IDS_ST_BUTTON_CANCEL"), + [this](void *) { + dispose(); + }, + dgetText("IDS_ST_BUTTON_RETRY"), + [this](void *) { + onRetry.emit(); + }); +} + +ExternalRetryEncrypt::ExternalRetryEncrypt(Widget *parent) + : RetryPopup(parent) +{ + setPartContent("IDS_ST_HEADER_FAILED_TO_ENCRYPT_SD_CARD", "IDS_ST_POP_AN_ERROR_HAS_OCCURRED_TO_USE_THE_SD_CARD_THE_ENCRYPTION_PROCESS_MUST_BE_COMPLETED_TAP_RETRY_TO_TRY_AGAIN"); + onRetry.connect(this, &ExternalRetryEncrypt::retry); +} + +ExternalRetryEncrypt::~ExternalRetryEncrypt() +{ +} + +void ExternalRetryEncrypt::retry() +{ + dispose(); + notification.dispose(); + appControl.setData("viewtype", "SD_CARD_PASSWORD"); + appControl.launch(); +} + +void ExternalRetryEncrypt::createNotification() +{ + appControl.setData("viewtype", "SD_CARD_PASSWORD"); + notification.setTitle(dgetText("IDS_ST_MBODY_SD_CARD_ENCRYPTION_ERROR")); + notification.setContent(dgetText("IDS_ST_SBODY_TAP_HERE_TO_TRY_AGAIN")); + notification.setAppControl(appControl); + notification.post(); +} + +ExternalRetryEncryptStorageFull::ExternalRetryEncryptStorageFull(Widget *parent) + : RetryPopup(parent) +{ + std::string text; + Vconf storageSize(VCONFKEY_ENCRYPT_NEEDED_SIZE); + int size = storageSize.getInt(); + + text.append(dgetText("IDS_ST_POP_YOUR_SD_CARD_DOESNT_HAVE_ENOUGH_SPACE")); + text.append(formatString("IDS_ST_POP_APPROXIMATELY_P1SS_P2SS_IS_NEEDED", (double)size)); + text.append(dgetText("IDS_ST_POP_GO_TO_SETTINGS_STORAGE_AND_RAM_STORAGE_DETAILS_THEN_DELETE_SOME_FILES_AND_TRY_AGAIN")); + setPartContent("IDS_ST_HEADER_FAILED_TO_ENCRYPT_SD_CARD", text); + onRetry.connect(this, &ExternalRetryEncryptStorageFull::retry); +} + +ExternalRetryEncryptStorageFull::~ExternalRetryEncryptStorageFull() +{ +} + +void ExternalRetryEncryptStorageFull::retry() +{ + /* TBD */ +} + +void ExternalRetryEncryptStorageFull::createNotification() +{ + appControl.setData("viewtype", "ENCRYPT_SD_CARD"); + notification.setTitle(dgetText("IDS_ST_MBODY_SD_CARD_ENCRYPTION_ERROR")); + notification.setContent(dgetText("IDS_ST_SBODY_DELETE_SOME_FILES_THEN_TRY_AGAIN")); + notification.setAppControl(appControl); + notification.post(); +} + +ExternalRetryDecrypt::ExternalRetryDecrypt(Widget *parent) + : RetryPopup(parent) +{ + setPartContent("IDS_ST_HEADER_FAILED_TO_DECRYPT_SD_CARD", "IDS_ST_POP_AN_ERROR_HAS_OCCURRED_TO_USE_THE_SD_CARD_THE_DECRYPTION_PROCESS_MUST_BE_COMPLETED_TAP_RETRY_TO_TRY_AGAIN"); + onRetry.connect(this, &ExternalRetryDecrypt::retry); +} + +ExternalRetryDecrypt::~ExternalRetryDecrypt() +{ +} + +void ExternalRetryDecrypt::retry() +{ + dispose(); + notification.dispose(); + appControl.setData("veiwtype", "SD_CARD_PASSWORD"); + appControl.launch(); +} + +void ExternalRetryDecrypt::createNotification() +{ + appControl.setData("viewtype", "SD_CARD_PASSWORD"); + notification.setTitle(dgetText("IDS_ST_MBODY_SD_CARD_DECRYPTION_ERROR")); + notification.setContent(dgetText("IDS_ST_SBODY_TAP_HERE_TO_TRY_AGAIN")); + notification.setAppControl(appControl); + notification.post(); +} + +ExternalRetryDecryptStorageFull::ExternalRetryDecryptStorageFull(Widget *parent) + : RetryPopup(parent) +{ + std::string text; + Vconf storageSize(VCONFKEY_ENCRYPT_NEEDED_SIZE); + int size = storageSize.getInt(); + + text.append(dgetText("IDS_ST_POP_YOUR_SD_CARD_DOESNT_HAVE_ENOUGH_SPACE")); + text.append(formatString("IDS_ST_POP_APPROXIMATELY_P1SS_P2SS_IS_NEEDED", (double)size)); + text.append(dgetText("IDS_ST_POP_GO_TO_SETTINGS_STORAGE_AND_RAM_STORAGE_DETAILS_THEN_DELETE_SOME_FILES_AND_TRY_AGAIN")); + setPartContent("IDS_ST_HEADER_FAILED_TO_DECRYPT_SD_CARD", text); + onRetry.connect(this, &ExternalRetryDecryptStorageFull::retry); +} + +ExternalRetryDecryptStorageFull::~ExternalRetryDecryptStorageFull() +{ +} + +void ExternalRetryDecryptStorageFull::retry() +{ + /* [TBD] retry decryption here */ +} + +void ExternalRetryDecryptStorageFull::createNotification() +{ + appControl.setData("viewtype", "DECRYPT_SD_CARD"); + notification.setTitle(dgetText("IDS_ST_MBODY_SD_CARD_DECRYPTION_ERROR")); + notification.setContent(dgetText("IDS_ST_SBODY_DELETE_SOME_FILES_THEN_TRY_AGAIN")); + notification.setAppControl(appControl); + notification.post(); +} + +ExternalRetry::ExternalRetry() + : popup(nullptr), vconf(VCONFKEY_SDE_CRYPTO_TYPE) +{ + window->setConfig(Window::Config::SetAlpha); +} + +ExternalRetry::~ExternalRetry() +{ +} + +void ExternalRetry::create() +{ + std::string type(vconf.getString()); + if (!type.compare("encrypt")) { + popup.reset(new ExternalRetryEncrypt(window)); + } else if(!type.compare("decrypt")) { + popup.reset(new ExternalRetryDecrypt(window)); + } + popup->show(); + popup->createNotification(); +} + +void ExternalRetry::dispose() +{ + ::ui_app_exit(); +} diff --git a/tools/apps/ode/rework/interface/external/retry-sdcard.h b/tools/apps/ode/rework/interface/external/retry-sdcard.h new file mode 100644 index 0000000..e94a5e9 --- /dev/null +++ b/tools/apps/ode/rework/interface/external/retry-sdcard.h @@ -0,0 +1,92 @@ +/* + * + * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __ODE_EXTERNAL_RETRY_POPUP_H__ +#define __ODE_EXTERNAL_RETRY_POPUP_H__ + +#include "../interface.h" +#include "../tools/vconf.h" +#include "../../widgets/popup.h" +#include "../../widgets/notification.h" +#include "../../widgets/appcontrol.h" +#include "../../widgets/signal.h" +#include "../../language.h" + +class RetryPopup : public MobileDefaultPopup { +public: + RetryPopup(Widget *parent); + virtual ~RetryPopup(); + + virtual void setPartContent(const std::string &title, const std::string &content); + virtual void createNotification() = 0; + virtual void retry() = 0; + + Signal<> onRetry; + AppControl appControl; + Notification notification; +}; + +class ExternalRetryEncrypt : public RetryPopup { +public: + ExternalRetryEncrypt(Widget *parent); + ~ExternalRetryEncrypt(); + + void createNotification(); + void retry(); +}; + +class ExternalRetryEncryptStorageFull : public RetryPopup { +public: + ExternalRetryEncryptStorageFull(Widget *parent); + ~ExternalRetryEncryptStorageFull(); + + void createNotification(); + void retry(); +}; + +class ExternalRetryDecrypt : public RetryPopup { +public: + ExternalRetryDecrypt(Widget *parent); + ~ExternalRetryDecrypt(); + + void createNotification(); + void retry(); +}; + +class ExternalRetryDecryptStorageFull : public RetryPopup { +public: + ExternalRetryDecryptStorageFull(Widget *parent); + ~ExternalRetryDecryptStorageFull(); + + void createNotification(); + void retry(); +}; + +class ExternalRetry : public ODEInterface { +public: + ExternalRetry(); + ~ExternalRetry(); + + void create(); + void dispose(); + +private: + std::unique_ptr popup; + Vconf vconf; +}; +#endif diff --git a/tools/apps/ode/rework/interface/progress.cpp b/tools/apps/ode/rework/interface/progress.cpp index 482d7b3..5e0d116 100644 --- a/tools/apps/ode/rework/interface/progress.cpp +++ b/tools/apps/ode/rework/interface/progress.cpp @@ -60,8 +60,13 @@ bool ProgressPage::setProgress() } ExternalEncryptProgress::ExternalEncryptProgress(Widget *parent) - : ProgressPage(parent, "external,encryption,progress", VCONFKEY_SDE_ENCRYPT_PROGRESS) + : ProgressPage(parent, "external,encryption,progress", VCONFKEY_SDE_ENCRYPT_PROGRESS), + cryptoState(VCONFKEY_SDE_CRYPTO_STATE), + retryPopup(parent) { + Vconf cryptoType(VCONFKEY_SDE_CRYPTO_TYPE); + cryptoType.setString("encrypt"); + std::string text; titleText.reset(new TextBlock(this, titleStyle, dgetText("IDS_ST_BODY_ENCRYPTING_SD_CARD_ING"))); setContent("message_title", titleText.get()); @@ -73,15 +78,33 @@ ExternalEncryptProgress::ExternalEncryptProgress(Widget *parent) text.append(dgetText("IDS_ST_BODY_THE_SD_CARD_CANT_BE_USED_UNTIL_IT_HAS_BEEN_ENCRYPTED")); contentText.reset(new TextBlock(this, contentStyle, text)); setContent("message_content", contentText.get()); + + cryptoState.addChangedCallback(); + cryptoState.onKeyChanged.connect(this, &ExternalEncryptProgress::cryptoStateChangedCallback); } ExternalEncryptProgress::~ExternalEncryptProgress() { + cryptoState.removeChangedCallback(); +} + +void ExternalEncryptProgress::cryptoStateChangedCallback() +{ + std::string state(cryptoState.getString()); + if (!state.compare("error_partially_encrypted")) { + retryPopup.show(); + retryPopup.createNotification(); + } } ExternalDecryptProgress::ExternalDecryptProgress(Widget *parent) - : ProgressPage(parent, "external,decryption,progress", VCONFKEY_SDE_ENCRYPT_PROGRESS) + : ProgressPage(parent, "external,decryption,progress", VCONFKEY_SDE_ENCRYPT_PROGRESS), + cryptoState(VCONFKEY_SDE_CRYPTO_STATE), + retryPopup(parent) { + Vconf cryptoType(VCONFKEY_SDE_CRYPTO_TYPE); + cryptoType.setString("decrypt"); + std::string text; titleText.reset(new TextBlock(this, titleStyle, dgetText("IDS_ST_BODY_DECRYPTING_SD_CARD_ING"))); setContent("message_title", titleText.get()); @@ -91,10 +114,23 @@ ExternalDecryptProgress::ExternalDecryptProgress(Widget *parent) text.append(dgetText("IDS_ST_BODY_THE_SD_CARD_CANT_BE_USED_UNTIL_IT_HAS_BEEN_DECRYPTED")); contentText.reset(new TextBlock(this, contentStyle, text)); setContent("message_content", contentText.get()); + + cryptoState.addChangedCallback(); + cryptoState.onKeyChanged.connect(this, &ExternalDecryptProgress::cryptoStateChangedCallback); } ExternalDecryptProgress::~ExternalDecryptProgress() { + cryptoState.removeChangedCallback(); +} + +void ExternalDecryptProgress::cryptoStateChangedCallback() +{ + std::string state(cryptoState.getString()); + if (!state.compare("error_partially_encrypted")) { + retryPopup.show(); + retryPopup.createNotification(); + } } InternalEncryptProgress::InternalEncryptProgress(Widget *parent) diff --git a/tools/apps/ode/rework/interface/progress.h b/tools/apps/ode/rework/interface/progress.h index 95a32e7..af9b684 100644 --- a/tools/apps/ode/rework/interface/progress.h +++ b/tools/apps/ode/rework/interface/progress.h @@ -21,6 +21,7 @@ #include "interface.h" #include "tools/vconf.h" +#include "external/retry-sdcard.h" #include "../language.h" #include "../widgets/layout.h" #include "../widgets/timer.h" @@ -49,12 +50,22 @@ class ExternalEncryptProgress : public ProgressPage { public: ExternalEncryptProgress(Widget *parent); ~ExternalEncryptProgress(); + + void cryptoStateChangedCallback(); + + Vconf cryptoState; + ExternalRetryEncrypt retryPopup; }; class ExternalDecryptProgress : public ProgressPage { public: ExternalDecryptProgress(Widget *parent); ~ExternalDecryptProgress(); + + void cryptoStateChangedCallback(); + + Vconf cryptoState; + ExternalRetryDecrypt retryPopup; }; class InternalEncryptProgress : public ProgressPage {