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

tfry at users.sf.net tfry at users.sf.net
Fri Jan 18 16:10:47 UTC 2013


Revision: 4498
          http://sourceforge.net/p/rkward/code/4498
Author:   tfry
Date:     2013-01-18 16:10:44 +0000 (Fri, 18 Jan 2013)
Log Message:
-----------
Some more bits on plugin meta info and dependency handling. Not yet compiled, or used.

Modified Paths:
--------------
    trunk/rkward/rkward/plugin/rkcomponentmeta.cpp
    trunk/rkward/rkward/plugin/rkcomponentmeta.h
    trunk/rkward/rkward/rbackend/rkrbackend.cpp
    trunk/rkward/rkward/rbackend/rksessionvars.cpp
    trunk/rkward/rkward/rbackend/rksessionvars.h

Modified: trunk/rkward/rkward/plugin/rkcomponentmeta.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponentmeta.cpp	2013-01-16 11:27:29 UTC (rev 4497)
+++ trunk/rkward/rkward/plugin/rkcomponentmeta.cpp	2013-01-18 16:10:44 UTC (rev 4498)
@@ -17,3 +17,84 @@
 
 #include "rkcomponentmeta.h"
 
+#include "../misc/xmlhelper.h"
+#include "../rbackend/rksessionvars.h"
+
+#include "../debug.h"
+
+QLatin1String rkward_min_version_tag ("rkward_min_version");
+QLatin1String rkward_max_version_tag ("rkward_max_version");
+QLatin1String R_min_version_tag ("R_min_version");
+QLatin1String R_max_version_tag ("R_max_version");
+QLatin1String any_min_version_tag ("min_version");
+QLatin1String any_max_version_tag ("max_version");
+
+bool RKComponentMeta::isRKWardVersionCompatible (const QDomElement& e) {
+	RK_TRACE (PLUGIN);
+
+	if (e.hasAttribute (rkward_min_version_tag)) {
+		if (RKSessionVars::compareRKWardVersion (e.attribute (rkward_min_version_tag)) > 0) return false;
+	}
+	if (e.hasAttribute (rkward_max_version_tag)) {
+		if (RKSessionVars::compareRKWardVersion (e.attribute (rkward_max_version_tag)) < 0) return false;
+	}
+
+	return true;
+}
+
+QList <RKComponentDependency> RKComponentMeta::parseDependencies (const QDomElement& e) {
+	RK_TRACE (PLUGIN);
+
+	XMLHelper *xml = XMLHelper::getStaticHelper ();
+	QList<RKComponentDependency> ret;
+	RKComponentDependency dep;
+
+	// Check for R dependency, first.
+	dep.type = RKComponentDependency::RBaseInstallation;
+	if (e.hasAttribute (R_min_version_tag)) dep.min_version = RKSessionVars::parseVersionString (e.attribute (R_min_version_tag), 0);
+	if (e.hasAttribute (R_max_version_tag)) dep.max_version = RKSessionVars::parseVersionString (e.attribute (R_max_version_tag), 0);
+	if ((dep.min_version > 0) || (dep.max_version < 0xFFFFFFFF)) ret.append (dep);
+
+	XMLChildList deps = xml->getChildElements (e);
+	for (int i = 0; i < deps.size (); ++i) {
+		QDomElement dep_e = deps[i];
+		if (dep_e.tagName () == "package") {
+			dep.type = RKComponentDependency::RPackage;
+			dep.package = xml->getStringAttribute (e, "repository", QString (), DL_INFO);
+		} else if (dep_e.tagName () == "pluginmap") {
+			dep.type = RKComponentDependency::RKWardPluginmap;
+			dep.package = xml->getStringAttribute (e, "url", QString ("http://rkward.sf.net"), DL_WARNING);
+		} else {
+			RK_DEBUG (PLUGIN, DL_ERROR, "Tag <%s> is not allowed, here.", qPrintable (dep_e.tagName ()));
+			continue;
+		}
+
+		dep.min_version = 0;
+		dep.max_version = 0xFFFFFFFF;
+		if (e.hasAttribute (any_min_version_tag)) dep.min_version = RKSessionVars::parseVersionString (e.attribute (any_min_version_tag), 0);
+		if (e.hasAttribute (any_max_version_tag)) dep.max_version = RKSessionVars::parseVersionString (e.attribute (any_max_version_tag), 0);
+
+		ret.append (dep);
+	}
+
+	return ret;
+}
+
+KAboutData RKComponentMeta::parseAboutData (const QDomElement& e) {
+	RK_TRACE (PLUGIN);
+
+	XMLHelper *xml = XMLHelper::getStaticHelper ();
+	QString name = xml->getStringAttribute (e, "name", QString, DL_ERROR);
+	KAboutData about (name, QString (), name,xml->getStringAttribute (e, "version", QString (), DL_WARNING));
+	about.setShortDescription (xml->getStringAttribute (e, "shortinfo", QString (), DL_WARNING));
+	about.setCopyrightStatement (xml->getStringAttribute (e, "copyright", QString (), DL_WARNING));
+	about.setLicenseText (xml->getStringAttribute (e, "license", QString (), DL_WARNING));
+	about.setHomepage (xml->getStringAttribute (e, "url", QString (), DL_WARNING));
+	// NOTE: Misusing catalog name for storing category.
+	about.setCatalogName (xml->getStringAttribute (e, "category", QString (), DL_WARNING));
+	// NOTE: ignoring releasedate for now.
+
+#error TODO: add authors
+
+	return about;
+}

