diff --git a/src/handlers/xdgurl.cpp b/src/handlers/xdgurl.cpp index 136d6b20610da9e9ab2274ba24024904178b5437..143a16b6ce618c5ce95e97c5d9feef1bf6447aeb 100644 --- a/src/handlers/xdgurl.cpp +++ b/src/handlers/xdgurl.cpp @@ -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; diff --git a/src/handlers/xdgurl.h b/src/handlers/xdgurl.h index 03001b5f19e4dc18d91c68c4a3c629638ed1a68a..c705843226afcfaa8e0686600b7372ba7ff01a75 100644 --- a/src/handlers/xdgurl.h +++ b/src/handlers/xdgurl.h @@ -43,6 +43,7 @@ private: private slots: public slots: + bool isValid(); bool process(); signals: