• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 OHOS_DISTRIBUTED_DATA_CLOUD_CLOUD_NOTIFIER_STUB_H
17 #define OHOS_DISTRIBUTED_DATA_CLOUD_CLOUD_NOTIFIER_STUB_H
18 
19 #include "cloud_notifier.h"
20 #include "iremote_broker.h"
21 #include "iremote_stub.h"
22 
23 namespace OHOS::CloudData {
24 using namespace DistributedRdb;
25 using NotifierCode = DistributedRdb::RelationalStore::ICloudNotifierInterfaceCode;
26 
27 class CloudNotifierStubBroker : public ICloudNotifier, public IRemoteBroker {
28 public:
29     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.CloudData.ICloudNotifier");
30 };
31 
32 class CloudNotifierStub : public IRemoteStub<CloudNotifierStubBroker> {
33 public:
34     using SyncCompleteHandler = std::function<void(uint32_t, Details &&)>;
35     explicit CloudNotifierStub(const SyncCompleteHandler &syncComplete);
36     virtual ~CloudNotifierStub() noexcept;
37 
38     int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override;
39     int32_t OnComplete(uint32_t seqNum, Details &&result) override;
40 
41 private:
42     int32_t OnCompleteInner(MessageParcel& data, MessageParcel& reply);
43     bool CheckInterfaceToken(MessageParcel& data);
44 
45     using RequestHandle = int32_t (CloudNotifierStub::*)(MessageParcel&, MessageParcel&);
46     static constexpr RequestHandle HANDLES[static_cast<uint32_t>(NotifierCode::CLOUD_NOTIFIER_CMD_MAX)] = {
47         [static_cast<uint32_t>(NotifierCode::CLOUD_NOTIFIER_CMD_SYNC_COMPLETE)] = &CloudNotifierStub::OnCompleteInner,
48     };
49 
50     SyncCompleteHandler completeNotifier_;
51 };
52 } // namespace OHOS::CloudData
53 #endif // OHOS_DISTRIBUTED_DATA_CLOUD_CLOUD_NOTIFIER_STUB_H
54