aboutsummaryrefslogtreecommitdiff
path: root/nxcomp/ClientStore.cpp
diff options
context:
space:
mode:
authorReinhard Tartler <siretart@tauware.de>2011-11-13 09:27:51 +0100
committerReinhard Tartler <siretart@tauware.de>2011-11-13 09:27:51 +0100
commit3e924126b56c4d421e8263d25f6b14aa4ceed047 (patch)
tree921403de7b834fb1ac89f97d84ce105e0b487051 /nxcomp/ClientStore.cpp
parenta840692edc9c6d19cd7c057f68e39c7d95eb767d (diff)
downloadnx-libs-3e924126b56c4d421e8263d25f6b14aa4ceed047.tar.gz
nx-libs-3e924126b56c4d421e8263d25f6b14aa4ceed047.tar.bz2
nx-libs-3e924126b56c4d421e8263d25f6b14aa4ceed047.zip
Imported nxcomp-3.1.0-4.tar.gznxcomp/3.1.0-4
Summary: Imported nxcomp-3.1.0-4.tar.gz Keywords: Imported nxcomp-3.1.0-4.tar.gz into Git repository
Diffstat (limited to 'nxcomp/ClientStore.cpp')
-rwxr-xr-xnxcomp/ClientStore.cpp228
1 files changed, 228 insertions, 0 deletions
diff --git a/nxcomp/ClientStore.cpp b/nxcomp/ClientStore.cpp
new file mode 100755
index 000000000..48996c08c
--- /dev/null
+++ b/nxcomp/ClientStore.cpp
@@ -0,0 +1,228 @@
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NXCOMP, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of NoMachine S.r.l. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+#include "ClientStore.h"
+
+//
+// Cached request classes.
+//
+
+#include "ChangeProperty.h"
+#include "SendEvent.h"
+#include "CreateGC.h"
+#include "ChangeGC.h"
+#include "CreatePixmap.h"
+#include "SetClipRectangles.h"
+#include "CopyArea.h"
+#include "PolyLine.h"
+#include "PolySegment.h"
+#include "PolyFillRectangle.h"
+#include "PutImage.h"
+#include "TranslateCoords.h"
+#include "GetImage.h"
+#include "ClearArea.h"
+#include "ConfigureWindow.h"
+#include "ShapeExtension.h"
+#include "RenderExtension.h"
+#include "PolyText8.h"
+#include "PolyText16.h"
+#include "ImageText8.h"
+#include "ImageText16.h"
+#include "PolyPoint.h"
+#include "PolyFillArc.h"
+#include "PolyArc.h"
+#include "FillPoly.h"
+#include "InternAtom.h"
+#include "GetProperty.h"
+#include "SetUnpackGeometry.h"
+#include "SetUnpackColormap.h"
+#include "SetUnpackAlpha.h"
+#include "PutPackedImage.h"
+#include "GenericRequest.h"
+
+#include "ChangeGCCompat.h"
+#include "CreatePixmapCompat.h"
+#include "SetUnpackColormapCompat.h"
+#include "SetUnpackAlphaCompat.h"
+
+//
+// Set the verbosity level.
+//
+
+#define WARNING
+#define PANIC
+#undef TEST
+
+ClientStore::ClientStore(StaticCompressor *compressor)
+
+ : compressor_(compressor)
+{
+ if (logofs == NULL)
+ {
+ logofs = &cout;
+ }
+
+ for (int i = 0; i < CHANNEL_STORE_OPCODE_LIMIT; i++)
+ {
+ requests_[i] = NULL;
+ }
+
+ requests_[X_ChangeProperty] = new ChangePropertyStore();
+ requests_[X_SendEvent] = new SendEventStore();
+ requests_[X_CreateGC] = new CreateGCStore();
+ requests_[X_SetClipRectangles] = new SetClipRectanglesStore();
+ requests_[X_CopyArea] = new CopyAreaStore();
+ requests_[X_PolyLine] = new PolyLineStore();
+ requests_[X_PolySegment] = new PolySegmentStore();
+ requests_[X_PolyFillRectangle] = new PolyFillRectangleStore();
+ requests_[X_PutImage] = new PutImageStore(compressor);
+ requests_[X_TranslateCoords] = new TranslateCoordsStore();
+ requests_[X_GetImage] = new GetImageStore();
+ requests_[X_ClearArea] = new ClearAreaStore();
+ requests_[X_ConfigureWindow] = new ConfigureWindowStore();
+ requests_[X_PolyText8] = new PolyText8Store();
+ requests_[X_PolyText16] = new PolyText16Store();
+ requests_[X_ImageText8] = new ImageText8Store();
+ requests_[X_ImageText16] = new ImageText16Store();
+ requests_[X_PolyPoint] = new PolyPointStore();
+ requests_[X_PolyFillArc] = new PolyFillArcStore();
+ requests_[X_PolyArc] = new PolyArcStore();
+ requests_[X_FillPoly] = new FillPolyStore();
+ requests_[X_InternAtom] = new InternAtomStore();
+ requests_[X_GetProperty] = new GetPropertyStore();
+
+ requests_[X_NXInternalShapeExtension] = new ShapeExtensionStore(compressor);
+ requests_[X_NXInternalGenericRequest] = new GenericRequestStore(compressor);
+ requests_[X_NXInternalRenderExtension] = new RenderExtensionStore(compressor);
+ requests_[X_NXSetUnpackGeometry] = new SetUnpackGeometryStore(compressor);
+ requests_[X_NXPutPackedImage] = new PutPackedImageStore(compressor);
+
+ if (control -> isProtoStep7() == 1)
+ {
+ requests_[X_ChangeGC] = new ChangeGCStore();
+ requests_[X_CreatePixmap] = new CreatePixmapStore();
+ requests_[X_NXSetUnpackColormap] = new SetUnpackColormapStore(compressor);
+ requests_[X_NXSetUnpackAlpha] = new SetUnpackAlphaStore(compressor);
+ }
+ else
+ {
+ requests_[X_ChangeGC] = new ChangeGCCompatStore();
+ requests_[X_CreatePixmap] = new CreatePixmapCompatStore();
+ requests_[X_NXSetUnpackColormap] = new SetUnpackColormapCompatStore(compressor);
+ requests_[X_NXSetUnpackAlpha] = new SetUnpackAlphaCompatStore(compressor);
+ }
+
+ for (int i = 0; i < CHANNEL_STORE_RESOURCE_LIMIT; i++)
+ {
+ splits_[i] = NULL;
+ }
+
+ commits_ = new CommitStore(compressor);
+}
+
+ClientStore::~ClientStore()
+{
+ if (logofs == NULL)
+ {
+ logofs = &cout;
+ }
+
+ for (int i = 0; i < CHANNEL_STORE_OPCODE_LIMIT; i++)
+ {
+ delete requests_[i];
+ }
+
+ for (int i = 0; i < CHANNEL_STORE_RESOURCE_LIMIT; i++)
+ {
+ delete splits_[i];
+ }
+
+ delete commits_;
+}
+
+int ClientStore::saveRequestStores(ostream *cachefs, md5_state_t *md5StateStream,
+ md5_state_t *md5StateClient, T_checksum_action checksumAction,
+ T_data_action dataAction) const
+{
+ for (int i = 0; i < CHANNEL_STORE_OPCODE_LIMIT; i++)
+ {
+ if (requests_[i] != NULL &&
+ requests_[i] -> saveStore(cachefs, md5StateStream, md5StateClient,
+ checksumAction, dataAction,
+ storeBigEndian()) < 0)
+ {
+ #ifdef WARNING
+ *logofs << "ClientStore: WARNING! Error saving request store "
+ << "for OPCODE#" << (unsigned int) i << ".\n"
+ << logofs_flush;
+ #endif
+
+ cerr << "Warning" << ": Error saving request store "
+ << "for opcode '" << (unsigned int) i << "'.\n";
+
+ return -1;
+ }
+ }
+
+ return 1;
+}
+
+int ClientStore::loadRequestStores(istream *cachefs, md5_state_t *md5StateStream,
+ T_checksum_action checksumAction, T_data_action dataAction) const
+{
+ for (int i = 0; i < CHANNEL_STORE_OPCODE_LIMIT; i++)
+ {
+ if (requests_[i] != NULL &&
+ requests_[i] -> loadStore(cachefs, md5StateStream,
+ checksumAction, dataAction,
+ storeBigEndian()) < 0)
+ {
+ #ifdef WARNING
+ *logofs << "ClientStore: WARNING! Error loading request store "
+ << "for OPCODE#" << (unsigned int) i << ".\n"
+ << logofs_flush;
+ #endif
+
+ return -1;
+ }
+ }
+
+ return 1;
+}
+
+void ClientStore::dumpSplitStores() const
+{
+ for (int i = 0; i < CHANNEL_STORE_RESOURCE_LIMIT; i++)
+ {
+ if (splits_[i] != NULL)
+ {
+ splits_[i] -> dump();
+ }
+ }
+
+ if ((getSplitTotalSize() != 0 && getSplitTotalStorageSize() == 0) ||
+ (getSplitTotalSize() == 0 && getSplitTotalStorageSize() != 0))
+ {
+ #ifdef PANIC
+ *logofs << "ClientStore: PANIC! Inconsistency detected "
+ << "while handling the split stores.\n"
+ << logofs_flush;
+ #endif
+
+ HandleCleanup();
+ }
+}