Add conditional statements for krate not supported 82/201282/1 accepted/tizen_5.5_unified accepted/tizen_5.5_unified_mobile_hotfix accepted/tizen_5.5_unified_wearable_hotfix accepted/tizen_6.0_unified accepted/tizen_6.0_unified_hotfix accepted/tizen_6.5_unified accepted/tizen_7.0_unified accepted/tizen_7.0_unified_hotfix accepted/tizen_8.0_unified accepted/tizen_unified tizen tizen_5.5 tizen_5.5_mobile_hotfix tizen_5.5_tv tizen_5.5_wearable_hotfix tizen_6.0 tizen_6.0_hotfix tizen_6.5 tizen_7.0 tizen_7.0_hotfix tizen_8.0 accepted/tizen/5.5/unified/20191031.022947 accepted/tizen/5.5/unified/mobile/hotfix/20201027.090622 accepted/tizen/5.5/unified/wearable/hotfix/20201027.113252 accepted/tizen/6.0/unified/20201030.115126 accepted/tizen/6.0/unified/hotfix/20201103.003927 accepted/tizen/6.5/unified/20211028.123801 accepted/tizen/7.0/unified/20221110.063536 accepted/tizen/7.0/unified/hotfix/20221116.105603 accepted/tizen/8.0/unified/20231005.093634 accepted/tizen/unified/20190312.113005 submit/tizen/20190312.060911 submit/tizen_5.5/20191031.000004 submit/tizen_5.5_mobile_hotfix/20201026.185104 submit/tizen_5.5_wearable_hotfix/20201026.184304 submit/tizen_6.0/20201029.205104 submit/tizen_6.0_hotfix/20201102.192504 submit/tizen_6.0_hotfix/20201103.114804 submit/tizen_6.5/20211028.162401 tizen_5.5.m2_release tizen_6.0.m2_release tizen_6.5.m2_release tizen_7.0_m2_release tizen_8.0_m2_release
authorSungbae Yoo <sungbae.yoo@samsung.com>
Tue, 12 Mar 2019 06:03:13 +0000 (15:03 +0900)
committerSungbae Yoo <sungbae.yoo@samsung.com>
Tue, 12 Mar 2019 06:03:13 +0000 (15:03 +0900)
Change-Id: Iee9d2918a2b8252192f319d9ea8102a7e8503b02
Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
CMakeLists.txt
packaging/dpm-zone.spec
plugin/CMakeLists.txt
plugin/zone.cpp

index a1fd7fa..9f41d2a 100755 (executable)
@@ -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")
index ea5b143..8c96bc2 100755 (executable)
@@ -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}
 
index 86ac78a..ffe18f3 100755 (executable)
@@ -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")
index c22049f..e505237 100644 (file)
@@ -13,7 +13,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License
  */
-
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/inotify.h>
 
 #include <tzplatform_config.h>
 #include <klay/auth/user.h>
-#include <krate/krate.h>
 
 #include <dpm/pil/policy-context.h>
 #include <dpm/pil/policy-model.h>
 #include <dpm/pil/policy-storage.h>
+
+#ifndef KRATE_SUPPORTED
 #include <dpm/pil/app-bundle.h>
 #include <dpm/pil/launchpad.h>
 
+#include <krate/krate.h>
+
 #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<std::string> Zone::enumerate(int state)
 {
        std::vector<std::string> 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;
 }