1
/**************************************************************************/
3
/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
5
/* NXCOMP, NX protocol compression and NX extensions to this software */
6
/* are copyright of NoMachine. Redistribution and use of the present */
7
/* software is allowed according to terms specified in the file LICENSE */
8
/* which comes in the source distribution. */
10
/* Check http://www.nomachine.com/licensing.html for applicability. */
12
/* NX and NoMachine are trademarks of NoMachine S.r.l. */
14
/* All rights reserved. */
16
/**************************************************************************/
20
#include "ClientCache.h"
22
#include "EncodeBuffer.h"
23
#include "DecodeBuffer.h"
26
// Set the verbosity level.
36
// Here are the methods to handle messages' content.
39
int FillPolyStore::parseIdentity(Message *message, const unsigned char *buffer,
40
unsigned int size, int bigEndian) const
42
FillPolyMessage *fillPoly = (FillPolyMessage *) message;
45
// Here is the fingerprint.
48
fillPoly -> drawable = GetULONG(buffer + 4, bigEndian);
49
fillPoly -> gcontext = GetULONG(buffer + 8, bigEndian);
51
fillPoly -> shape = *(buffer + 12);
52
fillPoly -> mode = *(buffer + 13);
54
if (control -> isProtoStep8() == 1 &&
55
size >= (unsigned int) dataOffset)
57
fillPoly -> x_origin = GetUINT(buffer + 16, bigEndian);
58
fillPoly -> y_origin = GetUINT(buffer + 18, bigEndian);
62
fillPoly -> x_origin = 0;
63
fillPoly -> y_origin = 0;
67
*logofs << name() << ": Parsed Identity for message at " << this << ".\n" << logofs_flush;
73
int FillPolyStore::unparseIdentity(const Message *message, unsigned char *buffer,
74
unsigned int size, int bigEndian) const
76
FillPolyMessage *fillPoly = (FillPolyMessage *) message;
79
// Fill all the message's fields.
82
PutULONG(fillPoly -> drawable, buffer + 4, bigEndian);
83
PutULONG(fillPoly -> gcontext, buffer + 8, bigEndian);
85
*(buffer + 12) = fillPoly -> shape;
86
*(buffer + 13) = fillPoly -> mode;
88
if (control -> isProtoStep8() == 1 &&
89
size >= (unsigned int) dataOffset)
91
PutUINT(fillPoly -> x_origin, buffer + 16, bigEndian);
92
PutUINT(fillPoly -> y_origin, buffer + 18, bigEndian);
96
*logofs << name() << ": Unparsed identity for message at " << this << ".\n" << logofs_flush;
102
void FillPolyStore::dumpIdentity(const Message *message) const
106
FillPolyMessage *fillPoly = (FillPolyMessage *) message;
108
*logofs << name() << ": Identity drawable " << fillPoly -> drawable
109
<< ", gcontext " << fillPoly -> gcontext << ", shape "
110
<< fillPoly -> shape << ", mode " << fillPoly -> mode
111
<< fillPoly -> size_ << ", x_origin " << fillPoly -> x_origin
112
<< ", y_origin " << fillPoly -> y_origin << ".\n"
117
void FillPolyStore::identityChecksum(const Message *message, const unsigned char *buffer,
118
unsigned int size, int bigEndian) const
121
// Fields shape, mode.
124
md5_append(md5_state_, buffer + 12, 2);
127
void FillPolyStore::updateIdentity(EncodeBuffer &encodeBuffer, const Message *message,
128
const Message *cachedMessage,
129
ChannelCache *channelCache) const
131
FillPolyMessage *fillPoly = (FillPolyMessage *) message;
132
FillPolyMessage *cachedFillPoly = (FillPolyMessage *) cachedMessage;
134
ClientCache *clientCache = (ClientCache *) channelCache;
137
*logofs << name() << ": Encoding value " << fillPoly -> drawable
138
<< " as drawable field.\n" << logofs_flush;
141
encodeBuffer.encodeXidValue(fillPoly -> drawable, clientCache -> drawableCache);
143
cachedFillPoly -> drawable = fillPoly -> drawable;
146
*logofs << name() << ": Encoding value " << fillPoly -> gcontext
147
<< " as gcontext field.\n" << logofs_flush;
150
encodeBuffer.encodeXidValue(fillPoly -> gcontext, clientCache -> gcCache);
152
cachedFillPoly -> gcontext = fillPoly -> gcontext;
154
if (control -> isProtoStep8() == 1 &&
155
fillPoly -> size_ >= dataOffset)
158
*logofs << name() << ": Encoding value " << fillPoly -> x_origin
159
<< " as x_origin field.\n" << logofs_flush;
162
encodeBuffer.encodeCachedValue(fillPoly -> x_origin, 16,
163
*clientCache -> fillPolyXAbsCache[0], 8);
165
cachedFillPoly -> x_origin = fillPoly -> x_origin;
168
*logofs << name() << ": Encoding value " << fillPoly -> y_origin
169
<< " as y_origin field.\n" << logofs_flush;
172
encodeBuffer.encodeCachedValue(fillPoly -> y_origin, 16,
173
*clientCache -> fillPolyYAbsCache[0], 8);
175
cachedFillPoly -> y_origin = fillPoly -> y_origin;
179
void FillPolyStore::updateIdentity(DecodeBuffer &decodeBuffer, const Message *message,
180
ChannelCache *channelCache) const
182
FillPolyMessage *fillPoly = (FillPolyMessage *) message;
184
ClientCache *clientCache = (ClientCache *) channelCache;
186
decodeBuffer.decodeXidValue(fillPoly -> drawable, clientCache -> drawableCache);
189
*logofs << name() << ": Decoded value " << fillPoly -> drawable
190
<< " as drawable field.\n" << logofs_flush;
193
decodeBuffer.decodeXidValue(fillPoly -> gcontext, clientCache -> gcCache);
196
*logofs << name() << ": Decoded value " << fillPoly -> gcontext
197
<< " as gcontext field.\n" << logofs_flush;
200
if (control -> isProtoStep8() == 1 &&
201
fillPoly -> size_ >= dataOffset)
205
decodeBuffer.decodeCachedValue(value, 16,
206
*clientCache -> fillPolyXAbsCache[0], 8);
208
fillPoly -> x_origin = value;
211
*logofs << name() << ": Decoded value " << fillPoly -> x_origin
212
<< " as x_origin field.\n" << logofs_flush;
215
decodeBuffer.decodeCachedValue(value, 16,
216
*clientCache -> fillPolyYAbsCache[0], 8);
218
fillPoly -> y_origin = value;
221
*logofs << name() << ": Decoded value " << fillPoly -> y_origin
222
<< " as y_origin field.\n" << logofs_flush;