aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenys Dmytriyenko <denys@konsulko.com>2023-05-20 20:49:21 +0000
committerDenys Dmytriyenko <denys@konsulko.com>2023-05-20 21:04:28 +0000
commit7a3e870a8349d43a4838604db2c28140c2f76c9f (patch)
treede3a0d2928b2d4ae8521b40c50bda485cc9671d0
parent5cab14e6a98519e0b6c6043a1a19e42f094d6522 (diff)
Remove deprecated D-Bus interface
As applaunchd now uses gRPC as its API and launches applications as systemd services, plus all applications have been converted now, it is time to remove the old D-Bus interface. Bug-AGL: SPEC-4801 Signed-off-by: Denys Dmytriyenko <denys@konsulko.com> Change-Id: Icec29c13d9310cfb043b87e44f4c5f3f0c986ccc
-rw-r--r--README.md5
-rw-r--r--data/meson.build57
-rw-r--r--data/org.automotivelinux.AppLaunch.service.in3
-rw-r--r--data/org.automotivelinux.AppLaunch.xml74
-rw-r--r--data/org.freedesktop.Application.xml17
-rw-r--r--meson.build3
-rw-r--r--src/app_launcher.c235
-rw-r--r--src/app_launcher.h30
-rw-r--r--src/main.c77
-rw-r--r--src/meson.build25
10 files changed, 1 insertions, 525 deletions
diff --git a/README.md b/README.md
index 4d0cabb..0e8af70 100644
--- a/README.md
+++ b/README.md
@@ -2,10 +2,7 @@ AGL Application Launcher service reference implementation
`applaunchd` is a simple service for launching applications from other
applications. It exposes a gRPC RPC interface as described in the file
-`protos/applauncher.proto`. Additionally, there is a now deprecated
-`applaunchd-dbus`, which exposes a comparable version of the interface
-named 'org.automotivelinux.AppLaunch' on the D-Bus session bus and can
-be autostarted by using this interface name.
+`protos/applauncher.proto`.
The interface can be used to:
- retrieve a list of available applications
diff --git a/data/meson.build b/data/meson.build
deleted file mode 100644
index 34aefa4..0000000
--- a/data/meson.build
+++ /dev/null
@@ -1,57 +0,0 @@
-#
-# Copyright (C) 2021 Collabora Ltd
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-gnome = import('gnome')
-
-# DBus server interface
-dbus_prefix = 'org.automotivelinux.'
-dbus_namespace = 'applaunchd'
-
-generated_dbus_sources = []
-
-dbus_interfaces = [ 'org.automotivelinux.AppLaunch.xml' ]
-
-generated_dbus_sources += gnome.gdbus_codegen('applaunch-dbus',
- sources : dbus_interfaces,
- object_manager : false,
- interface_prefix : 'org.automotivelinux.',
- install_header : false,
- namespace : 'applaunchd')
-
-dbus_header_dir = meson.current_build_dir()
-dbus_inc = include_directories('.')
-install_data(dbus_interfaces, install_dir: ifacedir)
-
-# Application DBus interface
-generated_dbus_sources += gnome.gdbus_codegen('fdo-dbus',
- sources : [ 'org.freedesktop.Application.xml' ],
- object_manager : false,
- interface_prefix : 'org.freedesktop.',
- install_header : false,
- namespace : 'fdo')
-
-# systemd service file
-service_data = configuration_data()
-service_data.set('bindir', bindir)
-service_file = 'org.automotivelinux.AppLaunch.service'
-
-configure_file(
- input : service_file + '.in',
- output : service_file,
- configuration : service_data,
- install : true,
- install_dir: servicedir,
-)
diff --git a/data/org.automotivelinux.AppLaunch.service.in b/data/org.automotivelinux.AppLaunch.service.in
deleted file mode 100644
index 6a0e297..0000000
--- a/data/org.automotivelinux.AppLaunch.service.in
+++ /dev/null
@@ -1,3 +0,0 @@
-[D-BUS Service]
-Name=org.automotivelinux.AppLaunch
-Exec=@bindir@/applaunchd-dbus
diff --git a/data/org.automotivelinux.AppLaunch.xml b/data/org.automotivelinux.AppLaunch.xml
deleted file mode 100644
index 52aa20b..0000000
--- a/data/org.automotivelinux.AppLaunch.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
-
-<!--
- AppLaunch Interface Specification
-
- Copyright (C) 2021 Collabora Ltd
--->
-<node name="/org/automotivelinux/AppLaunch" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
-
- <!--
- org.automotivelinux.AppLaunch:
- @short_description: The AppLaunch interface.
-
- The AppLaunch interface allows requesting application startup and
- being notified of application startup and termination events.
- -->
- <interface name="org.automotivelinux.AppLaunch">
-
- <!--
- start:
- @appid: Application ID, should match:
- - the xdg-shell app-id for graphical applications started
- through a command line
- - the D-Bus name owned by the application for D-Bus activated
- apps
-
- Start the application with the corresponding application ID.
- -->
- <method name="start">
- <arg name="appid" type="s" direction="in"/>
- </method>
-
- <!--
- listApplications:
- @graphical: Whether the should should be limited to graphical
- applications.
- @applist: The application list as an array of variants. Each array item
- is an application entry, represented as a structure of 3 strings:
- - application ID
- - application name
- - absolute icon path
-
- Retrieve the list of applications which can be started using this interface.
- -->
- <method name="listApplications">
- <arg name="graphical" type="b" direction="in"/>
- <arg name="applist" type="av" direction="out"/>
- </method>
-
- <!--
- started:
- @appid: Application ID
-
- Emitted when an application started successfully, which happens when:
- - the D-Bus name has been taken for D-Bus activated applications
- - the process was created for other applications
- -->
- <signal name="started">
- <arg name="appid" type="s"/>
- </signal>
-
- <!--
- terminated:
- @appid: Application ID
-
- Emitted when an application terminated, which happens when:
- - the D-Bus name has been released for D-Bus activated applications
- - the process exited for other applications
- -->
- <signal name="terminated">
- <arg name="appid" type="s"/>
- </signal>
- </interface>
-</node>
diff --git a/data/org.freedesktop.Application.xml b/data/org.freedesktop.Application.xml
deleted file mode 100644
index dc03d70..0000000
--- a/data/org.freedesktop.Application.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
-<node>
- <interface name='org.freedesktop.Application'>
- <method name='Activate'>
- <arg type='a{sv}' name='platform_data' direction='in'/>
- </method>
- <method name='Open'>
- <arg type='as' name='uris' direction='in'/>
- <arg type='as' name='platform_data' direction='in'/>
- </method>
- <method name='ActivateAction'>
- <arg type='s' name='action_name' direction='in'/>
- <arg type='av' name='parameter' direction='in'/>
- <arg type='as' name='platform_data' direction='in'/>
- </method>
- </interface>
-</node>
diff --git a/meson.build b/meson.build
index 9cca1be..b0fe55e 100644
--- a/meson.build
+++ b/meson.build
@@ -37,8 +37,6 @@ prefix = get_option('prefix')
datadir = get_option('datadir')
sysconfdir = get_option('sysconfdir')
bindir = join_paths(prefix, get_option('bindir'))
-ifacedir = join_paths(prefix, join_paths(datadir, 'dbus-1', 'interfaces'))
-servicedir = join_paths(prefix, join_paths(datadir, 'dbus-1', 'services'))
if datadir.startswith('/')
full_datadir = datadir
@@ -62,5 +60,4 @@ config_h = configure_file (
configuration: config_data
)
-subdir('data')
subdir('src')
diff --git a/src/app_launcher.c b/src/app_launcher.c
deleted file mode 100644
index d576332..0000000
--- a/src/app_launcher.c
+++ /dev/null
@@ -1,235 +0,0 @@
-// SPDX-License-Identifier: Apache-2.0
-/*
- * Copyright (C) 2021 Collabora Ltd
- * Copyright (C) 2022 Konsulko Group
- */
-
-#include "app_info.h"
-#include "app_launcher.h"
-#include "systemd_manager.h"
-
-typedef struct _AppLauncher {
- applaunchdAppLaunchSkeleton parent;
-
- SystemdManager *systemd_manager;
-
-} AppLauncher;
-
-static void app_launcher_iface_init(applaunchdAppLaunchIface *iface);
-
-G_DEFINE_TYPE_WITH_CODE(AppLauncher, app_launcher,
- APPLAUNCHD_TYPE_APP_LAUNCH_SKELETON,
- G_IMPLEMENT_INTERFACE(APPLAUNCHD_TYPE_APP_LAUNCH,
- app_launcher_iface_init));
-
-static void app_launcher_started_cb(AppLauncher *self,
- const gchar *app_id,
- gpointer caller);
-
-/*
- * Internal functions
- */
-
-/*
- * Construct the application list to be sent over D-Bus. It has format "av", meaning
- * the list itself is an array, each item being a variant consisting of 3 strings:
- * - app-id
- * - app name
- * - icon path
- */
-static GVariant *app_launcher_get_list_variant(AppLauncher *self)
-{
- GVariantBuilder builder;
- GList *apps_list = systemd_manager_get_app_list(self->systemd_manager);
- if (!apps_list)
- return NULL;
- guint len = g_list_length(apps_list);
-
- /* Init array variant for storing the applications list */
- g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
-
- for (guint i = 0; i < len; i++) {
- GVariantBuilder app_builder;
- AppInfo *app_info = g_list_nth_data(apps_list, i);
-
- g_variant_builder_init (&app_builder, G_VARIANT_TYPE("(sss)"));
-
- /* Create application entry */
- g_variant_builder_add(&app_builder, "s", app_info_get_app_id(app_info));
- g_variant_builder_add(&app_builder, "s", app_info_get_name(app_info));
- g_variant_builder_add(&app_builder, "s", app_info_get_icon_path(app_info));
-
- /* Add entry to apps list */
- g_variant_builder_add(&builder, "v", g_variant_builder_end(&app_builder));
- }
-
- return g_variant_builder_end(&builder);
-}
-
-/*
- * Starts the requested application using either the D-Bus activation manager
- * or the process manager.
- */
-gboolean app_launcher_start_app(AppLauncher *self, AppInfo *app_info)
-{
- g_return_val_if_fail(APPLAUNCHD_IS_APP_LAUNCHER(self), FALSE);
- g_return_val_if_fail(APPLAUNCHD_IS_APP_INFO(app_info), FALSE);
-
- return systemd_manager_start_app(self->systemd_manager, app_info);
-}
-
-/*
- * Internal callbacks
- */
-
-/*
- * Handler for the "start" D-Bus method.
- */
-static gboolean app_launcher_handle_start(applaunchdAppLaunch *object,
- GDBusMethodInvocation *invocation,
- const gchar *app_id)
-{
- AppInfo *app;
- AppLauncher *self = APPLAUNCHD_APP_LAUNCHER(object);
- g_return_val_if_fail(APPLAUNCHD_IS_APP_LAUNCHER(self), FALSE);
-
- /* Search the apps list for the given app-id */
- app = systemd_manager_get_app_info(self->systemd_manager, app_id);
- if (!app) {
- g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR,
- G_DBUS_ERROR_INVALID_ARGS,
- "Unknown application '%s'",
- app_id);
- return FALSE;
- }
-
- app_launcher_start_app(self, app);
- applaunchd_app_launch_complete_start(object, invocation);
-
- return TRUE;
-}
-
-/*
- * Handler for the "listApplications" D-Bus method.
- */
-static gboolean app_launcher_handle_list_applications(applaunchdAppLaunch *object,
- GDBusMethodInvocation *invocation,
- gboolean graphical)
-{
- GVariant *result = NULL;
- AppLauncher *self = APPLAUNCHD_APP_LAUNCHER(object);
- g_return_val_if_fail(APPLAUNCHD_IS_APP_LAUNCHER(self), FALSE);
-
- /* Retrieve the applications list in the right format for sending over D-Bus */
- result = app_launcher_get_list_variant(self);
- if (result)
- applaunchd_app_launch_complete_list_applications(object, invocation, result);
-
- return TRUE;
-}
-
-/*
- * Callback for the "started" signal emitted by both the
- * process manager and D-Bus activation manager. Forwards
- * the signal to other applications through D-Bus.
- */
-static void app_launcher_started_cb(AppLauncher *self,
- const gchar *app_id,
- gpointer caller)
-{
- applaunchdAppLaunch *iface = APPLAUNCHD_APP_LAUNCH(self);
- g_return_if_fail(APPLAUNCHD_IS_APP_LAUNCH(iface));
-
- g_debug("Application '%s' started", app_id);
- /*
- * Emit the "started" D-Bus signal so subscribers get notified
- * the application with ID "app_id" started and should be
- * activated
- */
- applaunchd_app_launch_emit_started(iface, app_id);
-}
-
-/*
- * Callback for the "terminated" signal emitted by both the
- * process manager and D-Bus activation manager. Forwards
- * the signal to other applications through D-Bus.
- */
-static void app_launcher_terminated_cb(AppLauncher *self,
- const gchar *app_id,
- gpointer caller)
-{
- applaunchdAppLaunch *iface = APPLAUNCHD_APP_LAUNCH(self);
- g_return_if_fail(APPLAUNCHD_IS_APP_LAUNCH(iface));
-
- g_debug("Application '%s' terminated", app_id);
- /*
- * Emit the "terminated" D-Bus signal so subscribers get
- * notified the application with ID "app_id" terminated
- */
- applaunchd_app_launch_emit_terminated(iface, app_id);
-}
-
-/*
- * Initialization & cleanup functions
- */
-
-static void app_launcher_dispose(GObject *object)
-{
- AppLauncher *self = APPLAUNCHD_APP_LAUNCHER(object);
-
- g_clear_object(&self->systemd_manager);
-
- G_OBJECT_CLASS(app_launcher_parent_class)->dispose(object);
-}
-
-static void app_launcher_finalize(GObject *object)
-{
- G_OBJECT_CLASS(app_launcher_parent_class)->finalize(object);
-}
-
-static void app_launcher_class_init(AppLauncherClass *klass)
-{
- GObjectClass *object_class = (GObjectClass *)klass;
-
- object_class->dispose = app_launcher_dispose;
-}
-
-static void app_launcher_iface_init(applaunchdAppLaunchIface *iface)
-{
- iface->handle_start = app_launcher_handle_start;
- iface->handle_list_applications = app_launcher_handle_list_applications;
-}
-
-static void app_launcher_init (AppLauncher *self)
-{
- /*
- * Create the systemd manager and connect to its signals
- * so we get notified on app startup/termination
- */
- self->systemd_manager = systemd_manager_get_default();
- systemd_manager_connect_callbacks(self->systemd_manager,
- G_CALLBACK(app_launcher_started_cb),
- G_CALLBACK(app_launcher_terminated_cb),
- self);
-}
-
-/*
- * Public functions
- */
-
-AppLauncher *app_launcher_get_default(void)
-{
- static AppLauncher *launcher;
-
- /*
- * AppLauncher is a singleton, only create the object if it doesn't
- * exist already.
- */
- if (launcher == NULL) {
- g_debug("Initializing app launcher service...");
- launcher = g_object_new(APPLAUNCHD_TYPE_APP_LAUNCHER, NULL);
- g_object_add_weak_pointer(G_OBJECT(launcher), (gpointer *)&launcher);
- }
-
- return launcher;
-}
diff --git a/src/app_launcher.h b/src/app_launcher.h
deleted file mode 100644
index 3155609..0000000
--- a/src/app_launcher.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// SPDX-License-Identifier: Apache-2.0
-/*
- * Copyright (C) 2021 Collabora Ltd
- * Copyright (C) 2022 Konsulko Group
- */
-
-#ifndef APPLAUNCHER_H
-#define APPLAUNCHER_H
-
-#include <glib-object.h>
-#include <systemd/sd-bus.h>
-#include <systemd/sd-event.h>
-
-#include "applaunch-dbus.h"
-#include "app_info.h"
-
-G_BEGIN_DECLS
-
-#define APPLAUNCHD_TYPE_APP_LAUNCHER app_launcher_get_type()
-
-G_DECLARE_FINAL_TYPE(AppLauncher, app_launcher, APPLAUNCHD, APP_LAUNCHER,
- applaunchdAppLaunchSkeleton);
-
-AppLauncher *app_launcher_get_default(void);
-
-gboolean app_launcher_start_app(AppLauncher *self, AppInfo *app_info);
-
-G_END_DECLS
-
-#endif
diff --git a/src/main.c b/src/main.c
deleted file mode 100644
index 97631f7..0000000
--- a/src/main.c
+++ /dev/null
@@ -1,77 +0,0 @@
-// SPDX-License-Identifier: Apache-2.0
-/*
- * Copyright (C) 2021 Collabora Ltd
- * Copyright (C) 2022 Konsulko Group
- */
-
-#include <glib.h>
-#include <glib-unix.h>
-#include <systemd/sd-bus.h>
-#include <systemd/sd-event.h>
-
-#include "app_launcher.h"
-#include "applaunch-dbus.h"
-
-#define APPLAUNCH_DBUS_NAME "org.automotivelinux.AppLaunch"
-#define APPLAUNCH_DBUS_PATH "/org/automotivelinux/AppLaunch"
-
-GMainLoop *main_loop = NULL;
-
-static gboolean quit_cb(gpointer user_data)
-{
- g_info("Quitting...");
-
- if (main_loop)
- g_idle_add(G_SOURCE_FUNC(g_main_loop_quit), main_loop);
- else
- exit(0);
-
- return G_SOURCE_REMOVE;
-}
-
-static void bus_acquired_cb(GDBusConnection *connection, const gchar *name,
- gpointer user_data)
-{
- AppLauncher *launcher = user_data;
-
- g_debug("Bus acquired, starting service...");
- g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(launcher),
- connection, APPLAUNCH_DBUS_PATH, NULL);
-}
-
-static void name_acquired_cb(GDBusConnection *connection, const gchar *name,
- gpointer user_data)
-{
- g_debug("D-Bus name '%s' was acquired", name);
-}
-
-static void name_lost_cb(GDBusConnection *connection, const gchar *name,
- gpointer user_data)
-{
- g_critical("Lost the '%s' service name, quitting...", name);
- g_main_loop_quit(main_loop);
-}
-
-int main(int argc, char *argv[])
-{
- g_unix_signal_add(SIGTERM, quit_cb, NULL);
- g_unix_signal_add(SIGINT, quit_cb, NULL);
-
- main_loop = g_main_loop_new(NULL, FALSE);
-
- AppLauncher *launcher = app_launcher_get_default();
-
- gint owner_id = g_bus_own_name(G_BUS_TYPE_SESSION, APPLAUNCH_DBUS_NAME,
- G_BUS_NAME_OWNER_FLAGS_NONE, bus_acquired_cb,
- name_acquired_cb, name_lost_cb,
- launcher, NULL);
-
- g_main_loop_run(main_loop);
- g_main_loop_unref(main_loop);
-
- g_object_unref(launcher);
-
- g_bus_unown_name (owner_id);
-
- return 0;
-}
diff --git a/src/meson.build b/src/meson.build
index 4a6f170..791e052 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -17,12 +17,6 @@
cpp = meson.get_compiler('cpp')
grpcpp_reflection_dep = cpp.find_library('grpc++_reflection')
-applaunchd_dbus_deps = [
- dependency('gobject-2.0'),
- dependency('gio-unix-2.0'),
- dependency('libsystemd'),
-]
-
applaunchd_deps = [
dependency('gobject-2.0'),
dependency('gio-unix-2.0'),
@@ -52,28 +46,9 @@ grpc_gen = generator(protoc, \
generated_grpc_sources = grpc_gen.process('../protos/applauncher.proto')
executable (
- 'applaunchd-dbus',
- config_h,
- [
- generated_dbus_sources,
- 'main.c',
- 'app_info.c', 'app_info.h',
- 'app_launcher.c', 'app_launcher.h',
- 'systemd_manager.c', 'systemd_manager.h',
- 'gdbus/systemd1_manager_interface.c',
- 'gdbus/systemd1_unit_interface.c',
- 'utils.c', 'utils.h',
- ],
- dependencies : applaunchd_dbus_deps,
- include_directories : include_directories('.', 'gdbus'),
- install : true
-)
-
-executable (
'applaunchd',
config_h,
[
- generated_dbus_sources,
generated_protoc_sources,
generated_grpc_sources,
'main-grpc.cc',