diff options
Diffstat (limited to 'src/VSession.h')
-rw-r--r-- | src/VSession.h | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/src/VSession.h b/src/VSession.h new file mode 100644 index 0000000..8eb99cd --- /dev/null +++ b/src/VSession.h @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2010,2011 - RZ Uni Freiburg + * Copyright (c) 2010,2011 - OpenSLX Project + * + * This program/file is free software distributed under the GPL version 2. + * See http://gpl.openslx.org/ + * + * If you have any feedback please consult http://feedback.openslx.org/ and + * send your feedback to feedback@openslx.org + * + * General information about OpenSLX - libChooser can be found under + * http://openslx.org + * + */ + +#ifndef VMCHOOSER_VSESSION_H_ +#define VMCHOOSER_VSESSION_H_ + +#include <QString> +#include <QList> +#include <QDomDocument> +#include <QDir> +#include <QProcess> +#include <QFSFileEngine> +#include <QDateTime> + +#include "Session.h" +#include "VSessionHandler.h" + +enum ImgType { + VMWARE, + VBOX, + OTHER +}; + +class VSession : public Session { + public: + VSession(VSessionHandler *parent); + bool init(const QString& xml, const QString& baseDirPath); + + ImgType imgtype() const; + bool isActive() const; + bool isLocked() const; + bool isValid() const; + int priority() const; + + QString shortDescription() const { + return getAttribute("short_description"); + } + + QString description() const { + QString ret; + ret = getNodeText("description_html"); + if (ret.size() > 0) return ret; + return getAttribute("long_description"); + } + + QString icon() const; + + QString os() const { + QString ret; + ret = getAttribute("operating_system"); + if (ret.size() > 0) return ret; + return getAttribute("os"); + } + + QString title() const { + QString tmp = getAttribute("title"); + if (tmp.size() > 0) return tmp; + return getAttribute("short_description"); + }; + + QString screenshot() const; + + QString emulator() const { + return getAttribute("emulator"); + }; + + QString author() const { + QString tmp; + tmp = getAttribute("creator") + "<" + getAttribute("email") + ">"; + return tmp; + }; + + QString creationDate () const { + if (QFile::exists(QString(this->baseDirPath_).append("/").append(getAttribute("image_name")))) { + QFSFileEngine fe(QString(this->baseDirPath_).append("/").append(getAttribute("image_name"))); //QAbstractFileEngine::ModificationTime + return fe.fileTime(QAbstractFileEngine::CreationTime).toString(Qt::SystemLocaleLongDate); + } + return QString(); + }; + + QString changeDate() const { + if (QFile::exists(QString(this->baseDirPath_).append("/").append(getAttribute("image_name")))) { + QFSFileEngine fe(QString(this->baseDirPath_).append("/").append(getAttribute("image_name"))); //QAbstractFileEngine::ModificationTime + return fe.fileTime(QAbstractFileEngine::AccessTime).toString(Qt::SystemLocaleLongDate); + } + return QString(); + }; + + + QString getAttribute(const QString& nodeName, + const QString& attribute = "param") const; + QString getNodeText(const QString& nodeName) const; + + void addNodeWithAttribute(const QString& nodeName, + const QString& value, + const QString& attribute = "param", + bool replace = true); + void addPrinters(const QString& script, const QString& type = "printer"); + void addScanners(const QString& script); + void addUserAndHostname(); + void mergePoolXml(); + + QString toXml() const; + + bool run() const; + + int type() const; + + bool operator<(const Session& other) const; + + static bool debugMode; + + + + private: + QDomDocument doc_; + QString baseDirPath_; + VSessionHandler *sessionHandler; + + + QProcess *_process; +}; + +#endif /*VMCHOOSER_VSESSION_H_*/ |