Add extension enryption interface 89/152789/6
authors414kim <s414.kim@samsung.com>
Wed, 27 Sep 2017 02:07:29 +0000 (11:07 +0900)
committers414kim <s414.kim@samsung.com>
Fri, 13 Oct 2017 09:16:00 +0000 (18:16 +0900)
 - added 'ENCRYPT_EXTENSION' to create encrypt-extension interface.
 - launch mode is set to 'group' in the org.tizen.ode.xml.
 - added a logic which is to get the 'dev_path' in encrypt-extension.cpp.

Change-Id: Ia35dd54f405c38bded2cca0e78e0d902e18260bd
Signed-off-by: s414kim <s414.kim@samsung.com>
19 files changed:
ode/CMakeLists.txt
ode/org.tizen.ode.xml
ode/src/interface/external-locktype/change.cpp
ode/src/interface/external-locktype/confirm.cpp
ode/src/interface/external-locktype/create.cpp
ode/src/interface/external-locktype/delete.cpp
ode/src/interface/external-locktype/password.cpp
ode/src/interface/external-locktype/password.h
ode/src/interface/external/decrypt-sdcard.cpp
ode/src/interface/external/encrypt-extension.cpp [new file with mode: 0644]
ode/src/interface/external/encrypt-extension.h [new file with mode: 0644]
ode/src/interface/external/encrypt-sdcard.cpp
ode/src/interface/external/password-sdcard.cpp
ode/src/interface/tools/encryption.cpp
ode/src/interface/tools/encryption.h
ode/src/ode.cpp
ode/src/ode.h
ode/src/widgets/appcontrol.cpp
ode/src/widgets/appcontrol.h

index bd99898d502fc25f9cab533ba9ab7fa520c32cda..1d5d60e10bd4bcf83a3d32a97c67ef6d7febbdca 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/encrypt-extension.cpp
                        ./src/interface/external/retry-sdcard.cpp)
 
 SET(EXTERNAL_LOCKTYPE_SRC
index 92689941cb98f63dab5138d816d908028af5dfac..293b2c530ed89beb9c9cd9d6449ce25abad3899a 100644 (file)
@@ -6,7 +6,7 @@
                <privilege>http://tizen.org/privilege/notification</privilege>
                <privilege>http://tizen.org/privilege/display</privilege>
        </privileges>
-       <ui-application appid="org.tizen.ode" exec="/usr/apps/org.tizen.ode/bin/org.tizen.ode" multiple="false" nodisplay="true" taskmanage="true" type="capp">
+       <ui-application appid="org.tizen.ode" exec="/usr/apps/org.tizen.ode/bin/org.tizen.ode" multiple="false" nodisplay="true" taskmanage="true" type="capp" launch_mode="group">
        <label>ODE</label>
        <icon>org.tizen.ode</icon>
        </ui-application>
index 918ad941cc21bf42e68a50efb86f0fb3e4720078..e4aa4ae396f8d0f3d664238d4ca4972b8905ca02 100644 (file)
 
 #include "password.h"
 
-PasswordChange::PasswordChange(Widget *parent)
-       : confirmPassword(parent),
-         createPassword(parent),
+PasswordChange::PasswordChange(Widget *parent, int type)
+       : PasswordInterface(type),
+         confirmPassword(parent, type),
+         createPassword(parent, type),
          prevData("")
 {
        confirmPassword.onResult.connect(this, &PasswordChange::onConfirmed);
@@ -53,6 +54,7 @@ void PasswordChange::onConfirmed(int ret, const std::string &data)
 
 void PasswordChange::onCreated(int ret, const std::string &data)
 {
-       encryption.changePassword(prevData, data);
+       if (encryption != nullptr)
+               encryption->changePassword(prevData, data);
        onResult.emit(ret, data);
 }
index 1a9435efa04f5ea8942d60b37bb04fc192d628b4..3d481312c907c6076335a6385c57fbec305d45e0 100644 (file)
@@ -18,8 +18,9 @@
 
 #include "password.h"
 
-PasswordConfirm::PasswordConfirm(Widget *parent)
-       : confirmPopup(parent, dgetText("IDS_ST_HEADER_USE_ENCRYPTED_SD_CARD"), dgetText("IDS_LCKSCN_NPBODY_ENTER_PASSWORD"), ""),
+PasswordConfirm::PasswordConfirm(Widget *parent, int type)
+       : PasswordInterface(type),
+         confirmPopup(parent, dgetText("IDS_ST_HEADER_USE_ENCRYPTED_SD_CARD"), dgetText("IDS_LCKSCN_NPBODY_ENTER_PASSWORD"), ""),
          resetStoragePopup(parent, dgetText("IDS_ST_HEADER_COULDNT_USE_SD_CARD"), ""),
          vconf(VCONFKEY_SYSMAN_MMC_STATUS),
          attempt(0),
@@ -103,7 +104,11 @@ void PasswordConfirm::setConfirmPopup()
                                                resetStoragePopup.show();
                                                return;
                                        }
-                                       result = encryption.verifyPassword(confirmPopup.getEntryData());
+                                       if (encryption != nullptr)
+                                               result = encryption->verifyPassword(confirmPopup.getEntryData());
+                                       else
+                                               result = 1;
+
                                        if (!result) {
                                                updateContentText();
                                        } else {
@@ -130,7 +135,7 @@ void PasswordConfirm::setResetStoragePopup()
                                        },
                                        dgetText("IDS_ST_BUTTON_OK"),
                                        [this](void *) {
-                                               encryption.recovery();
+                                               encryption->recovery();
                                                result = -1;
                                                dispose();
                                        });
