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

« back to all changes in this revision

Viewing changes to PolyText16.h

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