2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
18 #ifndef __CAPI_ZONE_POLICY_H__
19 #define __CAPI_ZONE_POLICY_H__
22 #include <dpm/device-policy-manager.h>
27 * @brief This file provides APIs to control zones.
37 * @addtogroup CAPI_DPM_ZONE_POLICY_MODULE
44 * @brief Creates a new zone.
45 * @details An administrator can use this API to create a container.
46 * Once the container is created, the admin package given to the parameter will be installed inside the container.
47 * Then ownership of the container gets transferred to the admin package from the client which triggered the container creation process.
50 * @privilege %http://tizen.org/privilege/dpm.zone
51 * @param[in] handle Device policy manager handle
52 * @param[in] name The zone name to be created
53 * @param[in] pkgname Admin package container ownership will be transferred
54 * @return #DPM_ERROR_NONE on success,
55 * otherwise a negative value
56 * @retval #DPM_ERROR_NONE Successful
57 * @retval #DPM_ERROR_INVALID_PARAMETER Invalid parameter
58 * @retval #DPM_ERROR_TIMED_OUT Time out
59 * @retval #DPM_ERROR_NOT_PERMITTED Operation not permitted
60 * @retval #DPM_ERROR_PERMISSION_DENIED The application does not have the privilege to call this API
61 * @pre The handle must be created by dpm_manager_create().
62 * @see dpm_manager_create()
63 * @see dpm_zone_destroy()
64 * @see dpm_zone_create_iterator()
66 int dpm_zone_create(device_policy_manager_h handle, const char* name, const char* pkgname);
71 * @brief Removes existing zone.
72 * @details Administrator can use this API to remove zone. All file system objects created for the zone will be also erased.
75 * @privilege %http://tizen.org/privilege/dpm.zone
76 * @param[in] handle Device policy manager handle
77 * @param[in] name The zone name to be removed
78 * @return #DPM_ERROR_NONE on success,
79 * otherwise a negative value
80 * @retval #DPM_ERROR_NONE Successful
81 * @retval #DPM_ERROR_INVALID_PARAMETER Invalid parameter
82 * @retval #DPM_ERROR_TIMED_OUT Time out
83 * @retval #DPM_ERROR_PERMISSION_DENIED The application does not have the privilege to call this API
84 * or the caller is not the owner of the zone
85 * @pre The handle must be created by dpm_manager_create().
86 * @pre The zone corresponding to the given name must be created before use of this API.
87 * @see dpm_manager_create()
88 * @see dpm_zone_create()
89 * @see dpm_zone_create_iterator()
91 int dpm_zone_destroy(device_policy_manager_h handle, const char* name);
95 * @brief Enumeration for zone state.
99 DPM_ZONE_STATE_LOCKED = 0x01, /**< Zone has been defined, but it can not start. */
100 DPM_ZONE_STATE_RUNNING = 0x02, /**< Zone has been started. */
101 DPM_ZONE_STATE_ALL = 0xff /**< This presents all of the state */
106 * @brief Gets the zone state.
107 * @details This API can be used to get the state of the zone. The zone can have one of the three states(running, locked).
109 * @param[in] handle Device policy manager handle
110 * @param[in] name The zone name
111 * @param[out] state The zone state
112 * @return #DPM_ERROR_NONE on success,
113 * otherwise a negative value
114 * @retval #DPM_ERROR_NONE Successful
115 * @retval #DPM_ERROR_NO_DATA No such zone to get state
116 * @retval #DPM_ERROR_INVALID_PARAMETER Invalid parameter
117 * @retval #DPM_ERROR_TIMED_OUT Time out
118 * @pre The handle must be created by dpm_manager_create().
119 * @see dpm_manager_create()
120 * @see dpm_zone_create()
121 * @see dpm_zone_destroy()
123 int dpm_zone_get_state(device_policy_manager_h handle, const char* name, dpm_zone_state_e *state);
127 * @brief Called to get all the names of created zones.
129 * @param[in] name The zone name
130 * @param[in] user_data The user data passed from dpm_zone_foreach_name
131 * @return true to continue with the next iteration of the loop,
132 * otherwise false to break out of the loop
133 * @see dpm_zone_foreach_name()
135 typedef bool(*dpm_zone_foreach_name_cb)(const char* name, void *user_data);
139 * @brief Retrieves all the names of created zones.
140 * @details This API calls dpm_zone_foreach_cb() once for each zone name with traversing the created zones list.
142 * @param[in] handle Device policy manager handle
143 * @param[in] state A combination of the zone state to look
144 * @param[in] callback The iteration callback function
145 * @param[in] user_data The user data passed to the callback function
146 * @return #DPM_ERROR_NONE on success,
147 * otherwise a negative value
148 * @retval #DPM_ERROR_NONE Successful
149 * @retval #DPM_ERROR_TIMED_OUT Time out
150 * @retval #DPM_ERROR_INVALID_PARAMETER Invalid parameter
151 * @pre The handle must be created by dpm_manager_create().
152 * @see dpm_manager_create()
153 * @see dpm_zone_create()
154 * @see dpm_zone_destroy()
156 int dpm_zone_foreach_name(device_policy_manager_h handle, dpm_zone_state_e state, dpm_zone_foreach_name_cb callback, void* user_data);
169 #endif /* __CAPI_ZONE_POLICY__ */