Fix rfbSendSupportedEncodings

There was a long standing TODO to make the counting of the supported
encodings dynamic.  It never triggered, until ZYWRLE was added.

Noticed by Christian Ehrlicher.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
pull/1/head
dscho 16 years ago
parent e32ebd64a0
commit c17aef31ac

@ -907,15 +907,6 @@ rfbSendSupportedMessages(rfbClientPtr cl)
static void rfbSendSupporteddEncodings_SendEncoding(rfbClientPtr cl, uint32_t enc)
{
uint32_t nSwapped=0;
nSwapped = Swap32IfLE(enc);
memcpy(&cl->updateBuf[cl->ublen], (char *)&nSwapped, sizeof(nSwapped));
cl->ublen+=sizeof(nSwapped);
}
/* /*
* Send rfbEncodingSupportedEncodings. * Send rfbEncodingSupportedEncodings.
*/ */
@ -924,21 +915,38 @@ rfbBool
rfbSendSupportedEncodings(rfbClientPtr cl) rfbSendSupportedEncodings(rfbClientPtr cl)
{ {
rfbFramebufferUpdateRectHeader rect; rfbFramebufferUpdateRectHeader rect;
uint16_t nEncodings=0; static uint32_t supported[] = {
rfbEncodingRaw,
/* think rfbSetEncodingsMsg */ rfbEncodingCopyRect,
rfbEncodingRRE,
/* TODO: dynamic way of doing this */ rfbEncodingCoRRE,
nEncodings=16; rfbEncodingHextile,
#ifdef LIBVNCSERVER_HAVE_LIBZ #ifdef LIBVNCSERVER_HAVE_LIBZ
nEncodings += 2; rfbEncodingZlib,
rfbEncodingZRLE,
rfbEncodingZYWRLE,
#endif #endif
#ifdef LIBVNCSERVER_HAVE_LIBZ #ifdef LIBVNCSERVER_HAVE_LIBJPEG
nEncodings++; rfbEncodingTight,
#endif #endif
rfbEncodingUltra,
rfbEncodingUltraZip,
rfbEncodingXCursor,
rfbEncodingRichCursor,
rfbEncodingPointerPos,
rfbEncodingLastRect,
rfbEncodingNewFBSize,
rfbEncodingKeyboardLedState,
rfbEncodingSupportedMessages,
rfbEncodingSupportedEncodings,
rfbEncodingServerIdentity,
};
uint32_t nEncodings = sizeof(supported) / sizeof(supported[0]), i;
/* think rfbSetEncodingsMsg */
if (cl->ublen + sz_rfbFramebufferUpdateRectHeader if (cl->ublen + sz_rfbFramebufferUpdateRectHeader
+ (nEncodings*sizeof(uint32_t)) > UPDATE_BUF_SIZE) { + (nEncodings * sizeof(uint32_t)) > UPDATE_BUF_SIZE) {
if (!rfbSendUpdateBuf(cl)) if (!rfbSendUpdateBuf(cl))
return FALSE; return FALSE;
} }
@ -953,30 +961,11 @@ rfbSendSupportedEncodings(rfbClientPtr cl)
sz_rfbFramebufferUpdateRectHeader); sz_rfbFramebufferUpdateRectHeader);
cl->ublen += sz_rfbFramebufferUpdateRectHeader; cl->ublen += sz_rfbFramebufferUpdateRectHeader;
rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingRaw); for (i = 0; i < nEncodings; i++) {
rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingCopyRect); uint32_t encoding = Swap32IfLE(supported[i]);
rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingRRE); memcpy(&cl->updateBuf[cl->ublen], (char *)&encoding, sizeof(encoding));
rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingCoRRE); cl->ublen += sizeof(encoding);
rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingHextile); }
#ifdef LIBVNCSERVER_HAVE_LIBZ
rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingZlib);
rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingTight);
#endif
#ifdef LIBVNCSERVER_HAVE_LIBZ
rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingZRLE);
rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingZYWRLE);
#endif
rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingUltra);
rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingUltraZip);
rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingXCursor);
rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingRichCursor);
rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingPointerPos);
rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingLastRect);
rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingNewFBSize);
rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingKeyboardLedState);
rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingSupportedMessages);
rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingSupportedEncodings);
rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingServerIdentity);
rfbStatRecordEncodingSent(cl, rfbEncodingSupportedEncodings, rfbStatRecordEncodingSent(cl, rfbEncodingSupportedEncodings,
sz_rfbFramebufferUpdateRectHeader+(nEncodings * sizeof(uint32_t)), sz_rfbFramebufferUpdateRectHeader+(nEncodings * sizeof(uint32_t)),

Loading…
Cancel
Save