diff --git a/src/calls-application.c b/src/calls-application.c index 50b3ac3..7e16ed1 100644 --- a/src/calls-application.c +++ b/src/calls-application.c @@ -34,7 +34,6 @@ #include "calls-call-window.h" #include "calls-main-window.h" #include "calls-application.h" -#include "session.h" #define HANDY_USE_UNSTABLE_API #include @@ -403,8 +402,6 @@ constructed (GObject *object) actions, G_N_ELEMENTS (actions), self); g_object_unref (action_group); - calls_session_register (APP_ID); - parent_class->constructed (object); } @@ -414,8 +411,6 @@ dispose (GObject *object) { CallsApplication *self = (CallsApplication *)object; - calls_session_unregister (); - g_clear_object (&self->call_window); g_clear_object (&self->main_window); g_clear_object (&self->record_store); @@ -496,5 +491,6 @@ calls_application_new (void) return g_object_new (CALLS_TYPE_APPLICATION, "application-id", APP_ID, "flags", G_APPLICATION_HANDLES_OPEN, + "register-session", TRUE, NULL); } diff --git a/src/meson.build b/src/meson.build index 4b712af..9216028 100644 --- a/src/meson.build +++ b/src/meson.build @@ -56,7 +56,6 @@ calls_sources = files(['calls-message-source.c', 'calls-message-source.h', 'calls-call-record.c', 'calls-call-record.h', 'calls-record-store.c', 'calls-record-store.h', 'calls-call-record-row.c', 'calls-call-record-row.h', - 'session.c', 'session.h', ]) calls_config_data = config_data diff --git a/src/session.c b/src/session.c deleted file mode 100644 index 60d4cfa..0000000 --- a/src/session.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 2018, 2019 Purism SPC - * SPDX-License-Identifier: GPL-3.0+ - * Author: Guido Günther - * - * Copied from phosh and modified for Calls - * by Bob Ham - * - * Based on code from gnome-settings-daemon - */ - -#define G_LOG_DOMAIN "calls-session" - -#include "session.h" - -#include -#include - -#define GNOME_SESSION_DBUS_NAME "org.gnome.SessionManager" -#define GNOME_SESSION_DBUS_OBJECT "/org/gnome/SessionManager" -#define GNOME_SESSION_DBUS_INTERFACE "org.gnome.SessionManager" -#define GNOME_SESSION_CLIENT_PRIVATE_DBUS_INTERFACE "org.gnome.SessionManager.ClientPrivate" - -static GDBusProxy *_proxy; - - -static void -respond_to_end_session (GDBusProxy *proxy) -{ - /* we must answer with "EndSessionResponse" */ - g_dbus_proxy_call (proxy, "EndSessionResponse", - g_variant_new ("(bs)", TRUE, ""), - G_DBUS_CALL_FLAGS_NONE, - -1, NULL, NULL, NULL); -} - - -static void -do_stop (void) -{ - gtk_main_quit (); -} - - -static void -client_proxy_signal_cb (GDBusProxy *proxy, - gchar *sender_name, - gchar *signal_name, - GVariant *parameters, - gpointer user_data) -{ - if (g_strcmp0 (signal_name, "QueryEndSession") == 0) { - g_debug ("Got QueryEndSession signal"); - respond_to_end_session (proxy); - } else if (g_strcmp0 (signal_name, "EndSession") == 0) { - g_debug ("Got EndSession signal"); - respond_to_end_session (proxy); - } else if (g_strcmp0 (signal_name, "Stop") == 0) { - g_debug ("Got Stop signal"); - do_stop (); - } -} - - -static void -on_client_registered (GObject *source_object, - GAsyncResult *res, - gpointer user_data) -{ - GVariant *variant; - GDBusProxy *client_proxy; - GError *error = NULL; - gchar *object_path = NULL; - - variant = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, &error); - if (!variant) { - g_warning ("Unable to register client: %s", error->message); - g_error_free (error); - return; - } - - g_variant_get (variant, "(o)", &object_path); - - g_debug ("Registered client at path %s", object_path); - - client_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, 0, NULL, - GNOME_SESSION_DBUS_NAME, - object_path, - GNOME_SESSION_CLIENT_PRIVATE_DBUS_INTERFACE, - NULL, - &error); - if (!client_proxy) { - g_warning ("Unable to get the session client proxy: %s", error->message); - g_error_free (error); - return; - } - - g_signal_connect (client_proxy, "g-signal", - G_CALLBACK (client_proxy_signal_cb), NULL); - - g_free (object_path); - g_variant_unref (variant); -} - - -void -calls_session_register (const char *client_id) -{ - const char *startup_id; - GError *err = NULL; - - if (!_proxy) { - _proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, - G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | - G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START_AT_CONSTRUCTION, - NULL, - GNOME_SESSION_DBUS_NAME, - GNOME_SESSION_DBUS_OBJECT, - GNOME_SESSION_DBUS_INTERFACE, - NULL, - &err); - if (!_proxy) { - g_debug ("Failed to contact gnome-session: %s", err->message); - g_clear_error (&err); - return; - } - }; - - startup_id = g_getenv ("DESKTOP_AUTOSTART_ID"); - g_dbus_proxy_call (_proxy, - "RegisterClient", - g_variant_new ("(ss)", client_id, startup_id ? startup_id : ""), - G_DBUS_CALL_FLAGS_NONE, - -1, - NULL, - (GAsyncReadyCallback) on_client_registered, - NULL); -} - - -void -calls_session_unregister (void) -{ - g_clear_object (&_proxy); -} diff --git a/src/session.h b/src/session.h deleted file mode 100644 index c1717e9..0000000 --- a/src/session.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (C) 2018, 2019 Purism SPC - * SPDX-License-Identifier: GPL-3.0+ - * Author: Guido Günther - * - * Copied from phosh and modified for Calls - * by Bob Ham - */ - -#pragma once - -#include - -void calls_session_register (const char *client_id); -void calls_session_unregister (void);