1 /**************************************************************************/
2 /*                                                                        */
3 /* Copyright (c) 2001, 2010 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 Medialogic S.p.A.                   */
13 /*                                                                        */
14 /* All rights reserved.                                                   */
15 /*                                                                        */
16 /**************************************************************************/
17 
18 #include "QueryFontReply.h"
19 
20 #include "ServerCache.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 
QueryFontReplyStore(StaticCompressor * compressor)35 QueryFontReplyStore::QueryFontReplyStore(StaticCompressor *compressor)
36 
37   : MessageStore(compressor)
38 {
39   enableCache    = QUERYFONTREPLY_ENABLE_CACHE;
40   enableData     = QUERYFONTREPLY_ENABLE_DATA;
41   enableSplit    = QUERYFONTREPLY_ENABLE_SPLIT;
42   enableCompress = QUERYFONTREPLY_ENABLE_COMPRESS;
43 
44   if (control -> isProtoStep7() == 1)
45   {
46     enableCompress = QUERYFONTREPLY_ENABLE_COMPRESS_IF_PROTO_STEP_7;
47   }
48 
49   dataLimit  = QUERYFONTREPLY_DATA_LIMIT;
50   dataOffset = QUERYFONTREPLY_DATA_OFFSET;
51 
52   cacheSlots          = QUERYFONTREPLY_CACHE_SLOTS;
53   cacheThreshold      = QUERYFONTREPLY_CACHE_THRESHOLD;
54   cacheLowerThreshold = QUERYFONTREPLY_CACHE_LOWER_THRESHOLD;
55 
56   messages_ -> resize(cacheSlots);
57 
58   for (T_messages::iterator i = messages_ -> begin();
59            i < messages_ -> end(); i++)
60   {
61     *i = NULL;
62   }
63 
64   temporary_ = NULL;
65 }
66 
~QueryFontReplyStore()67 QueryFontReplyStore::~QueryFontReplyStore()
68 {
69   for (T_messages::iterator i = messages_ -> begin();
70            i < messages_ -> end(); i++)
71   {
72     destroy(*i);
73   }
74 
75   destroy(temporary_);
76 }
77 
78 //
79 // Here are the methods to handle messages' content.
80 //
81 
parseIdentity(Message * message,const unsigned char * buffer,unsigned int size,int bigEndian) const82 int QueryFontReplyStore::parseIdentity(Message *message, const unsigned char *buffer,
83                                           unsigned int size, int bigEndian) const
84 {
85   //
86   // Clear the padding bytes.
87   //
88 
89   unsigned char *pad = (unsigned char *) buffer;
90 
91   if (size >= 24)
92   {
93     PutULONG(0, pad + 20, bigEndian);
94   }
95 
96   if (size >= 40)
97   {
98     PutULONG(0, pad + 36, bigEndian);
99   }
100 
101   //
102   // TODO: This doesn't work. Probably these
103   // padding bytes are not padding anymore.
104   // This is to be investigated.
105   //
106   // pad += 60;
107   //
108   // while (pad + 16 <= (buffer + size))
109   // {
110   //   PutULONG(0, pad + 12, bigEndian);
111   //
112   //   pad += 16;
113   // }
114   //
115 
116   #ifdef DEBUG
117   *logofs << name() << ": Cleaned padding bytes of "
118           << "message at " << message << ".\n"
119           << logofs_flush;
120   #endif
121 
122   return 1;
123 }
124 
unparseIdentity(const Message * message,unsigned char * buffer,unsigned int size,int bigEndian) const125 int QueryFontReplyStore::unparseIdentity(const Message *message, unsigned char *buffer,
126                                             unsigned int size, int bigEndian) const
127 {
128   return 1;
129 }
130 
dumpIdentity(const Message * message) const131 void QueryFontReplyStore::dumpIdentity(const Message *message) const
132 {
133   #ifdef DUMP
134 
135   QueryFontReplyMessage *queryFontReply = (QueryFontReplyMessage *) message;
136 
137   *logofs << name() << ": Identity size " << queryFontReply -> size_ << ".\n";
138 
139   #endif
140 }
141 
identityChecksum(const Message * message,const unsigned char * buffer,unsigned int size,int bigEndian) const142 void QueryFontReplyStore::identityChecksum(const Message *message, const unsigned char *buffer,
143                                                unsigned int size, int bigEndian) const
144 {
145 }
146