[rkward-cvs] SF.net SVN: rkward-code:[4500] trunk/rkward
tfry at users.sf.net
tfry at users.sf.net
Mon Jan 21 11:11:24 UTC 2013
Revision: 4500
http://sourceforge.net/p/rkward/code/4500
Author: tfry
Date: 2013-01-21 11:11:23 +0000 (Mon, 21 Jan 2013)
Log Message:
-----------
Some more bits of implementation, and more detailed TODO for plugin dependency handling.
Modified Paths:
--------------
trunk/rkward/ChangeLog
trunk/rkward/rkward/plugin/CMakeLists.txt
trunk/rkward/rkward/plugin/rkcomponentmap.cpp
trunk/rkward/rkward/plugin/rkcomponentmap.h
trunk/rkward/rkward/plugin/rkcomponentmeta.cpp
trunk/rkward/rkward/plugin/rkcomponentmeta.h
Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog 2013-01-18 16:13:12 UTC (rev 4499)
+++ trunk/rkward/ChangeLog 2013-01-21 11:11:23 UTC (rev 4500)
@@ -1,3 +1,11 @@
+- Implement basic dependency handling for plugins / pluginmaps
+ - NOTES: Contrary to existing documentation, <dependencies> is a top level element, not a child element of <about>
+ - TODO:
+ - Proper error reporting for failed dependencies (also handling alternative versions)
+ - Dependencies and about for individual plugins
+ - Pluginmap selection UI
+ - Explicitly document the fact that <include>s can be used for <about> and <dependencies>
+ - Add possibilities for soft dependencies (i.e. dynamic version check within a plugin)
- Added support for the upcoming R 3.0.0 TODO: Check for any more regressions, before release
- Added <switch> logic element to switch between several target properties (or fixed values) based on the value of a condition property
- Sort plugin gains option to sort data.frames by more than one column at a time, and options for type conversion TODO: adjust test(s)
Modified: trunk/rkward/rkward/plugin/CMakeLists.txt
===================================================================
--- trunk/rkward/rkward/plugin/CMakeLists.txt 2013-01-18 16:13:12 UTC (rev 4499)
+++ trunk/rkward/rkward/plugin/CMakeLists.txt 2013-01-21 11:11:23 UTC (rev 4500)
@@ -5,6 +5,7 @@
SET(plugin_STAT_SRCS
rkcomponentmap.cpp
+ rkcomponentmeta.cpp
rkcomponentproperties.cpp
rkcomponent.cpp
rkstandardcomponent.cpp
Modified: trunk/rkward/rkward/plugin/rkcomponentmap.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponentmap.cpp 2013-01-18 16:13:12 UTC (rev 4499)
+++ trunk/rkward/rkward/plugin/rkcomponentmap.cpp 2013-01-21 11:11:23 UTC (rev 4500)
@@ -342,6 +342,18 @@
RKPluginMapFile *pluginmap_file_desc = new RKPluginMapFile (prefix);
pluginmapfiles.insert (QFileInfo (plugin_map_file).absoluteFilePath (), pluginmap_file_desc);
+ // step 0: check dependencies, parse about, and initialize
+ QDomElement dependencies = xml->getChildElement (document_element, "dependencies", DL_INFO);
+ if (!dependencies.isNull ()) {
+ if (!RKComponentDependency::isRKWardVersionCompatible (dependencies)) {
+ RK_DEBUG (PLUGIN, DL_INFO, "Skipping plugin map file '%s': Not compatible with this version of RKWard", qPrintable (plugin_map_file_abs));
+ return 0;
+ }
+ pluginmap_file_desc->dependencies = RKComponentDependency::parseDependencies (dependencies);
+ }
+ QDomElement about = xml->getChildElement (document_element, "about", DL_INFO);
+ if (!about.isNull ()) pluginmap_file_desc->about = new RKComponentAboutData (about);
+
// step 1: include required files
int counter = 0;
QStringList includelist;
Modified: trunk/rkward/rkward/plugin/rkcomponentmap.h
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponentmap.h 2013-01-18 16:13:12 UTC (rev 4499)
+++ trunk/rkward/rkward/plugin/rkcomponentmap.h 2013-01-21 11:11:23 UTC (rev 4500)
@@ -20,16 +20,21 @@
#include <qstring.h>
+#include "rkcomponentmeta.h"
+
/** very simple helper class to keep track of .pluginmap files */
class RKPluginMapFile {
public:
- RKPluginMapFile (const QString &basedir) { RKPluginMapFile::basedir = basedir; };
+ RKPluginMapFile (const QString &basedir) : about (0) { RKPluginMapFile::basedir = basedir; };
~RKPluginMapFile () {};
QString getBaseDir () { return basedir; };
QString makeFileName (const QString &filename);
private:
+friend class RKComponentMap;
QString basedir;
+ RKComponentAboutData *about;
+ QList<RKComponentDependency> dependencies;
};
/** enum of different types of RKComponent */
Modified: trunk/rkward/rkward/plugin/rkcomponentmeta.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponentmeta.cpp 2013-01-18 16:13:12 UTC (rev 4499)
+++ trunk/rkward/rkward/plugin/rkcomponentmeta.cpp 2013-01-21 11:11:23 UTC (rev 4500)
@@ -29,9 +29,41 @@
QLatin1String any_min_version_tag ("min_version");
QLatin1String any_max_version_tag ("max_version");
-bool RKComponentMeta::isRKWardVersionCompatible (const QDomElement& e) {
+RKComponentAboutData::RKComponentAboutData (const QDomElement& e) {
RK_TRACE (PLUGIN);
+ XMLHelper *xml = XMLHelper::getStaticHelper ();
+ QString name = xml->getStringAttribute (e, "name", QString (), DL_ERROR);
+ about = new KAboutData (name.toLocal8Bit (), QByteArray (), ki18n ("%1").subs (name), xml->getStringAttribute (e, "version", QString (), DL_WARNING).toLocal8Bit ());
+ about->setShortDescription (ki18n ("%1").subs (xml->getStringAttribute (e, "shortinfo", QString (), DL_WARNING)));
+ about->setCopyrightStatement (ki18n ("%1").subs (xml->getStringAttribute (e, "copyright", QString (), DL_WARNING)));
+ about->setLicenseText (ki18n ("%1").subs (xml->getStringAttribute (e, "license", QString (), DL_WARNING)));
+ about->setHomepage (xml->getStringAttribute (e, "url", QString (), DL_WARNING).toLocal8Bit ());
+ // NOTE: Misusing catalog name for storing category.
+ category = xml->getStringAttribute (e, "category", i18n ("Unspecified"), DL_INFO);
+ // NOTE: ignoring releasedate for now.
+
+ XMLChildList authors = xml->getChildElements (e, "author", DL_INFO);
+ for (int i = 0; i < authors.size (); ++i) {
+ QDomElement author = authors[i];
+ about->addAuthor (ki18n ("%1").subs (xml->getStringAttribute (author, "given", QString (), DL_ERROR) + " " + xml->getStringAttribute (e, "family", QString (), DL_ERROR)),
+ ki18n ("%1").subs (xml->getStringAttribute (author, "role", QString (), DL_INFO)), // TODO: translate into human readable
+ xml->getStringAttribute (author, "email", QString (), DL_WARNING).toLocal8Bit (),
+ xml->getStringAttribute (author, "url", QString (), DL_INFO).toLocal8Bit ()
+ );
+ }
+}
+
+RKComponentAboutData::~RKComponentAboutData() {
+ RK_TRACE (PLUGIN);
+
+ delete about;
+}
+
+
+bool RKComponentDependency::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;
}
@@ -42,7 +74,7 @@
return true;
}
-QList <RKComponentDependency> RKComponentMeta::parseDependencies (const QDomElement& e) {
+QList <RKComponentDependency> RKComponentDependency::parseDependencies (const QDomElement& e) {
RK_TRACE (PLUGIN);
XMLHelper *xml = XMLHelper::getStaticHelper ();
@@ -55,7 +87,7 @@
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);
+ XMLChildList deps = xml->getChildElements (e, QString (), DL_INFO);
for (int i = 0; i < deps.size (); ++i) {
QDomElement dep_e = deps[i];
if (dep_e.tagName () == "package") {
@@ -77,24 +109,13 @@
ret.append (dep);
}
+ // Add RKWard dependency, last
+ dep.type = RKComponentDependency::RKWardVersion;
+ dep.min_version = 0;
+ dep.max_version = 0xFFFFFFFF;
+ if (e.hasAttribute (rkward_min_version_tag)) dep.min_version = RKSessionVars::parseVersionString (e.attribute (rkward_min_version_tag), 0);
+ if (e.hasAttribute (rkward_max_version_tag)) dep.max_version = RKSessionVars::parseVersionString (e.attribute (rkward_max_version_tag), 0);
+ if ((dep.min_version > 0) || (dep.max_version < 0xFFFFFFFF)) 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-18 16:13:12 UTC (rev 4499)
+++ trunk/rkward/rkward/plugin/rkcomponentmeta.h 2013-01-21 11:11:23 UTC (rev 4500)
@@ -22,23 +22,29 @@
#include <kaboutdata.h>
struct RKComponentDependency {
- RKComponentDependency () : type (RBaseInstallation), min_version (0), max_version (0xFFFFFFFF);
+ RKComponentDependency () : type (RBaseInstallation), min_version (0), max_version (0xFFFFFFFF) {};
enum DependencyType {
RBaseInstallation,
RPackage,
RKWardPluginmap,
+ RKWardVersion
};
DependencyType type;
QString package;
QString source_info;
quint32 min_version;
quint32 max_version;
-};
-class RKComponentMeta {
+ static QList<RKComponentDependency> parseDependencies (const QDomElement &e);
static bool isRKWardVersionCompatible (const QDomElement &e);
- static QList<RKComponentDependency> parseDependencies (const QDomElement &e);
- static KAboutData parseAboutData (const QDomElement &e);
};
+class RKComponentAboutData {
+public:
+ RKComponentAboutData (const QDomElement &e);
+ ~RKComponentAboutData ();
+ KAboutData *about;
+ QString category;
+};
+
#endif
More information about the rkward-tracker
mailing list