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

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