• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  * @addtogroup DlpPermissionApi
18  * @{
19  *
20  * @brief Provides the capability to access the data loss prevention (DLP) files.
21  *
22  * @since 14
23  */
24 
25 /**
26  * @file dlp_permission_api.h
27  *
28  * @brief Declares the APIs for accessing the data loss prevention (DLP) files.
29  *
30  * @library libohdlp_permission.so
31  * @kit DataProtectionKit
32  * @syscap SystemCapability.Security.DataLossPrevention
33  * @since 14
34  */
35 
36 #ifndef DLP_PERMISSION_API_H
37 #define DLP_PERMISSION_API_H
38 
39 #include <stdbool.h>
40 #include <stdint.h>
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /**
47  * @brief Enumerates the error codes.
48  *
49  * @since 14
50  */
51 typedef enum {
52     /** @error The operation is successful. */
53     ERR_OH_SUCCESS = 0,
54     /** @error Invalid parameter value. */
55     ERR_OH_INVALID_PARAMETER = 19100001,
56     /** @error No permission to call this API, which is available only for DLP sandbox applications. */
57     ERR_OH_API_ONLY_FOR_SANDBOX = 19100006,
58     /** @error No permission to call this API, which is available only for non-DLP sandbox applications. */
59     ERR_OH_API_NOT_FOR_SANDBOX = 19100007,
60     /** @error The system ability works abnormally. */
61     ERR_OH_SYSTEM_SERVICE_EXCEPTION = 19100011,
62     /** @error Indicates the memory error. */
63     ERR_OH_OUT_OF_MEMORY = 19100012,
64     /** @error DisplayName missing in want. */
65     ERR_OH_APPLICATION_NOT_AUTHORIZED = 19100018
66 } DLP_ErrCode;
67 
68 /**
69  * @brief Enumerates the access permissions for a DLP file.
70  *
71  * @since 14
72  */
73 typedef enum {
74     /** No permission. */
75     NO_PERMISSION = 0,
76     /** Read-only. */
77     READ_ONLY = 1,
78     /** Edit. */
79     CONTENT_EDIT = 2,
80     /** Full control. */
81     FULL_CONTROL = 3
82 } DLP_FileAccess;
83 
84 /**
85  * @brief Obtains the permission info of this DLP file.
86  *
87  * @param dlpFileAccess - Indicates the access permission for the DLP file.
88  * @param flags - Indicates the actions allowed for the DLP file.
89  *              0x00000000 - No file permissions.
90  *              0x00000001 - File view permission.
91  *              0x00000002 - File save permission.
92  *              0x00000004 - File save-as permission.
93  *              0x00000008 - File edit permission.
94  *              0x00000010 - File screenshot permission.
95  *              0x00000020 - File screen-sharing permission.
96  *              0x00000040 - File screen-recording permission.
97  *              0x00000080 - File copy permission.
98  *              0x00000100 - File print permission.
99  *              0x00000200 - File export permission.
100  *              0x00000400 - File permission modification permission.
101  * @return {@link DLP_ErrCode#ERR_OH_SUCCESS} 0 - If the operation is successful.
102  *         {@link DLP_ErrCode#ERR_OH_INVALID_PARAMETER} 19100001 - If the parameter value is invalid.
103  *         {@link DLP_ErrCode#ERR_OH_API_ONLY_FOR_SANDBOX} 19100006 - If no permission to
104  *             call this API, which is available only for DLP sandbox applications.
105  *         {@link DLP_ErrCode#ERR_OH_SYSTEM_SERVICE_EXCEPTION} 19100011 - If the system ability
106  *             works abnormally.
107  *         {@link DLP_ErrCode#ERR_OH_OUT_OF_MEMORY} 19100012 - If the memory error.
108  * @since 14
109  */
110 DLP_ErrCode OH_DLP_GetDlpPermissionInfo(DLP_FileAccess *dlpFileAccess, uint32_t *flags);
111 
112 /**
113  * @brief Obtains the original file name from a DLP file name.
114  *        This method removes the DLP file name extension from the DLP file name.
115  *
116  * @param fileName - Indicates the DLP file name.
117  * @param originalFileName - Indicates the original file name obtained.
118  * @return {@link DLP_ErrCode#ERR_OH_SUCCESS} 0 - If the operation is successful.
119  *         {@link DLP_ErrCode#ERR_OH_INVALID_PARAMS} 19100001 - If the parameter value is invalid.
120  *         {@link DLP_ErrCode#ERR_OH_OUT_OF_MEMORY} 19100012 - If the memory error.
121  * @since 14
122  */
123 DLP_ErrCode OH_DLP_GetOriginalFileName(const char *fileName, char **originalFileName);
124 
125 /**
126  * @brief Checks whether current application is in the DLP sandbox.
127  *
128  * @param isInSandbox - Indicates output parameter,
129  *                      {@code true} if current application is in a DLP sandbox, {@code false} otherwise.
130  * @return {@link DLP_ErrCode#ERR_OH_SUCCESS} 0 - If the operation is successful.
131  *         {@link DLP_ErrCode#ERR_OH_SYSTEM_SERVICE_EXCEPTION} 19100011 - If the system ability
132  *             works abnormally.
133  *         {@link DLP_ErrCode#ERR_OH_OUT_OF_MEMORY} 19100012 - If the memory error.
134  * @since 14
135  */
136 DLP_ErrCode OH_DLP_IsInSandbox(bool *isInSandbox);
137 
138 /**
139  * @brief Sets sandbox application configuration.
140  *
141  * @param configInfo - Configuration of the sandbox application.
142  * @return {@link DLP_ErrCode#ERR_OH_SUCCESS} 0 - If the operation is successful.
143  *         {@link DLP_ErrCode#ERR_OH_INVALID_PARAMETER} 19100001 - If the parameter value is invalid.
144  *         {@link DLP_ErrCode#ERR_OH_API_NOT_FOR_SANDBOX} 19100007 - If no permission to
145  *             call this API, which is available only for non-DLP sandbox applications.
146  *         {@link DLP_ErrCode#ERR_OH_SYSTEM_SERVICE_EXCEPTION} 19100011 - If the system ability
147  *             works abnormally.
148  *         {@link DLP_ErrCode#ERR_OH_APPLICATION_NOT_AUTHORIZED} 19100018 - If the application is not authorized.
149  * @since 14
150  */
151 DLP_ErrCode OH_DLP_SetSandboxAppConfig(const char *configInfo);
152 
153 /**
154  * @brief Obtains sandbox application configuration.
155  *
156  * @param configInfo - Configuration of the sandbox application.
157  * @return {@link DLP_ErrCode#ERR_OH_SUCCESS} 0 - If the operation is successful.
158  *         {@link DLP_ErrCode#ERR_OH_SYSTEM_SERVICE_EXCEPTION} 19100011 - If the system ability
159  *             works abnormally.
160  *         {@link DLP_ErrCode#ERR_OH_OUT_OF_MEMORY} 19100012 - If the memory error.
161  *         {@link DLP_ErrCode#ERR_OH_APPLICATION_NOT_AUTHORIZED} 19100018 - If the application is not authorized.
162  * @since 14
163  */
164 DLP_ErrCode OH_DLP_GetSandboxAppConfig(char **configInfo);
165 
166 /**
167  * @brief Cleans sandbox application configuration.
168  *
169  * @return {@link DLP_ErrCode#ERR_OH_SUCCESS} 0 - If the operation is successful.
170  *         {@link DLP_ErrCode#ERR_OH_API_NOT_FOR_SANDBOX} 19100007 - If no permission to
171  *             call this API, which is available only for non-DLP sandbox applications.
172  *         {@link DLP_ErrCode#ERR_OH_SYSTEM_SERVICE_EXCEPTION} 19100011 - If the system ability
173  *             works abnormally.
174  *         {@link DLP_ErrCode#ERR_OH_APPLICATION_NOT_AUTHORIZED} 19100018 - If the application is not authorized.
175  * @since 14
176  */
177 DLP_ErrCode OH_DLP_CleanSandboxAppConfig();
178 
179 #ifdef __cplusplus
180 }
181 #endif
182 
183 /** @} */
184 #endif /* DLP_PERMISSION_API_H */