#ifndef SH_PLUGINS_MANIFEST_H
#define SH_PLUGINS_MANIFEST_H

#include <pistring.h>
#include <QStringList>
#include <QDateTime>

class SHPluginsLoader;
class SHPluginsWeb;
class SHPluginBase;

class SHPluginManifest {
	friend class SHPluginsLoader;
	friend class SHPluginsWeb;
public:
	bool read(const QString & path);
	bool read(const QByteArray & content);
	bool checkFile() const;
	bool checkSystem() const;
	bool checkVersions() const;
	bool isValid() const {return !name.isEmpty();}
	bool isInvalid() const {return !isValid();}
	bool isBuiltin() const {return builtin;}
	void fillBuiltin(SHPluginBase * plugin);
	QString fullVersion() const;
	QString manifestPath() const {return manifestpath;}
	QString libraryPath() const {return libpath;}
	QString libraryDownloadPath() const;
	PIString comparableVersion() const;

	// Manifest itself
	QString name;
	QString file;
	QString author;
	QString description;
	QString version;
	QString version_PIP;
	QString version_QAD;
	QString version_SHS;
	QString build;
	QStringList dependencies;
	QString system;
	QString arch;
	QDateTime timestamp;

private:
	bool checkVersion(const QString & v0, const QString & v1, const char * name) const;
	QString versionComponents(const QString & v, int count = 2) const;

	bool builtin = false;
	QString manifestpath;
	QByteArray manifestcontent;
	mutable QString libpath;

};

#endif
