1 /* 2 * Copyright (c) 2023-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 DISTRIBUTED_FILE_DAEMON_MANAGER_H 17 #define DISTRIBUTED_FILE_DAEMON_MANAGER_H 18 19 #include <functional> 20 #include <memory> 21 22 #include "asset/asset_obj.h" 23 #include "asset/i_asset_recv_callback.h" 24 #include "asset/i_asset_send_callback.h" 25 #include "dfs_device_info.h" 26 #include "dm_device_info.h" 27 #include "hmdfs_info.h" 28 #include "i_file_dfs_listener.h" 29 #include "i_file_trans_listener.h" 30 31 namespace OHOS { 32 namespace Storage { 33 namespace DistributedFile { 34 class DistributedFileDaemonManager { 35 public: 36 using ProcessCallback = std::function<void (uint64_t processSize, uint64_t totalSize)>; 37 public: 38 static DistributedFileDaemonManager &GetInstance(); 39 40 virtual int32_t OpenP2PConnection(const DistributedHardware::DmDeviceInfo &deviceInfo) = 0; 41 virtual int32_t CloseP2PConnection(const DistributedHardware::DmDeviceInfo &deviceInfo) = 0; 42 virtual int32_t OpenP2PConnectionEx(const std::string &networkId, sptr<IFileDfsListener> remoteReverseObj) = 0; 43 virtual int32_t CloseP2PConnectionEx(const std::string &networkId) = 0; 44 virtual int32_t PrepareSession(const std::string &srcUri, 45 const std::string &dstUri, 46 const std::string &srcDeviceId, 47 const sptr<IRemoteObject> &listener, 48 HmdfsInfo &info) = 0; 49 virtual int32_t CancelCopyTask(const std::string &sessionName) = 0; 50 virtual int32_t CancelCopyTask(const std::string &srcUri, const std::string &dstUri) = 0; 51 52 virtual int32_t PushAsset(int32_t userId, 53 const sptr<AssetObj> &assetObj, 54 const sptr<IAssetSendCallback> &sendCallback) = 0; 55 virtual int32_t RegisterAssetCallback(const sptr<IAssetRecvCallback> &recvCallback) = 0; 56 virtual int32_t UnRegisterAssetCallback(const sptr<IAssetRecvCallback> &recvCallback) =0; 57 58 virtual int32_t GetSize(const std::string &uri, bool isSrcUri, uint64_t &size) = 0; 59 virtual int32_t IsDirectory(const std::string &uri, bool isSrcUri, bool &isDirectory) = 0; 60 virtual int32_t Copy(const std::string &srcUri, const std::string &destUri, ProcessCallback processCallback) = 0; 61 virtual int32_t Cancel(const std::string &srcUri, const std::string &destUri) = 0; 62 virtual int32_t Cancel() = 0; 63 virtual int32_t GetDfsSwitchStatus(const std::string &networkId, int32_t &switchStatus) = 0; 64 virtual int32_t UpdateDfsSwitchStatus(int32_t switchStatus) = 0; 65 virtual int32_t GetConnectedDeviceList(std::vector<DfsDeviceInfo> &deviceList) = 0; 66 }; 67 } // namespace DistributedFile 68 } // namespace Storage 69 } // namespace OHOS 70 71 #endif // DISTRIBUTED_FILE_DAEMON_MANAGER_H