index 1dd0514f6f389702034ffba3e335e56532448e28..71ac8ad7de1ef0782cc3135726e8ca6a5c86a813 100644 (file)
@@ -18,8 +18,9 @@
 
 #include "password.h"
 
-PasswordCreate::PasswordCreate(Widget *parent)
-       : rememberPopup(parent, dgetText("IDS_ST_HEADER_REMEMBER_PASSWORD"), dgetText("IDS_ST_POP_MAKE_SURE_YOU_REMEMBER_YOUR_PASSWORD_IF_YOU_FORGET_IT_YOU_WILL_NO_LONGER_BE_ABLE_TO_USE_ANY_MSG")),
+PasswordCreate::PasswordCreate(Widget *parent, int type)
+       : PasswordInterface(type),
+         rememberPopup(parent, dgetText("IDS_ST_HEADER_REMEMBER_PASSWORD"), dgetText("IDS_ST_POP_MAKE_SURE_YOU_REMEMBER_YOUR_PASSWORD_IF_YOU_FORGET_IT_YOU_WILL_NO_LONGER_BE_ABLE_TO_USE_ANY_MSG")),
          enterPopup(parent, dgetText("IDS_ST_BODY_PASSWORD"), dgetText("IDS_ST_HEADER_ENTER_NEW_PASSWORD_ABB"), formatString("IDS_LCKSCN_BODY_THE_PASSWORD_MUST_CONSIST_OF_AT_LEAST_PD_ALPHANUMERIC_CHARACTERS_INCLUDING_AT_LEAST_1_LETTER", 4)),
          confirmPopup(parent, dgetText("IDS_ST_BODY_PASSWORD"), dgetText("IDS_ST_POP_CONFIRM_PASSWORD"), dgetText("IDS_ST_BODY_MAKE_SURE_YOU_REMEMBER_YOUR_PASSWORD")),
          mode(InitPassword),
@@ -108,8 +109,8 @@ void PasswordCreate::setConfirmPopup()
                                        if (!isMatched()) {
                                                return;
                                        }
-                                       if (mode == InitPassword)
-                                               encryption.initPassword(confirmPopup.getEntryData());
+                                       if (mode == InitPassword && encryption != nullptr)
+                                               encryption->initPassword(confirmPopup.getEntryData());
                                        data = confirmPopup.getEntryData();
                                        result = 1;
                                        dispose();
index b7ff17374aac895f4d5b2388721844b2905aca5b..2044b03f4e16b31e2c0120a84d50153da23bc836 100644 (file)
 
 #include "password.h"
 
