1 /*
2  * Copyright (C) 2022 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 DEVCIES_MEADIA_LIBRARY_INFO_INTERACTION_H
17 #define DEVCIES_MEADIA_LIBRARY_INFO_INTERACTION_H
18 
19 #include "distributed_kv_data_manager.h"
20 #include "nlohmann/json.hpp"
21 
22 namespace OHOS {
23 namespace Media {
24 class DevicesInfoInteract final : public DistributedKv::KvStoreSyncCallback,
25                                   public std::enable_shared_from_this<DevicesInfoInteract> {
26 public:
27     DevicesInfoInteract();
28     virtual ~DevicesInfoInteract();
29     DevicesInfoInteract(const DevicesInfoInteract&) = delete;
30     DevicesInfoInteract& operator=(const DevicesInfoInteract&) = delete;
31     DevicesInfoInteract(const DevicesInfoInteract&&) = delete;
32     DevicesInfoInteract& operator=(const DevicesInfoInteract&&) = delete;
33 
34     void Init();
35     void PutMLDeviceInfos(const std::string &udid);
36     bool GetMLDeviceInfos(const std::string &udid, std::string &version);
37     void SyncMLDeviceInfos(const std::string &udid, const std::string &networkId);
38     void SyncCompleted(const std::map<std::string, DistributedKv::Status> &results) override;
39 private:
40     std::string GenerateKey(const std::string &udid);
41     std::shared_ptr<DistributedKv::SingleKvStore> kvStorePtr_;
42     std::string bundleName_;
43 };
44 } // namespace Media
45 } // namespace OHOS
46 #endif // DEVCIES_MEADIA_LIBRARY_INFO_INTERACTION_H
47