Merge pull request #26 from RS7-SECIOTSRK/server
[platform/core/security/suspicious-activity-monitor.git] / device-policy-manager / libs / dpm / zone.h
1 /*
2  *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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
15  */
16
17
18 #ifndef __CAPI_ZONE_POLICY_H__
19 #define __CAPI_ZONE_POLICY_H__
20
21
22 #include <dpm/device-policy-manager.h>
23
24
25 /**
26  * @file zone.h
27  * @brief This file provides APIs to control zones.
28  */
29
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35
36 /**
37  * @addtogroup CAPI_DPM_ZONE_POLICY_MODULE
38  * @{
39  */
40
41
42 /**
43  * @partner
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.
48  * @since_tizen 3.0
49  * @privlevel partner
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()
65  */
66 int dpm_zone_create(device_policy_manager_h handle, const char* name, const char* pkgname);
67
68
69 /**
70  * @partner
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.
73  * @since_tizen 3.0
74  * @privlevel partner
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()
90  */
91 int dpm_zone_destroy(device_policy_manager_h handle, const char* name);
92
93
94 /**
95  * @brief Enumeration for zone state.
96  * @since_tizen 3.0
97  */
98 typedef enum {
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  */
102 } dpm_zone_state_e;
103
104
105 /**
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).
108  * @since_tizen 3.0
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()
122  */
123 int dpm_zone_get_state(device_policy_manager_h handle, const char* name, dpm_zone_state_e *state);
124
125
126 /**
127  * @brief Called to get all the names of created zones.
128  * @since_tizen 3.0
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()
134  */
135 typedef bool(*dpm_zone_foreach_name_cb)(const char* name, void *user_data);
136
137
138 /**
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.
141  * @since_tizen 3.0
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()
155  */
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);
157
158
159 /**
160  * @}
161  */
162
163
164 #ifdef __cplusplus
165 }
166 #endif
167
168
169 #endif /* __CAPI_ZONE_POLICY__ */