Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. |
Pierre Ossman | b53c3bf | 2018-03-22 16:01:44 +0100 | [diff] [blame] | 2 | * Copyright 2009-2018 Pierre Ossman for Cendio AB |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 3 | * |
| 4 | * This is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This software is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this software; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 17 | * USA. |
| 18 | */ |
| 19 | |
| 20 | // -=- Single-Threaded VNC Server implementation |
| 21 | |
| 22 | |
| 23 | // Note about how sockets get closed: |
| 24 | // |
| 25 | // Closing sockets to clients is non-trivial because the code which calls |
| 26 | // VNCServerST must explicitly know about all the sockets (so that it can block |
| 27 | // on them appropriately). However, VNCServerST may want to close clients for |
| 28 | // a number of reasons, and from a variety of entry points. The simplest is |
| 29 | // when processSocketEvent() is called for a client, and the remote end has |
| 30 | // closed its socket. A more complex reason is when processSocketEvent() is |
| 31 | // called for a client which has just sent a ClientInit with the shared flag |
| 32 | // set to false - in this case we want to close all other clients. Yet another |
| 33 | // reason for disconnecting clients is when the desktop size has changed as a |
| 34 | // result of a call to setPixelBuffer(). |
| 35 | // |
| 36 | // The responsibility for creating and deleting sockets is entirely with the |
| 37 | // calling code. When VNCServerST wants to close a connection to a client it |
| 38 | // calls the VNCSConnectionST's close() method which calls shutdown() on the |
| 39 | // socket. Eventually the calling code will notice that the socket has been |
| 40 | // shut down and call removeSocket() so that we can delete the |
| 41 | // VNCSConnectionST. Note that the socket must not be deleted by the calling |
| 42 | // code until after removeSocket() has been called. |
| 43 | // |
| 44 | // One minor complication is that we don't allocate a VNCSConnectionST object |
| 45 | // for a blacklisted host (since we want to minimise the resources used for |
| 46 | // dealing with such a connection). In order to properly implement the |
| 47 | // getSockets function, we must maintain a separate closingSockets list, |
| 48 | // otherwise blacklisted connections might be "forgotten". |
| 49 | |
| 50 | |
Pierre Ossman | 559a2e8 | 2012-01-23 15:54:11 +0000 | [diff] [blame] | 51 | #include <assert.h> |
Pierre Ossman | f99c571 | 2009-03-13 14:41:27 +0000 | [diff] [blame] | 52 | #include <stdlib.h> |
| 53 | |
Pierre Ossman | 707fa12 | 2015-12-11 20:21:20 +0100 | [diff] [blame] | 54 | #include <rfb/ComparingUpdateTracker.h> |
| 55 | #include <rfb/KeyRemapper.h> |
| 56 | #include <rfb/ListConnInfo.h> |
| 57 | #include <rfb/Security.h> |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 58 | #include <rfb/ServerCore.h> |
| 59 | #include <rfb/VNCServerST.h> |
| 60 | #include <rfb/VNCSConnectionST.h> |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 61 | #include <rfb/util.h> |
Pierre Ossman | bb305ca | 2016-12-11 12:41:26 +0100 | [diff] [blame] | 62 | #include <rfb/ledStates.h> |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 63 | |
| 64 | #include <rdr/types.h> |
| 65 | |
| 66 | using namespace rfb; |
| 67 | |
| 68 | static LogWriter slog("VNCServerST"); |
| 69 | LogWriter VNCServerST::connectionsLog("Connections"); |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 70 | |
| 71 | // |
| 72 | // -=- VNCServerST Implementation |
| 73 | // |
| 74 | |
| 75 | // -=- Constructors/Destructor |
| 76 | |
Adam Tkac | a6578bf | 2010-04-23 14:07:41 +0000 | [diff] [blame] | 77 | VNCServerST::VNCServerST(const char* name_, SDesktop* desktop_) |
Pierre Ossman | 559a2e8 | 2012-01-23 15:54:11 +0000 | [diff] [blame] | 78 | : blHosts(&blacklist), desktop(desktop_), desktopStarted(false), |
Pierre Ossman | bb305ca | 2016-12-11 12:41:26 +0100 | [diff] [blame] | 79 | blockCounter(0), pb(0), ledState(ledUnknown), |
Adam Tkac | d36b626 | 2009-09-04 10:57:20 +0000 | [diff] [blame] | 80 | name(strDup(name_)), pointerClient(0), comparer(0), |
Pierre Ossman | 6a1a0d0 | 2017-02-19 15:48:17 +0100 | [diff] [blame] | 81 | cursor(new Cursor(0, 0, Point(), NULL)), |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 82 | renderedCursorInvalid(false), |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 83 | queryConnectionHandler(0), keyRemapper(&KeyRemapper::defInstance), |
Pierre Ossman | bbf955e | 2011-11-08 12:44:10 +0000 | [diff] [blame] | 84 | lastConnectionTime(0), disableclients(false), |
Pierre Ossman | 6e49e95 | 2016-10-07 15:59:38 +0200 | [diff] [blame] | 85 | frameTimer(this) |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 86 | { |
| 87 | lastUserInputTime = lastDisconnectTime = time(0); |
| 88 | slog.debug("creating single-threaded server %s", name.buf); |
| 89 | } |
| 90 | |
| 91 | VNCServerST::~VNCServerST() |
| 92 | { |
| 93 | slog.debug("shutting down server %s", name.buf); |
| 94 | |
| 95 | // Close any active clients, with appropriate logging & cleanup |
| 96 | closeClients("Server shutdown"); |
| 97 | |
Pierre Ossman | 6e49e95 | 2016-10-07 15:59:38 +0200 | [diff] [blame] | 98 | // Stop trying to render things |
| 99 | stopFrameClock(); |
| 100 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 101 | // Delete all the clients, and their sockets, and any closing sockets |
| 102 | // NB: Deleting a client implicitly removes it from the clients list |
| 103 | while (!clients.empty()) { |
| 104 | delete clients.front(); |
| 105 | } |
| 106 | |
| 107 | // Stop the desktop object if active, *only* after deleting all clients! |
Pierre Ossman | b53c3bf | 2018-03-22 16:01:44 +0100 | [diff] [blame] | 108 | stopDesktop(); |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 109 | |
Pierre Ossman | 05338bc | 2016-11-08 14:57:11 +0100 | [diff] [blame] | 110 | if (comparer) |
| 111 | comparer->logStats(); |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 112 | delete comparer; |
Pierre Ossman | 6a1a0d0 | 2017-02-19 15:48:17 +0100 | [diff] [blame] | 113 | |
| 114 | delete cursor; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | |
| 118 | // SocketServer methods |
| 119 | |
| 120 | void VNCServerST::addSocket(network::Socket* sock, bool outgoing) |
| 121 | { |
| 122 | // - Check the connection isn't black-marked |
| 123 | // *** do this in getSecurity instead? |
| 124 | CharArray address(sock->getPeerAddress()); |
| 125 | if (blHosts->isBlackmarked(address.buf)) { |
| 126 | connectionsLog.error("blacklisted: %s", address.buf); |
| 127 | try { |
| 128 | SConnection::writeConnFailedFromScratch("Too many security failures", |
| 129 | &sock->outStream()); |
| 130 | } catch (rdr::Exception&) { |
| 131 | } |
| 132 | sock->shutdown(); |
| 133 | closingSockets.push_back(sock); |
| 134 | return; |
| 135 | } |
| 136 | |
| 137 | if (clients.empty()) { |
| 138 | lastConnectionTime = time(0); |
| 139 | } |
| 140 | |
| 141 | VNCSConnectionST* client = new VNCSConnectionST(this, sock, outgoing); |
| 142 | client->init(); |
| 143 | } |
| 144 | |
| 145 | void VNCServerST::removeSocket(network::Socket* sock) { |
| 146 | // - If the socket has resources allocated to it, delete them |
| 147 | std::list<VNCSConnectionST*>::iterator ci; |
| 148 | for (ci = clients.begin(); ci != clients.end(); ci++) { |
| 149 | if ((*ci)->getSock() == sock) { |
| 150 | // - Delete the per-Socket resources |
| 151 | delete *ci; |
| 152 | |
| 153 | // - Check that the desktop object is still required |
Pierre Ossman | b53c3bf | 2018-03-22 16:01:44 +0100 | [diff] [blame] | 154 | if (authClientCount() == 0) |
| 155 | stopDesktop(); |
Pierre Ossman | 05338bc | 2016-11-08 14:57:11 +0100 | [diff] [blame] | 156 | |
| 157 | if (comparer) |
| 158 | comparer->logStats(); |
| 159 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 160 | return; |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | // - If the Socket has no resources, it may have been a closingSocket |
| 165 | closingSockets.remove(sock); |
| 166 | } |
| 167 | |
Pierre Ossman | d408ca5 | 2016-04-29 14:26:05 +0200 | [diff] [blame] | 168 | void VNCServerST::processSocketReadEvent(network::Socket* sock) |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 169 | { |
| 170 | // - Find the appropriate VNCSConnectionST and process the event |
| 171 | std::list<VNCSConnectionST*>::iterator ci; |
| 172 | for (ci = clients.begin(); ci != clients.end(); ci++) { |
| 173 | if ((*ci)->getSock() == sock) { |
| 174 | (*ci)->processMessages(); |
| 175 | return; |
| 176 | } |
| 177 | } |
| 178 | throw rdr::Exception("invalid Socket in VNCServerST"); |
| 179 | } |
| 180 | |
Pierre Ossman | d408ca5 | 2016-04-29 14:26:05 +0200 | [diff] [blame] | 181 | void VNCServerST::processSocketWriteEvent(network::Socket* sock) |
| 182 | { |
| 183 | // - Find the appropriate VNCSConnectionST and process the event |
| 184 | std::list<VNCSConnectionST*>::iterator ci; |
| 185 | for (ci = clients.begin(); ci != clients.end(); ci++) { |
| 186 | if ((*ci)->getSock() == sock) { |
| 187 | (*ci)->flushSocket(); |
| 188 | return; |
| 189 | } |
| 190 | } |
| 191 | throw rdr::Exception("invalid Socket in VNCServerST"); |
| 192 | } |
| 193 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 194 | int VNCServerST::checkTimeouts() |
| 195 | { |
| 196 | int timeout = 0; |
| 197 | std::list<VNCSConnectionST*>::iterator ci, ci_next; |
Pierre Ossman | 2d61deb | 2011-10-25 15:18:53 +0000 | [diff] [blame] | 198 | |
| 199 | soonestTimeout(&timeout, Timer::checkTimeouts()); |
| 200 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 201 | for (ci=clients.begin();ci!=clients.end();ci=ci_next) { |
| 202 | ci_next = ci; ci_next++; |
| 203 | soonestTimeout(&timeout, (*ci)->checkIdleTimeout()); |
| 204 | } |
| 205 | |
| 206 | int timeLeft; |
Constantin Kaplinsky | 8499d0c | 2008-08-21 05:51:29 +0000 | [diff] [blame] | 207 | time_t now = time(0); |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 208 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 209 | // Check MaxDisconnectionTime |
| 210 | if (rfb::Server::maxDisconnectionTime && clients.empty()) { |
| 211 | if (now < lastDisconnectTime) { |
| 212 | // Someone must have set the time backwards. |
| 213 | slog.info("Time has gone backwards - resetting lastDisconnectTime"); |
| 214 | lastDisconnectTime = now; |
| 215 | } |
| 216 | timeLeft = lastDisconnectTime + rfb::Server::maxDisconnectionTime - now; |
| 217 | if (timeLeft < -60) { |
| 218 | // Someone must have set the time forwards. |
| 219 | slog.info("Time has gone forwards - resetting lastDisconnectTime"); |
| 220 | lastDisconnectTime = now; |
| 221 | timeLeft = rfb::Server::maxDisconnectionTime; |
| 222 | } |
| 223 | if (timeLeft <= 0) { |
| 224 | slog.info("MaxDisconnectionTime reached, exiting"); |
| 225 | exit(0); |
| 226 | } |
| 227 | soonestTimeout(&timeout, timeLeft * 1000); |
| 228 | } |
| 229 | |
| 230 | // Check MaxConnectionTime |
| 231 | if (rfb::Server::maxConnectionTime && lastConnectionTime && !clients.empty()) { |
| 232 | if (now < lastConnectionTime) { |
| 233 | // Someone must have set the time backwards. |
| 234 | slog.info("Time has gone backwards - resetting lastConnectionTime"); |
| 235 | lastConnectionTime = now; |
| 236 | } |
| 237 | timeLeft = lastConnectionTime + rfb::Server::maxConnectionTime - now; |
| 238 | if (timeLeft < -60) { |
| 239 | // Someone must have set the time forwards. |
| 240 | slog.info("Time has gone forwards - resetting lastConnectionTime"); |
| 241 | lastConnectionTime = now; |
| 242 | timeLeft = rfb::Server::maxConnectionTime; |
| 243 | } |
| 244 | if (timeLeft <= 0) { |
| 245 | slog.info("MaxConnectionTime reached, exiting"); |
| 246 | exit(0); |
| 247 | } |
| 248 | soonestTimeout(&timeout, timeLeft * 1000); |
| 249 | } |
| 250 | |
| 251 | |
| 252 | // Check MaxIdleTime |
| 253 | if (rfb::Server::maxIdleTime) { |
| 254 | if (now < lastUserInputTime) { |
| 255 | // Someone must have set the time backwards. |
| 256 | slog.info("Time has gone backwards - resetting lastUserInputTime"); |
| 257 | lastUserInputTime = now; |
| 258 | } |
| 259 | timeLeft = lastUserInputTime + rfb::Server::maxIdleTime - now; |
| 260 | if (timeLeft < -60) { |
| 261 | // Someone must have set the time forwards. |
| 262 | slog.info("Time has gone forwards - resetting lastUserInputTime"); |
| 263 | lastUserInputTime = now; |
| 264 | timeLeft = rfb::Server::maxIdleTime; |
| 265 | } |
| 266 | if (timeLeft <= 0) { |
| 267 | slog.info("MaxIdleTime reached, exiting"); |
| 268 | exit(0); |
| 269 | } |
| 270 | soonestTimeout(&timeout, timeLeft * 1000); |
| 271 | } |
| 272 | |
| 273 | return timeout; |
| 274 | } |
| 275 | |
| 276 | |
| 277 | // VNCServer methods |
| 278 | |
Pierre Ossman | 559a2e8 | 2012-01-23 15:54:11 +0000 | [diff] [blame] | 279 | void VNCServerST::blockUpdates() |
| 280 | { |
| 281 | blockCounter++; |
Pierre Ossman | 6e49e95 | 2016-10-07 15:59:38 +0200 | [diff] [blame] | 282 | |
| 283 | stopFrameClock(); |
Pierre Ossman | 559a2e8 | 2012-01-23 15:54:11 +0000 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | void VNCServerST::unblockUpdates() |
| 287 | { |
| 288 | assert(blockCounter > 0); |
| 289 | |
| 290 | blockCounter--; |
| 291 | |
Pierre Ossman | 6e49e95 | 2016-10-07 15:59:38 +0200 | [diff] [blame] | 292 | // Restart the frame clock if we have updates |
| 293 | if (blockCounter == 0) { |
| 294 | if (!comparer->is_empty()) |
| 295 | startFrameClock(); |
| 296 | } |
Pierre Ossman | 559a2e8 | 2012-01-23 15:54:11 +0000 | [diff] [blame] | 297 | } |
| 298 | |
Pierre Ossman | 04e62db | 2009-03-23 16:57:07 +0000 | [diff] [blame] | 299 | void VNCServerST::setPixelBuffer(PixelBuffer* pb_, const ScreenSet& layout) |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 300 | { |
Pierre Ossman | 05338bc | 2016-11-08 14:57:11 +0100 | [diff] [blame] | 301 | if (comparer) |
| 302 | comparer->logStats(); |
| 303 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 304 | pb = pb_; |
| 305 | delete comparer; |
| 306 | comparer = 0; |
| 307 | |
Pierre Ossman | 04e62db | 2009-03-23 16:57:07 +0000 | [diff] [blame] | 308 | screenLayout = layout; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 309 | |
Pierre Ossman | 04e62db | 2009-03-23 16:57:07 +0000 | [diff] [blame] | 310 | if (!pb) { |
Michal Srb | 28d570d | 2017-09-29 14:45:33 +0200 | [diff] [blame] | 311 | screenLayout = ScreenSet(); |
| 312 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 313 | if (desktopStarted) |
| 314 | throw Exception("setPixelBuffer: null PixelBuffer when desktopStarted?"); |
Michal Srb | 28d570d | 2017-09-29 14:45:33 +0200 | [diff] [blame] | 315 | |
Pierre Ossman | 04e62db | 2009-03-23 16:57:07 +0000 | [diff] [blame] | 316 | return; |
| 317 | } |
| 318 | |
| 319 | comparer = new ComparingUpdateTracker(pb); |
Pierre Ossman | 6ea6e1a | 2014-02-12 16:33:43 +0100 | [diff] [blame] | 320 | renderedCursorInvalid = true; |
Pierre Ossman | b1e80f7 | 2017-09-22 16:48:14 +0200 | [diff] [blame] | 321 | startFrameClock(); |
Pierre Ossman | 04e62db | 2009-03-23 16:57:07 +0000 | [diff] [blame] | 322 | |
| 323 | // Make sure that we have at least one screen |
| 324 | if (screenLayout.num_screens() == 0) |
| 325 | screenLayout.add_screen(Screen(0, 0, 0, pb->width(), pb->height(), 0)); |
| 326 | |
| 327 | std::list<VNCSConnectionST*>::iterator ci, ci_next; |
| 328 | for (ci=clients.begin();ci!=clients.end();ci=ci_next) { |
| 329 | ci_next = ci; ci_next++; |
| 330 | (*ci)->pixelBufferChange(); |
| 331 | // Since the new pixel buffer means an ExtendedDesktopSize needs to |
| 332 | // be sent anyway, we don't need to call screenLayoutChange. |
| 333 | } |
| 334 | } |
| 335 | |
| 336 | void VNCServerST::setPixelBuffer(PixelBuffer* pb_) |
| 337 | { |
Michal Srb | 28d570d | 2017-09-29 14:45:33 +0200 | [diff] [blame] | 338 | ScreenSet layout = screenLayout; |
Pierre Ossman | 04e62db | 2009-03-23 16:57:07 +0000 | [diff] [blame] | 339 | |
| 340 | // Check that the screen layout is still valid |
Michal Srb | 28d570d | 2017-09-29 14:45:33 +0200 | [diff] [blame] | 341 | if (pb_ && !layout.validate(pb_->width(), pb_->height())) { |
Pierre Ossman | 04e62db | 2009-03-23 16:57:07 +0000 | [diff] [blame] | 342 | Rect fbRect; |
| 343 | ScreenSet::iterator iter, iter_next; |
| 344 | |
| 345 | fbRect.setXYWH(0, 0, pb_->width(), pb_->height()); |
| 346 | |
| 347 | for (iter = layout.begin();iter != layout.end();iter = iter_next) { |
| 348 | iter_next = iter; ++iter_next; |
| 349 | if (iter->dimensions.enclosed_by(fbRect)) |
| 350 | continue; |
| 351 | iter->dimensions = iter->dimensions.intersect(fbRect); |
| 352 | if (iter->dimensions.is_empty()) { |
| 353 | slog.info("Removing screen %d (%x) as it is completely outside the new framebuffer", |
| 354 | (int)iter->id, (unsigned)iter->id); |
| 355 | layout.remove_screen(iter->id); |
| 356 | } |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | setPixelBuffer(pb_, layout); |
| 361 | } |
| 362 | |
| 363 | void VNCServerST::setScreenLayout(const ScreenSet& layout) |
| 364 | { |
| 365 | if (!pb) |
| 366 | throw Exception("setScreenLayout: new screen layout without a PixelBuffer"); |
| 367 | if (!layout.validate(pb->width(), pb->height())) |
| 368 | throw Exception("setScreenLayout: invalid screen layout"); |
| 369 | |
Pierre Ossman | df45320 | 2009-04-02 14:26:45 +0000 | [diff] [blame] | 370 | screenLayout = layout; |
| 371 | |
Pierre Ossman | 04e62db | 2009-03-23 16:57:07 +0000 | [diff] [blame] | 372 | std::list<VNCSConnectionST*>::iterator ci, ci_next; |
| 373 | for (ci=clients.begin();ci!=clients.end();ci=ci_next) { |
| 374 | ci_next = ci; ci_next++; |
Pierre Ossman | a3ac01e | 2011-11-07 21:13:54 +0000 | [diff] [blame] | 375 | (*ci)->screenLayoutChangeOrClose(reasonServer); |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 376 | } |
| 377 | } |
| 378 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 379 | void VNCServerST::bell() |
| 380 | { |
| 381 | std::list<VNCSConnectionST*>::iterator ci, ci_next; |
| 382 | for (ci = clients.begin(); ci != clients.end(); ci = ci_next) { |
| 383 | ci_next = ci; ci_next++; |
Pierre Ossman | a3ac01e | 2011-11-07 21:13:54 +0000 | [diff] [blame] | 384 | (*ci)->bellOrClose(); |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 385 | } |
| 386 | } |
| 387 | |
| 388 | void VNCServerST::serverCutText(const char* str, int len) |
| 389 | { |
| 390 | std::list<VNCSConnectionST*>::iterator ci, ci_next; |
| 391 | for (ci = clients.begin(); ci != clients.end(); ci = ci_next) { |
| 392 | ci_next = ci; ci_next++; |
Pierre Ossman | a3ac01e | 2011-11-07 21:13:54 +0000 | [diff] [blame] | 393 | (*ci)->serverCutTextOrClose(str, len); |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 394 | } |
| 395 | } |
| 396 | |
Peter Ã…strand | c39e078 | 2009-01-15 12:21:42 +0000 | [diff] [blame] | 397 | void VNCServerST::setName(const char* name_) |
| 398 | { |
Adam Tkac | d36b626 | 2009-09-04 10:57:20 +0000 | [diff] [blame] | 399 | name.replaceBuf(strDup(name_)); |
Peter Ã…strand | c39e078 | 2009-01-15 12:21:42 +0000 | [diff] [blame] | 400 | std::list<VNCSConnectionST*>::iterator ci, ci_next; |
| 401 | for (ci = clients.begin(); ci != clients.end(); ci = ci_next) { |
| 402 | ci_next = ci; ci_next++; |
Pierre Ossman | a3ac01e | 2011-11-07 21:13:54 +0000 | [diff] [blame] | 403 | (*ci)->setDesktopNameOrClose(name_); |
Peter Ã…strand | c39e078 | 2009-01-15 12:21:42 +0000 | [diff] [blame] | 404 | } |
| 405 | } |
| 406 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 407 | void VNCServerST::add_changed(const Region& region) |
| 408 | { |
Pierre Ossman | bbf955e | 2011-11-08 12:44:10 +0000 | [diff] [blame] | 409 | if (comparer == NULL) |
| 410 | return; |
| 411 | |
| 412 | comparer->add_changed(region); |
Pierre Ossman | 6e49e95 | 2016-10-07 15:59:38 +0200 | [diff] [blame] | 413 | startFrameClock(); |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 414 | } |
| 415 | |
| 416 | void VNCServerST::add_copied(const Region& dest, const Point& delta) |
| 417 | { |
Pierre Ossman | bbf955e | 2011-11-08 12:44:10 +0000 | [diff] [blame] | 418 | if (comparer == NULL) |
| 419 | return; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 420 | |
Pierre Ossman | bbf955e | 2011-11-08 12:44:10 +0000 | [diff] [blame] | 421 | comparer->add_copied(dest, delta); |
Pierre Ossman | 6e49e95 | 2016-10-07 15:59:38 +0200 | [diff] [blame] | 422 | startFrameClock(); |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 423 | } |
| 424 | |
| 425 | void VNCServerST::setCursor(int width, int height, const Point& newHotspot, |
Pierre Ossman | 6a1a0d0 | 2017-02-19 15:48:17 +0100 | [diff] [blame] | 426 | const rdr::U8* data) |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 427 | { |
Pierre Ossman | 6a1a0d0 | 2017-02-19 15:48:17 +0100 | [diff] [blame] | 428 | delete cursor; |
| 429 | cursor = new Cursor(width, height, newHotspot, data); |
| 430 | cursor->crop(); |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 431 | |
| 432 | renderedCursorInvalid = true; |
| 433 | |
| 434 | std::list<VNCSConnectionST*>::iterator ci, ci_next; |
| 435 | for (ci = clients.begin(); ci != clients.end(); ci = ci_next) { |
| 436 | ci_next = ci; ci_next++; |
| 437 | (*ci)->renderedCursorChange(); |
| 438 | (*ci)->setCursorOrClose(); |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | void VNCServerST::setCursorPos(const Point& pos) |
| 443 | { |
| 444 | if (!cursorPos.equals(pos)) { |
| 445 | cursorPos = pos; |
| 446 | renderedCursorInvalid = true; |
| 447 | std::list<VNCSConnectionST*>::iterator ci; |
| 448 | for (ci = clients.begin(); ci != clients.end(); ci++) |
| 449 | (*ci)->renderedCursorChange(); |
| 450 | } |
| 451 | } |
| 452 | |
Pierre Ossman | bb305ca | 2016-12-11 12:41:26 +0100 | [diff] [blame] | 453 | void VNCServerST::setLEDState(unsigned int state) |
| 454 | { |
Pierre Ossman | b45a84f | 2016-12-12 16:59:15 +0100 | [diff] [blame] | 455 | std::list<VNCSConnectionST*>::iterator ci, ci_next; |
| 456 | |
| 457 | if (state == ledState) |
| 458 | return; |
| 459 | |
Pierre Ossman | bb305ca | 2016-12-11 12:41:26 +0100 | [diff] [blame] | 460 | ledState = state; |
Pierre Ossman | b45a84f | 2016-12-12 16:59:15 +0100 | [diff] [blame] | 461 | |
| 462 | for (ci = clients.begin(); ci != clients.end(); ci = ci_next) { |
| 463 | ci_next = ci; ci_next++; |
| 464 | (*ci)->setLEDStateOrClose(state); |
| 465 | } |
Pierre Ossman | bb305ca | 2016-12-11 12:41:26 +0100 | [diff] [blame] | 466 | } |
| 467 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 468 | // Other public methods |
| 469 | |
| 470 | void VNCServerST::approveConnection(network::Socket* sock, bool accept, |
| 471 | const char* reason) |
| 472 | { |
| 473 | std::list<VNCSConnectionST*>::iterator ci; |
| 474 | for (ci = clients.begin(); ci != clients.end(); ci++) { |
| 475 | if ((*ci)->getSock() == sock) { |
| 476 | (*ci)->approveConnectionOrClose(accept, reason); |
| 477 | return; |
| 478 | } |
| 479 | } |
| 480 | } |
| 481 | |
| 482 | void VNCServerST::closeClients(const char* reason, network::Socket* except) |
| 483 | { |
| 484 | std::list<VNCSConnectionST*>::iterator i, next_i; |
| 485 | for (i=clients.begin(); i!=clients.end(); i=next_i) { |
| 486 | next_i = i; next_i++; |
| 487 | if ((*i)->getSock() != except) |
| 488 | (*i)->close(reason); |
| 489 | } |
| 490 | } |
| 491 | |
| 492 | void VNCServerST::getSockets(std::list<network::Socket*>* sockets) |
| 493 | { |
| 494 | sockets->clear(); |
| 495 | std::list<VNCSConnectionST*>::iterator ci; |
| 496 | for (ci = clients.begin(); ci != clients.end(); ci++) { |
| 497 | sockets->push_back((*ci)->getSock()); |
| 498 | } |
| 499 | std::list<network::Socket*>::iterator si; |
| 500 | for (si = closingSockets.begin(); si != closingSockets.end(); si++) { |
| 501 | sockets->push_back(*si); |
| 502 | } |
| 503 | } |
| 504 | |
| 505 | SConnection* VNCServerST::getSConnection(network::Socket* sock) { |
| 506 | std::list<VNCSConnectionST*>::iterator ci; |
| 507 | for (ci = clients.begin(); ci != clients.end(); ci++) { |
| 508 | if ((*ci)->getSock() == sock) |
| 509 | return *ci; |
| 510 | } |
| 511 | return 0; |
| 512 | } |
| 513 | |
Pierre Ossman | bbf955e | 2011-11-08 12:44:10 +0000 | [diff] [blame] | 514 | bool VNCServerST::handleTimeout(Timer* t) |
| 515 | { |
Pierre Ossman | 6e49e95 | 2016-10-07 15:59:38 +0200 | [diff] [blame] | 516 | if (t == &frameTimer) { |
| 517 | // We keep running until we go a full interval without any updates |
| 518 | if (comparer->is_empty()) |
| 519 | return false; |
Pierre Ossman | bbf955e | 2011-11-08 12:44:10 +0000 | [diff] [blame] | 520 | |
Pierre Ossman | 6e49e95 | 2016-10-07 15:59:38 +0200 | [diff] [blame] | 521 | writeUpdate(); |
Pierre Ossman | 7be73d7 | 2017-11-06 13:16:35 +0100 | [diff] [blame] | 522 | |
| 523 | // If this is the first iteration then we need to adjust the timeout |
| 524 | if (frameTimer.getTimeoutMs() != 1000/rfb::Server::frameRate) { |
| 525 | frameTimer.start(1000/rfb::Server::frameRate); |
| 526 | return false; |
| 527 | } |
| 528 | |
Pierre Ossman | 6e49e95 | 2016-10-07 15:59:38 +0200 | [diff] [blame] | 529 | return true; |
| 530 | } |
Pierre Ossman | bbf955e | 2011-11-08 12:44:10 +0000 | [diff] [blame] | 531 | |
| 532 | return false; |
| 533 | } |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 534 | |
| 535 | // -=- Internal methods |
| 536 | |
| 537 | void VNCServerST::startDesktop() |
| 538 | { |
| 539 | if (!desktopStarted) { |
| 540 | slog.debug("starting desktop"); |
| 541 | desktop->start(this); |
| 542 | desktopStarted = true; |
| 543 | if (!pb) |
| 544 | throw Exception("SDesktop::start() did not set a valid PixelBuffer"); |
| 545 | } |
| 546 | } |
| 547 | |
Pierre Ossman | b53c3bf | 2018-03-22 16:01:44 +0100 | [diff] [blame] | 548 | void VNCServerST::stopDesktop() |
| 549 | { |
| 550 | if (desktopStarted) { |
| 551 | slog.debug("stopping desktop"); |
| 552 | desktopStarted = false; |
| 553 | desktop->stop(); |
| 554 | stopFrameClock(); |
| 555 | } |
| 556 | } |
| 557 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 558 | int VNCServerST::authClientCount() { |
| 559 | int count = 0; |
| 560 | std::list<VNCSConnectionST*>::iterator ci; |
| 561 | for (ci = clients.begin(); ci != clients.end(); ci++) { |
| 562 | if ((*ci)->authenticated()) |
| 563 | count++; |
| 564 | } |
| 565 | return count; |
| 566 | } |
| 567 | |
| 568 | inline bool VNCServerST::needRenderedCursor() |
| 569 | { |
| 570 | std::list<VNCSConnectionST*>::iterator ci; |
| 571 | for (ci = clients.begin(); ci != clients.end(); ci++) |
| 572 | if ((*ci)->needRenderedCursor()) return true; |
| 573 | return false; |
| 574 | } |
| 575 | |
Pierre Ossman | 6e49e95 | 2016-10-07 15:59:38 +0200 | [diff] [blame] | 576 | void VNCServerST::startFrameClock() |
Pierre Ossman | bbf955e | 2011-11-08 12:44:10 +0000 | [diff] [blame] | 577 | { |
Pierre Ossman | 6e49e95 | 2016-10-07 15:59:38 +0200 | [diff] [blame] | 578 | if (frameTimer.isStarted()) |
Pierre Ossman | bbf955e | 2011-11-08 12:44:10 +0000 | [diff] [blame] | 579 | return; |
Pierre Ossman | 559a2e8 | 2012-01-23 15:54:11 +0000 | [diff] [blame] | 580 | if (blockCounter > 0) |
| 581 | return; |
Pierre Ossman | b53c3bf | 2018-03-22 16:01:44 +0100 | [diff] [blame] | 582 | if (!desktopStarted) |
| 583 | return; |
Pierre Ossman | 559a2e8 | 2012-01-23 15:54:11 +0000 | [diff] [blame] | 584 | |
Pierre Ossman | 7be73d7 | 2017-11-06 13:16:35 +0100 | [diff] [blame] | 585 | // The first iteration will be just half a frame as we get a very |
| 586 | // unstable update rate if we happen to be perfectly in sync with |
| 587 | // the application's update rate |
| 588 | frameTimer.start(1000/rfb::Server::frameRate/2); |
Pierre Ossman | bbf955e | 2011-11-08 12:44:10 +0000 | [diff] [blame] | 589 | } |
| 590 | |
Pierre Ossman | 6e49e95 | 2016-10-07 15:59:38 +0200 | [diff] [blame] | 591 | void VNCServerST::stopFrameClock() |
| 592 | { |
| 593 | frameTimer.stop(); |
| 594 | } |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 595 | |
Pierre Ossman | a2b80d6 | 2018-03-23 09:30:09 +0100 | [diff] [blame] | 596 | int VNCServerST::msToNextUpdate() |
| 597 | { |
| 598 | // FIXME: If the application is updating slower than frameRate then |
| 599 | // we could allow the clients more time here |
| 600 | |
| 601 | if (!frameTimer.isStarted()) |
| 602 | return 1000/rfb::Server::frameRate/2; |
| 603 | else |
| 604 | return frameTimer.getRemainingMs(); |
| 605 | } |
| 606 | |
Pierre Ossman | 6e49e95 | 2016-10-07 15:59:38 +0200 | [diff] [blame] | 607 | // writeUpdate() is called on a regular interval in order to see what |
| 608 | // updates are pending and propagates them to the update tracker for |
| 609 | // each client. It uses the ComparingUpdateTracker's compare() method |
| 610 | // to filter out areas of the screen which haven't actually changed. It |
| 611 | // also checks the state of the (server-side) rendered cursor, if |
| 612 | // necessary rendering it again with the correct background. |
| 613 | |
| 614 | void VNCServerST::writeUpdate() |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 615 | { |
Constantin Kaplinsky | 604d781 | 2007-08-31 15:50:37 +0000 | [diff] [blame] | 616 | UpdateInfo ui; |
Pierre Ossman | 6e49e95 | 2016-10-07 15:59:38 +0200 | [diff] [blame] | 617 | Region toCheck; |
| 618 | |
| 619 | std::list<VNCSConnectionST*>::iterator ci, ci_next; |
| 620 | |
| 621 | assert(blockCounter == 0); |
Pierre Ossman | b53c3bf | 2018-03-22 16:01:44 +0100 | [diff] [blame] | 622 | assert(desktopStarted); |
Pierre Ossman | 6e49e95 | 2016-10-07 15:59:38 +0200 | [diff] [blame] | 623 | |
Constantin Kaplinsky | 604d781 | 2007-08-31 15:50:37 +0000 | [diff] [blame] | 624 | comparer->getUpdateInfo(&ui, pb->getRect()); |
Pierre Ossman | 6e49e95 | 2016-10-07 15:59:38 +0200 | [diff] [blame] | 625 | toCheck = ui.changed.union_(ui.copied); |
Constantin Kaplinsky | 604d781 | 2007-08-31 15:50:37 +0000 | [diff] [blame] | 626 | |
Pierre Ossman | 6e49e95 | 2016-10-07 15:59:38 +0200 | [diff] [blame] | 627 | if (needRenderedCursor()) { |
Pierre Ossman | 6a1a0d0 | 2017-02-19 15:48:17 +0100 | [diff] [blame] | 628 | Rect clippedCursorRect = Rect(0, 0, cursor->width(), cursor->height()) |
| 629 | .translate(cursorPos.subtract(cursor->hotspot())) |
| 630 | .intersect(pb->getRect()); |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 631 | |
Pierre Ossman | 24684e5 | 2016-12-05 16:58:19 +0100 | [diff] [blame] | 632 | if (!toCheck.intersect(clippedCursorRect).is_empty()) |
| 633 | renderedCursorInvalid = true; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 634 | } |
| 635 | |
| 636 | pb->grabRegion(toCheck); |
| 637 | |
Pierre Ossman | b114cec | 2011-11-20 15:36:11 +0000 | [diff] [blame] | 638 | if (getComparerState()) |
| 639 | comparer->enable(); |
| 640 | else |
| 641 | comparer->disable(); |
| 642 | |
| 643 | if (comparer->compare()) |
Constantin Kaplinsky | f0b3be7 | 2008-08-21 05:22:04 +0000 | [diff] [blame] | 644 | comparer->getUpdateInfo(&ui, pb->getRect()); |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 645 | |
Pierre Ossman | 6e49e95 | 2016-10-07 15:59:38 +0200 | [diff] [blame] | 646 | comparer->clear(); |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 647 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 648 | for (ci = clients.begin(); ci != clients.end(); ci = ci_next) { |
| 649 | ci_next = ci; ci_next++; |
Constantin Kaplinsky | 604d781 | 2007-08-31 15:50:37 +0000 | [diff] [blame] | 650 | (*ci)->add_copied(ui.copied, ui.copy_delta); |
| 651 | (*ci)->add_changed(ui.changed); |
Pierre Ossman | 6e49e95 | 2016-10-07 15:59:38 +0200 | [diff] [blame] | 652 | (*ci)->writeFramebufferUpdateOrClose(); |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 653 | } |
Pierre Ossman | 6e49e95 | 2016-10-07 15:59:38 +0200 | [diff] [blame] | 654 | } |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 655 | |
Pierre Ossman | 6e49e95 | 2016-10-07 15:59:38 +0200 | [diff] [blame] | 656 | // checkUpdate() is called by clients to see if it is safe to read from |
| 657 | // the framebuffer at this time. |
| 658 | |
Pierre Ossman | 8efc7b4 | 2018-03-23 11:45:51 +0100 | [diff] [blame^] | 659 | Region VNCServerST::getPendingRegion() |
Pierre Ossman | 6e49e95 | 2016-10-07 15:59:38 +0200 | [diff] [blame] | 660 | { |
Pierre Ossman | 8efc7b4 | 2018-03-23 11:45:51 +0100 | [diff] [blame^] | 661 | UpdateInfo ui; |
| 662 | |
Pierre Ossman | 6e49e95 | 2016-10-07 15:59:38 +0200 | [diff] [blame] | 663 | // Block clients as the frame buffer cannot be safely accessed |
| 664 | if (blockCounter > 0) |
Pierre Ossman | 8efc7b4 | 2018-03-23 11:45:51 +0100 | [diff] [blame^] | 665 | return pb->getRect(); |
Pierre Ossman | 6e49e95 | 2016-10-07 15:59:38 +0200 | [diff] [blame] | 666 | |
| 667 | // Block client from updating if there are pending updates |
Pierre Ossman | 8efc7b4 | 2018-03-23 11:45:51 +0100 | [diff] [blame^] | 668 | if (comparer->is_empty()) |
| 669 | return Region(); |
Pierre Ossman | bbf955e | 2011-11-08 12:44:10 +0000 | [diff] [blame] | 670 | |
Pierre Ossman | 8efc7b4 | 2018-03-23 11:45:51 +0100 | [diff] [blame^] | 671 | comparer->getUpdateInfo(&ui, pb->getRect()); |
| 672 | |
| 673 | return ui.changed.union_(ui.copied); |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 674 | } |
| 675 | |
Pierre Ossman | 24684e5 | 2016-12-05 16:58:19 +0100 | [diff] [blame] | 676 | const RenderedCursor* VNCServerST::getRenderedCursor() |
| 677 | { |
| 678 | if (renderedCursorInvalid) { |
Pierre Ossman | 7cb4f31 | 2017-02-24 13:25:00 +0100 | [diff] [blame] | 679 | renderedCursor.update(pb, cursor, cursorPos); |
Pierre Ossman | 24684e5 | 2016-12-05 16:58:19 +0100 | [diff] [blame] | 680 | renderedCursorInvalid = false; |
| 681 | } |
| 682 | |
| 683 | return &renderedCursor; |
| 684 | } |
| 685 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 686 | void VNCServerST::getConnInfo(ListConnInfo * listConn) |
| 687 | { |
| 688 | listConn->Clear(); |
| 689 | listConn->setDisable(getDisable()); |
| 690 | if (clients.empty()) |
| 691 | return; |
| 692 | std::list<VNCSConnectionST*>::iterator i; |
| 693 | for (i = clients.begin(); i != clients.end(); i++) |
| 694 | listConn->addInfo((void*)(*i), (*i)->getSock()->getPeerAddress(), |
| 695 | (*i)->getStartTime(), (*i)->getStatus()); |
| 696 | } |
| 697 | |
| 698 | void VNCServerST::setConnStatus(ListConnInfo* listConn) |
| 699 | { |
| 700 | setDisable(listConn->getDisable()); |
| 701 | if (listConn->Empty() || clients.empty()) return; |
| 702 | for (listConn->iBegin(); !listConn->iEnd(); listConn->iNext()) { |
| 703 | VNCSConnectionST* conn = (VNCSConnectionST*)listConn->iGetConn(); |
| 704 | std::list<VNCSConnectionST*>::iterator i; |
| 705 | for (i = clients.begin(); i != clients.end(); i++) { |
| 706 | if ((*i) == conn) { |
| 707 | int status = listConn->iGetStatus(); |
| 708 | if (status == 3) { |
| 709 | (*i)->close(0); |
| 710 | } else { |
| 711 | (*i)->setStatus(status); |
| 712 | } |
| 713 | break; |
| 714 | } |
| 715 | } |
| 716 | } |
| 717 | } |
Constantin Kaplinsky | 9d1fc6c | 2008-06-14 05:23:10 +0000 | [diff] [blame] | 718 | |
Pierre Ossman | 04e62db | 2009-03-23 16:57:07 +0000 | [diff] [blame] | 719 | void VNCServerST::notifyScreenLayoutChange(VNCSConnectionST* requester) |
| 720 | { |
| 721 | std::list<VNCSConnectionST*>::iterator ci, ci_next; |
| 722 | for (ci=clients.begin();ci!=clients.end();ci=ci_next) { |
| 723 | ci_next = ci; ci_next++; |
| 724 | if ((*ci) == requester) |
| 725 | continue; |
Pierre Ossman | a3ac01e | 2011-11-07 21:13:54 +0000 | [diff] [blame] | 726 | (*ci)->screenLayoutChangeOrClose(reasonOtherClient); |
Pierre Ossman | 04e62db | 2009-03-23 16:57:07 +0000 | [diff] [blame] | 727 | } |
| 728 | } |
Pierre Ossman | b114cec | 2011-11-20 15:36:11 +0000 | [diff] [blame] | 729 | |
| 730 | bool VNCServerST::getComparerState() |
| 731 | { |
| 732 | if (rfb::Server::compareFB == 0) |
| 733 | return false; |
| 734 | if (rfb::Server::compareFB != 2) |
| 735 | return true; |
| 736 | |
| 737 | std::list<VNCSConnectionST*>::iterator ci, ci_next; |
| 738 | for (ci=clients.begin();ci!=clients.end();ci=ci_next) { |
| 739 | ci_next = ci; ci_next++; |
| 740 | if ((*ci)->getComparerState()) |
| 741 | return true; |
| 742 | } |
| 743 | return false; |
| 744 | } |