You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CMsgHandler.cxx 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  2. * Copyright 2009-2019 Pierre Ossman for Cendio AB
  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. #ifdef HAVE_CONFIG_H
  20. #include <config.h>
  21. #endif
  22. #include <stdio.h>
  23. #include <rfb/Exception.h>
  24. #include <rfb/LogWriter.h>
  25. #include <rfb/CMsgHandler.h>
  26. #include <rfb/clipboardTypes.h>
  27. #include <rfb/screenTypes.h>
  28. #include <rfb/util.h>
  29. static rfb::LogWriter vlog("CMsgHandler");
  30. using namespace rfb;
  31. CMsgHandler::CMsgHandler()
  32. {
  33. }
  34. CMsgHandler::~CMsgHandler()
  35. {
  36. }
  37. void CMsgHandler::setDesktopSize(int width, int height)
  38. {
  39. server.setDimensions(width, height);
  40. }
  41. void CMsgHandler::setExtendedDesktopSize(unsigned reason, unsigned result,
  42. int width, int height,
  43. const ScreenSet& layout)
  44. {
  45. server.supportsSetDesktopSize = true;
  46. if ((reason == reasonClient) && (result != resultSuccess))
  47. return;
  48. server.setDimensions(width, height, layout);
  49. }
  50. void CMsgHandler::setPixelFormat(const PixelFormat& pf)
  51. {
  52. server.setPF(pf);
  53. }
  54. void CMsgHandler::setName(const char* name)
  55. {
  56. server.setName(name);
  57. }
  58. void CMsgHandler::fence(uint32_t /*flags*/, unsigned /*len*/,
  59. const uint8_t /*data*/ [])
  60. {
  61. server.supportsFence = true;
  62. }
  63. void CMsgHandler::endOfContinuousUpdates()
  64. {
  65. server.supportsContinuousUpdates = true;
  66. }
  67. void CMsgHandler::supportsQEMUKeyEvent()
  68. {
  69. server.supportsQEMUKeyEvent = true;
  70. }
  71. void CMsgHandler::serverInit(int width, int height,
  72. const PixelFormat& pf,
  73. const char* name)
  74. {
  75. server.setDimensions(width, height);
  76. server.setPF(pf);
  77. server.setName(name);
  78. }
  79. void CMsgHandler::framebufferUpdateStart()
  80. {
  81. }
  82. void CMsgHandler::framebufferUpdateEnd()
  83. {
  84. }
  85. void CMsgHandler::setLEDState(unsigned int state)
  86. {
  87. server.setLEDState(state);
  88. }
  89. void CMsgHandler::handleClipboardCaps(uint32_t flags, const uint32_t* lengths)
  90. {
  91. int i;
  92. vlog.debug("Got server clipboard capabilities:");
  93. for (i = 0;i < 16;i++) {
  94. if (flags & (1 << i)) {
  95. const char *type;
  96. switch (1 << i) {
  97. case clipboardUTF8:
  98. type = "Plain text";
  99. break;
  100. case clipboardRTF:
  101. type = "Rich text";
  102. break;
  103. case clipboardHTML:
  104. type = "HTML";
  105. break;
  106. case clipboardDIB:
  107. type = "Images";
  108. break;
  109. case clipboardFiles:
  110. type = "Files";
  111. break;
  112. default:
  113. vlog.debug(" Unknown format 0x%x", 1 << i);
  114. continue;
  115. }
  116. if (lengths[i] == 0)
  117. vlog.debug(" %s (only notify)", type);
  118. else {
  119. vlog.debug(" %s (automatically send up to %s)",
  120. type, iecPrefix(lengths[i], "B").c_str());
  121. }
  122. }
  123. }
  124. server.setClipboardCaps(flags, lengths);
  125. }
  126. void CMsgHandler::handleClipboardRequest(uint32_t /*flags*/)
  127. {
  128. }
  129. void CMsgHandler::handleClipboardPeek()
  130. {
  131. }
  132. void CMsgHandler::handleClipboardNotify(uint32_t /*flags*/)
  133. {
  134. }
  135. void CMsgHandler::handleClipboardProvide(uint32_t /*flags*/,
  136. const size_t* /*lengths*/,
  137. const uint8_t* const* /*data*/)
  138. {
  139. }