From a9be6f59105b7cf29bb799556274dc2c3b3d2af8 Mon Sep 17 00:00:00 2001 From: Fernando Carvajal Date: Tue, 12 Apr 2016 11:52:22 +0200 Subject: Remove compatibility code for nxcomp before 3.5.0 As a part of nxcomp's clean-up process, compatibility with old protocol versions has been set now at 3.5.0. This commit removes compatibility code from nxcomp so the minimum supported version changes from 1.5.0 (protocol step 6) to 3.5.0 (protocol step 10). At this moment the removal is not complete and it will be followed by some other commits, in order to get rid of several components and files that are no longer used as they were only needed to work with old protocol versions. Refs: ArcticaProject/nx-libs#108 --- nxcomp/Channel.cpp | 186 +++--------- nxcomp/ClientCache.cpp | 7 - nxcomp/ClientCache.h | 15 - nxcomp/ClientChannel.cpp | 525 +++++---------------------------- nxcomp/ClientChannel.h | 40 --- nxcomp/ClientProxy.h | 10 +- nxcomp/ClientStore.cpp | 24 +- nxcomp/Control.cpp | 107 ++----- nxcomp/Control.h | 50 ++-- nxcomp/CreateGC.cpp | 80 ++--- nxcomp/DecodeBuffer.cpp | 95 +----- nxcomp/DecodeBuffer.h | 12 - nxcomp/EncodeBuffer.cpp | 67 +---- nxcomp/EncodeBuffer.h | 12 - nxcomp/FillPoly.cpp | 16 +- nxcomp/FillPoly.h | 16 +- nxcomp/GenericChannel.h | 24 +- nxcomp/GenericReply.cpp | 7 +- nxcomp/GenericReply.h | 1 - nxcomp/GenericRequest.cpp | 9 +- nxcomp/GenericRequest.h | 1 - nxcomp/GetImageReply.cpp | 7 +- nxcomp/GetImageReply.h | 1 - nxcomp/GetPropertyReply.cpp | 7 +- nxcomp/GetPropertyReply.h | 1 - nxcomp/ListFontsReply.cpp | 7 +- nxcomp/ListFontsReply.h | 1 - nxcomp/Loop.cpp | 264 +++++------------ nxcomp/Message.cpp | 14 - nxcomp/Message.h | 21 -- nxcomp/PolyLine.cpp | 18 +- nxcomp/PolyPoint.cpp | 18 +- nxcomp/PositionCacheCompat.cpp | 17 -- nxcomp/Proxy.cpp | 280 +++++------------- nxcomp/Proxy.h | 5 - nxcomp/PutImage.cpp | 14 +- nxcomp/PutImage.h | 2 - nxcomp/PutPackedImage.cpp | 7 +- nxcomp/PutPackedImage.h | 1 - nxcomp/QueryFontReply.cpp | 7 +- nxcomp/QueryFontReply.h | 1 - nxcomp/RenderCompositeGlyphs.cpp | 166 ++++------- nxcomp/RenderCompositeGlyphs.h | 5 +- nxcomp/RenderExtension.cpp | 258 ++++------------ nxcomp/RenderExtension.h | 1 - nxcomp/ServerCache.cpp | 5 +- nxcomp/ServerCache.h | 8 - nxcomp/ServerChannel.cpp | 614 ++++++++------------------------------- nxcomp/ServerChannel.h | 15 - nxcomp/ServerProxy.h | 10 +- nxcomp/SetUnpackAlpha.cpp | 7 +- nxcomp/SetUnpackAlpha.h | 4 - nxcomp/SetUnpackColormap.cpp | 7 +- nxcomp/SetUnpackColormap.h | 3 - nxcomp/ShapeExtension.cpp | 7 +- nxcomp/ShapeExtension.h | 1 - nxcomp/Split.cpp | 23 +- nxcomp/Types.h | 10 +- 58 files changed, 649 insertions(+), 2492 deletions(-) (limited to 'nxcomp') diff --git a/nxcomp/Channel.cpp b/nxcomp/Channel.cpp index 71b556b0d..93efa6343 100644 --- a/nxcomp/Channel.cpp +++ b/nxcomp/Channel.cpp @@ -386,16 +386,14 @@ int Channel::handleDecode(DecodeBuffer &decodeBuffer, ChannelCache *channelCache if (store -> enableSplit == 1) { - if (control -> isProtoStep7() == 1) - { - #ifdef DEBUG - *logofs << "handleDecode: " << store -> name() - << ": Checking if the message was split.\n" - << logofs_flush; - #endif + // Since ProtoStep7 (#issue 108) + #ifdef DEBUG + *logofs << "handleDecode: " << store -> name() + << ": Checking if the message was split.\n" + << logofs_flush; + #endif - decodeBuffer.decodeBoolValue(split); - } + decodeBuffer.decodeBoolValue(split); if (split == 1) { @@ -537,16 +535,9 @@ int Channel::handleEncodeCached(EncodeBuffer &encodeBuffer, ChannelCache *channe if (control -> LocalDeltaCompression == 0 || enableCache_ == 0 || store -> enableCache == 0) { - if (control -> isProtoStep7() == 1) - { - encodeBuffer.encodeActionValue(is_discarded, - store -> lastActionCache); - } - else - { - encodeBuffer.encodeActionValueCompat(is_discarded, - store -> lastActionCacheCompat); - } + // Since ProtoStep7 (#issue 108) + encodeBuffer.encodeActionValue(is_discarded, + store -> lastActionCache); store -> lastAction = is_discarded; @@ -601,19 +592,9 @@ int Channel::handleEncodeCached(EncodeBuffer &encodeBuffer, ChannelCache *channe store -> lastRemoved = position; - if (control -> isProtoStep7() == 1) - { - encodeBuffer.encodeActionValue(is_removed, store -> lastRemoved, - store -> lastActionCache); - } - else - { - encodeBuffer.encodeActionValueCompat(is_removed, - store -> lastActionCacheCompat); - - encodeBuffer.encodePositionValueCompat(store -> lastRemoved, - store -> lastRemovedCacheCompat); - } + // Since ProtoStep7 (#issue 108) + encodeBuffer.encodeActionValue(is_removed, store -> lastRemoved, + store -> lastActionCache); #ifdef DEBUG *logofs << "handleEncodeCached: " << store -> name() << ": Going to " @@ -679,16 +660,9 @@ int Channel::handleEncodeCached(EncodeBuffer &encodeBuffer, ChannelCache *channe << logofs_flush; #endif - if (control -> isProtoStep7() == 1) - { - encodeBuffer.encodeActionValue(is_discarded, - store -> lastActionCache); - } - else - { - encodeBuffer.encodeActionValueCompat(is_discarded, - store -> lastActionCacheCompat); - } + // Since ProtoStep7 (#issue 108) + encodeBuffer.encodeActionValue(is_discarded, + store -> lastActionCache); store -> lastAction = is_discarded; @@ -759,16 +733,9 @@ int Channel::handleEncodeCached(EncodeBuffer &encodeBuffer, ChannelCache *channe << logofs_flush; #endif - if (control -> isProtoStep7() == 1) - { - encodeBuffer.encodeActionValue(is_discarded, - store -> lastActionCache); - } - else - { - encodeBuffer.encodeActionValueCompat(is_discarded, - store -> lastActionCacheCompat); - } + // Since ProtoStep7 (#issue 108) + encodeBuffer.encodeActionValue(is_discarded, + store -> lastActionCache); store -> lastAction = is_discarded; @@ -793,16 +760,9 @@ int Channel::handleEncodeCached(EncodeBuffer &encodeBuffer, ChannelCache *channe cerr << "Warning" << ": Message of size " << store -> plainSize(position) << " at position " << position << " is locked.\n"; - if (control -> isProtoStep7() == 1) - { - encodeBuffer.encodeActionValue(is_discarded, - store -> lastActionCache); - } - else - { - encodeBuffer.encodeActionValueCompat(is_discarded, - store -> lastActionCacheCompat); - } + // Since ProtoStep7 (#issue 108) + encodeBuffer.encodeActionValue(is_discarded, + store -> lastActionCache); store -> lastAction = is_discarded; @@ -843,20 +803,9 @@ int Channel::handleEncodeCached(EncodeBuffer &encodeBuffer, ChannelCache *channe store -> lastAdded = position; - if (control -> isProtoStep7() == 1) - { - encodeBuffer.encodeActionValue(IS_ADDED, store -> lastAdded, - store -> lastActionCache); - - } - else - { - encodeBuffer.encodeActionValueCompat(IS_ADDED, - store -> lastActionCacheCompat); - - encodeBuffer.encodePositionValueCompat(store -> lastAdded, - store -> lastAddedCacheCompat); - } + // Since ProtoStep7 (#issue 108) + encodeBuffer.encodeActionValue(IS_ADDED, store -> lastAdded, + store -> lastActionCache); return 0; } @@ -898,19 +847,9 @@ int Channel::handleEncodeCached(EncodeBuffer &encodeBuffer, ChannelCache *channe store -> lastHit = position; - if (control -> isProtoStep7() == 1) - { - encodeBuffer.encodeActionValue(IS_HIT, store -> lastHit, - store -> lastActionCache); - } - else - { - encodeBuffer.encodeActionValueCompat(IS_HIT, - store -> lastActionCacheCompat); - - encodeBuffer.encodePositionValueCompat(store -> lastHit, - store -> lastHitCacheCompat); - } + // Since ProtoStep7 (#issue 108) + encodeBuffer.encodeActionValue(IS_HIT, store -> lastHit, + store -> lastActionCache); // // Send the field by field differences in @@ -997,16 +936,9 @@ int Channel::handleDecodeCached(DecodeBuffer &decodeBuffer, ChannelCache *channe unsigned char action; unsigned short int position; - if (control -> isProtoStep7() == 1) - { - decodeBuffer.decodeActionValue(action, position, - store -> lastActionCache); - } - else - { - decodeBuffer.decodeActionValueCompat(action, - store -> lastActionCacheCompat); - } + // Since ProtoStep7 (#issue 108) + decodeBuffer.decodeActionValue(action, position, + store -> lastActionCache); // // Clean operations must always come @@ -1015,15 +947,8 @@ int Channel::handleDecodeCached(DecodeBuffer &decodeBuffer, ChannelCache *channe while (action == is_removed) { - if (control -> isProtoStep7() == 1) - { - store -> lastRemoved = position; - } - else - { - decodeBuffer.decodePositionValueCompat(store -> lastRemoved, - store -> lastRemovedCacheCompat); - } + // Since ProtoStep7 (#issue 108) + store -> lastRemoved = position; #ifdef DEBUG @@ -1046,16 +971,9 @@ int Channel::handleDecodeCached(DecodeBuffer &decodeBuffer, ChannelCache *channe store -> remove(store -> lastRemoved, discard_checksum, use_data); - if (control -> isProtoStep7() == 1) - { - decodeBuffer.decodeActionValue(action, position, - store -> lastActionCache); - } - else - { - decodeBuffer.decodeActionValueCompat(action, - store -> lastActionCacheCompat); - } + // Since ProtoStep7 (#issue 108) + decodeBuffer.decodeActionValue(action, position, + store -> lastActionCache); } // @@ -1065,15 +983,8 @@ int Channel::handleDecodeCached(DecodeBuffer &decodeBuffer, ChannelCache *channe if ((T_store_action) action == IS_HIT) { - if (control -> isProtoStep7() == 1) - { - store -> lastHit = position; - } - else - { - decodeBuffer.decodePositionValueCompat(store -> lastHit, - store -> lastHitCacheCompat); - } + // Since ProtoStep7 (#issue 108) + store -> lastHit = position; // // Get data from the cache at given position. @@ -1139,15 +1050,8 @@ int Channel::handleDecodeCached(DecodeBuffer &decodeBuffer, ChannelCache *channe } else if ((T_store_action) action == IS_ADDED) { - if (control -> isProtoStep7() == 1) - { - store -> lastAdded = position; - } - else - { - decodeBuffer.decodePositionValueCompat(store -> lastAdded, - store -> lastAddedCacheCompat); - } + // Since ProtoStep7 (#issue 108) + store -> lastAdded = position; #ifdef DEBUG *logofs << "handleDecodeCached: " << store -> name() @@ -2037,12 +1941,10 @@ Split *Channel::handleSplitCommitRemove(int request, int resource, int position) << ".\n" << logofs_flush; #endif - if ((control -> isProtoStep7() == 1 && - (resource != split -> getResource() || - request != split -> getRequest() || - position != split -> getPosition())) || - (request != split -> getRequest() || - position != split -> getPosition())) + // Since ProtoStep7 (#issue 108) + if (resource != split -> getResource() || + request != split -> getRequest() || + position != split -> getPosition()) { #ifdef PANIC *logofs << "handleSplitCommitRemove: PANIC! The data in " diff --git a/nxcomp/ClientCache.cpp b/nxcomp/ClientCache.cpp index 2a82009a3..ec37c69f6 100644 --- a/nxcomp/ClientCache.cpp +++ b/nxcomp/ClientCache.cpp @@ -25,7 +25,6 @@ ClientCache::ClientCache() : changePropertyPropertyCache(16), changePropertyTypeCache(16), changePropertyData32Cache(16), - changePropertyTextCompressor(textCache, CLIENT_TEXT_CACHE_SIZE), configureWindowBitmaskCache(4), @@ -53,17 +52,11 @@ ClientCache::ClientCache() : imageTextLengthCache(8), imageTextLastX(0), imageTextLastY(0), imageTextCacheX(8), imageTextCacheY(8), - imageTextTextCompressor(textCache, CLIENT_TEXT_CACHE_SIZE), - - internAtomTextCompressor(textCache, CLIENT_TEXT_CACHE_SIZE), - - openFontTextCompressor(textCache, CLIENT_TEXT_CACHE_SIZE), polySegmentCacheX(8), polySegmentCacheY(8), polySegmentCacheIndex(0), polyTextLastX(0), polyTextLastY(0), polyTextCacheX(8), polyTextCacheY(8), polyTextFontCache(8), - polyTextTextCompressor(textCache, CLIENT_TEXT_CACHE_SIZE), putImageWidthCache(8), putImageHeightCache(8), putImageLastX(0), putImageLastY(0), putImageXCache(8), putImageYCache(8), diff --git a/nxcomp/ClientCache.h b/nxcomp/ClientCache.h index 6702e5b66..3fa59f642 100644 --- a/nxcomp/ClientCache.h +++ b/nxcomp/ClientCache.h @@ -85,7 +85,6 @@ class ClientCache : public ChannelCache IntCache changePropertyPropertyCache; IntCache changePropertyTypeCache; IntCache changePropertyData32Cache; - TextCompressor changePropertyTextCompressor; // // ClearArea request. @@ -188,19 +187,6 @@ class ClientCache : public ChannelCache unsigned int imageTextLastY; IntCache imageTextCacheX; IntCache imageTextCacheY; - TextCompressor imageTextTextCompressor; - - // - // InternAtom request. - // - - TextCompressor internAtomTextCompressor; - - // - // OpenFont request. - // - - TextCompressor openFontTextCompressor; // // PolyFillRectangle request. @@ -251,7 +237,6 @@ class ClientCache : public ChannelCache IntCache polyTextCacheY; IntCache polyTextFontCache; CharCache polyTextDeltaCache; - TextCompressor polyTextTextCompressor; // // PutImage request. diff --git a/nxcomp/ClientChannel.cpp b/nxcomp/ClientChannel.cpp index 31d6d125a..813e83bee 100644 --- a/nxcomp/ClientChannel.cpp +++ b/nxcomp/ClientChannel.cpp @@ -154,13 +154,6 @@ ClientChannel::ClientChannel(Transport *transport, StaticCompressor *compressor) splitState_.commit = 0; splitState_.mode = split_none; - // - // Disable image streaming if the remote - // doesn't support our proxy version. - // - - handleSplitEnable(); - // // Number of outstanding tainted replies. // @@ -342,10 +335,8 @@ int ClientChannel::handleRead(EncodeBuffer &encodeBuffer, const unsigned char *m // previous versions. // - if (control -> isProtoStep7() == 1) - { - encodeBuffer.encodeValue(inputLength, 8); - } + // Since ProtoStep7 (#issue 108) + encodeBuffer.encodeValue(inputLength, 8); for (unsigned int i = 0; i < inputLength; i++) { @@ -364,20 +355,6 @@ int ClientChannel::handleRead(EncodeBuffer &encodeBuffer, const unsigned char *m #endif priority_++; - - // - // Due to the way the loop was implemented - // we can't encode multiple messages if we - // are encoding the first request. - // - - if (control -> isProtoStep7() == 0) - { - if (proxy -> handleAsyncInit() < 0) - { - return -1; - } - } } else { @@ -512,17 +489,8 @@ int ClientChannel::handleRead(EncodeBuffer &encodeBuffer, const unsigned char *m const unsigned char *nextSrc = inputMessage + 24; if (format == 8) { - if (control -> isProtoStep7() == 1) - { - encodeBuffer.encodeTextData(nextSrc, dataLength); - } - else - { - clientCache_ -> changePropertyTextCompressor.reset(); - for (unsigned int i = 0; i < dataLength; i++) - clientCache_ -> changePropertyTextCompressor. - encodeChar(*nextSrc++, encodeBuffer); - } + // Since ProtoStep7 (#issue 108) + encodeBuffer.encodeTextData(nextSrc, dataLength); } else if (format == 32) { @@ -872,18 +840,11 @@ int ClientChannel::handleRead(EncodeBuffer &encodeBuffer, const unsigned char *m break; } - if (control -> isProtoStep7() == 1) - { - encodeBuffer.encodeNewXidValue(GetULONG(inputMessage + 4, bigEndian_), - clientCache_ -> lastId, clientCache_ -> lastIdCache, - clientCache_ -> gcCache, - clientCache_ -> freeGCCache); - } - else - { - encodeBuffer.encodeXidValue(GetULONG(inputMessage + 4, - bigEndian_), clientCache_ -> gcCache); - } + // Since ProtoStep7 (#issue 108) + encodeBuffer.encodeNewXidValue(GetULONG(inputMessage + 4, bigEndian_), + clientCache_ -> lastId, clientCache_ -> lastIdCache, + clientCache_ -> gcCache, + clientCache_ -> freeGCCache); const unsigned char *nextSrc = inputMessage + 8; encodeBuffer.encodeXidValue(GetULONG(inputMessage + 8, @@ -1059,18 +1020,12 @@ int ClientChannel::handleRead(EncodeBuffer &encodeBuffer, const unsigned char *m encodeBuffer.encodeXidValue(GetULONG(inputMessage + 8, bigEndian_), clientCache_ -> windowCache); - if (control -> isProtoStep7() == 1) - { - encodeBuffer.encodeNewXidValue(GetULONG(inputMessage + 4, bigEndian_), - clientCache_ -> lastId, clientCache_ -> lastIdCache, - clientCache_ -> windowCache, - clientCache_ -> freeWindowCache); - } - else - { - encodeBuffer.encodeXidValue(GetULONG(inputMessage + 4, bigEndian_), - clientCache_ -> windowCache); - } + // Since ProtoStep7 (#issue 108) + encodeBuffer.encodeNewXidValue(GetULONG(inputMessage + 4, bigEndian_), + clientCache_ -> lastId, clientCache_ -> lastIdCache, + clientCache_ -> windowCache, + clientCache_ -> freeWindowCache); + const unsigned char *nextSrc = inputMessage + 12; for (unsigned int i = 0; i < 6; i++) { @@ -1140,16 +1095,9 @@ int ClientChannel::handleRead(EncodeBuffer &encodeBuffer, const unsigned char *m unsigned int numPoints = ((inputLength - 16) >> 2); - if (control -> isProtoStep10() == 1) - { - encodeBuffer.encodeCachedValue(numPoints, 16, - clientCache_ -> fillPolyNumPointsCache, 4); - } - else - { - encodeBuffer.encodeCachedValue(numPoints, 14, - clientCache_ -> fillPolyNumPointsCache, 4); - } + // Since ProtoStep10 (#issue 108) + encodeBuffer.encodeCachedValue(numPoints, 16, + clientCache_ -> fillPolyNumPointsCache, 4); encodeBuffer.encodeXidValue(GetULONG(inputMessage + 4, bigEndian_), clientCache_ -> drawableCache); @@ -1270,16 +1218,9 @@ int ClientChannel::handleRead(EncodeBuffer &encodeBuffer, const unsigned char *m #endif - if (control -> isProtoStep7() == 1) - { - encodeBuffer.encodeFreeXidValue(GetULONG(inputMessage + 4, bigEndian_), - clientCache_ -> freeGCCache); - } - else - { - encodeBuffer.encodeXidValue(GetULONG(inputMessage + 4, bigEndian_), - clientCache_ -> gcCache); - } + // Since ProtoStep7 (#issue 108) + encodeBuffer.encodeFreeXidValue(GetULONG(inputMessage + 4, bigEndian_), + clientCache_ -> freeGCCache); } break; case X_FreePixmap: @@ -1294,26 +1235,9 @@ int ClientChannel::handleRead(EncodeBuffer &encodeBuffer, const unsigned char *m #endif - if (control -> isProtoStep7() == 1) - { - encodeBuffer.encodeFreeXidValue(GetULONG(inputMessage + 4, bigEndian_), - clientCache_ -> freeDrawableCache); - } - else - { - unsigned int pixmap = GetULONG(inputMessage + 4, bigEndian_); - unsigned int diff = pixmap - clientCache_ -> createPixmapLastId; - if (diff == 0) - { - encodeBuffer.encodeBoolValue(1); - } - else - { - encodeBuffer.encodeBoolValue(0); - clientCache_ -> createPixmapLastId = pixmap; - encodeBuffer.encodeValue(diff, 29, 4); - } - } + // Since ProtoStep7 (#issue 108) + encodeBuffer.encodeFreeXidValue(GetULONG(inputMessage + 4, bigEndian_), + clientCache_ -> freeDrawableCache); } break; case X_GetAtomName: @@ -1536,18 +1460,9 @@ int ClientChannel::handleRead(EncodeBuffer &encodeBuffer, const unsigned char *m encodeBuffer.encodeCachedValue(*nextSrc++, 8, clientCache_ -> polyTextDeltaCache); - if (control -> isProtoStep7() == 1) - { - encodeBuffer.encodeTextData(nextSrc, textLength); - - nextSrc += textLength; - } - else - { - clientCache_ -> polyTextTextCompressor.reset(); - for (unsigned int i = 0; i < textLength; i++) - clientCache_ -> polyTextTextCompressor.encodeChar(*nextSrc++, encodeBuffer); - } + // Since ProtoStep7 (#issue 108) + encodeBuffer.encodeTextData(nextSrc, textLength); + nextSrc += textLength; } } encodeBuffer.encodeBoolValue(0); @@ -1620,18 +1535,9 @@ int ClientChannel::handleRead(EncodeBuffer &encodeBuffer, const unsigned char *m encodeBuffer.encodeCachedValue(*nextSrc++, 8, clientCache_ -> polyTextDeltaCache); - if (control -> isProtoStep7() == 1) - { - encodeBuffer.encodeTextData(nextSrc, textLength * 2); - - nextSrc += textLength * 2; - } - else - { - clientCache_ -> polyTextTextCompressor.reset(); - for (unsigned int i = 0; i < textLength * 2; i++) - clientCache_ -> polyTextTextCompressor.encodeChar(*nextSrc++, encodeBuffer); - } + // Since ProtoStep7 (#issue 108) + encodeBuffer.encodeTextData(nextSrc, textLength * 2); + nextSrc += textLength * 2; } } encodeBuffer.encodeBoolValue(0); @@ -1692,16 +1598,8 @@ int ClientChannel::handleRead(EncodeBuffer &encodeBuffer, const unsigned char *m clientCache_ -> imageTextCacheY); const unsigned char *nextSrc = inputMessage + 16; - if (control -> isProtoStep7() == 1) - { - encodeBuffer.encodeTextData(nextSrc, textLength); - } - else - { - clientCache_ -> imageTextTextCompressor.reset(); - for (unsigned int j = 0; j < textLength; j++) - clientCache_ -> imageTextTextCompressor.encodeChar(*nextSrc++, encodeBuffer); - } + // Since ProtoStep7 (#issue 108) + encodeBuffer.encodeTextData(nextSrc, textLength); } break; case X_ImageText16: @@ -1759,16 +1657,8 @@ int ClientChannel::handleRead(EncodeBuffer &encodeBuffer, const unsigned char *m clientCache_ -> imageTextCacheY); const unsigned char *nextSrc = inputMessage + 16; - if (control -> isProtoStep7() == 1) - { - encodeBuffer.encodeTextData(nextSrc, textLength * 2); - } - else - { - clientCache_ -> imageTextTextCompressor.reset(); - for (unsigned int j = 0; j < textLength * 2; j++) - clientCache_ -> imageTextTextCompressor.encodeChar(*nextSrc++, encodeBuffer); - } + // Since ProtoStep7 (#issue 108) + encodeBuffer.encodeTextData(nextSrc, textLength * 2); } break; case X_InternAtom: @@ -1800,18 +1690,8 @@ int ClientChannel::handleRead(EncodeBuffer &encodeBuffer, const unsigned char *m encodeBuffer.encodeBoolValue((unsigned int) inputMessage[1]); const unsigned char *nextSrc = inputMessage + 8; - if (control -> isProtoStep7() == 1) - { - encodeBuffer.encodeTextData(nextSrc, nameLength); - } - else - { - clientCache_ -> internAtomTextCompressor.reset(); - for (unsigned int i = 0; i < nameLength; i++) - { - clientCache_ -> internAtomTextCompressor.encodeChar(*nextSrc++, encodeBuffer); - } - } + // Since ProtoStep7 (#issue 108) + encodeBuffer.encodeTextData(nextSrc, nameLength); sequenceQueue_.push(clientSequence_, inputOpcode); @@ -1832,18 +1712,8 @@ int ClientChannel::handleRead(EncodeBuffer &encodeBuffer, const unsigned char *m encodeBuffer.encodeValue(GetUINT(inputMessage + 4, bigEndian_), 16, 6); const unsigned char* nextSrc = inputMessage + 8; - if (control -> isProtoStep7() == 1) - { - encodeBuffer.encodeTextData(nextSrc, textLength); - } - else - { - clientCache_ -> polyTextTextCompressor.reset(); - for (unsigned int i = 0; i < textLength; i++) - { - clientCache_ -> polyTextTextCompressor.encodeChar(*nextSrc++, encodeBuffer); - } - } + // Since ProtoStep7 (#issue 108) + encodeBuffer.encodeTextData(nextSrc, textLength); sequenceQueue_.push(clientSequence_, inputOpcode); @@ -1859,18 +1729,8 @@ int ClientChannel::handleRead(EncodeBuffer &encodeBuffer, const unsigned char *m 29, clientCache_ -> colormapCache); const unsigned char *nextSrc = inputMessage + 12; - if (control -> isProtoStep7() == 1) - { - encodeBuffer.encodeTextData(nextSrc, textLength); - } - else - { - clientCache_ -> polyTextTextCompressor.reset(); - for (unsigned int i = 0; i < textLength; i++) - { - clientCache_ -> polyTextTextCompressor.encodeChar(*nextSrc++, encodeBuffer); - } - } + // Since ProtoStep7 (#issue 108) + encodeBuffer.encodeTextData(nextSrc, textLength); sequenceQueue_.push(clientSequence_, inputOpcode); @@ -1900,8 +1760,9 @@ int ClientChannel::handleRead(EncodeBuffer &encodeBuffer, const unsigned char *m #endif - if (inputOpcode == X_DestroyWindow && control -> isProtoStep7() == 1) + if (inputOpcode == X_DestroyWindow) { + // Since ProtoStep7 (#issue 108) encodeBuffer.encodeFreeXidValue(GetULONG(inputMessage + 4, bigEndian_), clientCache_ -> freeWindowCache); } @@ -1930,19 +1791,8 @@ int ClientChannel::handleRead(EncodeBuffer &encodeBuffer, const unsigned char *m clientCache_ -> lastFont = font; const unsigned char *nextSrc = inputMessage + 12; - if (control -> isProtoStep7() == 1) - { - encodeBuffer.encodeTextData(nextSrc, nameLength); - } - else - { - clientCache_ -> openFontTextCompressor.reset(); - for (; nameLength; nameLength--) - { - clientCache_ -> openFontTextCompressor. - encodeChar(*nextSrc++, encodeBuffer); - } - } + // Since ProtoStep7 (#issue 108) + encodeBuffer.encodeTextData(nextSrc, nameLength); } break; case X_PolyFillRectangle: @@ -2638,14 +2488,8 @@ int ClientChannel::handleRead(EncodeBuffer &encodeBuffer, const unsigned char *m unsigned int numRectangles = ((inputLength - 12) >> 3); - if (control -> isProtoStep9() == 1) - { - encodeBuffer.encodeValue(numRectangles, 15, 4); - } - else - { - encodeBuffer.encodeValue(numRectangles, 13, 4); - } + // Since ProtoStep9 (#issue 108) + encodeBuffer.encodeValue(numRectangles, 15, 4); encodeBuffer.encodeValue((unsigned int) inputMessage[1], 2); encodeBuffer.encodeXidValue(GetULONG(inputMessage + 4, bigEndian_), @@ -3544,19 +3388,8 @@ int ClientChannel::handleWrite(const unsigned char *message, unsigned int length PutUINT(nameLength, outputMessage + 8, bigEndian_); unsigned char* nextDest = outputMessage + 32; - if (control -> isProtoStep7() == 1) - { - decodeBuffer.decodeTextData(nextDest, nameLength); - } - else - { - serverCache_ -> getAtomNameTextCompressor.reset(); - for (unsigned int i = 0; i < nameLength; i++) - { - *nextDest++ = serverCache_ -> getAtomNameTextCompressor. - decodeChar(decodeBuffer); - } - } + // Since ProtoStep7 (#issue 108) + decodeBuffer.decodeTextData(nextDest, nameLength); } break; case X_GetGeometry: @@ -3814,21 +3647,9 @@ int ClientChannel::handleWrite(const unsigned char *message, unsigned int length decodeBuffer.decodeValue(length, 8); *nextDest++ = (unsigned char)length; - if (control -> isProtoStep7() == 1) - { - decodeBuffer.decodeTextData(nextDest, length); - - nextDest += length; - } - else - { - serverCache_ -> getPropertyTextCompressor.reset(); - for (; length; length--) - { - *nextDest++ = serverCache_ -> getPropertyTextCompressor. - decodeChar(decodeBuffer); - } - } + // Since ProtoStep7 (#issue 108) + decodeBuffer.decodeTextData(nextDest, length); + nextDest += length; } handleSave(messageStore, outputMessage, outputLength); @@ -4243,35 +4064,11 @@ int ClientChannel::handleWrite(const unsigned char *message, unsigned int length serverCache_ -> visualCache); PutULONG(visual, outputMessage + 8, bigEndian_); - if (control -> isProtoStep8() == 0) - { - const unsigned char *compressedData = NULL; - unsigned int compressedDataSize = 0; + // Since ProtoStep8 (#issue 108) + handleCopy(decodeBuffer, requestOpcode, messageStore -> + dataOffset, outputMessage, outputLength); - int decompressed = handleDecompress(decodeBuffer, requestOpcode, messageStore -> dataOffset, - outputMessage, outputLength, compressedData, - compressedDataSize); - if (decompressed < 0) - { - return -1; - } - else if (decompressed > 0) - { - handleSave(messageStore, outputMessage, outputLength, - compressedData, compressedDataSize); - } - else - { - handleSave(messageStore, outputMessage, outputLength); - } - } - else - { - handleCopy(decodeBuffer, requestOpcode, messageStore -> - dataOffset, outputMessage, outputLength); - - handleSave(messageStore, outputMessage, outputLength); - } + handleSave(messageStore, outputMessage, outputLength); } break; case X_GetPointerMapping: @@ -5090,40 +4887,23 @@ int ClientChannel::handleSplit(EncodeBuffer &encodeBuffer, MessageStore *store, { #if defined(TEST) || defined(SPLIT) - if (control -> isProtoStep8() == 1) - { - *logofs << "handleSplit: PANIC! SPLIT! Split should " - << "not be enabled for message " << "OPCODE#" - << (unsigned int) store -> opcode() << ".\n" - << logofs_flush; + // Since ProtoStep8 (#issue 108) + *logofs << "handleSplit: PANIC! SPLIT! Split should " + << "not be enabled for message " << "OPCODE#" + << (unsigned int) store -> opcode() << ".\n" + << logofs_flush; - HandleCleanup(); - } + HandleCleanup(); #endif // - // Never split the message if connected to - // an old proxy version. Also refuse the - // split if we it is not introduced by a - // start split. + // Refuse the split if it is not introduced + // by a start split. // - if (control -> isProtoStep7() == 0) - { - #if defined(TEST) || defined(SPLIT) - *logofs << "handleSplit: SPLIT! Ignoring the split with " - << "an old proxy version.\n" << logofs_flush; - #endif - - if (action == IS_ADDED || action == is_discarded) - { - encodeBuffer.encodeBoolValue(0); - } - - return 0; - } - else if (splitState_.resource == nothing || enableSplit_ == 0) + // Since ProtoStep7 (#issue 108) + if (splitState_.resource == nothing || enableSplit_ == 0) { #if defined(TEST) || defined(SPLIT) *logofs << "handleSplit: SPLIT! Nothing to do for message " @@ -5875,16 +5655,7 @@ int ClientChannel::handleSplitEvent(DecodeBuffer &decodeBuffer) << strMsTimestamp() << ".\n" << logofs_flush; #endif - if (control -> isProtoStep7() == 0) - { - #ifdef PANIC - *logofs << "handleSplitEvent: PANIC! The split can't " - << "be aborted when connected to an old " - << "proxy version.\n" << logofs_flush; - #endif - - HandleCleanup(); - } + // Since ProtoStep7 (#issue 108) // // Decode the information about the @@ -6512,146 +6283,6 @@ int ClientChannel::handleRestart(T_sequence_mode mode, int resource) return 1; } -int ClientChannel::handleTaintCacheRequest(unsigned char &opcode, const unsigned char *&buffer, - unsigned int &size) -{ - #ifdef TEST - *logofs << "handleTaintCacheRequest: Tainting cache request " - << "for FD#" << fd_ << ".\n" << logofs_flush; - #endif - - // - // The save and load flags would affect - // the decoding side but the decoding - // side doesn't support the request. - // - - enableCache_ = *(buffer + 4); - enableSplit_ = *(buffer + 5); - - handleSplitEnable(); - - #ifdef TEST - *logofs << "handleTaintCacheRequest: Set cache parameters to " - << "cache " << enableCache_ << " split " << enableSplit_ - << " load " << enableLoad_ << " save " << enableSave_ - << ".\n" << logofs_flush; - #endif - - // - // Taint the request to a X_NoOperation. - // - - opcode = X_NoOperation; - - return 0; -} - -int ClientChannel::handleTaintFontRequest(unsigned char &opcode, const unsigned char *&buffer, - unsigned int &size) -{ - // - // The remote end doesn't support this - // request so generate an empty reply - // at the local side. - // - - #ifdef TEST - *logofs << "handleTaintFontRequest: Suppressing font " - << "request for FD#" << fd_ << ".\n" - << logofs_flush; - #endif - - // - // The client sequence number has not - // been incremented yet in the loop. - // - - unsigned int sequence = (clientSequence_ + 1) & 0xffff; - - #ifdef TEST - *logofs << "handleTaintFontRequest: Opcode is " << (unsigned) opcode - << " expected client sequence is " << sequence - << ".\n" << logofs_flush; - #endif - - unsigned char *reply = writeBuffer_.addMessage(36); - - *(reply + 0) = X_Reply; - - PutUINT(sequence, reply + 2, bigEndian_); - - PutULONG(1, reply + 4, bigEndian_); - - // - // Set the length of the returned - // path to 0. - // - - *(reply + 32) = 0; - - // - // Save the sequence number, not incremented - // yet, we used to auto-generate this reply. - // - - lastSequence_ = clientSequence_ + 1; - - #ifdef TEST - *logofs << "handleTaintFontRequest: Registered " << lastSequence_ - << " as last auto-generated sequence number.\n" - << logofs_flush; - #endif - - // - // Taint the request to a X_NoOperation. - // - - opcode = X_NoOperation; - - if (handleFlush(flush_if_any) < 0) - { - return -1; - } - - return 1; -} - -int ClientChannel::handleTaintSplitRequest(unsigned char &opcode, const unsigned char *&buffer, - unsigned int &size) -{ - #ifdef TEST - - if (opcode == opcodeStore_ -> abortSplit) - { - *logofs << "handleTaintSplitRequest: Tainting abort split " - << "request for FD#" << fd_ << ".\n" - << logofs_flush; - } - else if (opcode == opcodeStore_ -> finishSplit) - { - *logofs << "handleTaintSplitRequest: Tainting finish split " - << "request for FD#" << fd_ << ".\n" - << logofs_flush; - } - else - { - *logofs << "handleTaintSplitRequest: Tainting free split " - << "request for FD#" << fd_ << ".\n" - << logofs_flush; - } - - #endif - - // - // Taint the request to a X_NoOperation. - // - - opcode = X_NoOperation; - - return 1; -} - int ClientChannel::handleTaintLameRequest(unsigned char &opcode, const unsigned char *&buffer, unsigned int &size) { @@ -7485,12 +7116,12 @@ int ClientChannel::handleFastReadRequest(EncodeBuffer &encodeBuffer, const unsig // All the NX requests are handled in the // main message loop. The X_PutImage can // be handled here only if the split was - // not requested. + // not requested (since ProtoStep7 #issue 108). // if ((opcode >= X_NXFirstOpcode && opcode <= X_NXLastOpcode) || - (control -> isProtoStep7() == 1 && opcode == X_PutImage && - splitState_.resource != nothing) || opcode == X_ListExtensions || + (opcode == X_PutImage && splitState_.resource != nothing) || + opcode == X_ListExtensions || opcode == X_QueryExtension) { return 0; @@ -7977,8 +7608,6 @@ int ClientChannel::handleCacheRequest(EncodeBuffer &encodeBuffer, const unsigned enableSave_ = *(buffer + 6); enableLoad_ = *(buffer + 7); - handleSplitEnable(); - #ifdef TEST *logofs << "handleCacheRequest: Set cache parameters to " << " cache " << enableCache_ << " split " << enableSplit_ @@ -8068,11 +7697,9 @@ int ClientChannel::handleStartSplitRequest(EncodeBuffer &encodeBuffer, const uns // Send the selected resource to the remote. // - if (control -> isProtoStep7() == 1) - { - encodeBuffer.encodeCachedValue(splitState_.resource, 8, - clientCache_ -> resourceCache); - } + // Since ProtoStep7 (#issue 108) + encodeBuffer.encodeCachedValue(splitState_.resource, 8, + clientCache_ -> resourceCache); splitState_.mode = (T_split_mode) *(buffer + 4); @@ -8157,11 +7784,9 @@ int ClientChannel::handleEndSplitRequest(EncodeBuffer &encodeBuffer, const unsig // Send the selected resource to the remote. // - if (control -> isProtoStep7() == 1) - { - encodeBuffer.encodeCachedValue(splitState_.resource, 8, - clientCache_ -> resourceCache); - } + // Since ProtoStep7 (#issue 108) + encodeBuffer.encodeCachedValue(splitState_.resource, 8, + clientCache_ -> resourceCache); // // Send the split notification events diff --git a/nxcomp/ClientChannel.h b/nxcomp/ClientChannel.h index 9924bb263..5ec55595c 100644 --- a/nxcomp/ClientChannel.h +++ b/nxcomp/ClientChannel.h @@ -158,23 +158,6 @@ class ClientChannel : public Channel int handleTaintRequest(unsigned char &opcode, const unsigned char *&buffer, unsigned int &size) { - if (control -> isProtoStep7() == 0) - { - if (opcode == X_NXFreeSplit || opcode == X_NXAbortSplit || - opcode == X_NXFinishSplit) - { - return handleTaintSplitRequest(opcode, buffer, size); - } - else if (opcode == X_NXSetCacheParameters) - { - return handleTaintCacheRequest(opcode, buffer, size); - } - else if (opcode == X_NXGetFontParameters) - { - return handleTaintFontRequest(opcode, buffer, size); - } - } - if (control -> TaintReplies > 0 && opcode == X_GetInputFocus) { @@ -190,15 +173,6 @@ class ClientChannel : public Channel return 0; } - int handleTaintCacheRequest(unsigned char &opcode, const unsigned char *&buffer, - unsigned int &size); - - int handleTaintFontRequest(unsigned char &opcode, const unsigned char *&buffer, - unsigned int &size); - - int handleTaintSplitRequest(unsigned char &opcode, const unsigned char *&buffer, - unsigned int &size); - int handleTaintLameRequest(unsigned char &opcode, const unsigned char *&buffer, unsigned int &size); @@ -261,20 +235,6 @@ class ClientChannel : public Channel int handleSplitChecksum(EncodeBuffer &encodeBuffer, T_checksum checksum); - void handleSplitEnable() - { - if (control -> isProtoStep7() == 0) - { - #if defined(TEST) || defined(SPLIT) - *logofs << "handleSplitEnable: WARNING! Disabling split " - << "with an old proxy version.\n" - << logofs_flush; - #endif - - enableSplit_ = 0; - } - } - void handleSplitPending(int resource) { if (splitState_.pending == 0) diff --git a/nxcomp/ClientProxy.h b/nxcomp/ClientProxy.h index 2b669ba2d..88d345f00 100644 --- a/nxcomp/ClientProxy.h +++ b/nxcomp/ClientProxy.h @@ -84,14 +84,8 @@ class ClientProxy : public Proxy virtual int checkLocalChannelMap(int channelId) { - if (control -> isProtoStep7() == 1) - { - return ((channelId & control -> ChannelMask) != 0); - } - else - { - return 1; - } + // Since ProtoStep7 (#issue 108) + return ((channelId & control -> ChannelMask) != 0); } // diff --git a/nxcomp/ClientStore.cpp b/nxcomp/ClientStore.cpp index be0e892b4..d56019258 100644 --- a/nxcomp/ClientStore.cpp +++ b/nxcomp/ClientStore.cpp @@ -54,11 +54,6 @@ #include "PutPackedImage.h" #include "GenericRequest.h" -#include "ChangeGCCompat.h" -#include "CreatePixmapCompat.h" -#include "SetUnpackColormapCompat.h" -#include "SetUnpackAlphaCompat.h" - // // Set the verbosity level. // @@ -111,20 +106,11 @@ ClientStore::ClientStore(StaticCompressor *compressor) requests_[X_NXSetUnpackGeometry] = new SetUnpackGeometryStore(compressor); requests_[X_NXPutPackedImage] = new PutPackedImageStore(compressor); - if (control -> isProtoStep7() == 1) - { - requests_[X_ChangeGC] = new ChangeGCStore(); - requests_[X_CreatePixmap] = new CreatePixmapStore(); - requests_[X_NXSetUnpackColormap] = new SetUnpackColormapStore(compressor); - requests_[X_NXSetUnpackAlpha] = new SetUnpackAlphaStore(compressor); - } - else - { - requests_[X_ChangeGC] = new ChangeGCCompatStore(); - requests_[X_CreatePixmap] = new CreatePixmapCompatStore(); - requests_[X_NXSetUnpackColormap] = new SetUnpackColormapCompatStore(compressor); - requests_[X_NXSetUnpackAlpha] = new SetUnpackAlphaCompatStore(compressor); - } + // Since ProtoStep7 (#issue 108) + requests_[X_ChangeGC] = new ChangeGCStore(); + requests_[X_CreatePixmap] = new CreatePixmapStore(); + requests_[X_NXSetUnpackColormap] = new SetUnpackColormapStore(compressor); + requests_[X_NXSetUnpackAlpha] = new SetUnpackAlphaStore(compressor); for (int i = 0; i < CHANNEL_STORE_RESOURCE_LIMIT; i++) { diff --git a/nxcomp/Control.cpp b/nxcomp/Control.cpp index 062654235..1bf2dbdd2 100644 --- a/nxcomp/Control.cpp +++ b/nxcomp/Control.cpp @@ -348,6 +348,14 @@ #define FILE_SIZE_CHECK_TIMEOUT 60000 +// +// Protocol version compatibility values +// + +const int Control::NX_MIN_PROTO_STEP = 10; +const int Control::NX_MAX_PROTO_STEP = 10; +const char* const Control::NXPROXY_COMPATIBILITY_VERSION = "3.5.0"; + // // Set defaults for control. They should be what // you get in case of 'local' connection. @@ -633,11 +641,7 @@ Control::Control() // time the session is negotiated. // - protoStep6_ = 0; - protoStep7_ = 0; - protoStep8_ = 0; - protoStep9_ = 0; - protoStep10_ = 0; + protoStep_ = 0; } Control::~Control() @@ -705,92 +709,27 @@ Control::~Control() void Control::setProtoStep(int step) { - switch (step) + if (isValidProtoStep(step)) { - case 6: - { - protoStep6_ = 1; - protoStep7_ = 0; - protoStep8_ = 0; - protoStep9_ = 0; - protoStep10_ = 0; - - break; - } - case 7: - { - protoStep6_ = 1; - protoStep7_ = 1; - protoStep8_ = 0; - protoStep9_ = 0; - protoStep10_ = 0; - - break; - } - case 8: - { - protoStep6_ = 1; - protoStep7_ = 1; - protoStep8_ = 1; - protoStep9_ = 0; - protoStep10_ = 0; - - break; - } - case 9: - { - protoStep6_ = 1; - protoStep7_ = 1; - protoStep8_ = 1; - protoStep9_ = 1; - protoStep10_ = 0; - - break; - } - case 10: - { - protoStep6_ = 1; - protoStep7_ = 1; - protoStep8_ = 1; - protoStep9_ = 1; - protoStep10_ = 1; - - break; - } - default: - { - #ifdef PANIC - *logofs << "Control: PANIC! Invalid protocol step " - << "with value " << step << ".\n" - << logofs_flush; - #endif - - HandleCleanup(); - } + protoStep_ = step; + } + else + { + #ifdef PANIC + *logofs << "Control: PANIC! Invalid protocol step " + << "with value " << step << ".\n" + << logofs_flush; + #endif + + HandleCleanup(); } } int Control::getProtoStep() { - if (protoStep10_ == 1) - { - return 10; - } - else if (protoStep9_ == 1) - { - return 9; - } - else if (protoStep8_ == 1) - { - return 8; - } - else if (protoStep7_ == 1) - { - return 7; - } - else if (protoStep6_ == 1) + if (isValidProtoStep(protoStep_)) { - return 6; + return protoStep_; } else { diff --git a/nxcomp/Control.h b/nxcomp/Control.h index 71f357c4a..b3552e091 100644 --- a/nxcomp/Control.h +++ b/nxcomp/Control.h @@ -320,6 +320,12 @@ class Control int CompatVersionPatch; int CompatVersionMaintenancePatch; + // + // Compatibility version for the proxy + // + + static const char* const NXPROXY_COMPATIBILITY_VERSION; + // // Which unpack methods are implemented in proxy? // @@ -713,26 +719,6 @@ class Control int getProtoStep(); - int isProtoStep7() - { - return protoStep7_; - } - - int isProtoStep8() - { - return protoStep8_; - } - - int isProtoStep9() - { - return protoStep9_; - } - - int isProtoStep10() - { - return protoStep10_; - } - private: // @@ -746,11 +732,25 @@ class Control // to the protocol version. // - int protoStep6_; - int protoStep7_; - int protoStep8_; - int protoStep9_; - int protoStep10_; + int protoStep_; + + // + // Min and max values allowed for protocol step + // depending on protocol version compatibility + // + + static const int NX_MIN_PROTO_STEP; + static const int NX_MAX_PROTO_STEP; + + // + // Check the validity of protocol step + // + + bool isValidProtoStep(int step) + { + return ((step >= NX_MIN_PROTO_STEP) && (step <= NX_MAX_PROTO_STEP)); + } + }; #endif /* Control_H */ diff --git a/nxcomp/CreateGC.cpp b/nxcomp/CreateGC.cpp index f1c10e69b..fab8bba10 100644 --- a/nxcomp/CreateGC.cpp +++ b/nxcomp/CreateGC.cpp @@ -146,39 +146,17 @@ void CreateGCStore::updateIdentity(EncodeBuffer &encodeBuffer, const Message *me ClientCache *clientCache = (ClientCache *) channelCache; - if (control -> isProtoStep7() == 1) - { - #ifdef TEST - *logofs << name() << ": Encoding value " << createGC -> gcontext - << " as gcontext field.\n" << logofs_flush; - #endif - - encodeBuffer.encodeNewXidValue(createGC -> gcontext, clientCache -> lastId, - clientCache -> lastIdCache, clientCache -> gcCache, - clientCache -> freeGCCache); - - cachedCreateGC -> gcontext = createGC -> gcontext; - } - else - { - #ifdef TEST - *logofs << name() << ": Encoding value " << createGC -> drawable - << " as drawable field.\n" << logofs_flush; - #endif - - encodeBuffer.encodeXidValue(createGC -> drawable, clientCache -> drawableCache); - - cachedCreateGC -> drawable = createGC -> drawable; - - #ifdef TEST - *logofs << name() << ": Encoding value " << createGC -> gcontext - << " as gcontext field.\n" << logofs_flush; - #endif + // Since ProtoStep7 (#issue 108) + #ifdef TEST + *logofs << name() << ": Encoding value " << createGC -> gcontext + << " as gcontext field.\n" << logofs_flush; + #endif - encodeBuffer.encodeXidValue(createGC -> gcontext, clientCache -> gcCache); + encodeBuffer.encodeNewXidValue(createGC -> gcontext, clientCache -> lastId, + clientCache -> lastIdCache, clientCache -> gcCache, + clientCache -> freeGCCache); - cachedCreateGC -> gcontext = createGC -> gcontext; - } + cachedCreateGC -> gcontext = createGC -> gcontext; } void CreateGCStore::updateIdentity(DecodeBuffer &decodeBuffer, const Message *message, @@ -190,37 +168,15 @@ void CreateGCStore::updateIdentity(DecodeBuffer &decodeBuffer, const Message *me unsigned int value; - if (control -> isProtoStep7() == 1) - { - decodeBuffer.decodeNewXidValue(value, clientCache -> lastId, - clientCache -> lastIdCache, clientCache -> gcCache, - clientCache -> freeGCCache); + // Since ProtoStep7 (#issue 108) + decodeBuffer.decodeNewXidValue(value, clientCache -> lastId, + clientCache -> lastIdCache, clientCache -> gcCache, + clientCache -> freeGCCache); - createGC -> gcontext = value; + createGC -> gcontext = value; - #ifdef TEST - *logofs << name() << ": Decoded value " << createGC -> gcontext - << " as gcontext field.\n" << logofs_flush; - #endif - } - else - { - decodeBuffer.decodeXidValue(value, clientCache -> drawableCache); - - createGC -> drawable = value; - - #ifdef TEST - *logofs << name() << ": Decoded value " << createGC -> drawable - << " as drawable field.\n" << logofs_flush; - #endif - - decodeBuffer.decodeXidValue(value, clientCache -> gcCache); - - createGC -> gcontext = value; - - #ifdef TEST - *logofs << name() << ": Decoded value " << createGC -> gcontext - << " as gcontext field.\n" << logofs_flush; - #endif - } + #ifdef TEST + *logofs << name() << ": Decoded value " << createGC -> gcontext + << " as gcontext field.\n" << logofs_flush; + #endif } diff --git a/nxcomp/DecodeBuffer.cpp b/nxcomp/DecodeBuffer.cpp index 077bfdfc0..28c656cb2 100644 --- a/nxcomp/DecodeBuffer.cpp +++ b/nxcomp/DecodeBuffer.cpp @@ -34,10 +34,8 @@ DecodeBuffer::DecodeBuffer(const unsigned char *data, unsigned int length) : buffer_(data), end_(buffer_ + length), nextSrc_(buffer_), srcMask_(0x80) { - if (control -> isProtoStep7() == 1) - { - end_ = buffer_ + length - DECODE_BUFFER_POSTFIX_SIZE; - } + // Since ProtoStep7 (#issue 108) + end_ = buffer_ + length - DECODE_BUFFER_POSTFIX_SIZE; } int DecodeBuffer::decodeValue(unsigned int &value, unsigned int numBits, @@ -277,63 +275,25 @@ int DecodeBuffer::decodeCachedValue(unsigned int &value, unsigned int numBits, if (index == 2) { - if (control -> isProtoStep8() == 1) - { - blockSize = cache.getBlockSize(blockSize); - - if (decodeValue(value, numBits, blockSize, endOkay)) - { - cache.insert(value, IntMask[numBits]); - - return 1; - } + // Since ProtoStep8 (#issue 108) + blockSize = cache.getBlockSize(blockSize); - #ifdef PANIC - *logofs << "DecodeBuffer: PANIC! Assertion failed. Error [H] " - << "in decodeCacheValue() with no value found.\n" - << logofs_flush; - #endif - - cerr << "Error" << ": Failure decoding data in context [H].\n"; - - HandleAbort(); - } - else + if (decodeValue(value, numBits, blockSize, endOkay)) { - unsigned int sameDiff; - - decodeBoolValue(sameDiff); - - if (sameDiff) - { - value = cache.getLastDiff(IntMask[numBits]); + cache.insert(value, IntMask[numBits]); - cache.insert(value, IntMask[numBits]); - - return 1; - } - else - { - blockSize = cache.getBlockSize(blockSize); - - if (decodeValue(value, numBits, blockSize, endOkay)) - { - cache.insert(value, IntMask[numBits]); - - return 1; - } + return 1; + } - #ifdef PANIC - *logofs << "DecodeBuffer: PANIC! Assertion failed. Error [H] " - << "in decodeCacheValue() with no value found.\n" - << logofs_flush; - #endif + #ifdef PANIC + *logofs << "DecodeBuffer: PANIC! Assertion failed. Error [H] " + << "in decodeCacheValue() with no value found.\n" + << logofs_flush; + #endif - cerr << "Error" << ": Failure decoding data in context [H].\n"; + cerr << "Error" << ": Failure decoding data in context [H].\n"; - HandleAbort(); - } - } + HandleAbort(); } else { @@ -665,28 +625,3 @@ void DecodeBuffer::decodeFreeXidValue(unsigned int &value, FreeCache &cache) decodeCachedValue(value, 29, cache); } -void DecodeBuffer::decodePositionValueCompat(short int &value, PositionCacheCompat &cache) -{ - unsigned int t; - - decodeCachedValue(t, 13, *(cache.base_[cache.slot_])); - - cache.last_ += t; - cache.last_ &= 0x1fff; - - value = cache.last_; - - #ifdef DEBUG - *logofs << "DecodeBuffer: Decoded position " - << value << " with base " << cache.slot_ - << ".\n" << logofs_flush; - #endif - - #ifdef DEBUG - *logofs << "DecodeBuffer: Position block prediction is " - << (*(cache.base_[cache.slot_])).getBlockSize(13) - << ".\n" << logofs_flush; - #endif - - cache.slot_ = (value & 0x1f); -} diff --git a/nxcomp/DecodeBuffer.h b/nxcomp/DecodeBuffer.h index 9345f4e23..98f7bf35f 100644 --- a/nxcomp/DecodeBuffer.h +++ b/nxcomp/DecodeBuffer.h @@ -27,9 +27,6 @@ #include "OpcodeCache.h" #include "ActionCache.h" -#include "ActionCacheCompat.h" -#include "PositionCacheCompat.h" - #define DECODE_BUFFER_OVERFLOW_SIZE 4194304 #define DECODE_BUFFER_POSTFIX_SIZE 1 @@ -99,15 +96,6 @@ class DecodeBuffer void decodeFreeXidValue(unsigned int &value, FreeCache &cache); - void decodeActionValueCompat(unsigned char &value, ActionCacheCompat &cache) - { - decodeCachedValue(value, 2, cache.base_[cache.slot_]); - - cache.slot_ = value; - } - - void decodePositionValueCompat(short int &value, PositionCacheCompat &cache); - void decodeTextData(unsigned char *buffer, unsigned int numBytes) { decodeMemory(buffer, numBytes); diff --git a/nxcomp/EncodeBuffer.cpp b/nxcomp/EncodeBuffer.cpp index 12a57180e..afcf60a9e 100644 --- a/nxcomp/EncodeBuffer.cpp +++ b/nxcomp/EncodeBuffer.cpp @@ -261,47 +261,14 @@ void EncodeBuffer::encodeCachedValue(unsigned int value, unsigned int numBits, // Avoid to encode the additional bool. // - if (control -> isProtoStep8() == 1) - { - #ifdef DUMP - *logofs << "EncodeBuffer: Encoded missed int using " - << diffBits() << " bits out of " << numBits - << ".\n" << logofs_flush; - #endif - - encodeValue(value, numBits, blockSize); - } - else - { - if (sameDiff) - { - #ifdef DUMP - *logofs << "EncodeBuffer: Matched difference with block size " - << cache.getBlockSize(blockSize) << ".\n" - << logofs_flush; - #endif - - encodeBoolValue(1); - } - else - { - #ifdef DUMP - *logofs << "EncodeBuffer: Missed difference with block size " - << cache.getBlockSize(blockSize) << ".\n" - << logofs_flush; - #endif - - encodeBoolValue(0); - - encodeValue(value, numBits, blockSize); - } + // Since ProtoStep8 (#issue 108) + #ifdef DUMP + *logofs << "EncodeBuffer: Encoded missed int using " + << diffBits() << " bits out of " << numBits + << ".\n" << logofs_flush; + #endif - #ifdef DUMP - *logofs << "EncodeBuffer: Encoded missed int using " - << diffBits() << " bits out of " << numBits - << ".\n" << logofs_flush; - #endif - } + encodeValue(value, numBits, blockSize); } } @@ -454,7 +421,8 @@ unsigned int EncodeBuffer::getLength() const length++; } - if (length > 0 && control -> isProtoStep7() == 1) + // Since ProtoStep7 (#issue 108) + if (length > 0) { return length + ENCODE_BUFFER_POSTFIX_SIZE; } @@ -641,20 +609,3 @@ void EncodeBuffer::encodeFreeXidValue(unsigned int value, FreeCache &cache) { encodeCachedValue(value, 29, cache); } - -void EncodeBuffer::encodePositionValueCompat(short int value, PositionCacheCompat &cache) -{ - unsigned int t = (value - cache.last_); - - encodeCachedValue(t, 13, *(cache.base_[cache.slot_])); - - cache.last_ = value; - - #ifdef DEBUG - *logofs << "EncodeBuffer: Encoded position " - << value << " with base " << cache.slot_ - << ".\n" << logofs_flush; - #endif - - cache.slot_ = (value & 0x1f); -} diff --git a/nxcomp/EncodeBuffer.h b/nxcomp/EncodeBuffer.h index 9f5ac5352..c7ee0a3b0 100644 --- a/nxcomp/EncodeBuffer.h +++ b/nxcomp/EncodeBuffer.h @@ -25,9 +25,6 @@ #include "OpcodeCache.h" #include "ActionCache.h" -#include "ActionCacheCompat.h" -#include "PositionCacheCompat.h" - #define ENCODE_BUFFER_DEFAULT_SIZE 16384 // @@ -117,15 +114,6 @@ class EncodeBuffer void encodeFreeXidValue(unsigned int value, FreeCache &cache); - void encodeActionValueCompat(unsigned char value, ActionCacheCompat &cache) - { - encodeCachedValue(value, 2, cache.base_[cache.slot_]); - - cache.slot_ = value; - } - - void encodePositionValueCompat(short int value, PositionCacheCompat &cache); - void encodeTextData(const unsigned char *buffer, unsigned int numBytes) { encodeMemory(buffer, numBytes); diff --git a/nxcomp/FillPoly.cpp b/nxcomp/FillPoly.cpp index 37df3772b..291cc2a4b 100644 --- a/nxcomp/FillPoly.cpp +++ b/nxcomp/FillPoly.cpp @@ -51,8 +51,8 @@ int FillPolyStore::parseIdentity(Message *message, const unsigned char *buffer, fillPoly -> shape = *(buffer + 12); fillPoly -> mode = *(buffer + 13); - if (control -> isProtoStep8() == 1 && - size >= (unsigned int) dataOffset) + // Since ProtoStep8 (#issue 108) + if (size >= (unsigned int) dataOffset) { fillPoly -> x_origin = GetUINT(buffer + 16, bigEndian); fillPoly -> y_origin = GetUINT(buffer + 18, bigEndian); @@ -85,8 +85,8 @@ int FillPolyStore::unparseIdentity(const Message *message, unsigned char *buffer *(buffer + 12) = fillPoly -> shape; *(buffer + 13) = fillPoly -> mode; - if (control -> isProtoStep8() == 1 && - size >= (unsigned int) dataOffset) + // Since ProtoStep8 (#issue 108) + if (size >= (unsigned int) dataOffset) { PutUINT(fillPoly -> x_origin, buffer + 16, bigEndian); PutUINT(fillPoly -> y_origin, buffer + 18, bigEndian); @@ -151,8 +151,8 @@ void FillPolyStore::updateIdentity(EncodeBuffer &encodeBuffer, const Message *me cachedFillPoly -> gcontext = fillPoly -> gcontext; - if (control -> isProtoStep8() == 1 && - fillPoly -> size_ >= dataOffset) + // Since ProtoStep8 (#issue 108) + if (fillPoly -> size_ >= dataOffset) { #ifdef TEST *logofs << name() << ": Encoding value " << fillPoly -> x_origin @@ -197,8 +197,8 @@ void FillPolyStore::updateIdentity(DecodeBuffer &decodeBuffer, const Message *me << " as gcontext field.\n" << logofs_flush; #endif - if (control -> isProtoStep8() == 1 && - fillPoly -> size_ >= dataOffset) + // Since ProtoStep8 (#issue 108) + if (fillPoly -> size_ >= dataOffset) { unsigned int value; diff --git a/nxcomp/FillPoly.h b/nxcomp/FillPoly.h index f33968494..d926b6dee 100644 --- a/nxcomp/FillPoly.h +++ b/nxcomp/FillPoly.h @@ -40,7 +40,6 @@ #define FILLPOLY_ENABLE_COMPRESS 0 #define FILLPOLY_DATA_LIMIT 512 -#define FILLPOLY_DATA_OFFSET 16 #define FILLPOLY_CACHE_SLOTS 2000 #define FILLPOLY_CACHE_THRESHOLD 3 @@ -98,12 +97,9 @@ class FillPolyStore : public MessageStore enableCompress = FILLPOLY_ENABLE_COMPRESS; dataLimit = FILLPOLY_DATA_LIMIT; - dataOffset = FILLPOLY_DATA_OFFSET; - if (control -> isProtoStep8() == 1) - { - dataOffset = FILLPOLY_DATA_OFFSET_IF_PROTO_STEP_8; - } + // Since ProtoStep8 (#issue 108) + dataOffset = FILLPOLY_DATA_OFFSET_IF_PROTO_STEP_8; cacheSlots = FILLPOLY_CACHE_SLOTS; cacheThreshold = FILLPOLY_CACHE_THRESHOLD; @@ -169,11 +165,9 @@ class FillPolyStore : public MessageStore virtual int identitySize(const unsigned char *buffer, unsigned int size) { - unsigned int offset = (control -> isProtoStep8() == 1 ? - FILLPOLY_DATA_OFFSET_IF_PROTO_STEP_8 : - FILLPOLY_DATA_OFFSET); - - return (size >= offset ? offset : size); + // Since ProtoStep8 (#issue 108) + return (size >= FILLPOLY_DATA_OFFSET_IF_PROTO_STEP_8 ? + FILLPOLY_DATA_OFFSET_IF_PROTO_STEP_8 : size); } virtual int parseIdentity(Message *message, const unsigned char *buffer, diff --git a/nxcomp/GenericChannel.h b/nxcomp/GenericChannel.h index ba4f1e7e8..10ae794bb 100644 --- a/nxcomp/GenericChannel.h +++ b/nxcomp/GenericChannel.h @@ -209,11 +209,7 @@ class CupsChannel : public GenericChannel virtual int isCompressed() { - if (control -> isProtoStep8() == 0) - { - return 1; - } - + // Since ProtoStep8 (#issue 108) return 0; } @@ -252,11 +248,7 @@ class SmbChannel : public GenericChannel virtual int isCompressed() { - if (control -> isProtoStep8() == 0) - { - return 1; - } - + // Since ProtoStep8 (#issue 108) return 0; } @@ -344,11 +336,7 @@ class HttpChannel : public GenericChannel virtual int isCompressed() { - if (control -> isProtoStep8() == 0) - { - return 1; - } - + // Since ProtoStep8 (#issue 108) return 0; } @@ -387,11 +375,7 @@ class FontChannel : public GenericChannel virtual int isCompressed() { - if (control -> isProtoStep8() == 0) - { - return 1; - } - + // Since ProtoStep8 (#issue 108) return 0; } diff --git a/nxcomp/GenericReply.cpp b/nxcomp/GenericReply.cpp index 9daccc566..f7ffe83dd 100644 --- a/nxcomp/GenericReply.cpp +++ b/nxcomp/GenericReply.cpp @@ -45,12 +45,9 @@ GenericReplyStore::GenericReplyStore(StaticCompressor *compressor) enableCache = GENERICREPLY_ENABLE_CACHE; enableData = GENERICREPLY_ENABLE_DATA; enableSplit = GENERICREPLY_ENABLE_SPLIT; - enableCompress = GENERICREPLY_ENABLE_COMPRESS; - if (control -> isProtoStep7() == 1) - { - enableCompress = GENERICREPLY_ENABLE_COMPRESS_IF_PROTO_STEP_7; - } + // Since ProtoStep7 (#issue 108) + enableCompress = GENERICREPLY_ENABLE_COMPRESS_IF_PROTO_STEP_7; dataLimit = GENERICREPLY_DATA_LIMIT; dataOffset = GENERICREPLY_DATA_OFFSET; diff --git a/nxcomp/GenericReply.h b/nxcomp/GenericReply.h index de97b86d0..20786a8d2 100644 --- a/nxcomp/GenericReply.h +++ b/nxcomp/GenericReply.h @@ -37,7 +37,6 @@ #define GENERICREPLY_ENABLE_CACHE 1 #define GENERICREPLY_ENABLE_DATA 1 #define GENERICREPLY_ENABLE_SPLIT 0 -#define GENERICREPLY_ENABLE_COMPRESS 1 #define GENERICREPLY_DATA_LIMIT 1048576 - 32 #define GENERICREPLY_DATA_OFFSET 32 diff --git a/nxcomp/GenericRequest.cpp b/nxcomp/GenericRequest.cpp index 40077291b..fa34b89d2 100644 --- a/nxcomp/GenericRequest.cpp +++ b/nxcomp/GenericRequest.cpp @@ -45,14 +45,9 @@ GenericRequestStore::GenericRequestStore(StaticCompressor *compressor) enableCache = GENERICREQUEST_ENABLE_CACHE; enableData = GENERICREQUEST_ENABLE_DATA; enableSplit = GENERICREQUEST_ENABLE_SPLIT; - enableCompress = GENERICREQUEST_ENABLE_COMPRESS; - if (control -> isProtoStep7() == 1) - { - enableCompress = GENERICREQUEST_ENABLE_COMPRESS_IF_PROTO_STEP_7; - - enableCompress = 0; - } + // Since ProtoStep7 (#issue 108) + enableCompress = GENERICREQUEST_ENABLE_COMPRESS_IF_PROTO_STEP_7; dataLimit = GENERICREQUEST_DATA_LIMIT; dataOffset = GENERICREQUEST_DATA_OFFSET; diff --git a/nxcomp/GenericRequest.h b/nxcomp/GenericRequest.h index 3175fc2ba..4f164523e 100644 --- a/nxcomp/GenericRequest.h +++ b/nxcomp/GenericRequest.h @@ -37,7 +37,6 @@ #define GENERICREQUEST_ENABLE_CACHE 1 #define GENERICREQUEST_ENABLE_DATA 1 #define GENERICREQUEST_ENABLE_SPLIT 0 -#define GENERICREQUEST_ENABLE_COMPRESS 1 #define GENERICREQUEST_DATA_LIMIT 262144 - 20 #define GENERICREQUEST_DATA_OFFSET 20 diff --git a/nxcomp/GetImageReply.cpp b/nxcomp/GetImageReply.cpp index d4bc21b5a..bea3ee84d 100644 --- a/nxcomp/GetImageReply.cpp +++ b/nxcomp/GetImageReply.cpp @@ -43,12 +43,9 @@ GetImageReplyStore::GetImageReplyStore(StaticCompressor *compressor) enableCache = GETIMAGEREPLY_ENABLE_CACHE; enableData = GETIMAGEREPLY_ENABLE_DATA; enableSplit = GETIMAGEREPLY_ENABLE_SPLIT; - enableCompress = GETIMAGEREPLY_ENABLE_COMPRESS; - if (control -> isProtoStep7() == 1) - { - enableCompress = GETIMAGEREPLY_ENABLE_COMPRESS_IF_PROTO_STEP_7; - } + // Since ProtoStep7 (#issue 108) + enableCompress = GETIMAGEREPLY_ENABLE_COMPRESS_IF_PROTO_STEP_7; dataLimit = GETIMAGEREPLY_DATA_LIMIT; dataOffset = GETIMAGEREPLY_DATA_OFFSET; diff --git a/nxcomp/GetImageReply.h b/nxcomp/GetImageReply.h index ee7b0bfa3..0fd152122 100644 --- a/nxcomp/GetImageReply.h +++ b/nxcomp/GetImageReply.h @@ -37,7 +37,6 @@ #define GETIMAGEREPLY_ENABLE_CACHE 1 #define GETIMAGEREPLY_ENABLE_DATA 1 #define GETIMAGEREPLY_ENABLE_SPLIT 0 -#define GETIMAGEREPLY_ENABLE_COMPRESS 1 #define GETIMAGEREPLY_DATA_LIMIT 1048576 - 32 #define GETIMAGEREPLY_DATA_OFFSET 32 diff --git a/nxcomp/GetPropertyReply.cpp b/nxcomp/GetPropertyReply.cpp index 223131803..4a906e70a 100644 --- a/nxcomp/GetPropertyReply.cpp +++ b/nxcomp/GetPropertyReply.cpp @@ -45,12 +45,9 @@ GetPropertyReplyStore::GetPropertyReplyStore(StaticCompressor *compressor) enableCache = GETPROPERTYREPLY_ENABLE_CACHE; enableData = GETPROPERTYREPLY_ENABLE_DATA; enableSplit = GETPROPERTYREPLY_ENABLE_SPLIT; - enableCompress = GETPROPERTYREPLY_ENABLE_COMPRESS; - if (control -> isProtoStep7() == 1) - { - enableCompress = GETPROPERTYREPLY_ENABLE_COMPRESS_IF_PROTO_STEP_7; - } + // Since ProtoStep7 (#issue 108) + enableCompress = GETPROPERTYREPLY_ENABLE_COMPRESS_IF_PROTO_STEP_7; dataLimit = GETPROPERTYREPLY_DATA_LIMIT; dataOffset = GETPROPERTYREPLY_DATA_OFFSET; diff --git a/nxcomp/GetPropertyReply.h b/nxcomp/GetPropertyReply.h index 0f6b19508..f8d53ba0f 100644 --- a/nxcomp/GetPropertyReply.h +++ b/nxcomp/GetPropertyReply.h @@ -37,7 +37,6 @@ #define GETPROPERTYREPLY_ENABLE_CACHE 1 #define GETPROPERTYREPLY_ENABLE_DATA 1 #define GETPROPERTYREPLY_ENABLE_SPLIT 0 -#define GETPROPERTYREPLY_ENABLE_COMPRESS 1 #define GETPROPERTYREPLY_DATA_LIMIT 1048576 - 32 #define GETPROPERTYREPLY_DATA_OFFSET 32 diff --git a/nxcomp/ListFontsReply.cpp b/nxcomp/ListFontsReply.cpp index 5bace82f2..84acaba25 100644 --- a/nxcomp/ListFontsReply.cpp +++ b/nxcomp/ListFontsReply.cpp @@ -39,12 +39,9 @@ ListFontsReplyStore::ListFontsReplyStore(StaticCompressor *compressor) enableCache = LISTFONTSREPLY_ENABLE_CACHE; enableData = LISTFONTSREPLY_ENABLE_DATA; enableSplit = LISTFONTSREPLY_ENABLE_SPLIT; - enableCompress = LISTFONTSREPLY_ENABLE_COMPRESS; - if (control -> isProtoStep7() == 1) - { - enableCompress = LISTFONTSREPLY_ENABLE_COMPRESS_IF_PROTO_STEP_7; - } + // Since ProtoStep7 (#issue 108) + enableCompress = LISTFONTSREPLY_ENABLE_COMPRESS_IF_PROTO_STEP_7; dataLimit = LISTFONTSREPLY_DATA_LIMIT; dataOffset = LISTFONTSREPLY_DATA_OFFSET; diff --git a/nxcomp/ListFontsReply.h b/nxcomp/ListFontsReply.h index 078fd7ebc..549b7d1c1 100644 --- a/nxcomp/ListFontsReply.h +++ b/nxcomp/ListFontsReply.h @@ -37,7 +37,6 @@ #define LISTFONTSREPLY_ENABLE_CACHE 1 #define LISTFONTSREPLY_ENABLE_DATA 1 #define LISTFONTSREPLY_ENABLE_SPLIT 0 -#define LISTFONTSREPLY_ENABLE_COMPRESS 1 #define LISTFONTSREPLY_DATA_LIMIT 1048576 - 32 #define LISTFONTSREPLY_DATA_OFFSET 32 diff --git a/nxcomp/Loop.cpp b/nxcomp/Loop.cpp index 79d753dea..0f9fec6ef 100644 --- a/nxcomp/Loop.cpp +++ b/nxcomp/Loop.cpp @@ -4466,32 +4466,16 @@ int SetupServiceSockets() else { // - // Disable the font server connections if - // they are not supported by the remote - // proxy. + // Get ready to listen for the font server connections // if (useFontSocket) { - if (control -> isProtoStep7() == 1) - { - int port = atoi(fontPort); + // Since ProtoStep7 (#issue 108) + int port = atoi(fontPort); - if ((fontFD = ListenConnection(port, "font")) < 0) - { - useFontSocket = 0; - } - } - else + if ((fontFD = ListenConnection(port, "font")) < 0) { - #ifdef WARNING - *logofs << "Loop: WARNING! Font server connections not supported " - << "by the remote proxy.\n" << logofs_flush; - #endif - - cerr << "Warning" << ": Font server connections not supported " - << "by the remote proxy.\n"; - useFontSocket = 0; } } @@ -4510,23 +4494,9 @@ int SetupServiceSockets() if (useSlaveSocket) { - if (control -> isProtoStep7() == 1) - { - if ((slaveFD = ListenConnection(slavePort, "slave")) < 0) - { - useSlaveSocket = 0; - } - } - else + // Since ProtoStep7 (#issue 108) + if ((slaveFD = ListenConnection(slavePort, "slave")) < 0) { - #ifdef WARNING - *logofs << "Loop: WARNING! Slave connections not supported " - << "by the remote proxy.\n" << logofs_flush; - #endif - - cerr << "Warning" << ": Slave connections not supported " - << "by the remote proxy.\n"; - useSlaveSocket = 0; } } @@ -7226,8 +7196,11 @@ int SendProxyOptions(int fd) // value and ignore the second. // - sprintf(options, "NXPROXY-1.5.0-%i.%i.%i", control -> LocalVersionMajor, - control -> LocalVersionMinor, control -> LocalVersionPatch); + sprintf(options, "NXPROXY-%s-%i.%i.%i", + control -> NXPROXY_COMPATIBILITY_VERSION, + control -> LocalVersionMajor, + control -> LocalVersionMinor, + control -> LocalVersionPatch); // // If you want to send options from proxy @@ -7306,8 +7279,8 @@ int SendProxyOptions(int fd) // Add the 'strict' option, if needed. // - if (control -> isProtoStep7() == 1 && - useStrict != -1) + // Since ProtoStep7 (#issue 108) + if (useStrict != -1) { sprintf(options + strlen(options), "strict=%d,", useStrict); } @@ -7317,8 +7290,8 @@ int SendProxyOptions(int fd) // memory segment. // - if (control -> isProtoStep7() == 1 && - *shsegSizeName != '\0') + // Since ProtoStep7 (#issue 108) + if (*shsegSizeName != '\0') { sprintf(options + strlen(options), "shseg=%s,", shsegSizeName); } @@ -12064,9 +12037,12 @@ int SetSession() // to the agent. // - if (*sessionType != '\0' && - (control -> isProtoStep8() == 1 || - strncmp(sessionType, "unix-", strlen("unix-")) != 0)) + // + // Since ProtoStep8 (#issue 108) and also + // with older "unix-" sessions + // + + if (*sessionType != '\0') { #ifdef WARNING *logofs << "Loop: WARNING! Unrecognized session type '" @@ -12599,37 +12575,18 @@ int SetVersion() } // - // Handle the 1.5.0 versions. The protocol - // step 6 is the minimum supported version. + // Handle versions from 3.5.0. The protocol + // step 10 is the minimum supported version. // int step = 0; - if (major == 1) - { - if (minor == 5) - { - step = 6; - } - } - else if (major == 2) - { - step = 7; - } - else if (major == 3) + if (major == 3) { - if (minor >= 2) + if (minor >= 5) { step = 10; } - else if (minor > 0 || patch > 0) - { - step = 9; - } - else - { - step = 8; - } } else if (major > 3) { @@ -12638,6 +12595,16 @@ int SetVersion() if (step == 0) { + #ifdef PANIC + *logofs << "Loop: PANIC! Unable to set the protocol step value from " + << "the negotiated protocol version " << major << "." << minor + << "." << patch << ".\n" << logofs_flush; + #endif + + cerr << "Error" << ": Unable to set the protocol step value from " + << "the negotiated protocol version " << major << "." << minor + << "." << patch << ".\n"; + #ifdef PANIC *logofs << "Loop: PANIC! Incompatible remote version " << control -> RemoteVersionMajor << "." << control -> RemoteVersionMinor @@ -12702,97 +12669,21 @@ int SetVersion() if (control -> ProxyMode == proxy_client) { - if (control -> isProtoStep8() == 0) - { - if (strncmp(sessionType, "shadow", strlen("shadow")) == 0 || - strncmp(sessionType, "application", strlen("application")) == 0 || - strncmp(sessionType, "console", strlen("console")) == 0 || - strncmp(sessionType, "default", strlen("default")) == 0 || - strncmp(sessionType, "gnome", strlen("gnome")) == 0 || - strncmp(sessionType, "kde", strlen("kde")) == 0 || - strncmp(sessionType, "cde", strlen("cde")) == 0 || - strncmp(sessionType, "xdm", strlen("xdm")) == 0) - - { - #if defined(TEST) || defined(INFO) - *logofs << "Loop: WARNING! Prepending 'unix-' to the " - << "name of the session.\n" << logofs_flush; - #endif - - char buffer[DEFAULT_STRING_LENGTH]; - - snprintf(buffer, DEFAULT_STRING_LENGTH - 1, "unix-%s", sessionType); - - strcpy(sessionType, buffer); - } - } - // - // Check if the remote is able to handle - // the selected pack method. + // Since ProtoStep8 (#issue 108) // - - if (control -> isProtoStep8() == 0) - { - if (packMethod == PACK_ADAPTIVE || packMethod == PACK_LOSSY) - { - #ifdef TEST - *logofs << "Loop: WARNING! Assuming a lossy encoding with " - << "an old proxy version.\n" << logofs_flush; - #endif - - packMethod = PACK_JPEG_16M_COLORS; - } - else if (packMethod == PACK_LOSSLESS) - { - #ifdef TEST - *logofs << "Loop: WARNING! Assuming a lossless encoding with " - << "an old proxy version.\n" << logofs_flush; - #endif - - if (control -> isProtoStep7() == 1) - { - packMethod = PACK_RLE_16M_COLORS; - } - else - { - packMethod = PACK_PNG_16M_COLORS; - } - } - } - - // - // If the remote doesn't support the - // selected method use something that - // is compatible. + // Now it's assumed that the remote is + // able to handle the selected pack + // method // - if ((packMethod == PACK_RGB_16M_COLORS || - packMethod == PACK_RLE_16M_COLORS || - packMethod == PACK_BITMAP_16M_COLORS) && - control -> isProtoStep7() == 0) - { - #ifdef TEST - *logofs << "Loop: WARNING! Setting the pack method to '" - << PACK_PNG_16M_COLORS << "' with '" << packMethod - << "' unsupported.\n" << logofs_flush; - #endif - - packMethod = PACK_PNG_16M_COLORS; - packQuality = 9; - } - else if (packMethod == PACK_BITMAP_16M_COLORS && - control -> isProtoStep8() == 0) - { - #ifdef TEST - *logofs << "Loop: WARNING! Setting the pack method to '" - << PACK_RLE_16M_COLORS << "' with '" << packMethod - << "' unsupported.\n" << logofs_flush; - #endif - - packMethod = PACK_RLE_16M_COLORS; - packQuality = 9; - } + #ifdef TEST + *logofs << __FILE__ << " : " << __LINE__ << " - " + << "step = " << control -> getProtoStep() + << " packMethod = " << packMethod + << " packQuality = " << packQuality + << ".\n" << logofs_flush; + #endif // // Update the pack method name. @@ -12803,29 +12694,32 @@ int SetVersion() // // At the moment the image cache is not used by the - // agent but we need to take care of the compatibi- - // lity with old versions. Proxy versions older than - // the 3.0.0 assume that it is enabled and will send - // specific bits as part of the encoding. Conversely, - // it is advisable to disable the cache right now. - // By not enabling the image cache, the house-keep- - // ing process will only take care of cleaning up - // the "cache-" directories. + // agent. Proxy versions older than 3.0.0 assumed + // that it was enabled and sent specific bits as part + // of the encoding. Conversely, it is advisable to + // disable the cache right now. By not enabling the + // the image cache, the house-keeping process will + // only take care of cleaning up the "cache-" direc- + // tories. // - if (control -> isProtoStep8() == 1) - { - #ifdef TEST - *logofs << "Loop: Disabling image cache with protocol " - << "step '" << control -> getProtoStep() - << "'.\n" << logofs_flush; - #endif + // + // Considering that compatibility with older versions + // has been set to cover as far as 3.5.0, the cache can + // be disabled at this point without any concern + // - sprintf(imagesSizeName, "0"); + // Since ProtoStep8 (#issue 108) + #ifdef TEST + *logofs << "Loop: Disabling image cache with protocol " + << "step '" << control -> getProtoStep() + << "'.\n" << logofs_flush; + #endif - control -> ImageCacheEnableLoad = 0; - control -> ImageCacheEnableSave = 0; - } + sprintf(imagesSizeName, "0"); + + control -> ImageCacheEnableLoad = 0; + control -> ImageCacheEnableSave = 0; return 1; } @@ -15805,22 +15699,14 @@ static void handleAlertInLoop() return; } - if (lastAlert.local == 0 && - (lastAlert.code > LAST_PROTO_STEP_6_ALERT && - control -> isProtoStep7() == 0)) - { - // - // The remote proxy would be unable - // to handle the alert. - // + // + // Since ProtoStep7 (#issue 108) + // + // Now the remote proxy should always + // be able to handle the alert + // - #ifdef WARNING - *logofs << "Loop: WARNING! Ignoring unsupported alert " - << "with code '" << lastAlert.code << "'.\n" - << logofs_flush; - #endif - } - else if (lastAlert.local == 0) + if (lastAlert.local == 0) { if (proxy != NULL) { diff --git a/nxcomp/Message.cpp b/nxcomp/Message.cpp index 188ed9a0e..ccafa9963 100644 --- a/nxcomp/Message.cpp +++ b/nxcomp/Message.cpp @@ -112,20 +112,6 @@ MessageStore::MessageStore(StaticCompressor *compressor) lastRated = nothing; lastAction = is_discarded; - // - // This is used only for compatibility - // with older proxies. - // - - if (control -> isProtoStep7() == 1) - { - lastResize = -1; - } - else - { - lastResize = 0; - } - // // Private members. // diff --git a/nxcomp/Message.h b/nxcomp/Message.h index dcfff7cb6..c10cb266f 100644 --- a/nxcomp/Message.h +++ b/nxcomp/Message.h @@ -30,9 +30,6 @@ #include "ActionCache.h" -#include "ActionCacheCompat.h" -#include "PositionCacheCompat.h" - #include "StaticCompressor.h" // @@ -345,16 +342,6 @@ class MessageStore ActionCache lastActionCache; - // - // Used in old protocol versions. - // - - ActionCacheCompat lastActionCacheCompat; - - PositionCacheCompat lastAddedCacheCompat; - PositionCacheCompat lastHitCacheCompat; - PositionCacheCompat lastRemovedCacheCompat; - // // Position in cache where next insertion // is going to take place. @@ -362,14 +349,6 @@ class MessageStore short int lastRated; - // - // Size of data part of last split message - // once compressed. This is used only for - // compatibility with older proxies. - // - - int lastResize; - // // Constructors and destructors. // diff --git a/nxcomp/PolyLine.cpp b/nxcomp/PolyLine.cpp index 4d285e0b1..9f2d82a5d 100644 --- a/nxcomp/PolyLine.cpp +++ b/nxcomp/PolyLine.cpp @@ -93,10 +93,8 @@ void PolyLineStore::dumpIdentity(const Message *message) const void PolyLineStore::identityChecksum(const Message *message, const unsigned char *buffer, unsigned int size, int bigEndian) const { - if (control -> isProtoStep8() == 1) - { - md5_append(md5_state_, buffer + 1, 1); - } + // Since ProtoStep8 (#issue 108) + md5_append(md5_state_, buffer + 1, 1); } void PolyLineStore::updateIdentity(EncodeBuffer &encodeBuffer, const Message *message, @@ -108,11 +106,6 @@ void PolyLineStore::updateIdentity(EncodeBuffer &encodeBuffer, const Message *me ClientCache *clientCache = (ClientCache *) channelCache; - if (control -> isProtoStep8() == 0) - { - encodeBuffer.encodeBoolValue((unsigned int) polyLine -> mode); - } - #ifdef TEST *logofs << name() << ": Encoding value " << polyLine -> drawable << " as drawable field.\n" << logofs_flush; @@ -141,13 +134,6 @@ void PolyLineStore::updateIdentity(DecodeBuffer &decodeBuffer, const Message *me unsigned int value; - if (control -> isProtoStep8() == 0) - { - decodeBuffer.decodeBoolValue(value); - - polyLine -> mode = value; - } - decodeBuffer.decodeXidValue(value, clientCache -> drawableCache); polyLine -> drawable = value; diff --git a/nxcomp/PolyPoint.cpp b/nxcomp/PolyPoint.cpp index 847300f78..cae4b80a0 100644 --- a/nxcomp/PolyPoint.cpp +++ b/nxcomp/PolyPoint.cpp @@ -93,10 +93,8 @@ void PolyPointStore::dumpIdentity(const Message *message) const void PolyPointStore::identityChecksum(const Message *message, const unsigned char *buffer, unsigned int size, int bigEndian) const { - if (control -> isProtoStep8() == 1) - { - md5_append(md5_state_, buffer + 1, 1); - } + // Since ProtoStep8 (#issue 108) + md5_append(md5_state_, buffer + 1, 1); } void PolyPointStore::updateIdentity(EncodeBuffer &encodeBuffer, const Message *message, @@ -108,11 +106,6 @@ void PolyPointStore::updateIdentity(EncodeBuffer &encodeBuffer, const Message *m ClientCache *clientCache = (ClientCache *) channelCache; - if (control -> isProtoStep8() == 0) - { - encodeBuffer.encodeBoolValue((unsigned int) polyPoint -> mode); - } - #ifdef TEST *logofs << name() << ": Encoding value " << polyPoint -> drawable << " as drawable field.\n" << logofs_flush; @@ -141,13 +134,6 @@ void PolyPointStore::updateIdentity(DecodeBuffer &decodeBuffer, const Message *m unsigned int value; - if (control -> isProtoStep8() == 0) - { - decodeBuffer.decodeBoolValue(value); - - polyPoint -> mode = value; - } - decodeBuffer.decodeXidValue(value, clientCache -> drawableCache); polyPoint -> drawable = value; diff --git a/nxcomp/PositionCacheCompat.cpp b/nxcomp/PositionCacheCompat.cpp index 4a6a2cd63..dd301a0a4 100644 --- a/nxcomp/PositionCacheCompat.cpp +++ b/nxcomp/PositionCacheCompat.cpp @@ -21,25 +21,8 @@ PositionCacheCompat::PositionCacheCompat() { - if (control -> isProtoStep7() == 0) - { - for (int i = 0; i < 32; i++) - { - base_[i] = new IntCache(8); - } - - slot_ = 0; - last_ = 0; - } } PositionCacheCompat::~PositionCacheCompat() { - if (control -> isProtoStep7() == 0) - { - for (int i = 0; i < 32; i++) - { - delete base_[i]; - } - } } diff --git a/nxcomp/Proxy.cpp b/nxcomp/Proxy.cpp index 4eb99cf45..ae115fede 100644 --- a/nxcomp/Proxy.cpp +++ b/nxcomp/Proxy.cpp @@ -244,22 +244,6 @@ Proxy::Proxy(int fd) clientStore_ = new ClientStore(compressor_); serverStore_ = new ServerStore(compressor_); - // - // Older proxies will refuse to store - // messages bigger than 262144 bytes. - // - - if (control -> isProtoStep7() == 0) - { - #ifdef TEST - *logofs << "Proxy: WARNING! Limiting the maximum " - << "message size to " << 262144 << ".\n" - << logofs_flush; - #endif - - control -> MaximumMessageSize = 262144; - } - clientCache_ = new ClientCache(); serverCache_ = new ServerCache(); @@ -3049,31 +3033,19 @@ int Proxy::handleCloseAllXConnections() int Proxy::handleCloseAllListeners() { - if (control -> isProtoStep7() == 1) - { - if (finish_ == 0) - { - #ifdef TEST - *logofs << "Proxy: Closing down all remote listeners.\n" - << logofs_flush; - #endif - - if (handleControl(code_finish_listeners) < 0) - { - return -1; - } - - finish_ = 1; - } - } - else + // Since ProtoStep7 (#issue 108) + if (finish_ == 0) { #ifdef TEST - *logofs << "Proxy: WARNING! Not sending unsupported " - << "'code_finish_listeners' message.\n" + *logofs << "Proxy: Closing down all remote listeners.\n" << logofs_flush; #endif + if (handleControl(code_finish_listeners) < 0) + { + return -1; + } + finish_ = 1; } @@ -4546,15 +4518,8 @@ int Proxy::addTokenCodes(T_proxy_token &token) int count = 0; - if (control -> isProtoStep7() == 1) - { - count = token.bytes / token.size; - - if (count > 255) - { - count = 255; - } - } + // Since ProtoStep7 (#issue 108) + count = token.bytes / token.size; // // Force a count of 1, for example @@ -4569,6 +4534,12 @@ int Proxy::addTokenCodes(T_proxy_token &token) } else { + // Since ProtoStep7 (#issue 108) + if (count > 255) + { + count = 255; + } + // // Let the next token account for the // remaining bytes. @@ -4609,73 +4580,52 @@ int Proxy::handleToken(T_frame_type type) if (type == frame_data) { - if (control -> isProtoStep7() == 1) + // + // Since ProtoStep7 (#issue 108) + // + + // Send a distinct token for each data type. + // We don't want to slow down the sending of + // the X events, X replies and split confir- + // mation events on the X server side, so + // take care only of the generic data token. + // + + if (control -> ProxyMode == proxy_client) { - // - // Send a distinct token for each data type. - // We don't want to slow down the sending of - // the X events, X replies and split confir- - // mation events on the X server side, so - // take care only of the generic data token. - // + statistics -> updateControlToken(tokens_[token_control].bytes); - if (control -> ProxyMode == proxy_client) + if (tokens_[token_control].bytes > tokens_[token_control].size) { - statistics -> updateControlToken(tokens_[token_control].bytes); - - if (tokens_[token_control].bytes > tokens_[token_control].size) + if (addTokenCodes(tokens_[token_control]) < 0) { - if (addTokenCodes(tokens_[token_control]) < 0) - { - return -1; - } - - #if defined(TEST) || defined(INFO) || defined(TOKEN) - - T_proxy_token &token = tokens_[token_control]; - - *logofs << "Proxy: TOKEN! Token class [" - << DumpToken(token.type) << "] has now " - << token.bytes << " bytes accumulated and " - << token.remaining << " tokens remaining.\n" - << logofs_flush; - #endif + return -1; } - statistics -> updateSplitToken(tokens_[token_split].bytes); - - if (tokens_[token_split].bytes > tokens_[token_split].size) - { - if (addTokenCodes(tokens_[token_split]) < 0) - { - return -1; - } - - #if defined(TEST) || defined(INFO) || defined(TOKEN) + #if defined(TEST) || defined(INFO) || defined(TOKEN) - T_proxy_token &token = tokens_[token_split]; + T_proxy_token &token = tokens_[token_control]; - *logofs << "Proxy: TOKEN! Token class [" - << DumpToken(token.type) << "] has now " - << token.bytes << " bytes accumulated and " - << token.remaining << " tokens remaining.\n" - << logofs_flush; - #endif - } + *logofs << "Proxy: TOKEN! Token class [" + << DumpToken(token.type) << "] has now " + << token.bytes << " bytes accumulated and " + << token.remaining << " tokens remaining.\n" + << logofs_flush; + #endif } - statistics -> updateDataToken(tokens_[token_data].bytes); + statistics -> updateSplitToken(tokens_[token_split].bytes); - if (tokens_[token_data].bytes > tokens_[token_data].size) + if (tokens_[token_split].bytes > tokens_[token_split].size) { - if (addTokenCodes(tokens_[token_data]) < 0) + if (addTokenCodes(tokens_[token_split]) < 0) { return -1; } #if defined(TEST) || defined(INFO) || defined(TOKEN) - T_proxy_token &token = tokens_[token_data]; + T_proxy_token &token = tokens_[token_split]; *logofs << "Proxy: TOKEN! Token class [" << DumpToken(token.type) << "] has now " @@ -4685,37 +4635,26 @@ int Proxy::handleToken(T_frame_type type) #endif } } - else - { - // - // Sum everything to the control token. - // - if (control -> ProxyMode == proxy_client) - { - statistics -> updateControlToken(tokens_[token_control].bytes); - statistics -> updateSplitToken(tokens_[token_control].bytes); - statistics -> updateDataToken(tokens_[token_control].bytes); + statistics -> updateDataToken(tokens_[token_data].bytes); - if (tokens_[token_control].bytes > tokens_[token_control].size) - { - if (addTokenCodes(tokens_[token_control]) < 0) - { - return -1; - } + if (tokens_[token_data].bytes > tokens_[token_data].size) + { + if (addTokenCodes(tokens_[token_data]) < 0) + { + return -1; + } - #if defined(TEST) || defined(INFO) || defined(TOKEN) + #if defined(TEST) || defined(INFO) || defined(TOKEN) - T_proxy_token &token = tokens_[token_control]; + T_proxy_token &token = tokens_[token_data]; - *logofs << "Proxy: TOKEN! Token class [" - << DumpToken(token.type) << "] has now " - << token.bytes << " bytes accumulated and " - << token.remaining << " tokens remaining.\n" - << logofs_flush; - #endif - } - } + *logofs << "Proxy: TOKEN! Token class [" + << DumpToken(token.type) << "] has now " + << token.bytes << " bytes accumulated and " + << token.remaining << " tokens remaining.\n" + << logofs_flush; + #endif } } else @@ -4777,21 +4716,10 @@ int Proxy::handleTokenFromProxy(T_proxy_token &token, int count) << count << ".\n" << logofs_flush; #endif - if (control -> isProtoStep7() == 0) - { - if (control -> ProxyMode == proxy_client || - token.request != code_control_token_request) - { - #ifdef PANIC - *logofs << "Proxy: PANIC! Invalid token request received from remote.\n" - << logofs_flush; - #endif - - cerr << "Error" << ": Invalid token request received from remote.\n"; - - HandleCleanup(); - } - } + // + // Since ProtoStep7 (#issue 108) with no limitations + // concerning invalid token requests at this point + // // // Add our token reply. @@ -4815,25 +4743,13 @@ int Proxy::handleTokenReplyFromProxy(T_proxy_token &token, int count) #endif // - // Increment the available tokens. + // Since ProtoStep7 (#issue 108) with no limitations + // concerning invalid token requests at this point // - if (control -> isProtoStep7() == 0) - { - if (token.reply != code_control_token_reply) - { - #ifdef PANIC - *logofs << "Proxy: PANIC! Invalid token reply received from remote.\n" - << logofs_flush; - #endif - - cerr << "Error" << ": Invalid token reply received from remote.\n"; - - HandleCleanup(); - } - - count = 1; - } + // + // Increment the available tokens. + // token.remaining += count; @@ -4924,24 +4840,10 @@ void Proxy::handleFailOnLoad(const char *fullName, const char *failContext) cons int Proxy::handleSaveVersion(unsigned char *buffer, int &major, int &minor, int &patch) const { - if (control -> isProtoStep8() == 1) - { - major = 3; - minor = 0; - patch = 0; - } - else if (control -> isProtoStep7() == 1) - { - major = 2; - minor = 0; - patch = 0; - } - else - { - major = 1; - minor = 4; - patch = 0; - } + // Since ProtoStep8 (#issue 108) + major = 3; + minor = 0; + patch = 0; *(buffer + 0) = major; *(buffer + 1) = minor; @@ -4964,26 +4866,10 @@ int Proxy::handleLoadVersion(const unsigned char *buffer, int &major, // incompatible caches. // - if (control -> isProtoStep8() == 1) - { - if (major < 3) - { - return -1; - } - } - else if (control -> isProtoStep7() == 1) - { - if (major < 2) - { - return -1; - } - } - else + // Since ProtoStep8 (#issue 108) + if (major < 3) { - if (major != 1 && minor != 4) - { - return -1; - } + return -1; } return 1; @@ -6109,20 +5995,8 @@ int Proxy::handleNewGenericConnection(int clientFd, T_channel_type type, const c int Proxy::handleNewSlaveConnection(int clientFd) { - if (control -> isProtoStep7() == 1) - { - return handleNewGenericConnection(clientFd, channel_slave, "slave"); - } - else - { - #ifdef TEST - *logofs << "Proxy: WARNING! Not sending unsupported " - << "'code_new_slave_connection' message.\n" - << logofs_flush; - #endif - - return -1; - } + // Since ProtoStep7 (#issue 108) + return handleNewGenericConnection(clientFd, channel_slave, "slave"); } int Proxy::handleNewGenericConnectionFromProxy(int channelId, T_channel_type type, diff --git a/nxcomp/Proxy.h b/nxcomp/Proxy.h index 3d6c62c54..2f3be7596 100644 --- a/nxcomp/Proxy.h +++ b/nxcomp/Proxy.h @@ -767,11 +767,6 @@ class Proxy handleSplitEvent(encodeBuffer_, split); } - int handleAsyncInit() - { - return handleFlush(); - } - int handleAsyncPriority() { if (control -> FlushPriority == 1) diff --git a/nxcomp/PutImage.cpp b/nxcomp/PutImage.cpp index 325a4aa66..af170463d 100644 --- a/nxcomp/PutImage.cpp +++ b/nxcomp/PutImage.cpp @@ -44,13 +44,9 @@ PutImageStore::PutImageStore(StaticCompressor *compressor) { enableCache = PUTIMAGE_ENABLE_CACHE; enableData = PUTIMAGE_ENABLE_DATA; - enableSplit = PUTIMAGE_ENABLE_SPLIT; - enableCompress = PUTIMAGE_ENABLE_COMPRESS; - if (control -> isProtoStep7() == 1) - { - enableCompress = PUTIMAGE_ENABLE_COMPRESS_IF_PROTO_STEP_7; - } + // Since ProtoStep7 (#issue 108) + enableCompress = PUTIMAGE_ENABLE_COMPRESS_IF_PROTO_STEP_7; dataLimit = PUTIMAGE_DATA_LIMIT; dataOffset = PUTIMAGE_DATA_OFFSET; @@ -59,10 +55,8 @@ PutImageStore::PutImageStore(StaticCompressor *compressor) cacheThreshold = PUTIMAGE_CACHE_THRESHOLD; cacheLowerThreshold = PUTIMAGE_CACHE_LOWER_THRESHOLD; - if (control -> isProtoStep8() == 1) - { - enableSplit = PUTIMAGE_ENABLE_SPLIT_IF_PROTO_STEP_8; - } + // Since ProtoStep8 (#issue 108) + enableSplit = PUTIMAGE_ENABLE_SPLIT_IF_PROTO_STEP_8; messages_ -> resize(cacheSlots); diff --git a/nxcomp/PutImage.h b/nxcomp/PutImage.h index e9535cb29..9e438fc84 100644 --- a/nxcomp/PutImage.h +++ b/nxcomp/PutImage.h @@ -36,8 +36,6 @@ #define PUTIMAGE_ENABLE_CACHE 1 #define PUTIMAGE_ENABLE_DATA 1 -#define PUTIMAGE_ENABLE_SPLIT 1 -#define PUTIMAGE_ENABLE_COMPRESS 1 #define PUTIMAGE_DATA_LIMIT 262144 - 24 #define PUTIMAGE_DATA_OFFSET 24 diff --git a/nxcomp/PutPackedImage.cpp b/nxcomp/PutPackedImage.cpp index eae16a16f..af962c703 100644 --- a/nxcomp/PutPackedImage.cpp +++ b/nxcomp/PutPackedImage.cpp @@ -44,7 +44,6 @@ PutPackedImageStore::PutPackedImageStore(StaticCompressor *compressor) { enableCache = PUTPACKEDIMAGE_ENABLE_CACHE; enableData = PUTPACKEDIMAGE_ENABLE_DATA; - enableSplit = PUTPACKEDIMAGE_ENABLE_SPLIT; enableCompress = PUTPACKEDIMAGE_ENABLE_COMPRESS; dataLimit = PUTPACKEDIMAGE_DATA_LIMIT; @@ -54,10 +53,8 @@ PutPackedImageStore::PutPackedImageStore(StaticCompressor *compressor) cacheThreshold = PUTPACKEDIMAGE_CACHE_THRESHOLD; cacheLowerThreshold = PUTPACKEDIMAGE_CACHE_LOWER_THRESHOLD; - if (control -> isProtoStep8() == 1) - { - enableSplit = PUTPACKEDIMAGE_ENABLE_SPLIT_IF_PROTO_STEP_8; - } + // Since ProtoStep8 (#issue 108) + enableSplit = PUTPACKEDIMAGE_ENABLE_SPLIT_IF_PROTO_STEP_8; messages_ -> resize(cacheSlots); diff --git a/nxcomp/PutPackedImage.h b/nxcomp/PutPackedImage.h index 5287a5b57..7427499b8 100644 --- a/nxcomp/PutPackedImage.h +++ b/nxcomp/PutPackedImage.h @@ -36,7 +36,6 @@ #define PUTPACKEDIMAGE_ENABLE_CACHE 1 #define PUTPACKEDIMAGE_ENABLE_DATA 1 -#define PUTPACKEDIMAGE_ENABLE_SPLIT 1 #define PUTPACKEDIMAGE_ENABLE_COMPRESS 0 // diff --git a/nxcomp/QueryFontReply.cpp b/nxcomp/QueryFontReply.cpp index 2d42587f7..d723f9127 100644 --- a/nxcomp/QueryFontReply.cpp +++ b/nxcomp/QueryFontReply.cpp @@ -39,12 +39,9 @@ QueryFontReplyStore::QueryFontReplyStore(StaticCompressor *compressor) enableCache = QUERYFONTREPLY_ENABLE_CACHE; enableData = QUERYFONTREPLY_ENABLE_DATA; enableSplit = QUERYFONTREPLY_ENABLE_SPLIT; - enableCompress = QUERYFONTREPLY_ENABLE_COMPRESS; - if (control -> isProtoStep7() == 1) - { - enableCompress = QUERYFONTREPLY_ENABLE_COMPRESS_IF_PROTO_STEP_7; - } + // Since ProtoStep7 (#issue 108) + enableCompress = QUERYFONTREPLY_ENABLE_COMPRESS_IF_PROTO_STEP_7; dataLimit = QUERYFONTREPLY_DATA_LIMIT; dataOffset = QUERYFONTREPLY_DATA_OFFSET; diff --git a/nxcomp/QueryFontReply.h b/nxcomp/QueryFontReply.h index 537da4e63..e89720ffe 100644 --- a/nxcomp/QueryFontReply.h +++ b/nxcomp/QueryFontReply.h @@ -36,7 +36,6 @@ #define QUERYFONTREPLY_ENABLE_CACHE 1 #define QUERYFONTREPLY_ENABLE_DATA 1 #define QUERYFONTREPLY_ENABLE_SPLIT 0 -#define QUERYFONTREPLY_ENABLE_COMPRESS 1 #define QUERYFONTREPLY_DATA_LIMIT 1048576 - 32 #define QUERYFONTREPLY_DATA_OFFSET 8 diff --git a/nxcomp/RenderCompositeGlyphs.cpp b/nxcomp/RenderCompositeGlyphs.cpp index 1135633ff..752dedb2b 100644 --- a/nxcomp/RenderCompositeGlyphs.cpp +++ b/nxcomp/RenderCompositeGlyphs.cpp @@ -102,26 +102,14 @@ MESSAGE_BEGIN_ENCODE_MESSAGE unsigned int src_x = GetUINT(buffer + 24, bigEndian); unsigned int src_y = GetUINT(buffer + 26, bigEndian); - if (control -> isProtoStep8() == 1) - { - encodeBuffer.encodeDiffCachedValue(src_x, - clientCache -> renderGlyphX, 16, - clientCache -> renderGlyphXCache, 11); - - encodeBuffer.encodeDiffCachedValue(src_y, - clientCache -> renderGlyphY, 16, - clientCache -> renderGlyphYCache, 11); - } - else - { - encodeBuffer.encodeDiffCachedValue(src_x, - clientCache -> renderLastX, 16, - clientCache -> renderXCache, 11); + // Since ProtoStep8 (#issue 108) + encodeBuffer.encodeDiffCachedValue(src_x, + clientCache -> renderGlyphX, 16, + clientCache -> renderGlyphXCache, 11); - encodeBuffer.encodeDiffCachedValue(src_y, - clientCache -> renderLastY, 16, - clientCache -> renderYCache, 11); - } + encodeBuffer.encodeDiffCachedValue(src_y, + clientCache -> renderGlyphY, 16, + clientCache -> renderGlyphYCache, 11); #ifdef TEST *logofs << name() << ": Encoded source X " @@ -147,8 +135,8 @@ MESSAGE_BEGIN_ENCODE_MESSAGE // tive to the first offset coordinates. // - if (control -> isProtoStep8() == 1 && - size >= MESSAGE_OFFSET_IF_PROTO_STEP_8) + // Since ProtoStep8 (#issue 108) + if (size >= MESSAGE_OFFSET_IF_PROTO_STEP_8) { unsigned int numGlyphs = *(buffer + 28); @@ -232,32 +220,20 @@ MESSAGE_BEGIN_DECODE_MESSAGE unsigned int src_x; unsigned int src_y; - if (control -> isProtoStep8() == 1) - { - decodeBuffer.decodeDiffCachedValue(src_x, - clientCache -> renderGlyphX, 16, - clientCache -> renderGlyphXCache, 11); - - decodeBuffer.decodeDiffCachedValue(src_y, - clientCache -> renderGlyphY, 16, - clientCache -> renderGlyphYCache, 11); - } - else - { - decodeBuffer.decodeDiffCachedValue(src_x, - clientCache -> renderLastX, 16, - clientCache -> renderXCache, 11); + // Since ProtoStep8 (#issue 108) + decodeBuffer.decodeDiffCachedValue(src_x, + clientCache -> renderGlyphX, 16, + clientCache -> renderGlyphXCache, 11); - decodeBuffer.decodeDiffCachedValue(src_y, - clientCache -> renderLastY, 16, - clientCache -> renderYCache, 11); - } + decodeBuffer.decodeDiffCachedValue(src_y, + clientCache -> renderGlyphY, 16, + clientCache -> renderGlyphYCache, 11); PutUINT(src_x, buffer + 24, bigEndian); PutUINT(src_y, buffer + 26, bigEndian); - if (control -> isProtoStep8() == 1 && - size >= MESSAGE_OFFSET_IF_PROTO_STEP_8) + // Since ProtoStep8 (#issue 108) + if (size >= MESSAGE_OFFSET_IF_PROTO_STEP_8) { decodeBuffer.decodeCachedValue(value, 8, clientCache -> renderNumGlyphsCache); @@ -297,8 +273,8 @@ MESSAGE_END_DECODE_MESSAGE MESSAGE_BEGIN_ENCODE_DATA { - if (control -> isProtoStep8() == 1 && - size >= MESSAGE_OFFSET_IF_PROTO_STEP_8) + // Since ProtoStep8 (#issue 108) + if (size >= MESSAGE_OFFSET_IF_PROTO_STEP_8) { encodeCharData(encodeBuffer, buffer, MESSAGE_OFFSET_IF_PROTO_STEP_8, size, bigEndian, channelCache); @@ -318,8 +294,8 @@ MESSAGE_END_ENCODE_DATA MESSAGE_BEGIN_DECODE_DATA { - if (control -> isProtoStep8() == 1 && - size >= MESSAGE_OFFSET_IF_PROTO_STEP_8) + // Since ProtoStep8 (#issue 108) + if (size >= MESSAGE_OFFSET_IF_PROTO_STEP_8) { decodeCharData(decodeBuffer, buffer, MESSAGE_OFFSET_IF_PROTO_STEP_8, size, bigEndian, channelCache); @@ -353,8 +329,8 @@ MESSAGE_BEGIN_PARSE_IDENTITY renderExtension -> data.composite_glyphs.src_x = GetUINT(buffer + 24, bigEndian); renderExtension -> data.composite_glyphs.src_y = GetUINT(buffer + 26, bigEndian); - if (control -> isProtoStep8() == 1 && - size >= MESSAGE_OFFSET_IF_PROTO_STEP_8) + // Since ProtoStep8 (#issue 108) + if (size >= MESSAGE_OFFSET_IF_PROTO_STEP_8) { renderExtension -> data.composite_glyphs.num_elm = *(buffer + 28); @@ -387,8 +363,8 @@ MESSAGE_BEGIN_UNPARSE_IDENTITY PutUINT(renderExtension -> data.composite_glyphs.src_x, buffer + 24, bigEndian); PutUINT(renderExtension -> data.composite_glyphs.src_y, buffer + 26, bigEndian); - if (control -> isProtoStep8() == 1 && - size >= MESSAGE_OFFSET_IF_PROTO_STEP_8) + // Since ProtoStep8 (#issue 108) + if (size >= MESSAGE_OFFSET_IF_PROTO_STEP_8) { *(buffer + 28) = renderExtension -> data.composite_glyphs.num_elm; @@ -426,8 +402,8 @@ MESSAGE_BEGIN_IDENTITY_CHECKSUM // first string. // - if (control -> isProtoStep8() == 1 && - size >= MESSAGE_OFFSET_IF_PROTO_STEP_8) + // Since ProtoStep8 (#issue 108) + if (size >= MESSAGE_OFFSET_IF_PROTO_STEP_8) { md5_append(md5_state, buffer + 28, 1); } @@ -470,42 +446,22 @@ MESSAGE_BEGIN_ENCODE_UPDATE unsigned int value; unsigned int previous; - if (control -> isProtoStep8() == 1) - { - value = renderExtension -> data.composite_glyphs.src_x; - previous = cachedRenderExtension -> data.composite_glyphs.src_x; - - encodeBuffer.encodeDiffCachedValue(value, previous, 16, - clientCache -> renderGlyphXCache, 11); + // Since ProtoStep8 (#issue 108) + value = renderExtension -> data.composite_glyphs.src_x; + previous = cachedRenderExtension -> data.composite_glyphs.src_x; - cachedRenderExtension -> data.composite_glyphs.src_x = value; + encodeBuffer.encodeDiffCachedValue(value, previous, 16, + clientCache -> renderGlyphXCache, 11); - value = renderExtension -> data.composite_glyphs.src_y; - previous = cachedRenderExtension -> data.composite_glyphs.src_y; + cachedRenderExtension -> data.composite_glyphs.src_x = value; - encodeBuffer.encodeDiffCachedValue(value, previous, 16, - clientCache -> renderGlyphYCache, 11); + value = renderExtension -> data.composite_glyphs.src_y; + previous = cachedRenderExtension -> data.composite_glyphs.src_y; - cachedRenderExtension -> data.composite_glyphs.src_y = value; - } - else - { - value = renderExtension -> data.composite_glyphs.src_x; - previous = cachedRenderExtension -> data.composite_glyphs.src_x; - - encodeBuffer.encodeDiffCachedValue(value, previous, 16, - clientCache -> renderXCache, 11); - - cachedRenderExtension -> data.composite_glyphs.src_x = value; + encodeBuffer.encodeDiffCachedValue(value, previous, 16, + clientCache -> renderGlyphYCache, 11); - value = renderExtension -> data.composite_glyphs.src_y; - previous = cachedRenderExtension -> data.composite_glyphs.src_y; - - encodeBuffer.encodeDiffCachedValue(value, previous, 16, - clientCache -> renderYCache, 11); - - cachedRenderExtension -> data.composite_glyphs.src_y = value; - } + cachedRenderExtension -> data.composite_glyphs.src_y = value; #ifdef TEST *logofs << name() << ": Encoded source X " @@ -514,8 +470,8 @@ MESSAGE_BEGIN_ENCODE_UPDATE << logofs_flush; #endif - if (control -> isProtoStep8() == 1 && - renderExtension -> size_ >= MESSAGE_OFFSET_IF_PROTO_STEP_8) + // Since ProtoStep8 (#issue 108) + if (renderExtension -> size_ >= MESSAGE_OFFSET_IF_PROTO_STEP_8) { // // Offset X and Y. @@ -601,41 +557,23 @@ MESSAGE_BEGIN_DECODE_UPDATE unsigned int value; unsigned int previous; - if (control -> isProtoStep8() == 1) - { - previous = renderExtension -> data.composite_glyphs.src_x; - - decodeBuffer.decodeDiffCachedValue(value, previous, 16, - clientCache -> renderGlyphXCache, 11); - - renderExtension -> data.composite_glyphs.src_x = value; - - previous = renderExtension -> data.composite_glyphs.src_y; - - decodeBuffer.decodeDiffCachedValue(value, previous, 16, - clientCache -> renderGlyphYCache, 11); + // Since ProtoStep8 (#issue 108) + previous = renderExtension -> data.composite_glyphs.src_x; - renderExtension -> data.composite_glyphs.src_y = value; - } - else - { - previous = renderExtension -> data.composite_glyphs.src_x; + decodeBuffer.decodeDiffCachedValue(value, previous, 16, + clientCache -> renderGlyphXCache, 11); - decodeBuffer.decodeDiffCachedValue(value, previous, 16, - clientCache -> renderXCache, 11); + renderExtension -> data.composite_glyphs.src_x = value; - renderExtension -> data.composite_glyphs.src_x = value; + previous = renderExtension -> data.composite_glyphs.src_y; - previous = renderExtension -> data.composite_glyphs.src_y; + decodeBuffer.decodeDiffCachedValue(value, previous, 16, + clientCache -> renderGlyphYCache, 11); - decodeBuffer.decodeDiffCachedValue(value, previous, 16, - clientCache -> renderYCache, 11); - - renderExtension -> data.composite_glyphs.src_y = value; - } + renderExtension -> data.composite_glyphs.src_y = value; - if (control -> isProtoStep8() == 1 && - renderExtension -> size_ >= MESSAGE_OFFSET_IF_PROTO_STEP_8) + // Since ProtoStep8 (#issue 108) + if (renderExtension -> size_ >= MESSAGE_OFFSET_IF_PROTO_STEP_8) { // // Offset X and Y. diff --git a/nxcomp/RenderCompositeGlyphs.h b/nxcomp/RenderCompositeGlyphs.h index 527fd3d12..9458ecb14 100644 --- a/nxcomp/RenderCompositeGlyphs.h +++ b/nxcomp/RenderCompositeGlyphs.h @@ -80,9 +80,8 @@ class MESSAGE_STORE : public MESSAGE_CLASS virtual int identitySize(const unsigned char *buffer, unsigned int size) { - unsigned int offset = (control -> isProtoStep8() == 1 ? - MESSAGE_OFFSET_IF_PROTO_STEP_8 : - MESSAGE_OFFSET); + // Since ProtoStep8 (#issue 108) + unsigned int offset = MESSAGE_OFFSET_IF_PROTO_STEP_8; return (size >= offset ? offset : size); } diff --git a/nxcomp/RenderExtension.cpp b/nxcomp/RenderExtension.cpp index 79c26e64e..43933748c 100644 --- a/nxcomp/RenderExtension.cpp +++ b/nxcomp/RenderExtension.cpp @@ -42,13 +42,6 @@ #include "RenderTrapezoids.h" #include "RenderTriangles.h" -#include "RenderCreatePictureCompat.h" -#include "RenderFreePictureCompat.h" -#include "RenderPictureClipCompat.h" -#include "RenderCreateGlyphSetCompat.h" -#include "RenderCompositeCompat.h" -#include "RenderCompositeGlyphsCompat.h" - // // Set the verbosity level. // @@ -82,46 +75,27 @@ RenderExtensionStore::RenderExtensionStore(StaticCompressor *compressor) minors_[X_RenderFillRectangles] = new RenderFillRectanglesStore(); minors_[X_RenderAddGlyphs] = new RenderAddGlyphsStore(); - if (control -> isProtoStep7() == 1) - { - minors_[X_RenderCreatePicture] = new RenderCreatePictureStore(); - minors_[X_RenderFreePicture] = new RenderFreePictureStore(); - minors_[X_RenderSetPictureClipRectangles] = new RenderPictureClipStore(); - minors_[X_RenderCreateGlyphSet] = new RenderCreateGlyphSetStore(); - minors_[X_RenderComposite] = new RenderCompositeStore(); - minors_[X_RenderCompositeGlyphs8] = new RenderCompositeGlyphsStore(); - minors_[X_RenderCompositeGlyphs16] = new RenderCompositeGlyphsStore(); - minors_[X_RenderCompositeGlyphs32] = new RenderCompositeGlyphsStore(); - - minors_[X_RenderSetPictureTransform] = new RenderPictureTransformStore(); - minors_[X_RenderSetPictureFilter] = new RenderPictureFilterStore(); - minors_[X_RenderFreeGlyphSet] = new RenderFreeGlyphSetStore(); - minors_[X_RenderTrapezoids] = new RenderTrapezoidsStore(); - minors_[X_RenderTriangles] = new RenderTrianglesStore(); - } - else - { - minors_[X_RenderCreatePicture] = new RenderCreatePictureCompatStore(); - minors_[X_RenderFreePicture] = new RenderFreePictureCompatStore(); - minors_[X_RenderSetPictureClipRectangles] = new RenderPictureClipCompatStore(); - minors_[X_RenderCreateGlyphSet] = new RenderCreateGlyphSetCompatStore(); - minors_[X_RenderComposite] = new RenderCompositeCompatStore(); - minors_[X_RenderCompositeGlyphs8] = new RenderCompositeGlyphsCompatStore(); - minors_[X_RenderCompositeGlyphs16] = new RenderCompositeGlyphsCompatStore(); - minors_[X_RenderCompositeGlyphs32] = new RenderCompositeGlyphsCompatStore(); - } + // Since ProtoStep7 (#issue 108) + minors_[X_RenderCreatePicture] = new RenderCreatePictureStore(); + minors_[X_RenderFreePicture] = new RenderFreePictureStore(); + minors_[X_RenderSetPictureClipRectangles] = new RenderPictureClipStore(); + minors_[X_RenderCreateGlyphSet] = new RenderCreateGlyphSetStore(); + minors_[X_RenderComposite] = new RenderCompositeStore(); + minors_[X_RenderCompositeGlyphs8] = new RenderCompositeGlyphsStore(); + minors_[X_RenderCompositeGlyphs16] = new RenderCompositeGlyphsStore(); + minors_[X_RenderCompositeGlyphs32] = new RenderCompositeGlyphsStore(); + + minors_[X_RenderSetPictureTransform] = new RenderPictureTransformStore(); + minors_[X_RenderSetPictureFilter] = new RenderPictureFilterStore(); + minors_[X_RenderFreeGlyphSet] = new RenderFreeGlyphSetStore(); + minors_[X_RenderTrapezoids] = new RenderTrapezoidsStore(); + minors_[X_RenderTriangles] = new RenderTrianglesStore(); dataLimit = RENDEREXTENSION_DATA_LIMIT; dataOffset = RENDEREXTENSION_DATA_OFFSET; - if (control -> isProtoStep7() == 1) - { - cacheSlots = RENDEREXTENSION_CACHE_SLOTS_IF_PROTO_STEP_7; - } - else - { - cacheSlots = RENDEREXTENSION_CACHE_SLOTS; - } + // Since ProtoStep7 (#issue 108) + cacheSlots = RENDEREXTENSION_CACHE_SLOTS_IF_PROTO_STEP_7; cacheThreshold = RENDEREXTENSION_CACHE_THRESHOLD; cacheLowerThreshold = RENDEREXTENSION_CACHE_LOWER_THRESHOLD; @@ -268,204 +242,78 @@ void RenderMinorExtensionStore::encodeLongData(EncodeBuffer &encodeBuffer, const unsigned int offset, unsigned int size, int bigEndian, ChannelCache *channelCache) const { - if (control -> isProtoStep7() == 1) - { - encodeBuffer.encodeLongData(buffer + offset, size - offset); - - #ifdef TEST - *logofs << name() << ": Encoded " << size - offset - << " bytes of long data.\n" << logofs_flush; - #endif - - return; - } - - ClientCache *clientCache = (ClientCache *) channelCache; - - for (unsigned int i = offset, c = (offset - 4) % 16; i < size; i += 4) - { - #ifdef DEBUG - *logofs << name() << ": Encoding int with i = " << i << " c = " - << c << ".\n" << logofs_flush; - #endif - - encodeBuffer.encodeCachedValue(GetULONG(buffer + i, bigEndian), 32, - *clientCache -> renderDataCache[c]); + // Since ProtoStep7 (#issue 108) + encodeBuffer.encodeLongData(buffer + offset, size - offset); - if (++c == 16) c = 0; - } + #ifdef TEST + *logofs << name() << ": Encoded " << size - offset + << " bytes of long data.\n" << logofs_flush; + #endif } void RenderMinorExtensionStore::encodeIntData(EncodeBuffer &encodeBuffer, const unsigned char *buffer, unsigned int offset, unsigned int size, int bigEndian, ChannelCache *channelCache) const { - if (control -> isProtoStep7() == 1) - { - encodeBuffer.encodeIntData(buffer + offset, size - offset); - - #ifdef TEST - *logofs << name() << ": Encoded " << size - offset - << " bytes of int data.\n" << logofs_flush; - #endif + // Since ProtoStep7 (#issue 108) + encodeBuffer.encodeIntData(buffer + offset, size - offset); - return; - } - - ClientCache *clientCache = (ClientCache *) channelCache; - - for (unsigned int i = offset, c = (offset - 4) % 16; i < size; i += 2) - { - #ifdef DEBUG - *logofs << name() << ": Encoding int with i = " << i << " c = " - << c << ".\n" << logofs_flush; - #endif - - encodeBuffer.encodeCachedValue(GetUINT(buffer + i, bigEndian), 16, - *clientCache -> renderDataCache[c]); - - if (++c == 16) c = 0; - } + #ifdef TEST + *logofs << name() << ": Encoded " << size - offset + << " bytes of int data.\n" << logofs_flush; + #endif } void RenderMinorExtensionStore::encodeCharData(EncodeBuffer &encodeBuffer, const unsigned char *buffer, unsigned int offset, unsigned int size, int bigEndian, ChannelCache *channelCache) const { - if (control -> isProtoStep7() == 1) - { - encodeBuffer.encodeTextData(buffer + offset, size - offset); - - #ifdef TEST - *logofs << name() << ": Encoded " << size - offset - << " bytes of text data.\n" << logofs_flush; - #endif - - return; - } - - ClientCache *clientCache = (ClientCache *) channelCache; - - clientCache -> renderTextCompressor.reset(); + // Since ProtoStep7 (#issue 108) + encodeBuffer.encodeTextData(buffer + offset, size - offset); - const unsigned char *next = buffer + offset; - - for (unsigned int i = offset; i < size; i++) - { - #ifdef DEBUG - *logofs << name() << ": Encoding char with i = " << i - << ".\n" << logofs_flush; - #endif - - clientCache -> renderTextCompressor. - encodeChar(*next++, encodeBuffer); - } + #ifdef TEST + *logofs << name() << ": Encoded " << size - offset + << " bytes of text data.\n" << logofs_flush; + #endif } void RenderMinorExtensionStore::decodeLongData(DecodeBuffer &decodeBuffer, unsigned char *buffer, unsigned int offset, unsigned int size, int bigEndian, ChannelCache *channelCache) const { - if (control -> isProtoStep7() == 1) - { - decodeBuffer.decodeLongData(buffer + offset, size - offset); - - #ifdef TEST - *logofs << name() << ": Decoded " << size - offset - << " bytes of long data.\n" << logofs_flush; - #endif - - return; - } - - ClientCache *clientCache = (ClientCache *) channelCache; - - unsigned int value; - - for (unsigned int i = offset, c = (offset - 4) % 16; i < size; i += 4) - { - #ifdef DEBUG - *logofs << name() << ": Decoding int with i = " << i << " c = " - << c << ".\n" << logofs_flush; - #endif + // Since ProtoStep7 (#issue 108) + decodeBuffer.decodeLongData(buffer + offset, size - offset); - decodeBuffer.decodeCachedValue(value, 32, - *clientCache -> renderDataCache[c]); - - PutULONG(value, buffer + i, bigEndian); - - if (++c == 16) c = 0; - } + #ifdef TEST + *logofs << name() << ": Decoded " << size - offset + << " bytes of long data.\n" << logofs_flush; + #endif } void RenderMinorExtensionStore::decodeIntData(DecodeBuffer &decodeBuffer, unsigned char *buffer, unsigned int offset, unsigned int size, int bigEndian, ChannelCache *channelCache) const { - if (control -> isProtoStep7() == 1) - { - decodeBuffer.decodeIntData(buffer + offset, size - offset); - - #ifdef TEST - *logofs << name() << ": Decoded " << size - offset - << " bytes of int data.\n" << logofs_flush; - #endif - - return; - } - - ClientCache *clientCache = (ClientCache *) channelCache; - - unsigned int value; - - for (unsigned int i = offset, c = (offset - 4) % 16; i < size; i += 2) - { - #ifdef DEBUG - *logofs << name() << ": Decoding int with i = " << i << " c = " - << c << ".\n" << logofs_flush; - #endif + // Since ProtoStep7 (#issue 108) + decodeBuffer.decodeIntData(buffer + offset, size - offset); - decodeBuffer.decodeCachedValue(value, 16, - *clientCache -> renderDataCache[c]); - - PutUINT(value, buffer + i, bigEndian); - - if (++c == 16) c = 0; - } + #ifdef TEST + *logofs << name() << ": Decoded " << size - offset + << " bytes of int data.\n" << logofs_flush; + #endif } void RenderMinorExtensionStore::decodeCharData(DecodeBuffer &decodeBuffer, unsigned char *buffer, unsigned int offset, unsigned int size, int bigEndian, ChannelCache *channelCache) const { - if (control -> isProtoStep7() == 1) - { - decodeBuffer.decodeTextData(buffer + offset, size - offset); + // Since ProtoStep7 (#issue 108) + decodeBuffer.decodeTextData(buffer + offset, size - offset); - #ifdef TEST - *logofs << name() << ": Decoded " << size - offset - << " bytes of text data.\n" << logofs_flush; - #endif - - return; - } - - ClientCache *clientCache = (ClientCache *) channelCache; - - clientCache -> renderTextCompressor.reset(); - - unsigned char *next = buffer + offset; - - for (unsigned int i = offset; i < size; i++) - { - #ifdef DEBUG - *logofs << name() << ": Decoding char with i = " << i - << ".\n" << logofs_flush; - #endif - - *next++ = clientCache -> renderTextCompressor. - decodeChar(decodeBuffer); - } + #ifdef TEST + *logofs << name() << ": Decoded " << size - offset + << " bytes of text data.\n" << logofs_flush; + #endif } void RenderMinorExtensionStore::parseIntData(const Message *message, const unsigned char *buffer, diff --git a/nxcomp/RenderExtension.h b/nxcomp/RenderExtension.h index 275ef1c1d..2b616e1e5 100644 --- a/nxcomp/RenderExtension.h +++ b/nxcomp/RenderExtension.h @@ -44,7 +44,6 @@ #define RENDEREXTENSION_DATA_LIMIT 6144 #define RENDEREXTENSION_DATA_OFFSET 36 -#define RENDEREXTENSION_CACHE_SLOTS 6000 #define RENDEREXTENSION_CACHE_THRESHOLD 20 #define RENDEREXTENSION_CACHE_LOWER_THRESHOLD 10 diff --git a/nxcomp/ServerCache.cpp b/nxcomp/ServerCache.cpp index f0cc6f825..104ac4728 100644 --- a/nxcomp/ServerCache.cpp +++ b/nxcomp/ServerCache.cpp @@ -71,7 +71,6 @@ ServerCache::ServerCache() : getKeyboardMappingKeysymCache(8), getPropertyTypeCache(8), - getPropertyTextCompressor(textCache, SERVER_TEXT_CACHE_SIZE), getSelectionOwnerCache(8), @@ -85,9 +84,7 @@ ServerCache::ServerCache() : translateCoordsChildCache(8), translateCoordsXCache(8), translateCoordsYCache(8), - queryTreeWindowCache(8), - - getAtomNameTextCompressor(textCache, SERVER_TEXT_CACHE_SIZE) + queryTreeWindowCache(8) { unsigned int i; diff --git a/nxcomp/ServerCache.h b/nxcomp/ServerCache.h index ec213b89f..0968e235c 100644 --- a/nxcomp/ServerCache.h +++ b/nxcomp/ServerCache.h @@ -215,7 +215,6 @@ class ServerCache : public ChannelCache CharCache getPropertyFormatCache; IntCache getPropertyTypeCache; - TextCompressor getPropertyTextCompressor; static BlockCache xResources; // @@ -272,13 +271,6 @@ class ServerCache : public ChannelCache IntCache queryTreeWindowCache; - // - // GetAtomName reply in protocol - // versions >= 3. - // - - TextCompressor getAtomNameTextCompressor; - // // Generic reply. Use short data // in protocol versions >= 3. diff --git a/nxcomp/ServerChannel.cpp b/nxcomp/ServerChannel.cpp index 0f3a3e552..e0bd2132f 100644 --- a/nxcomp/ServerChannel.cpp +++ b/nxcomp/ServerChannel.cpp @@ -199,8 +199,6 @@ ServerChannel::ServerChannel(Transport *transport, StaticCompressor *compressor) splitState_.load = 1; splitState_.commit = 0; - handleSplitEnable(); - // // It will be eventually set by // the server proxy. @@ -394,19 +392,6 @@ int ServerChannel::handleRead(EncodeBuffer &encodeBuffer, const unsigned char *m priority_++; - // - // Due to the way the loop was implemented - // we can't encode multiple messages if we - // are encoding the first request. - // - - if (control -> isProtoStep7() == 0) - { - if (proxy -> handleAsyncInit() < 0) - { - return -1; - } - } } else { @@ -545,19 +530,8 @@ int ServerChannel::handleRead(EncodeBuffer &encodeBuffer, const unsigned char *m encodeBuffer.encodeValue(nameLength, 16, 6); const unsigned char *nextSrc = inputMessage + 32; - if (control -> isProtoStep7() == 1) - { - encodeBuffer.encodeTextData(nextSrc, nameLength); - } - else - { - serverCache_ -> getAtomNameTextCompressor.reset(); - for (unsigned int i = 0; i < nameLength; i++) - { - serverCache_ -> getAtomNameTextCompressor. - encodeChar(*nextSrc++, encodeBuffer); - } - } + // Since ProtoStep7 (#issue 108) + encodeBuffer.encodeTextData(nextSrc, nameLength); priority_++; } @@ -930,21 +904,10 @@ int ServerChannel::handleRead(EncodeBuffer &encodeBuffer, const unsigned char *m unsigned int length = (unsigned int) (*nextSrc++); encodeBuffer.encodeValue(length, 8); - if (control -> isProtoStep7() == 1) - { - encodeBuffer.encodeTextData(nextSrc, length); + // Since ProtoStep7 (#issue 108) + encodeBuffer.encodeTextData(nextSrc, length); - nextSrc += length; - } - else - { - serverCache_ -> getPropertyTextCompressor.reset(); - for (; length; length--) - { - serverCache_ -> getPropertyTextCompressor.encodeChar( - *nextSrc++, encodeBuffer); - } - } + nextSrc += length; } priority_++; @@ -1253,33 +1216,9 @@ int ServerChannel::handleRead(EncodeBuffer &encodeBuffer, const unsigned char *m encodeBuffer.encodeCachedValue(GetULONG(inputMessage + 8, bigEndian_), 29, serverCache_ -> visualCache); - if (control -> isProtoStep8() == 0) - { - unsigned int compressedDataSize = 0; - unsigned char *compressedData = NULL; - - int compressed = handleCompress(encodeBuffer, requestOpcode, messageStore -> dataOffset, - inputMessage, inputLength, compressedData, - compressedDataSize); - if (compressed < 0) - { - return -1; - } - else if (compressed > 0) - { - // - // Update size according to result of image compression. - // - - handleUpdate(messageStore, inputLength - messageStore -> - dataOffset, compressedDataSize); - } - } - else - { - handleCopy(encodeBuffer, requestOpcode, messageStore -> - dataOffset, inputMessage, inputLength); - } + // Since ProtoStep8 (#issue 108) + handleCopy(encodeBuffer, requestOpcode, messageStore -> + dataOffset, inputMessage, inputLength); priority_++; } @@ -2069,10 +2008,8 @@ int ServerChannel::handleWrite(const unsigned char *message, unsigned int length // encoding is used. // - if (control -> isProtoStep7() == 1) - { - decodeBuffer.decodeValue(length, 8); - } + // Since ProtoStep7 (#issue 108) + decodeBuffer.decodeValue(length, 8); unsigned int nextByte; unsigned char *outputMessage = writeBuffer_.addMessage(length); @@ -2285,19 +2222,8 @@ int ServerChannel::handleWrite(const unsigned char *message, unsigned int length if (format == 8) { - if (control -> isProtoStep7() == 1) - { - decodeBuffer.decodeTextData(nextDest, dataLength); - } - else - { - clientCache_ -> changePropertyTextCompressor.reset(); - for (unsigned int i = 0; i < dataLength; i++) - { - *nextDest++ = clientCache_ -> changePropertyTextCompressor. - decodeChar(decodeBuffer); - } - } + // Since ProtoStep7 (#issue 108) + decodeBuffer.decodeTextData(nextDest, dataLength); } else if (format == 32) { @@ -2584,16 +2510,10 @@ int ServerChannel::handleWrite(const unsigned char *message, unsigned int length outputMessage = writeBuffer_.addMessage(outputLength); writeBuffer_.registerPointer(&outputMessage); - if (control -> isProtoStep7() == 1) - { - decodeBuffer.decodeNewXidValue(value, clientCache_ -> lastId, - clientCache_ -> lastIdCache, clientCache_ -> gcCache, - clientCache_ -> freeGCCache); - } - else - { - decodeBuffer.decodeXidValue(value, clientCache_ -> gcCache); - } + // Since ProtoStep7 (#issue 108) + decodeBuffer.decodeNewXidValue(value, clientCache_ -> lastId, + clientCache_ -> lastIdCache, clientCache_ -> gcCache, + clientCache_ -> freeGCCache); PutULONG(value, outputMessage + 4, bigEndian_); unsigned int offset = 8; @@ -2688,16 +2608,10 @@ int ServerChannel::handleWrite(const unsigned char *message, unsigned int length decodeBuffer.decodeXidValue(value, clientCache_ -> windowCache); PutULONG(value, outputMessage + 8, bigEndian_); - if (control -> isProtoStep7() == 1) - { - decodeBuffer.decodeNewXidValue(value, clientCache_ -> lastId, - clientCache_ -> lastIdCache, clientCache_ -> windowCache, - clientCache_ -> freeWindowCache); - } - else - { - decodeBuffer.decodeXidValue(value, clientCache_ -> windowCache); - } + // Since ProtoStep7 (#issue 108) + decodeBuffer.decodeNewXidValue(value, clientCache_ -> lastId, + clientCache_ -> lastIdCache, clientCache_ -> windowCache, + clientCache_ -> freeWindowCache); PutULONG(value, outputMessage + 4, bigEndian_); unsigned char *nextDest = outputMessage + 12; @@ -2754,16 +2668,9 @@ int ServerChannel::handleWrite(const unsigned char *message, unsigned int length unsigned int numPoints; - if (control -> isProtoStep10() == 1) - { - decodeBuffer.decodeCachedValue(numPoints, 16, - clientCache_ -> fillPolyNumPointsCache, 4); - } - else - { - decodeBuffer.decodeCachedValue(numPoints, 14, - clientCache_ -> fillPolyNumPointsCache, 4); - } + // Since ProtoStep10 (#issue 108) + decodeBuffer.decodeCachedValue(numPoints, 16, + clientCache_ -> fillPolyNumPointsCache, 4); outputLength = 16 + (numPoints << 2); outputMessage = writeBuffer_.addMessage(outputLength); @@ -2859,14 +2766,8 @@ int ServerChannel::handleWrite(const unsigned char *message, unsigned int length outputLength = 8; outputMessage = writeBuffer_.addMessage(outputLength); - if (control -> isProtoStep7() == 1) - { - decodeBuffer.decodeFreeXidValue(value, clientCache_ -> freeGCCache); - } - else - { - decodeBuffer.decodeXidValue(value, clientCache_ -> gcCache); - } + // Since ProtoStep7 (#issue 108) + decodeBuffer.decodeFreeXidValue(value, clientCache_ -> freeGCCache); PutULONG(value, outputMessage + 4, bigEndian_); } @@ -2876,23 +2777,10 @@ int ServerChannel::handleWrite(const unsigned char *message, unsigned int length outputLength = 8; outputMessage = writeBuffer_.addMessage(outputLength); - if (control -> isProtoStep7() == 1) - { - decodeBuffer.decodeFreeXidValue(value, clientCache_ -> freeDrawableCache); + // Since ProtoStep7 (#issue 108) + decodeBuffer.decodeFreeXidValue(value, clientCache_ -> freeDrawableCache); - PutULONG(value, outputMessage + 4, bigEndian_); - } - else - { - decodeBuffer.decodeBoolValue(value); - if (!value) - { - decodeBuffer.decodeValue(value, 29, 4); - clientCache_ -> createPixmapLastId += value; - clientCache_ -> createPixmapLastId &= 0x1fffffff; - } - PutULONG(clientCache_ -> createPixmapLastId, outputMessage + 4, bigEndian_); - } + PutULONG(value, outputMessage + 4, bigEndian_); } break; case X_GetAtomName: @@ -3125,21 +3013,10 @@ int ServerChannel::handleWrite(const unsigned char *message, unsigned int length clientCache_ -> polyTextDeltaCache); *nextDest++ = cValue; - if (control -> isProtoStep7() == 1) - { - decodeBuffer.decodeTextData(nextDest, textLength); + // Since ProtoStep7 (#issue 108) + decodeBuffer.decodeTextData(nextDest, textLength); - nextDest += textLength; - } - else - { - clientCache_ -> polyTextTextCompressor.reset(); - while (textLength) - { - *nextDest++ = clientCache_ -> polyTextTextCompressor.decodeChar(decodeBuffer); - textLength--; - } - } + nextDest += textLength; } } outputLength += addedLength; @@ -3211,23 +3088,10 @@ int ServerChannel::handleWrite(const unsigned char *message, unsigned int length decodeBuffer.decodeCachedValue(cValue, 8, clientCache_ -> polyTextDeltaCache); *nextDest++ = cValue; - if (control -> isProtoStep7() == 1) - { - decodeBuffer.decodeTextData(nextDest, textLength * 2); + // Since ProtoStep7 (#issue 108) + decodeBuffer.decodeTextData(nextDest, textLength * 2); - nextDest += textLength * 2; - } - else - { - clientCache_ -> polyTextTextCompressor.reset(); - textLength <<= 1; - while (textLength) - { - *nextDest++ = - clientCache_ -> polyTextTextCompressor.decodeChar(decodeBuffer); - textLength--; - } - } + nextDest += textLength * 2; } } outputLength += addedLength; @@ -3279,16 +3143,8 @@ int ServerChannel::handleWrite(const unsigned char *message, unsigned int length PutUINT(clientCache_ -> imageTextLastY, outputMessage + 14, bigEndian_); unsigned char *nextDest = outputMessage + 16; - if (control -> isProtoStep7() == 1) - { - decodeBuffer.decodeTextData(nextDest, textLength); - } - else - { - clientCache_ -> imageTextTextCompressor.reset(); - for (unsigned int j = 0; j < textLength; j++) - *nextDest++ = clientCache_ -> imageTextTextCompressor.decodeChar(decodeBuffer); - } + // Since ProtoStep7 (#issue 108) + decodeBuffer.decodeTextData(nextDest, textLength); handleSave(messageStore, outputMessage, outputLength); } @@ -3326,16 +3182,8 @@ int ServerChannel::handleWrite(const unsigned char *message, unsigned int length PutUINT(clientCache_ -> imageTextLastY, outputMessage + 14, bigEndian_); unsigned char *nextDest = outputMessage + 16; - if (control -> isProtoStep7() == 1) - { - decodeBuffer.decodeTextData(nextDest, textLength * 2); - } - else - { - clientCache_ -> imageTextTextCompressor.reset(); - for (unsigned int j = 0; j < textLength * 2; j++) - *nextDest++ = clientCache_ -> imageTextTextCompressor.decodeChar(decodeBuffer); - } + // Since ProtoStep7 (#issue 108) + decodeBuffer.decodeTextData(nextDest, textLength * 2); handleSave(messageStore, outputMessage, outputLength); } @@ -3362,18 +3210,8 @@ int ServerChannel::handleWrite(const unsigned char *message, unsigned int length outputMessage[1] = (unsigned char) value; unsigned char *nextDest = outputMessage + 8; - if (control -> isProtoStep7() == 1) - { - decodeBuffer.decodeTextData(nextDest, nameLength); - } - else - { - clientCache_ -> internAtomTextCompressor.reset(); - for (unsigned int i = 0; i < nameLength; i++) - { - *nextDest++ = clientCache_ -> internAtomTextCompressor.decodeChar(decodeBuffer); - } - } + // Since ProtoStep7 (#issue 108) + decodeBuffer.decodeTextData(nextDest, nameLength); sequenceQueue_.push(clientSequence_, outputOpcode); @@ -3399,18 +3237,8 @@ int ServerChannel::handleWrite(const unsigned char *message, unsigned int length PutUINT(value, outputMessage + 4, bigEndian_); unsigned char* nextDest = outputMessage + 8; - if (control -> isProtoStep7() == 1) - { - decodeBuffer.decodeTextData(nextDest, textLength); - } - else - { - clientCache_ -> polyTextTextCompressor.reset(); - for (unsigned int i = 0; i < textLength; i++) - { - *nextDest++ = clientCache_ -> polyTextTextCompressor.decodeChar(decodeBuffer); - } - } + // Since ProtoStep7 (#issue 108) + decodeBuffer.decodeTextData(nextDest, textLength); sequenceQueue_.push(clientSequence_, outputOpcode); } @@ -3428,18 +3256,8 @@ int ServerChannel::handleWrite(const unsigned char *message, unsigned int length PutUINT(textLength, outputMessage + 8, bigEndian_); unsigned char *nextDest = outputMessage + 12; - if (control -> isProtoStep7() == 1) - { - decodeBuffer.decodeTextData(nextDest, textLength); - } - else - { - clientCache_ -> polyTextTextCompressor.reset(); - for (unsigned int i = 0; i < textLength; i++) - { - *nextDest++ = clientCache_ -> polyTextTextCompressor.decodeChar(decodeBuffer); - } - } + // Since ProtoStep7 (#issue 108) + decodeBuffer.decodeTextData(nextDest, textLength); sequenceQueue_.push(clientSequence_, outputOpcode); } @@ -3456,7 +3274,7 @@ int ServerChannel::handleWrite(const unsigned char *message, unsigned int length outputLength = 8; outputMessage = writeBuffer_.addMessage(outputLength); - if (outputOpcode == X_DestroyWindow && control -> isProtoStep7() == 1) + if (outputOpcode == X_DestroyWindow) // Since ProtoStep7 (#issue 108) { decodeBuffer.decodeFreeXidValue(value, clientCache_ -> freeWindowCache); } @@ -3487,19 +3305,8 @@ int ServerChannel::handleWrite(const unsigned char *message, unsigned int length PutULONG(clientCache_ -> lastFont, outputMessage + 4, bigEndian_); unsigned char *nextDest = outputMessage + 12; - if (control -> isProtoStep7() == 1) - { - decodeBuffer.decodeTextData(nextDest, nameLength); - } - else - { - clientCache_ -> openFontTextCompressor.reset(); - for (; nameLength; nameLength--) - { - *nextDest++ = clientCache_ -> openFontTextCompressor. - decodeChar(decodeBuffer); - } - } + // Since ProtoStep7 (#issue 108) + decodeBuffer.decodeTextData(nextDest, nameLength); } break; case X_PolyFillRectangle: @@ -4137,14 +3944,8 @@ int ServerChannel::handleWrite(const unsigned char *message, unsigned int length unsigned int numRectangles; - if (control -> isProtoStep9() == 1) - { - decodeBuffer.decodeValue(numRectangles, 15, 4); - } - else - { - decodeBuffer.decodeValue(numRectangles, 13, 4); - } + // Since ProtoStep9 (#issue 108) + decodeBuffer.decodeValue(numRectangles, 15, 4); outputLength = (numRectangles << 3) + 12; outputMessage = writeBuffer_.addMessage(outputLength); @@ -4669,10 +4470,8 @@ int ServerChannel::handleSplit(DecodeBuffer &decodeBuffer, MessageStore *store, T_store_action action, int position, unsigned char &opcode, unsigned char *&buffer, unsigned int &size) { - if (control -> isProtoStep7() == 1) - { - splitState_.current = splitState_.resource; - } + // Since ProtoStep7 (#issue 108) + splitState_.current = splitState_.resource; handleSplitStoreAlloc(&splitResources_, splitState_.current); @@ -4707,14 +4506,12 @@ int ServerChannel::handleSplit(DecodeBuffer &decodeBuffer, MessageStore *store, action, checksum, buffer, size); // - // If we are connected to an old proxy - // version or the encoding side didn't - // provide a checksum, then don't send - // the split report. + // If the encoding side didn't provide + // a checksum, then don't send the split + // report. // - if (control -> isProtoStep7() == 0 || - checksum == NULL) + if (checksum == NULL) { if (action == IS_HIT) { @@ -4736,8 +4533,6 @@ int ServerChannel::handleSplit(DecodeBuffer &decodeBuffer, MessageStore *store, #endif - delete [] checksum; - return 1; } @@ -4829,13 +4624,11 @@ int ServerChannel::handleSplit(DecodeBuffer &decodeBuffer) unsigned char resource; - if (control -> isProtoStep7() == 1) - { - decodeBuffer.decodeCachedValue(resource, 8, - clientCache_ -> resourceCache); + // Since ProtoStep7 (#issue 108) + decodeBuffer.decodeCachedValue(resource, 8, + clientCache_ -> resourceCache); - splitState_.current = resource; - } + splitState_.current = resource; handleSplitStoreAlloc(&splitResources_, splitState_.current); @@ -5391,8 +5184,11 @@ int ServerChannel::handleColormap(unsigned char &opcode, unsigned char *&buffer, // data in compressed form. // - if (control -> isProtoStep7() == 1) - { + // + // Since ProtoStep7 (#issue 108) + // + + { // An anonymous block is used here to limit the scope of local variables unsigned int packed = GetULONG(buffer + 8, bigEndian_); unsigned int unpacked = GetULONG(buffer + 12, bigEndian_); @@ -5486,85 +5282,7 @@ int ServerChannel::handleColormap(unsigned char &opcode, unsigned char *&buffer, } #endif - } - else - { - unsigned int entries = GetULONG(buffer + 4, bigEndian_); - - if (size == entries * 4 + 8) - { - if (unpackState_[resource] -> colormap -> entries != entries && - unpackState_[resource] -> colormap -> data != NULL) - { - #ifdef TEST - *logofs << "handleColormap: Freeing previously " - << "allocated unpack colormap.\n" - << logofs_flush; - #endif - - delete [] unpackState_[resource] -> colormap -> data; - - unpackState_[resource] -> colormap -> data = NULL; - unpackState_[resource] -> colormap -> entries = 0; - } - - if (entries > 0) - { - if (unpackState_[resource] -> colormap -> data == NULL) - { - unpackState_[resource] -> - colormap -> data = new unsigned int[entries]; - } - - if (unpackState_[resource] -> colormap -> data != NULL) - { - unpackState_[resource] -> colormap -> entries = entries; - - #ifdef DEBUG - *logofs << "handleColormap: Size of new colormap " - << "data is " << (entries << 2) << ".\n" - << logofs_flush; - #endif - - memcpy((unsigned char *) unpackState_[resource] -> - colormap -> data, buffer + 8, entries << 2); - - #if defined(DEBUG) && defined(DUMP) - - *logofs << "handleColormap: Dumping colormap entries:\n" - << logofs_flush; - - const unsigned int *p = (unsigned int *) buffer + 8; - - for (unsigned int i = 0; i < entries; i++) - { - *logofs << "handleColormap: [" << i << "] [" - << (void *) p[i] << "].\n" - << logofs_flush; - } - - #endif - } - else - { - #ifdef PANIC - *logofs << "handleColormap: PANIC! Can't allocate " - << entries << " entries for unpack colormap " - << "for FD#" << fd_ << ".\n" << logofs_flush; - #endif - } - } - } - else - { - #ifdef PANIC - *logofs << "handleColormap: PANIC! Bad size " << size - << " for set unpack colormap message for FD#" - << fd_ << " with " << entries << " entries.\n" - << logofs_flush; - #endif - } - } + } // end anonymous block handleColormapEnd: @@ -5593,8 +5311,11 @@ int ServerChannel::handleAlpha(unsigned char &opcode, unsigned char *&buffer, // data in compressed form. // - if (control -> isProtoStep7() == 1) - { + // + // Since ProtoStep7 (#issue 108) + // + + { // An anonymous block is used here to limit the scope of local variables unsigned int packed = GetULONG(buffer + 8, bigEndian_); unsigned int unpacked = GetULONG(buffer + 12, bigEndian_); @@ -5687,82 +5408,7 @@ int ServerChannel::handleAlpha(unsigned char &opcode, unsigned char *&buffer, } #endif - } - else - { - unsigned int entries = GetULONG(buffer + 4, bigEndian_); - - if (size == RoundUp4(entries) + 8) - { - if (unpackState_[resource] -> alpha -> entries != entries && - unpackState_[resource] -> alpha -> data != NULL) - { - #ifdef TEST - *logofs << "handleAlpha: Freeing previously allocated " - << "unpack alpha data.\n" << logofs_flush; - #endif - - delete [] unpackState_[resource] -> alpha -> data; - - unpackState_[resource] -> alpha -> data = NULL; - unpackState_[resource] -> alpha -> entries = 0; - } - - if (entries > 0) - { - if (unpackState_[resource] -> alpha -> data == NULL) - { - unpackState_[resource] -> alpha -> data = new unsigned char[entries]; - } - - if (unpackState_[resource] -> alpha -> data != NULL) - { - unpackState_[resource] -> alpha -> entries = entries; - - #ifdef DEBUG - *logofs << "handleAlpha: Size of new alpha data is " - << entries << ".\n" << logofs_flush; - #endif - - memcpy((unsigned char *) unpackState_[resource] -> - alpha -> data, buffer + 8, entries); - - #if defined(DEBUG) && defined(DUMP) - - *logofs << "handleAlpha: Dumping alpha entries:\n" - << logofs_flush; - - const unsigned char *p = buffer + 8; - - for (unsigned int i = 0; i < entries; i++) - { - *logofs << "handleAlpha: [" << i << "] [" - << (void *) ((int) p[i]) << "].\n" - << logofs_flush; - } - - #endif - } - else - { - #ifdef PANIC - *logofs << "handleAlpha: PANIC! Can't allocate " - << entries << " entries for unpack alpha data " - << "for FD#" << fd_ << ".\n" << logofs_flush; - #endif - } - } - } - #ifdef PANIC - else - { - *logofs << "handleAlpha: PANIC! Bad size " << size - << " for set unpack alpha message for FD#" - << fd_ << " with " << entries << " entries.\n" - << logofs_flush; - } - #endif - } + } //end anonymous block handleAlphaEnd: @@ -6680,15 +6326,20 @@ int ServerChannel::handleFastWriteRequest(DecodeBuffer &decodeBuffer, unsigned c { // // All the NX requests are handled in the - // main message loop. The X_PutImage can - // be handled here only if a split was - // not requested. + // main message loop. + // + + // + // Since ProtoStep7 (#issue 108) + // + // The X_PutImage can be handled here only + // if a split was not requested. // if ((opcode >= X_NXFirstOpcode && opcode <= X_NXLastOpcode) || - (control -> isProtoStep7() == 1 && opcode == X_PutImage && - splitState_.resource != nothing) || opcode == X_ListExtensions || - opcode == X_QueryExtension) + (opcode == X_PutImage && splitState_.resource != nothing) || + opcode == X_ListExtensions || + opcode == X_QueryExtension) { return 0; } @@ -7896,14 +7547,6 @@ int ServerChannel::handleCacheRequest(DecodeBuffer &decodeBuffer, unsigned char splitState_.save = (mask >> 8) & 0xff; splitState_.load = mask & 0xff; - // - // Just to be sure. We should never - // receive this request if connected - // to an old proxy version. - // - - handleSplitEnable(); - #ifdef TEST *logofs << "handleCacheRequest: Set cache parameters to " << "save " << splitState_.save << " load " @@ -7920,34 +7563,24 @@ int ServerChannel::handleStartSplitRequest(DecodeBuffer &decodeBuffer, unsigned { // // Prepare for the split for the selected - // resource. Old proxy versions only use + // resource. Old proxy versions only used // the split store at position 0. // - if (control -> isProtoStep7() == 1) - { - unsigned char resource; + // Since ProtoStep7 (#issue 108) + unsigned char resource; - decodeBuffer.decodeCachedValue(resource, 8, - clientCache_ -> resourceCache); + decodeBuffer.decodeCachedValue(resource, 8, + clientCache_ -> resourceCache); - splitState_.resource = resource; + splitState_.resource = resource; - splitState_.current = splitState_.resource; + splitState_.current = splitState_.resource; - #if defined(TEST) || defined(SPLIT) - *logofs << "handleStartSplitRequest: SPLIT! Registered id " - << splitState_.resource << " as resource " - << "waiting for a split.\n" << logofs_flush; - #endif - } #if defined(TEST) || defined(SPLIT) - else - { - *logofs << "handleStartSplitRequest: SPLIT! Assuming fake id " - << splitState_.current << " as resource " - << "waiting for a split.\n" << logofs_flush; - } + *logofs << "handleStartSplitRequest: SPLIT! Registered id " + << splitState_.resource << " as resource " + << "waiting for a split.\n" << logofs_flush; #endif handleNullRequest(opcode, buffer, size); @@ -7962,40 +7595,38 @@ int ServerChannel::handleEndSplitRequest(DecodeBuffer &decodeBuffer, unsigned ch // Verify that the agent resource matches. // - if (control -> isProtoStep7() == 1) - { - unsigned char resource; - - decodeBuffer.decodeCachedValue(resource, 8, - clientCache_ -> resourceCache); - - #ifdef TEST + // Since ProtoStep7 (#issue 108) + unsigned char resource; - if (splitState_.resource == nothing) - { - #ifdef PANIC - *logofs << "handleEndSplitRequest: PANIC! SPLIT! Received an end of " - << "split for resource id " << (unsigned int) *(buffer + 1) - << " without a previous start.\n" - << logofs_flush; - #endif + decodeBuffer.decodeCachedValue(resource, 8, + clientCache_ -> resourceCache); - HandleCleanup(); - } - else if (resource != splitState_.resource) - { - #ifdef PANIC - *logofs << "handleEndSplitRequest: PANIC! SPLIT! Invalid resource id " - << resource << " received while waiting for resource id " - << splitState_.resource << ".\n" << logofs_flush; - #endif + #ifdef TEST - HandleCleanup(); - } + if (splitState_.resource == nothing) + { + #ifdef PANIC + *logofs << "handleEndSplitRequest: PANIC! SPLIT! Received an end of " + << "split for resource id " << (unsigned int) *(buffer + 1) + << " without a previous start.\n" + << logofs_flush; + #endif + HandleCleanup(); + } + else if (resource != splitState_.resource) + { + #ifdef PANIC + *logofs << "handleEndSplitRequest: PANIC! SPLIT! Invalid resource id " + << resource << " received while waiting for resource id " + << splitState_.resource << ".\n" << logofs_flush; #endif + + HandleCleanup(); } + #endif + #if defined(TEST) || defined(SPLIT) *logofs << "handleEndSplitRequest: SPLIT! Reset id " << splitState_.resource << " as resource " @@ -8013,15 +7644,8 @@ int ServerChannel::handleSplitChecksum(DecodeBuffer &decodeBuffer, T_checksum &c { unsigned int receive; - if (control -> isProtoStep7() == 1) - { - decodeBuffer.decodeBoolValue(receive); - } - else - { - receive = (control -> ImageCacheEnableLoad == 1 || - control -> ImageCacheEnableSave == 1); - } + // Since ProtoStep7 (#issue 108) + decodeBuffer.decodeBoolValue(receive); if (receive == 1) { diff --git a/nxcomp/ServerChannel.h b/nxcomp/ServerChannel.h index 6536db829..28d5efb3e 100644 --- a/nxcomp/ServerChannel.h +++ b/nxcomp/ServerChannel.h @@ -312,21 +312,6 @@ class ServerChannel : public Channel int handleSplitChecksum(DecodeBuffer &decodeBuffer, T_checksum &checksum); - void handleSplitEnable() - { - if (control -> isProtoStep7() == 0) - { - #if defined(TEST) || defined(SPLIT) - *logofs << "handleSplitEnable: WARNING! Disabling load " - << "and save with an old proxy version.\n" - << logofs_flush; - #endif - - splitState_.save = 0; - splitState_.load = 0; - } - } - // // Allocate and free the shared memory // support resources. diff --git a/nxcomp/ServerProxy.h b/nxcomp/ServerProxy.h index 8c4a88410..54bc0f748 100644 --- a/nxcomp/ServerProxy.h +++ b/nxcomp/ServerProxy.h @@ -102,14 +102,8 @@ class ServerProxy : public Proxy virtual int checkLocalChannelMap(int channelId) { - if (control -> isProtoStep7() == 1) - { - return ((channelId & control -> ChannelMask) == 0); - } - else - { - return 0; - } + // Since ProtoStep7 (#issue 108) + return ((channelId & control -> ChannelMask) == 0); } private: diff --git a/nxcomp/SetUnpackAlpha.cpp b/nxcomp/SetUnpackAlpha.cpp index a0dd1fc2e..792aa33d7 100644 --- a/nxcomp/SetUnpackAlpha.cpp +++ b/nxcomp/SetUnpackAlpha.cpp @@ -44,7 +44,6 @@ SetUnpackAlphaStore::SetUnpackAlphaStore(StaticCompressor *compressor) { enableCache = SETUNPACKALPHA_ENABLE_CACHE; enableData = SETUNPACKALPHA_ENABLE_DATA; - enableSplit = SETUNPACKALPHA_ENABLE_SPLIT_IF_PROTO_STEP_7; enableCompress = SETUNPACKALPHA_ENABLE_COMPRESS_IF_PROTO_STEP_7; dataLimit = SETUNPACKALPHA_DATA_LIMIT; @@ -54,10 +53,8 @@ SetUnpackAlphaStore::SetUnpackAlphaStore(StaticCompressor *compressor) cacheThreshold = SETUNPACKALPHA_CACHE_THRESHOLD; cacheLowerThreshold = SETUNPACKALPHA_CACHE_LOWER_THRESHOLD; - if (control -> isProtoStep8() == 1) - { - enableSplit = SETUNPACKALPHA_ENABLE_SPLIT_IF_PROTO_STEP_8; - } + // Since ProtoStep8 (#issue 108) + enableSplit = SETUNPACKALPHA_ENABLE_SPLIT_IF_PROTO_STEP_8; messages_ -> resize(cacheSlots); diff --git a/nxcomp/SetUnpackAlpha.h b/nxcomp/SetUnpackAlpha.h index 2e32a6590..4c4306d8d 100644 --- a/nxcomp/SetUnpackAlpha.h +++ b/nxcomp/SetUnpackAlpha.h @@ -36,18 +36,14 @@ #define SETUNPACKALPHA_ENABLE_CACHE 1 #define SETUNPACKALPHA_ENABLE_DATA 1 -#define SETUNPACKALPHA_ENABLE_SPLIT 0 -#define SETUNPACKALPHA_ENABLE_COMPRESS 1 #define SETUNPACKALPHA_DATA_LIMIT 16384 -#define SETUNPACKALPHA_DATA_OFFSET 8 #define SETUNPACKALPHA_CACHE_SLOTS 2000 #define SETUNPACKALPHA_CACHE_THRESHOLD 10 #define SETUNPACKALPHA_CACHE_LOWER_THRESHOLD 5 #define SETUNPACKALPHA_DATA_OFFSET_IF_PROTO_STEP_7 16 -#define SETUNPACKALPHA_ENABLE_SPLIT_IF_PROTO_STEP_7 1 #define SETUNPACKALPHA_ENABLE_COMPRESS_IF_PROTO_STEP_7 0 #define SETUNPACKALPHA_ENABLE_SPLIT_IF_PROTO_STEP_8 0 diff --git a/nxcomp/SetUnpackColormap.cpp b/nxcomp/SetUnpackColormap.cpp index d522d328e..8fb8b3ce7 100644 --- a/nxcomp/SetUnpackColormap.cpp +++ b/nxcomp/SetUnpackColormap.cpp @@ -44,7 +44,6 @@ SetUnpackColormapStore::SetUnpackColormapStore(StaticCompressor *compressor) { enableCache = SETUNPACKCOLORMAP_ENABLE_CACHE; enableData = SETUNPACKCOLORMAP_ENABLE_DATA; - enableSplit = SETUNPACKCOLORMAP_ENABLE_SPLIT; enableCompress = SETUNPACKCOLORMAP_ENABLE_COMPRESS_IF_PROTO_STEP_7; dataLimit = SETUNPACKCOLORMAP_DATA_LIMIT; @@ -54,10 +53,8 @@ SetUnpackColormapStore::SetUnpackColormapStore(StaticCompressor *compressor) cacheThreshold = SETUNPACKCOLORMAP_CACHE_THRESHOLD; cacheLowerThreshold = SETUNPACKCOLORMAP_CACHE_LOWER_THRESHOLD; - if (control -> isProtoStep8() == 1) - { - enableSplit = SETUNPACKCOLORMAP_ENABLE_SPLIT_IF_PROTO_STEP_8; - } + // Since ProtoStep8 (#issue 108) + enableSplit = SETUNPACKCOLORMAP_ENABLE_SPLIT_IF_PROTO_STEP_8; messages_ -> resize(cacheSlots); diff --git a/nxcomp/SetUnpackColormap.h b/nxcomp/SetUnpackColormap.h index 53277b3f0..fda7fa16d 100644 --- a/nxcomp/SetUnpackColormap.h +++ b/nxcomp/SetUnpackColormap.h @@ -36,11 +36,8 @@ #define SETUNPACKCOLORMAP_ENABLE_CACHE 1 #define SETUNPACKCOLORMAP_ENABLE_DATA 1 -#define SETUNPACKCOLORMAP_ENABLE_SPLIT 1 -#define SETUNPACKCOLORMAP_ENABLE_COMPRESS 1 #define SETUNPACKCOLORMAP_DATA_LIMIT 4096 -#define SETUNPACKCOLORMAP_DATA_OFFSET 8 #define SETUNPACKCOLORMAP_CACHE_SLOTS 2000 #define SETUNPACKCOLORMAP_CACHE_THRESHOLD 5 diff --git a/nxcomp/ShapeExtension.cpp b/nxcomp/ShapeExtension.cpp index daa19fbb4..34fad27c9 100644 --- a/nxcomp/ShapeExtension.cpp +++ b/nxcomp/ShapeExtension.cpp @@ -45,12 +45,9 @@ ShapeExtensionStore::ShapeExtensionStore(StaticCompressor *compressor) enableCache = SHAPEEXTENSION_ENABLE_CACHE; enableData = SHAPEEXTENSION_ENABLE_DATA; enableSplit = SHAPEEXTENSION_ENABLE_SPLIT; - enableCompress = SHAPEEXTENSION_ENABLE_COMPRESS; - if (control -> isProtoStep7() == 1) - { - enableCompress = SHAPEEXTENSION_ENABLE_COMPRESS_IF_PROTO_STEP_7; - } + // Since ProtoStep7 (#issue 108) + enableCompress = SHAPEEXTENSION_ENABLE_COMPRESS_IF_PROTO_STEP_7; dataLimit = SHAPEEXTENSION_DATA_LIMIT; dataOffset = SHAPEEXTENSION_DATA_OFFSET; diff --git a/nxcomp/ShapeExtension.h b/nxcomp/ShapeExtension.h index 32c3b55ef..41fe48113 100644 --- a/nxcomp/ShapeExtension.h +++ b/nxcomp/ShapeExtension.h @@ -37,7 +37,6 @@ #define SHAPEEXTENSION_ENABLE_CACHE 1 #define SHAPEEXTENSION_ENABLE_DATA 1 #define SHAPEEXTENSION_ENABLE_SPLIT 0 -#define SHAPEEXTENSION_ENABLE_COMPRESS 1 #define SHAPEEXTENSION_DATA_LIMIT 3200 #define SHAPEEXTENSION_DATA_OFFSET 20 diff --git a/nxcomp/Split.cpp b/nxcomp/Split.cpp index 35a4ed4a2..607544312 100644 --- a/nxcomp/Split.cpp +++ b/nxcomp/Split.cpp @@ -748,27 +748,8 @@ int SplitStore::start(DecodeBuffer &decodeBuffer) // Get the compressed size. // - if (control -> isProtoStep7() == 1) - { - decodeBuffer.decodeValue(compressedSize, 32, 14); - } - else - { - // - // As we can't refuse to handle the decoding - // of the split message when connected to an - // old proxy version, we need to decode this - // in a way that is compatible. - // - - unsigned int diffSize; - - decodeBuffer.decodeValue(diffSize, 32, 14); - - split -> store_ -> lastResize += diffSize; - - compressedSize = split -> store_ -> lastResize; - } + // Since ProtoStep7 (#issue 108) + decodeBuffer.decodeValue(compressedSize, 32, 14); split -> store_ -> validateSize(split -> d_size_, compressedSize); diff --git a/nxcomp/Types.h b/nxcomp/Types.h index b7506124e..f4a3eb399 100644 --- a/nxcomp/Types.h +++ b/nxcomp/Types.h @@ -199,18 +199,18 @@ T_buffer; // received at the decoding side. // +// Since ProtoStep8 (#issue 108) enum T_store_action { is_hit, is_added, is_discarded, - is_removed, - is_added_compat = 0, - is_hit_compat = 1 + is_removed }; -#define IS_HIT (control -> isProtoStep8() == 1 ? is_hit : is_hit_compat) -#define IS_ADDED (control -> isProtoStep8() == 1 ? is_added : is_added_compat) +// Since ProtoStep8 (#issue 108) +#define IS_HIT is_hit +#define IS_ADDED is_added enum T_checksum_action { -- cgit v1.2.3