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