summaryrefslogtreecommitdiff
path: root/noncore/comm/keypebble/krfbdecoder.cpp
Unidiff
Diffstat (limited to 'noncore/comm/keypebble/krfbdecoder.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/comm/keypebble/krfbdecoder.cpp108
1 files changed, 52 insertions, 56 deletions
diff --git a/noncore/comm/keypebble/krfbdecoder.cpp b/noncore/comm/keypebble/krfbdecoder.cpp
index d61433f..837fcc5 100644
--- a/noncore/comm/keypebble/krfbdecoder.cpp
+++ b/noncore/comm/keypebble/krfbdecoder.cpp
@@ -22,15 +22,15 @@ const int endianTest = 1;
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//
35const int ServerInitLength = 24; 35const int ServerInitLength = 24;
36const int UpdateHeaderLength = 4; 36const int UpdateHeaderLength = 4;
@@ -137,25 +137,25 @@ void KRFBDecoder::start()
137 137
138void KRFBDecoder::sendClientInit() 138void 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
153void KRFBDecoder::gotServerInit() 153void 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 );
@@ -183,24 +183,23 @@ void KRFBDecoder::gotServerInit()
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 owarn << "Bpp = " << info->bpp << ", Depth = " << info->depth << ", Big = " << info->bigEndian
191 info->bpp, info->depth, info->bigEndian, info->trueColor ); 191 << ", True = " << info->trueColor << oendl;
192 qWarning( "RedMax = %d, GreenMax = %d, BlueMax = %d", 192 owarn << "RedMax = " << info->redMax << ", GreenMax = " << info->greenMax << ", BlueMax = " << info->blueMax << oendl;
193 info->redMax, info->greenMax, info->blueMax ); 193 owarn << "RedShift = " << info->redShift << ", GreenShift = " << info->greenShift
194 qWarning( "RedShift = %d, GreenShift = %d, BlueShift = %d", 194 << ", BlueShift = " << info-> blueShift << oendl;
195 info->redShift, info->greenShift,info-> blueShift );
196 195
197 buf->resize( info->width/con->options()->scaleFactor, info->height /con->options()->scaleFactor); 196 buf->resize( info->width/con->options()->scaleFactor, info->height /con->options()->scaleFactor);
198 197
199 // Wait for desktop name 198 // Wait for desktop name
200 owarn << "Waiting for desktop name" << oendl; 199 owarn << "Waiting for desktop name" << oendl;
201 200
202 static QString statusMsg = tr( "Waiting for desktop name..." ); 201 static QString statusMsg = tr( "Waiting for desktop name..." );
203 emit status( statusMsg ); 202 emit status( statusMsg );
204 203
205 currentState = AwaitingDesktopName; 204 currentState = AwaitingDesktopName;
206 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotDesktopName() ) ); 205 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotDesktopName() ) );
@@ -209,25 +208,25 @@ void KRFBDecoder::gotServerInit()
209 208
210void KRFBDecoder::gotDesktopName() 209void KRFBDecoder::gotDesktopName()
211{ 210{
212 assert( info ); 211 assert( info );
213 assert( currentState == AwaitingDesktopName ); 212 assert( currentState == AwaitingDesktopName );
214 213
215 owarn << "Got desktop name" << oendl; 214 owarn << "Got desktop name" << oendl;
216 215
217 disconnect( con, SIGNAL( gotEnoughData() ), 216 disconnect( con, SIGNAL( gotEnoughData() ),
218 this, SLOT( gotDesktopName() ) ); 217 this, SLOT( gotDesktopName() ) );
219 218
220 char *buf = new char[ info->nameLength + 1 ]; 219 char *buf = new char[ info->nameLength + 1 ];
221 CHECK_PTR( buf ); 220 CHECK_PTR( buf );
222 221
223 con->read( buf, info->nameLength ); 222 con->read( buf, info->nameLength );
224 buf[ info->nameLength ] = '\0'; 223 buf[ info->nameLength ] = '\0';
225 info->name = buf; 224 info->name = buf;
226 225
227 owarn << "Desktop: " << info->name.latin1() << "" << oendl; 226 owarn << "Desktop: " << info->name.latin1() << "" << oendl;
228 227
229 delete buf; 228 delete buf;
230 229
231 // Get the format we'll really use and tell the server 230 // Get the format we'll really use and tell the server
232 decidePixelFormat(); 231 decidePixelFormat();
233 sendPixelFormat(); 232 sendPixelFormat();
@@ -261,18 +260,15 @@ void KRFBDecoder::decidePixelFormat()
261 260
262 if ( con->options()->colors256 ) 261 if ( con->options()->colors256 )
263 chosenDepth = 8; 262 chosenDepth = 8;
264 else 263 else
265 chosenDepth = bestDepth; 264 chosenDepth = bestDepth;
266 265
267 qWarning( "Screen depth=%d, server depth=%d, best depth=%d, " \ 266 owarn << "Screen depth=" << screenDepth << ", server depth=" << info->depth
268 "eight bit %d, chosenDepth=%d", 267 << ", best depth=" << bestDepth << "eight bit " << con->options()->colors256
269 screenDepth, 268 << ", chosenDepth=" << chosenDepth << oendl;
270 info->depth,
271 bestDepth,
272 con->options()->colors256, chosenDepth );
273 269
274 format->depth = chosenDepth; 270 format->depth = chosenDepth;
275 271
276 // If we're using the servers native depth 272 // If we're using the servers native depth
277 if ( chosenDepth == info->depth ) { 273 if ( chosenDepth == info->depth ) {
278 // Use the servers native format 274 // Use the servers native format
@@ -373,16 +369,16 @@ void KRFBDecoder::sendUpdateRequest( bool incremental )
373} 369}
374 370
375void KRFBDecoder::gotUpdateHeader() 371void KRFBDecoder::gotUpdateHeader()
376{ 372{
377 assert( currentState == AwaitingUpdate ); 373 assert( currentState == AwaitingUpdate );
378 374
379 // owarn << "Got update header" << oendl; 375 // owarn << "Got update header" << oendl;
380 376
381 disconnect( con, SIGNAL( gotEnoughData() ), 377 disconnect( con, SIGNAL( gotEnoughData() ),
382 this, SLOT( gotUpdateHeader() ) ); 378 this, SLOT( gotUpdateHeader() ) );
383 379
384 CARD8 msgType; 380 CARD8 msgType;
385 con->read( &msgType, 1 ); 381 con->read( &msgType, 1 );
386 382
387 if ( msgType != UpdateId ) { 383 if ( msgType != UpdateId ) {
388 // We might have a bell or server cut 384 // We might have a bell or server cut
@@ -408,28 +404,28 @@ void KRFBDecoder::gotUpdateHeader()
408 CARD8 padding; 404 CARD8 padding;
409 con->read( &padding, 1 ); 405 con->read( &padding, 1 );
410 406
411 con->read( &noRects, 2 ); 407 con->read( &noRects, 2 );
412 noRects = Swap16IfLE( noRects ); 408 noRects = Swap16IfLE( noRects );
413 409
414 // owarn << "Expecting " << noRects << " rects" << oendl; 410 // owarn << "Expecting " << noRects << " rects" << oendl;
415 411
416 // Now wait for the data 412 // Now wait for the data
417 currentState = AwaitingRectHeader; 413 currentState = AwaitingRectHeader;
418 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) ); 414 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) );
419 con->waitForData( RectHeaderLength ); 415 con->waitForData( RectHeaderLength );
420} 416}
421 417
422void KRFBDecoder::gotRectHeader() 418void KRFBDecoder::gotRectHeader()
423{ 419{
424 assert( currentState == AwaitingRectHeader ); 420 assert( currentState == AwaitingRectHeader );
425 421
426 // owarn << "Got rect header" << oendl; 422 // owarn << "Got rect header" << oendl;
427 423
428 disconnect( con, SIGNAL( gotEnoughData() ), 424 disconnect( con, SIGNAL( gotEnoughData() ),
429 this, SLOT( gotRectHeader() ) ); 425 this, SLOT( gotRectHeader() ) );
430 426
431 con->read( &x, 2 ); 427 con->read( &x, 2 );
432 x = Swap16IfLE( x ); 428 x = Swap16IfLE( x );
433 con->read( &y, 2 ); 429 con->read( &y, 2 );
434 y = Swap16IfLE( y ); 430 y = Swap16IfLE( y );
435 431
@@ -438,47 +434,47 @@ void KRFBDecoder::gotRectHeader()
438 con->read( &h, 2 ); 434 con->read( &h, 2 );
439 h = Swap16IfLE( h ); 435 h = Swap16IfLE( h );
440 436
441 con->read( &encoding, 4 ); 437 con->read( &encoding, 4 );
442 438
443 // CARD32 encodingLocal = Swap32IfLE( encoding ); 439 // CARD32 encodingLocal = Swap32IfLE( encoding );
444 // qWarning( "Rect: x=%d, y= %d, w=%d, h=%d, encoding=%ld", 440 // owarn << "Rect: x=" << x << ", y= " << y << ", w=" << w << ", h=" << h
445 // x, y, w, h, encodingLocal ); 441 // << ", encoding= " << encodingLocal << oendl;
446 442
447 // 443 //
448 // Each encoding needs to be handled differently. Some require 444 // Each encoding needs to be handled differently. Some require
449 // waiting for more data, but others like a copyrect do not. 445 // waiting for more data, but others like a copyrect do not.
450 // Our constants have already been byte swapped, so we use 446 // Our constants have already been byte swapped, so we use
451 // the remote value as is. 447 // the remote value as is.
452 // 448 //
453 if ( encoding == RawEncoding ) { 449 if ( encoding == RawEncoding ) {
454 // owarn << "Raw encoding" << oendl; 450 // owarn << "Raw encoding" << oendl;
455 handleRawRect(); 451 handleRawRect();
456 } 452 }
457 else if ( encoding == CopyRectEncoding ) { 453 else if ( encoding == CopyRectEncoding ) {
458// owarn << "CopyRect encoding" << oendl; 454// owarn << "CopyRect encoding" << oendl;
459 handleCopyRect(); 455 handleCopyRect();
460 } 456 }
461 else if ( encoding == RreEncoding ) { 457 else if ( encoding == RreEncoding ) {
462 owarn << "RRE encoding" << oendl; 458 owarn << "RRE encoding" << oendl;
463 handleRRERect(); 459 handleRRERect();
464 } 460 }
465 else if ( encoding == CorreEncoding ) { 461 else if ( encoding == CorreEncoding ) {
466 owarn << "CoRRE encoding" << oendl; 462 owarn << "CoRRE encoding" << oendl;
467 handleCoRRERect(); 463 handleCoRRERect();
468 } 464 }
469 else if ( encoding == HexTileEncoding ) { 465 else if ( encoding == HexTileEncoding ) {
470 owarn << "HexTile encoding" << oendl; 466 owarn << "HexTile encoding" << oendl;
471 handleHexTileRect(); 467 handleHexTileRect();
472 } 468 }
473 else { 469 else {
474 int msg = Swap32IfLE( encoding ); 470 int msg = Swap32IfLE( encoding );
475 QString protocolError = tr( "Protocol Error: An unknown encoding was " 471 QString protocolError = tr( "Protocol Error: An unknown encoding was "
476 "used by the server %1" ).arg( msg ); 472 "used by the server %1" ).arg( msg );
477 currentState = Error; 473 currentState = Error;
478 owarn << "Unknown encoding, " << msg << "" << oendl; 474 owarn << "Unknown encoding, " << msg << "" << oendl;
479 emit error( protocolError ); 475 emit error( protocolError );
480 return; 476 return;
481 } 477 }
482} 478}
483 479
484// 480//
@@ -488,13 +484,13 @@ void KRFBDecoder::gotRectHeader()
488void KRFBDecoder::handleRawRect() 484void KRFBDecoder::handleRawRect()
489{ 485{
490 // We need something a bit cleverer here to handle large 486 // We need something a bit cleverer here to handle large
491 // rectanges nicely. The chunking should be based on the 487 // rectanges nicely. The chunking should be based on the
492 // overall size (but has to be in complete lines). 488 // overall size (but has to be in complete lines).
493 489
494 // owarn << "Handling a raw rect chunk" << oendl; 490 // owarn << "Handling a raw rect chunk" << oendl;
495 491
496 // CARD32 lineCount = w * format->bpp / 8; 492 // CARD32 lineCount = w * format->bpp / 8;
497 493
498 if ( h > RectChunkSize ) { 494 if ( h > RectChunkSize ) {
499 // if ( con->sock->size() / lineCount ) { 495 // if ( con->sock->size() / lineCount ) {
500 // getRawRectChunk( con->sock->size() / lineCount ); 496 // getRawRectChunk( con->sock->size() / lineCount );
@@ -511,13 +507,13 @@ void KRFBDecoder::handleRawRect()
511void KRFBDecoder::getRawRectChunk( int lines ) 507void KRFBDecoder::getRawRectChunk( int lines )
512{ 508{
513 this->lines = lines; 509 this->lines = lines;
514 CARD32 count = lines * w * format->bpp / 8; 510 CARD32 count = lines * w * format->bpp / 8;
515 511
516 // Wait for server init 512 // Wait for server init
517 // owarn << "Waiting for raw rect chunk, " << count << "" << oendl; 513 // owarn << "Waiting for raw rect chunk, " << count << "" << oendl;
518 514
519 currentState = AwaitingRawRectChunk; 515 currentState = AwaitingRawRectChunk;
520 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRawRectChunk() ) ); 516 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRawRectChunk() ) );
521 con->waitForData( count ); 517 con->waitForData( count );
522} 518}
523 519
@@ -525,13 +521,13 @@ void KRFBDecoder::gotRawRectChunk()
525{ 521{
526 assert( currentState == AwaitingRawRectChunk ); 522 assert( currentState == AwaitingRawRectChunk );
527 523
528 disconnect( con, SIGNAL( gotEnoughData() ), 524 disconnect( con, SIGNAL( gotEnoughData() ),
529 this, SLOT( gotRawRectChunk() ) ); 525 this, SLOT( gotRawRectChunk() ) );
530 526
531 // owarn << "Got raw rect chunk" << oendl; 527 // owarn << "Got raw rect chunk" << oendl;
532 528
533 // 529 //
534 // Read the rect data and copy it to the buffer. 530 // Read the rect data and copy it to the buffer.
535 // 531 //
536 532
537 // TODO: Replace this! 533 // TODO: Replace this!
@@ -548,13 +544,13 @@ void KRFBDecoder::gotRawRectChunk()
548 if ( h > 0 ) { 544 if ( h > 0 ) {
549 handleRawRect(); 545 handleRawRect();
550 } 546 }
551 else { 547 else {
552 noRects--; 548 noRects--;
553 549
554 // owarn << "There are " << noRects << " rects left" << oendl; 550 // owarn << "There are " << noRects << " rects left" << oendl;
555 551
556 if ( noRects ) { 552 if ( noRects ) {
557 currentState = AwaitingRectHeader; 553 currentState = AwaitingRectHeader;
558 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) ); 554 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) );
559 con->waitForData( RectHeaderLength ); 555 con->waitForData( RectHeaderLength );
560 } 556 }
@@ -592,36 +588,36 @@ void KRFBDecoder::gotCopyRectPos()
592 srcY = Swap16IfLE( srcY ); 588 srcY = Swap16IfLE( srcY );
593 589
594 buf->copyRect( srcX, srcY, x, y, w, h ); 590 buf->copyRect( srcX, srcY, x, y, w, h );
595 591
596 noRects--; 592 noRects--;
597 593
598 // owarn << "There are " << noRects << " rects left" << oendl; 594 // owarn << "There are " << noRects << " rects left" << oendl;
599 595
600 if ( noRects ) { 596 if ( noRects ) {
601 currentState = AwaitingRectHeader; 597 currentState = AwaitingRectHeader;
602 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) ); 598 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) );
603 con->waitForData( RectHeaderLength ); 599 con->waitForData( RectHeaderLength );
604 } 600 }
605 else 601 else
606 currentState = Idle; 602 currentState = Idle;
607} 603}
608 604
609void KRFBDecoder::handleRRERect() 605void KRFBDecoder::handleRRERect()
610{ 606{
611 owarn << "RRE not implemented" << oendl; 607 owarn << "RRE not implemented" << oendl;
612} 608}
613 609
614void KRFBDecoder::handleCoRRERect() 610void KRFBDecoder::handleCoRRERect()
615{ 611{
616 owarn << "CoRRE not implemented" << oendl; 612 owarn << "CoRRE not implemented" << oendl;
617} 613}
618 614
619void KRFBDecoder::handleHexTileRect() 615void KRFBDecoder::handleHexTileRect()
620{ 616{
621 owarn << "HexTile not implemented" << oendl; 617 owarn << "HexTile not implemented" << oendl;
622} 618}
623 619
624void KRFBDecoder::sendMouseEvent( QMouseEvent *e ) 620void KRFBDecoder::sendMouseEvent( QMouseEvent *e )
625{ 621{
626 // Deal with the buttons 622 // Deal with the buttons
627 if ( e->type() != QEvent::MouseMove ) { 623 if ( e->type() != QEvent::MouseMove ) {
@@ -641,15 +637,15 @@ void KRFBDecoder::sendMouseEvent( QMouseEvent *e )
641 buttonMask |= 0x03; 637 buttonMask |= 0x03;
642 if ( e->button() & RightButton ) 638 if ( e->button() & RightButton )
643 buttonMask |= 0x05; 639 buttonMask |= 0x05;
644 } 640 }
645 } 641 }
646 642
647 // HACK: Scaling 643 // HACK: Scaling
648 CARD16 x = Swap16IfLE( e->x() * con->options()->scaleFactor ); 644 CARD16 x = Swap16IfLE( e->x() * con->options()->scaleFactor );
649 CARD16 y = Swap16IfLE( e->y() *con->options()->scaleFactor ); 645 CARD16 y = Swap16IfLE( e->y() * con->options()->scaleFactor );
650 646
651 con->write( &PointerEventId, 1 ); 647 con->write( &PointerEventId, 1 );
652 con->write( &buttonMask, 1 ); 648 con->write( &buttonMask, 1 );
653 con->write( &x, 2 ); 649 con->write( &x, 2 );
654 con->write( &y, 2 ); 650 con->write( &y, 2 );
655} 651}
@@ -675,13 +671,13 @@ void KRFBDecoder::sendCutEvent( const QString &unicode )
675 con->write( &length, 4 ); 671 con->write( &length, 4 );
676 con->write( text.data(), length ); 672 con->write( text.data(), length );
677} 673}
678 674
679void KRFBDecoder::gotServerCut() 675void KRFBDecoder::gotServerCut()
680{ 676{
681 owarn << "Got server cut" << oendl; 677 owarn << "Got server cut" << oendl;
682 678
683 currentState = AwaitingServerCutLength; 679 currentState = AwaitingServerCutLength;
684 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerCutLength() ) ); 680 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerCutLength() ) );
685 con->waitForData( ServerCutLenLength ); 681 con->waitForData( ServerCutLenLength );
686} 682}
687 683
@@ -723,13 +719,13 @@ void KRFBDecoder::gotServerCutText()
723 719
724 con->read( cutbuf, serverCutTextLen ); 720 con->read( cutbuf, serverCutTextLen );
725 cutbuf[ serverCutTextLen ] = '\0'; 721 cutbuf[ serverCutTextLen ] = '\0';
726 722
727 /* For some reason QApplication::clipboard()->setText() segfaults when called 723 /* For some reason QApplication::clipboard()->setText() segfaults when called
728 * from within keypebble's mass of signals and slots 724 * from within keypebble's mass of signals and slots
729 owarn << "Server cut: " << cutbuf << "" << oendl; 725 owarn << "Server cut: " << cutbuf << "" << oendl;
730 726
731 QString cutText( cutbuf ); // DANGER!! 727 QString cutText( cutbuf ); // DANGER!!
732 qApp->clipboard()->setText( cutText ); 728 qApp->clipboard()->setText( cutText );
733 */ 729 */
734 730
735 delete cutbuf; 731 delete cutbuf;
@@ -740,33 +736,33 @@ void KRFBDecoder::gotServerCutText()
740 con->waitForData( UpdateHeaderLength ); 736 con->waitForData( UpdateHeaderLength );
741 } 737 }
742 else if ( oldState == Idle ) { 738 else if ( oldState == Idle ) {
743 currentState = Idle; 739 currentState = Idle;
744 } 740 }
745 else { 741 else {
746 owarn << "Async handled in weird state" << oendl; 742 owarn << "Async handled in weird state" << oendl;
747 currentState = oldState; 743 currentState = oldState;
748 }; 744 };
749} 745}
750 746
751void KRFBDecoder::gotBell() 747void KRFBDecoder::gotBell()
752{ 748{
753 owarn << "Got server bell" << oendl; 749 owarn << "Got server bell" << oendl;
754 buf->soundBell(); 750 buf->soundBell();
755 751
756 // Now wait for the update (again) 752 // Now wait for the update (again)
757 if ( oldState == AwaitingUpdate ) { 753 if ( oldState == AwaitingUpdate ) {
758 currentState = AwaitingUpdate; 754 currentState = AwaitingUpdate;
759 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotUpdateHeader() ) ); 755 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotUpdateHeader() ) );
760 con->waitForData( UpdateHeaderLength ); 756 con->waitForData( UpdateHeaderLength );
761 } 757 }
762 else if ( oldState == Idle ) { 758 else if ( oldState == Idle ) {
763 currentState = Idle; 759 currentState = Idle;
764 } 760 }
765 else { 761 else {
766 owarn << "Async handled in weird state" << oendl; 762 owarn << "Async handled in weird state" << oendl;
767 currentState = oldState; 763 currentState = oldState;
768 }; 764 };
769} 765}
770 766
771void KRFBDecoder::sendKeyPressEvent( QKeyEvent *event ) 767void KRFBDecoder::sendKeyPressEvent( QKeyEvent *event )
772{ 768{
@@ -816,17 +812,17 @@ int KRFBDecoder::toKeySym( QKeyEvent *k )
816{ 812{
817 813
818 // 814 //
819 // Try and map these "other common keys" first. 815 // Try and map these "other common keys" first.
820 // 816 //
821 if ((k->key() >= Qt::Key_Escape) && (k->key() <= Qt::Key_F12)) { 817 if ((k->key() >= Qt::Key_Escape) && (k->key() <= Qt::Key_F12)) {
822 for(int i = 0; keyMap[i].keycode != 0; i++) { 818 for(int i = 0; keyMap[i].keycode != 0; i++) {
823 if (k->key() == keyMap[i].keycode) { 819 if (k->key() == keyMap[i].keycode) {
824 return keyMap[i].keysym; 820 return keyMap[i].keysym;
825 } 821 }
826 } 822 }
827 } 823 }
828 824
829 // 825 //
830 // If these keys aren't matched, return the ascii code and let the 826 // If these keys aren't matched, return the ascii code and let the
831 // server figure it out. We don't return k->key(), as the data in 827 // server figure it out. We don't return k->key(), as the data in
832 // key differs between input methods, and we don't want special cases. 828 // key differs between input methods, and we don't want special cases.