From 921b18f7131342c1d90dc94db073b263cf53afed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 15 Aug 2017 15:25:09 +0800 Subject: [PATCH] screen-cast-session: Allow stand alone screen cast sessions When a screen cast session is stand-alone, i.e. not created given a remote desktop session managing it, allow calling the Start/Stop methods to start and stop it. https://bugzilla.gnome.org/show_bug.cgi?id=784199 --- src/backends/meta-screen-cast-session.c | 48 +++++++++++++++++++++---- 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/src/backends/meta-screen-cast-session.c b/src/backends/meta-screen-cast-session.c index e53f78dc5..907e645e3 100644 --- a/src/backends/meta-screen-cast-session.c +++ b/src/backends/meta-screen-cast-session.c @@ -105,9 +105,32 @@ static gboolean handle_start (MetaDBusScreenCastSession *skeleton, GDBusMethodInvocation *invocation) { - g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, - G_DBUS_ERROR_FAILED, - "Stand alone screen casting not yet implemented"); + MetaScreenCastSession *session = META_SCREEN_CAST_SESSION (skeleton); + GError *error = NULL; + + switch (session->session_type) + { + case META_SCREEN_CAST_SESSION_TYPE_NORMAL: + break; + case META_SCREEN_CAST_SESSION_TYPE_REMOTE_DESKTOP: + g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, + G_DBUS_ERROR_FAILED, + "Must be started from remote desktop session"); + return TRUE; + } + + if (!meta_screen_cast_session_start (session, &error)) + { + g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, + G_DBUS_ERROR_FAILED, + "Failed to start screen cast: %s", + error->message); + g_error_free (error); + + return TRUE; + } + + meta_dbus_screen_cast_session_complete_start (skeleton, invocation); return TRUE; } @@ -116,9 +139,22 @@ static gboolean handle_stop (MetaDBusScreenCastSession *skeleton, GDBusMethodInvocation *invocation) { - g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, - G_DBUS_ERROR_FAILED, - "Stand alone screen casting not yet implemented"); + MetaScreenCastSession *session = META_SCREEN_CAST_SESSION (skeleton); + + switch (session->session_type) + { + case META_SCREEN_CAST_SESSION_TYPE_NORMAL: + break; + case META_SCREEN_CAST_SESSION_TYPE_REMOTE_DESKTOP: + g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, + G_DBUS_ERROR_FAILED, + "Must be stopped from remote desktop session"); + return TRUE; + } + + meta_screen_cast_session_close (session); + + meta_dbus_screen_cast_session_complete_stop (skeleton, invocation); return TRUE; }