17777dab0Sopenharmony_ci/*
27777dab0Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
37777dab0Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
47777dab0Sopenharmony_ci * you may not use this file except in compliance with the License.
57777dab0Sopenharmony_ci * You may obtain a copy of the License at
67777dab0Sopenharmony_ci *
77777dab0Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
87777dab0Sopenharmony_ci *
97777dab0Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
107777dab0Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
117777dab0Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
127777dab0Sopenharmony_ci * See the License for the specific language governing permissions and
137777dab0Sopenharmony_ci * limitations under the License.
147777dab0Sopenharmony_ci */
157777dab0Sopenharmony_ci
167777dab0Sopenharmony_ci/**
177777dab0Sopenharmony_ci * @addtogroup DlpPermissionApi
187777dab0Sopenharmony_ci * @{
197777dab0Sopenharmony_ci *
207777dab0Sopenharmony_ci * @brief Provides the capability to access the data loss prevention (DLP) files.
217777dab0Sopenharmony_ci *
227777dab0Sopenharmony_ci * @since 13
237777dab0Sopenharmony_ci */
247777dab0Sopenharmony_ci
257777dab0Sopenharmony_ci/**
267777dab0Sopenharmony_ci * @file dlp_permission_api.h
277777dab0Sopenharmony_ci *
287777dab0Sopenharmony_ci * @brief Declares the APIs for accessing the data loss prevention (DLP) files.
297777dab0Sopenharmony_ci *
307777dab0Sopenharmony_ci * @library libohdlp_permission.so
317777dab0Sopenharmony_ci * @kit DataProtectionKit
327777dab0Sopenharmony_ci * @syscap SystemCapability.Security.DataLossPrevention
337777dab0Sopenharmony_ci * @since 13
347777dab0Sopenharmony_ci */
357777dab0Sopenharmony_ci
367777dab0Sopenharmony_ci#ifndef DLP_PERMISSION_API_H
377777dab0Sopenharmony_ci#define DLP_PERMISSION_API_H
387777dab0Sopenharmony_ci
397777dab0Sopenharmony_ci#include <stdbool.h>
407777dab0Sopenharmony_ci#include <stdint.h>
417777dab0Sopenharmony_ci
427777dab0Sopenharmony_ci#ifdef __cplusplus
437777dab0Sopenharmony_ciextern "C" {
447777dab0Sopenharmony_ci#endif
457777dab0Sopenharmony_ci
467777dab0Sopenharmony_ci/**
477777dab0Sopenharmony_ci * @brief Enumerates the error codes.
487777dab0Sopenharmony_ci *
497777dab0Sopenharmony_ci * @since 13
507777dab0Sopenharmony_ci */
517777dab0Sopenharmony_citypedef enum {
527777dab0Sopenharmony_ci    /** @error The operation is successful. */
537777dab0Sopenharmony_ci    ERR_OH_SUCCESS = 0,
547777dab0Sopenharmony_ci    /** @error Invalid parameter value. */
557777dab0Sopenharmony_ci    ERR_OH_INVALID_PARAMETER = 19100001,
567777dab0Sopenharmony_ci    /** @error No permission to call this API, which is available only for DLP sandbox applications. */
577777dab0Sopenharmony_ci    ERR_OH_API_ONLY_FOR_SANDBOX = 19100006,
587777dab0Sopenharmony_ci    /** @error No permission to call this API, which is available only for non-DLP sandbox applications. */
597777dab0Sopenharmony_ci    ERR_OH_API_NOT_FOR_SANDBOX = 19100007,
607777dab0Sopenharmony_ci    /** @error The system ability works abnormally. */
617777dab0Sopenharmony_ci    ERR_OH_SYSTEM_SERVICE_EXCEPTION = 19100011,
627777dab0Sopenharmony_ci    /** @error Indicates the memory error. */
637777dab0Sopenharmony_ci    ERR_OH_OUT_OF_MEMORY = 19100012,
647777dab0Sopenharmony_ci    /** @error DisplayName missing in want. */
657777dab0Sopenharmony_ci    ERR_OH_APPLICATION_NOT_AUTHORIZED = 19100018
667777dab0Sopenharmony_ci} DLP_ErrCode;
677777dab0Sopenharmony_ci
687777dab0Sopenharmony_ci/**
697777dab0Sopenharmony_ci * @brief Enumerates the access permissions for a DLP file.
707777dab0Sopenharmony_ci *
717777dab0Sopenharmony_ci * @since 13
727777dab0Sopenharmony_ci */
737777dab0Sopenharmony_citypedef enum {
747777dab0Sopenharmony_ci    /** No permission. */
757777dab0Sopenharmony_ci    NO_PERMISSION = 0,
767777dab0Sopenharmony_ci    /** Read-only. */
777777dab0Sopenharmony_ci    READ_ONLY = 1,
787777dab0Sopenharmony_ci    /** Edit. */
797777dab0Sopenharmony_ci    CONTENT_EDIT = 2,
807777dab0Sopenharmony_ci    /** Full control. */
817777dab0Sopenharmony_ci    FULL_CONTROL = 3
827777dab0Sopenharmony_ci} DLP_FileAccess;
837777dab0Sopenharmony_ci
847777dab0Sopenharmony_ci/**
857777dab0Sopenharmony_ci * @brief Obtains the permission info of this DLP file.
867777dab0Sopenharmony_ci *
877777dab0Sopenharmony_ci * @param dlpFileAccess - Indicates the access permission for the DLP file.
887777dab0Sopenharmony_ci * @param flags - Indicates the actions allowed for the DLP file.
897777dab0Sopenharmony_ci * @return {@link DLP_ErrCode#ERR_OH_SUCCESS} 0 - If the operation is successful.
907777dab0Sopenharmony_ci *         {@link DLP_ErrCode#ERR_OH_INVALID_PARAMETER} 19100001 - If the parameter value is invalid.
917777dab0Sopenharmony_ci *         {@link DLP_ErrCode#ERR_OH_API_ONLY_FOR_SANDBOX} 19100006 - If no permission to
927777dab0Sopenharmony_ci *             call this API, which is available only for DLP sandbox applications.
937777dab0Sopenharmony_ci *         {@link DLP_ErrCode#ERR_OH_SYSTEM_SERVICE_EXCEPTION} 19100011 - If the system ability
947777dab0Sopenharmony_ci *             works abnormally.
957777dab0Sopenharmony_ci *         {@link DLP_ErrCode#ERR_OH_OUT_OF_MEMORY} 19100012 - If the memory error.
967777dab0Sopenharmony_ci * @since 13
977777dab0Sopenharmony_ci */
987777dab0Sopenharmony_ciDLP_ErrCode OH_DLP_GetDlpPermissionInfo(DLP_FileAccess *dlpFileAccess, uint32_t *flags);
997777dab0Sopenharmony_ci
1007777dab0Sopenharmony_ci/**
1017777dab0Sopenharmony_ci * @brief Obtains the original file name from a DLP file name.
1027777dab0Sopenharmony_ci *        This method removes the DLP file name extension from the DLP file name.
1037777dab0Sopenharmony_ci *
1047777dab0Sopenharmony_ci * @param fileName - Indicates the DLP file name.
1057777dab0Sopenharmony_ci * @param originalFileName - Indicates the original file name obtained.
1067777dab0Sopenharmony_ci * @return {@link DLP_ErrCode#ERR_OH_SUCCESS} 0 - If the operation is successful.
1077777dab0Sopenharmony_ci *         {@link DLP_ErrCode#ERR_OH_INVALID_PARAMS} 19100001 - If the parameter value is invalid.
1087777dab0Sopenharmony_ci *         {@link DLP_ErrCode#ERR_OH_OUT_OF_MEMORY} 19100012 - If the memory error.
1097777dab0Sopenharmony_ci * @since 13
1107777dab0Sopenharmony_ci */
1117777dab0Sopenharmony_ciDLP_ErrCode OH_DLP_GetOriginalFileName(const char *fileName, char **originalFileName);
1127777dab0Sopenharmony_ci
1137777dab0Sopenharmony_ci/**
1147777dab0Sopenharmony_ci * @brief Checks whether current application is in the DLP sandbox.
1157777dab0Sopenharmony_ci *
1167777dab0Sopenharmony_ci * @param isInSandbox - Indicates output parameter,
1177777dab0Sopenharmony_ci *                      {@code true} if current application is in a DLP sandbox, {@code false} otherwise.
1187777dab0Sopenharmony_ci * @return {@link DLP_ErrCode#ERR_OH_SUCCESS} 0 - If the operation is successful.
1197777dab0Sopenharmony_ci *         {@link DLP_ErrCode#ERR_OH_SYSTEM_SERVICE_EXCEPTION} 19100011 - If the system ability
1207777dab0Sopenharmony_ci *             works abnormally.
1217777dab0Sopenharmony_ci *         {@link DLP_ErrCode#ERR_OH_OUT_OF_MEMORY} 19100012 - If the memory error.
1227777dab0Sopenharmony_ci * @since 13
1237777dab0Sopenharmony_ci */
1247777dab0Sopenharmony_ciDLP_ErrCode OH_DLP_IsInSandbox(bool *isInSandbox);
1257777dab0Sopenharmony_ci
1267777dab0Sopenharmony_ci/**
1277777dab0Sopenharmony_ci * @brief Sets sandbox application configuration.
1287777dab0Sopenharmony_ci *
1297777dab0Sopenharmony_ci * @param configInfo - Configuration of the sandbox application.
1307777dab0Sopenharmony_ci * @return {@link DLP_ErrCode#ERR_OH_SUCCESS} 0 - If the operation is successful.
1317777dab0Sopenharmony_ci *         {@link DLP_ErrCode#ERR_OH_INVALID_PARAMETER} 19100001 - If the parameter value is invalid.
1327777dab0Sopenharmony_ci *         {@link DLP_ErrCode#ERR_OH_API_NOT_FOR_SANDBOX} 19100007 - If no permission to
1337777dab0Sopenharmony_ci *             call this API, which is available only for non-DLP sandbox applications.
1347777dab0Sopenharmony_ci *         {@link DLP_ErrCode#ERR_OH_SYSTEM_SERVICE_EXCEPTION} 19100011 - If the system ability
1357777dab0Sopenharmony_ci *             works abnormally.
1367777dab0Sopenharmony_ci *         {@link DLP_ErrCode#ERR_OH_APPLICATION_NOT_AUTHORIZED} 19100018 - If not authorized application.
1377777dab0Sopenharmony_ci * @since 13
1387777dab0Sopenharmony_ci */
1397777dab0Sopenharmony_ciDLP_ErrCode OH_DLP_SetSandboxAppConfig(const char *configInfo);
1407777dab0Sopenharmony_ci
1417777dab0Sopenharmony_ci/**
1427777dab0Sopenharmony_ci * @brief Obtains sandbox application configuration.
1437777dab0Sopenharmony_ci *
1447777dab0Sopenharmony_ci * @param configInfo - Configuration of the sandbox application.
1457777dab0Sopenharmony_ci * @return {@link DLP_ErrCode#ERR_OH_SUCCESS} 0 - If the operation is successful.
1467777dab0Sopenharmony_ci *         {@link DLP_ErrCode#ERR_OH_SYSTEM_SERVICE_EXCEPTION} 19100011 - If the system ability
1477777dab0Sopenharmony_ci *             works abnormally.
1487777dab0Sopenharmony_ci *         {@link DLP_ErrCode#ERR_OH_OUT_OF_MEMORY} 19100012 - If the memory error.
1497777dab0Sopenharmony_ci *         {@link DLP_ErrCode#ERR_OH_APPLICATION_NOT_AUTHORIZED} 19100018 - If not authorized application.
1507777dab0Sopenharmony_ci * @since 13
1517777dab0Sopenharmony_ci */
1527777dab0Sopenharmony_ciDLP_ErrCode OH_DLP_GetSandboxAppConfig(char **configInfo);
1537777dab0Sopenharmony_ci
1547777dab0Sopenharmony_ci/**
1557777dab0Sopenharmony_ci * @brief Cleans sandbox application configuration.
1567777dab0Sopenharmony_ci *
1577777dab0Sopenharmony_ci * @return {@link DLP_ErrCode#ERR_OH_SUCCESS} 0 - If the operation is successful.
1587777dab0Sopenharmony_ci *         {@link DLP_ErrCode#ERR_OH_API_NOT_FOR_SANDBOX} 19100007 - If no permission to
1597777dab0Sopenharmony_ci *             call this API, which is available only for non-DLP sandbox applications.
1607777dab0Sopenharmony_ci *         {@link DLP_ErrCode#ERR_OH_SYSTEM_SERVICE_EXCEPTION} 19100011 - If the system ability
1617777dab0Sopenharmony_ci *             works abnormally.
1627777dab0Sopenharmony_ci *         {@link DLP_ErrCode#ERR_OH_APPLICATION_NOT_AUTHORIZED} 19100018 - If not authorized application.
1637777dab0Sopenharmony_ci * @since 13
1647777dab0Sopenharmony_ci */
1657777dab0Sopenharmony_ciDLP_ErrCode OH_DLP_CleanSandboxAppConfig();
1667777dab0Sopenharmony_ci
1677777dab0Sopenharmony_ci#ifdef __cplusplus
1687777dab0Sopenharmony_ci}
1697777dab0Sopenharmony_ci#endif
1707777dab0Sopenharmony_ci
1717777dab0Sopenharmony_ci/** @} */
1727777dab0Sopenharmony_ci#endif /* DLP_PERMISSION_API_H */