Modified: trunk/rkward/rkward/plugin/rkcomponentmeta.h
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponentmeta.h	2013-01-16 11:27:29 UTC (rev 4497)
+++ trunk/rkward/rkward/plugin/rkcomponentmeta.h	2013-01-18 16:10:44 UTC (rev 4498)
@@ -18,23 +18,27 @@
 #ifndef RKCOMPONENTMETA_H
 #define RKCOMPONENTMETA_H
 
+#include <QDomElement>
+#include <kaboutdata.h>
+
 struct RKComponentDependency {
-	RKComponentDependency (_type, _package, _min_version, _max_version) : type (_type), package (_package), min_version (_min_version), max_version (_max_version);
+	RKComponentDependency () : type (RBaseInstallation), min_version (0), max_version (0xFFFFFFFF);
 	enum DependencyType {
 		RBaseInstallation,
 		RPackage,
-		RKWardPackage
+		RKWardPluginmap,
 	};
 	DependencyType type;
 	QString package;
-	int min_version;
-	int max_version;
+	QString source_info;
+	quint32 min_version;
+	quint32 max_version;
 };
 
 class RKComponentMeta {
-	static bool isRKWardVersionCompatible (const QDomElement &e, bool optional);
+	static bool isRKWardVersionCompatible (const QDomElement &e);
 	static QList<RKComponentDependency> parseDependencies (const QDomElement &e);
-	KAboutData parseAboutData (const QDomElement &e);
+	static KAboutData parseAboutData (const QDomElement &e);
 };
 
 #endif

Modified: trunk/rkward/rkward/rbackend/rkrbackend.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rkrbackend.cpp	2013-01-16 11:27:29 UTC (rev 4497)
+++ trunk/rkward/rkward/rbackend/rkrbackend.cpp	2013-01-18 16:10:44 UTC (rev 4498)
@@ -788,6 +788,11 @@
 void RKRBackend::setupCallbacks () {
 	RK_TRACE (RBACKEND);
 }
+/*
+SEXP dummyselectlist (SEXP, SEXP, SEXP, SEXP) {
+	qDebug ("got it");
+	return R_NilValue;
+}*/
 
 void RKRBackend::connectCallbacks () {
 	RK_TRACE (RBACKEND);
@@ -811,6 +816,8 @@
 // TODO: R devels disabled this for some reason. We set it anyway...
 	ptr_R_EditFile = REditFile;
 //	ptr_R_EditFiles = REditFiles;		// undefined reference
+/*	ptr_do_selectlist = dummyselectlist;
+	ptr_do_dataviewer = dummyselectlist;*/
 
 // these two, we won't override
 //	ptr_R_loadhistory = ... 	// we keep our own history

Modified: trunk/rkward/rkward/rbackend/rksessionvars.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rksessionvars.cpp	2013-01-16 11:27:29 UTC (rev 4497)
+++ trunk/rkward/rkward/rbackend/rksessionvars.cpp	2013-01-18 16:10:44 UTC (rev 4498)
@@ -2,7 +2,7 @@
                           rksessionvars  -  description
                              -------------------
     begin                : Thu Sep 08 2011
-    copyright            : (C) 2011 by Thomas Friedrichsmeier
+    copyright            : (C) 2011, 2013 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -18,10 +18,13 @@
 #include "rksessionvars.h"
 
 #include "rinterface.h"
+#include "../version.h"
 
 #include "../debug.h"
 
 RKSessionVars* RKSessionVars::_instance = 0;
+quint32 RKSessionVars::rkward_version = 0;
+QString RKSessionVars::rkward_version_suffix;
 
 RKSessionVars::RKSessionVars (RInterface *parent) : QObject (parent) {
 	RK_TRACE (RBACKEND);
@@ -41,4 +44,45 @@
 	emit (installedPackagesChanged ());
 }
 
+quint32 RKSessionVars::parseVersionString (const QString &version, QString *suffix) {
+	quint32 ret = 0;
+	int pos = -1;
+	int opos = 0;
+	for (int i = 3; i > 0; --i) {
+		++pos;
+		if (!version[pos].isDigit ()) {
+			int val = version.mid (pos, pos - opos).toInt ();
+			if ((val < 0) || (val > 255) || (pos == opos)) {
+				RK_DEBUG (MISC, DL_ERROR, "Invalid version specification '%s'", qPrintable (version));
+				if (val > 255) val = 255;
+				else val = 0;
+			}
+			ret += val << (8 * i);
+			if (version[pos] == '.') {
+				opos = pos + 1;
+				continue;
+			}
+			opos = pos;
+			break;
+		}
+	}
+	if (opos < (version.size () - 1)) {
+		if (suffix) *suffix = version.mid (opos);
+		else RK_DEBUG (MISC, DL_WARNING, "Non numeric portion ('%s') of version specification '%s' will be ignored.", qPrintable (version.mid (opos)), qPrintable (version));
+	}
+	return ret;
+}
+
+int RKSessionVars::compareRKWardVersion (const QString& version) {
+	if (!rkward_version) {
+		rkward_version = parseVersionString (version, &rkward_version_suffix);
+	}
+
+	QString suffix;
+	quint32 ver = parseVersionString (version, &suffix);
+	if (ver < rkward_version) return -1;
+	if (ver > rkward_version) return 1;
+	return (suffix.compare (rkward_version_suffix));
+}
+
 #include "rksessionvars.moc"

Modified: trunk/rkward/rkward/rbackend/rksessionvars.h
===================================================================
--- trunk/rkward/rkward/rbackend/rksessionvars.h	2013-01-16 11:27:29 UTC (rev 4497)
+++ trunk/rkward/rkward/rbackend/rksessionvars.h	2013-01-18 16:10:44 UTC (rev 4498)
@@ -2,7 +2,7 @@
                           rksessionvars  -  description
                              -------------------
     begin                : Thu Sep 08 2011
-    copyright            : (C) 2011 by Thomas Friedrichsmeier
+    copyright            : (C) 2011, 2013 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -31,6 +31,12 @@
 	static RKSessionVars* instance () { return _instance; };
 	QStringList installedPackages () const { return installed_packages; };
 	void setInstalledPackages (const QStringList &new_list);
+/** compare given version string against the running version of RKWard. Returns -1 for earlier than current, 0 for equal, 1 for later than current version */
+	static int compareRKWardVersion (const QString &version);
+/** Split "a.b.c.d.e-fghi" into up to four numeric portions (returned as four bytes in a single 32bit unsigned int).
+Anything else (everything after the fourth dot, or after the first character that is neither dot, nor digit)
+is returned as suffix (via the suffix pointer; if that is 0, an error is reported, instead). */
+	static quint32 parseVersionString (const QString &version, QString *suffix);
 signals:
 	void installedPackagesChanged ();
 protected:
@@ -41,6 +47,8 @@
 	static RKSessionVars* _instance;
 
 	QStringList installed_packages;
+	static quint32 rkward_version;
+	static QString rkward_version_suffix;
 };
 
 #endif





More information about the rkward-tracker mailing list