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

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