123b3eb3cSopenharmony_ci/*
223b3eb3cSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
323b3eb3cSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
423b3eb3cSopenharmony_ci * you may not use this file except in compliance with the License.
523b3eb3cSopenharmony_ci * You may obtain a copy of the License at
623b3eb3cSopenharmony_ci *
723b3eb3cSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
823b3eb3cSopenharmony_ci *
923b3eb3cSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1023b3eb3cSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1123b3eb3cSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1223b3eb3cSopenharmony_ci * See the License for the specific language governing permissions and
1323b3eb3cSopenharmony_ci * limitations under the License.
1423b3eb3cSopenharmony_ci */
1523b3eb3cSopenharmony_ci
1623b3eb3cSopenharmony_ci#ifndef FOUNDATION_ACE_ACE_ENGINE_ADAPTER_OHOS_CAPABILITY_UDMF_IMPL_H
1723b3eb3cSopenharmony_ci#define FOUNDATION_ACE_ACE_ENGINE_ADAPTER_OHOS_CAPABILITY_UDMF_IMPL_H
1823b3eb3cSopenharmony_ci
1923b3eb3cSopenharmony_ci#include <memory>
2023b3eb3cSopenharmony_ci
2123b3eb3cSopenharmony_ci#include "udmf_client.h"
2223b3eb3cSopenharmony_ci
2323b3eb3cSopenharmony_ci#include "base/memory/ace_type.h"
2423b3eb3cSopenharmony_ci#include "core/common/udmf/udmf_client.h"
2523b3eb3cSopenharmony_ci
2623b3eb3cSopenharmony_cinamespace OHOS::Ace {
2723b3eb3cSopenharmony_ciclass UnifiedDataImpl;
2823b3eb3cSopenharmony_ciclass UdmfClientImpl : public UdmfClient {
2923b3eb3cSopenharmony_ci    DECLARE_ACE_TYPE(UdmfClientImpl, UdmfClient);
3023b3eb3cSopenharmony_ci
3123b3eb3cSopenharmony_cipublic:
3223b3eb3cSopenharmony_ci    RefPtr<UnifiedData> CreateUnifiedData() override;
3323b3eb3cSopenharmony_ci    RefPtr<UnifiedData> TransformUnifiedData(napi_value napiValue) override;
3423b3eb3cSopenharmony_ci    RefPtr<UnifiedData> TransformUnifiedDataForNative(void* rawData) override;
3523b3eb3cSopenharmony_ci    void* TransformUnifiedDataPtr(RefPtr<UnifiedData>& unifiedData) override;
3623b3eb3cSopenharmony_ci    napi_value TransformUdmfUnifiedData(RefPtr<UnifiedData>& UnifiedData) override;
3723b3eb3cSopenharmony_ci    napi_value TransformSummary(std::map<std::string, int64_t>& summary) override;
3823b3eb3cSopenharmony_ci    int32_t SetData(const RefPtr<UnifiedData>& unifiedData, std::string& key) override;
3923b3eb3cSopenharmony_ci    int32_t GetData(const RefPtr<UnifiedData>& unifiedData, const std::string& key) override;
4023b3eb3cSopenharmony_ci    int32_t GetSummary(std::string& key, std::map<std::string, int64_t>& summaryMap) override;
4123b3eb3cSopenharmony_ci    bool GetRemoteStatus(std::string& key) override;
4223b3eb3cSopenharmony_ci    void AddFormRecord(
4323b3eb3cSopenharmony_ci        const RefPtr<UnifiedData>& unifiedData, int32_t formId, const RequestFormInfo& cardInfo) override;
4423b3eb3cSopenharmony_ci    void AddLinkRecord(
4523b3eb3cSopenharmony_ci        const RefPtr<UnifiedData>& unifiedData, const std::string& url, const std::string& description) override;
4623b3eb3cSopenharmony_ci    void GetLinkRecord(
4723b3eb3cSopenharmony_ci        const RefPtr<UnifiedData>& unifiedData, std::string& url, std::string& description) override;
4823b3eb3cSopenharmony_ci    bool GetFileUriRecord(const RefPtr<UnifiedData>& unifiedData, std::vector<std::string>& uri) override;
4923b3eb3cSopenharmony_ci    bool AddFileUriRecord(const RefPtr<UnifiedData>& unifiedData, std::vector<std::string>& uri) override;
5023b3eb3cSopenharmony_ci    void AddHtmlRecord(const RefPtr<UnifiedData>& unifiedData, const std::string& htmlContent,
5123b3eb3cSopenharmony_ci        const std::string& plainContent) override;
5223b3eb3cSopenharmony_ci    void GetHtmlRecord(
5323b3eb3cSopenharmony_ci        const RefPtr<UnifiedData>& unifiedData, std::string& htmlContent, std::string& plainContent) override;
5423b3eb3cSopenharmony_ci    void AddPixelMapRecord(const RefPtr<UnifiedData>& unifiedData, std::vector<uint8_t>& data,
5523b3eb3cSopenharmony_ci        PixelMapRecordDetails& details) override;
5623b3eb3cSopenharmony_ci    void AddImageRecord(const RefPtr<UnifiedData>& unifiedData, const std::string& uri) override;
5723b3eb3cSopenharmony_ci    void AddPlainTextRecord(const RefPtr<UnifiedData>& unifiedData, const std::string& selectedStr) override;
5823b3eb3cSopenharmony_ci    std::string GetSinglePlainTextRecord(const RefPtr<UnifiedData>& unifiedData) override;
5923b3eb3cSopenharmony_ci    std::vector<std::string> GetPlainTextRecords(const RefPtr<UnifiedData>& unifiedData) override;
6023b3eb3cSopenharmony_ci    int32_t GetVideoRecordUri(const RefPtr<UnifiedData>& unifiedData, std::string& uri) override;
6123b3eb3cSopenharmony_ci    std::pair<int32_t, std::string> GetErrorInfo(int32_t errorCode) override;
6223b3eb3cSopenharmony_ci    void AddSpanStringRecord(
6323b3eb3cSopenharmony_ci        const RefPtr<UnifiedData>& unifiedData, std::vector<uint8_t>& data) override;
6423b3eb3cSopenharmony_ci    std::vector<uint8_t> GetSpanStringRecord(const RefPtr<UnifiedData>& unifiedData) override;
6523b3eb3cSopenharmony_ci};
6623b3eb3cSopenharmony_ci
6723b3eb3cSopenharmony_ciclass UnifiedDataImpl : public UnifiedData {
6823b3eb3cSopenharmony_ci    DECLARE_ACE_TYPE(UnifiedDataImpl, UnifiedData);
6923b3eb3cSopenharmony_ci
7023b3eb3cSopenharmony_cipublic:
7123b3eb3cSopenharmony_ci    UnifiedDataImpl() = default;
7223b3eb3cSopenharmony_ci    ~UnifiedDataImpl() = default;
7323b3eb3cSopenharmony_ci
7423b3eb3cSopenharmony_ci    int64_t GetSize() override;
7523b3eb3cSopenharmony_ci    std::shared_ptr<UDMF::UnifiedData> GetUnifiedData();
7623b3eb3cSopenharmony_ci    void SetUnifiedData(std::shared_ptr<UDMF::UnifiedData> unifiedData);
7723b3eb3cSopenharmony_ci
7823b3eb3cSopenharmony_ciprivate:
7923b3eb3cSopenharmony_ci    std::shared_ptr<UDMF::UnifiedData> unifiedData_;
8023b3eb3cSopenharmony_ci};
8123b3eb3cSopenharmony_ci} // namespace OHOS::Ace
8223b3eb3cSopenharmony_ci#endif // FOUNDATION_ACE_ACE_ENGINE_ADAPTER_OHOS_CAPABILITY_UDMF_IMPL_H
83