diff --git a/src/utility/package.cpp b/src/utility/package.cpp index eb2e58cc35930cc10ff831a23a28d2071559d127..7cd26680624ce14cc84a13c89fdcde3c199b0d33 100644 --- a/src/utility/package.cpp +++ b/src/utility/package.cpp @@ -9,23 +9,12 @@ namespace Utility { Package::Package(QObject *parent) : QObject(parent) {} -bool Package::process(const QString &program, const QStringList &arguments) -{ - QProcess process; - process.start(program, arguments); - if (process.waitForFinished()) { - process.waitForReadyRead(); - return true; - } - return false; -} - bool Package::installProgram(const QString &path, const QString &targetPath) { QString program = "install"; QStringList arguments; arguments << "-m" << "755" << "-p" << path << targetPath; - return process(program, arguments); + return _process(program, arguments); } bool Package::installFile(const QString &path, const QString &targetPath) @@ -33,7 +22,7 @@ bool Package::installFile(const QString &path, const QString &targetPath) QString program = "install"; QStringList arguments; arguments << "-m" << "644" << "-p" << path << targetPath; - return process(program, arguments); + return _process(program, arguments); } bool Package::installPlasmapkg(const QString &path, const QString &type) @@ -41,7 +30,7 @@ bool Package::installPlasmapkg(const QString &path, const QString &type) QString program = "plasmapkg2"; QStringList arguments; arguments << "-t" << type << "-i" << path; - return process(program, arguments); + return _process(program, arguments); } bool Package::uninstallPlasmapkg(const QString &path, const QString &type) @@ -49,7 +38,7 @@ bool Package::uninstallPlasmapkg(const QString &path, const QString &type) QString program = "plasmapkg2"; QStringList arguments; arguments << "-t" << type << "-r" << path; - return process(program, arguments); + return _process(program, arguments); } bool Package::uncompressArchive(const QString &path, const QString &targetDir) @@ -100,10 +89,21 @@ bool Package::uncompressArchive(const QString &path, const QString &targetDir) arguments << "e" << path << targetDir; } - return process(program, arguments); + return _process(program, arguments); } return false; } +bool Package::_process(const QString &program, const QStringList &arguments) +{ + QProcess process; + process.start(program, arguments); + if (process.waitForFinished()) { + process.waitForReadyRead(); + return true; + } + return false; +} + } // namespace Utility diff --git a/src/utility/package.h b/src/utility/package.h index 6300962c27530d6cee18b9df79cbba731c53cb64..04f81809a887763dec4d4d8b58e87f519b19d8d0 100644 --- a/src/utility/package.h +++ b/src/utility/package.h @@ -12,12 +12,14 @@ class Package : public QObject public: explicit Package(QObject *parent = 0); - static bool process(const QString &program, const QStringList &arguments); 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 uncompressArchive(const QString &path, const QString &targetDir); + +private: + static bool _process(const QString &program, const QStringList &arguments); }; } // namespace Utility