114cf0368Sopenharmony_ci/* 214cf0368Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 314cf0368Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 414cf0368Sopenharmony_ci * you may not use this file except in compliance with the License. 514cf0368Sopenharmony_ci * You may obtain a copy of the License at 614cf0368Sopenharmony_ci * 714cf0368Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 814cf0368Sopenharmony_ci * 914cf0368Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1014cf0368Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1114cf0368Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1214cf0368Sopenharmony_ci * See the License for the specific language governing permissions and 1314cf0368Sopenharmony_ci * limitations under the License. 1414cf0368Sopenharmony_ci */ 1514cf0368Sopenharmony_ci 1614cf0368Sopenharmony_ci#ifndef UDMF_CAPI_COMMON_H 1714cf0368Sopenharmony_ci#define UDMF_CAPI_COMMON_H 1814cf0368Sopenharmony_ci 1914cf0368Sopenharmony_ci#include "unified_record.h" 2014cf0368Sopenharmony_ci#include "unified_data.h" 2114cf0368Sopenharmony_ci#include <mutex> 2214cf0368Sopenharmony_ci#include <cstdint> 2314cf0368Sopenharmony_ci 2414cf0368Sopenharmony_ci# define MAX_GENERAL_ENTRY_SIZE (100 * 1024 * 1024) 2514cf0368Sopenharmony_ci 2614cf0368Sopenharmony_cistruct UdsObject { 2714cf0368Sopenharmony_ci const int64_t cid; 2814cf0368Sopenharmony_ci std::shared_ptr<OHOS::UDMF::Object> obj; 2914cf0368Sopenharmony_ci std::mutex mutex; 3014cf0368Sopenharmony_ci explicit UdsObject(int cid); 3114cf0368Sopenharmony_ci template<typename T> bool HasObjectKey(const char* paramName); 3214cf0368Sopenharmony_ci template<typename T> T* GetUdsValue(const char* paramName); 3314cf0368Sopenharmony_ci template<typename T> int SetUdsValue(const char* paramName, const T &pramValue); 3414cf0368Sopenharmony_ci}; 3514cf0368Sopenharmony_ci 3614cf0368Sopenharmony_cienum NdkStructId : std::int64_t { 3714cf0368Sopenharmony_ci UTD_STRUCT_ID = 1002930, 3814cf0368Sopenharmony_ci UDS_PLAIN_TEXT_STRUCT_ID, 3914cf0368Sopenharmony_ci UDS_HYPERLINK_STRUCT_ID, 4014cf0368Sopenharmony_ci UDS_HTML_STRUCT_ID, 4114cf0368Sopenharmony_ci UDS_APP_ITEM_STRUCT_ID, 4214cf0368Sopenharmony_ci UDMF_UNIFIED_DATA_STRUCT_ID, 4314cf0368Sopenharmony_ci UDMF_UNIFIED_RECORD_STRUCT_ID, 4414cf0368Sopenharmony_ci UDMF_UNIFIED_DATA_PROPERTIES_ID, 4514cf0368Sopenharmony_ci UDS_FILE_URI_STRUCT_ID, 4614cf0368Sopenharmony_ci UDS_PIXEL_MAP_STRUCT_ID, 4714cf0368Sopenharmony_ci UDS_ARRAY_BUFFER_STRUCT_ID, 4814cf0368Sopenharmony_ci UDS_CONTENT_FORM_STRUCT_ID 4914cf0368Sopenharmony_ci}; 5014cf0368Sopenharmony_ci 5114cf0368Sopenharmony_cistruct OH_Utd { 5214cf0368Sopenharmony_ci const int64_t cid = UTD_STRUCT_ID; 5314cf0368Sopenharmony_ci std::mutex mutex; 5414cf0368Sopenharmony_ci std::string typeId; 5514cf0368Sopenharmony_ci const char** belongingToTypes{nullptr}; 5614cf0368Sopenharmony_ci unsigned int belongingToTypesCount{0}; 5714cf0368Sopenharmony_ci const char** filenameExtensions{nullptr}; 5814cf0368Sopenharmony_ci unsigned int filenameExtensionsCount{0}; 5914cf0368Sopenharmony_ci const char** mimeTypes{nullptr}; 6014cf0368Sopenharmony_ci unsigned int mimeTypeCount{0}; 6114cf0368Sopenharmony_ci std::string description; 6214cf0368Sopenharmony_ci std::string referenceURL; 6314cf0368Sopenharmony_ci std::string iconFile; 6414cf0368Sopenharmony_ci}; 6514cf0368Sopenharmony_ci 6614cf0368Sopenharmony_cistruct OH_UdsPlainText : public UdsObject { 6714cf0368Sopenharmony_ci OH_UdsPlainText(); 6814cf0368Sopenharmony_ci}; 6914cf0368Sopenharmony_cistruct OH_UdsHyperlink : public UdsObject { 7014cf0368Sopenharmony_ci OH_UdsHyperlink(); 7114cf0368Sopenharmony_ci}; 7214cf0368Sopenharmony_cistruct OH_UdsHtml : public UdsObject { 7314cf0368Sopenharmony_ci OH_UdsHtml(); 7414cf0368Sopenharmony_ci}; 7514cf0368Sopenharmony_cistruct OH_UdsAppItem : public UdsObject { 7614cf0368Sopenharmony_ci OH_UdsAppItem(); 7714cf0368Sopenharmony_ci}; 7814cf0368Sopenharmony_cistruct OH_UdsFileUri : public UdsObject { 7914cf0368Sopenharmony_ci OH_UdsFileUri(); 8014cf0368Sopenharmony_ci}; 8114cf0368Sopenharmony_cistruct OH_UdsPixelMap : public UdsObject { 8214cf0368Sopenharmony_ci OH_UdsPixelMap(); 8314cf0368Sopenharmony_ci}; 8414cf0368Sopenharmony_cistruct OH_UdsArrayBuffer : public UdsObject { 8514cf0368Sopenharmony_ci OH_UdsArrayBuffer(); 8614cf0368Sopenharmony_ci}; 8714cf0368Sopenharmony_cistruct OH_UdsContentForm : public UdsObject { 8814cf0368Sopenharmony_ci OH_UdsContentForm(); 8914cf0368Sopenharmony_ci}; 9014cf0368Sopenharmony_ci 9114cf0368Sopenharmony_cistruct OH_UdmfRecord { 9214cf0368Sopenharmony_ci const int64_t cid = UDMF_UNIFIED_RECORD_STRUCT_ID; 9314cf0368Sopenharmony_ci std::shared_ptr<OHOS::UDMF::UnifiedRecord> record_; 9414cf0368Sopenharmony_ci unsigned char *recordData{nullptr}; 9514cf0368Sopenharmony_ci unsigned int recordDataLen{0}; 9614cf0368Sopenharmony_ci char **typesArray{nullptr}; 9714cf0368Sopenharmony_ci unsigned int typesCount{0}; 9814cf0368Sopenharmony_ci char *lastType{nullptr}; 9914cf0368Sopenharmony_ci std::mutex mutex; 10014cf0368Sopenharmony_ci}; 10114cf0368Sopenharmony_ci 10214cf0368Sopenharmony_cistruct OH_UdmfData { 10314cf0368Sopenharmony_ci const int64_t cid = UDMF_UNIFIED_DATA_STRUCT_ID; 10414cf0368Sopenharmony_ci std::shared_ptr<OHOS::UDMF::UnifiedData> unifiedData_; 10514cf0368Sopenharmony_ci char **typesArray{nullptr}; 10614cf0368Sopenharmony_ci unsigned int typesCount{0}; 10714cf0368Sopenharmony_ci OH_UdmfRecord **records{nullptr}; 10814cf0368Sopenharmony_ci unsigned int recordsCount{0}; 10914cf0368Sopenharmony_ci std::mutex mutex; 11014cf0368Sopenharmony_ci}; 11114cf0368Sopenharmony_ci 11214cf0368Sopenharmony_cistruct OH_UdmfProperty { 11314cf0368Sopenharmony_ci const int64_t cid = UDMF_UNIFIED_DATA_PROPERTIES_ID; 11414cf0368Sopenharmony_ci std::shared_ptr<OHOS::UDMF::UnifiedDataProperties> properties_; 11514cf0368Sopenharmony_ci std::mutex mutex; 11614cf0368Sopenharmony_ci std::string extraStr; 11714cf0368Sopenharmony_ci}; 11814cf0368Sopenharmony_ci 11914cf0368Sopenharmony_cibool IsInvalidUdsObjectPtr(const UdsObject* pThis, int cid); 12014cf0368Sopenharmony_ci 12114cf0368Sopenharmony_cibool IsInvalidUdsObjectByType(const UdsObject* pThis, const OHOS::UDMF::UDType& type); 12214cf0368Sopenharmony_ci 12314cf0368Sopenharmony_ci#endif 124