-PasswordDelete::PasswordDelete(Widget *parent)
-       : deletePopup(parent, dgetText("IDS_ST_HEADER_DELETE_SD_CARD_PASSWORD"), dgetText("IDS_ST_POP_YOUR_DEVICE_WILL_FORGET_ALL_SD_CARDS_THAT_HAVE_PREVIOUSLY_BEEN_ENCRYPTED_BY_THIS_DEVICE_MSG")),
-         confirmPassword(parent)
+PasswordDelete::PasswordDelete(Widget *parent, int type)
+       : PasswordInterface(type),
+         deletePopup(parent, dgetText("IDS_ST_HEADER_DELETE_SD_CARD_PASSWORD"), dgetText("IDS_ST_POP_YOUR_DEVICE_WILL_FORGET_ALL_SD_CARDS_THAT_HAVE_PREVIOUSLY_BEEN_ENCRYPTED_BY_THIS_DEVICE_MSG")),
+         confirmPassword(parent, type)
 {
        setDeletePopup();
        confirmPassword.onResult.connect(this, &PasswordDelete::onDeleted);
@@ -61,7 +62,7 @@ void PasswordDelete::onDeleted(int ret, const std::string &data)
        if (ret == -1) {
                onResult.emit(1, data);
        } else if (ret == 1) {
-               encryption.cleanPassword(data);
+               encryption->cleanPassword(data);
                onResult.emit(0, data);
        }
 }
index b47fcf3386fa9445be3924d8820330efa4e31838..ae20b67ad32cd9eb87f781b2aa14ffcf23011d7c 100644 (file)
@@ -50,9 +50,11 @@ TextPopup::~TextPopup()
 {
 }
 
-PasswordInterface::PasswordInterface()
-       : result(0)
+PasswordInterface::PasswordInterface(int mode)
+       : encryption(nullptr), result(0)
 {
+       if (mode != EXTENSION)
+               encryption.reset(new ExternalEncryption{});
 }
 
 PasswordInterface::~PasswordInterface()
index b9e0bbe53b770e126014f67339daea354d9f6b1f..7525808a2f53a5459ee9fb90eecdf067b32a2a76 100644 (file)
@@ -48,7 +48,12 @@ public:
 
 class PasswordInterface {
 public:
-       PasswordInterface();
+       enum Mode {
+               EXTENSION = 0,
+               EXTERNAL,
+       };
+
+       PasswordInterface(int mode);
        virtual ~PasswordInterface();
 
        virtual void show() = 0;
@@ -56,7 +61,7 @@ public:
 public:
        Signal<int, const std::string&> onResult;
 protected:
-       ExternalEncryption encryption; /*TBD*/
+       std::unique_ptr<ExternalEncryption> encryption; /*TBD*/
        int result;
 };
 
@@ -67,7 +72,7 @@ public:
                ChangePassword,
        };
 
-       PasswordCreate(Widget *parent);
+       PasswordCreate(Widget *parent, int type);
        ~PasswordCreate();
 
        void show();
