created a new thread to write file to drop directory on client side
This commit is contained in:
parent
8301d50ab7
commit
6e50945bf9
|
@ -68,7 +68,8 @@ CClient::CClient(IEventQueue* events,
|
|||
m_events(events),
|
||||
m_cryptoStream(NULL),
|
||||
m_crypto(crypto),
|
||||
m_sendFileThread(NULL)
|
||||
m_sendFileThread(NULL),
|
||||
m_writeToDropDirThread(NULL)
|
||||
{
|
||||
assert(m_socketFactory != NULL);
|
||||
assert(m_screen != NULL);
|
||||
|
@ -722,16 +723,31 @@ void
|
|||
CClient::onFileRecieveCompleted()
|
||||
{
|
||||
if (isReceivedFileSizeValid()) {
|
||||
m_writeToDropDirThread = new CThread(
|
||||
new TMethodJob<CClient>(
|
||||
this, &CClient::writeToDropDirThread));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CClient::writeToDropDirThread(void*)
|
||||
{
|
||||
while (m_screen->getFakeDraggingStarted()) {
|
||||
ARCH->sleep(.1f);
|
||||
}
|
||||
|
||||
m_fileTransferDes = m_screen->getDropTarget();
|
||||
if (!m_fileTransferDes.empty()) {
|
||||
if (!m_fileTransferDes.empty() && m_dragFileList.size() > 0) {
|
||||
std::fstream file;
|
||||
CString dropTarget = m_fileTransferDes;
|
||||
#ifdef SYSAPI_WIN32
|
||||
m_fileTransferDes.append("\\");
|
||||
dropTarget.append("\\");
|
||||
#else
|
||||
m_fileTransferDes.append("/");
|
||||
dropTarget.append("/");
|
||||
#endif
|
||||
m_fileTransferDes.append(m_dragFileList.at(0));
|
||||
file.open(m_fileTransferDes.c_str(), std::ios::out | std::ios::binary);
|
||||
dropTarget.append(m_dragFileList.at(0));
|
||||
file.open(dropTarget.c_str(), std::ios::out | std::ios::binary);
|
||||
if (!file.is_open()) {
|
||||
// TODO: file open failed
|
||||
}
|
||||
|
@ -742,7 +758,6 @@ CClient::onFileRecieveCompleted()
|
|||
else {
|
||||
LOG((CLOG_ERR "drop file failed: drop target is empty"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -182,6 +182,7 @@ private:
|
|||
void sendConnectionFailedEvent(const char* msg);
|
||||
void sendFileChunk(const void* data);
|
||||
void sendFileThread(void*);
|
||||
void writeToDropDirThread(void*);
|
||||
void setupConnecting();
|
||||
void setupConnection();
|
||||
void setupScreen();
|
||||
|
@ -234,6 +235,7 @@ private:
|
|||
CDragFileList m_dragFileList;
|
||||
CString m_dragFileExt;
|
||||
CThread* m_sendFileThread;
|
||||
CThread* m_writeToDropDirThread;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -640,7 +640,6 @@ COSXScreen::getDropTargetThread(void*)
|
|||
void
|
||||
COSXScreen::fakeMouseMove(SInt32 x, SInt32 y)
|
||||
{
|
||||
if (CApp::instance().argsBase().m_enableDragDrop) {
|
||||
if (m_fakeDraggingStarted) {
|
||||
// HACK: for some reason the drag icon
|
||||
// does not follow the cursor unless a key
|
||||
|
@ -653,7 +652,6 @@ COSXScreen::fakeMouseMove(SInt32 x, SInt32 y)
|
|||
if (m_buttonState.test(0)) {
|
||||
m_draggingStarted = true;
|
||||
}
|
||||
}
|
||||
|
||||
// synthesize event
|
||||
CGPoint pos;
|
||||
|
@ -2086,6 +2084,7 @@ COSXScreen::CFStringRefToUTF8String(CFStringRef aString)
|
|||
void
|
||||
COSXScreen::fakeDraggingFiles(CString str)
|
||||
{
|
||||
if (CApp::instance().argsBase().m_enableDragDrop) {
|
||||
m_fakeDraggingStarted = true;
|
||||
#if defined(MAC_OS_X_VERSION_10_7)
|
||||
// TODO: use real file extension
|
||||
|
@ -2093,6 +2092,7 @@ COSXScreen::fakeDraggingFiles(CString str)
|
|||
#else
|
||||
LOG((CLOG_WARN "drag drop not supported"));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
CString&
|
||||
|
|
|
@ -76,7 +76,7 @@ CServer::CServer(CConfig& config, CPrimaryClient* primaryClient, CScreen* screen
|
|||
m_lockedToScreen(false),
|
||||
m_screen(screen),
|
||||
m_sendFileThread(NULL),
|
||||
m_writeToDropDir(NULL)
|
||||
m_writeToDropDirThread(NULL)
|
||||
{
|
||||
// must have a primary client and it must have a canonical name
|
||||
assert(m_primaryClient != NULL);
|
||||
|
@ -1958,7 +1958,7 @@ void
|
|||
CServer::onFileRecieveCompleted()
|
||||
{
|
||||
if (isReceivedFileSizeValid()) {
|
||||
m_writeToDropDir = new CThread(
|
||||
m_writeToDropDirThread = new CThread(
|
||||
new TMethodJob<CServer>(
|
||||
this, &CServer::writeToDropDirThread));
|
||||
}
|
||||
|
|
|
@ -469,7 +469,7 @@ private:
|
|||
CString m_fileTransferDes;
|
||||
CDragFileList m_dragFileList;
|
||||
CThread* m_sendFileThread;
|
||||
CThread* m_writeToDropDir;
|
||||
CThread* m_writeToDropDirThread;
|
||||
CString m_dragFileExt;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue