Add UI Application for show progress of encrypt/decrypt 84/99284/6
authorSungbae Yoo <sungbae.yoo@samsung.com>
Tue, 22 Nov 2016 09:16:51 +0000 (18:16 +0900)
committerSungbae Yoo <sungbae.yoo@samsung.com>
Thu, 1 Dec 2016 04:47:30 +0000 (13:47 +0900)
Change-Id: I4755d56139507b1260b0ea627b36f5b2a5750978
Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
23 files changed:
packaging/ode.spec
server/CMakeLists.txt
server/app-bundle.cpp [new file with mode: 0644]
server/app-bundle.h [new file with mode: 0644]
server/external-encryption.cpp
server/internal-encryption.cpp
server/launchpad.cpp [new file with mode: 0644]
server/launchpad.h [new file with mode: 0644]
server/systemd/ode.service.in
tools/CMakeLists.txt
tools/apps/CMakeLists.txt [new file with mode: 0755]
tools/apps/ode/CMakeLists.txt [new file with mode: 0644]
tools/apps/ode/include/ode.h [new file with mode: 0644]
tools/apps/ode/include/text.h [new file with mode: 0644]
tools/apps/ode/include/widget.h [new file with mode: 0644]
tools/apps/ode/org.tizen.ode-gui.manifest [new file with mode: 0644]
tools/apps/ode/org.tizen.ode-gui.xml [new file with mode: 0644]
tools/apps/ode/res/edje/org.tizen.ode-gui.edc [new file with mode: 0644]
tools/apps/ode/res/edje/progress.edc [new file with mode: 0644]
tools/apps/ode/res/images/icon.png [new file with mode: 0644]
tools/apps/ode/src/main.c [new file with mode: 0644]
tools/apps/ode/src/ui.c [new file with mode: 0644]
tools/apps/ode/src/widget.c [new file with mode: 0644]

index 3a734a3..30b3323 100644 (file)
@@ -11,7 +11,8 @@ BuildRequires: cmake
 BuildRequires: gettext-tools
 BuildRequires: pkgconfig(klay)
 BuildRequires: pkgconfig(glib-2.0)
-BuildRequires: pkgconfig(libxml-2.0)
+BuildRequires: pkgconfig(aul)
+BuildRequires: pkgconfig(bundle)
 BuildRequires: pkgconfig(libtzplatform-config)
 BuildRequires: pkgconfig(key-manager)
 BuildRequires: pkgconfig(cynara-client)
@@ -44,7 +45,9 @@ The ode package provides a daemon which is responsible for encrypting/decryption
          -DCMAKE_BUILD_TYPE=%{build_type} \
          -DRUN_DIR=%{TZ_SYS_RUN} \
          -DBIN_DIR=%{TZ_SYS_BIN} \
-         -DSYSTEMD_UNIT_DIR=%{_unitdir}
+         -DSYSTEMD_UNIT_DIR=%{_unitdir} \
+         -DAPP_INSTALL_PREFIX="%{TZ_SYS_RO_APP}" \
+         -DAPP_SHARE_PACKAGES_DIR="%{TZ_SYS_RO_PACKAGES}"
 
 make %{?jobs:-j%jobs}
 
@@ -111,3 +114,30 @@ developing device encryption client program.
 %manifest ode.manifest
 %defattr(644,root,root,755)
 %attr(755,root,root) %{_bindir}/ode-engine-unit-tests
