• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 #ifndef FOUNDATION_ACE_ACE_ENGINE_ADAPTER_OHOS_CAPABILITY_UDMF_IMPL_H
17 #define FOUNDATION_ACE_ACE_ENGINE_ADAPTER_OHOS_CAPABILITY_UDMF_IMPL_H
18 
19 #include <memory>
20 
21 #include "udmf_client.h"
22 
23 #include "base/memory/ace_type.h"
24 #include "core/common/udmf/udmf_client.h"
25 
26 namespace OHOS::Ace {
27 class UnifiedDataImpl;
28 class UdmfClientImpl : public UdmfClient {
29     DECLARE_ACE_TYPE(UdmfClientImpl, UdmfClient);
30 
31 public:
32     RefPtr<UnifiedData> CreateUnifiedData() override;
33     RefPtr<UnifiedData> TransformUnifiedData(NativeValue* nativeValue) override;
34     NativeValue* TransformUdmfUnifiedData(RefPtr<UnifiedData>& UnifiedData) override;
35     NativeValue* TransformSummary(std::map<std::string, int64_t>& summary) override;
36     int32_t SetData(const RefPtr<UnifiedData>& unifiedData, std::string& key) override;
37     int32_t GetData(const RefPtr<UnifiedData>& unifiedData, const std::string& key) override;
38     int32_t GetSummary(std::string& key, std::map<std::string, int64_t>& summaryMap) override;
39     void AddFormRecord(
40         const RefPtr<UnifiedData>& unifiedData, int32_t formId, const RequestFormInfo& cardInfo) override;
41     void AddLinkRecord(
42         const RefPtr<UnifiedData>& unifiedData, const std::string& url, const std::string& description) override;
43     void GetLinkRecord(
44         const RefPtr<UnifiedData>& unifiedData, std::string& url, std::string& description) override;
45     void AddHtmlRecord(const RefPtr<UnifiedData>& unifiedData, const std::string& htmlContent,
46         const std::string& plainContent) override;
47     void GetHtmlRecord(
48         const RefPtr<UnifiedData>& unifiedData, std::string& htmlContent, std::string& plainContent) override;
49     void AddPixelMapRecord(const RefPtr<UnifiedData>& unifiedData, std::vector<uint8_t>& data) override;
50     void AddImageRecord(const RefPtr<UnifiedData>& unifiedData, const std::string& uri) override;
51     void AddPlainTextRecord(const RefPtr<UnifiedData>& unifiedData, const std::string& selectedStr) override;
52     std::string GetSinglePlainTextRecord(const RefPtr<UnifiedData>& unifiedData) override;
53     std::vector<std::string> GetPlainTextRecords(const RefPtr<UnifiedData>& unifiedData) override;
54     int32_t GetVideoRecordUri(const RefPtr<UnifiedData>& unifiedData, std::string& uri) override;
55     std::pair<int32_t, std::string> GetErrorInfo(int32_t errorCode) override;
56 };
57 
58 class UnifiedDataImpl : public UnifiedData {
59     DECLARE_ACE_TYPE(UnifiedDataImpl, UnifiedData);
60 
61 public:
62     UnifiedDataImpl() = default;
63     ~UnifiedDataImpl() = default;
64 
65     int64_t GetSize() override;
66     std::shared_ptr<UDMF::UnifiedData> GetUnifiedData();
67     void SetUnifiedData(std::shared_ptr<UDMF::UnifiedData> unifiedData);
68 
69 private:
70     std::shared_ptr<UDMF::UnifiedData> unifiedData_;
71 };
72 } // namespace OHOS::Ace
73 #endif // FOUNDATION_ACE_ACE_ENGINE_ADAPTER_OHOS_CAPABILITY_UDMF_IMPL_H
74