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_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 "dm_device_info.h" 26 #include "hmdfs_info.h" 27 #include "i_file_dfs_listener.h" 28 #include "i_file_trans_listener.h" 29 30 namespace OHOS { 31 namespace Storage { 32 namespace DistributedFile { 33 class DistributedFileDaemonManager { 34 public: 35 using ProcessCallback = std::function<void (uint64_t processSize, uint64_t totalSize)>; 36 public: 37 static DistributedFileDaemonManager &GetInstance(); 38 39 virtual int32_t OpenP2PConnection(const DistributedHardware::DmDeviceInfo &deviceInfo) = 0; 40 virtual int32_t CloseP2PConnection(const DistributedHardware::DmDeviceInfo &deviceInfo) = 0; 41 virtual int32_t OpenP2PConnectionEx(const std::string &networkId, sptr<IFileDfsListener> remoteReverseObj) = 0; 42 virtual int32_t CloseP2PConnectionEx(const std::string &networkId) = 0; 43 virtual int32_t PrepareSession(const std::string &srcUri, 44 const std::string &dstUri, 45 const std::string &srcDeviceId, 46 const sptr<IRemoteObject> &listener, 47 HmdfsInfo &info) = 0; 48 virtual int32_t CancelCopyTask(const std::string &sessionName) = 0; 49 50 virtual int32_t PushAsset(int32_t userId, 51 const sptr<AssetObj> &assetObj, 52 const sptr<IAssetSendCallback> &sendCallback) = 0; 53 virtual int32_t RegisterAssetCallback(const sptr<IAssetRecvCallback> &recvCallback) = 0; 54 virtual int32_t UnRegisterAssetCallback(const sptr<IAssetRecvCallback> &recvCallback) =0; 55 56 virtual int32_t GetSize(const std::string &uri, bool isSrcUri, uint64_t &size) = 0; 57 virtual int32_t IsDirectory(const std::string &uri, bool isSrcUri, bool &isDirectory) = 0; 58 virtual int32_t Copy(const std::string &srcUri, const std::string &destUri, ProcessCallback processCallback) = 0; 59 virtual int32_t Cancel(const std::string &srcUri, const std::string &destUri) = 0; 60 virtual int32_t Cancel() = 0; 61 }; 62 } // namespace DistributedFile 63 } // namespace Storage 64 } // namespace OHOS 65 66 #endif // DISTRIBUTED_FILE_DAEMON_MANAGER_H