+
+## ODE App package #############################################################
+%package -n org.tizen.ode-gui
+Summary: Tizen ODE User Interface
+Group: Security/Other
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(evas)
+BuildRequires: pkgconfig(elementary)
+BuildRequires: pkgconfig(efl-extension)
+BuildRequires: pkgconfig(capi-ui-efl-util)
+BuildRequires: pkgconfig(capi-appfw-app-control)
+BuildRequires: pkgconfig(capi-appfw-application)
+
+%description -n org.tizen.ode-gui
+Tizen ODE User Interface for device policy management
+
+%define odeapp_home %{TZ_SYS_RO_APP}/org.tizen.ode-gui
+
+%post -n org.tizen.ode-gui
+ln -sf %{odeapp_home}/bin/org.tizen.ode-gui /usr/bin/ode-gui
+
+%files -n org.tizen.ode-gui
+%defattr(-,root,root,-)
+%{odeapp_home}/bin/*
+%{odeapp_home}/res/*
+%{TZ_SYS_RO_PACKAGES}/org.tizen.ode-gui.xml
index e32abb2..7287295 100644 (file)
@@ -15,7 +15,9 @@
 #
 SET(SERVER_SRCS        main.cpp
                                server.cpp
+                               launchpad.cpp
                                ext4-tool.cpp
+                               app-bundle.cpp
                                secure-erase.cpp
                                block-device.cpp
                                internal-encryption.cpp
@@ -31,7 +33,8 @@ SET(SERVER_SRCS       main.cpp
 SET(DEPENDENCY klay
                                glib-2.0
                                gio-2.0
-                               libxml-2.0
+                               aul
+                               bundle
                                libtzplatform-config
                                cynara-client
                                cynara-session
diff --git a/server/app-bundle.cpp b/server/app-bundle.cpp
new file mode 100644 (file)
index 0000000..e4e9ea9
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ *  Copyright (c) 2015 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 <memory>
+
+#include <klay/exception.h>
+
+#include "app-bundle.h"
+
+AppBundle::AppBundle() :
+       handle(nullptr)
+{
+       handle = ::bundle_create();
+       if (handle == nullptr) {
+               throw runtime::Exception("Failed to create bundle");
+       }
+}
+
+AppBundle::~AppBundle()
+{
+       ::bundle_free(handle);
+}
+
+void AppBundle::addInternal(const std::string& key, const std::string& value)
+{
+       ::bundle_add_str(handle, key.c_str(), value.c_str());
+}
+
+void AppBundle::addArrayInternal(const std::string& key, const std::vector<std::string>& array)
+{
+       std::unique_ptr<const char*[]> arrayptr(new const char*[array.size()]);
+
+       int index = 0;
+       for (const std::string& data : array) {
+               arrayptr.get()[index++] = data.c_str();
+       }
+
+       ::bundle_add_str_array(handle, key.c_str(), arrayptr.get(), array.size());
+}
diff --git a/server/app-bundle.h b/server/app-bundle.h
new file mode 100644 (file)
index 0000000..09fb8c8
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ *  Copyright (c) 2015 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 __DPM_APP_BUNDLE_H__
+#define __DPM_APP_BUNDLE_H__
+
+#include <string>
+#include <vector>
+
+#include <bundle.h>
+
+class AppBundle {
+public:
+       AppBundle();
+       ~AppBundle();
+
+       template<typename T>
+       void add(const std::string& key, const std::vector<T>& value)
+       {
+               addArrayInternal(key, value);
+       }
+
+       template<typename T>
+       void add(const std::string& key, const T& value)
+       {
+               addInternal(key, value);
+       }
+
+       bundle* get() const
+       {
+               return handle;
+       }
+
+private:
+       void addInternal(const std::string& key, const std::string& value);
+       void addArrayInternal(const std::string& key, const std::vector<std::string>& array);
+
+private:
+       bundle* handle;
+};
+
+#endif //__DPM_APP_BUNDLE_H__
index 870ca38..0904773 100644 (file)
@@ -22,6 +22,8 @@
 #include <klay/filesystem.h>
 #include <klay/audit/logger.h>
 
+#include "launchpad.h"
+#include "app-bundle.h"
 #include "engine/ecryptfs-engine.h"
 #include "key-manager/key-manager.h"
 
@@ -45,6 +47,16 @@ void killDependedApplications()
        }
 }
 
+void showProgressUI(const std::string type) {
+       AppBundle bundle;
+       bundle.add("mode", "progress");
+       bundle.add("type", type);
+       bundle.add("target", "SD card encryption");
+
+       Launchpad launchpad(::tzplatform_getuid(TZ_SYS_DEFAULT_USER));
+       launchpad.launch("org.tizen.ode-gui", bundle);
+}
+
 }
 
 ExternalEncryption::ExternalEncryption(ODEControlContext& ctx) :
@@ -109,6 +121,8 @@ int ExternalEncryption::encrypt(const std::string& password)
 
        KeyManager::data DEK = keyManager.getDEK(pwData);
        auto encryptWorker = [DEK, this]() {
+               showProgressUI("Encrypting");
+
                INFO("Close all applications using external storage...");
                killDependedApplications();
                INFO("Encryption started...");
@@ -139,6 +153,8 @@ int ExternalEncryption::decrypt(const std::string& password)
 
        KeyManager::data DEK = keyManager.getDEK(pwData);
        auto decryptWorker = [DEK, this]() {
+               showProgressUI("Decrypting");
+
                INFO("Close all applications using external storage...");
                killDependedApplications();
                INFO("Umount internal storage...");
index 3a217fc..d6979df 100644 (file)
@@ -20,6 +20,7 @@
 #include <sys/mount.h>
 #include <sys/reboot.h>
 
+#include <klay/process.h>
 #include <klay/file-user.h>
 #include <klay/filesystem.h>
 #include <klay/dbus/connection.h>
@@ -70,6 +71,15 @@ void stopDependedSystemdServices()
        }
 }
 
+void showProgressUI(const std::string type) {
+       std::vector<std::string> args = {
+               "ode-gui", "progress", type, "Internal storage encryption"
+       };
+
+       runtime::Process proc("/usr/bin/ode-gui", args);
+       proc.execute();
+}
+
 }
 
 InternalEncryption::InternalEncryption(ODEControlContext& ctx) :
@@ -133,6 +143,8 @@ int InternalEncryption::encrypt(const std::string& password)
 
        KeyManager::data DEK = keyManager.getDEK(pwData);
        auto encryptWorker = [DEK, this]() {
+               showProgressUI("Encrypting");
+
                INFO("Close all processes using internal storage...");
                stopDependedSystemdServices();
                INFO("Umount internal storage...");
@@ -141,6 +153,7 @@ int InternalEncryption::encrypt(const std::string& password)
                                break;
                        }
                }
+
                INFO("Encryption started...");
                engine.encrypt(DEK);
                INFO("Sync disk...");
@@ -170,12 +183,15 @@ int InternalEncryption::decrypt(const std::string& password)
 
        KeyManager::data DEK = keyManager.getDEK(pwData);
        auto decryptWorker = [DEK, this]() {
+               showProgressUI("Decrypting");
+
                INFO("Close all processes using internal storage...");
                stopDependedSystemdServices();
                INFO("Umount internal storage...");
                try {
                        engine.umount();
                } catch (runtime::Exception& e) {}
+
                INFO("Decryption started...");
                engine.decrypt(DEK);
                INFO("Sync disk...");
diff --git a/server/launchpad.cpp b/server/launchpad.cpp
new file mode 100644 (file)
index 0000000..27d47e2
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ *  Copyright (c) 2015 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 <unistd.h>
+#include <signal.h>
+#include <sys/types.h>
+
+#include <aul.h>
+#include <klay/exception.h>
+#include <klay/audit/logger.h>
+
+#include "launchpad.h"
+
+Launchpad::Launchpad(const uid_t uid) :
+       user(uid)
+{
+       if (user == 0) {
+               throw runtime::Exception("No logined user for launching app");
+       }
+}
+
+bool Launchpad::isRunning(const std::string& appid)
+{
+       return ::aul_app_is_running_for_uid(appid.c_str(), user);
+}
+
+void Launchpad::launch(const std::string& appid)
+{
+       launch(appid, AppBundle());
+}
+
+void Launchpad::launch(const std::string& appid, const AppBundle& bundle)
+{
+       if (::aul_launch_app_for_uid(appid.c_str(), bundle.get(), user) < 0) {
+               throw runtime::Exception("Failed to launch app " + appid);
+       }
+}
+
+void Launchpad::resume(const std::string& appid)
+{
+       if (::aul_resume_app_for_uid(appid.c_str(), user) < 0) {
+               throw runtime::Exception("Failed to resume app " + appid);
+       }
+}
+
+void Launchpad::terminate(const std::string& appid)
+{
+       int pid = ::aul_app_get_pid_for_uid(appid.c_str(), user);
+       if (pid > 0) {
+               if (::aul_terminate_pid_for_uid(pid, user) < 0) {
+                       WARN("Failed to terminate app PID=" + std::to_string(pid));
+                       ::kill(pid, SIGKILL);
+               }
+       }
+}
diff --git a/server/launchpad.h b/server/launchpad.h
new file mode 100644 (file)
index 0000000..3726ee3
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ *  Copyright (c) 2015 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 __DPM_LAUNCHPAD_H__
+#define __DPM_LAUNCHPAD_H__
+
+#include <string>
+
+#include "app-bundle.h"
+
+class Launchpad {
+public:
+       Launchpad(const uid_t uid = 0);
+       Launchpad(const Launchpad&) = delete;
+       Launchpad(Launchpad&&) = delete;
+
+       void launch(const std::string& appid);
+       void launch(const std::string& appid, const AppBundle& bundle);
+       void resume(const std::string& appid);
+       bool isRunning(const std::string& appid);
+       void terminate(const std::string& appid);
+
+private:
+       uid_t user;
+};
+
+#endif //__DPM_LAUNCHPAD_H__
index 922e17c..152ba0e 100644 (file)
@@ -10,6 +10,8 @@ ExecReload=/bin/kill -HUP $MAINPID
 CapabilityBoundingSet=~CAP_MAC_ADMIN
 CapabilityBoundingSet=~CAP_MAC_OVERRIDE
 CapabilityBoundingSet=~CAP_DAC_OVERRIDE
+EnvironmentFile=/run/tizen-system-env
+EnvironmentFile=/run/xdg-root-env
 
 [Install]
 WantedBy=multi-user.target
index 9262bb2..9ae73bf 100755 (executable)
@@ -14,8 +14,8 @@
 # limitations under the License.
 #
 
-#SET(ODE_APPS  ${ODE_TOOLS}/apps)
+SET(ODE_APPS  ${ODE_TOOLS}/apps)
 SET(ODE_CLI  ${ODE_TOOLS}/cli)
 
-#ADD_SUBDIRECTORY(${ODE_APPS})
+ADD_SUBDIRECTORY(${ODE_APPS})
 ADD_SUBDIRECTORY(${ODE_CLI})
diff --git a/tools/apps/CMakeLists.txt b/tools/apps/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..041c9ca
--- /dev/null
@@ -0,0 +1,31 @@
+#
+# Copyright (c) 2016 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.
+#
+
+FIND_PACKAGE(PkgConfig REQUIRED)
+PKG_CHECK_MODULES(EFL_APP REQUIRED
+               dlog
+               glib-2.0
+               bundle
+               efl-extension
+               elementary
+               capi-appfw-application
+               capi-ui-efl-util
+               evas
+)
+
+SET(ODE_APPS_ODE       ${ODE_APPS}/ode)
+
+ADD_SUBDIRECTORY(${ODE_APPS_ODE})
diff --git a/tools/apps/ode/CMakeLists.txt b/tools/apps/ode/CMakeLists.txt
new file mode 100644 (file)
index 0000000..c5d8aa1
--- /dev/null
@@ -0,0 +1,30 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(org.tizen.ode-gui C)
+
+INCLUDE_DIRECTORIES(${EFL_APP_INCLUDE_DIRS} ${ODE_LIB} include)
+LINK_DIRECTORIES(${EFL_APP_LIBRARY_DIRS})
+
+SET(APP_SRCS
+       src/main.c
+       src/ui.c
+       src/widget.c
+)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIE")
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${APP_SRCS})
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${APP_INSTALL_PREFIX}/${PROJECT_NAME}/bin)
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${EFL_APP_LIBRARIES} ode)
+
+ADD_CUSTOM_TARGET(${PROJECT_NAME}.edj
+       COMMAND edje_cc -no-save -id ${CMAKE_CURRENT_SOURCE_DIR}/res/images
+       ${CMAKE_CURRENT_SOURCE_DIR}/res/edje/${PROJECT_NAME}.edc
+       ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.edj
+       DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/res/edje/${PROJECT_NAME}.edc)
+
+ADD_DEPENDENCIES(${PROJECT_NAME} ${PROJECT_NAME}.edj)
+INSTALL(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.edj DESTINATION ${APP_INSTALL_PREFIX}/${PROJECT_NAME}/res)
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.xml DESTINATION ${APP_SHARE_PACKAGES_DIR})
diff --git a/tools/apps/ode/include/ode.h b/tools/apps/ode/include/ode.h
new file mode 100644 (file)
index 0000000..64dada7
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Tizen Krate Setup-Wizard application
+ *
+ * Copyright (c) 2016 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_H__
+#define __ODE_H__
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include <app.h>
+#include <app_common.h>
+#include <bundle.h>
+#include <dlog.h>
+#include <Elementary.h>
+#include <efl_extension.h>
+
+#include "text.h"
+
+#ifdef  LOG_TAG
+#undef  LOG_TAG
+#endif
+#define LOG_TAG "ODE"
+
+#if !defined(PACKAGE)
+#define PACKAGE "org.tizen.ode-gui"
+#endif
+
+void _create_base_window();
+void _create_progress_view(const char *type, const char *target);
+
+#endif /* __ODE_H__ */
diff --git a/tools/apps/ode/include/text.h b/tools/apps/ode/include/text.h
new file mode 100644 (file)
index 0000000..82574ca
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Tizen Krate Setup-Wizard application
+ *
+ * Copyright (c) 2016 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 __TEXT_H__
+#define __TEXT_H__
+
+#define SUB_TITLE_STYLE_B "DEFAULT='font=Tizen:style=Regular font_size=50 color=#000000 wrap=mixed align=center'"
+#define SUB_CONTENT_STYLE_B "DEFAULT='font=Tizen:style=Regular font_size=36 color=#000000 wrap=mixed'"
+
+#define SUB_TITLE_STYLE_W "DEFAULT='font=Tizen:style=Regular font_size=50 color=#ffffff wrap=mixed align=center'"
+#define SUB_CONTENT_STYLE_W "DEFAULT='font=Tizen:style=Regular font_size=36 color=#ffffff wrap=mixed'"
+
+#define ENTRY_TITLE_STYLE_B "DEFAULT='font=Tizen:style=Regular font_size=36 color=#000000 wrap=mixed'"
+#define ENTRY_INFO_STYLE_G "DEFAULT='font=Tizen:style=Regular font_size=32 color=#A9A9A9 wrap=mixed'"
+
+#define PROGRESS_MESSAGE_TITLE "%s..."
+#define PROGRESS_MESSAGE_CONTENT "Wait until %s is completed."
+
+#endif /*__TEXT_H__*/
diff --git a/tools/apps/ode/include/widget.h b/tools/apps/ode/include/widget.h
new file mode 100644 (file)
index 0000000..c38ab49
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Tizen Krate Setup-Wizard application
+ *
+ * Copyright (c) 2016 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 WIDGET_H_
+#define WIDGET_H_
+
+#include <app.h>
+#include <dlog.h>
+#include <Elementary.h>
+#include <efl_extension.h>
+
+Evas_Object *_create_win(const char *package);
+Evas_Object *_create_conformant(Evas_Object *parent);
+Evas_Object *_create_layout(Evas_Object *parent, char *file, const char *group);
+Evas_Object *_create_button(Evas_Object *parent, const char *text, Evas_Smart_Cb callback, void *user_data);
+Evas_Object *_create_textblock(Evas_Object *parent, const char *text, char *style);
+Evas_Object *_create_progressbar(Evas_Object *parent, const char *style);
+
+#endif /* WIDGET_H_ */
diff --git a/tools/apps/ode/org.tizen.ode-gui.manifest b/tools/apps/ode/org.tizen.ode-gui.manifest
new file mode 100644 (file)
index 0000000..a76fdba
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_" />
+       </request>
+</manifest>
diff --git a/tools/apps/ode/org.tizen.ode-gui.xml b/tools/apps/ode/org.tizen.ode-gui.xml
new file mode 100644 (file)
index 0000000..2713a6e
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<manifest xmlns="http://tizen.org/ns/packages" api-version="3.0" package="org.tizen.ode-gui" version="1.0.0">
+       <profile name="mobile"/>
+       <privileges>
+       </privileges>
+       <ui-application appid="org.tizen.ode-gui" exec="/usr/apps/org.tizen.ode-gui/bin/org.tizen.ode-gui" multiple="false" nodisplay="false" taskmanage="true" type="capp">
+               <label>ODE</label>
+       </ui-application>
+</manifest>
diff --git a/tools/apps/ode/res/edje/org.tizen.ode-gui.edc b/tools/apps/ode/res/edje/org.tizen.ode-gui.edc
new file mode 100644 (file)
index 0000000..0eec6d2
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2016 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.
+ *
+ */
+
+collections {
+       base_scale: 1.8;
+       #include "progress.edc"
+}
diff --git a/tools/apps/ode/res/edje/progress.edc b/tools/apps/ode/res/edje/progress.edc
new file mode 100644 (file)
index 0000000..ba4efaa
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * Tizen Krate Setup-Wizard Layout
+ *
+ * Copyright (c) 2016 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 { name: "progress_layout";
+       parts {
+               part { name: "bg1";
+                       type: RECT;
+                       scale: 1;
+                       description { state: "default" 0.0;
+                               color: 55 166 184 255;
+                               rel1 { relative: 0.0 0.0; }
+                               rel2 { relative: 1.0 1.0; }
+                       }
+               }
+               part { name: "bg2";
+                       type: RECT;
+                       scale: 1;
+                       description { state: "default" 0.0;
+                               color: 0 0 0 25;
+                               rel1 { relative: 0.0 0.0; to: "bg1";}
+                               rel2 { relative: 1.0 1.0; to: "bg1";}
+                       }
+               }
+               part { name: "bg_top_padding";
+                       type: SPACER;
+                       scale: 1;
+                       description { state: "default" 0.0;
+                               rel1 {relative: 0.0 0.0; to: "bg1";}
+                               rel2 {relative: 1.0 0.0; to: "bg1"; offset: 0 160;}
+                       }
+               }
+               part { name: "message_title";
+                       type: SWALLOW;
+                       scale: 1;
+                       description { state: "default" 0.0;
+                               rel1 { relative: 0.0 1.0; to: "bg_top_padding"; offset: 32 0;}
+                               rel2 { relative: 1.0 1.0; to: "bg_top_padding"; offset: -32 67;}
+                       }
+               }
+               part { name: "message_top_padding";
+                       type: SPACER;
+                       scale: 1;
+                       description { state: "default" 0.0;
+                               rel1 { relative: 0.0 1.0; to: "message_title";}
+                               rel2 { relative: 1.0 1.0; to: "message_title"; offset: 0 42;}
+                       }
+               }
+               part { name: "progress_area";
+                       type: SPACER;
+                       scale: 1;
+                       description { state: "default" 0.0;
+                               rel1 { relative: 0.0 1.0; to: "message_top_padding";}
+                               rel2 { relative: 1.0 1.0; to: "message_top_padding"; offset: 0 114;}
+                       }
+               }
+               part { name: "progress_top_padding";
+                       type: SPACER;
+                       scale: 1;
+                       description { state: "default" 0.0;
+                               rel1 { relative: 0.0 0.0; to: "progress_area";}
+                               rel2 { relative: 1.0 0.0; to: "progress_area"; offset: 0 66;}
+                       }
+               }
+               part { name: "progress_indicator";
+                       type: SWALLOW;
+                       scale: 1;
+                       description { state: "default" 0.0;
+                               rel1 { relative: 0.0 1.0; to: "progress_top_padding";}
+                               rel2 { relative: 1.0 1.0; to: "progress_top_padding"; offset: 0 48;}
+                       }
+               }
+               part { name: "progress_bottom_padding";
+                       type: SPACER;
+                       scale: 1;
+                       description { state: "default" 0.0;
+                               rel1 { relative: 0.0 1.0; to: "progress_area";}
+                               rel2 { relative: 1.0 1.0; to: "progress_area"; offset: 0 49;}
+                       }
+               }
+               part { name: "message_content";
+                       type: SWALLOW;
+                       scale: 1;
+                       description { state: "default" 0.0;
+                               rel1 { relative: 0.0 1.0; to: "progress_bottom_padding";}
+                               rel2 { relative: 1.0 1.0; to: "progress_bottom_padding"; offset: 0 208;}
+                       }
+               }
+       }
+}
diff --git a/tools/apps/ode/res/images/icon.png b/tools/apps/ode/res/images/icon.png
new file mode 100644 (file)
index 0000000..ea3a791
Binary files /dev/null and b/tools/apps/ode/res/images/icon.png differ
diff --git a/tools/apps/ode/src/main.c b/tools/apps/ode/src/main.c
new file mode 100644 (file)
index 0000000..8fad1a9
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+ * Tizen Krate Setup-Wizard application
+ *
+ * Copyright (c) 2016 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 launchpad_main(int argc, char *argv[]);
+int standalone_main(int argc, char *argv[]);
+
+struct submain {
+       const char* name;
+       int (*main)(int argc, char* argv[]);
+} submains[] = {
+       {
+               .name = PACKAGE,
+               .main = launchpad_main
+       },
+       {
+               .name = "ode-gui",
+               .main = standalone_main
+       },
+};
+
+static bool __app_create(void *data)
+{
+       return true;
+}
+
+static void __app_pause(void *data)
+{
+}
+
+static void __app_resume(void *data)
+{
+}
+
+static void __app_terminate(void *data)
+{
+}
+
+static void __app_control(app_control_h app_control, void *data)
+{
+       char *mode;
+       int ret = 0;
+
+       ret = app_control_get_extra_data(app_control, "mode", &mode);
+       if (ret != APP_CONTROL_ERROR_NONE) {
+               dlog_print(DLOG_ERROR, LOG_TAG, "Failed to get mode");
+               ui_app_exit();
+               return;
+       }
+
+       _create_base_window();
+
+       if (!strncmp(mode, "progress", sizeof("progress"))) {
+               char *type, *target;
+
+               ret = app_control_get_extra_data(app_control, "type", &type);
+               if (ret != APP_CONTROL_ERROR_NONE) {
+                       dlog_print(DLOG_ERROR, LOG_TAG, "Failed to get type");
+                       ui_app_exit();
+                       return;
+               }
+               ret = app_control_get_extra_data(app_control, "target", &target);
+               if (ret != APP_CONTROL_ERROR_NONE) {
+                       dlog_print(DLOG_ERROR, LOG_TAG, "Failed to get target");
+                       ui_app_exit();
+                       return;
+               }
+               _create_progress_view(type, target);
+       }
+}
+
+int launchpad_main(int argc, char *argv[])
+{
+       int ret = 0;
+
+       ui_app_lifecycle_callback_s event_callback = {0, };
+
+       event_callback.create = __app_create;
+       event_callback.terminate = __app_terminate;
+       event_callback.pause = __app_pause;
+       event_callback.resume = __app_resume;
+       event_callback.app_control = __app_control;
+
+       ret = ui_app_main(argc, argv, &event_callback, NULL);
+       if (ret != APP_ERROR_NONE)
+               dlog_print(DLOG_ERROR, LOG_TAG, "ui_app_main is failed. err = %d", ret);
+
+       return ret;
+}
+
+int standalone_main(int argc, char *argv[])
+{
+       setenv("HOME", "/root", 1);
+
+       if (argc <2) {
+               fprintf(stderr, "Other arguments is needed\n");
+               return EXIT_FAILURE;
+       }
+
+       elm_init(argc, argv);
+       _create_base_window();
+
+       if (!strncmp(argv[1], "progress", sizeof("progress"))) {
+               if (argc < 4) {
+                       fprintf(stderr, "Other arguments is needed\n");
+                       return EXIT_FAILURE;
+               }
+               _create_progress_view(argv[2], argv[3]);
+       }
+
+       elm_run();
+
+       return EXIT_SUCCESS;
+}
+
+int main(int argc, char* argv[])
+{
+       char *name = strrchr(argv[0], '/');
+       int i;
+
+       name = name ? name + 1 : argv[0];
+
+       for (i = 0; i < sizeof(submains) / sizeof(struct submain); i++) {
+               if (strcmp(name, submains[i].name) == 0) {
+                   return submains[i].main(argc, argv);
+               }
+       }
+
+       return EXIT_FAILURE;
+}
diff --git a/tools/apps/ode/src/ui.c b/tools/apps/ode/src/ui.c
new file mode 100644 (file)
index 0000000..1c1bf07
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Tizen Krate Setup-Wizard application
+ *
+ * Copyright (c) 2016 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"
+#include "widget.h"
+
+#define EDJ_PATH "/usr/apps/" PACKAGE "/res/" PACKAGE ".edj"
+
+static Evas_Object *win, *conform, *layout;
+
+void _create_base_window()
+{
+       /* Create main UI widget */
+       win = _create_win(PACKAGE);
+       conform = _create_conformant(win);
+       layout = _create_layout(conform, NULL, NULL);
+       elm_object_content_set(conform, layout);
+
+       evas_object_show(win);
+       return;
+}
+
+void _create_progress_view(const char *type, const char *target)
+{
+       Evas_Object *progress_layout;
+       Evas_Object *progressbar;
+       Evas_Object *title, *content;
+       char string[256];
+
+       progress_layout = _create_layout(layout, EDJ_PATH, "progress_layout");
+
+       snprintf(string, sizeof(string), PROGRESS_MESSAGE_TITLE, type);
+       title = _create_textblock(progress_layout, string, SUB_TITLE_STYLE_W);
+
+       snprintf(string, sizeof(string), PROGRESS_MESSAGE_CONTENT, target);
+       content = _create_textblock(progress_layout, string, SUB_CONTENT_STYLE_W);
+
+       elm_object_part_content_set(progress_layout, "message_title", title);
+
+       progressbar = _create_progressbar(progress_layout, "pending");
+       elm_object_part_content_set(progress_layout, "progress_indicator", progressbar);
+
+       elm_object_part_content_set(progress_layout, "message_content", content);
+
+       elm_object_part_content_set(layout, "elm.swallow.content", progress_layout);
+
+       return;
+}
diff --git a/tools/apps/ode/src/widget.c b/tools/apps/ode/src/widget.c
new file mode 100644 (file)
index 0000000..04aabf4
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * Tizen Krate Setup-Wizard application
+ *
+ * Copyright (c) 2016 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 "widget.h"
+
+static void __win_delete_request_cb(void *data , Evas_Object *obj , void *event_info)
+{
+       ui_app_exit();
+}
+
+Evas_Object *_create_win(const char *package)
+{
+       Evas_Object *win;
+
+       elm_app_base_scale_set(1.8);
+
+       win = elm_win_add(NULL, package, ELM_WIN_BASIC);
+       elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_SHOW);
+       elm_win_indicator_opacity_set(win, ELM_WIN_INDICATOR_BG_TRANSPARENT);
+
+       elm_win_conformant_set(win, EINA_TRUE);
+       elm_win_autodel_set(win, EINA_TRUE);
+       elm_win_alpha_set(win, EINA_TRUE);
+
+       evas_object_smart_callback_add(win, "delete,request", __win_delete_request_cb, NULL);
+
+       return win;
+}
+
+Evas_Object *_create_conformant(Evas_Object *parent)
+{
+       Evas_Object *conform = elm_conformant_add(parent);
+
+       evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       elm_win_resize_object_add(parent, conform);
+
+       evas_object_show(conform);
+
+       return conform;
+}
+
+Evas_Object *_create_layout(Evas_Object *parent, char *file, const char *group)
+{
+       Evas_Object *layout = elm_layout_add(parent);
+
+       evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+       if (file == NULL)
+               elm_layout_theme_set(layout, "layout", "application", "default");
+       else
+               elm_layout_file_set(layout, file, group);
+
+       evas_object_show(layout);
+
+       return layout;
+}
+
+Evas_Object *_create_button(Evas_Object *parent, const char *text, Evas_Smart_Cb callback, void *user_data)
+{
+       Evas_Object *btn = elm_button_add(parent);
+
+       evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       elm_object_text_set(btn, text);
+       elm_object_style_set(btn, "bottom");
+       evas_object_smart_callback_add(btn, "clicked", callback, user_data);
+
+       evas_object_show(btn);
+
+       return btn;
+}
+
+Evas_Object *_create_textblock(Evas_Object *parent, const char *text, char *style)
+{
+       Evas_Object *txt = evas_object_textblock_add(parent);
+       Evas_Textblock_Style *text_st = NULL;
+
+       if (style != NULL) {
+               text_st = evas_textblock_style_new();
+               evas_textblock_style_set(text_st, style);
+               evas_object_textblock_style_set(txt, text_st);
+       }
+
+       evas_object_textblock_text_markup_set(txt, text);
+       evas_object_show(txt);
+
+       if (text_st != NULL)
+               evas_textblock_style_free(text_st);
+
+       return txt;
+}
+
+Evas_Object *_create_progressbar(Evas_Object *parent, const char *style)
+{
+       Evas_Object *progressbar = elm_progressbar_add(parent);
+
+       if (style != NULL)
+               elm_object_style_set(progressbar, style);
+
+       evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, 0.5);
+       evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       elm_progressbar_pulse(progressbar, EINA_TRUE);
+       elm_progressbar_pulse_set(progressbar, EINA_TRUE);
+       evas_object_show(progressbar);
+
+       return progressbar;
+}