CQtDeployer/Deploy/Distributions/idistribution.h

125 lines
4.1 KiB
C
Raw Normal View History

2019-11-28 18:13:56 +03:00
#ifndef IDISTRIBUTION_H
#define IDISTRIBUTION_H
#include "distrostruct.h"
#include "envirement.h"
2020-01-13 18:25:03 +03:00
#include "templateinfo.h"
2020-01-16 11:10:16 +03:00
#include <QProcess>
#include <QHash>
2020-01-14 15:48:35 +03:00
#include <QFileInfo>
2020-01-15 18:31:09 +03:00
class FileManager;
2020-01-18 20:01:14 +03:00
class DistroModule;
2020-08-15 14:38:03 +03:00
class PackageControl;
class DeployConfig;
2020-01-14 15:48:35 +03:00
struct SystemCommandData {
QString command;
QStringList arguments;
};
2019-11-28 18:13:56 +03:00
class DEPLOYSHARED_EXPORT iDistribution
{
public:
2020-01-15 18:31:09 +03:00
iDistribution(FileManager * fileManager);
2019-11-28 18:13:56 +03:00
virtual ~iDistribution();
2020-08-15 14:38:03 +03:00
virtual bool deployTemplate(PackageControl& pkgCtrl) = 0;
2020-01-15 11:50:30 +03:00
virtual bool removeTemplate() const = 0;
2020-01-16 11:10:16 +03:00
virtual Envirement toolKitEnv() const = 0;
virtual QProcessEnvironment processEnvirement() const = 0;
virtual QList<SystemCommandData> runCmd() = 0;
2020-03-08 13:52:26 +03:00
virtual QStringList outPutFiles() const = 0;
2020-11-09 16:33:50 +03:00
virtual bool cb() const;
QString getClassName() const;
protected:
QString getLocation() const;
void setLocation(const QString &location);
2020-01-14 15:48:35 +03:00
bool unpackFile(const QFileInfo& resource,
const QString& target,
2020-01-19 13:26:47 +03:00
const TemplateInfo& info,
const QStringList &sufixes) const;
2020-01-14 15:48:35 +03:00
bool unpackDir(const QString& resource,
const QString& target,
2020-01-19 13:26:47 +03:00
const TemplateInfo& info,
2020-11-09 16:33:50 +03:00
const QStringList &sufixes,
const QHash<QString, QString> &folderNewNames = {}) const;
2020-01-18 20:01:14 +03:00
bool moveData(const QString& from, const QString& to, const QString &ignore) const;
bool copyFile(const QString& from, const QString& to, bool isFileTarget) const;
2020-08-15 19:29:17 +03:00
bool copyDir(const QString &resource, const QString &target) const;
2020-01-16 15:25:36 +03:00
2020-03-08 13:52:26 +03:00
void registerOutFiles() const;
2020-12-02 17:53:14 +03:00
/**
* @brief collectInfoWithDeployIcons This is wraper of the collectInfo and deployIcon methods.
* @param pkg This is package object.
* @param info This is return value (created template information)
* @return true if information collected successful.
*/
bool collectInfoWithDeployIcons(const DistroModule &pkg,
2020-12-03 20:00:14 +03:00
TemplateInfo& info);
2020-12-02 17:53:14 +03:00
/**
* @brief collectInfo This method collect information about package.
2020-12-02 17:53:14 +03:00
* @param pkg This is package object.
* @param info This is return value (created template information)
* @return true if information collected successful.
*/
2020-12-02 17:53:14 +03:00
bool collectInfo(const DistroModule &pkg,
2020-12-03 20:00:14 +03:00
TemplateInfo& info);
/**
* @brief getName This method return name of package from pacakge key.
* @param pkgKey This is pacakge.
* @return package name.
*/
QString getName(const DistroModule &pkgKey) const;
2020-12-02 17:53:14 +03:00
/**
* @brief deployIcon This method copy default or custom icon to the package.
* @param info This is information about package.
* @note This method change the icon field of the info object.
* If packages support the icons then you need to invocke this method after the collectInfo method.
* @param pkg This is package info
* @return true if this method finished successful.
*/
bool deployIcon(TemplateInfo &info, const DistroModule &pkg);
/**
* @brief dataLocation This method should be retrun location of application or package files.
2020-12-03 20:00:14 +03:00
* @param module This is module with information about package.
* @return return location of data files.
*/
2020-12-03 20:00:14 +03:00
virtual QString dataLocation(const DistroModule &module) const = 0;
/**
* @brief location This method return main patho to files of package.
2020-12-03 20:00:14 +03:00
* @param module This is module with information about package.
* @return location of package.
*/
2020-12-03 20:00:14 +03:00
virtual QString location(const DistroModule &module) const = 0;
/**
* @brief releativeLocation This method must be return releative path after install.
* Default implementation return prefix value. but for some packages types may need to change a prefix value.
* @param module This is module with information about package.
* @return releative prefix value.
*/
virtual QString releativeLocation(const DistroModule &module) const;
private:
2020-01-19 13:26:47 +03:00
2020-01-18 20:01:14 +03:00
QString _location = "Temp Template";
2020-01-15 18:31:09 +03:00
FileManager * _fileManager = nullptr;
2019-11-28 18:13:56 +03:00
};
#endif // IDISTRIBUTION_H