[rkward-cvs] SF.net SVN: rkward-code:[4616] branches/development_branches/ rkward_graphpics_device/rkward

tfry at users.sf.net tfry at users.sf.net
Thu Mar 21 19:34:54 UTC 2013


Revision: 4616
          http://sourceforge.net/p/rkward/code/4616
Author:   tfry
Date:     2013-03-21 19:34:53 +0000 (Thu, 21 Mar 2013)
Log Message:
-----------
Basic communication appears to be working.

Modified Paths:
--------------
    branches/development_branches/rkward_graphpics_device/rkward/debug.h
    branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkbackendtransmitter.h
    branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkfrontendtransmitter.cpp
    branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkfrontendtransmitter.h
    branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkrbackend.cpp
    branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkrbackendprotocol_backend.cpp
    branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkrbackendprotocol_backend.h
    branches/development_branches/rkward_graphpics_device/rkward/rbackend/rktransmitter.h
    branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_backendtransmitter.cpp
    branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_backendtransmitter.h
    branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_frontendtransmitter.cpp
    branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_protocol_shared.h
    branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_setup.cpp
    branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_stubs.cpp
    branches/development_branches/rkward_graphpics_device/rkward/settings/rksettingsmoduledebug.cpp

Added Paths:
-----------
    branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_frontendtransmitter.h

Modified: branches/development_branches/rkward_graphpics_device/rkward/debug.h
===================================================================
--- branches/development_branches/rkward_graphpics_device/rkward/debug.h	2013-03-21 15:53:25 UTC (rev 4615)
+++ branches/development_branches/rkward_graphpics_device/rkward/debug.h	2013-03-21 19:34:53 UTC (rev 4616)
@@ -32,17 +32,18 @@
 
 // Debug components
 #define APP 1
-#define PLUGIN 2
-#define OBJECTS 4
-#define EDITOR 8
-#define SETTINGS 16
-#define PHP 64
-#define RBACKEND 128
-#define COMMANDEDITOR 256
-#define MISC 512
-#define DIALOGS 1024
-#define OUTPUT 2048
-#define XML 4096
+#define PLUGIN 1 << 1
+#define OBJECTS 1 << 2
+#define EDITOR 1 << 3
+#define SETTINGS 1 << 4
+#define PHP 1 << 5
+#define RBACKEND 1 << 6
+#define COMMANDEDITOR 1 << 7
+#define MISC 1 << 8
+#define DIALOGS 1 << 9
+#define OUTPUT 1 << 10
+#define XML 1 << 11
+#define GRAPHICS_DEVICE 1 << 12
 #define ALL (APP | PLUGIN | PHP | OBJECTS | EDITOR | RBACKEND | COMMANDEDITOR | MISC | DIALOGS | OUTPUT | XML)
 
 #ifdef RKWARD_DEBUG

Modified: branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkbackendtransmitter.h
===================================================================
--- branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkbackendtransmitter.h	2013-03-21 15:53:25 UTC (rev 4615)
+++ branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkbackendtransmitter.h	2013-03-21 19:34:53 UTC (rev 4616)
@@ -40,7 +40,6 @@
 	void flushOutput (bool force);
 	QList<RBackendRequest*> current_sync_requests;	// pointers to the request that we expect a reply for. Yes, internally, this can be several requests.
 	QString servername;
-	QString token;
 };
 
 #endif

Modified: branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkfrontendtransmitter.cpp
===================================================================
--- branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkfrontendtransmitter.cpp	2013-03-21 15:53:25 UTC (rev 4615)
+++ branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkfrontendtransmitter.cpp	2013-03-21 19:34:53 UTC (rev 4616)
@@ -2,7 +2,7 @@
                           rkfrontendtransmitter  -  description
                              -------------------
     begin                : Thu Nov 04 2010
-    copyright            : (C) 2010, 2011 by Thomas Friedrichsmeier
+    copyright            : (C) 2010, 2011, 2013 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -18,6 +18,7 @@
 #include "rkfrontendtransmitter.h"
 
 #include "rkrbackendprotocol_frontend.h"
+#include "rkwarddevice/rkgraphicsdevice_frontendtransmitter.h"
 #include "../misc/rkcommonfunctions.h"
 #include "../settings/rksettingsmodulegeneral.h"
 
@@ -36,12 +37,14 @@
 RKFrontendTransmitter::RKFrontendTransmitter () : RKAbstractTransmitter () {
 	RK_TRACE (RBACKEND);
 
+	rkd_transmitter = new RKGraphicsDeviceFrontendTransmitter ();
 	start ();
 }
 
 RKFrontendTransmitter::~RKFrontendTransmitter () {
 	RK_TRACE (RBACKEND);
 
+	delete rkd_transmitter;
 	RK_ASSERT (!server->isListening ());
 }
 
@@ -68,6 +71,7 @@
 	QStringList args;
 	args.append ("--debug-level=" + QString::number (RK_Debug_Level));
 	args.append ("--server-name=" + server->fullServerName ());
+	args.append ("--rkd-server-name=" + rkd_transmitter->serverName ());
 	args.append ("--data-dir=" + RKSettingsModuleGeneral::filesPath ());
 	args.append ("--locale-dir=" + KGlobal::dirs()->findResourceDir ("locale", KGlobal::locale ()->language () + "/LC_MESSAGES/rkward.mo"));
 	connect (backend, SIGNAL (finished (int, QProcess::ExitStatus)), this, SLOT (backendExit (int)));

Modified: branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkfrontendtransmitter.h
===================================================================
--- branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkfrontendtransmitter.h	2013-03-21 15:53:25 UTC (rev 4615)
+++ branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkfrontendtransmitter.h	2013-03-21 19:34:53 UTC (rev 4616)
@@ -22,6 +22,7 @@
 
 class QProcess;
 class QLocalServer;
+class RKGraphicsDeviceFrontendTransmitter;
 
 class RKFrontendTransmitter : public RKAbstractTransmitter, public RKROutputBuffer {
 Q_OBJECT
@@ -46,7 +47,7 @@
 	int current_request_length;
 	QProcess* backend;
 	QLocalServer* server;
-	QString token;
+	RKGraphicsDeviceFrontendTransmitter* rkd_transmitter;
 };
 
 #endif

