136a3a8d0Sopenharmony_ci/*
236a3a8d0Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
336a3a8d0Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
436a3a8d0Sopenharmony_ci * you may not use this file except in compliance with the License.
536a3a8d0Sopenharmony_ci * You may obtain a copy of the License at
636a3a8d0Sopenharmony_ci *
736a3a8d0Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
836a3a8d0Sopenharmony_ci *
936a3a8d0Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1036a3a8d0Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1136a3a8d0Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1236a3a8d0Sopenharmony_ci * See the License for the specific language governing permissions and
1336a3a8d0Sopenharmony_ci * limitations under the License.
1436a3a8d0Sopenharmony_ci */
1536a3a8d0Sopenharmony_ci
1636a3a8d0Sopenharmony_ci#ifndef RESOURCE_MANAGER_FFI_H
1736a3a8d0Sopenharmony_ci#define RESOURCE_MANAGER_FFI_H
1836a3a8d0Sopenharmony_ci
1936a3a8d0Sopenharmony_ci#include "ffi_remote_data.h"
2036a3a8d0Sopenharmony_ci#include "cj_common_ffi.h"
2136a3a8d0Sopenharmony_ci#include "resource_manager_log.h"
2236a3a8d0Sopenharmony_ci#include "resource_manager_impl.h"
2336a3a8d0Sopenharmony_ci
2436a3a8d0Sopenharmony_ci#include <cstdint>
2536a3a8d0Sopenharmony_ci
2636a3a8d0Sopenharmony_ciextern "C" {
2736a3a8d0Sopenharmony_ci    struct RetGetNumber {
2836a3a8d0Sopenharmony_ci        bool isInt;
2936a3a8d0Sopenharmony_ci        int intValue;
3036a3a8d0Sopenharmony_ci        float floatValue;
3136a3a8d0Sopenharmony_ci    };
3236a3a8d0Sopenharmony_ci
3336a3a8d0Sopenharmony_ci    struct CResource {
3436a3a8d0Sopenharmony_ci        /** the hap bundle name */
3536a3a8d0Sopenharmony_ci        char* bundleName;
3636a3a8d0Sopenharmony_ci
3736a3a8d0Sopenharmony_ci        /** the hap module name */
3836a3a8d0Sopenharmony_ci        char* moduleName;
3936a3a8d0Sopenharmony_ci
4036a3a8d0Sopenharmony_ci        /** the resource id in hap */
4136a3a8d0Sopenharmony_ci        int32_t id;
4236a3a8d0Sopenharmony_ci    };
4336a3a8d0Sopenharmony_ci
4436a3a8d0Sopenharmony_ci    struct RetDataU32 {
4536a3a8d0Sopenharmony_ci        int32_t code;
4636a3a8d0Sopenharmony_ci        uint32_t data;
4736a3a8d0Sopenharmony_ci    };
4836a3a8d0Sopenharmony_ci
4936a3a8d0Sopenharmony_ci    FFI_EXPORT int64_t CJ_GetResourceManagerStageMode(OHOS::AbilityRuntime::Context* context);
5036a3a8d0Sopenharmony_ci    FFI_EXPORT RetDataI64 CJ_GetSystemResMgr();
5136a3a8d0Sopenharmony_ci    FFI_EXPORT int32_t CJ_CloseRawFd(int64_t id, const char* path);
5236a3a8d0Sopenharmony_ci    FFI_EXPORT int32_t CJ_GetRawFd(int64_t id, const char* rawFileName,
5336a3a8d0Sopenharmony_ci        OHOS::Global::Resource::ResourceManager::RawFileDescriptor &descriptor);
5436a3a8d0Sopenharmony_ci    FFI_EXPORT RetDataCArrUI8 CJ_GetRawFileContent(int64_t id, const char* path);
5536a3a8d0Sopenharmony_ci    FFI_EXPORT RetDataCArrString CJ_GetRawFileList(int64_t id, const char* path);
5636a3a8d0Sopenharmony_ci    FFI_EXPORT RetDataCString CJ_GetPluralStringValue(int64_t id, uint32_t resId, int64_t num);
5736a3a8d0Sopenharmony_ci    FFI_EXPORT RetDataCString CJ_GetPluralStringValueByResource(int64_t id, CResource resource, int64_t num);
5836a3a8d0Sopenharmony_ci    FFI_EXPORT RetDataCString CJ_GetPluralStringByName(int64_t id, const char* name, int64_t quantity);
5936a3a8d0Sopenharmony_ci    FFI_EXPORT RetDataCArrString CJ_GetStringArrayValue(int64_t id, uint32_t resId);
6036a3a8d0Sopenharmony_ci    FFI_EXPORT RetDataCArrString CJ_GetStringArrayValueByResource(int64_t id, CResource resource);
6136a3a8d0Sopenharmony_ci    FFI_EXPORT RetDataCArrString CJ_GetStringArrayByName(int64_t id, const char *name);
6236a3a8d0Sopenharmony_ci    FFI_EXPORT RetDataCString CJ_GetString(int64_t id, uint32_t resId);
6336a3a8d0Sopenharmony_ci    FFI_EXPORT RetDataCString CJ_GetStringByResource(int64_t id, CResource resource);
6436a3a8d0Sopenharmony_ci    FFI_EXPORT RetDataCString CJ_GetStringByName(int64_t id, const char* name);
6536a3a8d0Sopenharmony_ci    FFI_EXPORT int32_t CJ_GetColorByName(int64_t id, const char* name, uint32_t &data);
6636a3a8d0Sopenharmony_ci    FFI_EXPORT int32_t CJ_GetColor(int64_t id, uint32_t resId, uint32_t &data);
6736a3a8d0Sopenharmony_ci    FFI_EXPORT int32_t CJ_GetColorByResource(int64_t id, CResource resource, uint32_t &data);
6836a3a8d0Sopenharmony_ci    FFI_EXPORT int32_t CJ_GetBoolean(int64_t id, uint32_t resId, bool &data);
6936a3a8d0Sopenharmony_ci    FFI_EXPORT int32_t CJ_GetBooleanByResource(int64_t id, CResource resource, bool &data);
7036a3a8d0Sopenharmony_ci    FFI_EXPORT int32_t CJ_GetBooleanByName(int64_t id, const char* name, bool &data);
7136a3a8d0Sopenharmony_ci    FFI_EXPORT int32_t CJ_GetNumber(int64_t id, uint32_t resId, RetGetNumber &data);
7236a3a8d0Sopenharmony_ci    FFI_EXPORT int32_t CJ_GetNumberByResource(int64_t id, CResource resource, RetGetNumber &data);
7336a3a8d0Sopenharmony_ci    FFI_EXPORT int32_t CJ_GetNumberByName(int64_t id, const char* name, RetGetNumber &data);
7436a3a8d0Sopenharmony_ci    FFI_EXPORT int32_t CJ_GetConfiguration(int64_t id, OHOS::Resource::Configuration &cfg);
7536a3a8d0Sopenharmony_ci    FFI_EXPORT int32_t CJ_GetDeviceCapability(int64_t id, OHOS::Resource::DeviceCapability &deviceCapability);
7636a3a8d0Sopenharmony_ci    FFI_EXPORT RetDataCArrUI8 CJ_GetMediaByName(int64_t id, const char* resName, uint32_t density);
7736a3a8d0Sopenharmony_ci    FFI_EXPORT RetDataCArrUI8 CJ_GetMediaContent(int64_t id, uint32_t resId, uint32_t density);
7836a3a8d0Sopenharmony_ci    FFI_EXPORT RetDataCArrUI8 CJ_GetMediaContentByResource(int64_t id, CResource resource, uint32_t density);
7936a3a8d0Sopenharmony_ci    FFI_EXPORT RetDataCString CJ_GetMediaContentBase64(int64_t id, uint32_t resId, uint32_t density);
8036a3a8d0Sopenharmony_ci    FFI_EXPORT RetDataCString CJ_GetMediaContentBase64ByResource(int64_t id, CResource resource, uint32_t density);
8136a3a8d0Sopenharmony_ci    FFI_EXPORT RetDataCString CJ_GetMediaContentBase64ByName(int64_t id, const char* resName, uint32_t density);
8236a3a8d0Sopenharmony_ci    FFI_EXPORT RetDataI64 CJ_GetDrawableDescriptor(int64_t id, uint32_t resId, uint32_t density);
8336a3a8d0Sopenharmony_ci    FFI_EXPORT RetDataI64 CJ_GetDrawableDescriptorByResource(int64_t id, CResource resource, uint32_t density);
8436a3a8d0Sopenharmony_ci    FFI_EXPORT RetDataI64 CJ_GetDrawableDescriptorByName(int64_t id, const char* resName, uint32_t density);
8536a3a8d0Sopenharmony_ci    FFI_EXPORT int32_t CJ_AddResource(int64_t id, const char *path);
8636a3a8d0Sopenharmony_ci    FFI_EXPORT int32_t CJ_RemoveResource(int64_t id, const char *path);
8736a3a8d0Sopenharmony_ci    FFI_EXPORT RetDataCArrString CJ_GetLocales(int64_t id, bool includeSystem);
8836a3a8d0Sopenharmony_ci    FFI_EXPORT RetDataU32 CJ_GetSymbol(int64_t id, uint32_t resId);
8936a3a8d0Sopenharmony_ci    FFI_EXPORT RetDataU32 CJ_GetSymbolByResource(int64_t id, CResource resource);
9036a3a8d0Sopenharmony_ci    FFI_EXPORT RetDataU32 CJ_GetSymbolByName(int64_t id, const char* name);
9136a3a8d0Sopenharmony_ci}
9236a3a8d0Sopenharmony_ci
9336a3a8d0Sopenharmony_ci#endif