From 7874bea068f546049f43b046ba819276ffa8515c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 11 Mar 2022 00:35:14 +0100 Subject: [PATCH] dbus-session: Rename client_vanished() to close() This means the MetaDbusSession interface takes a more active role instead of being something that more or less sends signals to the interface implementor. This will allow better control when using MetaDbusSession to manage these sessions, instead of their non-abstract variants. Part-of: --- src/backends/meta-dbus-session-watcher.c | 18 ++++++--------- src/backends/meta-dbus-session-watcher.h | 4 +++- src/backends/meta-remote-desktop-session.c | 27 +++++++++++----------- src/backends/meta-remote-desktop-session.h | 2 -- src/backends/meta-remote-desktop.c | 4 ++-- src/backends/meta-screen-cast-session.c | 19 ++++++--------- src/backends/meta-screen-cast-session.h | 2 -- src/backends/meta-screen-cast.c | 4 ++-- 8 files changed, 34 insertions(+), 46 deletions(-) diff --git a/src/backends/meta-dbus-session-watcher.c b/src/backends/meta-dbus-session-watcher.c index a885b423b..9ebcb3335 100644 --- a/src/backends/meta-dbus-session-watcher.c +++ b/src/backends/meta-dbus-session-watcher.c @@ -57,12 +57,6 @@ typedef struct _MetaDbusSessionClient GList *sessions; } MetaDbusSessionClient; -static void -meta_dbus_session_client_vanished (MetaDbusSession *session) -{ - META_DBUS_SESSION_GET_IFACE (session)->client_vanished (session); -} - static void meta_dbus_session_client_destroy (MetaDbusSessionClient *client) { @@ -77,11 +71,7 @@ meta_dbus_session_client_destroy (MetaDbusSessionClient *client) session = l->data; - /* - * This will invoke on_session_closed which removes the session from the - * list. - */ - meta_dbus_session_client_vanished (session); + meta_dbus_session_close (session); } if (client->name_watcher_id) @@ -235,3 +225,9 @@ meta_dbus_session_watcher_class_init (MetaDbusSessionWatcherClass *klass) object_class->finalize = meta_dbus_session_watcher_finalize; } + +void +meta_dbus_session_close (MetaDbusSession *session) +{ + META_DBUS_SESSION_GET_IFACE (session)->close (session); +} diff --git a/src/backends/meta-dbus-session-watcher.h b/src/backends/meta-dbus-session-watcher.h index 06d3e1ff9..03cd7b33e 100644 --- a/src/backends/meta-dbus-session-watcher.h +++ b/src/backends/meta-dbus-session-watcher.h @@ -34,7 +34,7 @@ struct _MetaDbusSessionInterface { GTypeInterface parent_iface; - void (* client_vanished) (MetaDbusSession *session); + void (* close) (MetaDbusSession *session); }; #define META_TYPE_DBUS_SESSION_WATCHER (meta_dbus_session_watcher_get_type ()) @@ -49,4 +49,6 @@ void meta_dbus_session_watcher_watch_session (MetaDbusSessionWatcher *session_wa void meta_dbus_session_notify_closed (MetaDbusSession *session); +void meta_dbus_session_close (MetaDbusSession *session); + #endif /* META_DBUS_SESSION_WATCHER_H */ diff --git a/src/backends/meta-remote-desktop-session.c b/src/backends/meta-remote-desktop-session.c index f08fd6359..e1303d44a 100644 --- a/src/backends/meta-remote-desktop-session.c +++ b/src/backends/meta-remote-desktop-session.c @@ -207,9 +207,11 @@ meta_remote_desktop_session_start (MetaRemoteDesktopSession *session, return TRUE; } -void -meta_remote_desktop_session_close (MetaRemoteDesktopSession *session) +static void +meta_remote_desktop_session_close (MetaDbusSession *dbus_session) { + MetaRemoteDesktopSession *session = + META_REMOTE_DESKTOP_SESSION (dbus_session); MetaDBusRemoteDesktopSession *skeleton = META_DBUS_REMOTE_DESKTOP_SESSION (session); @@ -217,9 +219,12 @@ meta_remote_desktop_session_close (MetaRemoteDesktopSession *session) if (session->screen_cast_session) { + MetaDbusSession *screen_cast_session = + META_DBUS_SESSION (session->screen_cast_session); + g_clear_signal_handler (&session->screen_cast_session_closed_handler_id, session->screen_cast_session); - meta_screen_cast_session_close (session->screen_cast_session); + meta_dbus_session_close (screen_cast_session); session->screen_cast_session = NULL; } @@ -259,7 +264,7 @@ on_screen_cast_session_closed (MetaScreenCastSession *screen_cast_session, MetaRemoteDesktopSession *session) { session->screen_cast_session = NULL; - meta_remote_desktop_session_close (session); + meta_dbus_session_close (META_DBUS_SESSION (session)); } gboolean @@ -384,7 +389,7 @@ handle_start (MetaDBusRemoteDesktopSession *skeleton, error->message); g_error_free (error); - meta_remote_desktop_session_close (session); + meta_dbus_session_close (META_DBUS_SESSION (session)); return TRUE; } @@ -416,7 +421,7 @@ handle_stop (MetaDBusRemoteDesktopSession *skeleton, return TRUE; } - meta_remote_desktop_session_close (session); + meta_dbus_session_close (META_DBUS_SESSION (session)); meta_dbus_remote_desktop_session_complete_stop (skeleton, invocation); @@ -1675,16 +1680,10 @@ meta_remote_desktop_session_init_iface (MetaDBusRemoteDesktopSessionIface *iface iface->handle_selection_read = handle_selection_read; } -static void -meta_remote_desktop_session_client_vanished (MetaDbusSession *dbus_session) -{ - meta_remote_desktop_session_close (META_REMOTE_DESKTOP_SESSION (dbus_session)); -} - static void meta_dbus_session_init_iface (MetaDbusSessionInterface *iface) { - iface->client_vanished = meta_remote_desktop_session_client_vanished; + iface->close = meta_remote_desktop_session_close; } static void @@ -1759,7 +1758,7 @@ meta_remote_desktop_session_handle_stop (MetaRemoteAccessHandle *handle) if (!session) return; - meta_remote_desktop_session_close (session); + meta_dbus_session_close (META_DBUS_SESSION (session)); } static void diff --git a/src/backends/meta-remote-desktop-session.h b/src/backends/meta-remote-desktop-session.h index 7af9c4897..dec331bd2 100644 --- a/src/backends/meta-remote-desktop-session.h +++ b/src/backends/meta-remote-desktop-session.h @@ -51,8 +51,6 @@ void meta_remote_desktop_session_request_transfer (MetaRemoteDesktopSession *se const char *mime_type, GTask *task); -void meta_remote_desktop_session_close (MetaRemoteDesktopSession *session); - MetaRemoteDesktopSession * meta_remote_desktop_session_new (MetaRemoteDesktop *remote_desktop, const char *peer_name, GError **error); diff --git a/src/backends/meta-remote-desktop.c b/src/backends/meta-remote-desktop.c index 0ad4d7508..1174a78b7 100644 --- a/src/backends/meta-remote-desktop.c +++ b/src/backends/meta-remote-desktop.c @@ -88,7 +88,7 @@ meta_remote_desktop_inhibit (MetaRemoteDesktop *remote_desktop) MetaRemoteDesktopSession *session = value; g_hash_table_iter_steal (&iter); - meta_remote_desktop_session_close (session); + meta_dbus_session_close (META_DBUS_SESSION (session)); } } } @@ -262,7 +262,7 @@ on_prepare_shutdown (MetaBackend *backend, MetaRemoteDesktopSession *session = value; g_hash_table_iter_steal (&iter); - meta_remote_desktop_session_close (session); + meta_dbus_session_close (META_DBUS_SESSION (session)); } } diff --git a/src/backends/meta-screen-cast-session.c b/src/backends/meta-screen-cast-session.c index 16077880b..a9b0757a5 100644 --- a/src/backends/meta-screen-cast-session.c +++ b/src/backends/meta-screen-cast-session.c @@ -130,9 +130,10 @@ meta_screen_cast_session_is_active (MetaScreenCastSession *session) return session->is_active; } -void -meta_screen_cast_session_close (MetaScreenCastSession *session) +static void +meta_screen_cast_session_close (MetaDbusSession *dbus_session) { + MetaScreenCastSession *session = META_SCREEN_CAST_SESSION (dbus_session); MetaDBusScreenCastSession *skeleton = META_DBUS_SCREEN_CAST_SESSION (session); session->is_active = FALSE; @@ -287,7 +288,7 @@ handle_stop (MetaDBusScreenCastSession *skeleton, return TRUE; } - meta_screen_cast_session_close (session); + meta_dbus_session_close (META_DBUS_SESSION (session)); meta_dbus_screen_cast_session_complete_stop (skeleton, invocation); @@ -298,7 +299,7 @@ static void on_stream_closed (MetaScreenCastStream *stream, MetaScreenCastSession *session) { - meta_screen_cast_session_close (session); + meta_dbus_session_close (META_DBUS_SESSION (session)); } static gboolean @@ -710,16 +711,10 @@ meta_screen_cast_session_init_iface (MetaDBusScreenCastSessionIface *iface) iface->handle_record_virtual = handle_record_virtual; } -static void -meta_screen_cast_session_client_vanished (MetaDbusSession *dbus_session) -{ - meta_screen_cast_session_close (META_SCREEN_CAST_SESSION (dbus_session)); -} - static void meta_dbus_session_init_iface (MetaDbusSessionInterface *iface) { - iface->client_vanished = meta_screen_cast_session_client_vanished; + iface->close = meta_screen_cast_session_close; } MetaScreenCastSession * @@ -822,7 +817,7 @@ meta_screen_cast_session_handle_stop (MetaRemoteAccessHandle *handle) if (!session) return; - meta_screen_cast_session_close (session); + meta_dbus_session_close (META_DBUS_SESSION (session)); } static void diff --git a/src/backends/meta-screen-cast-session.h b/src/backends/meta-screen-cast-session.h index d9c3d0ecc..e65bad7e6 100644 --- a/src/backends/meta-screen-cast-session.h +++ b/src/backends/meta-screen-cast-session.h @@ -61,8 +61,6 @@ gboolean meta_screen_cast_session_start (MetaScreenCastSession *session, gboolean meta_screen_cast_session_is_active (MetaScreenCastSession *session); -void meta_screen_cast_session_close (MetaScreenCastSession *session); - MetaScreenCastStream * meta_screen_cast_session_get_stream (MetaScreenCastSession *session, const char *path); diff --git a/src/backends/meta-screen-cast.c b/src/backends/meta-screen-cast.c index 1376cbbc9..41c11556f 100644 --- a/src/backends/meta-screen-cast.c +++ b/src/backends/meta-screen-cast.c @@ -68,7 +68,7 @@ meta_screen_cast_inhibit (MetaScreenCast *screen_cast) { MetaScreenCastSession *session = screen_cast->sessions->data; - meta_screen_cast_session_close (session); + meta_dbus_session_close (META_DBUS_SESSION (session)); } } } @@ -338,7 +338,7 @@ on_prepare_shutdown (MetaBackend *backend, if (meta_screen_cast_session_get_session_type (session) != META_SCREEN_CAST_SESSION_TYPE_REMOTE_DESKTOP) - meta_screen_cast_session_close (session); + meta_dbus_session_close (META_DBUS_SESSION (session)); } }