From 5a04a063379b8996072d1fb90eb453aeb950aa37 Mon Sep 17 00:00:00 2001 From: Sungbae Yoo Date: Tue, 12 Mar 2019 15:03:13 +0900 Subject: [PATCH] Add conditional statements for krate not supported Change-Id: Iee9d2918a2b8252192f319d9ea8102a7e8503b02 Signed-off-by: Sungbae Yoo --- CMakeLists.txt | 5 +++++ packaging/dpm-zone.spec | 5 +++-- plugin/CMakeLists.txt | 5 ++++- plugin/zone.cpp | 26 +++++++++++++++++++++----- 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a1fd7fa..9f41d2a 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,6 +38,11 @@ else() endif() SET(COMPILE_BASE_FLAGS "-g -fPIC -Werror -Wall -Wl,--as-needed -Wl,--no-whole-archive") + +IF(KRATE_SUPPORTED) + SET(COMPILE_BASE_FLAGS "${COMPILE_BASE_FLAGS} -DKRATE_SUPPORTED") +ENDIF(KRATE_SUPPORTED) + SET(CMAKE_C_FLAGS_PROFILING "${COMPILE_BASE_FLAGS} -O0 -pg") SET(CMAKE_CXX_FLAGS_PROFILING "${COMPILE_BASE_FLAGS} -O0 -pg -std=${CXX_STD} -fno-rtti") SET(CMAKE_C_FLAGS_DEBUG "${COMPILE_BASE_FLAGS} -O0 -ggdb") diff --git a/packaging/dpm-zone.spec b/packaging/dpm-zone.spec index ea5b143..8c96bc2 100755 --- a/packaging/dpm-zone.spec +++ b/packaging/dpm-zone.spec @@ -10,9 +10,9 @@ BuildRequires: cmake BuildRequires: gettext-tools BuildRequires: pkgconfig(klay) BuildRequires: pkgconfig(dpm-pil) -BuildRequires: pkgconfig(krate) BuildRequires: pkgconfig(capi-system-info) BuildRequires: pkgconfig(capi-base-common) +#BuildRequires: pkgconfig(krate) %description The dpm-zone package provides zone policy module for device policy manager @@ -37,7 +37,7 @@ The dpm-zone package provides zone policy module for device policy manager %cmake . -DVERSION=%{version} \ -DCMAKE_BUILD_TYPE=%{build_type} \ - -DPLUGIN_INSTALL_DIR=%{_libdir}/dpm/plugins \ + -DPLUGIN_INSTALL_DIR=%{_libdir}/dpm/plugins \ -DSCRIPT_INSTALL_DIR=%{_scriptdir} \ -DSYSTEMD_UNIT_INSTALL_DIR=%{_unitdir} \ -DDATA_INSTALL_DIR=%{TZ_SYS_DATA}/dpm \ @@ -45,6 +45,7 @@ The dpm-zone package provides zone policy module for device policy manager -DRUN_INSTALL_DIR=%{TZ_SYS_RUN} \ -DAPP_INSTALL_PREFIX="%{TZ_SYS_RO_APP}" \ -DAPP_SHARE_PACKAGES_DIR="%{TZ_SYS_RO_PACKAGES}" \ + -DKRATE_SUPPORTED=1 make %{?jobs:-j%jobs} diff --git a/plugin/CMakeLists.txt b/plugin/CMakeLists.txt index 86ac78a..ffe18f3 100755 --- a/plugin/CMakeLists.txt +++ b/plugin/CMakeLists.txt @@ -19,9 +19,12 @@ SET(PLUGIN_SOURCES "zone.cpp") SET(DEPENDENCY klay dpm-pil - krate ) +IF(NOT KRATE_SUPPORTED) + SET(DEPENDENCY ${DEPENDENCY} krate) +ENDIF(NOT KRATE_SUPPORTED) + PKG_CHECK_MODULES(PLUGIN_DEPS REQUIRED ${DEPENDENCY}) SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,noexecstack") diff --git a/plugin/zone.cpp b/plugin/zone.cpp index c22049f..e505237 100644 --- a/plugin/zone.cpp +++ b/plugin/zone.cpp @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License */ - #include #include #include @@ -24,14 +23,17 @@ #include #include -#include #include #include #include + +#ifndef KRATE_SUPPORTED #include #include +#include + #define NAME_PATTERN "^[A-Za-z_][A-Za-z0-9_.-]*" namespace { @@ -63,7 +65,7 @@ bool isAllowedName(const std::string& name) } } // namespace - +#endif class Zone : public AbstractPolicyProvider { public: @@ -75,8 +77,9 @@ public: int Zone::create(const std::string& name, const std::string& setupWizAppid) { +#ifndef KRATE_SUPPORTED if (!isAllowedName(name)) { - return -1; + return TIZEN_ERROR_NOT_PERMITTED; } try { @@ -92,14 +95,18 @@ int Zone::create(const std::string& name, const std::string& setupWizAppid) } return 0; +#else + return TIZEN_ERROR_NOT_PERMITTED; +#endif } int Zone::remove(const std::string& name) { if (getState(name) == 0) { - return -1; + return TIZEN_ERROR_NOT_PERMITTED; } +#ifndef KRATE_SUPPORTED try { Bundle bundle; bundle.add("id", "krate-remove"); @@ -113,16 +120,23 @@ int Zone::remove(const std::string& name) } return 0; +#else + return TIZEN_ERROR_NOT_PERMITTED; +#endif } int Zone::getState(const std::string& name) { +#ifndef KRATE_SUPPORTED krate_state_e state = (krate_state_e)0; krate_manager_h krate_manager; krate_manager_create(&krate_manager); krate_manager_get_krate_state(krate_manager, name.c_str(), &state); krate_manager_destroy(krate_manager); +#else + int state = 0; +#endif return (int)state; } @@ -130,11 +144,13 @@ int Zone::getState(const std::string& name) std::vector Zone::enumerate(int state) { std::vector list; +#ifndef KRATE_SUPPORTED krate_manager_h krate_manager; krate_manager_create(&krate_manager); krate_manager_foreach_name(krate_manager, (krate_state_e)state, foreachKrateCallback, &list); krate_manager_destroy(krate_manager); +#endif return list; } -- 2.7.4