-rw-r--r-- | noncore/comm/keypebble/krfbdecoder.cpp | 108 |
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 @@ -24,11 +24,11 @@ const int endianTest = 1; (*(char *)&endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s)) #define Swap32IfLE(l) \ (*(char *)&endianTest ? ((((l) & 0xff000000) >> 24) | \ - (((l) & 0x00ff0000) >> 8) | \ - (((l) & 0x0000ff00) << 8) | \ - (((l) & 0x000000ff) << 24)) : (l)) + (((l) & 0x00ff0000) >> 8) | \ + (((l) & 0x0000ff00) << 8) | \ + (((l) & 0x000000ff) << 24)) : (l)) // // The lengths of the messages we need to wait for // @@ -139,9 +139,9 @@ void KRFBDecoder::sendClientInit() { con->write( &( con->options()->shared ), 1 ); // Wait for server init - owarn << "Waiting for server init" << oendl; + owarn << "Waiting for server init" << oendl; static QString statusMsg = tr( "Waiting for server initialization..." ); emit status( statusMsg ); @@ -151,9 +151,9 @@ void KRFBDecoder::sendClientInit() } void KRFBDecoder::gotServerInit() { - owarn << "Got server init" << oendl; + owarn << "Got server init" << oendl; disconnect( con, SIGNAL( gotEnoughData() ), this, SLOT( gotServerInit() ) ); if ( info ) delete info; @@ -185,20 +185,19 @@ void KRFBDecoder::gotServerInit() con->read( &(info->nameLength), 4 ); info->nameLength = Swap32IfLE( info->nameLength ); - owarn << "Width = " << info->width << ", Height = " << info->height << "" << oendl; - qWarning( "Bpp = %d, Depth = %d, Big = %d, True = %d", - info->bpp, info->depth, info->bigEndian, info->trueColor ); - qWarning( "RedMax = %d, GreenMax = %d, BlueMax = %d", - info->redMax, info->greenMax, info->blueMax ); - qWarning( "RedShift = %d, GreenShift = %d, BlueShift = %d", - info->redShift, info->greenShift,info-> blueShift ); + owarn << "Width = " << info->width << ", Height = " << info->height << "" << oendl; + owarn << "Bpp = " << info->bpp << ", Depth = " << info->depth << ", Big = " << info->bigEndian + << ", True = " << info->trueColor << oendl; + owarn << "RedMax = " << info->redMax << ", GreenMax = " << info->greenMax << ", BlueMax = " << info->blueMax << oendl; + owarn << "RedShift = " << info->redShift << ", GreenShift = " << info->greenShift + << ", BlueShift = " << info-> blueShift << oendl; buf->resize( info->width/con->options()->scaleFactor, info->height /con->options()->scaleFactor); // Wait for desktop name - owarn << "Waiting for desktop name" << oendl; + owarn << "Waiting for desktop name" << oendl; static QString statusMsg = tr( "Waiting for desktop name..." ); emit status( statusMsg ); @@ -211,21 +210,21 @@ void KRFBDecoder::gotDesktopName() { assert( info ); assert( currentState == AwaitingDesktopName ); - owarn << "Got desktop name" << oendl; + owarn << "Got desktop name" << oendl; disconnect( con, SIGNAL( gotEnoughData() ), - this, SLOT( gotDesktopName() ) ); + this, SLOT( gotDesktopName() ) ); char *buf = new char[ info->nameLength + 1 ]; CHECK_PTR( buf ); con->read( buf, info->nameLength ); buf[ info->nameLength ] = '\0'; info->name = buf; - owarn << "Desktop: " << info->name.latin1() << "" << oendl; + owarn << "Desktop: " << info->name.latin1() << "" << oendl; delete buf; // Get the format we'll really use and tell the server @@ -263,14 +262,11 @@ void KRFBDecoder::decidePixelFormat() chosenDepth = 8; else chosenDepth = bestDepth; - qWarning( "Screen depth=%d, server depth=%d, best depth=%d, " \ - "eight bit %d, chosenDepth=%d", - screenDepth, - info->depth, - bestDepth, - con->options()->colors256, chosenDepth ); + owarn << "Screen depth=" << screenDepth << ", server depth=" << info->depth + << ", best depth=" << bestDepth << "eight bit " << con->options()->colors256 + << ", chosenDepth=" << chosenDepth << oendl; format->depth = chosenDepth; // If we're using the servers native depth @@ -375,12 +371,12 @@ void KRFBDecoder::sendUpdateRequest( bool incremental ) void KRFBDecoder::gotUpdateHeader() { assert( currentState == AwaitingUpdate ); - // owarn << "Got update header" << oendl; + // owarn << "Got update header" << oendl; disconnect( con, SIGNAL( gotEnoughData() ), - this, SLOT( gotUpdateHeader() ) ); + this, SLOT( gotUpdateHeader() ) ); CARD8 msgType; con->read( &msgType, 1 ); @@ -410,9 +406,9 @@ void KRFBDecoder::gotUpdateHeader() con->read( &noRects, 2 ); noRects = Swap16IfLE( noRects ); - // owarn << "Expecting " << noRects << " rects" << oendl; + // owarn << "Expecting " << noRects << " rects" << oendl; // Now wait for the data currentState = AwaitingRectHeader; connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) ); @@ -422,12 +418,12 @@ void KRFBDecoder::gotUpdateHeader() void KRFBDecoder::gotRectHeader() { assert( currentState == AwaitingRectHeader ); - // owarn << "Got rect header" << oendl; + // owarn << "Got rect header" << oendl; disconnect( con, SIGNAL( gotEnoughData() ), - this, SLOT( gotRectHeader() ) ); + this, SLOT( gotRectHeader() ) ); con->read( &x, 2 ); x = Swap16IfLE( x ); con->read( &y, 2 ); @@ -440,43 +436,43 @@ void KRFBDecoder::gotRectHeader() con->read( &encoding, 4 ); // CARD32 encodingLocal = Swap32IfLE( encoding ); - // qWarning( "Rect: x=%d, y= %d, w=%d, h=%d, encoding=%ld", - // x, y, w, h, encodingLocal ); + // owarn << "Rect: x=" << x << ", y= " << y << ", w=" << w << ", h=" << h + // << ", encoding= " << encodingLocal << oendl; // // Each encoding needs to be handled differently. Some require // waiting for more data, but others like a copyrect do not. // Our constants have already been byte swapped, so we use // the remote value as is. // if ( encoding == RawEncoding ) { - // owarn << "Raw encoding" << oendl; + // owarn << "Raw encoding" << oendl; handleRawRect(); } else if ( encoding == CopyRectEncoding ) { -// owarn << "CopyRect encoding" << oendl; +// owarn << "CopyRect encoding" << oendl; handleCopyRect(); } else if ( encoding == RreEncoding ) { - owarn << "RRE encoding" << oendl; + owarn << "RRE encoding" << oendl; handleRRERect(); } else if ( encoding == CorreEncoding ) { - owarn << "CoRRE encoding" << oendl; + owarn << "CoRRE encoding" << oendl; handleCoRRERect(); } else if ( encoding == HexTileEncoding ) { - owarn << "HexTile encoding" << oendl; + owarn << "HexTile encoding" << oendl; handleHexTileRect(); } else { int msg = Swap32IfLE( encoding ); QString protocolError = tr( "Protocol Error: An unknown encoding was " - "used by the server %1" ).arg( msg ); + "used by the server %1" ).arg( msg ); currentState = Error; - owarn << "Unknown encoding, " << msg << "" << oendl; + owarn << "Unknown encoding, " << msg << "" << oendl; emit error( protocolError ); return; } } @@ -490,9 +486,9 @@ void KRFBDecoder::handleRawRect() // We need something a bit cleverer here to handle large // rectanges nicely. The chunking should be based on the // overall size (but has to be in complete lines). - // owarn << "Handling a raw rect chunk" << oendl; + // owarn << "Handling a raw rect chunk" << oendl; // CARD32 lineCount = w * format->bpp / 8; if ( h > RectChunkSize ) { @@ -513,9 +509,9 @@ void KRFBDecoder::getRawRectChunk( int lines ) this->lines = lines; CARD32 count = lines * w * format->bpp / 8; // Wait for server init - // owarn << "Waiting for raw rect chunk, " << count << "" << oendl; + // owarn << "Waiting for raw rect chunk, " << count << "" << oendl; currentState = AwaitingRawRectChunk; connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRawRectChunk() ) ); con->waitForData( count ); @@ -527,9 +523,9 @@ void KRFBDecoder::gotRawRectChunk() disconnect( con, SIGNAL( gotEnoughData() ), this, SLOT( gotRawRectChunk() ) ); - // owarn << "Got raw rect chunk" << oendl; + // owarn << "Got raw rect chunk" << oendl; // // Read the rect data and copy it to the buffer. // @@ -550,9 +546,9 @@ void KRFBDecoder::gotRawRectChunk() } else { noRects--; - // owarn << "There are " << noRects << " rects left" << oendl; + // owarn << "There are " << noRects << " rects left" << oendl; if ( noRects ) { currentState = AwaitingRectHeader; connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) ); @@ -594,9 +590,9 @@ void KRFBDecoder::gotCopyRectPos() buf->copyRect( srcX, srcY, x, y, w, h ); noRects--; - // owarn << "There are " << noRects << " rects left" << oendl; + // owarn << "There are " << noRects << " rects left" << oendl; if ( noRects ) { currentState = AwaitingRectHeader; connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) ); @@ -607,19 +603,19 @@ void KRFBDecoder::gotCopyRectPos() } void KRFBDecoder::handleRRERect() { - owarn << "RRE not implemented" << oendl; + owarn << "RRE not implemented" << oendl; } void KRFBDecoder::handleCoRRERect() { - owarn << "CoRRE not implemented" << oendl; + owarn << "CoRRE not implemented" << oendl; } void KRFBDecoder::handleHexTileRect() { - owarn << "HexTile not implemented" << oendl; + owarn << "HexTile not implemented" << oendl; } void KRFBDecoder::sendMouseEvent( QMouseEvent *e ) { @@ -643,11 +639,11 @@ void KRFBDecoder::sendMouseEvent( QMouseEvent *e ) buttonMask |= 0x05; } } - // HACK: Scaling + // HACK: Scaling CARD16 x = Swap16IfLE( e->x() * con->options()->scaleFactor ); - CARD16 y = Swap16IfLE( e->y() * con->options()->scaleFactor ); + CARD16 y = Swap16IfLE( e->y() * con->options()->scaleFactor ); con->write( &PointerEventId, 1 ); con->write( &buttonMask, 1 ); con->write( &x, 2 ); @@ -677,9 +673,9 @@ void KRFBDecoder::sendCutEvent( const QString &unicode ) } void KRFBDecoder::gotServerCut() { - owarn << "Got server cut" << oendl; + owarn << "Got server cut" << oendl; currentState = AwaitingServerCutLength; connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerCutLength() ) ); con->waitForData( ServerCutLenLength ); @@ -725,9 +721,9 @@ void KRFBDecoder::gotServerCutText() cutbuf[ serverCutTextLen ] = '\0'; /* For some reason QApplication::clipboard()->setText() segfaults when called * from within keypebble's mass of signals and slots - owarn << "Server cut: " << cutbuf << "" << oendl; + owarn << "Server cut: " << cutbuf << "" << oendl; QString cutText( cutbuf ); // DANGER!! qApp->clipboard()->setText( cutText ); */ @@ -742,16 +738,16 @@ void KRFBDecoder::gotServerCutText() else if ( oldState == Idle ) { currentState = Idle; } else { - owarn << "Async handled in weird state" << oendl; + owarn << "Async handled in weird state" << oendl; currentState = oldState; }; } void KRFBDecoder::gotBell() { - owarn << "Got server bell" << oendl; + owarn << "Got server bell" << oendl; buf->soundBell(); // Now wait for the update (again) if ( oldState == AwaitingUpdate ) { @@ -762,9 +758,9 @@ void KRFBDecoder::gotBell() else if ( oldState == Idle ) { currentState = Idle; } else { - owarn << "Async handled in weird state" << oendl; + owarn << "Async handled in weird state" << oendl; currentState = oldState; }; } @@ -818,13 +814,13 @@ int KRFBDecoder::toKeySym( QKeyEvent *k ) // // Try and map these "other common keys" first. // if ((k->key() >= Qt::Key_Escape) && (k->key() <= Qt::Key_F12)) { - for(int i = 0; keyMap[i].keycode != 0; i++) { - if (k->key() == keyMap[i].keycode) { - return keyMap[i].keysym; - } - } + for(int i = 0; keyMap[i].keycode != 0; i++) { + if (k->key() == keyMap[i].keycode) { + return keyMap[i].keysym; + } + } } // // If these keys aren't matched, return the ascii code and let the |