summaryrefslogtreecommitdiff
path: root/noncore/comm/keypebble/krfbdecoder.h
Unidiff
Diffstat (limited to 'noncore/comm/keypebble/krfbdecoder.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/comm/keypebble/krfbdecoder.h134
1 files changed, 134 insertions, 0 deletions
diff --git a/noncore/comm/keypebble/krfbdecoder.h b/noncore/comm/keypebble/krfbdecoder.h
new file mode 100644
index 0000000..4ba0185
--- a/dev/null
+++ b/noncore/comm/keypebble/krfbdecoder.h
@@ -0,0 +1,134 @@
1// -*- c++ -*-
2
3#ifndef KRFBDECODER_H
4#define KRFBDECODER_H
5
6#include <qobject.h>
7
8class KRFBConnection;
9class KRFBServerInfo;
10class KRFBPixelFormat;
11class KRFBBuffer;
12
13
14typedef unsigned char CARD8;
15typedef unsigned short CARD16;
16typedef unsigned long CARD32;
17
18/**
19 * Negotiates the pixel format to be used then decodes the resulting
20 * data stream.
21 *
22 * @author Richard Moore, rich@kde.org
23 */
24class KRFBDecoder : public QObject
25{
26 Q_OBJECT
27
28public:
29 friend class KRFBBuffer;
30
31 enum State {
32 AwaitingServerInit,
33 AwaitingDesktopName,
34 AwaitingUpdate,
35 AwaitingRectHeader,
36 AwaitingRawRectChunk,
37 AwaitingCopyRectPos,
38 AwaitingServerCutLength,
39 AwaitingServerCutText,
40 Idle,
41 Error
42 };
43
44 /**
45 * Create a KRFBDecoder that reads data from a logged in KRFBConnection
46 * and sends its output to a KRFBBuffer.
47 */
48 KRFBDecoder( KRFBConnection *con );
49 ~KRFBDecoder();
50
51 void setBuffer( KRFBBuffer *buf ) { this->buf = buf; };
52 void start();
53
54 int toKeySym( QKeyEvent *k );
55
56 //
57 // Client -> Server messages
58 //
59 void sendUpdateRequest( bool incremental );
60 void sendMouseEvent( QMouseEvent *e );
61 void sendKeyPressEvent( QKeyEvent *e );
62 void sendKeyReleaseEvent( QKeyEvent *e );
63 void sendCutEvent( const QString &text );
64
65protected:
66 //
67 // Initial format negotiation
68 //
69 void decidePixelFormat();
70 void sendPixelFormat();
71 void sendClientInit();
72 void sendAllowedEncodings();
73
74 //
75 // Rectange processing
76 //
77 void handleRawRect();
78 void handleCopyRect();
79 void handleRRERect();
80 void handleCoRRERect();
81 void handleHexTileRect();
82
83 void getRawRectChunk( int lines );
84
85protected slots:
86 void gotServerInit();
87 void gotDesktopName();
88 void gotUpdateHeader();
89 void gotRectHeader();
90 void gotRawRectChunk();
91 void gotCopyRectPos();
92 void gotServerCut();
93 void gotServerCutLength();
94 void gotServerCutText();
95 void gotBell();
96
97signals:
98 void error( const QString & );
99 void status( const QString & );
100
101private:
102 State currentState;
103
104 // Used to store the state we were in before a cut or bell msg
105 State oldState;
106
107 // The number of rects we're expecting
108 CARD16 noRects;
109
110 //
111 // Info about the current rect.
112 //
113 CARD16 x, y, w, h;
114 int lines;
115 CARD32 encoding;
116
117 CARD32 serverCutTextLen;
118
119 /** Where we draw the data (and the source of our events). */
120 KRFBBuffer *buf;
121 /** The connection to the server. */
122 KRFBConnection *con;
123
124 /** Info about the RFB server. */
125 KRFBServerInfo *info;
126 /** The pixel format we want. */
127 KRFBPixelFormat *format;
128
129 CARD8 buttonMask;
130};
131
132#endif // KRFBDECODER_H
133
134