Add capi for device policy admin client registration/deregistration 14/66114/2
authorJaemin Ryu <jm77.ryu@samsung.com>
Fri, 15 Apr 2016 08:32:05 +0000 (17:32 +0900)
committerJaemin Ryu <jm77.ryu@samsung.com>
Fri, 15 Apr 2016 09:07:32 +0000 (18:07 +0900)
Change-Id: I780fc2e261b7b63949db6df6702bcee6c4774774
Signed-off-by: Jaemin Ryu <jm77.ryu@samsung.com>
libs/CMakeLists.txt
libs/dpm/administration.cpp [new file with mode: 0644]
libs/dpm/administration.h [new file with mode: 0644]

index 5ce8197..33eb4b7 100755 (executable)
@@ -43,6 +43,7 @@ SET(SOURCES policy-client.cpp
 
 SET(CAPI_INCLUDE_FILES  dpm/dpm.h
                                                dpm/device-policy-client.h
+                                               dpm/administration.h
                                                dpm/application.h
                                                dpm/security.h
                                                dpm/password.h
diff --git a/libs/dpm/administration.cpp b/libs/dpm/administration.cpp
new file mode 100644 (file)
index 0000000..b24324a
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ *  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 <cstring>
+
+#include "administration.h"
+#include "administration.hxx"
+
+#include "capi-assert.h"
+#include "policy-client.h"
+
+using namespace DevicePolicyManager;
+
+int dpm_register_client(dpm_client_h handle, const char* name)
+{
+    DevicePolicyClient &client = GetDevicePolicyClient(handle);
+    Administration admin = client.createPolicyInterface<Administration>();
+    return admin.registerPolicyClient(name);
+}
+
+int dpm_deregister_client(dpm_client_h handle, const char* name)
+{
+    DevicePolicyClient &client = GetDevicePolicyClient(handle);
+    Administration admin = client.createPolicyInterface<Administration>();
+    return admin.deregisterPolicyClient(name);
+}
diff --git a/libs/dpm/administration.h b/libs/dpm/administration.h
new file mode 100644 (file)
index 0000000..6e8888b
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ *  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_ADMINISTRATION_POLICY_H__
+#define __CAPI_ADMINISTRATION_POLICY_H__
+
+#include <dpm/device-policy-client.h>
+
+/**
+ * @file administration.h
+ * @brief This file provides APIs to register/deregister Device Policy Admin Client
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup  CAPI_DPM_ADMINISTRATION_POLICY_MODULE
+ * @{
+ */
+/**
+ * @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.
+ * @since_tizen 3.0
+ * @privlevel   public
+ * @param[in]   handle Device Policy Client handle
+ * @param[in]   name Device Policy Admin package name
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_TIMEOUT Timeout
+ * @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()
+ */
+DPM_API int dpm_register_client(dpm_client_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
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_TIMEOUT Timeout
+ * @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()
+ */
+DPM_API int dpm_deregister_client(dpm_client_h handle, const char* name);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__CAPI_ADMINISTRATION_POLICY_H__