1bc03f14fSopenharmony_ci/*
2bc03f14fSopenharmony_ci* Copyright (c) 2024 Huawei Device Co., Ltd.
3bc03f14fSopenharmony_ci* Licensed under the Apache License, Version 2.0 (the "License");
4bc03f14fSopenharmony_ci* you may not use this file except in compliance with the License.
5bc03f14fSopenharmony_ci* You may obtain a copy of the License at
6bc03f14fSopenharmony_ci*
7bc03f14fSopenharmony_ci*     http://www.apache.org/licenses/LICENSE-2.0
8bc03f14fSopenharmony_ci*
9bc03f14fSopenharmony_ci* Unless required by applicable law or agreed to in writing, software
10bc03f14fSopenharmony_ci* distributed under the License is distributed on an "AS IS" BASIS,
11bc03f14fSopenharmony_ci* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12bc03f14fSopenharmony_ci* See the License for the specific language governing permissions and
13bc03f14fSopenharmony_ci* limitations under the License.
14bc03f14fSopenharmony_ci*/
15bc03f14fSopenharmony_ci
16bc03f14fSopenharmony_ci#include "convert_utils.h"
17bc03f14fSopenharmony_ci#include "pasteboard_entry_getter_client.h"
18bc03f14fSopenharmony_ci#include "pasteboard_error.h"
19bc03f14fSopenharmony_ci#include "pasteboard_hilog.h"
20bc03f14fSopenharmony_ci
21bc03f14fSopenharmony_cinamespace OHOS {
22bc03f14fSopenharmony_cinamespace MiscServices {
23bc03f14fSopenharmony_ciusing namespace OHOS::UDMF;
24bc03f14fSopenharmony_ciPasteboardEntryGetterClient::PasteboardEntryGetterClient(
25bc03f14fSopenharmony_ci    const std::map<uint32_t, std::shared_ptr<EntryGetter>> entryGetters)
26bc03f14fSopenharmony_ci    : entryGetters_(entryGetters)
27bc03f14fSopenharmony_ci{
28bc03f14fSopenharmony_ci}
29bc03f14fSopenharmony_ci
30bc03f14fSopenharmony_ciint32_t PasteboardEntryGetterClient::GetRecordValueByType(uint32_t recordId, PasteDataEntry &value)
31bc03f14fSopenharmony_ci{
32bc03f14fSopenharmony_ci    auto it = entryGetters_.find(recordId);
33bc03f14fSopenharmony_ci    if (it == entryGetters_.end()) {
34bc03f14fSopenharmony_ci        PASTEBOARD_HILOGE(PASTEBOARD_MODULE_CLIENT, "recordId:%{public}d, have no entry getter", recordId);
35bc03f14fSopenharmony_ci        return static_cast<int32_t>(PasteboardError::INVALID_DATA_ERROR);
36bc03f14fSopenharmony_ci    }
37bc03f14fSopenharmony_ci    auto utdId = value.GetUtdId();
38bc03f14fSopenharmony_ci    if (it->second != nullptr) {
39bc03f14fSopenharmony_ci        value.SetValue(it->second->GetValueByType(utdId));
40bc03f14fSopenharmony_ci    }
41bc03f14fSopenharmony_ci    return static_cast<int32_t>(PasteboardError::E_OK);
42bc03f14fSopenharmony_ci}
43bc03f14fSopenharmony_ci} // namespace MiscServices
44bc03f14fSopenharmony_ci} // namespace OHOS