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 "RenderPictureTransform.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 // Size is always 44. The identity size 56 // is set to 8, so we encode the 36 bytes 57 // of the transformation matrix as our 58 // data. 59 // 60 } 61 MESSAGE_END_ENCODE_SIZE 62 63 MESSAGE_BEGIN_DECODE_SIZE 64 { 65 size = MESSAGE_OFFSET + 36; 66 67 buffer = writeBuffer -> addMessage(size); 68 69 #ifdef TEST 70 *logofs << name() << ": Decoded size with value " 71 << size << ".\n" << logofs_flush; 72 #endif 73 } 74 MESSAGE_END_DECODE_SIZE 75 76 MESSAGE_BEGIN_ENCODE_MESSAGE 77 { 78 ClientCache *clientCache = (ClientCache *) channelCache; 79 80 encodeBuffer.encodeXidValue(GetULONG(buffer + 4, bigEndian), 81 clientCache -> renderSrcPictureCache); 82 83 #ifdef TEST 84 *logofs << name() << ": Encoded message. Type is " 85 << (unsigned int) *(buffer + 1) << " size is " 86 << size << ".\n" << logofs_flush; 87 #endif 88 } 89 MESSAGE_END_ENCODE_MESSAGE 90 91 MESSAGE_BEGIN_DECODE_MESSAGE 92 { 93 ClientCache *clientCache = (ClientCache *) channelCache; 94 95 unsigned int value; 96 97 *(buffer + 1) = type; 98 99 decodeBuffer.decodeXidValue(value, 100 clientCache -> renderSrcPictureCache); 101 102 PutULONG(value, buffer + 4, bigEndian); 103 104 #ifdef TEST 105 *logofs << name() << ": Decoded message. Type is " 106 << (unsigned int) type << " size is " << size 107 << ".\n" << logofs_flush; 108 #endif 109 } 110 MESSAGE_END_DECODE_MESSAGE 111 112 MESSAGE_BEGIN_ENCODE_DATA 113 { 114 encodeLongData(encodeBuffer, buffer, MESSAGE_OFFSET, 115 size, bigEndian, channelCache); 116 117 #ifdef TEST 118 *logofs << name() << ": Encoded " << size - MESSAGE_OFFSET 119 << " bytes of data.\n" << logofs_flush; 120 #endif 121 } 122 MESSAGE_END_ENCODE_DATA 123 124 MESSAGE_BEGIN_DECODE_DATA 125 { 126 decodeLongData(decodeBuffer, buffer, MESSAGE_OFFSET, 127 size, bigEndian, channelCache); 128 129 #ifdef TEST 130 *logofs << name() << ": Decoded " << size - MESSAGE_OFFSET 131 << " bytes of data.\n" << logofs_flush; 132 #endif 133 } 134 MESSAGE_END_DECODE_DATA 135 136 MESSAGE_BEGIN_PARSE_IDENTITY 137 { 138 RenderExtensionMessage *renderExtension = (RenderExtensionMessage *) message; 139 140 renderExtension -> data.picture_transform.type = *(buffer + 1); 141 142 renderExtension -> data.picture_transform.src_id = GetULONG(buffer + 4, bigEndian); 143 144 #ifdef TEST 145 *logofs << name() << ": Parsed identity. Type is " 146 << (unsigned int) renderExtension -> data.picture_transform.type 147 << " size is " << renderExtension -> size_ << ".\n" 148 << logofs_flush; 149 #endif 150 } 151 MESSAGE_END_PARSE_IDENTITY 152 153 MESSAGE_BEGIN_UNPARSE_IDENTITY 154 { 155 RenderExtensionMessage *renderExtension = (RenderExtensionMessage *) message; 156 157 *(buffer + 1) = renderExtension -> data.picture_transform.type; 158 159 PutULONG(renderExtension -> data.picture_transform.src_id, buffer + 4, bigEndian); 160 161 #ifdef TEST 162 *logofs << name() << ": Unparsed identity. Type is " 163 << (unsigned int) renderExtension -> data.picture_transform.type 164 << " size is " << renderExtension -> size_ << ".\n" 165 << logofs_flush; 166 #endif 167 } 168 MESSAGE_END_UNPARSE_IDENTITY 169 170 MESSAGE_BEGIN_IDENTITY_CHECKSUM 171 { 172 md5_append(md5_state, buffer + 1, 3); 173 } 174 MESSAGE_END_IDENTITY_CHECKSUM 175 176 MESSAGE_BEGIN_ENCODE_UPDATE 177 { 178 RenderExtensionMessage *renderExtension = (RenderExtensionMessage *) message; 179 RenderExtensionMessage *cachedRenderExtension = (RenderExtensionMessage *) cachedMessage; 180 181 ClientCache *clientCache = (ClientCache *) channelCache; 182 183 encodeBuffer.encodeXidValue(renderExtension -> data.picture_transform.src_id, 184 clientCache -> renderSrcPictureCache); 185 186 cachedRenderExtension -> data.picture_transform.src_id = 187 renderExtension -> data.picture_transform.src_id; 188 189 #ifdef TEST 190 *logofs << name() << ": Encoded update. Type is " 191 << (unsigned int) renderExtension -> data.picture_transform.type 192 << " size is " << renderExtension -> size_ << ".\n" 193 << logofs_flush; 194 #endif 195 } 196 MESSAGE_END_ENCODE_UPDATE 197 198 MESSAGE_BEGIN_DECODE_UPDATE 199 { 200 RenderExtensionMessage *renderExtension = (RenderExtensionMessage *) message; 201 202 ClientCache *clientCache = (ClientCache *) channelCache; 203 204 decodeBuffer.decodeXidValue(renderExtension -> data.picture_transform.src_id, 205 clientCache -> renderSrcPictureCache); 206 207 #ifdef TEST 208 *logofs << name() << ": Decoded update. Type is " 209 << (unsigned int) renderExtension -> data.picture_transform.type 210 << " size is " << renderExtension -> size_ << ".\n" 211 << logofs_flush; 212 #endif 213 } 214 MESSAGE_END_DECODE_UPDATE 215