Add insert extended encrypted sdcard interface. 41/155141/2 accepted/tizen/4.0/unified/20171018.231432 submit/tizen_4.0/20171018.042033
authors414kim <s414.kim@samsung.com>
Thu, 12 Oct 2017 06:50:21 +0000 (15:50 +0900)
committers414kim <s414.kim@samsung.com>
Fri, 13 Oct 2017 09:26:38 +0000 (18:26 +0900)
Change-Id: I61919365094b999003b50a2ad474d0f1677af632
Signed-off-by: s414kim <s414.kim@samsung.com>
ode/CMakeLists.txt
ode/src/interface/external/insert-sdcard.cpp
ode/src/interface/external/insert-sdcard.h
ode/src/interface/external/password-sdcard-extended.cpp [new file with mode: 0644]
ode/src/interface/external/password-sdcard-extended.h [new file with mode: 0644]
ode/src/interface/external/password-sdcard.cpp
ode/src/ode.cpp
ode/src/ode.h

index 1d5d60e10bd4bcf83a3d32a97c67ef6d7febbdca..3aaa5839ce21af9e21006bf921e78b3a7f646a22 100755 (executable)
@@ -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)
 
index 283a36186b1658817b3b67603461c3cfd444f0e9..9e36d611965fbed0d4457023f891b47d78e4e311 100644 (file)
 
 #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);
index 608dd046d244f4d4db28fe7e1b958e08fa25b145..ed8f629f144fcaa3ee8626963eb59783ea1932c9 100644 (file)
@@ -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<ODEInterface> 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 (file)
index 0000000..a23628e
--- /dev/null
@@ -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 (file)
index 0000000..e374c4c
--- /dev/null
@@ -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
index 0047d00e9aaec69d36a8979bcba2c2e12ee7068c..6ab1e6b807c224ef512576fd82dfcbb4e51abf5d 100644 (file)
@@ -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)
 {
index 7e8c4d6fb67b68a44c4d19837c54cd2a68f2cc61..449fddffebaa5ecd270fa638c6276a264470bbe7 100644 (file)
@@ -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;
index e79ca4fecd2d9a3ef7992b4a40871d90d0bf695d..734604ec516653cc4d9136b5409faf5f60321c88 100644 (file)
@@ -42,6 +42,7 @@ public:
                DECRYPT_SD_CARD,
                INSERT_SD_CARD,
                SD_CARD_PASSWORD,
+               SD_CARD_EXTENDED_PASSWORD,
                ENCRYPT_EXTENSION,
                DO_NOT_SUPPORTED,
        };