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
CClient::dragInfoReceived(UInt32 fileNum, CString data)
{
// TODO: fix duplicate function from CServer
if (!m_enableDragDrop) {
LOG((CLOG_DEBUG "drag drop not enabled, ignoring drag info."));
return;
}
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) {
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);
m_screen->startDraggingFiles(m_dragFileList);
}
bool

View File

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

View File

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

View File

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

View File

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

View File

@ -2387,31 +2387,14 @@ CServer::sendFileThread(void* data)
void
CServer::dragInfoReceived(UInt32 fileNum, CString content)
{
// TODO: fix duplicate function from CClient
if (!m_enableDragDrop) {
LOG((CLOG_DEBUG "drag drop not enabled, ignoring drag info."));
return;
}
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) {
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);
m_screen->startDraggingFiles(m_dragFileList);
}
void

View File

@ -46,6 +46,12 @@ CDragInformation::parseDragInfo(CDragFileList& dragFileList, UInt32 fileNum, CSt
startPos = findResult1 + 1;
--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

View File

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

View File

@ -19,6 +19,7 @@
#pragma once
#include "synergy/IPlatformScreen.h"
#include "synergy/DragInformation.h"
#include "common/stdexcept.h"
//! Base screen implementation
@ -97,7 +98,7 @@ public:
virtual void setSequenceNumber(UInt32) = 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&
getDropTarget() const { throw std::runtime_error("getDropTarget not implemented"); }

View File

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

View File

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