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 #ifdef HAVE_CONFIG_H 27 #include "config.h" 28 #endif 29 30 // 31 // Include the template for 32 // this message class. 33 // 34 35 #include "RenderFillRectangles.h" 36 37 // 38 // Set the verbosity level. 39 // 40 41 #define PANIC 42 #define WARNING 43 #undef TEST 44 #undef DEBUG 45 46 #include MESSAGE_TAGS 47 48 // 49 // Message handling methods. 50 // 51 52 MESSAGE_BEGIN_ENCODE_SIZE 53 { 54 // 55 // The color structure (4 components, 2 bytes 56 // each) is included in the data part, so that 57 // it gets into the checksum. The rectangles 58 // are in the format x, y, width, height with 59 // 2 bytes per each field, so each request is 60 // at least 12 + 8 + 8 = 28 bytes long. 61 // 62 63 ClientCache *clientCache = (ClientCache *) channelCache; 64 65 encodeBuffer.encodeCachedValue((size - MESSAGE_OFFSET) >> 2, 16, 66 clientCache -> renderLengthCache, 5); 67 68 #ifdef TEST 69 *logofs << name() << ": Encoded size with value " 70 << size << ".\n" << logofs_flush; 71 #endif 72 } 73 MESSAGE_END_ENCODE_SIZE 74 75 MESSAGE_BEGIN_DECODE_SIZE 76 { 77 ClientCache *clientCache = (ClientCache *) channelCache; 78 79 decodeBuffer.decodeCachedValue(size, 16, 80 clientCache -> renderLengthCache, 5); 81 82 size = MESSAGE_OFFSET + (size << 2); 83 84 buffer = writeBuffer -> addMessage(size); 85 86 #ifdef TEST 87 *logofs << name() << ": Decoded size with value " 88 << size << ".\n" << logofs_flush; 89 #endif 90 } 91 MESSAGE_END_DECODE_SIZE 92 93 MESSAGE_BEGIN_ENCODE_MESSAGE 94 { 95 ClientCache *clientCache = (ClientCache *) channelCache; 96 97 encodeBuffer.encodeCachedValue(*(buffer + 4), 8, 98 clientCache -> renderOpCache); 99 100 encodeBuffer.encodeXidValue(GetULONG(buffer + 8, bigEndian), 101 clientCache -> renderSrcPictureCache); 102 103 #ifdef TEST 104 *logofs << name() << ": Encoded message. Type is " 105 << (unsigned int) *(buffer + 1) << " size is " 106 << size << ".\n" << logofs_flush; 107 #endif 108 } 109 MESSAGE_END_ENCODE_MESSAGE 110 111 MESSAGE_BEGIN_DECODE_MESSAGE 112 { 113 ClientCache *clientCache = (ClientCache *) channelCache; 114 115 unsigned int value; 116 117 *(buffer + 1) = type; 118 119 decodeBuffer.decodeCachedValue(*(buffer + 4), 8, 120 clientCache -> renderOpCache); 121 122 decodeBuffer.decodeXidValue(value, clientCache -> renderSrcPictureCache); 123 124 PutULONG(value, buffer + 8, bigEndian); 125 126 #ifdef TEST 127 *logofs << name() << ": Decoded message. Type is " 128 << (unsigned int) type << " size is " << size 129 << ".\n" << logofs_flush; 130 #endif 131 } 132 MESSAGE_END_DECODE_MESSAGE 133 134 MESSAGE_BEGIN_ENCODE_DATA 135 { 136 encodeIntData(encodeBuffer, buffer, MESSAGE_OFFSET, 137 size, bigEndian, channelCache); 138 139 #ifdef TEST 140 *logofs << name() << ": Encoded " << size - MESSAGE_OFFSET 141 << " bytes of data.\n" << logofs_flush; 142 #endif 143 } 144 MESSAGE_END_ENCODE_DATA 145 146 MESSAGE_BEGIN_DECODE_DATA 147 { 148 decodeIntData(decodeBuffer, buffer, MESSAGE_OFFSET, 149 size, bigEndian, channelCache); 150 151 #ifdef TEST 152 *logofs << name() << ": Decoded " << size - MESSAGE_OFFSET 153 << " bytes of data.\n" << logofs_flush; 154 #endif 155 } 156 MESSAGE_END_DECODE_DATA 157 158 MESSAGE_BEGIN_PARSE_IDENTITY 159 { 160 RenderExtensionMessage *renderExtension = (RenderExtensionMessage *) message; 161 162 renderExtension -> data.fill_rectangles.type = *(buffer + 1); 163 renderExtension -> data.fill_rectangles.op = *(buffer + 4); 164 165 renderExtension -> data.fill_rectangles.dst_id = GetULONG(buffer + 8, bigEndian); 166 167 #ifdef TEST 168 *logofs << name() << ": Parsed identity. Type is " 169 << (unsigned int) renderExtension -> data.fill_rectangles.type << " size is " 170 << renderExtension -> size_ << ".\n" << logofs_flush; 171 #endif 172 } 173 MESSAGE_END_PARSE_IDENTITY 174 175 MESSAGE_BEGIN_UNPARSE_IDENTITY 176 { 177 RenderExtensionMessage *renderExtension = (RenderExtensionMessage *) message; 178 179 *(buffer + 1) = renderExtension -> data.fill_rectangles.type; 180 *(buffer + 4) = renderExtension -> data.fill_rectangles.op; 181 182 PutULONG(renderExtension -> data.fill_rectangles.dst_id, buffer + 8, bigEndian); 183 184 #ifdef TEST 185 *logofs << name() << ": Unparsed identity. Type is " 186 << (unsigned int) renderExtension -> data.fill_rectangles.type 187 << " size is " << renderExtension -> size_ << ".\n" 188 << logofs_flush; 189 #endif 190 } 191 MESSAGE_END_UNPARSE_IDENTITY 192 193 MESSAGE_BEGIN_IDENTITY_CHECKSUM 194 { 195 md5_append(md5_state, buffer + 1, 4); 196 } 197 MESSAGE_END_IDENTITY_CHECKSUM 198 199 MESSAGE_BEGIN_ENCODE_UPDATE 200 { 201 RenderExtensionMessage *renderExtension = (RenderExtensionMessage *) message; 202 RenderExtensionMessage *cachedRenderExtension = (RenderExtensionMessage *) cachedMessage; 203 204 ClientCache *clientCache = (ClientCache *) channelCache; 205 206 encodeBuffer.encodeXidValue(renderExtension -> data.fill_rectangles.dst_id, 207 clientCache -> renderSrcPictureCache); 208 209 cachedRenderExtension -> data.fill_rectangles.dst_id = 210 renderExtension -> data.fill_rectangles.dst_id; 211 212 #ifdef TEST 213 *logofs << name() << ": Encoded update. Type is " 214 << (unsigned int) renderExtension -> data.fill_rectangles.type 215 << " size is " << renderExtension -> size_ << ".\n" 216 << logofs_flush; 217 #endif 218 } 219 MESSAGE_END_ENCODE_UPDATE 220 221 MESSAGE_BEGIN_DECODE_UPDATE 222 { 223 RenderExtensionMessage *renderExtension = (RenderExtensionMessage *) message; 224 225 ClientCache *clientCache = (ClientCache *) channelCache; 226 227 decodeBuffer.decodeXidValue(renderExtension -> data.fill_rectangles.dst_id, 228 clientCache -> renderSrcPictureCache); 229 230 #ifdef TEST 231 *logofs << name() << ": Decoded update. Type is " 232 << (unsigned int) renderExtension -> data.fill_rectangles.type 233 << " size is " << renderExtension -> size_ << ".\n" 234 << logofs_flush; 235 #endif 236 } 237 MESSAGE_END_DECODE_UPDATE 238