--- /dev/null
+/*
+ * 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_DPM_ASSERT_H__
+#define __CAPI_DPM_ASSERT_H__
+
+#define RET_ON_FAILURE(cond, ret) \
+ { \
+ if (!(cond)) \
+ return (ret); \
+ }
+
+#endif //! __CAPI_DPM_ASSERT_H__
* limitations under the License
*/
-#include <string.h>
+#include <cstring>
#include "password.h"
-
#include "password.hxx"
+#include "capi-assert.h"
#include "policy-client.h"
using namespace DevicePolicyManager;
{
int ret = 0;
+ RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+
DevicePolicyClient &client = GetDevicePolicyClient(handle);
Password password = client.createPolicyInterface<Password>();
{
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>();
{
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>();
{
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>();
{
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>();
{
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>();
{
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>();
{
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>();
{
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>();
{
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>();
{
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);
+
DevicePolicyClient &client = GetDevicePolicyClient(handle);
Password password = client.createPolicyInterface<Password>();
{
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>();
{
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>();
char *dpm_get_password_pattern(dpm_client_h handle, const char *username)
{
+ RET_ON_FAILURE(handle, NULL);
+ RET_ON_FAILURE(username, NULL);
+
DevicePolicyClient &client = GetDevicePolicyClient(handle);
Password password = client.createPolicyInterface<Password>();
{
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>();
{
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);
+
DevicePolicyClient &client = GetDevicePolicyClient(handle);
Password password = client.createPolicyInterface<Password>();
*p_value = password.getMaximumCharacterOccurrences(username);
{
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>();
{
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);
* limitations under the License
*/
-#include <cassert>
-
+#include "security.h"
#include "security.hxx"
-#include "security.h"
+#include "capi-assert.h"
#include "policy-client.h"
using namespace DevicePolicyManager;
int dpm_lockout_device(dpm_client_h handle)
{
- assert(handle);
+ RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
DevicePolicyClient &client = GetDevicePolicyClient(handle);
Security security = client.createPolicyInterface<Security>();
int dpm_lockout_screen(dpm_client_h handle)
{
- assert(handle);
+ RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
DevicePolicyClient &client = GetDevicePolicyClient(handle);
Security security = client.createPolicyInterface<Security>();
int dpm_wipe_data(dpm_client_h handle, const dpm_wipe_type_e type)
{
- assert(handle);
+ RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
DevicePolicyClient &client = GetDevicePolicyClient(handle);
Security security = client.createPolicyInterface<Security>();
int dpm_reboot(dpm_client_h handle)
{
- assert(handle);
+ RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
DevicePolicyClient &client = GetDevicePolicyClient(handle);
Security security = client.createPolicyInterface<Security>();
int dpm_poweroff_device(dpm_client_h handle)
{
- assert(handle);
+ RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
DevicePolicyClient &client = GetDevicePolicyClient(handle);
Security security = client.createPolicyInterface<Security>();
int dpm_set_internal_storage_encryption(dpm_client_h handle, const int encrypt)
{
- assert(handle);
+ RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
DevicePolicyClient &client = GetDevicePolicyClient(handle);
Security security = client.createPolicyInterface<Security>();
int dpm_is_internal_storage_encrypted(dpm_client_h handle)
{
- assert(handle);
+ RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
DevicePolicyClient &client = GetDevicePolicyClient(handle);
Security security = client.createPolicyInterface<Security>();
int dpm_set_external_storage_encryption(dpm_client_h handle, const int encrypt)
{
- assert(handle);
+ RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
DevicePolicyClient &client = GetDevicePolicyClient(handle);
Security security = client.createPolicyInterface<Security>();
int dpm_is_external_storage_encrypted(dpm_client_h handle)
{
- assert(handle);
+ RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
DevicePolicyClient &client = GetDevicePolicyClient(handle);
Security security = client.createPolicyInterface<Security>();
* limitations under the License
*/
-#include <cassert>
-
-#include "dpm/zone.h"
-
+#include "zone.h"
#include "zone.hxx"
+
#include "array.h"
+#include "capi-assert.h"
#include "policy-client.h"
using namespace DevicePolicyManager;
int dpm_create_zone(dpm_client_h handle, const char* name, const char* pkgid)
{
- assert(handle);
- assert(name);
- assert(pkgid);
+ RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(name, DPM_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(pkgid, DPM_ERROR_INVALID_PARAMETER);
DevicePolicyClient &client = GetDevicePolicyClient(handle);
Zone zone = client.createPolicyInterface<Zone>();
int dpm_remove_zone(dpm_client_h handle, const char* name)
{
- assert(handle);
- assert(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>();
dpm_zone_iterator_h dpm_get_zone_iterator(dpm_client_h handle)
{
- assert(handle);
+ RET_ON_FAILURE(handle, NULL);
DevicePolicyClient &client = GetDevicePolicyClient(handle);
Zone zone = client.createPolicyInterface<Zone>();
const char* dpm_zone_iterator_next(dpm_zone_iterator_h iter)
{
- assert(iter);
+ RET_ON_FAILURE(iter, NULL);
std::string* result = reinterpret_cast<dpm_zone_iterator*>(iter)->next();
- if (result == NULL) {
- return NULL;
- }
+ RET_ON_FAILURE(result, NULL);
return result->c_str();
}
void dpm_free_zone_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)
{
- assert(handle);
- assert(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>();
int dpm_subscribe_zone_signal(dpm_client_h handle, dpm_zone_signal_cb callback, void* user_data)
{
- assert(handle);
- assert(callback);
+ RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(callback, DPM_ERROR_INVALID_PARAMETER);
/* TODO : should implement */
int dpm_unsubscribe_zone_signal(dpm_client_h handle, dpm_zone_signal_cb callback)
{
- assert(handle);
- assert(callback);
+ RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(callback, DPM_ERROR_INVALID_PARAMETER);
/* TODO : should implement */