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 * @return {@link DLP_ErrCode#ERR_OH_SUCCESS} 0 - If the operation is successful. 90 * {@link DLP_ErrCode#ERR_OH_INVALID_PARAMETER} 19100001 - If the parameter value is invalid. 91 * {@link DLP_ErrCode#ERR_OH_API_ONLY_FOR_SANDBOX} 19100006 - If no permission to 92 * call this API, which is available only for DLP sandbox applications. 93 * {@link DLP_ErrCode#ERR_OH_SYSTEM_SERVICE_EXCEPTION} 19100011 - If the system ability 94 * works abnormally. 95 * {@link DLP_ErrCode#ERR_OH_OUT_OF_MEMORY} 19100012 - If the memory error. 96 * @since 14 97 */ 98 DLP_ErrCode OH_DLP_GetDlpPermissionInfo(DLP_FileAccess *dlpFileAccess, uint32_t *flags); 99 100 /** 101 * @brief Obtains the original file name from a DLP file name. 102 * This method removes the DLP file name extension from the DLP file name. 103 * 104 * @param fileName - Indicates the DLP file name. 105 * @param originalFileName - Indicates the original file name obtained. 106 * @return {@link DLP_ErrCode#ERR_OH_SUCCESS} 0 - If the operation is successful. 107 * {@link DLP_ErrCode#ERR_OH_INVALID_PARAMS} 19100001 - If the parameter value is invalid. 108 * {@link DLP_ErrCode#ERR_OH_OUT_OF_MEMORY} 19100012 - If the memory error. 109 * @since 14 110 */ 111 DLP_ErrCode OH_DLP_GetOriginalFileName(const char *fileName, char **originalFileName); 112 113 /** 114 * @brief Checks whether current application is in the DLP sandbox. 115 * 116 * @param isInSandbox - Indicates output parameter, 117 * {@code true} if current application is in a DLP sandbox, {@code false} otherwise. 118 * @return {@link DLP_ErrCode#ERR_OH_SUCCESS} 0 - If the operation is successful. 119 * {@link DLP_ErrCode#ERR_OH_SYSTEM_SERVICE_EXCEPTION} 19100011 - If the system ability 120 * works abnormally. 121 * {@link DLP_ErrCode#ERR_OH_OUT_OF_MEMORY} 19100012 - If the memory error. 122 * @since 14 123 */ 124 DLP_ErrCode OH_DLP_IsInSandbox(bool *isInSandbox); 125 126 /** 127 * @brief Sets sandbox application configuration. 128 * 129 * @param configInfo - Configuration of the sandbox application. 130 * @return {@link DLP_ErrCode#ERR_OH_SUCCESS} 0 - If the operation is successful. 131 * {@link DLP_ErrCode#ERR_OH_INVALID_PARAMETER} 19100001 - If the parameter value is invalid. 132 * {@link DLP_ErrCode#ERR_OH_API_NOT_FOR_SANDBOX} 19100007 - If no permission to 133 * call this API, which is available only for non-DLP sandbox applications. 134 * {@link DLP_ErrCode#ERR_OH_SYSTEM_SERVICE_EXCEPTION} 19100011 - If the system ability 135 * works abnormally. 136 * {@link DLP_ErrCode#ERR_OH_APPLICATION_NOT_AUTHORIZED} 19100018 - If not authorized application. 137 * @since 14 138 */ 139 DLP_ErrCode OH_DLP_SetSandboxAppConfig(const char *configInfo); 140 141 /** 142 * @brief Obtains sandbox application configuration. 143 * 144 * @param configInfo - Configuration of the sandbox application. 145 * @return {@link DLP_ErrCode#ERR_OH_SUCCESS} 0 - If the operation is successful. 146 * {@link DLP_ErrCode#ERR_OH_SYSTEM_SERVICE_EXCEPTION} 19100011 - If the system ability 147 * works abnormally. 148 * {@link DLP_ErrCode#ERR_OH_OUT_OF_MEMORY} 19100012 - If the memory error. 149 * {@link DLP_ErrCode#ERR_OH_APPLICATION_NOT_AUTHORIZED} 19100018 - If not authorized application. 150 * @since 14 151 */ 152 DLP_ErrCode OH_DLP_GetSandboxAppConfig(char **configInfo); 153 154 /** 155 * @brief Cleans sandbox application configuration. 156 * 157 * @return {@link DLP_ErrCode#ERR_OH_SUCCESS} 0 - If the operation is successful. 158 * {@link DLP_ErrCode#ERR_OH_API_NOT_FOR_SANDBOX} 19100007 - If no permission to 159 * call this API, which is available only for non-DLP sandbox applications. 160 * {@link DLP_ErrCode#ERR_OH_SYSTEM_SERVICE_EXCEPTION} 19100011 - If the system ability 161 * works abnormally. 162 * {@link DLP_ErrCode#ERR_OH_APPLICATION_NOT_AUTHORIZED} 19100018 - If not authorized application. 163 * @since 14 164 */ 165 DLP_ErrCode OH_DLP_CleanSandboxAppConfig(); 166 167 #ifdef __cplusplus 168 } 169 #endif 170 171 /** @} */ 172 #endif /* DLP_PERMISSION_API_H */