1 /*
2 * Copyright (c) 2024 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 #include "include/kvdb_notifier_client_mock.h"
17
18 namespace OHOS::DistributedKv {
19
~KVDBNotifierClient()20 KVDBNotifierClient::~KVDBNotifierClient() { }
21
IsChanged(const std::string & deviceId,DataType dataType)22 bool KVDBNotifierClient::IsChanged(const std::string &deviceId, DataType dataType)
23 {
24 if (BKVDBNotifierClient::kVDBNotifierClient == nullptr) {
25 return false;
26 }
27 return BKVDBNotifierClient::kVDBNotifierClient->IsChanged(deviceId, dataType);
28 }
29
AddSyncCallback(const std::shared_ptr<KvStoreSyncCallback> callback,uint64_t sequenceId)30 void KVDBNotifierClient::AddSyncCallback(const std::shared_ptr<KvStoreSyncCallback> callback, uint64_t sequenceId)
31 {
32 if (BKVDBNotifierClient::kVDBNotifierClient != nullptr) {
33 return BKVDBNotifierClient::kVDBNotifierClient->AddSyncCallback(callback, sequenceId);
34 }
35 }
36
DeleteSyncCallback(uint64_t sequenceId)37 void KVDBNotifierClient::DeleteSyncCallback(uint64_t sequenceId)
38 {
39 if (BKVDBNotifierClient::kVDBNotifierClient != nullptr) {
40 return BKVDBNotifierClient::kVDBNotifierClient->DeleteSyncCallback(sequenceId);
41 }
42 }
43
AddCloudSyncCallback(uint64_t sequenceId,const AsyncDetail & async)44 void KVDBNotifierClient::AddCloudSyncCallback(uint64_t sequenceId, const AsyncDetail &async)
45 {
46 if (BKVDBNotifierClient::kVDBNotifierClient != nullptr) {
47 return BKVDBNotifierClient::kVDBNotifierClient->AddCloudSyncCallback(sequenceId, async);
48 }
49 }
50
DeleteCloudSyncCallback(uint64_t sequenceId)51 void KVDBNotifierClient::DeleteCloudSyncCallback(uint64_t sequenceId)
52 {
53 if (BKVDBNotifierClient::kVDBNotifierClient != nullptr) {
54 return BKVDBNotifierClient::kVDBNotifierClient->DeleteCloudSyncCallback(sequenceId);
55 }
56 }
57
AddSwitchCallback(const std::string & appId,std::shared_ptr<KvStoreObserver> observer)58 void KVDBNotifierClient::AddSwitchCallback(const std::string &appId, std::shared_ptr<KvStoreObserver> observer)
59 {
60 if (BKVDBNotifierClient::kVDBNotifierClient != nullptr) {
61 return BKVDBNotifierClient::kVDBNotifierClient->AddSwitchCallback(appId, observer);
62 }
63 }
64
DeleteSwitchCallback(const std::string & appId,std::shared_ptr<KvStoreObserver> observer)65 void KVDBNotifierClient::DeleteSwitchCallback(const std::string &appId, std::shared_ptr<KvStoreObserver> observer)
66 {
67 if (BKVDBNotifierClient::kVDBNotifierClient != nullptr) {
68 return BKVDBNotifierClient::kVDBNotifierClient->DeleteSwitchCallback(appId, observer);
69 }
70 }
71
SyncCompleted(uint64_t seqNum,ProgressDetail && detail)72 void KVDBNotifierClient::SyncCompleted(uint64_t seqNum, ProgressDetail &&detail)
73 {
74 if (BKVDBNotifierClient::kVDBNotifierClient != nullptr) {
75 return BKVDBNotifierClient::kVDBNotifierClient->SyncCompleted(seqNum, std::move(detail));
76 }
77 }
78
SyncCompleted(const std::map<std::string,Status> & results,uint64_t sequenceId)79 void KVDBNotifierClient::SyncCompleted(const std::map<std::string, Status> &results, uint64_t sequenceId)
80 {
81 if (BKVDBNotifierClient::kVDBNotifierClient != nullptr) {
82 return BKVDBNotifierClient::kVDBNotifierClient->SyncCompleted(results, sequenceId);
83 }
84 }
85
OnRemoteChange(const std::map<std::string,bool> & mask,int32_t dataType)86 void KVDBNotifierClient::OnRemoteChange(const std::map<std::string, bool> &mask, int32_t dataType)
87 {
88 if (BKVDBNotifierClient::kVDBNotifierClient != nullptr) {
89 return BKVDBNotifierClient::kVDBNotifierClient->OnRemoteChange(mask, dataType);
90 }
91 }
92
OnSwitchChange(const SwitchNotification & notification)93 void KVDBNotifierClient::OnSwitchChange(const SwitchNotification ¬ification)
94 {
95 if (BKVDBNotifierClient::kVDBNotifierClient != nullptr) {
96 return BKVDBNotifierClient::kVDBNotifierClient->OnSwitchChange(notification);
97 }
98 }
99 } // namespace OHOS::DistributedKv