• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-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 #ifndef DISTRIBUTED_FILE_DAEMON_MANAGER_IMPL_H
17 #define DISTRIBUTED_FILE_DAEMON_MANAGER_IMPL_H
18 
19 #include "asset/asset_obj.h"
20 #include "asset/i_asset_recv_callback.h"
21 #include "asset/i_asset_send_callback.h"
22 #include "dm_device_info.h"
23 #include "ipc/distributed_file_daemon_manager.h"
24 #include "ipc/i_file_dfs_listener.h"
25 #include "nocopyable.h"
26 #include "refbase.h"
27 
28 namespace OHOS {
29 namespace Storage {
30 namespace DistributedFile {
31 class DistributedFileDaemonManagerImpl final : public DistributedFileDaemonManager, public NoCopyable {
32 public:
33     static DistributedFileDaemonManagerImpl &GetInstance();
34 
35     int32_t OpenP2PConnection(const DistributedHardware::DmDeviceInfo &deviceInfo) override;
36     int32_t CloseP2PConnection(const DistributedHardware::DmDeviceInfo &deviceInfo) override;
37     int32_t OpenP2PConnectionEx(const std::string &networkId, sptr<IFileDfsListener> remoteReverseObj) override;
38     int32_t CloseP2PConnectionEx(const std::string &networkId) override;
39     int32_t PrepareSession(const std::string &srcUri,
40                            const std::string &dstUri,
41                            const std::string &srcDeviceId,
42                            const sptr<IRemoteObject> &listener,
43                            HmdfsInfo &info) override;
44     int32_t CancelCopyTask(const std::string &sessionName) override;
45     int32_t CancelCopyTask(const std::string &srcUri, const std::string &dstUri) override;
46     int32_t RequestSendFile(const std::string &srcUri,
47                             const std::string &dstPath,
48                             const std::string &remoteDeviceId,
49                             const std::string &sessionName);
50     int32_t GetRemoteCopyInfo(const std::string &srcUri, bool &isFile, bool &isDir);
51 
52     int32_t PushAsset(int32_t userId,
53                       const sptr<AssetObj> &assetObj,
54                       const sptr<IAssetSendCallback> &sendCallback) override;
55     int32_t RegisterAssetCallback(const sptr<IAssetRecvCallback> &recvCallback) override;
56     int32_t UnRegisterAssetCallback(const sptr<IAssetRecvCallback> &recvCallback) override;
57 
58     int32_t GetSize(const std::string &uri, bool isSrcUri, uint64_t &size) override;
59     int32_t IsDirectory(const std::string &uri, bool isSrcUri, bool &isDirectory) override;
60     int32_t Copy(const std::string &srcUri, const std::string &destUri, ProcessCallback processCallback) override;
61     int32_t Cancel(const std::string &srcUri, const std::string &destUri) override;
62     int32_t Cancel() override;
63     int32_t GetDfsSwitchStatus(const std::string &networkId, int32_t &switchStatus) override;
64     int32_t UpdateDfsSwitchStatus(int32_t switchStatus) override;
65     int32_t GetConnectedDeviceList(std::vector<DfsDeviceInfo> &deviceList) override;
66 private:
67     DistributedFileDaemonManagerImpl() = default;
68 };
69 } // namespace DistributedFile
70 } // namespace Storage
71 } // namespace OHOS
72 
73 #endif // DISTRIBUTED_FILE_DAEMON_MANAGER_IMPL_H
74