Modified: branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkrbackend.cpp
===================================================================
--- branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkrbackend.cpp	2013-03-21 15:53:25 UTC (rev 4615)
+++ branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkrbackend.cpp	2013-03-21 19:34:53 UTC (rev 4616)
@@ -992,6 +992,8 @@
 	return (R_NilValue);
 }
 
+SEXP RKStartGraphicsDevice (SEXP width, SEXP height, SEXP pointsize, SEXP family);
+
 bool RKRBackend::startR () {
 	RK_TRACE (RBACKEND);
 
@@ -1077,6 +1079,7 @@
 		{ "rk.dialog", (DL_FUNC) &doDialog, 6 },
 		{ "rk.update.locale", (DL_FUNC) &doUpdateLocale, 0 },
 		{ "rk.locale.name", (DL_FUNC) &doLocaleName, 0 },
+		{ "rk.graphics.device", (DL_FUNC) &RKStartGraphicsDevice, 4},
 		{ 0, 0, 0 }
 	};
 	R_registerRoutines (R_getEmbeddingDllInfo(), NULL, callMethods, NULL, NULL);

Modified: branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkrbackendprotocol_backend.cpp
===================================================================
--- branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkrbackendprotocol_backend.cpp	2013-03-21 15:53:25 UTC (rev 4615)
+++ branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkrbackendprotocol_backend.cpp	2013-03-21 19:34:53 UTC (rev 4616)
@@ -2,7 +2,7 @@
                           rkrbackendprotocol  -  description
                              -------------------
     begin                : Thu Nov 04 2010
-    copyright            : (C) 2010 by Thomas Friedrichsmeier
+    copyright            : (C) 2010, 2013 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -125,7 +125,7 @@
 		RK_Debug_File->setAutoRemove (false);
 		if (RK_Debug_File->open ()) qInstallMsgHandler (RKDebugMessageOutput);
 
-		QString servername;
+		QString servername, rkd_server_name;
 		QString data_dir, locale_dir;
 		QStringList args = app.arguments ();
 		for (int i = 1; i < args.count (); ++i) {
@@ -138,6 +138,8 @@
 				data_dir = args[i].section ('=', 1);
 			} else if (args[i].startsWith ("--locale-dir")) {
 				locale_dir = args[i].section ('=', 1);
+			} else if (args[i].startsWith ("--rkd-server-name")) {
+				rkd_server_name = args[i].section ('=', 1);
 			} else {
 				printf ("unkown argument %s", qPrintable (args[i]));
 			}
@@ -154,7 +156,7 @@
 		fflush (stdout);
 
 		RKRBackendTransmitter transmitter (servername, token);
-		RKRBackendProtocolBackend backend (data_dir);
+		RKRBackendProtocolBackend backend (data_dir, rkd_server_name);
 		transmitter.start ();
 		RKRBackend::this_pointer->run (locale_dir);
 		transmitter.quit ();
@@ -165,7 +167,7 @@
 #endif
 
 RKRBackendProtocolBackend* RKRBackendProtocolBackend::_instance = 0;
