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 #ifndef PolyFillRectangle_H
27 #define PolyFillRectangle_H
28 
29 #include "Message.h"
30 
31 //
32 // Set the verbosity level.
33 //
34 
35 #define PANIC
36 #define WARNING
37 #undef  TEST
38 #undef  DEBUG
39 #undef  DUMP
40 
41 //
42 // Set default values.
43 //
44 
45 #define POLYFILLRECTANGLE_ENABLE_CACHE                           1
46 #define POLYFILLRECTANGLE_ENABLE_DATA                            0
47 #define POLYFILLRECTANGLE_ENABLE_SPLIT                           0
48 #define POLYFILLRECTANGLE_ENABLE_COMPRESS                        0
49 
50 #define POLYFILLRECTANGLE_DATA_LIMIT                             2048
51 #define POLYFILLRECTANGLE_DATA_OFFSET                            12
52 
53 #define POLYFILLRECTANGLE_CACHE_SLOTS                            4000
54 #define POLYFILLRECTANGLE_CACHE_THRESHOLD                        5
55 #define POLYFILLRECTANGLE_CACHE_LOWER_THRESHOLD                  1
56 
57 //
58 // The message class.
59 //
60 
61 class PolyFillRectangleMessage : public Message
62 {
63   friend class PolyFillRectangleStore;
64 
65   public:
66 
PolyFillRectangleMessage()67   PolyFillRectangleMessage()
68   {
69   }
70 
~PolyFillRectangleMessage()71   ~PolyFillRectangleMessage()
72   {
73   }
74 
75   //
76   // Put here the fields which constitute
77   // the 'identity' part of the message.
78   //
79 
80   private:
81 
82   unsigned int drawable;
83   unsigned int gcontext;
84 };
85 
86 class PolyFillRectangleStore : public MessageStore
87 {
88   //
89   // Constructors and destructors.
90   //
91 
92   public:
93 
PolyFillRectangleStore()94   PolyFillRectangleStore() : MessageStore()
95   {
96     enableCache    = POLYFILLRECTANGLE_ENABLE_CACHE;
97     enableData     = POLYFILLRECTANGLE_ENABLE_DATA;
98     enableSplit    = POLYFILLRECTANGLE_ENABLE_SPLIT;
99     enableCompress = POLYFILLRECTANGLE_ENABLE_COMPRESS;
100 
101     dataLimit  = POLYFILLRECTANGLE_DATA_LIMIT;
102     dataOffset = POLYFILLRECTANGLE_DATA_OFFSET;
103 
104     cacheSlots          = POLYFILLRECTANGLE_CACHE_SLOTS;
105     cacheThreshold      = POLYFILLRECTANGLE_CACHE_THRESHOLD;
106     cacheLowerThreshold = POLYFILLRECTANGLE_CACHE_LOWER_THRESHOLD;
107 
108     messages_ -> resize(cacheSlots);
109 
110     for (T_messages::iterator i = messages_ -> begin();
111              i < messages_ -> end(); i++)
112     {
113       *i = NULL;
114     }
115 
116     temporary_ = NULL;
117   }
118 
~PolyFillRectangleStore()119   virtual ~PolyFillRectangleStore()
120   {
121     for (T_messages::iterator i = messages_ -> begin();
122              i < messages_ -> end(); i++)
123     {
124       destroy(*i);
125     }
126 
127     destroy(temporary_);
128   }
129 
name()130   virtual const char *name() const
131   {
132     return "PolyFillRectangle";
133   }
134 
opcode()135   virtual unsigned char opcode() const
136   {
137     return X_PolyFillRectangle;
138   }
139 
storage()140   virtual unsigned int storage() const
141   {
142     return sizeof(PolyFillRectangleMessage);
143   }
144 
145   //
146   // Message handling methods.
147   //
148 
149   public:
150 
create()151   virtual Message *create() const
152   {
153     return new PolyFillRectangleMessage();
154   }
155 
create(const Message & message)156   virtual Message *create(const Message &message) const
157   {
158     return new PolyFillRectangleMessage((const PolyFillRectangleMessage &) message);
159   }
160 
destroy(Message * message)161   virtual void destroy(Message *message) const
162   {
163     delete (PolyFillRectangleMessage *) message;
164   }
165 
166   virtual int parseIdentity(Message *message, const unsigned char *buffer,
167                                 unsigned int size, int bigEndian) const;
168 
169   virtual int unparseIdentity(const Message *message, unsigned char *buffer,
170                                   unsigned int size, int bigEndian) const;
171 
172   virtual void updateIdentity(EncodeBuffer &encodeBuffer, const Message *message,
173                                   const Message *cachedMessage,
174                                       ChannelCache *channelCache) const;
175 
176   virtual void updateIdentity(DecodeBuffer &decodeBuffer, const Message *message,
177                                   ChannelCache *channelCache) const;
178 
179   virtual void identityChecksum(const Message *message, const unsigned char *buffer,
180                                     unsigned int size, int bigEndian) const;
181 
182   virtual void dumpIdentity(const Message *message) const;
183 };
184 
185 #endif /* PolyFillRectangle_H */
186