[rkward-cvs] SF.net SVN: rkward:[3909] trunk/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Sat Oct 8 12:29:12 UTC 2011


Revision: 3909
          http://rkward.svn.sourceforge.net/rkward/?rev=3909&view=rev
Author:   tfry
Date:     2011-10-08 12:29:12 +0000 (Sat, 08 Oct 2011)
Log Message:
-----------
Remove kde library dependency from backend (esp. in the hope to avoid library clashes on Windows)

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/rkward/main.cpp
    trunk/rkward/rkward/rbackend/CMakeLists.txt
    trunk/rkward/rkward/rbackend/FindR.cmake
    trunk/rkward/rkward/rbackend/rkfrontendtransmitter.cpp
    trunk/rkward/rkward/rbackend/rkrbackend.cpp
    trunk/rkward/rkward/rbackend/rkrbackend.h
    trunk/rkward/rkward/rbackend/rkrbackendprotocol_backend.cpp
    trunk/rkward/rkward/settings/rksettingsmoduledebug.cpp
    trunk/rkward/rkward/settings/rksettingsmoduledebug.h

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2011-10-08 12:25:13 UTC (rev 3908)
+++ trunk/rkward/ChangeLog	2011-10-08 12:29:12 UTC (rev 3909)
@@ -1,3 +1,4 @@
+- The backend executable is no longer linked against KDE libraries
 - Objects, which are not acceptable in a varslot, will still be shown, there, with a warning		TODO: add a UI to override
 
 --- Version 0.5.7 - Oct-23-2011

Modified: trunk/rkward/rkward/main.cpp
===================================================================
--- trunk/rkward/rkward/main.cpp	2011-10-08 12:25:13 UTC (rev 3908)
+++ trunk/rkward/rkward/main.cpp	2011-10-08 12:29:12 UTC (rev 3909)
@@ -53,11 +53,12 @@
 #include <kcmdlineargs.h>
 #include <kaboutdata.h>
 #include <klocale.h>
-#include <ktemporaryfile.h>
 #include <kstandarddirs.h>
 
 #include <qstring.h>
 #include <QMutex>
+#include <QTemporaryFile>
+#include <QDir>
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -154,7 +155,7 @@
 
 	RKWardApplication app;
 	// install message handler *after* the componentData has been initialized
