Change device policy manager interface submit/tizen/20170817.045900
authorJaemin Ryu <jm77.ryu@samsung.com>
Wed, 16 Aug 2017 04:19:20 +0000 (13:19 +0900)
committerJaemin Ryu <jm77.ryu@samsung.com>
Wed, 16 Aug 2017 07:44:33 +0000 (16:44 +0900)
Signed-off-by: Jaemin Ryu <jm77.ryu@samsung.com>
52 files changed:
CMakeLists.txt
administration.cpp [deleted file]
application.cpp [deleted file]
bluetooth.cpp [deleted file]
krate.cpp [deleted file]
libs/CMakeLists.txt [new file with mode: 0755]
libs/administration.cpp [moved from dpm/administration.cpp with 73% similarity]
libs/application.cpp [moved from dpm/application.cpp with 62% similarity]
libs/array.h [moved from dpm/array.h with 100% similarity]
libs/bluetooth.cpp [moved from dpm/bluetooth.cpp with 61% similarity]
libs/client-handle.cpp [moved from dpm/client-handle.cpp with 79% similarity]
libs/debug.h [moved from dpm/debug.h with 100% similarity]
libs/dpm.pc.in [moved from dpm.pc.in with 100% similarity]
libs/dpm/administration.h [moved from dpm/administration.h with 100% similarity]
libs/dpm/application.h [moved from dpm/application.h with 100% similarity]
libs/dpm/bluetooth.h [moved from dpm/bluetooth.h with 100% similarity]
libs/dpm/device-policy-manager.h [moved from dpm/device-policy-manager.h with 100% similarity]
libs/dpm/password.h [moved from dpm/password.h with 100% similarity]
libs/dpm/password_internal.h [moved from dpm/password_internal.h with 100% similarity]
libs/dpm/restriction.h [moved from dpm/restriction.h with 100% similarity]
libs/dpm/security.h [moved from dpm/security.h with 100% similarity]
libs/dpm/storage.h [moved from dpm/storage.h with 100% similarity]
libs/dpm/wifi.h [moved from dpm/wifi.h with 100% similarity]
libs/dpm/zone.h [moved from dpm/zone.h with 100% similarity]
libs/password.cpp [moved from dpm/password.cpp with 59% similarity]
libs/policy-client.cpp [new file with mode: 0644]
libs/policy-client.h [moved from policy-client.h with 63% similarity]
libs/restriction.cpp [moved from dpm/restriction.cpp with 57% similarity]
libs/security.cpp [moved from dpm/security.cpp with 64% similarity]
libs/status.h [moved from status.h with 100% similarity]
libs/storage.cpp [moved from dpm/storage.cpp with 73% similarity]
libs/wifi.cpp [moved from dpm/wifi.cpp with 64% similarity]
libs/zone.cpp [moved from dpm/zone.cpp with 71% similarity]
location.cpp [deleted file]
password.cpp [deleted file]
policy-client.cpp [deleted file]
policy-context.hxx [deleted file]
policy/administration.hxx [deleted file]
policy/application.hxx [deleted file]
policy/bluetooth.hxx [deleted file]
policy/krate.hxx [deleted file]
policy/location.hxx [deleted file]
policy/password.hxx [deleted file]
policy/restriction.hxx [deleted file]
policy/security.hxx [deleted file]
policy/smack.hxx [deleted file]
policy/storage.hxx [deleted file]
policy/wifi.hxx [deleted file]
restriction.cpp [deleted file]
security.cpp [deleted file]
storage.cpp [deleted file]
wifi.cpp [deleted file]

index 630b15e..eeb4c25 100755 (executable)
@@ -15,9 +15,7 @@
 #
 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 
-PROJECT(dpm)
-SET(LIB_VERSION "${VERSION}")
-SET(LIB_SOVERSION "0")
+PROJECT(device-policy-client)
 
 INCLUDE(FindPkgConfig)
 
@@ -25,8 +23,7 @@ IF(NOT CMAKE_BUILD_TYPE)
        SET(CMAKE_BUILD_TYPE "DEBUG")
 ENDIF(NOT CMAKE_BUILD_TYPE)
 
-SET(DPM_POLICY     ${PROJECT_SOURCE_DIR}/policy)
-SET(DPM_LIBS       ${PROJECT_SOURCE_DIR}/)
+SET(DPM_LIBS       ${PROJECT_SOURCE_DIR}/libs)
 
 IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
        SET(CXX_STD "c++0x")
@@ -58,64 +55,5 @@ ENDIF(NOT DEFINED TEST_DATA_INSTALL_DIR)
 
 ADD_DEFINITIONS(-DUG_WAYLAND)
 
-SET(PC_FILE "${PROJECT_NAME}.pc")
+ADD_SUBDIRECTORY(${DPM_LIBS})
 
