./src/external-encrypt/confirm.c
./src/external-decrypt/main.c
./src/external-decrypt/confirm.c)
+SET(REWORK_SRC
+ ./rework/main.cpp
+ ./rework/ode.cpp
+ ./rework/application.cpp
+ ./rework/interface/interface.cpp
+ ./rework/interface/page.cpp)
SET(WIDGET_SRC ./rework/widgets/widget.cpp
./rework/widgets/window.cpp
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIE")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
-ADD_EXECUTABLE(${PKG_NAME} ${PKG_SRC} ${WIDGET_SRC})
+ADD_EXECUTABLE(${PKG_NAME} ${REWORK_SRC} ${WIDGET_SRC})
INSTALL(TARGETS ${PKG_NAME} DESTINATION ${APP_INSTALL_PREFIX}/${PKG_NAME}/bin)
TARGET_LINK_LIBRARIES(${PKG_NAME} ${EFL_APP_LIBRARIES} ${tools_pkgs_LIBRARIES} ode)
--- /dev/null
+/*
+ *
+ * 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 "application.h"
+
+Application::Application(const std::string &name)
+ : packageName(name), appControl(nullptr)
+{
+}
+
+Application::~Application()
+{
+}
+
+bool Application::createDispatcher(void *data)
+{
+ Application *application = reinterpret_cast<Application *>(data);
+ return application->onCreate();
+}
+
+void Application::terminateDispatcher(void *data)
+{
+ Application *application = reinterpret_cast<Application *>(data);
+ return application->onTerminate();
+}
+
+void Application::pauseDispatcher(void *data)
+{
+ Application *application = reinterpret_cast<Application *>(data);
+ return application->onPause();
+}
+
+void Application::resumeDispatcher(void *data)
+{
+ Application *application = reinterpret_cast<Application *>(data);
+ return application->onResume();
+}
+
+void Application::appControlDispatcher(app_control_h app_control, void *data)
+{
+ Application *application = reinterpret_cast<Application *>(data);
+ application->appControl.reset(new AppControl {app_control});
+
+ return application->onAppControl();
+}
+
+void Application::languageChangedDispatcher(app_event_info_h event_info, void *user_data)
+{
+ int ret = 0;
+ char *locale = NULL;
+
+ ret = ::system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
+ if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
+ throw runtime::Exception("failed to get language");
+ }
+
+ ::elm_language_set(locale);
+ ::free(locale);
+}
+
+int Application::run(int argc, char *argv[])
+{
+ int ret = 0;
+ ui_app_lifecycle_callback_s event_callback = { 0, };
+ app_event_handler_h handlers[5] = { NULL, };
+
+ event_callback.create = createDispatcher;
+ event_callback.terminate = terminateDispatcher;
+ event_callback.pause = pauseDispatcher;
+ event_callback.resume = resumeDispatcher;
+ event_callback.app_control = appControlDispatcher;
+
+ try {
+ ::ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED],
+ APP_EVENT_LANGUAGE_CHANGED,
+ languageChangedDispatcher, NULL);
+
+ ret = ::ui_app_main(argc, argv, &event_callback, this);
+ if (ret != APP_ERROR_NONE)
+ throw runtime::Exception("app_main() is failed");
+ } catch (runtime::Exception &e) {
+ dlog_print(DLOG_ERROR, packageName.c_str(), "%s", e.what());
+ ::ui_app_exit();
+ }
+
+ return ret;
+}
+
+bool Application::onCreate()
+{
+ return true;
+}
+
+void Application::onTerminate()
+{
+}
+
+void Application::onPause()
+{
+}
+
+void Application::onResume()
+{
+}
+
+void Application::onAppControl()
+{
+}
--- /dev/null
+/*
+ *
+ * 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 __APPLICATION_H__
+#define __APPLICATION_H__
+
+#include <memory>
+
+#include <app.h>
+#include <app_common.h>
+#include <Elementary.h>
+#include <efl_util.h>
+
+#include <dlog.h>
+#include <system_info.h>
+#include <system_settings.h>
+#include <klay/exception.h>
+
+#include "widgets/appcontrol.h"
+
+class Application {
+public:
+ Application(const std::string &name);
+ virtual ~Application();
+
+ virtual int run(int argc, char *argv[]);
+protected:
+ virtual bool onCreate();
+ virtual void onResume();
+ virtual void onPause();
+ virtual void onTerminate();
+ virtual void onAppControl();
+
+protected:
+ std::string packageName;
+ std::unique_ptr<AppControl> appControl;
+
+private:
+ static bool createDispatcher(void *data);
+ static void resumeDispatcher(void *data);
+ static void pauseDispatcher(void *data);
+ static void terminateDispatcher(void *data);
+ static void appControlDispatcher(app_control_h app_control, void *data);
+ static void languageChangedDispatcher(app_event_info_h event_info, void *user_data);
+};
+
+#endif /*__APPLICATION_H__*/
--- /dev/null
+/*
+ *
+ * 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 <dlog.h>
+#include "interface.h"
+
+ODEInterface::ODEInterface()
+ : window(new ConformantWindow{"ode", ELM_WIN_BASIC}),
+ naviframe(nullptr),
+ base(nullptr)
+{
+ window->show();
+}
+
+ODEInterface::~ODEInterface()
+{
+ if (base)
+ delete base;
+ if (naviframe)
+ delete naviframe;
+ if (window)
+ delete window;
+}
+
+void ODEInterface::create()
+{
+}
+
+void ODEInterface::dispose()
+{
+ ::ui_app_exit();
+}
+
+void ODEInterface::setNaviframe()
+{
+ if (naviframe == nullptr)
+ naviframe = new Naviframe(window);
+
+ naviframe->show();
+ naviframe->setFocus(true);
+ naviframe->setAutoPrevButton(true);
+ window->setContent(naviframe);
+}
+
+void ODEInterface::setBaseLayout()
+{
+ if (base == nullptr)
+ base = new Layout(window);
+ window->setContent(base);
+}
+
+void ODEInterface::setFullContent(Widget *content)
+{
+ window->setIndicatorOpacity(ELM_WIN_INDICATOR_BG_TRANSPARENT);
+ window->setIndicatorOverlap(true);
+ window->setContent(content);
+}
+
+Widget *ODEInterface::getWindow()
+{
+ return window ? window : nullptr;
+}
--- /dev/null
+/*
+ *
+ * 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_INTERFACE_H__
+#define __ODE_INTERFACE_H__
+
+#include "../widgets/window.h"
+#include "../widgets/layout.h"
+#include "../language.h"
+#include "page.h"
+
+class ODEInterface {
+public:
+ ODEInterface();
+ virtual ~ODEInterface();
+
+ virtual void create();
+ virtual void dispose();
+
+ void setBaseLayout();
+ void setFullContent(Widget *content);
+
+ Widget *getWindow();
+
+protected:
+ void setNaviframe();
+
+ Window *window;
+ Naviframe *naviframe;
+ Layout *base;
+};
+#endif
--- /dev/null
+/*
+ *
+ * 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 "dlog.h"
+#include "page.h"
+
+Page::Page(Widget *parent, const std::string &name, int type)
+ : Layout(parent), nextButton(nullptr), prevButton(nullptr), content(nullptr), bottom(nullptr)
+{
+ setEDJPath("org.tizen.ode.edj");
+ setFile(edjFile, "base_layout");
+ initialize(name, type);
+ show();
+}
+
+Page::~Page()
+{
+}
+
+void Page::setEDJPath(const std::string &name)
+{
+ char *resPath = nullptr;
+ resPath = ::app_get_resource_path();
+ if (resPath) {
+ edjFile.append(resPath);
+ edjFile.append("/");
+ edjFile.append(name);
+ }
+ ::free(resPath);
+}
+
+void Page::initialize(const std::string &name, int type)
+{
+ content.reset(new Layout(this));
+ content->setFile(edjFile, name);
+ setContent("content_layout", content.get());
+
+ bottom.reset(new Layout(this));
+
+ if (type & Type::SetOneButton) {
+ bottom->setFile(edjFile, "next_button_layout");
+ } else if (type & Type::SetTwoButton) {
+ bottom->setFile(edjFile, "two_button_layout");
+ }
+ setContent("bottom_layout", bottom.get());
+
+ nextButton.reset(new Button(this));
+ nextButton->setText(dgetText("IDS_ST_BUTTON_NEXT"));
+ nextButton->setStyle("bottom");
+ bottom->setContent("next_button", nextButton.get());
+
+ if (type & Type::SetTwoButton) {
+ prevButton.reset(new Button(this));
+ prevButton->setText(dgetText("IDS_ST_BUTTON_BACK"));
+ prevButton->setStyle("bottom");
+ bottom->setContent("prev_button", prevButton.get());
+ }
+}
+
+void Page::setPartContent()
+{
+}
--- /dev/null
+/*
+ *
+ * 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_PAGE_H__
+#define __ODE_PAGE_H__
+
+#include <memory>
+#include <vector>
+
+#include "../widgets/signal.h"
+#include "../widgets/layout.h"
+#include "../widgets/button.h"
+#include "../widgets/naviframe.h"
+#include "../language.h"
+
+class Page : public Layout {
+public:
+ enum Type {
+ SetOneButton = (1 << 0),
+ SetTwoButton = (1 << 1),
+ };
+
+ Page(Widget *parent, const std::string &name, int type);
+ virtual ~Page();
+
+public:
+ std::unique_ptr<Button> nextButton;
+ std::unique_ptr<Button> prevButton;
+protected:
+ void setEDJPath(const std::string &name);
+ virtual void setPartContent(void);
+protected:
+ std::unique_ptr<Layout> content;
+ std::unique_ptr<Layout> bottom;
+ std::string edjFile;
+private:
+ void initialize(const std::string &name, int type);
+};
+
+#endif
--- /dev/null
+/*
+ *
+ * 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_LANGUAGE_H__
+#define __ODE_LANGUAGE_H__
+
+const std::string moFile("ode");
+
+inline char *dgetText(const std::string &text)
+{
+ return ::dgettext(moFile.c_str(), text.c_str());
+}
+
+template <typename ...Args>
+std::string formatString(const std::string &format, Args &&...args)
+{
+ char buff[PATH_MAX] = "";
+ snprintf(buff, sizeof(buff), dgetText(format), std::forward<Args>(args)...);
+ return buff;
+}
+
+#endif
--- /dev/null
+/*
+ *
+ * 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 "ode.h"
+
+int main(int argc, char *argv[])
+{
+ std::unique_ptr<Application> application;
+ char *name = nullptr;
+
+ name = strrchr(argv[0], '/');
+ name = name ? name + 1 : argv[0];
+
+ if (!strcmp(name, "ode")) {
+ application.reset(new ODEStandAlone{});
+ } else {
+ application.reset(new ODELaunchPad{});
+ }
+
+ return application->run(argc, argv);
+}
--- /dev/null
+/*
+ *
+ * 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 <dlog.h>
+#include "ode.h"
+
+ODELaunchPad::ODELaunchPad()
+ : Application("org.tizen.ode"), viewtype(""), mode(0), interface(nullptr)
+{
+}
+
+ODELaunchPad::~ODELaunchPad()
+{
+}
+
+int ODELaunchPad::getMode(const std::string &type)
+{
+ if (!type.compare("ENCRYPT_DEVICE")) {
+ return Type::ENCRYPT_DEVICE;
+ } else if (!type.compare("DECRYPT_DEVICE")) {
+ return Type::DECRYPT_DEVICE;
+ } else if (!type.compare("ENCRYPT_SD_CARD")) {
+ return Type::ENCRYPT_SD_CARD;
+ } else if (!type.compare("DECRYPT_SD_CARD")) {
+ return Type::DECRYPT_SD_CARD;
+ } else if (!type.compare("INSERT_SD_CARD")) {
+ return Type::INSERT_SD_CARD;
+ } else if (!type.compare("SD_CARD_PASSWORD")) {
+ return Type::SD_CARD_PASSWORD;
+ }
+ return Type::DO_NOT_SUPPORTED;
+}
+
+void ODELaunchPad::onAppControl()
+{
+ viewtype = appControl->getData("viewtype");
+ mode = getMode(viewtype);
+
+ switch (mode) {
+ case Type::ENCRYPT_DEVICE:
+ /* TBD create interface */
+ break;
+ case Type::DECRYPT_DEVICE:
+ /* TBD create interface */
+ break;
+ case Type::ENCRYPT_SD_CARD:
+ /* TBD create interface */
+ break;
+ case Type::DECRYPT_SD_CARD:
+ /* TBD create interface */
+ break;
+ case Type::INSERT_SD_CARD:
+ /* TBD create interface */
+ break;
+ case Type::SD_CARD_PASSWORD:
+ /* TBD create interface */
+ break;
+ default:
+ throw runtime::Exception("Do not supported viewtype");
+ break;
+ }
+
+ if (interface)
+ interface->create();
+}
+
+void ODELaunchPad::onTerminate()
+{
+ if (interface) {
+ delete interface;
+ }
+}
+
+ODEStandAlone::ODEStandAlone()
+ : Application("ode"), interface(nullptr)
+{
+}
+
+ODEStandAlone::~ODEStandAlone()
+{
+}
+
+void ODEStandAlone::createProgressInterface(const std::string &type, const std::string &target)
+{
+ if (!type.compare("Encrypting") && !target.compare("External")) {
+ /* TBD create interface */
+ } else if (!type.compare("Decrypting") && !target.compare("External")) {
+ /* TBD create interface */
+ } else if (!type.compare("Encrypting") && !target.compare("Internal")) {
+ /* TBD create interface */
+ } else {
+ /* TBD create interface */
+ }
+}
+
+int ODEStandAlone::run(int argc, char *argv[])
+{
+ char *lang = nullptr;
+ ::setenv("HOME", "/opt/home/root", 1);
+ if (argc < 2) {
+ return -1;
+ }
+
+ lang = ::vconf_get_str(VCONFKEY_LANGSET);
+ ::setlocale(LC_ALL, lang);
+ if (lang) {
+ ::free(lang);
+ }
+ ::bindtextdomain("ode", "/usr/apps/org.tizen.ode/res/locale");
+
+ ::elm_init(argc, argv);
+ ::elm_scale_set(1.8);
+ if (!strncmp(argv[1], "progress", sizeof("progress"))) {
+ if (argc < 4) {
+ return -1;
+ }
+ createProgressInterface(argv[2], argv[3]);
+ }
+
+ ::elm_run();
+ return EXIT_SUCCESS;
+}
--- /dev/null
+/*
+ *
+ * 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_APPLICATION_H__
+#define __ODE_APPLICATION_H__
+
+#include <vconf.h>
+
+#include "application.h"
+#include "interface/interface.h"
+
+class ODELaunchPad : public Application {
+public:
+ enum Type {
+ ENCRYPT_DEVICE = 1,
+ DECRYPT_DEVICE,
+ ENCRYPT_SD_CARD,
+ DECRYPT_SD_CARD,
+ INSERT_SD_CARD,
+ SD_CARD_PASSWORD,
+ DO_NOT_SUPPORTED,
+ };
+
+ ODELaunchPad();
+ ~ODELaunchPad();
+
+ void onAppControl();
+ void onTerminate();
+
+private:
+ int getMode(const std::string &type);
+ std::string viewtype;
+ int mode;
+ ODEInterface *interface;
+};
+
+class ODEStandAlone : public Application {
+public:
+ ODEStandAlone();
+ ~ODEStandAlone();
+
+ int run(int argc, char *argv[]);
+ void createProgressInterface(const std::string &type, const std::string &target);
+private:
+ std::unique_ptr<ODEInterface> interface;
+};
+
+#endif
void setConfig(int config);
void setNotificationLevel(efl_util_notification_level_e level);
void setIndicatorOpacity(Elm_Win_Indicator_Opacity_Mode mode);
+ virtual void setIndicatorOverlap(bool set) = 0;
void resize(Widget *widget);
protected: