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 "RenderFreePicture.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_MESSAGE
53 {
54   ClientCache *clientCache = (ClientCache *) channelCache;
55 
56   encodeBuffer.encodeFreeXidValue(GetULONG(buffer + 4, bigEndian),
57                      clientCache -> renderFreePictureCache);
58 
59   #ifdef TEST
60   *logofs << name() << ": Encoded message. Type is "
61           << (unsigned int) *(buffer + 1) << " size is "
62           << size << ".\n" << logofs_flush;
63   #endif
64 }
65 MESSAGE_END_ENCODE_MESSAGE
66 
67 MESSAGE_BEGIN_DECODE_MESSAGE
68 {
69   unsigned int value;
70 
71   ClientCache *clientCache = (ClientCache *) channelCache;
72 
73   *(buffer + 1) = type;
74 
75   decodeBuffer.decodeFreeXidValue(value,
76                      clientCache -> renderFreePictureCache);
77 
78   PutULONG(value, buffer + 4, bigEndian);
79 
80   #ifdef TEST
81   *logofs << name() << ": Decoded message. Type is "
82           << (unsigned int) type << " size is " << size
83           << ".\n" << logofs_flush;
84   #endif
85 }
86 MESSAGE_END_DECODE_MESSAGE
87 
88 MESSAGE_BEGIN_PARSE_IDENTITY
89 {
90   RenderExtensionMessage *renderExtension = (RenderExtensionMessage *) message;
91 
92   renderExtension -> data.free_picture.type = *(buffer + 1);
93 
94   renderExtension -> data.free_picture.src_id = GetULONG(buffer + 4, bigEndian);
95 
96   #ifdef TEST
97   *logofs << name() << ": Parsed identity. Type is "
98           << (unsigned int) renderExtension -> data.free_picture.type
99           << " size is " << renderExtension -> size_ << ".\n"
100           << logofs_flush;
101   #endif
102 }
103 MESSAGE_END_PARSE_IDENTITY
104 
105 MESSAGE_BEGIN_UNPARSE_IDENTITY
106 {
107   RenderExtensionMessage *renderExtension = (RenderExtensionMessage *) message;
108 
109   *(buffer + 1) = renderExtension -> data.free_picture.type;
110 
111   PutULONG(renderExtension -> data.free_picture.src_id, buffer + 4, bigEndian);
112 
113   #ifdef TEST
114   *logofs << name() << ": Unparsed identity. Type is "
115           << (unsigned int) renderExtension -> data.free_picture.type
116           << " size is " << renderExtension -> size_ << ".\n"
117           << logofs_flush;
118   #endif
119 }
120 MESSAGE_END_UNPARSE_IDENTITY
121 
122 MESSAGE_BEGIN_IDENTITY_CHECKSUM
123 {
124   md5_append(md5_state, buffer + 1, 3);
125 }
126 MESSAGE_END_IDENTITY_CHECKSUM
127 
128 MESSAGE_BEGIN_ENCODE_UPDATE
129 {
130   RenderExtensionMessage *renderExtension       = (RenderExtensionMessage *) message;
131   RenderExtensionMessage *cachedRenderExtension = (RenderExtensionMessage *) cachedMessage;
132 
133   ClientCache *clientCache = (ClientCache *) channelCache;
134 
135   encodeBuffer.encodeFreeXidValue(renderExtension -> data.free_picture.src_id,
136                      clientCache -> renderFreePictureCache);
137 
138   cachedRenderExtension -> data.free_picture.src_id =
139               renderExtension -> data.free_picture.src_id;
140 
141   #ifdef TEST
142   *logofs << name() << ": Encoded update. Type is "
143           << (unsigned int) renderExtension -> data.free_picture.type
144           << " size is " << renderExtension -> size_ << ".\n"
145           << logofs_flush;
146   #endif
147 }
148 MESSAGE_END_ENCODE_UPDATE
149 
150 MESSAGE_BEGIN_DECODE_UPDATE
151 {
152   RenderExtensionMessage *renderExtension = (RenderExtensionMessage *) message;
153 
154   ClientCache *clientCache = (ClientCache *) channelCache;
155 
156   decodeBuffer.decodeFreeXidValue(renderExtension -> data.free_picture.src_id,
157                      clientCache -> renderFreePictureCache);
158 
159   #ifdef TEST
160   *logofs << name() << ": Decoded update. Type is "
161           << (unsigned int) renderExtension -> data.free_picture.type
162           << " size is " << renderExtension -> size_ << ".\n"
163           << logofs_flush;
164   #endif
165 }
166 MESSAGE_END_DECODE_UPDATE
167