-RKRBackendProtocolBackend::RKRBackendProtocolBackend (const QString &storage_dir) {
+RKRBackendProtocolBackend::RKRBackendProtocolBackend (const QString &storage_dir, const QString &_rkd_server_name) {
 	RK_TRACE (RBACKEND);
 
 	_instance = this;
@@ -181,6 +183,7 @@
 #	endif
 #endif
 	data_dir = storage_dir;
+	rkd_server_name = _rkd_server_name;
 }
 
 RKRBackendProtocolBackend::~RKRBackendProtocolBackend () {

Modified: branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkrbackendprotocol_backend.h
===================================================================
--- branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkrbackendprotocol_backend.h	2013-03-21 15:53:25 UTC (rev 4615)
+++ branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkrbackendprotocol_backend.h	2013-03-21 19:34:53 UTC (rev 4616)
@@ -2,7 +2,7 @@
                           rkrbackendprotocol  -  description
                              -------------------
     begin                : Thu Nov 04 2010
-    copyright            : (C) 2010, 2011 by Thomas Friedrichsmeier
+    copyright            : (C) 2010, 2011, 2013 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -26,9 +26,10 @@
 public:
 	static bool inRThread ();
 	static QString dataDir () { return _instance->data_dir; };
+	static QString rkdServerName () { return _instance->rkd_server_name; };
 	static QString backendDebugFile ();
 
-	RKRBackendProtocolBackend (const QString &data_dir);
+	RKRBackendProtocolBackend (const QString &data_dir, const QString &rkd_server_name);
 	~RKRBackendProtocolBackend ();
 protected:
 friend class RKRBackendProtocolFrontend;
@@ -40,6 +41,7 @@
 	static RKRBackendProtocolBackend* instance () { return _instance; };
 	QString data_dir;
 private:
+	QString rkd_server_name;
 	static RKRBackendProtocolBackend* _instance;
 	QThread *r_thread;
 #ifndef Q_WS_WIN

Modified: branches/development_branches/rkward_graphpics_device/rkward/rbackend/rktransmitter.h
===================================================================
--- branches/development_branches/rkward_graphpics_device/rkward/rbackend/rktransmitter.h	2013-03-21 15:53:25 UTC (rev 4615)
+++ branches/development_branches/rkward_graphpics_device/rkward/rbackend/rktransmitter.h	2013-03-21 19:34:53 UTC (rev 4616)
@@ -2,7 +2,7 @@
                           rktransmitter  -  description
                              -------------------
     begin                : Thu Nov 18 2010
-    copyright            : (C) 2010 by Thomas Friedrichsmeier
+    copyright            : (C) 2010, 2013 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -50,6 +50,9 @@
 public:
 	static RKAbstractTransmitter* instance () { return _instance; };
 	virtual ~RKAbstractTransmitter ();
+
+/** returns the magic token negotiated between frontend and backend (for validating incoming connections) */
+	QString connectionToken () { return token; };
 protected:
 	RKAbstractTransmitter ();
 
@@ -61,6 +64,7 @@
 	void customEvent (QEvent *e);
 	void setConnection (QLocalSocket *connection);
 	QLocalSocket *connection;
+	QString token;
 private slots:
 	/** Note: this blocks until a compelete request has been received. Connected to the "readyRead"-signal of the connection. Calls requestReceived() once the request has been read. */
 	void fetchTransmission ();

Modified: branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_backendtransmitter.cpp
===================================================================
--- branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_backendtransmitter.cpp	2013-03-21 15:53:25 UTC (rev 4615)
+++ branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_backendtransmitter.cpp	2013-03-21 19:34:53 UTC (rev 4616)
@@ -1,5 +1,5 @@
 /***************************************************************************
-                          rkgraphicsdevice  -  description
+                          rkgraphicsdevice_backendtransmitter  -  description
                              -------------------
     begin                : Mon Mar 18 20:06:08 CET 2013
     copyright            : (C) 2013 by Thomas Friedrichsmeier 
@@ -17,29 +17,53 @@
 
 #include "rkgraphicsdevice_backendtransmitter.h"
 
+#include <QLocalSocket>
+#include "../rkrbackendprotocol_backend.h"
+#define RKWARD_SPLIT_PROCESS 1
+#include "../rkbackendtransmitter.h"
+
 #include "../../debug.h"
 
-QByteArray RKGraphicsDeviceBackendTransmitter::buffer;
-QDataStream RKGraphicsDeviceBackendTransmitter::protocol (&buffer, QIODevice::ReadWrite);
-QAbstractSocket* RKGraphicsDeviceBackendTransmitter::connection = 0;
+RKAsyncDataStreamHelper RKGraphicsDeviceBackendTransmitter::streamer;
+QIODevice* RKGraphicsDeviceBackendTransmitter::connection = 0;
 QMutex RKGraphicsDeviceBackendTransmitter::mutex;
+RKGraphicsDeviceBackendTransmitter* RKGraphicsDeviceBackendTransmitter::_instance = 0;
 
-RKGraphicsDeviceBackendTransmitter::RKGraphicsDeviceBackendTransmitter (QAbstractSocket* _connection) : QThread () {
-	RK_TRACE (RBACKEND);
+RKGraphicsDeviceBackendTransmitter::RKGraphicsDeviceBackendTransmitter (QIODevice* _connection) : QThread () {
+	RK_TRACE (GRAPHICS_DEVICE);
 
 	RK_ASSERT (!connection);
 	RK_ASSERT (_connection);
 	connection = _connection;
+	streamer.setIODevice (connection);
 	alive = true;
 	start ();
 }
 
 RKGraphicsDeviceBackendTransmitter::~RKGraphicsDeviceBackendTransmitter () {
-	RK_TRACE (RBACKEND);
+	RK_TRACE (GRAPHICS_DEVICE);
+	delete connection;
 }
 
+RKGraphicsDeviceBackendTransmitter* RKGraphicsDeviceBackendTransmitter::instance () {
+	if (_instance) return _instance;
+	RK_TRACE (GRAPHICS_DEVICE);
+
+	QLocalSocket *con = new QLocalSocket ();
+	con->connectToServer (RKRBackendProtocolBackend::rkdServerName ());
+	con->waitForConnected (2000);
+	if (con->state () == QLocalSocket::ConnectedState) {
+		con->write (RKRBackendTransmitter::instance ()->connectionToken ().toLocal8Bit ().data ());
+		con->write ("\n");
+		con->waitForBytesWritten (1000);
+		_instance = new RKGraphicsDeviceBackendTransmitter (con);
+		return _instance;
+	}
+	return 0;
+}
+
 void RKGraphicsDeviceBackendTransmitter::run () {
-	RK_TRACE (RBACKEND);
+	RK_TRACE (GRAPHICS_DEVICE);
 
 	while (alive) {
 		msleep (10);	// it's ok to be lazy. If a request expects a reply, RKGraphicsDataStreamReadGuard will take care of pushing everything, itself. Essentially, this thread's job is simply to make sure we don't lag *too* far behind.
@@ -48,13 +72,17 @@
 		mutex.unlock ();
 	}
 
-	RK_TRACE (RBACKEND);
+	RK_TRACE (GRAPHICS_DEVICE);
 }
 
 void RKGraphicsDeviceBackendTransmitter::kill () {
-	RK_TRACE (RBACKEND);
-	mutex.lock ();
-	alive = false;
-	mutex.unlock ();
-	wait (1000);
+	if (_instance) {
+		RK_TRACE (GRAPHICS_DEVICE);
+		mutex.lock ();
+		_instance->alive = false;
+		mutex.unlock ();
+		_instance->wait (1000);
+		delete _instance;
+		_instance = 0;
+	}
 }

Modified: branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_backendtransmitter.h
===================================================================
--- branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_backendtransmitter.h	2013-03-21 15:53:25 UTC (rev 4615)
+++ branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_backendtransmitter.h	2013-03-21 19:34:53 UTC (rev 4616)
@@ -1,5 +1,5 @@
 /***************************************************************************
-                          rkgraphicsdevice  -  description
+                          rkgraphicsdevice_backendtransmitter  -  description
                              -------------------
     begin                : Mon Mar 18 20:06:08 CET 2013
     copyright            : (C) 2013 by Thomas Friedrichsmeier 
@@ -15,24 +15,31 @@
  *                                                                         *
  ***************************************************************************/
 
-#include <QAbstractSocket>
+#ifndef RKGRAPHICSDEVICE_BACKENDTRANSMITTER_H
+#define RKGRAPHICSDEVICE_BACKENDTRANSMITTER_H
+
+#include <QIODevice>
 #include <QThread>
 #include <QMutex>
 
+#include "rkgraphicsdevice_protocol_shared.h"
+
 /** This simple class is responsible for handling the backend side of transmitting data / requests for the RKGraphicsDevice
  Also it provides the namespace for some statics.
  As the protocol is really quite simple (only the backend send requests, only one request at a time), so is the transmitter. */
 class RKGraphicsDeviceBackendTransmitter : public QThread {
-	RKGraphicsDeviceBackendTransmitter (QAbstractSocket *connection);
+	RKGraphicsDeviceBackendTransmitter (QIODevice *connection);
 	~RKGraphicsDeviceBackendTransmitter ();
-
-	void kill ();
 public:
-	static QByteArray buffer;
-	static QDataStream protocol;
-	static QAbstractSocket* connection;
+	static void kill ();
+	static RKGraphicsDeviceBackendTransmitter* instance ();
+	static RKAsyncDataStreamHelper streamer;
+	static QIODevice* connection;
 	static QMutex mutex;
 private:
+	static RKGraphicsDeviceBackendTransmitter* _instance;
 	bool alive;
 	void run ();
 };
+
+#endif

Modified: branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_frontendtransmitter.cpp
===================================================================
--- branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_frontendtransmitter.cpp	2013-03-21 15:53:25 UTC (rev 4615)
+++ branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_frontendtransmitter.cpp	2013-03-21 19:34:53 UTC (rev 4616)
@@ -0,0 +1,116 @@
+/***************************************************************************
+                          rkgraphicsdevice_frontendtransmitter  -  description
+                             -------------------
+    begin                : Mon Mar 18 20:06:08 CET 2013
+    copyright            : (C) 2013 by Thomas Friedrichsmeier 
+    email                : tfry at users.sourceforge.net
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#include "rkgraphicsdevice_frontendtransmitter.h"
+
+#include <QLocalServer>
+#include <QLocalSocket>
+#include <QIODevice>
+#include <krandom.h>
+
+// NOTE: This is but the latest nail in the coffin of the single process variant of RKWard.
+// *IF* the RKWard Graphics Device works out as hoped, the single process variant can finally be ditched for good.
+#define RKWARD_SPLIT_PROCESS 1
+#include "../rkfrontendtransmitter.h"
+#include "../../version.h"
+
+#include "../../debug.h"
+
+RKGraphicsDeviceFrontendTransmitter::RKGraphicsDeviceFrontendTransmitter () : QObject () {
+	RK_TRACE (GRAPHICS_DEVICE);
+
+	connection = 0;
+	local_server = 0;
+
+	setupServer ();
+}
+
+RKGraphicsDeviceFrontendTransmitter::~RKGraphicsDeviceFrontendTransmitter () {
+	RK_TRACE (GRAPHICS_DEVICE);
+
+	if (connection) connection->close ();
+}
+
+void RKGraphicsDeviceFrontendTransmitter::setupServer () {
+	RK_TRACE (GRAPHICS_DEVICE);
+
+	RK_ASSERT (!local_server);
+	local_server = new QLocalServer ();
+	RK_ASSERT (local_server->listen ("rkd" + KRandom::randomString (8)));
+	connect (local_server, SIGNAL (newConnection ()), this, SLOT (newConnection()));
+	server_name = local_server->fullServerName ();
+}
+
+void RKGraphicsDeviceFrontendTransmitter::newConnection () {
+	RK_TRACE (GRAPHICS_DEVICE);
+
+	RK_ASSERT (!connection);
+	QLocalSocket *con = local_server->nextPendingConnection ();
+	local_server->close ();
+
+	// handshake
+	QString token = RKFrontendTransmitter::instance ()->connectionToken ();
+	if (!con->canReadLine ()) con->waitForReadyRead (1000);
+	QString token_c = QString::fromLocal8Bit (con->readLine ());
+	token_c.chop (1);
+	if (token_c != token) {
+#warning TODO error handling
+		con->close ();
+		return;
+	}
+
+	connection = con;
+	streamer.setIODevice (con);
+	connect (connection, SIGNAL (readyRead ()), this, SLOT (newData ()));
+}
+
+void RKGraphicsDeviceFrontendTransmitter::newData () {
+//	RK_TRACE (GRAPHICS_DEVICE);
+
+	if (!streamer.readInBuffer ()) return;	// wait for more data to come in
+
+	quint8 opcode, devnum;
+	streamer.instream >> opcode;
+	streamer.instream >> devnum;
+	RK_DEBUG (DL_WARNING, GRAPHICS_DEVICE, "Received transmission of type %d, devnum %d, size %d", opcode, devnum, streamer.inSize ());
+
+#warning TODO: Actually handle the data!
+	if (opcode == RKDLocator) {
+		bool ok = true;
+		double x, y;
+		x = y = 0;
+		streamer.outstream << ok << x << y;
+		streamer.writeOutBuffer ();
+	} else if (opcode == RKDMetricInfo) {
+		double ascent, descent, width;
+		ascent = descent = width = 0.1;
+		streamer.outstream << ascent << descent << width;
+		streamer.writeOutBuffer ();
+	} else if (opcode == RKDNewPageConfirm) {
+		bool ok = true;
+		streamer.outstream << ok;
+		streamer.writeOutBuffer ();
+	} else if (opcode == RKDStrWidthUTF8) {
+		double width = 1;
+		streamer.outstream << width;
+		streamer.writeOutBuffer ();
+	}
+
+	if (connection->bytesAvailable ()) newData ();
+}
+
+#include "rkgraphicsdevice_frontendtransmitter.moc"
\ No newline at end of file

Added: branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_frontendtransmitter.h
===================================================================
--- branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_frontendtransmitter.h	                        (rev 0)
+++ branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_frontendtransmitter.h	2013-03-21 19:34:53 UTC (rev 4616)
@@ -0,0 +1,45 @@
+/***************************************************************************
+                          rkgraphicsdevice_frontendtransmitter  -  description
+                             -------------------
+    begin                : Mon Mar 18 20:06:08 CET 2013
+    copyright            : (C) 2013 by Thomas Friedrichsmeier 
+    email                : tfry at users.sourceforge.net
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#ifndef RKGRAPHICSDEVICE_FRONTENDTRANSMITTER_H
+#define RKGRAPHICSDEVICE_FRONTENDTRANSMITTER_H
+
+#include "rkgraphicsdevice_protocol_shared.h"
+
+class QIODevice;
+class QLocalServer;
+
+/** Handles the frontend side of RKWard Graphics Device transmissions. Since the
+ * frontend has a running Qt event loop, We can use simple signals and slots, here. */
+class RKGraphicsDeviceFrontendTransmitter : public QObject {
+	Q_OBJECT
+public:
+	RKGraphicsDeviceFrontendTransmitter ();
+	~RKGraphicsDeviceFrontendTransmitter ();
+	QString serverName () const { return server_name; };
+public slots:
+	void newData ();
+	void newConnection ();
+private:
+	void setupServer ();
+	QString server_name;
+	QIODevice *connection;
+	QLocalServer *local_server;
+	RKAsyncDataStreamHelper streamer;
+};
+
+#endif

Modified: branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_protocol_shared.h
===================================================================
--- branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_protocol_shared.h	2013-03-21 15:53:25 UTC (rev 4615)
+++ branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_protocol_shared.h	2013-03-21 19:34:53 UTC (rev 4616)
@@ -1,5 +1,5 @@
 /***************************************************************************
-                          rkgraphicsdevice  -  description
+                          rkgraphicsdevice_protocol_shared  -  description
                              -------------------
     begin                : Mon Mar 18 20:06:08 CET 2013
     copyright            : (C) 2013 by Thomas Friedrichsmeier 
@@ -15,6 +15,29 @@
  *                                                                         *
  ***************************************************************************/
 
+#ifndef RKGRAPHICSDEVICE_PROTOCOL_SHARED_H
+#define RKGRAPHICSDEVICE_PROTOCOL_SHARED_H
+
+/** @page RKGraphicsDeviceProtocol
+ * 
+ * The key feature of the RKWard Graphics Device is that it serializes all drawing operations, so they
+ * can be sent to a separate process (the frontend) or even computer (well, not yet). Some notes on the protocol:
+ * 
+ * This is not the same protocol as used for other communication between frontend and backend, and not even
+ * the same connection. The key idea behind this protocol here, is that it should have very low overhead,
+ * even when sending many @em small requests.
+ * 
+ * All communication is initiated from the backend. The backend sends a request, starting with the size of the
+ * request in bytes (quint32), then an opcode, then the device number, then all applicable parameters. Most requests
+ * are asynchronous, but a few await a reply from the frontend.
+ * 
+ * At any time, there can only be one request waiting for a reply, and the request waiting for a reply is always the most
+ * recent one. This makes the protocol very simple.
+ * 
+ * If the frontend has spontaneous need for communication, it will have to use some separate channel.
+ * 
+ */
+
 enum RKDOpcodes {
 	// Asynchronous operations
 	RKDCreate,
@@ -38,3 +61,79 @@
 	RKDLocator,
 	RKDNewPageConfirm
 };
+
+#include <QIODevice>
+#include <QDataStream>
+#include <QByteArray>
+
+/** Using a QDataStream on an asynchronous connection is somewhat cumbersome due to the need to ensure that chunks of
+ * data are complete, when we process them. This small class helps with that. Essentially:
+ *
+ * - write to outstream
+ * - when a chunk is done, push it to the device using writeOutBuffer().
+ * 
+ * To read a chunk call
+ * - readInBuffer() repeatedly, until it returns true
+ * - read from instream
+ */
+class RKAsyncDataStreamHelper {
+public:
+	RKAsyncDataStreamHelper () : instream (&inbuffer, QIODevice::ReadOnly), outstream (&outbuffer, QIODevice::WriteOnly), auxstream (&auxbuffer, QIODevice::ReadWrite) {
+		device = 0;
+		expected_read_size = 0;
+	}
+	~RKAsyncDataStreamHelper () {};
+
+	void setIODevice (QIODevice *_device) {
+		device = _device;
+	}
+
+	void writeOutBuffer () {
+		auxstream.device ()->seek (0);
+		auxbuffer.resize (0);
+		auxstream << (quint32) outbuffer.size ();
+		device->write (auxbuffer);
+		device->write (outbuffer);
+		outstream.device ()->seek (0);
+		outbuffer.resize (0);
+	}
+
+/** @returns false if no complete chunk of data is available, yet. true, if the next chunk of data is available for
+ * processing from instream. */
+	bool readInBuffer () {
+		if (!expected_read_size) {
+			if (device->bytesAvailable () < sizeof (quint32)) {
+				return false;
+			} else {
+				auxbuffer = device->read (sizeof (quint32));
+				auxstream.device ()->seek (0);
+				auxstream >> expected_read_size;
+			}
+		}
+
+		if (device->bytesAvailable () < expected_read_size) {
+			return false;
+		}
+
+		inbuffer = device->read (expected_read_size);
+		instream.device ()->seek (0);
+		expected_read_size = 0;
+		return true;
+	}
+
+	int inSize () const {
+		return inbuffer.size ();
+	}
+	
+	QDataStream instream;
+	QDataStream outstream;
+private:
+	QIODevice *device;
+	quint32 expected_read_size;
+	QByteArray inbuffer;
+	QByteArray outbuffer;
+	QByteArray auxbuffer;
+	QDataStream auxstream;
+};
+
+#endif

Modified: branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_setup.cpp
===================================================================
--- branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_setup.cpp	2013-03-21 15:53:25 UTC (rev 4615)
+++ branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_setup.cpp	2013-03-21 19:34:53 UTC (rev 4616)
@@ -1,5 +1,5 @@
 /***************************************************************************
-                          rkgraphicsdevice  -  description
+                          rkgraphicsdevice_setup  -  description
                              -------------------
     begin                : Mon Mar 18 20:06:08 CET 2013
     copyright            : (C) 2013 by Thomas Friedrichsmeier 
@@ -64,21 +64,20 @@
 	BEGIN_SUSPEND_INTERRUPTS {
 		/* Allocate and initialize the device driver data */
 		dev = (pDevDesc) calloc (1, sizeof(DevDesc));
-		if (!(dev && desc->initRDevDesc (dev, pointsize))) {
+		if (!(dev && desc->initRDevDesc (dev, pointsize) && RKGraphicsDeviceBackendTransmitter::instance ())) {
 			free (dev);
 			delete (desc);
 			desc = 0;
 		} else {
+			desc->devnum = curDevice ();
+			RKD_Create (desc->width, desc->height, dev);
 			pGEDevDesc gdd = GEcreateDevDesc (dev);
 			gdd->displayList = R_NilValue;
 			GEaddDevice2 (gdd, "RKGraphicsDevice");
 		}
 	} END_SUSPEND_INTERRUPTS;
 
-	if (desc) {
-		desc->devnum = curDevice ();
-		RKD_Create (desc->width, desc->height, dev);
-	} else {
+	if (!desc) {
 		Rf_error("unable to start device");
 	}
 }

Modified: branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_stubs.cpp
===================================================================
--- branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_stubs.cpp	2013-03-21 15:53:25 UTC (rev 4615)
+++ branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_stubs.cpp	2013-03-21 19:34:53 UTC (rev 4616)
@@ -1,5 +1,5 @@
 /***************************************************************************
-                          rkgraphicsdevice  -  description
+                          rkgraphicsdevice_stubs  -  description
                              -------------------
     begin                : Mon Mar 18 20:06:08 CET 2013
     copyright            : (C) 2013 by Thomas Friedrichsmeier 
@@ -15,6 +15,10 @@
  *                                                                         *
  ***************************************************************************/
 
+/* NOTE: This file is essentially a split-out from rkgraphicsdevice_setup.cpp,
+ * not a compilation unit of its own.
+ * It is meant to be included, there. */
+
 #include "rkgraphicsdevice_protocol_shared.h"
 #include "rkgraphicsdevice_backendtransmitter.h"
 #include "../rkrbackend.h"
@@ -25,7 +29,8 @@
 
 #include <QRectF>
 
-#define RKD_PROTOCOL RKGraphicsDeviceBackendTransmitter::protocol
+#define RKD_IN_STREAM RKGraphicsDeviceBackendTransmitter::streamer.instream
+#define RKD_OUT_STREAM RKGraphicsDeviceBackendTransmitter::streamer.outstream
 
 /** This class is essentially like QMutexLocker. In addition, the constructor waits until the next chunk of the transmission is ready (and does event processing) */
 class RKGraphicsDataStreamReadGuard {
@@ -36,28 +41,21 @@
  * request down the line. This tells the frontend to send a reply to the last request ASAP (if the frontend has already sent the reply, it will ignore the RKD_Cancel). From there, we simply process the reply as usual, and leave it to R to actually
  * do the interrupt. */
 		RKGraphicsDeviceBackendTransmitter::mutex.lock ();
-		QAbstractSocket* connection = RKGraphicsDeviceBackendTransmitter::connection;
+		QIODevice* connection = RKGraphicsDeviceBackendTransmitter::connection;
 		BEGIN_SUSPEND_INTERRUPTS {
 			while (connection->bytesToWrite ()) {
 				connection->waitForBytesWritten (10);
+#warning TODO: Use R_CheckUserInterrupt(), instead?
 				if (connection->bytesToWrite ()) RKRBackend::processX11Events ();
 			}
-			while (connection->bytesAvailable () < sizeof (quint32)) {
+			while (!RKGraphicsDeviceBackendTransmitter::streamer.readInBuffer ()) {
 				RKRBackend::processX11Events ();
 				connection->waitForReadyRead (10);
 			}
-			quint32 transmisison_size;
-			RKD_PROTOCOL >> transmisison_size;
-			while (connection->bytesAvailable () < transmisison_size) {
-				RKRBackend::processX11Events ();
-				connection->waitForReadyRead (10);
-			}
-			RKGraphicsDeviceBackendTransmitter::buffer = connection->read (transmisison_size);
 		} END_SUSPEND_INTERRUPTS;
 	}
 
 	~RKGraphicsDataStreamReadGuard () {
-		RKGraphicsDeviceBackendTransmitter::buffer.resize (0);
 		RKGraphicsDeviceBackendTransmitter::mutex.unlock ();
 	}
 };
@@ -69,21 +67,11 @@
 		RKGraphicsDeviceBackendTransmitter::mutex.lock ();
 	}
 	~RKGraphicsDataStreamWriteGuard () {
-		aux_stream << (quint32) RKGraphicsDeviceBackendTransmitter::buffer.size ();		// TODO: is uint32 always enough?
-		RKGraphicsDeviceBackendTransmitter::connection->write (aux_buffer);
-		aux_buffer.resize (0);
-		RKGraphicsDeviceBackendTransmitter::connection->write (RKGraphicsDeviceBackendTransmitter::buffer);
-		RKGraphicsDeviceBackendTransmitter::buffer.resize (0);
+		RKGraphicsDeviceBackendTransmitter::streamer.writeOutBuffer ();
 		RKGraphicsDeviceBackendTransmitter::mutex.unlock ();
 	}
-private:
-	static QByteArray aux_buffer;
-	static QDataStream aux_stream;
 };
 
