rfb.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. """Remote Framebuffer Protocol."""
  2. from pypacker import pypacker
  3. # Remote Framebuffer Protocol
  4. # http://www.realvnc.com/docs/rfbproto.pdf
  5. # TODO: RFP uses dynamic ports 5900+..auto-decoding for this?
  6. # Client to Server Messages
  7. CLIENT_SET_PIXEL_FORMAT = 0
  8. CLIENT_SET_ENCODINGS = 2
  9. CLIENT_FRAMEBUFFER_UPDATE_REQUEST = 3
  10. CLIENT_KEY_EVENT = 4
  11. CLIENT_POINTER_EVENT = 5
  12. CLIENT_CUT_TEXT = 6
  13. # Server to Client Messages
  14. SERVER_FRAMEBUFFER_UPDATE = 0
  15. SERVER_SET_COLOUR_MAP_ENTRIES = 1
  16. SERVER_BELL = 2
  17. SERVER_CUT_TEXT = 3
  18. class RFB(pypacker.Packet):
  19. __hdr__ = (
  20. ("type", "B", 0),
  21. )
  22. class SetPixelFormat(pypacker.Packet):
  23. __hdr__ = (
  24. ("pad", "3s", ""),
  25. ("pixel_fmt", "16s", "")
  26. )
  27. class SetEncodings(pypacker.Packet):
  28. __hdr__ = (
  29. ("pad", "1s", ""),
  30. ("num_encodings", "H", 0)
  31. )
  32. class FramebufferUpdateRequest(pypacker.Packet):
  33. __hdr__ = (
  34. ("incremental", "B", 0),
  35. ("x_position", "H", 0),
  36. ("y_position", "H", 0),
  37. ("width", "H", 0),
  38. ("height", "H", 0)
  39. )
  40. class KeyEvent(pypacker.Packet):
  41. __hdr__ = (
  42. ("down_flag", "B", 0),
  43. ("pad", "2s", ""),
  44. ("key", "I", 0)
  45. )
  46. class PointerEvent(pypacker.Packet):
  47. __hdr__ = (
  48. ("button_mask", "B", 0),
  49. ("x_position", "H", 0),
  50. ("y_position", "H", 0)
  51. )
  52. class FramebufferUpdate(pypacker.Packet):
  53. __hdr__ = (
  54. ("pad", "1s", ""),
  55. ("num_rects", "H", 0)
  56. )
  57. class SetColourMapEntries(pypacker.Packet):
  58. __hdr__ = (
  59. ("pad", "1s", ""),
  60. ("first_colour", "H", 0),
  61. ("num_colours", "H", 0)
  62. )
  63. class CutText(pypacker.Packet):
  64. __hdr__ = (
  65. ("pad", "3s", ""),
  66. ("length", "I", 0)
  67. )