Skip to content
Snippets Groups Projects
Commit 9c966b2b authored by Sébastien Blin's avatar Sébastien Blin
Browse files

stream: remove unused method as we use setOnRecv

Change-Id: I9f7e256911ef9c59947f605fadc6fb08aec5d5d0
parent d92eb322
No related branches found
No related tags found
No related merge requests found
...@@ -280,7 +280,6 @@ public: ...@@ -280,7 +280,6 @@ public:
void close() noexcept override; void close() noexcept override;
void closeAndEmit(DRing::DataTransferEventCode code) const noexcept; void closeAndEmit(DRing::DataTransferEventCode code) const noexcept;
bool read(std::vector<uint8_t>&) const override;
bool write(std::string_view) override; bool write(std::string_view) override;
void emit(DRing::DataTransferEventCode code) const override; void emit(DRing::DataTransferEventCode code) const override;
const std::string& peer() { return peerUri_; } const std::string& peer() { return peerUri_; }
...@@ -404,41 +403,6 @@ SubOutgoingFileTransfer::closeAndEmit(DRing::DataTransferEventCode code) const n ...@@ -404,41 +403,6 @@ SubOutgoingFileTransfer::closeAndEmit(DRing::DataTransferEventCode code) const n
emit(code); emit(code);
} }
bool
SubOutgoingFileTransfer::read(std::vector<uint8_t>& buf) const
{
// Need to send headers?
if (!headerSent_) {
sendHeader(buf);
return true;
}
// Wait for peer ready reply?
if (!peerReady_) {
buf.resize(0);
return true;
}
// Sending file data...
input_.read(reinterpret_cast<char*>(&buf[0]), buf.size());
buf.resize(input_.gcount());
if (buf.size()) {
std::lock_guard<std::mutex> lk {infoMutex_};
info_.bytesProgress += buf.size();
metaInfo_->updateInfo(info_);
return true;
}
// File end reached?
if (input_.eof()) {
JAMI_DBG() << "FTP#" << getId() << ": sent " << info_.bytesProgress << " bytes";
emit(DRing::DataTransferEventCode::finished);
return false;
}
throw std::runtime_error("FileTransfer IO read failed"); // TODO: better exception?
}
bool bool
SubOutgoingFileTransfer::write(std::string_view buffer) SubOutgoingFileTransfer::write(std::string_view buffer)
{ {
......
...@@ -135,36 +135,6 @@ FtpServer::closeCurrentFile() ...@@ -135,36 +135,6 @@ FtpServer::closeCurrentFile()
} }
} }
bool
FtpServer::read(std::vector<uint8_t>& buffer) const
{
if (!out_.stream) {
if (closed_.exchange(false)) {
if (rx_ < fileSize_) {
buffer.resize(4);
buffer[0] = 'N';
buffer[1] = 'G';
buffer[2] = 'O';
buffer[3] = '\n';
JAMI_DBG() << "[FTP] sending NGO (cancel) order";
return true;
}
}
buffer.resize(0);
} else if (go_) {
go_ = false;
buffer.resize(3);
buffer[0] = 'G';
buffer[1] = 'O';
buffer[2] = '\n';
JAMI_DBG() << "[FTP] sending GO order";
} else {
// Nothing to send. Avoid to have an useless buffer filled with 0.
buffer.resize(0);
}
return true;
}
bool bool
FtpServer::write(std::string_view buffer) FtpServer::write(std::string_view buffer)
{ {
...@@ -191,7 +161,8 @@ FtpServer::write(std::string_view buffer) ...@@ -191,7 +161,8 @@ FtpServer::write(std::string_view buffer)
closeCurrentFile(); closeCurrentFile();
// data may remains into the buffer: copy into the header stream for next header parsing // data may remains into the buffer: copy into the header stream for next header parsing
if (read_size < buffer.size()) if (read_size < buffer.size())
headerStream_.write((const char*)(buffer.data() + read_size), buffer.size() - read_size); headerStream_.write((const char*) (buffer.data() + read_size),
buffer.size() - read_size);
state_ = FtpState::PARSE_HEADERS; state_ = FtpState::PARSE_HEADERS;
} }
} break; } break;
......
...@@ -40,7 +40,6 @@ public: ...@@ -40,7 +40,6 @@ public:
const DRing::DataTransferId& outId = 0, const DRing::DataTransferId& outId = 0,
InternalCompletionCb&& cb = {}); InternalCompletionCb&& cb = {});
bool read(std::vector<uint8_t>& buffer) const override;
bool write(std::string_view data) override; bool write(std::string_view data) override;
DRing::DataTransferId getId() const override; DRing::DataTransferId getId() const override;
void close() noexcept override; void close() noexcept override;
......
...@@ -63,11 +63,6 @@ public: ...@@ -63,11 +63,6 @@ public:
virtual ~Stream() { close(); } virtual ~Stream() { close(); }
virtual void close() noexcept {} virtual void close() noexcept {}
virtual DRing::DataTransferId getId() const = 0; virtual DRing::DataTransferId getId() const = 0;
virtual bool read(std::vector<uint8_t>& buffer) const
{
(void) buffer;
return false;
}
virtual bool write(std::string_view) { return false; }; virtual bool write(std::string_view) { return false; };
virtual void setOnRecv(std::function<void(std::string_view)>&&) virtual void setOnRecv(std::function<void(std::string_view)>&&)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment