~freenx-team/nx-x11/nxcomp-upstream

« back to all changes in this revision

Viewing changes to PolyFillArc.cpp

  • Committer: Marcelo Boveto Shima
  • Date: 2009-03-28 22:24:56 UTC
  • Revision ID: mshima@ufserv-20090328222456-rdtaq3oedfyq890c
Import nxcomp 3.3.0-3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**************************************************************************/
 
2
/*                                                                        */
 
3
/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/.         */
 
4
/*                                                                        */
 
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.                                */
 
9
/*                                                                        */
 
10
/* Check http://www.nomachine.com/licensing.html for applicability.       */
 
11
/*                                                                        */
 
12
/* NX and NoMachine are trademarks of NoMachine S.r.l.                    */
 
13
/*                                                                        */
 
14
/* All rights reserved.                                                   */
 
15
/*                                                                        */
 
16
/**************************************************************************/
 
17
 
 
18
#include "PolyFillArc.h"
 
19
 
 
20
#include "ClientCache.h"
 
21
 
 
22
#include "EncodeBuffer.h"
 
23
#include "DecodeBuffer.h"
 
24
 
 
25
//
 
26
// Set the verbosity level.
 
27
//
 
28
 
 
29
#define PANIC
 
30
#define WARNING
 
31
#undef  TEST
 
32
#undef  DEBUG
 
33
#undef  DUMP
 
34
 
 
35
//
 
36
// Here are the methods to handle messages' content.
 
37
//
 
38
 
 
39
int PolyFillArcStore::parseIdentity(Message *message, const unsigned char *buffer,
 
40
                                        unsigned int size, int bigEndian) const
 
41
{
 
42
  PolyFillArcMessage *polyFillArc = (PolyFillArcMessage *) message;
 
43
 
 
44
  //
 
45
  // Here is the fingerprint.
 
46
  //
 
47
 
 
48
  polyFillArc -> drawable = GetULONG(buffer + 4, bigEndian);
 
49
  polyFillArc -> gcontext = GetULONG(buffer + 8, bigEndian);
 
50
 
 
51
  #ifdef DEBUG
 
52
  *logofs << name() << ": Parsed Identity for message at " << this << ".\n" << logofs_flush;
 
53
  #endif
 
54
 
 
55
  return 1;
 
56
}
 
57
 
 
58
int PolyFillArcStore::unparseIdentity(const Message *message, unsigned char *buffer,
 
59
                                          unsigned int size, int bigEndian) const
 
60
{
 
61
  PolyFillArcMessage *polyFillArc = (PolyFillArcMessage *) message;
 
62
 
 
63
  //
 
64
  // Fill all the message's fields.
 
65
  //
 
66
 
 
67
  PutULONG(polyFillArc -> drawable, buffer + 4, bigEndian);
 
68
  PutULONG(polyFillArc -> gcontext, buffer + 8, bigEndian);
 
69
 
 
70
  #ifdef DEBUG
 
71
  *logofs << name() << ": Unparsed identity for message at " << this << ".\n" << logofs_flush;
 
72
  #endif
 
73
 
 
74
  return 1;
 
75
}
 
76
 
 
77
void PolyFillArcStore::dumpIdentity(const Message *message) const
 
78
{
 
79
  #ifdef DUMP
 
80
 
 
81
  PolyFillArcMessage *polyFillArc = (PolyFillArcMessage *) message;
 
82
 
 
83
  *logofs << name() << ": Identity drawable " << polyFillArc -> drawable
 
84
                    << ", gcontext " << polyFillArc -> gcontext
 
85
                    << ", size " << polyFillArc -> size_ << ".\n" << logofs_flush;
 
86
  #endif
 
87
}
 
88
 
 
89
void PolyFillArcStore::identityChecksum(const Message *message, const unsigned char *buffer,
 
90
                                            unsigned int size, int bigEndian) const
 
91
{
 
92
}
 
93
 
 
94
void PolyFillArcStore::updateIdentity(EncodeBuffer &encodeBuffer, const Message *message,
 
95
                                          const Message *cachedMessage,
 
96
                                              ChannelCache *channelCache) const
 
97
{
 
98
  PolyFillArcMessage *polyFillArc       = (PolyFillArcMessage *) message;
 
99
  PolyFillArcMessage *cachedPolyFillArc = (PolyFillArcMessage *) cachedMessage;
 
100
 
 
101
  ClientCache *clientCache = (ClientCache *) channelCache;
 
102
 
 
103
  #ifdef TEST
 
104
  *logofs << name() << ": Encoding value " << polyFillArc -> drawable
 
105
          << " as drawable field.\n" << logofs_flush;
 
106
  #endif
 
107
 
 
108
  encodeBuffer.encodeXidValue(polyFillArc -> drawable, clientCache -> drawableCache);
 
109
 
 
110
  cachedPolyFillArc -> drawable = polyFillArc -> drawable;
 
111
 
 
112
  #ifdef TEST
 
113
  *logofs << name() << ": Encoding value " << polyFillArc -> gcontext
 
114
          << " as gcontext field.\n" << logofs_flush;
 
115
  #endif
 
116
 
 
117
  encodeBuffer.encodeXidValue(polyFillArc -> gcontext, clientCache -> gcCache);
 
118
 
 
119
  cachedPolyFillArc -> gcontext = polyFillArc -> gcontext;
 
120
}
 
121
 
 
122
void PolyFillArcStore::updateIdentity(DecodeBuffer &decodeBuffer, const Message *message,
 
123
                                          ChannelCache *channelCache) const
 
124
{
 
125
  PolyFillArcMessage *polyFillArc = (PolyFillArcMessage *) message;
 
126
 
 
127
  ClientCache *clientCache = (ClientCache *) channelCache;
 
128
 
 
129
  unsigned int value;
 
130
 
 
131
  decodeBuffer.decodeXidValue(value, clientCache -> drawableCache);
 
132
 
 
133
  polyFillArc -> drawable = value;
 
134
 
 
135
  #ifdef DEBUG
 
136
  *logofs << name() << ": Decoded value " << polyFillArc -> drawable
 
137
          << " as drawable field.\n" << logofs_flush;
 
138
  #endif
 
139
 
 
140
  decodeBuffer.decodeXidValue(value, clientCache -> gcCache);
 
141
 
 
142
  polyFillArc -> gcontext = value;
 
143
 
 
144
  #ifdef DEBUG
 
145
  *logofs << name() << ": Decoded value " << polyFillArc -> gcontext
 
146
          << " as gcontext field.\n" << logofs_flush;
 
147
  #endif
 
148
}
 
149
 
 
150