Diffstat (limited to 'noncore/comm/keypebble/krfbdecoder.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/comm/keypebble/krfbdecoder.cpp | 63 |
1 files changed, 34 insertions, 29 deletions
diff --git a/noncore/comm/keypebble/krfbdecoder.cpp b/noncore/comm/keypebble/krfbdecoder.cpp index db95154..69457e2 100644 --- a/noncore/comm/keypebble/krfbdecoder.cpp +++ b/noncore/comm/keypebble/krfbdecoder.cpp | |||
@@ -1,26 +1,31 @@ | |||
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 */ | ||
7 | #include <opie2/odebug.h> | ||
8 | using namespace Opie::Core; | ||
6 | 9 | ||
10 | /* QT */ | ||
7 | #include <qpixmap.h> | 11 | #include <qpixmap.h> |
8 | 12 | ||
13 | /* STD */ | ||
9 | #include <assert.h> | 14 | #include <assert.h> |
10 | 15 | ||
11 | // | 16 | // |
12 | // Endian stuff | 17 | // Endian stuff |
13 | // | 18 | // |
14 | #ifndef KDE_USE_FINAL | 19 | #ifndef OPIE_NO_DEBUG |
15 | const int endianTest = 1; | 20 | const int endianTest = 1; |
16 | #endif | 21 | #endif |
17 | 22 | ||
18 | #define Swap16IfLE(s) \ | 23 | #define Swap16IfLE(s) \ |
19 | (*(char *)&endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s)) | 24 | (*(char *)&endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s)) |
20 | 25 | ||
21 | #define Swap32IfLE(l) \ | 26 | #define Swap32IfLE(l) \ |
22 | (*(char *)&endianTest ? ((((l) & 0xff000000) >> 24) | \ | 27 | (*(char *)&endianTest ? ((((l) & 0xff000000) >> 24) | \ |
23 | (((l) & 0x00ff0000) >> 8) | \ | 28 | (((l) & 0x00ff0000) >> 8) | \ |
24 | (((l) & 0x0000ff00) << 8) | \ | 29 | (((l) & 0x0000ff00) << 8) | \ |
25 | (((l) & 0x000000ff) << 24)) : (l)) | 30 | (((l) & 0x000000ff) << 24)) : (l)) |
26 | 31 | ||
@@ -126,37 +131,37 @@ KRFBDecoder::~KRFBDecoder() | |||
126 | } | 131 | } |
127 | 132 | ||
128 | void KRFBDecoder::start() | 133 | void KRFBDecoder::start() |
129 | { | 134 | { |
130 | sendClientInit(); | 135 | sendClientInit(); |
131 | } | 136 | } |
132 | 137 | ||
133 | void KRFBDecoder::sendClientInit() | 138 | void KRFBDecoder::sendClientInit() |
134 | { | 139 | { |
135 | con->write( &( con->options()->shared ), 1 ); | 140 | con->write( &( con->options()->shared ), 1 ); |
136 | 141 | ||
137 | // Wait for server init | 142 | // Wait for server init |
138 | qWarning( "Waiting for server init" ); | 143 | owarn << "Waiting for server init" << oendl; |
139 | 144 | ||
140 | static QString statusMsg = tr( "Waiting for server initialization..." ); | 145 | static QString statusMsg = tr( "Waiting for server initialization..." ); |
141 | emit status( statusMsg ); | 146 | emit status( statusMsg ); |
142 | 147 | ||
143 | currentState = AwaitingServerInit; | 148 | currentState = AwaitingServerInit; |
144 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerInit() ) ); | 149 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerInit() ) ); |
145 | con->waitForData( ServerInitLength ); | 150 | con->waitForData( ServerInitLength ); |
146 | } | 151 | } |
147 | 152 | ||
148 | void KRFBDecoder::gotServerInit() | 153 | void KRFBDecoder::gotServerInit() |
149 | { | 154 | { |
150 | qWarning( "Got server init" ); | 155 | owarn << "Got server init" << oendl; |
151 | disconnect( con, SIGNAL( gotEnoughData() ), this, SLOT( gotServerInit() ) ); | 156 | disconnect( con, SIGNAL( gotEnoughData() ), this, SLOT( gotServerInit() ) ); |
152 | 157 | ||
153 | if ( info ) | 158 | if ( info ) |
154 | delete info; | 159 | delete info; |
155 | info = new KRFBServerInfo; | 160 | info = new KRFBServerInfo; |
156 | CHECK_PTR( info ); | 161 | CHECK_PTR( info ); |
157 | 162 | ||
158 | con->read( &(info->width), 2 ); | 163 | con->read( &(info->width), 2 ); |
159 | info->width = Swap16IfLE( info->width ); | 164 | info->width = Swap16IfLE( info->width ); |
160 | con->read( &info->height, 2 ); | 165 | con->read( &info->height, 2 ); |
161 | info->height = Swap16IfLE( info->height ); | 166 | info->height = Swap16IfLE( info->height ); |
162 | 167 | ||
@@ -172,63 +177,63 @@ void KRFBDecoder::gotServerInit() | |||
172 | con->read( &(info->blueMax), 2 ); | 177 | con->read( &(info->blueMax), 2 ); |
173 | info->blueMax = Swap16IfLE( info->blueMax ); | 178 | info->blueMax = Swap16IfLE( info->blueMax ); |
174 | 179 | ||
175 | con->read( &(info->redShift), 1 ); | 180 | con->read( &(info->redShift), 1 ); |
176 | con->read( &(info->greenShift), 1 ); | 181 | con->read( &(info->greenShift), 1 ); |
177 | con->read( &(info->blueShift), 1 ); | 182 | con->read( &(info->blueShift), 1 ); |
178 | 183 | ||
179 | con->read( info->padding, 3 ); | 184 | con->read( info->padding, 3 ); |
180 | 185 | ||
181 | con->read( &(info->nameLength), 4 ); | 186 | con->read( &(info->nameLength), 4 ); |
182 | info->nameLength = Swap32IfLE( info->nameLength ); | 187 | info->nameLength = Swap32IfLE( info->nameLength ); |
183 | 188 | ||
184 | qWarning( "Width = %d, Height = %d", info->width, info->height ); | 189 | owarn << "Width = " << info->width << ", Height = " << info->height << "" << oendl; |
185 | qWarning( "Bpp = %d, Depth = %d, Big = %d, True = %d", | 190 | qWarning( "Bpp = %d, Depth = %d, Big = %d, True = %d", |
186 | info->bpp, info->depth, info->bigEndian, info->trueColor ); | 191 | info->bpp, info->depth, info->bigEndian, info->trueColor ); |
187 | qWarning( "RedMax = %d, GreenMax = %d, BlueMax = %d", | 192 | qWarning( "RedMax = %d, GreenMax = %d, BlueMax = %d", |
188 | info->redMax, info->greenMax, info->blueMax ); | 193 | info->redMax, info->greenMax, info->blueMax ); |
189 | qWarning( "RedShift = %d, GreenShift = %d, BlueShift = %d", | 194 | qWarning( "RedShift = %d, GreenShift = %d, BlueShift = %d", |
190 | info->redShift, info->greenShift,info-> blueShift ); | 195 | info->redShift, info->greenShift,info-> blueShift ); |
191 | 196 | ||
192 | 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); |
193 | 198 | ||
194 | // Wait for desktop name | 199 | // Wait for desktop name |
195 | qWarning( "Waiting for desktop name" ); | 200 | owarn << "Waiting for desktop name" << oendl; |
196 | 201 | ||
197 | static QString statusMsg = tr( "Waiting for desktop name..." ); | 202 | static QString statusMsg = tr( "Waiting for desktop name..." ); |
198 | emit status( statusMsg ); | 203 | emit status( statusMsg ); |
199 | 204 | ||
200 | currentState = AwaitingDesktopName; | 205 | currentState = AwaitingDesktopName; |
201 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotDesktopName() ) ); | 206 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotDesktopName() ) ); |
202 | con->waitForData( info->nameLength ); | 207 | con->waitForData( info->nameLength ); |
203 | } | 208 | } |
204 | 209 | ||
205 | void KRFBDecoder::gotDesktopName() | 210 | void KRFBDecoder::gotDesktopName() |
206 | { | 211 | { |
207 | assert( info ); | 212 | assert( info ); |
208 | assert( currentState == AwaitingDesktopName ); | 213 | assert( currentState == AwaitingDesktopName ); |
209 | 214 | ||
210 | qWarning( "Got desktop name" ); | 215 | owarn << "Got desktop name" << oendl; |
211 | 216 | ||
212 | disconnect( con, SIGNAL( gotEnoughData() ), | 217 | disconnect( con, SIGNAL( gotEnoughData() ), |
213 | this, SLOT( gotDesktopName() ) ); | 218 | this, SLOT( gotDesktopName() ) ); |
214 | 219 | ||
215 | char *buf = new char[ info->nameLength + 1 ]; | 220 | char *buf = new char[ info->nameLength + 1 ]; |
216 | CHECK_PTR( buf ); | 221 | CHECK_PTR( buf ); |
217 | 222 | ||
218 | con->read( buf, info->nameLength ); | 223 | con->read( buf, info->nameLength ); |
219 | buf[ info->nameLength ] = '\0'; | 224 | buf[ info->nameLength ] = '\0'; |
220 | info->name = buf; | 225 | info->name = buf; |
221 | 226 | ||
222 | qWarning( "Desktop: %s", info->name.latin1() ); | 227 | owarn << "Desktop: " << info->name.latin1() << "" << oendl; |
223 | 228 | ||
224 | delete buf; | 229 | delete buf; |
225 | 230 | ||
226 | // Get the format we'll really use and tell the server | 231 | // Get the format we'll really use and tell the server |
227 | decidePixelFormat(); | 232 | decidePixelFormat(); |
228 | sendPixelFormat(); | 233 | sendPixelFormat(); |
229 | sendAllowedEncodings(); | 234 | sendAllowedEncodings(); |
230 | currentState = Idle; | 235 | currentState = Idle; |
231 | 236 | ||
232 | QString msg; | 237 | QString msg; |
233 | msg = tr( "Connected to %1" ); | 238 | msg = tr( "Connected to %1" ); |
234 | msg = msg.arg( info->name ); | 239 | msg = msg.arg( info->name ); |
@@ -362,25 +367,25 @@ void KRFBDecoder::sendUpdateRequest( bool incremental ) | |||
362 | con->write( &h, 2 ); | 367 | con->write( &h, 2 ); |
363 | 368 | ||
364 | // Now wait for the update | 369 | // Now wait for the update |
365 | currentState = AwaitingUpdate; | 370 | currentState = AwaitingUpdate; |
366 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotUpdateHeader() ) ); | 371 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotUpdateHeader() ) ); |
367 | con->waitForData( UpdateHeaderLength ); | 372 | con->waitForData( UpdateHeaderLength ); |
368 | } | 373 | } |
369 | 374 | ||
370 | void KRFBDecoder::gotUpdateHeader() | 375 | void KRFBDecoder::gotUpdateHeader() |
371 | { | 376 | { |
372 | assert( currentState == AwaitingUpdate ); | 377 | assert( currentState == AwaitingUpdate ); |
373 | 378 | ||
374 | // qWarning( "Got update header" ); | 379 | // owarn << "Got update header" << oendl; |
375 | 380 | ||
376 | disconnect( con, SIGNAL( gotEnoughData() ), | 381 | disconnect( con, SIGNAL( gotEnoughData() ), |
377 | this, SLOT( gotUpdateHeader() ) ); | 382 | this, SLOT( gotUpdateHeader() ) ); |
378 | 383 | ||
379 | CARD8 msgType; | 384 | CARD8 msgType; |
380 | con->read( &msgType, 1 ); | 385 | con->read( &msgType, 1 ); |
381 | 386 | ||
382 | if ( msgType != UpdateId ) { | 387 | if ( msgType != UpdateId ) { |
383 | // We might have a bell or server cut | 388 | // We might have a bell or server cut |
384 | if ( msgType == ServerCutId ) { | 389 | if ( msgType == ServerCutId ) { |
385 | oldState = currentState; | 390 | oldState = currentState; |
386 | gotServerCut(); | 391 | gotServerCut(); |
@@ -397,37 +402,37 @@ void KRFBDecoder::gotUpdateHeader() | |||
397 | currentState = Error; | 402 | currentState = Error; |
398 | emit error( protocolError ); | 403 | emit error( protocolError ); |
399 | } | 404 | } |
400 | return; | 405 | return; |
401 | } | 406 | } |
402 | 407 | ||
403 | CARD8 padding; | 408 | CARD8 padding; |
404 | con->read( &padding, 1 ); | 409 | con->read( &padding, 1 ); |
405 | 410 | ||
406 | con->read( &noRects, 2 ); | 411 | con->read( &noRects, 2 ); |
407 | noRects = Swap16IfLE( noRects ); | 412 | noRects = Swap16IfLE( noRects ); |
408 | 413 | ||
409 | // qWarning( "Expecting %d rects", noRects ); | 414 | // owarn << "Expecting " << noRects << " rects" << oendl; |
410 | 415 | ||
411 | // Now wait for the data | 416 | // Now wait for the data |
412 | currentState = AwaitingRectHeader; | 417 | currentState = AwaitingRectHeader; |
413 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) ); | 418 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) ); |
414 | con->waitForData( RectHeaderLength ); | 419 | con->waitForData( RectHeaderLength ); |
415 | } | 420 | } |
416 | 421 | ||
417 | void KRFBDecoder::gotRectHeader() | 422 | void KRFBDecoder::gotRectHeader() |
418 | { | 423 | { |
419 | assert( currentState == AwaitingRectHeader ); | 424 | assert( currentState == AwaitingRectHeader ); |
420 | 425 | ||
421 | // qWarning( "Got rect header" ); | 426 | // owarn << "Got rect header" << oendl; |
422 | 427 | ||
423 | disconnect( con, SIGNAL( gotEnoughData() ), | 428 | disconnect( con, SIGNAL( gotEnoughData() ), |
424 | this, SLOT( gotRectHeader() ) ); | 429 | this, SLOT( gotRectHeader() ) ); |
425 | 430 | ||
426 | con->read( &x, 2 ); | 431 | con->read( &x, 2 ); |
427 | x = Swap16IfLE( x ); | 432 | x = Swap16IfLE( x ); |
428 | con->read( &y, 2 ); | 433 | con->read( &y, 2 ); |
429 | y = Swap16IfLE( y ); | 434 | y = Swap16IfLE( y ); |
430 | 435 | ||
431 | con->read( &w, 2 ); | 436 | con->read( &w, 2 ); |
432 | w = Swap16IfLE( w ); | 437 | w = Swap16IfLE( w ); |
433 | con->read( &h, 2 ); | 438 | con->read( &h, 2 ); |
@@ -437,125 +442,125 @@ void KRFBDecoder::gotRectHeader() | |||
437 | 442 | ||
438 | // CARD32 encodingLocal = Swap32IfLE( encoding ); | 443 | // CARD32 encodingLocal = Swap32IfLE( encoding ); |
439 | // qWarning( "Rect: x=%d, y= %d, w=%d, h=%d, encoding=%ld", | 444 | // qWarning( "Rect: x=%d, y= %d, w=%d, h=%d, encoding=%ld", |
440 | // x, y, w, h, encodingLocal ); | 445 | // x, y, w, h, encodingLocal ); |
441 | 446 | ||
442 | // | 447 | // |
443 | // Each encoding needs to be handled differently. Some require | 448 | // Each encoding needs to be handled differently. Some require |
444 | // waiting for more data, but others like a copyrect do not. | 449 | // waiting for more data, but others like a copyrect do not. |
445 | // Our constants have already been byte swapped, so we use | 450 | // Our constants have already been byte swapped, so we use |
446 | // the remote value as is. | 451 | // the remote value as is. |
447 | // | 452 | // |
448 | if ( encoding == RawEncoding ) { | 453 | if ( encoding == RawEncoding ) { |
449 | // qWarning( "Raw encoding" ); | 454 | // owarn << "Raw encoding" << oendl; |
450 | handleRawRect(); | 455 | handleRawRect(); |
451 | } | 456 | } |
452 | else if ( encoding == CopyRectEncoding ) { | 457 | else if ( encoding == CopyRectEncoding ) { |
453 | // qWarning( "CopyRect encoding" ); | 458 | // owarn << "CopyRect encoding" << oendl; |
454 | handleCopyRect(); | 459 | handleCopyRect(); |
455 | } | 460 | } |
456 | else if ( encoding == RreEncoding ) { | 461 | else if ( encoding == RreEncoding ) { |
457 | qWarning( "RRE encoding" ); | 462 | owarn << "RRE encoding" << oendl; |
458 | handleRRERect(); | 463 | handleRRERect(); |
459 | } | 464 | } |
460 | else if ( encoding == CorreEncoding ) { | 465 | else if ( encoding == CorreEncoding ) { |
461 | qWarning( "CoRRE encoding" ); | 466 | owarn << "CoRRE encoding" << oendl; |
462 | handleCoRRERect(); | 467 | handleCoRRERect(); |
463 | } | 468 | } |
464 | else if ( encoding == HexTileEncoding ) { | 469 | else if ( encoding == HexTileEncoding ) { |
465 | qWarning( "HexTile encoding" ); | 470 | owarn << "HexTile encoding" << oendl; |
466 | handleHexTileRect(); | 471 | handleHexTileRect(); |
467 | } | 472 | } |
468 | else { | 473 | else { |
469 | int msg = Swap32IfLE( encoding ); | 474 | int msg = Swap32IfLE( encoding ); |
470 | QString protocolError = tr( "Protocol Error: An unknown encoding was " | 475 | QString protocolError = tr( "Protocol Error: An unknown encoding was " |
471 | "used by the server %1" ).arg( msg ); | 476 | "used by the server %1" ).arg( msg ); |
472 | currentState = Error; | 477 | currentState = Error; |
473 | qWarning( "Unknown encoding, %d", msg ); | 478 | owarn << "Unknown encoding, " << msg << "" << oendl; |
474 | emit error( protocolError ); | 479 | emit error( protocolError ); |
475 | return; | 480 | return; |
476 | } | 481 | } |
477 | } | 482 | } |
478 | 483 | ||
479 | // | 484 | // |
480 | // Raw Encoding | 485 | // Raw Encoding |
481 | // | 486 | // |
482 | 487 | ||
483 | void KRFBDecoder::handleRawRect() | 488 | void KRFBDecoder::handleRawRect() |
484 | { | 489 | { |
485 | // We need something a bit cleverer here to handle large | 490 | // We need something a bit cleverer here to handle large |
486 | // rectanges nicely. The chunking should be based on the | 491 | // rectanges nicely. The chunking should be based on the |
487 | // overall size (but has to be in complete lines). | 492 | // overall size (but has to be in complete lines). |
488 | 493 | ||
489 | // qWarning( "Handling a raw rect chunk" ); | 494 | // owarn << "Handling a raw rect chunk" << oendl; |
490 | 495 | ||
491 | // CARD32 lineCount = w * format->bpp / 8; | 496 | // CARD32 lineCount = w * format->bpp / 8; |
492 | 497 | ||
493 | if ( h > RectChunkSize ) { | 498 | if ( h > RectChunkSize ) { |
494 | // if ( con->sock->size() / lineCount ) { | 499 | // if ( con->sock->size() / lineCount ) { |
495 | // getRawRectChunk( con->sock->size() / lineCount ); | 500 | // getRawRectChunk( con->sock->size() / lineCount ); |
496 | // } | 501 | // } |
497 | // else { | 502 | // else { |
498 | getRawRectChunk( RectChunkSize ); | 503 | getRawRectChunk( RectChunkSize ); |
499 | // } | 504 | // } |
500 | } | 505 | } |
501 | else { | 506 | else { |
502 | getRawRectChunk( h ); | 507 | getRawRectChunk( h ); |
503 | } | 508 | } |
504 | } | 509 | } |
505 | 510 | ||
506 | void KRFBDecoder::getRawRectChunk( int lines ) | 511 | void KRFBDecoder::getRawRectChunk( int lines ) |
507 | { | 512 | { |
508 | this->lines = lines; | 513 | this->lines = lines; |
509 | CARD32 count = lines * w * format->bpp / 8; | 514 | CARD32 count = lines * w * format->bpp / 8; |
510 | 515 | ||
511 | // Wait for server init | 516 | // Wait for server init |
512 | // qWarning( "Waiting for raw rect chunk, %ld", count ); | 517 | // owarn << "Waiting for raw rect chunk, " << count << "" << oendl; |
513 | 518 | ||
514 | currentState = AwaitingRawRectChunk; | 519 | currentState = AwaitingRawRectChunk; |
515 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRawRectChunk() ) ); | 520 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRawRectChunk() ) ); |
516 | con->waitForData( count ); | 521 | con->waitForData( count ); |
517 | } | 522 | } |
518 | 523 | ||
519 | void KRFBDecoder::gotRawRectChunk() | 524 | void KRFBDecoder::gotRawRectChunk() |
520 | { | 525 | { |
521 | assert( currentState == AwaitingRawRectChunk ); | 526 | assert( currentState == AwaitingRawRectChunk ); |
522 | 527 | ||
523 | disconnect( con, SIGNAL( gotEnoughData() ), | 528 | disconnect( con, SIGNAL( gotEnoughData() ), |
524 | this, SLOT( gotRawRectChunk() ) ); | 529 | this, SLOT( gotRawRectChunk() ) ); |
525 | 530 | ||
526 | // qWarning( "Got raw rect chunk" ); | 531 | // owarn << "Got raw rect chunk" << oendl; |
527 | 532 | ||
528 | // | 533 | // |
529 | // Read the rect data and copy it to the buffer. | 534 | // Read the rect data and copy it to the buffer. |
530 | // | 535 | // |
531 | 536 | ||
532 | // TODO: Replace this! | 537 | // TODO: Replace this! |
533 | int count = lines * w * format->bpp / 8; | 538 | int count = lines * w * format->bpp / 8; |
534 | char *hack = new char[ count ]; | 539 | char *hack = new char[ count ]; |
535 | con->read( hack, count ); | 540 | con->read( hack, count ); |
536 | buf->drawRawRectChunk( hack, x, y, w, lines ); | 541 | buf->drawRawRectChunk( hack, x, y, w, lines ); |
537 | delete hack; | 542 | delete hack; |
538 | // /TODO: | 543 | // /TODO: |
539 | 544 | ||
540 | h = h - lines; | 545 | h = h - lines; |
541 | y = y + lines; | 546 | y = y + lines; |
542 | 547 | ||
543 | if ( h > 0 ) { | 548 | if ( h > 0 ) { |
544 | handleRawRect(); | 549 | handleRawRect(); |
545 | } | 550 | } |
546 | else { | 551 | else { |
547 | noRects--; | 552 | noRects--; |
548 | 553 | ||
549 | // qWarning( "There are %d rects left", noRects ); | 554 | // owarn << "There are " << noRects << " rects left" << oendl; |
550 | 555 | ||
551 | if ( noRects ) { | 556 | if ( noRects ) { |
552 | currentState = AwaitingRectHeader; | 557 | currentState = AwaitingRectHeader; |
553 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) ); | 558 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) ); |
554 | con->waitForData( RectHeaderLength ); | 559 | con->waitForData( RectHeaderLength ); |
555 | } | 560 | } |
556 | else { | 561 | else { |
557 | // we are now ready for the next update - no need to wait for the timer | 562 | // we are now ready for the next update - no need to wait for the timer |
558 | currentState = Idle; | 563 | currentState = Idle; |
559 | sendUpdateRequest (1); | 564 | sendUpdateRequest (1); |
560 | } | 565 | } |
561 | } | 566 | } |
@@ -581,48 +586,48 @@ void KRFBDecoder::gotCopyRectPos() | |||
581 | CARD16 srcY; | 586 | CARD16 srcY; |
582 | 587 | ||
583 | con->read( &srcX, 2 ); | 588 | con->read( &srcX, 2 ); |
584 | con->read( &srcY, 2 ); | 589 | con->read( &srcY, 2 ); |
585 | 590 | ||
586 | srcX = Swap16IfLE( srcX ); | 591 | srcX = Swap16IfLE( srcX ); |
587 | srcY = Swap16IfLE( srcY ); | 592 | srcY = Swap16IfLE( srcY ); |
588 | 593 | ||
589 | buf->copyRect( srcX, srcY, x, y, w, h ); | 594 | buf->copyRect( srcX, srcY, x, y, w, h ); |
590 | 595 | ||
591 | noRects--; | 596 | noRects--; |
592 | 597 | ||
593 | // qWarning( "There are %d rects left", noRects ); | 598 | // owarn << "There are " << noRects << " rects left" << oendl; |
594 | 599 | ||
595 | if ( noRects ) { | 600 | if ( noRects ) { |
596 | currentState = AwaitingRectHeader; | 601 | currentState = AwaitingRectHeader; |
597 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) ); | 602 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) ); |
598 | con->waitForData( RectHeaderLength ); | 603 | con->waitForData( RectHeaderLength ); |
599 | } | 604 | } |
600 | else | 605 | else |
601 | currentState = Idle; | 606 | currentState = Idle; |
602 | } | 607 | } |
603 | 608 | ||
604 | void KRFBDecoder::handleRRERect() | 609 | void KRFBDecoder::handleRRERect() |
605 | { | 610 | { |
606 | qWarning( "RRE not implemented" ); | 611 | owarn << "RRE not implemented" << oendl; |
607 | } | 612 | } |
608 | 613 | ||
609 | void KRFBDecoder::handleCoRRERect() | 614 | void KRFBDecoder::handleCoRRERect() |
610 | { | 615 | { |
611 | qWarning( "CoRRE not implemented" ); | 616 | owarn << "CoRRE not implemented" << oendl; |
612 | } | 617 | } |
613 | 618 | ||
614 | void KRFBDecoder::handleHexTileRect() | 619 | void KRFBDecoder::handleHexTileRect() |
615 | { | 620 | { |
616 | qWarning( "HexTile not implemented" ); | 621 | owarn << "HexTile not implemented" << oendl; |
617 | } | 622 | } |
618 | 623 | ||
619 | void KRFBDecoder::sendMouseEvent( QMouseEvent *e ) | 624 | void KRFBDecoder::sendMouseEvent( QMouseEvent *e ) |
620 | { | 625 | { |
621 | // Deal with the buttons | 626 | // Deal with the buttons |
622 | if ( e->type() != QEvent::MouseMove ) { | 627 | if ( e->type() != QEvent::MouseMove ) { |
623 | buttonMask = 0; | 628 | buttonMask = 0; |
624 | if ( e->type() == QEvent::MouseButtonPress ) { | 629 | if ( e->type() == QEvent::MouseButtonPress ) { |
625 | if ( e->button() & LeftButton ) | 630 | if ( e->button() & LeftButton ) |
626 | buttonMask |= 0x01; | 631 | buttonMask |= 0x01; |
627 | if ( e->button() & MidButton ) | 632 | if ( e->button() & MidButton ) |
628 | buttonMask |= 0x04; | 633 | buttonMask |= 0x04; |
@@ -664,25 +669,25 @@ void KRFBDecoder::sendCutEvent( const QString &unicode ) | |||
664 | QCString text = unicode.local8Bit(); | 669 | QCString text = unicode.local8Bit(); |
665 | CARD32 length = text.length(); | 670 | CARD32 length = text.length(); |
666 | length = Swap32IfLE( length ); | 671 | length = Swap32IfLE( length ); |
667 | 672 | ||
668 | con->write( &ClientCutTextId, 1 ); | 673 | con->write( &ClientCutTextId, 1 ); |
669 | con->write( &padding, 3 ); | 674 | con->write( &padding, 3 ); |
670 | con->write( &length, 4 ); | 675 | con->write( &length, 4 ); |
671 | con->write( text.data(), length ); | 676 | con->write( text.data(), length ); |
672 | } | 677 | } |
673 | 678 | ||
674 | void KRFBDecoder::gotServerCut() | 679 | void KRFBDecoder::gotServerCut() |
675 | { | 680 | { |
676 | qWarning( "Got server cut" ); | 681 | owarn << "Got server cut" << oendl; |
677 | 682 | ||
678 | currentState = AwaitingServerCutLength; | 683 | currentState = AwaitingServerCutLength; |
679 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerCutLength() ) ); | 684 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerCutLength() ) ); |
680 | con->waitForData( ServerCutLenLength ); | 685 | con->waitForData( ServerCutLenLength ); |
681 | } | 686 | } |
682 | 687 | ||
683 | void KRFBDecoder::gotServerCutLength() | 688 | void KRFBDecoder::gotServerCutLength() |
684 | { | 689 | { |
685 | assert( currentState = AwaitingServerCutLength ); | 690 | assert( currentState = AwaitingServerCutLength ); |
686 | disconnect( con, SIGNAL( gotEnoughData() ), | 691 | disconnect( con, SIGNAL( gotEnoughData() ), |
687 | this, SLOT( gotServerCutLength() ) ); | 692 | this, SLOT( gotServerCutLength() ) ); |
688 | 693 | ||
@@ -712,62 +717,62 @@ void KRFBDecoder::gotServerCutText() | |||
712 | // same. I've reported this problem to the ORL guys, but they apparantly have no | 717 | // same. I've reported this problem to the ORL guys, but they apparantly have no |
713 | // immediate plans to fix the issue. :-( (rich) | 718 | // immediate plans to fix the issue. :-( (rich) |
714 | // | 719 | // |
715 | 720 | ||
716 | char *cutbuf = new char[ serverCutTextLen + 1 ]; | 721 | char *cutbuf = new char[ serverCutTextLen + 1 ]; |
717 | CHECK_PTR( cutbuf ); | 722 | CHECK_PTR( cutbuf ); |
718 | 723 | ||
719 | con->read( cutbuf, serverCutTextLen ); | 724 | con->read( cutbuf, serverCutTextLen ); |
720 | cutbuf[ serverCutTextLen ] = '\0'; | 725 | cutbuf[ serverCutTextLen ] = '\0'; |
721 | 726 | ||
722 | /* For some reason QApplication::clipboard()->setText() segfaults when called | 727 | /* For some reason QApplication::clipboard()->setText() segfaults when called |
723 | * from within keypebble's mass of signals and slots | 728 | * from within keypebble's mass of signals and slots |
724 | qWarning( "Server cut: %s", cutbuf ); | 729 | owarn << "Server cut: " << cutbuf << "" << oendl; |
725 | 730 | ||
726 | QString cutText( cutbuf ); // DANGER!! | 731 | QString cutText( cutbuf ); // DANGER!! |
727 | qApp->clipboard()->setText( cutText ); | 732 | qApp->clipboard()->setText( cutText ); |
728 | */ | 733 | */ |
729 | 734 | ||
730 | delete cutbuf; | 735 | delete cutbuf; |
731 | // Now wait for the update (again) | 736 | // Now wait for the update (again) |
732 | if ( oldState == AwaitingUpdate ) { | 737 | if ( oldState == AwaitingUpdate ) { |
733 | currentState = AwaitingUpdate; | 738 | currentState = AwaitingUpdate; |
734 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotUpdateHeader() ) ); | 739 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotUpdateHeader() ) ); |
735 | con->waitForData( UpdateHeaderLength ); | 740 | con->waitForData( UpdateHeaderLength ); |
736 | } | 741 | } |
737 | else if ( oldState == Idle ) { | 742 | else if ( oldState == Idle ) { |
738 | currentState = Idle; | 743 | currentState = Idle; |
739 | } | 744 | } |
740 | else { | 745 | else { |
741 | qWarning( "Async handled in weird state" ); | 746 | owarn << "Async handled in weird state" << oendl; |
742 | currentState = oldState; | 747 | currentState = oldState; |
743 | }; | 748 | }; |
744 | } | 749 | } |
745 | 750 | ||
746 | void KRFBDecoder::gotBell() | 751 | void KRFBDecoder::gotBell() |
747 | { | 752 | { |
748 | qWarning( "Got server bell" ); | 753 | owarn << "Got server bell" << oendl; |
749 | buf->soundBell(); | 754 | buf->soundBell(); |
750 | 755 | ||
751 | // Now wait for the update (again) | 756 | // Now wait for the update (again) |
752 | if ( oldState == AwaitingUpdate ) { | 757 | if ( oldState == AwaitingUpdate ) { |
753 | currentState = AwaitingUpdate; | 758 | currentState = AwaitingUpdate; |
754 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotUpdateHeader() ) ); | 759 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotUpdateHeader() ) ); |
755 | con->waitForData( UpdateHeaderLength ); | 760 | con->waitForData( UpdateHeaderLength ); |
756 | } | 761 | } |
757 | else if ( oldState == Idle ) { | 762 | else if ( oldState == Idle ) { |
758 | currentState = Idle; | 763 | currentState = Idle; |
759 | } | 764 | } |
760 | else { | 765 | else { |
761 | qWarning( "Async handled in weird state" ); | 766 | owarn << "Async handled in weird state" << oendl; |
762 | currentState = oldState; | 767 | currentState = oldState; |
763 | }; | 768 | }; |
764 | } | 769 | } |
765 | 770 | ||
766 | void KRFBDecoder::sendKeyPressEvent( QKeyEvent *event ) | 771 | void KRFBDecoder::sendKeyPressEvent( QKeyEvent *event ) |
767 | { | 772 | { |
768 | int key; | 773 | int key; |
769 | key = toKeySym( event ); | 774 | key = toKeySym( event ); |
770 | if ( key ) { | 775 | if ( key ) { |
771 | key = Swap32IfLE( key ); | 776 | key = Swap32IfLE( key ); |
772 | 777 | ||
773 | CARD8 mask = true; | 778 | CARD8 mask = true; |