Skip to content

Commit

Permalink
#1232: part 1, add LargeStructure wrapper for items that make the pac…
Browse files Browse the repository at this point in the history
…kets quite big but that we know about and don't want to see warnings for

git-svn-id: https://xpra.org/svn/Xpra/trunk@12877 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jun 21, 2016
1 parent 5b8746e commit fc21061
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/xpra/net/compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,16 @@ def __repr__(self):
return "LevelCompressed(%s: %i bytes as %s/%i)" % (self.datatype, len(self.data), self.algorithm, self.level)


class Uncompressed(object):
class LargeStructure(object):
def __init__(self, datatype, data):
self.datatype = datatype
self.data = data
def __len__(self):
return len(self.data)
def __repr__(self):
return "LargeStructure(%s: %i bytes)" % (self.datatype, len(self.data))

class Uncompressed(LargeStructure):
def __repr__(self):
return "Uncompressed(%s: %i bytes)" % (self.datatype, len(self.data))
def compress(self):
Expand Down
9 changes: 7 additions & 2 deletions src/xpra/net/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from xpra.net import compression
from xpra.net import packet_encoding
from xpra.net.compression import get_compression_caps, decompress, sanity_checks as compression_sanity_checks,\
InvalidCompressionException, Compressed, LevelCompressed, Uncompressed
InvalidCompressionException, Compressed, LevelCompressed, Uncompressed, LargeStructure
from xpra.net.packet_encoding import get_packet_encoding_caps, decode, sanity_checks as packet_encoding_sanity_checks, InvalidPacketEncodingException
from xpra.net.header import unpack_header, pack_header, FLAGS_CIPHER, FLAGS_NOHEADER
from xpra.net.crypto import get_crypto_caps, get_encryptor, get_decryptor, pad, INITIAL_PADDING
Expand Down Expand Up @@ -483,7 +483,12 @@ def encode(self, packet_in):
l = len(item)
except TypeError as e:
raise TypeError("invalid type %s in %s packet at index %s: %s" % (ti, packet[0], i, e))
if ti==Uncompressed:
if ti==LargeStructure:
item = item.data
packet[i] = item
ti = type(item)
continue
elif ti==Uncompressed:
#this is a marker used to tell us we should compress it now
#(used by the client for clipboard data)
item = item.compress()
Expand Down

0 comments on commit fc21061

Please sign in to comment.