1 /**************************************************************************/ 2 /* */ 3 /* Copyright (c) 2001, 2011 NoMachine (http://www.nomachine.com) */ 4 /* Copyright (c) 2008-2014 Oleksandr Shneyder <o.shneyder@phoca-gmbh.de> */ 5 /* Copyright (c) 2014-2016 Ulrich Sibiller <uli42@gmx.de> */ 6 /* Copyright (c) 2014-2016 Mihai Moldovan <ionic@ionic.de> */ 7 /* Copyright (c) 2011-2016 Mike Gabriel <mike.gabriel@das-netzwerkteam.de>*/ 8 /* Copyright (c) 2015-2016 Qindel Group (http://www.qindel.com) */ 9 /* */ 10 /* NXCOMP, NX protocol compression and NX extensions to this software */ 11 /* are copyright of the aforementioned persons and companies. */ 12 /* */ 13 /* Redistribution and use of the present software is allowed according */ 14 /* to terms specified in the file LICENSE.nxcomp which comes in the */ 15 /* source distribution. */ 16 /* */ 17 /* All rights reserved. */ 18 /* */ 19 /* NOTE: This software has received contributions from various other */ 20 /* contributors, only the core maintainers and supporters are listed as */ 21 /* copyright holders. Please contact us, if you feel you should be listed */ 22 /* as copyright holder, as well. */ 23 /* */ 24 /**************************************************************************/ 25 26 #ifndef PolySegment_H 27 #define PolySegment_H 28 29 #include "Message.h" 30 31 // 32 // Set the verbosity level. 33 // 34 35 #define PANIC 36 #define WARNING 37 #undef TEST 38 #undef DEBUG 39 #undef DUMP 40 41 // 42 // Set default values. 43 // 44 45 #define POLYSEGMENT_ENABLE_CACHE 1 46 #define POLYSEGMENT_ENABLE_DATA 0 47 #define POLYSEGMENT_ENABLE_SPLIT 0 48 #define POLYSEGMENT_ENABLE_COMPRESS 0 49 50 #define POLYSEGMENT_DATA_LIMIT 8192 51 #define POLYSEGMENT_DATA_OFFSET 12 52 53 #define POLYSEGMENT_CACHE_SLOTS 3000 54 #define POLYSEGMENT_CACHE_THRESHOLD 5 55 #define POLYSEGMENT_CACHE_LOWER_THRESHOLD 1 56 57 // 58 // The message class. 59 // 60 61 class PolySegmentMessage : public Message 62 { 63 friend class PolySegmentStore; 64 65 public: 66 PolySegmentMessage()67 PolySegmentMessage() 68 { 69 } 70 ~PolySegmentMessage()71 ~PolySegmentMessage() 72 { 73 } 74 75 // 76 // Put here the fields which constitute 77 // the 'identity' part of the message. 78 // 79 80 private: 81 82 unsigned int drawable; 83 unsigned int gcontext; 84 }; 85 86 class PolySegmentStore : public MessageStore 87 { 88 // 89 // Constructors and destructors. 90 // 91 92 public: 93 PolySegmentStore()94 PolySegmentStore() : MessageStore() 95 { 96 enableCache = POLYSEGMENT_ENABLE_CACHE; 97 enableData = POLYSEGMENT_ENABLE_DATA; 98 enableSplit = POLYSEGMENT_ENABLE_SPLIT; 99 enableCompress = POLYSEGMENT_ENABLE_COMPRESS; 100 101 dataLimit = POLYSEGMENT_DATA_LIMIT; 102 dataOffset = POLYSEGMENT_DATA_OFFSET; 103 104 cacheSlots = POLYSEGMENT_CACHE_SLOTS; 105 cacheThreshold = POLYSEGMENT_CACHE_THRESHOLD; 106 cacheLowerThreshold = POLYSEGMENT_CACHE_LOWER_THRESHOLD; 107 108 messages_ -> resize(cacheSlots); 109 110 for (T_messages::iterator i = messages_ -> begin(); 111 i < messages_ -> end(); i++) 112 { 113 *i = NULL; 114 } 115 116 temporary_ = NULL; 117 } 118 ~PolySegmentStore()119 virtual ~PolySegmentStore() 120 { 121 for (T_messages::iterator i = messages_ -> begin(); 122 i < messages_ -> end(); i++) 123 { 124 destroy(*i); 125 } 126 127 destroy(temporary_); 128 } 129 name()130 virtual const char *name() const 131 { 132 return "PolySegment"; 133 } 134 opcode()135 virtual unsigned char opcode() const 136 { 137 return X_PolySegment; 138 } 139 storage()140 virtual unsigned int storage() const 141 { 142 return sizeof(PolySegmentMessage); 143 } 144 145 // 146 // Message handling methods. 147 // 148 149 public: 150 create()151 virtual Message *create() const 152 { 153 return new PolySegmentMessage(); 154 } 155 create(const Message & message)156 virtual Message *create(const Message &message) const 157 { 158 return new PolySegmentMessage((const PolySegmentMessage &) message); 159 } 160 destroy(Message * message)161 virtual void destroy(Message *message) const 162 { 163 delete (PolySegmentMessage *) message; 164 } 165 166 virtual int parseIdentity(Message *message, const unsigned char *buffer, 167 unsigned int size, int bigEndian) const; 168 169 virtual int unparseIdentity(const Message *message, unsigned char *buffer, 170 unsigned int size, int bigEndian) const; 171 172 virtual void updateIdentity(EncodeBuffer &encodeBuffer, const Message *message, 173 const Message *cachedMessage, 174 ChannelCache *channelCache) const; 175 176 virtual void updateIdentity(DecodeBuffer &decodeBuffer, const Message *message, 177 ChannelCache *channelCache) const; 178 179 virtual void identityChecksum(const Message *message, const unsigned char *buffer, 180 unsigned int size, int bigEndian) const; 181 182 virtual void dumpIdentity(const Message *message) const; 183 }; 184 185 #endif /* PolySegment_H */ 186