-	RKSettingsModuleDebug::debug_file = new KTemporaryFile ();
+	RKSettingsModuleDebug::debug_file = new QTemporaryFile (QDir::tempPath () + "/rkward.frontend");
 	RKSettingsModuleDebug::debug_file->setAutoRemove (false);
 	if (RKSettingsModuleDebug::debug_file->open ()) {
 		RK_DO (qDebug ("Full debug output is at %s", qPrintable (RKSettingsModuleDebug::debug_file->fileName ())), APP, DL_INFO);

Modified: trunk/rkward/rkward/rbackend/CMakeLists.txt
===================================================================
--- trunk/rkward/rkward/rbackend/CMakeLists.txt	2011-10-08 12:25:13 UTC (rev 3908)
+++ trunk/rkward/rkward/rbackend/CMakeLists.txt	2011-10-08 12:29:12 UTC (rev 3909)
@@ -58,8 +58,8 @@
 	QT4_AUTOMOC(${rbackend_BACKEND_SRCS})
 	ADD_DEFINITIONS (-DRKWARD_SPLIT_PROCESS)
 	LINK_DIRECTORIES(${R_SHAREDLIBDIR})
-	KDE4_ADD_EXECUTABLE(rkward.rbackend ${rbackend_BACKEND_SRCS})
-	TARGET_LINK_LIBRARIES(rkward.rbackend ${R_USED_LIBS} ${CMAKE_THREAD_LIBS_INIT} ${KDE4_KDECORE_LIBS} ${QT_QTNETWORK_LIBRARY})
+	ADD_EXECUTABLE(rkward.rbackend ${rbackend_BACKEND_SRCS})
+	TARGET_LINK_LIBRARIES(rkward.rbackend ${R_USED_LIBS} ${CMAKE_THREAD_LIBS_INIT} ${QT_QTNETWORK_LIBRARY} ${QT_QTCORE_LIBRARY})
 	INSTALL(TARGETS rkward.rbackend DESTINATION ${LIBEXEC_INSTALL_DIR})
 ELSE(RBACKEND_SPLIT)
 	SET (

Modified: trunk/rkward/rkward/rbackend/FindR.cmake
===================================================================
--- trunk/rkward/rkward/rbackend/FindR.cmake	2011-10-08 12:25:13 UTC (rev 3908)
+++ trunk/rkward/rkward/rbackend/FindR.cmake	2011-10-08 12:29:12 UTC (rev 3909)
@@ -68,7 +68,7 @@
 MESSAGE(STATUS "Checking for existence of R shared library")
 FIND_LIBRARY(LIBR_SO
 	R
-	PATHS ${R_HOME}/lib ${R_SHAREDLIBDIR} ${R_HOME}/bin
+	PATHS ${R_HOME}/lib ${R_SHAREDLIBDIR} ${R_HOME}/bin ${R_HOME}/bin/i386
 	NO_DEFAULT_PATH)
 IF(NOT LIBR_SO)
 	MESSAGE(FATAL_ERROR "Not found. Make sure the location of R was detected correctly, above, and R was compiled with the --enable-R-shlib option")

Modified: trunk/rkward/rkward/rbackend/rkfrontendtransmitter.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rkfrontendtransmitter.cpp	2011-10-08 12:25:13 UTC (rev 3908)
+++ trunk/rkward/rkward/rbackend/rkfrontendtransmitter.cpp	2011-10-08 12:29:12 UTC (rev 3909)
@@ -57,10 +57,19 @@
 
 	// start backend
 	backend = new QProcess (this);
+
+	// Try to synchronize language selection in frontend and backend
+	QStringList env = QProcess::systemEnvironment ();
+	int index = env.indexOf (QRegExp("^LANGUAGE=.*", Qt::CaseInsensitive));
+	if (index >= 0) env.removeAt (index);
+	env.append ("LANGUAGE=" + KGlobal::locale ()->language ());
+	backend->setEnvironment (env);
+
 	QStringList args;
-	args.append ("--debug-level " + QString::number (RK_Debug_Level));
-	args.append ("--server-name " + server->fullServerName ());
-	args.append ("--data-dir " + RKSettingsModuleGeneral::filesPath ());
+	args.append ("--debug-level=" + QString::number (RK_Debug_Level));
+	args.append ("--server-name=" + server->fullServerName ());
+	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)));
 	QString backend_executable = KStandardDirs::findExe (QDir::toNativeSeparators (QCoreApplication::applicationDirPath () + "/rkward.rbackend"));
 	if (backend_executable.isEmpty ()) backend_executable = KStandardDirs::findExe (QDir::toNativeSeparators (QCoreApplication::applicationDirPath () + "/rbackend/rkward.rbackend"));	// for running directly from the build-dir

Modified: trunk/rkward/rkward/rbackend/rkrbackend.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rkrbackend.cpp	2011-10-08 12:25:13 UTC (rev 3908)
+++ trunk/rkward/rkward/rbackend/rkrbackend.cpp	2011-10-08 12:29:12 UTC (rev 3909)
@@ -39,7 +39,6 @@
 #include <QThread>
 #include <QDir>
 #include <qtextcodec.h>
-#include <klocale.h>
 
 #include "../core/robject.h"
 #include "../version.h"
@@ -100,6 +99,23 @@
 #	include <fcntl.h>
 #endif
 
+///// i18n
+#if (defined ENABLE_NLS) && (!defined RKWARD_THREADED)		// ENABLE_NLS is from Rconfig.h
+#	include <libintl.h>
+#	define RK_MSG_DOMAIN "rkward"
+	// define i18n to be compatible with the easiest usage in KDE
+#	define i18n(msgid) QString::fromUtf8(dgettext(RK_MSG_DOMAIN, msgid))
+	void RK_setupGettext (const char* locale_dir) {
+		bindtextdomain (RK_MSG_DOMAIN, locale_dir);
+		bind_textdomain_codeset (RK_MSG_DOMAIN, "UTF-8");
+	}
+#else
+#	define i18n(msgid) QString(msgid)
+	void RK_setupGettext (const char*) {};
+#endif
+
+
+///// interrupting R
 void RK_scheduleIntr () {
 	RK_DO (qDebug ("interrupt scheduled"), RBACKEND, DL_DEBUG);
 	RKRBackend::repl_status.interrupted = true;
@@ -1293,12 +1309,12 @@
 	catToOutputFile (out);
 }
 
