mirror of
https://github.com/debauchee/barrier.git
synced 2026-07-27 08:40:41 +08:00
- redesigned drag information protocol
- used DragInformation to encapsulate information and helper functions. - renamed parameters in sendDragInfo function.
This commit is contained in:
@@ -78,7 +78,8 @@ public:
|
||||
virtual void screensaver(bool activate) = 0;
|
||||
virtual void resetOptions() = 0;
|
||||
virtual void setOptions(const COptionsList& options) = 0;
|
||||
virtual void sendDragInfo(UInt32 fileCount, const char* data, size_t dataSize) = 0;
|
||||
virtual void sendDragInfo(UInt32 fileCount, const char* info,
|
||||
size_t size) = 0;
|
||||
virtual void fileChunkSending(UInt8 mark, char* data, size_t dataSize) = 0;
|
||||
virtual CString getName() const;
|
||||
|
||||
|
||||
@@ -83,7 +83,8 @@ public:
|
||||
virtual void screensaver(bool activate) = 0;
|
||||
virtual void resetOptions() = 0;
|
||||
virtual void setOptions(const COptionsList& options) = 0;
|
||||
virtual void sendDragInfo(UInt32 fileCount, const char* data, size_t dataSize) = 0;
|
||||
virtual void sendDragInfo(UInt32 fileCount, const char* info,
|
||||
size_t size) = 0;
|
||||
virtual void fileChunkSending(UInt8 mark, char* data, size_t dataSize) = 0;
|
||||
|
||||
private:
|
||||
|
||||
@@ -361,7 +361,7 @@ CClientProxy1_0::mouseWheel(SInt32, SInt32 yDelta)
|
||||
}
|
||||
|
||||
void
|
||||
CClientProxy1_0::sendDragInfo(UInt32 fileCount, const char* data, size_t dataSize)
|
||||
CClientProxy1_0::sendDragInfo(UInt32 fileCount, const char* info, size_t size)
|
||||
{
|
||||
// ignore -- not supported in protocol 1.0
|
||||
LOG((CLOG_DEBUG "draggingInfoSending not supported"));
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
virtual void screensaver(bool activate);
|
||||
virtual void resetOptions();
|
||||
virtual void setOptions(const COptionsList& options);
|
||||
virtual void sendDragInfo(UInt32 fileCount, const char* data, size_t dataSize);
|
||||
virtual void sendDragInfo(UInt32 fileCount, const char* info, size_t size);
|
||||
virtual void fileChunkSending(UInt8 mark, char* data, size_t dataSize);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -42,11 +42,11 @@ CClientProxy1_5::~CClientProxy1_5()
|
||||
}
|
||||
|
||||
void
|
||||
CClientProxy1_5::sendDragInfo(UInt32 fileCount, const char* data, size_t dataSize)
|
||||
CClientProxy1_5::sendDragInfo(UInt32 fileCount, const char* info, size_t size)
|
||||
{
|
||||
CString info(data, dataSize);
|
||||
CString data(info, size);
|
||||
|
||||
CProtocolUtil::writef(getStream(), kMsgDDragInfo, fileCount, &info);
|
||||
CProtocolUtil::writef(getStream(), kMsgDDragInfo, fileCount, &data);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
CClientProxy1_5(const CString& name, synergy::IStream* adoptedStream, CServer* server, IEventQueue* events);
|
||||
~CClientProxy1_5();
|
||||
|
||||
virtual void sendDragInfo(UInt32 fileCount, const char* data, size_t dataSize);
|
||||
virtual void sendDragInfo(UInt32 fileCount, const char* info, size_t size);
|
||||
virtual void fileChunkSending(UInt8 mark, char* data, size_t dataSize);
|
||||
virtual bool parseMessage(const UInt8* code);
|
||||
void fileChunkReceived();
|
||||
|
||||
@@ -250,7 +250,7 @@ CPrimaryClient::screensaver(bool)
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryClient::sendDragInfo(UInt32 fileCount, const char* data, size_t dataSize)
|
||||
CPrimaryClient::sendDragInfo(UInt32 fileCount, const char* info, size_t size)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ public:
|
||||
virtual void screensaver(bool activate);
|
||||
virtual void resetOptions();
|
||||
virtual void setOptions(const COptionsList& options);
|
||||
virtual void sendDragInfo(UInt32 fileCount, const char* data, size_t dataSize);
|
||||
virtual void sendDragInfo(UInt32 fileCount, const char* info, size_t size);
|
||||
virtual void fileChunkSending(UInt8 mark, char* data, size_t dataSize);
|
||||
|
||||
private:
|
||||
|
||||
@@ -1802,7 +1802,9 @@ CServer::getDragInfoThread(void*)
|
||||
m_dragFileList.clear();
|
||||
CString& dragFileList = m_screen->getDraggingFilename();
|
||||
if (!dragFileList.empty()) {
|
||||
m_dragFileList.push_back(dragFileList);
|
||||
CDragInformation di;
|
||||
di.setFilename(dragFileList);
|
||||
m_dragFileList.push_back(di);
|
||||
}
|
||||
|
||||
#if defined(__APPLE__)
|
||||
@@ -1820,20 +1822,19 @@ CServer::getDragInfoThread(void*)
|
||||
void
|
||||
CServer::sendDragInfo(CBaseClientProxy* newScreen)
|
||||
{
|
||||
// TODO: support multiple files dragging
|
||||
CString& dragFile = m_dragFileList.at(0);
|
||||
size_t size = dragFile.size() + 1;
|
||||
char* fileList = NULL;
|
||||
UInt32 fileCount = 1;
|
||||
if (dragFile.empty() == false) {
|
||||
fileList = new char[size];
|
||||
memcpy(fileList, dragFile.c_str(), size);
|
||||
fileList[size - 1] = '\0';
|
||||
|
||||
CString infoString;
|
||||
UInt32 fileCount = CDragInformation::setupDragInfo(m_dragFileList, infoString);
|
||||
|
||||
if (fileCount > 0) {
|
||||
char* info = NULL;
|
||||
size_t size = infoString.size();
|
||||
info = new char[size];
|
||||
memcpy(info, infoString.c_str(), size);
|
||||
|
||||
LOG((CLOG_DEBUG2 "sending drag information to client"));
|
||||
LOG((CLOG_DEBUG3 "dragging file list: %s", fileList));
|
||||
LOG((CLOG_DEBUG3 "dragging file list: %s", info));
|
||||
LOG((CLOG_DEBUG3 "dragging file list string size: %i", size));
|
||||
newScreen->sendDragInfo(fileCount, fileList, size);
|
||||
newScreen->sendDragInfo(fileCount, info, size);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2050,7 +2051,7 @@ CServer::writeToDropDirThread(void*)
|
||||
#else
|
||||
dropTarget.append("/");
|
||||
#endif
|
||||
dropTarget.append(m_dragFileList.at(0));
|
||||
dropTarget.append(m_dragFileList.at(0).getFilename());
|
||||
file.open(dropTarget.c_str(), std::ios::out | std::ios::binary);
|
||||
if (!file.is_open()) {
|
||||
// TODO: file open failed
|
||||
@@ -2058,6 +2059,8 @@ CServer::writeToDropDirThread(void*)
|
||||
|
||||
file.write(m_receivedFileData.c_str(), m_receivedFileData.size());
|
||||
file.close();
|
||||
|
||||
m_dragFileList.clear();
|
||||
}
|
||||
else {
|
||||
LOG((CLOG_ERR "drop file failed: drop target is empty"));
|
||||
|
||||
Reference in New Issue
Block a user