diff options
Diffstat (limited to 'common/rfb/VNCServerST.cxx')
-rw-r--r-- | common/rfb/VNCServerST.cxx | 76 |
1 files changed, 65 insertions, 11 deletions
diff --git a/common/rfb/VNCServerST.cxx b/common/rfb/VNCServerST.cxx index 21af0dac..a3655bca 100644 --- a/common/rfb/VNCServerST.cxx +++ b/common/rfb/VNCServerST.cxx @@ -1,5 +1,5 @@ /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. - * Copyright 2009-2018 Pierre Ossman for Cendio AB + * Copyright 2009-2019 Pierre Ossman for Cendio AB * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -77,8 +77,8 @@ static LogWriter connectionsLog("Connections"); VNCServerST::VNCServerST(const char* name_, SDesktop* desktop_) : blHosts(&blacklist), desktop(desktop_), desktopStarted(false), blockCounter(0), pb(0), ledState(ledUnknown), - name(strDup(name_)), pointerClient(0), comparer(0), - cursor(new Cursor(0, 0, Point(), NULL)), + name(strDup(name_)), pointerClient(0), clipboardClient(0), + comparer(0), cursor(new Cursor(0, 0, Point(), NULL)), renderedCursorInvalid(false), keyRemapper(&KeyRemapper::defInstance), idleTimer(this), disconnectTimer(this), connectTimer(this), @@ -167,9 +167,12 @@ void VNCServerST::removeSocket(network::Socket* sock) { if ((*ci)->getSock() == sock) { clients.remove(*ci); - // - Release the cursor if this client owns it + // - Remove any references to it if (pointerClient == *ci) pointerClient = NULL; + if (clipboardClient == *ci) + clipboardClient = NULL; + clipboardRequestors.remove(*ci); // Adjust the exit timers connectTimer.stop(); @@ -331,23 +334,51 @@ void VNCServerST::setScreenLayout(const ScreenSet& layout) } } -void VNCServerST::bell() +void VNCServerST::requestClipboard() +{ + if (clipboardClient == NULL) + return; + + clipboardClient->requestClipboard(); +} + +void VNCServerST::announceClipboard(bool available) { std::list<VNCSConnectionST*>::iterator ci, ci_next; + + if (available) + clipboardClient = NULL; + + clipboardRequestors.clear(); + for (ci = clients.begin(); ci != clients.end(); ci = ci_next) { ci_next = ci; ci_next++; - (*ci)->bellOrClose(); + (*ci)->announceClipboard(available); } } -void VNCServerST::serverCutText(const char* str) +void VNCServerST::sendClipboardData(const char* data) { - if (strchr(str, '\r') != NULL) + std::list<VNCSConnectionST*>::iterator ci, ci_next; + + if (strchr(data, '\r') != NULL) throw Exception("Invalid carriage return in clipboard data"); + + for (ci = clipboardRequestors.begin(); + ci != clipboardRequestors.end(); ci = ci_next) { + ci_next = ci; ci_next++; + (*ci)->sendClipboardData(data); + } + + clipboardRequestors.clear(); +} + +void VNCServerST::bell() +{ std::list<VNCSConnectionST*>::iterator ci, ci_next; for (ci = clients.begin(); ci != clients.end(); ci = ci_next) { ci_next = ci; ci_next++; - (*ci)->serverCutTextOrClose(str); + (*ci)->bellOrClose(); } } @@ -461,9 +492,32 @@ void VNCServerST::pointerEvent(VNCSConnectionST* client, desktop->pointerEvent(pos, buttonMask); } -void VNCServerST::clientCutText(const char* str) +void VNCServerST::handleClipboardRequest(VNCSConnectionST* client) { - desktop->clientCutText(str); + clipboardRequestors.push_back(client); + if (clipboardRequestors.size() == 1) + desktop->handleClipboardRequest(); +} + +void VNCServerST::handleClipboardAnnounce(VNCSConnectionST* client, + bool available) +{ + if (available) + clipboardClient = client; + else { + if (client != clipboardClient) + return; + clipboardClient = NULL; + } + desktop->handleClipboardAnnounce(available); +} + +void VNCServerST::handleClipboardData(VNCSConnectionST* client, + const char* data) +{ + if (client != clipboardClient) + return; + desktop->handleClipboardData(data); } unsigned int VNCServerST::setDesktopSize(VNCSConnectionST* requester, |