Add internal encryption/decryption interface and tools for rework 93/137793/5
authors414kim <s414.kim@samsung.com>
Sat, 8 Jul 2017 09:37:28 +0000 (18:37 +0900)
committerSungbae Yoo <sungbae.yoo@samsung.com>
Mon, 31 Jul 2017 05:26:24 +0000 (05:26 +0000)
Change-Id: I247edc868b7550c55d29e2948314db8ea15fa463
Signed-off-by: s414kim <s414.kim@samsung.com>
18 files changed:
tools/apps/ode/CMakeLists.txt
tools/apps/ode/res/edc_resource/check-item.edc [new file with mode: 0644]
tools/apps/ode/res/edc_resource/internal.edc [new file with mode: 0644]
tools/apps/ode/res/org.tizen.ode.edc
tools/apps/ode/rework/interface/internal/decrypt-device.cpp [new file with mode: 0644]
tools/apps/ode/rework/interface/internal/decrypt-device.h [new file with mode: 0644]
tools/apps/ode/rework/interface/internal/encrypt-device.cpp [new file with mode: 0644]
tools/apps/ode/rework/interface/internal/encrypt-device.h [new file with mode: 0644]
tools/apps/ode/rework/interface/tools/battery.cpp [new file with mode: 0644]
tools/apps/ode/rework/interface/tools/battery.h [new file with mode: 0644]
tools/apps/ode/rework/interface/tools/encryption.cpp [new file with mode: 0644]
tools/apps/ode/rework/interface/tools/encryption.h [new file with mode: 0644]
tools/apps/ode/rework/interface/tools/locktype.cpp [new file with mode: 0644]
tools/apps/ode/rework/interface/tools/locktype.h [new file with mode: 0644]
tools/apps/ode/rework/interface/tools/vconf.cpp [new file with mode: 0644]
tools/apps/ode/rework/interface/tools/vconf.h [new file with mode: 0644]
tools/apps/ode/rework/ode.cpp
tools/apps/ode/rework/ode.h