-QByteArray RKGraphicsDataStreamWriteGuard::aux_buffer;
-QDataStream RKGraphicsDataStreamWriteGuard::aux_stream (&RKGraphicsDataStreamWriteGuard::aux_buffer, QIODevice::WriteOnly);
-
 #define WRITE_HEADER(x,dev) (qint8) x << (quint8) static_cast<RKGraphicsDeviceDesc*> (dev->deviceSpecific)->devnum
 #define WRITE_COL() (qint32) gc->col
 #define WRITE_PEN() WRITE_COL() << gc->col << (double) gc->lwd << (qint32) gc->lty
@@ -93,115 +81,115 @@
 
 static void RKD_Create (double width, double height, pDevDesc dev) {
 	RKGraphicsDataStreamWriteGuard guard;
-	RKD_PROTOCOL << WRITE_HEADER (RKDCreate, dev);
-	RKD_PROTOCOL << width << height;
+	RKD_OUT_STREAM << WRITE_HEADER (RKDCreate, dev);
+	RKD_OUT_STREAM << width << height;
 }
 
 static void RKD_Circle (double x, double y, double r, R_GE_gcontext *gc, pDevDesc dev) {
 	RKGraphicsDataStreamWriteGuard guard;
-	RKD_PROTOCOL << WRITE_HEADER (RKDCircle, dev);
-	RKD_PROTOCOL << x << y << r;
-	RKD_PROTOCOL << WRITE_PEN ();
+	RKD_OUT_STREAM << WRITE_HEADER (RKDCircle, dev);
+	RKD_OUT_STREAM << x << y << r;
+	RKD_OUT_STREAM << WRITE_PEN ();
 }
 
 static void RKD_Line (double x1, double y1, double x2, double y2, R_GE_gcontext *gc, pDevDesc dev) {
 	RKGraphicsDataStreamWriteGuard guard;
-	RKD_PROTOCOL << WRITE_HEADER (RKDLine, dev);
-	RKD_PROTOCOL << x1 << y1 << x2 << y2;
-	RKD_PROTOCOL << WRITE_PEN ();
+	RKD_OUT_STREAM << WRITE_HEADER (RKDLine, dev);
+	RKD_OUT_STREAM << x1 << y1 << x2 << y2;
+	RKD_OUT_STREAM << WRITE_PEN ();
 }
 
 static void RKD_Polygon (int n, double *x, double *y, R_GE_gcontext *gc, pDevDesc dev) {
 	RKGraphicsDataStreamWriteGuard guard;
-	RKD_PROTOCOL << WRITE_HEADER (RKDPolygon, dev);
-	quint32 _n = qMax (n, 1 << 25);	// skip stuff exceeding reasonable limits to keep protocol simple
-	RKD_PROTOCOL << _n;
+	RKD_OUT_STREAM << WRITE_HEADER (RKDPolygon, dev);
+	quint32 _n = qMin (n, 1 << 25);	// skip stuff exceeding reasonable limits to keep protocol simple
+	RKD_OUT_STREAM << _n;
 	for (quint32 i = 0; i < _n; ++i) {
-		RKD_PROTOCOL << x[i] << y[i];
+		RKD_OUT_STREAM << x[i] << y[i];
 	}
-	RKD_PROTOCOL << WRITE_PEN ();
-	RKD_PROTOCOL << WRITE_LINE_ENDS ();
-	RKD_PROTOCOL << WRITE_FILL ();
+	RKD_OUT_STREAM << WRITE_PEN ();
+	RKD_OUT_STREAM << WRITE_LINE_ENDS ();
+	RKD_OUT_STREAM << WRITE_FILL ();
 }
 
 static void RKD_Polyline (int n, double *x, double *y, R_GE_gcontext *gc, pDevDesc dev) {
 	RKGraphicsDataStreamWriteGuard guard;
-	RKD_PROTOCOL << WRITE_HEADER (RKDPolyline, dev);
-	quint32 _n = qMax (n, 1 << 25);	// skip stuff exceeding reasonable limits to keep protocol simple
-	RKD_PROTOCOL << _n;
+	RKD_OUT_STREAM << WRITE_HEADER (RKDPolyline, dev);
+	quint32 _n = qMin (n, 1 << 25);	// skip stuff exceeding reasonable limits to keep protocol simple
+	RKD_OUT_STREAM << _n;
 	for (quint32 i = 0; i < _n; ++i) {
-		RKD_PROTOCOL << x[i] << y[i];
+		RKD_OUT_STREAM << x[i] << y[i];
 	}
-	RKD_PROTOCOL << WRITE_PEN ();
-	RKD_PROTOCOL << WRITE_LINE_ENDS ();
+	RKD_OUT_STREAM << WRITE_PEN ();
+	RKD_OUT_STREAM << WRITE_LINE_ENDS ();
 }
 
 static void RKD_Rect (double x0, double y0, double x1, double y1, R_GE_gcontext *gc, pDevDesc dev) {
 	RKGraphicsDataStreamWriteGuard guard;
-	RKD_PROTOCOL << WRITE_HEADER (RKDPolyline, dev);
-	RKD_PROTOCOL << QRectF (x0, y0, x1-x0, y1-y0);
-	RKD_PROTOCOL << WRITE_PEN ();
-	RKD_PROTOCOL << WRITE_LINE_ENDS ();
-	RKD_PROTOCOL << WRITE_FILL ();
+	RKD_OUT_STREAM << WRITE_HEADER (RKDPolyline, dev);
+	RKD_OUT_STREAM << QRectF (x0, y0, x1-x0, y1-y0);
+	RKD_OUT_STREAM << WRITE_PEN ();
+	RKD_OUT_STREAM << WRITE_LINE_ENDS ();
+	RKD_OUT_STREAM << WRITE_FILL ();
 }
 
 static void RKD_TextUTF8 (double x, double y, const char *str, double rot, double hadj, R_GE_gcontext *gc, pDevDesc dev) {
 	RKGraphicsDataStreamWriteGuard guard;
-	RKD_PROTOCOL << WRITE_HEADER (RKDTextUTF8, dev);
-	RKD_PROTOCOL << x << y << QString::fromUtf8 (str) << rot << hadj;
-	RKD_PROTOCOL << WRITE_COL ();
-	RKD_PROTOCOL << WRITE_FONT (dev);
+	RKD_OUT_STREAM << WRITE_HEADER (RKDTextUTF8, dev);
+	RKD_OUT_STREAM << x << y << QString::fromUtf8 (str) << rot << hadj;
+	RKD_OUT_STREAM << WRITE_COL ();
+	RKD_OUT_STREAM << WRITE_FONT (dev);
 }
 
 static double RKD_StrWidthUTF8 (const char *str, R_GE_gcontext *gc, pDevDesc dev) {
 	{
 		RKGraphicsDataStreamWriteGuard guard;
-		RKD_PROTOCOL << WRITE_HEADER (RKDStrWidthUTF8, dev);
-		RKD_PROTOCOL << QString::fromUtf8 (str);
-		RKD_PROTOCOL << WRITE_FONT (dev);
+		RKD_OUT_STREAM << WRITE_HEADER (RKDStrWidthUTF8, dev);
+		RKD_OUT_STREAM << QString::fromUtf8 (str);
+		RKD_OUT_STREAM << WRITE_FONT (dev);
 	}
 	double ret;
 	{
 		RKGraphicsDataStreamReadGuard guard;
-		RKD_PROTOCOL >> ret;
+		RKD_IN_STREAM >> ret;
 	}
 	return ret;
 }
 
 static void RKD_NewPage (R_GE_gcontext *gc, pDevDesc dev) {
 	RKGraphicsDataStreamWriteGuard guard;
-	RKD_PROTOCOL << WRITE_HEADER (RKDNewPage, dev);
-	RKD_PROTOCOL << WRITE_FILL ();
+	RKD_OUT_STREAM << WRITE_HEADER (RKDNewPage, dev);
+	RKD_OUT_STREAM << WRITE_FILL ();
 }
 
 static void RKD_MetricInfo (int c, R_GE_gcontext *gc, double* ascent, double* descent, double* width, pDevDesc dev) {
 	{
 		RKGraphicsDataStreamWriteGuard wguard;
-		RKD_PROTOCOL << WRITE_HEADER (RKDMetricInfo, dev);
-		RKD_PROTOCOL << QChar (c);
-		RKD_PROTOCOL << WRITE_FONT (dev);
+		RKD_OUT_STREAM << WRITE_HEADER (RKDMetricInfo, dev);
+		RKD_OUT_STREAM << QChar (c);
+		RKD_OUT_STREAM << WRITE_FONT (dev);
 	}
 	{
 		RKGraphicsDataStreamReadGuard rguard;
-		RKD_PROTOCOL >> *ascent;
-		RKD_PROTOCOL >> *descent;
-		RKD_PROTOCOL >> *width;
+		RKD_IN_STREAM >> *ascent;
+		RKD_IN_STREAM >> *descent;
+		RKD_IN_STREAM >> *width;
 	}
 }
 
 static void RKD_Close (pDevDesc dev) {
 	RKGraphicsDataStreamWriteGuard guard;
-	RKD_PROTOCOL << WRITE_HEADER (RKDClose, dev);
+	RKD_OUT_STREAM << WRITE_HEADER (RKDClose, dev);
 }
 
 static void RKD_Activate (pDevDesc dev) {
 	RKGraphicsDataStreamWriteGuard guard;
-	RKD_PROTOCOL << WRITE_HEADER (RKDActivate, dev);
+	RKD_OUT_STREAM << WRITE_HEADER (RKDActivate, dev);
 }
 
 static void RKD_Deactivate (pDevDesc dev) {
 	RKGraphicsDataStreamWriteGuard guard;
-	RKD_PROTOCOL << WRITE_HEADER (RKDDeActivate, dev);
+	RKD_OUT_STREAM << WRITE_HEADER (RKDDeActivate, dev);
 }
 
 static void RKD_Clip (double left, double right, double top, double bottom, pDevDesc dev) {
@@ -210,8 +198,8 @@
 	dev->clipTop = top;
 	dev->clipBottom = bottom;
 	RKGraphicsDataStreamWriteGuard guard;
-	RKD_PROTOCOL << WRITE_HEADER (RKDClip, dev);
-	RKD_PROTOCOL << QRectF (left, top, right - left, bottom - top);
+	RKD_OUT_STREAM << WRITE_HEADER (RKDClip, dev);
+	RKD_OUT_STREAM << QRectF (left, top, right - left, bottom - top);
 }
 
 static void RKD_Mode (int mode, pDevDesc dev) {
@@ -220,21 +208,21 @@
 /* Left empty for now. 1 is start signal, 0 is stop signal. Might be useful for flushing, though.
 
 	RKGraphicsDataStreamWriteGuard guard;
-	RKD_PROTOCOL << WRITE_HEADER (RKDMode, dev);
+	RKD_OUT_STREAM << WRITE_HEADER (RKDMode, dev);
 	connectoin << (qint8) mode; */
 }
 
 static Rboolean RKD_Locator (double *x, double *y, pDevDesc dev) {
 	{
 		RKGraphicsDataStreamWriteGuard wguard;
-		RKD_PROTOCOL << WRITE_HEADER (RKDLocator, dev);
+		RKD_OUT_STREAM << WRITE_HEADER (RKDLocator, dev);
 	}
 	{
 		RKGraphicsDataStreamReadGuard rguard;
 		bool ok;
-		RKD_PROTOCOL >> ok;
-		RKD_PROTOCOL >> *x;
-		RKD_PROTOCOL >> *y;
+		RKD_IN_STREAM >> ok;
+		RKD_IN_STREAM >> *x;
+		RKD_IN_STREAM >> *y;
 		if (ok) return (Rboolean) TRUE;
 		return (Rboolean) FALSE;
 	}
@@ -243,12 +231,12 @@
 static Rboolean RKD_NewFrameConfirm (pDevDesc dev) {
 	{
 		RKGraphicsDataStreamWriteGuard wguard;
-		RKD_PROTOCOL << WRITE_HEADER (RKDNewPageConfirm, dev);
+		RKD_OUT_STREAM << WRITE_HEADER (RKDNewPageConfirm, dev);
 	}
 	{
 		RKGraphicsDataStreamReadGuard rguard;
 		bool ok;
-		RKD_PROTOCOL >> ok;
+		RKD_IN_STREAM >> ok;
 		if (ok) return (Rboolean) TRUE;
 		return (Rboolean) FALSE;
 	}

Modified: branches/development_branches/rkward_graphpics_device/rkward/settings/rksettingsmoduledebug.cpp
===================================================================
--- branches/development_branches/rkward_graphpics_device/rkward/settings/rksettingsmoduledebug.cpp	2013-03-21 15:53:25 UTC (rev 4615)
+++ branches/development_branches/rkward_graphpics_device/rkward/settings/rksettingsmoduledebug.cpp	2013-03-21 19:34:53 UTC (rev 4616)
@@ -70,6 +70,7 @@
 	debug_flags_group->addButton (new QCheckBox ("DIALOGS", group), DIALOGS);
 	debug_flags_group->addButton (new QCheckBox ("OUTPUT", group), OUTPUT);
 	debug_flags_group->addButton (new QCheckBox ("XML", group), XML);
+	debug_flags_group->addButton (new QCheckBox ("GRAPHICS_DEVICE", group), GRAPHICS_DEVICE);
 
 	QList<QAbstractButton*> buttons = debug_flags_group->buttons ();
 	for (QList<QAbstractButton*>::const_iterator it = buttons.constBegin (); it != buttons.constEnd (); ++it) {





More information about the rkward-tracker mailing list