Skip to content
Snippets Groups Projects
Commit cd1614fd authored by akiraohgaki's avatar akiraohgaki
Browse files

Validation of metadata

parent b23d2edd
No related branches found
No related tags found
No related merge requests found
...@@ -63,6 +63,7 @@ QJsonObject XdgUrl::_parse() ...@@ -63,6 +63,7 @@ QJsonObject XdgUrl::_parse()
QString XdgUrl::_convertPathString(const QString &path) QString XdgUrl::_convertPathString(const QString &path)
{ {
QString newPath = path; QString newPath = path;
if (newPath.contains("$HOME")) { if (newPath.contains("$HOME")) {
newPath.replace("$HOME", Utility::File::homePath()); newPath.replace("$HOME", Utility::File::homePath());
} }
...@@ -72,6 +73,7 @@ QString XdgUrl::_convertPathString(const QString &path) ...@@ -72,6 +73,7 @@ QString XdgUrl::_convertPathString(const QString &path)
else if (newPath.contains("$KDE_DATA")) { else if (newPath.contains("$KDE_DATA")) {
newPath.replace("$KDE_DATA", Utility::File::kdeDataHomePath()); newPath.replace("$KDE_DATA", Utility::File::kdeDataHomePath());
} }
return newPath; return newPath;
} }
...@@ -134,10 +136,13 @@ bool XdgUrl::_installPlasmapkg(const QString &path, const QString &type) ...@@ -134,10 +136,13 @@ bool XdgUrl::_installPlasmapkg(const QString &path, const QString &type)
QProcess process; QProcess process;
QStringList arguments; QStringList arguments;
arguments << "-t" << type << "-i" << path; arguments << "-t" << type << "-i" << path;
process.start("plasmapkg2", arguments); process.start("plasmapkg2", arguments);
if (process.waitForFinished()) { if (process.waitForFinished()) {
return true; return true;
} }
return false; return false;
} }
...@@ -200,6 +205,33 @@ bool XdgUrl::_install() ...@@ -200,6 +205,33 @@ bool XdgUrl::_install()
* Public slots * Public slots
*/ */
bool XdgUrl::isValid()
{
bool isValid = true;
if (_meta["scheme"].toString() != "xdg" && _meta["scheme"].toString() != "xdgs") {
isValid = false;
}
if (_meta["command"].toString() != "download" && _meta["command"].toString() != "install") {
isValid = false;
}
if (!QUrl(_meta["url"].toString()).isValid()) {
isValid = false;
}
if (!_destinations.contains(_meta["type"].toString())) {
isValid = false;
}
if (_meta["filename"].toString().isEmpty()) {
isValid = false;
}
return isValid;
}
bool XdgUrl::process() bool XdgUrl::process()
{ {
return true; return true;
......
...@@ -43,6 +43,7 @@ private: ...@@ -43,6 +43,7 @@ private:
private slots: private slots:
public slots: public slots:
bool isValid();
bool process(); bool process();
signals: signals:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment