- Allow dragging one file from Windows (server) to Mac (client), --filetransfer-des needs to be specified in client side's command line.

This commit is contained in:
jerry
2013-08-23 15:36:23 +00:00
parent 012fe6ddd8
commit 031a84ca84
17 changed files with 95 additions and 23 deletions

View File

@@ -85,6 +85,10 @@ CClient::CClient(IEventQueue* events,
this,
new TMethodEventJob<CClient>(this,
&CClient::handleFileChunkSending));
m_events->adoptHandler(m_events->forIScreen().fileRecieveComplete(),
this,
new TMethodEventJob<CClient>(this,
&CClient::handleFileRecieveComplete));
}
CClient::~CClient()
@@ -706,6 +710,29 @@ CClient::handleFileChunkSending(const CEvent& event, void*)
sendFileChunk(event.getData());
}
void
CClient::handleFileRecieveComplete(const CEvent& event, void*)
{
onFileRecieveComplete();
}
void
CClient::onFileRecieveComplete()
{
if (isReceivedFileSizeValid()) {
if (!m_fileTransferDes.empty()) {
std::fstream file;
file.open(m_fileTransferDes.c_str(), std::ios::out | std::ios::binary);
if (!file.is_open()) {
// TODO: file open failed
}
file.write(m_receivedFileData.c_str(), m_receivedFileData.size());
file.close();
}
}
}
void
CClient::clearReceivedFileData()
{

View File

@@ -104,6 +104,9 @@ public:
//! Create a new thread and use it to send file to Server
void sendFileToServer(const char* filename);
//! Set file transder destination
void setFileTransferDes(CString& des) { m_fileTransferDes = des; }
//@}
//! @name accessors
//@{
@@ -190,6 +193,8 @@ private:
void handleSuspend(const CEvent& event, void*);
void handleResume(const CEvent& event, void*);
void handleFileChunkSending(const CEvent&, void*);
void handleFileRecieveComplete(const CEvent&, void*);
void onFileRecieveComplete();
public:
bool m_mock;
@@ -216,6 +221,8 @@ private:
CCryptoOptions m_crypto;
std::size_t m_expectedFileSize;
CString m_receivedFileData;
CString m_fileTransferSrc;
CString m_fileTransferDes;
};
#endif