+++ /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.
-#
-SET(CLI_TOOLKIT_TARGET "dpm-cli-toolkit")
-
-SET(CLI_TOOLKIT_SOURCES main.c
- dpm-cli-toolkit.c
- bluetooth.c
- password.c
- restriction.c
- zone.c
-)
-
-ADD_EXECUTABLE(${CLI_TOOLKIT_TARGET} ${CLI_TOOLKIT_SOURCES})
-
-INCLUDE_DIRECTORIES(SYSTEM ${DPM_LIBS} ${DPM_TOOLS})
-
-TARGET_LINK_LIBRARIES(${CLI_TOOLKIT_TARGET} dpm)
-
-INSTALL(TARGETS ${CLI_TOOLKIT_TARGET} DESTINATION bin)
+++ /dev/null
-#include <stdbool.h>
-
-#include "dpm-cli-toolkit.h"
-#include <dpm/bluetooth.h>
-
-int add_device_to_blacklist_handler(const char *mac_address)
-{
- dpm_context_h context;
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed to create client context\n");
- return -1;
- }
-
- 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 -1;
- }
-
- if (dpm_bluetooth_add_device_to_blacklist(policy, mac_address) < 0) {
- printf("Failed to add MAC Address to blacklist\n");
- dpm_context_release_bluetooth_policy(context, policy);
- dpm_context_destroy(context);
- return -1;
- }
-
- dpm_context_release_bluetooth_policy(context, policy);
- dpm_context_destroy(context);
-
- return 0;
-}
-
-int remove_device_from_blacklist_handler(const char *mac_address)
-{
- dpm_context_h context;
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed to create client context\n");
- return -1;
- }
-
- 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 -1;
- }
-
- if (dpm_bluetooth_remove_device_from_blacklist(policy, mac_address) < 0) {
- printf("Failed to remove MAC address to blacklist\n");
- dpm_context_release_bluetooth_policy(context, policy);
- dpm_context_destroy(context);
- return -1;
- }
-
- dpm_context_release_bluetooth_policy(context, policy);
- dpm_context_destroy(context);
-
- return 0;
-}
-
-int set_device_restriction_handler(const int enable)
-{
- dpm_context_h context;
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed to create client context\n");
- return -1;
- }
-
- 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 -1;
- }
-
- if (dpm_bluetooth_set_device_restriction(policy, enable) < 0) {
- printf("Failed to set device restriction\n");
- dpm_context_release_bluetooth_policy(context, policy);
- dpm_context_destroy(context);
- return -1;
- }
-
- dpm_context_release_bluetooth_policy(context, policy);
- dpm_context_destroy(context);
-
- return 0;
-}
-
-int is_device_restricted_handler(int *enable)
-{
- dpm_context_h context;
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed to create client context\n");
- return -1;
- }
-
- 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 -1;
- }
-
- if (dpm_bluetooth_is_device_restricted(policy, enable) != DPM_ERROR_NONE) {
- printf("Failed to check device restriction\n");
- dpm_context_release_bluetooth_policy(context, policy);
- dpm_context_destroy(context);
- return -1;
- }
-
- dpm_context_release_bluetooth_policy(context, policy);
- dpm_context_destroy(context);
-
- return 0;
-}
-
-int add_uuid_to_blacklist_handler(const char *uuid)
-{
- dpm_context_h context;
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed to create client context");
- return -1;
- }
-
- 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 -1;
- }
-
- if (dpm_bluetooth_add_uuid_to_blacklist(policy, uuid) < 0) {
- printf("Failed to add UUID to blacklist\n");
- dpm_context_release_bluetooth_policy(context, policy);
- dpm_context_destroy(context);
- return -1;
- }
-
- dpm_context_release_bluetooth_policy(context, policy);
- dpm_context_destroy(context);
-
- return 0;
-}
-
-int remove_uuid_from_blacklist_handler(const char *uuid)
-{
- dpm_context_h context;
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed to create client context\n");
- return -1;
- }
-
- 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 -1;
- }
-
- if (dpm_bluetooth_remove_uuid_from_blacklist(policy, uuid) < 0) {
- printf("Failed to remove UUID to blacklist\n");
- dpm_context_release_bluetooth_policy(context, policy);
- dpm_context_destroy(context);
- return -1;
- }
-
- dpm_context_release_bluetooth_policy(context, policy);
- dpm_context_destroy(context);
-
- return 0;
-}
-
-int set_uuid_restriction_handler(const int enable)
-{
- dpm_context_h context;
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed to create client context\n");
- return -1;
- }
-
- 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 -1;
- }
-
- if (dpm_bluetooth_set_uuid_restriction(policy, enable) < 0) {
- printf("Failed to set uuid restriction\n");
- dpm_context_release_bluetooth_policy(context, policy);
- dpm_context_destroy(context);
- return -1;
- }
-
- return 0;
-}
-
-int is_uuid_restricted_handler(int *enable)
-{
- dpm_context_h context;
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed to create client context\n");
- return -1;
- }
-
- 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 -1;
- }
-
- if (dpm_bluetooth_is_uuid_restricted(policy, enable) != DPM_ERROR_NONE) {
- printf("Failed to check uuid restriction\n");
- dpm_context_release_bluetooth_policy(context, policy);
- dpm_context_destroy(context);
- return -1;
- }
-
- dpm_context_release_bluetooth_policy(context, policy);
- dpm_context_destroy(context);
-
- return 0;
-}
+++ /dev/null
-// Copyright (c) 2015 Samsung Electronics Co., Ltd.
-//
-// 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 "dpm-cli-toolkit.h"
-
-void print_menu(int num)
-{
- switch (num) {
- case 0:
- printf("[Password Policy]\n");
- printf("1. Set Password Quality\n");
- printf("2. Set Password Minimum Length\n");
- printf("3. Set Password Minimum Complex Characters\n");
- printf("4. Set Password Maximum number of failed attempts before device is wiped\n");
- printf("5. Set the number of days after which the password expires\n");
- printf("6. Set the number of previous passwords\n");
- printf("7. Set Password Pattern\n");
- printf("8. Reset Password\n");
- printf("9. Enforce Password Change\n");
- printf("10. Set Maximum Inactivity Time Device Lock\n");
- printf("11. Get Maximum Inactivity Time Device Lock\n");
- printf("12. Set Password Status\n");
- printf("13. Delete Password Pattern\n");
- printf("14. Get Password Pattern\n");
- printf("15. Set Maximum Character Occurrences\n");
- printf("16. Get Maximum Character Occurrences\n");
- printf("17. Set Maximum Numeric Sequence Length\n");
- printf("18. Get Maximum Numeric Sequence Length\n");
- break;
- case 1:
- printf("[Security Policy]\n");
- printf("1. Force Lock\n");
- printf("2. Wipe Data\n");
- printf("3. Reboot\n");
- printf("4. Power Off Device\n");
- break;
- case 2:
- printf("[Wifi Policy]\n");
- printf("1. Set Allow WIFI\n");
- printf("2. Get Allow WIFI\n");
- break;
- case 3:
- printf("[Zone Policy]\n");
- printf("1. Create zone\n");
- printf("2. Destroy zone\n");
- printf("3. Get zones list\n");
- printf("4. Get zone state\n");
- break;
- case 4:
- printf("[Bluetooth Policy]\n");
- printf("1. Add device MAC address to blacklist\n");
- printf("2. Remove device MAC address from blacklist\n");
- printf("3. Set device restriction\n");
- printf("4. Check device restriction\n");
- printf("5. Add uuid to blacklist\n");
- printf("6. Remove uuid from blacklist\n");
- printf("7. Set uuid restriction\n");
- printf("8. Check uuid restriction\n");
- printf("9. Set mode change state\n");
- printf("10. Check mode change state\n");
- break;
- default:
- break;
- }
- printf("> ");
-}
-
-void password_policy_handler(void)
-{
- int channel;
- int input_status = 0;
- int ret = -1;
- int value = 0;
- char pattern[100], new_password[100];
- char *get_pattern = NULL;
-
- print_menu(DPM_PASSWORD);
- if (scanf("%d", &channel) < 0) {
- input_status = -1;
- goto out;
- }
-
- switch (channel) {
- case 1:
- printf("[Password Quality]\n");
- printf("1. UNSPECIFIED\n");
- printf("2. SIMPLE_PASSWORD\n");
- printf("3. SOMETHING\n");
- printf("4. NUMERIC\n");
- printf("5. ALPHABETIC\n");
- printf("6. ALPHANUMERIC\n");
- printf("> ");
- if (scanf("%d", &channel) < 0) {
- input_status = -1;
- goto out;
- }
- if (channel < 1 || channel > 6) {
- input_status = -1;
- goto out;
- }
- channel--;
- ret = set_password_quality_handler(channel);
- break;
- case 2:
- printf("minimum length(<=32)> ");
- if (scanf("%d", &channel) < 0) {
- input_status = -1;
- goto out;
- }
- ret = set_password_min_length_handler(channel);
- break;
- case 3:
- printf("minimum complex characters(<=32)> ");
- if (scanf("%d", &channel) < 0) {
- input_status = -1;
- goto out;
- }
- ret = set_password_min_complex_chars_handler(channel);
- break;
- case 4:
- printf("max failed attempts> ");
- if (scanf("%d", &channel) < 0) {
- input_status = -1;
- goto out;
- }
- ret = set_password_max_failed_attempts_for_wipe_handler(channel);
- break;
- case 5:
- printf("day for password expiration> ");
- if (scanf("%d", &channel) < 0) {
- input_status = -1;
- goto out;
- }
- ret = set_password_expires_handler(channel);
- break;
- case 6:
- printf("history> ");
- if (scanf("%d", &channel) < 0) {
- input_status = -1;
- goto out;
- }
- ret = set_password_history_handler(channel);
- break;
- case 7:
- printf("pattern> ");
- if (scanf("%100s", pattern) < 0) {
- input_status = -1;
- goto out;
- }
- ret = set_password_pattern_handler(pattern);
- break;
- case 8:
- printf("new password> ");
- if (scanf("%100s", new_password) < 0) {
- input_status = -1;
- goto out;
- }
- ret = reset_password_handler(new_password);
- break;
- case 9:
- ret = enforce_password_change_handler();
- break;
- case 10:
- printf("max inactivity time> ");
- if (scanf("%d", &channel) < 0) {
- input_status = -1;
- goto out;
- }
- ret = set_max_inactivity_time_device_lock_handler(channel);
- break;
- case 11:
- ret = get_max_inactivity_time_device_lock_handler(&value);
- if (ret == 0)
- printf("max inactivity time: %d\n", value);
- break;
- case 12:
- printf("status> ");
- if (scanf("%d", &channel) < 0) {
- input_status = -1;
- goto out;
- }
- ret = set_password_status_handler(channel);
- break;
- case 13:
- ret = delete_password_pattern_handler();
- break;
- case 14:
- ret = get_password_pattern_handler(&get_pattern);
- if (ret == 0)
- printf("pattern: %s\n", get_pattern);
- break;
- case 15:
- printf("max character occurrences(<=32)> ");
- if (scanf("%d", &channel) < 0) {
- input_status = -1;
- goto out;
- }
- ret = set_max_char_occurrences_handler(channel);
- break;
- case 16:
- ret = get_max_char_occurrences_handler(&value);
- if (ret == 0)
- printf("max character occurrences: %d\n", value);
- break;
- case 17:
- printf("max numeric sequence length(<=32)> ");
- if (scanf("%d", &channel) < 0) {
- input_status = -1;
- goto out;
- }
- ret = set_max_numeric_sequence_length_handler(channel);
- break;
- case 18:
- ret = get_max_numeric_sequence_length_handler(&value);
- if (ret == 0)
- printf("max numeric sequence length: %d\n", value);
- break;
- default:
- printf("Wrong command!\n");
- break;
- }
-
-out:
- if (input_status < 0)
- printf("Input Error!\n");
-
- if (ret < 0)
- printf("password policy operation is failed.\n");
- else
- printf("password policy operation is passed.\n");
-}
-
-void security_policy_handler(void)
-{
- int channel;
- int input_status = 0;
- int ret = -1;
-
- print_menu(DPM_SECURITY);
- if (scanf("%d", &channel) < 0) {
- input_status = -1;
- goto out;
- }
-
- switch (channel) {
- case 1:
- case 2:
- case 3:
- case 4:
- ret = 0;
- printf("TBD\n");
- break;
- default:
- printf("Wrong command!\n");
- break;
- }
-
-out:
- if (input_status < 0)
- printf("Input Error!\n");
-
- if (ret < 0)
- printf("security policy operation is failed.\n");
- else
- printf("security policy operation is passed.\n");
-}
-
-void wifi_policy_handler(void)
-{
- int channel;
- int input_status = 0;
- int ret = -1;
-
- print_menu(DPM_WIFI);
- if (scanf("%d", &channel) < 0) {
- input_status = -1;
- goto out;
- }
-
- switch (channel) {
- case 1:
- case 2:
- ret = 0;
- printf("TBD\n");
- break;
- default:
- printf("Wrong command!\n");
- break;
- }
-
-out:
- if (input_status < 0)
- printf("Input Error!\n");
-
- if (ret < 0)
- printf("wifi policy operation is failed.\n");
- else
- printf("wifi policy operation is passed.\n");
-}
-
-void zone_policy_handler(void)
-{
- int channel;
- int input_status = 0;
- int ret = -1;
- char name[100];
-
- print_menu(DPM_ZONE);
- if (scanf("%d", &channel) < 0) {
- input_status = -1;
- goto out;
- }
-
- switch (channel) {
- case 1:
- printf("zone name> ");
- if (scanf("%100s", name) < 0) {
- input_status = -1;
- goto out;
- }
- ret = create_zone_handler(name);
- break;
- case 2:
- printf("zone name> ");
- if (scanf("%100s", name) < 0) {
- input_status = -1;
- goto out;
- }
- ret = destroy_zone_handler(name);
- break;
- case 3:
- case 4:
- ret = 0;
- printf("TBD\n");
- break;
- default:
- printf("Wrong command!\n");
- break;
- }
-
-out:
- if (input_status < 0)
- printf("Input Error!\n");
-
- if (ret < 0)
- printf("zone policy operation is failed.\n");
- else
- printf("zone policy operation is passed.\n");
-}
-
-void bluetooth_policy_handler(void)
-{
- int channel;
- int input_status = 0;
- int ret = -1, enable = 0;
- char mac_address[100], uuid[100];
-
- print_menu(DPM_BLUETOOTH);
- if (scanf("%d", &channel) < 0) {
- input_status = -1;
- goto out;
- }
-
- switch (channel) {
- case 1:
- printf("mac address> ");
- if (scanf("%100s", mac_address) < 0) {
- input_status = -1;
- goto out;
- }
- ret = add_device_to_blacklist_handler(mac_address);
- break;
- case 2:
- printf("mac address> ");
- if (scanf("%100s", mac_address) < 0) {
- input_status = -1;
- goto out;
- }
- ret = remove_device_from_blacklist_handler(mac_address);
- break;
- case 3:
- printf("enable(1) or disable(0)> ");
- if (scanf("%d", &enable) < 0) {
- input_status = -1;
- goto out;
- }
- if ((enable != 0) && (enable != 1)) {
- input_status = -1;
- goto out;
- }
- ret = set_device_restriction_handler(enable);
- break;
- case 4:
- ret = is_device_restricted_handler(&enable);
- if (ret == 0) {
- if (enable == 0)
- printf("Device Restriction: Disallowed\n");
- else
- printf("Device Restriction: Allowed\n");
- }
- break;
- case 5:
- printf("uuid> ");
- if (scanf("%100s", uuid) < 0) {
- input_status = -1;
- goto out;
- }
- ret = add_uuid_to_blacklist_handler(uuid);
- break;
- case 6:
- printf("uuid> ");
- if (scanf("%100s", uuid) < 0) {
- input_status = -1;
- goto out;
- }
- ret = remove_uuid_from_blacklist_handler(uuid);
- break;
- case 7:
- printf("enable(1) or disable(0)> ");
- if (scanf("%d", &enable) < 0) {
- input_status = -1;
- goto out;
- }
- if ((enable != 0) && (enable != 1)) {
- input_status = -1;
- goto out;
- }
- ret = set_uuid_restriction_handler(enable);
- break;
- case 8:
- ret = is_uuid_restricted_handler(&enable);
- if (ret == 0) {
- if (enable == 0)
- printf("UUID Restriction: Disallowed\n");
- else
- printf("UUID Restriction: Allowed\n");
- }
- break;
- case 9:
- printf("enable(1) or disable(0)> ");
- if (scanf("%d", &enable) < 0) {
- input_status = -1;
- goto out;
- }
- if ((enable != 0) && (enable != 1)) {
- input_status = -1;
- goto out;
- }
- ret = set_mode_change_state_handler(enable);
- break;
- case 10:
- ret = is_mode_change_state_handler(&enable);
- if (ret == 0) {
- if (enable == 0)
- printf("Mode change state: Disallowed\n");
- else
- printf("Mode change state: Allowed\n");
- }
- break;
- default:
- printf("Wrong command!\n");
- break;
- }
-
-out:
- if (input_status < 0)
- printf("Input Error!\n");
-
- if (ret < 0)
- printf("bluetooth policy operation is failed.\n");
- else
- printf("bluetooth policy operation is passed.\n");
-}
-
-void camera_policy_handler(int command , int state)
-{
- int ret = 1;
- int p_state = 1;
- char state_text[2][10] = {"DISABLE", "ENABLE"};
-
- if (command == 'v') {
- p_state = state;
- ret = set_camera_state_handler(p_state);
- } else
- ret = get_camera_state_handler(&p_state);
-
- if (ret < 0)
- printf("camera policy operation is failed.\n");
- else
- printf("camera state: %s\n", state_text[p_state]);
-}
-
-void microphone_policy_handler(int command, int state)
-{
- int ret = 1;
- int p_state = 1;
- char state_text[2][10] = {"DISABLE", "ENABLE"};
-
- if (command == 'v') {
- p_state = state;
- ret = set_microphone_state_handler(p_state);
- } else
- ret = get_microphone_state_handler(&p_state);
-
- if (ret < 0)
- printf("microphone policy operation is failed.\n");
- else
- printf("microphone state: %s\n", state_text[p_state]);
-}
-
-void location_policy_handler(int command, int state)
-{
- int ret = 1;
- int p_state = 1;
- char state_text[2][10] = {"DISABLE", "ENABLE"};
-
- if (command == 'v') {
- p_state = state;
- ret = set_location_state_handler(p_state);
- } else
- ret = get_location_state_handler(&p_state);
-
- if (ret < 0)
- printf("location policy operation is failed.\n");
- else
- printf("location state: %s\n", state_text[p_state]);
-}
-
-void clipboard_policy_handler(int command, int state)
-{
- int ret = 1;
- int p_state = 1;
- char state_text[2][10] = {"DISABLE", "ENABLE"};
-
- if (command == 'v') {
- p_state = state;
- ret = set_clipboard_state_handler(p_state);
- } else
- ret = get_clipboard_state_handler(&p_state);
-
- if (ret < 0)
- printf("clipboard policy operation is failed.\n");
- else
- printf("clipboard state: %s\n", state_text[p_state]);
-}
-
-void settings_policy_handler(int command, int state)
-{
- int ret = 1;
- int p_state = 1;
- char state_text[2][10] = {"DISABLE", "ENABLE"};
-
- if (command == 'v') {
- p_state = state;
- ret = set_settings_changes_restriction_handler(p_state);
- } else
- ret = get_settings_changes_restriction_handler(&p_state);
-
- if (ret < 0)
- printf("settings changes policy operation is failed.\n");
- else
- printf("settings changes state: %s\n", state_text[p_state]);
-}
-
-void usb_debugging_policy_handler(int command, int state)
-{
- int ret = 1;
- int p_state = 1;
- char state_text[2][10] = {"DISABLE", "ENABLE"};
-
- if (command == 'v') {
- p_state = state;
- ret = set_usb_debugging_state_handler(p_state);
- } else
- ret = get_usb_debugging_state_handler(&p_state);
-
- if (ret < 0)
- printf("usb_debugging policy operation is failed.\n");
- else
- printf("usb_debugging state: %s\n", state_text[p_state]);
-}
-
-void usb_tethering_policy_handler(int command, int state)
-{
- int ret = 1;
- int p_state = 1;
- char state_text[2][10] = {"DISALLOW", "ALLOW"};
-
- if (command == 'v') {
- p_state = state;
- ret = set_usb_tethering_state_handler(p_state);
- } else
- ret = get_usb_tethering_state_handler(&p_state);
-
- if (ret < 0)
- printf("usb-tethering policy operation is failed.\n");
- else
- printf("usb-tethering state: %s\n", state_text[p_state]);
-}
-
-void bluetooth_tethering_policy_handler(int command, int state)
-{
- int ret = 1;
- int p_state = 1;
- char state_text[2][10] = {"DISALLOW", "ALLOW"};
-
- if (command == 'v') {
- p_state = state;
- ret = set_bluetooth_tethering_state_handler(p_state);
- } else
- ret = get_bluetooth_tethering_state_handler(&p_state);
-
- if (ret < 0)
- printf("bluetooth-tethering policy operation is failed.\n");
- else
- printf("bluetooth-tethering state: %s\n", state_text[p_state]);
-}
-
-void bluetooth_desktop_connectivity_policy_handler(int command, int state)
-{
- int ret = 1;
- int p_state = 1;
- char state_text[2][10] = {"DISALLOW", "ALLOW"};
-
- if (command == 'v') {
- p_state = state;
- ret = set_bluetooth_desktop_connectivity_handler(p_state);
- } else
- ret = get_bluetooth_desktop_connectivity_handler(&p_state);
-
- if (ret < 0)
- printf("bluetooth-desktop-connectivity policy operation is failed.\n");
- else
- printf("bluetooth-desktop-connectivity state: %s\n", state_text[p_state]);
-}
+++ /dev/null
-// Copyright (c) 2015 Samsung Electronics Co., Ltd.
-//
-// 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 __DPM_CLI_TOOLKIT_H__
-#define __DPM_CLI_TOOLKIT_H__
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#define DPM_PASSWORD 0
-#define DPM_SECURITY 1
-#define DPM_WIFI 2
-#define DPM_ZONE 3
-#define DPM_BLUETOOTH 4
-
-void password_policy_handler(void);
-void security_policy_handler(void);
-void wifi_policy_handler(void);
-void zone_policy_handler(void);
-void bluetooth_policy_handler(void);
-void restriction_policy_command_handler(char *policy, int command, int state);
-void camera_policy_handler(int command, int state);
-void microphone_policy_handler(int command, int state);
-void location_policy_handler(int command, int state);
-void clipboard_policy_handler(int command, int state);
-void settings_policy_handler(int command, int state);
-void usb_debugging_policy_handler(int command, int state);
-void usb_tethering_policy_handler(int command, int state);
-void bluetooth_tethering_policy_handler(int command, int state);
-void bluetooth_desktop_connectivity_policy_handler(int command, int state);
-
-int set_password_quality_handler(int password_quality);
-int set_password_min_length_handler(int min_length);
-int set_password_min_complex_chars_handler(int min_complex_chars);
-int set_password_max_failed_attempts_for_wipe_handler(int max_failed_attempts);
-int set_password_expires_handler(int expired_day);
-int set_password_history_handler(int history);
-int set_password_pattern_handler(char *pattern);
-int reset_password_handler(char *new_password);
-int enforce_password_change_handler(void);
-int set_max_inactivity_time_device_lock_handler(int max_inactivity_time);
-int get_max_inactivity_time_device_lock_handler(int *max_inactivity_time);
-int set_password_status_handler(int status);
-int delete_password_pattern_handler(void);
-int get_password_pattern_handler(char **password_pattern);
-int set_max_char_occurrences_handler(int max_char_occur);
-int get_max_char_occurrences_handler(int *max_char_occur);
-int set_max_numeric_sequence_length_handler(int max_numeric_seq_length);
-int get_max_numeric_sequence_length_handler(int *max_numeric_seq_length);
-
-int create_zone_handler(char *name);
-int destroy_zone_handler(char *name);
-
-int add_device_to_blacklist_handler(const char *mac_address);
-int remove_device_from_blacklist_handler(const char *mac_address);
-int set_device_restriction_handler(const int enable);
-int is_device_restricted_handler(int *enable);
-int add_uuid_to_blacklist_handler(const char *uuid);
-int remove_uuid_from_blacklist_handler(const char *uuid);
-int set_uuid_restriction_handler(const int enable);
-int is_uuid_restricted_handler(int *enable);
-int set_mode_change_state_handler(const int enable);
-int is_mode_change_state_handler(int *enable);
-
-int set_camera_state_handler(int state);
-int get_camera_state_handler(int *state);
-int set_microphone_state_handler(int state);
-int get_microphone_state_handler(int *state);
-int set_location_state_handler(int state);
-int get_location_state_handler(int *state);
-int set_clipboard_state_handler(int state);
-int get_clipboard_state_handler(int *state);
-int set_settings_changes_restriction_handler(int state);
-int get_settings_changes_restriction_handler(int *state);
-int set_usb_debugging_state_handler(int state);
-int get_usb_debugging_state_handler(int *state);
-int set_usb_tethering_state_handler(int state);
-int get_usb_tethering_state_handler(int *state);
-int set_bluetooth_tethering_state_handler(int state);
-int get_bluetooth_tethering_state_handler(int *state);
-int set_bluetooth_desktop_connectivity_handler(int state);
-int get_bluetooth_desktop_connectivity_handler(int *state);
-
-#endif /* !__DPM_CLI_TOOLKIT_H__ */
+++ /dev/null
-// Copyright (c) 2015 Samsung Electronics Co., Ltd.
-//
-// 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 "dpm-cli-toolkit.h"
-
-void print_rule(void)
-{
- printf("--------------------------------------------------------------\n");
- printf("[Password Polocy]\n");
- printf("password\n");
- printf("[Security Polocy]\n");
- printf("security\n");
- printf("[Wifi Polocy]\n");
- printf("wifi\n");
- printf("[Zone Polocy]\n");
- printf("zone\n");
- printf("[Bluetooth Polocy]\n");
- printf("bluetooth\n");
- printf("Usage: dpm-cli-toolkit -s [policy-name]\n");
- printf("Ex: dpm-cli-toolkit -s password\n");
- printf("--------------------------------------------------------------\n");
- printf("[Restrictioin Policy]\n");
- printf("camera, microphone, location, clipboard, settings, usb_debugging\n");
- printf("usb_tethering, bluetooth_tethering, bluetooth_desktop_connectivity\n");
- printf("Usage: dpm-cli-toolkit -s [policy-name] -v [value: 0 or 1]\n");
- printf("Ex: dpm-cli-toolkit -s camera -v 1\n");
- printf("--------------------------------------------------------------\n");
-}
-
-int main(int argc, char **argv)
-{
- int dpm_opt;
- int prev_opt = 0;
- int state = 1;
- char *policy_name = NULL;
- char *value = NULL;
-
- if (argc == 1) {
- printf("Wrong command rule! Please refer to the rule bleow.\n");
- print_rule();
- return 0;
- }
-
- opterr = 0;
-
- while ((dpm_opt = getopt(argc, argv, "s:g:v:h")) != -1) {
- switch (dpm_opt) {
- case 's':
- prev_opt = 's';
- policy_name = optarg;
- //printf("[%s] SET\n", policy_name);
- break;
- case 'g':
- prev_opt = 'g';
- policy_name = optarg;
- //printf("[%s] GET\n", policy_name);
- break;
- case 'v':
- if (prev_opt != 's') {
- printf("Usage: dpm-cli-toolkit -s [policy-name] -v [value: 0 or 1]\n");
- return 0;
- } else {
- prev_opt = 'v';
- if ((*optarg == '0') | (*optarg == '1')) {
- value = optarg;
- state = atoi(value);
- printf("State: %s\n", value);
- } else {
- printf("Usage: dpm-cli-toolkit -s [policy-name] -v [value: 0 or 1]\n");
- return 0;
- }
- }
- break;
- case 'h':
- print_rule();
- break;
- case '?':
- if ((optopt == 's') | (optopt == 'v'))
- printf("Usage: dpm-cli-toolkit -s [policy-name] -v [value: 0 or 1]\n");
- else if (optopt == 'g')
- printf("Usage: dpm-cli-toolkit -g [policy-name]\n");
- else
- printf("Usage: dpm-cli-toolkit -s [policy-name] -v [value: 0 or 1] or dpm-cli-toolkit -g [policy-name]\n");
- return 0;
- break;
- }
- }
-
- if (prev_opt == 's') {
- if (strcmp(policy_name, "password") == 0)
- password_policy_handler();
- else if (strcmp(policy_name, "security") == 0)
- security_policy_handler();
- else if (strcmp(policy_name, "wifi") == 0)
- wifi_policy_handler();
- else if (strcmp(policy_name, "zone") == 0)
- zone_policy_handler();
- else if (strcmp(policy_name, "bluetooth") == 0)
- bluetooth_policy_handler();
- else {
- printf("Wrong policy name! Please refer to the policy names bleow.\n");
- print_rule();
- }
- return 0;
- }
-
- restriction_policy_command_handler(policy_name, prev_opt, state);
-
- return 0;
-}
-
-void restriction_policy_command_handler(char *policy, int command, int state)
-{
- if (strcmp(policy, "camera") == 0)
- camera_policy_handler(command, state);
- else if (strcmp(policy, "microphone") == 0)
- microphone_policy_handler(command, state);
- else if (strcmp(policy, "location") == 0)
- location_policy_handler(command, state);
- else if (strcmp(policy, "clipboard") == 0)
- clipboard_policy_handler(command, state);
- else if (strcmp(policy, "settings") == 0)
- settings_policy_handler(command, state);
- else if (strcmp(policy, "usb_debugging") == 0)
- usb_debugging_policy_handler(command, state);
- else if (strcmp(policy, "usb_tethering") == 0)
- usb_tethering_policy_handler(command, state);
- else if (strcmp(policy, "bluetooth_tethering") == 0)
- bluetooth_tethering_policy_handler(command, state);
- else if (strcmp(policy, "bluetooth_desktop_connectivity") == 0)
- bluetooth_desktop_connectivity_policy_handler(command, state);
- else {
- printf("Wrong policy name! Please refer to the policy names bleow.\n");
- print_rule();
- }
-}
+++ /dev/null
-#include "dpm-cli-toolkit.h"
-#include <dpm/password.h>
-
-int set_password_quality_handler(int password_quality)
-{
- dpm_context_h handle;
- dpm_password_policy_h password_policy_handle;
- dpm_password_quality_e quality;
-
- switch (password_quality) {
- case 0:
- quality = DPM_PASSWORD_QUALITY_UNSPECIFIED;
- break;
- case 1:
- quality = DPM_PASSWORD_QUALITY_SIMPLE_PASSWORD;
- break;
- case 2:
- quality = DPM_PASSWORD_QUALITY_SOMETHING;
- break;
- case 3:
- quality = DPM_PASSWORD_QUALITY_NUMERIC;
- break;
- case 4:
- quality = DPM_PASSWORD_QUALITY_ALPHABETIC;
- break;
- case 5:
- quality = DPM_PASSWORD_QUALITY_ALPHANUMERIC;
- break;
- default:
- quality = DPM_PASSWORD_QUALITY_UNSPECIFIED;
- break;
- }
-
- handle = dpm_context_create();
- if (handle == NULL) {
- printf("Failed to create device policy context handle\n");
- return -1;
- }
-
- password_policy_handle = dpm_context_acquire_password_policy(handle);
- if (password_policy_handle == NULL) {
- printf("Failed to create password policy handle\n");
- return -1;
- }
-
- if (dpm_password_set_quality(password_policy_handle, quality) == 0) {
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return 0;
- }
-
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return -1;
-}
-
-int set_password_min_length_handler(int min_length)
-{
- dpm_context_h handle;
- dpm_password_policy_h password_policy_handle;
-
- handle = dpm_context_create();
- if (handle == NULL) {
- printf("Failed to create client handle\n");
- return -1;
- }
-
- password_policy_handle = dpm_context_acquire_password_policy(handle);
- if (password_policy_handle == NULL) {
- printf("Failed to create password policy handle\n");
- return -1;
- }
-
- if (dpm_password_set_minimum_length(password_policy_handle, min_length) == 0) {
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return 0;
- }
-
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return -1;
-}
-
-int set_password_min_complex_chars_handler(int min_complex_chars)
-{
- dpm_context_h handle;
- dpm_password_policy_h password_policy_handle;
-
- handle = dpm_context_create();
- if (handle == NULL) {
- printf("Failed to create client handle\n");
- return -1;
- }
-
- password_policy_handle = dpm_context_acquire_password_policy(handle);
- if (password_policy_handle == NULL) {
- printf("Failed to create password policy handle\n");
- return -1;
- }
-
- if (dpm_password_set_min_complex_chars(password_policy_handle, min_complex_chars) == 0) {
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return 0;
- }
-
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return -1;
-}
-
-int set_password_max_failed_attempts_for_wipe_handler(int max_failed_attempts)
-{
- dpm_context_h handle;
- dpm_password_policy_h password_policy_handle;
-
- handle = dpm_context_create();
- if (handle == NULL) {
- printf("Failed to create client handle\n");
- return -1;
- }
-
- password_policy_handle = dpm_context_acquire_password_policy(handle);
- if (password_policy_handle == NULL) {
- printf("Failed to create password policy handle\n");
- return -1;
- }
-
- if (dpm_password_set_maximum_failed_attempts_for_wipe(password_policy_handle, max_failed_attempts) == 0) {
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return 0;
- }
-
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return -1;
-}
-
-int set_password_expires_handler(int expired_day)
-{
- dpm_context_h handle;
- dpm_password_policy_h password_policy_handle;
-
- handle = dpm_context_create();
- if (handle == NULL) {
- printf("Failed to create client handle\n");
- return -1;
- }
-
- password_policy_handle = dpm_context_acquire_password_policy(handle);
- if (password_policy_handle == NULL) {
- printf("Failed to create password policy handle\n");
- return -1;
- }
-
- if (dpm_password_set_expires(password_policy_handle, expired_day) == 0) {
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return 0;
- }
-
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return -1;
-}
-
-int set_password_history_handler(int history)
-{
- dpm_context_h handle;
- dpm_password_policy_h password_policy_handle;
-
- handle = dpm_context_create();
- if (handle == NULL) {
- printf("Failed to create client handle\n");
- return -1;
- }
-
- password_policy_handle = dpm_context_acquire_password_policy(handle);
- if (password_policy_handle == NULL) {
- printf("Failed to create password policy handle\n");
- return -1;
- }
-
- if (dpm_password_set_history(password_policy_handle, history) == 0) {
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return 0;
- }
-
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return -1;
-}
-
-int set_password_pattern_handler(char *pattern)
-{
- dpm_context_h handle;
- dpm_password_policy_h password_policy_handle;
-
- handle = dpm_context_create();
- if (handle == NULL) {
- printf("Failed to create client handle\n");
- return -1;
- }
-
- password_policy_handle = dpm_context_acquire_password_policy(handle);
- if (password_policy_handle == NULL) {
- printf("Failed to create password policy handle\n");
- return -1;
- }
-
- if (dpm_password_set_pattern(password_policy_handle, pattern) == 0) {
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return 0;
- }
-
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return -1;
-}
-
-int reset_password_handler(char *new_password)
-{
- dpm_context_h handle;
- dpm_password_policy_h password_policy_handle;
-
- handle = dpm_context_create();
- if (handle == NULL) {
- printf("Failed to create client handle\n");
- return -1;
- }
-
- password_policy_handle = dpm_context_acquire_password_policy(handle);
- if (password_policy_handle == NULL) {
- printf("Failed to create password policy handle\n");
- return -1;
- }
-
- if (dpm_password_reset(password_policy_handle, new_password) == 0) {
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return 0;
- }
-
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return -1;
-}
-
-int enforce_password_change_handler(void)
-{
- dpm_context_h handle;
- dpm_password_policy_h password_policy_handle;
-
- handle = dpm_context_create();
- if (handle == NULL) {
- printf("Failed to create client handle\n");
- return -1;
- }
-
- password_policy_handle = dpm_context_acquire_password_policy(handle);
- if (password_policy_handle == NULL) {
- printf("Failed to create password policy handle\n");
- return -1;
- }
-
- if (dpm_password_enforce_change(password_policy_handle) == 0) {
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return 0;
- }
-
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return -1;
-}
-
-int set_max_inactivity_time_device_lock_handler(int max_inactivity_time)
-{
- dpm_context_h handle;
- dpm_password_policy_h password_policy_handle;
-
- handle = dpm_context_create();
- if (handle == NULL) {
- printf("Failed to create client handle\n");
- return -1;
- }
-
- password_policy_handle = dpm_context_acquire_password_policy(handle);
- if (password_policy_handle == NULL) {
- printf("Failed to create password policy handle\n");
- return -1;
- }
-
- if (dpm_password_set_max_inactivity_time_device_lock(password_policy_handle, max_inactivity_time) == 0) {
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return 0;
- }
-
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return -1;
-}
-
-int get_max_inactivity_time_device_lock_handler(int *max_inactivity_time)
-{
- dpm_context_h handle;
- dpm_password_policy_h password_policy_handle;
-
- handle = dpm_context_create();
- if (handle == NULL) {
- printf("Failed to create client handle\n");
- return -1;
- }
-
- password_policy_handle = dpm_context_acquire_password_policy(handle);
- if (password_policy_handle == NULL) {
- printf("Failed to create password policy handle\n");
- return -1;
- }
-
- if (dpm_password_get_max_inactivity_time_device_lock(password_policy_handle, max_inactivity_time) == 0) {
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return 0;
- }
-
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return -1;
-}
-
-int set_password_status_handler(int status)
-{
- dpm_context_h handle;
- dpm_password_policy_h password_policy_handle;
-
- handle = dpm_context_create();
- if (handle == NULL) {
- printf("Failed to create client handle\n");
- return -1;
- }
-
- password_policy_handle = dpm_context_acquire_password_policy(handle);
- if (password_policy_handle == NULL) {
- printf("Failed to create password policy handle\n");
- return -1;
- }
-
- if (dpm_password_set_status(password_policy_handle, status) == 0) {
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return 0;
- }
-
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return -1;
-}
-
-int delete_password_pattern_handler(void)
-{
- dpm_context_h handle;
- dpm_password_policy_h password_policy_handle;
-
- handle = dpm_context_create();
- if (handle == NULL) {
- printf("Failed to create client handle\n");
- return -1;
- }
-
- password_policy_handle = dpm_context_acquire_password_policy(handle);
- if (password_policy_handle == NULL) {
- printf("Failed to create password policy handle\n");
- return -1;
- }
-
- if (dpm_password_delete_pattern(password_policy_handle) == 0) {
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return 0;
- }
-
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return -1;
-}
-
-int get_password_pattern_handler(char **password_pattern)
-{
- dpm_context_h handle;
- dpm_password_policy_h password_policy_handle;
-
- handle = dpm_context_create();
- if (handle == NULL) {
- printf("Failed to create client handle\n");
- return -1;
- }
-
- password_policy_handle = dpm_context_acquire_password_policy(handle);
- if (password_policy_handle == NULL) {
- printf("Failed to create password policy handle\n");
- return -1;
- }
-
- if (dpm_password_get_pattern(password_policy_handle, password_pattern) == 0) {
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return 0;
- }
-
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return -1;
-}
-
-int set_max_char_occurrences_handler(int max_char_occur)
-{
- dpm_context_h handle;
- dpm_password_policy_h password_policy_handle;
-
- handle = dpm_context_create();
- if (handle == NULL) {
- printf("Failed to create client handle\n");
- return -1;
- }
-
- password_policy_handle = dpm_context_acquire_password_policy(handle);
- if (password_policy_handle == NULL) {
- printf("Failed to create password policy handle\n");
- return -1;
- }
-
- if (dpm_password_set_maximum_character_occurrences(password_policy_handle, max_char_occur) == 0) {
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return 0;
- }
-
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return -1;
-}
-
-int get_max_char_occurrences_handler(int *max_char_occur)
-{
- dpm_context_h handle;
- dpm_password_policy_h password_policy_handle;
-
- handle = dpm_context_create();
- if (handle == NULL) {
- printf("Failed to create client handle\n");
- return -1;
- }
-
- password_policy_handle = dpm_context_acquire_password_policy(handle);
- if (password_policy_handle == NULL) {
- printf("Failed to create password policy handle\n");
- return -1;
- }
-
- if (dpm_password_get_maximum_character_occurrences(password_policy_handle, max_char_occur) == 0) {
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return 0;
- }
-
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return -1;
-}
-
-int set_max_numeric_sequence_length_handler(int max_numeric_seq_length)
-{
- dpm_context_h handle;
- dpm_password_policy_h password_policy_handle;
-
- handle = dpm_context_create();
- if (handle == NULL) {
- printf("Failed to create client handle\n");
- return -1;
- }
-
- password_policy_handle = dpm_context_acquire_password_policy(handle);
- if (password_policy_handle == NULL) {
- printf("Failed to create password policy handle\n");
- return -1;
- }
-
- if (dpm_password_set_maximum_numeric_sequence_length(password_policy_handle, max_numeric_seq_length) == 0) {
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return 0;
- }
-
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return -1;
-}
-
-int get_max_numeric_sequence_length_handler(int *max_numeric_seq_length)
-{
- dpm_context_h handle;
- dpm_password_policy_h password_policy_handle;
-
- handle = dpm_context_create();
- if (handle == NULL) {
- printf("Failed to create client handle\n");
- return -1;
- }
-
- password_policy_handle = dpm_context_acquire_password_policy(handle);
- if (password_policy_handle == NULL) {
- printf("Failed to create password policy handle\n");
- return -1;
- }
-
- if (dpm_password_get_maximum_numeric_sequence_length(password_policy_handle, max_numeric_seq_length) == 0) {
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return 0;
- }
-
- dpm_context_release_password_policy(handle, password_policy_handle);
- dpm_context_destroy(handle);
- return -1;
-}
+++ /dev/null
-#include "dpm-cli-toolkit.h"
-#include <dpm/restriction.h>
-
-int set_camera_state_handler(int state)
-{
- dpm_context_h context = NULL;
- dpm_restriction_policy_h policy = NULL;
-
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed to create device policy context handle\n");
- return -1;
- }
-
- policy = dpm_context_acquire_restriction_policy(context);
- if (policy == NULL) {
- printf("Failed to create camera policy handle\n");
- dpm_context_destroy(context);
- return -1;
- }
-
- if (dpm_restriction_set_camera_state(policy, state) == 0) {
- dpm_context_release_restriction_policy(context, policy);
- dpm_context_destroy(context);
- return 0;
- }
-
- dpm_context_release_restriction_policy(context, policy);
- dpm_context_destroy(context);
- return -1;
-}
-
-int get_camera_state_handler(int *state)
-{
- dpm_context_h context = NULL;
- dpm_restriction_policy_h policy = NULL;
-
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed to create device policy context handle\n");
- return -1;
- }
-
- policy = dpm_context_acquire_restriction_policy(context);
- if (policy == NULL) {
- printf("Failed to create camera policy handle");
- dpm_context_destroy(context);
- return -1;
- }
-
- if (dpm_restriction_get_camera_state(policy, state) == 0) {
- dpm_context_release_restriction_policy(context, policy);
- dpm_context_destroy(context);
- return 0;
- }
-
- dpm_context_release_restriction_policy(context, policy);
- dpm_context_destroy(context);
- return -1;
-}
-
-int set_microphone_state_handler(int state)
-{
- dpm_context_h context = NULL;
- dpm_restriction_policy_h policy = NULL;
-
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed to create device policy context handle\n");
- return -1;
- }
-
- policy = dpm_context_acquire_restriction_policy(context);
- if (policy == NULL) {
- printf("Failed to create microphone policy handle\n");
- dpm_context_destroy(context);
- return -1;
- }
-
- if (dpm_restriction_set_microphone_state(policy, state) == 0) {
- dpm_context_release_restriction_policy(context, policy);
- dpm_context_destroy(context);
- return 0;
- }
-
- dpm_context_release_restriction_policy(context, policy);
- dpm_context_destroy(context);
- return -1;
-}
-
-int get_microphone_state_handler(int *state)
-{
- dpm_context_h context = NULL;
- dpm_restriction_policy_h policy = NULL;
-
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed to create device policy context handle\n");
- return -1;
- }
-
- policy = dpm_context_acquire_restriction_policy(context);
- if (policy == NULL) {
- printf("Failed to create microphone policy handle\n");
- dpm_context_destroy(context);
- return -1;
- }
-
- if (dpm_restriction_get_microphone_state(policy, state) == 0) {
- dpm_context_release_restriction_policy(context, policy);
- dpm_context_destroy(context);
- return 0;
- }
-
- dpm_context_release_restriction_policy(context, policy);
- dpm_context_destroy(context);
- return -1;
-}
-
-int set_location_state_handler(int state)
-{
- dpm_context_h context = NULL;
- dpm_restriction_policy_h policy = NULL;
-
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed to create dpm context\n");
- return -1;
- }
-
- policy = dpm_context_acquire_restriction_policy(context);
- if (policy == NULL) {
- printf("Failed to create client handle\n");
- dpm_context_destroy(context);
- return -1;
- }
-
- if (dpm_restriction_set_location_state(policy, state) != 0) {
- printf("Failed to set location state\n");
- dpm_context_release_restriction_policy(context, policy);
- dpm_context_destroy(context);
- return -1;
- }
-
- dpm_context_release_restriction_policy(context, policy);
- dpm_context_destroy(context);
- return 0;
-}
-
-int get_location_state_handler(int *state)
-{
- dpm_context_h context = NULL;
- dpm_restriction_policy_h policy = NULL;
-
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed to create dpm context\n");
- return -1;
- }
-
- policy = dpm_context_acquire_restriction_policy(context);
- if (policy == NULL) {
- printf("Failed to create client handle\n");
- dpm_context_destroy(context);
- return -1;
- }
-
- dpm_restriction_get_location_state(policy, state);
- if (state < 0) {
- printf("Failed to get location state\n");
- dpm_context_release_restriction_policy(context, policy);
- dpm_context_destroy(context);
- return -1;
- }
-
- dpm_context_release_restriction_policy(context, policy);
- dpm_context_destroy(context);
-
- return 0;
-}
-
-int set_clipboard_state_handler(int state)
-{
- dpm_context_h context = NULL;
- dpm_restriction_policy_h policy = NULL;
- int ret = 0;
- int get_value = 0;
-
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed in dpm_context_create()\n");
- return -1;
- }
-
- policy = dpm_context_acquire_restriction_policy(context);
- if (policy == NULL) {
- printf("Failed in dpm_context_acquire_restriction_policy()\n");
- dpm_context_destroy(context);
- return -1;
- }
-
- if (dpm_restriction_set_clipboard_state(policy, state) != 0) {
- printf("Failed in dpm_restriction_set_clipboard_state()\n");
- ret = -1;
- goto out;
- }
-
- if (dpm_restriction_get_clipboard_state(policy, &get_value) < 0) {
- printf("Failed in dpm_restriction_get_clipboard_state()\n");
- ret = -1;
- goto out;
- }
-
- if (state != get_value) {
- printf("Failed to set value of restriction\n");
- ret = -1;
- goto out;
- }
-out:
- dpm_context_release_restriction_policy(context, policy);
- dpm_context_destroy(context);
-
- if (ret == -1)
- return ret;
- else
- return 0;
-}
-
-int get_clipboard_state_handler(int *state)
-{
- dpm_context_h context = NULL;
- dpm_restriction_policy_h policy = NULL;
- int ret = 0;
-
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed in dpm_context_create()\n");
- return -1;
- }
-
- policy = dpm_context_acquire_restriction_policy(context);
- if (policy == NULL) {
- printf("Failed in dpm_context_acquire_restriction_policy()\n");
- dpm_context_destroy(context);
- return -1;
- }
-
- if (dpm_restriction_get_clipboard_state(policy, state) < 0) {
- printf("Failed in dpm_restriction_get_clipboard_state()\n");
- ret = -1;
- goto out;
- }
-
- if (*state == 1 || *state == 0)
- ret = 0;
- else
- ret = -1;
-
-out:
- dpm_context_release_restriction_policy(context, policy);
- dpm_context_destroy(context);
-
- if (ret == -1)
- return ret;
- else
- return 0;
-}
-
-int set_settings_changes_restriction_handler(int state)
-{
- dpm_context_h context = NULL;
- dpm_restriction_policy_h policy = NULL;
- int ret = 0;
- int get_value = 0;
-
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed in dpm_context_create()\n");
- return -1;
- }
-
- policy = dpm_context_acquire_restriction_policy(context);
- if (policy == NULL) {
- printf("Failed in dpm_context_acquire_restriction_policy()\n");
- dpm_context_destroy(context);
- return -1;
- }
-
- if (dpm_restriction_set_settings_changes_state(policy, state) != 0) {
- printf("Failed in dpm_restriction_set_settings_changes_state()\n");
- ret = -1;
- goto out;
- }
-
- if (dpm_restriction_get_settings_changes_state(policy, &get_value) < 0) {
- printf("Failed in dpm_restriction_get_settings_changes_state()\n");
- ret = -1;
- goto out;
- }
-
- if (state != get_value) {
- printf("Failed to set value of restriction\n");
- ret = -1;
- goto out;
- }
-
-out:
- dpm_context_release_restriction_policy(context, policy);
- dpm_context_destroy(context);
-
- if (ret == -1)
- return ret;
- else
- return 0;
-}
-
-int get_settings_changes_restriction_handler(int *state)
-{
- dpm_context_h context = NULL;
- dpm_restriction_policy_h policy = NULL;
- int ret = 0;
-
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed in dpm_context_create()");
- return -1;
- }
-
- policy = dpm_context_acquire_restriction_policy(context);
- if (policy == NULL) {
- printf("Failed in dpm_context_acquire_restriction_policy()\n");
- dpm_context_destroy(context);
- return -1;
- }
-
- if (dpm_restriction_get_settings_changes_state(policy, state) < 0) {
- printf("Failed in dpm_restriction_get_settings_changes_state()\n");
- ret = -1;
- goto out;
- }
-
- if (*state == 1 || *state == 0)
- ret = 0;
- else
- ret = -1;
-
-out:
- dpm_context_release_restriction_policy(context, policy);
- dpm_context_destroy(context);
-
- if (ret == -1)
- return ret;
- else
- return 0;
-}
-
-int set_usb_debugging_state_handler(int state)
-{
- dpm_context_h context = NULL;
- dpm_restriction_policy_h policy = NULL;
- int ret = 0;
- int get_value = 0;
-
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed in dpm_context_create()\n");
- return -1;
- }
-
- policy = dpm_context_acquire_restriction_policy(context);
- if (policy == NULL) {
- printf("Failed in dpm_context_acquire_restriction_policy()\n");
- dpm_context_destroy(context);
- return -1;
- }
-
- if (dpm_restriction_set_usb_debugging_state(policy, state) != 0) {
- printf("Failed in dpm_restriction_set_usb_debugging_state()\n");
- ret = -1;
- goto out;
- }
-
- if (dpm_restriction_get_usb_debugging_state(policy, &get_value) < 0) {
- printf("Failed in dpm_restriction_get_usb_debugging_state()\n");
- ret = -1;
- goto out;
- }
-
- if (state != get_value) {
- printf("Failed to set value of restriction\n");
- ret = -1;
- goto out;
- }
-
-out:
- dpm_context_release_restriction_policy(context, policy);
- dpm_context_destroy(context);
-
- if (ret == -1)
- return ret;
- else
- return 0;
-}
-
-int get_usb_debugging_state_handler(int *state)
-{
- dpm_context_h context = NULL;
- dpm_restriction_policy_h policy = NULL;
- int ret = 0;
-
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed in dpm_context_create()\n");
- return -1;
- }
-
- policy = dpm_context_acquire_restriction_policy(context);
- if (policy == NULL) {
- printf("Failed in dpm_context_acquire_restriction_policy()\n");
- dpm_context_destroy(context);
- return -1;
- }
-
- if (dpm_restriction_get_usb_debugging_state(policy, state) < 0) {
- printf("Failed in dpm_restriction_get_usb_debugging_state()\n");
- ret = -1;
- goto out;
- }
-
- if (*state == 1 || *state == 0)
- ret = 0;
- else
- ret = -1;
-
-out:
- dpm_context_release_restriction_policy(context, policy);
- dpm_context_destroy(context);
-
- if (ret == -1)
- return ret;
- else
- return 0;
-}
-
-int set_usb_tethering_state_handler(int state)
-{
- dpm_context_h context = NULL;
- dpm_restriction_policy_h policy = NULL;
- int ret = 0;
- int get_value = 0;
-
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed in dpm_context_create()\n");
- return -1;
- }
-
- policy = dpm_context_acquire_restriction_policy(context);
- if (policy == NULL) {
- printf("Failed in dpm_context_acquire_restriction_policy()\n");
- dpm_context_destroy(context);
- return -1;
- }
-
- if (dpm_restriction_set_usb_tethering_state(policy, state) != 0) {
- printf("Failed in dpm_restriction_set_usb_tethering_state()\n");
- ret = -1;
- goto out;
- }
-
- if (dpm_restriction_get_usb_tethering_state(policy, &get_value) < 0) {
- printf("Failed in dpm_restriction_get_usb_tethering_state()\n");
- ret = -1;
- goto out;
- }
-
- if (state != get_value) {
- printf("Failed to set value of restriction\n");
- ret = -1;
- goto out;
- }
-
-out:
- dpm_context_release_restriction_policy(context, policy);
- dpm_context_destroy(context);
-
- if (ret == -1)
- return ret;
- else
- return 0;
-}
-
-int get_usb_tethering_state_handler(int *state)
-{
- dpm_context_h context = NULL;
- dpm_restriction_policy_h policy = NULL;
- int ret = 0;
-
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed in dpm_context_create()\n");
- return -1;
- }
-
- policy = dpm_context_acquire_restriction_policy(context);
- if (policy == NULL) {
- printf("Failed in dpm_context_acquire_restriction_policy()\n");
- dpm_context_destroy(context);
- return -1;
- }
-
- if (dpm_restriction_get_usb_tethering_state(policy, state) < 0) {
- printf("Failed in dpm_restriction_get_usb_tethering_state()\n");
- ret = -1;
- goto out;
- }
-
- if (*state == 1 || *state == 0)
- ret = 0;
- else
- ret = -1;
-
-out:
- dpm_context_release_restriction_policy(context, policy);
- dpm_context_destroy(context);
-
- if (ret == -1)
- return ret;
- else
- return 0;
-}
-
-int set_bluetooth_tethering_state_handler(int state)
-{
- dpm_context_h context = NULL;
- dpm_restriction_policy_h policy = NULL;
- int ret = 0;
- int get_value = 0;
-
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed in dpm_context_create()\n");
- return -1;
- }
-
- policy = dpm_context_acquire_restriction_policy(context);
- if (policy == NULL) {
- printf("Failed in dpm_context_acquire_restriction_policy()\n");
- dpm_context_destroy(context);
- return -1;
- }
-
- if (dpm_restriction_set_bluetooth_tethering_state(policy, state) != 0) {
- printf("Failed in dpm_restriction_set_bluetooth_tethering_state()\n");
- ret = -1;
- goto out;
- }
-
- if (dpm_restriction_get_bluetooth_tethering_state(policy, &get_value) < 0) {
- printf("Failed in dpm_restriction_get_bluetooth_tethering_state()\n");
- ret = -1;
- goto out;
- }
-
- if (state != get_value) {
- printf("Failed to set value of restriction\n");
- ret = -1;
- goto out;
- }
-
-out:
- dpm_context_release_restriction_policy(context, policy);
- dpm_context_destroy(context);
-
- if (ret == -1)
- return ret;
- else
- return 0;
-}
-
-int get_bluetooth_tethering_state_handler(int *state)
-{
- dpm_context_h context = NULL;
- dpm_restriction_policy_h policy = NULL;
- int ret = 0;
-
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed in dpm_context_create()\n");
- return -1;
- }
-
- policy = dpm_context_acquire_restriction_policy(context);
- if (policy == NULL) {
- printf("Failed in dpm_context_acquire_restriction_policy()\n");
- dpm_context_destroy(context);
- return -1;
- }
-
- if (dpm_restriction_get_bluetooth_tethering_state(policy, state) < 0) {
- printf("Failed in dpm_restriction_get_bluetooth_tethering_state()\n");
- ret = -1;
- goto out;
- }
-
- if (*state == 1 || *state == 0)
- ret = 0;
- else
- ret = -1;
-
-out:
- dpm_context_release_restriction_policy(context, policy);
- dpm_context_destroy(context);
-
- if (ret == -1)
- return ret;
- else
- return 0;
-}
-
-int set_mode_change_state_handler(const int enable)
-{
- dpm_context_h context;
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed to create client context\n");
- return -1;
- }
-
- dpm_restriction_policy_h policy = dpm_context_acquire_restriction_policy(context);
- if (policy == NULL) {
- printf("Failed to get restriction policy interface\n");
- dpm_context_destroy(context);
- return -1;
- }
-
- if (dpm_restriction_set_bluetooth_mode_change_state(policy, enable) < 0) {
- printf("Failed to set mode change state\n");
- dpm_context_release_restriction_policy(context, policy);
- dpm_context_destroy(context);
- return -1;
- }
-
- return 0;
-}
-
-int is_mode_change_state_handler(int *enable)
-{
- dpm_context_h context;
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed to create client context\n");
- return -1;
- }
-
- dpm_restriction_policy_h policy = dpm_context_acquire_restriction_policy(context);
- if (policy == NULL) {
- printf("Failed to get restriction policy interface\n");
- dpm_context_destroy(context);
- return -1;
- }
-
- if (dpm_restriction_get_bluetooth_mode_change_state(policy, enable) != DPM_ERROR_NONE) {
- printf("Failed to check mode change state\n");
- dpm_context_release_restriction_policy(context, policy);
- dpm_context_destroy(context);
- return -1;
- }
-
- dpm_context_release_restriction_policy(context, policy);
- dpm_context_destroy(context);
-
- return 0;
-}
-
-int set_bluetooth_desktop_connectivity_handler(int state)
-{
- dpm_context_h context;
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed to create client context\n");
- return -1;
- }
-
- dpm_restriction_policy_h policy = dpm_context_acquire_restriction_policy(context);
- if (policy == NULL) {
- printf("Failed to get restriction policy interface\n");
- dpm_context_destroy(context);
- return -1;
- }
-
- if (dpm_restriction_set_bluetooth_desktop_connectivity_state(policy, state) < 0) {
- printf("Failed to set mode change state\n");
- dpm_context_release_restriction_policy(context, policy);
- dpm_context_destroy(context);
- return -1;
- }
-
- return 0;
-}
-
-int get_bluetooth_desktop_connectivity_handler(int *state)
-{
- dpm_context_h context;
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed to create client context\n");
- return -1;
- }
-
- dpm_restriction_policy_h policy = dpm_context_acquire_restriction_policy(context);
- if (policy == NULL) {
- printf("Failed to get restriction policy interface\n");
- dpm_context_destroy(context);
- return -1;
- }
-
- if (dpm_restriction_get_bluetooth_desktop_connectivity_state(policy, state) != DPM_ERROR_NONE) {
- printf("Failed to check mode change state\n");
- dpm_context_release_restriction_policy(context, policy);
- dpm_context_destroy(context);
- return -1;
- }
-
- dpm_context_release_restriction_policy(context, policy);
- dpm_context_destroy(context);
-
- return 0;
-}
+++ /dev/null
-#include "dpm-cli-toolkit.h"
-#include <dpm/zone.h>
-
-int create_zone_handler(char *name)
-{
- dpm_zone_policy_h policy;
- dpm_context_h context;
- int ret = 0;
-
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed to create client context\n");
- return -1;
- }
-
- policy = dpm_context_acquire_zone_policy(context);
- if (policy == NULL) {
- printf("Failed to get zone policy interface\n");
- dpm_context_destroy(context);
- return -1;
- }
-
- ret = dpm_zone_create(policy, name, "org.tizen.zone-setup-wizard");
-
- dpm_context_release_zone_policy(context, policy);
- dpm_context_destroy(context);
-
- return ret;
-}
-
-int destroy_zone_handler(char *name)
-{
- dpm_zone_policy_h policy;
- dpm_context_h context;
- int ret = 0;
-
- context = dpm_context_create();
- if (context == NULL) {
- printf("Failed to create client context\n");
- return -1;
- }
-
- policy = dpm_context_acquire_zone_policy(context);
- if (policy == NULL) {
- printf("Failed to get zone policy interface\n");
- dpm_context_destroy(context);
- return -1;
- }
-
- ret = dpm_zone_destroy(policy, name);
-
- dpm_context_release_zone_policy(context, policy);
- dpm_context_destroy(context);
-
- return ret;
-}