00001
00002
00003 #ifndef KRFBDECODER_H
00004 #define KRFBDECODER_H
00005
00006 #include <qobject.h>
00007
00008 class KRFBConnection;
00009 class KRFBServerInfo;
00010 class KRFBPixelFormat;
00011 class KRFBBuffer;
00012
00013
00014 typedef unsigned char CARD8;
00015 typedef unsigned short CARD16;
00016 typedef unsigned long CARD32;
00017
00024 class KRFBDecoder : public QObject
00025 {
00026 Q_OBJECT
00027
00028 public:
00029 friend class KRFBBuffer;
00030
00031 enum State {
00032 AwaitingServerInit,
00033 AwaitingDesktopName,
00034 AwaitingUpdate,
00035 AwaitingRectHeader,
00036 AwaitingRawRectChunk,
00037 AwaitingCopyRectPos,
00038 AwaitingServerCutLength,
00039 AwaitingServerCutText,
00040 Idle,
00041 Error
00042 };
00043
00048 KRFBDecoder( KRFBConnection *con );
00049 ~KRFBDecoder();
00050
00051 void setBuffer( KRFBBuffer *buf ) { this->buf = buf; };
00052 void start();
00053
00054 int toKeySym( QKeyEvent *k );
00055
00056
00057
00058
00059 void sendUpdateRequest( bool incremental );
00060 void sendMouseEvent( QMouseEvent *e );
00061 void sendKeyPressEvent( QKeyEvent *e );
00062 void sendKeyReleaseEvent( QKeyEvent *e );
00063 void sendCutEvent( const QString &text );
00064
00065 protected:
00066
00067
00068
00069 void decidePixelFormat();
00070 void sendPixelFormat();
00071 void sendClientInit();
00072 void sendAllowedEncodings();
00073
00074
00075
00076
00077 void handleRawRect();
00078 void handleCopyRect();
00079 void handleRRERect();
00080 void handleCoRRERect();
00081 void handleHexTileRect();
00082
00083 void getRawRectChunk( int lines );
00084
00085 protected slots:
00086 void gotServerInit();
00087 void gotDesktopName();
00088 void gotUpdateHeader();
00089 void gotRectHeader();
00090 void gotRawRectChunk();
00091 void gotCopyRectPos();
00092 void gotServerCut();
00093 void gotServerCutLength();
00094 void gotServerCutText();
00095 void gotBell();
00096
00097 signals:
00098 void error( const QString & );
00099 void status( const QString & );
00100
00101 protected:
00103 KRFBConnection *con;
00104 private:
00105 State currentState;
00106
00107
00108 State oldState;
00109
00110
00111 CARD16 noRects;
00112
00113
00114
00115
00116 CARD16 x, y, w, h;
00117 int lines;
00118 CARD32 encoding;
00119
00120 CARD32 serverCutTextLen;
00121
00123 KRFBBuffer *buf;
00124
00126 KRFBServerInfo *info;
00128 KRFBPixelFormat *format;
00129
00130 CARD8 buttonMask;
00131 };
00132
00133 #endif // KRFBDECODER_H
00134
00135