Skip to content

Commit

Permalink
Add connect to libappimage
Browse files Browse the repository at this point in the history
  • Loading branch information
azubieta committed May 7, 2019
1 parent 4a02f59 commit 342ba23
Show file tree
Hide file tree
Showing 18 changed files with 394 additions and 44 deletions.
31 changes: 31 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
language: cpp
compiler: gcc
dist: trusty


notifications:
email: false

addons:
apt:
packages:
- realpath wget git realpath

install:
- sudo wget -c https://github.com/appimage-conan-community/conan-appimage/releases/download/continuous/conan-8e5c23a-x86_64.AppImage -O /usr/local/bin/conan
- sudo chmod a+x /usr/local/bin/conan
- conan user

script:
- # Original cmake binaries are faulty forcing re-build
- conan install cmake_installer/3.14.3@conan/stable --build 'cmake_install*'
- conan remote add appimage-conan-community https://api.bintray.com/conan/appimage-conan-community/public-conan --insert=0
- conan remote add bincrafters https://api.bintray.com/conan/bincrafters/public-conan --insert=1
- ci/create_appimage.sh

after_success:
- ls -lh
# make sure only pushes to rewrite create a new release, otherwise pretend PR and upload to transfer.sh
- if [ "$TRAVIS_BRANCH" != "$TRAVIS_TAG" ] && [ "$TRAVIS_BRANCH" != "master" ]; then export TRAVIS_EVENT_TYPE=pull_request; fi
- wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh
- bash upload.sh appimage-services*.AppImage*
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ cmake_policy(SET CMP0048 NEW)
cmake_minimum_required(VERSION 3.10)

# Project
project(AppImageService VERSION 0.1.0 LANGUAGES CXX DESCRIPTION "Language agnostic implementation of the AppImage user experience")
project(AppImageServices VERSION 0.1.0 LANGUAGES CXX DESCRIPTION "Language agnostic implementation of the AppImage user experience")

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include(GNUInstallDirs)

add_subdirectory(src)
add_subdirectory(res)
69 changes: 68 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# AppImageService
# AppImageServices
Language agnostic implementation of the AppImage user experience (not mandatory to use AppImages)

This is meant to be used by file managers, software centers or other tools that aims to provide a consistent user
Expand All @@ -16,3 +16,70 @@ The following features will be provided:
- metadata extraction

_This service must be considered an enhancement to the AppImage UX but not a mandatory requirement to use AppImages._

## D-Bus Interface
```
org.appimage.Services.Launcher
\- launch ( String appImagePath )
\- register ( String appImagePath )
\- unregister ( String appImagePath )
org.appimage.Services.Updater
\- checkUpdates ( String appImagePath )
\- update ( String appImagePath )
\- rollback ( String appImagePath )
org.appimage.Services.Updater.Task
\- tasks
org.appimage.Services.Inspector
\- inspect ( String appImagePath )
\- verifySignature ( String appImagePath )
org.appimamge.Services.Self
\- checkUpdates
\- update
\- rollback
```

## Command Line Interface
```
cmd=appimage-services
appimage_path=$HOME/RandomApp.AppImage
appimage_id=org.appmakers.CoolApp
# Launcher
$cmd launch $appimage_path
$cmd launch $appimage_id # ?
$cmd register $appimage_path
$cmd unregister $appimage_path
# Directories monitoring
$cmd add-applications-dir $HOME/Applications
$cmd remove-applications-dir $HOME/Applications
# Updates
$cmd check-updates $appimage_path
$cmd update $appimage_path
$cmd rollback $appimage_path
# Inspection
$cmd inspect $appimage_path # shows appimage contents and metadata
$cmd verify-signature $appimage_path # verify checksums
# Thumbnailer
$cmd create-thumbnail $appimage_path
$cmd remove-thumbnail $appimage_path
# Self Management
$cmd # starts as a service (deamon)
./appimage-services.AppImage # starts as a service (deamon)
./appimage-services.AppImage self-install --move-to-opt
./appimage-services.AppImage self-uninstall
./appimage-services.AppImage self-update
./appimage-services.AppImage self-rollback
```

17 changes: 17 additions & 0 deletions ci/create_appimage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

set -xe

build_scripts_dir=`dirname $0`
source_dir=`dirname $build_scripts_dir`

echo $source_dir
conan install $source_dir --build missing

. activate_run.sh

cmake $source_dir -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_PROJECT_AppImageServices_INCLUDE=$PWD/conan_paths.cmake
make install -j`nproc` DESTDIR=AppDir
linuxdeploy --appdir=AppDir --plugin qt --output appimage --desktop-file=AppDir/usr/share/applications/org.appimage.services.desktop

. deactivate_run.sh
19 changes: 17 additions & 2 deletions conanfile.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
[requires]
qt/5.12.2@bincrafters/stable
libpng/1.6.36@bincrafters/stable
qt/5.12.3@appimage-conan-community/stable
xdg-utils-cxx/0.1.1@appimage-conan-community/stable
libappimage/1.0.0@appimage-conan-community/stable


[build_requires]
patchelf_installer/0.9@appimage-conan-community/stable
gtest/1.8.1@bincrafters/stable
glib/2.40.0@appimage-conan-community/stable
cmake_installer/3.14.3@conan/stable
linuxdeploy/continuous@appimage-conan-community/stable
linuxdeploy-plugin-qt/continuous@appimage-conan-community/stable
linuxdeploy-plugin-appimage/continuous@appimage-conan-community/stable

[generators]
cmake_paths
qt
virtualenv
virtualrunenv

