1 /*
2  * Copyright (c) 2021-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 #ifndef DAEMON_STUB_H
16 #define DAEMON_STUB_H
17 
18 #include <map>
19 
20 #include "dm_device_info.h"
21 #include "i_daemon.h"
22 #include "iremote_stub.h"
23 #include "message_option.h"
24 #include "message_parcel.h"
25 #include "refbase.h"
26 
27 namespace OHOS {
28 namespace Storage {
29 namespace DistributedFile {
30 class DaemonStub : public IRemoteStub<IDaemon> {
31 public:
32     DaemonStub();
33     virtual ~DaemonStub() = default;
34     int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
35 
36 private:
37     using DaemonInterface = int32_t (DaemonStub::*)(MessageParcel &data, MessageParcel &reply);
38     std::map<uint32_t, DaemonInterface> opToInterfaceMap_;
39 
40     int32_t HandleOpenP2PConnection(MessageParcel &data, MessageParcel &reply);
41     int32_t HandleCloseP2PConnection(MessageParcel &data, MessageParcel &reply);
42     int32_t HandleOpenP2PConnectionEx(MessageParcel &data, MessageParcel &reply);
43     int32_t HandleCloseP2PConnectionEx(MessageParcel &data, MessageParcel &reply);
44     int32_t HandlePrepareSession(MessageParcel &data, MessageParcel &reply);
45     int32_t HandleCancelCopyTask(MessageParcel &data, MessageParcel &reply);
46     int32_t HandleRequestSendFile(MessageParcel &data, MessageParcel &reply);
47     int32_t HandleGetRemoteCopyInfo(MessageParcel &data, MessageParcel &reply);
48 
49     int32_t HandlePushAsset(MessageParcel &data, MessageParcel &reply);
50     int32_t HandleRegisterRecvCallback(MessageParcel &data, MessageParcel &reply);
51     int32_t HandleUnRegisterRecvCallback(MessageParcel &data, MessageParcel &reply);
52 };
53 } // namespace DistributedFile
54 } // namespace Storage
55 } // namespace OHOS
56 #endif // DAEMON_STUB_H