@@ -89,7 +94,7 @@ private:
 
 class PasswordConfirm : public PasswordInterface {
 public:
-       PasswordConfirm(Widget *parent);
+       PasswordConfirm(Widget *parent, int type);
        ~PasswordConfirm();
 
        void show();
@@ -114,7 +119,7 @@ private:
 
 class PasswordChange : public PasswordInterface {
 public:
-       PasswordChange(Widget *parent);
+       PasswordChange(Widget *parent, int type);
        ~PasswordChange();
 
        void show();
@@ -130,7 +135,7 @@ private:
 
 class PasswordDelete : public PasswordInterface {
 public:
-       PasswordDelete(Widget *parent);
+       PasswordDelete(Widget *parent, int type);
        ~PasswordDelete();
 
        void show();
index d0b92c0a2bc088ed2dca5fd3cdacdcd912ac3423..3e36dcf4db8e342a7a5d2be394f54931c79c21f3 100644 (file)
@@ -38,7 +38,7 @@ void DecryptSDCardInfo::setPartContent()
 
        changePasswordButton.setText(dgetText("IDS_ST_BUTTON_CHANGE_PASSWORD_ABB2"));
        changePasswordButton.onClick = [this](void *) {
-               passwordChange.reset(new PasswordChange(frame));
+               passwordChange.reset(new PasswordChange(frame, PasswordInterface::Mode::EXTERNAL));
                passwordChange->show();
        };
        content->setContent("password_button", &changePasswordButton);
@@ -89,7 +89,7 @@ void DecryptSDCardInterface::onConfirmed(int result, const std::string &data)
 
 void DecryptSDCardInterface::checkPassword()
 {
-       passwordConfirm.reset(new PasswordConfirm(naviframe));
+       passwordConfirm.reset(new PasswordConfirm(naviframe, PasswordInterface::Mode::EXTERNAL));
        passwordConfirm->onResult.connect(this, &DecryptSDCardInterface::onConfirmed);
        passwordConfirm->show();
 }
diff --git a/ode/src/interface/external/encrypt-extension.cpp b/ode/src/interface/external/encrypt-extension.cpp
new file mode 100644 (file)
index 0000000..c96e39c
--- /dev/null
@@ -0,0 +1,195 @@
+/*
+ *
+ * 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 "encrypt-extension.h"
+
+EncryptExtensionInfo::EncryptExtensionInfo(Widget *parent)
+       : Page(parent, "external_info", Page::Type::SetOneButton)
+{
+       setPartContent();
+}
+
+EncryptExtensionInfo::~EncryptExtensionInfo()
+{
+}
+
+void EncryptExtensionInfo::setPartContent()
+{
+       std::string info("");
+       info.append(dgetText("IDS_ST_BODY_ENCRYPTING_YOUR_SD_CARD_WILL_PROTECT_ITS_DATA_IF_ITS_LOST_OR_STOLEN_ENCRYPTED_SD_CARDS_CAN_ONLY_MSG"));
+       info.append("<br><br>");
+       info.append(dgetText("IDS_ST_BODY_ONCE_THE_SD_CARD_IS_ENCRYPTED_A_PASSWORD_IS_REQUIRED_TO_USE_IT_THE_SAME_PASSWORD_MUST_MSG"));
+
+       content->setText("msg_content", info);
+}
+
+EncryptExtensionCheck::EncryptExtensionCheck(Widget *parent)
+       : Page(parent, "external_check_status", Page::Type::SetTwoButton),
+         genlist(nullptr),
+         createButton(content.get()),
+         password(nullptr),
+         mmcStatus(true), pwdStatus(false),
+         groupIndex(dgetText("IDS_ST_BODY_TO_ENCRYPT_YOUR_SD_CARD_C")),
+         userData("")
+{
+       setPartContent();
+}
+
+EncryptExtensionCheck::~EncryptExtensionCheck()
+{
+}
+
+std::string EncryptExtensionCheck::getUserData()
+{
+       return userData;
+}
+
+void EncryptExtensionCheck::updateNextButton()
+{
+       if (mmcStatus && pwdStatus)
+               nextButton->setDisabled(false);
+       else
+               nextButton->setDisabled(true);
+}
+
+char *EncryptExtensionCheck::getLabel(const std::string &part, Evas_Object *obj, std::string *data)
+{
+       if (part == "elm.text") {
+               return ::strdup(dgetText(*data));
+       }
+       return nullptr;
+}
+
+void EncryptExtensionCheck::addItems(Genlist<std::string> *genlist)
+{
+       genlist->append("group_index", &groupIndex);
+}
+
+void EncryptExtensionCheck::setPartContent()
+{
+       content->emitSignal("checked,effect", "", "check_list", 1, 1);
+       updateNextButton();
+       passwordResultCallback(0, "");
+
+       std::string info("");
+       info.append(dgetText("IDS_ST_BODY_THE_ENCRYPTION_PROCESS_MAY_TAKE_A_LONG_TIME_DEPENDING_ON_THE_AMOUNT_OF_DATA_MSG"));
+       info.append("</br>");
+       info.append(dgetText("IDS_ST_BODY_MAKE_SURE_THAT_THE_BATTERY_IS_CHARGED_AND_KEEP_THE_PHONE_PLUGGED_IN_UNTIL_ENCRYPTION_IS_COMPLETE"));
+
+       content->setText("msg_content", info);
+
+       genlist.reset(new Genlist<std::string>(content.get(), 0));
+       genlist->setContentProvider(this);
+       content->setContent("group_index", genlist.get());
+
+       info.clear();
+       info.append(dgetText("IDS_ST_BODY_INSERT_THE_SD_CARD_ABB"));
+       content->setPartTableChildText("check_list", 1, 1, "check_text", info);
+
+       info.clear();
+       info.append(dgetText("IDS_ST_BODY_CREATE_AN_SD_CARD_PASSWORD"));
+       content->setPartTableChildText("check_list", 1, 2, "check_text", info);
+
+       createButton.setText(dgetText("IDS_ST_BUTTON_CREATE_PASSWORD"));
+       createButton.setStyle("auto_expand");
+       createButton.onClick = [this](void *) {
+               password.reset(new PasswordCreate(frame, PasswordInterface::Mode::EXTENSION));
+               password->onResult.connect(this, &EncryptExtensionCheck::passwordResultCallback);
+               password->show();
+       };
+       content->setContent("create_button", &createButton);
+}
+
+void EncryptExtensionCheck::passwordResultCallback(int status, const std::string &data)
+{
+       if (!status) {
+               pwdStatus = false;
+               createButton.setDisabled(false);
+               content->emitSignal("unchecked,effect", "", "check_list", 1, 2);
+       } else {
+               pwdStatus = true;
+               createButton.setDisabled(true);
+               content->emitSignal("checked,effect", "", "check_list", 1, 2);
+               userData = data;
+       }
+       updateNextButton();
+}
+
+EncryptExtensionInterface::EncryptExtensionInterface(AppControl *appControl)
+       : exitButton(nullptr), infoPage(nullptr), checkPage(nullptr), replyControl("org.tizen.ode", appControl), devPath(""), mappingNode("mapping_node")
+{
+       devPath = appControl->getData("dev_path");
+       mappingNode = appControl->getData("mapping_node");
+       setNaviframe();
+}
+
+EncryptExtensionInterface::~EncryptExtensionInterface()
+{
+}
+
+void EncryptExtensionInterface::mountStorage()
+{
+       int ret = 0;
+
+       ret = encryption.format(devPath, checkPage->getUserData());
+       if (ret != ODE_ERROR_NONE) {
+               replyControl.sendReply("result", "fail");
+               ::ui_app_exit();
+       }
+
+       ret = encryption.mount(devPath, checkPage->getUserData(), mappingNode);
+       if (ret != ODE_ERROR_NONE)
+               replyControl.sendReply("result", "fail");
+       else
+               replyControl.sendReply("result", "success");
+
+       ::ui_app_exit();
+}
+
+void EncryptExtensionInterface::createCheckPage()
+{
+       checkPage.reset(nullptr);
+       checkPage.reset(new EncryptExtensionCheck {naviframe});
+       checkPage->nextButton->onClickSignal.connect(this, &EncryptExtensionInterface::mountStorage);
+       checkPage->prevButton->onClick = [this](void *) {
+               naviframe->popItem();
+       };
+
+       naviframe->pushPage(dgetText("IDS_ST_HEADER_ENCRYPT_SD_CARD"), checkPage.get(), nullptr);
+}
+
+void EncryptExtensionInterface::create()
+{
+       NaviframeItem *item = nullptr;
+
+       exitButton.reset(new Button{naviframe});
+       exitButton->setStyle("naviframe/back_btn/default");
+       exitButton->onClick = [this](void *) {
+               naviframe->popItem();
+       };
+
+       infoPage.reset(new EncryptExtensionInfo {naviframe});
+       infoPage->nextButton->onClickSignal.connect(this, &EncryptExtensionInterface::createCheckPage);
+       item = naviframe->pushPage(dgetText("IDS_ST_HEADER_ENCRYPT_SD_CARD"), infoPage.get(), exitButton.get());
+       item->pagePopEvent.connect(this, &EncryptExtensionInterface::dispose);
+}
+
+void EncryptExtensionInterface::dispose()
+{
+       replyControl.sendReply("result", "cancel");
+       ::ui_app_exit();
+}
diff --git a/ode/src/interface/external/encrypt-extension.h b/ode/src/interface/external/encrypt-extension.h
new file mode 100644 (file)
index 0000000..083e7ad
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ *
+ * 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_ENCRYPT_EXTENSION_H_
+#define __ODE_ENCRYPT_EXTENSION_H__
+
+#include "../interface.h"
+#include "../progress.h"
+#include "../tools/vconf.h"
+#include "../tools/encryption.h"
+#include "../../widgets/appcontrol.h"
+#include "../../widgets/genlist.h"
+#include "../../widgets/button.h"
+#include "../external-locktype/password.h"
+
+class EncryptExtensionInfo : public Page {
+public:
+       EncryptExtensionInfo(Widget *parent);
+       ~EncryptExtensionInfo();
+
+       void setPartContent();
+};
+
+class EncryptExtensionCheck : public Page, public GenlistContentProvider<std::string> {
+public:
+       EncryptExtensionCheck(Widget *parent);
+       ~EncryptExtensionCheck();
+
+       std::string getUserData();
+       void setPartContent();
+       void passwordResultCallback(int status, const std::string &data);
+       void updateNextButton();
+
+       char *getLabel(const std::string &part, Evas_Object *obj, std::string *data);
+       void addItems(Genlist<std::string> *genlist);
+public:
+       std::unique_ptr<Genlist<std::string>> genlist;
+       Button createButton;
+       std::unique_ptr<PasswordInterface> password;
+
+       bool mmcStatus;
+       bool pwdStatus;
+       std::string groupIndex;
+       std::string userData;
+};
+
+class EncryptExtensionInterface : public ODEInterface {
+public:
+       EncryptExtensionInterface(AppControl *appControl);
+       ~EncryptExtensionInterface();
+
+       void create();
+       void dispose();
+       void mountStorage();
+       void createCheckPage();
+private:
+       std::unique_ptr<Button> exitButton;
+       std::unique_ptr<EncryptExtensionInfo> infoPage;
+       std::unique_ptr<EncryptExtensionCheck> checkPage;
+       ExtensionEncryption encryption;
+       AppControl replyControl;
+       std::string devPath;
+       std::string mappingNode;
+};
+#endif
index f09f85c2e247491f2ffa7c9c94fc5f365ae49339..90d9a2f6378a27bd4a58cd1e95b18331ff6cad07 100644 (file)
@@ -106,7 +106,7 @@ void EncryptSDCardCheck::setPartContent()
        createButton.setText(dgetText("IDS_ST_BUTTON_CREATE_PASSWORD"));
        createButton.setStyle("auto_expand");
        createButton.onClick = [this](void *) {
-               password.reset(new PasswordCreate(frame));
+               password.reset(new PasswordCreate(frame, PasswordInterface::Mode::EXTERNAL));
                password->onResult.connect(this, &EncryptSDCardCheck::passwordResultCallback);
                password->show();
        };
@@ -114,7 +114,7 @@ void EncryptSDCardCheck::setPartContent()
 
        changeButton.setText(dgetText("IDS_ST_BUTTON_CHANGE_PW_ABB"));
        changeButton.onClick = [this](void *) {
-               password.reset(new PasswordChange(frame));
+               password.reset(new PasswordChange(frame, PasswordInterface::Mode::EXTERNAL));
                password->onResult.connect(this, &EncryptSDCardCheck::passwordResultCallback);
                password->show();
        };
@@ -122,7 +122,7 @@ void EncryptSDCardCheck::setPartContent()
 
        deleteButton.setText(dgetText("IDS_ST_BUTTON_DELETE_PW_ABB"));
        deleteButton.onClick = [this](void *) {
-               password.reset(new PasswordDelete(frame));
+               password.reset(new PasswordDelete(frame, PasswordInterface::Mode::EXTERNAL));
                password->onResult.connect(this, &EncryptSDCardCheck::passwordResultCallback);
                password->show();
        };
@@ -279,7 +279,7 @@ void EncryptSDCardInterface::onConfirmed(int result, const std::string &data)
 
 void EncryptSDCardInterface::checkPassword()
 {
-       passwordConfirm.reset(new PasswordConfirm(naviframe));
+       passwordConfirm.reset(new PasswordConfirm(naviframe, PasswordInterface::Mode::EXTERNAL));
        passwordConfirm->onResult.connect(this, &EncryptSDCardInterface::onConfirmed);
        passwordConfirm->show();
 }
index 20574320bd9e1687df30f286c51d67a1cc96c1d2..0047d00e9aaec69d36a8979bcba2c2e12ee7068c 100644 (file)
@@ -19,7 +19,7 @@
 
 PasswordSDCard::PasswordSDCard()
        : baseLayout(new Layout(window)),
-         passwordConfirm(baseLayout),
+         passwordConfirm(baseLayout, PasswordInterface::Mode::EXTENSION),
          notification(NOTIFICATION_TYPE_NOTI),
          progress(nullptr)
 {
index a9db88eb22b2f53e13f67e7b3d872a8a2c456715..dada78ecaa97c228adf024f921410ae15bcb512f 100644 (file)
@@ -15,7 +15,6 @@
  * limitations under the License.
  *
  */
-
 #include "encryption.h"
 
 InternalEncryption::InternalEncryption()
@@ -77,10 +76,17 @@ void ExternalEncryption::encrypt(const std::string &pwd, int option)
        ::ode_external_encryption_encrypt(pwd.c_str(), option);
 }
 
-void ExternalEncryption::mount(const std::string &pwd)
+int ExternalEncryption::mount(const std::string &pwd)
 {
+       int ret = 0;
        ::ode_external_encryption_set_mount_password(pwd.c_str());
-       ::ode_external_encryption_mount();
+       ret = ::ode_external_encryption_mount();
+       return ret;
+}
+
+void ExternalEncryption::umount()
+{
+       ::ode_external_encryption_umount();
 }
 
 void ExternalEncryption::decrypt(const std::string &pwd)
@@ -92,3 +98,30 @@ void ExternalEncryption::recovery()
 {
        ::ode_external_encryption_recovery();
 }
+
+ExtensionEncryption::ExtensionEncryption()
+{
+}
+
+ExtensionEncryption::~ExtensionEncryption()
+{
+}
+
+int ExtensionEncryption::format(const std::string &device, const std::string &pwd)
+{
+       int ret = 0;
+       ret = ::ode_luks_format(device.c_str(), pwd.c_str());
+       return ret;
+}
+
+int ExtensionEncryption::mount(const std::string &device, const std::string &pwd, const std::string &node)
+{
+       int ret = 0;
+       ret = ::ode_luks_open(device.c_str(), pwd.c_str(), node.c_str());
+       return ret;
+}
+
+void ExtensionEncryption::umount(const std::string &node)
+{
+       ::ode_luks_close(node.c_str());
+}
index 2e4cfe6b3c58328a3237e7eb501604fe3722d098..45717664da6b666f5eda439045e67823eace01ee 100644 (file)
@@ -22,6 +22,7 @@
 #include <iostream>
 #include <ode/external-encryption.h>
 #include <ode/internal-encryption.h>
+#include <ode/luks.h>
 
 class InternalEncryption {
 public:
@@ -41,10 +42,20 @@ public:
        bool verifyPassword(const std::string &pwd);
        void changePassword(const std::string &prev, const std::string &next);
        void cleanPassword(const std::string &prev);
-       void mount(const std::string &pwd);
+       int mount(const std::string &pwd);
+       void umount();
        void encrypt(const std::string &pwd, int opt);
        void decrypt(const std::string &pwd);
        void recovery();
 };
 
+class ExtensionEncryption {
+public:
+       ExtensionEncryption();
+       ~ExtensionEncryption();
+
+       int format(const std::string &device, const std::string &pwd);
+       int mount(const std::string &device, const std::string &pwd, const std::string &node);
+       void umount(const std::string &node);
+};
 #endif
index 98dea2724cb5709972571b29930e89f536c5c9af..7e8c4d6fb67b68a44c4d19837c54cd2a68f2cc61 100644 (file)
@@ -40,7 +40,10 @@ int ODELaunchPad::getMode(const std::string &type)
                return Type::INSERT_SD_CARD;
        } else if (!type.compare("SD_CARD_PASSWORD")) {
                return Type::SD_CARD_PASSWORD;
+       } else if (!type.compare("ENCRYPT_EXTENSION")) {
+               return Type::ENCRYPT_EXTENSION;
        }
+
        return Type::DO_NOT_SUPPORTED;
 }
 
