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 | |||
@@ -2,17 +2,22 @@ | |||
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) \ |
@@ -134,9 +139,9 @@ 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 | ||
@@ -146,9 +151,9 @@ void KRFBDecoder::sendClientInit() | |||
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; |
@@ -180,9 +185,9 @@ void KRFBDecoder::gotServerInit() | |||
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 ); |
@@ -191,9 +196,9 @@ void KRFBDecoder::gotServerInit() | |||
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 | ||
@@ -206,9 +211,9 @@ 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 | ||
@@ -218,9 +223,9 @@ void KRFBDecoder::gotDesktopName() | |||
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 |
@@ -370,9 +375,9 @@ void KRFBDecoder::sendUpdateRequest( bool incremental ) | |||
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 | ||
@@ -405,9 +410,9 @@ void KRFBDecoder::gotUpdateHeader() | |||
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() ) ); |
@@ -417,9 +422,9 @@ void KRFBDecoder::gotUpdateHeader() | |||
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 | ||
@@ -445,33 +450,33 @@ void KRFBDecoder::gotRectHeader() | |||
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 | } |
@@ -485,9 +490,9 @@ void KRFBDecoder::handleRawRect() | |||
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 ) { |
@@ -508,9 +513,9 @@ void KRFBDecoder::getRawRectChunk( int lines ) | |||
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 ); |
@@ -522,9 +527,9 @@ void KRFBDecoder::gotRawRectChunk() | |||
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 | // |
@@ -545,9 +550,9 @@ void KRFBDecoder::gotRawRectChunk() | |||
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() ) ); |
@@ -589,9 +594,9 @@ void KRFBDecoder::gotCopyRectPos() | |||
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() ) ); |
@@ -602,19 +607,19 @@ void KRFBDecoder::gotCopyRectPos() | |||
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 | { |
@@ -672,9 +677,9 @@ void KRFBDecoder::sendCutEvent( const QString &unicode ) | |||
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 ); |
@@ -720,9 +725,9 @@ void KRFBDecoder::gotServerCutText() | |||
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 | */ |
@@ -737,16 +742,16 @@ void KRFBDecoder::gotServerCutText() | |||
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 ) { |
@@ -757,9 +762,9 @@ void KRFBDecoder::gotBell() | |||
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 | ||