summaryrefslogblamecommitdiffstats
path: root/src/vsession.h
blob: 6c48ce412b9c6d7a107bdfdf99c05a49366da162 (plain) (tree)
1
2
3
4
5
6
7
8
9






                             
                    
                    








                                 
                                      




                            
 

                         







                                                         



                                                       




                                                 
                                                
     
 
                       




                                  



                                    







                                                                          

     
                          
                                    
 

                                                                       
                                    
                                                                





                                                                 








                                               


                                                                
                             
                      
                         

                        
 


                                
#ifndef VMCHOOSER_VSESSION_H_
#define VMCHOOSER_VSESSION_H_

#include <QString>
#include <QList>
#include <QDomDocument>
#include <QDir>
#include "session.h"
#include "globals.h"

enum ImgType {
    VMWARE,
    VBOX,
    OTHER
};

class VSession : public Session {
  public:
    bool init(const QDomElement& xml);

    ImgType imgtype() const;
    bool isActive() const;
    bool isLocked() const;
    bool isValid() const;

    int priority() const;

    bool isTemplate() const {
        return getAttribute("is_template").toInt() != 0;
    }

    bool isForLocation() const {
        return getAttribute("for_location").toInt() != 0;
    }

    bool canEdit() const {
        return getAttribute("allow_edit").toInt() != 0;
    }

    QString shortDescription() const {
        return getAttribute("short_description");
    }

    QString description() const {
        return getAttribute("long_description");
    }

    QIcon icon() const;

    QString os() const {
        return getAttribute("os");
    }

    QString uuid() const {
        return getAttribute("uuid");
    }

    SectionType section() const {
        if (g_forLocationHandling != LOCATION_IGNORE && isForLocation()) {
            return SECTION_FOR_LOCATION;
        }
        if (g_templateHandling == TEMPLATES_BUMP && isTemplate()) {
            return SECTION_TEMPLATES;
        }
        return SECTION_GENERIC;
    }

    bool needsVtx() const;
    QVariant foregroundRole() const;

    QString getAttribute(const QString& nodeName,
                             const QString& attribute = "param") const;
    QList<QString> keywords() const;
    bool containsKeywords(const QList<QString>& keywords) const;
    QString getNodeText(const QString& nodeName) const;

    void addNodeWithAttribute(const QString& nodeName,
                              const QString& value,
                              const QString& attribute = "param",
                              bool replace = true);

    QString toXml() const;

    bool run() const;

    int type() const;

    bool operator<(const Session& other) const;

    static QList<Session*> readXmlFile(const QString& filepath);

  private:
    QList<QString> keywords_;
    QDomDocument doc_;
    QDomElement eintrag_;

    void readKeywords();

};

#endif /*VMCHOOSER_VSESSION_H_*/