114cf0368Sopenharmony_ci/* 214cf0368Sopenharmony_ci * Copyright (c) 2023 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 UTD_CLIENT_H 1714cf0368Sopenharmony_ci#define UTD_CLIENT_H 1814cf0368Sopenharmony_ci 1914cf0368Sopenharmony_ci#include <shared_mutex> 2014cf0368Sopenharmony_ci#include <string> 2114cf0368Sopenharmony_ci#include <vector> 2214cf0368Sopenharmony_ci#include <map> 2314cf0368Sopenharmony_ci#include "utd_common.h" 2414cf0368Sopenharmony_ci#include "preset_type_descriptors.h" 2514cf0368Sopenharmony_ci#include "preset_type_descriptors.h" 2614cf0368Sopenharmony_ci#include "flexible_type.h" 2714cf0368Sopenharmony_ci#include "type_descriptor.h" 2814cf0368Sopenharmony_ci#include "error_code.h" 2914cf0368Sopenharmony_ci#include "visibility.h" 3014cf0368Sopenharmony_cinamespace OHOS { 3114cf0368Sopenharmony_cinamespace UDMF { 3214cf0368Sopenharmony_ciclass TypeDescriptor; 3314cf0368Sopenharmony_ciclass UtdChangeSubscriber; 3414cf0368Sopenharmony_ciclass API_EXPORT UtdClient { 3514cf0368Sopenharmony_cipublic: 3614cf0368Sopenharmony_ci static UtdClient &GetInstance(); 3714cf0368Sopenharmony_ci Status GetTypeDescriptor(const std::string &typeId, std::shared_ptr<TypeDescriptor> &descriptor); 3814cf0368Sopenharmony_ci Status GetUniformDataTypeByFilenameExtension(const std::string &fileExtension, std::string &typeId, 3914cf0368Sopenharmony_ci std::string belongsTo = DEFAULT_TYPE_ID); 4014cf0368Sopenharmony_ci Status GetUniformDataTypesByFilenameExtension(const std::string &fileExtension, 4114cf0368Sopenharmony_ci std::vector<std::string> &typeIds, const std::string &belongsTo = DEFAULT_TYPE_ID); 4214cf0368Sopenharmony_ci Status GetUniformDataTypeByMIMEType(const std::string &mimeType, std::string &typeId, 4314cf0368Sopenharmony_ci std::string belongsTo = DEFAULT_TYPE_ID); 4414cf0368Sopenharmony_ci Status GetUniformDataTypesByMIMEType(const std::string &mimeType, std::vector<std::string> &typeIds, 4514cf0368Sopenharmony_ci const std::string &belongsTo = DEFAULT_TYPE_ID); 4614cf0368Sopenharmony_ci Status IsUtd(std::string typeId, bool &result); 4714cf0368Sopenharmony_ci void InstallCustomUtds(const std::string &bundleName, const std::string &jsonStr, int32_t user); 4814cf0368Sopenharmony_ci void UninstallCustomUtds(const std::string &bundleName, int32_t user); 4914cf0368Sopenharmony_ci 5014cf0368Sopenharmony_ciprivate: 5114cf0368Sopenharmony_ci UtdClient(); 5214cf0368Sopenharmony_ci ~UtdClient(); 5314cf0368Sopenharmony_ci UtdClient(const UtdClient &obj) = delete; 5414cf0368Sopenharmony_ci UtdClient &operator=(const UtdClient &obj) = delete; 5514cf0368Sopenharmony_ci bool Init(); 5614cf0368Sopenharmony_ci bool IsHapTokenType(); 5714cf0368Sopenharmony_ci Status GetCurrentActiveUserId(int32_t& userId); 5814cf0368Sopenharmony_ci bool IsValidFileExtension(const std::string &fileExtension); 5914cf0368Sopenharmony_ci bool IsValidMimeType(const std::string &mimeType); 6014cf0368Sopenharmony_ci Status GetFlexibleTypeDescriptor(const std::string &typeId, std::shared_ptr<TypeDescriptor> &descriptor); 6114cf0368Sopenharmony_ci std::string GetTypeIdFromCfg(const std::string &mimeType); 6214cf0368Sopenharmony_ci std::vector<std::string> GetTypeIdsFromCfg(const std::string &mimeType); 6314cf0368Sopenharmony_ci void UpdateGraph(const std::vector<TypeDescriptorCfg> &customTyepCfgs); 6414cf0368Sopenharmony_ci 6514cf0368Sopenharmony_ci std::vector<TypeDescriptorCfg> descriptorCfgs_; 6614cf0368Sopenharmony_ci std::shared_mutex utdMutex_; 6714cf0368Sopenharmony_ci}; 6814cf0368Sopenharmony_ci} // namespace UDMF 6914cf0368Sopenharmony_ci} // namespace OHOS 7014cf0368Sopenharmony_ci#endif // UTD_CLIENT_H