-void RKRBackend::run () {
+void RKRBackend::run (const QString &locale_dir) {
 	RK_TRACE (RBACKEND);
 	killed = NotKilled;
 	previous_command = 0;
 
-	initialize ();
+	initialize (QFile::encodeName (locale_dir));
 
 	enterEventLoop ();
 }
@@ -1434,7 +1450,7 @@
 	return request.params.value ("return").toStringList ();
 }
 
-void RKRBackend::initialize () {
+void RKRBackend::initialize (const char *locale_dir) {
 	RK_TRACE (RBACKEND);
 
 	// in RInterface::RInterface() we have created a fake RCommand to capture all the output/errors during startup. Fetch it
@@ -1446,6 +1462,7 @@
 	bool lib_load_fail = false;
 	bool sink_fail = false;
 	if (!runDirectCommand ("library (\"rkward\")\n")) lib_load_fail = true;
+	RK_setupGettext (locale_dir);	// must happen *after* package loading, since R will re-set it
 	if (!runDirectCommand (QString ("stopifnot(.rk.app.version==\"%1\")\n").arg (RKWARD_VERSION))) lib_load_fail = true;
 	if (!runDirectCommand (".rk.fix.assignments ()\n")) sink_fail = true;
 

Modified: trunk/rkward/rkward/rbackend/rkrbackend.h
===================================================================
--- trunk/rkward/rkward/rbackend/rkrbackend.h	2011-10-08 12:25:13 UTC (rev 3908)
+++ trunk/rkward/rkward/rbackend/rkrbackend.h	2011-10-08 12:29:12 UTC (rev 3909)
@@ -87,7 +87,7 @@
 
 /** initializes the R-backend. Emits an RCallbackType::Started-request (with any error messages) when done.
 Note that you should call initialize only once in a application */
-	void initialize ();
+	void initialize (const char* locale_dir);
 
 	void enterEventLoop ();
 protected:
@@ -171,7 +171,7 @@
 /** A list of symbols that have been assigned new values during the current command */
 	QStringList changed_symbol_names;
 /** the main loop. See \ref RKRBackend for a more detailed description */
-	void run ();
+	void run (const QString &locale_dir);
 	static void scheduleInterrupt ();
 
 	void startOutputCapture ();

Modified: trunk/rkward/rkward/rbackend/rkrbackendprotocol_backend.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rkrbackendprotocol_backend.cpp	2011-10-08 12:25:13 UTC (rev 3908)
+++ trunk/rkward/rkward/rbackend/rkrbackendprotocol_backend.cpp	2011-10-08 12:29:12 UTC (rev 3909)
@@ -29,8 +29,6 @@
 #else
 #	include <QLocalSocket>
 #	include <QMutex>
-#	include "kcomponentdata.h"
-#	include "kglobal.h"
 #	include "rktransmitter.h"
 #	include <stdio.h>
 #endif
@@ -81,13 +79,15 @@
 	RKRBackendThread* RKRBackendThread::instance = 0;
 #else
 #	include "rkbackendtransmitter.h"
+#	include <QUuid>		// mis-used as a random-string generator
+#	include <QTemporaryFile>
+#	include <QDir>
 
-#	include "ktemporaryfile.h"
-#	include "krandom.h"
+	extern "C" void RK_setupGettext (const char*);
 	int RK_Debug_Level = 2;
 	int RK_Debug_Flags = ALL;
 	QMutex RK_Debug_Mutex;
-	KTemporaryFile* RK_Debug_File;
+	QTemporaryFile* RK_Debug_File;
 
 	void RKDebugMessageOutput (QtMsgType type, const char *msg) {
 		RK_Debug_Mutex.lock ();
@@ -102,28 +102,27 @@
 
 	int main(int argc, char *argv[]) {
 		QCoreApplication app (argc, argv);
-		KComponentData data ("rkward");
-		KGlobal::locale ();		// to initialize it in the primary thread
 
 		setvbuf (stdout, NULL, _IONBF, 0);
 		setvbuf (stderr, NULL, _IONBF, 0);
 
-		RK_Debug_File = new KTemporaryFile ();
-		RK_Debug_File->setPrefix ("rkward.rbackend");
+		RK_Debug_File = new QTemporaryFile (QDir::tempPath () + "/rkward.rbackend");
 		RK_Debug_File->setAutoRemove (false);
 		if (RK_Debug_File->open ()) qInstallMsgHandler (RKDebugMessageOutput);
 
 		QString servername;
-		QString data_dir;
+		QString data_dir, locale_dir;
 		QStringList args = app.arguments ();
 		for (int i = 1; i < args.count (); ++i) {
 			if (args[i].startsWith ("--debug-level")) {
-				RK_Debug_Level = args[i].section (' ', 1).toInt ();
+				RK_Debug_Level = args[i].section ('=', 1).toInt ();
 			} else if (args[i].startsWith ("--server-name")) {
-				servername = args[i].section (' ', 1);
+				servername = args[i].section ('=', 1);
 			} else if (args[i].startsWith ("--data-dir")) {
 #warning What about paths with spaces?!
-				data_dir = args[i].section (' ', 1);
+				data_dir = args[i].section ('=', 1);
+			} else if (args[i].startsWith ("--locale-dir")) {
+				locale_dir = args[i].section ('=', 1);
 			} else {
 				printf ("unkown argument %s", qPrintable (args[i]));
 			}
@@ -133,16 +132,16 @@
 			return 1;
 		}
 
-		// a simple security token to all the frontend to make sure that it is really talking to the backend process that it started in the local socket connection.
+		// a simple security token to send to the frontend to make sure that it is really talking to the backend process that it started in the local socket connection.
 		// this token is sent both via stdout and the local socket connection. The frontend simply compares both values.
-		QString token = KRandom::randomString (32);
+		QString token = QUuid::createUuid ().toString ();
 		printf ("%s\n", token.toLocal8Bit ().data ());
 		fflush (stdout);
 
 		RKRBackendTransmitter transmitter (servername, token);
 		RKRBackendProtocolBackend backend (data_dir);
 		transmitter.start ();
-		RKRBackend::this_pointer->run ();
+		RKRBackend::this_pointer->run (locale_dir);
 		transmitter.quit ();
 		transmitter.wait (5000);
 

Modified: trunk/rkward/rkward/settings/rksettingsmoduledebug.cpp
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmoduledebug.cpp	2011-10-08 12:25:13 UTC (rev 3908)
+++ trunk/rkward/rkward/settings/rksettingsmoduledebug.cpp	2011-10-08 12:29:12 UTC (rev 3909)
@@ -19,7 +19,6 @@
 #include <klocale.h>
 #include <kconfig.h>
 #include <kconfiggroup.h>
-#include <ktemporaryfile.h>
 
 #include <qlayout.h>
 #include <qlabel.h>
@@ -27,12 +26,13 @@
 #include <QCheckBox>
 #include <QGroupBox>
 #include <QButtonGroup>
+#include <QTemporaryFile>
 
 #include "../misc/rkspinbox.h"
 #include "../rkglobals.h"
 #include "../debug.h"
 
-KTemporaryFile* RKSettingsModuleDebug::debug_file = 0;
+QTemporaryFile* RKSettingsModuleDebug::debug_file = 0;
 
 RKSettingsModuleDebug::RKSettingsModuleDebug (RKSettings *gui, QWidget *parent) : RKSettingsModule (gui, parent) {
 	RK_TRACE (SETTINGS);

Modified: trunk/rkward/rkward/settings/rksettingsmoduledebug.h
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmoduledebug.h	2011-10-08 12:25:13 UTC (rev 3908)
+++ trunk/rkward/rkward/settings/rksettingsmoduledebug.h	2011-10-08 12:29:12 UTC (rev 3909)
@@ -21,7 +21,7 @@
 
 class RKSpinBox;
 class QButtonGroup;
-class KTemporaryFile;
+class QTemporaryFile;
 
 /**
 configuration for the Command Editor windows
@@ -49,7 +49,7 @@
 	void settingChanged (int);
 public:
 	// public for internal reason, only! Do not mess with this!
-	static KTemporaryFile* debug_file;
+	static QTemporaryFile* debug_file;
 private:
 	RKSpinBox* command_timeout_box;
 	RKSpinBox* debug_level_box;

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the rkward-tracker mailing list