Verified Commit 4c17136c authored by azubieta's avatar azubieta
Browse files

Add uninstall command

parent 18f5bd1e
...@@ -4,3 +4,6 @@ RemoveCommandArgs=remove %1 ...@@ -4,3 +4,6 @@ RemoveCommandArgs=remove %1
UpdateCommand=plasma-appimage-integration UpdateCommand=plasma-appimage-integration
UpdateCommandArgs=update %1 UpdateCommandArgs=update %1
UninstallCommand=plasma-appimage-integration
UninstallCommandArgs=uninstall %1
...@@ -4,6 +4,7 @@ add_executable( ...@@ -4,6 +4,7 @@ add_executable(
UpdateJob.cpp UpdateJob.cpp
RemoveJob.cpp RemoveJob.cpp
InstallJob.cpp InstallJob.cpp
UninstallJob.cpp
) )
target_link_libraries(plasma-appimage-integration appimageservices-interfaces KF5::KIOWidgets KF5::I18n KF5::Notifications) target_link_libraries(plasma-appimage-integration appimageservices-interfaces KF5::KIOWidgets KF5::I18n KF5::Notifications)
......
// libraries
#include <QtCore/QTimer>
#include <QtCore/QDebug>
#include <KI18n/KLocalizedString>
#include <utility>
// local
#include "UninstallJob.h"
UninstallJob::UninstallJob(QString target, QObject* parent) : KJob(parent), target(std::move(target)) {}
void UninstallJob::start() {
process.setProgram("pkexec");
process.setArguments({"appimage-services", "uninstall", target});
qDebug() << "calling pkexec appimage-services install " << target;
connect(&process, SIGNAL(finished(int)), this, SLOT(onProcessFinished(int)));
description(this, i18n("Uninstalling Application"),
qMakePair<QString, QString>(i18nc("The AppImage being uninstalled", "Source"), target));
process.start();
}
void UninstallJob::onProcessFinished(int exitCode) {
qDebug() << exitCode;
qDebug() << process.errorString();
if (exitCode != 0) {
setError(exitCode);
setErrorText(process.readAllStandardError());
}
// notify result delayed
QTimer::singleShot(1000, this, &UninstallJob::emitResult);
}
#pragma once
// libraries
#include <KJob>
#include <QtCore/QProcess>
class UninstallJob : public KJob {
Q_OBJECT
public:
explicit UninstallJob(QString target, QObject* parent = nullptr);
void start() override;
protected slots:
void onProcessFinished(int exitCode);
private:
QString target;
QProcess process;
};
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "UpdateJob.h" #include "UpdateJob.h"
#include "RemoveJob.h" #include "RemoveJob.h"
#include "InstallJob.h" #include "InstallJob.h"
#include "UninstallJob.h"
QString parseTarget(QCommandLineParser& parser) { QString parseTarget(QCommandLineParser& parser) {
...@@ -59,6 +60,13 @@ void executeInstallCommand(const QString& target) { ...@@ -59,6 +60,13 @@ void executeInstallCommand(const QString& target) {
job->start(); job->start();
} }
void executeUninstallCommand(const QString& target) {
KJob* job = new UninstallJob(target);
KIO::getJobTracker()->registerJob(job);
job->start();
}
int main(int argc, char** argv) { int main(int argc, char** argv) {
QApplication app(argc, argv); QApplication app(argc, argv);
QApplication::setApplicationName("plasma-appimage-integration"); QApplication::setApplicationName("plasma-appimage-integration");
...@@ -94,6 +102,11 @@ int main(int argc, char** argv) { ...@@ -94,6 +102,11 @@ int main(int argc, char** argv) {
QString target = parseTarget(parser); QString target = parseTarget(parser);
executeInstallCommand(target); executeInstallCommand(target);
} }
if (command == "uninstall") {
QString target = parseTarget(parser);
executeUninstallCommand(target);
}
return QApplication::exec(); return QApplication::exec();
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment