diff --git a/src/utility/package.cpp b/src/utility/package.cpp index 698ca55580c7368afc1429a02fd9851bce62c1c2..a8ca8e102a6ed032d65fc882afe45b301ccdc874 100644 --- a/src/utility/package.cpp +++ b/src/utility/package.cpp @@ -9,6 +9,70 @@ namespace Utility { Package::Package(QObject *parent) : QObject(parent) {} +bool Package::installProgram(const QString &path, const QString &targetPath) +{ + QProcess process; + QString program = "install"; + QStringList arguments; + arguments << "-m" << "755" << "-p" << path << targetPath; + + process.start(program, arguments); + + if (process.waitForFinished()) { + return true; + } + + return false; +} + +bool Package::installFile(const QString &path, const QString &targetPath) +{ + QProcess process; + QString program = "install"; + QStringList arguments; + arguments << "-m" << "644" << "-p" << path << targetPath; + + process.start(program, arguments); + + if (process.waitForFinished()) { + return true; + } + + return false; +} + +bool Package::installPlasmapkg(const QString &path, const QString &type) +{ + QProcess process; + QString program = "plasmapkg2"; // Use plasmapkg2 for now + QStringList arguments; + arguments << "-t" << type << "-i" << path; + + process.start(program, arguments); + + if (process.waitForFinished()) { + return true; + } + + return false; +} + +bool Package::uninstallPlasmapkg(const QString &path, const QString &type) +{ + QProcess process; + QString program = "plasmapkg2"; // Use plasmapkg2 for now + QStringList arguments; + arguments << "-t" << type << "-r" << path; + + process.start(program, arguments); + + if (process.waitForFinished()) { + return true; + } + + return false; +} + bool Package::uncompressArchive(const QString &path, const QString &targetDir) { QJsonObject archiveTypes; @@ -69,52 +133,4 @@ bool Package::uncompressArchive(const QString &path, const QString &targetDir) return false; } -bool Package::installPlasmapkg(const QString &path, const QString &type) -{ - QProcess process; - QString program = "plasmapkg2"; // Use plasmapkg2 for now - QStringList arguments; - arguments << "-t" << type << "-i" << path; - - process.start(program, arguments); - - if (process.waitForFinished()) { - return true; - } - - return false; -} - -bool Package::uninstallPlasmapkg(const QString &path, const QString &type) -{ - QProcess process; - QString program = "plasmapkg2"; // Use plasmapkg2 for now - QStringList arguments; - arguments << "-t" << type << "-r" << path; - - process.start(program, arguments); - - if (process.waitForFinished()) { - return true; - } - - return false; -} - -bool Package::installProgram(const QString &path, const QString &targetPath) -{ - QProcess process; - QString program = "install"; - QStringList arguments; - arguments << "-D" << "-m" << "755" << path << targetPath; - - process.start(program, arguments); - - if (process.waitForFinished()) { - return true; - } - - return false; -} - } // namespace Utility diff --git a/src/utility/package.h b/src/utility/package.h index a3a0ae180c43219ce4b7aa8eaf75c50f29f9e25f..b8c07010ab67c842f92ba308280bb31af8379584 100644 --- a/src/utility/package.h +++ b/src/utility/package.h @@ -12,10 +12,11 @@ class Package : public QObject public: explicit Package(QObject *parent = 0); - static bool uncompressArchive(const QString &path, const QString &targetDir); + static bool installProgram(const QString &path, const QString &targetPath); + static bool installFile(const QString &path, const QString &targetPath); static bool installPlasmapkg(const QString &path, const QString &type = "plasmoid"); static bool uninstallPlasmapkg(const QString &path, const QString &type = "plasmoid"); - static bool installProgram(const QString &path, const QString &targetPath); + static bool uncompressArchive(const QString &path, const QString &targetDir); }; } // namespace Utility