index 988f48d..93d1c13 100755 (executable)
@@ -44,7 +44,13 @@ SET(REWORK_SRC
                        ./rework/ode.cpp
                        ./rework/application.cpp
                        ./rework/interface/interface.cpp
-                       ./rework/interface/page.cpp)
+                       ./rework/interface/page.cpp
+                       ./rework/interface/internal/encrypt-device.cpp
+                       ./rework/interface/internal/decrypt-device.cpp
+                       ./rework/interface/tools/vconf.cpp
+                       ./rework/interface/tools/encryption.cpp
+                       ./rework/interface/tools/locktype.cpp
+                       ./rework/interface/tools/battery.cpp)
 
 SET(WIDGET_SRC         ./rework/widgets/widget.cpp
                        ./rework/widgets/window.cpp
diff --git a/tools/apps/ode/res/edc_resource/check-item.edc b/tools/apps/ode/res/edc_resource/check-item.edc
new file mode 100644 (file)
index 0000000..d943b7c
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * 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.
+ *
+ */
+
+group {"check_item";
+        images {
+                image: "../images/icon_encrypt_bar.png" COMP;
+                image: "../images/icon_encrypt_check.png" COMP;
+        }
+        parts {
+                rect {"bg";
+                        scale: 1;
+                        desc { "default";
+                                min: 0 54;
+                                max: -1 54;
+                                rel1 { relative: 0.0 0.0;}
+                                rel2 { relative: 1.0 1.0;}
+                                visible: 0;
+                        }
+                }
+       image { "icon";
+                        scale: 1;
+                        desc { "default";
+                                min: 78 54;
+                                max: 78 54;
+                                align: 0.0 0.5;
+                                rel1 { relative: 0.0 0.0; to: "bg";}
+                                rel2 { relative: 1.0 1.0; to: "bg";}
+                                image.normal: "../images/icon_encrypt_bar.png";
+                                color: 5 5 5 220;
+                        }
+                        desc { "checked";
+                                min: 78 54;
+                                max: 78 54;
+                                align: 0.0 0.5;
+                                rel1 { relative: 0.0 0.0; to: "bg";}
+                                rel2 { relative: 1.0 1.0; to: "bg";}
+                                image.normal: "../images/icon_encrypt_check.png";
+                                color: 5 5 5 220;
+                        }
+                        desc { "hide";
+                                inherit: "default";
+                                visible: 0;
+                        }
+                }
+                textblock {"check_text";
+                        scale: 1;
+                        desc { "default";
+                                text { style: "info_text";
+                                        min: 0 1;
+                                        align: 0.0 0.5;
+                                }
+                                rel1 {relative: 1.0 0.0; to: "icon";}
+                                rel2 {relative: 1.0 1.0;}
+                        }
+                }
+        }
+       programs {
+                program {
+                        signal: "checked,effect";
+                        action: STATE_SET "checked" 0.0;
+                        source: "";
+                        target: "icon";
+                }
+                program {
+                        signal: "unchecked,effect";
+                        action: STATE_SET "default" 0.0;
+                        source: "";
+                        target: "icon";
+                }
+                program {
+                        signal: "hide,effect";
+                        action: STATE_SET "hide" 0.0;
+                        source: "";
+                        target: "icon";
+                }
+        }
+}
diff --git a/tools/apps/ode/res/edc_resource/internal.edc b/tools/apps/ode/res/edc_resource/internal.edc
new file mode 100644 (file)
index 0000000..a2d602f
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+ * 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.
+ *
+ */
+
+group {"internal_check";
+       parts {
+               rect { "bg";
+                       scale: 1;
+                       desc { "default";
+                               rel1 { relative: 0.0 0.0;}
+                               rel2 { relative: 1.0 1.0;}
+                               visible: 0;
+                               fixed: 1 1;
+                       }
+               }
+               textblock { "msg_content";
+                       scale: 1;
+                       desc { "default";
+                               fixed: 1 1;
+                               text { style: "info_text";
+                                       min: 0 1;
+                                       align: 0.0 0.0;
+                               }
+                               rel1 {relative: 0.0 0.0; offset: 32 24; to: "bg";}
+                               rel2 {relative: 1.0 0.5; offset: -32 0; to: "bg";}
+                       }
+               }
+               swallow { "group_index";
+                       scale: 1;
+                       desc { "default";
+                               min: 0 54;
+                               max: -1 54;
+                               rel1 {relative: 0.0 1.0; offset: -32 24; to: "msg_content";}
+                               rel2 {relative: 1.0 1.0;}
+                               align: 0.0 0.0;
+                               fixed: 1 1;
+                       }
+               }
+               rect { "opt_bg";
+                       scale: 1;
+                       desc { "default";
+                               rel1 { relative: 0.0 1.0; to: "group_index";}
+                               rel2 { relative: 1.0 1.0;}
+                               fixed: 1 1;
+                               color: 245 245 245 245;
+                       }
+               }
+               rect { "check_area";
+                       scale: 1;
+                       desc { "default";
+                               rel1 { relative: 0.0 1.0; offset: 0 24; to: "group_index";}
+                               rel2 { relative: 1.0 1.0; offset: 0 200; to: "group_index";}
+                               align: 0.0 0.0;
+                               visible: 0;
+                               fixed: 1 1;
+                       }
+               }
+               table { "check_list";
+                       scale: 1;
+                       desc { "default";
+                               rel1 {relative: 0.0 0.0; offset: 32 0; to: "check_area";}
+                               rel2 {relative: 1.0 1.0; to: "check_area";}
+                       }
+                       table {
+                               #define ITEM(source_name, part_name, x, y) \
+                                       item { \
+                                       source: source_name; \
+                                       name: part_name; \
+                                       position: x y; \
+                                       weight: 1.0 1.0; \
+                                       span: 1 1; \
+                                       align: -1.0 -1.0; \
+                               }
+                               items {
+                                       ITEM("check_item", "check_charger", 1, 1);
+                                       ITEM("check_item", "check_capacity", 1, 2);
+                                       ITEM("check_item", "check_locktype", 1, 3);
+                               }
+                       }
+               }
+               spacer { "padding.checklist";
+                       scale: 1;
+                       desc { "default";
+                               rel1 { relative: 0.0 1.0; offset: 0 0; to: "check_area";}
+                               rel2 { relative: 1.0 1.0; offset: 0 24; to: "check_area";}
+                               fixed: 1 1;
+                       }
+               }
+               swallow { "create_button";
+                       scale: 1;
+                       desc { "default";
+                               rel1 { relative: 0.0 1.0; offset: 110 22; to: "padding.checklist";}
+                               rel2 { relative: 1.0 1.0; offset: -110 80; to: "padding.checklist";}
+                               align: 1.0 0.5;
+                               fixed: 1 1;
+                               visible: 1;
+                       }
+               }
+       }
+}
+
+group { "internal_confirm"
+       parts {
+               rect { "bg";
+                       scale: 1;
+                       desc { "default";
+                               rel1 { relative: 0.0 0.0;}
+                               rel2 { relative: 1.0 1.0;}
+                               visible: 0;
+                       }
+               }
+               textblock { "msg_content";
+                       scale: 1;
+                       desc { "default";
+                               fixed: 1 1;
+                               text { style: "info_text";
+                                       min: 0 1;
+                                       align: 0.0 0.0;
+                               }
+                               rel1 {relative: 0.0 0.0; offset: 32 24; to: "bg";}
+                               rel2 {relative: 1.0 0.5; offset: -32 0; to: "bg";}
+                       }
+               }
+               swallow { "option_list";
+                       scale: 1;
+                       desc { "default";
+                               rel1 { relative: 0.0 1.0; offset: -32 24; to: "msg_content";}
+                               rel2 { relative: 1.0 1.0;}
+                               fixed: 1 1;
+                               align: 0.0 0.0;
+                       }
+               }
+       }
+}
index 48c1808..179a6ca 100644 (file)
  */
 
 collections {
+       styles {
+               style { name: "info_text";
+                       base: "font=Tizen:style=Medium font_size=22 color=#000000 wrap=mixed align=left text_calss=tizen";
+                       tag: "br" "\n";
+               }
+       }
        base_scale: 1.8;
        #include "./edc_resource/encryption_device.edc"
+       #include "./edc_resource/check-item.edc"
+       #include "./edc_resource/internal.edc"
        #include "./edc_resource/entry-popup.edc"
 }
diff --git a/tools/apps/ode/rework/interface/internal/decrypt-device.cpp b/tools/apps/ode/rework/interface/internal/decrypt-device.cpp
new file mode 100644 (file)
index 0000000..4f90205
--- /dev/null
@@ -0,0 +1,189 @@
+/*
+ *
+ * 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 "decrypt-device.h"
+
+DecryptDeviceCheck::DecryptDeviceCheck(Widget *parent)
+       : Page(parent, "internal_check", Page::Type::SetOneButton),
+       genlist(nullptr),
+       groupIndex(dgetText("IDS_ST_HEADER_TO_DECRYPT_YOUR_DEVICE_C_ABB")),
+       chargerState(false), capacityState(false)
+{
+       registStatusCallback();
+       setPartContent();
+}
+
+DecryptDeviceCheck::~DecryptDeviceCheck()
+{
+       removeStatusCallback();
+}
+
+char *DecryptDeviceCheck::getLabel(const std::string &part, Evas_Object *obj, std::string *data)
+{
+       if (part == "elm.text") {
+               return ::strdup(data->c_str());
+       }
+       return nullptr;
+}
+
+void DecryptDeviceCheck::addItems(Genlist<std::string> *genlist)
+{
+       genlist->append("group_index", &groupIndex);
+}
+
+void DecryptDeviceCheck::checkCapacity()
+{
+       int capacity = 0;
+       capacity = battery.getCapacity();
+       if (capacity > 80) {
+               content->emitSignal("checked,effect", "", "check_list", 1, 1);
+               capacityState = true;
+       } else {
+               content->emitSignal("unchecked,effect", "", "check_list", 1, 1);
+               capacityState = false;
+       }
+       updateNextButton();
+}
+
+void DecryptDeviceCheck::checkCharger()
+{
+       chargerState = battery.getChargerConnected();
+       if (chargerState) {
+               content->emitSignal("checked,effect", "", "check_list", 1, 2);
+       } else {
+               content->emitSignal("unchecked,effect", "", "check_list", 1, 2);
+       }
+       updateNextButton();
+}
+
+void DecryptDeviceCheck::updateNextButton()
+{
+       if (chargerState && capacityState) {
+               nextButton->setDisabled(false);
+       } else {
+               nextButton->setDisabled(true);
+       }
+}
+
+void DecryptDeviceCheck::setPartContent()
+{
+       checkCharger();
+       checkCapacity();
+       content->emitSignal("hide,effect", "", "check_list", 1, 3);
+
+       std::string text("");
+       text.append(dgetText("IDS_ST_BODY_DECRYPTING_YOUR_DEVICE_WILL_DECRYPT_THE_APPS_DATA_AND_OTHER_CONTENT_ON_YOUR_DEVICE"));
+       text.append("</br></br>");
+       text.append(dgetText("IDS_ST_BODY_THIS_MAY_TAKE_A_LONG_TIME_DEPENDING_ON_THE_AMOUNT_OF_DATA_INTERRUPTING_THIS_PROCESS_MAY_CAUSE_MSG"));
+       content->setText("msg_content", text);
+
+       genlist.reset(new Genlist<std::string>(content.get(), 0));
+       genlist->setContentProvider(this);
+       content->setContent("group_index", genlist.get());
+
+       text.clear();
+       text.append(formatString("IDS_ST_BODY_CHARGE_THE_BATTERY_TO_AT_LEAST_PDP", 80));
+       content->setPartTableChildText("check_list", 1, 1, "check_text", text);
+
+       text.clear();
+       text.append(dgetText("IDS_ST_BODY_CONNECT_THE_DEVICE_TO_A_CHARGER"));
+       content->setPartTableChildText("check_list", 1, 2, "check_text", text);
+}
+
+void DecryptDeviceCheck::registStatusCallback()
+{
+       battery.onChargerEvent.connect(this, &DecryptDeviceCheck::checkCharger);
+       battery.onCapacityEvent.connect(this, &DecryptDeviceCheck::checkCapacity);
+}
+
+void DecryptDeviceCheck::removeStatusCallback()
+{
+       battery.onChargerEvent.disconnectAll();
+       battery.onCapacityEvent.disconnectAll();
+}
+
+DecryptDeviceConfirm::DecryptDeviceConfirm(Widget *parent)
+       : Page(parent, "internal_confirm", Page::Type::SetOneButton)
+{
+       setPartContent();
+}
+
+DecryptDeviceConfirm::~DecryptDeviceConfirm()
+{
+}
+
+void DecryptDeviceConfirm::setPartContent()
+{
+       nextButton->setText(dgetText("IDS_ST_BUTTON_DECRYPT_DEVICE"));
+       std::string text("");
+
+       text.append(dgetText("IDS_ST_BODY_TAP_DECRYPT_TO_START_THE_DECRYPTION_PROCESS"));
+       text.append("</br></br>");
+       text.append(dgetText("IDS_ST_BODY_THE_DECRYPTION_CANT_BE_CANCELLED_AND_DATA_WILL_BE_LOST_IF_THE_PROCESS_IS_INTERRUPTED_DURING_THE_DECRYPTION_MSG"));
+       content->setText("msg_content", text);
+}
+
+DecryptDeviceInterface::DecryptDeviceInterface()
+       : exitButton(nullptr), checkPage(nullptr), confirmPage(nullptr)
+{
+       setNaviframe();
+}
+
+DecryptDeviceInterface::~DecryptDeviceInterface()
+{
+}
+
+void DecryptDeviceInterface::onConfirmed(const std::string &current)
+{
+       encryption.decrypt(current);
+       dispose();
+}
+
+void DecryptDeviceInterface::checkPassword()
+{
+       locktype.onResultSignal.connect(this, &DecryptDeviceInterface::onConfirmed);
+       locktype.confirm();
+}
+
+void DecryptDeviceInterface::createConfirmPage()
+{
+       confirmPage.reset(nullptr);
+       confirmPage.reset(new DecryptDeviceConfirm{naviframe});
+       confirmPage->nextButton->onClickSignal.connect(this, &DecryptDeviceInterface::checkPassword);
+       naviframe->pushPage(dgetText("IDS_ST_HEADER_CONFIRM_DECRYPTION"), confirmPage.get(), nullptr);
+}
+
+void DecryptDeviceInterface::create()
+{
+       NaviframeItem *item = nullptr;
+
+       exitButton.reset(new Button{naviframe});
+       exitButton->setStyle("naviframe/back_btn/default");
+       exitButton->onClick = [this](void *) {
+               naviframe->popItem();
+       };
+
+       checkPage.reset(new DecryptDeviceCheck{naviframe});
+       checkPage->nextButton->onClickSignal.connect(this, &DecryptDeviceInterface::createConfirmPage);
+       item = naviframe->pushPage(dgetText("IDS_ST_HEADER_DECRYPT_DEVICE"), checkPage.get(), exitButton.get());
+       item->pagePopEvent.connect(this, &DecryptDeviceInterface::dispose);
+}
+
+void DecryptDeviceInterface::dispose()
+{
+       ::ui_app_exit();
+}
diff --git a/tools/apps/ode/rework/interface/internal/decrypt-device.h b/tools/apps/ode/rework/interface/internal/decrypt-device.h
new file mode 100644 (file)
index 0000000..2581166
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ *
+ * 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 __DECRYPT_DEVICE_H__
+#define __DECRYPT_DEVICE_H__
+
+#include "../interface.h"
+#include "../tools/battery.h"
+#include "../tools/vconf.h"
+#include "../tools/encryption.h"
+#include "../tools/locktype.h"
+#include "../../widgets/genlist.h"
+#include "../../widgets/button.h"
+
+class DecryptDeviceCheck : public Page, public GenlistContentProvider<std::string> {
+public:
+       DecryptDeviceCheck(Widget *parent);
+       ~DecryptDeviceCheck();
+
+       void setPartContent();
+       char *getLabel(const std::string &part, Evas_Object *obj, std::string *data);
+       void addItems(Genlist<std::string> *genlist);
+
+       void checkCharger();
+       void checkCapacity();
+
+private:
+       void updateNextButton();
+       void registStatusCallback();
+       void removeStatusCallback();
+private:
+       std::unique_ptr<Genlist<std::string>> genlist;
+       std::string groupIndex;
+       Battery battery;
+       bool chargerState;
+       bool capacityState;
+};
+
+class DecryptDeviceConfirm : public Page {
+public:
+       DecryptDeviceConfirm(Widget *parent);
+       ~DecryptDeviceConfirm();
+
+       void setPartContent();
+};
+
+class DecryptDeviceInterface : public ODEInterface {
+public:
+       DecryptDeviceInterface();
+       ~DecryptDeviceInterface();
+
+       void create();
+       void dispose();
+
+       void onConfirmed(const std::string &current);
+       void checkPassword();
+       void createConfirmPage();
+
+private:
+       std::unique_ptr<Button> exitButton;
+       std::unique_ptr<DecryptDeviceCheck> checkPage;
+       std::unique_ptr<DecryptDeviceConfirm> confirmPage;
+
+       Locktype locktype;
+       InternalEncryption encryption;
+};
+
+#endif
diff --git a/tools/apps/ode/rework/interface/internal/encrypt-device.cpp b/tools/apps/ode/rework/interface/internal/encrypt-device.cpp
new file mode 100644 (file)
index 0000000..8fbbd8c
--- /dev/null
@@ -0,0 +1,278 @@
+/*
+ *
+ * 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-device.h"
+
+EncryptDeviceCheck::EncryptDeviceCheck(Widget *parent)
+       : Page(parent, "internal_check", Page::Type::SetOneButton),
+       genlist(nullptr),
+       lockTypeButton(content.get()),
+       groupIndex(dgetText("IDS_ST_BODY_TO_ENCRYPT_YOUR_DEVICE_C_ABB")),
+       vconf(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT),
+       chargerState(false), capacityState(false), pwdState(false)
+{
+       registStatusCallback();
+       setPartContent();
+}
+
+EncryptDeviceCheck::~EncryptDeviceCheck()
+{
+       removeStatusCallback();
+}
+
+char *EncryptDeviceCheck::getLabel(const std::string &part, Evas_Object *obj, std::string *data)
+{
+       if (part == "elm.text") {
+               return ::strdup(data->c_str());
+       }
+       return nullptr;
+}
+
+void EncryptDeviceCheck::addItems(Genlist<std::string> *genlist)
+{
+       genlist->append("group_index", &groupIndex);
+}
+
+void EncryptDeviceCheck::checkCapacity()
+{
+       int capacity = 0;
+       capacity = battery.getCapacity();
+       if (capacity > 80) {
+               content->emitSignal("checked,effect", "", "check_list", 1, 1);
+               capacityState = true;
+       } else {
+               content->emitSignal("unchecked,effect", "", "check_list", 1, 1);
+               capacityState = false;
+       }
+       updateNextButton();
+}
+
+void EncryptDeviceCheck::checkCharger()
+{
+       chargerState = battery.getChargerConnected();
+       if (chargerState) {
+               content->emitSignal("checked,effect", "", "check_list", 1, 2);
+       } else {
+               content->emitSignal("unchecked,effect", "", "check_list", 1, 2);
+       }
+       updateNextButton();
+}
+
+void EncryptDeviceCheck::checkLockType()
+{
+       pwdState = locktype.getState();
+       if (pwdState) {
+               content->emitSignal("checked,effect", "", "check_list", 1, 3);
+       } else {
+               content->emitSignal("unchecked,effect", "", "check_list", 1, 3);
+       }
+       updateNextButton();
+}
+
+void EncryptDeviceCheck::updateNextButton()
+{
+       if (chargerState && capacityState && pwdState) {
+               nextButton->setDisabled(false);
+       } else {
+               nextButton->setDisabled(true);
+       }
+}
+
+void EncryptDeviceCheck::setPartContent()
+{
+       checkCharger();
+       checkCapacity();
+       checkLockType();
+
+       std::string text("");
+       text.append(dgetText("IDS_ST_BODY_ENCRYPTING_YOUR_PHONE_WILL_SECURE_THE_APPS_DATA_AND_OTHER_CONTENT_ON_IT_N_NTO_DECRYPT_YOUR_PHONE_ONCE_MSG"));
+       text.append("</br></br>");
+       text.append(dgetText("IDS_ST_BODY_THE_ENCRYPTION_PROCESS_MAY_TAKE_A_LONG_TIME_DEPENDING_ON_THE_AMOUNT_OF_DATA_MSG"));
+       content->setText("msg_content", text);
+
+       genlist.reset(new Genlist<std::string>(content.get(), 0));
+       genlist->setContentProvider(this);
+       content->setContent("group_index", genlist.get());
+
+       text.clear();
+       text.append(formatString("IDS_ST_BODY_CHARGE_THE_BATTERY_TO_AT_LEAST_PDP", 80));
+       content->setPartTableChildText("check_list", 1, 1, "check_text", text);
+
+       text.clear();
+       text.append(dgetText("IDS_ST_BODY_CONNECT_THE_DEVICE_TO_A_CHARGER"));
+       content->setPartTableChildText("check_list", 1, 2, "check_text", text);
+
+       text.clear();
+       text.append(dgetText("IDS_ST_BODY_SET_THE_SCREEN_LOCK_TYPE_TO_PASSWORD"));
+       content->setPartTableChildText("check_list", 1, 3, "check_text", text);
+
+       lockTypeButton.setText(dgetText("IDS_ST_BUTTON_SCREEN_LOCK_TYPE_ABB"));
+       lockTypeButton.onClick = [this](void *) {
+               locktype.create();
+       };
+       content->setContent("create_button", &lockTypeButton);
+}
+
+void EncryptDeviceCheck::registStatusCallback()
+{
+       battery.onChargerEvent.connect(this, &EncryptDeviceCheck::checkCharger);
+       battery.onCapacityEvent.connect(this, &EncryptDeviceCheck::checkCapacity);
+       vconf.addChangedCallback();
+       vconf.onKeyChanged.connect(this, &EncryptDeviceCheck::checkLockType);
+}
+
+void EncryptDeviceCheck::removeStatusCallback()
+{
+       battery.onChargerEvent.disconnectAll();
+       battery.onCapacityEvent.disconnectAll();
+       vconf.removeChangedCallback();
+}
+
+EncryptDeviceConfirm::EncryptDeviceConfirm(Widget *parent)
+       : Page(parent, "internal_confirm", Page::Type::SetTwoButton),
+       genlist(nullptr),
+       checkBox(nullptr),
+       option(FAST_DEVICE_ENCRYPTION)
+{
+       setPartContent();
+}
+
+EncryptDeviceConfirm::~EncryptDeviceConfirm()
+{
+       optionList.clear();
+}
+
+char *EncryptDeviceConfirm::getLabel(const std::string &part, Evas_Object *obj, EncryptDeviceOption *data)
+{
+       if (part == "elm.text") {
+               return ::strdup(dgetText(data->header));
+       } else if (part == "elm.text.multiline") {
+               return ::strdup(dgetText(data->multiline));
+       }
+       return nullptr;
+}
+
+Evas_Object *EncryptDeviceConfirm::getObject(const std::string &part, Evas_Object *obj, EncryptDeviceOption *data)
+{
+       if (part == "elm.swallow.end") {
+               checkBox.reset(new CheckBox(this));
+               checkBox->setState(false);
+               checkBox->onChangedSignal.connect(this, &EncryptDeviceConfirm::setOption);
+               return Widget::evasObject(checkBox.get());
+       }
+       return nullptr;
+}
+
+void EncryptDeviceConfirm::setOption()
+{
+       if (checkBox->getState()) {
+               option = FAST_DEVICE_ENCRYPTION;
+       } else {
+               option = FULL_DEVICE_ENCRYPTION;
+       }
+}
+
+int EncryptDeviceConfirm::getOption()
+{
+       return option;
+}
+
+void EncryptDeviceConfirm::addItems(Genlist<EncryptDeviceOption> *genlist)
+{
+       for (EncryptDeviceOption *elem : optionList) {
+               if (elem == optionList[0]) {
+                       genlist->append("group_index", elem);
+               } else {
+                       genlist->append("multiline", elem).setSelectMode(ELM_OBJECT_SELECT_MODE_NONE);
+               }
+       }
+}
+
+void EncryptDeviceConfirm::setPartContent()
+{
+       nextButton->setText(dgetText("IDS_ST_HEADER_ENCRYPT_DEVICE"));
+       std::string text("");
+
+       text.append(dgetText("IDS_ST_BODY_TAP_ENCRYPT_TO_START_THE_ENCRYPTION_PROCESS"));
+       text.append("</br></br>");
+       text.append(dgetText("IDS_ST_BODY_THE_ENCRYPTION_CANT_BE_CANCELLED_AND_DATA_WILL_BE_LOST_IF_THE_PROCESS_IS_INTERRUPTED_DURING_MSG"));
+
+       content->setText("msg_content", text);
+
+       genlist.reset(new Genlist<EncryptDeviceOption>(content.get(), Genlist<EncryptDeviceOption>::Flags::setCompressMode));
+       genlist->setStyle("solid/default");
+
+       optionList.push_back(new EncryptDeviceOption(dgetText("IDS_ST_HEADER_ENCRYPTION_OPTIONS_ABB"), ""));
+       optionList.push_back(new EncryptDeviceOption(dgetText("IDS_ST_MBODY_FULL_ENCRYPTION"), dgetText("IDS_ST_SBODY_ENCRYPT_NOT_ONLY_THE_USED_PHONE_STORAGE_BUT_ALSO_ANY_EMPTY_SPACE_THIS_WILL_TAKE_MORE_TIME")));
+
+       genlist->setContentProvider(this);
+       content->setContent("option_list", genlist.get());
+}
+
+EncryptDeviceInterface::EncryptDeviceInterface()
+       : exitButton(nullptr), checkPage(nullptr), confirmPage(nullptr)
+{
+       setNaviframe();
+}
+
+EncryptDeviceInterface::~EncryptDeviceInterface()
+{
+}
+
+void EncryptDeviceInterface::onConfirmed(const std::string &current)
+{
+       encryption.encrypt(current, confirmPage->getOption());
+       dispose();
+}
+
+void EncryptDeviceInterface::checkPassword()
+{
+       locktype.onResultSignal.connect(this, &EncryptDeviceInterface::onConfirmed);
+       locktype.confirm();
+}
+
+void EncryptDeviceInterface::createConfirmPage()
+{
+       confirmPage.reset(nullptr);
+       confirmPage.reset(new EncryptDeviceConfirm{naviframe});
+       confirmPage->nextButton->onClickSignal.connect(this, &EncryptDeviceInterface::checkPassword);
+       confirmPage->prevButton->onClick = [this](void *) {
+               naviframe->popItem();
+       };
+       naviframe->pushPage(dgetText("IDS_ST_HEADER_ENCRYPT_DEVICE"), confirmPage.get(), nullptr);
+}
+
+void EncryptDeviceInterface::create()
+{
+       NaviframeItem *item = nullptr;
+
+       exitButton.reset(new Button{naviframe});
+       exitButton->setStyle("naviframe/back_btn/default");
+       exitButton->onClick = [this](void *) {
+               naviframe->popItem();
+       };
+
+       checkPage.reset(new EncryptDeviceCheck{naviframe});
+       checkPage->nextButton->onClickSignal.connect(this, &EncryptDeviceInterface::createConfirmPage);
+       item = naviframe->pushPage(dgetText("IDS_ST_HEADER_ENCRYPT_DEVICE"), checkPage.get(), exitButton.get());
+       item->pagePopEvent.connect(this, &EncryptDeviceInterface::dispose);
+}
+
+void EncryptDeviceInterface::dispose()
+{
+       ::ui_app_exit();
+}
diff --git a/tools/apps/ode/rework/interface/internal/encrypt-device.h b/tools/apps/ode/rework/interface/internal/encrypt-device.h
new file mode 100644 (file)
index 0000000..d31e905
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ *
+ * 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 __ENCRYPT_DEVICE_H__
+#define __ENCRYPT_DEVICE_H__
+
+#include "../interface.h"
+#include "../tools/battery.h"
+#include "../tools/vconf.h"
+#include "../tools/encryption.h"
+#include "../tools/locktype.h"
+#include "../../widgets/genlist.h"
+#include "../../widgets/button.h"
+#include "../../widgets/checkbox.h"
+
+class EncryptDeviceCheck : public Page, public GenlistContentProvider<std::string> {
+public:
+       EncryptDeviceCheck(Widget *parent);
+       ~EncryptDeviceCheck();
+
+       void setPartContent();
+       char *getLabel(const std::string &part, Evas_Object *obj, std::string *data);
+       void addItems(Genlist<std::string> *genlist);
+
+       void checkCharger();
+       void checkCapacity();
+       void checkLockType();
+
+private:
+       void updateNextButton();
+       void registStatusCallback();
+       void removeStatusCallback();
+private:
+       std::unique_ptr<Genlist<std::string>> genlist;
+       Button lockTypeButton;
+       std::string groupIndex;
+       Vconf vconf;
+       Battery battery;
+       bool chargerState;
+       bool capacityState;
+       bool pwdState;
+       Locktype locktype;
+};
+
+struct EncryptDeviceOption {
+public:
+        EncryptDeviceOption(const std::string &h, const std::string &m) : header(h), multiline(m) {
+       }
+        std::string header;
+        std::string multiline;
+};
+
+class EncryptDeviceConfirm : public Page, public GenlistContentProvider<EncryptDeviceOption> {
+public:
+       enum Option {
+               FULL_DEVICE_ENCRYPTION = 0,
+               FAST_DEVICE_ENCRYPTION,
+       };
+
+       EncryptDeviceConfirm(Widget *parent);
+       ~EncryptDeviceConfirm();
+
+       void setPartContent();
+       void setOption();
+       int getOption();
+
+       char *getLabel(const std::string &part, Evas_Object *obj, EncryptDeviceOption *data);
+       Evas_Object *getObject(const std::string &part, Evas_Object *obj, EncryptDeviceOption *data);
+       void addItems(Genlist<EncryptDeviceOption> *genlist);
+
+private:
+       std::unique_ptr<Genlist<EncryptDeviceOption>> genlist;
+       std::vector<EncryptDeviceOption*> optionList;
+       std::unique_ptr<CheckBox> checkBox;
+       int option;
+};
+
+
+class EncryptDeviceInterface : public ODEInterface {
+public:
+       EncryptDeviceInterface();
+       ~EncryptDeviceInterface();
+
+       void create();
+       void dispose();
+
+       void onConfirmed(const std::string &current);
+       void checkPassword();
+       void createConfirmPage();
+
+private:
+       std::unique_ptr<Button> exitButton;
+       std::unique_ptr<EncryptDeviceCheck> checkPage;
+       std::unique_ptr<EncryptDeviceConfirm> confirmPage;
+       Locktype locktype;
+       InternalEncryption encryption;
+};
+
+#endif
diff --git a/tools/apps/ode/rework/interface/tools/battery.cpp b/tools/apps/ode/rework/interface/tools/battery.cpp
new file mode 100644 (file)
index 0000000..daa0d94
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ *
+ * 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 "battery.h"
+
+static void chargerCallback(runtime_info_key_e key, void *data)
+{
+       Battery *battery = reinterpret_cast<Battery *>(data);
+       if (key == RUNTIME_INFO_KEY_CHARGER_CONNECTED)
+               battery->onChargerEvent.emit();
+}
+
+static void capacityCallback(device_callback_e type, void *value, void *data)
+{
+       Battery *battery = reinterpret_cast<Battery *>(data);
+       if (type != DEVICE_CALLBACK_BATTERY_CAPACITY)
+               battery->onCapacityEvent.emit();
+}
+
+Battery::Battery()
+{
+       ::runtime_info_set_changed_cb(RUNTIME_INFO_KEY_CHARGER_CONNECTED, chargerCallback, reinterpret_cast<void *>(this));
+       ::device_add_callback(DEVICE_CALLBACK_BATTERY_CAPACITY, capacityCallback, reinterpret_cast<void *>(this));
+}
+
+Battery::~Battery()
+{
+       ::runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_CHARGER_CONNECTED);
+       ::device_remove_callback(DEVICE_CALLBACK_BATTERY_CAPACITY, capacityCallback);
+}
+
+bool Battery::getChargerConnected()
+{
+       bool connected = false;
+       ::runtime_info_get_value_bool(RUNTIME_INFO_KEY_CHARGER_CONNECTED, &connected);
+       return connected;
+}
+
+int Battery::getCapacity()
+{
+       int percentage = 0;
+       ::device_battery_get_percent(&percentage);
+       return percentage;
+}
diff --git a/tools/apps/ode/rework/interface/tools/battery.h b/tools/apps/ode/rework/interface/tools/battery.h
new file mode 100644 (file)
index 0000000..27fcb68
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ *
+ * 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_BATTERY_H__
+#define __ODE_BATTERY_H__
+
+#include <device/battery.h>
+#include <device/callback.h>
+#include <runtime_info.h>
+#include "../../widgets/signal.h"
+
+class Battery {
+public:
+       Battery();
+       ~Battery();
+
+       bool getChargerConnected();
+       int getCapacity();
+
+       Signal<> onChargerEvent;
+       Signal<> onCapacityEvent;
+};
+
+#endif
diff --git a/tools/apps/ode/rework/interface/tools/encryption.cpp b/tools/apps/ode/rework/interface/tools/encryption.cpp
new file mode 100644 (file)
index 0000000..a9db88e
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ *
+ * 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 "encryption.h"
+
+InternalEncryption::InternalEncryption()
+{
+}
+
+InternalEncryption::~InternalEncryption()
+{
+}
+
+void InternalEncryption::encrypt(const std::string &pwd, int opt)
+{
+       bool ret = false;
+       ::ode_internal_encryption_verify_password(pwd.c_str(), &ret);
+       if (!ret) {
+               return;
+       }
+
+       ::ode_internal_encryption_encrypt(pwd.c_str(), opt);
+}
+
+void InternalEncryption::decrypt(const std::string &pwd)
+{
+       ::ode_internal_encryption_decrypt(pwd.c_str());
+}
+
+ExternalEncryption::ExternalEncryption()
+{
+}
+
+ExternalEncryption::~ExternalEncryption()
+{
+}
+
+void ExternalEncryption::initPassword(const std::string &init)
+{
+       ::ode_external_encryption_init_password(init.c_str());
+}
+
+bool ExternalEncryption::verifyPassword(const std::string &pwd)
+{
+       bool result = false;
+       ::ode_external_encryption_verify_password(pwd.c_str(), &result);
+       return result;
+}
+
+void ExternalEncryption::changePassword(const std::string &prev, const std::string &next)
+{
+       ::ode_external_encryption_change_password(prev.c_str(), next.c_str());
+}
+
+void ExternalEncryption::cleanPassword(const std::string &prev)
+{
+       ::ode_external_encryption_clean_password(prev.c_str());
+}
+
+void ExternalEncryption::encrypt(const std::string &pwd, int option)
+{
+       ::ode_external_encryption_encrypt(pwd.c_str(), option);
+}
+
+void ExternalEncryption::mount(const std::string &pwd)
+{
+       ::ode_external_encryption_set_mount_password(pwd.c_str());
+       ::ode_external_encryption_mount();
+}
+
+void ExternalEncryption::decrypt(const std::string &pwd)
+{
+       ::ode_external_encryption_decrypt(pwd.c_str());
+}
+
+void ExternalEncryption::recovery()
+{
+       ::ode_external_encryption_recovery();
+}
diff --git a/tools/apps/ode/rework/interface/tools/encryption.h b/tools/apps/ode/rework/interface/tools/encryption.h
new file mode 100644 (file)
index 0000000..2e4cfe6
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ *
+ * 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_ENCRYPTION_H__
+#define __ODE_ENCRYPTION_H__
+
+#include <iostream>
+#include <ode/external-encryption.h>
+#include <ode/internal-encryption.h>
+
+class InternalEncryption {
+public:
+       InternalEncryption();
+       ~InternalEncryption();
+
+       void encrypt(const std::string &pwd, int opt);
+       void decrypt(const std::string &pwd);
+};
+
+class ExternalEncryption {
+public:
+       ExternalEncryption();
+       ~ExternalEncryption();
+
+       void initPassword(const std::string &init);
+       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);
+       void encrypt(const std::string &pwd, int opt);
+       void decrypt(const std::string &pwd);
+       void recovery();
+};
+
+#endif
diff --git a/tools/apps/ode/rework/interface/tools/locktype.cpp b/tools/apps/ode/rework/interface/tools/locktype.cpp
new file mode 100644 (file)
index 0000000..5989ce5
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ *
+ * 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 "locktype.h"
+
+Locktype::Locktype()
+       : setLocktype("org.tizen.setting-locktype"),
+         verifyLocktype("org.tizen.setting-password")
+{
+       verifyLocktype.setData("viewtype", "SETTING_PW_TYPE_ENTER_LOCK_TYPE");
+       verifyLocktype.setData(APP_CONTROL_DATA_SHIFT_WINDOW, "true");
+}
+
+Locktype::~Locktype()
+{
+}
+
+void Locktype::resultCallback(AppControl *ug, AppControl *reply, int result)
+{
+       if (result != APP_CONTROL_RESULT_SUCCEEDED || reply == nullptr) {
+               throw runtime::Exception("failed to get result");
+       }
+
+       std::string resultData = reply->getData("result");
+       if (!resultData.compare("SETTING_PW_TYPE_ENTER_LOCK_TYPE")
+                       || !resultData.compare("SETTING_PW_TYPE_VERIFY_FP_ALT_PASSWORD")) {
+               std::string current(reply->getData("current"));
+               if (!current.empty()) {
+                       onResultSignal.emit(current);
+               }
+       }
+}
+
+void Locktype::reset(const std::string &current)
+{
+       setLocktype.setData("current", current);
+       setLocktype.launch();
+}
+
+bool Locktype::getState()
+{
+       Vconf vconf(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT);
+       int locktype = 0;
+       locktype = vconf.getInt();
+       if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD
+               || locktype == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD) {
+               return true;
+       }
+       return false;
+}
+
+void Locktype::create()
+{
+       if (getState()) {
+               onResultSignal.connect(this, &Locktype::reset);
+               verifyLocktype.replyEventHandler.connect(this, &Locktype::resultCallback);
+               verifyLocktype.launch();
+       } else {
+               setLocktype.launch();
+       }
+}
+
+void Locktype::confirm()
+{
+       if (getState()) {
+               verifyLocktype.replyEventHandler.connect(this, &Locktype::resultCallback);
+               verifyLocktype.launch();
+       }
+}
diff --git a/tools/apps/ode/rework/interface/tools/locktype.h b/tools/apps/ode/rework/interface/tools/locktype.h
new file mode 100644 (file)
index 0000000..2e8107c
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ *
+ * 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_LOCKTYPE_H__
+#define __ODE_LOCKTYPE_H__
+
+#include "../tools/vconf.h"
+#include "../../widgets/appcontrol.h"
+
+class Locktype {
+public:
+       Locktype();
+       ~Locktype();
+
+       bool getState();
+       void reset(const std::string &current);
+       void create();
+       void confirm();
+
+       void resultCallback(AppControl *ug, AppControl *reply, int result);
+public:
+       Signal<const std::string &> onResultSignal;
+private:
+       AppControl setLocktype;
+       AppControl verifyLocktype;
+};
+
+#endif
diff --git a/tools/apps/ode/rework/interface/tools/vconf.cpp b/tools/apps/ode/rework/interface/tools/vconf.cpp
new file mode 100644 (file)
index 0000000..2c1fe3b
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ *
+ * 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 "vconf.h"
+
+static void keyChangedCallback(keynode_t *node, void *data)
+{
+       Vconf *vconf = reinterpret_cast<Vconf *>(data);
+       vconf->onKeyChanged.emit();
+}
+
+Vconf::Vconf(const std::string &key)
+       : vconfKey(key)
+{
+}
+
+Vconf::~Vconf()
+{
+}
+
+char *Vconf::getString()
+{
+       return ::vconf_get_str(vconfKey.c_str());
+}
+
+int Vconf::getInt()
+{
+       int value = 0;
+       ::vconf_get_int(vconfKey.c_str(), &value);
+       return value;
+}
+
+bool Vconf::getBool()
+{
+       int value = false;
+       ::vconf_get_bool(vconfKey.c_str(), &value);
+       return value;
+}
+
+void Vconf::setString(const std::string &value)
+{
+       ::vconf_set_str(vconfKey.c_str(), value.c_str());
+}
+
+void Vconf::setInt(int value)
+{
+       ::vconf_set_int(vconfKey.c_str(), value);
+}
+
+void Vconf::setBool(bool value)
+{
+       ::vconf_set_bool(vconfKey.c_str(), value);
+}
+
+void Vconf::addChangedCallback()
+{
+       ::vconf_notify_key_changed(vconfKey.c_str(), keyChangedCallback, reinterpret_cast<void *>(this));
+}
+
+void Vconf::removeChangedCallback()
+{
+       ::vconf_ignore_key_changed(vconfKey.c_str(), keyChangedCallback);
+       onKeyChanged.disconnectAll();
+}
diff --git a/tools/apps/ode/rework/interface/tools/vconf.h b/tools/apps/ode/rework/interface/tools/vconf.h
new file mode 100644 (file)
index 0000000..680fcea
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ *
+ * 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_VCONF_H__
+#define __ODE_VCONF_H__
+
+#include <vconf.h>
+#include "../../widgets/signal.h"
+
+class Vconf {
+public:
+       Vconf(const std::string &key);
+       ~Vconf();
+
+       char *getString();
+       int getInt();
+       bool getBool();
+
+       void setString(const std::string &value);
+       void setInt(int value);
+       void setBool(bool value);
+
+       void addChangedCallback();
+       void removeChangedCallback();
+
+       Signal<> onKeyChanged;
+       std::string vconfKey;
+};
+
+#endif
index 3d7946c..9afa091 100644 (file)
@@ -52,10 +52,10 @@ void ODELaunchPad::onAppControl()
 
        switch (mode) {
        case Type::ENCRYPT_DEVICE:
-               /* TBD create interface */
+               interface = new EncryptDeviceInterface{};
                break;
        case Type::DECRYPT_DEVICE:
-               /* TBD create interface */
+               interface = new DecryptDeviceInterface{};
                break;
        case Type::ENCRYPT_SD_CARD:
                /* TBD create interface */
index 0fc2a77..afec1e2 100644 (file)
@@ -23,6 +23,8 @@
 
 #include "application.h"
 #include "interface/interface.h"
+#include "interface/internal/encrypt-device.h"
+#include "interface/internal/decrypt-device.h"
 
 class ODELaunchPad : public Application {
 public: