refactored duplicated code in dragInfoReceived

refactored fakeDraggigFiles interface
This commit is contained in:
jerry 2014-04-30 18:54:32 +00:00
parent fd68b70878
commit f773ff3d00
11 changed files with 29 additions and 48 deletions

View File

@ -793,31 +793,14 @@ CClient::fileChunkReceived(CString data)
void void
CClient::dragInfoReceived(UInt32 fileNum, CString data) CClient::dragInfoReceived(UInt32 fileNum, CString data)
{ {
// TODO: fix duplicate function from CServer
if (!m_enableDragDrop) { if (!m_enableDragDrop) {
LOG((CLOG_DEBUG "drag drop not enabled, ignoring drag info.")); LOG((CLOG_DEBUG "drag drop not enabled, ignoring drag info."));
return; return;
} }
CDragInformation::parseDragInfo(m_dragFileList, fileNum, data); CDragInformation::parseDragInfo(m_dragFileList, fileNum, data);
LOG((CLOG_DEBUG "drag info received, total drag file number: %i", m_dragFileList.size()));
for (size_t i = 0; i < m_dragFileList.size(); ++i) { m_screen->startDraggingFiles(m_dragFileList);
LOG((CLOG_DEBUG2 "dragging file %i name: %s", i + 1, m_dragFileList.at(i).c_str()));
}
if (m_dragFileList.size() == 1) {
m_dragFileExt = CDragInformation::getDragFileExtension(m_dragFileList.at(0));
}
else if (m_dragFileList.size() > 1) {
m_dragFileExt.clear();
}
else {
return;
}
m_screen->startDraggingFiles(m_dragFileExt);
} }
bool bool

View File

@ -1827,7 +1827,7 @@ CMSWindowsScreen::CHotKeyItem::operator<(const CHotKeyItem& x) const
} }
void void
CMSWindowsScreen::fakeDraggingFiles(CString str) CMSWindowsScreen::fakeDraggingFiles(CDragFileList fileList)
{ {
// possible design flaw: this function stops a "not implemented" // possible design flaw: this function stops a "not implemented"
// exception from being thrown. // exception from being thrown.

View File

@ -20,6 +20,7 @@
#include "platform/MSWindowsHook.h" #include "platform/MSWindowsHook.h"
#include "synergy/PlatformScreen.h" #include "synergy/PlatformScreen.h"
#include "synergy/DragInformation.h"
#include "synwinhk/synwinhk.h" #include "synwinhk/synwinhk.h"
#include "mt/CondVar.h" #include "mt/CondVar.h"
#include "mt/Mutex.h" #include "mt/Mutex.h"
@ -115,7 +116,7 @@ public:
virtual void setOptions(const COptionsList& options); virtual void setOptions(const COptionsList& options);
virtual void setSequenceNumber(UInt32); virtual void setSequenceNumber(UInt32);
virtual bool isPrimary() const; virtual bool isPrimary() const;
virtual void fakeDraggingFiles(CString str); virtual void fakeDraggingFiles(CDragFileList fileList);
virtual CString& getDraggingFilename(); virtual CString& getDraggingFilename();
virtual const CString& virtual const CString&
getDropTarget() const; getDropTarget() const;

View File

@ -2075,12 +2075,16 @@ COSXScreen::CFStringRefToUTF8String(CFStringRef aString)
} }
void void
COSXScreen::fakeDraggingFiles(CString str) COSXScreen::fakeDraggingFiles(CDragFileList fileList)
{ {
m_fakeDraggingStarted = true; m_fakeDraggingStarted = true;
CString fileExt;
if (fileList.size() == 1) {
fileExt = CDragInformation::getDragFileExtension(fileList.at(0));
}
#if defined(MAC_OS_X_VERSION_10_7) #if defined(MAC_OS_X_VERSION_10_7)
// TODO: use real file extension fakeDragging(fileExt.c_str(), m_xCursor, m_yCursor);
fakeDragging(str.c_str(), m_xCursor, m_yCursor);
#else #else
LOG((CLOG_WARN "drag drop not supported")); LOG((CLOG_WARN "drag drop not supported"));
#endif #endif

View File

@ -20,6 +20,7 @@
#include "platform/OSXClipboard.h" #include "platform/OSXClipboard.h"
#include "synergy/PlatformScreen.h" #include "synergy/PlatformScreen.h"
#include "synergy/DragInformation.h"
#include "base/EventTypes.h" #include "base/EventTypes.h"
#include "common/stdmap.h" #include "common/stdmap.h"
#include "common/stdvector.h" #include "common/stdvector.h"
@ -95,7 +96,7 @@ public:
virtual void setOptions(const COptionsList& options); virtual void setOptions(const COptionsList& options);
virtual void setSequenceNumber(UInt32); virtual void setSequenceNumber(UInt32);
virtual bool isPrimary() const; virtual bool isPrimary() const;
virtual void fakeDraggingFiles(CString str); virtual void fakeDraggingFiles(CDragFileList fileList);
virtual CString& getDraggingFilename(); virtual CString& getDraggingFilename();
const CString& getDropTarget() const { return m_dropTarget; } const CString& getDropTarget() const { return m_dropTarget; }

View File

@ -2387,31 +2387,14 @@ CServer::sendFileThread(void* data)
void void
CServer::dragInfoReceived(UInt32 fileNum, CString content) CServer::dragInfoReceived(UInt32 fileNum, CString content)
{ {
// TODO: fix duplicate function from CClient
if (!m_enableDragDrop) { if (!m_enableDragDrop) {
LOG((CLOG_DEBUG "drag drop not enabled, ignoring drag info.")); LOG((CLOG_DEBUG "drag drop not enabled, ignoring drag info."));
return; return;
} }
CDragInformation::parseDragInfo(m_dragFileList, fileNum, content); CDragInformation::parseDragInfo(m_dragFileList, fileNum, content);
LOG((CLOG_DEBUG "drag info received, total drag file number: %i", m_dragFileList.size()));
for (size_t i = 0; i < m_dragFileList.size(); ++i) { m_screen->startDraggingFiles(m_dragFileList);
LOG((CLOG_DEBUG "dragging file %i name: %s", i + 1, m_dragFileList.at(i).c_str()));
}
if (m_dragFileList.size() == 1) {
m_dragFileExt = CDragInformation::getDragFileExtension(m_dragFileList.at(0));
}
else if (m_dragFileList.size() > 1) {
m_dragFileExt.clear();
}
else {
return;
}
m_screen->startDraggingFiles(m_dragFileExt);
} }
void void

View File

@ -46,6 +46,12 @@ CDragInformation::parseDragInfo(CDragFileList& dragFileList, UInt32 fileNum, CSt
startPos = findResult1 + 1; startPos = findResult1 + 1;
--fileNum; --fileNum;
} }
LOG((CLOG_DEBUG "drag info received, total drag file number: %i", dragFileList.size()));
for (size_t i = 0; i < dragFileList.size(); ++i) {
LOG((CLOG_DEBUG2 "dragging file %i name: %s", i + 1, dragFileList.at(i).c_str()));
}
} }
CString CString

View File

@ -18,6 +18,7 @@
#pragma once #pragma once
#include "synergy/DragInformation.h"
#include "synergy/clipboard_types.h" #include "synergy/clipboard_types.h"
#include "synergy/IScreen.h" #include "synergy/IScreen.h"
#include "synergy/IPrimaryScreen.h" #include "synergy/IPrimaryScreen.h"
@ -192,7 +193,7 @@ public:
virtual bool isDraggingStarted() = 0; virtual bool isDraggingStarted() = 0;
virtual bool isFakeDraggingStarted() = 0; virtual bool isFakeDraggingStarted() = 0;
virtual void fakeDraggingFiles(CString str) = 0; virtual void fakeDraggingFiles(CDragFileList fileList) = 0;
virtual const CString& virtual const CString&
getDropTarget() const = 0; getDropTarget() const = 0;

View File

@ -19,6 +19,7 @@
#pragma once #pragma once
#include "synergy/IPlatformScreen.h" #include "synergy/IPlatformScreen.h"
#include "synergy/DragInformation.h"
#include "common/stdexcept.h" #include "common/stdexcept.h"
//! Base screen implementation //! Base screen implementation
@ -97,7 +98,7 @@ public:
virtual void setSequenceNumber(UInt32) = 0; virtual void setSequenceNumber(UInt32) = 0;
virtual bool isPrimary() const = 0; virtual bool isPrimary() const = 0;
virtual void fakeDraggingFiles(CString str) { throw std::runtime_error("fakeDraggingFiles not implemented"); } virtual void fakeDraggingFiles(CDragFileList fileList) { throw std::runtime_error("fakeDraggingFiles not implemented"); }
virtual const CString& virtual const CString&
getDropTarget() const { throw std::runtime_error("getDropTarget not implemented"); } getDropTarget() const { throw std::runtime_error("getDropTarget not implemented"); }

View File

@ -435,9 +435,9 @@ CScreen::setDraggingStarted(bool started)
} }
void void
CScreen::startDraggingFiles(CString str) CScreen::startDraggingFiles(CDragFileList& fileList)
{ {
m_screen->fakeDraggingFiles(str); m_screen->fakeDraggingFiles(fileList);
} }
void void

View File

@ -18,6 +18,7 @@
#pragma once #pragma once
#include "synergy/DragInformation.h"
#include "synergy/clipboard_types.h" #include "synergy/clipboard_types.h"
#include "synergy/IScreen.h" #include "synergy/IScreen.h"
#include "synergy/key_types.h" #include "synergy/key_types.h"
@ -222,7 +223,7 @@ public:
void setDraggingStarted(bool started); void setDraggingStarted(bool started);
//! Fake a files dragging operation //! Fake a files dragging operation
void startDraggingFiles(CString str); void startDraggingFiles(CDragFileList& fileList);
void setEnableDragDrop(bool enabled); void setEnableDragDrop(bool enabled);
//@} //@}