author | wimpie <wimpie> | 2004-04-07 01:11:12 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2004-04-07 01:11:12 (UTC) |
commit | 843ac5d18f43e7f79ea6144c93bde0bd0e3e2f40 (patch) (unidiff) | |
tree | 5ea4a70406b4f8428493d050eeaf16580db5293d | |
parent | 453109d9dafc25fdaf82197ef8a3f4e34c9272af (diff) | |
download | opie-843ac5d18f43e7f79ea6144c93bde0bd0e3e2f40.zip opie-843ac5d18f43e7f79ea6144c93bde0bd0e3e2f40.tar.gz opie-843ac5d18f43e7f79ea6144c93bde0bd0e3e2f40.tar.bz2 |
COnversion too quick to odebug
-rw-r--r-- | noncore/comm/keypebble/krfbdecoder.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/comm/keypebble/krfbdecoder.cpp b/noncore/comm/keypebble/krfbdecoder.cpp index 69457e2..d61433f 100644 --- a/noncore/comm/keypebble/krfbdecoder.cpp +++ b/noncore/comm/keypebble/krfbdecoder.cpp | |||
@@ -1,213 +1,213 @@ | |||
1 | #include "krfbconnection.h" | 1 | #include "krfbconnection.h" |
2 | #include "krfbserverinfo.h" | 2 | #include "krfbserverinfo.h" |
3 | #include "krfbdecoder.h" | 3 | #include "krfbdecoder.h" |
4 | #include "krfbbuffer.h" | 4 | #include "krfbbuffer.h" |
5 | 5 | ||
6 | /* OPIE */ | 6 | /* OPIE */ |
7 | #include <opie2/odebug.h> | 7 | #include <opie2/odebug.h> |
8 | using namespace Opie::Core; | 8 | using namespace Opie::Core; |
9 | 9 | ||
10 | /* QT */ | 10 | /* QT */ |
11 | #include <qpixmap.h> | 11 | #include <qpixmap.h> |
12 | 12 | ||
13 | /* STD */ | 13 | /* STD */ |
14 | #include <assert.h> | 14 | #include <assert.h> |
15 | 15 | ||
16 | // | 16 | // |
17 | // Endian stuff | 17 | // Endian stuff |
18 | // | 18 | // |
19 | #ifndef OPIE_NO_DEBUG | 19 | //#ifndef OPIE_NO_DEBUG |
20 | const int endianTest = 1; | 20 | const int endianTest = 1; |
21 | #endif | 21 | //#endif |
22 | 22 | ||
23 | #define Swap16IfLE(s) \ | 23 | #define Swap16IfLE(s) \ |
24 | (*(char *)&endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s)) | 24 | (*(char *)&endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s)) |
25 | 25 | ||
26 | #define Swap32IfLE(l) \ | 26 | #define Swap32IfLE(l) \ |
27 | (*(char *)&endianTest ? ((((l) & 0xff000000) >> 24) | \ | 27 | (*(char *)&endianTest ? ((((l) & 0xff000000) >> 24) | \ |
28 | (((l) & 0x00ff0000) >> 8) | \ | 28 | (((l) & 0x00ff0000) >> 8) | \ |
29 | (((l) & 0x0000ff00) << 8) | \ | 29 | (((l) & 0x0000ff00) << 8) | \ |
30 | (((l) & 0x000000ff) << 24)) : (l)) | 30 | (((l) & 0x000000ff) << 24)) : (l)) |
31 | 31 | ||
32 | // | 32 | // |
33 | // The lengths of the messages we need to wait for | 33 | // The lengths of the messages we need to wait for |
34 | // | 34 | // |
35 | const int ServerInitLength = 24; | 35 | const int ServerInitLength = 24; |
36 | const int UpdateHeaderLength = 4; | 36 | const int UpdateHeaderLength = 4; |
37 | const int RectHeaderLength = 12; | 37 | const int RectHeaderLength = 12; |
38 | const int RectChunkSize = 4; | 38 | const int RectChunkSize = 4; |
39 | const int CopyRectPosLength = 4; | 39 | const int CopyRectPosLength = 4; |
40 | const int ServerCutLenLength = 7; | 40 | const int ServerCutLenLength = 7; |
41 | 41 | ||
42 | // | 42 | // |
43 | // Client -> Server Message Identifiers | 43 | // Client -> Server Message Identifiers |
44 | // | 44 | // |
45 | static CARD8 SetPixelFormatId = 0; | 45 | static CARD8 SetPixelFormatId = 0; |
46 | //static CARD8 FixColourMapEntriesId = 1; // Not used | 46 | //static CARD8 FixColourMapEntriesId = 1; // Not used |
47 | static CARD8 SetEncodingsId = 2; | 47 | static CARD8 SetEncodingsId = 2; |
48 | static CARD8 UpdateRequestId = 3; | 48 | static CARD8 UpdateRequestId = 3; |
49 | static CARD8 KeyEventId = 4; | 49 | static CARD8 KeyEventId = 4; |
50 | static CARD8 PointerEventId = 5; | 50 | static CARD8 PointerEventId = 5; |
51 | static CARD8 ClientCutTextId = 6; | 51 | static CARD8 ClientCutTextId = 6; |
52 | 52 | ||
53 | // | 53 | // |
54 | // Server -> Client Message Identifiers | 54 | // Server -> Client Message Identifiers |
55 | // | 55 | // |
56 | static CARD8 UpdateId = 0; | 56 | static CARD8 UpdateId = 0; |
57 | static CARD8 BellId = 2; | 57 | static CARD8 BellId = 2; |
58 | static CARD8 ServerCutId = 3; | 58 | static CARD8 ServerCutId = 3; |
59 | 59 | ||
60 | // | 60 | // |
61 | // Encoding identifiers | 61 | // Encoding identifiers |
62 | // | 62 | // |
63 | static CARD32 RawEncoding = Swap32IfLE( 0 ); | 63 | static CARD32 RawEncoding = Swap32IfLE( 0 ); |
64 | static CARD32 CopyRectEncoding = Swap32IfLE(1 ); | 64 | static CARD32 CopyRectEncoding = Swap32IfLE(1 ); |
65 | static CARD32 RreEncoding = Swap32IfLE( 2 ); | 65 | static CARD32 RreEncoding = Swap32IfLE( 2 ); |
66 | static CARD32 CorreEncoding = Swap32IfLE( 4 ); | 66 | static CARD32 CorreEncoding = Swap32IfLE( 4 ); |
67 | static CARD32 HexTileEncoding = Swap32IfLE( 5 ); | 67 | static CARD32 HexTileEncoding = Swap32IfLE( 5 ); |
68 | 68 | ||
69 | static struct { | 69 | static struct { |
70 | int keysym; | 70 | int keysym; |
71 | int keycode; | 71 | int keycode; |
72 | } keyMap[] = { | 72 | } keyMap[] = { |
73 | { 0xff08, Qt::Key_Backspace }, | 73 | { 0xff08, Qt::Key_Backspace }, |
74 | { 0xff09, Qt::Key_Tab }, | 74 | { 0xff09, Qt::Key_Tab }, |
75 | { 0xff0d, Qt::Key_Return }, | 75 | { 0xff0d, Qt::Key_Return }, |
76 | { 0xff1b, Qt::Key_Escape }, | 76 | { 0xff1b, Qt::Key_Escape }, |
77 | { 0xff63, Qt::Key_Insert }, | 77 | { 0xff63, Qt::Key_Insert }, |
78 | { 0xffff, Qt::Key_Delete }, | 78 | { 0xffff, Qt::Key_Delete }, |
79 | { 0xff50, Qt::Key_Home }, | 79 | { 0xff50, Qt::Key_Home }, |
80 | { 0xff57, Qt::Key_End }, | 80 | { 0xff57, Qt::Key_End }, |
81 | { 0xff55, Qt::Key_Prior }, | 81 | { 0xff55, Qt::Key_Prior }, |
82 | { 0xff56, Qt::Key_Next }, | 82 | { 0xff56, Qt::Key_Next }, |
83 | { 0xff51, Qt::Key_Left }, | 83 | { 0xff51, Qt::Key_Left }, |
84 | { 0xff52, Qt::Key_Up }, | 84 | { 0xff52, Qt::Key_Up }, |
85 | { 0xff53, Qt::Key_Right }, | 85 | { 0xff53, Qt::Key_Right }, |
86 | { 0xff54, Qt::Key_Down }, | 86 | { 0xff54, Qt::Key_Down }, |
87 | { 0xffbe, Qt::Key_F1 }, | 87 | { 0xffbe, Qt::Key_F1 }, |
88 | { 0xffbf, Qt::Key_F2 }, | 88 | { 0xffbf, Qt::Key_F2 }, |
89 | { 0xffc0, Qt::Key_F3 }, | 89 | { 0xffc0, Qt::Key_F3 }, |
90 | { 0xffc1, Qt::Key_F4 }, | 90 | { 0xffc1, Qt::Key_F4 }, |
91 | { 0xffc2, Qt::Key_F5 }, | 91 | { 0xffc2, Qt::Key_F5 }, |
92 | { 0xffc3, Qt::Key_F6 }, | 92 | { 0xffc3, Qt::Key_F6 }, |
93 | { 0xffc4, Qt::Key_F7 }, | 93 | { 0xffc4, Qt::Key_F7 }, |
94 | { 0xffc5, Qt::Key_F8 }, | 94 | { 0xffc5, Qt::Key_F8 }, |
95 | { 0xffc6, Qt::Key_F9 }, | 95 | { 0xffc6, Qt::Key_F9 }, |
96 | { 0xffc7, Qt::Key_F10 }, | 96 | { 0xffc7, Qt::Key_F10 }, |
97 | { 0xffc8, Qt::Key_F11 }, | 97 | { 0xffc8, Qt::Key_F11 }, |
98 | { 0xffc9, Qt::Key_F12 }, | 98 | { 0xffc9, Qt::Key_F12 }, |
99 | { 0xffe1, Qt::Key_Shift }, | 99 | { 0xffe1, Qt::Key_Shift }, |
100 | { 0xffe2, Qt::Key_Shift }, | 100 | { 0xffe2, Qt::Key_Shift }, |
101 | { 0xffe3, Qt::Key_Control }, | 101 | { 0xffe3, Qt::Key_Control }, |
102 | { 0xffe4, Qt::Key_Control }, | 102 | { 0xffe4, Qt::Key_Control }, |
103 | { 0xffe7, Qt::Key_Meta }, | 103 | { 0xffe7, Qt::Key_Meta }, |
104 | { 0xffe8, Qt::Key_Meta }, | 104 | { 0xffe8, Qt::Key_Meta }, |
105 | { 0xffe9, Qt::Key_Alt }, | 105 | { 0xffe9, Qt::Key_Alt }, |
106 | { 0xffea, Qt::Key_Alt }, | 106 | { 0xffea, Qt::Key_Alt }, |
107 | { 0, 0 } | 107 | { 0, 0 } |
108 | }; | 108 | }; |
109 | 109 | ||
110 | 110 | ||
111 | KRFBDecoder::KRFBDecoder( KRFBConnection *con ) | 111 | KRFBDecoder::KRFBDecoder( KRFBConnection *con ) |
112 | : QObject( con, "RFB Decoder" ) | 112 | : QObject( con, "RFB Decoder" ) |
113 | { | 113 | { |
114 | assert( con ); | 114 | assert( con ); |
115 | assert( con->state() == KRFBConnection::Connected ); | 115 | assert( con->state() == KRFBConnection::Connected ); |
116 | 116 | ||
117 | this->con = con; | 117 | this->con = con; |
118 | this->buf = 0; | 118 | this->buf = 0; |
119 | this->info = 0; | 119 | this->info = 0; |
120 | this->format = 0; | 120 | this->format = 0; |
121 | this->buttonMask = 0; | 121 | this->buttonMask = 0; |
122 | currentState = Idle; | 122 | currentState = Idle; |
123 | } | 123 | } |
124 | 124 | ||
125 | KRFBDecoder::~KRFBDecoder() | 125 | KRFBDecoder::~KRFBDecoder() |
126 | { | 126 | { |
127 | if ( info ) | 127 | if ( info ) |
128 | delete info; | 128 | delete info; |
129 | if ( format ) | 129 | if ( format ) |
130 | delete format; | 130 | delete format; |
131 | } | 131 | } |
132 | 132 | ||
133 | void KRFBDecoder::start() | 133 | void KRFBDecoder::start() |
134 | { | 134 | { |
135 | sendClientInit(); | 135 | sendClientInit(); |
136 | } | 136 | } |
137 | 137 | ||
138 | void KRFBDecoder::sendClientInit() | 138 | void KRFBDecoder::sendClientInit() |
139 | { | 139 | { |
140 | con->write( &( con->options()->shared ), 1 ); | 140 | con->write( &( con->options()->shared ), 1 ); |
141 | 141 | ||
142 | // Wait for server init | 142 | // Wait for server init |
143 | owarn << "Waiting for server init" << oendl; | 143 | owarn << "Waiting for server init" << oendl; |
144 | 144 | ||
145 | static QString statusMsg = tr( "Waiting for server initialization..." ); | 145 | static QString statusMsg = tr( "Waiting for server initialization..." ); |
146 | emit status( statusMsg ); | 146 | emit status( statusMsg ); |
147 | 147 | ||
148 | currentState = AwaitingServerInit; | 148 | currentState = AwaitingServerInit; |
149 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerInit() ) ); | 149 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerInit() ) ); |
150 | con->waitForData( ServerInitLength ); | 150 | con->waitForData( ServerInitLength ); |
151 | } | 151 | } |
152 | 152 | ||
153 | void KRFBDecoder::gotServerInit() | 153 | void KRFBDecoder::gotServerInit() |
154 | { | 154 | { |
155 | owarn << "Got server init" << oendl; | 155 | owarn << "Got server init" << oendl; |
156 | disconnect( con, SIGNAL( gotEnoughData() ), this, SLOT( gotServerInit() ) ); | 156 | disconnect( con, SIGNAL( gotEnoughData() ), this, SLOT( gotServerInit() ) ); |
157 | 157 | ||
158 | if ( info ) | 158 | if ( info ) |
159 | delete info; | 159 | delete info; |
160 | info = new KRFBServerInfo; | 160 | info = new KRFBServerInfo; |
161 | CHECK_PTR( info ); | 161 | CHECK_PTR( info ); |
162 | 162 | ||
163 | con->read( &(info->width), 2 ); | 163 | con->read( &(info->width), 2 ); |
164 | info->width = Swap16IfLE( info->width ); | 164 | info->width = Swap16IfLE( info->width ); |
165 | con->read( &info->height, 2 ); | 165 | con->read( &info->height, 2 ); |
166 | info->height = Swap16IfLE( info->height ); | 166 | info->height = Swap16IfLE( info->height ); |
167 | 167 | ||
168 | con->read( &(info->bpp), 1 ); | 168 | con->read( &(info->bpp), 1 ); |
169 | con->read( &(info->depth), 1 ); | 169 | con->read( &(info->depth), 1 ); |
170 | con->read( &(info->bigEndian), 1 ); | 170 | con->read( &(info->bigEndian), 1 ); |
171 | con->read( &(info->trueColor), 1 ); | 171 | con->read( &(info->trueColor), 1 ); |
172 | 172 | ||
173 | con->read( &(info->redMax), 2 ); | 173 | con->read( &(info->redMax), 2 ); |
174 | info->redMax = Swap16IfLE( info->redMax ); | 174 | info->redMax = Swap16IfLE( info->redMax ); |
175 | con->read( &(info->greenMax), 2 ); | 175 | con->read( &(info->greenMax), 2 ); |
176 | info->greenMax = Swap16IfLE( info->greenMax ); | 176 | info->greenMax = Swap16IfLE( info->greenMax ); |
177 | con->read( &(info->blueMax), 2 ); | 177 | con->read( &(info->blueMax), 2 ); |
178 | info->blueMax = Swap16IfLE( info->blueMax ); | 178 | info->blueMax = Swap16IfLE( info->blueMax ); |
179 | 179 | ||
180 | con->read( &(info->redShift), 1 ); | 180 | con->read( &(info->redShift), 1 ); |
181 | con->read( &(info->greenShift), 1 ); | 181 | con->read( &(info->greenShift), 1 ); |
182 | con->read( &(info->blueShift), 1 ); | 182 | con->read( &(info->blueShift), 1 ); |
183 | 183 | ||
184 | con->read( info->padding, 3 ); | 184 | con->read( info->padding, 3 ); |
185 | 185 | ||
186 | con->read( &(info->nameLength), 4 ); | 186 | con->read( &(info->nameLength), 4 ); |
187 | info->nameLength = Swap32IfLE( info->nameLength ); | 187 | info->nameLength = Swap32IfLE( info->nameLength ); |
188 | 188 | ||
189 | owarn << "Width = " << info->width << ", Height = " << info->height << "" << oendl; | 189 | owarn << "Width = " << info->width << ", Height = " << info->height << "" << oendl; |
190 | qWarning( "Bpp = %d, Depth = %d, Big = %d, True = %d", | 190 | qWarning( "Bpp = %d, Depth = %d, Big = %d, True = %d", |
191 | info->bpp, info->depth, info->bigEndian, info->trueColor ); | 191 | info->bpp, info->depth, info->bigEndian, info->trueColor ); |
192 | qWarning( "RedMax = %d, GreenMax = %d, BlueMax = %d", | 192 | qWarning( "RedMax = %d, GreenMax = %d, BlueMax = %d", |
193 | info->redMax, info->greenMax, info->blueMax ); | 193 | info->redMax, info->greenMax, info->blueMax ); |
194 | qWarning( "RedShift = %d, GreenShift = %d, BlueShift = %d", | 194 | qWarning( "RedShift = %d, GreenShift = %d, BlueShift = %d", |
195 | info->redShift, info->greenShift,info-> blueShift ); | 195 | info->redShift, info->greenShift,info-> blueShift ); |
196 | 196 | ||
197 | buf->resize( info->width/con->options()->scaleFactor, info->height /con->options()->scaleFactor); | 197 | buf->resize( info->width/con->options()->scaleFactor, info->height /con->options()->scaleFactor); |
198 | 198 | ||
199 | // Wait for desktop name | 199 | // Wait for desktop name |
200 | owarn << "Waiting for desktop name" << oendl; | 200 | owarn << "Waiting for desktop name" << oendl; |
201 | 201 | ||
202 | static QString statusMsg = tr( "Waiting for desktop name..." ); | 202 | static QString statusMsg = tr( "Waiting for desktop name..." ); |
203 | emit status( statusMsg ); | 203 | emit status( statusMsg ); |
204 | 204 | ||
205 | currentState = AwaitingDesktopName; | 205 | currentState = AwaitingDesktopName; |
206 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotDesktopName() ) ); | 206 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotDesktopName() ) ); |
207 | con->waitForData( info->nameLength ); | 207 | con->waitForData( info->nameLength ); |
208 | } | 208 | } |
209 | 209 | ||
210 | void KRFBDecoder::gotDesktopName() | 210 | void KRFBDecoder::gotDesktopName() |
211 | { | 211 | { |
212 | assert( info ); | 212 | assert( info ); |
213 | assert( currentState == AwaitingDesktopName ); | 213 | assert( currentState == AwaitingDesktopName ); |