#6344 Make client recognise clipboard size limit

This commit is contained in:
Andrew Nelless 2017-01-24 16:20:50 +00:00 committed by Nick Bolton
parent 01109e0499
commit 8af215364f
2 changed files with 33 additions and 19 deletions

View File

@ -44,6 +44,7 @@
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <algorithm>
//
// Client
@ -73,7 +74,8 @@ Client::Client(
m_socket(NULL),
m_useSecureNetwork(args.m_enableCrypto),
m_args(args),
m_enableClipboard(true)
m_enableClipboard(true),
m_maximumClipboardSize(INT32_MAX)
{
assert(m_socketFactory != NULL);
assert(m_screen != NULL);
@ -359,13 +361,24 @@ Client::setOptions(const OptionsList& options)
const OptionID id = *index;
if (id == kOptionClipboardSharing) {
index++;
if (*index == static_cast<OptionValue>(false)) {
if (index != options.end()) {
if (*index) {
LOG((CLOG_NOTE "clipboard sharing is disabled"));
}
m_enableClipboard = *index;
break;
}
} else if (id == kOptionClipboardSharingSize) {
index++;
if (index != options.end()) {
m_maximumClipboardSize = std::max(0u, *index);
}
}
}
if (m_enableClipboard && !m_maximumClipboardSize) {
m_enableClipboard = false;
LOG((CLOG_NOTE "clipboard sharing is disabled because the server "
"set the maximum clipboard size to 0"));
}
m_screen->setOptions(options);
@ -656,7 +669,7 @@ Client::handleShapeChanged(const Event&, void*)
void
Client::handleClipboardGrabbed(const Event& event, void*)
{
if (!m_enableClipboard) {
if (!m_enableClipboard || (m_maximumClipboardSize == 0)) {
return;
}

View File

@ -224,4 +224,5 @@ private:
bool m_useSecureNetwork;
ClientArgs m_args;
bool m_enableClipboard;
size_t m_maximumClipboardSize;
};