Verified Commit 0c9a90cf authored by azubieta's avatar azubieta
Browse files

Deploy with AppImage Services

parent 7c758030
Pipeline #601 failed with stages
in 51 seconds
cmake_minimum_required(VERSION 3.10)
project(plasma-appimage-integration)
project(
plasma-appimage-integration
VERSION 0.1.0
LANGUAGES CXX
)
set(CMAKE_CXX_STANDARD 11)
......@@ -27,6 +31,8 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
add_subdirectory(src)
add_subdirectory(res)
add_subdirectory(dist)
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
# general CPack options
set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
set(CPACK_PACKAGE_VENDOR "The AppImage Project https://appimage.org")
# global options
set(CPACK_PACKAGE_CONTACT "Alexis Lopez Zubieta <contact@azubieta.net>")
#set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md")
#set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE.txt")
set(CPACK_PACKAGE_DESCRIPTION "Extensions to enhance AppImage support on plasma")
add_subdirectory(deb)
# Must be after all the package configurations
include(CPack)
# Debian packaging global options
set(CPACK_DEBIAN_COMPRESSION_TYPE xz PARENT_SCOPE)
set(CPACK_DEBIAN_PACKAGE_PROVIDES appimage-services PARENT_SCOPE)
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON PARENT_SCOPE)
set(CPACK_DEBIAN_PACKAGE_PREDEPENDS "bash, libqt5widgets5 (>= 5.2.1), libqt5gui5 (>= 5.2.1), libqt5core5a (>= 5.2.1)" PARENT_SCOPE)
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/postinst" "${CMAKE_CURRENT_SOURCE_DIR}/postrm" PARENT_SCOPE)
#! /bin/bash
set -e
echo "Installing appimage-services"
echo "Downloading latest version from opencode.net"
APPIMAGE_SERVICES_URL="https://www.opencode.net/azubieta/AppImageService/-/jobs/artifacts/master/raw/appimage-services-x86_64.AppImage?job=build:AppImage"
wget $APPIMAGE_SERVICES_URL -O /usr/bin/appimage-services
chmod +x /usr/bin/appimage-services
/usr/bin/appimage-services self-install
#! /bin/bash
set -e
/usr/bin/appimage-services self-uninstall
rm /usr/bin/appimage-services
[Launcher]
RemoveCommand=plasma-appimage-integration
RemoveCommandArgs=remove %1
UpdateCommand=plasma-appimage-integration
UpdateCommandArgs=update %1
install(FILES "AppImage Services.conf" DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/The AppImage Project")
......@@ -2,6 +2,7 @@ add_executable(
plasma-appimage-integration
main.cpp
UpdateJob.cpp
RemoveJob.cpp
)
target_link_libraries(plasma-appimage-integration appimageservices-interfaces KF5::KIOWidgets KF5::I18n KF5::Notifications)
......
// libraries
#include <KLocalizedString>
#include <QDBusPendingCallWatcher>
// local
#include "RemoveJob.h"
#include "LauncherInterface.h"
RemoveJob::RemoveJob(const QString& target, QObject* parent)
: KJob(parent), target(target),
launcherInterface(new OrgAppimageServices1LauncherInterface("org.appimage.Services1.Launcher",
"/org/appimage/Services1/Launcher",
QDBusConnection::sessionBus(), this)) {}
void RemoveJob::start() {
auto reply = launcherInterface->unregisterApp(target);
if (reply.isError()) {
setError(-1);
setErrorText(i18n("Remove failed: %0").arg(reply.error().message()));
}
QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher(reply, this);
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, &RemoveJob::callFinishedSlot);
}
void RemoveJob::callFinishedSlot(QDBusPendingCallWatcher* watcher) {
if (watcher->isError()) {
setError(-1);
setErrorText(i18n("Remove failed: %0").arg(watcher->error().message()));
} else
description(this, i18n("Application successfully removed"));
// notify result delayed
QTimer::singleShot(1000, this, &RemoveJob::emitResult);
}
#pragma once
// libraries
#include <KJob>
#include <QUrl>
class QDBusPendingCallWatcher;
class OrgAppimageServices1LauncherInterface;
class RemoveJob : public KJob {
public:
RemoveJob(const QString& target, QObject* parent = nullptr);
void start() override;
protected slots:
void callFinishedSlot(QDBusPendingCallWatcher* watcher);
private:
QString target;
OrgAppimageServices1LauncherInterface* launcherInterface;
};
......@@ -10,6 +10,7 @@
// local
#include "UpdateJob.h"
#include "RemoveJob.h"
QString parseTarget(QCommandLineParser& parser) {
......@@ -39,6 +40,17 @@ void executeUpdateCommand(const QString& target) {
UpdateJob::notifyError(i18n("Update failed").arg(target), job->errorString());
}
void executeRemoveCommand(const QString& target) {
KJob* job = new RemoveJob(target);
KIO::getJobTracker()->registerJob(job);
job->start();
if (job->error() != 0)
UpdateJob::notifyError(i18n("Remove failed").arg(target), job->errorString());
}
int main(int argc, char** argv) {
QApplication app(argc, argv);
QApplication::setApplicationName("plasma-appimage-integration");
......@@ -64,6 +76,12 @@ int main(int argc, char** argv) {
QString target = parseTarget(parser);
executeUpdateCommand(target);
}
if (command == "remove") {
QString target = parseTarget(parser);
executeRemoveCommand(target);
}
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