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

« back to all changes in this revision

Viewing changes to PolyArc.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 PolyArc_H
 
19
#define PolyArc_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 POLYARC_ENABLE_CACHE               1
 
38
#define POLYARC_ENABLE_DATA                0
 
39
#define POLYARC_ENABLE_SPLIT               0
 
40
#define POLYARC_ENABLE_COMPRESS            0
 
41
 
 
42
#define POLYARC_DATA_LIMIT                 1980
 
43
#define POLYARC_DATA_OFFSET                12
 
44
 
 
45
#define POLYARC_CACHE_SLOTS                2000
 
46
#define POLYARC_CACHE_THRESHOLD            2
 
47
#define POLYARC_CACHE_LOWER_THRESHOLD      1
 
48
 
 
49
//
 
50
// The message class.
 
51
//
 
52
 
 
53
class PolyArcMessage : public Message
 
54
{
 
55
  friend class PolyArcStore;
 
56
 
 
57
  public:
 
58
 
 
59
  PolyArcMessage()
 
60
  {
 
61
  }
 
62
 
 
63
  ~PolyArcMessage()
 
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
 
 
78
class PolyArcStore : public MessageStore
 
79
{
 
80
  //
 
81
  // Constructors and destructors.
 
82
  //
 
83
 
 
84
  public:
 
85
 
 
86
  PolyArcStore() : MessageStore()
 
87
  {
 
88
    enableCache    = POLYARC_ENABLE_CACHE;
 
89
    enableData     = POLYARC_ENABLE_DATA;
 
90
    enableSplit    = POLYARC_ENABLE_SPLIT;
 
91
    enableCompress = POLYARC_ENABLE_COMPRESS;
 
92
 
 
93
    dataLimit  = POLYARC_DATA_LIMIT;
 
94
    dataOffset = POLYARC_DATA_OFFSET;
 
95
 
 
96
    cacheSlots          = POLYARC_CACHE_SLOTS;
 
97
    cacheThreshold      = POLYARC_CACHE_THRESHOLD;
 
98
    cacheLowerThreshold = POLYARC_CACHE_LOWER_THRESHOLD;
 
99
 
 
100
    messages_ -> resize(cacheSlots);
 
101
 
 
102
    for (T_messages::iterator i = messages_ -> begin();
 
103
             i < messages_ -> end(); i++)
 
104
    {
 
105
      *i = NULL;
 
106
    }
 
107
 
 
108
    temporary_ = NULL;
 
109
  }
 
110
 
 
111
  virtual ~PolyArcStore()
 
112
  {
 
113
    for (T_messages::iterator i = messages_ -> begin();
 
114
             i < messages_ -> end(); i++)
 
115
    {
 
116
      destroy(*i);
 
117
    }
 
118
 
 
119
    destroy(temporary_);
 
120
  }
 
121
 
 
122
  virtual const char *name() const
 
123
  {
 
124
    return "PolyArc";
 
125
  }
 
126
 
 
127
  virtual unsigned char opcode() const
 
128
  {
 
129
    return X_PolyArc;
 
130
  }
 
131
 
 
132
  virtual unsigned int storage() const
 
133
  {
 
134
    return sizeof(PolyArcMessage);
 
135
  }
 
136
 
 
137
  //
 
138
  // Message handling methods.
 
139
  //
 
140
 
 
141
  public:
 
142
 
 
143
  virtual Message *create() const
 
144
  {
 
145
    return new PolyArcMessage();
 
146
  }
 
147
 
 
148
  virtual Message *create(const Message &message) const
 
149
  {
 
150
    return new PolyArcMessage((const PolyArcMessage &) message);
 
151
  }
 
152
 
 
153
  virtual void destroy(Message *message) const
 
154
  {
 
155
    delete (PolyArcMessage *) message;
 
156
  }
 
157
 
 
158
  virtual int parseIdentity(Message *message, const unsigned char *buffer,
 
159
                                unsigned int size, int bigEndian) const;
 
160
 
 
161
  virtual int unparseIdentity(const Message *message, unsigned char *buffer,
 
162
                                  unsigned int size, int bigEndian) const;
 
163
 
 
164
  virtual void updateIdentity(EncodeBuffer &encodeBuffer, const Message *message,
 
165
                                  const Message *cachedMessage,
 
166
                                      ChannelCache *channelCache) const;
 
167
 
 
168
  virtual void updateIdentity(DecodeBuffer &decodeBuffer, const Message *message,
 
169
                                  ChannelCache *channelCache) const;
 
170
 
 
171
  virtual void identityChecksum(const Message *message, const unsigned char *buffer,
 
172
                                    unsigned int size, int bigEndian) const;
 
173
 
 
174
  virtual void dumpIdentity(const Message *message) const;
 
175
};
 
176
 
 
177
#endif /* PolyArc_H */