-SET(FOUNDATION          policy-client.cpp
-                                               dpm/client-handle.cpp
-)
-
-SET(POLICY              administration.cpp
-                                               application.cpp
-                                               bluetooth.cpp
-                                               location.cpp
-                                               restriction.cpp
-                                               security.cpp
-                                               storage.cpp
-                                               wifi.cpp
-                                               password.cpp
-                                               krate.cpp
-                                               dpm/administration.cpp
-                                               dpm/application.cpp
-                                               dpm/bluetooth.cpp
-                                               dpm/restriction.cpp
-                                               dpm/security.cpp
-                                               dpm/wifi.cpp
-                                               dpm/password.cpp
-                                               dpm/zone.cpp
-)
-
-SET(CAPI                dpm/device-policy-manager.h
-                                               dpm/administration.h
-                                               dpm/application.h
-                                               dpm/bluetooth.h
-                                               dpm/restriction.h
-                                               dpm/security.h
-                                               dpm/wifi.h
-                                               dpm/password.h
-                                               dpm/password_internal.h
-                                               dpm/zone.h
-)
-
-SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,noexecstack")
-
-ADD_LIBRARY(${PROJECT_NAME} SHARED ${FOUNDATION} ${POLICY})
-
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${LIB_SOVERSION})
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION   ${LIB_VERSION})
-
-PKG_CHECK_MODULES(LIBS_DEPS    REQUIRED
-                                                       klay
-                                                       glib-2.0
-                                                       capi-base-common
-                                                       capi-system-info
-)
-
-INCLUDE_DIRECTORIES(SYSTEM ${LIBS_DEPS_INCLUDE_DIRS} ${DPM_POLICY} ${DPM_LIBS})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIBS_DEPS_LIBRARIES} pthread)
-
-CONFIGURE_FILE(${PC_FILE}.in ${CMAKE_BINARY_DIR}/${PC_FILE} @ONLY)
-
-INSTALL(FILES ${CMAKE_BINARY_DIR}/${PC_FILE} DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
-INSTALL(FILES ${CAPI} DESTINATION ${INCLUDE_INSTALL_DIR}/dpm)
diff --git a/administration.cpp b/administration.cpp
deleted file mode 100644 (file)
index 507076f..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- *  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 "status.h"
-#include "administration.hxx"
-
-namespace DevicePolicyManager {
-
-struct AdministrationPolicy::Private {
-       Private(PolicyControlContext& ctx) : context(ctx) {}
-       PolicyControlContext& context;
-};
-
-AdministrationPolicy::AdministrationPolicy(AdministrationPolicy&& rhs) = default;
-AdministrationPolicy& AdministrationPolicy::operator=(AdministrationPolicy&& rhs) = default;
-
-AdministrationPolicy::AdministrationPolicy(const AdministrationPolicy& rhs) :
-       pimpl(nullptr)
-{
-       if (rhs.pimpl) {
-               pimpl.reset(new Private(*rhs.pimpl));
-       }
-}
-
-AdministrationPolicy& AdministrationPolicy::operator=(const AdministrationPolicy& rhs)
-{
-       if (!rhs.pimpl) {
-               pimpl.reset();
-       } else {
-               pimpl.reset(new Private(*rhs.pimpl));
-       }
-
-       return *this;
-}
-
-AdministrationPolicy::AdministrationPolicy(PolicyControlContext& ctx) :
-       pimpl(new Private(ctx))
-{
-}
-
-AdministrationPolicy::~AdministrationPolicy()
-{
-}
-
-int AdministrationPolicy::registerPolicyClient(const std::string& name, uid_t uid)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("AdministrationPolicy::registerPolicyClient", name, uid);
-
-       return status.get();
-}
-
-int AdministrationPolicy::deregisterPolicyClient(const std::string& name, uid_t uid)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("AdministrationPolicy::deregisterPolicyClient", name, uid);
-
-       return status.get();
-}
-
-} // namespace DevicePolicyManager
diff --git a/application.cpp b/application.cpp
deleted file mode 100644 (file)
index 429e6bd..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- *  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 "status.h"
-#include "application.hxx"
-
-namespace DevicePolicyManager {
-
-struct ApplicationPolicy::Private {
-       Private(PolicyControlContext& ctxt) : context(ctxt) {}
-       PolicyControlContext& context;
-};
-
-ApplicationPolicy::ApplicationPolicy(ApplicationPolicy&& rhs) = default;
-ApplicationPolicy& ApplicationPolicy::operator=(ApplicationPolicy&& rhs) = default;
-
-ApplicationPolicy::ApplicationPolicy(const ApplicationPolicy& rhs)
-{
-       if (rhs.pimpl) {
-               pimpl.reset(new Private(*rhs.pimpl));
-       }
-}
-
-ApplicationPolicy& ApplicationPolicy::operator=(const ApplicationPolicy& rhs)
-{
-       if (!rhs.pimpl) {
-               pimpl.reset();
-       } else {
-               pimpl.reset(new Private(*rhs.pimpl));
-       }
-
-       return *this;
-}
-
-ApplicationPolicy::ApplicationPolicy(PolicyControlContext& ctxt) :
-       pimpl(new Private(ctxt))
-{
-}
-
-ApplicationPolicy::~ApplicationPolicy()
-{
-}
-
-int ApplicationPolicy::installPackage(const std::string& pkgpath)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("ApplicationPolicy::installPackage", pkgpath);
-
-       return status.get();
-}
-
-int ApplicationPolicy::uninstallPackage(const std::string& pkgid)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("ApplicationPolicy::uninstallPackage", pkgid);
-
-       return status.get();
-}
-
-int ApplicationPolicy::setModeRestriction(int mode)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("ApplicationPolicy::setModeRestriction", mode);
-
-       return status.get();
-}
-
-int ApplicationPolicy::unsetModeRestriction(int mode)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("ApplicationPolicy::unsetModeRestriction", mode);
-
-       return status.get();
-}
-
-int ApplicationPolicy::getModeRestriction()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { 0 };
-
-       status = context.methodCall<int>("ApplicationPolicy::getModeRestriction");
-
-       return status.get();
-}
-
-int ApplicationPolicy::addPrivilegeToBlacklist(int type, const std::string& privilege)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("ApplicationPolicy::addPrivilegeToBlacklist", type, privilege);
-
-       return status.get();
-}
-
-int ApplicationPolicy::removePrivilegeFromBlacklist(int type, const std::string& privilege)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("ApplicationPolicy::removePrivilegeFromBlacklist", type, privilege);
-
-       return status.get();
-}
-
-int ApplicationPolicy::checkPrivilegeIsBlacklisted(int type, const std::string& privilege)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { 0 };
-
-       status = context.methodCall<int>("ApplicationPolicy::checkPrivilegeIsBlacklisted", type, privilege);
-
-       return status.get();
-}
-} // namespace DevicePolicyManager
diff --git a/bluetooth.cpp b/bluetooth.cpp
deleted file mode 100644 (file)
index ade8f32..0000000
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- *  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 "status.h"
-#include "bluetooth.hxx"
-
-namespace DevicePolicyManager {
-
-struct BluetoothPolicy::Private {
-       Private(PolicyControlContext& ctx) : context(ctx) {}
-       PolicyControlContext& context;
-};
-
-BluetoothPolicy::BluetoothPolicy(BluetoothPolicy&& rhs) = default;
-BluetoothPolicy& BluetoothPolicy::operator=(BluetoothPolicy&& rhs) = default;
-
-BluetoothPolicy::BluetoothPolicy(const BluetoothPolicy& rhs)
-{
-       if (rhs.pimpl) {
-               pimpl.reset(new Private(*rhs.pimpl));
-       }
-}
-
-BluetoothPolicy& BluetoothPolicy::operator=(const BluetoothPolicy& rhs)
-{
-       if (!rhs.pimpl) {
-               pimpl.reset();
-       } else {
-               pimpl.reset(new Private(*rhs.pimpl));
-       }
-
-       return *this;
-}
-
-BluetoothPolicy::BluetoothPolicy(PolicyControlContext& ctxt) :
-       pimpl(new Private(ctxt))
-{
-}
-
-BluetoothPolicy::~BluetoothPolicy()
-{
-}
-
-// for restriction CPIs
-int BluetoothPolicy::setModeChangeState(bool enable)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("BluetoothPolicy::setModeChangeState", enable);
-
-       return status.get();
-}
-
-bool BluetoothPolicy::getModeChangeState()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<bool> status { true };
-
-       status = context.methodCall<bool>("BluetoothPolicy::getModeChangeState");
-
-       return status.get();
-}
-
-int BluetoothPolicy::setDesktopConnectivityState(bool enable)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<bool>("BluetoothPolicy::setDesktopConnectivityState", enable);
-
-       return status.get();
-}
-
-bool BluetoothPolicy::getDesktopConnectivityState()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<bool> status { true };
-
-       status = context.methodCall<bool>("BluetoothPolicy::getDesktopConnectivityState");
-
-       return status.get();
-}
-
-int BluetoothPolicy::setTetheringState(bool enable)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("BluetoothPolicy::setTetheringState", enable);
-
-       return status.get();
-}
-
-bool BluetoothPolicy::getTetheringState()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<bool> status { true };
-
-       status = context.methodCall<bool>("BluetoothPolicy::getTetheringState");
-
-       return status.get();
-}
-
-int BluetoothPolicy::setPairingState(bool enable)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("BluetoothPolicy::setPairingState", enable);
-
-       return status.get();
-}
-
-bool BluetoothPolicy::getPairingState()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<bool> status { true };
-
-       status = context.methodCall<bool>("BluetoothPolicy::getPairingState");
-
-       return status.get();
-}
-
-int BluetoothPolicy::addDeviceToBlacklist(const std::string& mac)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("BluetoothPolicy::addDeviceToBlacklist", mac);
-
-       return status.get();
-}
-
-int BluetoothPolicy::removeDeviceFromBlacklist(const std::string& mac)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("BluetoothPolicy::removeDeviceFromBlacklist", mac);
-
-       return status.get();
-}
-
-int BluetoothPolicy::setDeviceRestriction(bool enable)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("BluetoothPolicy::setDeviceRestriction", enable);
-
-       return status.get();
-}
-
-bool BluetoothPolicy::isDeviceRestricted()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<bool> status { false };
-
-       status = context.methodCall<bool>("BluetoothPolicy::isDeviceRestricted");
-
-       return status.get();
-}
-
-int BluetoothPolicy::addUuidToBlacklist(const std::string& uuid)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("BluetoothPolicy::addUuidToBlacklist", uuid);
-
-       return status.get();
-}
-
-int BluetoothPolicy::removeUuidFromBlacklist(const std::string& uuid)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("BluetoothPolicy::removeUuidFromBlacklist", uuid);
-
-       return status.get();
-}
-
-int BluetoothPolicy::setUuidRestriction(bool enable)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("BluetoothPolicy::setUuidRestriction", enable);
-
-       return status.get();
-}
-
-bool BluetoothPolicy::isUuidRestricted()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<bool> status { false };
-
-       status = context.methodCall<bool>("BluetoothPolicy::isUuidRestricted");
-
-       return status.get();
-}
-
-} // namespace DevicePolicyManager
diff --git a/krate.cpp b/krate.cpp
deleted file mode 100644 (file)
index b49ac3f..0000000
--- a/krate.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- *  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 "status.h"
-#include "krate.hxx"
-
-namespace DevicePolicyManager {
-
-struct KratePolicy::Private {
-       Private(PolicyControlContext& ctxt) : context(ctxt) {}
-       PolicyControlContext& context;
-};
-
-KratePolicy::KratePolicy(KratePolicy&& rhs) = default;
-KratePolicy& KratePolicy::operator=(KratePolicy&& rhs) = default;
-
-KratePolicy::KratePolicy(const KratePolicy& rhs)
-{
-       if (rhs.pimpl) {
-               pimpl.reset(new Private(*rhs.pimpl));
-       }
-}
-
-KratePolicy& KratePolicy::operator=(const KratePolicy& rhs)
-{
-       if (!rhs.pimpl) {
-               pimpl.reset();
-       } else {
-               pimpl.reset(new Private(*rhs.pimpl));
-       }
-
-       return *this;
-}
-
-KratePolicy::KratePolicy(PolicyControlContext& ctx) :
-       pimpl(new Private(ctx))
-{
-}
-
-KratePolicy::~KratePolicy()
-{
-}
-
-int KratePolicy::createKrate(const std::string& name, const std::string& setupWizAppid)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("KratePolicy::createKrate", name, setupWizAppid);
-
-       return status.get();
-}
-
-int KratePolicy::removeKrate(const std::string& name)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("KratePolicy::removeKrate", name);
-
-       return status.get();
-}
-
-int KratePolicy::getKrateState(const std::string& name)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { 0 };
-
-       status = context.methodCall<int>("KratePolicy::getKrateState", name);
-
-       return status.get();
-}
-
-std::vector<std::string> KratePolicy::getKrateList(int state)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<std::vector<std::string>> status { std::vector<std::string>() };
-
-       status = context.methodCall<std::vector<std::string>>("KratePolicy::getKrateList", state);
-
-       return status.get();
-}
-
-} // namespace DevicePolicyManager
diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..3d5f6bd
--- /dev/null
@@ -0,0 +1,70 @@
+#
+# 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.
+#
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
+
+SET(TARGET "dpm")
+SET(LIB_VERSION "${VERSION}")
+SET(LIB_SOVERSION "0")
+
+SET(PC_FILE "${TARGET}.pc")
+
+SET(POLICY             policy-client.cpp
+                               client-handle.cpp
+                               administration.cpp
+                               application.cpp
+                               bluetooth.cpp
+                               restriction.cpp
+                               security.cpp
+                               wifi.cpp
+                               password.cpp
+                               zone.cpp
+)
+
+SET(CAPI               dpm/device-policy-manager.h
+                               dpm/administration.h
+                               dpm/application.h
+                               dpm/bluetooth.h
+                               dpm/restriction.h
+                               dpm/security.h
+                               dpm/wifi.h
+                               dpm/password.h
+                               dpm/password_internal.h
+                               dpm/zone.h
+)
+
+SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,noexecstack")
+
+ADD_LIBRARY(${TARGET} SHARED ${FOUNDATION} ${POLICY})
+
+SET_TARGET_PROPERTIES(${TARGET} PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
+SET_TARGET_PROPERTIES(${TARGET} PROPERTIES SOVERSION ${LIB_SOVERSION})
+SET_TARGET_PROPERTIES(${TARGET} PROPERTIES VERSION   ${LIB_VERSION})
+
+PKG_CHECK_MODULES(LIBS_DEPS    REQUIRED
+                                                       klay
+                                                       glib-2.0
+                                                       capi-base-common
+                                                       capi-system-info
+)
+
+INCLUDE_DIRECTORIES(SYSTEM ${LIBS_DEPS_INCLUDE_DIRS} ${DPM_LIBS})
+TARGET_LINK_LIBRARIES(${TARGET} ${LIBS_DEPS_LIBRARIES} pthread)
+
+CONFIGURE_FILE(${PC_FILE}.in ${CMAKE_BINARY_DIR}/${PC_FILE} @ONLY)
+
+INSTALL(FILES ${CMAKE_BINARY_DIR}/${PC_FILE} DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+INSTALL(TARGETS ${TARGET} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
+INSTALL(FILES ${CAPI} DESTINATION ${INCLUDE_INSTALL_DIR}/dpm)
similarity index 73%
rename from dpm/administration.cpp
rename to libs/administration.cpp
index 6a19eaf..5e8b500 100644 (file)
 #include <cstring>
 #include <cassert>
 
-#include "administration.h"
-#include "administration.hxx"
+#include "dpm/administration.h"
 
 #include "debug.h"
+#include "status.h"
 #include "policy-client.h"
 
-using namespace DevicePolicyManager;
-
 EXPORT_API int dpm_admin_register_client(device_policy_manager_h handle, const char* name, uid_t uid)
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(name, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(uid, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       AdministrationPolicy admin = client.createPolicyInterface<AdministrationPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return admin.registerPolicyClient(name, uid);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("DevicePolicyManager::enroll", name, uid);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -47,11 +46,12 @@ EXPORT_API int dpm_admin_deregister_client(device_policy_manager_h handle, const
        RET_ON_FAILURE(name, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(uid, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       AdministrationPolicy admin = client.createPolicyInterface<AdministrationPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return admin.deregisterPolicyClient(name, uid);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("DevicePolicyManager::disenroll", name, uid);
+               return status.get();
        } catch (...) {
                return -1;
        }
similarity index 62%
rename from dpm/application.cpp
rename to libs/application.cpp
index 0983819..4b3ae3b 100644 (file)
  *  limitations under the License
  */
 
-#include "application.h"
-#include "application.hxx"
+#include "dpm/application.h"
 
 #include "debug.h"
+#include "status.h"
 #include "policy-client.h"
 
-using namespace DevicePolicyManager;
-
 EXPORT_API int dpm_application_set_mode_restriction(device_policy_manager_h handle, int mode)
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(mode, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext& client = GetDevicePolicyContext(handle);
-       ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
+       DevicePolicyClient& client = GetDevicePolicyClient(handle);
 
        try {
-               return application.setModeRestriction(mode);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Application::setModeRestriction", mode);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -42,11 +41,12 @@ EXPORT_API int dpm_application_unset_mode_restriction(device_policy_manager_h ha
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(mode, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext& client = GetDevicePolicyContext(handle);
-       ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
+       DevicePolicyClient& client = GetDevicePolicyClient(handle);
 
        try {
-               return application.unsetModeRestriction(mode);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Application::unsetModeRestriction", mode);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -57,15 +57,15 @@ EXPORT_API int dpm_application_get_mode_restriction(device_policy_manager_h hand
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(mode, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext& client = GetDevicePolicyContext(handle);
-       ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
+       DevicePolicyClient& client = GetDevicePolicyClient(handle);
 
        try {
-               int ret = application.getModeRestriction();
-               if (ret < 0) {
+               Status<int> status { 0 };
+               status = client.methodCall<int>("Application::getModeRestriction");
+               if (status.get() < 0) {
                        return -1;
                }
-               *mode = ret;
+               *mode = status.get();
        } catch (...) {
                return -1;
        }
@@ -78,11 +78,12 @@ EXPORT_API int dpm_application_add_privilege_to_blacklist(device_policy_manager_
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(privilege, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext& client = GetDevicePolicyContext(handle);
-       ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
+       DevicePolicyClient& client = GetDevicePolicyClient(handle);
 
        try {
-               return application.addPrivilegeToBlacklist(type, privilege);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Application::addPrivilegeToBlacklist", type, privilege);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -93,11 +94,12 @@ EXPORT_API int dpm_application_remove_privilege_from_blacklist(device_policy_man
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(privilege, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext& client = GetDevicePolicyContext(handle);
-       ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
+       DevicePolicyClient& client = GetDevicePolicyClient(handle);
 
        try {
-               return application.removePrivilegeFromBlacklist(type, privilege);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Application::removePrivilegeFromBlacklist", type, privilege);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -109,16 +111,16 @@ EXPORT_API int dpm_application_check_privilege_is_blacklisted(device_policy_mana
        RET_ON_FAILURE(privilege, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(is_blacklisted, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext& client = GetDevicePolicyContext(handle);
-       ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
+       DevicePolicyClient& client = GetDevicePolicyClient(handle);
 
        try {
-               int ret = application.checkPrivilegeIsBlacklisted(type, privilege);
-               if (ret < 0) {
+               Status<int> status { 0 };
+               status = client.methodCall<int>("Application::checkPrivilegeIsBlacklisted", type, privilege);
+               if (status.get() < 0) {
                        return -1;
                }
 
-               *is_blacklisted = ret;
+               *is_blacklisted = status.get();
        } catch (...) {
                return -1;
        }
@@ -131,11 +133,12 @@ EXPORT_API int dpm_application_install_package(device_policy_manager_h handle, c
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(pkgpath, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext& client = GetDevicePolicyContext(handle);
-       ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
+       DevicePolicyClient& client = GetDevicePolicyClient(handle);
 
        try {
-               return application.installPackage(pkgpath);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Application::installPackage", pkgpath);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -146,11 +149,12 @@ EXPORT_API int dpm_application_uninstall_package(device_policy_manager_h handle,
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(pkgid, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext& client = GetDevicePolicyContext(handle);
-       ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
+       DevicePolicyClient& client = GetDevicePolicyClient(handle);
 
        try {
-               return application.uninstallPackage(pkgid);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Application::uninstallPackage", pkgid);
+               return status.get();
        } catch (...) {
                return -1;
        }
similarity index 100%
rename from dpm/array.h
rename to libs/array.h
similarity index 61%
rename from dpm/bluetooth.cpp
rename to libs/bluetooth.cpp
index cb8c409..a5d8470 100644 (file)
  *  limitations under the License
  */
 
-#include "bluetooth.h"
-#include "bluetooth.hxx"
+#include "dpm/bluetooth.h"
 
 #include "debug.h"
+#include "status.h"
 #include "policy-client.h"
 
-using namespace DevicePolicyManager;
-
 EXPORT_API int dpm_bluetooth_add_device_to_blacklist(device_policy_manager_h handle, const char* mac)
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(mac, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return bluetooth.addDeviceToBlacklist(mac);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Bluetooth::addDeviceToBlacklist", mac);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -42,11 +41,12 @@ EXPORT_API int dpm_bluetooth_remove_device_from_blacklist(device_policy_manager_
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(mac, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return bluetooth.removeDeviceFromBlacklist(mac);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Bluetooth::removeDeviceFromBlacklist", mac);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -56,11 +56,12 @@ EXPORT_API int dpm_bluetooth_set_device_restriction(device_policy_manager_h hand
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return bluetooth.setDeviceRestriction(enable);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Bluetooth::setDeviceRestriction", enable);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -70,11 +71,12 @@ EXPORT_API int dpm_bluetooth_is_device_restricted(device_policy_manager_h handle
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               *state = bluetooth.isDeviceRestricted();
+               Status<bool> status { false };
+               status = client.methodCall<bool>("Bluetooth::isDeviceRestricted");
+               *state = status.get();
        } catch (...) {
                return -1;
        }
@@ -87,11 +89,12 @@ EXPORT_API int dpm_bluetooth_add_uuid_to_blacklist(device_policy_manager_h handl
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(uuid, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return bluetooth.addUuidToBlacklist(uuid);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Bluetooth::addUuidToBlacklist", uuid);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -102,11 +105,12 @@ EXPORT_API int dpm_bluetooth_remove_uuid_from_blacklist(device_policy_manager_h
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(uuid, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return bluetooth.removeUuidFromBlacklist(uuid);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Bluetooth::removeUuidFromBlacklist", uuid);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -116,11 +120,12 @@ EXPORT_API int dpm_bluetooth_set_uuid_restriction(device_policy_manager_h handle
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return bluetooth.setUuidRestriction(enable);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Bluetooth::setUuidRestriction", enable);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -130,11 +135,12 @@ EXPORT_API int dpm_bluetooth_is_uuid_restricted(device_policy_manager_h handle,
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               *state = bluetooth.isUuidRestricted();
+               Status<bool> status { false };
+               status = client.methodCall<bool>("Bluetooth::isUuidRestricted");
+               *state = status.get();
        } catch (...) {
                return -1;
        }
similarity index 79%
rename from dpm/client-handle.cpp
rename to libs/client-handle.cpp
index 1c5eb7d..d2ea116 100644 (file)
 #include <cassert>
 #include <iostream>
 
-#include "device-policy-manager.h"
+#include "dpm/device-policy-manager.h"
 
 #include "policy-client.h"
 #include "debug.h"
 
-DevicePolicyContext& GetDevicePolicyContext(void* handle)
+DevicePolicyClient& GetDevicePolicyClient(void* handle)
 {
        assert(handle);
-       return *reinterpret_cast<DevicePolicyContext*>(handle);
+       return *reinterpret_cast<DevicePolicyClient*>(handle);
 }
 
 EXPORT_API device_policy_manager_h dpm_manager_create(void)
 {
-       DevicePolicyContext* client = new(std::nothrow) DevicePolicyContext();
+       DevicePolicyClient* client = new(std::nothrow) DevicePolicyClient();
        if (client == nullptr) {
                return NULL;
        }
@@ -47,7 +47,7 @@ EXPORT_API int dpm_manager_destroy(device_policy_manager_h handle)
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       delete &GetDevicePolicyContext(handle);
+       delete &GetDevicePolicyClient(handle);
 
        return 0;
 }
@@ -63,8 +63,8 @@ EXPORT_API int dpm_add_policy_changed_cb(device_policy_manager_h handle,
        RET_ON_FAILURE(callback, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(id, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext& client = GetDevicePolicyContext(handle);
-       int ret = client.subscribePolicyChange(name, callback, user_data);
+       DevicePolicyClient& client = GetDevicePolicyClient(handle);
+       int ret = client.subscribeSignal(name, callback, user_data);
        if (ret < 0) {
                return -1;
        }
@@ -78,8 +78,8 @@ EXPORT_API int dpm_remove_policy_changed_cb(device_policy_manager_h handle, int
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(id >= 0, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext& client = GetDevicePolicyContext(handle);
-       return client.unsubscribePolicyChange(id);
+       DevicePolicyClient& client = GetDevicePolicyClient(handle);
+       return client.unsubscribeSignal(id);
 }
 
 EXPORT_API int dpm_add_signal_cb(device_policy_manager_h handle, const char* signal,
@@ -90,7 +90,7 @@ EXPORT_API int dpm_add_signal_cb(device_policy_manager_h handle, const char* sig
        RET_ON_FAILURE(callback, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(id, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext& context = GetDevicePolicyContext(handle);
+       DevicePolicyClient& context = GetDevicePolicyClient(handle);
        int ret = context.subscribeSignal(signal, callback, user_data);
        if (ret < 0) {
                return -1;
@@ -105,6 +105,6 @@ EXPORT_API int dpm_remove_signal_cb(device_policy_manager_h handle, int id)
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(id >= 0, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext& context = GetDevicePolicyContext(handle);
+       DevicePolicyClient& context = GetDevicePolicyClient(handle);
        return context.unsubscribeSignal(id);
 }
similarity index 100%
rename from dpm/debug.h
rename to libs/debug.h
similarity index 100%
rename from dpm.pc.in
rename to libs/dpm.pc.in
similarity index 100%
rename from dpm/application.h
rename to libs/dpm/application.h
similarity index 100%
rename from dpm/bluetooth.h
rename to libs/dpm/bluetooth.h
similarity index 100%
rename from dpm/password.h
rename to libs/dpm/password.h
similarity index 100%
rename from dpm/restriction.h
rename to libs/dpm/restriction.h
similarity index 100%
rename from dpm/security.h
rename to libs/dpm/security.h
similarity index 100%
rename from dpm/storage.h
rename to libs/dpm/storage.h
similarity index 100%
rename from dpm/wifi.h
rename to libs/dpm/wifi.h
similarity index 100%
rename from dpm/zone.h
rename to libs/dpm/zone.h
similarity index 59%
rename from dpm/password.cpp
rename to libs/password.cpp
index 377788a..131113e 100644 (file)
 #include <cstring>
 #include <cassert>
 
-#include "password.h"
-#include "password_internal.h"
-#include "password.hxx"
+#include "dpm/password.h"
+#include "dpm/password_internal.h"
 
 #include "array.h"
 #include "debug.h"
+#include "status.h"
 #include "policy-client.h"
 
-using namespace DevicePolicyManager;
-
 EXPORT_API int dpm_password_set_quality(device_policy_manager_h handle, int quality)
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(quality >= 0, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return password.setQuality(quality);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Password::setQuality", quality);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -47,16 +46,15 @@ EXPORT_API int dpm_password_get_quality(device_policy_manager_h handle, int *qua
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(quality, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               int ret = password.getQuality();
-               if (ret < 0) {
+               Status<int> status { 0 };
+               status = client.methodCall<int>("Password::getQuality");
+               if (status.get() < 0)
                        return -1;
-               }
 
-               *quality = (dpm_password_quality_e)ret;
+               *quality = (dpm_password_quality_e)status.get();
        } catch (...) {
                return -1;
        }
@@ -69,11 +67,12 @@ EXPORT_API int dpm_password_set_minimum_length(device_policy_manager_h handle, i
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return password.setMinimumLength(value);
+               Status<int> status { 0 };
+               status = client.methodCall<int>("Password::setMinimumLength", value);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -84,16 +83,15 @@ EXPORT_API int dpm_password_get_minimum_length(device_policy_manager_h handle, i
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               int ret = password.getMinimumLength();
-               if (ret < 0) {
+               Status<int> status { 0 };
+               status = client.methodCall<int>("Password::getMinimumLength");
+               if (status.get() < 0)
                        return -1;
-               }
 
-               *value = ret;
+               *value = status.get();
        } catch (...) {
                return -1;
        }
@@ -106,11 +104,12 @@ EXPORT_API int dpm_password_set_min_complex_chars(device_policy_manager_h handle
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return password.setMinComplexChars(value);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Password::setMinComplexChars", value);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -121,16 +120,15 @@ EXPORT_API int dpm_password_get_min_complex_chars(device_policy_manager_h handle
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               int ret = password.getMinComplexChars();
-               if (ret < 0) {
+               Status<int> status { 0 };
+               status = client.methodCall<int>("Password::getMinComplexChars");
+               if (status.get() < 0)
                        return -1;
-               }
 
-               *value = ret;
+               *value = status.get();
        } catch (...) {
                return -1;
        }
@@ -143,11 +141,12 @@ EXPORT_API int dpm_password_set_maximum_failed_attempts_for_wipe(device_policy_m
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return password.setMaximumFailedForWipe(value);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Password::setMaximumFailedForWipe", value);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -158,16 +157,15 @@ EXPORT_API int dpm_password_get_maximum_failed_attempts_for_wipe(device_policy_m
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               int ret = password.getMaximumFailedForWipe();
-               if (ret < 0) {
+               Status<int> status { 0 };
+               status = client.methodCall<int>("Password::getMaximumFailedForWipe");
+               if (status.get() < 0)
                        return -1;
-               }
 
-               *value = ret;
+               *value = status.get();
        } catch (...) {
                return -1;
        }
@@ -180,11 +178,12 @@ EXPORT_API int dpm_password_set_expires(device_policy_manager_h handle, int valu
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return password.setExpires(value);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Password::setExpires", value);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -195,16 +194,15 @@ EXPORT_API int dpm_password_get_expires(device_policy_manager_h handle, int *val
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               int ret = password.getExpires();
-               if (ret < 0) {
+               Status<int> status { 0 };
+               status = client.methodCall<int>("Password::getExpires");
+               if (status.get() < 0)
                        return -1;
-               }
 
-               *value = ret;
+               *value = status.get();
        } catch (...) {
                return -1;
        }
@@ -217,11 +215,12 @@ EXPORT_API int dpm_password_set_history(device_policy_manager_h handle, int valu
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return password.setHistory(value);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Password::setHistory", value);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -232,16 +231,15 @@ EXPORT_API int dpm_password_get_history(device_policy_manager_h handle, int *val
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               int ret = password.getHistory();
-               if (ret < 0) {
+               Status<int> status { 0 };
+               status = client.methodCall<int>("Password::getHistory");
+               if (status.get() < 0)
                        return -1;
-               }
 
-               *value = ret;
+               *value = status.get();
        } catch (...) {
                return -1;
        }
@@ -254,11 +252,12 @@ EXPORT_API int dpm_password_set_pattern(device_policy_manager_h handle, const ch
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(pattern, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return password.setPattern(pattern);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Password::setPattern", pattern);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -269,11 +268,12 @@ EXPORT_API int dpm_password_reset(device_policy_manager_h handle, const char *pa
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(passwd, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return password.reset(passwd);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Password::reset", passwd);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -283,11 +283,12 @@ EXPORT_API int dpm_password_enforce_change(device_policy_manager_h handle)
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return password.enforceChange();
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Password::enforceChange");
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -298,11 +299,12 @@ EXPORT_API int dpm_password_set_max_inactivity_time_device_lock(device_policy_ma
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return password.setMaxInactivityTimeDeviceLock(value);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Password::setMaxInactivityTimeDeviceLock", value);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -313,16 +315,15 @@ EXPORT_API int dpm_password_get_max_inactivity_time_device_lock(device_policy_ma
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               int ret = password.getMaxInactivityTimeDeviceLock();
-               if (ret < 0) {
+               Status<int> status { 0 };
+               status = client.methodCall<int>("Password::getMaxInactivityTimeDeviceLock");;
+               if (status.get() < 0)
                        return -1;
-               }
 
-               *value = ret;
+               *value = status.get();
        } catch (...) {
                return -1;
        }
@@ -330,38 +331,38 @@ EXPORT_API int dpm_password_get_max_inactivity_time_device_lock(device_policy_ma
        return DPM_ERROR_NONE;
 }
 
-EXPORT_API int dpm_password_set_status(device_policy_manager_h handle, dpm_password_status_e status)
+EXPORT_API int dpm_password_set_status(device_policy_manager_h handle, dpm_password_status_e stat)
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-       RET_ON_FAILURE(status >= DPM_PASSWORD_STATUS_NORMAL &&
-                                  status <= DPM_PASSWORD_STATUS_PATTERN_CHANGED,
+       RET_ON_FAILURE(stat >= DPM_PASSWORD_STATUS_NORMAL &&
+                                  stat <= DPM_PASSWORD_STATUS_PATTERN_CHANGED,
                                   DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return password.setStatus(status);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Password::setStatus", (int)stat);
+               return status.get();
        } catch (...) {
                return -1;
        }
 }
 
-EXPORT_API int dpm_password_get_status(device_policy_manager_h handle, dpm_password_status_e *status)
+EXPORT_API int dpm_password_get_status(device_policy_manager_h handle, dpm_password_status_e *stat)
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-       RET_ON_FAILURE(status, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(stat, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               int ret = password.getStatus();
-               if (ret < 0) {
+               Status<int> status { 0 };
+               status = client.methodCall<int>("Password::getStatus");
+               if (status.get() < 0)
                        return -1;
-               }
 
-               *status = (dpm_password_status_e)ret;
+               *stat = (dpm_password_status_e)status.get();
        } catch (...) {
                return -1;
        }
@@ -373,11 +374,12 @@ EXPORT_API int dpm_password_delete_pattern(device_policy_manager_h handle)
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return password.deletePattern();
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Password::deletePattern");
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -388,11 +390,12 @@ EXPORT_API int dpm_password_get_pattern(device_policy_manager_h handle, char **p
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(pattern, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               *pattern = ::strdup(password.getPattern().c_str());
+               Status<std::string> status { std::string() };
+               status = client.methodCall<std::string>("Password::getPattern");
+               *pattern = ::strdup(status.get().c_str());
        } catch (...) {
                return -1;
        }
@@ -405,11 +408,12 @@ EXPORT_API int dpm_password_set_maximum_character_occurrences(device_policy_mana
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return password.setMaximumCharacterOccurrences(value);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Password::setMaximumCharacterOccurrences", value);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -420,16 +424,15 @@ EXPORT_API int dpm_password_get_maximum_character_occurrences(device_policy_mana
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               int ret = password.getMaximumCharacterOccurrences();
-               if (ret < 0) {
+               Status<int> status { 0 };
+               status = client.methodCall<int>("Password::getMaximumCharacterOccurrences");
+               if (status.get() < 0)
                        return -1;
-               }
 
-               *value = ret;
+               *value = status.get();
        } catch (...) {
                return -1;
        }
@@ -442,11 +445,12 @@ EXPORT_API int dpm_password_set_maximum_numeric_sequence_length(device_policy_ma
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return password.setMaximumNumericSequenceLength(value);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Password::setMaximumNumericSequenceLength", value);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -457,16 +461,15 @@ EXPORT_API int dpm_password_get_maximum_numeric_sequence_length(device_policy_ma
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               int ret = password.getMaximumNumericSequenceLength();
-               if (ret < 0) {
+               Status<int> status { 0 };
+               status = client.methodCall<int>("Password::getMaximumNumericSequenceLength");
+               if (status.get() < 0)
                        return -1;
-               }
 
-               *value = ret;
+               *value = status.get();
        } catch (...) {
                return -1;
        }
@@ -480,10 +483,13 @@ EXPORT_API dpm_password_iterator_h dpm_password_create_iterator(device_policy_ma
 {
        RET_ON_FAILURE(handle, NULL);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
+
+       Status<std::vector<std::string>> status { std::vector<std::string>() };
+       status = client.methodCall<std::vector<std::string>>("Password::getForbiddenStrings");
 
-       return reinterpret_cast<dpm_password_iterator_h>(new dpm_password_iterator(password.getForbiddenStrings()));
+       dpm_password_iterator *iter = new dpm_password_iterator(status.get());
+       return reinterpret_cast<dpm_password_iterator_h>(iter);
 }
 
 EXPORT_API int dpm_password_iterator_next(dpm_password_iterator_h iter, const char **result)
@@ -522,14 +528,15 @@ EXPORT_API int dpm_password_set_forbidden_strings(device_policy_manager_h handle
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(strings, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        for (iter = 0; iter < length; iter++)
                forbiddenStrings.push_back(strings[iter]);
 
        try {
-               return password.setForbiddenStrings(forbiddenStrings);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Password::setForbiddenStrings", forbiddenStrings);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -539,11 +546,12 @@ EXPORT_API int dpm_password_set_recovery(device_policy_manager_h handle, int ena
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return password.setRecovery(enable);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Password::setRecovery", enable);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -554,16 +562,15 @@ EXPORT_API int dpm_password_get_recovery(device_policy_manager_h handle, int *en
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(enable, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               int ret = password.getRecovery();
-               if (ret < 0) {
+               Status<int> status { false };
+               status = client.methodCall<int>("Password::getRecovery");
+               if (status.get() < 0)
                        return -1;
-               }
 
-               *enable = ret;
+               *enable = status.get();
        } catch (...) {
                return -1;
        }
diff --git a/libs/policy-client.cpp b/libs/policy-client.cpp
new file mode 100644 (file)
index 0000000..8c819c3
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ *  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 <system_info.h>
+#include <klay/filesystem.h>
+
+#include "policy-client.h"
+
+namespace {
+
+const std::string SIGNAL_INTERFACE = "DevicePolicyManager::subscribeSignal";
+
+const std::string POLICY_MANAGER_ADDRESS = "/tmp/.device-policy-manager.sock";
+
+int GetPolicyEnforceMode()
+{
+       runtime::File policyManagerSocket(POLICY_MANAGER_ADDRESS);
+
+       if (policyManagerSocket.exists()) {
+               return 1;
+       }
+
+       return 0;
+}
+
+} // namespace
+
+
+DevicePolicyClient::DevicePolicyClient() noexcept :
+       maintenanceMode(GetPolicyEnforceMode())
+{
+}
+
+DevicePolicyClient::~DevicePolicyClient() noexcept
+{
+       disconnect();
+}
+
+int DevicePolicyClient::connect(const std::string& address) noexcept
+{
+       try {
+               client.reset(new rmi::Client(address));
+               if (maintenanceMode) {
+                       client->connect();
+               }
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
+
+       return 0;
+}
+
+int DevicePolicyClient::connect() noexcept
+{
+       return connect(POLICY_MANAGER_ADDRESS);
+}
+
+void DevicePolicyClient::disconnect() noexcept
+{
+       client.reset();
+}
+
+int DevicePolicyClient::subscribeSignal(const std::string& name,
+                                                                               const SignalHandler& handler,
+                                                                               void* data)
+{
+       auto dispatch = [handler, data](const std::string &name, const std::string &object) {
+               handler(name.c_str(), object.c_str(), data);
+       };
+
+       if (!maintenanceMode) {
+               return 0;
+       }
+
+       try {
+               return client->subscribe<std::string, std::string>(SIGNAL_INTERFACE, name, dispatch);
+       } catch (runtime::Exception& e) {
+               std::cout << e.what() << std::endl;
+               return -1;
+       }
+}
+
+int DevicePolicyClient::unsubscribeSignal(int id)
+{
+       if (!maintenanceMode) {
+               return 0;
+       }
+
+       return client->unsubscribe("", id);
+}
similarity index 63%
rename from policy-client.h
rename to libs/policy-client.h
index 4d5145d..3fa15a3 100644 (file)
 
 #include <klay/rmi/client.h>
 
-typedef std::function<void(const char*, const char*, void*)> PolicyChangeListener;
-typedef std::function<void(const char*, const char*, void*)> SignalListener;
+typedef std::function<void(const char*, const char*, void*)> SignalHandler;
 
-class DevicePolicyContext {
+class DevicePolicyClient {
 public:
-       typedef DevicePolicyContext PolicyControlContext;
-
-       DevicePolicyContext() noexcept;
-       ~DevicePolicyContext() noexcept;
+       DevicePolicyClient() noexcept;
+       ~DevicePolicyClient() noexcept;
 
        int connect() noexcept;
        int connect(const std::string& address) noexcept;
        void disconnect() noexcept;
 
-       int subscribePolicyChange(const std::string& name, const PolicyChangeListener& listener, void* data);
-       int unsubscribePolicyChange(int subscriberId);
-
-       int subscribeSignal(const std::string& name, const SignalListener& listener, void* data);
+       int subscribeSignal(const std::string& name, const SignalHandler& handler, void* data);
        int unsubscribeSignal(int subscriberId);
 
-       template<typename Policy, typename... Args>
-       Policy createPolicyInterface(Args&&... args) noexcept
-       {
-               return Policy(getPolicyControlContext(), std::forward<Args>(args)...);
-       }
-
        template<typename Type, typename... Args>
        Type methodCall(const std::string& method, Args&&... args)
        {
@@ -62,16 +50,10 @@ public:
        }
 
 private:
-       PolicyControlContext& getPolicyControlContext()
-       {
-               return *this;
-       }
-
-private:
        int maintenanceMode;
        std::unique_ptr<rmi::Client> client;
 };
 
-DevicePolicyContext& GetDevicePolicyContext(void* handle);
+DevicePolicyClient& GetDevicePolicyClient(void* handle);
 
 #endif //__POLICY_CLIENT_H__
similarity index 57%
rename from dpm/restriction.cpp
rename to libs/restriction.cpp
index 97021a4..662ddff 100644 (file)
  *  limitations under the License
  */
 
-#include "restriction.h"
-#include "restriction.hxx"
-#include "location.hxx"
-#include "bluetooth.hxx"
-#include "wifi.hxx"
+#include "dpm/restriction.h"
 
 #include "debug.h"
+#include "status.h"
 #include "policy-client.h"
 
-using namespace DevicePolicyManager;
-
 EXPORT_API int dpm_restriction_set_camera_state(device_policy_manager_h handle, int allow)
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return restriction.setCameraState(allow);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Media::setCameraState", allow);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -44,11 +40,12 @@ EXPORT_API int dpm_restriction_get_camera_state(device_policy_manager_h handle,
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               *is_allowed = restriction.getCameraState();
+               Status<bool> status { true };
+               status = client.methodCall<bool>("Media::getCameraState");
+               *is_allowed = status.get();
        } catch (...) {
                return -1;
        }
@@ -60,11 +57,12 @@ EXPORT_API int dpm_restriction_set_microphone_state(device_policy_manager_h hand
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return restriction.setMicrophoneState(allow);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Media::setMicrophoneState", allow);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -75,11 +73,12 @@ EXPORT_API int dpm_restriction_get_microphone_state(device_policy_manager_h hand
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               *is_allowed = restriction.getMicrophoneState();
+               Status<bool> status { true };
+               status = client.methodCall<bool>("Media::getMicrophoneState");
+               *is_allowed = status.get();
        } catch (...) {
                return -1;
        }
@@ -91,11 +90,12 @@ EXPORT_API int dpm_restriction_set_location_state(device_policy_manager_h handle
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       LocationPolicy location = client.createPolicyInterface<LocationPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return location.setLocationState(allow);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Location::setState", allow);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -106,11 +106,12 @@ EXPORT_API int dpm_restriction_get_location_state(device_policy_manager_h handle
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       LocationPolicy location = client.createPolicyInterface<LocationPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               *is_allowed = location.getLocationState();
+               Status<bool> status { true };
+               status = client.methodCall<bool>("Location::getState");
+               *is_allowed = status.get();
        } catch (...) {
                return -1;
        }
@@ -122,11 +123,12 @@ EXPORT_API int dpm_restriction_set_usb_debugging_state(device_policy_manager_h h
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return restriction.setUsbDebuggingState(allow);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Usb::setDebuggingState", allow);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -137,11 +139,12 @@ EXPORT_API int dpm_restriction_get_usb_debugging_state(device_policy_manager_h h
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               *is_allowed = restriction.getUsbDebuggingState();
+               Status<bool> status { true };
+               status = client.methodCall<bool>("Usb::getDebuggingState");
+               *is_allowed = status.get();
        } catch (...) {
                return -1;
        }
@@ -153,11 +156,12 @@ EXPORT_API int dpm_restriction_set_usb_tethering_state(device_policy_manager_h h
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return restriction.setUsbTetheringState(allow);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Usb::setTetheringState", allow);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -168,11 +172,12 @@ EXPORT_API int dpm_restriction_get_usb_tethering_state(device_policy_manager_h h
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               *is_allowed = restriction.getUsbTetheringState();
+               Status<bool> status { true };
+               status = client.methodCall<bool>("Usb::getTetheringState");
+               *is_allowed = status.get();
        } catch (...) {
                return -1;
        }
@@ -184,11 +189,12 @@ EXPORT_API int dpm_restriction_set_external_storage_state(device_policy_manager_
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return restriction.setExternalStorageState(allow);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Storage::setExternalStorageState", allow);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -199,11 +205,12 @@ EXPORT_API int dpm_restriction_get_external_storage_state(device_policy_manager_
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               *is_allowed = restriction.getExternalStorageState();
+               Status<bool> status { true };
+               status = client.methodCall<bool>("Storage::getExternalStorageState");
+               *is_allowed = status.get();
        } catch (...) {
                return -1;
        }
@@ -215,11 +222,12 @@ EXPORT_API int dpm_restriction_set_clipboard_state(device_policy_manager_h handl
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return restriction.setClipboardState(allow);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Media::setClipboardState", allow);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -230,11 +238,12 @@ EXPORT_API int dpm_restriction_get_clipboard_state(device_policy_manager_h handl
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               *is_allowed = restriction.getClipboardState();
+               Status<bool> status { true };
+               status = client.methodCall<bool>("Media::getClipboardState");
+               *is_allowed = status.get();
        } catch (...) {
                return -1;
        }
@@ -246,11 +255,12 @@ EXPORT_API int dpm_restriction_set_wifi_state(device_policy_manager_h handle, in
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return wifi.setState(allow);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Wifi::setState", allow);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -261,11 +271,12 @@ EXPORT_API int dpm_restriction_get_wifi_state(device_policy_manager_h handle, in
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               *is_allowed = wifi.getState();
+               Status<bool> status { true };
+               status = client.methodCall<bool>("Wifi::getState");
+               *is_allowed = status.get();
        } catch (...) {
                return -1;
        }
@@ -277,11 +288,12 @@ EXPORT_API int dpm_restriction_set_wifi_hotspot_state(device_policy_manager_h ha
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return wifi.setHotspotState(allow);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Wifi::setHotspotState", allow);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -292,11 +304,12 @@ EXPORT_API int dpm_restriction_get_wifi_hotspot_state(device_policy_manager_h ha
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               *is_allowed = wifi.getHotspotState();
+               Status<bool> status { true };
+               status = client.methodCall<bool>("Wifi::getHotspotState");
+               *is_allowed = status.get();
        } catch (...) {
                return -1;
        }
@@ -308,11 +321,12 @@ EXPORT_API int dpm_restriction_set_bluetooth_tethering_state(device_policy_manag
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return bluetooth.setTetheringState(allow);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Bluetooth::setTetheringState", allow);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -323,11 +337,12 @@ EXPORT_API int dpm_restriction_get_bluetooth_tethering_state(device_policy_manag
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               *is_allowed = bluetooth.getTetheringState();
+               Status<bool> status { true };
+               status = client.methodCall<bool>("Bluetooth::getTetheringState");
+               *is_allowed = status.get();
        } catch (...) {
                return -1;
        }
@@ -339,11 +354,12 @@ EXPORT_API int dpm_restriction_set_bluetooth_mode_change_state(device_policy_man
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return bluetooth.setModeChangeState(allow);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Bluetooth::setModeChangeState", allow);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -354,11 +370,12 @@ EXPORT_API int dpm_restriction_get_bluetooth_mode_change_state(device_policy_man
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               *is_allowed = bluetooth.getModeChangeState();
+               Status<bool> status { true };
+               status = client.methodCall<bool>("Bluetooth::getModeChangeState");
+               *is_allowed = status.get();
        } catch (...) {
                return -1;
        }
@@ -370,11 +387,12 @@ EXPORT_API int dpm_restriction_set_bluetooth_desktop_connectivity_state(device_p
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return bluetooth.setDesktopConnectivityState(allow);
+               Status<int> status { -1 };
+               status = client.methodCall<bool>("Bluetooth::setDesktopConnectivityState", allow);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -385,11 +403,12 @@ EXPORT_API int dpm_restriction_get_bluetooth_desktop_connectivity_state(device_p
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               *is_allowed = bluetooth.getDesktopConnectivityState();
+               Status<bool> status { true };
+               status = client.methodCall<bool>("Bluetooth::getDesktopConnectivityState");
+               *is_allowed = status.get();
        } catch (...) {
                return -1;
        }
@@ -401,11 +420,12 @@ EXPORT_API int dpm_restriction_set_bluetooth_pairing_state(device_policy_manager
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return bluetooth.setPairingState(allow);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Bluetooth::setPairingState", allow);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -416,11 +436,12 @@ EXPORT_API int dpm_restriction_get_bluetooth_pairing_state(device_policy_manager
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               *is_allowed = bluetooth.getPairingState();
+               Status<bool> status { true };
+               status = client.methodCall<bool>("Bluetooth::getPairingState");
+               *is_allowed = status.get();
        } catch (...) {
                return -1;
        }
@@ -432,11 +453,12 @@ EXPORT_API int dpm_restriction_set_popimap_email_state(device_policy_manager_h h
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return restriction.setPopImapEmailState(allow);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("EMail::setPopImapState", allow);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -447,11 +469,12 @@ EXPORT_API int dpm_restriction_get_popimap_email_state(device_policy_manager_h h
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               *is_allowed = restriction.getPopImapEmailState();
+               Status<bool> status { true };
+               status = client.methodCall<bool>("EMail::getPopImapState");
+               *is_allowed = status.get();
        } catch (...) {
                return -1;
        }
@@ -463,11 +486,12 @@ EXPORT_API int dpm_restriction_set_messaging_state(device_policy_manager_h handl
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return restriction.setMessagingState(sim_id, allow);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Telephony::setMessagingState", sim_id, allow);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -478,11 +502,12 @@ EXPORT_API int dpm_restriction_get_messaging_state(device_policy_manager_h handl
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               *is_allowed = restriction.getMessagingState(sim_id);
+               Status<bool> status { true };
+               status = client.methodCall<bool>("Telephony::getMessagingState", sim_id);
+               *is_allowed = status.get();
        } catch (...) {
                return -1;
        }
@@ -494,11 +519,12 @@ EXPORT_API int dpm_restriction_set_browser_state(device_policy_manager_h handle,
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return restriction.setBrowserState(allow);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Browser::setState", allow);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -509,11 +535,12 @@ EXPORT_API int dpm_restriction_get_browser_state(device_policy_manager_h handle,
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               *is_allowed = restriction.getBrowserState();
+               Status<bool> status { true };
+               status = client.methodCall<bool>("Browser::getState");
+               *is_allowed = status.get();
        } catch (...) {
                return -1;
        }
similarity index 64%
rename from dpm/security.cpp
rename to libs/security.cpp
index 328c4c7..78b77f3 100644 (file)
  *  limitations under the License
  */
 
-#include "security.h"
-#include "security.hxx"
-#include "storage.hxx"
+#include "dpm/security.h"
 
 #include "debug.h"
+#include "status.h"
 #include "policy-client.h"
 
-using namespace DevicePolicyManager;
-
 EXPORT_API int dpm_security_lockout_screen(device_policy_manager_h handle)
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &context = GetDevicePolicyContext(handle);
-       SecurityPolicy security = context.createPolicyInterface<SecurityPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
        try {
-               return security.lockoutScreen();
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Security::lockoutScreen");
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -40,10 +38,11 @@ EXPORT_API int dpm_security_set_internal_storage_encryption(device_policy_manage
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &context = GetDevicePolicyContext(handle);
-       SecurityPolicy security = context.createPolicyInterface<SecurityPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
        try {
-               return security.setInternalStorageEncryption(encrypt);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Security::setInternalStorageEncryption", encrypt);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -54,10 +53,11 @@ EXPORT_API int dpm_security_is_internal_storage_encrypted(device_policy_manager_
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(is_encrypted, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &context = GetDevicePolicyContext(handle);
-       SecurityPolicy security = context.createPolicyInterface<SecurityPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
        try {
-               *is_encrypted = security.isInternalStorageEncrypted();
+               Status<bool> status { false };
+               status = client.methodCall<int>("Security::isInternalStorageEncrypted");
+               *is_encrypted = status.get();
        } catch (...) {
                return -1;
        }
@@ -69,10 +69,11 @@ EXPORT_API int dpm_security_set_external_storage_encryption(device_policy_manage
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &context = GetDevicePolicyContext(handle);
-       SecurityPolicy security = context.createPolicyInterface<SecurityPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
        try {
-               return security.setExternalStorageEncryption(encrypt);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Security::setExternalStorageEncryption", encrypt);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -83,10 +84,11 @@ EXPORT_API int dpm_security_is_external_storage_encrypted(device_policy_manager_
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(is_encrypted, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &context = GetDevicePolicyContext(handle);
-       SecurityPolicy security = context.createPolicyInterface<SecurityPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
        try {
-               *is_encrypted = security.isExternalStorageEncrypted();
+               Status<bool> status { false };
+               status = client.methodCall<int>("Security::isExternalStorageEncrypted");
+               *is_encrypted = status.get();
        } catch (...) {
                return -1;
        }
@@ -101,10 +103,11 @@ EXPORT_API int dpm_security_wipe_data(device_policy_manager_h handle, dpm_securi
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(mask, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       StoragePolicy storage = client.createPolicyInterface<StoragePolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
        try {
-               return storage.wipeData(type);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Security::wipeData", (int)type);
+               return status.get();
        } catch (...) {
                return -1;
        }
similarity index 100%
rename from status.h
rename to libs/status.h
similarity index 73%
rename from dpm/storage.cpp
rename to libs/storage.cpp
index ca828af..60398bc 100644 (file)
  *  limitations under the License
  */
 
-#include "storage.h"
-#include "storage.hxx"
+#include "dpm/storage.h"
 
 #include "debug.h"
+#include "status.h"
 #include "policy-client.h"
 
-using namespace DevicePolicyManager;
-
-dpm_storage_policy_h dpm_context_acquire_storage_policy(dpm_context_h handle)
+dpm_storage_policy_h dpm_client_acquire_storage_policy(dpm_client_h handle)
 {
        return handle;
 }
 
-int dpm_context_release_storage_policy(dpm_storage_policy_h handle)
+int dpm_client_release_storage_policy(dpm_storage_policy_h handle)
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        return DPM_ERROR_NONE;
@@ -37,8 +35,7 @@ int dpm_storage_wipe_data(dpm_storage_policy_h handle, const dpm_wipe_type_e typ
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       StoragePolicy storage = client.createPolicyInterface<StoragePolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
        try {
                return storage.wipeData(type);
        } catch (...) {
similarity index 64%
rename from dpm/wifi.cpp
rename to libs/wifi.cpp
index bdcf094..ae056c8 100644 (file)
  *  limitations under the License
  */
 
-#include "wifi.h"
-#include "wifi.hxx"
+#include "dpm/wifi.h"
 
 #include "debug.h"
+#include "status.h"
 #include "policy-client.h"
 
-using namespace DevicePolicyManager;
-
 EXPORT_API int dpm_wifi_set_profile_change_restriction(device_policy_manager_h handle, int enable)
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return wifi.setProfileChangeRestriction(enable);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Wifi::setProfileChangeRestriction", enable);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -41,11 +40,12 @@ EXPORT_API int dpm_wifi_is_profile_change_restricted(device_policy_manager_h han
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(enable, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               *enable = wifi.isProfileChangeRestricted();
+               Status<bool> status { false };
+               status = client.methodCall<bool>("Wifi::isProfileChangeRestricted");
+               *enable = status.get();
        } catch (...) {
                return -1;
        }
@@ -57,11 +57,12 @@ EXPORT_API int dpm_wifi_set_network_access_restriction(device_policy_manager_h h
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return wifi.setNetworkAccessRestriction(enable);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Wifi::setNetworkAccessRestriction", enable);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -72,11 +73,12 @@ EXPORT_API int dpm_wifi_is_network_access_restricted(device_policy_manager_h han
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(enable, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               *enable = wifi.isNetworkAccessRestricted();
+               Status<bool> status { false };
+               status = client.methodCall<bool>("Wifi::isNetworkAccessRestricted");
+               *enable = status.get();
        } catch (...) {
                return -1;
        }
@@ -89,11 +91,12 @@ EXPORT_API int dpm_wifi_add_ssid_to_blocklist(device_policy_manager_h handle, co
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(ssid, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return wifi.addSsidToBlocklist(ssid);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Wifi::addSsidToBlocklist", ssid);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -104,11 +107,12 @@ EXPORT_API int dpm_wifi_remove_ssid_from_blocklist(device_policy_manager_h handl
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(ssid, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return wifi.removeSsidFromBlocklist(ssid);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Wifi::removeSsidFromBlocklist", ssid);
+               return status.get();
        } catch (...) {
                return -1;
        }
similarity index 71%
rename from dpm/zone.cpp
rename to libs/zone.cpp
index 9e51c67..ac99b4d 100755 (executable)
  *  limitations under the License
  */
 
-#include "zone.h"
-#include "krate.hxx"
+#include "dpm/zone.h"
 
 #include "array.h"
 #include "debug.h"
+#include "status.h"
 #include "policy-client.h"
 
-using namespace DevicePolicyManager;
-
 EXPORT_API int dpm_zone_create(device_policy_manager_h handle, const char* name, const char* pkgname)
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(name, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(pkgname, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       KratePolicy krate = client.createPolicyInterface<KratePolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return krate.createKrate(name, pkgname);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Zone::create", name, pkgname);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -44,11 +43,12 @@ EXPORT_API int dpm_zone_destroy(device_policy_manager_h handle, const char* name
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(name, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       KratePolicy krate = client.createPolicyInterface<KratePolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               return krate.removeKrate(name);
+               Status<int> status { -1 };
+               status = client.methodCall<int>("Zone::remove", name);
+               return status.get();
        } catch (...) {
                return -1;
        }
@@ -60,16 +60,15 @@ EXPORT_API int dpm_zone_get_state(device_policy_manager_h handle, const char* na
        RET_ON_FAILURE(name, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       KratePolicy krate = client.createPolicyInterface<KratePolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               int result = krate.getKrateState(name);
-               if (result == 0) {
+               Status<int> status { 0 };
+               status = client.methodCall<int>("Zone::getState", name);
+               if (status.get() == 0)
                        return DPM_ERROR_NO_DATA;
-               }
 
-               *state = (dpm_zone_state_e)result;
+               *state = (dpm_zone_state_e)status.get();
        } catch (...) {
                return -1;
        }
@@ -86,12 +85,12 @@ EXPORT_API int dpm_zone_foreach_name(device_policy_manager_h handle, dpm_zone_st
        RET_ON_FAILURE(callback, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(mask, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyContext &client = GetDevicePolicyContext(handle);
-       KratePolicy krate = client.createPolicyInterface<KratePolicy>();
+       DevicePolicyClient &client = GetDevicePolicyClient(handle);
 
        try {
-               std::vector<std::string> list = krate.getKrateList(state);
-               for (const std::string& name : list) {
+               Status<std::vector<std::string>> status { std::vector<std::string>() };
+               status = client.methodCall<std::vector<std::string>>("Zone::enumerate", (int)state);
+               for (const std::string& name : status.get()) {
                        if (!callback(name.c_str(), user_data))
                                break;
                }
diff --git a/location.cpp b/location.cpp
deleted file mode 100644 (file)
index 5a5bcb6..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- *  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 "status.h"
-#include "location.hxx"
-
-namespace DevicePolicyManager {
-
-struct LocationPolicy::Private {
-       Private(PolicyControlContext& ctxt) : context(ctxt) {}
-       PolicyControlContext& context;
-};
-
-LocationPolicy::LocationPolicy(LocationPolicy&& rhs) = default;
-LocationPolicy& LocationPolicy::operator=(LocationPolicy&& rhs) = default;
-
-LocationPolicy::LocationPolicy(const LocationPolicy& rhs)
-{
-       if (rhs.pimpl) {
-               pimpl.reset(new Private(*rhs.pimpl));
-       }
-}
-
-LocationPolicy& LocationPolicy::operator=(const LocationPolicy& rhs)
-{
-       if (!rhs.pimpl) {
-               pimpl.reset();
-       } else {
-               pimpl.reset(new Private(*rhs.pimpl));
-       }
-
-       return *this;
-}
-
-LocationPolicy::LocationPolicy(PolicyControlContext& ctxt) :
-       pimpl(new Private(ctxt))
-{
-}
-
-LocationPolicy::~LocationPolicy()
-{
-}
-
-int LocationPolicy::setLocationState(bool enable)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("LocationPolicy::setLocationState", enable);
-
-       return status.get();
-}
-
-bool LocationPolicy::getLocationState()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<bool> status { true };
-
-       status = context.methodCall<bool>("LocationPolicy::getLocationState");
-
-       return status.get();
-}
-
-} //namespace DevicePolicyManager
diff --git a/password.cpp b/password.cpp
deleted file mode 100644 (file)
index 8724c47..0000000
+++ /dev/null
@@ -1,375 +0,0 @@
-/*
- *  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 "status.h"
-#include "password.hxx"
-
-namespace DevicePolicyManager {
-
-struct PasswordPolicy::Private {
-       Private(PolicyControlContext& ctxt) : context(ctxt) {}
-       PolicyControlContext& context;
-};
-
-PasswordPolicy::PasswordPolicy(PasswordPolicy&& rhs) = default;
-PasswordPolicy& PasswordPolicy::operator=(PasswordPolicy&& rhs) = default;
-
-PasswordPolicy::PasswordPolicy(const PasswordPolicy& rhs)
-{
-       if (rhs.pimpl) {
-               pimpl.reset(new Private(*rhs.pimpl));
-       }
-}
-
-PasswordPolicy& PasswordPolicy::operator=(const PasswordPolicy& rhs)
-{
-       if (!rhs.pimpl) {
-               pimpl.reset();
-       } else {
-               pimpl.reset(new Private(*rhs.pimpl));
-       }
-
-       return *this;
-}
-
-PasswordPolicy::PasswordPolicy(PolicyControlContext &ctxt) :
-       pimpl(new Private(ctxt))
-{
-}
-
-PasswordPolicy::~PasswordPolicy()
-{
-}
-
-int PasswordPolicy::setQuality(const int quality)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("PasswordPolicy::setQuality", quality);
-
-       return status.get();
-}
-
-int PasswordPolicy::getQuality()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { 0 };
-
-       status = context.methodCall<int>("PasswordPolicy::getQuality");
-
-       return status.get();
-}
-
-int PasswordPolicy::setMinimumLength(int value)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { 0 };
-
-       status = context.methodCall<int>("PasswordPolicy::setMinimumLength", value);
-
-       return status.get();
-}
-
-int PasswordPolicy::getMinimumLength()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { 0 };
-
-       status = context.methodCall<int>("PasswordPolicy::getMinimumLength");
-
-       return status.get();
-}
-
-int PasswordPolicy::setMinComplexChars(int value)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("PasswordPolicy::setMinComplexChars", value);
-
-       return status.get();
-}
-
-int PasswordPolicy::getMinComplexChars()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { 0 };
-
-       status = context.methodCall<int>("PasswordPolicy::getMinComplexChars");
-
-       return status.get();
-}
-
-int PasswordPolicy::setMaximumFailedForWipe(int value)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("PasswordPolicy::setMaximumFailedForWipe", value);
-
-       return status.get();
-}
-
-int PasswordPolicy::getMaximumFailedForWipe()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { 0 };
-
-       status = context.methodCall<int>("PasswordPolicy::getMaximumFailedForWipe");
-
-       return status.get();
-}
-
-int PasswordPolicy::setExpires(int value)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("PasswordPolicy::setExpires", value);
-
-       return status.get();
-}
-
-int PasswordPolicy::getExpires()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { 0 };
-
-       status = context.methodCall<int>("PasswordPolicy::getExpires");
-
-       return status.get();
-}
-
-int PasswordPolicy::setHistory(int value)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("PasswordPolicy::setHistory", value);
-
-       return status.get();
-}
-
-int PasswordPolicy::getHistory()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { 0 };
-
-       status = context.methodCall<int>("PasswordPolicy::getHistory");
-
-       return status.get();
-}
-
-int PasswordPolicy::setPattern(const std::string &pattern)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("PasswordPolicy::setPattern", pattern);
-
-       return status.get();
-}
-
-int PasswordPolicy::reset(const std::string &passwd)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("PasswordPolicy::reset", passwd);
-
-       return status.get();
-}
-
-int PasswordPolicy::enforceChange()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("PasswordPolicy::enforceChange");
-
-       return status.get();
-}
-
-int PasswordPolicy::setMaxInactivityTimeDeviceLock(int value)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("PasswordPolicy::setMaxInactivityTimeDeviceLock", value);
-
-       return status.get();
-}
-
-int PasswordPolicy::getMaxInactivityTimeDeviceLock()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { 0 };
-
-       status = context.methodCall<int>("PasswordPolicy::getMaxInactivityTimeDeviceLock");;
-
-       return status.get();
-}
-
-int PasswordPolicy::setStatus(int status)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> rstatus { -1 };
-
-       rstatus = context.methodCall<int>("PasswordPolicy::setStatus", status);
-
-       return rstatus.get();
-}
-
-int PasswordPolicy::getStatus()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { 0 };
-
-       status = context.methodCall<int>("PasswordPolicy::getStatus");
-
-       return status.get();
-}
-
-int PasswordPolicy::deletePattern()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("PasswordPolicy::deletePattern");
-
-       return status.get();
-}
-
-std::string PasswordPolicy::getPattern()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<std::string> status { std::string() };
-
-       status = context.methodCall<std::string>("PasswordPolicy::getPattern");
-
-       return status.get();
-}
-
-int PasswordPolicy::setMaximumCharacterOccurrences(int value)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("PasswordPolicy::setMaximumCharacterOccurrences", value);
-
-       return status.get();
-}
-
-int PasswordPolicy::getMaximumCharacterOccurrences()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { 0 };
-
-       status = context.methodCall<int>("PasswordPolicy::getMaximumCharacterOccurrences");
-
-       return status.get();
-}
-
-int PasswordPolicy::setMaximumNumericSequenceLength(int value)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("PasswordPolicy::setMaximumNumericSequenceLength", value);
-
-       return status.get();
-}
-
-int PasswordPolicy::getMaximumNumericSequenceLength()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { 0 };
-
-       status = context.methodCall<int>("PasswordPolicy::getMaximumNumericSequenceLength");
-
-       return status.get();
-}
-
-int PasswordPolicy::setForbiddenStrings(const std::vector<std::string> &forbiddenStrings)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("PasswordPolicy::setForbiddenStrings", forbiddenStrings);
-
-       return status.get();
-}
-
-std::vector<std::string> PasswordPolicy::getForbiddenStrings()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<std::vector<std::string>> status { std::vector<std::string>() };
-
-       status = context.methodCall<std::vector<std::string>>("PasswordPolicy::getForbiddenStrings");
-
-       return status.get();
-}
-
-int PasswordPolicy::setRecovery(int enable)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("PasswordPolicy::setRecovery", enable);
-
-       return status.get();
-}
-
-int PasswordPolicy::getRecovery()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { false };
-
-       status = context.methodCall<int>("PasswordPolicy::getRecovery");
-
-       return status.get();
-}
-} /* namespace DevicePolicyManager */
diff --git a/policy-client.cpp b/policy-client.cpp
deleted file mode 100644 (file)
index ebcc32a..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- *  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 <system_info.h>
-#include <klay/filesystem.h>
-
-#include "policy-client.h"
-
-namespace {
-
-const std::string SUBSCRIBER_REGISTER = "Server::registerNotificationSubscriber";
-const std::string SUBSCRIBER_UNREGISTER = "Server::unregisterNotificationSubscriber";
-
-const std::string POLICY_MANAGER_ADDRESS = "/tmp/.device-policy-manager.sock";
-
-int GetPolicyEnforceMode()
-{
-       runtime::File policyManagerSocket(POLICY_MANAGER_ADDRESS);
-
-       if (policyManagerSocket.exists()) {
-               return 1;
-       }
-
-       return 0;
-}
-
-} // namespace
-
-
-DevicePolicyContext::DevicePolicyContext() noexcept :
-       maintenanceMode(GetPolicyEnforceMode())
-{
-}
-
-DevicePolicyContext::~DevicePolicyContext() noexcept
-{
-       disconnect();
-}
-
-int DevicePolicyContext::connect(const std::string& address) noexcept
-{
-       try {
-               client.reset(new rmi::Client(address));
-               if (maintenanceMode) {
-                       client->connect();
-               }
-       } catch (runtime::Exception& e) {
-               return -1;
-       }
-
-       return 0;
-}
-
-int DevicePolicyContext::connect() noexcept
-{
-       return connect(POLICY_MANAGER_ADDRESS);
-}
-
-void DevicePolicyContext::disconnect() noexcept
-{
-       client.reset();
-}
-
-int DevicePolicyContext::subscribePolicyChange(const std::string& name,
-                                                                                         const PolicyChangeListener& listener,
-                                                                                         void* data)
-{
-       auto listenerDispatcher = [listener, data](const std::string& policy, std::string &state) {
-               listener(policy.c_str(), state.c_str(), data);
-       };
-
-       if (!maintenanceMode) {
-               return 0;
-       }
-
-       try {
-               return client->subscribe<std::string, std::string>(SUBSCRIBER_REGISTER,
-                                                                                                                  name, listenerDispatcher);
-       } catch (runtime::Exception& e) {
-               std::cout << e.what() << std::endl;
-               return -1;
-       }
-}
-
-int DevicePolicyContext::unsubscribePolicyChange(int subscriberId)
-{
-       if (!maintenanceMode) {
-               return 0;
-       }
-
-       return client->unsubscribe(SUBSCRIBER_UNREGISTER, subscriberId);
-}
-
-int DevicePolicyContext::subscribeSignal(const std::string& name,
-                                                                               const SignalListener& listener,
-                                                                               void* data)
-{
-       auto listenerDispatcher = [listener, data](std::string &name, std::string &from, std::string &object) {
-               listener(from.c_str(), object.c_str(), data);
-       };
-
-       if (!maintenanceMode) {
-               return 0;
-       }
-
-       try {
-               return client->subscribe<std::string, std::string, std::string>(SUBSCRIBER_REGISTER,
-                                                                                                                                               name, listenerDispatcher);
-       } catch (runtime::Exception& e) {
-               std::cout << e.what() << std::endl;
-               return -1;
-       }
-}
-
-int DevicePolicyContext::unsubscribeSignal(int subscriberId)
-{
-       if (!maintenanceMode) {
-               return 0;
-       }
-
-       return client->unsubscribe(SUBSCRIBER_UNREGISTER, subscriberId);
-}
diff --git a/policy-context.hxx b/policy-context.hxx
deleted file mode 100644 (file)
index f5d872f..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- *  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 __DEVICE_POLICY_CONTEXT__
-#define __DEVICE_POLICY_CONTEXT__
-
-#include <memory>
-
-#include "policy-client.h"
-
-using PolicyControlContext = ::DevicePolicyContext::PolicyControlContext;
-
-#endif //!__DEVICE_POLICY_CONTEXT__
diff --git a/policy/administration.hxx b/policy/administration.hxx
deleted file mode 100644 (file)
index 9cc1fbb..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- *  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 __ADMINISTRATION_POLICY__
-#define __ADMINISTRATION_POLICY__
-
-#include "policy-context.hxx"
-
-namespace DevicePolicyManager {
-
-class AdministrationPolicy {
-public:
-       AdministrationPolicy(PolicyControlContext& ctxt);
-       ~AdministrationPolicy();
-
-       AdministrationPolicy(const AdministrationPolicy& rhs);
-       AdministrationPolicy(AdministrationPolicy&& rhs);
-
-       AdministrationPolicy& operator=(const AdministrationPolicy& rhs);
-       AdministrationPolicy& operator=(AdministrationPolicy&& rhs);
-
-       int registerPolicyClient(const std::string& name, uid_t uid);
-       int deregisterPolicyClient(const std::string& name, uid_t uid);
-
-private:
-       struct Private;
-       std::unique_ptr<Private> pimpl;
-};
-
-} // namespace DevicePolicyManager
-#endif // __ADMINISTRATION_POLICY__
diff --git a/policy/application.hxx b/policy/application.hxx
deleted file mode 100644 (file)
index c141441..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- *  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 __APPLICATION_POLICY__
-#define __APPLICATION_POLICY__
-
-#include "policy-context.hxx"
-
-namespace DevicePolicyManager {
-
-class ApplicationPolicy {
-public:
-       enum PrivilegeType {
-               PRIVILEGE_TYPE_WRT = 0,
-               PRIVILEGE_TYPE_CORE = 1
-       };
-
-       enum RestrictionMode {
-               RESTRICTION_MODE_ALL = 0x0F,
-               RESTRICTION_MODE_INSTALL = 0x01,
-               RESTRICTION_MODE_UNINSTALL = 0x02,
-               RESTRICTION_MODE_REINSTALL = 0x04,
-               RESTRICTION_MODE_MVOE = 0x08
-       };
-
-       ApplicationPolicy(PolicyControlContext& ctxt);
-       ~ApplicationPolicy();
-
-       ApplicationPolicy(const ApplicationPolicy& rhs);
-       ApplicationPolicy(ApplicationPolicy&& rhs);
-
-       ApplicationPolicy& operator=(const ApplicationPolicy& rhs);
-       ApplicationPolicy& operator=(ApplicationPolicy&& rhs);
-
-
-       int installPackage(const std::string& pkgpath);
-       int uninstallPackage(const std::string& pkgid);
-
-       int setModeRestriction(int mode);
-       int unsetModeRestriction(int mode);
-       int getModeRestriction();
-
-       int addPrivilegeToBlacklist(int type, const std::string& privilege);
-       int removePrivilegeFromBlacklist(int type, const std::string& privilege);
-       int checkPrivilegeIsBlacklisted(int type, const std::string& privilege);
-
-private:
-       struct Private;
-       std::unique_ptr<Private> pimpl;
-};
-
-} // namespace DevicePolicyManager
-#endif // __APPLICATION_POLICY__
diff --git a/policy/bluetooth.hxx b/policy/bluetooth.hxx
deleted file mode 100644 (file)
index fd2e3bb..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- *  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 __BLUETOOTH_POLICY__
-#define __BLUETOOTH_POLICY__
-
-#include "policy-context.hxx"
-
-namespace DevicePolicyManager {
-
-/**
- * This class provides APIs to control bluetooth functionalities
- * such as bluetooth device or uuid restriction
- */
-
-class BluetoothPolicy {
-public:
-       BluetoothPolicy(PolicyControlContext& ctxt);
-       ~BluetoothPolicy();
-
-       BluetoothPolicy(const BluetoothPolicy& rhs);
-       BluetoothPolicy(BluetoothPolicy&& rhs);
-
-       BluetoothPolicy& operator=(const BluetoothPolicy& rhs);
-       BluetoothPolicy& operator=(BluetoothPolicy&& rhs);
-
-       // for restriction CPIs
-       int setModeChangeState(bool enable);
-       bool getModeChangeState();
-       int setDesktopConnectivityState(bool enable);
-       bool getDesktopConnectivityState();
-       int setTetheringState(bool enable);
-       bool getTetheringState();
-       int setPairingState(bool enable);
-       bool getPairingState();
-
-       // for bluetooth CAPIs
-       int addDeviceToBlacklist(const std::string& mac);
-       int removeDeviceFromBlacklist(const std::string& mac);
-       int setDeviceRestriction(bool enable);
-       bool isDeviceRestricted();
-
-       int addUuidToBlacklist(const std::string& uuid);
-       int removeUuidFromBlacklist(const std::string& uuid);
-       int setUuidRestriction(bool enable);
-       bool isUuidRestricted();
-
-private:
-       struct Private;
-       std::unique_ptr<Private> pimpl;
-};
-
-} // namespace DevicePolicyManager
-#endif // __BLUETOOTH_POLICY__
diff --git a/policy/krate.hxx b/policy/krate.hxx
deleted file mode 100644 (file)
index a638c54..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- *  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 __KRATE_POLICY__
-#define __KRATE_POLICY__
-
-#include "policy-context.hxx"
-
-namespace DevicePolicyManager {
-
-class KratePolicy {
-public:
-       enum State {
-               Locked      = 0x01,
-               Running     = 0x02,
-       };
-
-       KratePolicy(PolicyControlContext& ctxt);
-       ~KratePolicy();
-
-       KratePolicy(const KratePolicy& rhs);
-       KratePolicy(KratePolicy&& rhs);
-
-       KratePolicy& operator=(const KratePolicy& rhs);
-       KratePolicy& operator=(KratePolicy&& rhs);
-
-       int createKrate(const std::string& name, const std::string& setupWizardAppid);
-       int removeKrate(const std::string& name);
-
-       int getKrateState(const std::string& name);
-
-       std::vector<std::string> getKrateList(int state);
-
-private:
-       struct Private;
-       std::unique_ptr<Private> pimpl;
-};
-
-} // namespace DevicePolicyManager
-#endif // __KRATE_POLICY__
diff --git a/policy/location.hxx b/policy/location.hxx
deleted file mode 100644 (file)
index 4f071c3..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- *  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 __LOCATION_POLICY__
-#define __LOCATION_POLICY__
-
-#include "policy-context.hxx"
-
-namespace DevicePolicyManager {
-
-class LocationPolicy {
-public:
-       LocationPolicy(PolicyControlContext& ctxt);
-       ~LocationPolicy();
-
-       LocationPolicy(const LocationPolicy& rhs);
-       LocationPolicy(LocationPolicy&& rhs);
-
-       LocationPolicy& operator=(const LocationPolicy& rhs);
-       LocationPolicy& operator=(LocationPolicy&& rhs);
-
-       int setLocationState(bool enable);
-       bool getLocationState();
-
-private:
-       struct Private;
-       std::unique_ptr<Private> pimpl;
-};
-
-} // namespace DevicePolicyManager
-
-#endif /* __LOCATION_POLICY__ */
diff --git a/policy/password.hxx b/policy/password.hxx
deleted file mode 100644 (file)
index f35d323..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- *  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 __PASSWORD_POLICY__
-#define __PASSWORD_POLICY__
-
-#include "policy-context.hxx"
-
-namespace DevicePolicyManager {
-
-class PasswordPolicy {
-public:
-       typedef enum {
-               DPM_PASSWORD_QUALITY_UNSPECIFIED     = 0x00,    /**< No requirements for password. */
-               DPM_PASSWORD_QUALITY_SIMPLE_PASSWORD = 0x01,    /**< Eas requirement for simple password */
-               DPM_PASSWORD_QUALITY_SOMETHING       = 0x10,    /**< Some kind password is required, but doesn't care what it is */
-               DPM_PASSWORD_QUALITY_NUMERIC         = 0x20,    /**< Containing at least numeric characters */
-               DPM_PASSWORD_QUALITY_ALPHABETIC      = 0x40,    /**< Containing at least alphabetic (or other symbol) characters */
-               DPM_PASSWORD_QUALITY_ALPHANUMERIC    = 0x80,    /**< Containing at least numeric and alphabetic characters */
-       } PasswordPolicyQuality;
-
-       typedef enum {
-               DPM_PASSWORD_STATUS_NORMAL,                  /**< Password normal status */
-               DPM_PASSWORD_STATUS_CHANGED,                 /**< Password successfully changed */
-               DPM_PASSWORD_STATUS_NOT_CHANGED,             /**< Password not changed */
-               DPM_PASSWORD_STATUS_CHANGE_REQUIRED ,        /**< Password change required */
-               DPM_PASSWORD_STATUS_MAX_ATTEMPTS_EXCEEDED,   /**< Password Max Attempts Exceeded*/
-
-               DPM_PASSWORD_STATUS_EXPIRED,                                    /**< Password expired */
-               DPM_PASSWORD_STATUS_RECOVERY_PASSWORD_FAILED,   /**< Device unlock failed by Password Recovery */
-               DPM_PASSWORD_STATUS_RECOVERY_PASSWORD_SUCCEEDED,/**< Device unlock succeeded by Password Recovery */
-
-               DPM_PASSWORD_STATUS_QUALITY_CHANGED,                    /**< Password quality successfully changed */
-               DPM_PASSWORD_STATUS_MIN_LENGTH_CHANGED,                 /**< Password min_length successfully changed */
-               DPM_PASSWORD_STATUS_COMPLEX_CHAR_CHANGED,               /**< Password complex_char successfully changed */
-               DPM_PASSWORD_STATUS_PATTERN_CHANGED,                    /**< Password pattern successfully changed */
-               DPM_PASSWORD_STATUS_MAX
-       } PasswordPolicyStatus;
-
-       PasswordPolicy(PolicyControlContext &ctxt);
-       ~PasswordPolicy();
-
-       PasswordPolicy(const PasswordPolicy& rhs);
-       PasswordPolicy(PasswordPolicy&& rhs);
-
-       PasswordPolicy& operator=(const PasswordPolicy& rhs);
-       PasswordPolicy& operator=(PasswordPolicy&& rhs);
-
-       int setQuality(int quality);
-       int getQuality();
-       int setMinimumLength(int value);
-       int getMinimumLength();
-       int setMinComplexChars(int value);
-       int getMinComplexChars();
-       int setMaximumFailedForWipe(int value);
-       int getMaximumFailedForWipe();
-       int setExpires(int value);
-       int getExpires();
-       int setHistory(int value);
-       int getHistory();
-       int setPattern(const std::string &pattern);
-       int reset(const std::string &passwd);
-       int enforceChange();
-       int setMaxInactivityTimeDeviceLock(int value);
-       int getMaxInactivityTimeDeviceLock();
-       int setStatus(int status);
-       int getStatus();
-       int deletePattern();
-       std::string getPattern();
-       int setMaximumCharacterOccurrences(int value);
-       int getMaximumCharacterOccurrences();
-       int setMaximumNumericSequenceLength(int value);
-       int getMaximumNumericSequenceLength();
-       int setForbiddenStrings(const std::vector<std::string> &forbiddenStrings);
-       std::vector<std::string> getForbiddenStrings();
-       int setRecovery(int enable);
-       int getRecovery();
-
-private:
-       struct Private;
-       std::unique_ptr<Private> pimpl;
-};
-
-} /* namespace DevicePolicyManager */
-#endif /* __PASSWORD_POLICY__ */
diff --git a/policy/restriction.hxx b/policy/restriction.hxx
deleted file mode 100644 (file)
index 8a5245a..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- *  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 __RESTRICTION_POLICY__
-#define __RESTRICTION_POLICY__
-
-#include "policy-context.hxx"
-
-namespace DevicePolicyManager {
-
-class RestrictionPolicy {
-public:
-       RestrictionPolicy(PolicyControlContext& ctxt);
-       ~RestrictionPolicy();
-
-       RestrictionPolicy(const RestrictionPolicy& rhs);
-       RestrictionPolicy(RestrictionPolicy&& rhs);
-
-       RestrictionPolicy& operator=(const RestrictionPolicy& rhs);
-       RestrictionPolicy& operator=(RestrictionPolicy&& rhs);
-
-       int setCameraState(bool enable);
-       bool getCameraState();
-
-       int setMicrophoneState(bool enable);
-       bool getMicrophoneState();
-
-       int setClipboardState(bool enable);
-       bool getClipboardState();
-
-       int setUsbDebuggingState(bool enable);
-       bool getUsbDebuggingState();
-
-       int setUsbTetheringState(bool enable);
-       bool getUsbTetheringState();
-
-       int setExternalStorageState(bool enable);
-       bool getExternalStorageState();
-
-       int setPopImapEmailState(bool enable);
-       bool getPopImapEmailState();
-
-       int setMessagingState(const std::string& sim_id, bool enable);
-       bool getMessagingState(const std::string& sim_id);
-
-       int setBrowserState(bool enable);
-       bool getBrowserState();
-
-private:
-       struct Private;
-       std::unique_ptr<Private> pimpl;
-};
-
-} // namespace DevicePolicyManager
-
-#endif /* __RESTRICTION_POLICY__ */
diff --git a/policy/security.hxx b/policy/security.hxx
deleted file mode 100644 (file)
index 9fa0801..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- *  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 __SECURITY_POLICY__
-#define __SECURITY_POLICY__
-
-#include "policy-context.hxx"
-
-namespace DevicePolicyManager {
-
-/**
- * This class provides APIs to control security functionalities
- * such as certificate installation, encryption and wipe
- */
-
-class SecurityPolicy {
-public:
-       SecurityPolicy(PolicyControlContext& ctxt);
-       ~SecurityPolicy();
-
-       SecurityPolicy(const SecurityPolicy& rhs);
-       SecurityPolicy(SecurityPolicy&& rhs);
-
-       SecurityPolicy& operator=(const SecurityPolicy& rhs);
-       SecurityPolicy& operator=(SecurityPolicy&& rhs);
-
-       int lockoutScreen();
-       int wipeData(int id);
-       int setInternalStorageEncryption(bool encrypt);
-       bool isInternalStorageEncrypted();
-       int setExternalStorageEncryption(bool encrypt);
-       bool isExternalStorageEncrypted();
-
-private:
-       struct Private;
-       std::unique_ptr<Private> pimpl;
-};
-
-} // namespace DevicePolicyManager
-#endif // __SECURITY_POLICY__
diff --git a/policy/smack.hxx b/policy/smack.hxx
deleted file mode 100644 (file)
index 8b3f13d..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- *  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
- */
-
-/**
- *  @file smack.hxx
- *  @brief SMACK agent internal interface.
- *  @author Dmytro Logachev (d.logachev@samsung.com)
- *  @date Created Oct 13, 2016
- *  @par In Samsung Ukraine R&D Center (SRK) under a contract between
- *  @par LLC "Samsung Electronics Ukraine Company" (Kyiv, Ukraine)
- *  @par and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
- *  @par Copyright: (c) Samsung Electronics Co, Ltd 2016. All rights reserved.
-**/
-
-#ifndef __SMACK_SECURITY_MONITOR__
-#define __SMACK_SECURITY_MONITOR__
-
-#include "policy-context.hxx"
-
-namespace DevicePolicyManager {
-
-/**
- * This class provides APIs to control smack security monitor functionalities
- */
-
-class SmackSecurityMonitor {
-public:
-       SmackSecurityMonitor(PolicyControlContext &ctxt);
-       ~SmackSecurityMonitor();
-
-       SmackSecurityMonitor(const SmackSecurityMonitor &rhs);
-       SmackSecurityMonitor(SmackSecurityMonitor &&rhs);
-
-       SmackSecurityMonitor &operator=(const SmackSecurityMonitor &rhs);
-       SmackSecurityMonitor &operator=(SmackSecurityMonitor &&rhs);
-
-       /**
-       * @brief       Returns SMACK report.
-       * @details     This API can be used for requesting current SMACK report
-       * @return      String contains SMACK report
-       */
-       std::string getReport();
-
-       /**
-        * @brief       Returns number of SMACK issues.
-        * @details     This API can be used for requesting current number of of SMACK issues
-        * @return      Number of threats
-        */
-       int getIssueCount();
-
-private:
-       struct Private;
-       std::unique_ptr<Private> pimpl;
-};
-
-} // namespace DevicePolicyManager
-#endif // __SMACK_SECURITY_MONITOR__
diff --git a/policy/storage.hxx b/policy/storage.hxx
deleted file mode 100644 (file)
index 31ca994..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- *  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 __STORAGE_POLICY__
-#define __STORAGE_POLICY__
-
-#include "policy-context.hxx"
-
-namespace DevicePolicyManager {
-
-class StoragePolicy {
-public:
-       enum {
-               WIPE_INTERNAL_STORAGE = (1 << 0),
-               WIPE_EXTERNAL_STORAGE = (1 << 1)
-       };
-
-       StoragePolicy(PolicyControlContext& ctxt);
-       ~StoragePolicy();
-
-       StoragePolicy(const StoragePolicy& rhs);
-       StoragePolicy(StoragePolicy&& rhs);
-
-       StoragePolicy& operator=(const StoragePolicy& rhs);
-       StoragePolicy& operator=(StoragePolicy&& rhs);
-
-       int wipeData(int id);
-
-private:
-       struct Private;
-       std::unique_ptr<Private> pimpl;
-};
-
-} // namespace DeivcePolicyManager
-
-#endif //!__STORAGE_POLICY__
diff --git a/policy/wifi.hxx b/policy/wifi.hxx
deleted file mode 100644 (file)
index e77c050..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- *  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 __WIFI_POLICY__
-#define __WIFI_POLICY__
-
-#include "policy-context.hxx"
-
-namespace DevicePolicyManager {
-
-/**
- * This class provides APIs to configure Wi-Fi related settings and manage Wi-Fi profiles.
- */
-
-class WifiPolicy {
-public:
-       WifiPolicy(PolicyControlContext& ctxt);
-       ~WifiPolicy();
-
-       WifiPolicy(const WifiPolicy& rhs);
-       WifiPolicy(WifiPolicy&& rhs);
-
-       WifiPolicy& operator=(const WifiPolicy& rhs);
-       WifiPolicy& operator=(WifiPolicy&& rhs);
-
-       int setState(bool enable);
-       bool getState();
-
-       int setHotspotState(bool enable);
-       bool getHotspotState();
-
-       int setProfileChangeRestriction(bool restrict);
-       bool isProfileChangeRestricted();
-
-       int setNetworkAccessRestriction(bool restrict);
-       bool isNetworkAccessRestricted();
-
-       int addSsidToBlocklist(const std::string& ssid);
-       int removeSsidFromBlocklist(const std::string& ssid);
-
-private:
-       struct Private;
-       std::unique_ptr<Private> pimpl;
-};
-
-} // namespace DevicePolicyManager
-#endif // __WIFI_POLICY__
diff --git a/restriction.cpp b/restriction.cpp
deleted file mode 100644 (file)
index 9decd7f..0000000
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- *  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 "status.h"
-#include "restriction.hxx"
-
-namespace DevicePolicyManager {
-
-struct RestrictionPolicy::Private {
-       Private(PolicyControlContext& ctxt) : context(ctxt) {}
-       PolicyControlContext& context;
-};
-
-RestrictionPolicy::RestrictionPolicy(RestrictionPolicy&& rhs) = default;
-RestrictionPolicy& RestrictionPolicy::operator=(RestrictionPolicy&& rhs) = default;
-
-RestrictionPolicy::RestrictionPolicy(const RestrictionPolicy& rhs)
-{
-       std::cout << "Copy Constructor" << std::endl;
-       if (rhs.pimpl) {
-               pimpl.reset(new Private(*rhs.pimpl));
-       }
-}
-
-RestrictionPolicy& RestrictionPolicy::operator=(const RestrictionPolicy& rhs)
-{
-       std::cout << "Copy Operator" << std::endl;
-       if (!rhs.pimpl) {
-               pimpl.reset();
-       } else {
-               pimpl.reset(new Private(*rhs.pimpl));
-       }
-
-       return *this;
-}
-
-RestrictionPolicy::RestrictionPolicy(PolicyControlContext& ctxt) :
-       pimpl(new Private(ctxt))
-{
-}
-
-RestrictionPolicy::~RestrictionPolicy()
-{
-}
-
-int RestrictionPolicy::setMicrophoneState(bool enable)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("RestrictionPolicy::setMicrophoneState", enable);
-
-       return status.get();
-}
-
-bool RestrictionPolicy::getMicrophoneState()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<bool> status { true };
-
-       status = context.methodCall<bool>("RestrictionPolicy::getMicrophoneState");
-
-       return status.get();
-}
-
-int RestrictionPolicy::setCameraState(bool enable)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("RestrictionPolicy::setCameraState", enable);
-
-       return status.get();
-}
-
-bool RestrictionPolicy::getCameraState()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<bool> status { true };
-
-       status = context.methodCall<bool>("RestrictionPolicy::getCameraState");
-
-       return status.get();
-}
-
-int RestrictionPolicy::setClipboardState(bool enable)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("RestrictionPolicy::setClipboardState", enable);
-
-       return status.get();
-}
-
-bool RestrictionPolicy::getClipboardState()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<bool> status { true };
-
-       status = context.methodCall<bool>("RestrictionPolicy::getClipboardState");
-
-       return status.get();
-}
-
-int RestrictionPolicy::setUsbDebuggingState(bool enable)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("RestrictionPolicy::setUsbDebuggingState", enable);
-
-       return status.get();
-}
-
-bool RestrictionPolicy::getUsbDebuggingState()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<bool> status { true };
-
-       status = context.methodCall<bool>("RestrictionPolicy::getUsbDebuggingState");
-
-       return status.get();
-}
-
-int RestrictionPolicy::setUsbTetheringState(bool enable)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("RestrictionPolicy::setUsbTetheringState", enable);
-
-       return status.get();
-}
-
-bool RestrictionPolicy::getUsbTetheringState()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<bool> status { true };
-
-       status = context.methodCall<bool>("RestrictionPolicy::getUsbTetheringState");
-
-       return status.get();
-}
-
-int RestrictionPolicy::setExternalStorageState(bool enable)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("RestrictionPolicy::setExternalStorageState", enable);
-
-       return status.get();
-}
-
-bool RestrictionPolicy::getExternalStorageState()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<bool> status { true };
-
-       status = context.methodCall<bool>("RestrictionPolicy::getExternalStorageState");
-
-       return status.get();
-}
-
-int RestrictionPolicy::setPopImapEmailState(bool enable)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("RestrictionPolicy::setPopImapEmailState", enable);
-
-       return status.get();
-}
-
-bool RestrictionPolicy::getPopImapEmailState()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<bool> status { true };
-
-       status = context.methodCall<bool>("RestrictionPolicy::getPopImapEmailState");
-
-       return status.get();
-}
-
-int RestrictionPolicy::setMessagingState(const std::string &sim_id, bool enable)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("RestrictionPolicy::setMessagingState", sim_id, enable);
-
-       return status.get();
-}
-
-bool RestrictionPolicy::getMessagingState(const std::string &sim_id)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<bool> status { true };
-
-       status = context.methodCall<bool>("RestrictionPolicy::getMessagingState", sim_id);
-
-       return status.get();
-}
-
-int RestrictionPolicy::setBrowserState(bool enable)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("RestrictionPolicy::setBrowserState", enable);
-
-       return status.get();
-}
-
-bool RestrictionPolicy::getBrowserState()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<bool> status { true };
-
-       status = context.methodCall<bool>("RestrictionPolicy::getBrowserState");
-
-       return status.get();
-}
-
-} //namespace DevicePolicyManager
diff --git a/security.cpp b/security.cpp
deleted file mode 100644 (file)
index cb2513d..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- *  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 "status.h"
-#include "security.hxx"
-
-namespace DevicePolicyManager {
-
-struct SecurityPolicy::Private {
-       Private(PolicyControlContext& ctxt) : context(ctxt) {}
-       PolicyControlContext& context;
-};
-
-SecurityPolicy::SecurityPolicy(SecurityPolicy&& rhs) = default;
-SecurityPolicy& SecurityPolicy::operator=(SecurityPolicy&& rhs) = default;
-
-SecurityPolicy::SecurityPolicy(const SecurityPolicy& rhs)
-{
-       if (rhs.pimpl) {
-               pimpl.reset(new Private(*rhs.pimpl));
-       }
-}
-
-SecurityPolicy& SecurityPolicy::operator=(const SecurityPolicy& rhs)
-{
-       if (!rhs.pimpl) {
-               pimpl.reset();
-       } else {
-               pimpl.reset(new Private(*rhs.pimpl));
-       }
-
-       return *this;
-}
-
-SecurityPolicy::SecurityPolicy(PolicyControlContext& ctxt) :
-       pimpl(new Private(ctxt))
-{
-}
-
-SecurityPolicy::~SecurityPolicy()
-{
-}
-
-int SecurityPolicy::lockoutScreen()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("SecurityPolicy::lockoutScreen");
-
-       return status.get();
-}
-
-int SecurityPolicy::setInternalStorageEncryption(bool encrypt)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("SecurityPolicy::setInternalStorageEncryption", encrypt);
-
-       return status.get();
-}
-
-bool SecurityPolicy::isInternalStorageEncrypted()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<bool> status { false };
-
-       status = context.methodCall<int>("SecurityPolicy::isInternalStorageEncrypted");
-
-       return status.get();
-}
-
-int SecurityPolicy::setExternalStorageEncryption(bool encrypt)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("SecurityPolicy::setExternalStorageEncryption", encrypt);
-
-       return status.get();
-}
-
-bool SecurityPolicy::isExternalStorageEncrypted()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<bool> status { false };
-
-       status = context.methodCall<int>("SecurityPolicy::isExternalStorageEncrypted");
-
-       return status.get();
-}
-
-} // namespace DevicePolicyManager
diff --git a/storage.cpp b/storage.cpp
deleted file mode 100644 (file)
index 2d98adc..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- *  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 "status.h"
-#include "storage.hxx"
-
-namespace DevicePolicyManager {
-
-struct StoragePolicy::Private {
-       Private(PolicyControlContext& ctxt) : context(ctxt) {}
-       PolicyControlContext& context;
-};
-
-StoragePolicy::StoragePolicy(StoragePolicy&& rhs) = default;
-StoragePolicy& StoragePolicy::operator=(StoragePolicy&& rhs) = default;
-
-StoragePolicy::StoragePolicy(const StoragePolicy& rhs)
-{
-       if (rhs.pimpl) {
-               pimpl.reset(new Private(*rhs.pimpl));
-       }
-}
-
-StoragePolicy& StoragePolicy::operator=(const StoragePolicy& rhs)
-{
-       if (!rhs.pimpl) {
-               pimpl.reset();
-       } else {
-               pimpl.reset(new Private(*rhs.pimpl));
-       }
-
-       return *this;
-}
-
-StoragePolicy::StoragePolicy(PolicyControlContext& ctx) :
-       pimpl(new Private(ctx))
-{
-}
-
-StoragePolicy::~StoragePolicy()
-{
-}
-
-int StoragePolicy::wipeData(int type)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("StoragePolicy::wipeData", type);
-
-       return status.get();
-}
-
-} //namespace DevicePolicyManager
diff --git a/wifi.cpp b/wifi.cpp
deleted file mode 100644 (file)
index 69d338e..0000000
--- a/wifi.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- *  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 "status.h"
-#include "wifi.hxx"
-
-namespace DevicePolicyManager {
-
-struct WifiPolicy::Private {
-       Private(PolicyControlContext& ctxt) : context(ctxt) {}
-       PolicyControlContext& context;
-};
-
-WifiPolicy::WifiPolicy(WifiPolicy&& rhs) = default;
-WifiPolicy& WifiPolicy::operator=(WifiPolicy&& rhs) = default;
-
-WifiPolicy::WifiPolicy(const WifiPolicy& rhs)
-{
-       if (rhs.pimpl) {
-               pimpl.reset(new Private(*rhs.pimpl));
-       }
-}
-
-
-WifiPolicy& WifiPolicy::operator=(const WifiPolicy& rhs)
-{
-       if (!rhs.pimpl) {
-               pimpl.reset();
-       } else {
-               pimpl.reset(new Private(*rhs.pimpl));
-       }
-
-       return *this;
-}
-
-WifiPolicy::WifiPolicy(PolicyControlContext& ctxt) :
-       pimpl(new Private(ctxt))
-{
-}
-
-WifiPolicy::~WifiPolicy()
-{
-}
-
-int WifiPolicy::setState(bool enable)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("WifiPolicy::setState", enable);
-
-       return status.get();
-}
-
-bool WifiPolicy::getState()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<bool> status { true };
-
-       status = context.methodCall<bool>("WifiPolicy::getState");
-
-       return status.get();
-}
-
-int WifiPolicy::setHotspotState(bool enable)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("WifiPolicy::setHotspotState", enable);
-
-       return status.get();
-}
-
-bool WifiPolicy::getHotspotState()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<bool> status { true };
-
-       status = context.methodCall<bool>("WifiPolicy::getHotspotState");
-
-       return status.get();
-}
-
-int WifiPolicy::setProfileChangeRestriction(bool enable)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("WifiPolicy::setProfileChangeRestriction", enable);
-
-       return status.get();
-}
-
-bool WifiPolicy::isProfileChangeRestricted()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<bool> status { false };
-
-       status = context.methodCall<bool>("WifiPolicy::isProfileChangeRestricted");
-
-       return status.get();
-}
-
-int WifiPolicy::setNetworkAccessRestriction(bool enable)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("WifiPolicy::setNetworkAccessRestriction", enable);
-
-       return status.get();
-}
-
-bool WifiPolicy::isNetworkAccessRestricted()
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<bool> status { false };
-
-       status = context.methodCall<bool>("WifiPolicy::isNetworkAccessRestricted");
-
-       return status.get();
-}
-
-int WifiPolicy::addSsidToBlocklist(const std::string& ssid)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("WifiPolicy::addSsidToBlocklist", ssid);
-
-       return status.get();
-}
-
-int WifiPolicy::removeSsidFromBlocklist(const std::string& ssid)
-{
-       PolicyControlContext& context = pimpl->context;
-
-       Status<int> status { -1 };
-
-       status = context.methodCall<int>("WifiPolicy::removeSsidFromBlocklist", ssid);
-
-       return status.get();
-}
-
-} // namespace DevicePolicyManager