1# DlpPermissionApi 2 3 4## Overview 5 6Data loss prevention (DLP) is a system solution provided to prevent data disclosure. The **dlppermissionapi** file provides APIs for cross-device file access management, encrypted storage, and access authorization. 7 8**Since**: 14 9 10 11## Summary 12 13 14### Files 15 16| Name| Description| 17| -------- | -------- | 18| [dlp_permission_api.h](dlp__permission__api_8h.md) | Defines the APIs for cross-device file access management, encrypted storage, and access authorization. | 19 20 21### Enums 22 23| Name| Description| 24| -------- | -------- | 25| [DLP_ErrCode](#dlp_errcode) {<br>ERR_OH_SUCCESS = 0,<br>ERR_OH_INVALID_PARAMETER = 19100001,<br>ERR_OH_API_ONLY_FOR_SANDBOX = 19100006,<br>ERR_OH_API_NOT_FOR_SANDBOX = 19100007,<br>ERR_OH_SYSTEM_SERVICE_EXCEPTION = 19100011,<br>ERR_OH_OUT_OF_MEMORY = 19100012,<br>ERR_OH_APPLICATION_NOT_AUTHORIZED = 19100018<br>} | Enumerates the DLP error codes.| 26| [DLP_FileAccess](#dlp_fileaccess) {<br>NO_PERMISSION = 0,<br>READ_ONLY = 1,<br>CONTENT_EDIT = 2,<br>FULL_CONTROL = 3<br>} | Enumerates the permissions on a DLP file.| 27 28 29### Functions 30 31| Name| Description| 32| -------- | -------- | 33| [DLP_ErrCode](#dlp_errcode) [OH_DLP_GetDlpPermissionInfo](#oh_dlp_getdlppermissioninfo) ([DLP_FileAccess](#dlp_fileaccess) \*dlpFileAccess, uint32_t \*flags) | Obtains the permission information of this DLP file.| 34| [DLP_ErrCode](#dlp_errcode) [OH_DLP_GetOriginalFileName](#oh_dlp_getoriginalfilename) (const char \*fileName, char \*\*originalFileName) | Obtains the original file name of a DLP file.| 35| [DLP_ErrCode](#dlp_errcode) [OH_DLP_IsInSandbox](#oh_dlp_isinsandbox) (bool \*isInSandbox) | Checks whether this application is running in a DLP sandbox environment.| 36| [DLP_ErrCode](#dlp_errcode) [OH_DLP_SetSandboxAppConfig](#oh_dlp_setsandboxappconfig) (const char \*configInfo) | Sets sandbox application configuration.| 37| [DLP_ErrCode](#dlp_errcode) [OH_DLP_GetSandboxAppConfig](#oh_dlp_getsandboxappconfig) (char \*\*configInfo) | Obtains the sandbox application configuration.| 38| [DLP_ErrCode](#dlp_errcode) [OH_DLP_CleanSandboxAppConfig](#oh_dlp_cleansandboxappconfig) () | Cleans the sandbox application configuration.| 39 40 41## Enum Description 42 43 44### DLP_ErrCode 45 46``` 47enum DLP_ErrCode 48``` 49 50**Description** 51 52Enumerates the DLP error codes. 53 54**Since**: 14 55 56| Value| Description| 57| -------- | -------- | 58| ERR_OH_SUCCESS | The operation is successful.| 59| ERR_OH_INVALID_PARAMETER | Invalid parameters are specified.| 60| ERR_OH_API_ONLY_FOR_SANDBOX | The caller is not a DLP sandbox application.| 61| ERR_OH_API_NOT_FOR_SANDBOX | The API is not available to a DLP sandbox application.| 62| ERR_OH_SYSTEM_SERVICE_EXCEPTION | The system service is abnormal.| 63| ERR_OH_OUT_OF_MEMORY | The memory allocation fails.| 64| ERR_OH_APPLICATION_NOT_AUTHORIZED | The application is not authorized to perform the operation.| 65 66 67### DLP_FileAccess 68 69``` 70enum DLP_FileAccess 71``` 72 73**Description** 74 75Enumerates the permissions on a DLP file. 76 77**Since**: 14 78 79| Value| Description| 80| -------- | -------- | 81| NO_PERMISSION | No permission on the file.| 82| READ_ONLY | Read-only permission.| 83| CONTENT_EDIT | Edit permission.| 84| FULL_CONTROL | Full control.| 85 86 87## Function Description 88 89 90### OH_DLP_GetDlpPermissionInfo() 91 92``` 93DLP_ErrCode OH_DLP_GetDlpPermissionInfo(DLP_FileAccess *dlpFileAccess, uint32_t *flags) 94``` 95 96**Description** 97 98Obtains the permission information of this DLP file. 99 100**Since**: 14 101 102**Parameters** 103 104| Name| Description| 105| -------- | -------- | 106| dlpFileAccess | Pointer to the authorization type of the DLP file for users. For details, see [DLP_FileAccess](#dlp_fileaccess).| 107| flags | Pointer to the operation permissions allowed for the DLP file. The options are as follows:<br>**0x00000000** indicates no permission on the file.<br>**0x00000001** indicates the permission for viewing the file.<br>**0x00000002** indicates the permission for saving the file.<br>**0x00000004** indicates the permission for saving the file as another file.<br>**0x00000008** indicates the permission for editing the file.<br>**0x00000010** indicates the permission for capturing screenshots of the file.<br>**0x00000020** indicates the permission for sharing the screen, on which the file is open.<br>**0x00000040** indicates the permission for recording the screen, on which the file is open.<br>**0x00000080** indicates the permission for copying the file.<br>**0x00000100** indicates the permission for printing the file.<br>**0x00000200** indicates the permission for exporting the file.<br>**0x00000400** indicates the permission for modifying the permissions on the file.| 108 109**Returns** 110 111[DLP_ErrCode](#dlp_errcode): 112 113Returns **0** if the operation is successful. 114 115Returns **19100001** if invalid parameters are detected. 116 117Returns **19100006** when the access is denied for a non-DLP sandbox application. 118 119Returns **19100011** when the system service is abnormal. 120 121Returns **19100012** if the memory allocation fails. 122 123 124### OH_DLP_GetOriginalFileName() 125 126``` 127DLP_ErrCode OH_DLP_GetOriginalFileName(const char *fileName, char **originalFileName) 128``` 129 130**Description** 131 132Obtains the original file name of a DLP file. 133 134**Since**: 14 135 136**Parameters** 137 138| Name| Description| 139| -------- | -------- | 140| fileName | Pointer to the target file whose original file name is to be obtained.| 141| originalFileName | Double pointer to the original file name obtained.| 142 143**Returns** 144 145[DLP_ErrCode](#dlp_errcode): 146 147Returns **0** if the operation is successful. 148 149Returns **19100001** if invalid parameters are detected. 150 151Returns **19100012** if the memory allocation fails. 152 153 154### OH_DLP_IsInSandbox() 155 156``` 157DLP_ErrCode OH_DLP_IsInSandbox(bool *isInSandbox) 158``` 159 160**Description** 161 162Checks whether this application is running in a DLP sandbox environment. 163 164**Since**: 14 165 166**Parameters** 167 168| Name| Description| 169| -------- | -------- | 170| isInSandbox | Pointer to the value indicating whether the application is running in a DLP sandbox environment.| 171 172**Returns** 173 174[DLP_ErrCode](#dlp_errcode): 175 176Returns **0** if the operation is successful. 177 178Returns **19100011** when the system service is abnormal. 179 180Returns **19100012** if the memory allocation fails. 181 182 183### OH_DLP_SetSandboxAppConfig() 184 185``` 186DLP_ErrCode OH_DLP_SetSandboxAppConfig(const char *configInfo) 187``` 188 189**Description** 190 191Sets sandbox application configuration. 192 193**Since**: 14 194 195**Parameters** 196 197| Name| Description| 198| -------- | -------- | 199| configInfo | Pointer to the sandbox application configuration to set.| 200 201**Returns** 202 203[DLP_ErrCode](#dlp_errcode): 204 205Returns **0** if the operation is successful. 206 207Returns **19100001** if invalid parameters are detected. 208 209Returns **19100007** if the API cannot be called by a DLP sandbox application. 210 211Returns **19100011** when the system service is abnormal. 212 213Returns **19100018** if the application is unauthorized. 214 215 216### OH_DLP_GetSandboxAppConfig() 217 218``` 219DLP_ErrCode OH_DLP_GetSandboxAppConfig(char **configInfo) 220``` 221 222**Description** 223 224Obtains the sandbox application configuration. 225 226**Since**: 14 227 228**Parameters** 229 230| Name| Description| 231| -------- | -------- | 232| configInfo | Pointer to the sandbox application configuration obtained.| 233 234**Returns** 235 236[DLP_ErrCode](#dlp_errcode): 237 238Returns **0** if the operation is successful. 239 240Returns **19100011** when the system service is abnormal. 241 242Returns **19100012** if the memory allocation fails. 243 244Returns **19100018** if the application is unauthorized. 245 246 247### OH_DLP_CleanSandboxAppConfig() 248 249``` 250DLP_ErrCode OH_DLP_CleanSandboxAppConfig() 251``` 252 253**Description** 254 255Cleans the sandbox application configuration. 256 257**Since**: 14 258 259**Returns** 260 261[DLP_ErrCode](#dlp_errcode): 262 263Returns **0** if the operation is successful. 264 265Returns **19100007** if the API cannot be called by a DLP sandbox application. 266 267Returns **19100011** when the system service is abnormal. 268 269Returns **19100018** if the application is unauthorized. 270