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 resourcemanager
18 * @{
19 *
20 * @brief Provides the c interface to obtain resources, and relies on librawfile.z.so when used.
21 *
22 * @since 12
23 */
24
25/**
26 * @file resmgr_common.h
27 *
28 * @brief Provides the structure required by the interface.
29 * @syscap SystemCapability.Global.ResourceManager
30 * @library libohresmgr.so
31 * @kit LocalizationKit
32 * @since 12
33 */
34#ifndef GLOBAL_RESMGR_COMMON_H
35#define GLOBAL_RESMGR_COMMON_H
36
37# include <stdint.h>
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
43/**
44 * @brief The error code of resource manager.
45 *
46 * @since 12
47 */
48typedef enum ResourceManager_ErrorCode {
49    /** @error Success */
50    SUCCESS = 0,
51    /** @error Invalid input parameter */
52    ERROR_CODE_INVALID_INPUT_PARAMETER = 401,
53    /** @error Invalid resource ID */
54    ERROR_CODE_RES_ID_NOT_FOUND = 9001001,
55    /** @error Invalid resource name */
56    ERROR_CODE_RES_NOT_FOUND_BY_ID = 9001002,
57    /** @error No matching resource is found based on the resource ID */
58    ERROR_CODE_RES_NAME_NOT_FOUND = 9001003,
59    /** @error No matching resource is found based on the resource name */
60    ERROR_CODE_RES_NOT_FOUND_BY_NAME = 9001004,
61    /** @error Invalid relative path */
62    ERROR_CODE_RES_PATH_INVALID = 9001005,
63    /** @error The resource is referenced cyclically */
64    ERROR_CODE_RES_REF_TOO_MUCH = 9001006,
65    /** @error Failed to format the resource obtained based on the resource ID */
66    ERROR_CODE_RES_ID_FORMAT_ERROR = 9001007,
67    /** @error Failed to format the resource obtained based on the resource Name */
68    ERROR_CODE_RES_NAME_FORMAT_ERROR = 9001008,
69    /** @error Failed to access the system resource */
70    ERROR_CODE_SYSTEM_RES_MANAGER_GET_FAILED = 9001009,
71    /** @error Invalid overlay path */
72    ERROR_CODE_OVERLAY_RES_PATH_INVALID = 9001010,
73    /** @error Out of memory */
74    ERROR_CODE_OUT_OF_MEMORY = 9001100,
75} ResourceManager_ErrorCode;
76
77/**
78 * @brief Enumerates screen directions.
79 *
80 * @since 12
81 */
82typedef enum ResourceManager_Direction {
83    /** Indicates the vertical direction. */
84    DIRECTION_VERTICAL = 0,
85    /** Indicates the horizontal direction. */
86    DIRECTION_HORIZONTAL = 1,
87} ResourceManager_Direction;
88
89/**
90 * @brief Enumerates color mode types.
91 *
92 * @since 12
93 */
94typedef enum ResourceManager_ColorMode {
95    /** Indicates dark mode. */
96    COLOR_MODE_DARK = 0,
97    /** Indicates light mode. */
98    COLOR_MODE_LIGHT = 1,
99} ResourceManager_ColorMode;
100
101/**
102 * @brief Enumerates device types.
103 *
104 * @since 12
105 */
106typedef enum ResourceManager_DeviceType {
107    /** Indicates a phone. */
108    DEVICE_TYPE_PHONE = 0X00,
109    /** Indicates a tablet. */
110    DEVICE_TYPE_TABLET = 0x01,
111    /** Indicates a car. */
112    DEVICE_TYPE_CAR = 0x02,
113    /** Indicates a PC. */
114    DEVICE_TYPE_PC = 0x03,
115    /** Indicates a smart TV. */
116    DEVICE_TYPE_TV = 0x04,
117    /** Indicates a wearable device. */
118    DEVICE_TYPE_WEARABLE = 0x06,
119    /** Indicates a 2in1 device. */
120    DEVICE_TYPE_2IN1 = 0x07,
121} ResourceManager_DeviceType;
122
123/**
124 * @brief Enumerates screen density types.
125 *
126 * @since 12
127 */
128typedef enum ScreenDensity {
129    /** Indicates small screen density. */
130    SCREEN_SDPI = 120,
131    /** Indicates medium screen density. */
132    SCREEN_MDPI = 160,
133    /** Indicates large screen density. */
134    SCREEN_LDPI = 240,
135    /** Indicates extra-large screen density. */
136    SCREEN_XLDPI = 320,
137    /** Indicates extra-extra-large screen density. */
138    SCREEN_XXLDPI = 480,
139    /** Indicates extra-extra-extra-large screen density. */
140    SCREEN_XXXLDPI = 640,
141} ScreenDensity;
142
143/**
144 * @brief Enumerates device configuration.
145 *
146 * @since 12
147 */
148typedef struct ResourceManager_Configuration {
149    /** Indicates the screen direction of the current device. */
150    ResourceManager_Direction direction;
151    /** Indicates the current system language, for example, zh-Hans-CN. */
152    char* locale;
153    /** Indicates the device type. */
154    ResourceManager_DeviceType deviceType;
155    /** Indicates the screen density. */
156    ScreenDensity screenDensity;
157    /** Indicates the color mode. */
158    ResourceManager_ColorMode colorMode;
159    /** Indicates the mcc. */
160    uint32_t mcc;
161    /** Indicates the mnc. */
162    uint32_t mnc;
163    /** Reserved attributes. */
164    uint32_t reserved[20];
165} ResourceManager_Configuration;
166#ifdef __cplusplus
167};
168#endif
169
170/** @} */
171#endif // GLOBAL_RESMGR_COMMON_H
172