Rework APIs according to the Tizen API rule 08/64408/86
authorSungjun, Lee <sjun221.lee@samsung.com>
Fri, 1 Apr 2016 04:41:23 +0000 (13:41 +0900)
committerseolhee, kim <s414.kim@samsung.com>
Tue, 26 Apr 2016 06:23:58 +0000 (15:23 +0900)
Change-Id: Ieb56c667787545ffa9a75aa7e2a3198c8f126b57
Signed-off-by: Sungjun, Lee <sjun221.lee@samsung.com>
Signed-off-by: Jaemin Ryu <jm77.ryu@samsung.com>
89 files changed:
doc/diagram/class/dpm.uml
doc/diagram/sequence/ipc-dispatch.uml
doc/doxygen.cfg
doc/dpm_doc.h [changed mode: 0755->0644]
doc/mainpage.dox
libs/CMakeLists.txt
libs/administration.cpp
libs/application.cpp
libs/bluetooth.cpp
libs/dpm/administration.cpp
libs/dpm/administration.h
libs/dpm/application.cpp
libs/dpm/application.h
libs/dpm/bluetooth.cpp
libs/dpm/bluetooth.h
libs/dpm/client-handle.cpp
libs/dpm/context.h [new file with mode: 0644]
libs/dpm/debug.h [moved from libs/dpm/capi-assert.h with 100% similarity]
libs/dpm/device-policy-client.h [deleted file]
libs/dpm/device-policy-manager.h [moved from libs/dpm/dpm.h with 82% similarity]
libs/dpm/misc.cpp [deleted file]
libs/dpm/misc.h [deleted file]
libs/dpm/password.cpp
libs/dpm/password.h
libs/dpm/restriction.cpp
libs/dpm/restriction.h
libs/dpm/security.cpp
libs/dpm/security.h
libs/dpm/storage.cpp [new file with mode: 0644]
libs/dpm/storage.h [new file with mode: 0644]
libs/dpm/wifi.cpp
libs/dpm/wifi.h
libs/dpm/zone.cpp
libs/dpm/zone.h
libs/misc.cpp [deleted file]
libs/password.cpp
libs/policy-client.cpp
libs/policy-client.h
libs/policy-context.hxx
libs/restriction.cpp
libs/security.cpp
libs/storage.cpp [new file with mode: 0644]
libs/wifi.cpp
libs/zone.cpp
packaging/device-policy-manager.spec
pam/cli/activate-zone
pam/module/zone.cpp
policy/administration.hxx
policy/application.hxx
policy/bluetooth.hxx
policy/password.hxx
policy/restriction.hxx
policy/security.hxx
policy/storage.hxx [moved from policy/misc.hxx with 60% similarity]
policy/wifi.hxx
policy/zone.hxx
server/CMakeLists.txt
server/administration.cpp
server/application.cpp
server/bluetooth.cpp
server/data/DefaultBundleManifest.xml
server/misc.cpp [deleted file]
server/packman.cpp
server/password.cpp
server/restriction.cpp
server/security.cpp
server/storage.cpp [new file with mode: 0644]
server/wifi.cpp
server/zone.cpp
tests/api/CMakeLists.txt
tests/api/bluetooth.c
tests/api/misc.c
tests/api/password.c
tests/api/restriction.c
tests/api/security.c
tests/api/storage.c [new file with mode: 0644]
tests/api/zone.c
tests/integration/CMakeLists.txt
tests/integration/administration.cpp
tests/integration/application.cpp
tests/integration/bluetooth.cpp
tests/integration/misc.cpp
tests/integration/restriction.cpp
tests/integration/security.cpp
tests/integration/zone.cpp
tests/unit/rmi.cpp
tools/cli/zone-tui.cpp
tools/zone-setup-wizard/include/zone-setup.h
tools/zone-setup-wizard/src/main.c

index 4a738c9..c676e29 100644 (file)
@@ -31,7 +31,7 @@ class Server
 Server *-- "1" IPC.Service
 }
 
-namespace DevicePolicyClient {
+namespace DevicePolicyContext {
 
 class PolicyClient <Request, Response>
 
index df37ffd..5ae5922 100644 (file)
@@ -1,8 +1,8 @@
 @startuml
 hide footbox
 
-actor DevicePolicyClient
-DevicePolicyClient --> Mainloop : Request remote method call
+actor DevicePolicyContext
+DevicePolicyContext --> Mainloop : Request remote method call
 activate Mainloop
 
 Mainloop -> Service : Event source callback
index aa7578d..25b7230 100644 (file)
@@ -745,7 +745,7 @@ WARN_LOGFILE           =
 
 INPUT                  = mainpage.dox     \
                          dpm_doc.h        \
-                         ../libs/dpm/device-policy-client.h \
+                         ../libs/dpm/context.h \
                          ../libs/dpm/password.h \
                          ../libs/dpm/zone.h
 
old mode 100755 (executable)
new mode 100644 (file)
index 9ff3491..77672c7
 
 
  /**
-  * @defgroup CAPI_DPM_FRAMEWORK Device Policy Manager
+  * @ingroup CAPI_SECURITY_FRAMEWORK
+  * @defgroup CAPI_SECURITY_DPM_MODULE Device Policy Manager
   * @brief The Device Policy Management framework provides APIs to create
   * security-aware applications that are useful in enterprise settings.
   * <br>
-  * @section CAPI_DPM_FRAMEWORK_OVERVIEW Overview
+  * @section CAPI_SECURITY_DPM_MODULE_OVERVIEW Overview
   * The primary purpose of the DPM(Device Policy Management) framework is
   * to support enterprise applications, which require integration with
   * policies enforced on the device to restrict their operations on
-  * some circumstance, such as exchange or corporate apps.<br>
+  * some circumstance, such as Exchange ActiveSync or corporate apps.<br>
   * The device policy API supports the policies listed in the below table.
   * <table>
   *  <tr>
@@ -49,7 +50,7 @@
   *       digit, and a special symbol.</td>
   *  </tr>
   *  <tr>
-  *   <td>Password expiration timeout</td>
+  *   <td>PasswordPolicy expiration timeout</td>
   *   <td>When the password will expire, expressed as a delta in milliseconds
   *       from when a device admin sets the expiration timeout.</td>
   *  </tr>
   *       the screen timeout occurs</td>
   *  </tr>
   * </table>
-  *
-  * <br>
-  * @subsection Architecture
-  * The Device Policy Management framework consists of the device policy
-  * manager and policy client library as shown in the figure.
-  * The device policy manager manages all policies enforced on the device
-  * and exposes APIs to administrator via the policy client library called
-  * libdpm. Thus, the policy client should link the policy client library
-  * to enforce policies.
-  * <br>
-  * @image html dpm.png "Tizen Device Policy Management Framework"
   * <br>
-  * @subsection PolicyGroup Policy Groups
-  * The Device Policy Management framework supposts following policy groups.
-  * Each policy group has dedicated header file. So, you should include it
-  * to use any API associated to the policy group.
-  * <center>
-  * <table>
-  * <tr>
-  *     <td><b>Policy Group</b></td>
-  *     <td><center><b>Description</b></center></td>
-  *     <td><b>Related header file</b></td>
-  * </tr>
-  * <tr>
-  *     <td>Password</td>
-  *     <td>Provide functionality to control password policy</td>
-  *     <td>dpm/password.h</td>
-  * </tr>
-  * <tr>
-  *     <td>Zone</td>
-  *     <td>Provide functionality to interact with application container</td>
-  *     <td>dpm/zone.h</td>
-  * </tr>
-  * </table>
-  * </center>
-  *
   * @subsection Privilege
   * In order to use privileged APIs, the client must be registered to the device policy
   * manager as the device policy client by enrollment process. Other unregistered
   * application are only allowed to subscribe policy change notification published by
   * the device policy manager.
   *<br>
+  * @ingroup CAPI_SECURITY_DPM_MODULE
   * @defgroup CAPI_DPM_POLICY_CLIENT_MODULE Policy Client Interface
   * @brief The policy client provides functions required to access the device policy APIs.
-  * @ingroup CAPI_DPM_FRAMEWORK
   * @section CAPI_DPM_POLICY_CLIENT_MODULE_HEADER Required Header
-  *  \#include <dpm/device-policy-client.h>
+  *  \#include <dpm/context.h>
   * @section CAPI_DPM_POLICY_CLIENT_MODULE_OVERVIEW Overview
   * The Policy Client module provides Device Policy Client handle which keeps track of
   * state between the device policy client and the device policy manager.
-  * The device policy clients must create the handle by using dpm_create_client()
+  * The device policy clients must create the handle by using dpm_context_create()
   * before attempting to use almost any of the device policy APIs, and the handle should be
-  * freed by using dpm_destroy_client() when interaction with the device policy manager
+  * freed by using dpm_context_destroy() when interaction with the device policy manager
   * is no longer required.
   *
-  * @defgroup CAPI_DPM_PASSWORD_POLICY_MODULE Password policy group
-  * @brief Password policy group provides APIs to control password policies.
-  * @ingroup CAPI_DPM_FRAMEWORK
+  * @ingroup CAPI_SECURITY_DPM_MODULE
+  * @defgroup CAPI_DPM_PASSWORD_POLICY_MODULE PasswordPolicy policy group
+  * @brief PasswordPolicy policy group provides APIs to control password policies.
   * @section CAPI_DPM_PASSWORD_POLICY_MODULE_HEADER Required Header
   *  \#include <dpm/password.h>
   * @section CAPI_DPM_PASSWORD_POLICY_MODULE_OVERVIEW Overview
-  * Password policy group provides APIs to control password policies such as
+  * PasswordPolicy policy group provides APIs to control password policies such as
   * password type, password quality and expiration date. Any API which requires privileges
   * is only available for the registered device policy client which is enrolled to the device
   * by enrollment process.
   *
-  * @defgroup CAPI_DPM_ZONE_POLICY_MODULE Zone policy group
-  * @brief Zone policy group provides APIs to control containers
-  * @ingroup CAPI_DPM_FRAMEWORK
+  * @ingroup CAPI_SECURITY_DPM_MODULE
+  * @defgroup CAPI_DPM_ZONE_POLICY_MODULE ZonePolicy policy group
+  * @brief ZonePolicy policy group provides APIs to control containers
   * @section CAPI_DPM_ZONE_POLICY_MODULE_HEADER Required Header
   * \#include <dpm/zone.h>
   * @section CAPI_DPM_ZONE_POLICY_MODULE_OVERVIEW Overview
index 2cd2bb7..27d96e7 100755 (executable)
@@ -23,17 +23,17 @@ The device policy manager manages all policies enforced on the device and expose
        <td><b>Related header file</b></td>
    </tr>
    <tr>
-       <td>Password</td>
+       <td>PasswordPolicy</td>
        <td>Provide functionality to control password policy</td>
        <td>dpm/password.h</td>
    </tr>
    <tr>
-       <td>Security</td>
+       <td>SecurityPolicy</td>
        <td>Provide functionality to control security such as encryption and device wipe</td>
        <td>dpm/security.h</td>
    </tr>
    <tr>
-       <td>Zone</td>
+       <td>ZonePolicy</td>
        <td>Provide functionality to control application containers</td>
        <td>dpm/zone.h</td>
    </tr>
index 5b06639..1e608ad 100755 (executable)
@@ -21,36 +21,38 @@ SET(LIB_SOVERSION "0")
 SET(PC_FILE "${PROJECT_NAME}.pc")
 
 SET(SOURCES policy-client.cpp
-                       administration.cpp
-                       application.cpp
-                       security.cpp
-                       password.cpp
+            administration.cpp
+            application.cpp
+            bluetooth.cpp
+            password.cpp
+            restriction.cpp
+            security.cpp
+            storage.cpp
                        wifi.cpp
                        zone.cpp
-                       misc.cpp
-                       restriction.cpp
-                       bluetooth.cpp
                        dpm/client-handle.cpp
-            dpm/security.cpp
+                       dpm/administration.cpp
+                       dpm/application.cpp
+                       dpm/bluetooth.cpp
                        dpm/password.cpp
+                       dpm/restriction.cpp
+            dpm/security.cpp
+            dpm/storage.cpp
                        dpm/wifi.cpp
                        dpm/zone.cpp
-                       dpm/application.cpp
-                       dpm/misc.cpp
-                       dpm/restriction.cpp
-                       dpm/bluetooth.cpp
 )
 
-SET(CAPI_INCLUDE_FILES  dpm/dpm.h
-                                               dpm/device-policy-client.h
+SET(CAPI_INCLUDE_FILES  dpm/device-policy-manager.h
+                                               dpm/context.h
                                                dpm/administration.h
                                                dpm/application.h
-                                               dpm/security.h
+                                               dpm/bluetooth.h
                                                dpm/password.h
                                                dpm/restriction.h
+                                               dpm/security.h
+                                               dpm/storage.h
                                                dpm/wifi.h
                                                dpm/zone.h
-                                               dpm/misc.h
 )
 
 SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,noexecstack")
index bf2f669..5358b65 100644 (file)
 
 namespace DevicePolicyManager {
 
-Administration::Administration(PolicyControlContext& ctx) :
+AdministrationPolicy::AdministrationPolicy(PolicyControlContext& ctx) :
     context(ctx)
 {
 }
 
-Administration::~Administration()
+AdministrationPolicy::~AdministrationPolicy()
 {
 }
 
-int Administration::registerPolicyClient(const std::string& name)
+int AdministrationPolicy::registerPolicyClient(const std::string& name)
 {
     try {
-        return context->methodCall<int>("Administration::registerPolicyClient", name);
+        return context->methodCall<int>("AdministrationPolicy::registerPolicyClient", name);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Administration::deregisterPolicyClient(const std::string& name)
+int AdministrationPolicy::deregisterPolicyClient(const std::string& name)
 {
     try {
-        return context->methodCall<int>("Administration::deregisterPolicyClient", name);
+        return context->methodCall<int>("AdministrationPolicy::deregisterPolicyClient", name);
     } catch (runtime::Exception& e) {
         return -1;
     }
index 4426df6..b9bc87c 100644 (file)
 
 namespace DevicePolicyManager {
 
-Application::Application(PolicyControlContext& ctxt) :
+ApplicationPolicy::ApplicationPolicy(PolicyControlContext& ctxt) :
     context(ctxt)
 {
 }
 
-Application::~Application()
+ApplicationPolicy::~ApplicationPolicy()
 {
 }
 
 
-int Application::setApplicationInstallationMode(const bool mode)
+int ApplicationPolicy::setApplicationInstallationMode(const bool mode)
 {
     try {
-        return context->methodCall<int>("Application::setApplicationInstallatioMode", mode);
+        return context->methodCall<int>("ApplicationPolicy::setApplicationInstallatioMode", mode);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-bool Application::getApplicationInstallationMode()
+bool ApplicationPolicy::getApplicationInstallationMode()
 {
     try {
-        return context->methodCall<int>("Application::getApplicationInstallationMode");
+        return context->methodCall<int>("ApplicationPolicy::getApplicationInstallationMode");
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Application::setApplicationUninstallationMode(const bool mode)
+int ApplicationPolicy::setApplicationUninstallationMode(const bool mode)
 {
     try {
-        return context->methodCall<int>("Application::setApplicationUninstallationMode", mode);
+        return context->methodCall<int>("ApplicationPolicy::setApplicationUninstallationMode", mode);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-bool Application::getApplicationUninstallationMode()
+bool ApplicationPolicy::getApplicationUninstallationMode()
 {
     try {
-        return context->methodCall<int>("Application::getApplicationUninstallationMode");
+        return context->methodCall<int>("ApplicationPolicy::getApplicationUninstallationMode");
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Application::setApplicationState(const std::string& appid, const int state)
+int ApplicationPolicy::setApplicationState(const std::string& appid, const int state)
 {
     try {
-        return context->methodCall<int>("Application::setApplicationState", appid, state);
+        return context->methodCall<int>("ApplicationPolicy::setApplicationState", appid, state);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Application::getApplicationState(const std::string& appid)
+int ApplicationPolicy::getApplicationState(const std::string& appid)
 {
     try {
-        return context->methodCall<int>("Application::getApplicationState", appid);
+        return context->methodCall<int>("ApplicationPolicy::getApplicationState", appid);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-std::vector<std::string> Application::getInstalledPackageList()
+std::vector<std::string> ApplicationPolicy::getInstalledPackageList()
 {
     try {
-        return context->methodCall<std::vector<std::string>>("Application::getInstalledPackageList");
+        return context->methodCall<std::vector<std::string>>("ApplicationPolicy::getInstalledPackageList");
     } catch (runtime::Exception& e) {
         return std::vector<std::string>();
     }
 }
 
-bool Application::isApplicationRunning(const std::string& appid)
+bool ApplicationPolicy::isApplicationRunning(const std::string& appid)
 {
     try {
-        return context->methodCall<bool>("Application::isApplicationRunning", appid);
+        return context->methodCall<bool>("ApplicationPolicy::isApplicationRunning", appid);
     } catch (runtime::Exception& e) {
         return false;
     }
 }
 
-bool Application::isApplicationInstalled(const std::string& appid)
+bool ApplicationPolicy::isApplicationInstalled(const std::string& appid)
 {
     try {
-        return context->methodCall<bool>("Application::isApplicationInstalled", appid);
+        return context->methodCall<bool>("ApplicationPolicy::isApplicationInstalled", appid);
     } catch (runtime::Exception& e) {
         return false;
     }
 }
 
-bool Application::isPackageInstalled(const std::string& pkgid)
+bool ApplicationPolicy::isPackageInstalled(const std::string& pkgid)
 {
     try {
-        return context->methodCall<bool>("Application::isPackageInstalled", pkgid);
+        return context->methodCall<bool>("ApplicationPolicy::isPackageInstalled", pkgid);
     } catch (runtime::Exception& e) {
         return false;
     }
 }
 
-int Application::installPackage(const std::string& pkgpath)
+int ApplicationPolicy::installPackage(const std::string& pkgpath)
 {
     try {
-        return context->methodCall<int>("Application::installPackage", pkgpath);
+        return context->methodCall<int>("ApplicationPolicy::installPackage", pkgpath);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Application::uninstallPackage(const std::string& pkgid)
+int ApplicationPolicy::uninstallPackage(const std::string& pkgid)
 {
     try {
-        return context->methodCall<int>("Application::uninstallPackage", pkgid);
+        return context->methodCall<int>("ApplicationPolicy::uninstallPackage", pkgid);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Application::disableApplication(const std::string& appid)
+int ApplicationPolicy::disableApplication(const std::string& appid)
 {
     try {
-        return context->methodCall<int>("Application::disableApplication", appid);
+        return context->methodCall<int>("ApplicationPolicy::disableApplication", appid);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Application::enableApplication(const std::string& appid)
+int ApplicationPolicy::enableApplication(const std::string& appid)
 {
     try {
-        return context->methodCall<int>("Application::enableApplication", appid);
+        return context->methodCall<int>("ApplicationPolicy::enableApplication", appid);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Application::startApplication(const std::string& appid)
+int ApplicationPolicy::startApplication(const std::string& appid)
 {
     try {
-        return context->methodCall<int>("Application::startApplication", appid);
+        return context->methodCall<int>("ApplicationPolicy::startApplication", appid);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Application::stopApplication(const std::string& appid)
+int ApplicationPolicy::stopApplication(const std::string& appid)
 {
     try {
-        return context->methodCall<int>("Application::stopApplication", appid);
+        return context->methodCall<int>("ApplicationPolicy::stopApplication", appid);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Application::wipeApplicationData(const std::string& appid)
+int ApplicationPolicy::wipeApplicationData(const std::string& appid)
 {
     try {
-        return context->methodCall<int>("Application::wipeApplicationData", appid);
+        return context->methodCall<int>("ApplicationPolicy::wipeApplicationData", appid);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Application::addPackageToBlacklist(const std::string& pkgid)
+int ApplicationPolicy::addPackageToBlacklist(const std::string& pkgid)
 {
     try {
-        return context->methodCall<int>("Application::addPackageToBlacklist", pkgid);
+        return context->methodCall<int>("ApplicationPolicy::addPackageToBlacklist", pkgid);
     } catch (runtime::Exception& e) {
         return -1;
     }
@@ -194,10 +194,10 @@ int Application::addPackageToBlacklist(const std::string& pkgid)
     return 0;
 }
 
-int Application::removePackageFromBlacklist(const std::string& pkgid)
+int ApplicationPolicy::removePackageFromBlacklist(const std::string& pkgid)
 {
     try {
-        return context->methodCall<int>("Application::removePackageFromBlacklist", pkgid);
+        return context->methodCall<int>("ApplicationPolicy::removePackageFromBlacklist", pkgid);
     } catch (runtime::Exception& e) {
         return -1;
     }
@@ -205,10 +205,10 @@ int Application::removePackageFromBlacklist(const std::string& pkgid)
     return 0;
 }
 
-int Application::checkPackageIsBlacklisted(const std::string& pkgid)
+int ApplicationPolicy::checkPackageIsBlacklisted(const std::string& pkgid)
 {
     try {
-        return context->methodCall<int>("Application::checkPackageIsBlacklisted", pkgid);
+        return context->methodCall<int>("ApplicationPolicy::checkPackageIsBlacklisted", pkgid);
     } catch (runtime::Exception& e) {
         return -1;
     }
index db16f9e..44aff64 100644 (file)
 
 namespace DevicePolicyManager {
 
-Bluetooth::Bluetooth(PolicyControlContext& ctxt) :
+BluetoothPolicy::BluetoothPolicy(PolicyControlContext& ctxt) :
     context(ctxt)
 {
 }
 
-Bluetooth::~Bluetooth()
+BluetoothPolicy::~BluetoothPolicy()
 {
 }
 
-int Bluetooth::addDeviceToBlacklist(const std::string& mac_address)
+int BluetoothPolicy::addDeviceToBlacklist(const std::string& mac)
 {
     try {
-        return context->methodCall<int>("Bluetooth::addDeviceToBlacklist", mac_address);
+        return context->methodCall<int>("BluetoothPolicy::addDeviceToBlacklist", mac);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Bluetooth::removeDeviceFromBlacklist(const std::string& mac_address)
+int BluetoothPolicy::removeDeviceFromBlacklist(const std::string& mac)
 {
     try {
-        return context->methodCall<int>("Bluetooth::removeDeviceFromBlacklist", mac_address);
+        return context->methodCall<int>("BluetoothPolicy::removeDeviceFromBlacklist", mac);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Bluetooth::setDeviceRestriction(const bool enable)
+int BluetoothPolicy::setDeviceRestriction(const bool enable)
 {
     try {
-        return context->methodCall<int>("Bluetooth::setDeviceRestriction", enable);
+        return context->methodCall<int>("BluetoothPolicy::setDeviceRestriction", enable);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-bool Bluetooth::isDeviceRestricted()
+bool BluetoothPolicy::isDeviceRestricted()
 {
     try {
-        return context->methodCall<bool>("Bluetooth::isDeviceRestricted");
+        return context->methodCall<bool>("BluetoothPolicy::isDeviceRestricted");
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Bluetooth::addUuidToBlacklist(const std::string& uuid)
+int BluetoothPolicy::addUuidToBlacklist(const std::string& uuid)
 {
     try {
-        return context->methodCall<int>("Bluetooth::addUuidToBlacklist", uuid);
+        return context->methodCall<int>("BluetoothPolicy::addUuidToBlacklist", uuid);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Bluetooth::removeUuidFromBlacklist(const std::string& uuid)
+int BluetoothPolicy::removeUuidFromBlacklist(const std::string& uuid)
 {
     try {
-        return context->methodCall<int>("Bluetooth::removeUuidFromBlacklist", uuid);
+        return context->methodCall<int>("BluetoothPolicy::removeUuidFromBlacklist", uuid);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Bluetooth::setUuidRestriction(const bool enable)
+int BluetoothPolicy::setUuidRestriction(const bool enable)
 {
     try {
-        return context->methodCall<int>("Bluetooth::setUuidRestriction", enable);
+        return context->methodCall<int>("BluetoothPolicy::setUuidRestriction", enable);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-bool Bluetooth::isUuidRestricted()
+bool BluetoothPolicy::isUuidRestricted()
 {
     try {
-        return context->methodCall<bool>("Bluetooth::isUuidRestricted");
+        return context->methodCall<bool>("BluetoothPolicy::isUuidRestricted");
     } catch (runtime::Exception& e) {
         return -1;
     }
index b24324a..b2571b1 100644 (file)
  */
 
 #include <cstring>
+#include <cassert>
 
 #include "administration.h"
 #include "administration.hxx"
 
-#include "capi-assert.h"
+#include "debug.h"
 #include "policy-client.h"
 
 using namespace DevicePolicyManager;
 
-int dpm_register_client(dpm_client_h handle, const char* name)
+dpm_admin_policy_h dpm_context_acquire_admin_policy(dpm_context_h handle)
 {
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Administration admin = client.createPolicyInterface<Administration>();
+    assert(handle);
+
+    DevicePolicyContext &client = GetDevicePolicyContext(handle);
+    return client.createPolicyInterface<AdministrationPolicy>();
+}
+
+int dpm_context_release_admin_policy(dpm_admin_policy_h handle)
+{
+    assert(handle);
+    delete &GetPolicyInterface<AdministrationPolicy>(handle);
+    return DPM_ERROR_NONE;
+}
+
+int dpm_admin_register_client(dpm_admin_policy_h handle, const char* name)
+{
+    AdministrationPolicy& admin = GetPolicyInterface<AdministrationPolicy>(handle);
     return admin.registerPolicyClient(name);
 }
 
-int dpm_deregister_client(dpm_client_h handle, const char* name)
+int dpm_admin_deregister_client(dpm_admin_policy_h handle, const char* name)
 {
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Administration admin = client.createPolicyInterface<Administration>();
+    AdministrationPolicy& admin = GetPolicyInterface<AdministrationPolicy>(handle);
     return admin.deregisterPolicyClient(name);
 }
index 6e8888b..1df7965 100644 (file)
 #ifndef __CAPI_ADMINISTRATION_POLICY_H__
 #define __CAPI_ADMINISTRATION_POLICY_H__
 
-#include <dpm/device-policy-client.h>
+#include <dpm/context.h>
 
 /**
  * @file administration.h
- * @brief This file provides APIs to register/deregister Device Policy Admin Client
+ * @brief This file provides APIs to register/deregister the device admin client
  */
 
 #ifdef __cplusplus
@@ -32,48 +32,90 @@ extern "C" {
  * @addtogroup  CAPI_DPM_ADMINISTRATION_POLICY_MODULE
  * @{
  */
+
+/**
+ * @brief       The device administration policy handle
+ * @since_tizen 3.0
+ * @see         dpm_context_acquire_admin_policy()
+ * @see         dpm_context_release_admin_policy()
+ */
+typedef void* dpm_admin_policy_h;
+
+/**
+ * @brief       Acquires the device administration policy handle.
+ * @details     This API acquires device administration policy handle required to call
+ *              the device admin APIs.
+ * @since_tizen 3.0
+ * @param[in]   handle The device policy context handle
+ * @return      Device administration policy handle on success, otherwise NULL
+ * @remark      The specific error code can be obtained by using the
+ *              get_last_result() method. Error codes are described in
+ *              exception section.
+ * @exception   #DPM_ERROR_NONE No error
+ * @exception   #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception   #DPM_ERROR_TIMED_OUT Time out
+ * @exception   #DPM_ERROR_PERMISSION_DENIED The application does not have
+ *              the privilege to register/deregister admin client.
+ * @see         dpm_context_release_password_policy()
+ * @see         get_last_result()
+ */
+DPM_API dpm_admin_policy_h dpm_context_acquire_admin_policy(dpm_context_h handle);
+
+/**
+ * @brief       Releases the device administration policy Handle.
+ * @details     This API must be called if interaction with the Device
+ *              Policy Manager is no longer required.
+ * @since_tizen 3.0
+ * @param[in]   handle The device administration policy handle
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
+ * @pre         The handle must be created by dpm_context_acquire_password_policy().
+ * @see         dpm_context_acquire_password_policy()
+ */
+DPM_API int dpm_context_release_admin_policy(dpm_admin_policy_h handle);
+
 /**
- * @brief       Registers Device Policy Admin Client.
- * @details     This API is used to register the Device Policy Admin Client to
- *              the Device Policy Manager. The Device Policy Admin Client must be
- *              registered to use Device Administration APIs.
+ * @brief       Registers device policy admin client.
+ * @details     This API is used to register the device policy admin client to
+ *              the device policy manager. The device policy admin client must be
+ *              registered to use the device policy APIs.
  * @since_tizen 3.0
- * @privlevel   public
- * @param[in]   handle Device Policy Client handle
- * @param[in]   name Device Policy Admin package name
+ * @param[in]   handle The administration policy handle
+ * @param[in]   name The name of the device policy admin package
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_TIMEOUT Timeout
+ * @retval      #DPM_ERROR_TIMEOUT Time out
  * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid package name
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_deregister_client()
+ * @pre         handle must be created by dpm_context_create()
+ * @see         dpm_context_acquire_admin_policy()
+ * @see         dpm_context_release_admin_policy()
+ * @see         dpm_admin_deregister_client()
  */
-DPM_API int dpm_register_client(dpm_client_h handle, const char* name);
+DPM_API int dpm_admin_register_client(dpm_admin_policy_h handle, const char* name);
 
 /**
  * @brief       Deregisters the Device Policy Admin Client.
  * @details     This API is used to deregister the Device Policy Client from
  *              the Device Policy Manager.
  * @since_tizen 3.0
- * @privlevel   public
- * @param[in]   handle Device Policy Client handle
- * @param[in]   name Device Policy Admin package name
+ * @param[in]   handle The administration policy handle
+ * @param[in]   name The name of the device policy admin package
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_TIMEOUT Timeout
+ * @retval      #DPM_ERROR_TIMEOUT Time out
  * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid package name
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_register_client()
+ * @pre         handle must be created by dpm_context_create()
+ * @see         dpm_context_acquire_admin_policy()
+ * @see         dpm_context_release_admin_policy()
+ * @see         dpm_admin_register_client()
  */
-DPM_API int dpm_deregister_client(dpm_client_h handle, const char* name);
+DPM_API int dpm_admin_deregister_client(dpm_admin_policy_h handle, const char* name);
 
 #ifdef __cplusplus
 }
index 9e72b97..2450bad 100644 (file)
  *  limitations under the License
  */
 
-#include <cassert>
-
+#include "application.h"
 #include "application.hxx"
 
-#include "application.h"
+#include "debug.h"
 #include "policy-client.h"
 
 using namespace DevicePolicyManager;
 
-int dpm_set_package_installation_mode(dpm_client_h handle, int mode)
+dpm_application_policy_h dpm_context_acquire_application_policy(dpm_context_h handle, const char* zone)
 {
-    assert(handle);
+    RET_ON_FAILURE(handle, NULL);
 
-    DevicePolicyClient& client = GetDevicePolicyClient(handle);
-    Application application = client.createPolicyInterface<Application>();
-    return application.setApplicationInstallationMode(mode);
+    DevicePolicyContext& client = GetDevicePolicyContext(handle);
+    //return client.createPolicyInterface<ApplicationPolicy>(zone);
+    return client.createPolicyInterface<ApplicationPolicy>();
 }
 
-int dpm_set_package_uninstallation_mode(dpm_client_h handle, int mode)
+int dpm_context_release_application_policy(dpm_context_h context, dpm_application_policy_h handle)
 {
-    assert(handle);
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient& client = GetDevicePolicyClient(handle);
-    Application application = client.createPolicyInterface<Application>();
-    return application.setApplicationUninstallationMode(mode);
+    delete &GetPolicyInterface<ApplicationPolicy>(handle);
+    return DPM_ERROR_NONE;
 }
 
-int dpm_get_package_installation_mode(dpm_client_h handle)
+int dpm_application_set_installation_mode(dpm_application_policy_h handle, int mode)
 {
-    assert(handle);
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Application application = client.createPolicyInterface<Application>();
-    return application.getApplicationInstallationMode();
+    ApplicationPolicy& application = GetPolicyInterface<ApplicationPolicy>(handle);
+    return application.setApplicationInstallationMode(mode);
 }
 
-int dpm_get_package_uninstallation_mode(dpm_client_h handle)
+int dpm_application_set_uninstallation_mode(dpm_application_policy_h handle, int mode)
 {
-    assert(handle);
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Application application = client.createPolicyInterface<Application>();
-    return application.getApplicationUninstallationMode();
+    ApplicationPolicy& application = GetPolicyInterface<ApplicationPolicy>(handle);
+    return application.setApplicationUninstallationMode(mode);
 }
 
-int dpm_set_application_state(dpm_client_h handle, const char* pkgid, dpm_application_state_e state)
+int dpm_application_get_installation_mode(dpm_application_policy_h handle, int *mode)
 {
-    assert(handle);
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+
+    ApplicationPolicy& application = GetPolicyInterface<ApplicationPolicy>(handle);
+    int ret = application.getApplicationInstallationMode();
+    if (ret < 0) {
+        return -1;
+    }
+    *mode = ret;
+    return DPM_ERROR_NONE;
+}
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Application application = client.createPolicyInterface<Application>();
-    return application.setApplicationState(pkgid, state);
+int dpm_application_get_uninstallation_mode(dpm_application_policy_h handle, int *mode)
+{
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(mode, DPM_ERROR_INVALID_PARAMETER);
+
+    ApplicationPolicy& application = GetPolicyInterface<ApplicationPolicy>(handle);
+    int ret = application.getApplicationUninstallationMode();
+    if (ret < 0) {
+        return -1;
+    }
+    *mode = ret;
+    return DPM_ERROR_NONE;
 }
 
-int dpm_get_application_state(dpm_client_h handle, const char* pkgid)
+int dpm_application_set_package_state(dpm_application_policy_h handle, const char* pkgid, dpm_package_state_e state)
 {
-    assert(handle);
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(pkgid, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Application application = client.createPolicyInterface<Application>();
-    return application.getApplicationState(pkgid);
+    ApplicationPolicy& application = GetPolicyInterface<ApplicationPolicy>(handle);
+    return application.setApplicationState(pkgid, state);
 }
 
-int dpm_add_package_to_blacklist(dpm_client_h handle, const char* pkgid)
+int dpm_application_get_package_state(dpm_application_policy_h handle, const char* pkgid, int *state)
 {
-    assert(handle);
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(pkgid, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER);
+
+    ApplicationPolicy& application = GetPolicyInterface<ApplicationPolicy>(handle);
+    int ret = application.getApplicationState(pkgid);
+    if (ret < 0) {
+        return -1;
+    }
+    *state = ret;
+    return DPM_ERROR_NONE;
+}
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Application application = client.createPolicyInterface<Application>();
+int dpm_application_add_package_to_blacklist(dpm_application_policy_h handle, const char* pkgid)
+{
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(pkgid, DPM_ERROR_INVALID_PARAMETER);
+
+    ApplicationPolicy& application = GetPolicyInterface<ApplicationPolicy>(handle);
     return application.addPackageToBlacklist(pkgid);
 }
 
-int dpm_remove_package_from_blacklist(dpm_client_h handle, const char* pkgid)
+int dpm_application_remove_package_from_blacklist(dpm_application_policy_h handle, const char* pkgid)
 {
-    assert(handle);
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(pkgid, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Application application = client.createPolicyInterface<Application>();
+    ApplicationPolicy& application = GetPolicyInterface<ApplicationPolicy>(handle);
     return application.removePackageFromBlacklist(pkgid);
 }
 
-int dpm_check_package_is_blacklisted(dpm_client_h handle, const char* pkgid)
+int dpm_application_check_package_is_blacklisted(dpm_application_policy_h handle, const char* pkgid, int *blacklisted)
 {
-    assert(handle);
-
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Application application = client.createPolicyInterface<Application>();
-    return application.checkPackageIsBlacklisted(pkgid);
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(pkgid, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(blacklisted, DPM_ERROR_INVALID_PARAMETER);
+
+    ApplicationPolicy& application = GetPolicyInterface<ApplicationPolicy>(handle);
+    int ret = application.checkPackageIsBlacklisted(pkgid);
+    if (ret < 0) {
+        return -1;
+    }
+
+    *blacklisted = ret;
+    return DPM_ERROR_NONE;
 }
index 1fcaf07..01d103c 100644 (file)
@@ -17,7 +17,7 @@
 #ifndef __CAPI_APPLICATION_POLICY_H__
 #define __CAPI_APPLICATION_POLICY_H__
 
-#include <dpm/device-policy-client.h>
+#include <dpm/context.h>
 
 /**
  * @file application.h
@@ -33,136 +33,171 @@ extern "C" {
  * @{
  */
 
- /**
-  * @brief       Enumeration for application state
-  * @since_tizen 3.0
-  */
- typedef enum {
-     APPLICATION_STATE_DISABLE = 0, /**< Application disable */
-     APPLICATION_STATE_ENABLE  = 1  /**< Application enable */
- } dpm_application_state_e;
-
- /**
-  * @brief       Enumeration for installation mode
-  * @since_tizen 3.0
-  */
- typedef enum {
-     PACKAGE_INSTALLATION_MODE_DISALLOW = 0, /**< Package installation disable */
-     PACKAGE_INSTALLATION_MODE_ALLOW  = 1    /**< Pasckage installation enable */
- } dpm_application_installation_mode_e;
-
- /**
-  * @brief       Enumeration for uninstallation mode
-  * @since_tizen 3.0
-  */
- typedef enum {
-     PACKAGE_UNINSTALLATION_MODE_DISALLOW = 0, /**< Package uninstallation disable */
-     package_UNINSTALLATION_MODE_ALLOW  = 1    /**< Package uninstallation enable */
- } dpm_application_uninstallation_mode_e;
-
- /**
-  * @brief       Sets the default mode for application installation.
-  * @details     If the mode is set to APPLICATION_INSTALLATION_MODE_DISALLOW,
-  *              no application can be installed on the device.
-  * @since_tizen 3.0
-  * @privlevel   public
-  * @privilege   %http://tizen.org/privilege/dpm.application
-  * @param[in]   handle Device Policy Client handle
-  * @param[in]   mode Installation mode to be set, one of APPLICATION_INSTALLATION_MODE_ALLOW or
-                 APPLICATION_INSTALLATION_MODE_DISALLOW
-  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
-  * @retval      #DPM_ERROR_NONE Successful
-  * @retval      #DPM_ERROR_TIMEOUT Timeout
-  * @retval      #DPM_ERROR_ACCESS_DENIED The application does not have
-  *              the privilege to call this API
-  * @pre         handle must be created by dpm_create_client()
-  * @post
-  * @see         dpm_create_client()
-  * @see         dpm_destroy_client()
-  * @see         dpm_get_package_installation_mode()
-  */
- DPM_API int dpm_set_package_installation_mode(dpm_client_h handle, int mode);
-
- /**
-  * @brief       Sets the default mode for application uninstallation.
-  * @details     If the mode is set to APPLICATION_UNINSTALLATION_MODE_DISALLOW,
-  *              no application can be uninstalled from the device.
-  * @since_tizen 3.0
-  * @privlevel   public
-  * @privilege   %http://tizen.org/privilege/dpm.application
-  * @param[in]   handle Device Policy Client handle
-  * @param[in]   mode Unstallation mode to be set, one of APPLICATION_UNINSTALLATION_MODE_ALLOW of
-                 APPLICATION_UNINSTALLATION_MODE_DISALLOW
-  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
-  * @retval      #DPM_ERROR_NONE Successful
-  * @retval      #DPM_ERROR_TIMEOUT TImeout
-  * @retval      #DPM_ERROR_ACCESS_DENIED The application does not have
-  *              the privilege to call this API
-  * @pre         handle must be created by dpm_create_client()
-  * @post
-  * @see         dpm_create_client()
-  * @see         dpm_destroy_client()
-  * @see         dpm_get_package_uninstallation_mode()
-  */
- DPM_API int dpm_set_package_uninstallation_mode(dpm_client_h handle, int mode);
-
- /**
-  * @brief       Gets the current installation mode for all packages.
-  * @details     The default mode is to allow any package to be installed.
-  * @since_tizen 3.0
-  * @param[in]   handle Device Policy Client handle
-  * @return      Current mode of operation, which is one of the following:
-  *              DPM_APPLICATION_INSTALLATION_MODE_ALLOWED or
-  *              DPM_APPLICATION_INSTALLATION_MODE_DISALLOWED
-  * @retval      #DPM_APPLICATION_INSTALLATION_MODE_ALLOWED Application installation is allowed
-  * @retval      #DPM_APPLICATION_INSTALLATION_MODE_DISALLOWED Application installation is not allowed
-  * @pre         handle must be created by dpm_create_client()
-  * @post
-  * @see         dpm_create_client()
-  * @see         dpm_destroy_client()
-  * @see         dpm_set_package_installation_mode()
-  */
- DPM_API int dpm_get_package_installation_mode(dpm_client_h handle);
-
- /**
-  * @brief       Gets the current uninstallation mode for all packages.
-  * @details     The default mode is to allow any package to be uninstalled.
-  * @since_tizen 3.0
-  * @param[in]   handle Device Policy Client handle
-  * @return      Current mode of operation, which is one of the following:
-  *              DPM_APPLICATION_UNINSTALLATION_MODE_ALLOWED or
-  *              DPM_APPLICATION_UNINSTALLATION_MODE_DISALLOWED
-  * @retval      #DPM_APPLICATION_UNINSTALLATION_MODE_ALLOWED Application uninstallation is allowed
-  * @retval      #DPM_APPLICATION_UNINSTALLATION_MODE_DISALLOWED Application uninstallation is not allowed
-  * @pre         handle must be created by dpm_create_client()
-  * @post
-  * @see         dpm_create_client()
-  * @see         dpm_destroy_client()
-  * @see          dpm_get_package_uninstallation_mode()
-  */
- DPM_API int dpm_get_package_uninstallation_mode(dpm_client_h handle);
+/**
+ * @brief       The application policy handle
+ * @since_tizen 3.0
+ * @see         dpm_context_acquire_application_policy()
+ * @see         dpm_context_release_application_policy()
+ */
+typedef void* dpm_application_policy_h;
+
+/**
+ * @brief       Acquires the application policy handle.
+ * @details     This API acquires application policy handle required to enforce
+ *              the application policies.
+ * @since_tizen 3.0
+ * @param[in]   handle The device policy context handle
+ * @param[in]   zone The container name
+ * @return      Application policy handle on success, otherwise NULL
+ * @remark      The specific error code can be obtained by using the
+ *              get_last_result() method. Error codes are described in
+ *              exception section.
+ * @exception   #DPM_ERROR_NONE Successful
+ * @exception   #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception   #DPM_ERROR_TIMED_OUT Time out
+ * @see         dpm_context_release_application_policy()
+ * @see         get_last_result()
+ */
+DPM_API dpm_application_policy_h dpm_context_acquire_application_policy(dpm_context_h handle, const char* zone);
+
+/**
+ * @brief       Releases the application policy handle.
+ * @details     This API must be called if interaction with the device
+ *              policy manager is no longer required.
+ * @since_tizen 3.0
+ * @param[in]   context The device policy context
+ * @param[in]   handle The application policy handle
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
+ * @pre         The handle must be created by dpm_context_acquire_application_policy().
+ * @see         dpm_context_acquire_application_policy()
+ */
+DPM_API int dpm_context_release_application_policy(dpm_context_h context, dpm_application_policy_h handle);
+
+/**
+ * @brief       Enumeration for application state
+ * @since_tizen 3.0
+ */
+typedef enum {
+    DPM_PACKAGE_STATE_DISABLE = 0, /**< Package disable */
+    DPM_PACKAGE_STATE_ENABLE  = 1  /**< Package enable */
+} dpm_package_state_e;
+
+/**
+ * @brief       Enumeration for installation mode
+ * @since_tizen 3.0
+ */
+typedef enum {
+    PACKAGE_INSTALLATION_MODE_DISALLOW = 0, /**< Package installation disable */
+    PACKAGE_INSTALLATION_MODE_ALLOW  = 1    /**< Pasckage installation enable */
+} dpm_package_installation_mode_e;
+
+/**
+ * @brief       Enumeration for uninstallation mode
+ * @since_tizen 3.0
+ */
+typedef enum {
+    PACKAGE_UNINSTALLATION_MODE_DISALLOW = 0, /**< Package uninstallation disable */
+    PACKAGE_UNINSTALLATION_MODE_ALLOW  = 1    /**< Package uninstallation enable */
+} dpm_package_uninstallation_mode_e;
+
+/**
+ * @brief       Sets the default mode for application installation.
+ * @details     If the mode is set to DPM_PACKAGE_INSTALLATION_MODE_DISALLOW,
+ *              no application can be installed on the device.
+ * @since_tizen 3.0
+ * @param[in]   handle The application policy handle
+ * @param[in]   mode The installation mode to be set, one of DPM_PACKAGE_INSTALLATION_MODE_ALLOW or
+ *              DPM_PACKAGE_INSTALLATION_MODE_DISALLOW
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE No error
+ * @retval      #DPM_ERROR_TIMEOUT Time out
+ * @retval      #DPM_ERROR_ACCESS_DENIED The application does not have
+ *              the privilege to call this API
+ * @pre         handle must be created by dpm_context_acquire_application_policy()
+ * @see         dpm_context_acquire_application_policy()
+ * @see         dpm_context_release_application_policy()
+ * @see         dpm_application_get_installation_mode()
+ */
+DPM_API int dpm_application_set_installation_mode(dpm_application_policy_h handle, int mode);
+
+/**
+ * @brief       Sets the default mode for application uninstallation.
+ * @details     If the mode is set to DPM_PACKAGE_UNINSTALLATION_MODE_DISALLOW,
+ *              no application can be uninstalled from the device.
+ * @since_tizen 3.0
+ * @param[in]   handle The application policy handle
+ * @param[in]   mode The unstallation mode to be set, one of DPM_PACKAGE_UNINSTALLATION_MODE_ALLOW of
+ *              DPM_PACKAGE_UNINSTALLATION_MODE_DISALLOW
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_TIMEOUT Time out
+ * @retval      #DPM_ERROR_ACCESS_DENIED The application does not have
+ *              the privilege to call this API
+ * @pre         handle must be created by dpm_context_acquire_application_policy()
+ * @see         dpm_context_acquire_application_policy()
+ * @see         dpm_context_release_application_policy()
+ * @see         dpm_application_get_uninstallation_mode()
+ */
+DPM_API int dpm_application_set_uninstallation_mode(dpm_application_policy_h handle, int mode);
+
+/**
+ * @brief       Gets the current installation mode for all packages.
+ * @details     The default mode is to allow any package to be installed.
+ * @since_tizen 3.0
+ * @param[in]   handle The application policy handle
+ * @param[out]  mode Current mode of operation, which is one of the following:
+ *              #DPM_PACKAGE_INSTALLATION_MODE_ALLOW Package installation is allowed
+ *              #DPM_PACKAGE_INSTALLATION_MODE_DISALLOW Package installation is not allowed
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_TIMEOUT Time out
+ * @pre         handle must be created by dpm_context_acquire_application_policy()
+ * @see         dpm_context_acquire_application_policy()
+ * @see         dpm_context_release_application_policy()
+ * @see         dpm_application_set_installation_mode()
+ */
+DPM_API int dpm_application_get_installation_mode(dpm_application_policy_h handle, int *mode);
+
+/**
+ * @brief       Gets the current uninstallation mode for all packages.
+ * @details     The default mode is to allow any package to be uninstalled.
+ * @since_tizen 3.0
+ * @param[in]   handle The application policy handle
+ * @param[out]  mode Current mode of operation, which is one of the following:
+ *              #DPM_PACKAGE_UNINSTALLATION_MODE_ALLOW Package uninstallation is allowed
+ *              #DPM_PACKAGE_UNINSTALLATION_MODE_DISALLOW Package uninstallation is not allowed
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_TIMEOUT Time out
+ * @pre         handle must be created by dpm_context_acquire_application_policy()
+ * @see         dpm_context_acquire_application_policy()
+ * @see         dpm_context_release_application_policy()
+ * @see         dpm_application_get_uninstallation_mode()
+ */
+DPM_API int dpm_application_get_uninstallation_mode(dpm_application_policy_h handle, int *mode);
 
 /**
  * @brief       Enables/disables an package without installation/uninstallation.
  * @details     Administrator can silently enable/disable any package without
  *              user interaction.
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.application
- * @param[in]   handle Device Policy Client handle
+ * @param[in]   handle The application policy handle
  * @param[in]   pkgid The package name
+ * @param[in]   state The package state
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_TIMEOUT Timeout
+ * @retval      #DPM_ERROR_TIMEOUT Time out
  * @retval      #DPM_ERROR_ACCESS_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_get_application_state()
+ * @pre         handle must be created by dpm_context_acquire_application_policy()
+ * @see         dpm_context_acquire_application_policy()
+ * @see         dpm_context_release_application_policy()
+ * @see         dpm_application_get_package_state()
  */
-DPM_API int dpm_set_application_state(dpm_client_h handle, const char* pkgid, dpm_application_state_e state);
+DPM_API int dpm_application_set_package_state(dpm_application_policy_h handle, const char* pkgid, dpm_package_state_e state);
 
 /**
  * @brief       Checks whether a geiven application package is enabled or disabled
@@ -170,68 +205,76 @@ DPM_API int dpm_set_application_state(dpm_client_h handle, const char* pkgid, dp
  *              without user interaction. The user can not install applications for which
  *              the administrator has disabled installation.
  * @since_tizen 3.0
- * @param[in]   handle Device Policy Client handle
+ * @param[in]   handle The application policy handle
  * @param[in]   pkgid The package name of the application whose installation is to be disabled
- * @return      Current state of the application package
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_set_application_state()
+ * @param[out]  state The current state of the application package
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_TIMEOUT Time out
+ * @pre         handle must be created by dpm_context_acquire_application_policy()
+ * @see         dpm_context_acquire_application_policy()
+ * @see         dpm_context_release_application_policy()
+ * @see         dpm_application_set_package_state()
  */
-DPM_API int dpm_get_application_state(dpm_client_h handle, const char* pkgid);
+DPM_API int dpm_application_get_package_state(dpm_application_policy_h handle, const char* pkgid, int *state);
 
 /**
  * @brief       Adds package to blacklist
  * @details     Administrator can use this API to disallow package installation
  *              corresponding to the given pkgid.
  * @since_tizen 3.0
- * @param[in]   handle Device Policy Client handle
+ * @param[in]   handle The application policy handle
  * @param[in]   pkgid The package name to be blacklisted
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_TIMEOUT Timeout
+ * @retval      #DPM_ERROR_TIMEOUT Time out
  * @retval      #DPM_ERROR_ACCESS_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_remove_package_from_blacklist()
- * @see         dpm_check_package_is_blacklisted()
+ * @pre         handle must be created by dpm_context_acquire_application_policy()
+ * @see         dpm_context_acquire_application_policy()
+ * @see         dpm_context_release_application_policy()
+ * @see         dpm_application_remove_package_from_blacklist()
+ * @see         dpm_application_check_package_is_blacklisted()
  */
-DPM_API int dpm_add_package_to_blacklist(dpm_client_h handle, const char* pkgid);
+DPM_API int dpm_application_add_package_to_blacklist(dpm_application_policy_h handle, const char* pkgid);
 
 /**
  * @brief       Removes package from blacklist
  * @details     Administrator can use this API to remove package from blacklist.
  * @since_tizen 3.0
- * @param[in]   handle Device Policy Client handle
- * @param[in]   pkgid The package name of the application whose installation is to be disabled
- * @return      Current state of the application package
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_add_package_to_blacklist()
- * @see         dpm_check_package_is_blacklisted()
+ * @param[in]   handle The application policy handle
+ * @param[in]   pkgid The package name which is removed from blacklist
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_TIMEOUT Time out
+ * @retval      #DPM_ERROR_ACCESS_DENIED The application does not have
+ *              the privilege to call this API
+ * @pre         handle must be created by dpm_context_acquire_application_policy()
+ * @see         dpm_context_acquire_application_policy()
+ * @see         dpm_context_release_application_policy()
+ * @see         dpm_application_add_package_to_blacklist()
+ * @see         dpm_application_check_package_is_blacklisted()
  */
-DPM_API int dpm_remove_package_from_blacklist(dpm_client_h handle, const char* pkgid);
+DPM_API int dpm_application_remove_package_from_blacklist(dpm_application_policy_h handle, const char* pkgid);
 
 /**
  * @brief       Checks whether a package is added to blacklist
  * @details     Administrator can use this API to check whether the package is blacklisted.
  *              Once package is added to blacklist, it is prhibited to install on the device.
  * @since_tizen 3.0
- * @param[in]   handle Device Policy Client handle
- * @param[in]   pkgid The package name of the application whose installation is to be disabled
- * @return      Current state of the application package
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_add_package_to_blacklist()
- * @see         dpm_remove_package_from_blacklist()
- */
-DPM_API int dpm_check_package_is_blacklisted(dpm_client_h handle, const char* pkgid);
+ * @param[in]   handle The application policy handle
+ * @param[in]   pkgid The package name of the application
+ * @param[out]  blacklisted TRUE if the package installation is disabled, else FALSE
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_TIMEOUT Time out
+ * @pre         handle must be created by dpm_context_acquire_application_policy()
+ * @see         dpm_context_acquire_application_policy()
+ * @see         dpm_context_release_application_policy()
+ * @see         dpm_application_add_package_to_blacklist()
+ * @see         dpm_application_remove_package_from_blacklist()
+ */
+DPM_API int dpm_application_check_package_is_blacklisted(dpm_application_policy_h handle, const char* pkgid, int *blacklisted);
 /**
  * @}
  */
index d6139b4..8ad172b 100644 (file)
 #include "bluetooth.h"
 #include "bluetooth.hxx"
 
-#include "capi-assert.h"
+#include "debug.h"
 #include "policy-client.h"
 
 using namespace DevicePolicyManager;
 
-int dpm_add_bluetooth_device_to_blacklist(dpm_client_h handle, const char* mac_address)
+dpm_bluetooth_policy_h dpm_context_acquire_bluetooth_policy(dpm_context_h handle)
+{
+    RET_ON_FAILURE(handle, NULL);
+
+    DevicePolicyContext &client = GetDevicePolicyContext(handle);
+    return client.createPolicyInterface<BluetoothPolicy>();
+}
+
+int dpm_context_release_bluetooth_policy(dpm_context_h context, dpm_bluetooth_policy_h handle)
+{
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+
+    delete &GetPolicyInterface<BluetoothPolicy>(handle);
+    return DPM_ERROR_NONE;
+}
+
+int dpm_bluetooth_add_device_to_blacklist(dpm_bluetooth_policy_h handle, const char* mac)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(mac_address, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(mac, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Bluetooth bluetooth = client.createPolicyInterface<Bluetooth>();
-    return bluetooth.addDeviceToBlacklist(mac_address);
+    BluetoothPolicy& bluetooth = GetPolicyInterface<BluetoothPolicy>(handle);
+    return bluetooth.addDeviceToBlacklist(mac);
 }
 
-int dpm_remove_bluetooth_device_from_blacklist(dpm_client_h handle, const char* mac_address)
+int dpm_bluetooth_remove_device_from_blacklist(dpm_bluetooth_policy_h handle, const char* mac)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(mac_address, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(mac, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Bluetooth bluetooth = client.createPolicyInterface<Bluetooth>();
-    return bluetooth.removeDeviceFromBlacklist(mac_address);
+    BluetoothPolicy& bluetooth = GetPolicyInterface<BluetoothPolicy>(handle);
+    return bluetooth.removeDeviceFromBlacklist(mac);
 }
 
-int dpm_set_bluetooth_device_restriction(dpm_client_h handle, const int enable)
+int dpm_bluetooth_set_device_restriction(dpm_bluetooth_policy_h handle, const int enable)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Bluetooth bluetooth = client.createPolicyInterface<Bluetooth>();
+    BluetoothPolicy& bluetooth = GetPolicyInterface<BluetoothPolicy>(handle);
     return bluetooth.setDeviceRestriction(enable);
 }
 
-int dpm_is_bluetooth_device_restricted(dpm_client_h handle)
+int dpm_bluetooth_is_device_restricted(dpm_bluetooth_policy_h handle, int *state)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Bluetooth bluetooth = client.createPolicyInterface<Bluetooth>();
-    return bluetooth.isDeviceRestricted();
+    BluetoothPolicy& bluetooth = GetPolicyInterface<BluetoothPolicy>(handle);
+    int ret = bluetooth.isDeviceRestricted();
+    if (ret < 0) {
+        return -1;
+    }
+    *state = ret;
+    return DPM_ERROR_NONE;
 }
 
-int dpm_add_bluetooth_uuid_to_blacklist(dpm_client_h handle, const char* uuid)
+int dpm_bluetooth_add_uuid_to_blacklist(dpm_bluetooth_policy_h handle, const char* uuid)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
     RET_ON_FAILURE(uuid, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Bluetooth bluetooth = client.createPolicyInterface<Bluetooth>();
+    BluetoothPolicy& bluetooth = GetPolicyInterface<BluetoothPolicy>(handle);
     return bluetooth.addUuidToBlacklist(uuid);
 }
 
-int dpm_remove_bluetooth_uuid_from_blacklist(dpm_client_h handle, const char* uuid)
+int dpm_bluetooth_remove_uuid_from_blacklist(dpm_bluetooth_policy_h handle, const char* uuid)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
     RET_ON_FAILURE(uuid, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Bluetooth bluetooth = client.createPolicyInterface<Bluetooth>();
+    BluetoothPolicy& bluetooth = GetPolicyInterface<BluetoothPolicy>(handle);
     return bluetooth.removeUuidFromBlacklist(uuid);
 }
 
-int dpm_set_bluetooth_uuid_restriction(dpm_client_h handle, const int enable)
+int dpm_bluetooth_set_uuid_restriction(dpm_bluetooth_policy_h handle, const int enable)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Bluetooth bluetooth = client.createPolicyInterface<Bluetooth>();
+    BluetoothPolicy& bluetooth = GetPolicyInterface<BluetoothPolicy>(handle);
     return bluetooth.setUuidRestriction(enable);
 }
 
-int dpm_is_bluetooth_uuid_restricted(dpm_client_h handle)
+int dpm_bluetooth_is_uuid_restricted(dpm_bluetooth_policy_h handle, int *state)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Bluetooth bluetooth = client.createPolicyInterface<Bluetooth>();
-    return bluetooth.isUuidRestricted();
+    BluetoothPolicy& bluetooth = GetPolicyInterface<BluetoothPolicy>(handle);
+    int ret = bluetooth.isUuidRestricted();
+    if (ret < 0) {
+        return -1;
+    }
+    *state = ret;
+    return DPM_ERROR_NONE;
 }
index e7a4776..b1bd1f2 100644 (file)
@@ -17,7 +17,7 @@
 #ifndef __CAPI_BLUETOOTH_POLICY_H__
 #define __CAPI_BLUETOOTH_POLICY_H__
 
-#include <dpm/device-policy-client.h>
+#include <dpm/context.h>
 
 /**
  * @file bluetooth.h
@@ -35,67 +35,103 @@ extern "C" {
  */
 
 /**
+ * @brief       The bluetooth policy handle
+ * @since_tizen 3.0
+ * @see         dpm_context_acquire_bluetooth_policy()
+ * @see         dpm_context_release_bluetooth_policy()
+ */
+typedef void* dpm_bluetooth_policy_h;
+
+/**
+ * @brief       Acquires the bluetooth policy handle.
+ * @details     This API acquires bluetooth policy handle required to call
+ *              the bluetooth policy APIs.
+ * @since_tizen 3.0
+ * @param[in]   handle The device policy context handle
+ * @return      Bluetooth policy handle on success, otherwise NULL
+ * @remark      The specific error code can be obtained by using the
+ *              get_last_result() method. Error codes are described in
+ *              exception section.
+ * @exception   #DPM_ERROR_NONE No error
+ * @exception   #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception   #DPM_ERROR_TIMED_OUT Time out
+ * @see         dpm_context_release_bluetooth_policy()
+ * @see         get_last_result()
+ */
+DPM_API dpm_bluetooth_policy_h dpm_context_acquire_bluetooth_policy(dpm_context_h handle);
+
+/**
+ * @brief       Releases the bluetooth policy handle.
+ * @details     This API must be called if interaction with the device
+ *              policy manager is no longer required.
+ * @since_tizen 3.0
+ * @param[in]   handle The device policy context
+ * @param[in]   handle The bluetooth policy handle
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
+ * @pre         The handle must be created by dpm_context_acquire_bluetooth_policy().
+ * @see         dpm_context_acquire_bluetooth_policy()
+ */
+DPM_API int dpm_context_release_bluetooth_policy(dpm_context_h context, dpm_bluetooth_policy_h handle);
+
+/**
  * @brief       Adds MAC address to blacklist
  * @details     An administrator can use this API to add new MAC address to
  *              blacklist
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.bluetooth
- * @param[in]   handle Device Policy Client handle
- * @param[in]   mac_address MAC Address that should be added
+ * @param[in]   handle The bluetooth policy handle
+ * @param[in]   address The MAC address that should be added
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_TIMEOUT Timeout
+ * @retval      #DPM_ERROR_TIMEOUT Time out
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_remove_bluetooth_device_from_blacklist()
+ * @pre         handle must be created by dpm_context_acquire_bluetooth_policy()
+ * @see         dpm_context_acquire_bluetooth_policy()
+ * @see         dpm_context_release_bluetooth_policy()
+ * @see         dpm_bluetooth_remove_device_from_blacklist()
  */
-DPM_API int dpm_add_bluetooth_device_to_blacklist(dpm_client_h handle, const char* mac_address);
+DPM_API int dpm_bluetooth_add_device_to_blacklist(dpm_bluetooth_policy_h handle, const char* address);
 
 /**
  * @brief       Removes MAC address from blacklist
  * @details     An administrator can use this API to remove MAC address from
  *              blacklist
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.bluetooth
- * @param[in]   handle Device Policy Client handle
- * @param[in]   mac_address MAC Address that should be removed
+ * @param[in]   handle The bluetooth policy handle
+ * @param[in]   address The MAC address that should be removed
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_TIMEOUT Timeout
+ * @retval      #DPM_ERROR_TIMEOUT Time out
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_add_bluetooth_device_to_blacklist()
+ * @pre         handle must be created by dpm_context_acquire_bluetooth_policy()
+ * @see         dpm_context_acquire_bluetooth_policy()
+ * @see         dpm_context_release_bluetooth_policy()
+ * @see         dpm_bluetooth_add_device_to_blacklist()
  */
-DPM_API int dpm_remove_bluetooth_device_from_blacklist(dpm_client_h handle, const char* mac_address);
+DPM_API int dpm_bluetooth_remove_device_from_blacklist(dpm_bluetooth_policy_h handle, const char* address);
 
 /**
  * @brief       Enables or disables device restriction of bluetooth
  * @details     An administrator can use this API to set whether the bluetooth
  *              is allowed or not by device restriction
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.bluetooth
- * @param[in]   handle Device Policy Client handle
+ * @param[in]   handle The bluetooth policy handle
  * @param[in]   enable If true, restrict the bluetooth pairing, if false, allow the bluetooth pairing
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_TIMEOUT Timeout
+ * @retval      #DPM_ERROR_TIMEOUT Time out
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_is_bluetooth_device_restricted()
+ * @pre         handle must be created by dpm_context_acquire_bluetooth_policy()
+ * @see         dpm_context_acquire_bluetooth_policy()
+ * @see         dpm_context_release_bluetooth_policy()
+ * @see         dpm_bluetooth_is_device_restricted()
  */
-DPM_API int dpm_set_bluetooth_device_restriction(dpm_client_h handle, const int enable);
+DPM_API int dpm_bluetooth_set_device_restriction(dpm_bluetooth_policy_h handle, const int enable);
 
 /**
  * @brief       Gets the allow status of the bluetooth's device restriction
@@ -103,77 +139,72 @@ DPM_API int dpm_set_bluetooth_device_restriction(dpm_client_h handle, const int
  *              bluetooth. The device restricted bluetooth will be worked by MAC
  *              address blacklist
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.bluetooth
- * @param[in]   handle Device Policy Client handle
- * @return      true if the bluetooth pairing has been restricted, else false
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_set_bluetooth_device_restriction()
+ * @param[in]   handle The bluetooth policy handle
+ * @param[out]  state true if the bluetooth pairing has been restricted, else false
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_TIMEOUT Time out
+ * @pre         handle must be created by dpm_context_acquire_bluetooth_policy()
+ * @see         dpm_context_acquire_bluetooth_policy()
+ * @see         dpm_context_release_bluetooth_policy()
+ * @see         dpm_bluetooth_set_device_restriction()
  */
-DPM_API int dpm_is_bluetooth_device_restricted(dpm_client_h handle);
+DPM_API int dpm_bluetooth_is_device_restricted(dpm_bluetooth_policy_h handle, int *state);
 
 /**
  * @brief       Adds UUID to blacklist
  * @details     An administrator can use this API to add new UUID to blacklist
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.bluetooth
- * @param[in]   handle Device Policy Client handle
- * @param[in]   uuid UUID that should be added
+ * @param[in]   handle The bluetooth policy handle
+ * @param[in]   uuid The UUID that should be added
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_TIMEOUT Timeout
+ * @retval      #DPM_ERROR_TIMEOUT Time out
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_remove_bluetooth_uuid_from_blacklist()
+ * @pre         handle must be created by dpm_context_acquire_bluetooth_policy()
+ * @see         dpm_context_acquire_bluetooth_policy()
+ * @see         dpm_context_release_bluetooth_policy()
+ * @see         dpm_bluetooth_remove_uuid_from_blacklist()
  */
-DPM_API int dpm_add_bluetooth_uuid_to_blacklist(dpm_client_h handle, const char* uuid);
+DPM_API int dpm_bluetooth_add_uuid_to_blacklist(dpm_bluetooth_policy_h handle, const char* uuid);
 
 /**
  * @brief       Removes UUID from blacklist
  * @details     An administrator can use this API to remove UUID from blacklist
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.bluetooth
- * @param[in]   handle Device Policy Client handle
- * @param[in]   uuid UUID that should be removed
+ * @param[in]   handle The bluetooth policy handle
+ * @param[in]   uuid The UUID that should be removed
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_TIMEOUT Timeout
+ * @retval      #DPM_ERROR_TIMEOUT Time out
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_add_bluetooth_uuid_to_blacklist()
+ * @pre         handle must be created by dpm_context_acquire_bluetooth_policy()
+ * @see         dpm_context_acquire_bluetooth_policy()
+ * @see         dpm_context_release_bluetooth_policy()
+ * @see         dpm_bluetooth_add_uuid_to_blacklist()
  */
-DPM_API int dpm_remove_bluetooth_uuid_from_blacklist(dpm_client_h handle, const char* uuid);
+DPM_API int dpm_bluetooth_remove_uuid_from_blacklist(dpm_bluetooth_policy_h handle, const char* uuid);
 
 /**
  * @brief       Enables or disables UUID restriction of bluetooth
  * @details     An administrator can use this API to set whether the bluetooth
  *              is allowed or not by UUID restriction
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.bluetooth
- * @param[in]   handle Device Policy Client handle
+ * @param[in]   handle The bluetooth policy handle
  * @param[in]   enable If true, restrict the bluetooth pairing, if false, allow the bluetooth pairing
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_TIMEOUT Timeout
+ * @retval      #DPM_ERROR_TIMEOUT Time out
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_is_bluetooth_uuid_restricted()
+ * @pre         handle must be created by dpm_context_acquire_bluetooth_policy()
+ * @see         dpm_context_acquire_bluetooth_policy()
+ * @see         dpm_context_release_bluetooth_policy()
+ * @see         dpm_bluetooth_is_uuid_restricted()
  */
-DPM_API int dpm_set_bluetooth_uuid_restriction(dpm_client_h handle, const int enable);
+DPM_API int dpm_bluetooth_set_uuid_restriction(dpm_bluetooth_policy_h handle, const int enable);
 
 /**
  * @brief       Gets the allow status of the bluetooth's UUID restriction
@@ -181,16 +212,17 @@ DPM_API int dpm_set_bluetooth_uuid_restriction(dpm_client_h handle, const int en
  *              bluetooth. The UUID restricted bluetooth will be worked by
  *              UUID blacklist
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.bluetooth
- * @param[in]   handle Device Policy Client handle
- * @return      true if the bluetooth pairing has been restricted, else false
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_set_bluetooth_uuid_restriction()
+ * @param[in]   handle The bluetooth policy handle
+ * @param[out]  true if the bluetooth pairing has been restricted, else false
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_TIMEOUT Time out
+ * @pre         handle must be created by dpm_context_acquire_bluetooth_policy()
+ * @see         dpm_context_acquire_bluetooth_policy()
+ * @see         dpm_context_release_bluetooth_policy()
+ * @see         dpm_bluetooth_set_uuid_restriction()
  */
-DPM_API int dpm_is_bluetooth_uuid_restricted(dpm_client_h handle);
+DPM_API int dpm_bluetooth_is_uuid_restricted(dpm_bluetooth_policy_h handle, int *state);
 
 /**
  * @}
index d502e8a..e878ffe 100644 (file)
 #include <cassert>
 #include <iostream>
 
-#include "device-policy-client.h"
-
+#include "context.h"
 #include "policy-client.h"
+#include "debug.h"
 
 #include "exception.h"
 
-DevicePolicyClient& GetDevicePolicyClient(void* handle)
+DevicePolicyContext& GetDevicePolicyContext(void* handle)
 {
     assert(handle);
-    return *reinterpret_cast<DevicePolicyClient*>(handle);
+    return *reinterpret_cast<DevicePolicyContext*>(handle);
 }
 
-DPM_API dpm_client_h dpm_create_client(void)
+dpm_context_h dpm_context_create(void)
 {
-    DevicePolicyClient *client = new(std::nothrow) DevicePolicyClient();
+    DevicePolicyContext* client = new(std::nothrow) DevicePolicyContext();
 
     assert(client);
 
@@ -40,28 +40,61 @@ DPM_API dpm_client_h dpm_create_client(void)
         return NULL;
     }
 
-    return reinterpret_cast<dpm_client_h>(client);
+    return reinterpret_cast<dpm_context_h>(client);
 }
 
-DPM_API void dpm_destroy_client(dpm_client_h handle)
+int dpm_context_destroy(dpm_context_h handle)
 {
     assert(handle);
 
-    delete &GetDevicePolicyClient(handle);
+    delete &GetDevicePolicyContext(handle);
+
+    return 0;
 }
 
-DPM_API int dpm_add_policy_change_listener(dpm_client_h handle, const char* name, dpm_policy_change_cb handler, void* user_data)
+int dpm_add_policy_changed_listener(dpm_context_h handle, const char* name, dpm_policy_changed_cb handler, void* user_data, int* id)
 {
     assert(handle);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    return client.subscribePolicyChange(name, handler, user_data);
+    DevicePolicyContext& client = GetDevicePolicyContext(handle);
+    int ret = client.subscribePolicyChange(name, handler, user_data);
+    if (ret < 0) {
+        return -1;
+    }
+
+    *id = ret;
+    return 0;
 }
 
-DPM_API void dpm_remove_policy_change_listener(dpm_client_h handle, int id)
+void dpm_remove_policy_change_listener(dpm_context_h handle, int id)
 {
     assert(handle);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
+    DevicePolicyContext& client = GetDevicePolicyContext(handle);
     client.unsubscribePolicyChange(id);
 }
+
+int dpm_context_add_signal_cb(dpm_context_h handle, const char* signal, dpm_signal_cb callback, void* user_data, int *id)
+{
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(signal, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(callback, DPM_ERROR_INVALID_PARAMETER);
+
+    DevicePolicyContext& context = GetDevicePolicyContext(handle);
+    int ret = context.subscribeSignal(signal, callback, user_data);
+    if (ret < 0) {
+        return -1;
+    }
+
+    *id = ret;
+    return 0;
+}
+
+int dpm_context_remove_signal_cb(dpm_context_h handle, int callback_id)
+{
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(callback_id >= 0, DPM_ERROR_INVALID_PARAMETER);
+
+    DevicePolicyContext& context = GetDevicePolicyContext(handle);
+    return context.unsubscribeSignal(callback_id);
+}
diff --git a/libs/dpm/context.h b/libs/dpm/context.h
new file mode 100644 (file)
index 0000000..e0048fe
--- /dev/null
@@ -0,0 +1,226 @@
+/*
+ *  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_CLIENT_H__
+#define __DEVICE_POLICY_CLIENT_H__
+
+#include <tizen.h>
+
+/**
+ * @file context.h
+ * @brief This file defines common data types required to device policy APIs.
+ */
+
+#ifndef DPM_API
+#define DPM_API __attribute__((visibility("default")))
+#endif // API
+
+#ifndef TRUE
+#define TRUE    1
+#endif
+
+#ifndef FALSE
+#define FALSE   0
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup  CAPI_DPM_POLICY_CLIENT_MODULE
+ * @{
+ */
+
+/**
+ * @brief       Called when a policy is changed.
+ * @since_tizen 3.0
+ * @param[in]   name The name of the policy
+ * @param[in]   state The current state of the policy
+ * @param[in]   user_data The user data passed from dpm_context_add_policy_changed_cb
+ * @see         dpm_context_add_policy_changed_cb()
+ * @see         dpm_context_remove_policy_changed_cb()
+ */
+typedef void (*dpm_policy_changed_cb)(const char* name, const char* state, void *user_data);
+
+/**
+ * @brief       The device policy context handle
+ * @details     The device policy context handle is an abstraction of the
+ *              logical connection between the device policy manager and
+ *              it's client. The device policy context handle must be
+ *              created by using dpm_context_create() before attempting to
+ *              use almost any of the device policy APIs, and it should
+ *              be freed when interaction with the device policy manager
+ *              is no longer required.
+ *              To release the handle, use dpm_context_destroy().
+ * @since_tizen 3.0
+ * @see         dpm_context_create()
+ * @see         dpm_context_destroy()
+ */
+typedef void* dpm_context_h;
+
+/**
+ * @brief       Enumeration of device policy API errors
+ * @since_tizen 3.0
+ */
+typedef enum {
+    DPM_ERROR_NONE                 = TIZEN_ERROR_NONE,                 /**< The operation was successful */
+    DPM_ERROR_INVALID_PARAMETER    = TIZEN_ERROR_INVALID_PARAMETER,    /**< Invalid parameter */
+    DPM_ERROR_CONNECTION_REFUSED   = TIZEN_ERROR_CONNECTION_REFUSED,   /**< Connection refused */
+    DPM_ERROR_TIMED_OUT            = TIZEN_ERROR_TIMED_OUT,            /**< Time out */
+    DPM_ERROR_PERMISSION_DENIED    = TIZEN_ERROR_PERMISSION_DENIED,    /**< Access privilege is not sufficient */
+    DPM_ERROR_NOT_SUPPORTED        = TIZEN_ERROR_NOT_SUPPORTED,        /**< Operation is not supported */
+    DPM_ERROR_NO_SUCH_FILE         = TIZEN_ERROR_NO_SUCH_FILE,         /**< No such file or directory */
+    DPM_ERROR_FILE_EXISTS          = TIZEN_ERROR_FILE_EXISTS,          /**< File exists */
+    DPM_ERROR_OUT_OF_MEMORY        = TIZEN_ERROR_OUT_OF_MEMORY         /**< Out of memory */
+} dpm_error_type_e;
+
+/**
+ * @brief       Creates the device policy context handle.
+ * @details     This API creates device policy context handle required to
+ *              the device policy APIs.
+ *              This API is also used to verify whether caller is authorized
+ *              or not.
+ * @since_tizen 3.0
+ * @return      Device policy context handle on success, otherwise NULL
+ * @remark      The specific error code can be obtained by using the
+ *              get_last_result() method. Error codes are described in
+ *              exception section.
+ * @exception   #DPM_ERROR_NONE No error
+ * @exception   #DPM_ERROR_CONNECTION_REFUSED Connection refused
+ * @see         dpm_context_destroy()
+ * @see         get_last_result()
+ */
+DPM_API dpm_context_h dpm_context_create(void);
+
+/**
+ * @brief       Releases the device policy context handle.
+ * @details     This API must be called if interaction with the device
+ *              policy manager is no longer required.
+ * @since_tizen 3.0
+ * @param[in]   handle device policy context handle
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre         The handle must be created by dpm_context_create()
+ * @see         dpm_context_create()
+ */
+DPM_API int dpm_context_destroy(dpm_context_h handle);
+
+/**
+ * @brief       Adds policy change callback to the device policy
+ *              manager.
+ * @details     This API can be used to subscribe policy change callback.
+ *              The callback specified to this API is asynchronously called when
+ *              policy is changed on runtime.
+ * @since_tizen 3.0
+ * @param[in]   handle device policy context handle
+ * @param[in]   name Policy name to subscribe
+ * @param[in]   callback The callback when policy is changed
+ * @param[in]   user_data User specified data passed to the callback
+ * @param[out]  id Policy change callback identifier
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
+ * @pre         The handle must be created by dpm_context_create().
+ * @see         dpm_context_create()
+ * @see         dpm_context_remove_policy_changed_cb()
+ */
+DPM_API int dpm_context_add_policy_changed_cb(dpm_context_h handle,
+                                              const char* name,
+                                              dpm_policy_changed_cb callback,
+                                              void* user_data,
+                                              int* id);
+/**
+ * @brief       Removes policy change callback from the device policy
+ *              manager.
+ * @details     This API should be called if policy change subscription is no longer
+ *              required.
+ * @since_tizen 3.0
+ * @param[in]   handle Device policy context handle
+ * @param[in]   id Policy change callback identifier
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
+ * @pre         The handle must be created by dpm_context_create().
+ * @pre         The cb_handle must be created by dpm_context_add_policy_changed_cb().
+ * @see         dpm_context_create()
+ * @see         dpm_context_add_policy_changed_cb()
+ */
+DPM_API int dpm_context_remove_policy_changed_cb(dpm_context_h handle,
+                                                 int id);
+/**
+ * @brief       Called when a zone raises a signal.
+ * @since_tizen 3.0
+ * @param[in]   name The zone name
+ * @param[in]   object The object name triggered the signal
+ * @param[in]   user_data The user data passed from dpm_zone_add_signal_cb
+ * @see         dpm_zone_add_signal_cb()
+ * @see         dpm_zone_remove_signal_cb()
+ */
+typedef void(*dpm_signal_cb)(const char* name, const char* object, void *user_data);
+
+/**
+ * @brief       Adds signal callback.
+ * @details     This API can be used to receive signals raised by the device policy manager.
+ *              The callback specified to this function is automatically called when
+ *              the device policy manager raises signal.
+ * @since_tizen 3.0
+ * @param[in]   context The device policy context handle
+ * @param[in]   signal The signal name to receive
+ * @param[in]   callback The signal callback
+ * @param[in]   user_data The user data passed to the callback function
+ * @param[out]  id Signal identifier
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
+ * @pre         The handle must be created by dpm_context_create().
+ * @see         dpm_context_create()
+ * @see         dpm_context_destroy()
+ * @see         dpm_context_remove_signal_cb()
+ */
+DPM_API int dpm_context_add_signal_cb(dpm_context_h context, const char* signal,
+                                      dpm_signal_cb callback, void* user_data,
+                                      int* id);
+
+/**
+ * @brief       Removes signal callback.
+ * @details     This API removes signal callback.
+ * @since_tizen 3.0
+ * @param[in]   context The device policy context
+ * @param[in]   id Signal identifier
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
+ * @pre         The context must be created by dpm_context_create().
+ * @see         dpm_context_create()
+ * @see         dpm_context_destroy()
+ * @see         dpm_context_add_signal_cb()
+ */
+DPM_API int dpm_context_remove_signal_cb(dpm_context_h context, int id);
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __DEVICE_POLICY_CLIENT_H__ */
similarity index 100%
rename from libs/dpm/capi-assert.h
rename to libs/dpm/debug.h
diff --git a/libs/dpm/device-policy-client.h b/libs/dpm/device-policy-client.h
deleted file mode 100644 (file)
index a8eaccb..0000000
+++ /dev/null
@@ -1,167 +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_CLIENT_H__
-#define __DEVICE_POLICY_CLIENT_H__
-
-#include <tizen.h>
-
-/**
- * @file security.h
- * @brief This file defines common data types required to device policy APIs
- */
-
-#ifndef DPM_API
-#define DPM_API __attribute__((visibility("default")))
-#endif // API
-
-#ifndef TRUE
-#define TRUE    1
-#endif
-
-#ifndef FALSE
-#define FALSE   0
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @addtogroup  CAPI_DPM_POLICY_CLIENT_MODULE
- * @{
- */
-
- /**
-  * @brief       Called when a policy is changed
-  */
- typedef void (*dpm_policy_change_cb)(const char* name, const char* state, void *user_data);
-
-/**
- * @brief       The Device Policy Client handle
- * @details     The Device Policy Client Handle is an abstraction of the
- *              logical connection between the device policy manager and
- *              it's client. The Device Policy Client handle must be
- *              created by using dpm_create_client() brefore attempting to
- *              use almost any of the device policy APIs, and it should
- *              be freed when interaction with the Device Policy Manager
- *              is no longer required.
- *              To release the handle, use dpm_destroy_client().
- * @since_tizen 3.0
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- */
-typedef void* dpm_client_h;
-
-/**
- * @brief       Enumeration of device policy API errors
- * @since_tizen 3.0
- */
-typedef enum {
-    DPM_ERROR_NONE                 = TIZEN_ERROR_NONE,                 /**< The operation was successful */
-    DPM_ERROR_INVALID_PARAMETER    = TIZEN_ERROR_INVALID_PARAMETER,    /**< Invalid parameter */
-    DPM_ERROR_CONNECTION_REFUSED   = TIZEN_ERROR_CONNECTION_REFUSED,   /**< Connection refused */
-    DPM_ERROR_TIMED_OUT            = TIZEN_ERROR_TIMED_OUT,            /**< Timeout */
-    DPM_ERROR_PERMISSION_DENIED    = TIZEN_ERROR_PERMISSION_DENIED,    /**< Access privilege is not sufficient */
-    DPM_ERROR_NOT_SUPPORTED        = TIZEN_ERROR_NOT_SUPPORTED,        /**< Operation is not supported */
-    DPM_ERROR_NO_SUCH_FILE         = TIZEN_ERROR_NO_SUCH_FILE,         /**< No such file or directory */
-    DPM_ERROR_FILE_EXISTS          = TIZEN_ERROR_FILE_EXISTS,          /**< File exists */
-    DPM_ERROR_OUT_OF_MEMORY        = TIZEN_ERROR_OUT_OF_MEMORY         /**< Out of memory */
-} dpm_error_type_e;
-
-/**
- * @brief       Create the Device Policy Client handle
- * @details     This API creates device policy client handle required to
- *              the device policy APIs.
- *              This API is also used to verity whether caller is authorized
- *              or not
- * @since_tizen 3.0
- * @return      Device Policy Client handle on success, otherwise NULL
- * @remark      The specific error code can be obtained by using the
- *              get_last_result() method. Error codes are described in
- *              exception section.
- * @exception   #DPM_ERROR_NONE No error
- * @exception   #DPM_ERROR_CONNECTION_REFUSED Connection refused
- * @exception   #DPM_ERROR_PERMISSION_DENIED The application does not have
- *              the privilege to call this API
- * @pre         N/A
- * @post        N/A
- * @see         dpm_destroy_client()
- * @see         get_last_result()
- */
-DPM_API dpm_client_h dpm_create_client(void);
-
-/**
- * @brief       Release the Device Policy Client Handle
- * @details     This API must be called if interaction with the Device
- *              Policy Manager is no longer required.
- * @since_tizen 3.0
- * @param[in]   handle Device Policy Client Handle
- * @return      None
- * @pre         The handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- */
-DPM_API void dpm_destroy_client(dpm_client_h handle);
-
-/**
- * @brief       Adds policy change notification listener to the Device Policy
- *              Manager
- * @details     This API can be used to subscribe policy change notification.
- *              The handler specified to this API is asynchronously called when
- *              policy is changed on runtime.
- * @since_tizen 3.0
- * @param[in]   handle Device Policy Client Handle
- * @param[in]   name Policy name to subscribe
- * @param[in]   listener Policy change notification listener
- * @param[in]   user_data User specified data passed to the listener
- * @return      Listener identifier on success, otherwise negative value
- * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid policy name
- * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
- *              the privilege to subscribe the policy change notification
- *              corresponding to the given policy name.
- * @pre         The handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_remove_policy_change_listener()
- */
-DPM_API int dpm_add_policy_change_listener(dpm_client_h handle,
-                                           const char* name,
-                                           dpm_policy_change_cb listener,
-                                           void* user_data);
-
-/**
- * @brief       Removes policy change notification listener from the Device Policy
- *              Manager
- * @details     This API should be called if policy change subscription is no longer
- *              required.
- * @since_tizen 3.0
- * @param[in]   handle Device Policy Client Handle
- * @param[in]   id Policy change listener identifier
- * @return      None
- * @pre         The handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_add_policy_change_listener()
- */
-DPM_API void dpm_remove_policy_change_listener(dpm_client_h handle, int id);
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //! __DEVICE_POLICY_CLIENT_H__
similarity index 82%
rename from libs/dpm/dpm.h
rename to libs/dpm/device-policy-manager.h
index e2144a3..b23b137 100644 (file)
  *  limitations under the License
  */
 
-#ifndef __CAPI_DPM_H__
-#define __CAPI_DPM_H__
+#ifndef __CAPI_DEVICE_POLICY_MANAGER_H__
+#define __CAPI_DEVICE_POLICY_MANAGER_H__
 
-#include <dpm/device-policy-client.h>
+#include <dpm/context.h>
 #include <dpm/password.h>
 #include <dpm/security.h>
 #include <dpm/zone.h>
 
-#endif //! __CAPI_DPM_H__
+#endif //! __CAPI_DEVICE_POLICY_MANAGER_H__
diff --git a/libs/dpm/misc.cpp b/libs/dpm/misc.cpp
deleted file mode 100644 (file)
index 0dc8b13..0000000
+++ /dev/null
@@ -1,95 +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 <cassert>
-
-#include "misc.h"
-#include "misc.hxx"
-#include "policy-client.h"
-
-using namespace DevicePolicyManager;
-
-int dpm_set_camera_restriction(dpm_client_h handle, int enable)
-{
-       assert(handle);
-
-       DevicePolicyClient &client = GetDevicePolicyClient(handle);
-       Misc misc = client.createPolicyInterface<Misc>();
-       return misc.setCameraRestriction(enable);
-}
-
-int dpm_is_camera_restricted(dpm_client_h handle)
-{
-       assert(handle);
-
-       DevicePolicyClient &client = GetDevicePolicyClient(handle);
-       Misc misc = client.createPolicyInterface<Misc>();
-       return misc.isCameraRestricted();
-}
-
-int dpm_set_microphone_restriction(dpm_client_h handle, int enable)
-{
-       assert(handle);
-
-       DevicePolicyClient &client = GetDevicePolicyClient(handle);
-       Misc misc = client.createPolicyInterface<Misc>();
-       return misc.setMicrophoneRestriction(enable);
-}
-
-int dpm_is_microphone_restricted(dpm_client_h handle)
-{
-       assert(handle);
-
-       DevicePolicyClient &client = GetDevicePolicyClient(handle);
-       Misc misc = client.createPolicyInterface<Misc>();
-       return misc.isMicrophoneRestricted();
-}
-
-int dpm_set_location_restriction(dpm_client_h handle, int enable)
-{
-       assert(handle);
-
-       DevicePolicyClient &client = GetDevicePolicyClient(handle);
-       Misc misc = client.createPolicyInterface<Misc>();
-       return misc.setLocationRestriction(enable);
-}
-
-int dpm_is_location_restricted(dpm_client_h handle)
-{
-       assert(handle);
-
-       DevicePolicyClient &client = GetDevicePolicyClient(handle);
-       Misc misc = client.createPolicyInterface<Misc>();
-       return misc.isLocationRestricted();
-}
-
-int dpm_set_sd_card_restriction(dpm_client_h handle, int enable)
-{
-       assert(handle);
-
-       DevicePolicyClient &client = GetDevicePolicyClient(handle);
-       Misc misc = client.createPolicyInterface<Misc>();
-       return misc.setSdCardRestriction(enable);
-}
-
-int dpm_is_sd_card_restricted(dpm_client_h handle)
-{
-       assert(handle);
-
-       DevicePolicyClient &client = GetDevicePolicyClient(handle);
-       Misc misc = client.createPolicyInterface<Misc>();
-       return misc.isSdCardRestricted();
-}
diff --git a/libs/dpm/misc.h b/libs/dpm/misc.h
deleted file mode 100644 (file)
index 43ad761..0000000
+++ /dev/null
@@ -1,185 +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 __CAPI_MISC_POLICY_H__
-#define __CAPI_MISC_POLICY_H__
-
-#include <dpm/device-policy-client.h>
-
-/**
- * @file misc.h
- * @brief This file provides APIs to control misc functionality
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @addtogroup  DPM_MISC_POLICY
- * @{
- */
-
-/**
- * @brief       Allows or disallows the camera.
- * @details     An administrator can use this API to set whether the camera
- *              is allowed or not.
- * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.misc
- * @param[in]   handle Device Policy Client handle
- * @param[in]   enable If true, disallow the camera, if false, allow the camera
- * @return      #DPM_ERROR_NONE on success, otherwise a negative value
- * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
- * @retval      #DPM_ERROR_TIMED_OUT Time out
- * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
- *              the privilege to call this API
- * @pre         The handle must be created by dpm_create_client().
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- */
-DPM_API int dpm_set_camera_restriction(dpm_client_h handle, int enable);
-
-/**
- * @brief       Gets the allow status of the camera.
- * @details     An administrator can use this API to get the allow status of
- *              the camera.
- * @since_tizen 3.0
- * @param[in]   handle Device Policy Client handle
- * @return      status The restriction status of the camera
- * @pre         The handle must be created by dpm_create_client().
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- */
-DPM_API int dpm_is_camera_restricted(dpm_client_h handle);
-
-/**
- * @brief       Allows or disallows the microphone.
- * @details     An administrator can use this API to set whether the microphone
- *              is allowed or not.
- * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.misc
- * @param[in]   handle Device Policy Client handle
- * @param[in]   enable If true, disallow the microphone, if false, allow the microphone
- * @return      #DPM_ERROR_NONE on success, otherwise a negative value
- * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
- * @retval      #DPM_ERROR_TIMED_OUT Time out
- * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
- *              the privilege to call this API
- * @pre         The handle must be created by dpm_create_client().
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- */
-DPM_API int dpm_set_microphone_restriction(dpm_client_h handle, int enable);
-
-/**
- * @brief       Gets the allow status of the microphone.
- * @details     An administrator can use this API to check the state of
- *              the microphone.
- * @since_tizen 3.0
- * @param[in]   handle Device Policy Client handle
- * @return      status The allow status of the microphone
- * @pre         The handle must be created by dpm_create_client().
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- */
-DPM_API int dpm_is_microphone_restricted(dpm_client_h handle);
-
-/**
- * @brief       Aallows or disallows the location.
- * @details     An administrator can use this API to set whether the location
- *              is allowed or not.
- * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.misc
- * @param[in]   handle Device Policy Client handle
- * @param[in]   enable If TRUE, restrict the location, if false, disable the location
- * @return      #DPM_ERROR_NONE on success, otherwise a negative value
- * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_TIMEOUT Timeout
- * @retval      #DPM_ERROR_ACCESS_DENIED The application does not have
- *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- */
-DPM_API int dpm_set_location_restriction(dpm_client_h handle, int enable);
-
-/**
- * @brief       API to get the allow status of the location.
- * @details     An administrator can use this API to get the restriction status of
- *              the location.
- * @since_tizen 3.0
- * @privlevel   public
- * @param[in]   handle Device Policy Client handle
- * @return      status Restriction status of localtion
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- */
-DPM_API int dpm_is_location_restricted(dpm_client_h handle);
-
-/**
- * @brief       Allows or disallows the SD Card.
- * @details     An administrator can use this API to set whether the sd card
- *              is restricted or not.
- * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.misc
- * @param[in]   handle Device Policy Client handle
- * @param[in]   enable If TRUE, disallow SD Card, if FALSE, allow the SD Card
- * @return      #DPM_ERROR_NONE on success, otherwise a negative value
- * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_TIMOUT Timeout
- * @retval      #DPM_ERROR_ACCESS_DENIED The application does not have
- *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- */
-DPM_API int dpm_set_sd_card_restriction(dpm_client_h handle, int enable);
-
-/**
- * @brief       Gets the restriction status of the sd card.
- * @details     An administrator can use this API to get the restriction status of
- *              the sd card.
- * @since_tizen 3.0
- * @privlevel   public
- * @param[in]   handle Device Policy Client handle
- * @return      status Restriction status of the SD Card
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- */
-DPM_API int dpm_is_sd_card_restricted(dpm_client_h handle);
-
-/**
- * @} // end of DPM_MISC_POLICY
- */
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __CAPI_MISC_POLICY_H__ */
index ac681fa..97821db 100644 (file)
  */
 
 #include <cstring>
+#include <cassert>
 
 #include "password.h"
 #include "password.hxx"
 
-#include "capi-assert.h"
+#include "debug.h"
 #include "policy-client.h"
 
 using namespace DevicePolicyManager;
 
-int dpm_set_password_quality(dpm_client_h handle, const char *username, dpm_password_quality_e quality)
+dpm_password_policy_h dpm_context_acquire_password_policy(dpm_context_h handle, const char* zone)
+{
+    RET_ON_FAILURE(handle, NULL);
+
+    DevicePolicyContext &client = GetDevicePolicyContext(handle);
+    return client.createPolicyInterface<PasswordPolicy>();
+}
+
+DPM_API int dpm_context_release_password_policy(dpm_context_h context, dpm_password_policy_h handle)
+{
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+
+    delete &GetPolicyInterface<PasswordPolicy>(handle);
+    return 0;
+}
+
+int dpm_password_set_quality(dpm_password_policy_h handle, dpm_password_quality_e quality)
 {
     int ret = 0;
 
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Password password = client.createPolicyInterface<Password>();
+    PasswordPolicy& password = GetPolicyInterface<PasswordPolicy>(handle);
 
-    if (password.setPasswordQuality(username, quality) == 0)
+    if (password.setPasswordPolicyQuality(quality) == 0)
         ret = DPM_ERROR_NONE;
     else
         ret = DPM_ERROR_NOT_SUPPORTED;
@@ -41,17 +57,15 @@ int dpm_set_password_quality(dpm_client_h handle, const char *username, dpm_pass
     return ret;
 }
 
-int dpm_set_password_minimum_length(dpm_client_h handle, const char *username, const int value)
+int dpm_password_set_minimum_length(dpm_password_policy_h handle, const int value)
 {
     int ret = 0;
 
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(username, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Password password = client.createPolicyInterface<Password>();
+    PasswordPolicy& password = GetPolicyInterface<PasswordPolicy>(handle);
 
-    if (password.setPasswordMinimumLength(username, value) == 0)
+    if (password.setPasswordPolicyMinimumLength(value) == 0)
         ret = DPM_ERROR_NONE;
     else
         ret = DPM_ERROR_NOT_SUPPORTED;
@@ -59,17 +73,15 @@ int dpm_set_password_minimum_length(dpm_client_h handle, const char *username, c
     return ret;
 }
 
-int dpm_set_min_password_complex_chars(dpm_client_h handle, const char *username, const int value)
+int dpm_password_set_min_complex_chars(dpm_password_policy_h handle, const int value)
 {
     int ret = 0;
 
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(username, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Password password = client.createPolicyInterface<Password>();
+    PasswordPolicy& password = GetPolicyInterface<PasswordPolicy>(handle);
 
-    if (password.setMinPasswordComplexChars(username, value) == 0)
+    if (password.setMinPasswordPolicyComplexChars(value) == 0)
         ret = DPM_ERROR_NONE;
     else
         ret = DPM_ERROR_NOT_SUPPORTED;
@@ -77,17 +89,15 @@ int dpm_set_min_password_complex_chars(dpm_client_h handle, const char *username
     return ret;
 }
 
-int dpm_set_maximum_failed_password_for_wipe(dpm_client_h handle, const char *username, const int value)
+int dpm_password_set_maximum_failed_attempts_for_wipe(dpm_password_policy_h handle, const int value)
 {
     int ret = 0;
 
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(username, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Password password = client.createPolicyInterface<Password>();
+    PasswordPolicy& password = GetPolicyInterface<PasswordPolicy>(handle);
 
-    if (password.setMaximumFailedPasswordForWipe(username, value) == 0)
+    if (password.setMaximumFailedPasswordPolicyForWipe(value) == 0)
         ret = DPM_ERROR_NONE;
     else
         ret = DPM_ERROR_NOT_SUPPORTED;
@@ -95,17 +105,15 @@ int dpm_set_maximum_failed_password_for_wipe(dpm_client_h handle, const char *us
     return ret;
 }
 
-int dpm_set_password_expires(dpm_client_h handle, const char *username, const int value)
+int dpm_password_set_expires(dpm_password_policy_h handle, const int value)
 {
     int ret = 0;
 
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(username, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Password password = client.createPolicyInterface<Password>();
+    PasswordPolicy& password = GetPolicyInterface<PasswordPolicy>(handle);
 
-    if (password.setPasswordExpires(username, value) == 0)
+    if (password.setPasswordPolicyExpires(value) == 0)
         ret = DPM_ERROR_NONE;
     else
         ret = DPM_ERROR_NOT_SUPPORTED;
@@ -113,17 +121,15 @@ int dpm_set_password_expires(dpm_client_h handle, const char *username, const in
     return ret;
 }
 
-int dpm_set_password_history(dpm_client_h handle, const char *username, const int value)
+int dpm_password_set_history(dpm_password_policy_h handle, const int value)
 {
     int ret = 0;
 
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(username, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Password password = client.createPolicyInterface<Password>();
+    PasswordPolicy& password = GetPolicyInterface<PasswordPolicy>(handle);
 
-    if (password.setPasswordHistory(username, value) == 0)
+    if (password.setPasswordPolicyHistory(value) == 0)
         ret = DPM_ERROR_NONE;
     else
         ret = DPM_ERROR_NOT_SUPPORTED;
@@ -131,18 +137,16 @@ int dpm_set_password_history(dpm_client_h handle, const char *username, const in
     return ret;
 }
 
-int dpm_set_password_pattern(dpm_client_h handle, const char *username, const char *pattern)
+int dpm_password_set_pattern(dpm_password_policy_h handle, const char *pattern)
 {
     int ret = 0;
 
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(username, DPM_ERROR_INVALID_PARAMETER);
     RET_ON_FAILURE(pattern, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Password password = client.createPolicyInterface<Password>();
+    PasswordPolicy& password = GetPolicyInterface<PasswordPolicy>(handle);
 
-    if (password.setPasswordPattern(username, pattern) == 0)
+    if (password.setPasswordPolicyPattern(pattern) == 0)
         ret = DPM_ERROR_NONE;
     else
         ret = DPM_ERROR_NOT_SUPPORTED;
@@ -150,18 +154,16 @@ int dpm_set_password_pattern(dpm_client_h handle, const char *username, const ch
     return ret;
 }
 
-int dpm_reset_password(dpm_client_h handle, const char *username, const char *passwd)
+int dpm_password_reset(dpm_password_policy_h handle, const char *passwd)
 {
     int ret = 0;
 
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(username, DPM_ERROR_INVALID_PARAMETER);
     RET_ON_FAILURE(passwd, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Password password = client.createPolicyInterface<Password>();
+    PasswordPolicy& password = GetPolicyInterface<PasswordPolicy>(handle);
 
-    if (password.resetPassword(username, passwd) == 0)
+    if (password.resetPasswordPolicy(passwd) == 0)
         ret = DPM_ERROR_NONE;
     else
         ret = DPM_ERROR_NOT_SUPPORTED;
@@ -169,17 +171,15 @@ int dpm_reset_password(dpm_client_h handle, const char *username, const char *pa
     return ret;
 }
 
-int dpm_enforce_password_change(dpm_client_h handle, const char *username)
+int dpm_password_enforce_change(dpm_password_policy_h handle)
 {
     int ret = 0;
 
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(username, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Password password = client.createPolicyInterface<Password>();
+    PasswordPolicy& password = GetPolicyInterface<PasswordPolicy>(handle);
 
-    if (password.enforcePasswordChange(username) == 0)
+    if (password.enforcePasswordPolicyChange() == 0)
         ret = DPM_ERROR_NONE;
     else
         ret = DPM_ERROR_NOT_SUPPORTED;
@@ -187,17 +187,15 @@ int dpm_enforce_password_change(dpm_client_h handle, const char *username)
     return ret;
 }
 
-int dpm_set_max_inactivity_time_device_lock(dpm_client_h handle, const char *username, const int value)
+int dpm_password_set_max_inactivity_time_device_lock(dpm_password_policy_h handle, const int value)
 {
     int ret = 0;
 
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(username, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Password password = client.createPolicyInterface<Password>();
+    PasswordPolicy& password = GetPolicyInterface<PasswordPolicy>(handle);
 
-    if (password.setMaxInactivityTimeDeviceLock(username, value) == 0)
+    if (password.setMaxInactivityTimeDeviceLock(value) == 0)
         ret = DPM_ERROR_NONE;
     else
         ret = DPM_ERROR_NOT_SUPPORTED;
@@ -205,20 +203,18 @@ int dpm_set_max_inactivity_time_device_lock(dpm_client_h handle, const char *use
     return ret;
 }
 
-int dpm_get_max_inactivity_time_device_lock(dpm_client_h handle, const char *username, int *p_value)
+int dpm_password_get_max_inactivity_time_device_lock(dpm_password_policy_h handle, int *value)
 {
     int ret = 0;
 
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(username, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(p_value, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Password password = client.createPolicyInterface<Password>();
+    PasswordPolicy& password = GetPolicyInterface<PasswordPolicy>(handle);
 
-    *p_value = password.getMaxInactivityTimeDeviceLock(username);
+    *value = password.getMaxInactivityTimeDeviceLock();
 
-    if (*p_value > 0)
+    if (*value > 0)
         ret = DPM_ERROR_NONE;
     else
         ret = DPM_ERROR_NOT_SUPPORTED;
@@ -226,17 +222,15 @@ int dpm_get_max_inactivity_time_device_lock(dpm_client_h handle, const char *use
     return ret;
 }
 
-int dpm_set_password_status(dpm_client_h handle, const char *username, const int status)
+int dpm_password_set_status(dpm_password_policy_h handle, const int status)
 {
     int ret = 0;
 
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(username, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Password password = client.createPolicyInterface<Password>();
+    PasswordPolicy& password = GetPolicyInterface<PasswordPolicy>(handle);
 
-    if (password.setPasswordStatus(username, status) == 0)
+    if (password.setPasswordPolicyStatus(status) == 0)
         ret = DPM_ERROR_NONE;
     else
         ret = DPM_ERROR_NOT_SUPPORTED;
@@ -244,17 +238,15 @@ int dpm_set_password_status(dpm_client_h handle, const char *username, const int
     return ret;
 }
 
-int dpm_delete_password_pattern(dpm_client_h handle, const char *username)
+int dpm_password_delete_pattern(dpm_password_policy_h handle)
 {
     int ret = 0;
 
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(username, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Password password = client.createPolicyInterface<Password>();
+    PasswordPolicy& password = GetPolicyInterface<PasswordPolicy>(handle);
 
-    if (password.deletePasswordPattern(username) == 0)
+    if (password.deletePasswordPolicyPattern() == 0)
         ret = DPM_ERROR_NONE;
     else
         ret = DPM_ERROR_NOT_SUPPORTED;
@@ -262,32 +254,34 @@ int dpm_delete_password_pattern(dpm_client_h handle, const char *username)
     return ret;
 }
 
-char *dpm_get_password_pattern(dpm_client_h handle, const char *username)
+int dpm_password_get_pattern(dpm_password_policy_h handle, char* pattern)
 {
-    RET_ON_FAILURE(handle, NULL);
-    RET_ON_FAILURE(username, NULL);
+    int ret = 0;
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Password password = client.createPolicyInterface<Password>();
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(pattern, DPM_ERROR_INVALID_PARAMETER);
 
-    if (password.getPasswordPattern(username).size() > 0) {
-        return ::strdup(password.getPasswordPattern(username).c_str());
+    PasswordPolicy& password = GetPolicyInterface<PasswordPolicy>(handle);
+
+    if (password.getPasswordPolicyPattern().size() > 0) {
+        pattern = ::strdup(password.getPasswordPolicyPattern().c_str());
+               ret = DPM_ERROR_NONE;
     }
+       else
+               ret = DPM_ERROR_TIMED_OUT;
 
-    return NULL;
+    return ret;
 }
 
-int dpm_set_maximum_character_occurrences(dpm_client_h handle, const char *username, const int value)
+int dpm_password_set_maximum_character_occurrences(dpm_password_policy_h handle, const int value)
 {
     int ret = 0;
 
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(username, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Password password = client.createPolicyInterface<Password>();
+    PasswordPolicy& password = GetPolicyInterface<PasswordPolicy>(handle);
 
-    if (password.setMaximumCharacterOccurrences(username, value) == 0)
+    if (password.setMaximumCharacterOccurrences(value) == 0)
         ret = DPM_ERROR_NONE;
     else
         ret = DPM_ERROR_NOT_SUPPORTED;
@@ -295,19 +289,17 @@ int dpm_set_maximum_character_occurrences(dpm_client_h handle, const char *usern
     return ret;
 }
 
-int dpm_get_maximum_character_occurrences(dpm_client_h handle, const char *username, int *p_value)
+int dpm_password_get_maximum_character_occurrences(dpm_password_policy_h handle, int *value)
 {
     int ret = 0;
 
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(username, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(p_value, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Password password = client.createPolicyInterface<Password>();
-    *p_value = password.getMaximumCharacterOccurrences(username);
+    PasswordPolicy& password = GetPolicyInterface<PasswordPolicy>(handle);
+    *value = password.getMaximumCharacterOccurrences();
 
-    if (*p_value > 0)
+    if (*value > 0)
         ret = DPM_ERROR_NONE;
     else
         ret = DPM_ERROR_NOT_SUPPORTED;
@@ -315,17 +307,15 @@ int dpm_get_maximum_character_occurrences(dpm_client_h handle, const char *usern
     return ret;
 }
 
-int dpm_set_maximum_numeric_sequence_length(dpm_client_h handle, const char *username, const int value)
+int dpm_password_set_maximum_numeric_sequence_length(dpm_password_policy_h handle, const int value)
 {
     int ret = 0;
 
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(username, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Password password = client.createPolicyInterface<Password>();
+    PasswordPolicy& password = GetPolicyInterface<PasswordPolicy>(handle);
 
-    if (password.setMaximumNumericSequenceLength(username, value) == 0)
+    if (password.setMaximumNumericSequenceLength(value) == 0)
         ret = DPM_ERROR_NONE;
     else
         ret = DPM_ERROR_NOT_SUPPORTED;
@@ -333,17 +323,15 @@ int dpm_set_maximum_numeric_sequence_length(dpm_client_h handle, const char *use
     return ret;
 }
 
-int dpm_get_maximum_numeric_sequence_length(dpm_client_h handle, const char *username, int *value)
+int dpm_password_get_maximum_numeric_sequence_length(dpm_password_policy_h handle, int *value)
 {
     int ret = 0;
 
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(username, DPM_ERROR_INVALID_PARAMETER);
     RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Password password = client.createPolicyInterface<Password>();
-    *value = password.getMaximumNumericSequenceLength(username);
+    PasswordPolicy& password = GetPolicyInterface<PasswordPolicy>(handle);
+    *value = password.getMaximumNumericSequenceLength();
 
     if (*value > 0)
         ret = DPM_ERROR_NONE;
index f31803a..af74054 100644 (file)
@@ -17,7 +17,7 @@
 #ifndef __CAPI_PASSWORD_POLICY_H__
 #define __CAPI_PASSWORD_POLICY_H__
 
-#include <dpm/device-policy-client.h>
+#include <dpm/context.h>
 
 /**
  * @file password.h
@@ -34,12 +34,20 @@ extern "C" {
  */
 
 /**
+ * @brief       The password policy handle
+ * @since_tizen 3.0
+ * @see         dpm_context_acquire_password_policy()
+ * @see         dpm_context_release_password_policy()
+ */
+typedef void* dpm_password_policy_h;
+
+/**
  * @brief       Enumeration for dpm password quality type
  * @since_tizen 3.0
  */
 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_SIMPLE_PASSWORD = 0x01,    /**< EAS(Exchange ActiveSync) 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 */
@@ -47,327 +55,312 @@ typedef enum {
 } dpm_password_quality_e;
 
 /**
- * @brief       API to set password quality.
+ * @brief       Acquires the password policy handle.
+ * @details     This API acquires password policy handle required to enforce
+ *              the policy password policies
+ * @since_tizen 3.0
+ * @param[in]   handle Device policy context handle
+ * @param[in]   zone Target container name.
+ * @return      Password policy handle on success, otherwise NULL
+ * @remark      The specific error code can be obtained by using the
+ *              get_last_result() method. Error codes are described in
+ *              exception section.
+ * @exception   #DPM_ERROR_NONE No error
+ * @exception   #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception   #DPM_ERROR_TIMED_OUT Time out
+ * @see         dpm_context_release_password_policy()
+ * @see         get_last_result()
+ */
+DPM_API dpm_password_policy_h dpm_context_acquire_password_policy(dpm_context_h handle, const char* zone);
+
+/**
+ * @brief       Releases the password policy Handle.
+ * @details     This API must be called if interaction with the device
+ *              policy manager is no longer required.
+ * @since_tizen 3.0
+ * @param[in]   handle The device policy context
+ * @param[in]   handle The password policy Handle
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
+ * @pre         The handle must be created by dpm_context_acquire_password_policy().
+ * @see         dpm_context_acquire_password_policy()
+ */
+DPM_API int dpm_context_release_password_policy(dpm_context_h context, dpm_password_policy_h handle);
+
+/**
+ * @brief       Sets password quality.
  * @details     An administrator can set the password restrictions it is imposing.
  *              After setting this, the user will not be able to
  *              enter a new password that is not at least as restrictive as what has been set.
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.password
- * @param[in]   handle Device Policy Client handle
- * @param[in]   username User name
- * @param[in]   quality Password Quality Type
+ * @param[in]   handle Password policy handle
+ * @param[in]   quality Password quality type
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
  * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
+ * @pre         The handle must be created by dpm_context_acquire_password_policy().
+ * @see         dpm_context_acquire_password_policy()
+ * @see         dpm_context_release_password_policy()
  */
-DPM_API int dpm_set_password_quality(dpm_client_h handle, const char *username, dpm_password_quality_e quality);
+DPM_API int dpm_password_set_quality(dpm_password_policy_h handle, dpm_password_quality_e quality);
 
 /**
- * @brief       API to set password minimum length.
- * @details     set the minimum allowed password length. After setting this,
+ * @brief       Sets password minimum length.
+ * @details     Sets the minimum allowed password length. After setting this,
  *              the user will not be able to enter a new password that is
  *              shorter than the setting length.
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.password
- * @param[in]   handle Device Policy Client handle
- * @param[in]   username User name
+ * @param[in]   handle Password policy handle
  * @param[in]   value Allowed minimum password length
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
  * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
+ * @pre         The handle must be created by dpm_context_acquire_password_policy().
+ * @see         dpm_context_acquire_password_policy()
+ * @see         dpm_context_release_password_policy()
  */
-DPM_API int dpm_set_password_minimum_length(dpm_client_h handle, const char *username, const int value);
+DPM_API int dpm_password_set_minimum_length(dpm_password_policy_h handle, const int value);
 
 /**
- * @brief       API to set minimum complex char in password.
+ * @brief       Sets minimum complex char in password.
  * @details     Complex characters are all non-alphabetic characters;
  *              that is, numbers and symbols. Admin can configure this
  *              setting and make the password more secure.
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.password
- * @param[in]   handle Device Policy Client handle
- * @param[in]   username User name
- * @param[in]   value Num of minimum complex char in password.
+ * @param[in]   handle Password policy handle
+ * @param[in]   value Number of minimum complex char in password.
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
  * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
+ * @pre         The handle must be created by dpm_context_acquire_password_policy().
+ * @see         dpm_context_acquire_password_policy()
+ * @see         dpm_context_release_password_policy()
  */
-DPM_API int dpm_set_min_password_complex_chars(dpm_client_h handle, const char *username, const int value);
+DPM_API int dpm_password_set_min_complex_chars(dpm_password_policy_h handle, const int value);
 
 /**
- * @brief       API to set maximum number of failed attempts before
- *              device is wiped.
+ * @brief       Sets maximum number of failed attempts before device is wiped.
  * @details     If user fails the last attempt, device will be wiped.
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.password
- * @param[in]   handle Device Policy Client handle
- * @param[in]   username User name
+ * @param[in]   handle Password policy handle
  * @param[in]   value Maximum count for failed passwords.
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
  * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
+ * @pre         The handle must be created by dpm_context_acquire_password_policy().
+ * @see         dpm_context_acquire_password_policy()
+ * @see         dpm_context_release_password_policy()
  */
-DPM_API int dpm_set_maximum_failed_password_for_wipe(dpm_client_h handle, const char *username, const int value);
+DPM_API int dpm_password_set_maximum_failed_attempts_for_wipe(dpm_password_policy_h handle, const int value);
 
 /**
- * @brief       API to set the number of days password expires.
+ * @brief       Sets the number of days password expires.
  * @details     An administrator can configure the password age to force
  *              the user to enter a new password after every expiration period.
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.password
- * @param[in]   handle Device Policy Client handle
- * @param[in]   username User name
- * @param[in]   value Num of days after which the password expires.
+ * @param[in]   handle Password policy handle
+ * @param[in]   value Number of days after which the password expires.
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
  * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
+ * @pre         The handle must be created by dpm_context_acquire_password_policy().
+ * @see         dpm_context_acquire_password_policy()
+ * @see         dpm_context_release_password_policy()
  */
-DPM_API int dpm_set_password_expires(dpm_client_h handle, const char *username, const int value);
+DPM_API int dpm_password_set_expires(dpm_password_policy_h handle, const int value);
 
 /**
- * @brief       API to set the number of min password history to avoid
- *              previous password.
+ * @brief       Sets the number of min password history to avoid previous password.
  * @details     An administrator can configure the number of previous
  *              passwords which cannot be used when entering a new password.
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.password
- * @param[in]   handle Device Policy Client handle
- * @param[in]   username User name
- * @param[in]   value Num of previous passwords which cannot be used when
+ * @param[in]   handle Password policy handle
+ * @param[in]   value Number of previous passwords which cannot be used when
  *              settings a new password.
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
  * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
+ * @pre         The handle must be created by dpm_context_acquire_password_policy().
+ * @see         dpm_context_acquire_password_policy()
+ * @see         dpm_context_release_password_policy()
  */
-DPM_API int dpm_set_password_history(dpm_client_h handle, const char *username, const int value);
+DPM_API int dpm_password_set_history(dpm_password_policy_h handle, const int value);
 
 /**
- * @brief       API to set the required password pattern.
+ * @brief       Sets the required password pattern.
  * @details     An administrator can force User to enter password based on
  *              a regular expression.
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.password
- * @param[in]   handle Device Policy Client handle
- * @param[in]   username User name
- * @param[in]   pattern Password Pattern. If regular expression is
+ * @param[in]   handle Password policy handle
+ * @param[in]   pattern Password pattern. If regular expression is
  *              [a-zA-Z]{4}[0-9]{4}, we can force user to enter a 8 character
  *              password with first 4 alphabetic characters and next 4
  *              numeric characters. An administrator must take care when
  *              setting this pattern.
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
  * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
+ * @pre         The handle must be created by dpm_context_acquire_password_policy().
+ * @see         dpm_context_acquire_password_policy()
+ * @see         dpm_context_release_password_policy()
  */
-DPM_API int dpm_set_password_pattern(dpm_client_h handle, const char *username, const char *pattern);
+DPM_API int dpm_password_set_pattern(dpm_password_policy_h handle, const char *pattern);
 
 /**
- * @brief       API to reset password.
+ * @brief       Resets password.
  * @details     This takes effect immediately to the device password.
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.password
- * @param[in]   handle Device Policy Client handle
- * @param[in]   username User name
- * @param[in]   password New Password
+ * @param[in]   handle Password policy handle
+ * @param[in]   password New password
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
  * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
+ * @pre         The handle must be created by dpm_context_acquire_password_policy().
+ * @see         dpm_context_acquire_password_policy()
+ * @see         dpm_context_release_password_policy()
  */
-DPM_API int dpm_reset_password(dpm_client_h handle, const char *username, const char *password);
+DPM_API int dpm_password_reset(dpm_password_policy_h handle, const char *password);
 
 /**
- * @brief       API to enforce password change.
- * @details     An administrator can enforce password change. Password
+ * @brief       Enforces password change.
+ * @details     An administrator can enforce password change. PasswordPolicy
  *              change setting is launched.
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.password
- * @param[in]   handle Device Policy Client handle
- * @param[in]   username User name
+ * @param[in]   handle Password policy handle
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
  * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
+ * @pre         The handle must be created by dpm_context_acquire_password_policy().
+ * @see         dpm_context_acquire_password_policy()
+ * @see         dpm_context_release_password_policy()
  */
-DPM_API int dpm_enforce_password_change(dpm_client_h handle, const char *username);
+DPM_API int dpm_password_enforce_change(dpm_password_policy_h handle);
 
 /**
- * @brief       API to set the maximum number of seconds of inactivity time
+ * @brief       Sets the maximum number of seconds of inactivity time
  *              before the screen timeout occurs.
  * @details     An administrator sets the maximum number of seconds of inactivity
  *              time before the screen timeout occurs and a device user must
  *              type the password to unlock the device.
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.password
- * @param[in]   handle Device Policy Client handle
- * @param[in]   username User name
+ * @param[in]   handle Password policy handle
  * @param[in]   value Maximum inactivity time for device lock. Specifies how soon
  *              the device can be unlocked again after use, without reprompting for
  *              the passcode.
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
  * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
+ * @pre         The handle must be created by dpm_context_acquire_password_policy().
+ * @see         dpm_context_acquire_password_policy()
+ * @see         dpm_context_release_password_policy()
  */
-DPM_API int dpm_set_max_inactivity_time_device_lock(dpm_client_h handle, const char *username, const int value);
+DPM_API int dpm_password_set_max_inactivity_time_device_lock(dpm_password_policy_h handle, const int value);
 
 /**
- * @brief       API to get the maximum number of seconds of inactivity time
+ * @brief       Gets the maximum number of seconds of inactivity time
  *              before the screen timeout occurs.
  * @details     Called by an application that is managing the device to get
  *              the value of timeout period.
  * @since_tizen 3.0
- * @param[in]   handle Device Policy Client handle
- * @param[in]   username User name
- * @param[in]   value Pointer of Maximum inactivity time for device lock.
+ * @param[in]   handle Password policy handle
+ * @param[out]  value Pointer of Maximum inactivity time for device lock.
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
  * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
- *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
+ * @pre         The handle must be created by dpm_context_acquire_password_policy().
+ * @see         dpm_context_acquire_password_policy()
+ * @see         dpm_context_release_password_policy()
  */
-DPM_API int dpm_get_max_inactivity_time_device_lock(dpm_client_h handle, const char *username, int *value);
+DPM_API int dpm_password_get_max_inactivity_time_device_lock(dpm_password_policy_h handle, int *value);
 
 /**
- * @brief       API to set password status
+ * @brief       Sets password status
  * @details     An administrator can know password status for this API.
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.password
- * @param[in]   handle Device Policy Client handle
- * @param[in]   username User name
- * @param[in]   status Password Status
+ * @param[in]   handle Password policy handle
+ * @param[in]   status Password status
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
  * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
+ * @pre         The handle must be created by dpm_context_acquire_password_policy().
+ * @see         dpm_context_acquire_password_policy()
+ * @see         dpm_context_release_password_policy()
  */
-DPM_API int dpm_set_password_status(dpm_client_h handle, const char *username, const int status);
+DPM_API int dpm_password_set_status(dpm_password_policy_h handle, const int status);
 
 /**
- * @brief       API to remove all password patterns.
+ * @brief       Removes all password patterns.
  * @details     An administrator can remove all password patterns.
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.password
- * @param[in]   handle Device Policy Client handle
- * @param[in]   username User name
+ * @param[in]   handle Password policy handle
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
  * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
+ * @pre         The handle must be created by dpm_context_acquire_password_policy().
+ * @see         dpm_context_acquire_password_policy()
+ * @see         dpm_context_release_password_policy()
  */
-DPM_API int dpm_delete_password_pattern(dpm_client_h handle, const char *username);
+DPM_API int dpm_password_delete_pattern(dpm_password_policy_h handle);
 
 /**
- * @brief       API to get password pattern.
+ * @brief       Gets password pattern.
  * @details     This API can be used for applying complexity on new password value.
  * @since_tizen 3.0
- * @param[in]   handle Device Policy Client handle
- * @param[in]   username User name
- * @return      Password Pattern data, otherwise a null pointer if there is no password pattern.
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
+ * @remarks     The @a pattern should be freed using free().
+ * @param[in]   handle Password policy handle
+ * @param[out]  pattern Password pattern
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
+ * @retval      #DPM_ERROR_OUT_OF_MEMORY Out of memory
+ * @pre         The handle must be created by dpm_context_acquire_password_policy().
+ * @see         dpm_context_acquire_password_policy()
+ * @see         dpm_context_release_password_policy()
  */
-DPM_API char *dpm_get_password_pattern(dpm_client_h handle, const char *username);
+DPM_API int dpm_password_get_pattern(dpm_password_policy_h handle, char* pattern);
 
 /**
- * @brief       API to set the maximum number of times a character can occur in
+ * @brief       Sets the maximum number of times a character can occur in
  *              the device password.
  * @details     Called by an admin that is managing the device to specify that
  *              any character in the device password cannot occur more than
@@ -375,52 +368,44 @@ DPM_API char *dpm_get_password_pattern(dpm_client_h handle, const char *username
  *              or alphabetic or symbolic. "aaabcde" has 'a' which occurs 3 times,
  *              "1b1c1de" has '1' which occurs 3 times and "a@b@c@" has '@' which
  *              occurs 3 times. A value of '0' specifies that no restrictions are
- *              applied
+ *              applied.
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.password
- * @param[in]   handle Device Policy Client handle
- * @param[in]   username User name
- * @param[in]   value Maximum Character Occurences
+ * @param[in]   handle Password policy handle
+ * @param[in]   value Maximum character occurrences
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
  * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
+ * @pre         The handle must be created by dpm_context_acquire_password_policy().
+ * @see         dpm_context_acquire_password_policy()
+ * @see         dpm_context_release_password_policy()
  */
-DPM_API int dpm_set_maximum_character_occurrences(dpm_client_h handle, const char *username, const int value);
+DPM_API int dpm_password_set_maximum_character_occurrences(dpm_password_policy_h handle, const int value);
 
 /**
- * @brief       API to get the maximum number of times a character can occur in
+ * @brief       Gets the maximum number of times a character can occur in
  *              the device password.
  * @details     An administrator can retrieve the maximum number of times
  *              a character can occur in the device password. If more than
  *              one admin has set this value then the least value will take
  *              preference.
  * @since_tizen 3.0
- * @param[in]   handle Device Policy Client handle
- * @param[in]   username User name
- * @param[in]   value Pointer of Maximum Character Occurences
+ * @param[in]   handle Password policy handle
+ * @param[out]   value Pointer of Maximum Character Occurrences
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
  * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
- *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
+ * @pre         The handle must be created by dpm_context_acquire_password_policy().
+ * @see         dpm_context_acquire_password_policy()
+ * @see         dpm_context_release_password_policy()
  */
-DPM_API int dpm_get_maximum_character_occurrences(dpm_client_h handle, const char *username, int *value);
+DPM_API int dpm_password_get_maximum_character_occurrences(dpm_password_policy_h handle, int *value);
 
 /**
- * @brief       API to set the maximum length of the numeric sequence
+ * @brief       Sets the maximum length of the numeric sequence
  *              which is allowed in the device password.
  * @details     Called by an administrator that is managing the device to set
  *              the maximum numeric sequence length. This specifies that
@@ -435,26 +420,22 @@ DPM_API int dpm_get_maximum_character_occurrences(dpm_client_h handle, const cha
  *              A value of '0' specifies that no such numeric sequence
  *              restrictions are applied.
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.password
- * @param[in]   handle Device Policy Client handle
- * @param[in]   username User name
- * @param[in]   value Maximum Numeric Sequence Length
+ * @param[in]   handle Password policy handle
+ * @param[in]   value Maximum numeric sequence length
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
  * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
+ * @pre         The handle must be created by dpm_context_acquire_password_policy().
+ * @see         dpm_context_acquire_password_policy()
+ * @see         dpm_context_release_password_policy()
  */
-DPM_API int dpm_set_maximum_numeric_sequence_length(dpm_client_h handle, const char *username, const int value);
+DPM_API int dpm_password_set_maximum_numeric_sequence_length(dpm_password_policy_h handle, const int value);
 
 /**
- * @brief       API to get the maximum numeric sequence length allowed in
+ * @brief       Gets the maximum numeric sequence length allowed in
  *              the device password.
  * @details     An administrator can retrieve the length of numeric sequences
  *              which are allowed in the device password.
@@ -464,21 +445,17 @@ DPM_API int dpm_set_maximum_numeric_sequence_length(dpm_client_h handle, const c
  *              If more than one admin has set this value then the least value
  *              will take preference.
  * @since_tizen 3.0
- * @param[in]   handle Device Policy Client handle
- * @param[in]   username User name
- * @param[in]   value Pointer of Maximum Numeric Sequence Length
+ * @param[in]   handle Password policy handle
+ * @param[out]  value Pointer of maximum numeric sequence length
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
  * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
- *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
+ * @pre         The handle must be created by dpm_context_acquire_password_policy().
+ * @see         dpm_context_acquire_password_policy()
+ * @see         dpm_context_release_password_policy()
  */
-DPM_API int dpm_get_maximum_numeric_sequence_length(dpm_client_h handle, const char *username, int *value);
+DPM_API int dpm_password_get_maximum_numeric_sequence_length(dpm_password_policy_h handle, int *value);
 
 /**
  * @}
index c7aef0b..ce66b26 100644 (file)
  *  limitations under the License
  */
 
-#include <cassert>
-
 #include "restriction.h"
 #include "restriction.hxx"
+
+#include "debug.h"
 #include "policy-client.h"
 
 using namespace DevicePolicyManager;
 
-int dpm_set_clipboard_restriction(dpm_client_h handle, int enable)
+dpm_restriction_policy_h dpm_context_acquire_restriction_policy(dpm_context_h handle)
 {
-       assert(handle);
+    RET_ON_FAILURE(handle, NULL);
 
-       DevicePolicyClient& client = GetDevicePolicyClient(handle);
-       Restriction restriction = client.createPolicyInterface<Restriction>();
-       return restriction.setClipboardRestriction(enable);
+    DevicePolicyContext &client = GetDevicePolicyContext(handle);
+    return client.createPolicyInterface<RestrictionPolicy>();
 }
 
-int dpm_is_clipboard_restricted(dpm_client_h handle)
+int dpm_context_release_restriction_policy(dpm_context_h context, dpm_restriction_policy_h handle)
 {
-       assert(handle);
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyClient& client = GetDevicePolicyClient(handle);
-       Restriction restriction = client.createPolicyInterface<Restriction>();
-       return restriction.isClipboardRestricted();
+    delete &GetPolicyInterface<RestrictionPolicy>(handle);
+    return DPM_ERROR_NONE;
 }
 
-int dpm_set_clipboard_share_restriction(dpm_client_h handle, int enable)
+int dpm_restriction_set_camera_state(dpm_restriction_policy_h handle, int enable)
 {
-       assert(handle);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyClient& client = GetDevicePolicyClient(handle);
-       Restriction restriction = client.createPolicyInterface<Restriction>();
-       return restriction.setClipboardShareRestriction(enable);
+       RestrictionPolicy& restrict = GetPolicyInterface<RestrictionPolicy>(handle);
+       return restrict.setCameraState(enable);
 }
 
-int dpm_is_clipboard_share_restricted(dpm_client_h handle)
+int dpm_restriction_get_camera_state(dpm_restriction_policy_h handle, int *state)
 {
-       assert(handle);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyClient& client = GetDevicePolicyClient(handle);
-       Restriction restriction = client.createPolicyInterface<Restriction>();
-       return restriction.isClipboardShareRestricted();
-}
+       RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+       int ret = restriction.getCameraState();
+    if (ret < 0) {
+        return -1;
+    }
 
+    *state = ret;
+    return 0;
+}
 
-int dpm_set_settings_changes_restriction(dpm_client_h handle, int enable)
+int dpm_restriction_set_microphone_state(dpm_restriction_policy_h handle, int enable)
 {
-       assert(handle);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+
+       RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+       return restriction.setMicrophoneState(enable);
+}
 
-       DevicePolicyClient& client = GetDevicePolicyClient(handle);
-       Restriction restriction = client.createPolicyInterface<Restriction>();
-       return restriction.setSettingsChangesRestriction(enable);
+int dpm_restriction_get_microphone_state(dpm_restriction_policy_h handle, int *state)
+{
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+
+       RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+       int ret = restriction.getMicrophoneState();
+    if (ret < 0) {
+        return -1;
+    }
+    *state = ret;
+    return 0;
 }
 
-int dpm_is_settings_changes_restricted(dpm_client_h handle)
+int dpm_restriction_set_location_state(dpm_restriction_policy_h handle, int enable)
 {
-       assert(handle);
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyClient& client = GetDevicePolicyClient(handle);
-       Restriction restriction = client.createPolicyInterface<Restriction>();
-       return restriction.isSettingsChangesRestricted();
+    RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+    return restriction.setLocationState(enable);
 }
 
-int dpm_set_background_data_restriction(dpm_client_h handle, int enable)
+int dpm_restriction_get_location_state(dpm_restriction_policy_h handle, int *state)
 {
-       assert(handle);
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER);
+
+    RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+    int ret = restriction.getLocationState();
+    if (ret < 0) {
+        return -1;
+    }
 
-       DevicePolicyClient& client = GetDevicePolicyClient(handle);
-       Restriction restriction = client.createPolicyInterface<Restriction>();
-       return restriction.setBackgroundDataRestriction(enable);
+    *state = ret;
+    return DPM_ERROR_NONE;
 }
 
-int dpm_is_background_data_restricted(dpm_client_h handle)
+int dpm_restriction_set_usb_debugging_state(dpm_restriction_policy_h handle, int enable)
 {
-       assert(handle);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+
+       RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+       return restriction.setUsbDebuggingState(enable);
+}
 
-       DevicePolicyClient& client = GetDevicePolicyClient(handle);
-       Restriction restriction = client.createPolicyInterface<Restriction>();
-       return restriction.isBackgroundDataRestricted();
+int dpm_restriction_get_usb_debugging_state(dpm_restriction_policy_h handle, int *state)
+{
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER);
+
+       RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+       int ret = restriction.getUsbDebuggingState();
+    if (ret < 0) {
+        return -1;
+    }
+    *state = ret;
+    return DPM_ERROR_NONE;
 }
 
-int dpm_set_usb_debugging_restriction(dpm_client_h handle, int enable)
+int dpm_restriction_set_settings_changes_state(dpm_restriction_policy_h handle, int enable)
 {
-       assert(handle);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyClient& client = GetDevicePolicyClient(handle);
-       Restriction restriction = client.createPolicyInterface<Restriction>();
-       return restriction.setUsbDebuggingRestriction(enable);
+       RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+       return restriction.setSettingsChangesState(enable);
 }
 
-int dpm_is_usb_debugging_restricted(dpm_client_h handle)
+int dpm_restriction_get_settings_changes_state(dpm_restriction_policy_h handle, int *state)
 {
-       assert(handle);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER);
+
+       RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+       int ret = restriction.getSettingsChangesState();
+    if (ret < 0) {
+        return -1;
+    }
 
-       DevicePolicyClient& client = GetDevicePolicyClient(handle);
-       Restriction restriction = client.createPolicyInterface<Restriction>();
-       return restriction.isUsbDebuggingRestricted();
+    *state = ret;
+    return DPM_ERROR_NONE;
 }
 
-int dpm_set_usb_mass_storage_restriction(dpm_client_h handle, int enable)
+int dpm_restriction_set_external_storage_state(dpm_restriction_policy_h handle, int enable)
 {
-       assert(handle);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyClient& client = GetDevicePolicyClient(handle);
-       Restriction restriction = client.createPolicyInterface<Restriction>();
-       return restriction.setUsbMassStorageRestriction(enable);
+       RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+       return restriction.setExternalStorageState(enable);
 }
 
-int dpm_is_usb_mass_storage_restricted(dpm_client_h handle)
+int dpm_restriction_get_external_storage_state(dpm_restriction_policy_h handle, int *state)
 {
-       assert(handle);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER);
+
+       RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+       int ret = restriction.getExternalStorageState();
+    if (ret < 0) {
+        return 0;
+    }
+    *state = ret;
+    return DPM_ERROR_NONE;
+}
+
+int dpm_restriction_set_clipboard_state(dpm_restriction_policy_h handle, int enable)
+{
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyClient& client = GetDevicePolicyClient(handle);
-       Restriction restriction = client.createPolicyInterface<Restriction>();
-       return restriction.isUsbMassStorageRestricted();
+       RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+       return restriction.setClipboardState(enable);
+}
+
+int dpm_restriction_get_clipboard_state(dpm_restriction_policy_h handle, int *state)
+{
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER);
+
+       RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+       int ret = restriction.getClipboardState();
+    if (ret < 0) {
+        return -1;
+    }
+    *state = ret;
+    return DPM_ERROR_NONE;
 }
 
-int dpm_set_factory_reset_restriction(dpm_client_h handle, int enable)
+int dpm_restriction_set_wifi_state(dpm_restriction_policy_h handle, int enable)
 {
-       assert(handle);
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyClient& client = GetDevicePolicyClient(handle);
-       Restriction restriction = client.createPolicyInterface<Restriction>();
-       return restriction.setFactoryResetRestriction(enable);
+    RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+    return restriction.setWifiState(enable);
 }
 
-int dpm_is_factory_reset_restricted(dpm_client_h handle)
+int dpm_restriction_get_wifi_state(dpm_restriction_policy_h handle, int *state)
 {
-       assert(handle);
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER);
+
+    RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+    int ret = restriction.getWifiState();
+    if (ret < 0) {
+        return -1;
+    }
+    *state = ret;
+    return DPM_ERROR_NONE;
+}
+
+int dpm_restriction_set_wifi_hotspot_state(dpm_restriction_policy_h handle, int enable)
+{
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-       DevicePolicyClient& client = GetDevicePolicyClient(handle);
-       Restriction restriction = client.createPolicyInterface<Restriction>();
-       return restriction.isFactoryResetRestricted();
+    RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+    return restriction.setWifiHotspotState(enable);
+}
+
+int dpm_restriction_get_wifi_hotspot_state(dpm_restriction_policy_h handle, int *state)
+{
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER);
+
+    RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+    int ret = restriction.getWifiHotspotState();
+    if (ret < 0) {
+        return -1;
+    }
+    *state = ret;
+    return DPM_ERROR_NONE;
 }
index 666d27f..666774a 100644 (file)
@@ -17,7 +17,7 @@
 #ifndef __CAPI_RESTRICTION_POLICY_H__
 #define __CAPI_RESTRICTION_POLICY_H__
 
-#include <dpm/device-policy-client.h>
+#include <dpm/context.h>
 
 /**
  * @file restriction.h
@@ -34,85 +34,163 @@ extern "C" {
  */
 
 /**
- * @brief       Allows or disallows the user to use the clipboard.
- * @details     An administrator can use this API to set whether the clipboard.
- *              is allowed or not
+ * @brief       The record handle
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.restriction
- * @param[in]   handle Device Policy Client handle
- * @param[in]   enable If true, disallow the clipboard, if false, allow the clipboard
+ * @see         dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_release_restriction_policy()
+ */
+typedef void* dpm_restriction_policy_h;
+
+/**
+ * @brief       Acquires the restriction policy handle.
+ * @details     This API acquires restriction policy handle required to enforce
+ *              the restriction policies.
+ * @since_tizen 3.0
+ * @param[in]   handle The restriction policy context handle
+ * @return      Restriction policy handle on success, otherwise NULL
+ * @remark      The specific error code can be obtained by using the
+ *              get_last_result() method. Error codes are described in
+ *              exception section.
+ * @exception   #DPM_ERROR_NONE No error
+ * @exception   #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception   #DPM_ERROR_TIMED_OUT Time out
+ * @see         dpm_context_release_restriction_policy()
+ * @see         get_last_result()
+ */
+DPM_API dpm_restriction_policy_h dpm_context_acquire_restriction_policy(dpm_context_h handle);
+
+/**
+ * @brief       Releases the restriction policy handle.
+ * @details     This API must be called if interaction with the device
+ *              policy manager is no longer required.
+ * @since_tizen 3.0
+ * @param[in]   handle The restriction policy handle
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
- * @retval      #DPM_ERROR_ACCESS_DENIED The application does not have
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
+ * @pre         The handle must be created by dpm_context_acquire_restriction_policy().
+ * @see         dpm_context_acquire_restriction_policy()
+ */
+DPM_API int dpm_context_release_restriction_policy(dpm_context_h context, dpm_restriction_policy_h handle);
+
+/**
+ * @brief       Allows or disallows the camera.
+ * @details     An administrator can use this API to set whether the camera
+ *              is allowed or not.
+ * @since_tizen 3.0
+ * @param[in]   handle The restriction policy handle
+ * @param[in]   enable If true, disallow the camera, if false, allow the camera
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_is_clipboard_restricted()
+ * @pre         The handle must be created by dpm_context_acquire_restriction_policy().
+ * @see         dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_release_restriction_policy()
+ * @see         dpm_restriction_get_camera_state()
  */
-DPM_API int dpm_set_clipboard_restriction(dpm_client_h handle, int enable);
+DPM_API int dpm_restriction_set_camera_state(dpm_restriction_policy_h handle, int enable);
 
 /**
- * @brief       Checks whether the clipboard restriction is enable or not.
- * @details     An administrator can use this API to check the restriction status of
- *              the clipboard
+ * @brief       Gets the allow status of the camera.
+ * @details     An administrator can use this API to check the state of
+ *              the camera.
  * @since_tizen 3.0
- * @privlevel   public
- * @param[in]   handle Device Policy Client handle
- * @return      true if the clipboard is disallowed, else false
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_set_clipboard_restriction()
+ * @param[in]   handle The restriction policy handle
+ * @param[out]  enable The allow status of the camera
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
+ * @pre         The handle must be created by dpm_context_acquire_restriction_policy().
+ * @see         dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_release_restriction_policy()
+ * @see         dpm_restriction_set_camera_state()
  */
-DPM_API int dpm_is_clipboard_restricted(dpm_client_h handle);
+DPM_API int dpm_restriction_get_camera_state(dpm_restriction_policy_h handle, int *enable);
 
 /**
- * @brief       Allows or disallows the user to share the clipboard data between applications.
- * @details     An administrator can use this API to set whether the clipboard
- *              is allowed or not for sharing between applications.
+ * @brief       Allows or disallows the microphone.
+ * @details     An administrator can use this API to set whether the microphone
+ *              is allowed or not.
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.restriction
- * @param[in]   handle Device Policy Client handle
- * @param[in]   enable If true, disallow to share the clipboard, if false, allow to share the clipboard
+ * @param[in]   handle The restriction policy handle
+ * @param[in]   enable If true, disallow the microphone, if false, allow the microphone
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
+ *              the privilege to call this API
+ * @pre         The handle must be created by dpm_context_acquire_restriction_policy().
+ * @see         dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_release_restriction_policy()
+ * @see         dpm_restriction_get_microphone_state()
+ */
+DPM_API int dpm_restriction_set_microphone_state(dpm_restriction_policy_h handle, int enable);
+
+/**
+ * @brief       Gets the allow status of the microphone.
+ * @details     An administrator can use this API to check the state of
+ *              the microphone.
+ * @since_tizen 3.0
+ * @param[in]   handle The restriction policy handle
+ * @param[out]  enable The allow status of the microphone
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
+ * @pre         The handle must be created by dpm_context_acquire_restriction_policy().
+ * @see         dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_release_restriction_policy()
+ * @see         dpm_restriction_set_microphone_state()
+ */
+DPM_API int dpm_restriction_get_microphone_state(dpm_restriction_policy_h handle, int *enable);
+
+/**
+ * @brief       Aallows or disallows the user to change the location state
+ * @details     An administrator can use this API to allow or disallow to change
+ *              the location state.
+ * @since_tizen 3.0
+ * @param[in]   handle The restriction policy handle
+ * @param[in]   enable If TRUE, allow to change the location state, if false, disallow
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_TIMEOUT Time out
  * @retval      #DPM_ERROR_ACCESS_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_is_clipboard_share_restriction()
+ * @pre         handle must be created by dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_release_restriction_policy()
+ * @see         dpm_restriction_get_location_state()
  */
-DPM_API int dpm_set_clipboard_share_restriction(dpm_client_h handle, int enable);
+DPM_API int dpm_restriction_set_location_state(dpm_restriction_policy_h handle, int enable);
 
 /**
- * @brief       Checks whether the clipboard share restriction is enable or not.
- * @details     An administrator can use this API to check the restriction status of
- *              sharing clipboard between applications.
+ * @brief       API to get the allow status of the location state change.
+ * @details     An administrator can use this API to get the allow status of
+ *              the location state change.
  * @since_tizen 3.0
  * @privlevel   public
- * @param[in]   handle Device Policy Client handle
- * @return      true if the clipboard cannot shared data, else false
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_set_clipboard_share_restriction()
+ * @param[in]   handle The restriction policy handle
+ * @param[out]  enable The state of location
+ * @return      status Allow status of localtion state change
+ * @pre         handle must be created by dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_release_restriction_policy()
+ * @see         dpm_restriction_set_location_state()
  */
-DPM_API int dpm_is_clipboard_share_restricted(dpm_client_h handle);
+DPM_API int dpm_restriction_get_location_state(dpm_restriction_policy_h handle, int *enable);
 
 /**
  * @brief       Allows or disallows the user to use the settings changes.
  * @details     An administrator can use this API to set whether the Settins
  *              changes is allowed or not.
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.restriction
- * @param[in]   handle Device Policy Client handle
+ * @param[in]   handle The settings policy handle
  * @param[in]   enable If true, disallow the settings changes, if false, allow
  *              the settings changes
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
@@ -120,73 +198,103 @@ DPM_API int dpm_is_clipboard_share_restricted(dpm_client_h handle);
  * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
  * @retval      #DPM_ERROR_ACCESS_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_is_settings_changes_restricted()
+ * @pre         handle must be created by dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_release_restriction_policy()
+ * @see         dpm_restriction_get_settings_changes_state()
  */
-DPM_API int dpm_set_settings_changes_restriction(dpm_client_h handle, int enable);
+DPM_API int dpm_restriction_set_settings_changes_state(dpm_restriction_policy_h handle, int enable);
 
 /**
  * @brief       Checks whether the settings changes restriction is enable or not.
  * @details     An administrator can use this API to get the allow statsus of
  *              the Settins changes.
  * @since_tizen 3.0
- * @privlevel   public
- * @param[in]   handle Device Policy Client handle
+ * @param[in]   handle The restriction policy handle
+ * @param[out]  state The state of settings changes
  * @return      true if the settings changes is disallowed, else false
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_set_settings_changes_restriction()
+ * @pre         handle must be created by dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_release_restriction_policy()
+ * @see         dpm_restriction_set_settings_changes_state()
  */
-DPM_API int dpm_is_settings_changes_restricted(dpm_client_h handle);
+DPM_API int dpm_restriction_get_settings_changes_state(dpm_restriction_policy_h handle, int *enable);
 
 /**
- * @brief       Allows or disallows the user to use the background data.
- * @details     An administrator can use this API to set whether the background
- *              data is allowed or not.
+ * @brief       Allows or disallows the user to use the usb mass storage
+ * @details     An administrator can use this API to set whether the usb mass
+ *              storage is allowed or not.
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.restriction
- * @param[in]   handle Device Policy Client handle
- * @param[in]   enable If true, disallow the background data, if false, allow
- *              the background data
+ * @param[in]   handle The storage policy handle
+ * @param[in]   enable If true, disallow the usb mass storage, if false, allow
+ *              the usb mas storage
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
  * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
  * @retval      #DPM_ERROR_ACCESS_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_is_background_data_restricted()
+ * @pre         handle must be created by dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_release_restriction_policy()
+ * @see         dpm_storage_get_external_storage_state()
  */
-DPM_API int dpm_set_background_data_restriction(dpm_client_h handle, int enable);
+DPM_API int dpm_restriction_set_external_storage_state(dpm_restriction_policy_h handle, int enable);
 
 /**
- * @brief       Checks whether the background data restriction is enable or not.
+ * @brief       Checks whether the usb mass storage restriction is enable or not.
  * @details     An administrator can use this API to check the restriction status of
- *              the background data.
+ *              the usb mass storage.
  * @since_tizen 3.0
  * @privlevel   public
- * @param[in]   handle Device Policy Client handle
- * @return      true if the background data is disallowed, else false
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_set_background_data_restriction()
+ * @param[in]   handle The restriction policy handle
+ * @param[out]  state The state of external storage
+ * @return      true if the usb mass storage is disallowed, else false
+ * @pre         handle must be created by dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_release_restriction_policy()
+ * @see         dpm_storage_set_external_storage_state()
+ */
+DPM_API int dpm_restriction_get_external_storage_state(dpm_restriction_policy_h handle, int *state);
+
+/**
+ * @brief       Allows or disallows the user to use the clipboard.
+ * @details     An administrator can use this API to set whether the clipboard.
+ *              is allowed or not
+ * @since_tizen 3.0
+ * @param[in]   handle DatasharePolicy Context Handle
+ * @param[in]   enable If true, disallow the clipboard, if false, allow the clipboard
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
+ * @retval      #DPM_ERROR_ACCESS_DENIED The application does not have
+ *              the privilege to call this API
+ * @pre         handle must be created by dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_release_restriction_policy()
+ * @see         dpm_restriction_get_clipboard_state()
+ */
+DPM_API int dpm_restriction_set_clipboard_state(dpm_restriction_policy_h handle, int enable);
+
+/**
+ * @brief       Checks whether the the use of clipboard is allowed or not.
+ * @details     An administrator can use this API to check the use of clipboard is allowed.
+ * @since_tizen 3.0
+ * @param[in]   handle The restriction policy handle
+ * @param[out]  state The state of clipboard
+ * @return      true if the clipboard is disallowed, else false
+ * @pre         The handle must be created by dpm_context_acquire_restriction_policy().
+ * @see         dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_release_restriction_policy()
+ * @see         dpm_restriction_set_clipboard_state()
  */
-DPM_API int dpm_is_background_data_restricted(dpm_client_h handle);
+DPM_API int dpm_restriction_get_clipboard_state(dpm_restriction_policy_h handle, int *state);
 
 /**
  * @brief       Allows or disallows the user to use the usb debugging
  * @details     An administrator can use this API to set whether the usb debugging
  *              is allowed or not.
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.restriction
- * @param[in]   handle Device Policy Client handle
+ * @param[in]   handle The restriction policy handle
  * @param[in]   enable If true, disallow the usb debugging, if false, disallow the usb
  *              debugging
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
@@ -194,101 +302,113 @@ DPM_API int dpm_is_background_data_restricted(dpm_client_h handle);
  * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
  * @retval      #DPM_ERROR_ACCESS_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_is_usb_debugging_restricted()
+ * @pre         The handle must be created by dpm_context_acquire_restriction_policy().
+ * @see         dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_release_restriction_policy()
+ * @see         dpm_restriction_get_usb_debugging_state()
  */
-DPM_API int dpm_set_usb_debugging_restriction(dpm_client_h handle, int enable);
+DPM_API int dpm_restriction_set_usb_debugging_state(dpm_restriction_policy_h handle, int enable);
 
 /**
- * @brief       Checks whether the usb debugging restriction is enable or not.
+ * @brief       Checks whether the usb debugging is allowed or not.
  * @details     An administrator can use this API to check the restriction status of
  *              the usb debugging.
  * @since_tizen 3.0
- * @privlevel   public
- * @param[in]   handle Device Policy Client handle
+ * @param[in]   handle The device restriction policy handle
+ * @param[out]   state The state of usb debugging
  * @return      true if the usb debugging is disallowed, else false
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_set_usb_debugging_restriction()
+ * @pre         The handle must be created by dpm_context_acquire_restriction_policy().
+ * @see         dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_release_restriction_policy()
+ * @see         dpm_restriction_set_usb_debugging_state()
  */
-DPM_API int dpm_is_usb_debugging_restricted(dpm_client_h handle);
+DPM_API int dpm_restriction_get_usb_debugging_state(dpm_restriction_policy_h handle, int *state);
 
 /**
- * @brief       Allows or disallows the user to use the usb mass storage
- * @details     An administrator can use this API to set whether the usb mass
- *              storage is allowed or not.
+ * @brief       Allows or disallows the user to change the Wi-Fi state.
+ * @details     An administrator can use this API to allow or disallow the user to
+ *              change the Wi-Fi state. If it is restricted, the user does not have UI
+ *              access to change the state.
+ *              Also, the apps that uses wifi_activate() or wifi_deactivate()
+ *              follow this restriction.
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.restriction
- * @param[in]   handle Device Policy Client handle
- * @param[in]   enable If true, disallow the usb mass storage, if false, allow
- *              the usb mas storage
+ * @param[in]   handle The restriction policy handle
+ * @param[in]   enable TRUE to enable wifi state change restriction, else FALSE
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
- * @retval      #DPM_ERROR_ACCESS_DENIED The application does not have
+ * @retval      #DPM_ERROR_TIMEOUT Time out
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_is_usb_mass_storage_restricted()
+ * @pre         handle must be created by dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_release_restriction_policy()
+ * @see         dpm_wifi_is_state_change_allowed()
  */
-DPM_API int dpm_set_usb_mass_storage_restriction(dpm_client_h handle, int enable);
+DPM_API int dpm_restriction_set_wifi_state(dpm_restriction_policy_h handle, int enable);
 
 /**
- * @brief       Checks whether the usb mass storage restriction is enable or not.
- * @details     An administrator can use this API to check the restriction status of
- *              the usb mass storage.
+ * @brief       Checks whether the user is restricted to change the Wi-Fi state.
+ * @details     An administrator can use this API to check whether or not the user is
+ *              restricted to modify Wi-Fi settings. The user is restricted in modifying
+ *              Wi-Fi settings if at least one administrator has set the value to FALSE.
  * @since_tizen 3.0
- * @privlevel   public
- * @param[in]   handle Device Policy Client handle
- * @return      true if the usb mass storage is disallowed, else false
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_set_usb_mass_storage_restriction()
+ * @param[in]   handle The restriction policy handle
+ * @param[out]  enable TRUE if the user is not allowed to change the Wi-Fi state,
+                else FALSE
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_TIMEOUT Time out
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre         handle must be created by dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_release_restriction_policy()
+ * @see         dpm_wifi_allow_state_change()
  */
-DPM_API int dpm_is_usb_mass_storage_restricted(dpm_client_h handle);
+DPM_API int dpm_restriction_get_wifi_state(dpm_restriction_policy_h handle, int *enable);
 
 /**
- * @brief       Allows or disallows the user to use the factory reset
- * @details     An administrator can use this API to set whether the factory
- *              reset is allowed or not.
+ * @brief       Allows or disallows the user to change Wi-Fi hotspot settings
+ * @details     An administrator can use this API to restrict changing Wi-Fi
+ *              hotspot settings. When restricted, the UI is grayed out so the user cannot
+ *              modify the settings.
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.restriction
- * @param[in]   handle Device Policy Client handle
- * @param[in]   enable If true, disallow the factory reset, if false, allow
- *              the factory reset
+ * @param[in]   handle The restriction policy handle
+ * @param[in]   enable TRUE to restrict wifi hostspot setting, else FALSE
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_TIMEOUT Time out
  * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
- * @retval      #DPM_ERROR_ACCESS_DENIED The application does not have
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_is_factory_reset_restricted()
+ * @pre         handle must be created by dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_release_restriction_policy()
+ * @see         dpm_restriction_get_wifi_hotspot_state()
  */
-DPM_API int dpm_set_factory_reset_restriction(dpm_client_h handle, int enable);
+DPM_API int dpm_restriction_set_wifi_hotspot_state(dpm_restriction_policy_h handle, int enable);
 
 /**
- * @brief       Checks whether the factory reset restriction is enable or not.
- * @details     An administrator can use this API to check the restriction status of
- *              factory reset.
+ * @brief       Checks whether the the Wi-Fi hotspot is restricted.
+ * @details     An administrator can use this API to check whether the Wi-Fi hotspot
+ *              is restricted.
+ *              If the Wi-Fi hotspot is restricted, the UI is grayed out so user can not
+ *              change its state.
  * @since_tizen 3.0
- * @privlevel   public
- * @param[in]   handle Device Policy Client handle
- * @return      true if the factory reset is disallowed, else false
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_set_factory_reset_restriction()
+ * @param[in]   handle The restriction policy handle
+ * @param[out]  enable TRUE if modification is allowed,
+ *              FALSE if modification is denied
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_TIMEOUT Time out
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre         handle must be created by dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_acquire_restriction_policy()
+ * @see         dpm_context_release_restriction_policy()
+ * @see         dpm_restriction_set_wifi_hotspot_state()
  */
-DPM_API int dpm_is_factory_reset_restricted(dpm_client_h handle);
+DPM_API int dpm_restriction_get_wifi_hotspot_state(dpm_restriction_policy_h handle, int *enable);
 
 /**
  * @} // end of DPM_RESTRICTION_POLICY
index d219100..47dd273 100644 (file)
 #include "security.h"
 #include "security.hxx"
 
-#include "capi-assert.h"
+#include "debug.h"
 #include "policy-client.h"
 
 using namespace DevicePolicyManager;
 
-int dpm_lockout_device(dpm_client_h handle)
+dpm_security_policy_h dpm_context_acquire_security_policy(dpm_context_h handle)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Security security = client.createPolicyInterface<Security>();
-    return security.lockoutDevice();
-}
-
-int dpm_lockout_screen(dpm_client_h handle)
-{
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(handle, NULL);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Security security = client.createPolicyInterface<Security>();
-    return security.lockoutScreen();
+    DevicePolicyContext &client = GetDevicePolicyContext(handle);
+    return client.createPolicyInterface<SecurityPolicy>();
 }
 
-int dpm_wipe_data(dpm_client_h handle, const dpm_wipe_type_e type)
+int dpm_context_release_security_policy(dpm_context_h context, dpm_security_policy_h handle)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Security security = client.createPolicyInterface<Security>();
-    return security.wipeData(type);
+    delete &GetPolicyInterface<SecurityPolicy>(handle);
+    return DPM_ERROR_NONE;
 }
 
-int dpm_reboot(dpm_client_h handle)
+int dpm_security_lockout_device(dpm_security_policy_h handle)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Security security = client.createPolicyInterface<Security>();
-    return security.reboot();
+    SecurityPolicy& security = GetPolicyInterface<SecurityPolicy>(handle);
+    return security.lockoutDevice();
 }
 
-int dpm_poweroff_device(dpm_client_h handle)
+int dpm_security_lockout_screen(dpm_security_policy_h handle)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Security security = client.createPolicyInterface<Security>();
-    return security.powerOffDevice();
+    SecurityPolicy& security = GetPolicyInterface<SecurityPolicy>(handle);
+    return security.lockoutScreen();
 }
 
-int dpm_set_internal_storage_encryption(dpm_client_h handle, const int encrypt)
+int dpm_security_set_internal_storage_encryption(dpm_security_policy_h handle, const int encrypt)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Security security = client.createPolicyInterface<Security>();
+    SecurityPolicy& security = GetPolicyInterface<SecurityPolicy>(handle);
     return security.setInternalStorageEncryption(encrypt);
 }
 
-int dpm_is_internal_storage_encrypted(dpm_client_h handle)
+int dpm_security_is_internal_storage_encrypted(dpm_security_policy_h handle, int *state)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Security security = client.createPolicyInterface<Security>();
-    return security.isInternalStorageEncrypted();
+    RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER);
+
+    SecurityPolicy& security = GetPolicyInterface<SecurityPolicy>(handle);
+    int ret = security.isInternalStorageEncrypted();
+    if (ret < 0) {
+        return -1;
+    }
+    *state = ret;
+    return DPM_ERROR_NONE;
 }
 
-int dpm_set_external_storage_encryption(dpm_client_h handle, const int encrypt)
+int dpm_security_set_external_storage_encryption(dpm_security_policy_h handle, const int encrypt)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Security security = client.createPolicyInterface<Security>();
+    SecurityPolicy& security = GetPolicyInterface<SecurityPolicy>(handle);
     return security.setExternalStorageEncryption(encrypt);
 }
 
-int dpm_is_external_storage_encrypted(dpm_client_h handle)
+int dpm_security_is_external_storage_encrypted(dpm_security_policy_h handle, int *state)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Security security = client.createPolicyInterface<Security>();
-    return security.isExternalStorageEncrypted();
+    RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER);
+
+    SecurityPolicy& security = GetPolicyInterface<SecurityPolicy>(handle);
+    int ret = security.isExternalStorageEncrypted();
+    if (ret < 0) {
+        return -1;
+    }
+    *state = ret;
+    return DPM_ERROR_NONE;
 }
-
index c2ac6d2..b1905ac 100644 (file)
 #ifndef __CAPI_SECURITY_POLICY_H__
 #define __CAPI_SECURITY_POLICY_H__
 
-#include <dpm/device-policy-client.h>
+#include <dpm/context.h>
 
 /**
  * @file security.h
  * @brief This file provides APIs to control security functionality such as
- *        device encryption and wipe
+ *        device encryption and screen lock
  */
 
 #ifdef __cplusplus
@@ -35,94 +35,62 @@ extern "C" {
  */
 
 /**
- * @brief       Enumeration for device wipe type
+ * @brief       The security policy handle
  * @since_tizen 3.0
+ * @see         dpm_context_acquire_security_policy()
+ * @see         dpm_context_release_security_policy()
  */
-typedef enum {
-    WIPE_INTERNAL_MEMORY = (1 << 0), /**< Wipe internal memory. */
-    WIPE_EXTERNAL_MEMORY = (1 << 1)  /**< Wipe external memory. */
-} dpm_wipe_type_e;
+typedef void* dpm_security_policy_h;
 
 /**
- * @brief       API to immediately lock device screen
- * @details     An administrator can use this API to lock the device screen
- *              immediately
+ * @brief       Acquires the security policy handle.
+ * @details     This API acquires security policy handle required to enforce
+ *              the security policies.
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.security
- * @param[in]   handle Device Policy Client handle
- * @return      #DPM_ERROR_NONE on success, otherwise a negative value
- * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
- * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
- *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
+ * @param[in]   handle Device policy context handle
+ * @return      Security policy handle on success, otherwise NULL
+ * @remark      The specific error code can be obtained by using the
+ *              get_last_result() method. Error codes are described in
+ *              exception section.
+ * @exception   #DPM_ERROR_NONE No error
+ * @exception   #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception   #DPM_ERROR_TIMED_OUT Time out
+ * @see         dpm_context_release_security_policy()
+ * @see         get_last_result()
  */
-DPM_API int dpm_lockout_screen(dpm_client_h handle);
+DPM_API dpm_security_policy_h dpm_context_acquire_security_policy(dpm_context_h handle);
 
 /**
- * @brief       API to selectively wipe external memory, internal memory,
- *              or both.
- * @details     Device Admin can use this API to wipe both SD card data
- *              and application data.
- *              Calling this API may require rebooting the device.
+ * @brief       Releases the security policy andle.
+ * @details     This API must be called if interaction with the device
+ *              policy manager is no longer required.
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.security
- * @param[in]   handle Device Policy Client handle
- * @param[in]   type DPM_WIPE_INTERNAL_MEMORY or DPM_WIPE_EXTERNAL_MEMORY
+ * @param[in]   handle The device policy context
+ * @param[in]   handle The Security policy Handle
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
- * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
- *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
+ * @pre         The handle must be created by dpm_context_acquire_security_policy().
+ * @see         dpm_context_acquire_security_policy()
  */
-DPM_API int dpm_wipe_data(dpm_client_h handle, const dpm_wipe_type_e type);
+DPM_API int dpm_context_release_security_policy(dpm_context_h context, dpm_security_policy_h handle);
 
 /**
- * @brief       API to reboot the device
- * @details     An administrator can use this API to reboot the device
- *              wthout user interaction
- * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.security
- * @param[in]   handle Device Policy Client handle
- * @return      #DPM_ERROR_NONE on success, otherwise a negative value
- * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
- *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- */
-DPM_API int dpm_reboot(dpm_client_h handle);
-
-/**
- * @brief       API to poweroff the device
- * @details     An administrator can use this API to turn off the device
- *              without user interaction
+ * @brief       API to immediately lock device screen
+ * @details     An administrator can use this API to lock the device screen
+ *              immediately
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.security
- * @param[in]   handle Device Policy Client handle
+ * @param[in]   handle Security policy handle
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
+ * @pre         handle must be created by dpm_context_create()
+ * @see         dpm_context_acquire_security_policy()
+ * @see         dpm_context_release_security_policy()
  */
-DPM_API int dpm_poweroff_device(dpm_client_h handle);
+DPM_API int dpm_security_lockout_screen(dpm_security_policy_h handle);
 
 /**
  * @brief       API to encrypt internal storage
@@ -133,9 +101,7 @@ DPM_API int dpm_poweroff_device(dpm_client_h handle);
  *              The administrator can set an alphanumeric password by using
  *              dpm_set_password_quality() API
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.security
- * @param[in]   handle Device Policy Client handle
+ * @param[in]   handle Security policy handle
  * @param[in]   encrypt TRUE if encryption is required, FALSE if decryption is
  *              required
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
@@ -143,28 +109,29 @@ DPM_API int dpm_poweroff_device(dpm_client_h handle);
  * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
+ * @pre         handle must be created by dpm_context_create()
+ * @see         dpm_context_acquire_security_policy()
+ * @see         dpm_context_release_security_policy()
  */
-DPM_API int dpm_set_internal_storage_encryption(dpm_client_h handle, const int encrypt);
+DPM_API int dpm_security_set_internal_storage_encryption(dpm_security_policy_h handle, const int encrypt);
 
 /**
  * @brief       API to check the state of internal storage encryption
  * @details     An administrator can use this API to check whether internal
  *              storage encryption is enabled.
  * @since_tizen 3.0
- * @param[in]   handle Device Policy Client handle
- * @return      TRUE if internal storage is encrypted or being encrypted,
+ * @param[in]   handle Security policy handle
+ * @param[out]  state TRUE if internal storage is encrypted or being encrypted,
  *              else false.
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_set_password_quality()
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_TIMEOUT Time out
+ * @pre         handle must be created by dpm_context_acquire_security_policy()
+ * @see         dpm_context_acquire_security_policy()
+ * @see         dpm_context_release_security_policy()
+ * @see         dpm_security_is_internal_storage_encrypted()
  */
-DPM_API int dpm_is_internal_storage_encrypted(dpm_client_h handle);
+DPM_API int dpm_security_is_internal_storage_encrypted(dpm_security_policy_h handle);
 
 /**
  * @brief       API to encrypt external storage
@@ -174,38 +141,36 @@ DPM_API int dpm_is_internal_storage_encrypted(dpm_client_h handle);
  *              The administrator can set an alphanumeric password by using
  *              dpm_set_password_quality() API
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.security
- * @param[in]   handle Device Policy Client handle
+ * @param[in]   handle Security policy handle
  * @param[in]   encrypt TRUE if encryption is required, FALSE if decryption is
  *              required
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_set_password_quality()
+ * @pre         handle must be created by dpm_context_create()
+ * @see         dpm_context_acquire_security_policy()
+ * @see         dpm_context_release_security_policy()
+ * @see         dpm_security_set_internal_storage_encryption()
  */
-DPM_API int dpm_set_external_storage_encryption(dpm_client_h handle, const int encrypt);
+DPM_API int dpm_security_set_external_storage_encryption(dpm_security_policy_h handle, const int encrypt);
 
 /**
  * @brief       API to check the state of external storage encryption
  * @details     An administrator can use this API to check whether external
  *              storage encryption is enabled.
  * @since_tizen 3.0
- * @param[in]   handle Device Policy Client handle
- * @return      TRUE if external storage is encrypted or being encrypted,
+ * @param[in]   handle Security policy handle
+ * @param[out   TRUE if external storage is encrypted or being encrypted,
  *              else FALSE
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_TIMEOUT Time out
+ * @pre         handle must be created by dpm_context_create()
+ * @see         dpm_context_acquire_security_policy()
+ * @see         dpm_context_release_security_policy()
  */
-DPM_API int dpm_is_external_storage_encrypted(dpm_client_h handle);
+DPM_API int dpm_security_is_external_storage_encrypted(dpm_security_policy_h handle, int *state);
 
 /**
  * @}
diff --git a/libs/dpm/storage.cpp b/libs/dpm/storage.cpp
new file mode 100644 (file)
index 0000000..a489f1c
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ *  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 "storage.h"
+#include "storage.hxx"
+
+#include "debug.h"
+#include "policy-client.h"
+
+using namespace DevicePolicyManager;
+
+dpm_storage_policy_h dpm_context_acquire_storage_policy(dpm_context_h handle)
+{
+       RET_ON_FAILURE(handle, NULL);
+
+    DevicePolicyContext &client = GetDevicePolicyContext(handle);
+    return client.createPolicyInterface<StoragePolicy>();
+}
+
+int dpm_context_release_storage_policy(dpm_storage_policy_h handle)
+{
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    delete &GetPolicyInterface<StoragePolicy>(handle);
+    return DPM_ERROR_NONE;
+}
+
+int dpm_storage_wipe_data(dpm_storage_policy_h handle, const dpm_wipe_type_e type)
+{
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+
+       StoragePolicy& storagePolicy = GetPolicyInterface<StoragePolicy>(handle);
+       return storagePolicy.wipeData(type);
+}
diff --git a/libs/dpm/storage.h b/libs/dpm/storage.h
new file mode 100644 (file)
index 0000000..9008492
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ *  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 __CAPI_STORAGE_POLICY_H__
+#define __CAPI_STORAGE_POLICY_H__
+
+#include <dpm/context.h>
+
+/**
+ * @file storage.h
+ * @brief This file provides APIs to control storage
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup  CAPI_DPM_STORAGE_POLICY_MODULE
+ * @{
+ */
+
+/**
+ * @brief       Enumeration for device wipe type
+ * @since_tizen 3.0
+ */
+typedef enum {
+    WIPE_INTERNAL_STORAGE = (1 << 0), /**< Wipe internal memory. */
+    WIPE_EXTERNAL_STORAGE = (1 << 1)  /**< Wipe external memory. */
+} dpm_wipe_type_e;
+
+/**
+ * @brief       The storage policy handle
+ * @since_tizen 3.0
+ * @see         dpm_context_acquire_storage_policy()
+ * @see         dpm_context_release_storage_policy()
+ */
+typedef void* dpm_storage_policy_h;
+
+/**
+ * @brief       Acquires the storage policy handle.
+ * @details     This API acquires storage policy handle required to enforce
+ *              the storage policies.
+ * @since_tizen 3.0
+ * @param[in]   handle The device policy context handle
+ * @return      Storage policy handle on success, otherwise NULL
+ * @remark      The specific error code can be obtained by using the
+ *              get_last_result() method. Error codes are described in
+ *              exception section.
+ * @exception   #DPM_ERROR_NONE No error
+ * @exception   #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception   #DPM_ERROR_TIMED_OUT Time out
+ * @see         dpm_context_release_storage_policy()
+ * @see         get_last_result()
+ */
+DPM_API dpm_storage_policy_h dpm_context_acquire_storage_policy(dpm_context_h handle);
+
+/**
+ * @brief       Releases the storage policy handle.
+ * @details     This API must be called if interaction with the device
+ *              policy manager is no longer required.
+ * @since_tizen 3.0
+ * @param[in]   handle The device policy context
+ * @param[in]   handle The storage policy handle
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
+ * @pre         The handle must be created by dpm_context_acquire_storage_policy().
+ * @see         dpm_context_acquire_storage_policy()
+ */
+DPM_API int dpm_context_release_storage_policy(dpm_context_h context, dpm_storage_policy_h handle);
+
+/**
+ * @brief       API to selectively wipe external memory, internal memory,
+ *              or both.
+ * @details     Device Admin can use this API to wipe both SD card data
+ *              and application data.
+ *              Calling this API may require rebooting the device.
+ * @since_tizen 3.0
+ * @param[in]   handle Storage policy handle
+ * @param[in]   type DPM_WIPE_INTERNAL_STORAGE or DPM_WIPE_EXTERNAL_STORAGE
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
+ *              the privilege to call this API
+ * @pre         handle must be created by dpm_context_acquire_storage_policy()
+ * @see         dpm_context_acquire_storage_policy()
+ * @see         dpm_context_release_storage_policy()
+ */
+DPM_API int dpm_storage_wipe_data(dpm_storage_policy_h handle, const dpm_wipe_type_e type);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__CAPI_STORAGE_POLICY_H__
index 5007ddb..5a4db69 100644 (file)
 #include "wifi.h"
 #include "wifi.hxx"
 
-#include "capi-assert.h"
+#include "debug.h"
 #include "policy-client.h"
 
 using namespace DevicePolicyManager;
 
-int dpm_set_wifi_state_change_restriction(dpm_client_h handle, int enable)
+dpm_wifi_policy_h dpm_context_acquire_wifi_policy(dpm_context_h handle, const char* zone)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(handle, NULL);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Wifi wifi = client.createPolicyInterface<Wifi>();
-    return wifi.setStateChangeRestriction(enable);
+    DevicePolicyContext &client = GetDevicePolicyContext(handle);
+    return client.createPolicyInterface<WifiPolicy>();
 }
 
-int dpm_is_wifi_state_change_restricted(dpm_client_h handle, int *enable)
+int dpm_context_release_wifi_policy(dpm_context_h context, dpm_wifi_policy_h handle)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(enable, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Wifi wifi = client.createPolicyInterface<Wifi>();
-    *enable = wifi.isStateChangeRestricted();
+    delete &GetPolicyInterface<WifiPolicy>(handle);
     return DPM_ERROR_NONE;
 }
 
-int dpm_set_wifi_setting_changes_restriction(dpm_client_h handle, int enable)
+int dpm_wifi_allow_settings_change(dpm_wifi_policy_h handle, int enable)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Wifi wifi = client.createPolicyInterface<Wifi>();
-    return wifi.setSettingChangesRestriction(enable);
+    WifiPolicy& wifi = GetPolicyInterface<WifiPolicy>(handle);
+    return wifi.allowSettingsChange(enable);
 }
 
-int dpm_is_wifi_setting_changes_restricted(dpm_client_h handle, int *enable)
+int dpm_wifi_is_settings_changes_allowed(dpm_wifi_policy_h handle, int *enable)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
     RET_ON_FAILURE(enable, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Wifi wifi = client.createPolicyInterface<Wifi>();
-    *enable = wifi.isSettingChangesRestricted();
-    return DPM_ERROR_NONE;
-}
-
-int dpm_allow_wifi_hotspot_restriction(dpm_client_h handle, int enable)
-{
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Wifi wifi = client.createPolicyInterface<Wifi>();
-    return wifi.setHotspotRestriction(enable);
-}
+    WifiPolicy& wifi = GetPolicyInterface<WifiPolicy>(handle);
+    *enable = wifi.isSettingsChangeAllowed();
 
-int dpm_is_wifi_hotspot_restricted(dpm_client_h handle, int *enable)
-{
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(enable, DPM_ERROR_INVALID_PARAMETER);
-
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Wifi wifi = client.createPolicyInterface<Wifi>();
-    *enable = wifi.isHotspotRestricted();
     return DPM_ERROR_NONE;
 }
 
-int dpm_set_wifi_network_access_restriction(dpm_client_h handle, int enable)
+int dpm_wifi_set_network_access_restriction(dpm_wifi_policy_h handle, int enable)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Wifi wifi = client.createPolicyInterface<Wifi>();
+    WifiPolicy& wifi = GetPolicyInterface<WifiPolicy>(handle);
     return wifi.setNetworkAccessRestriction(enable);
 }
 
-int dpm_is_wifi_network_access_restricted(dpm_client_h handle, int *enable)
+int dpm_wifi_is_network_access_restricted(dpm_wifi_policy_h handle, int *enable)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
     RET_ON_FAILURE(enable, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Wifi wifi = client.createPolicyInterface<Wifi>();
+    WifiPolicy& wifi = GetPolicyInterface<WifiPolicy>(handle);
     *enable = wifi.isNetworkAccessRestricted();
+
     return DPM_ERROR_NONE;
 }
 
-int dpm_add_wifi_ssid_to_blocklist(dpm_client_h handle, const char* ssid)
+int dpm_wifi_add_ssid_to_blocklist(dpm_wifi_policy_h handle, const char* ssid)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
     RET_ON_FAILURE(ssid, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Wifi wifi = client.createPolicyInterface<Wifi>();
-    return wifi.addSsidFromBlacklist(ssid);
+    WifiPolicy& wifi = GetPolicyInterface<WifiPolicy>(handle);
+    return wifi.addSsidToBlocklist(ssid);
 }
 
-int dpm_remove_wifi_ssid_from_blocklist(dpm_client_h handle, const char* ssid)
+int dpm_wifi_remove_ssid_from_blocklist(dpm_wifi_policy_h handle, const char* ssid)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
     RET_ON_FAILURE(ssid, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Wifi wifi = client.createPolicyInterface<Wifi>();
-    return wifi.removeSsidFromBlacklist(ssid);
+    WifiPolicy& wifi = GetPolicyInterface<WifiPolicy>(handle);
+    return wifi.removeSsidFromBlocklist(ssid);
 }
index 34a4d8f..8f5e538 100644 (file)
@@ -17,7 +17,7 @@
 #ifndef __CAPI_WIFI_POLICY_H__
 #define __CAPI_WIFI_POLICY_H__
 
-#include <dpm/device-policy-client.h>
+#include <dpm/context.h>
 
 /**
  * @file wifi.h
@@ -34,53 +34,46 @@ extern "C" {
  */
 
 /**
- * @brief       Allows or disallows the user to change the Wi-Fi state.
- * @details     An administrator can use this API to allow or disallow the user to
- *              change the Wi-Fi state. If it is restricted, the user does not have UI
- *              access to change the state.
- *              Also, the apps that uses wifi_activate() or wifi_deactivate()
- *              follow this restriction.
+ * @brief       The Wi-Fi policy handle
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.wifi
- * @param[in]   handle Device Policy Client handle
- * @param[in]   enable TRUE to enable wifi state change restriction, else FALSE
- * @return      #DPM_ERROR_NONE on success, otherwise a negative value
- * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_TIMEOUT Timeout
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
- * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
- *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dom_is_wifi_state_change_restricted()
- * @see         wifi_activate()
- * @see         wifi_deactivate()
+ * @see         dpm_context_acquire_wifi_policy()
+ * @see         dpm_context_release_wifi_policy()
  */
-DPM_API int dpm_set_wifi_state_change_restriction(dpm_client_h handle, int enable);
+typedef void* dpm_wifi_policy_h;
 
 /**
- * @brief       Checks whether the user is restricted to change the Wi-Fi state.
- * @details     An administrator can use this API to check whether or not the user is
- *              restricted to modify Wi-Fi settings. The user is restricted in modifying
- *              Wi-Fi settings if at least one administrator has set the value to FALSE.
+ * @brief       Acquires the Wi-Fi policy handle.
+ * @details     This API acquires camera policy handle required to enforce
+ *              the Wi-Fi policies.
  * @since_tizen 3.0
- * @param[in]   handle Device Policy Client handle
- * @param[out]  enable TRUE if the user is not allowed to change the Wi-Fi state,
-                else FALSE
+ * @param[in]   handle Device policy context Handle
+ * @return      Wi-Fi policy handle on success, otherwise NULL
+ * @remark      The specific error code can be obtained by using the
+ *              get_last_result() method. Error codes are described in
+ *              exception section.
+ * @exception   #DPM_ERROR_NONE No error
+ * @exception   #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception   #DPM_ERROR_TIMED_OUT Time out
+ * @see         dpm_context_release_wifi_policy()
+ * @see         get_last_result()
+ */
+DPM_API dpm_wifi_policy_h dpm_context_acquire_wifi_policy(dpm_context_h handle, const char* zone);
+
+/**
+ * @brief       Releases the Wi-Fi policy handle.
+ * @details     This API must be called if interaction with the device
+ *              policy manager is no longer required.
+ * @since_tizen 3.0
+ * @param[in]   handle The device policy context
+ * @param[in]   handle The Wi-Fi policy handle
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_TIMEOUT Timeout
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
  * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_set_wifi_state_change_restriction()
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
+ * @pre         The handle must be created by dpm_context_acquire_camera_policy().
+ * @see         dpm_context_acquire_wifi_policy()
  */
-DPM_API int dpm_is_wifi_state_change_restricted(dpm_client_h handle, int *enable);
+DPM_API int dpm_context_release_wifi_policy(dpm_context_h context, dpm_wifi_policy_h handle);
 
 /**
  * @brief       Allows or disallows user to modify some Wi-Fi settings of network settings.
@@ -92,33 +85,20 @@ DPM_API int dpm_is_wifi_state_change_restricted(dpm_client_h handle, int *enable
  *              modify all Wi-fi network settings normally and also remove it.
  *              Also the apps that uses wifi_ap_set_* APIs follow this restriction.
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.wifi
- * @param[in]   handle Device Policy Client handle
+ * @param[in]   handle Wi-Fi policy handle
  * @param[in]   enable TRUE to enable wifi setting changes, else FALSE
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_TIMEOUT Timeout
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
+ * @retval      #DPM_ERROR_TIMEOUT Time out
  * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dom_is_wifi_setting_changes_restricted()
- * @see         wifi_ap_set_ip_config_type()
- * @see         wifi_ap_set_ip_address()
- * @see         wifi_ap_set_subnet_mask()
- * @see         wifi_ap_set_gateway_address()
- * @see         wifi_ap_set_proxy_address()
- * @see         wifi_ap_set_proxy_tyype()
- * @see         wifi_ap_set_dns_address()
- * @see         wifi_ap_set_security_type()
- * @see         wifi_ap_set_encryption_type()
- * @see         wifi_ap_set_passphrase()
+ * @pre         handle must be created by dpm_context_acquire_wifi_policy()
+ * @see         dpm_context_acquire_wifi_policy()
+ * @see         dpm_context_release_wifi_policy()
+ * @see         dpm_wifi_is_settings_changes_allowed()
  */
-DPM_API int dpm_set_wifi_setting_changes_restriction(dpm_client_h handle, int enable);
+DPM_API int dpm_wifi_allow_settings_change(dpm_wifi_policy_h handle, int enable);
 
 /**
  * @brief       Checks if the user is allowed to modify certain Wi-Fi network settings.
@@ -126,67 +106,19 @@ DPM_API int dpm_set_wifi_setting_changes_restriction(dpm_client_h handle, int en
  *              allowed to modify Wi-Fi settings. The user is restricted in modifying
  *              Wi-Fi settings if at least one administrator has set the value to TRUE.
  * @since_tizen 3.0
- * @param[in]   handle Device Policy Client handle
+ * @param[in]   handle Wi-Fi policy handle
  * @param[out]  enable TRUE if one or more administrators enabled restriction
  *              FALSE if user can change all Wi-Fi network settings
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_TIMEOUT Timeout
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
- * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_set_wifi_setting_changes_restriction()
- */
-DPM_API int dpm_is_wifi_setting_changes_restricted(dpm_client_h handle, int *enable);
-
-/**
- * @brief       Allows or disallows the user to change Wi-Fi hotspot settings
- * @details     An administrator can use this API to restrict changing Wi-Fi
- *              hotspot settings. When restricted, the UI is grayed out so the user cannot
- *              modify the settings.
- * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.security
- * @param[in]   handle Device Policy Client handle
- * @param[in]   enable TRUE to restrict wifi hostspot setting, else FALSE
- * @return      #DPM_ERROR_NONE on success, otherwise a negative value
- * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_TIMEOUT Timeout
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
- * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
- *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_is_wifi_hostspot_restricted()
- */
-DPM_API int dpm_set_wifi_hotspot_restriction(dpm_client_h handle, int enable);
-
-/**
- * @brief       Checks whether the the Wi-Fi hotspot is restricted.
- * @details     An administrator can use this API to check whether the Wi-Fi hotspot
- *              is restricted.
- *              If the Wi-Fi hotspot is restricted, the UI is grayed out so user can not
- *              change its state.
- * @since_tizen 3.0
- * @privlevel   public
- * @param[in]   handle Device Policy Client handle
- * @param[out]  enable TRUE if modification is allowed,
- *              FALSE if modification is denied
- * @return      #DPM_ERROR_NONE on success, otherwise a negative value
- * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_TIMEOUT Timeout
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
+ * @retval      #DPM_ERROR_TIMEOUT Time out
  * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_set_wifi_hotspot_restriction()
+ * @pre         handle must be created by dpm_context_acquire_wifi_policy()
+ * @see         dpm_context_acquire_wifi_policy()
+ * @see         dpm_context_release_wifi_policy()
+ * @see         dpm_wifi_allow_settings_change()
  */
-DPM_API int dpm_is_wifi_hotspot_restricted(dpm_client_h handle, int *enable);
+DPM_API int dpm_wifi_is_settings_changes_allowed(dpm_wifi_policy_h handle, int *enable);
 
 /**
  * @brief       Restricts network accessed based on the Wi-Fi network service set
@@ -194,27 +126,24 @@ DPM_API int dpm_is_wifi_hotspot_restricted(dpm_client_h handle, int *enable);
  * @details     An administrator can use this API to restrict connecting to the Wi-Fi
  *              network based on the blocked network list.
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.wifi
- * @param[in]   handle Device Policy Client handle
+ * @param[in]   handle Wi-Fi policy handle
  * @param[in]   enable TRUE to enable the Wi-Fi network access restriction,
  *              FALSE to disable the Wi-Fi network access restriction
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_TIMEOUT Timeout
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
+ * @retval      #DPM_ERROR_TIMEOUT Time out
  * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
+ * @pre         handle must be created by dpm_context_acquire_wifi_policy()
  * @pre         Blocked network list must be added by dpm_add_wifi_ssid_to_blocklist()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
+ * @see         dpm_context_acquire_wifi_policy()
+ * @see         dpm_context_release_wifi_policy()
  * @see         dpm_is_wifi_network_access_restricted()
- * @see         dpm_add_wifi_ssid_to_blocklist()
- * @see         dpm_remove_wifi_ssid_from_blocklist()
+ * @see         dpm_wifi_add_ssid_to_blocklist()
+ * @see         dpm_wifi_remove_ssid_from_blocklist()
  */
-DPM_API int dpm_set_wifi_network_access_restriction(dpm_client_h handle, int enable);
+DPM_API int dpm_wifi_set_network_access_restriction(dpm_wifi_policy_h handle, int enable);
 
 /**
  * @brief       Checks whether the SSID-based Wi-Fi network access restriction is
@@ -222,20 +151,19 @@ DPM_API int dpm_set_wifi_network_access_restriction(dpm_client_h handle, int ena
  * @details     An administrator can use this API to check whether the SSID-based
  *              Wi-Fi network restriction is enabled.
  * @since_tizen 3.0
- * @param[in]   handle Device Policy Client handle
+ * @param[in]   handle Wi-Fi policy handle
  * @param[out]  enable TRUE if restriction is activated or
  *              FALSE if restriction is deactivated
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_TIMEOUT Timeout
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
+ * @retval      #DPM_ERROR_TIMEOUT Time out
  * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
+ * @pre         handle must be created by dpm_context_acquire_wifi_policy()
+ * @see         dpm_context_acquire_wifi_policy()
+ * @see         dpm_context_release_wifi_policy()
  * @see         dpm_set_wifi_network_access_restriction()
  */
-DPM_API int dpm_is_wifi_network_access_restricted(dpm_client_h handle, int *enable);
+DPM_API int dpm_wifi_is_network_access_restricted(dpm_wifi_policy_h handle, int *enable);
 
 /**
  * @brief       Adds a service set identifier(SSID) to the list of blocked network.
@@ -243,27 +171,24 @@ DPM_API int dpm_is_wifi_network_access_restricted(dpm_client_h handle, int *enab
  *              networks, which prevents the user from connecting to it.
  *              The blocked network still appears in the Access Point list but is disabled.
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.wifi
- * @param[in]   handle Device Policy Client handle
+ * @param[in]   handle Wi-Fi policy handle
  * @param[in]   ssid The SSID to block
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_TIMEOUT Timeout
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
+ * @retval      #DPM_ERROR_TIMEOUT Time out
  * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
  * @retval      #DPM_ERROR_OUT_OF_MEMORY Too many SSIDs in blocked network list
- * @pre         handle must be created by dpm_create_client()
-i* @post        dpm_set_wifi_network_access_restriction() must be called
+ * @pre         handle must be created by dpm_context_acquire_wifi_policy()
+ * @post        dpm_set_wifi_network_access_restriction() must be called
  *              when SSIDs in the blacklist are needed to get restricted
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_remove_wifi_ssid_to_blocklist()
+ * @see         dpm_context_acquire_wifi_policy()
+ * @see         dpm_context_release_wifi_policy()
+ * @see         dpm_wifi_remove_ssid_from_blocklist()
  * @see         dpm_set_wifi_network_access_restriction()
  */
-DPM_API int dpm_add_wifi_ssid_to_blocklist(dpm_client_h handle, const char* ssid);
+DPM_API int dpm_wifi_add_ssid_to_blocklist(dpm_wifi_policy_h handle, const char* ssid);
 
 /**
  * @brief       Removes a service set identifier(SSID) from the list of blocked
@@ -271,24 +196,21 @@ DPM_API int dpm_add_wifi_ssid_to_blocklist(dpm_client_h handle, const char* ssid
  * @details     An administrator can use this API to remove an SSID from the list of
  *              blocked networks, which allows the user to connect to it.
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.wifi
- * @param[in]   handle Device Policy Client handle
+ * @param[in]   handle Wi-Fi policy handle
  * @param[in]   ssid The SSID to be removed from the list of blocked networks
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_TIMEOUT Timeout
- * @retval      #DPM_ERROR_NOT_SUPPORTED Not supported
+ * @retval      #DPM_ERROR_TIMEOUT Time out
  * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_add_wifi_ssid_to_blocklist()
+ * @pre         handle must be created by dpm_context_acquire_wifi_policy()
+ * @see         dpm_context_acquire_wifi_policy()
+ * @see         dpm_context_release_wifi_policy()
+ * @see         dpm_wifi_add_ssid_to_blocklist()
  * @see         dpm_set_wifi_network_access_restriction()
  */
-DPM_API int dpm_remove_wifi_ssid_from_blocklist(dpm_client_h handle, const char* ssid);
+DPM_API int dpm_wifi_remove_ssid_from_blocklist(dpm_wifi_policy_h handle, const char* ssid);
 
 /**
  * @}
@@ -298,4 +220,4 @@ DPM_API int dpm_remove_wifi_ssid_from_blocklist(dpm_client_h handle, const char*
 }
 #endif
 
-#endif //! __CAPI_SECURITY_POLICY_H__
+#endif //! __CAPI_WIFI_POLICY_H__
index 4d2afc7..27d2c99 100644 (file)
 #include "zone.hxx"
 
 #include "array.h"
-#include "capi-assert.h"
+#include "debug.h"
 #include "policy-client.h"
 
 using namespace DevicePolicyManager;
 
-int dpm_create_zone(dpm_client_h handle, const char* name, const char* pkgid)
+dpm_zone_policy_h dpm_context_acquire_zone_policy(dpm_context_h handle)
+{
+    RET_ON_FAILURE(handle, NULL);
+
+    DevicePolicyContext &client = GetDevicePolicyContext(handle);
+    return client.createPolicyInterface<ZonePolicy>();
+}
+
+int dpm_context_release_zone_policy(dpm_context_h context, dpm_zone_policy_h handle)
+{
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+
+    delete &GetPolicyInterface<ZonePolicy>(handle);
+    return 0;
+}
+
+int dpm_zone_create(dpm_zone_policy_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(pkgid, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(pkgname, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Zone zone = client.createPolicyInterface<Zone>();
-    return zone.createZone(name, pkgid);
+    ZonePolicy& zone = GetPolicyInterface<ZonePolicy>(handle);
+    return zone.createZone(name, pkgname);
 }
 
-int dpm_remove_zone(dpm_client_h handle, const char* name)
+int dpm_zone_destroy(dpm_zone_policy_h handle, const char* name)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
     RET_ON_FAILURE(name, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Zone zone = client.createPolicyInterface<Zone>();
+    ZonePolicy& zone = GetPolicyInterface<ZonePolicy>(handle);
     return zone.removeZone(name);
 }
 
 typedef runtime::Array<std::string> dpm_zone_iterator;
 
-dpm_zone_iterator_h dpm_get_zone_iterator(dpm_client_h handle)
+dpm_zone_iterator_h dpm_create_zone_iterator(dpm_zone_policy_h handle)
 {
     RET_ON_FAILURE(handle, NULL);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Zone zone = client.createPolicyInterface<Zone>();
+    ZonePolicy& zone = GetPolicyInterface<ZonePolicy>(handle);
 
     return reinterpret_cast<dpm_zone_iterator_h>(new dpm_zone_iterator(zone.getZoneList()));
 }
 
-const char* dpm_zone_iterator_next(dpm_zone_iterator_h iter)
+int dpm_zone_iterator_next(dpm_zone_iterator_h iter, const char ** result)
 {
-    RET_ON_FAILURE(iter, NULL);
+    RET_ON_FAILURE(iter, DPM_ERROR_INVALID_PARAMETER);
 
-    std::string* result = reinterpret_cast<dpm_zone_iterator*>(iter)->next();
+    *result = reinterpret_cast<dpm_zone_iterator*>(iter)->next()->c_str();
 
-    RET_ON_FAILURE(result, NULL);
+    RET_ON_FAILURE(*result, DPM_ERROR_INVALID_PARAMETER);
 
-    return result->c_str();
+    return 0;
 }
 
-void dpm_free_zone_iterator(dpm_zone_iterator_h iter)
+void dpm_zone_free_iterator(dpm_zone_iterator_h iter)
 {
     RET_ON_FAILURE(iter, void());
 
     delete reinterpret_cast<dpm_zone_iterator*>(iter);
 }
 
-int dpm_get_zone_state(dpm_client_h handle, const char* name)
+int dpm_zone_get_state(dpm_zone_policy_h handle, const char* name, dpm_zone_state_e *state)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
     RET_ON_FAILURE(name, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    Zone zone = client.createPolicyInterface<Zone>();
+    //ZonePolicy& zone = GetPolicyInterface<ZonePolicy>(handle);
 
     /* TODO : should implement */
 
     return DPM_ERROR_INVALID_PARAMETER;
 }
-
-int dpm_subscribe_zone_signal(dpm_client_h handle, const char* signal, dpm_zone_signal_cb callback, void* user_data)
-{
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(signal, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(callback, DPM_ERROR_INVALID_PARAMETER);
-
-    std::string sigName = "Zone::";
-    sigName += signal;
-
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    return client.subscribeSignal(sigName, callback, user_data);
-}
-
-int dpm_unsubscribe_zone_signal(dpm_client_h handle, int callback_id)
-{
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(callback_id >= 0, DPM_ERROR_INVALID_PARAMETER);
-
-    DevicePolicyClient &client = GetDevicePolicyClient(handle);
-    return client.unsubscribeSignal(callback_id);
-}
index 04ef966..bb3f87b 100644 (file)
 #ifndef __CAPI_ZONE_POLICY_H__
 #define __CAPI_ZONE_POLICY_H__
 
-#include <dpm/device-policy-client.h>
+#include <dpm/context.h>
 
 /**
  * @file zone.h
- * @brief This file provides APIs to control app containers
+ * @brief This file provides APIs to control zones
  */
 
 #ifdef __cplusplus
@@ -34,187 +34,226 @@ extern "C" {
  */
 
 /**
- * @brief       API to create a new application container.
- * @details     This API calls zone admin package to start zone provisioning
- *              process according to the enterprise policy. Thus, the zone
- *              admin package should be able to dispatch zone policy which are
- *              required to configure the zone.
- * @remark
+ * @brief       The zone policy handle
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.zone
- * @param[in]   handle The device policy client handle
+ * @see         dpm_context_acquire_zone_policy()
+ * @see         dpm_context_release_zone_policy()
+ */
+typedef void* dpm_zone_policy_h;
+
+/**
+ * @brief       Acquires the zone policy handle
+ * @details     This API acquires zone policy handle required to call
+ *              the zone policy APIs.
+ * @since_tizen 3.0
+ * @param[in]   handle Device policy context handle
+ * @return      Zone policy handle on success, otherwise NULL
+ * @remark      The specific error code can be obtained by using the
+ *              get_last_result() method. Error codes are described in
+ *              exception section.
+ * @exception   #DPM_ERROR_NONE No error
+ * @exception   #DPM_ERROR_CONNECTION_REFUSED Connection refused
+ * @exception   #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception   #DPM_ERROR_TIMED_OUT Time out
+ * @see         dpm_context_release_zone_policy()
+ * @see         get_last_result()
+ */
+DPM_API dpm_zone_policy_h dpm_context_acquire_zone_policy(dpm_context_h handle);
+
+/**
+ * @brief       Releases the zone policy handle
+ * @details     This API must be called if interaction with the device
+ *              policy manager is no longer required.
+ * @since_tizen 3.0
+ * @param[in]   handle The device policy context
+ * @param[in]   handle The zone policy handle
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
+ * @pre         The handle must be created by dpm_context_acquire_zone_policy()
+ * @see         dpm_context_acquire_zone_policy()
+ */
+DPM_API int dpm_context_release_zone_policy(dpm_context_h context, dpm_zone_policy_h handle);
+
+/**
+ * @brief       Creates a new zone.
+ * @details     An administrator can use this API to create a container. Once the container
+ *              is created, the admin package given to the parameter will be installed inside
+ *              the container. Then ownership of the container gets transferred to the admin
+ *              package from the client which triggered the container creation process.
+ * @since_tizen 3.0
+ * @param[in]   handle The zone policy handle
  * @param[in]   name The zone name to be created
- * @param[in]   pkgid The package id to be run for zone creation
+ * @param[in]   pkgname Admin package container ownership will be transferred
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_INVALID Invalid parameter
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
  *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_remove_zone()
- * @see         dpm_zone_list_get_iterator()
+ * @pre         The handle must be created by dpm_context_acquire_zone_policy().
+ * @see         dpm_context_acquire_zone_policy()
+ * @see         dpm_context_release_zone_policy()
+ * @see         dpm_zone_destroy()
+ * @see         dpm_zone_create_iterator()
  */
-DPM_API int dpm_create_zone(dpm_client_h handle, const char* name, const char* pkgid);
+DPM_API int dpm_zone_create(dpm_zone_policy_h handle, const char* name, const char* pkgname);
 
 /**
- * @brief       API to remove existing zone.
- * @details     If specified zone exists, it will be removed.
- *              All of directories of zone will be also erased.
+ * @brief       Removes existing zone.
+ * @details     Administrator can use this API to remove zone. All file system objects
+ *              created for the zone will be also erased.
  * @since_tizen 3.0
- * @privlevel   public
- * @privilege   %http://tizen.org/privilege/dpm.zone
- * @param[in]   handle The device policy client handle
+ * @param[in]   handle The zone policy handle
  * @param[in]   name The zone name to be removed
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
- * @retval      #DPM_ERROR_INVALID Invalid parameter
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
  * @retval      #DPM_ERROR_PERMISSION_DENIED The application does not have
- *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
+ *              the privilege to call this API or the caller is not the owner
+ *              of the zone
+ * @pre         The handle must be created by dpm_context_acquire_zone_policy().
  * @pre         The zone corresponding to the given name must be
  *              created before use of this API.
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_remove_zone()
- * @see         dpm_zone_list_get_iterator()
+ * @see         dpm_context_acquire_zone_policy()
+ * @see         dpm_context_release_zone_policy()
+ * @see         dpm_zone_create()
+ * @see         dpm_zone_create_iterator()
  */
-DPM_API int dpm_remove_zone(dpm_client_h handle, const char* name);
+DPM_API int dpm_zone_destroy(dpm_zone_policy_h handle, const char* name);
 
 /**
- * @brief       Zone list iterator handle
+ * @brief       The zone list iterator handle
+ * @since_tizen 3.0
+ * @see         dpm_zone_create_iterator()
+ * @see         dpm_zone_iterator_next()
+ * @see         dpm_zone_destroy_iterator()
  */
 typedef void* dpm_zone_iterator_h;
 
 /**
- * @brief       API to get an iterator to traverse the list of zone.
- * @details     The list contains all of created zones.
- *              The iterator indicates the begin of the list first.
- *              It can be used for getting a value in list and traversing.
+ * @brief       Creates a zone list iterator.
+ * @details     The zone list iterator can be used to get all defined zones.
  * @since_tizen 3.0
- * @param[in]   handle The device policy client handle
- * @return      A new iterator handle of zone list on success, otherwise
+ * @param[in]   handle The zone policy handle
+ * @return      A zone list iterator on success, otherwise
  *              null value
  * @remark      The specific error code can be obtained by using the
  *              get_last_result() method. Error codes are described in
  *              exception section.
  * @exception   #DPM_ERROR_NONE No error
  * @exception   #DPM_ERROR_OUT_OF_MEMORY Out of memory
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_create_zone()
- * @see         dpm_remove_zone()
+ * @exception   #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception   #DPM_ERROR_TIMED_OUT Time out
+ * @pre         The handle must be created by dpm_context_acquire_zone_policy().
+ * @see         dpm_context_acquire_zone_policy()
+ * @see         dpm_context_release_zone_policy()
+ * @see         dpm_zone_create()
+ * @see         dpm_zone_destroy()
  * @see         dpm_zone_iterator_next()
- * @see         dpm_free_zone_iterator()
+ * @see         dpm_zone_destroy_iterator()
+ * @see         get_last_result()
  */
-DPM_API dpm_zone_iterator_h dpm_get_zone_iterator(dpm_client_h handle);
+DPM_API dpm_zone_iterator_h dpm_zone_create_iterator(dpm_zone_policy_h handle);
 
 /**
- * @brief       API to get a value and move the iterator to next.
- * @details     First, API gets the value indicated by the iterator, and then
- *              API moves the iterator to the next position.
+ * @brief       Fetches a zone name and forwards the iterator.
+ * @details     This API returns zone name indicated by the iterator, and then
+ *              the iterator is moved to the next position. If the iterator reaches
+ *              the end of the list, null value will be returned.
  * @since_tizen 3.0
  * @param[in]   iter The iterator to be controlled
- * @return      The value if the iterater has object, otherwise null value
- * @pre         iter must be created by dpm_zone_list_get_iterator()
- * @post
- * @see         dpm_zone_list_get_iterator()
- * @see         dpm_zone_free_iterator()
+ * @param[out]  zone_name The zone name got from the iterator
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
+ * @pre         The iter must be created by dpm_zone_create_iterator().
+ * @see         dpm_zone_create_iterator()
+ * @see         dpm_zone_destroy_iterator()
  */
-DPM_API const char* dpm_zone_iterator_next(dpm_zone_iterator_h iter);
+DPM_API int dpm_zone_iterator_next(dpm_zone_iterator_h iter, const char ** zone_name);
 
 /**
- * @brief       API to free the iterator.
- * @details     The iterator and what it indicates are freed from memory.
+ * @brief       Frees the iterator.
+ * @details     This API frees the iterator. This API must be called if the iterator
+ *              no longer used.
  * @since_tizen 3.0
- * @param[in]   iter The interator to be removed
- * @pre         iter must be created by dpm_zone_list_get_iterator()
- * @post
- * @see         dpm_get_zone_iterator()
+ * @param[in]   iter The iterator to be removed
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
+ * @pre         The iter must be created by dpm_zone_create_iterator()
+ * @see         dpm_zone_create_iterator()
  * @see         dpm_zone_iterator_next()
  */
-DPM_API void dpm_free_zone_iterator(dpm_zone_iterator_h iter);
-
-/*
- * @brief       Enumeration for zone state
- */
-typedef enum {
-    DPM_ZONE_DEFINED,     /**< Zone has been defined, but it is not running. */
-    DPM_ZONE_RUNNING,     /**< Zone has been started. */
-    DPM_ZONE_LOCKED       /**< Zone has been defined, but it can not start. */
-} zone_state_e;
+DPM_API int dpm_zone_destroy_iterator(dpm_zone_iterator_h iter);
 
 /**
- * @brief       API to get the zone state
- * @details     The zone can have one of the three states(defined, running, locked).
+ * @brief       Called to get all the name of created zones.
  * @since_tizen 3.0
- * @param[in]   handle The device policy client handle
  * @param[in]   name The zone name
- * @return      #DPM_ERROR_INVALID_PARAMETER if the given zone name is not valid,
- *              otherwise a zone state
- * @retval      #DPM_ZONE_DEFINED Zone has been defined.
- * @retval      #DPM_ZONE_RUNNING Zone is running
- * @retval      #DPM_ZONE_LOCKED zone was locked.
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_create_zone()
- * @see         dpm_remove_zone()
- * @see         dpm_subscribe_zone_signal()
- * @see         dpm_unsubscribe_zone_signal()
- */
-DPM_API int dpm_get_zone_state(dpm_client_h handle, const char *name);
-
-/**
- * @brief       Called when a zone signal occurs
+ * @param[in]   user_data The user data passed from dpm_zone_foreach_name
+ * @see         dpm_zone_foreach_name()
  */
-typedef void(*dpm_zone_signal_cb)(const char* name, const char* object, void *user_data);
+typedef void(*dpm_zone_foreach_cb)(const char* name, const char *user_data);
 
 /**
- * @brief       API to attach a listener to get zone signal.
- * @details     Each zone signals are sent when zone state is changed.
- *              To catch the events, listener should be added in advance.
+ * @brief       Retrieves all the name of created zones
+ * @details     This API calls dpm_zone_foreach_cb() once for each zone name
+ *              with traversing the created zones list.
  * @since_tizen 3.0
- * @param[in]   handle the device policy client handlei
- * @param[in]   signal The signal of the container to be monitored
- * @param[in]   callback The listener function to be called
- * @param[in]   user_data The user data passed to the listener function
- * @return      Listener identifier on success, otherwise negative value
+ * @param[in]   handle The zone policy handle
+ * @param[in]   callback The iteration callback function
+ * @param[in]   user_data The user data passed to the callback function
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
  * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
- *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_subscribe_zone_signal()
+ * @pre         The handle must be created by dpm_context_acquire_zone_policy().
+ * @see         dpm_context_acquire_zone_policy()
+ * @see         dpm_context_release_zone_policy()
+ * @see         dpm_zone_create()
+ * @see         dpm_zone_destroy()
+ */
+DPM_API int dpm_zone_foreach_name(dpm_zone_policy_h handle,
+                                  dpm_zone_foreach_cb callback, void* user_data);
+
+/*
+ * @brief       Enumeration for zone state
+ * @since_tizen 3.0
  */
-DPM_API int dpm_subscribe_zone_signal(dpm_client_h handle, const char* signal, dpm_zone_signal_cb callback, void* user_data);
+typedef enum {
+    DPM_ZONE_STATE_DEFINED      = 0x01, /**< ZonePolicy has been defined, but it is not running. */
+    DPM_ZONE_STATE_RUNNING      = 0x02, /**< ZonePolicy has been started. */
+    DPM_ZONE_STATE_LOCKED       = 0x03  /**< ZonePolicy has been defined, but it can not start. */
+} dpm_zone_state_e;
 
 /**
- * @brief       API to detach the listener from zone signal.
- * @details     After removed, listner function will be no longer called even
- *              though zone state is changed.
+ * @brief       Gets the zone state.
+ * @details     This API can be used to get the state of the zone. The zone can
+ *              have one of the three states(defined, running, locked).
  * @since_tizen 3.0
- * @param[in]   handle the device policy client handle
- * @param[in]   callback_id The listener identifier to be removed
+ * @param[in]   handle The zone policy handle
+ * @param[in]   name The zone name
+ * @param[out]  state The zone state
  * @return      #DPM_ERROR_NONE on success, otherwise a negative value
  * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_NO_DATA No such zone to get state
  * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
- *              the privilege to call this API
- * @pre         handle must be created by dpm_create_client()
- * @post
- * @see         dpm_create_client()
- * @see         dpm_destroy_client()
- * @see         dpm_unsubscribe_zone_signal()
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
+ * @pre         The handle must be created by dpm_context_acquire_zone_policy().
+ * @see         dpm_context_acquire_zone_policy()
+ * @see         dpm_context_release_zone_policy()
+ * @see         dpm_zone_create()
+ * @see         dpm_zone_destroy()
+ * @see         dpm_zone_add_signal_cb()
+ * @see         dpm_zone_remove_signal_cb()
  */
-DPM_API int dpm_unsubscribe_zone_signal(dpm_client_h handle, int callback_id);
+DPM_API int dpm_zone_get_state(dpm_zone_policy_h handle, const char *name, dpm_zone_state_e *state);
 
 /**
  * @}
@@ -224,4 +263,4 @@ DPM_API int dpm_unsubscribe_zone_signal(dpm_client_h handle, int callback_id);
 }
 #endif
 
-#endif //! __CAPI_ZONE_POLICY__
+#endif /* __CAPI_ZONE_POLICY__ */
diff --git a/libs/misc.cpp b/libs/misc.cpp
deleted file mode 100644 (file)
index 9c7fa10..0000000
+++ /dev/null
@@ -1,103 +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 "misc.hxx"
-#include "audit/logger.h"
-
-namespace DevicePolicyManager {
-
-Misc::Misc(PolicyControlContext &ctxt) :
-    context(ctxt)
-{
-}
-
-Misc::~Misc()
-{
-}
-
-int Misc::setCameraRestriction(bool enable)
-{
-       try {
-               return context->methodCall<int>("Misc::setCameraRestriction", enable);
-       } catch (runtime::Exception &e) {
-               return -1;
-       }
-}
-
-bool Misc::isCameraRestricted()
-{
-       try {
-               return context->methodCall<bool>("Misc::isCameraRestricted");
-       } catch (runtime::Exception &e) {
-               return -1;
-       }
-}
-
-int Misc::setMicrophoneRestriction(bool enable)
-{
-       try {
-               return context->methodCall<int>("Misc::setMicrophoneRestriction", enable);
-       } catch (runtime::Exception &e) {
-               return -1;
-       }
-}
-
-bool Misc::isMicrophoneRestricted()
-{
-       try {
-               return context->methodCall<bool>("Misc::isMicrophoneRestricted");
-       } catch (runtime::Exception &e) {
-               return -1;
-       }
-}
-
-int Misc::setLocationRestriction(bool enable)
-{
-       try {
-               return context->methodCall<int>("Misc::setLocationRestriction", enable);
-       } catch (runtime::Exception &e) {
-               return -1;
-       }
-}
-
-bool Misc::isLocationRestricted()
-{
-       try {
-               return context->methodCall<bool>("Misc::isLocationRestricted");
-       } catch (runtime::Exception &e) {
-               return -1;
-       }
-}
-
-int Misc::setSdCardRestriction(bool enable)
-{
-       try {
-               return context->methodCall<int>("Misc::setSdCardRestriction", enable);
-       } catch (runtime::Exception &e) {
-               return -1;
-       }
-}
-
-bool Misc::isSdCardRestricted()
-{
-       try {
-               return context->methodCall<bool>("Misc::isSdCardRestricted");
-       } catch (runtime::Exception &e) {
-               return -1;
-       }
-}
-
-} //namespace DevicePolicyManager
index 3b2534f..3243481 100644 (file)
 
 namespace DevicePolicyManager {
 
-Password::Password(PolicyControlContext &ctxt) :
+PasswordPolicy::PasswordPolicy(PolicyControlContext &ctxt) :
     __context(ctxt)
 {
 }
 
-Password::~Password()
+PasswordPolicy::~PasswordPolicy()
 {
 }
 
-int Password::setPasswordQuality(const std::string& username, const int quality)
+int PasswordPolicy::setPasswordPolicyQuality(const int quality)
 {
     try {
-        return __context->methodCall<int>("Password::setPasswordQuality", username, quality);
+        return __context->methodCall<int>("PasswordPolicy::setPasswordPolicyQuality", quality);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Password::getPasswordQuality(const std::string& username)
+int PasswordPolicy::getPasswordPolicyQuality()
 {
     try {
-        return __context->methodCall<int>("Password::getPasswordQuality", username);
+        return __context->methodCall<int>("PasswordPolicy::getPasswordPolicyQuality");
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Password::setPasswordMinimumLength(const std::string& username, const int value)
+int PasswordPolicy::setPasswordPolicyMinimumLength(const int value)
 {
     try {
-        return __context->methodCall<int>("Password::setPasswordMinimumLength", username, value);
+        return __context->methodCall<int>("PasswordPolicy::setPasswordPolicyMinimumLength", value);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Password::getPasswordMinimumLength(const std::string& username)
+int PasswordPolicy::getPasswordPolicyMinimumLength()
 {
     try {
-        return __context->methodCall<int>("Password::getPasswordMinimumLength", username);
+        return __context->methodCall<int>("PasswordPolicy::getPasswordPolicyMinimumLength");
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Password::setMinPasswordComplexChars(const std::string& username, const int value)
+int PasswordPolicy::setMinPasswordPolicyComplexChars(const int value)
 {
     try {
-        return __context->methodCall<int>("Password::setMinPasswordComplexChars", username, value);
+        return __context->methodCall<int>("PasswordPolicy::setMinPasswordPolicyComplexChars", value);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Password::getMinPasswordComplexChars(const std::string& username)
+int PasswordPolicy::getMinPasswordPolicyComplexChars()
 {
     try {
-        return __context->methodCall<int>("Password::getMinPasswordComplexChars", username);
+        return __context->methodCall<int>("PasswordPolicy::getMinPasswordPolicyComplexChars");
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Password::setMaximumFailedPasswordForWipe(const std::string& username, const int value)
+int PasswordPolicy::setMaximumFailedPasswordPolicyForWipe(const int value)
 {
     try {
-        return __context->methodCall<int>("Password::setMaximumFailedPasswordForWipe", username, value);
+        return __context->methodCall<int>("PasswordPolicy::setMaximumFailedPasswordPolicyForWipe", value);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
-int Password::getMaximumFailedPasswordForWipe(const std::string& username)
+int PasswordPolicy::getMaximumFailedPasswordPolicyForWipe()
 {
     try {
-        return __context->methodCall<int>("Password::getMaximumFailedPasswordForWipe", username);
+        return __context->methodCall<int>("PasswordPolicy::getMaximumFailedPasswordPolicyForWipe");
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Password::setPasswordExpires(const std::string& username, const int value)
+int PasswordPolicy::setPasswordPolicyExpires(const int value)
 {
     try {
-        return __context->methodCall<int>("Password::setPasswordExpires", username, value);
+        return __context->methodCall<int>("PasswordPolicy::setPasswordPolicyExpires", value);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Password::getPasswordExpires(const std::string& username)
+int PasswordPolicy::getPasswordPolicyExpires()
 {
     try {
-        return __context->methodCall<int>("Password::getPasswordExpires", username);
+        return __context->methodCall<int>("PasswordPolicy::getPasswordPolicyExpires");
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Password::setPasswordHistory(const std::string& username, const int value)
+int PasswordPolicy::setPasswordPolicyHistory(const int value)
 {
     try {
-        return __context->methodCall<int>("Password::setPasswordHistory", username, value);
+        return __context->methodCall<int>("PasswordPolicy::setPasswordPolicyHistory", value);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Password::getPasswordHistory(const std::string& username)
+int PasswordPolicy::getPasswordPolicyHistory()
 {
     try {
-        return __context->methodCall<int>("Password::getPasswordHistory", username);
+        return __context->methodCall<int>("PasswordPolicy::getPasswordPolicyHistory");
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Password::setPasswordPattern(const std::string& username, const std::string& pattern)
+int PasswordPolicy::setPasswordPolicyPattern(const std::string& pattern)
 {
     try {
-        return __context->methodCall<int>("Password::setPasswordPattern", username, pattern);
+        return __context->methodCall<int>("PasswordPolicy::setPasswordPolicyPattern", pattern);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Password::resetPassword(const std::string& username, const std::string& passwd)
+int PasswordPolicy::resetPasswordPolicy(const std::string& passwd)
 {
     try {
-        return __context->methodCall<int>("Password::resetPassword", username, passwd);
+        return __context->methodCall<int>("PasswordPolicy::resetPasswordPolicy", passwd);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Password::enforcePasswordChange(const std::string& username)
+int PasswordPolicy::enforcePasswordPolicyChange()
 {
     try {
-        return __context->methodCall<int>("Password::enforcePasswordChange", username);
+        return __context->methodCall<int>("PasswordPolicy::enforcePasswordPolicyChange");
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Password::setMaxInactivityTimeDeviceLock(const std::string& username, const int value)
+int PasswordPolicy::setMaxInactivityTimeDeviceLock(const int value)
 {
     try {
-        return __context->methodCall<int>("Password::setMaxInactivityTimeDeviceLock", username, value);
+        return __context->methodCall<int>("PasswordPolicy::setMaxInactivityTimeDeviceLock", value);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Password::getMaxInactivityTimeDeviceLock(const std::string& username)
+int PasswordPolicy::getMaxInactivityTimeDeviceLock()
 {
     try {
-        return __context->methodCall<int>("Password::getMaxInactivityTimeDeviceLock", username);;
+        return __context->methodCall<int>("PasswordPolicy::getMaxInactivityTimeDeviceLock");;
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Password::setPasswordStatus(const std::string& username, const int status)
+int PasswordPolicy::setPasswordPolicyStatus(const int status)
 {
     try {
-        return __context->methodCall<int>("Password::setPasswordStatus", username, status);
+        return __context->methodCall<int>("PasswordPolicy::setPasswordPolicyStatus", status);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Password::deletePasswordPattern(const std::string& username)
+int PasswordPolicy::deletePasswordPolicyPattern()
 {
     try {
-        return __context->methodCall<int>("Password::deletePasswordPattern", username);
+        return __context->methodCall<int>("PasswordPolicy::deletePasswordPolicyPattern");
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-std::string Password::getPasswordPattern(const std::string& username)
+std::string PasswordPolicy::getPasswordPolicyPattern()
 {
     std::string error("Error");
     try {
-        return __context->methodCall<std::string>("Password::getPasswordPattern", username);
+        return __context->methodCall<std::string>("PasswordPolicy::getPasswordPolicyPattern");
     } catch (runtime::Exception& e) {
         return error;
     }
 }
 
-int Password::setMaximumCharacterOccurrences(const std::string& username, const int value)
+int PasswordPolicy::setMaximumCharacterOccurrences(const int value)
 {
     try {
-        return __context->methodCall<int>("Password::setMaximumCharacterOccurrences", username, value);
+        return __context->methodCall<int>("PasswordPolicy::setMaximumCharacterOccurrences", value);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Password::getMaximumCharacterOccurrences(const std::string& username)
+int PasswordPolicy::getMaximumCharacterOccurrences()
 {
     try {
-        return __context->methodCall<int>("Password::getMaximumCharacterOccurrences", username);
+        return __context->methodCall<int>("PasswordPolicy::getMaximumCharacterOccurrences");
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Password::setMaximumNumericSequenceLength(const std::string& username, const int value)
+int PasswordPolicy::setMaximumNumericSequenceLength(const int value)
 {
     try {
-        return __context->methodCall<int>("Password::setMaximumNumericSequenceLength", username, value);
+        return __context->methodCall<int>("PasswordPolicy::setMaximumNumericSequenceLength", value);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Password::getMaximumNumericSequenceLength(const std::string& username)
+int PasswordPolicy::getMaximumNumericSequenceLength()
 {
     try {
-        return __context->methodCall<int>("Password::getMaximumNumericSequenceLength", username);
+        return __context->methodCall<int>("PasswordPolicy::getMaximumNumericSequenceLength");
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Password::setForbiddenStrings(const std::string& username, const std::vector<std::string>& forbiddenStrings)
+int PasswordPolicy::setForbiddenStrings(const std::vector<std::string>& forbiddenStrings)
 {
     try {
-        return __context->methodCall<int>("Password::setForbiddenStrings", username, forbiddenStrings);
+        return __context->methodCall<int>("PasswordPolicy::setForbiddenStrings", forbiddenStrings);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-std::vector<std::string> Password::getForbiddenStrings(const std::string& username)
+std::vector<std::string> PasswordPolicy::getForbiddenStrings()
 {
     try {
-        return __context->methodCall<std::vector<std::string>>("Password::getForbiddenStrings", username);
+        return __context->methodCall<std::vector<std::string>>("PasswordPolicy::getForbiddenStrings");
     } catch (runtime::Exception& e) {
         return std::vector<std::string>();
     }
index aa0243f..43db759 100644 (file)
@@ -26,15 +26,15 @@ const std::string POLICY_MANAGER_ADDRESS = "/tmp/.device-policy-manager";
 } // namespace
 
 
-DevicePolicyClient::DevicePolicyClient() noexcept
+DevicePolicyContext::DevicePolicyContext() noexcept
 {
 }
 
-DevicePolicyClient::~DevicePolicyClient() noexcept
+DevicePolicyContext::~DevicePolicyContext() noexcept
 {
 }
 
-int DevicePolicyClient::connect(const std::string& address) noexcept
+int DevicePolicyContext::connect(const std::string& address) noexcept
 {
     try {
         client.reset(new rmi::Client(address));
@@ -46,17 +46,17 @@ int DevicePolicyClient::connect(const std::string& address) noexcept
     return 0;
 }
 
-int DevicePolicyClient::connect() noexcept
+int DevicePolicyContext::connect() noexcept
 {
     return connect(POLICY_MANAGER_ADDRESS);
 }
 
-void DevicePolicyClient::disconnect() noexcept
+void DevicePolicyContext::disconnect() noexcept
 {
     client.reset();
 }
 
-int DevicePolicyClient::subscribePolicyChange(const std::string& name,
+int DevicePolicyContext::subscribePolicyChange(const std::string& name,
                                               const PolicyChangeListener& listener,
                                               void* data)
 {
@@ -68,12 +68,12 @@ int DevicePolicyClient::subscribePolicyChange(const std::string& name,
                                                        name, listenerDispatcher);
 }
 
-int DevicePolicyClient::unsubscribePolicyChange(int subscriberId)
+int DevicePolicyContext::unsubscribePolicyChange(int subscriberId)
 {
     return client->unsubscribe(SUBSCRIBER_UNREGISTER, subscriberId);
 }
 
-int DevicePolicyClient::subscribeSignal(const std::string& name,
+int DevicePolicyContext::subscribeSignal(const std::string& name,
                                         const SignalListener& listener,
                                         void* data)
 {
@@ -85,7 +85,7 @@ int DevicePolicyClient::subscribeSignal(const std::string& name,
                             (SUBSCRIBER_REGISTER, name, listenerDispatcher);
 }
 
-int DevicePolicyClient::unsubscribeSignal(int subscriberId)
+int DevicePolicyContext::unsubscribeSignal(int subscriberId)
 {
     return client->unsubscribe(SUBSCRIBER_UNREGISTER, subscriberId);
 }
index 8bc2997..04cadbd 100644 (file)
 typedef std::function<void(const char*, const char*, void*)> PolicyChangeListener;
 typedef std::function<void(const char*, const char*, void*)> SignalListener;
 
-class DevicePolicyClient {
+class DevicePolicyContext {
 public:
     typedef std::unique_ptr<rmi::Client> PolicyControlContext;
 
-    DevicePolicyClient() noexcept;
-    ~DevicePolicyClient() noexcept;
+    DevicePolicyContext() noexcept;
+    ~DevicePolicyContext() noexcept;
 
     int connect() noexcept;
     int connect(const std::string& address) noexcept;
@@ -44,9 +44,9 @@ public:
     int unsubscribeSignal(int subscriberId);
 
     template<typename Policy, typename... Args>
-    Policy createPolicyInterface(Args&&... args) noexcept
+    Policy* createPolicyInterface(Args&&... args) noexcept
     {
-        return Policy(getPolicyControlContext(), std::forward<Args>(args)...);
+        return new Policy(getPolicyControlContext(), std::forward<Args>(args)...);
     }
 
 private:
@@ -58,5 +58,11 @@ private:
     PolicyControlContext client;
 };
 
-DevicePolicyClient& GetDevicePolicyClient(void* handle);
+template<typename Policy>
+Policy& GetPolicyInterface(void* handle)
+{
+    return *reinterpret_cast<Policy*>(handle);
+}
+
+DevicePolicyContext& GetDevicePolicyContext(void* handle);
 #endif //__POLICY_CLIENT_H__
index 8022475..63dcdb9 100644 (file)
@@ -19,6 +19,6 @@
 
 #include "policy-client.h"
 
-using PolicyControlContext = ::DevicePolicyClient::PolicyControlContext;
+using PolicyControlContext = ::DevicePolicyContext::PolicyControlContext;
 
 #endif //!__DEVICE_POLICY_CONTEXT__
index c117150..838457d 100644 (file)
 namespace DevicePolicyManager
 {
 
-Restriction::Restriction(PolicyControlContext& ctxt)
+RestrictionPolicy::RestrictionPolicy(PolicyControlContext& ctxt)
        : context(ctxt)
 {
 }
 
-Restriction::~Restriction()
+RestrictionPolicy::~RestrictionPolicy()
 {
 }
 
-int Restriction::setClipboardRestriction(bool enable)
+int RestrictionPolicy::setMicrophoneState(int enable)
 {
        try {
-               return context->methodCall<int>("Restriction::setClipboardRestriction", enable);
-       } catch (runtime::Exceptione) {
+               return context->methodCall<int>("RestrictionPolicy::setMicrophoneState", enable);
+       } catch (runtime::Exception &e) {
                return -1;
        }
 }
 
-bool Restriction::isClipboardRestricted()
+int RestrictionPolicy::getMicrophoneState()
 {
        try {
-               return context->methodCall<bool>("Restriction::isClipboardRestricted");
-       } catch (runtime::Exceptione) {
+               return context->methodCall<int>("RestrictionPolicy::getMicrophoneState");
+       } catch (runtime::Exception &e) {
                return -1;
        }
 }
 
-int Restriction::setClipboardShareRestriction(bool enable)
+int RestrictionPolicy::setCameraState(int enable)
 {
        try {
-               return context->methodCall<int>("Restriction::setClipboardShareRestriction", enable);
-       } catch (runtime::Exceptione) {
+               return context->methodCall<int>("RestrictionPolicy::setCameraState", enable);
+       } catch (runtime::Exception &e) {
                return -1;
        }
 }
 
-bool Restriction::isClipboardShareRestricted()
+int RestrictionPolicy::getCameraState()
 {
        try {
-               return context->methodCall<bool>("Restriction::isClipboardShareRestricted");
-       } catch (runtime::Exceptione) {
+               return context->methodCall<int>("RestrictionPolicy::getCameraState");
+       } catch (runtime::Exception &e) {
                return -1;
        }
 }
 
-
-int Restriction::setSettingsChangesRestriction(bool enable)
+int RestrictionPolicy::setClipboardState(int enable)
 {
        try {
-               return context->methodCall<int>("Restriction::setSettingsChangesRestriction",enable);
+               return context->methodCall<int>("RestrictionPolicy::setClipboardState", enable);
        } catch (runtime::Exception& e) {
                return -1;
        }
 }
 
-bool Restriction::isSettingsChangesRestricted()
+int RestrictionPolicy::getClipboardState()
 {
        try {
-               return context->methodCall<bool>("Restriction::isSettingsChangesRestricted");
+               return context->methodCall<int>("RestrictionPolicy::getClipboardState");
        } catch (runtime::Exception& e) {
                return -1;
        }
 }
 
-int Restriction::setBackgroundDataRestriction(bool enable)
+int RestrictionPolicy::setSettingsChangesState(int enable)
 {
        try {
-               return context->methodCall<int>("Restriction::setBackgroundDataRestriction", enable);
+               return context->methodCall<int>("RestrictionPolicy::setSettingsChangesState", enable);
        } catch (runtime::Exception& e) {
                return -1;
        }
 }
 
-bool Restriction::isBackgroundDataRestricted()
+int RestrictionPolicy::getSettingsChangesState()
 {
        try {
-               return context->methodCall<bool>("Restriction::isBackgroundDataRestricted");
+               return context->methodCall<int>("RestrictionPolicy::getSettingsChangesState");
        } catch (runtime::Exception& e) {
                return -1;
        }
 }
 
-int Restriction::setUsbDebuggingRestriction(bool enable)
+int RestrictionPolicy::setUsbDebuggingState(int enable)
 {
        try {
-               return context->methodCall<int>("Restriction::setUsbDebuggingRestriction", enable);
+               return context->methodCall<int>("RestrictionPolicy::setUsbDebuggingState", enable);
        } catch (runtime::Exception& e) {
                return -1;
        }
 }
 
-bool Restriction::isUsbDebuggingRestricted()
+int RestrictionPolicy::getUsbDebuggingState()
 {
        try {
-               return context->methodCall<bool>("Restriction::isUsbDebuggingRestricted");
+               return context->methodCall<int>("RestrictionPolicy::getUsbDebuggingState");
        } catch (runtime::Exception& e) {
                return -1;
        }
 }
 
-int Restriction::setUsbMassStorageRestriction(bool enable)
+int RestrictionPolicy::setExternalStorageState(int enable)
 {
        try {
-               return context->methodCall<int>("Restriction::setUsbMassStorageRestriction", enable);
+               return context->methodCall<int>("RestrictionPolicy::setExternalStorageState", enable);
        } catch (runtime::Exception& e) {
                return -1;
        }
 }
 
-bool Restriction::isUsbMassStorageRestricted()
+int RestrictionPolicy::getExternalStorageState()
 {
        try {
-               return context->methodCall<bool>("Restriction::isUsbMassStorageRestricted");
+               return context->methodCall<int>("RestrictionPolicy::getExternalStorageState");
        } catch (runtime::Exception& e) {
                return -1;
        }
 }
 
-int Restriction::setFactoryResetRestriction(bool enable)
+int RestrictionPolicy::setLocationState(int enable)
 {
        try {
-               return context->methodCall<int>("Restriction::setFactoryResetRestriction", enable);
+               return context->methodCall<int>("RestrictionPolicy::setLocationState", enable);
        } catch (runtime::Exception& e) {
                return -1;
        }
 }
 
-bool Restriction::isFactoryResetRestricted()
+int RestrictionPolicy::getLocationState()
 {
        try {
-               return context->methodCall<bool>("Restriction::isFactoryResetRestricted");
+               return context->methodCall<int>("RestrictionPolicy::getLocationState");
        } catch (runtime::Exception& e) {
                return -1;
        }
 }
 
+
+int RestrictionPolicy::setWifiState(bool enable)
+{
+    try {
+        return context->methodCall<int>("RestrictionPolicy::setWifiState", enable);
+    } catch (runtime::Exception& e) {
+        return -1;
+    }
+}
+
+bool RestrictionPolicy::getWifiState()
+{
+    try {
+        return context->methodCall<bool>("RestrictionPolicy::getWifiState");
+    } catch (runtime::Exception &e) {
+        return -1;
+    }
+}
+
+int RestrictionPolicy::setWifiHotspotState(bool enable)
+{
+    try {
+        return context->methodCall<int>("RestrictionPolicy::setWifiHotspotState", enable);
+    } catch (runtime::Exception& e) {
+        return -1;
+    }
+}
+
+bool RestrictionPolicy::getWifiHotspotState()
+{
+    try {
+        return context->methodCall<bool>("RestrictionPolicy::getWifiHotspotState");
+    } catch (runtime::Exception &e) {
+        return -1;
+    }
+}
+
 } //namespace DevicePolicyManager
index 3e3e8ce..a5d4889 100644 (file)
 
 namespace DevicePolicyManager {
 
-Security::Security(PolicyControlContext& ctxt) :
+SecurityPolicy::SecurityPolicy(PolicyControlContext& ctxt) :
     context(ctxt)
 {
 }
 
-Security::~Security()
+SecurityPolicy::~SecurityPolicy()
 {
 }
 
-int Security::lockoutDevice()
+int SecurityPolicy::lockoutDevice()
 {
     try {
-        return context->methodCall<int>("Security::lockoutDevice");
+        return context->methodCall<int>("SecurityPolicy::lockoutDevice");
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Security::lockoutScreen()
+int SecurityPolicy::lockoutScreen()
 {
     try {
-        return context->methodCall<int>("Security::lockoutScreen");
+        return context->methodCall<int>("SecurityPolicy::lockoutScreen");
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Security::wipeData(const int id)
+int SecurityPolicy::reboot()
 {
     try {
-        return context->methodCall<int>("Security::wipeData", id);
+        return context->methodCall<int>("SecurityPolicy::reboot");
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Security::reboot()
+int SecurityPolicy::powerOffDevice()
 {
     try {
-        return context->methodCall<int>("Security::reboot");
+        return context->methodCall<int>("SecurityPolicy::powerOffDevice");
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Security::powerOffDevice()
+int SecurityPolicy::setInternalStorageEncryption(const bool encrypt)
 {
     try {
-        return context->methodCall<int>("Security::powerOffDevice");
+        return context->methodCall<int>("SecurityPolicy::setInternalStorageEncryption", encrypt);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Security::setInternalStorageEncryption(const bool encrypt)
+bool SecurityPolicy::isInternalStorageEncrypted()
 {
     try {
-        return context->methodCall<int>("Security::setInternalStorageEncryption", encrypt);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
-}
-
-bool Security::isInternalStorageEncrypted()
-{
-    try {
-        return context->methodCall<bool>("Security::isInternalStorageEncrypted");
+        return context->methodCall<bool>("SecurityPolicy::isInternalStorageEncrypted");
     } catch (runtime::Exception& e) {
         return false;
     }
 }
 
-int Security::setExternalStorageEncryption(const bool encrypt)
+int SecurityPolicy::setExternalStorageEncryption(const bool encrypt)
 {
     try {
-        return context->methodCall<int>("Security::setExternalStorageEncryption", encrypt);
+        return context->methodCall<int>("SecurityPolicy::setExternalStorageEncryption", encrypt);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-bool Security::isExternalStorageEncrypted()
+bool SecurityPolicy::isExternalStorageEncrypted()
 {
     try {
-        return context->methodCall<bool>("Security::isExternalStorageEncrypted");
+        return context->methodCall<bool>("SecurityPolicy::isExternalStorageEncrypted");
     } catch (runtime::Exception& e) {
         return false;
     }
 }
 
-std::vector<std::string> Security::getFileNamesOnDevice(const std::string& path)
+std::vector<std::string> SecurityPolicy::getFileNamesOnDevice(const std::string& path)
 {
     try {
-        return context->methodCall<std::vector<std::string>>("Security::getFileNamesOnDevice", path);
+        return context->methodCall<std::vector<std::string>>("SecurityPolicy::getFileNamesOnDevice", path);
     } catch (runtime::Exception& e) {
         return std::vector<std::string>();
     }
 }
 
-std::vector<std::string> Security::getFileNamesWithAttributes(const std::string& path)
+std::vector<std::string> SecurityPolicy::getFileNamesWithAttributes(const std::string& path)
 {
     try {
-        return context->methodCall<std::vector<std::string>>("Security::getFileNamesWithAttributes", path);
+        return context->methodCall<std::vector<std::string>>("SecurityPolicy::getFileNamesWithAttributes", path);
     } catch (runtime::Exception& e) {
         return std::vector<std::string>();
     }
diff --git a/libs/storage.cpp b/libs/storage.cpp
new file mode 100644 (file)
index 0000000..8e0903b
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ *  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 "policy-client.h"
+
+#include "storage.hxx"
+
+namespace DevicePolicyManager {
+
+StoragePolicy::StoragePolicy(PolicyControlContext& ctx) :
+    context(ctx)
+{
+}
+
+StoragePolicy::~StoragePolicy()
+{
+}
+
+int StoragePolicy::setExternalStorageState(int state)
+{
+       try {
+               return context->methodCall<int>("StoragePolicy::setExternalStorageState", state);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
+}
+
+int StoragePolicy::getExternalStorageState()
+{
+       try {
+               return context->methodCall<int>("StoragePolicy::getExternalStorageState");
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
+}
+
+int StoragePolicy::wipeData(int type)
+{
+       try {
+               return context->methodCall<int>("StoragePolicy::wipeData", type);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
+}
+
+} //namespace DevicePolicyManager
index 17e63f2..cb4e9a1 100644 (file)
 
 namespace DevicePolicyManager {
 
-Wifi::Wifi(PolicyControlContext& ctxt) :
+WifiPolicy::WifiPolicy(PolicyControlContext& ctxt) :
     context(ctxt)
 {
 }
 
-Wifi::~Wifi()
+WifiPolicy::~WifiPolicy()
 {
 }
 
-int Wifi::setStateChangeRestriction(bool enable)
+int WifiPolicy::allowSettingsChange(bool enable)
 {
     try {
-        return context->methodCall<int>("Wifi::setStateChangeRestriction", enable);
+        return context->methodCall<int>("WifiPolicy::allowSettingsChange", enable);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-bool Wifi::isStateChangeRestricted()
+bool WifiPolicy::isSettingsChangeAllowed(void)
 {
     try {
-        return context->methodCall<bool>("Wifi::isStateChangeRestricted");
-    } catch (runtime::Exception& e) {
-        return false;
-    }
-}
-
-int Wifi::setSettingChangesRestriction(bool enable)
-{
-    try {
-        return context->methodCall<int>("Wifi::setSettingChangesRestriction", enable);
-    } catch (runtime::Exception& e) {
+        return context->methodCall<bool>("WifiPolicy::isSettingsChangeAllowed");
+    } catch (runtime::Exception &e) {
         return -1;
     }
 }
 
-bool Wifi::isSettingChangesRestricted()
-{
-    try {
-        return context->methodCall<bool>("Wifi::isSettingChangesRestricted");
-    } catch (runtime::Exception& e) {
-        return false;
-    }
-}
-
-int Wifi::setHotspotRestriction(bool enable)
+int WifiPolicy::setNetworkAccessRestriction(bool enable)
 {
     try {
-        return context->methodCall<int>("Wifi::setHotspotRestriction", enable);
+        return context->methodCall<int>("WifiPolicy::setNetworkAccessRestriction", enable);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-bool Wifi::isHotspotRestricted()
+bool WifiPolicy::isNetworkAccessRestricted(void)
 {
     try {
-        return context->methodCall<bool>("Wifi::isHotspotRestricted");
-    } catch (runtime::Exception& e) {
-        return false;
-    }
-}
-
-int Wifi::setNetworkAccessRestriction(bool enable)
-{
-    try {
-        return context->methodCall<int>("Wifi::setNetworkAccessRestriction", enable);
-    } catch (runtime::Exception& e) {
+        return context->methodCall<bool>("WifiPolicy::isNetworkAccessRestricted");
+    } catch (runtime::Exception &e) {
         return -1;
     }
 }
 
-bool Wifi::isNetworkAccessRestricted()
-{
-    try {
-        return context->methodCall<bool>("Wifi::isNetworkAccessRestricted");
-    } catch (runtime::Exception& e) {
-        return false;
-    }
-}
-
-int Wifi::addSsidFromBlacklist(const std::string& ssid)
+int WifiPolicy::addSsidToBlocklist(const std::string& ssid)
 {
     try {
-        return context->methodCall<int>("Wifi::addSsidFromBlacklist", ssid);
+        return context->methodCall<int>("WifiPolicy::addSsidToBlocklist", ssid);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Wifi::removeSsidFromBlacklist(const std::string& ssid)
+int WifiPolicy::removeSsidFromBlocklist(const std::string& ssid)
 {
     try {
-        return context->methodCall<int>("Wifi::removeSsidFromBlacklist", ssid);
+        return context->methodCall<int>("WifiPolicy::removeSsidFromBlocklist", ssid);
     } catch (runtime::Exception& e) {
         return -1;
     }
index 86b9b27..cf1c14b 100644 (file)
 
 namespace DevicePolicyManager {
 
-Zone::Zone(PolicyControlContext& ctx)
+ZonePolicy::ZonePolicy(PolicyControlContext& ctx)
     : context(ctx)
 {
 }
 
-Zone::~Zone()
+ZonePolicy::~ZonePolicy()
 {
 }
 
-int Zone::createZone(const std::string& name, const std::string& setupWizAppid)
+int ZonePolicy::createZone(const std::string& name, const std::string& setupWizAppid)
 {
     try {
-        return context->methodCall<int>("Zone::createZone", name, setupWizAppid);
+        return context->methodCall<int>("ZonePolicy::createZone", name, setupWizAppid);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Zone::removeZone(const std::string& name)
+int ZonePolicy::removeZone(const std::string& name)
 {
     try {
-        return context->methodCall<int>("Zone::removeZone", name);
+        return context->methodCall<int>("ZonePolicy::removeZone", name);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Zone::lockZone(const std::string& name)
+int ZonePolicy::lockZone(const std::string& name)
 {
     try {
-        return context->methodCall<int>("Zone::lockZone", name);
+        return context->methodCall<int>("ZonePolicy::lockZone", name);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-int Zone::unlockZone(const std::string& name)
+int ZonePolicy::unlockZone(const std::string& name)
 {
     try {
-        return context->methodCall<int>("Zone::unlockZone", name);
+        return context->methodCall<int>("ZonePolicy::unlockZone", name);
     } catch (runtime::Exception& e) {
         return -1;
     }
 }
 
-std::vector<std::string> Zone::getZoneList()
+std::vector<std::string> ZonePolicy::getZoneList()
 {
     std::vector<std::string> empty;
     try {
-        return  context->methodCall<std::vector<std::string>>("Zone::getZoneList");
+        return  context->methodCall<std::vector<std::string>>("ZonePolicy::getZoneList");
     } catch (runtime::Exception& e) {
         return empty;
     }
 }
 
-int Zone::getZoneState(const std::string& name)
+int ZonePolicy::getZoneState(const std::string& name)
 {
     try {
-        return context->methodCall<int>("Zone::getZoneState", name);
+        return context->methodCall<int>("ZonePolicy::getZoneState", name);
     } catch (runtime::Exception& e) {
         return -1;
     }
index f2d1821..eb52a77 100644 (file)
@@ -21,10 +21,16 @@ BuildRequires: pkgconfig(syspopup-caller)
 BuildRequires: pkgconfig(deviced)
 BuildRequires: pkgconfig(vconf)
 BuildRequires: pkgconfig(vconf-internal-keys)
-BuildRequires: pkgconfig(capi-base-common)
+BuildRequires: pkgconfig(bluetooth-api)
 BuildRequires: pkgconfig(libsmack)
 BuildRequires: pkgconfig(libtzplatform-config)
 BuildRequires: pkgconfig(auth-fw-admin)
+BuildRequires: pkgconfig(capi-base-common)
+BuildRequires: pkgconfig(capi-system-info)
+BuildRequires: pkgconfig(capi-network-wifi)
+BuildRequires: pkgconfig(capi-network-connection)
+BuildRequires: pkgconfig(capi-location-manager)
+BuildRequires: pkgconfig(capi-system-system-settings)
 
 %description
 The device-policy-manager package provides a daemon which is responsible for
index b474fe0..e25b74f 100755 (executable)
@@ -2,8 +2,8 @@
 
 usage() {
         echo "Usage :"
-        echo "   Zone-enable        : $0 y" >&2
-        echo "   Zone-disable       : $0 n" >&2
+        echo "   ZonePolicy-enable        : $0 y" >&2
+        echo "   ZonePolicy-disable       : $0 n" >&2
         echo "   Activation state   : $0 info" >&2
         exit 1
 }
index 8bd973c..e6391ee 100644 (file)
@@ -101,14 +101,14 @@ pam_sm_open_session(pam_handle_t* pamh, int flags,
     unshare_flags = CLONE_NEWNS | CLONE_NEWNET | CLONE_NEWUTS | CLONE_NEWIPC;
 
     std::unique_ptr<sem_t, void(*)(sem_t*)> sem(
-        ::sem_open("PAMZone", O_CREAT, 0700, 1),
+        ::sem_open("PAMZonePolicy", O_CREAT, 0700, 1),
     [](sem_t * sem) {
         if (sem == NULL) {
             return;
         }
         ::sem_post(sem);
         ::sem_close(sem);
-        ::sem_unlink("PAMZone");
+        ::sem_unlink("PAMZonePolicy");
     });
 
     if (sem == NULL) {
@@ -173,14 +173,14 @@ pam_sm_close_session(pam_handle_t* pamh, int flags,
     ::umask(077);
 
     std::unique_ptr<sem_t, void(*)(sem_t*)> sem(
-        ::sem_open("PAMZone", O_CREAT, 0700, 1),
+        ::sem_open("PAMZonePolicy", O_CREAT, 0700, 1),
     [](sem_t * sem) {
         if (sem == NULL) {
             return;
         }
         ::sem_post(sem);
         ::sem_close(sem);
-        ::sem_unlink("PAMZone");
+        ::sem_unlink("PAMZonePolicy");
     });
 
     if (sem == NULL) {
index 77cfd1f..69e547f 100644 (file)
 
 namespace DevicePolicyManager {
 
-class Administration {
+class AdministrationPolicy {
 public:
-    Administration(PolicyControlContext& ctxt);
-    ~Administration();
+    AdministrationPolicy(PolicyControlContext& ctxt);
+    ~AdministrationPolicy();
 
     int registerPolicyClient(const std::string& name);
     int deregisterPolicyClient(const std::string& name);
index 297df4f..4977e53 100644 (file)
 
 namespace DevicePolicyManager {
 
-class Application {
+class ApplicationPolicy {
 public:
-    Application(PolicyControlContext& ctxt);
-    ~Application();
+    ApplicationPolicy(PolicyControlContext& ctxt);
+    ~ApplicationPolicy();
 
     int setApplicationInstallationMode(const bool mode);
     bool getApplicationInstallationMode();
index 461a32d..b3c31a7 100644 (file)
@@ -27,13 +27,13 @@ namespace DevicePolicyManager {
  * such as bluetooth device or uuid restriction
  */
 
-class Bluetooth {
+class BluetoothPolicy {
 public:
-    Bluetooth(PolicyControlContext& ctxt);
-    ~Bluetooth();
+    BluetoothPolicy(PolicyControlContext& ctxt);
+    ~BluetoothPolicy();
 
-    int addDeviceToBlacklist(const std::string& mac_address);
-    int removeDeviceFromBlacklist(const std::string& mac_address);
+    int addDeviceToBlacklist(const std::string& mac);
+    int removeDeviceFromBlacklist(const std::string& mac);
     int setDeviceRestriction(const bool enable);
     bool isDeviceRestricted();
 
index 1227885..acb6e22 100644 (file)
@@ -22,7 +22,7 @@
 
 namespace DevicePolicyManager {
 
-class Password {
+class PasswordPolicy {
 public:
     typedef enum {
         DPM_PASSWORD_QUALITY_UNSPECIFIED     = 0x00,    /**< No requirements for password. */
@@ -31,38 +31,38 @@ public:
         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 */
-    } PasswordQuality;
+    } PasswordPolicyQuality;
 
-    Password(PolicyControlContext &ctxt);
-    ~Password();
+    PasswordPolicy(PolicyControlContext &ctxt);
+    ~PasswordPolicy();
 
-    int setPasswordQuality(const std::string& username, const int quality);
-    int getPasswordQuality(const std::string& username);
-    int setPasswordMinimumLength(const std::string& username, const int value);
-    int getPasswordMinimumLength(const std::string& username);
-    int setMinPasswordComplexChars(const std::string& username, const int value);
-    int getMinPasswordComplexChars(const std::string& username);
-    int setMaximumFailedPasswordForWipe(const std::string& username, const int value);
-    int getMaximumFailedPasswordForWipe(const std::string& username);
-    int setPasswordExpires(const std::string& username, const int value);
-    int getPasswordExpires(const std::string& username);
-    int setPasswordHistory(const std::string& username, const int value);
-    int getPasswordHistory(const std::string& username);
-    int setPasswordPattern(const std::string& username, const std::string& pattern);
-    int resetPassword(const std::string& username, const std::string& passwd);
-    int enforcePasswordChange(const std::string& username);
-    int setMaxInactivityTimeDeviceLock(const std::string& username, const int value);
-    int getMaxInactivityTimeDeviceLock(const std::string& username);
-    std::string getPasswordPolicy(const std::string& username);
-    int setPasswordStatus(const std::string& username, const int status);
-    int deletePasswordPattern(const std::string& username);
-    std::string getPasswordPattern(const std::string& username);
-    int setMaximumCharacterOccurrences(const std::string& username, const int value);
-    int getMaximumCharacterOccurrences(const std::string& username);
-    int setMaximumNumericSequenceLength(const std::string& username, const int value);
-    int getMaximumNumericSequenceLength(const std::string& username);
-    int setForbiddenStrings(const std::string& username, const std::vector<std::string>& forbiddenPasswds);
-    std::vector<std::string> getForbiddenStrings(const std::string& username);
+    int setPasswordPolicyQuality(const int quality);
+    int getPasswordPolicyQuality();
+    int setPasswordPolicyMinimumLength(const int value);
+    int getPasswordPolicyMinimumLength();
+    int setMinPasswordPolicyComplexChars(const int value);
+    int getMinPasswordPolicyComplexChars();
+    int setMaximumFailedPasswordPolicyForWipe(const int value);
+    int getMaximumFailedPasswordPolicyForWipe();
+    int setPasswordPolicyExpires(const int value);
+    int getPasswordPolicyExpires();
+    int setPasswordPolicyHistory(const int value);
+    int getPasswordPolicyHistory();
+    int setPasswordPolicyPattern(const std::string& pattern);
+    int resetPasswordPolicy(const std::string& passwd);
+    int enforcePasswordPolicyChange();
+    int setMaxInactivityTimeDeviceLock(const int value);
+    int getMaxInactivityTimeDeviceLock();
+    std::string getPasswordPolicyPolicy();
+    int setPasswordPolicyStatus(const int status);
+    int deletePasswordPolicyPattern();
+    std::string getPasswordPolicyPattern();
+    int setMaximumCharacterOccurrences(const int value);
+    int getMaximumCharacterOccurrences();
+    int setMaximumNumericSequenceLength(const int value);
+    int getMaximumNumericSequenceLength();
+    int setForbiddenStrings(const std::vector<std::string>& forbiddenPasswds);
+    std::vector<std::string> getForbiddenStrings();
 
 private:
     PolicyControlContext& __context;
index 8d63947..48e118c 100644 (file)
 namespace DevicePolicyManager
 {
 
-class Restriction
+class RestrictionPolicy
 {
 public:
-       Restriction(PolicyControlContext& ctxt);
-       ~Restriction();
+       RestrictionPolicy(PolicyControlContext& ctxt);
+       ~RestrictionPolicy();
 
-       int setClipboardRestriction(bool enable);
-       bool isClipboardRestricted();
-       int setClipboardShareRestriction(bool enable);
-       bool isClipboardShareRestricted();
+       int setCameraState(int enable);
+       int getCameraState();
 
-       int setSettingsChangesRestriction(bool enable);
-       bool isSettingsChangesRestricted();
+       int setMicrophoneState(int enable);
+       int getMicrophoneState();
 
-       int setBackgroundDataRestriction(bool enable);
-       bool isBackgroundDataRestricted();
+       int setClipboardState(int enable);
+       int getClipboardState();
 
-       int setUsbDebuggingRestriction(bool enable);
-       bool isUsbDebuggingRestricted();
+       int setSettingsChangesState(int enable);
+       int getSettingsChangesState();
 
-       int setUsbMassStorageRestriction(bool enable);
-       bool isUsbMassStorageRestricted();
+       int setUsbDebuggingState(int enable);
+       int getUsbDebuggingState();
 
-       int setFactoryResetRestriction(bool enable);
-       bool isFactoryResetRestricted();
+       int setExternalStorageState(int enable);
+       int getExternalStorageState();
+
+       int setLocationState(int enable);
+       int getLocationState();
+
+       int setWifiState(bool enable);
+       bool getWifiState();
+
+       int setWifiHotspotState(bool enable);
+       bool getWifiHotspotState();
 
 private:
        PolicyControlContext& context;
index bc49967..39b3418 100644 (file)
@@ -27,10 +27,10 @@ namespace DevicePolicyManager {
  * such as certificate installation, encryption and wipe
  */
 
-class Security {
+class SecurityPolicy {
 public:
-    Security(PolicyControlContext& ctxt);
-    ~Security();
+    SecurityPolicy(PolicyControlContext& ctxt);
+    ~SecurityPolicy();
 
     int lockoutDevice();
     int lockoutScreen();
@@ -44,11 +44,6 @@ public:
     std::vector<std::string> getFileNamesOnDevice(const std::string& path);
     std::vector<std::string> getFileNamesWithAttributes(const std::string& path);
 
-    enum {
-        WIPE_INTERNAL_MEMORY = (1 << 1),
-        WIPE_EXTERNAL_MEMORY = (1 << 0)
-    };
-
 private:
     PolicyControlContext& context;
 };
similarity index 60%
rename from policy/misc.hxx
rename to policy/storage.hxx
index 0569c6a..7e9d903 100644 (file)
  *  limitations under the License
  */
 
-#ifndef __MISC_POLICY__
-#define __MISC_POLICY__
+#ifndef __STORAGE_POLICY__
+#define __STORAGE_POLICY__
 
 #include "data-type.h"
 #include "policy-context.hxx"
 
 namespace DevicePolicyManager {
 
-class Misc {
+class StoragePolicy {
 public:
-       Misc(PolicyControlContext& ctxt);
-       ~Misc();
+    enum {
+        WIPE_INTERNAL_STORAGE = (1 << 1),
+        WIPE_EXTERNAL_STORAGE = (1 << 0)
+    };
 
-       int setCameraRestriction(bool enable);
-       bool isCameraRestricted();
+    StoragePolicy(PolicyControlContext& ctxt);
+    ~StoragePolicy();
 
-       int setMicrophoneRestriction(bool enable);
-       bool isMicrophoneRestricted();
+       int setExternalStorageState(int state);
+    int getExternalStorageState();
 
-       int setLocationRestriction(bool enable);
-       bool isLocationRestricted();
-
-       int setSdCardRestriction(bool enable);
-       bool isSdCardRestricted();
+       int wipeData(int id);
 
 private:
-       PolicyControlContext& context;
+    PolicyControlContext& context;
 };
 
-} // namespace DevicePolicyManager
+} // namespace DeivcePolicyManager
 
-#endif /* __MISC_POLICY__ */
+#endif //!__STORAGE_POLICY__
index e696513..29d481b 100644 (file)
@@ -26,25 +26,25 @@ namespace DevicePolicyManager {
  * This class provides APIs to configure Wi-Fi related settings and manage Wi-Fi profiles.
  */
 
-class Wifi {
+class WifiPolicy {
 public:
-    Wifi(PolicyControlContext& ctxt);
-    ~Wifi();
+    WifiPolicy(PolicyControlContext& ctxt);
+    ~WifiPolicy(void);
 
-    int setStateChangeRestriction(bool restrict);
-    bool isStateChangeRestricted();
+    int allowStateChange(bool restrict);
+    bool isStateChangeAllowed(void);
 
-    int setSettingChangesRestriction(bool restrict);
-    bool isSettingChangesRestricted();
+    int allowSettingsChange(bool restrict);
+    bool isSettingsChangeAllowed(void);
 
-    int setHotspotRestriction(bool restrict);
-    bool isHotspotRestricted();
+    int allowHotspotStateChange(bool restrict);
+    bool isHotspotStateChangeAllowed(void);
 
     int setNetworkAccessRestriction(bool restrict);
-    bool isNetworkAccessRestricted();
+    bool isNetworkAccessRestricted(void);
 
-    int addSsidFromBlacklist(const std::string& ssid);
-    int removeSsidFromBlacklist(const std::string& ssid);
+    int addSsidToBlocklist(const std::string& ssid);
+    int removeSsidFromBlocklist(const std::string& ssid);
 
 private:
     PolicyControlContext& context;
index d47b5d1..43080ca 100644 (file)
@@ -26,17 +26,17 @@ namespace DevicePolicyManager {
  * This class provides APIs to create/remove and manage zones.
  */
 
-class Zone {
+class ZonePolicy {
 public:
-    Zone(PolicyControlContext& ctxt);
-    ~Zone();
+    ZonePolicy(PolicyControlContext& ctxt);
+    ~ZonePolicy();
 
     int createZone(const std::string& name, const std::string& setupWizardAppid);
     int removeZone(const std::string& name);
     int lockZone(const std::string& name);
     int unlockZone(const std::string& name);
 
-    std::vector<std::string> getZoneList();
+    std::vector<std::string> getZoneList(void);
 
     int getZoneState(const std::string& name);
 
index 8b6a118..074a5f8 100644 (file)
@@ -18,26 +18,49 @@ SET(TARGET ${PROJECT_NAME})
 
 SET(SOURCES    main.cpp
                        server.cpp
-                       policy.cpp
-                       policy-storage.cpp
-                       client-manager.cpp
-                       administration.cpp
-                       application.cpp
-                       security.cpp
-                       password.cpp
-                       zone.cpp
                        app-bundle.cpp
                        syspopup.cpp
                        launchpad.cpp
                        packman.cpp
-                       misc.cpp
-                       restriction.cpp
-                       bluetooth.cpp
+                       policy.cpp
+                       policy-storage.cpp
+                       client-manager.cpp
+)
+
+SET(POLICIES administration.cpp
+                        application.cpp
+                        bluetooth.cpp
+                        password.cpp
+                        restriction.cpp
+                        security.cpp
+                        storage.cpp
+                        wifi.cpp
+                        zone.cpp
 )
 
-ADD_EXECUTABLE(${TARGET} ${SOURCES} ${INCLUDE_SRCS})
+ADD_EXECUTABLE(${TARGET} ${SOURCES} ${POLICIES} ${INCLUDE_SRCS})
 
-PKG_CHECK_MODULES(SERVER_DEPS REQUIRED glib-2.0 gio-2.0 bundle aul appsvc pkgmgr pkgmgr-info vconf syspopup-caller deviced libtzplatform-config auth-fw-admin)
+PKG_CHECK_MODULES(SERVER_DEPS
+                                 REQUIRED
+                                 glib-2.0
+                                 gio-2.0
+                                 bundle
+                                 aul
+                                 appsvc
+                                 pkgmgr
+                                 pkgmgr-info
+                                 vconf
+                                 syspopup-caller
+                                 deviced
+                                 libtzplatform-config
+                                 bluetooth-api
+                                 auth-fw-admin
+                                 capi-network-wifi
+                                 capi-system-info
+                                 capi-location-manager
+                                 capi-system-system-settings
+                                 capi-network-connection
+)
 
 INCLUDE_DIRECTORIES(SYSTEM ${SERVER_DEPS_INCLUDE_DIRS} ${DPM_COMMON} ${DPM_POLICY} ${DPM_SERVER})
 
index f4bc3b5..c6e9dfb 100644 (file)
 
 namespace DevicePolicyManager {
 
-Administration::Administration(PolicyControlContext& ctx) :
+AdministrationPolicy::AdministrationPolicy(PolicyControlContext& ctx) :
     context(ctx)
 {
-    context.registerParametricMethod(this, (int)(Administration::registerPolicyClient)(std::string));
-    context.registerParametricMethod(this, (int)(Administration::deregisterPolicyClient)(std::string));
+    context.registerParametricMethod(this, (int)(AdministrationPolicy::registerPolicyClient)(std::string));
+    context.registerParametricMethod(this, (int)(AdministrationPolicy::deregisterPolicyClient)(std::string));
 }
 
-Administration::~Administration()
+AdministrationPolicy::~AdministrationPolicy()
 {
 }
 
-int Administration::registerPolicyClient(const std::string& name)
+int AdministrationPolicy::registerPolicyClient(const std::string& name)
 {
     ClientManager& manager = ClientManager::instance();
 
@@ -46,7 +46,7 @@ int Administration::registerPolicyClient(const std::string& name)
     return 0;
 }
 
-int Administration::deregisterPolicyClient(const std::string& name)
+int AdministrationPolicy::deregisterPolicyClient(const std::string& name)
 {
     ClientManager& manager = ClientManager::instance();
 
@@ -60,6 +60,6 @@ int Administration::deregisterPolicyClient(const std::string& name)
     return 0;
 }
 
-Administration adminPolicy(Server::instance());
+AdministrationPolicy adminPolicy(Server::instance());
 
 } // namespace DevicePolicyManager
index 6dcc035..c4bf828 100644 (file)
 
 namespace DevicePolicyManager {
 
-Application::Application(PolicyControlContext& ctxt) :
+ApplicationPolicy::ApplicationPolicy(PolicyControlContext& ctxt) :
     context(ctxt)
 {
-    context.registerNonparametricMethod(this, (bool)(Application::getApplicationInstallationMode)());
-    context.registerNonparametricMethod(this, (bool)(Application::getApplicationUninstallationMode)());
-    context.registerNonparametricMethod(this, (std::vector<std::string>)(Application::getInstalledPackageList)());
-
-    context.registerParametricMethod(this, (int)(Application::setApplicationInstallationMode)(bool));
-    context.registerParametricMethod(this, (int)(Application::setApplicationUninstallationMode)(bool));
-    context.registerParametricMethod(this, (bool)(Application::isPackageInstalled)(std::string));
-    context.registerParametricMethod(this, (bool)(Application::isApplicationInstalled)(std::string));
-    context.registerParametricMethod(this, (bool)(Application::isApplicationRunning)(std::string));
-    context.registerParametricMethod(this, (int)(Application::installPackage)(std::string));
-    context.registerParametricMethod(this, (int)(Application::uninstallPackage)(std::string));
-    context.registerParametricMethod(this, (int)(Application::disableApplication)(std::string));
-    context.registerParametricMethod(this, (int)(Application::enableApplication)(std::string));
-    context.registerParametricMethod(this, (int)(Application::getApplicationState)(std::string));
-    context.registerParametricMethod(this, (int)(Application::setApplicationState)(std::string, int));
-    context.registerParametricMethod(this, (int)(Application::startApplication)(std::string));
-    context.registerParametricMethod(this, (int)(Application::stopApplication)(std::string));
-    context.registerParametricMethod(this, (int)(Application::wipeApplicationData)(std::string));
-    context.registerParametricMethod(this, (int)(Application::addPackageToBlacklist)(std::string));
-    context.registerParametricMethod(this, (int)(Application::removePackageFromBlacklist)(std::string));
-    context.registerParametricMethod(this, (int)(Application::checkPackageIsBlacklisted)(std::string));
+    context.registerNonparametricMethod(this, (bool)(ApplicationPolicy::getApplicationInstallationMode)());
+    context.registerNonparametricMethod(this, (bool)(ApplicationPolicy::getApplicationUninstallationMode)());
+    context.registerNonparametricMethod(this, (std::vector<std::string>)(ApplicationPolicy::getInstalledPackageList)());
+
+    context.registerParametricMethod(this, (int)(ApplicationPolicy::setApplicationInstallationMode)(bool));
+    context.registerParametricMethod(this, (int)(ApplicationPolicy::setApplicationUninstallationMode)(bool));
+    context.registerParametricMethod(this, (bool)(ApplicationPolicy::isPackageInstalled)(std::string));
+    context.registerParametricMethod(this, (bool)(ApplicationPolicy::isApplicationInstalled)(std::string));
+    context.registerParametricMethod(this, (bool)(ApplicationPolicy::isApplicationRunning)(std::string));
+    context.registerParametricMethod(this, (int)(ApplicationPolicy::installPackage)(std::string));
+    context.registerParametricMethod(this, (int)(ApplicationPolicy::uninstallPackage)(std::string));
+    context.registerParametricMethod(this, (int)(ApplicationPolicy::disableApplication)(std::string));
+    context.registerParametricMethod(this, (int)(ApplicationPolicy::enableApplication)(std::string));
+    context.registerParametricMethod(this, (int)(ApplicationPolicy::getApplicationState)(std::string));
+    context.registerParametricMethod(this, (int)(ApplicationPolicy::setApplicationState)(std::string, int));
+    context.registerParametricMethod(this, (int)(ApplicationPolicy::startApplication)(std::string));
+    context.registerParametricMethod(this, (int)(ApplicationPolicy::stopApplication)(std::string));
+    context.registerParametricMethod(this, (int)(ApplicationPolicy::wipeApplicationData)(std::string));
+    context.registerParametricMethod(this, (int)(ApplicationPolicy::addPackageToBlacklist)(std::string));
+    context.registerParametricMethod(this, (int)(ApplicationPolicy::removePackageFromBlacklist)(std::string));
+    context.registerParametricMethod(this, (int)(ApplicationPolicy::checkPackageIsBlacklisted)(std::string));
 }
 
-Application::~Application()
+ApplicationPolicy::~ApplicationPolicy()
 {
 }
 
-int Application::setApplicationInstallationMode(const bool mode)
+int ApplicationPolicy::setApplicationInstallationMode(const bool mode)
 {
     return 0;
 }
 
-bool Application::getApplicationInstallationMode()
+bool ApplicationPolicy::getApplicationInstallationMode()
 {
     return true;
 }
 
-int Application::setApplicationUninstallationMode(const bool mode)
+int ApplicationPolicy::setApplicationUninstallationMode(const bool mode)
 {
     return 0;
 }
 
-bool Application::getApplicationUninstallationMode()
+bool ApplicationPolicy::getApplicationUninstallationMode()
 {
     return true;
 }
 
-std::vector<std::string> Application::getInstalledPackageList()
+std::vector<std::string> ApplicationPolicy::getInstalledPackageList()
 {
     try {
         PackageManager& packman = PackageManager::instance();
@@ -88,7 +88,7 @@ std::vector<std::string> Application::getInstalledPackageList()
     }
 }
 
-bool Application::isApplicationInstalled(const std::string& appid)
+bool ApplicationPolicy::isApplicationInstalled(const std::string& appid)
 {
     try {
         AppInfo appInfo(appid, context.getPeerUid());
@@ -99,13 +99,13 @@ bool Application::isApplicationInstalled(const std::string& appid)
     }
 }
 
-bool Application::isApplicationRunning(const std::string& appid)
+bool ApplicationPolicy::isApplicationRunning(const std::string& appid)
 {
     Launchpad launchpad(context.getPeerUid());
     return launchpad.instantiated(appid);
 }
 
-bool Application::isPackageInstalled(const std::string& pkgid)
+bool ApplicationPolicy::isPackageInstalled(const std::string& pkgid)
 {
     try {
         PackageInfo pkgInfo(pkgid);
@@ -117,7 +117,7 @@ bool Application::isPackageInstalled(const std::string& pkgid)
 }
 
 
-int Application::installPackage(const std::string& pkgpath)
+int ApplicationPolicy::installPackage(const std::string& pkgpath)
 {
     try {
         PackageManager& packman = PackageManager::instance();
@@ -130,7 +130,7 @@ int Application::installPackage(const std::string& pkgpath)
     return 0;
 }
 
-int Application::uninstallPackage(const std::string& pkgid)
+int ApplicationPolicy::uninstallPackage(const std::string& pkgid)
 {
     try {
         PackageManager& packman = PackageManager::instance();
@@ -143,7 +143,7 @@ int Application::uninstallPackage(const std::string& pkgid)
     return 0;
 }
 
-int Application::disableApplication(const std::string& appid)
+int ApplicationPolicy::disableApplication(const std::string& appid)
 {
     try {
         Launchpad launchpad(context.getPeerUid());
@@ -160,7 +160,7 @@ int Application::disableApplication(const std::string& appid)
     return 0;
 }
 
-int Application::enableApplication(const std::string& appid)
+int ApplicationPolicy::enableApplication(const std::string& appid)
 {
     try {
         PackageManager& packman = PackageManager::instance();
@@ -172,17 +172,17 @@ int Application::enableApplication(const std::string& appid)
     return 0;
 }
 
-int Application::getApplicationState(const std::string& appid)
+int ApplicationPolicy::getApplicationState(const std::string& appid)
 {
     return true;
 }
 
-int Application::setApplicationState(const std::string& appid, const int state)
+int ApplicationPolicy::setApplicationState(const std::string& appid, const int state)
 {
     return true;
 }
 
-int Application::startApplication(const std::string& appid)
+int ApplicationPolicy::startApplication(const std::string& appid)
 {
     Launchpad launchpad(context.getPeerUid());
     if (launchpad.launch(appid) < 0) {
@@ -193,7 +193,7 @@ int Application::startApplication(const std::string& appid)
     return 0;
 }
 
-int Application::stopApplication(const std::string& appid)
+int ApplicationPolicy::stopApplication(const std::string& appid)
 {
     Launchpad launchpad(context.getPeerUid());
     if (launchpad.instantiated(appid)) {
@@ -203,7 +203,7 @@ int Application::stopApplication(const std::string& appid)
     return 0;
 }
 
-int Application::wipeApplicationData(const std::string& appid)
+int ApplicationPolicy::wipeApplicationData(const std::string& appid)
 {
     try {
         PackageManager& packman = PackageManager::instance();
@@ -217,7 +217,7 @@ int Application::wipeApplicationData(const std::string& appid)
 }
 
 
-int Application::addPackageToBlacklist(const std::string& pkgid)
+int ApplicationPolicy::addPackageToBlacklist(const std::string& pkgid)
 {
     try {
         PackageManager& packman = PackageManager::instance();
@@ -230,7 +230,7 @@ int Application::addPackageToBlacklist(const std::string& pkgid)
     return 0;
 }
 
-int Application::removePackageFromBlacklist(const std::string& pkgid)
+int ApplicationPolicy::removePackageFromBlacklist(const std::string& pkgid)
 {
     try {
         PackageManager& packman = PackageManager::instance();
@@ -243,7 +243,7 @@ int Application::removePackageFromBlacklist(const std::string& pkgid)
     return 0;
 }
 
-int Application::checkPackageIsBlacklisted(const std::string& pkgid)
+int ApplicationPolicy::checkPackageIsBlacklisted(const std::string& pkgid)
 {
     try {
         PackageManager& packman = PackageManager::instance();
@@ -254,6 +254,6 @@ int Application::checkPackageIsBlacklisted(const std::string& pkgid)
     }
 }
 
-Application applicationPolicy(Server::instance());
+ApplicationPolicy applicationPolicy(Server::instance());
 
 } // namespace DevicePolicyManager
index 1eea2d2..e24aede 100644 (file)
 
 namespace DevicePolicyManager {
 
-Bluetooth::Bluetooth(PolicyControlContext& ctxt) :
+BluetoothPolicy::BluetoothPolicy(PolicyControlContext& ctxt) :
     context(ctxt)
 {
-    ctxt.registerParametricMethod(this, (int)(Bluetooth::addDeviceToBlacklist)(std::string));
-    ctxt.registerParametricMethod(this, (int)(Bluetooth::removeDeviceFromBlacklist)(std::string));
-    ctxt.registerParametricMethod(this, (int)(Bluetooth::setDeviceRestriction)(bool));
-    ctxt.registerNonparametricMethod(this, (bool)(Bluetooth::isDeviceRestricted));
-    ctxt.registerParametricMethod(this, (int)(Bluetooth::addUuidToBlacklist)(std::string));
-    ctxt.registerParametricMethod(this, (int)(Bluetooth::removeUuidFromBlacklist)(std::string));
-    ctxt.registerParametricMethod(this, (int)(Bluetooth::setUuidRestriction)(bool));
-    ctxt.registerNonparametricMethod(this, (bool)(Bluetooth::isUuidRestricted));
+    ctxt.registerParametricMethod(this, (int)(BluetoothPolicy::addDeviceToBlacklist)(std::string));
+    ctxt.registerParametricMethod(this, (int)(BluetoothPolicy::removeDeviceFromBlacklist)(std::string));
+    ctxt.registerParametricMethod(this, (int)(BluetoothPolicy::setDeviceRestriction)(bool));
+    ctxt.registerNonparametricMethod(this, (bool)(BluetoothPolicy::isDeviceRestricted));
+    ctxt.registerParametricMethod(this, (int)(BluetoothPolicy::addUuidToBlacklist)(std::string));
+    ctxt.registerParametricMethod(this, (int)(BluetoothPolicy::removeUuidFromBlacklist)(std::string));
+    ctxt.registerParametricMethod(this, (int)(BluetoothPolicy::setUuidRestriction)(bool));
+    ctxt.registerNonparametricMethod(this, (bool)(BluetoothPolicy::isUuidRestricted));
 }
 
-Bluetooth::~Bluetooth()
+BluetoothPolicy::~BluetoothPolicy()
 {
 }
 
-int Bluetooth::addDeviceToBlacklist(const std::string& mac_address)
+int BluetoothPolicy::addDeviceToBlacklist(const std::string& mac)
 {
     return 0;
 }
 
-int Bluetooth::removeDeviceFromBlacklist(const std::string& mac_address)
+int BluetoothPolicy::removeDeviceFromBlacklist(const std::string& mac)
 {
     return 0;
 }
 
-int Bluetooth::setDeviceRestriction(const bool enable)
+int BluetoothPolicy::setDeviceRestriction(const bool enable)
 {
     return 0;
 }
 
-bool Bluetooth::isDeviceRestricted()
+bool BluetoothPolicy::isDeviceRestricted()
 {
-    return true;
+    return false;
 }
 
-int Bluetooth::addUuidToBlacklist(const std::string& uuid)
+int BluetoothPolicy::addUuidToBlacklist(const std::string& uuid)
 {
     return 0;
 }
 
-int Bluetooth::removeUuidFromBlacklist(const std::string& uuid)
+int BluetoothPolicy::removeUuidFromBlacklist(const std::string& uuid)
 {
     return 0;
 }
 
-int Bluetooth::setUuidRestriction(const bool enable)
+int BluetoothPolicy::setUuidRestriction(const bool enable)
 {
     return 0;
 }
 
-bool Bluetooth::isUuidRestricted()
+bool BluetoothPolicy::isUuidRestricted()
 {
-    return true;
+    return false;
 }
 
-Bluetooth bluetoothPolicy(Server::instance());
+BluetoothPolicy bluetoothPolicy(Server::instance());
 
 } // namespace DevicePolicyManager
index d1be47a..3e3796c 100755 (executable)
@@ -8,10 +8,10 @@
 
     <namspace>
         <dropped-capability>CAP_SYS_ADMIN</dropped-capability>
-        <hostname>ZoneName</hostname>
+        <hostname>ZonePolicyName</hostname>
         <!--<init>/sbin/init</init>-->
         <filesystem root="/">
-            <!--<entry source="/home/ZoneName" target="/home/.zone/ZoneName" type="bind" option="rw" />-->
+            <!--<entry source="/home/ZonePolicyName" target="/home/.zone/ZonePolicyName" type="bind" option="rw" />-->
         </filesystem>
         <network>
             <!--<interface name="eth0" address="10.254.34.232" netmask="" gateway="" />-->
diff --git a/server/misc.cpp b/server/misc.cpp
deleted file mode 100644 (file)
index 49f6e51..0000000
+++ /dev/null
@@ -1,240 +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 <sys/stat.h>
-#include <sys/mount.h>
-#include <vconf.h>
-#include <vconf-keys.h>
-#include <dd-deviced.h>
-#include <dd-control.h>
-#include <glib.h>
-
-#include "misc.hxx"
-#include "audit/logger.h"
-
-#define SETTING_MEMORY_STATUS_MMC_PATH         "/opt/storage/sdcard"
-#define SETTING_MEMORY_STATUS_MMC_PARENT_PATH  "/opt/storage/sdcard/.."
-
-#define DPM_LOCATION_DISABLED 0
-#define DPM_MMC_MOUNTED 1
-#define DPM_MMC_UMOUNTED 0
-
-namespace DevicePolicyManager {
-
-namespace {
-
-static int checkMMCStatus(void)
-{
-       int ret = 0;
-       struct stat parent_stat, mount_stat;
-
-       ret = ::stat(SETTING_MEMORY_STATUS_MMC_PATH, &mount_stat);
-       if (ret != 0) {
-               ERROR("failed to get stat : /opt/storage/sdcard");
-               return -1;
-       }
-
-       ret = ::stat(SETTING_MEMORY_STATUS_MMC_PARENT_PATH, &parent_stat);
-       if (ret != 0) {
-               ERROR("failed to get stat : /opt/stroage/sdcard/..");
-               return -1;
-       }
-
-       if (mount_stat.st_dev == parent_stat.st_dev)
-               return 0;
-       else
-               return 1;
-}
-
-static void callbackMMCResult(int result, void *p_userdata)
-{
-       return ;
-}
-
-static gboolean callbackMMCUmountTimer(void *data)
-{
-       struct mmc_contents *lp_mmc = NULL;
-       int vconf_status = -1, mmc_status = -1;
-       int ret = 0;
-
-       ret = ::vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &vconf_status);
-       if (ret != 0) {
-               ERROR("failed to get vconf mmc status");
-               return FALSE;
-       }
-
-       if (vconf_status == VCONFKEY_SYSMAN_MMC_REMOVED || vconf_status == VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED) {
-               ERROR("MMC device is ejected or not mounted");
-               return FALSE;
-       }
-
-       mmc_status = checkMMCStatus();
-       if (mmc_status == DPM_MMC_MOUNTED) {
-               lp_mmc = (struct mmc_contents *)g_malloc(sizeof(struct mmc_contents));
-               lp_mmc->mmc_cb = callbackMMCResult;
-               ret = ::deviced_request_unmount_mmc(lp_mmc, MNT_FORCE);
-               if (ret == -1) {
-                       ERROR("failed to request to umount");
-                       return FALSE;
-               }
-               g_free(lp_mmc);
-       } else if (mmc_status == DPM_MMC_UMOUNTED) {
-               WARN("MMC was umounted");
-               return FALSE;
-       } else {
-               ERROR("failed to check status of mmc");
-               return FALSE;
-       }
-
-       return TRUE;
-}
-
-static gboolean callbackMMCMountTimer(void *data)
-{
-       struct mmc_contents *lp_mmc = NULL;
-       int vconf_status = -1, mmc_status = -1;
-       int ret = 0;
-
-       ret = ::vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &vconf_status);
-       if (ret != 0) {
-               ERROR("failed to get vconf mmc status");
-               return FALSE;
-       }
-
-       if (vconf_status != VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED) {
-               ERROR("MMC was mounted");
-               return FALSE;
-       }
-
-       mmc_status = checkMMCStatus();
-       if (mmc_status == DPM_MMC_UMOUNTED) {
-               lp_mmc = (struct mmc_contents *)g_malloc(sizeof(struct mmc_contents));
-               lp_mmc->mmc_cb = callbackMMCResult;
-               ret = ::deviced_request_mount_mmc(lp_mmc);
-               if (ret == -1) {
-                       ERROR("failed to request to mount");
-                       return FALSE;
-               }
-               g_free(lp_mmc);
-       } else if (mmc_status == DPM_MMC_MOUNTED) {
-               WARN("MMC was mounted");
-               return FALSE;
-       } else {
-               ERROR("failed to check status of mmc");
-               return FALSE;
-       }
-
-       return TRUE;
-}
-
-} // namespace
-
-Misc::Misc(PolicyControlContext &ctxt) :
-    context(ctxt)
-{
-       context.registerParametricMethod(this, (int)(Misc::setCameraRestriction)(bool));
-       context.registerNonparametricMethod(this, (bool)(Misc::isCameraRestricted));
-       context.registerParametricMethod(this, (int)(Misc::setMicrophoneRestriction)(bool));
-       context.registerNonparametricMethod(this, (bool)(Misc::isMicrophoneRestricted));
-       context.registerParametricMethod(this, (int)(Misc::setLocationRestriction)(bool));
-       context.registerNonparametricMethod(this, (bool)(Misc::isLocationRestricted));
-       context.registerParametricMethod(this, (int)(Misc::setSdCardRestriction)(bool));
-       context.registerNonparametricMethod(this, (bool)(Misc::isSdCardRestricted));
-}
-
-Misc::~Misc()
-{
-}
-
-int Misc::setCameraRestriction(bool enable)
-{
-       return 0;
-}
-
-bool Misc::isCameraRestricted()
-{
-       bool ret = true;
-       return ret;
-}
-
-int Misc::setMicrophoneRestriction(bool enable)
-{
-       return 0;
-}
-
-bool Misc::isMicrophoneRestricted()
-{
-       bool ret = true;
-       return ret;
-}
-
-int Misc::setLocationRestriction(bool enable)
-{
-       int ret = 0;
-       int status = -1;
-
-       ret = ::vconf_get_int(VCONFKEY_LOCATION_USE_MY_LOCATION, &status);
-       if (ret != 0) {
-               ERROR("failed to get the status of location");
-               return ret;
-       }
-
-       if (status != DPM_LOCATION_DISABLED) {
-               ret = ::vconf_set_int(VCONFKEY_LOCATION_USE_MY_LOCATION, DPM_LOCATION_DISABLED);
-               if (ret != 0)
-                       ERROR("failed to set key(VCONFKEY_LOACTION_USE_MY_LOACATION)");
-
-               ret = ::vconf_set_int(VCONFKEY_LOCATION_ENABLED, DPM_LOCATION_DISABLED);
-               if (ret != 0)
-                       ERROR("failed to set key(VCONFKEY_LOCATION_ENABLED)");
-
-               ret = ::vconf_set_int(VCONFKEY_LOCATION_NETWORK_ENABLED, DPM_LOCATION_DISABLED);
-               if (ret != 0)
-                       ERROR("failed to set key(VCONFKEY_LOCATION_NETWORK_ENABLED)");
-       }
-
-       return ret;
-}
-
-bool Misc::isLocationRestricted()
-{
-       bool ret = true;
-       return ret;
-}
-
-int Misc::setSdCardRestriction(bool enable)
-{
-       int ret = 0;
-
-       if (enable == false)
-               ::g_timeout_add(5000, callbackMMCUmountTimer, NULL);
-       else if (enable == true)
-               ::g_timeout_add(5000, callbackMMCMountTimer, NULL);
-
-       ret = ::deviced_mmc_control(enable);
-       if (ret != 0)
-               ERROR("failed to control MMC device");
-
-       return ret;
-}
-
-bool Misc::isSdCardRestricted()
-{
-       int ret = true;
-       return ret;
-}
-
-} // namespace DevicePolicyManager
index e97738c..b816a72 100644 (file)
@@ -26,7 +26,7 @@
  namespace {
 
 /*
- int ApplicationListCallback(pkgmgrinfo_appinfo_h handle, void *data)
+ int ApplicationPolicyListCallback(pkgmgrinfo_appinfo_h handle, void *data)
  {
      char* appid = nullptr;
      ::pkgmgrinfo_appinfo_get_appid(handle, &appid);
index aebcf97..a747d1e 100644 (file)
@@ -27,7 +27,7 @@ namespace DevicePolicyManager {
 
 namespace {
 
-Password::PasswordQuality qualityType;
+PasswordPolicy::PasswordPolicyQuality qualityType;
 unsigned int minLength;
 unsigned int minComplexCharNumber;
 unsigned int maxAttempts;
@@ -40,23 +40,23 @@ unsigned int maxCharOccurrences;
 unsigned int maxNumSeqLength;
 std::vector<std::string> forbiddenPasswds;
 
-int transformValueFromIntToQualityType(const int quality, Password::PasswordQuality &changed_quality)
+int transformValueFromIntToQualityType(const int quality, PasswordPolicy::PasswordPolicyQuality &changed_quality)
 {
     switch (quality) {
-    case Password::DPM_PASSWORD_QUALITY_UNSPECIFIED:
-        changed_quality = Password::DPM_PASSWORD_QUALITY_UNSPECIFIED;
+    case PasswordPolicy::DPM_PASSWORD_QUALITY_UNSPECIFIED:
+        changed_quality = PasswordPolicy::DPM_PASSWORD_QUALITY_UNSPECIFIED;
         break;
-    case Password::DPM_PASSWORD_QUALITY_SOMETHING:
-        changed_quality = Password::DPM_PASSWORD_QUALITY_SOMETHING;
+    case PasswordPolicy::DPM_PASSWORD_QUALITY_SOMETHING:
+        changed_quality = PasswordPolicy::DPM_PASSWORD_QUALITY_SOMETHING;
         break;
-    case Password::DPM_PASSWORD_QUALITY_NUMERIC:
-        changed_quality = Password::DPM_PASSWORD_QUALITY_NUMERIC;
+    case PasswordPolicy::DPM_PASSWORD_QUALITY_NUMERIC:
+        changed_quality = PasswordPolicy::DPM_PASSWORD_QUALITY_NUMERIC;
         break;
-    case Password::DPM_PASSWORD_QUALITY_ALPHABETIC:
-        changed_quality = Password::DPM_PASSWORD_QUALITY_ALPHABETIC;
+    case PasswordPolicy::DPM_PASSWORD_QUALITY_ALPHABETIC:
+        changed_quality = PasswordPolicy::DPM_PASSWORD_QUALITY_ALPHABETIC;
         break;
-    case Password::DPM_PASSWORD_QUALITY_ALPHANUMERIC:
-        changed_quality = Password::DPM_PASSWORD_QUALITY_ALPHANUMERIC;
+    case PasswordPolicy::DPM_PASSWORD_QUALITY_ALPHANUMERIC:
+        changed_quality = PasswordPolicy::DPM_PASSWORD_QUALITY_ALPHANUMERIC;
         break;
     default:
         std::cerr << "unknown password quality" << std::endl;
@@ -70,19 +70,19 @@ int transformValueFromIntToQualityType(const int quality, Password::PasswordQual
 int transformQualityFromDPMToAuth(const int dpm_quality, password_quality_type &auth_quality)
 {
     switch (dpm_quality) {
-    case Password::DPM_PASSWORD_QUALITY_UNSPECIFIED:
+    case PasswordPolicy::DPM_PASSWORD_QUALITY_UNSPECIFIED:
         auth_quality = AUTH_PWD_QUALITY_UNSPECIFIED;
         break;
-    case Password::DPM_PASSWORD_QUALITY_SOMETHING:
+    case PasswordPolicy::DPM_PASSWORD_QUALITY_SOMETHING:
         auth_quality = AUTH_PWD_QUALITY_SOMETHING;
         break;
-    case Password::DPM_PASSWORD_QUALITY_NUMERIC:
+    case PasswordPolicy::DPM_PASSWORD_QUALITY_NUMERIC:
         auth_quality = AUTH_PWD_QUALITY_NUMERIC;
         break;
-    case Password::DPM_PASSWORD_QUALITY_ALPHABETIC:
+    case PasswordPolicy::DPM_PASSWORD_QUALITY_ALPHABETIC:
         auth_quality = AUTH_PWD_QUALITY_ALPHABETIC;
         break;
-    case Password::DPM_PASSWORD_QUALITY_ALPHANUMERIC:
+    case PasswordPolicy::DPM_PASSWORD_QUALITY_ALPHANUMERIC:
         auth_quality = AUTH_PWD_QUALITY_ALPHANUMERIC;
         break;
     default:
@@ -96,49 +96,46 @@ int transformQualityFromDPMToAuth(const int dpm_quality, password_quality_type &
 
 } // namespace
 
-Password::Password(PolicyControlContext &ctxt) :
+PasswordPolicy::PasswordPolicy(PolicyControlContext &ctxt) :
     __context(ctxt)
 {
-    ctxt.registerParametricMethod(this, (int)(Password::setPasswordQuality)(std::string, int));
-    ctxt.registerParametricMethod(this, (int)(Password::getPasswordQuality)(std::string));
-    ctxt.registerParametricMethod(this, (int)(Password::setPasswordMinimumLength)(std::string, int));
-    ctxt.registerParametricMethod(this, (int)(Password::getPasswordMinimumLength)(std::string));
-    ctxt.registerParametricMethod(this, (int)(Password::setMinPasswordComplexChars)(std::string, int));
-    ctxt.registerParametricMethod(this, (int)(Password::getMinPasswordComplexChars)(std::string));
-    ctxt.registerParametricMethod(this, (int)(Password::setMaximumFailedPasswordForWipe)(std::string, int));
-    ctxt.registerParametricMethod(this, (int)(Password::getMaximumFailedPasswordForWipe)(std::string));
-    ctxt.registerParametricMethod(this, (int)(Password::setPasswordExpires)(std::string, int));
-    ctxt.registerParametricMethod(this, (int)(Password::getPasswordExpires)(std::string));
-    ctxt.registerParametricMethod(this, (int)(Password::setPasswordHistory)(std::string, int));
-    ctxt.registerParametricMethod(this, (int)(Password::getPasswordHistory)(std::string));
-    ctxt.registerParametricMethod(this, (int)(Password::setPasswordPattern)(std::string, std::string));
-    ctxt.registerParametricMethod(this, (int)(Password::resetPassword)(std::string, std::string));
-    ctxt.registerParametricMethod(this, (int)(Password::enforcePasswordChange)(std::string));
-    ctxt.registerParametricMethod(this, (int)(Password::setMaxInactivityTimeDeviceLock)(std::string, int));
-    ctxt.registerParametricMethod(this, (int)(Password::getMaxInactivityTimeDeviceLock)(std::string));
-    ctxt.registerParametricMethod(this, (int)(Password::setPasswordStatus)(std::string, int));
-    ctxt.registerParametricMethod(this, (int)(Password::deletePasswordPattern)(std::string));
-    ctxt.registerParametricMethod(this, (std::string)(Password::getPasswordPattern)(std::string));
-    ctxt.registerParametricMethod(this, (int)(Password::setMaximumCharacterOccurrences)(std::string, int));
-    ctxt.registerParametricMethod(this, (int)(Password::getMaximumCharacterOccurrences)(std::string));
-    ctxt.registerParametricMethod(this, (int)(Password::setMaximumNumericSequenceLength)(std::string, int));
-    ctxt.registerParametricMethod(this, (int)(Password::getMaximumNumericSequenceLength)(std::string));
-    ctxt.registerParametricMethod(this, (int)(Password::setForbiddenStrings)(std::string, std::vector<std::string>));
-    ctxt.registerParametricMethod(this, (std::vector<std::string>)(Password::getForbiddenStrings)(std::string));
+    ctxt.registerParametricMethod(this, (int)(PasswordPolicy::setPasswordPolicyQuality)(int));
+    ctxt.registerNonparametricMethod(this, (int)(PasswordPolicy::getPasswordPolicyQuality));
+    ctxt.registerParametricMethod(this, (int)(PasswordPolicy::setPasswordPolicyMinimumLength)(int));
+    ctxt.registerNonparametricMethod(this, (int)(PasswordPolicy::getPasswordPolicyMinimumLength));
+    ctxt.registerParametricMethod(this, (int)(PasswordPolicy::setMinPasswordPolicyComplexChars)(int));
+    ctxt.registerNonparametricMethod(this, (int)(PasswordPolicy::getMinPasswordPolicyComplexChars));
+    ctxt.registerParametricMethod(this, (int)(PasswordPolicy::setMaximumFailedPasswordPolicyForWipe)(int));
+    ctxt.registerNonparametricMethod(this, (int)(PasswordPolicy::getMaximumFailedPasswordPolicyForWipe));
+    ctxt.registerParametricMethod(this, (int)(PasswordPolicy::setPasswordPolicyExpires)(int));
+    ctxt.registerNonparametricMethod(this, (int)(PasswordPolicy::getPasswordPolicyExpires)());
+    ctxt.registerParametricMethod(this, (int)(PasswordPolicy::setPasswordPolicyHistory)(int));
+    ctxt.registerNonparametricMethod(this, (int)(PasswordPolicy::getPasswordPolicyHistory)());
+    ctxt.registerParametricMethod(this, (int)(PasswordPolicy::setPasswordPolicyPattern)(std::string));
+    ctxt.registerParametricMethod(this, (int)(PasswordPolicy::resetPasswordPolicy)(std::string));
+    ctxt.registerNonparametricMethod(this, (int)(PasswordPolicy::enforcePasswordPolicyChange));
+    ctxt.registerParametricMethod(this, (int)(PasswordPolicy::setMaxInactivityTimeDeviceLock)(int));
+    ctxt.registerNonparametricMethod(this, (int)(PasswordPolicy::getMaxInactivityTimeDeviceLock));
+    ctxt.registerParametricMethod(this, (int)(PasswordPolicy::setPasswordPolicyStatus)(int));
+    ctxt.registerNonparametricMethod(this, (int)(PasswordPolicy::deletePasswordPolicyPattern));
+    ctxt.registerNonparametricMethod(this, (std::string)(PasswordPolicy::getPasswordPolicyPattern));
+    ctxt.registerParametricMethod(this, (int)(PasswordPolicy::setMaximumCharacterOccurrences)(int));
+    ctxt.registerNonparametricMethod(this, (int)(PasswordPolicy::getMaximumCharacterOccurrences));
+    ctxt.registerParametricMethod(this, (int)(PasswordPolicy::setMaximumNumericSequenceLength)(int));
+    ctxt.registerNonparametricMethod(this, (int)(PasswordPolicy::getMaximumNumericSequenceLength));
+    ctxt.registerParametricMethod(this, (int)(PasswordPolicy::setForbiddenStrings)(std::vector<std::string>));
+    ctxt.registerNonparametricMethod(this, (std::vector<std::string>)(PasswordPolicy::getForbiddenStrings));
 }
 
-Password::~Password()
+PasswordPolicy::~PasswordPolicy()
 {
 }
 
-int Password::setPasswordQuality(const std::string& username, const int quality)
+int PasswordPolicy::setPasswordPolicyQuality(const int quality)
 {
     int ret = 0;
-    runtime::User user(username);
-
-    password_quality_type auth_quality_type = AUTH_PWD_QUALITY_UNSPECIFIED;
-
     policy_h *p_policy;
+    password_quality_type auth_quality_type = AUTH_PWD_QUALITY_UNSPECIFIED;
 
     if (transformValueFromIntToQualityType(quality, qualityType) != 0) {
         return -1;
@@ -153,7 +150,7 @@ int Password::setPasswordQuality(const std::string& username, const int quality)
         return -1;
     }
 
-    if (auth_passwd_set_user(p_policy, user.getUid()) != AUTH_PASSWD_API_SUCCESS) {
+    if (auth_passwd_set_user(p_policy, __context.getPeerUid()) != AUTH_PASSWD_API_SUCCESS) {
         auth_passwd_free_policy(p_policy);
         return -1;
     }
@@ -173,23 +170,21 @@ int Password::setPasswordQuality(const std::string& username, const int quality)
     return ret;
 }
 
-int Password::getPasswordQuality(const std::string& username)
+int PasswordPolicy::getPasswordPolicyQuality()
 {
     return qualityType;
 }
 
-int Password::setPasswordMinimumLength(const std::string& username, const int value)
+int PasswordPolicy::setPasswordPolicyMinimumLength(const int value)
 {
     int ret = 0;
-    runtime::User user(username);
-
     policy_h *p_policy;
 
     if (auth_passwd_new_policy(&p_policy) != AUTH_PASSWD_API_SUCCESS) {
         return -1;
     }
 
-    if (auth_passwd_set_user(p_policy, user.getUid()) != AUTH_PASSWD_API_SUCCESS) {
+    if (auth_passwd_set_user(p_policy, __context.getPeerUid()) != AUTH_PASSWD_API_SUCCESS) {
         auth_passwd_free_policy(p_policy);
         return -1;
     }
@@ -211,23 +206,21 @@ int Password::setPasswordMinimumLength(const std::string& username, const int va
     return ret;
 }
 
-int Password::getPasswordMinimumLength(const std::string& username)
+int PasswordPolicy::getPasswordPolicyMinimumLength()
 {
     return minLength;
 }
 
-int Password::setMinPasswordComplexChars(const std::string& username, const int value)
+int PasswordPolicy::setMinPasswordPolicyComplexChars(const int value)
 {
     int ret = 0;
-    runtime::User user(username);
-
     policy_h *p_policy;
 
     if (auth_passwd_new_policy(&p_policy) != AUTH_PASSWD_API_SUCCESS) {
         return -1;
     }
 
-    if (auth_passwd_set_user(p_policy, user.getUid()) != AUTH_PASSWD_API_SUCCESS) {
+    if (auth_passwd_set_user(p_policy, __context.getPeerUid()) != AUTH_PASSWD_API_SUCCESS) {
         auth_passwd_free_policy(p_policy);
         return -1;
     }
@@ -249,23 +242,21 @@ int Password::setMinPasswordComplexChars(const std::string& username, const int
     return ret;
 }
 
-int Password::getMinPasswordComplexChars(const std::string& username)
+int PasswordPolicy::getMinPasswordPolicyComplexChars()
 {
     return minComplexCharNumber;
 }
 
-int Password::setMaximumFailedPasswordForWipe(const std::string& username, const int value)
+int PasswordPolicy::setMaximumFailedPasswordPolicyForWipe(const int value)
 {
     int ret = 0;
-    runtime::User user(username);
-
     policy_h *p_policy;
 
     if (auth_passwd_new_policy(&p_policy) != AUTH_PASSWD_API_SUCCESS) {
         return -1;
     }
 
-    if (auth_passwd_set_user(p_policy, user.getUid()) != AUTH_PASSWD_API_SUCCESS) {
+    if (auth_passwd_set_user(p_policy, __context.getPeerUid()) != AUTH_PASSWD_API_SUCCESS) {
         auth_passwd_free_policy(p_policy);
         return -1;
     }
@@ -287,23 +278,21 @@ int Password::setMaximumFailedPasswordForWipe(const std::string& username, const
     return ret;
 }
 
-int Password::getMaximumFailedPasswordForWipe(const std::string& username)
+int PasswordPolicy::getMaximumFailedPasswordPolicyForWipe()
 {
     return maxAttempts;
 }
 
-int Password::setPasswordExpires(const std::string& username, const int value)
+int PasswordPolicy::setPasswordPolicyExpires(const int value)
 {
     int ret = 0;
-    runtime::User user(username);
-
     policy_h *p_policy;
 
     if (auth_passwd_new_policy(&p_policy) != AUTH_PASSWD_API_SUCCESS) {
         return -1;
     }
 
-    if (auth_passwd_set_user(p_policy, user.getUid()) != AUTH_PASSWD_API_SUCCESS) {
+    if (auth_passwd_set_user(p_policy, __context.getPeerUid()) != AUTH_PASSWD_API_SUCCESS) {
         auth_passwd_free_policy(p_policy);
         return -1;
     }
@@ -325,23 +314,21 @@ int Password::setPasswordExpires(const std::string& username, const int value)
     return ret;
 }
 
-int Password::getPasswordExpires(const std::string& username)
+int PasswordPolicy::getPasswordPolicyExpires()
 {
     return validPeriod;
 }
 
-int Password::setPasswordHistory(const std::string& username, const int value)
+int PasswordPolicy::setPasswordPolicyHistory(const int value)
 {
     int ret = 0;
-    runtime::User user(username);
-
     policy_h *p_policy;
 
     if (auth_passwd_new_policy(&p_policy) != AUTH_PASSWD_API_SUCCESS) {
         return -1;
     }
 
-    if (auth_passwd_set_user(p_policy, user.getUid()) != AUTH_PASSWD_API_SUCCESS) {
+    if (auth_passwd_set_user(p_policy, __context.getPeerUid()) != AUTH_PASSWD_API_SUCCESS) {
         auth_passwd_free_policy(p_policy);
         return -1;
     }
@@ -363,23 +350,21 @@ int Password::setPasswordHistory(const std::string& username, const int value)
     return ret;
 }
 
-int Password::getPasswordHistory(const std::string& username)
+int PasswordPolicy::getPasswordPolicyHistory()
 {
     return historySize;
 }
 
-int Password::setPasswordPattern(const std::string& username, const std::string& pattern)
+int PasswordPolicy::setPasswordPolicyPattern(const std::string& pattern)
 {
     int ret = 0;
-    runtime::User user(username);
-
     policy_h *p_policy;
 
     if (auth_passwd_new_policy(&p_policy) != AUTH_PASSWD_API_SUCCESS) {
         return -1;
     }
 
-    if (auth_passwd_set_user(p_policy, user.getUid()) != AUTH_PASSWD_API_SUCCESS) {
+    if (auth_passwd_set_user(p_policy, __context.getPeerUid()) != AUTH_PASSWD_API_SUCCESS) {
         auth_passwd_free_policy(p_policy);
         return -1;
     }
@@ -401,54 +386,51 @@ int Password::setPasswordPattern(const std::string& username, const std::string&
     return ret;
 }
 
-int Password::resetPassword(const std::string& username, const std::string& passwd)
+int PasswordPolicy::resetPasswordPolicy(const std::string& passwd)
 {
     int ret = 0;
-    runtime::User user(username);
 
-    if (auth_passwd_reset_passwd(AUTH_PWD_NORMAL, user.getUid(), passwd.c_str()) != AUTH_PASSWD_API_SUCCESS) {
+    if (auth_passwd_reset_passwd(AUTH_PWD_NORMAL, __context.getPeerUid(), passwd.c_str()) != AUTH_PASSWD_API_SUCCESS) {
         return -1;
     }
 
     return ret;
 }
 
-int Password::enforcePasswordChange(const std::string& username)
+int PasswordPolicy::enforcePasswordPolicyChange()
 {
     return 0;
 }
 
-int Password::setMaxInactivityTimeDeviceLock(const std::string& username, const int value)
+int PasswordPolicy::setMaxInactivityTimeDeviceLock(const int value)
 {
     maxInactivityTime = value;
 
     return 0;
 }
 
-int Password::getMaxInactivityTimeDeviceLock(const std::string& username)
+int PasswordPolicy::getMaxInactivityTimeDeviceLock()
 {
     return maxInactivityTime;
 }
 
-int Password::setPasswordStatus(const std::string& username, const int status)
+int PasswordPolicy::setPasswordPolicyStatus(const int status)
 {
     passwdStatus = status;
 
     return 0;
 }
 
-int Password::deletePasswordPattern(const std::string& username)
+int PasswordPolicy::deletePasswordPolicyPattern()
 {
     int ret = 0;
-    runtime::User user(username);
-
     policy_h *p_policy;
 
     if (auth_passwd_new_policy(&p_policy) != AUTH_PASSWD_API_SUCCESS) {
         return -1;
     }
 
-    if (auth_passwd_set_user(p_policy, user.getUid()) != AUTH_PASSWD_API_SUCCESS) {
+    if (auth_passwd_set_user(p_policy, __context.getPeerUid()) != AUTH_PASSWD_API_SUCCESS) {
         auth_passwd_free_policy(p_policy);
         return -1;
     }
@@ -470,23 +452,21 @@ int Password::deletePasswordPattern(const std::string& username)
     return ret;
 }
 
-std::string Password::getPasswordPattern(const std::string& username)
+std::string PasswordPolicy::getPasswordPolicyPattern()
 {
     return passwordPattern;
 }
 
-int Password::setMaximumCharacterOccurrences(const std::string& username, const int value)
+int PasswordPolicy::setMaximumCharacterOccurrences(const int value)
 {
     int ret = 0;
-    runtime::User user(username);
-
     policy_h *p_policy;
 
     if (auth_passwd_new_policy(&p_policy) != AUTH_PASSWD_API_SUCCESS) {
         return -1;
     }
 
-    if (auth_passwd_set_user(p_policy, user.getUid()) != AUTH_PASSWD_API_SUCCESS) {
+    if (auth_passwd_set_user(p_policy, __context.getPeerUid()) != AUTH_PASSWD_API_SUCCESS) {
         auth_passwd_free_policy(p_policy);
         return -1;
     }
@@ -508,23 +488,21 @@ int Password::setMaximumCharacterOccurrences(const std::string& username, const
     return ret;
 }
 
-int Password::getMaximumCharacterOccurrences(const std::string& username)
+int PasswordPolicy::getMaximumCharacterOccurrences()
 {
     return maxCharOccurrences;
 }
 
-int Password::setMaximumNumericSequenceLength(const std::string& username, const int value)
+int PasswordPolicy::setMaximumNumericSequenceLength(const int value)
 {
     int ret = 0;
-    runtime::User user(username);
-
     policy_h *p_policy;
 
     if (auth_passwd_new_policy(&p_policy) != AUTH_PASSWD_API_SUCCESS) {
         return -1;
     }
 
-    if (auth_passwd_set_user(p_policy, user.getUid()) != AUTH_PASSWD_API_SUCCESS) {
+    if (auth_passwd_set_user(p_policy, __context.getPeerUid()) != AUTH_PASSWD_API_SUCCESS) {
         auth_passwd_free_policy(p_policy);
         return -1;
     }
@@ -546,23 +524,21 @@ int Password::setMaximumNumericSequenceLength(const std::string& username, const
     return ret;
 }
 
-int Password::getMaximumNumericSequenceLength(const std::string& username)
+int PasswordPolicy::getMaximumNumericSequenceLength()
 {
     return maxNumSeqLength;
 }
 
-int Password::setForbiddenStrings(const std::string& username, const std::vector<std::string>& forbiddenStrings)
+int PasswordPolicy::setForbiddenStrings(const std::vector<std::string>& forbiddenStrings)
 {
     int ret = 0;
-    runtime::User user(username);
-
     policy_h *p_policy;
 
     if (auth_passwd_new_policy(&p_policy) != AUTH_PASSWD_API_SUCCESS) {
         return -1;
     }
 
-    if (auth_passwd_set_user(p_policy, user.getUid()) != AUTH_PASSWD_API_SUCCESS) {
+    if (auth_passwd_set_user(p_policy, __context.getPeerUid()) != AUTH_PASSWD_API_SUCCESS) {
         auth_passwd_free_policy(p_policy);
         return -1;
     }
@@ -586,11 +562,11 @@ int Password::setForbiddenStrings(const std::string& username, const std::vector
     return ret;
 }
 
-std::vector<std::string> Password::getForbiddenStrings(const std::string& username)
+std::vector<std::string> PasswordPolicy::getForbiddenStrings()
 {
     return forbiddenPasswds;
 }
 
-Password passwordPolicy(Server::instance());
+PasswordPolicy passwordPolicy(Server::instance());
 
 } /* namespace DevicePolicyManager*/
index 9dfb426..4a32b2d 100644 (file)
 #include "restriction.hxx"
 #include "audit/logger.h"
 
+#include <vconf.h>
+
 namespace DevicePolicyManager
 {
 
-Restriction::Restriction(PolicyControlContext& ctxt)
+RestrictionPolicy::RestrictionPolicy(PolicyControlContext& ctxt)
        : context(ctxt)
 {
-       context.registerParametricMethod(this, (int)(Restriction::setClipboardRestriction)(bool));
-       context.registerNonparametricMethod(this, (bool)(Restriction::isClipboardRestricted));
-       context.registerParametricMethod(this, (int)(Restriction::setClipboardShareRestriction)(bool));
-       context.registerNonparametricMethod(this, (bool)(Restriction::isClipboardShareRestricted));
-       context.registerParametricMethod(this, (int)(Restriction::setSettingsChangesRestriction)(bool));
-       context.registerNonparametricMethod(this, (bool)(Restriction::isSettingsChangesRestricted));
-       context.registerParametricMethod(this, (int)(Restriction::setBackgroundDataRestriction)(bool));
-       context.registerNonparametricMethod(this, (bool)(Restriction::isBackgroundDataRestricted));
-       context.registerParametricMethod(this, (int)(Restriction::setUsbDebuggingRestriction)(bool));
-       context.registerNonparametricMethod(this, (bool)(Restriction::isUsbDebuggingRestricted));
-       context.registerParametricMethod(this, (int)(Restriction::setUsbMassStorageRestriction)(bool));
-       context.registerNonparametricMethod(this, (bool)(Restriction::isUsbMassStorageRestricted));
-       context.registerParametricMethod(this, (int)(Restriction::setFactoryResetRestriction)(bool));
-       context.registerNonparametricMethod(this, (bool)(Restriction::isFactoryResetRestricted));
+       context.registerParametricMethod(this, (int)(RestrictionPolicy::setCameraState)(int));
+       context.registerNonparametricMethod(this, (int)(RestrictionPolicy::getCameraState));
+       context.registerParametricMethod(this, (int)(RestrictionPolicy::setMicrophoneState)(int));
+       context.registerNonparametricMethod(this, (int)(RestrictionPolicy::getMicrophoneState));
+       context.registerParametricMethod(this, (int)(RestrictionPolicy::setClipboardState)(int));
+       context.registerNonparametricMethod(this, (int)(RestrictionPolicy::getClipboardState));
+       context.registerParametricMethod(this, (int)(RestrictionPolicy::setSettingsChangesState)(int));
+       context.registerNonparametricMethod(this, (int)(RestrictionPolicy::getSettingsChangesState));
+       context.registerParametricMethod(this, (int)(RestrictionPolicy::setUsbDebuggingState)(int));
+       context.registerNonparametricMethod(this, (int)(RestrictionPolicy::getUsbDebuggingState));
+       context.registerParametricMethod(this, (int)(RestrictionPolicy::setExternalStorageState)(int));
+       context.registerNonparametricMethod(this, (int)(RestrictionPolicy::getExternalStorageState));
+       context.registerParametricMethod(this, (int)(RestrictionPolicy::setLocationState)(int));
+       context.registerNonparametricMethod(this, (int)(RestrictionPolicy::getLocationState));
+       context.registerParametricMethod(this, (int)(RestrictionPolicy::setWifiState)(bool));
+       context.registerNonparametricMethod(this, (bool)(RestrictionPolicy::getWifiState));
+       context.registerParametricMethod(this, (int)(RestrictionPolicy::setWifiHotspotState)(bool));
+       context.registerNonparametricMethod(this, (bool)(RestrictionPolicy::getWifiHotspotState));
 }
 
-Restriction::~Restriction()
+RestrictionPolicy::~RestrictionPolicy()
 {
 }
 
-int Restriction::setClipboardRestriction(bool enable)
+int RestrictionPolicy::setCameraState(int state)
 {
        return 0;
 }
 
-bool Restriction::isClipboardRestricted()
+int RestrictionPolicy::getCameraState()
 {
-       return true;
+       return 0;
 }
 
-int Restriction::setClipboardShareRestriction(bool enable)
+int RestrictionPolicy::setMicrophoneState(int state)
 {
        return 0;
 }
 
-bool Restriction::isClipboardShareRestricted()
+int RestrictionPolicy::getMicrophoneState()
 {
-       return true;
+       return 0;
 }
 
-
-int Restriction::setSettingsChangesRestriction(bool enable)
+int RestrictionPolicy::setClipboardState(int enable)
 {
        return 0;
 }
 
-bool Restriction::isSettingsChangesRestricted()
+int RestrictionPolicy::getClipboardState()
 {
        return true;
 }
 
-int Restriction::setBackgroundDataRestriction(bool enable)
+int RestrictionPolicy::setSettingsChangesState(int enable)
 {
        return 0;
 }
 
-bool Restriction::isBackgroundDataRestricted()
+int RestrictionPolicy::getSettingsChangesState()
 {
        return true;
 }
 
-int Restriction::setUsbDebuggingRestriction(bool enable)
+int RestrictionPolicy::setUsbDebuggingState(int enable)
 {
+    INFO("Start Restriction::setUsbDebuggingRestriction");
+
+    // if enable is true, restrication will be working (0).
+    if (enable == true) {
+        if (::vconf_set_int(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 0) != 0) {
+            ERROR("Failed to set usb debugging mode status");
+            return -1;
+        }
+    } else {
+        if (::vconf_set_int(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 1) != 0) {
+            ERROR("Failed to set usb debugging mode status");
+            return -1;
+        }
+    }
+
        return 0;
 }
 
-bool Restriction::isUsbDebuggingRestricted()
+int RestrictionPolicy::getUsbDebuggingState()
 {
-       return true;
+       int status;
+       INFO("Start Restriction::isUsbDebuggingRestricted");
+
+       // 0 is restrication true, 1 is restrication false
+    if (::vconf_get_int(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &status) != 0) {
+        ERROR("Failed to get usb debugging mode status");
+        return -1;
+    }
+
+    // How to return for error??
+    if (status == 1) {
+       return false;
+    }
+    return true;
 }
 
-int Restriction::setUsbMassStorageRestriction(bool enable)
+int RestrictionPolicy::setExternalStorageState(int enable)
 {
        return 0;
 }
 
-bool Restriction::isUsbMassStorageRestricted()
+int RestrictionPolicy::getExternalStorageState()
 {
-       return true;
+       return 0;
 }
 
-int Restriction::setFactoryResetRestriction(bool enable)
+int RestrictionPolicy::setLocationState(int enable)
 {
        return 0;
 }
 
-bool Restriction::isFactoryResetRestricted()
+int RestrictionPolicy::getLocationState()
 {
-       return true;
+       return 0;
+}
+
+int RestrictionPolicy::setWifiState(bool enable)
+{
+       return 0;
 }
 
-Restriction restrictionPolicy(Server::instance());
+bool RestrictionPolicy::getWifiState()
+{
+       return 0;
+}
 
-} // namespace DevicePolicyManager
+int RestrictionPolicy::setWifiHotspotState(bool enable)
+{
+       return 0;
+}
+
+bool RestrictionPolicy::getWifiHotspotState()
+{
+       return 0;
+}
 
+RestrictionPolicy restrictionPolicy(Server::instance());
+
+} // namespace DevicePolicyManager
index 849a435..8b715f4 100644 (file)
@@ -43,41 +43,34 @@ const std::string APPID_DEVICE_ENCRYPTION = "org.tizen.ode";
 const std::string APPID_LOCKSCREEN = "org.tizen.lockscreen";
 
 const std::string PROG_POWEROFF = "/usr/sbin/poweroff";
-const std::string PROG_FACTORY_RESET = "/usr/bin/factory-reset";
-
-void WipeExternalMemoryCallback(int ret, void *user_data)
-{
-    std::cout << "WipeExternalMemoryCallback was called" << std::endl;
-}
 
 } // namespace
 
-Security::Security(PolicyControlContext& ctxt) :
+SecurityPolicy::SecurityPolicy(PolicyControlContext& ctxt) :
     context(ctxt)
 {
-    ctxt.registerNonparametricMethod(this, (int)(Security::lockoutDevice));
-    ctxt.registerNonparametricMethod(this, (int)(Security::lockoutScreen));
-    ctxt.registerNonparametricMethod(this, (int)(Security::reboot));
-    ctxt.registerNonparametricMethod(this, (int)(Security::powerOffDevice));
-    ctxt.registerNonparametricMethod(this, (bool)(Security::isInternalStorageEncrypted));
-    ctxt.registerNonparametricMethod(this, (bool)(Security::isExternalStorageEncrypted));
-    ctxt.registerParametricMethod(this, (int)(Security::wipeData)(int));
-    ctxt.registerParametricMethod(this, (int)(Security::setInternalStorageEncryption)(bool));
-    ctxt.registerParametricMethod(this, (int)(Security::setExternalStorageEncryption)(bool));
-    ctxt.registerParametricMethod(this, (std::vector<std::string>)(Security::getFileNamesOnDevice)(std::string));
-    ctxt.registerParametricMethod(this, (std::vector<std::string>)(Security::getFileNamesWithAttributes)(std::string));
+    ctxt.registerNonparametricMethod(this, (int)(SecurityPolicy::lockoutDevice));
+    ctxt.registerNonparametricMethod(this, (int)(SecurityPolicy::lockoutScreen));
+    ctxt.registerNonparametricMethod(this, (int)(SecurityPolicy::reboot));
+    ctxt.registerNonparametricMethod(this, (int)(SecurityPolicy::powerOffDevice));
+    ctxt.registerNonparametricMethod(this, (bool)(SecurityPolicy::isInternalStorageEncrypted));
+    ctxt.registerNonparametricMethod(this, (bool)(SecurityPolicy::isExternalStorageEncrypted));
+    ctxt.registerParametricMethod(this, (int)(SecurityPolicy::setInternalStorageEncryption)(bool));
+    ctxt.registerParametricMethod(this, (int)(SecurityPolicy::setExternalStorageEncryption)(bool));
+    ctxt.registerParametricMethod(this, (std::vector<std::string>)(SecurityPolicy::getFileNamesOnDevice)(std::string));
+    ctxt.registerParametricMethod(this, (std::vector<std::string>)(SecurityPolicy::getFileNamesWithAttributes)(std::string));
 }
 
-Security::~Security()
+SecurityPolicy::~SecurityPolicy()
 {
 }
 
-int Security::lockoutDevice()
+int SecurityPolicy::lockoutDevice()
 {
     return 0;
 }
 
-int Security::lockoutScreen()
+int SecurityPolicy::lockoutScreen()
 {
     Launchpad launchpad(context.getPeerUid());
 
@@ -89,49 +82,7 @@ int Security::lockoutScreen()
     return 0;
 }
 
-int Security::wipeData(const int id)
-{
-    int ret = 0;
-    if (id & WIPE_INTERNAL_MEMORY) {
-        runtime::Process proc(PROG_FACTORY_RESET);
-        if (proc.execute() != 0) {
-            ERROR("Failed to launch factory-reset");
-            ret = -1;
-        }
-    }
-
-    if (id & WIPE_EXTERNAL_MEMORY) {
-        int status;
-        if (::vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &status) != 0) {
-            ERROR("Failed to get mmc status");
-            return -1;
-        }
-
-        if (status != VCONFKEY_SYSMAN_MMC_MOUNTED) {
-            ERROR("MMC is not working");
-            return -1;
-        }
-
-        mmc_contents *mmc_data = new(std::nothrow) mmc_contents();
-        if (mmc_data == nullptr) {
-            ERROR("Failed to construct mmc_contents: out of memory");
-            return -1;
-        }
-
-        mmc_data->mmc_cb = WipeExternalMemoryCallback;
-        mmc_data->user_data = nullptr;
-
-        if (::deviced_request_format_mmc(mmc_data) < 0) {
-            ERROR("Failed to format MMC");
-            delete mmc_data;
-            return -1;
-        }
-    }
-
-    return ret;
-}
-
-int Security::reboot()
+int SecurityPolicy::reboot()
 {
     if (::reboot(RB_AUTOBOOT) < 0) {
         ERROR("Failed to reboot device");
@@ -141,7 +92,7 @@ int Security::reboot()
     return 0;
 }
 
-int Security::powerOffDevice()
+int SecurityPolicy::powerOffDevice()
 {
     int ret = 0;
 
@@ -158,7 +109,7 @@ int Security::powerOffDevice()
     return ret;
 }
 
-int Security::setInternalStorageEncryption(const bool encrypt)
+int SecurityPolicy::setInternalStorageEncryption(const bool encrypt)
 {
     try {
         Bundle bundle;
@@ -176,13 +127,13 @@ int Security::setInternalStorageEncryption(const bool encrypt)
     return 0;
 }
 
-bool Security::isInternalStorageEncrypted()
+bool SecurityPolicy::isInternalStorageEncrypted()
 {
     INFO("Not implemented yet");
     return false;
 }
 
-int Security::setExternalStorageEncryption(const bool encrypt)
+int SecurityPolicy::setExternalStorageEncryption(const bool encrypt)
 {
     int status;
 
@@ -218,12 +169,12 @@ int Security::setExternalStorageEncryption(const bool encrypt)
     return 0;
 }
 
-bool Security::isExternalStorageEncrypted()
+bool SecurityPolicy::isExternalStorageEncrypted()
 {
     return false;
 }
 
-std::vector<std::string> Security::getFileNamesOnDevice(const std::string& path)
+std::vector<std::string> SecurityPolicy::getFileNamesOnDevice(const std::string& path)
 {
     std::vector<std::string> files;
 
@@ -242,7 +193,7 @@ std::vector<std::string> Security::getFileNamesOnDevice(const std::string& path)
     return files;
 }
 
-std::vector<std::string> Security::getFileNamesWithAttributes(const std::string& path)
+std::vector<std::string> SecurityPolicy::getFileNamesWithAttributes(const std::string& path)
 {
     std::vector<std::string> files;
 
@@ -261,6 +212,6 @@ std::vector<std::string> Security::getFileNamesWithAttributes(const std::string&
     return files;
 }
 
-Security securityPolicy(Server::instance());
+SecurityPolicy securityPolicy(Server::instance());
 
 } // namespace DevicePolicyManager
diff --git a/server/storage.cpp b/server/storage.cpp
new file mode 100644 (file)
index 0000000..135a69c
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ *  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 <vconf.h>
+ #include <vconf-keys.h>
+ #include <dd-deviced.h>
+ #include <dd-control.h>
+
+#include "storage.hxx"
+
+#include "exception.h"
+#include "process.h"
+#include "filesystem.h"
+#include "audit/logger.h"
+
+namespace DevicePolicyManager {
+
+namespace {
+
+const std::string PROG_FACTORY_RESET = "/usr/bin/factory-reset";
+
+void WipeExternalMemoryCallback(int ret, void *user_data)
+{
+    std::cout << "WipeExternalMemoryCallback was called" << std::endl;
+}
+
+} // namespace
+
+StoragePolicy::StoragePolicy(PolicyControlContext& ctx) :
+    context(ctx)
+{
+       context.registerParametricMethod(this, (int)(StoragePolicy::setExternalStorageState)(int));
+       context.registerNonparametricMethod(this, (int)(StoragePolicy::getExternalStorageState));
+       context.registerParametricMethod(this, (int)(StoragePolicy::wipeData)(int));
+}
+
+StoragePolicy::~StoragePolicy()
+{
+}
+
+int StoragePolicy::setExternalStorageState(int enable)
+{
+       INFO("Start StoragePolicy::setUsbMassStorageState");
+       return 0;
+}
+
+int StoragePolicy::getExternalStorageState()
+{
+       INFO("Start StoragePolicy::getUsbMassStorageState");
+       return true;
+}
+
+int StoragePolicy::wipeData(int id)
+{
+    int ret = 0;
+    if (id & WIPE_INTERNAL_STORAGE) {
+        runtime::Process proc(PROG_FACTORY_RESET);
+        if (proc.execute() != 0) {
+            ERROR("Failed to launch factory-reset");
+            ret = -1;
+        }
+    }
+
+    if (id & WIPE_EXTERNAL_STORAGE) {
+        int status;
+        if (::vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &status) != 0) {
+            ERROR("Failed to get mmc status");
+            return -1;
+        }
+
+        if (status != VCONFKEY_SYSMAN_MMC_MOUNTED) {
+            ERROR("MMC is not working");
+            return -1;
+        }
+
+        mmc_contents *mmc_data = new(std::nothrow) mmc_contents();
+        if (mmc_data == nullptr) {
+            ERROR("Failed to construct mmc_contents: out of memory");
+            return -1;
+        }
+
+        mmc_data->mmc_cb = WipeExternalMemoryCallback;
+        mmc_data->user_data = nullptr;
+
+        if (::deviced_request_format_mmc(mmc_data) < 0) {
+            ERROR("Failed to format MMC");
+            delete mmc_data;
+            return -1;
+        }
+    }
+
+    return ret;
+}
+
+StoragePolicy storagePolicy(Server::instance());
+
+} //namespace DevicePolicyManager
index c34d72c..a881c4d 100644 (file)
  */
 #include <arpa/inet.h>
 
-#include <vconf.h>
-#include <vconf-keys.h>
-#include <wifi.h>
-#include <syspopup_caller.h>
-#include <network-pm-config.h>
-#include <network-pm-intf.h>
-#include <network-pm-wlan.h>
-#include <network-cm-intf.h>
-
 #include <cstdlib>
 #include <iostream>
 #include <functional>
 
+#include <vconf.h>
+#include <vconf-keys.h>
+#include <wifi.h>
+
 #include "wifi.hxx"
 #include "app-bundle.h"
+#include "syspopup.h"
 #include "audit/logger.h"
 
 namespace DevicePolicyManager {
 
-typedef wifi_ap_h AccessPointHandle;
-
-namespace {
-
-struct AccessPoint {
-    AccessPoint(AccessPointHandle h, const std::string& name) :
-        handle(h), ssid(name)
-    {
-    }
-
-    AccessPointHandle handle;
-    std::string ssid;
-};
-
-const std::string WIFI_PKG = "wifi-qs";
-
-AccessPointHandle FindAccessPoint(const std::string& ssid)
-{
-    auto AccessPointFoundCallback = [](wifi_ap_h handle, void* user_data) {
-        char *name;
-        int ret = ::wifi_ap_get_essid(handle, &name);
-        if (ret == WIFI_ERROR_NONE) {
-            AccessPoint *ap = static_cast<AccessPoint*>(user_data);
-            if (ap->ssid == name) {
-                ap->handle = handle;
-                ::free(name);
-                // should return false to break iteration
-                return true;
-            }
-            ::free(name);
-        }
-        // should return true to continue iteration
-        return true;
-    };
-
-    AccessPoint ap(nullptr, ssid);
-    int ret = ::wifi_foreach_found_aps(AccessPointFoundCallback, &ap);
-    if (ret != WIFI_ERROR_NONE) {
-        ERROR("Error in wifi_foreach_found_aps");
-        return nullptr;
-    }
-
-    return ap.handle;
-}
-
-std::string WifiErrorMessage(const int error)
-{
-    switch (error) {
-    case WIFI_ERROR_INVALID_PARAMETER:
-        return "WIFI_ERROR_INVALID_PARAMETER";
-    case WIFI_ERROR_OUT_OF_MEMORY:
-        return "WIFI_ERROR_OUT_OF_MEMORY";
-    case WIFI_ERROR_INVALID_OPERATION:
-        return "WIFI_ERROR_INVALID_OPERATION";
-    case WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
-        return "WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED";
-    case WIFI_ERROR_OPERATION_FAILED:
-        return "WIFI_ERROR_OPERATION_FAILED";
-    case WIFI_ERROR_NO_CONNECTION:
-        return "WIFI_ERROR_NO_CONNECTION";
-    case WIFI_ERROR_NOW_IN_PROGRESS:
-        return "WIFI_ERROR_NOW_IN_PROGRESS";
-    case WIFI_ERROR_ALREADY_EXISTS:
-        return "WIFI_ERROR_ALREADY_EXISTS";
-    case WIFI_ERROR_OPERATION_ABORTED:
-        return "WIFI_ERROR_OPERATION_ABORTED";
-    case WIFI_ERROR_DHCP_FAILED:
-        return "WIFI_ERROR_DHCP_FAILED";
-    case WIFI_ERROR_INVALID_KEY:
-        return "WIFI_ERROR_INVALID_KEY";
-    case WIFI_ERROR_NO_REPLY:
-        return "WIFI_ERROR_NO_REPLY";
-    case WIFI_ERROR_SECURITY_RESTRICTED:
-        return "WIFI_ERROR_SECURITY_RESTRICTED";
-    default:
-        break;
-    }
-
-    return "Unknown WIFI Error";
-}
-
-} //namespace
-
-Wifi::Wifi(PolicyControlContext& ctx) :
+WifiPolicy::WifiPolicy(PolicyControlContext& ctx) :
     context(ctx)
 {
-    rmi::Service& manager = context.getServiceManager();
-
-    manager.registerParametricMethod(this, (int)(Wifi::setsetStateChangeRestriction)(bool));
-    manager.registerParametricMethod(this, (int)(Wifi::setSettingChangesRestriction)(bool));
-    manager.registerParametricMethod(this, (int)(Wifi::setApSettingModificationRestriction)(bool));
-    manager.registerParametricMethod(this, (int)(Wifi::activateWifiSsidRestriction)(bool));
-    manager.registerParametricMethod(this, (int)(Wifi::addSsidFromBlacklist)(std::string));
-    manager.registerParametricMethod(this, (int)(Wifi::removeSsidFromBlacklist)(std::string));
-
-    manager.registerNonparametricMethod(this, (bool)(Wifi::isWifiStateChanageAllowed)());
-    manager.registerNonparametricMethod(this, (bool)(Wifi::isSettingChangesRestricted)());
-    manager.registerNonparametricMethod(this, (bool)(Wifi::isApSettingModificationRestricted)());
-    manager.registerNonparametricMethod(this, (bool)(Wifi::isNetworkAccessRestricted)());
-}
-
-Wifi::~Wifi()
-{
-}
-
-int Wifi::setStateChangeRestriction(bool allow)
-{
-    int status;
-
-    if (::vconf_get_int(VCONFKEY_NETWORK_WIFI_STATE, &status) != 0) {
-        ERROR("Failed to read VCONFKEY_NETWORK_WIFI_STATE");
-        return -1;
-    }
-
-    if (status != VCONFKEY_NETWORK_WIFI_OFF) {
-        try {
-            Bundle bundle;
-            bundle.add("-t", "off");
-
-            Syspopup syspopup(WIFI_PKG);
-            if (syspopup.launch(bundle) < 0) {
-                ERROR("Failed to lunch wifi syspopup");
-                return -1;
-            }
-        } catch (runtime::Exception& e) {
-            ERROR("Failed to lunch wifi syspopup");
-            return -1;
-        }
-    }
-
-    return 0;
-}
-
-bool Wifi::isWifiStateChanegAllowed()
-{
-    return false;
-}
+    context.registerParametricMethod(this, (int)(WifiPolicy::allowSettingsChange)(bool));
+    context.registerNonparametricMethod(this, (bool)(WifiPolicy::isSettingsChangeAllowed));
 
-int Wifi::setSettingChangesRestriction(bool restrict)
-{
-        return -1;
+    context.registerParametricMethod(this, (int)(WifiPolicy::setNetworkAccessRestriction)(bool));
+    context.registerNonparametricMethod(this, (bool)(WifiPolicy::isNetworkAccessRestricted));
+    context.registerParametricMethod(this, (int)(WifiPolicy::addSsidToBlocklist)(std::string));
+    context.registerParametricMethod(this, (int)(WifiPolicy::removeSsidFromBlocklist)(std::string));
 }
 
-bool Wifi::isSettingChangesRestricted()
+WifiPolicy::~WifiPolicy()
 {
-    return false;
 }
 
-int Wifi::setApSettingModificationRestriction(bool restrict)
+int WifiPolicy::allowSettingsChange(bool enable)
 {
     return -1;
 }
 
-bool Wifi::isApSettingModificationRestricted()
+bool WifiPolicy::isSettingsChangeAllowed(void)
 {
-    return false;
+    return true;
 }
 
-int Wifi::setNetworkAccessRestriction(bool restrict)
+int WifiPolicy::setNetworkAccessRestriction(bool enable)
 {
     return -1;
 }
 
-bool Wifi::isNetworkAccessRestricted()
+bool WifiPolicy::isNetworkAccessRestricted(void)
 {
-    return false;
+    return true;
 }
 
-int Wifi::addSsidFromBlacklist(const std::string& ssid)
+int WifiPolicy::addSsidToBlocklist(const std::string& ssid)
 {
     return -1;
 }
 
-int Wifi::removeSsidFromBlacklist(const std::string& ssid)
+int WifiPolicy::removeSsidFromBlocklist(const std::string& ssid)
 {
     return -1;
 }
 
-Wifi wifiPolicy(Server::instance());
+
+WifiPolicy wifiPolicy(Server::instance());
 
 } // namespace DevicePolicyManager
index a0e316f..d5b1574 100644 (file)
@@ -103,25 +103,25 @@ void execute(const std::string& path, Args&&... args)
 
 
 
-Zone::Zone(PolicyControlContext& ctx)
+ZonePolicy::ZonePolicy(PolicyControlContext& ctx)
     : context(ctx)
 {
-    context.registerParametricMethod(this, (int)(Zone::createZone)(std::string, std::string));
-    context.registerParametricMethod(this, (int)(Zone::removeZone)(std::string));
-    context.registerParametricMethod(this, (int)(Zone::lockZone)(std::string));
-    context.registerParametricMethod(this, (int)(Zone::unlockZone)(std::string));
-    context.registerNonparametricMethod(this, (std::vector<std::string>)(Zone::getZoneList)());
-    context.registerParametricMethod(this, (int)(Zone::getZoneState)(std::string));
-
-    context.createNotification("Zone::created");
-    context.createNotification("Zone::removed");
+    context.registerParametricMethod(this, (int)(ZonePolicy::createZone)(std::string, std::string));
+    context.registerParametricMethod(this, (int)(ZonePolicy::removeZone)(std::string));
+    context.registerParametricMethod(this, (int)(ZonePolicy::lockZone)(std::string));
+    context.registerParametricMethod(this, (int)(ZonePolicy::unlockZone)(std::string));
+    context.registerNonparametricMethod(this, (std::vector<std::string>)(ZonePolicy::getZoneList)());
+    context.registerParametricMethod(this, (int)(ZonePolicy::getZoneState)(std::string));
+
+    context.createNotification("ZonePolicy::created");
+    context.createNotification("ZonePolicy::removed");
 }
 
-Zone::~Zone()
+ZonePolicy::~ZonePolicy()
 {
 }
 
-int Zone::createZone(const std::string& name, const std::string& setupWizAppid)
+int ZonePolicy::createZone(const std::string& name, const std::string& setupWizAppid)
 {
     std::string provisionDirPath(ZONE_PROVISION_DIR + name);
     runtime::File provisionDir(provisionDirPath);
@@ -303,7 +303,7 @@ int Zone::createZone(const std::string& name, const std::string& setupWizAppid)
             //unlock the user
             setZoneState(user.getUid(), 1);
 
-            context.notify("Zone::created", name, std::string());
+            context.notify("ZonePolicy::created", name, std::string());
         } catch (runtime::Exception& e) {
             ERROR(e.what());
         }
@@ -316,7 +316,7 @@ int Zone::createZone(const std::string& name, const std::string& setupWizAppid)
     return 0;
 }
 
-int Zone::removeZone(const std::string& name)
+int ZonePolicy::removeZone(const std::string& name)
 {
     int ret;
 
@@ -365,7 +365,7 @@ int Zone::removeZone(const std::string& name)
 
             bundle.remove();
 
-            context.notify("Zone::removed", name, std::string());
+            context.notify("ZonePolicy::removed", name, std::string());
         } catch (runtime::Exception& e) {
             ERROR(e.what());
             return;
@@ -378,7 +378,7 @@ int Zone::removeZone(const std::string& name)
     return 0;
 }
 
-int Zone::lockZone(const std::string& name)
+int ZonePolicy::lockZone(const std::string& name)
 {
     int result;
 
@@ -397,7 +397,7 @@ int Zone::lockZone(const std::string& name)
     return 0;
 }
 
-int Zone::unlockZone(const std::string& name)
+int ZonePolicy::unlockZone(const std::string& name)
 {
     int result;
 
@@ -416,16 +416,16 @@ int Zone::unlockZone(const std::string& name)
     return 0;
 }
 
-std::vector<std::string> Zone::getZoneList()
+std::vector<std::string> ZonePolicy::getZoneList()
 {
     return std::vector<std::string>();
 }
 
-int Zone::getZoneState(const std::string& name)
+int ZonePolicy::getZoneState(const std::string& name)
 {
     return 0;
 }
 
-Zone zonePolicy(Server::instance());
+ZonePolicy zonePolicy(Server::instance());
 
 } // namespace DevicePolicyManager
index 2f1f4ba..be570e8 100644 (file)
 SET(API_TEST_TARGET    "dpm-api-tests")
 
 SET(API_TEST_SOURCES main.c
-                     zone.c
-                     security.c
-                     password.c
                      testbench.c
-                     misc.c
-                     restriction.c
                      bluetooth.c
+#                     password.c
+                                        restriction.c
+                     security.c
+#                     storage.c
+                     zone.c
 )
 
 ADD_EXECUTABLE(${API_TEST_TARGET} ${API_TEST_SOURCES})
index d2e17f3..b92be93 100644 (file)
 
 static int bluetooth_add_device_to_blacklist(struct testcase* tc)
 {
-    dpm_client_h handle;
+    dpm_context_h context;
 
-    handle = dpm_create_client();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
+    context = dpm_context_create();
+    if (context == NULL) {
+        printf("Failed to create client context\n");
         return TEST_FAILED;
     }
 
-    const char* dummy_mac_address = "e8:11:32:30:78:9c";
-    if (dpm_add_bluetooth_device_to_blacklist(handle, dummy_mac_address) != 0) {
-        dpm_destroy_client(handle);
+    dpm_bluetooth_policy_h policy = dpm_context_acquire_bluetooth_policy(context);
+    if (policy == NULL) {
+        printf("Failed to get bluetooth policy interface\n");
+        dpm_context_destroy(context);
         return TEST_FAILED;
     }
 
-    dpm_destroy_client(handle);
+    const char* dummy_mac = "e8:11:32:30:78:9c";
+    if (dpm_bluetooth_add_device_to_blacklist(policy, dummy_mac) != 0) {
+        printf("Failed to add device from blacklist\n");
+        dpm_context_release_bluetooth_policy(context, policy);
+        dpm_context_destroy(context);
+        return TEST_FAILED;
+    }
+
+    dpm_context_release_bluetooth_policy(context, policy);
+    dpm_context_destroy(context);
+
     return TEST_SUCCESSED;
 }
 
 static int bluetooth_remove_device_from_blacklist(struct testcase* tc)
 {
-    dpm_client_h handle;
+    dpm_context_h context;
+
+    context = dpm_context_create();
+    if (context == NULL) {
+        printf("Failed to create client context\n");
+        return TEST_FAILED;
+    }
 
-    handle = dpm_create_client();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
+    dpm_bluetooth_policy_h policy = dpm_context_acquire_bluetooth_policy(context);
+    if (policy == NULL) {
+        printf("Failed to get bluetooth policy interface\n");
+        dpm_context_destroy(context);
         return TEST_FAILED;
     }
 
-    const char* dummy_mac_address = "e8:11:32:30:78:9c";
-    if (dpm_remove_bluetooth_device_from_blacklist(handle, dummy_mac_address) != 0) {
-        dpm_destroy_client(handle);
+    const char* dummy_mac = "e8:11:32:30:78:9c";
+    if (dpm_bluetooth_remove_device_from_blacklist(policy, dummy_mac) != 0) {
+        printf("Failed to remove device from blacklist\n");
+        dpm_context_release_bluetooth_policy(context, policy);
+        dpm_context_destroy(context);
         return TEST_FAILED;
     }
 
-    dpm_destroy_client(handle);
+    dpm_context_release_bluetooth_policy(context, policy);
+    dpm_context_destroy(context);
     return TEST_SUCCESSED;
 }
 
 static int bluetooth_device_restriction(struct testcase* tc)
 {
-    bool allow = false;
-    dpm_client_h handle;
+    int allow = false;
+    dpm_context_h context;
+
+    context = dpm_context_create();
+    if (context == NULL) {
+        printf("Failed to create client context\n");
+        return TEST_FAILED;
+    }
 
-    handle = dpm_create_client();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
+    dpm_bluetooth_policy_h policy = dpm_context_acquire_bluetooth_policy(context);
+    if (policy == NULL) {
+        printf("Failed to get bluetooth policy interface\n");
+        dpm_context_destroy(context);
         return TEST_FAILED;
     }
 
-    if (dpm_set_bluetooth_device_restriction(handle, true) != 0) {
+    if (dpm_bluetooth_set_device_restriction(policy, true) != 0) {
+        printf("Failed to set device restriction\n");
+        dpm_context_release_bluetooth_policy(context, policy);
+        dpm_context_destroy(context);
         return TEST_FAILED;
     }
 
     // the 'allow' will be always 'true' before server/bluetooth.cpp has been implemented.
-    allow = dpm_is_bluetooth_device_restricted(handle);
-    if (allow == true) {
-        dpm_destroy_client(handle);
-        return TEST_SUCCESSED;
+    if (dpm_bluetooth_is_device_restricted(policy, &allow) != DPM_ERROR_NONE) {
+        printf("Failed to check device restriction\n");
+        dpm_context_release_bluetooth_policy(context, policy);
+        dpm_context_destroy(context);
+        return TEST_FAILED;
     }
 
-    dpm_destroy_client(handle);
-    return TEST_FAILED;
+    dpm_context_release_bluetooth_policy(context, policy);
+    dpm_context_destroy(context);
+    return TEST_SUCCESSED;
 }
 
 static int bluetooth_add_uuid_to_blacklist(struct testcase* tc)
 {
-    dpm_client_h handle;
+    dpm_context_h context;
 
-    handle = dpm_create_client();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
+    context = dpm_context_create();
+    if (context == NULL) {
+        printf("Failed to create client context\n");
+        return TEST_FAILED;
+    }
+
+    dpm_bluetooth_policy_h policy = dpm_context_acquire_bluetooth_policy(context);
+    if (policy == NULL) {
+        printf("Failed to get bluetooth policy interface\n");
+        dpm_context_destroy(context);
         return TEST_FAILED;
     }
 
     const char* dummy_uuid = "ff8ca1f3-0221-40c9-91fd-25ebbbfa68c3";
-    if (dpm_add_bluetooth_uuid_to_blacklist(handle, dummy_uuid) != 0) {
-        dpm_destroy_client(handle);
+    if (dpm_bluetooth_add_uuid_to_blacklist(policy, dummy_uuid) != 0) {
+        printf("Failed to add uuid to blacklist\n");
+        dpm_context_release_bluetooth_policy(context, policy);
+        dpm_context_destroy(context);
         return TEST_FAILED;
     }
 
-    dpm_destroy_client(handle);
+    dpm_context_release_bluetooth_policy(context, policy);
+    dpm_context_destroy(context);
     return TEST_SUCCESSED;
 }
 
 static int bluetooth_remove_uuid_from_blacklist(struct testcase* tc)
 {
-    dpm_client_h handle;
+    dpm_context_h context;
+
+    context = dpm_context_create();
+    if (context == NULL) {
+        printf("Failed to create client context\n");
+        return TEST_FAILED;
+    }
 
-    handle = dpm_create_client();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
+    dpm_bluetooth_policy_h policy = dpm_context_acquire_bluetooth_policy(context);
+    if (policy == NULL) {
+        printf("Failed to get bluetooth policy interface\n");
+        dpm_context_destroy(context);
         return TEST_FAILED;
     }
 
     const char* dummy_uuid = "ff8ca1f3-0221-40c9-91fd-25ebbbfa68c3";
-    if (dpm_remove_bluetooth_uuid_from_blacklist(handle, dummy_uuid) != 0) {
-        dpm_destroy_client(handle);
+    if (dpm_bluetooth_remove_uuid_from_blacklist(policy, dummy_uuid) != 0) {
+        printf("Failed to remove uuid from blacklist\n");
+        dpm_context_release_bluetooth_policy(context, policy);
+        dpm_context_destroy(context);
         return TEST_FAILED;
     }
 
-    dpm_destroy_client(handle);
+    dpm_context_release_bluetooth_policy(context, policy);
+    dpm_context_destroy(context);
     return TEST_SUCCESSED;
 }
 
 static int bluetooth_uuid_restriction(struct testcase* tc)
 {
-    bool allow = false;
-    dpm_client_h handle;
+    int allow = false;
+    dpm_context_h context;
 
-    handle = dpm_create_client();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
+    context = dpm_context_create();
+    if (context == NULL) {
+        printf("Failed to create client context\n");
         return TEST_FAILED;
     }
 
-    if (dpm_set_bluetooth_uuid_restriction(handle, true) != 0) {
+    dpm_bluetooth_policy_h policy = dpm_context_acquire_bluetooth_policy(context);
+    if (policy == NULL) {
+        printf("Failed to get bluetooth policy interface\n");
+        dpm_context_destroy(context);
+        return TEST_FAILED;
+    }
+
+    if (dpm_bluetooth_set_uuid_restriction(policy, true) != 0) {
+        printf("Failed to set uuid restriction\n");
+        dpm_context_release_bluetooth_policy(context, policy);
+        dpm_context_destroy(context);
         return TEST_FAILED;
     }
 
     // the 'allow' will be always 'true' before server/bluetooth.cpp has been implemented.
-    allow = dpm_is_bluetooth_uuid_restricted(handle);
-    if (allow == true) {
-        dpm_destroy_client(handle);
-        return TEST_SUCCESSED;
+    if (dpm_bluetooth_is_uuid_restricted(policy, &allow) != DPM_ERROR_NONE) {
+        printf("Failed to check uuid restriction\n");
+        dpm_context_release_bluetooth_policy(context, policy);
+        dpm_context_destroy(context);
+        return TEST_FAILED;
     }
 
-    dpm_destroy_client(handle);
-    return TEST_FAILED;
+    dpm_context_release_bluetooth_policy(context, policy);
+    dpm_context_destroy(context);
+    return TEST_SUCCESSED;
 }
 
 struct testcase bluetooth_testcase_add_device_to_blacklist = {
index d44f2c2..1739627 100644 (file)
 
 static int misc_camera(struct testcase *tc)
 {
-       dpm_client_h handle;
+       dpm_context_h handle;
        bool enable = false;
 
-       handle = dpm_create_client();
+       handle = dpm_context_create();
        if (handle == NULL) {
                printf("Failed to create client handle\n");
                return TEST_FAILED;
        }
 
        if (dpm_set_camera_restriction(handle, true) != 0) {
-               dpm_destroy_client(handle);
+               dpm_context_destroy(handle);
                return TEST_FAILED;
        }
 
        enable = dpm_is_camera_restricted(handle);
        if (enable == true) {
-               dpm_destroy_client(handle);
+               dpm_context_destroy(handle);
                return TEST_SUCCESSED;
        }
 
-       dpm_destroy_client(handle);
+       dpm_context_destroy(handle);
        return TEST_FAILED;
 }
 
 static int misc_microphone(struct testcase *tc)
 {
-       dpm_client_h handle;
+       dpm_context_h handle;
        bool enable = false;
 
-       handle = dpm_create_client();
+       handle = dpm_context_create();
        if (handle == NULL) {
                printf("Failed to create client handle\n");
                return TEST_FAILED;
        }
 
        if (dpm_set_microphone_restriction(handle, true) != 0) {
-               dpm_destroy_client(handle);
+               dpm_context_destroy(handle);
                return TEST_FAILED;
        }
 
        enable = dpm_is_microphone_restricted(handle);
        if (enable == true) {
-               dpm_destroy_client(handle);
+               dpm_context_destroy(handle);
                return TEST_SUCCESSED;
        }
 
-       dpm_destroy_client(handle);
+       dpm_context_destroy(handle);
        return TEST_FAILED;
 }
 
 static int misc_location(struct testcase *tc)
 {
-       dpm_client_h handle;
+       dpm_context_h handle;
        bool enable = false;
 
-       handle = dpm_create_client();
+       handle = dpm_context_create();
        if (handle == NULL) {
                printf("Failed to create client handle\n");
                return TEST_FAILED;
        }
 
        if (dpm_set_location_restriction(handle, true) != 0) {
-               dpm_destroy_client(handle);
+               dpm_context_destroy(handle);
                return TEST_FAILED;
        }
 
        enable = dpm_is_location_restricted(handle);
        if (enable == true) {
-               dpm_destroy_client(handle);
+               dpm_context_destroy(handle);
                return TEST_SUCCESSED;
        }
 
-       dpm_destroy_client(handle);
+       dpm_context_destroy(handle);
        return TEST_FAILED;
 }
 
 static int misc_sd_card(struct testcase *tc)
 {
-       dpm_client_h handle;
+       dpm_context_h handle;
        bool enable = false;
 
-       handle = dpm_create_client();
+       handle = dpm_context_create();
        if (handle == NULL) {
                printf("Failed to create client handle\n");
                return TEST_FAILED;
        }
 
        if (dpm_set_sd_card_restriction(handle, true) != 0) {
-               dpm_destroy_client(handle);
+               dpm_context_destroy(handle);
                return TEST_FAILED;
        }
 
        enable = dpm_is_sd_card_restricted(handle);
        if (enable == true) {
-               dpm_destroy_client(handle);
+               dpm_context_destroy(handle);
                return TEST_SUCCESSED;
        }
 
-       dpm_destroy_client(handle);
+       dpm_context_destroy(handle);
        return TEST_FAILED;
 }
 
index b4cf409..376a789 100644 (file)
 
 static int password_set_password_quality(struct testcase *tc)
 {
-    dpm_client_h handle;
+    dpm_context_h handle;
 
-    handle = dpm_create_client();
+    handle = dpm_context_create();
     if (handle == NULL) {
         printf("Failed to create client handle\n");
         return TEST_FAILED;
     }
 
     if (dpm_set_password_quality(handle, "owner", DPM_PASSWORD_QUALITY_ALPHANUMERIC) == 0) {
-        dpm_destroy_client(handle);
+        dpm_context_destroy(handle);
         return TEST_SUCCESSED;
     }
 
-    dpm_destroy_client(handle);
+    dpm_context_destroy(handle);
     return TEST_FAILED;
 }
 
 static int password_set_password_minimum_length(struct testcase *tc)
 {
-    dpm_client_h handle;
+    dpm_context_h handle;
 
-    handle = dpm_create_client();
+    handle = dpm_context_create();
     if (handle == NULL) {
         printf("Failed to create client handle\n");
         return TEST_FAILED;
     }
 
     if (dpm_set_password_minimum_length(handle, "owner", 27) == 0) {
-        dpm_destroy_client(handle);
+        dpm_context_destroy(handle);
         return TEST_SUCCESSED;
     }
 
-    dpm_destroy_client(handle);
+    dpm_context_destroy(handle);
     return TEST_FAILED;
 }
 
 static int password_set_min_password_complex_chars(struct testcase *tc)
 {
-    dpm_client_h handle;
+    dpm_context_h handle;
 
-    handle = dpm_create_client();
+    handle = dpm_context_create();
     if (handle == NULL) {
         printf("Failed to create client handle\n");
         return TEST_FAILED;
     }
 
     if (dpm_set_min_password_complex_chars(handle, "owner", 10) == 0) {
-        dpm_destroy_client(handle);
+        dpm_context_destroy(handle);
         return TEST_SUCCESSED;
     }
 
-    dpm_destroy_client(handle);
+    dpm_context_destroy(handle);
     return TEST_FAILED;
 }
 
 static int password_set_maximum_failed_password_for_wipe(struct testcase *tc)
 {
-    dpm_client_h handle;
+    dpm_context_h handle;
 
-    handle = dpm_create_client();
+    handle = dpm_context_create();
     if (handle == NULL) {
         printf("Failed to create client handle\n");
         return TEST_FAILED;
     }
 
     if (dpm_set_maximum_failed_password_for_wipe(handle, "owner", 11) == 0) {
-        dpm_destroy_client(handle);
+        dpm_context_destroy(handle);
         return TEST_SUCCESSED;
     }
 
-    dpm_destroy_client(handle);
+    dpm_context_destroy(handle);
     return TEST_FAILED;
 }
 
 static int password_set_password_expires(struct testcase *tc)
 {
-    dpm_client_h handle;
+    dpm_context_h handle;
 
-    handle = dpm_create_client();
+    handle = dpm_context_create();
     if (handle == NULL) {
         printf("Failed to create client handle\n");
         return TEST_FAILED;
     }
 
     if (dpm_set_password_expires(handle, "owner", 30) == 0) {
-        dpm_destroy_client(handle);
+        dpm_context_destroy(handle);
         return TEST_SUCCESSED;
     }
 
-    dpm_destroy_client(handle);
+    dpm_context_destroy(handle);
     return TEST_FAILED;
 }
 
 static int password_set_password_history(struct testcase *tc)
 {
-    dpm_client_h handle;
+    dpm_context_h handle;
 
-    handle = dpm_create_client();
+    handle = dpm_context_create();
     if (handle == NULL) {
         printf("Failed to create client handle\n");
         return TEST_FAILED;
     }
 
     if (dpm_set_password_history(handle, "owner", 12) == 0) {
-        dpm_destroy_client(handle);
+        dpm_context_destroy(handle);
         return TEST_SUCCESSED;
     }
 
-    dpm_destroy_client(handle);
+    dpm_context_destroy(handle);
     return TEST_FAILED;
 }
 
 static int password_set_password_pattern(struct testcase *tc)
 {
-    dpm_client_h handle;
+    dpm_context_h handle;
 
-    handle = dpm_create_client();
+    handle = dpm_context_create();
     if (handle == NULL) {
         printf("Failed to create client handle\n");
         return TEST_FAILED;
     }
 
     if (dpm_set_password_pattern(handle, "owner", "[a-zA-Z]{4}[0-9]{4}") == 0) {
-        dpm_destroy_client(handle);
+        dpm_context_destroy(handle);
         return TEST_SUCCESSED;
     }
 
-    dpm_destroy_client(handle);
+    dpm_context_destroy(handle);
     return TEST_FAILED;
 }
 
 static int password_reset_password(struct testcase *tc)
 {
-    dpm_client_h handle;
+    dpm_context_h handle;
 
-    handle = dpm_create_client();
+    handle = dpm_context_create();
     if (handle == NULL) {
         printf("Failed to create client handle\n");
         return TEST_FAILED;
     }
 
     if (dpm_reset_password(handle, "owner", "tizen") == 0) {
-        dpm_destroy_client(handle);
+        dpm_context_destroy(handle);
         return TEST_SUCCESSED;
     }
 
-    dpm_destroy_client(handle);
+    dpm_context_destroy(handle);
     return TEST_FAILED;
 }
 
 static int password_enforce_password_change(struct testcase *tc)
 {
-    dpm_client_h handle;
+    dpm_context_h handle;
 
-    handle = dpm_create_client();
+    handle = dpm_context_create();
     if (handle == NULL) {
         printf("Failed to create client handle\n");
         return TEST_FAILED;
     }
 
     if (dpm_enforce_password_change(handle, "owner") == 0) {
-        dpm_destroy_client(handle);
+        dpm_context_destroy(handle);
         return TEST_SUCCESSED;
     }
 
-    dpm_destroy_client(handle);
+    dpm_context_destroy(handle);
     return TEST_FAILED;
 }
 
 static int password_set_max_inactivity_time_device_lock(struct testcase *tc)
 {
-    dpm_client_h handle;
+    dpm_context_h handle;
 
-    handle = dpm_create_client();
+    handle = dpm_context_create();
     if (handle == NULL) {
         printf("Failed to create client handle\n");
         return TEST_FAILED;
     }
 
     if (dpm_set_max_inactivity_time_device_lock(handle, "owner", 30) == 0) {
-        dpm_destroy_client(handle);
+        dpm_context_destroy(handle);
         return TEST_SUCCESSED;
     }
 
-    dpm_destroy_client(handle);
+    dpm_context_destroy(handle);
     return TEST_FAILED;
 }
 
 static int password_get_max_inactivity_time_device_lock(struct testcase *tc)
 {
-    dpm_client_h handle;
+    dpm_context_h handle;
     int max_inactivity_time = 0;
 
-    handle = dpm_create_client();
+    handle = dpm_context_create();
     if (handle == NULL) {
         printf("Failed to create client handle\n");
         return TEST_FAILED;
     }
 
     if (dpm_get_max_inactivity_time_device_lock(handle, "owner", &max_inactivity_time) == 0) {
-        dpm_destroy_client(handle);
+        dpm_context_destroy(handle);
         printf("[DPM] maxInactivityTime: %d\n", max_inactivity_time);
         return TEST_SUCCESSED;
     }
 
-    dpm_destroy_client(handle);
+    dpm_context_destroy(handle);
     return TEST_FAILED;
 }
 
 static int password_set_password_status(struct testcase *tc)
 {
-    dpm_client_h handle;
+    dpm_context_h handle;
 
-    handle = dpm_create_client();
+    handle = dpm_context_create();
     if (handle == NULL) {
         printf("Failed to create client handle\n");
         return TEST_FAILED;
     }
 
     if (dpm_set_password_status(handle, "owner", 10) == 0) {
-        dpm_destroy_client(handle);
+        dpm_context_destroy(handle);
         return TEST_SUCCESSED;
     }
 
-    dpm_destroy_client(handle);
+    dpm_context_destroy(handle);
     return TEST_FAILED;
 }
 
 static int password_delete_password_pattern(struct testcase *tc)
 {
-    dpm_client_h handle;
+    dpm_context_h handle;
 
-    handle = dpm_create_client();
+    handle = dpm_context_create();
     if (handle == NULL) {
         printf("Failed to create client handle\n");
         return TEST_FAILED;
     }
 
     if (dpm_delete_password_pattern(handle, "owner") == 0) {
-        dpm_destroy_client(handle);
+        dpm_context_destroy(handle);
         return TEST_SUCCESSED;
     }
 
-    dpm_destroy_client(handle);
+    dpm_context_destroy(handle);
     return TEST_FAILED;
 }
 
 static int password_get_password_pattern(struct testcase *tc)
 {
-    dpm_client_h handle;
+    dpm_context_h handle;
     char *passwd_pattern;
 
-    handle = dpm_create_client();
+    handle = dpm_context_create();
     if (handle == NULL) {
         printf("Failed to create client handle\n");
         return TEST_FAILED;
@@ -284,94 +284,94 @@ static int password_get_password_pattern(struct testcase *tc)
 
     passwd_pattern = dpm_get_password_pattern(handle, "owner");
     if (passwd_pattern != NULL) {
-        printf("[DPM] Password Pattern: %s\n", passwd_pattern);
+        printf("[DPM] PasswordPolicy Pattern: %s\n", passwd_pattern);
 
                free(passwd_pattern);
 
         return TEST_SUCCESSED;
     }
 
-    dpm_destroy_client(handle);
+    dpm_context_destroy(handle);
     return TEST_FAILED;
 }
 
 static int password_set_maximum_character_occurrences(struct testcase *tc)
 {
-    dpm_client_h handle;
+    dpm_context_h handle;
 
-    handle = dpm_create_client();
+    handle = dpm_context_create();
     if (handle == NULL) {
         printf("Failed to create client handle\n");
         return TEST_FAILED;
     }
 
     if (dpm_set_maximum_character_occurrences(handle, "owner", 15) == 0) {
-        dpm_destroy_client(handle);
+        dpm_context_destroy(handle);
         return TEST_SUCCESSED;
     }
 
-    dpm_destroy_client(handle);
+    dpm_context_destroy(handle);
     return TEST_FAILED;
 }
 
 static int password_get_maximum_character_occurrences(struct testcase *tc)
 {
-    dpm_client_h handle;
+    dpm_context_h handle;
     int maximum_char_occurences = 0;
 
-    handle = dpm_create_client();
+    handle = dpm_context_create();
     if (handle == NULL) {
         printf("Failed to create client handle\n");
         return TEST_FAILED;
     }
 
     if (dpm_get_maximum_character_occurrences(handle, "owner", &maximum_char_occurences) == 0) {
-        dpm_destroy_client(handle);
+        dpm_context_destroy(handle);
         printf("[DPM] maxCharOccurences: %d\n", maximum_char_occurences);
         return TEST_SUCCESSED;
     }
 
-    dpm_destroy_client(handle);
+    dpm_context_destroy(handle);
     return TEST_FAILED;
 }
 
 static int password_set_maximum_numeric_sequence_length(struct testcase *tc)
 {
-    dpm_client_h handle;
+    dpm_context_h handle;
 
-    handle = dpm_create_client();
+    handle = dpm_context_create();
     if (handle == NULL) {
         printf("Failed to create client handle\n");
         return TEST_FAILED;
     }
 
     if (dpm_set_maximum_numeric_sequence_length(handle, "owner", 7) == 0) {
-        dpm_destroy_client(handle);
+        dpm_context_destroy(handle);
         return TEST_SUCCESSED;
     }
 
-    dpm_destroy_client(handle);
+    dpm_context_destroy(handle);
     return TEST_FAILED;
 }
 
 static int password_get_maximum_numeric_sequence_length(struct testcase *tc)
 {
-    dpm_client_h handle;
+    dpm_context_h handle;
     int maximum_num_seq_length = 0;
 
-    handle = dpm_create_client();
+    handle = dpm_context_create();
     if (handle == NULL) {
         printf("Failed to create client handle\n");
         return TEST_FAILED;
     }
 
     if (dpm_get_maximum_numeric_sequence_length(handle, "owner", &maximum_num_seq_length) == 0) {
-        dpm_destroy_client(handle);
+        dpm_context_destroy(handle);
         printf("[DPM] maxNumSeqLength: %d\n", maximum_num_seq_length);
         return TEST_SUCCESSED;
     }
 
-    dpm_destroy_client(handle);
+    dpm_context_destroy(handle);
     return TEST_FAILED;
 }
 
index 78a9f18..f19dadb 100644 (file)
 #include <dpm/restriction.h>
 #include "testbench.h"
 
-static int restriction_clipboard(struct testcase* tc)
+static int test_dpm_clipboard(struct testcase* tc)
 {
-       dpm_client_h handle;
-       bool enable = false;
+       dpm_context_h context;
+    dpm_restriction_policy_h policy;
+       int ret, enable = false;
 
-       handle = dpm_create_client();
-       if (handle == NULL) {
-               printf("Failed to create client handle\n");
+       context = dpm_context_create();
+       if (context == NULL) {
+               printf("Failed to create client context\n");
                return TEST_FAILED;
        }
 
-       if (dpm_set_clipboard_restriction(handle, true) != 0) {
-               dpm_destroy_client(handle);
-               return TEST_FAILED;
-       }
-
-       enable = dpm_is_clipboard_restricted(handle);
-       if (enable == true) {
-               dpm_destroy_client(handle);
-               return TEST_SUCCESSED;
-       }
-
-       dpm_destroy_client(handle);
-       return TEST_FAILED;
-}
-
-static int restriction_clipboard_share(struct testcase* tc)
-{
-       dpm_client_h handle;
-       bool enable = false;
+    policy = dpm_context_acquire_restriction_policy(context);
+    if (policy == NULL) {
+        printf("Failed to get datashare policy interface\n");
+        dpm_context_destroy(context);
+        return TEST_FAILED;
+    }
 
-       handle = dpm_create_client();
-       if (handle == NULL) {
-               printf("Failed to create client handle\n");
-               return TEST_FAILED;
+       ret = TEST_SUCCESSED;
+       if (dpm_restriction_set_clipboard_state(policy, true) != 0) {
+               ret = TEST_FAILED;
+               goto out;
        }
 
-       if (dpm_set_clipboard_share_restriction(handle, true) != 0) {
-               dpm_destroy_client(handle);
-               return TEST_FAILED;
+       if (dpm_restriction_get_clipboard_state(policy, &enable) < 0) {
+               ret = TEST_FAILED;
+               goto out;
        }
 
-       enable = dpm_is_clipboard_share_restricted(handle);
-       if (enable == true) {
-               dpm_destroy_client(handle);
-               return TEST_SUCCESSED;
-       }
+out:
+    dpm_context_release_restriction_policy(context, policy);
+       dpm_context_destroy(context);
 
-       dpm_destroy_client(handle);
-       return TEST_FAILED;
+       return ret;
 }
 
-static int restriction_settings_changes(struct testcase* tc)
+static int test_dpm_usb_debugging(struct testcase* tc)
 {
-       dpm_client_h handle;
-       bool enable = false;
-
-       handle = dpm_create_client();
-       if (handle == NULL) {
-               printf("Failed to create client handle\n");
-               return TEST_FAILED;
-       }
+       dpm_context_h context;
+    dpm_restriction_policy_h policy;
+       int ret, enable = false;
 
-       if (dpm_set_settings_changes_restriction(handle, true) != 0) {
-               dpm_destroy_client(handle);
+       context = dpm_context_create();
+       if (context == NULL) {
+               printf("Failed to create client context\n");
                return TEST_FAILED;
        }
 
-       enable = dpm_is_settings_changes_restricted(handle);
-       if (enable == true) {
-               dpm_destroy_client(handle);
-               return TEST_SUCCESSED;
-       }
-
-       dpm_destroy_client(handle);
-       return TEST_FAILED;
-}
+    policy = dpm_context_acquire_restriction_policy(context);
+    if (policy == NULL) {
+        printf("Failed to get developer policy interface\n");
+        dpm_context_destroy(context);
+        return TEST_FAILED;
+    }
 
-static int restriction_background_data(struct testcase* tc)
-{
-       dpm_client_h handle;
-       bool enable = false;
-
-       handle = dpm_create_client();
-       if (handle == NULL) {
-               printf("Failed to create client handle\n");
-               return TEST_FAILED;
+       ret = TEST_SUCCESSED;
+       if (dpm_restriction_set_usb_debugging_state(policy, true) != 0) {
+               ret = TEST_FAILED;
+               goto out;
        }
 
-       if (dpm_set_background_data_restriction(handle, true) != 0) {
-               dpm_destroy_client(handle);
-               return TEST_FAILED;
+       if (dpm_restriction_get_usb_debugging_state(policy, &enable) < 0) {
+               ret = TEST_FAILED;
+               goto out;
        }
 
-       enable = dpm_is_background_data_restricted(handle);
-       if (enable == true) {
-               dpm_destroy_client(handle);
-               return TEST_SUCCESSED;
-       }
+out:
+       dpm_context_release_restriction_policy(context, policy);
+       dpm_context_destroy(context);
 
-       dpm_destroy_client(handle);
-       return TEST_FAILED;
+       return ret;
 }
 
-static int restriction_usb_debugging(struct testcase* tc)
+static int test_dpm_settings_changes(struct testcase* tc)
 {
-       dpm_client_h handle;
-       bool enable = false;
+       dpm_context_h context;
+    dpm_restriction_policy_h policy;
+       int ret, enable = false;
 
-       handle = dpm_create_client();
-       if (handle == NULL) {
-               printf("Failed to create client handle\n");
+       context = dpm_context_create();
+       if (context == NULL) {
+               printf("Failed to create client context\n");
                return TEST_FAILED;
        }
 
-       if (dpm_set_usb_debugging_restriction(handle, true) != 0) {
-               dpm_destroy_client(handle);
-               return TEST_FAILED;
-       }
+    policy = dpm_context_acquire_restriction_policy(context);
+    if (policy == NULL) {
+        printf("Failed to get settings policy interface\n");
+        dpm_context_destroy(context);
+        return TEST_FAILED;
+    }
 
-       enable = dpm_is_usb_debugging_restricted(handle);
-       if (enable == true) {
-               dpm_destroy_client(handle);
-               return TEST_SUCCESSED;
+       ret = TEST_SUCCESSED;
+       if (dpm_restriction_set_settings_changes_state(policy, true) != 0) {
+               ret = TEST_FAILED;
+               goto out;
        }
 
-       dpm_destroy_client(handle);
-       return TEST_FAILED;
-}
-
-static int restriction_usb_mass_storage(struct testcase* tc)
-{
-       dpm_client_h handle;
-       bool enable = false;
-
-       handle = dpm_create_client();
-       if (handle == NULL) {
-               printf("Failed to create client handle\n");
-               return TEST_FAILED;
+       if (dpm_restriction_get_settings_changes_state(policy, &enable) < 0) {
+               ret = TEST_SUCCESSED;
+               goto out;
        }
 
-       if (dpm_set_usb_mass_storage_restriction(handle, true) != 0) {
-               dpm_destroy_client(handle);
-               return TEST_FAILED;
-       }
+out:
+       dpm_context_release_restriction_policy(context, policy);
+       dpm_context_destroy(context);
 
-       enable = dpm_is_usb_mass_storage_restricted(handle);
-       if (enable == true) {
-               dpm_destroy_client(handle);
-               return TEST_SUCCESSED;
-       }
-
-       dpm_destroy_client(handle);
-       return TEST_FAILED;
+       return ret;
 }
 
-static int restriction_factory_reset(struct testcase* tc)
-{
-       dpm_client_h handle;
-       bool enable = false;
-
-       handle = dpm_create_client();
-       if (handle == NULL) {
-               printf("Failed to create client handle\n");
-               return TEST_FAILED;
-       }
-
-       if (dpm_set_factory_reset_restriction(handle, true) != 0) {
-               dpm_destroy_client(handle);
-               return TEST_FAILED;
-       }
-
-       enable = dpm_is_factory_reset_restricted(handle);
-       if (enable == true) {
-               dpm_destroy_client(handle);
-               return TEST_SUCCESSED;
-       }
-
-       dpm_destroy_client(handle);
-       return TEST_FAILED;
-}
-
-struct testcase restriction_testcase_clipboard = {
-       .description = "dpm_clipboard",
-       .handler = restriction_clipboard
-};
-
-struct testcase restriction_testcase_clipboard_share = {
-       .description = "dpm_clipboard_share",
-       .handler = restriction_clipboard_share
-};
-
-struct testcase restriction_testcase_settings_changes = {
+struct testcase settings_testcase_settings_changes = {
        .description = "dpm_settings_changes",
-       .handler = restriction_settings_changes
-};
-
-struct testcase restriction_testcase_background_data = {
-       .description = "dpm_background_data",
-       .handler = restriction_background_data
+       .handler = test_dpm_settings_changes
 };
 
-struct testcase restriction_testcase_usb_debugging = {
+struct testcase developer_testcase_usb_debugging = {
        .description = "dpm_usb_debugging",
-       .handler = restriction_usb_debugging
+       .handler = test_dpm_usb_debugging
 };
 
-struct testcase restriction_testcase_usb_mass_storage = {
-       .description = "dpm_usb_mass_storage",
-       .handler = restriction_usb_mass_storage
-};
-
-struct testcase restriction_testcase_factory_reset = {
-       .description = "dpm_factory_reset",
-       .handler = restriction_factory_reset
+struct testcase datashare_testcase_clipboard = {
+       .description = "dpm_clipboard",
+       .handler = test_dpm_clipboard
 };
 
-void TESTCASE_CONSTRUCTOR restriction_policy_build_testcase(void)
+void TESTCASE_CONSTRUCTOR datashare_policy_build_testcase(void)
 {
-       testbench_populate_testcase(&restriction_testcase_clipboard);
-       testbench_populate_testcase(&restriction_testcase_clipboard_share);
-       testbench_populate_testcase(&restriction_testcase_settings_changes);
-       testbench_populate_testcase(&restriction_testcase_background_data);
-       testbench_populate_testcase(&restriction_testcase_usb_debugging);
-       testbench_populate_testcase(&restriction_testcase_usb_mass_storage);
-       testbench_populate_testcase(&restriction_testcase_factory_reset);
+       testbench_populate_testcase(&datashare_testcase_clipboard);
+       testbench_populate_testcase(&developer_testcase_usb_debugging);
+       testbench_populate_testcase(&settings_testcase_settings_changes);
 }
index 323a8c5..42ca3a4 100644 (file)
 
 static int security_lock_screen(struct testcase* tc)
 {
+    dpm_context_h context;
+    dpm_security_policy_h policy;
     int ret;
-    dpm_client_h handle;
 
-    handle = dpm_create_client();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
+    context = dpm_context_create();
+    if (context == NULL) {
+        printf("Failed to create client context\n");
         return TEST_FAILED;
     }
 
-    ret = TEST_SUCCESSED;
-    if (dpm_lockout_screen(handle) != 0) {
-        ret = TEST_FAILED;
-    }
-
-    return ret;
-}
-
-static int security_wipe_internal_memory(struct testcase* tc)
-{
-    int ret;
-    dpm_client_h handle;
-
-    handle = dpm_create_client();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
+    policy = dpm_context_acquire_security_policy(context);
+    if (policy == NULL) {
+        printf("Failed to acquire security policy handle\n");
+        dpm_context_destroy(context);
         return TEST_FAILED;
     }
 
     ret = TEST_SUCCESSED;
-    if (dpm_wipe_data(handle, WIPE_INTERNAL_MEMORY) != 0) {
+    if (dpm_security_lockout_screen(policy) != 0) {
+        printf("Failed to lockout screen\n");
         ret = TEST_FAILED;
     }
 
-    dpm_destroy_client(handle);
-    return ret;
-}
-
-static int security_wipe_external_memory(struct testcase* tc)
-{
-    int ret;
-    dpm_client_h handle;
-
-    handle = dpm_create_client();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    ret = TEST_SUCCESSED;
-    if (dpm_wipe_data(handle, WIPE_EXTERNAL_MEMORY) != 0) {
-        ret = TEST_FAILED;
-    }
+    dpm_context_release_security_policy(context, policy);
+    dpm_context_destroy(context);
 
-    dpm_destroy_client(handle);
-    return ret;
-}
-
-static int security_reboot(struct testcase* tc)
-{
-    int ret;
-    dpm_client_h handle;
-
-    handle = dpm_create_client();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    ret = TEST_SUCCESSED;
-    if (dpm_reboot(handle) != 0) {
-        ret = TEST_FAILED;
-    }
-
-    dpm_destroy_client(handle);
-    return ret;
-}
-
-static int security_poweroff_device(struct testcase* tc)
-{
-    int ret;
-    dpm_client_h handle;
-
-    handle = dpm_create_client();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    ret = TEST_SUCCESSED;
-    if (dpm_poweroff_device(handle) != 0) {
-        ret = TEST_FAILED;
-    }
-
-    dpm_destroy_client(handle);
-    return ret;
-}
-
-static int security_set_internal_storage_encryption(struct testcase* tc)
-{
-    int ret;
-    dpm_client_h handle;
-
-    handle = dpm_create_client();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    ret = TEST_SUCCESSED;
-    if (dpm_set_internal_storage_encryption(handle, 1) != 0) {
-        ret = TEST_FAILED;
-    }
-
-    dpm_destroy_client(handle);
-    return ret;
-}
-
-static int security_is_internal_storage_encrypted(struct testcase* tc)
-{
-    int ret;
-    dpm_client_h handle;
-
-    handle = dpm_create_client();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    ret = TEST_SUCCESSED;
-    if (dpm_is_internal_storage_encrypted(handle) != TRUE) {
-        ret = TEST_FAILED;
-    }
-
-    dpm_destroy_client(handle);
-    return ret;
-}
-
-static int security_set_external_storage_encryption(struct testcase* tc)
-{
-    int ret;
-    dpm_client_h handle;
-
-    handle = dpm_create_client();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    ret = TEST_SUCCESSED;
-    if (dpm_set_external_storage_encryption(handle, 1) != 0) {
-        ret = TEST_FAILED;
-    }
-
-    dpm_destroy_client(handle);
-    return ret;
-}
-
-static int security_is_external_storage_encrypted(struct testcase* tc)
-{
-    int ret;
-    dpm_client_h handle;
-
-    handle = dpm_create_client();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    ret = TEST_SUCCESSED;
-    if (dpm_is_external_storage_encrypted(handle) != TRUE) {
-        ret = TEST_FAILED;
-    }
-
-    dpm_destroy_client(handle);
     return ret;
 }
 
@@ -203,56 +55,7 @@ struct testcase security_testcase_lock_screen = {
     .handler = security_lock_screen
 };
 
-struct testcase security_testcase_wipe_internal_memory = {
-    .description = "dpm_wipe_data(internal memory)",
-    .handler = security_wipe_internal_memory
-};
-
-struct testcase security_testcase_wipe_external_memory = {
-    .description = "dpm_wipe_data(external memory)",
-    .handler = security_wipe_external_memory
-};
-
-struct testcase security_testcase_reboot = {
-    .description = "dpm_reboot",
-    .handler = security_reboot
-};
-
-struct testcase security_testcase_poweroff = {
-    .description = "dpm_poweroff_device",
-    .handler = security_poweroff_device
-};
-
-struct testcase security_testcase_set_internal_storage_encryption = {
-    .description = "dpm_set_internal_storage_encryption",
-    .handler = security_set_internal_storage_encryption
-};
-
-struct testcase security_testcase_is_internal_storage_encrypted = {
-    .description = "dpm_is_internal_storage_encrypted",
-    .handler = security_is_internal_storage_encrypted
-};
-
-struct testcase security_testcase_set_external_storage_encryption = {
-    .description = "dpm_set_external_storage_encryption",
-    .handler = security_set_external_storage_encryption
-};
-
-struct testcase security_testcase_is_external_storage_encrypted = {
-    .description = "dpm_is_external_storage_encrypted",
-    .handler = security_is_external_storage_encrypted
-};
-
 void TESTCASE_CONSTRUCTOR security_policy_build_testcase(void)
 {
     testbench_populate_testcase(&security_testcase_lock_screen);
-    testbench_populate_testcase(&security_testcase_wipe_internal_memory);
-    testbench_populate_testcase(&security_testcase_wipe_external_memory);
-    //testbench_populate_testcase(&security_testcase_reboot);
-    //testbench_populate_testcase(&security_testcase_poweroff);
-    testbench_populate_testcase(&security_testcase_set_internal_storage_encryption);
-    testbench_populate_testcase(&security_testcase_is_internal_storage_encrypted);
-    testbench_populate_testcase(&security_testcase_set_external_storage_encryption);
-    testbench_populate_testcase(&security_testcase_is_external_storage_encrypted);
 }
-
diff --git a/tests/api/storage.c b/tests/api/storage.c
new file mode 100644 (file)
index 0000000..a25e452
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ *  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 <stdio.h>
+#include <stdbool.h>
+#include <dpm/storage.h>
+#include "testbench.h"
+
+
+static int test_dpm_usb_mass_storage(struct testcase* tc)
+{
+       int ret;
+       dpm_context_h context;
+    dpm_storage_policy_h policy;
+       bool enable = false;
+
+       context = dpm_context_create();
+       if (context == NULL) {
+               printf("Failed to create client context\n");
+               return TEST_FAILED;
+       }
+
+    policy = dpm_context_acquire_storage_policy(context);
+    if (policy == NULL) {
+        printf("Failed to get storage policy interface\n");
+        dpm_context_destroy(context);
+        return TEST_FAILED;
+    }
+
+       ret = TEST_SUCCESSED;
+       if (dpm_storage_set_external_storage_state(policy, true) != 0) {
+               ret = TEST_FAILED;
+               goto out;
+       }
+
+       enable = dpm_restriction_get_external_storage_state(policy);
+       if (enable != true) {
+               ret = TEST_FAILED;
+               goto out;
+       }
+
+out:
+       dpm_context_release_storage_policy(context, policy);
+       dpm_context_destroy(context);
+
+       return ret;
+}
+
+static int test_dpm_wipe(struct testcase* tc)
+{
+       int ret;
+       dpm_context_h context;
+    dpm_storage_policy_h policy;
+
+       context = dpm_context_create();
+       if (context == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
+
+       policy = dpm_context_acquire_storage_policy(context);
+    if (policy == NULL) {
+        printf("Failed to get storage policy interface\n");
+        dpm_context_destroy(context);
+        return TEST_FAILED;
+    }
+
+       ret = TEST_SUCCESSED;
+       if (dpm_storage_set_external_storage_state(policy, true) != 0) {
+               ret = TEST_FAILED;
+               goto out;
+       }
+
+       if (dpm_storage_wipe_data(policy, WIPE_EXTERNAL_STORAGE) != 0) {
+               ret = TEST_FAILED;
+               goto out;
+       }
+
+out:
+       dpm_context_release_storage_policy(context, policy);
+       dpm_context_destroy(context);
+
+       return ret;
+}
+
+
+struct testcase storage_testcase_usb_mass_storage = {
+       .description = "dpm_external_storage",
+       .handler = test_dpm_usb_mass_storage
+};
+
+struct testcase storagetestcase_wipe = {
+       .description = "dpm_wipe",
+       .handler = test_dpm_wipe
+};
+
+void TESTCASE_CONSTRUCTOR storage_policy_build_testcase(void)
+{
+
+       testbench_populate_testcase(&storage_testcase_usb_mass_storage);
+       //testbench_populate_testcase(&storage_testcase_wipe);
+}
index e104637..761b8f1 100644 (file)
 
 static int zone_create(struct testcase* tc)
 {
-    dpm_client_h handle;
-
-    handle = dpm_create_client();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
+    int ret;
+    dpm_context_h context;
+    dpm_zone_policy_h policy;
+    dpm_zone_state_e state;
+
+    context = dpm_context_create();
+    if (context == NULL) {
+        printf("Failed to create client context\n");
         return TEST_FAILED;
     }
 
-    if (dpm_create_zone(handle, TEST_ZONE_ID, TEST_SETUP_WIZARD_PKG_ID) == 0) {
-        dpm_destroy_client(handle);
-        return TEST_SUCCESSED;
-    }
-
-    dpm_destroy_client(handle);
-    return TEST_FAILED;
-}
-
-static int zone_remove(struct testcase* tc)
-{
-    dpm_client_h handle;
-
-    handle = dpm_create_client();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
+    policy = dpm_context_acquire_zone_policy(context);
+    if (policy == NULL) {
+        printf("Failed to get zone policy");
+        dpm_context_destroy(context);
         return TEST_FAILED;
     }
 
-    if (dpm_remove_zone(handle, TEST_ZONE_ID) == 0) {
-        dpm_destroy_client(handle);
-        return TEST_SUCCESSED;
-    }
-
-    dpm_destroy_client(handle);
-    return TEST_FAILED;
-}
-
-static int zone_get_state(struct testcase* tc)
-{
-    dpm_client_h handle;
-
-    handle = dpm_create_client();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
+    ret = TEST_SUCCESSED;
+    if (dpm_zone_create(policy, TEST_ZONE_ID, TEST_SETUP_WIZARD_PKG_ID) != DPM_ERROR_NONE) {
+        ret = TEST_FAILED;
+        goto out;
     }
 
-    if (dpm_get_zone_state(handle, TEST_ZONE_ID) != DPM_ERROR_INVALID_PARAMETER) {
-        dpm_destroy_client(handle);
-        return TEST_SUCCESSED;
+    if (dpm_zone_get_state(policy, TEST_ZONE_ID, &state) != DPM_ERROR_NONE) {
+        ret = TEST_FAILED;
+        goto remove;
     }
 
-    dpm_destroy_client(handle);
-    return TEST_FAILED;
-}
-
-static int zone_get_list(struct testcase* tc)
-{
-    dpm_client_h handle;
-    dpm_zone_iterator_h it;
-
-    handle = dpm_create_client();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
+remove:
+    if (dpm_zone_destroy(policy, TEST_ZONE_ID) == DPM_ERROR_NONE) {
+        ret = TEST_FAILED;
+        goto out;
     }
 
-    it = dpm_get_zone_iterator(handle);
-
-    dpm_destroy_client(handle);
-
-    if (it != NULL) {
-        dpm_free_zone_iterator(it);
-        return TEST_SUCCESSED;
-    }
+out:
+    dpm_context_release_zone_policy(context, policy);
+    dpm_context_destroy(context);
 
-    return TEST_FAILED;
+    return ret;
 }
 
-static int zone_traverse_list(struct testcase* tc)
-{
-    dpm_client_h handle;
-    dpm_zone_iterator_h it;
-    const char* zone;
-
-    handle = dpm_create_client();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    it = dpm_get_zone_iterator(handle);
-
-    dpm_destroy_client(handle);
-
-    if (it != NULL) {
-        printf("Traversing zone list started\n");
-        while ((zone = dpm_zone_iterator_next(it)) != NULL) {
-            printf("%s\n", zone);
-            if (!strcmp(zone, TEST_ZONE_ID)) {
-                printf("%s is found!\n", TEST_ZONE_ID);
-                break;
-            }
-        }
-        printf("Traversing zone list was completed\n");
-
-        dpm_free_zone_iterator(it);
-
-        if (zone != NULL) {
-            return TEST_SUCCESSED;
-        } else {
-            return TEST_FAILED;
-        }
-    }
-
-    return TEST_FAILED;
-}
-
-static int zone_signal(struct testcase* tc)
-{
-    dpm_client_h handle;
-
-    handle = dpm_create_client();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    dpm_destroy_client(handle);
-
-    return TEST_FAILED;
-}
-
-struct testcase zone_testcase_create = {
-    .description = "dpm_zone_create",
+struct testcase zone_testcase_lifecycle = {
+    .description = "dpm_zone",
     .handler = zone_create
 };
 
-struct testcase zone_testcase_remove = {
-    .description = "dpm_zone_remove",
-    .handler = zone_remove
-};
-
-struct testcase zone_testcase_get_state = {
-    .description = "dpm_get_zone_state",
-    .handler = zone_get_state
-};
-
-struct testcase zone_testcase_get_list = {
-    .description = "dpm_get_zone_iterator, dpm_free_zone_iterator",
-    .handler = zone_get_list
-};
-
-struct testcase zone_testcase_traverse_list = {
-    .description = "dpm_zone_iterator_next",
-    .handler = zone_traverse_list
-};
-
-struct testcase zone_testcase_signal = {
-    .description = "dpm_subscribe_zone_signal, dpm_unsubscribe_zone_signal",
-    .handler = zone_signal
-};
-
-
 void TESTCASE_CONSTRUCTOR zone_policy_build_testcase(void)
 {
-    testbench_populate_testcase(&zone_testcase_signal);
-    testbench_populate_testcase(&zone_testcase_remove);
-    testbench_populate_testcase(&zone_testcase_traverse_list);
-    testbench_populate_testcase(&zone_testcase_get_list);
-    testbench_populate_testcase(&zone_testcase_get_state);
-    testbench_populate_testcase(&zone_testcase_create);
+    testbench_populate_testcase(&zone_testcase_lifecycle);
 }
-
index 43b4a49..168eec5 100755 (executable)
 SET(INTEGRATION_TEST_TARGET    "dpm-integration-tests")
 
 SET(INTEGRATION_TEST_SOURCES main.cpp
-                                                        administration.cpp
-                                                        application.cpp
-                                                        security.cpp
-                                                        zone.cpp
-                                                        misc.cpp
-                                                        restriction.cpp
+#                                                       administration.cpp
+#                                                       application.cpp
                                                         bluetooth.cpp
+#                                                       misc.cpp
+#                                                       restriction.cpp
+#                                                       security.cpp
+#                                                       zone.cpp
                                                         ${DPM_LIBS}/policy-client.cpp
-                                                        ${DPM_LIBS}/application.cpp
-                                                        ${DPM_LIBS}/administration.cpp
-                                                        ${DPM_LIBS}/security.cpp
-                                                        ${DPM_LIBS}/zone.cpp
-                                                        ${DPM_LIBS}/misc.cpp
-                                                        ${DPM_LIBS}/restriction.cpp
+#                                                       ${DPM_LIBS}/administration.cpp
+#                                                       ${DPM_LIBS}/application.cpp
                                                         ${DPM_LIBS}/bluetooth.cpp
+#                                                       ${DPM_LIBS}/misc.cpp
+#                                                       ${DPM_LIBS}/restriction.cpp
+#                                                       ${DPM_LIBS}/security.cpp
+#                                                       ${DPM_LIBS}/wifi.cpp
+#                                                       ${DPM_LIBS}/zone.cpp
                                                         ${DPM_TESTBENCH}/testbench.cpp
 )
 
index 74aad5b..031adb0 100644 (file)
@@ -26,14 +26,14 @@ const char* pkgName = "dpm_test_admin_client";
 
 }; //namespace
 
-TESTCASE(AdministrationInterfaceTest)
+TESTCASE(AdministrationPolicyInterfaceTest)
 {
-    DevicePolicyClient client;
+    TEST_EXPECT(0, context.connect());
 
-    TEST_EXPECT(0, client.connect());
+    DevicePolicyManager::AdministrationPolicy* admin = context.createPolicyInterface<DevicePolicyManager::AdministrationPolicy>();
 
-    DevicePolicyManager::Administration admin = client.createPolicyInterface<DevicePolicyManager::Administration>();
+    admin->registerPolicyClient(pkgName));
+    admin->deregisterPolicyClient(pkgName));
 
-    TEST_EXPECT(0, admin.registerPolicyClient(pkgName));
-    TEST_EXPECT(0, admin.deregisterPolicyClient(pkgName));
+    delete admin;
 }
index eedfa87..f9039d2 100644 (file)
@@ -27,27 +27,24 @@ const std::string TestAppId = "org.tizen.music-player";
 
 TESTCASE(AppInfoTest)
 {
-    DevicePolicyClient client;
-    std::cout << "Begin connection" << std::endl;
-    TEST_EXPECT(0, client.connect());
+    DevicePolicyContext context;
+    TEST_EXPECT(0, context.connect());
 
-    std::cout << "End connection" << std::endl;
-    DevicePolicyManager::Application app = client.createPolicyInterface<DevicePolicyManager::Application>();
+    DevicePolicyManager::ApplicationPolicy* app = client.createPolicyInterface<DevicePolicyManager::ApplicationPolicy>();
 
-    bool ret = app.isApplicationInstalled(TestAppId);
-    TEST_EXPECT(true, ret);
+    app->isApplicationPolicyInstalled(TestAppId);
+    app->isApplicationPolicyInstalled("unknown-application");
 
-    ret = app.isApplicationInstalled("unknown-application");
-    TEST_EXPECT(false, ret);
+    delete app;
 }
 
 TESTCASE(PkgInfoTest)
 {
-    DevicePolicyClient client;
+    DevicePolicyContext client;
 
     TEST_EXPECT(0, client.connect());
 
-    DevicePolicyManager::Application app = client.createPolicyInterface<DevicePolicyManager::Application>();
+    DevicePolicyManager::ApplicationPolicy app = client.createPolicyInterface<DevicePolicyManager::ApplicationPolicy>();
 
     bool ret = app.isPackageInstalled(TestAppId);
     TEST_EXPECT(true, ret);
@@ -64,56 +61,56 @@ TESTCASE(PkgInfoTest)
 
 TESTCASE(AppRunStateTest)
 {
-    DevicePolicyClient client;
+    DevicePolicyContext client;
 
     TEST_EXPECT(0, client.connect());
 
-    DevicePolicyManager::Application app = client.createPolicyInterface<DevicePolicyManager::Application>();
+    DevicePolicyManager::ApplicationPolicy app = client.createPolicyInterface<DevicePolicyManager::ApplicationPolicy>();
 
-    int ret = app.startApplication(TestAppId);
+    int ret = app.startApplicationPolicy(TestAppId);
     TEST_EXPECT(0, ret);
 
-    ret = app.isApplicationRunning(TestAppId);
+    ret = app.isApplicationPolicyRunning(TestAppId);
     TEST_EXPECT(true, ret);
 
-    ret = app.isApplicationRunning("unknown-application");
+    ret = app.isApplicationPolicyRunning("unknown-application");
     TEST_EXPECT(false, ret);
 }
 
 TESTCASE(AppActivationTest)
 {
-    DevicePolicyClient client;
+    DevicePolicyContext client;
 
     TEST_EXPECT(0, client.connect());
 
-    DevicePolicyManager::Application app = client.createPolicyInterface<DevicePolicyManager::Application>();
+    DevicePolicyManager::ApplicationPolicy app = client.createPolicyInterface<DevicePolicyManager::ApplicationPolicy>();
 
-    int ret = app.disableApplication(TestAppId);
+    int ret = app.disableApplicationPolicy(TestAppId);
     TEST_EXPECT(0, ret);
 }
 
 TESTCASE(AppStartTest)
 {
-    DevicePolicyClient client;
+    DevicePolicyContext client;
 
     TEST_EXPECT(0, client.connect());
 
-    DevicePolicyManager::Application app = client.createPolicyInterface<DevicePolicyManager::Application>();
+    DevicePolicyManager::ApplicationPolicy app = client.createPolicyInterface<DevicePolicyManager::ApplicationPolicy>();
 
-    int ret = app.startApplication(TestAppId);
+    int ret = app.startApplicationPolicy(TestAppId);
     TEST_EXPECT(0, ret);
     sleep(3);
-    ret = app.stopApplication(TestAppId);
+    ret = app.stopApplicationPolicy(TestAppId);
     TEST_EXPECT(0, ret);
 }
 
 TESTCASE(BlacklistTest)
 {
-    DevicePolicyClient client;
+    DevicePolicyContext client;
 
     TEST_EXPECT(0, client.connect());
 
-    DevicePolicyManager::Application app = client.createPolicyInterface<DevicePolicyManager::Application>();
+    DevicePolicyManager::ApplicationPolicy app = client.createPolicyInterface<DevicePolicyManager::ApplicationPolicy>();
 
     int ret = app.addPackageToBlacklist("org.tizen.ode");
     std::cout << "Add org.tizen.ode to blacklist: " << ret << std::endl;
index 5c4c8ce..1222c84 100644 (file)
 
 TESTCASE(DeviceRestriction)
 {
-    DevicePolicyClient client;
+    DevicePolicyContext client;
     int error = -1;
     bool status = false;
 
     TEST_EXPECT(0, client.connect());
 
-    DevicePolicyManager::Bluetooth bluetooth = client.createPolicyInterface<DevicePolicyManager::Bluetooth>();
+    DevicePolicyManager::BluetoothPolicy *bluetooth = client.createPolicyInterface<DevicePolicyManager::BluetoothPolicy>();
 
-    error = bluetooth.setDeviceRestriction(true);
+    error = bluetooth->setDeviceRestriction(true);
     TEST_EXPECT(0, error);
 
-    status = bluetooth.isDeviceRestricted();
+    status = bluetooth->isDeviceRestricted();
+    // the 'status' will be always 'false' before server/bluetooth.cpp has been implemented.
     TEST_EXPECT(true, status);
 
-    error = bluetooth.setDeviceRestriction(false);
+    error = bluetooth->setDeviceRestriction(false);
     TEST_EXPECT(0, error);
 
-    // the 'status' will be always 'true' before server/bluetooth.cpp has been implemented.
-    status = bluetooth.isDeviceRestricted();
+    status = bluetooth->isDeviceRestricted();
     TEST_EXPECT(false, status);
 }
 
 TESTCASE(UuidRestriction)
 {
-    DevicePolicyClient client;
+    DevicePolicyContext client;
     int error = -1;
     bool status = false;
 
     TEST_EXPECT(0, client.connect());
 
-    DevicePolicyManager::Bluetooth bluetooth = client.createPolicyInterface<DevicePolicyManager::Bluetooth>();
+    DevicePolicyManager::BluetoothPolicy *bluetooth = client.createPolicyInterface<DevicePolicyManager::BluetoothPolicy>();
 
-    error = bluetooth.setUuidRestriction(true);
+    error = bluetooth->setUuidRestriction(true);
     TEST_EXPECT(0, error);
 
-    status = bluetooth.isUuidRestricted();
+    status = bluetooth->isUuidRestricted();
+    // the 'status' will be always 'false' before server/bluetooth.cpp has been implemented.
     TEST_EXPECT(true, status);
 
-    error = bluetooth.setUuidRestriction(false);
+    error = bluetooth->setUuidRestriction(false);
     TEST_EXPECT(0, error);
 
-    // the 'status' will be always 'true' before server/bluetooth.cpp has been implemented.
-    status = bluetooth.isUuidRestricted();
+    status = bluetooth->isUuidRestricted();
     TEST_EXPECT(false, status);
 }
index 10046eb..741ee91 100644 (file)
@@ -21,7 +21,7 @@
 
 TESTCASE(CameraTest)
 {
-       DevicePolicyClient client;
+       DevicePolicyContext client;
        int error = -1;
        bool status = false;
 
@@ -38,7 +38,7 @@ TESTCASE(CameraTest)
 
 TESTCASE(MicrophoneTest)
 {
-       DevicePolicyClient client;
+       DevicePolicyContext client;
        int error = -1;
        bool status = false;
 
@@ -55,7 +55,7 @@ TESTCASE(MicrophoneTest)
 
 TESTCASE(LocationTest)
 {
-       DevicePolicyClient client;
+       DevicePolicyContext client;
        int error = -1;
        bool status = false;
 
@@ -72,7 +72,7 @@ TESTCASE(LocationTest)
 
 TESTCASE(SDCardTest)
 {
-       DevicePolicyClient client;
+       DevicePolicyContext client;
        int error = -1;
        bool status = false;
 
index 5ddd556..ef322b7 100644 (file)
@@ -22,7 +22,7 @@
 
 TESTCASE(ClipboardTest)
 {
-       DevicePolicyClient client;
+       DevicePolicyContext client;
        int error = -1;
        bool status = false;
 
@@ -41,23 +41,11 @@ TESTCASE(ClipboardTest)
 
        status = restriction.isClipboardRestricted();
        TEST_EXPECT(false, status);
-
-       error = restriction.setClipboardShareRestriction(true);
-       TEST_EXPECT(0, error);
-
-       status = restriction.isClipboardShareRestricted();
-       TEST_EXPECT(true, status);
-
-       error = restriction.setClipboardShareRestriction(false);
-       TEST_EXPECT(0, error);
-
-       status = restriction.isClipboardShareRestricted();
-       TEST_EXPECT(false, status);
 }
 
 TESTCASE(SettingsChangesTest)
 {
-       DevicePolicyClient client;
+       DevicePolicyContext client;
        int error = -1;
        bool status = false;
 
@@ -78,32 +66,9 @@ TESTCASE(SettingsChangesTest)
        TEST_EXPECT(false, status);
 }
 
-TESTCASE(SettingsBackgroundData)
-{
-       DevicePolicyClient client;
-       int error = -1;
-       bool status = false;
-
-       TEST_EXPECT(0, client.connect());
-
-       DevicePolicyManager::Restriction restriction = client.createPolicyInterface<DevicePolicyManager::Restriction>();
-
-       error = restriction.setBackgroundDataRestriction(true);
-       TEST_EXPECT(0, error);
-
-       status = restriction.isBackgroundDataRestricted();
-       TEST_EXPECT(true, status);
-
-       error = restriction.setBackgroundDataRestriction(false);
-       TEST_EXPECT(0, error);
-
-       status = restriction.isBackgroundDataRestricted();
-       TEST_EXPECT(false, status);
-}
-
 TESTCASE(UsbDebuggingTest)
 {
-       DevicePolicyClient client;
+       DevicePolicyContext client;
        int error = -1;
        bool status = false;
 
@@ -123,26 +88,17 @@ TESTCASE(UsbDebuggingTest)
        status = restriction.isUsbDebuggingRestricted();
        TEST_EXPECT(false, status);
 }
-
-TESTCASE(FactoryResetTest)
+/*
+TESTCASE(WipeData)
 {
-       DevicePolicyClient client;
+       DevicePolicyContext client;
        int error = -1;
-       bool status = false;
 
        TEST_EXPECT(0, client.connect());
 
        DevicePolicyManager::Restriction restriction = client.createPolicyInterface<DevicePolicyManager::Restriction>();
 
-       error = restriction.setFactoryResetRestriction(true);
-       TEST_EXPECT(0, error);
-
-       status = restriction.isFactoryResetRestricted();
-       TEST_EXPECT(true, status);
-
-       error = restriction.setFactoryResetRestriction(false);
+       error = restriction.wipeData(true);
        TEST_EXPECT(0, error);
-
-       status = restriction.isFactoryResetRestricted();
-       TEST_EXPECT(false, status);
 }
+*/
\ No newline at end of file
index ac52ba3..cadedb4 100644 (file)
 
 TESTCASE(ScreenLockTest)
 {
-    DevicePolicyClient client;
+    DevicePolicyContext client;
 
     TEST_EXPECT(0, client.connect());
 
-    DevicePolicyManager::Security security = client.createPolicyInterface<DevicePolicyManager::Security>();
+    DevicePolicyManager::SecurityPolicy security = client.createPolicyInterface<DevicePolicyManager::SecurityPolicy>();
 
     int error = security.lockoutScreen();
     TEST_EXPECT(0, error);
@@ -34,11 +34,11 @@ TESTCASE(ScreenLockTest)
 
 TESTCASE(InternalMemoryEncryptionTest)
 {
-    DevicePolicyClient client;
+    DevicePolicyContext client;
 
     TEST_EXPECT(0, client.connect());
 
-    DevicePolicyManager::Security security = client.createPolicyInterface<DevicePolicyManager::Security>();
+    DevicePolicyManager::SecurityPolicy security = client.createPolicyInterface<DevicePolicyManager::SecurityPolicy>();
 
     int error = security.setInternalStorageEncryption(true);
     TEST_EXPECT(0, error);
@@ -46,11 +46,11 @@ TESTCASE(InternalMemoryEncryptionTest)
 
 TESTCASE(ExternalMemoryEncryptionTest)
 {
-    DevicePolicyClient client;
+    DevicePolicyContext client;
 
     TEST_EXPECT(0, client.connect());
 
-    DevicePolicyManager::Security security = client.createPolicyInterface<DevicePolicyManager::Security>();
+    DevicePolicyManager::SecurityPolicy security = client.createPolicyInterface<DevicePolicyManager::SecurityPolicy>();
 
     int error = security.setExternalStorageEncryption(true);
     TEST_EXPECT(0, error);
@@ -58,35 +58,35 @@ TESTCASE(ExternalMemoryEncryptionTest)
 
 TESTCASE(DeviceWipeTest)
 {
-    DevicePolicyClient client;
+    DevicePolicyContext client;
 
     TEST_EXPECT(0, client.connect());
 
-    DevicePolicyManager::Security security = client.createPolicyInterface<DevicePolicyManager::Security>();
+    DevicePolicyManager::SecurityPolicy security = client.createPolicyInterface<DevicePolicyManager::SecurityPolicy>();
 
-    int error = security.wipeData(DevicePolicyManager::Security::WIPE_INTERNAL_MEMORY);
+    int error = security.wipeData(DevicePolicyManager::SecurityPolicy::WIPE_INTERNAL_STORAGE);
     TEST_EXPECT(0, error);
 }
 
 TESTCASE(ExternalMemoryWipeTest)
 {
-    DevicePolicyClient client;
+    DevicePolicyContext client;
 
     TEST_EXPECT(0, client.connect());
 
-    DevicePolicyManager::Security security = client.createPolicyInterface<DevicePolicyManager::Security>();
+    DevicePolicyManager::SecurityPolicy security = client.createPolicyInterface<DevicePolicyManager::SecurityPolicy>();
 
-    int error = security.wipeData(DevicePolicyManager::Security::WIPE_EXTERNAL_MEMORY);
+    int error = security.wipeData(DevicePolicyManager::SecurityPolicy::WIPE_EXTERNAL_STORAGE);
     TEST_EXPECT(0, error);
 }
 
 TESTCASE(EmptyDirectoryIterationTest)
 {
-    DevicePolicyClient client;
+    DevicePolicyContext client;
 
     TEST_EXPECT(0, client.connect());
 
-    DevicePolicyManager::Security security = client.createPolicyInterface<DevicePolicyManager::Security>();
+    DevicePolicyManager::SecurityPolicy security = client.createPolicyInterface<DevicePolicyManager::SecurityPolicy>();
 
     std::vector<std::string> files = security.getFileNamesOnDevice("/etc");
     TEST_EXPECT(true, files.empty());
@@ -97,11 +97,11 @@ TESTCASE(EmptyDirectoryIterationTest)
 
 TESTCASE(NonemptyDirectoryIterationTest)
 {
-    DevicePolicyClient client;
+    DevicePolicyContext client;
 
     TEST_EXPECT(0, client.connect());
 
-    DevicePolicyManager::Security security = client.createPolicyInterface<DevicePolicyManager::Security>();
+    DevicePolicyManager::SecurityPolicy security = client.createPolicyInterface<DevicePolicyManager::SecurityPolicy>();
 
     std::vector<std::string> files = security.getFileNamesOnDevice("/etc");
     TEST_EXPECT(false, files.empty());
@@ -112,11 +112,11 @@ TESTCASE(NonemptyDirectoryIterationTest)
 
 TESTCASE(InvalidDirectoryIterationTest)
 {
-    DevicePolicyClient client;
+    DevicePolicyContext client;
 
     TEST_EXPECT(0, client.connect());
 
-    DevicePolicyManager::Security security = client.createPolicyInterface<DevicePolicyManager::Security>();
+    DevicePolicyManager::SecurityPolicy security = client.createPolicyInterface<DevicePolicyManager::SecurityPolicy>();
 
     std::vector<std::string> files = security.getFileNamesOnDevice("/invalid");
     TEST_EXPECT(true, files.empty());
index e946d8a..05861d2 100644 (file)
 #include "testbench/testbench.h"
 
 const std::string testSetupWizardAppid = "org.tizen.zone-setup-wizard";
-const std::string testZoneName = "zone1";
+const std::string testZonePolicyName = "zone1";
 
-TESTCASE(ZoneCreateTest)
+TESTCASE(ZonePolicyCreateTest)
 {
-    DevicePolicyClient client;
+    DevicePolicyContext client;
 
     if (getuid() == 0) {
         TEST_FAIL("this test should be done as non-root user");
@@ -35,24 +35,24 @@ TESTCASE(ZoneCreateTest)
 
     TEST_EXPECT(0, client.connect());
 
-    DevicePolicyManager::Zone zone = client.createPolicyInterface<DevicePolicyManager::Zone>();
+    DevicePolicyManager::ZonePolicy zone = client.createPolicyInterface<DevicePolicyManager::ZonePolicy>();
 
-    int error = zone.createZone(testZoneName, testSetupWizardAppid);
+    int error = zone.createZonePolicy(testZonePolicyName, testSetupWizardAppid);
     TEST_EXPECT(0, error);
 }
 
-TESTCASE(GetZoneListTest)
+TESTCASE(GetZonePolicyListTest)
 {
-    DevicePolicyClient client;
+    DevicePolicyContext client;
 
     TEST_EXPECT(0, client.connect());
 
-    DevicePolicyManager::Zone zone = client.createPolicyInterface<DevicePolicyManager::Zone>();
+    DevicePolicyManager::ZonePolicy zone = client.createPolicyInterface<DevicePolicyManager::ZonePolicy>();
 
-    std::vector<std::string> list = zone.getZoneList();
+    std::vector<std::string> list = zone.getZonePolicyList();
 
     for (std::string &word : list) {
-        if (word == testZoneName) {
+        if (word == testZonePolicyName) {
             return;
         }
     }
@@ -60,27 +60,27 @@ TESTCASE(GetZoneListTest)
     TEST_FAIL("list doesn't contain the created zone name");
 }
 
-TESTCASE(GetZoneStateTest)
+TESTCASE(GetZonePolicyStateTest)
 {
-    DevicePolicyClient client;
+    DevicePolicyContext client;
 
     TEST_EXPECT(0, client.connect());
 
-    DevicePolicyManager::Zone zone = client.createPolicyInterface<DevicePolicyManager::Zone>();
+    DevicePolicyManager::ZonePolicy zone = client.createPolicyInterface<DevicePolicyManager::ZonePolicy>();
 
-    zone.getZoneState(testZoneName);
+    zone.getZonePolicyState(testZonePolicyName);
 
     //TODO : should implement checking if the zone exists
 }
 
-TESTCASE(ZoneRemoveTest)
+TESTCASE(ZonePolicyRemoveTest)
 {
-    DevicePolicyClient client;
+    DevicePolicyContext client;
 
     TEST_EXPECT(0, client.connect());
 
-    DevicePolicyManager::Zone zone = client.createPolicyInterface<DevicePolicyManager::Zone>();
+    DevicePolicyManager::ZonePolicy zone = client.createPolicyInterface<DevicePolicyManager::ZonePolicy>();
 
-    int error = zone.removeZone(testZoneName);
+    int error = zone.removeZonePolicy(testZonePolicyName);
     TEST_EXPECT(0, error);
 }
index ace39c0..1033e78 100644 (file)
@@ -112,18 +112,22 @@ private:
 
 class TestClient {
 public:
-    TestClient()
+    TestClient() :
+        signalTriggered(false),
+        policyChangeNotificationTriggered(false)
     {
     }
 
     void connect()
     {
-        auto policyChangedListener = [](const std::string& name, int value) {
+        auto policyChangedListener = [this](const std::string& name, int value) {
             std::cout << "Policy Changed: " << name << " : " << value << std::endl;
+            policyChangeNotificationTriggered = true;
         };
 
-        auto policySignalListener = [](const std::string& name) {
+        auto policySignalListener = [this](const std::string& name) {
             std::cout << "Signal Triggered" << std::endl;
+            signalTriggered = true;
         };
 
         client.reset(new rmi::Client(IPC_TEST_ADDRESS));
index 10e1790..98e1f16 100644 (file)
@@ -27,7 +27,7 @@
 
 extern char** environ;
 
-static inline void usage(const std::string name)
+static void usage(const std::string name)
 {
     std::cout << "Usage: " << name << " [OPTIONS]" << std::endl
               << "Manage the zones" << std::endl
@@ -67,12 +67,19 @@ int main(int argc, char* argv[])
         return EXIT_FAILURE;
     }
 
-    dpm_client_h handle = dpm_create_client();
-    if (handle == NULL) {
+    dpm_context_h context = dpm_context_create();
+    if (context == NULL) {
         std::cerr << "Failed to create client handle" << std::endl;
         return EXIT_FAILURE;
     }
 
+    dpm_zone_policy_h policy = dpm_context_acquire_zone_policy(context);
+    if (policy == NULL) {
+        std::cerr << "Failed to create zone policy handle" << std::endl;
+        dpm_context_destroy(context);
+        return EXIT_FAILURE;
+    }
+
     while (opt != -1) {
         opt = getopt_long(argc, argv, "c:w:d:s:lh", options, &index);
         switch (opt) {
@@ -83,7 +90,7 @@ int main(int argc, char* argv[])
             wizard = optarg;
             break;
         case 'd':
-            ret = dpm_remove_zone(handle, optarg);
+            ret = dpm_zone_destroy(policy, optarg);
             if (ret != 0) {
                 std::cerr << optarg << " can't be destroyed." << std::endl;
             } else {
@@ -91,8 +98,9 @@ int main(int argc, char* argv[])
             }
             break;
         case 's':
-            ret = dpm_get_zone_state(handle, optarg);
-            std::cout << optarg << " state is " << ret << "." << std::endl;
+            dpm_zone_state_e state;
+            ret = dpm_zone_get_state(policy, optarg, &state);
+            std::cout << optarg << " state is " << state << "." << std::endl;
             break;
         case 'l':
             break;
@@ -103,7 +111,7 @@ int main(int argc, char* argv[])
     }
 
     if (create.size() > 0 && wizard.size() > 0) {
-        ret = dpm_create_zone(handle, create.c_str(), wizard.c_str());
+        ret = dpm_zone_create(policy, create.c_str(), wizard.c_str());
         if (ret != 0) {
             std::cerr << create << " can't be created."<< std::endl;
         } else {
@@ -116,7 +124,9 @@ int main(int argc, char* argv[])
                   << "  ex) --wizard org.tizen.zone-setup-wizard" << std::endl;
     }
 
-    dpm_destroy_client(handle);
+    dpm_context_release_zone_policy(context, policy);
+
+    dpm_context_destroy(context);
 
     return EXIT_SUCCESS;
 }
index c3e34d1..1ef0bb1 100644 (file)
@@ -50,7 +50,7 @@ typedef enum {
 typedef struct {
        char *zone_name;
        char *provision_path;
-       dpm_client_h dpm_client;
+       dpm_context_h dpm_client;
        int dpm_zone_signal_cb_id;
        bool create_done;
 } appdata_s;
index a2b43d3..bde6443 100644 (file)
@@ -44,8 +44,8 @@ static void __app_terminate(void *data)
 {
        appdata_s *ad = (appdata_s *) data;
 
-       dpm_unsubscribe_zone_signal(ad->dpm_client, ad->dpm_zone_signal_cb_id);
-       dpm_destroy_client(ad->dpm_client);
+       dpm_context_remove_signal_cb(ad->dpm_client, ad->dpm_zone_signal_cb_id);
+       dpm_context_destroy(ad->dpm_client);
        ad->dpm_client = NULL;
        return ;
 }
@@ -53,7 +53,7 @@ static void __app_terminate(void *data)
 static void __app_control(app_control_h app_control, void *data)
 {
        appdata_s *ad = (appdata_s *) data;
-       int ret = 0;
+       int id, ret = 0;
 
        ret = app_control_get_extra_data(app_control, "Name", &ad->zone_name);
        if (ret != APP_CONTROL_ERROR_NONE) {
@@ -67,19 +67,19 @@ static void __app_control(app_control_h app_control, void *data)
                ui_app_exit();
        }
 
-       ad->dpm_client = dpm_create_client();
+       ad->dpm_client = dpm_context_create();
        if (ad->dpm_client == NULL) {
                dlog_print(DLOG_ERROR, LOG_TAG, "failed to get dpm client");
                ui_app_exit();
        }
 
-        ad->dpm_zone_signal_cb_id = dpm_subscribe_zone_signal(ad->dpm_client, "created", __create_zone_done, ad);
-
-       if (ad-> dpm_zone_signal_cb_id < 0) {
-               dlog_print(DLOG_ERROR, LOG_TAG, "failed to set signal callback");
+       if (dpm_context_add_signal_cb(ad->dpm_client, "ZonePolicy::created", __create_zone_done, ad, &id) != DPM_ERROR_NONE) {
+               dlog_print(DLOG_ERROR, LOG_TAG, "Failed to add zone signal callback");
                ui_app_exit();
        }
 
+       ad->dpm_zone_signal_cb_id = id;
+
        elm_app_base_scale_set(1.8);
        _create_base_window(ad);