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