@@ -68,6 +71,9 @@ void ODELaunchPad::onAppControl()
        case Type::SD_CARD_PASSWORD:
                interface = new PasswordSDCard{};
                break;
+       case Type::ENCRYPT_EXTENSION:
+               interface = new EncryptExtensionInterface{appControl.get()};
+               break;
        default:
                throw runtime::Exception("Do not supported viewtype");
                break;
index 2afcd1c58638fa0ccf72f51fd31aa2ce3f4081b0..e79ca4fecd2d9a3ef7992b4a40871d90d0bf695d 100644 (file)
@@ -31,6 +31,7 @@
 #include "interface/external/decrypt-sdcard.h"
 #include "interface/external/insert-sdcard.h"
 #include "interface/external/password-sdcard.h"
+#include "interface/external/encrypt-extension.h"
 
 class ODELaunchPad : public Application {
 public:
@@ -41,6 +42,7 @@ public:
                DECRYPT_SD_CARD,
                INSERT_SD_CARD,
                SD_CARD_PASSWORD,
+               ENCRYPT_EXTENSION,
                DO_NOT_SUPPORTED,
        };
 
index a7aa7361918f0c84c2bddbcbe659cb0979a37308..80f1ecfc96a46745ac667e1554eee0adff6a1bdc 100644 (file)
  * limitations under the License.
  *
  */
-#include <dlog.h>
 #include "appcontrol.h"
 
 AppControl::AppControl(app_control_h handle)
-       : appControl(nullptr)
+       : appControl(nullptr), caller(nullptr)
 {
        if (handle != nullptr) {
                ::app_control_clone(&appControl, handle);
@@ -27,12 +26,21 @@ AppControl::AppControl(app_control_h handle)
 }
 
 AppControl::AppControl(const std::string &id)
-       : appControl(nullptr)
+       : appControl(nullptr), caller(nullptr)
 {
        ::app_control_create(&appControl);
        setAppID(id);
 }
 
+AppControl::AppControl(const std::string &id, AppControl *service)
+       : appControl(nullptr), caller(nullptr)
+{
+       ::app_control_create(&appControl);
+       setAppID(id);
+       if (service != nullptr)
+               ::app_control_clone(&caller, service->appControl);
+}
+
 AppControl::~AppControl()
 {
        if (appControl != nullptr)
@@ -80,3 +88,11 @@ void AppControl::replyEventHandlerDispatcher(app_control_h ug, app_control_h rep
 
        appControl->replyEventHandler.emit(&ugControl, &replyControl, result);
 }
+
+void AppControl::sendReply(const std::string &key, const std::string &value)
+{
+       if (caller) {
+               setData(key, value);
+               ::app_control_reply_to_launch_request(appControl, caller, APP_CONTROL_RESULT_SUCCEEDED);
+       }
+}
index 3247a0e9d406842df8de0a2fdf2299a2a7345146..e6a55dd5f130bfe34105e9d170ec022d352c8551 100644 (file)
@@ -27,6 +27,7 @@ class AppControl {
 public:
        AppControl(app_control_h handle);
        AppControl(const std::string &id);
+       AppControl(const std::string &id, AppControl *service);
        ~AppControl();
 
        operator app_control_h();
@@ -37,10 +38,12 @@ public:
 
        void launch();
        static void replyEventHandlerDispatcher(app_control_h ug, app_control_h reply, app_control_result_e result, void *data);
+       void sendReply(const std::string &key, const std::string &value);
 public:
        Signal<AppControl *, AppControl *, int> replyEventHandler;
 private:
        app_control_h appControl;
+       app_control_h caller;
 };
 
 #endif