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()
QString XdgUrl::_convertPathString(const QString &path)
{
QString newPath = path;
if (newPath.contains("$HOME")) {
newPath.replace("$HOME", Utility::File::homePath());
}
......@@ -72,6 +73,7 @@ QString XdgUrl::_convertPathString(const QString &path)
else if (newPath.contains("$KDE_DATA")) {
newPath.replace("$KDE_DATA", Utility::File::kdeDataHomePath());
}
return newPath;
}
......@@ -134,10 +136,13 @@ bool XdgUrl::_installPlasmapkg(const QString &path, const QString &type)
QProcess process;
QStringList arguments;
arguments << "-t" << type << "-i" << path;
process.start("plasmapkg2", arguments);
if (process.waitForFinished()) {
return true;
}
return false;
}
......@@ -200,6 +205,33 @@ bool XdgUrl::_install()
* 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()
{
return true;
......
......@@ -43,6 +43,7 @@ private:
private slots:
public slots:
bool isValid();
bool process();
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