[options]
glib:shared=True
2 changes: 2 additions & 0 deletions res/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
install(FILES appimage_logo.svg DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps COMPONENT APPIMAGE_SERVICES)
install(FILES org.appimage.services.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications COMPONENT APPIMAGE_SERVICES)
78 changes: 78 additions & 0 deletions res/appimage_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions res/org.appimage.services.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Desktop Entry]
Version=1.0
Type=Application
Name=appimage-services
Comment=App
TryExec=appimage-services
Exec=appimage-services
Icon=appimage_logo
Categories=Utility;
NoDisplay=true
12 changes: 11 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
add_subdirectory(dbus)
add_subdirectory(launcher)

find_package(Qt5 CONFIG REQUIRED Core)
add_executable(appimage-services main.cpp)
target_link_libraries(appimage-services PRIVATE AppImageServicesLauncher Qt5::Core)

install(
TARGETS appimage-services
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT AppImageServices
)
25 changes: 0 additions & 25 deletions src/dbus/DBusInterface.cpp

This file was deleted.

24 changes: 12 additions & 12 deletions src/dbus/CMakeLists.txt → src/launcher/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
find_package(libappimage REQUIRED)
find_package(Qt5 CONFIG REQUIRED Core DBus)
find_package(XdgUtils REQUIRED COMPONENTS DesktopEntry)

# Generate the xml interface file from DBusInterface.h
qt5_generate_dbus_interface(
Expand All @@ -10,9 +12,9 @@ qt5_generate_dbus_interface(
OPTIONS -A
)

# Create a dbus adaptor (header and implementation file) from the xml file
# Create a launcher adaptor (header and implementation file) from the xml file
qt5_add_dbus_adaptor(
AppImageServiceSRCS
AppImageServicesSRCS
# xmlfile
${CMAKE_CURRENT_BINARY_DIR}/org.appimage.Services.Launcher.xml
# parentheader
Expand All @@ -22,24 +24,22 @@ qt5_add_dbus_adaptor(
)
set(CMAKE_AUTOMOC ON)

add_executable(AppImageService ${AppImageServiceSRCS} main.cpp DBusInterface.cpp)
add_library(AppImageServicesLauncher OBJECT LauncherService.cpp ${AppImageServicesSRCS} DBusInterface.cpp)

target_include_directories(
AppImageService
AppImageServicesLauncher
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
)

target_link_libraries(AppImageService PRIVATE Qt5::Core Qt5::DBus)

install(
TARGETS AppImageService
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT AppImageService
)
target_link_libraries(AppImageServicesLauncher
PUBLIC Qt5::DBus libappimage
PRIVATE Qt5::Core XdgUtils::DesktopEntry
)

# Install D-Bus interface descriptor
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/org.appimage.Services.Launcher.xml
DESTINATION ${CMAKE_INSTALL_DATADIR}/dbus-1/interfaces
COMPONENT AppImageServiceAPI
COMPONENT AppImageServicesAPI
)
42 changes: 42 additions & 0 deletions src/launcher/DBusInterface.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// libraries
#include <QDBusConnection>
#include <QDebug>

// local
#include "DBusInterface.h"
#include <LauncherService.h>

// generated by `qt5_add_dbus_adaptor` cmake function
#include "launcheradaptor.h"

DBusInterface::DBusInterface(QObject* parent) : QObject(parent) {
new LauncherAdaptor(this);
QDBusConnection dbus = QDBusConnection::sessionBus();
bool operationSucceed;
operationSucceed = dbus.registerObject(LAUNCHER_DBUS_OBJECT_PATH, this);
if (!operationSucceed)
qCritical() << "Unable to register d-bus object: " << LAUNCHER_DBUS_OBJECT_PATH;

operationSucceed = dbus.registerService(LAUNCHER_DBUS_INTERFACE_NAME);
if (!operationSucceed)
qCritical() << "Unable to register d-bus service: " << LAUNCHER_DBUS_INTERFACE_NAME;

}

bool DBusInterface::registerApp(const QString& appImagePath) {
qDebug() << __FUNCTION__ << " : " << appImagePath;
if (appImagePath.startsWith("file://"))
return launcherService.registerApp(appImagePath.mid(7).toStdString());
else
return launcherService.registerApp(appImagePath.toStdString());
}

bool DBusInterface::unregisterApp(const QString& appImagePath) {
qDebug() << __FUNCTION__ << " : " << appImagePath;
if (appImagePath.startsWith("file://"))
return launcherService.unregisterApp(appImagePath.mid(7).toStdString());
else
return launcherService.unregisterApp(appImagePath.toStdString());
}

DBusInterface::~DBusInterface() = default;
7 changes: 6 additions & 1 deletion src/dbus/DBusInterface.h → src/launcher/DBusInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

// local
#include "DBusResponseType.h"
#include "LauncherService.h"
#include "LauncherDefines.h"

class DBusInterface : public QObject {
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.appimage.Services.Launcher")
Q_CLASSINFO("D-Bus Interface", LAUNCHER_DBUS_INTERFACE_NAME)

public:
explicit DBusInterface(QObject* parent = nullptr);
Expand All @@ -34,5 +36,8 @@ public Q_SLOTS:
* @return
*/
bool unregisterApp(const QString& appImagePath);

private:
LauncherService launcherService;
};

File renamed without changes.
8 changes: 8 additions & 0 deletions src/launcher/LauncherDefines.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

#define LAUNCHER_DBUS_INTERFACE_NAME "org.appimage.Services.Launcher"
#define LAUNCHER_DBUS_OBJECT_PATH "/org/appimage/Services/Launcher"
#define LAUNCHER_DBUS_METHOD_REGISTER_APP "org.appimage.Services.Launcher.registerApp"
#define LAUNCHER_DBUS_METHOD_UNREGISTER_APP "org.appimage.Services.Launcher.unregisterApp"


Loading

0 comments on commit 342ba23

Please sign in to comment.