22#include <dhtnet/multiplexed_socket.h>
59 const std::string& fileId,
60 const std::string& interactionId,
75 std::shared_ptr<dhtnet::ChannelSocket>
channel_ {};
84 const std::string& fileId,
85 const std::string& interactionId,
92 std::mutex streamMtx_;
93 std::ofstream stream_;
94 std::string sha3Sum_ {};
95 std::filesystem::path path_;
102 const std::string& fileId,
103 const std::string& interactionId,
112 std::ifstream stream_;
120 TransferManager(
const std::string& accountId,
const std::string&
accountUri,
const std::string& to,
const std::mt19937_64& rand);
132 void transferFile(
const std::shared_ptr<dhtnet::ChannelSocket>& channel,
133 const std::string& fileId,
134 const std::string& interactionId,
135 const std::string&
path,
144 bool cancel(
const std::string& fileId);
154 bool info(
const std::string& fileId,
168 const std::string& interactionId,
169 const std::string& sha3sum,
170 const std::string&
path,
180 const std::shared_ptr<dhtnet::ChannelSocket>& channel,
187 std::filesystem::path
path(
const std::string& fileId)
const;
194 bool isWaiting(
const std::string& fileId)
const;
204 std::weak_ptr<TransferManager> weak()
210 std::unique_ptr<Impl> pimpl_;
void emit(libjami::DataTransferEventCode code)
void onFinished(std::function< void(uint32_t)> &&cb)
std::string interactionId_
std::shared_ptr< dhtnet::ChannelSocket > channel() const
libjami::DataTransferInfo info() const
libjami::DataTransferInfo info_
std::atomic_bool isUserCancelled_
std::function< void(uint32_t)> finishedCb_
std::shared_ptr< dhtnet::ChannelSocket > channel_
void waitForTransfer(const std::string &fileId, const std::string &interactionId, const std::string &sha3sum, const std::string &path, std::size_t total)
Inform the transfer manager that a transfer is waited (and will be automatically accepted)
std::filesystem::path path(const std::string &fileId) const
Retrieve path of a file.
void onIncomingFileTransfer(const std::string &fileId, const std::shared_ptr< dhtnet::ChannelSocket > &channel, size_t start)
Handle incoming transfer.
void onIncomingProfile(const std::shared_ptr< dhtnet::ChannelSocket > &channel, const std::string &sha3Sum="")
std::vector< WaitingRequest > waitingRequests() const
Retrieve waiting files.
std::filesystem::path profilePath(const std::string &contactId) const
void transferFile(const std::shared_ptr< dhtnet::ChannelSocket > &channel, const std::string &fileId, const std::string &interactionId, const std::string &path, size_t start=0, size_t end=0, OnFinishedCb onFinished={})
Send a file to a channel.
bool info(const std::string &fileId, std::string &path, int64_t &total, int64_t &progress) const noexcept
Get current transfer info.
bool cancel(const std::string &fileId)
Refuse a transfer.
bool isWaiting(const std::string &fileId) const
std::function< void()> OnFinishedCb
void emitSignal(Args... args)
libjami::DataTransferId generateUID(std::mt19937_64 &engine)
std::function< void(const std::string &)> InternalCompletionCb
enum LIBJAMI_PUBLIC DataTransferEventCode
Simple macro to hide class' copy constructor and assignment operator.
#define NON_COPYABLE(ClassName)
std::shared_ptr< Stream > stream
libjami::DataTransferId id
std::string interactionId