From: s414kim Date: Thu, 12 Oct 2017 06:50:21 +0000 (+0900) Subject: Add insert extended encrypted sdcard interface. X-Git-Tag: submit/tizen_4.0/20171018.042033^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F41%2F155141%2F2;p=platform%2Fcore%2Fsecurity%2Fode-ui.git Add insert extended encrypted sdcard interface. Change-Id: I61919365094b999003b50a2ad474d0f1677af632 Signed-off-by: s414kim --- diff --git a/ode/CMakeLists.txt b/ode/CMakeLists.txt index 1d5d60e..3aaa583 100755 --- a/ode/CMakeLists.txt +++ b/ode/CMakeLists.txt @@ -26,6 +26,7 @@ SET(PKG_SRC ./src/main.cpp ./src/interface/external/decrypt-sdcard.cpp ./src/interface/external/insert-sdcard.cpp ./src/interface/external/password-sdcard.cpp + ./src/interface/external/password-sdcard-extended.cpp ./src/interface/external/encrypt-extension.cpp ./src/interface/external/retry-sdcard.cpp) diff --git a/ode/src/interface/external/insert-sdcard.cpp b/ode/src/interface/external/insert-sdcard.cpp index 283a361..9e36d61 100644 --- a/ode/src/interface/external/insert-sdcard.cpp +++ b/ode/src/interface/external/insert-sdcard.cpp @@ -18,10 +18,12 @@ #include "insert-sdcard.h" -InsertSDCardInterface::InsertSDCardInterface() - : popup(nullptr), appControl("org.tizen.ode"), notification(NOTIFICATION_TYPE_NOTI) +InsertSDCardInterface::InsertSDCardInterface(AppControl *appData) + : popup(nullptr), appControl("org.tizen.ode"), interface(nullptr), notification(NOTIFICATION_TYPE_NOTI), device(""), node("") { window->setConfig(Window::Config::SetAlpha); + device = appData->getData("dev_path"); + node = appData->getData("mapping_node"); } InsertSDCardInterface::~InsertSDCardInterface() @@ -32,7 +34,13 @@ InsertSDCardInterface::~InsertSDCardInterface() void InsertSDCardInterface::createPasswordSDCard() { - passwordSDCard.create(); + if (device.compare("")) { + interface.reset(new PasswordSDCardExtended{device, node}); + interface->create(); + } else { + interface.reset(new PasswordSDCard{}); + interface->create(); + } } void InsertSDCardInterface::create() @@ -57,7 +65,14 @@ void InsertSDCardInterface::create() popup->show(); /* SD Card Encrypted Notification */ - appControl.setData("viewtype", "SD_CARD_PASSWORD"); + if (device.compare("")) { + appControl.setData("viewtype", "SD_CARD_EXTENDED_PASSWORD"); + appControl.setData("dev_path", device); + appControl.setData("mapping_node", node); + } else { + appControl.setData("viewtype", "SD_CARD_PASSWORD"); + } + notification.setTitle(dgetText("IDS_ST_MBODY_SD_CARD_ENCRYPTED")); notification.setContentText(dgetText("IDS_ST_SBODY_TAP_HERE_TO_ENTER_PW_FOR_SD_CARD_ABB")); notification.setAppControl(appControl); diff --git a/ode/src/interface/external/insert-sdcard.h b/ode/src/interface/external/insert-sdcard.h index 608dd04..ed8f629 100644 --- a/ode/src/interface/external/insert-sdcard.h +++ b/ode/src/interface/external/insert-sdcard.h @@ -20,6 +20,7 @@ #define __ODE_INSERT_SD_CARD_H__ #include "password-sdcard.h" +#include "password-sdcard-extended.h" #include "../interface.h" #include "../../widgets/popup.h" #include "../../widgets/appcontrol.h" @@ -27,7 +28,7 @@ class InsertSDCardInterface : public ODEInterface { public: - InsertSDCardInterface(); + InsertSDCardInterface(AppControl *appData); ~InsertSDCardInterface(); void create(); @@ -37,8 +38,10 @@ public: private: Popup *popup; AppControl appControl; - PasswordSDCard passwordSDCard; + std::unique_ptr interface; Notification notification; + std::string device; + std::string node; }; #endif diff --git a/ode/src/interface/external/password-sdcard-extended.cpp b/ode/src/interface/external/password-sdcard-extended.cpp new file mode 100644 index 0000000..a23628e --- /dev/null +++ b/ode/src/interface/external/password-sdcard-extended.cpp @@ -0,0 +1,52 @@ +/* + * + * 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 "password-sdcard-extended.h" + +PasswordSDCardExtended::PasswordSDCardExtended(const std::string &device, const std::string &node) + : baseLayout(new Layout(window)), + passwordConfirm(baseLayout, PasswordInterface::Mode::EXTENSION), + devicePath(device), + mappingNode(node) +{ + window->setContent(baseLayout); + window->setConfig(Window::Config::SetAlpha); +} + +PasswordSDCardExtended::~PasswordSDCardExtended() +{ + if (baseLayout) + delete baseLayout; +} + +void PasswordSDCardExtended::create() +{ + passwordConfirm.onResult.connect(this, &PasswordSDCardExtended::onResultCallback); + passwordConfirm.show(); +} + +void PasswordSDCardExtended::dispose() +{ + ::ui_app_exit(); +} + +void PasswordSDCardExtended::onResultCallback(int result, const std::string &data) +{ + if (result == 1) + encryption.mount(devicePath, data, mappingNode); + dispose(); +} diff --git a/ode/src/interface/external/password-sdcard-extended.h b/ode/src/interface/external/password-sdcard-extended.h new file mode 100644 index 0000000..e374c4c --- /dev/null +++ b/ode/src/interface/external/password-sdcard-extended.h @@ -0,0 +1,44 @@ +/* + * + * 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_PASSWORD_SDCARD_EXTENDED_H__ +#define __ODE_PASSWORD_SDCARD_EXTENDED_H__ + +#include "../interface.h" +#include "../tools/encryption.h" +#include "../external-locktype/password.h" +#include "../../language.h" +#include "../../widgets/appcontrol.h" + +class PasswordSDCardExtended : public ODEInterface { +public: + PasswordSDCardExtended(const std::string &device, const std::string &node); + ~PasswordSDCardExtended(); + + void create(); + void dispose(); + void onResultCallback(int result, const std::string &data); +private: + Layout *baseLayout; + PasswordConfirm passwordConfirm; + ExtensionEncryption encryption; + std::string devicePath; + std::string mappingNode; +}; + +#endif diff --git a/ode/src/interface/external/password-sdcard.cpp b/ode/src/interface/external/password-sdcard.cpp index 0047d00..6ab1e6b 100644 --- a/ode/src/interface/external/password-sdcard.cpp +++ b/ode/src/interface/external/password-sdcard.cpp @@ -19,7 +19,7 @@ PasswordSDCard::PasswordSDCard() : baseLayout(new Layout(window)), - passwordConfirm(baseLayout, PasswordInterface::Mode::EXTENSION), + passwordConfirm(baseLayout, PasswordInterface::Mode::EXTERNAL), notification(NOTIFICATION_TYPE_NOTI), progress(nullptr) { diff --git a/ode/src/ode.cpp b/ode/src/ode.cpp index 7e8c4d6..449fddf 100644 --- a/ode/src/ode.cpp +++ b/ode/src/ode.cpp @@ -42,6 +42,8 @@ int ODELaunchPad::getMode(const std::string &type) return Type::SD_CARD_PASSWORD; } else if (!type.compare("ENCRYPT_EXTENSION")) { return Type::ENCRYPT_EXTENSION; + } else if (!type.compare("SD_CARD_EXTENDED_PASSWORD")) { + return Type::SD_CARD_EXTENDED_PASSWORD; } return Type::DO_NOT_SUPPORTED; @@ -66,7 +68,7 @@ void ODELaunchPad::onAppControl() interface = new DecryptSDCardInterface{}; break; case Type::INSERT_SD_CARD: - interface = new InsertSDCardInterface{}; + interface = new InsertSDCardInterface{appControl.get()}; break; case Type::SD_CARD_PASSWORD: interface = new PasswordSDCard{}; @@ -74,6 +76,9 @@ void ODELaunchPad::onAppControl() case Type::ENCRYPT_EXTENSION: interface = new EncryptExtensionInterface{appControl.get()}; break; + case Type::SD_CARD_EXTENDED_PASSWORD: + interface = new PasswordSDCardExtended{appControl->getData("dev_path"), appControl->getData("mapping_node")}; + break; default: throw runtime::Exception("Do not supported viewtype"); break; diff --git a/ode/src/ode.h b/ode/src/ode.h index e79ca4f..734604e 100644 --- a/ode/src/ode.h +++ b/ode/src/ode.h @@ -42,6 +42,7 @@ public: DECRYPT_SD_CARD, INSERT_SD_CARD, SD_CARD_PASSWORD, + SD_CARD_EXTENDED_PASSWORD, ENCRYPT_EXTENSION, DO_NOT_SUPPORTED, };