[Spice-devel,spice-gtk,2/3] Add a desktop-integration helper class

Submitted by Hans de Goede on June 13, 2012, 5:07 p.m.

Details

Message ID 1339607243-2344-2-git-send-email-hdegoede@redhat.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Hans de Goede June 13, 2012, 5:07 p.m.
We need to integrate closely with the desktop environment of the user in
several cases. Some examples are disabling auto-mounting when auto-usbredir
is active (rhbz#812972), and disabling the screensaver when fullscreen
(fdo#34793).

Unfortuntely these kinds of things require desktop environment specific
handling. Therefor this patch introduces a desktop-integration helper class,
which is to server as a container for all sort of desktop environment specific
functions.

For now it just supports disabling automounting under Gnome-3, another patch
extending it to also support disabling automounting under Gnome-2 is in the
pipeline.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 configure.ac              |   20 +++++
 gtk/Makefile.am           |    2 +
 gtk/desktop-integration.c |  196 +++++++++++++++++++++++++++++++++++++++++++++
 gtk/desktop-integration.h |   64 +++++++++++++++
 gtk/spice-session-priv.h  |    2 +
 gtk/spice-session.c       |    1 +
 6 files changed, 285 insertions(+)
 create mode 100644 gtk/desktop-integration.c
 create mode 100644 gtk/desktop-integration.h

Patch hide | download patch | download mbox

diff --git a/configure.ac b/configure.ac
index 09129b7..ade3649 100644
--- a/configure.ac
+++ b/configure.ac
@@ -566,6 +566,26 @@  fi
 
 AM_CONDITIONAL(WITH_PYTHON, [test "$WITH_PYTHON" = "yes"])
 
+
+AC_ARG_ENABLE([gsettings],
+  AS_HELP_STRING([--enable-gsettings=@<:@auto/yes/no@:>@],
+                 [Enable gsettings/gnome3 support for disabling automount @<:@default=auto@:>@]),
+  [],
+  [enable_gsettings="auto"])
+
+if test "x$enable_gsettings" != "xno"; then
+  PKG_CHECK_MODULES([GSETTINGS], [glib-2.0 >= 2.26],
+                                 [have_gsettings=yes],
+                                 [have_gsettings=no])
+  if test "x$enable_gsettings" = "xyes" && test "x$have_gsettings" = "xno"; then
+    AC_MSG_ERROR([GSettings support explicitly requested, but some required packages are not available])
+  fi
+
+  if test "x$have_gsettings" = "xyes"; then
+    AC_DEFINE(USE_GSETTINGS, [1], [Define if supporting gsettings])
+  fi
+fi
+
 dnl ===========================================================================
 dnl check compiler flags
 
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 0327d65..c146601 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -226,6 +226,8 @@  libspice_client_glib_2_0_la_SOURCES =			\
 	channel-smartcard.c				\
 	channel-usbredir.c				\
 	channel-usbredir-priv.h				\
+	desktop-integration.c				\
+	desktop-integration.h				\
 	smartcard-manager.c				\
 	smartcard-manager-priv.h			\
 	usb-device-manager.c				\
diff --git a/gtk/desktop-integration.c b/gtk/desktop-integration.c
new file mode 100644
index 0000000..d948179
--- /dev/null
+++ b/gtk/desktop-integration.c
@@ -0,0 +1,196 @@ 
+/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+   Copyright (C) 2012 Red Hat, Inc.
+
+   Red Hat Authors:
+   Hans de Goede <hdegoede@redhat.com>
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "config.h"
+
+#include <glib-object.h>
+#include <glib/gi18n.h>
+#include "glib-compat.h"
+#include "spice-session-priv.h"
+#include "desktop-integration.h"
+
+/* ------------------------------------------------------------------ */
+/* gobject glue                                                       */
+
+#define SPICE_DESKTOP_INTEGRATION_GET_PRIVATE(obj)                                  \
+    (G_TYPE_INSTANCE_GET_PRIVATE ((obj), SPICE_TYPE_DESKTOP_INTEGRATION, SpiceDesktopIntegrationPrivate))
+
+struct _SpiceDesktopIntegrationPrivate {
+#ifdef USE_GSETTINGS
+    struct {
+        GSettings *media_hdl;
+        gboolean initial_automount;
+        gboolean current_automount;
+    } gnome3;
+#else
+    gint dummy;
+#endif
+};
+
+G_DEFINE_TYPE(SpiceDesktopIntegration, spice_desktop_integration, G_TYPE_OBJECT);
+
+/* ------------------------------------------------------------------ */
+/* Gnome3 specific code                                               */
+
+#ifdef USE_GSETTINGS
+static void gnome3_integration_init(SpiceDesktopIntegration *self)
+{
+    SpiceDesktopIntegrationPrivate *priv = self->priv;
+    const gchar * const *schemas;
+    static gsize initial_automount = 0;
+
+    schemas = g_settings_list_schemas();
+    while (*schemas) {
+        if (strcmp(*schemas, "org.gnome.desktop.media-handling") == 0)
+            break;
+        schemas++;
+    }
+
+    if (*schemas == NULL)
+        return;
+
+    self->priv->gnome3.media_hdl = g_settings_new(*schemas);
+    if (g_once_init_enter(&initial_automount)) {
+        gsize init;
+        if (g_settings_get_boolean(self->priv->gnome3.media_hdl, "automount"))
+            init = 1;
+        else
+            init = -1;
+        g_once_init_leave(&initial_automount, init);
+    }
+    priv->gnome3.initial_automount = (initial_automount == 1) ? TRUE : FALSE;
+    priv->gnome3.current_automount = priv->gnome3.initial_automount;
+}
+
+static void gnome3_integration_finalize(SpiceDesktopIntegration *self)
+{
+    g_clear_object(&self->priv->gnome3.media_hdl);
+}
+
+static void gnome3_integration_disable_automount(SpiceDesktopIntegration *self)
+{
+    SpiceDesktopIntegrationPrivate *priv = self->priv;
+
+    if (priv->gnome3.current_automount) {
+        if (g_settings_set_boolean(priv->gnome3.media_hdl, "automount", FALSE)) {
+            g_settings_sync();
+            priv->gnome3.current_automount = FALSE;
+        }
+    }
+}
+
+static void gnome3_integration_restore_automount(SpiceDesktopIntegration *self)
+{
+    SpiceDesktopIntegrationPrivate *priv = self->priv;
+
+    if (priv->gnome3.current_automount != priv->gnome3.initial_automount) {
+        if (g_settings_set_boolean(priv->gnome3.media_hdl, "automount",
+                                   priv->gnome3.initial_automount)) {
+            priv->gnome3.current_automount = priv->gnome3.initial_automount;
+        }
+    }
+}
+
+#endif
+
+/* ------------------------------------------------------------------ */
+/* gobject glue                                                       */
+
+static void spice_desktop_integration_init(SpiceDesktopIntegration *self)
+{
+    SpiceDesktopIntegrationPrivate *priv;
+
+    priv = SPICE_DESKTOP_INTEGRATION_GET_PRIVATE(self);
+    self->priv = priv;
+
+#ifdef USE_GSETTINGS
+    gnome3_integration_init(self);
+#endif
+}
+
+static void spice_desktop_integration_dispose(GObject *gobject)
+{
+    SpiceDesktopIntegration *self = SPICE_DESKTOP_INTEGRATION(gobject);
+
+    spice_desktop_integration_restore_automount(self);
+
+    /* Chain up to the parent class */
+    if (G_OBJECT_CLASS(spice_desktop_integration_parent_class)->dispose)
+        G_OBJECT_CLASS(spice_desktop_integration_parent_class)->dispose(gobject);
+}
+
+static void spice_desktop_integration_finalize(GObject *gobject)
+{
+    SpiceDesktopIntegration *self = SPICE_DESKTOP_INTEGRATION(gobject);
+
+#ifdef USE_GSETTINGS
+    gnome3_integration_finalize(self);
+#endif
+
+    /* Chain up to the parent class */
+    if (G_OBJECT_CLASS(spice_desktop_integration_parent_class)->finalize)
+        G_OBJECT_CLASS(spice_desktop_integration_parent_class)->finalize(gobject);
+}
+
+static void spice_desktop_integration_class_init(SpiceDesktopIntegrationClass *klass)
+{
+    GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+    gobject_class->dispose      = spice_desktop_integration_dispose;
+    gobject_class->finalize     = spice_desktop_integration_finalize;
+
+    g_type_class_add_private(klass, sizeof(SpiceDesktopIntegrationPrivate));
+}
+
+/* ------------------------------------------------------------------ */
+/* public methods                                                     */
+
+SpiceDesktopIntegration *spice_desktop_integration_get(SpiceSession *session)
+{
+    SpiceDesktopIntegration *self;
+    static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
+
+    g_return_val_if_fail(session != NULL, NULL);
+
+    g_static_mutex_lock(&mutex);
+    self = session->priv->desktop_integration;
+    if (self == NULL) {
+        self = g_object_new(SPICE_TYPE_DESKTOP_INTEGRATION, NULL);
+        session->priv->desktop_integration = self;
+    }
+    g_static_mutex_unlock(&mutex);
+
+    return self;
+}
+
+void spice_desktop_integration_disable_automount(SpiceDesktopIntegration *self)
+{
+#ifdef USE_GSETTINGS
+    gnome3_integration_disable_automount(self);
+#endif
+}
+
+void spice_desktop_integration_restore_automount(SpiceDesktopIntegration *self)
+{
+#ifdef USE_GSETTINGS
+    gnome3_integration_restore_automount(self);
+#endif
+}
diff --git a/gtk/desktop-integration.h b/gtk/desktop-integration.h
new file mode 100644
index 0000000..6780310
--- /dev/null
+++ b/gtk/desktop-integration.h
@@ -0,0 +1,64 @@ 
+/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+   Copyright (C) 2012 Red Hat, Inc.
+
+   Red Hat Authors:
+   Hans de Goede <hdegoede@redhat.com>
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef __SPICE_DESKTOP_INTEGRATION_H__
+#define __SPICE_DESKTOP_INTEGRATION_H__
+
+#include "spice-client.h"
+
+G_BEGIN_DECLS
+
+#define SPICE_TYPE_DESKTOP_INTEGRATION            (spice_desktop_integration_get_type ())
+#define SPICE_DESKTOP_INTEGRATION(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPICE_TYPE_DESKTOP_INTEGRATION, SpiceDesktopIntegration))
+#define SPICE_DESKTOP_INTEGRATION_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), SPICE_TYPE_DESKTOP_INTEGRATION, SpiceDesktopIntegrationClass))
+#define SPICE_IS_DESKTOP_INTEGRATION(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SPICE_TYPE_DESKTOP_INTEGRATION))
+#define SPICE_IS_DESKTOP_INTEGRATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SPICE_TYPE_DESKTOP_INTEGRATION))
+#define SPICE_DESKTOP_INTEGRATION_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), SPICE_TYPE_DESKTOP_INTEGRATION, SpiceDesktopIntegrationClass))
+
+typedef struct _SpiceDesktopIntegration SpiceDesktopIntegration;
+typedef struct _SpiceDesktopIntegrationClass SpiceDesktopIntegrationClass;
+typedef struct _SpiceDesktopIntegrationPrivate SpiceDesktopIntegrationPrivate;
+
+/*
+ * SpiceDesktopIntegration offers helper-functions to do desktop environment
+ * and/or platform specific tasks like disabling automount, disabling the
+ * screen-saver, etc. SpiceDesktopIntegration is for internal spice-gtk usage
+ * only!
+ */
+struct _SpiceDesktopIntegration
+{
+    GObject parent;
+
+    SpiceDesktopIntegrationPrivate *priv;
+};
+
+struct _SpiceDesktopIntegrationClass
+{
+    GObjectClass parent_class;
+};
+
+GType spice_desktop_integration_get_type(void);
+SpiceDesktopIntegration *spice_desktop_integration_get(SpiceSession *session);
+void spice_desktop_integration_disable_automount(SpiceDesktopIntegration *);
+void spice_desktop_integration_restore_automount(SpiceDesktopIntegration *);
+
+G_END_DECLS
+
+#endif /* __SPICE_DESKTOP_INTEGRATION_H__ */
diff --git a/gtk/spice-session-priv.h b/gtk/spice-session-priv.h
index 5cef264..c24ef8e 100644
--- a/gtk/spice-session-priv.h
+++ b/gtk/spice-session-priv.h
@@ -20,6 +20,7 @@ 
 
 #include <glib.h>
 #include <gio/gio.h>
+#include "desktop-integration.h"
 #include "spice-session.h"
 #include "spice-gtk-session.h"
 #include "spice-channel-cache.h"
@@ -97,6 +98,7 @@  struct _SpiceSessionPrivate {
 
     /* associated objects */
     SpiceAudio        *audio_manager;
+    SpiceDesktopIntegration *desktop_integration;
     SpiceGtkSession   *gtk_session;
     SpiceUsbDeviceManager *usb_manager;
 };
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index fface67..995b2ed 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -155,6 +155,7 @@  spice_session_dispose(GObject *gobject)
     }
 
     g_clear_object(&s->audio_manager);
+    g_clear_object(&s->desktop_integration);
     g_clear_object(&s->gtk_session);
     g_clear_object(&s->usb_manager);
 

Comments

Hi


On Wed, Jun 13, 2012 at 7:07 PM, Hans de Goede <hdegoede@redhat.com> wrote:
> We need to integrate closely with the desktop environment of the user in
> several cases. Some examples are disabling auto-mounting when auto-usbredir
> is active (rhbz#812972), and disabling the screensaver when fullscreen
> (fdo#34793).
>
> Unfortuntely these kinds of things require desktop environment specific
> handling. Therefor this patch introduces a desktop-integration helper class,
> which is to server as a container for all sort of desktop environment specific
> functions.
>
> For now it just supports disabling automounting under Gnome-3, another patch
> extending it to also support disabling automounting under Gnome-2 is in the
> pipeline.

Looks reasonable to me, however, I don't see why it should be in
spice-glib, since it's very much desktop related. Wouldn't it make
more sense in spice-gtk? Since it's not directly dependent and related
to a particular spice session, it could perhaps even be a separate
library (although for now, a few extra functions and dependency in
spice-gtk is surely fine).
Hi,

On 06/14/2012 12:05 AM, Marc-André Lureau wrote:
> Hi
>
>
> On Wed, Jun 13, 2012 at 7:07 PM, Hans de Goede <hdegoede@redhat.com> wrote:
>> We need to integrate closely with the desktop environment of the user in
>> several cases. Some examples are disabling auto-mounting when auto-usbredir
>> is active (rhbz#812972), and disabling the screensaver when fullscreen
>> (fdo#34793).
>>
>> Unfortuntely these kinds of things require desktop environment specific
>> handling. Therefor this patch introduces a desktop-integration helper class,
>> which is to server as a container for all sort of desktop environment specific
>> functions.
>>
>> For now it just supports disabling automounting under Gnome-3, another patch
>> extending it to also support disabling automounting under Gnome-2 is in the
>> pipeline.
>
> Looks reasonable to me, however, I don't see why it should be in
> spice-glib, since it's very much desktop related.  Wouldn't it make
 > more sense in spice-gtk?

I actually put it in spice-gtk at first, but that does not work very well
because usb-device-manager needs access to the automount disable functionality.

 > Since it's not directly dependent and related
> to a particular spice session, it could perhaps even be a separate
> library (although for now, a few extra functions and dependency in
> spice-gtk is surely fine).

There is various state inside, which needs to be coupled to some object,
using the session for this seems best.

Regards,

Hans
Hi

----- Mensaje original -----
> > Looks reasonable to me, however, I don't see why it should be in
> > spice-glib, since it's very much desktop related.  Wouldn't it make
>  > more sense in spice-gtk?
> 
> I actually put it in spice-gtk at first, but that does not work very
> well
> because usb-device-manager needs access to the automount disable
> functionality.

Ok
 
>  > Since it's not directly dependent and related
> > to a particular spice session, it could perhaps even be a separate
> > library (although for now, a few extra functions and dependency in
> > spice-gtk is surely fine).
> 
> There is various state inside, which needs to be coupled to some
> object,
> using the session for this seems best.

Except setting/getting its own SpiceDesktopIntegration *desktop_integration; what does it need from SpiceSession? If I understand correctly, the changes made by desktop-integration are session-wide, so why having a 1-1 relation with each spice session?
Hi,

On 06/14/2012 11:28 AM, Marc-André Lureau wrote:
> Hi
>
> ----- Mensaje original -----
>>> Looks reasonable to me, however, I don't see why it should be in
>>> spice-glib, since it's very much desktop related.  Wouldn't it make
>>> more sense in spice-gtk?
>>
>> I actually put it in spice-gtk at first, but that does not work very
>> well because usb-device-manager needs access to the automount disable
>> functionality.
>
> Ok
>
>>> Since it's not directly dependent and related
>>> to a particular spice session, it could perhaps even be a separate
>>> library (although for now, a few extra functions and dependency in
>>> spice-gtk is surely fine).
>>
>> There is various state inside, which needs to be coupled to some
>> object, using the session for this seems best.
>
> Except setting/getting its own SpiceDesktopIntegration *desktop_integration; what does it need from SpiceSession?

Nothing.

> If I understand correctly, the changes made by desktop-integration are session-wide

Correct.

> so why having a 1-1 relation with each spice session?

We also need to undo the changes at some point in time, iow the desktop-integration objects
lifetime needs to be coupled to *something*, and spice-session seems best for this. IE,
think usage in python from virt-manager, when the vm viewing window is closed (which does
not necessarily end the virt-manager process) we want to restore the settings.

Regards,

Hans
Hi

----- Mensaje original -----
> > so why having a 1-1 relation with each spice session?
> 
> We also need to undo the changes at some point in time, iow the
> desktop-integration objects
> lifetime needs to be coupled to *something*, and spice-session seems
> best for this. IE,
> think usage in python from virt-manager, when the vm viewing window
> is closed (which does
> not necessarily end the virt-manager process) we want to restore the
> settings.

But we can have simultaneous Spice sessions in the same process or in the same desktop session..

Also, changing the user settings looks like the wrong approach. Perhaps something similar to screensaver Inhibit on org.gnome.SessionManager is needed?
Hi,

On 06/14/2012 02:43 PM, Marc-André Lureau wrote:
> Hi
>
> ----- Mensaje original -----
>>> so why having a 1-1 relation with each spice session?
>>
>> We also need to undo the changes at some point in time, iow the
>> desktop-integration objects
>> lifetime needs to be coupled to *something*, and spice-session seems
>> best for this. IE,
>> think usage in python from virt-manager, when the vm viewing window
>> is closed (which does
>> not necessarily end the virt-manager process) we want to restore the
>> settings.
>
> But we can have simultaneous Spice sessions in the same process or in the same desktop session..
>
> Also, changing the user settings looks like the wrong approach. Perhaps something similar to screensaver Inhibit on org.gnome.SessionManager is needed?

Something like screensaver Inhibit on org.gnome.SessionManager would be ideal,
but that won't help us with RHEL-6 (gnome-2), kde / xfce / etc. Also I'm afraid
that the same may apply to the screensaver stuff (inhibit not supported
everywhere).

One possible idea would be the following:
-we add a /usr/libexec/spice-gtk-<arch>/spice-desktop-integration executable,
  which listens on a unix socket under $HOME
-that process controls disabling / enabling automount, screensaver, etc.
-one or more spice-gtk sessions can give it (un)inhibit-automount commands,
  when inhibiting the spice-gtk sessions must keep the unix socket open, closing
  it is an automatic uninhibit.
-this process gets started the first time it is needed, and exits when the
  session dbus goes away

Regards,

Hans
Hi,

On 06/14/2012 04:19 PM, Hans de Goede wrote:
> Hi,
>
> On 06/14/2012 02:43 PM, Marc-André Lureau wrote:
>> Hi
>>
>> ----- Mensaje original -----
>>>> so why having a 1-1 relation with each spice session?
>>>
>>> We also need to undo the changes at some point in time, iow the
>>> desktop-integration objects
>>> lifetime needs to be coupled to *something*, and spice-session seems
>>> best for this. IE,
>>> think usage in python from virt-manager, when the vm viewing window
>>> is closed (which does
>>> not necessarily end the virt-manager process) we want to restore the
>>> settings.
>>
>> But we can have simultaneous Spice sessions in the same process or in the same desktop session..
>>
>> Also, changing the user settings looks like the wrong approach. Perhaps something similar to screensaver Inhibit on org.gnome.SessionManager is needed?
>
> Something like screensaver Inhibit on org.gnome.SessionManager would be ideal,
> but that won't help us with RHEL-6 (gnome-2), kde / xfce / etc. Also I'm afraid
> that the same may apply to the screensaver stuff (inhibit not supported
> everywhere).
>
> One possible idea would be the following:
> -we add a /usr/libexec/spice-gtk-<arch>/spice-desktop-integration executable,
>   which listens on a unix socket under $HOME
> -that process controls disabling / enabling automount, screensaver, etc.
> -one or more spice-gtk sessions can give it (un)inhibit-automount commands,
>   when inhibiting the spice-gtk sessions must keep the unix socket open, closing
>   it is an automatic uninhibit.
> -this process gets started the first time it is needed, and exits when the
>   session dbus goes away

Scrap that, having thought more about this, I'm going to use udisks inhibit functionality
instead. The downside of that is that it requires root rights, but we can integrate that
into the existing spice-client-glib-usb-acl-helper.

One problem with this approach is that udisks2 seems to lack inhibit functionality ...

Regards,

Hans
Hi,

On 06/15/2012 10:02 AM, Hans de Goede wrote:
> Hi,
>
> On 06/14/2012 04:19 PM, Hans de Goede wrote:
>> Hi,
>>
>> On 06/14/2012 02:43 PM, Marc-André Lureau wrote:
>>> Hi
>>>
>>> ----- Mensaje original -----
>>>>> so why having a 1-1 relation with each spice session?
>>>>
>>>> We also need to undo the changes at some point in time, iow the
>>>> desktop-integration objects
>>>> lifetime needs to be coupled to *something*, and spice-session seems
>>>> best for this. IE,
>>>> think usage in python from virt-manager, when the vm viewing window
>>>> is closed (which does
>>>> not necessarily end the virt-manager process) we want to restore the
>>>> settings.
>>>
>>> But we can have simultaneous Spice sessions in the same process or in the same desktop session..
>>>
>>> Also, changing the user settings looks like the wrong approach. Perhaps something similar to screensaver Inhibit on org.gnome.SessionManager is needed?
>>
>> Something like screensaver Inhibit on org.gnome.SessionManager would be ideal,
>> but that won't help us with RHEL-6 (gnome-2), kde / xfce / etc. Also I'm afraid
>> that the same may apply to the screensaver stuff (inhibit not supported
>> everywhere).
>>
>> One possible idea would be the following:
>> -we add a /usr/libexec/spice-gtk-<arch>/spice-desktop-integration executable,
>>   which listens on a unix socket under $HOME
>> -that process controls disabling / enabling automount, screensaver, etc.
>> -one or more spice-gtk sessions can give it (un)inhibit-automount commands,
>>   when inhibiting the spice-gtk sessions must keep the unix socket open, closing
>>   it is an automatic uninhibit.
>> -this process gets started the first time it is needed, and exits when the
>>   session dbus goes away
>
> Scrap that, having thought more about this, I'm going to use udisks inhibit functionality
> instead. The downside of that is that it requires root rights, but we can integrate that
> into the existing spice-client-glib-usb-acl-helper.

Ok, yet another change of plan, if David Zeuthen agrees I'm going to change udisks, so
that it is possible to do an inhibit which is only valid for the calling UID.

> One problem with this approach is that udisks2 seems to lack inhibit functionality ...

And this I need to discuss with David too.

Regards,

Hans
Hi

----- Mensaje original -----
> > Also, changing the user settings looks like the wrong approach.
> > Perhaps something similar to screensaver Inhibit on
> > org.gnome.SessionManager is needed?
> 
> Something like screensaver Inhibit on org.gnome.SessionManager would
> be ideal,
> but that won't help us with RHEL-6 (gnome-2), kde / xfce / etc. Also

Any solution will probably specific to a desktop, and your patch doesn't seem different since it addresses gnome 3 that we can still modify.

> One possible idea would be the following:
> -we add a /usr/libexec/spice-gtk-<arch>/spice-desktop-integration
> executable,
>   which listens on a unix socket under $HOME
> -that process controls disabling / enabling automount, screensaver,
> etc.

Sounds like you are trying to proxy what should be in gnome-settings-daemon. If another process decides to implement the same thing, they will conflict.

> -one or more spice-gtk sessions can give it (un)inhibit-automount
> commands,
>   when inhibiting the spice-gtk sessions must keep the unix socket
>   open, closing
>   it is an automatic uninhibit.

This kind of connection can be initiated and tracked with dbus.

> -this process gets started the first time it is needed, and exits
> when the
>   session dbus goes away

This is trivial to do thank to dbus service activation.
Hi

----- Mensaje original -----
> Ok, yet another change of plan, if David Zeuthen agrees I'm going to
> change udisks, so
> that it is possible to do an inhibit which is only valid for the
> calling UID.
> 
> > One problem with this approach is that udisks2 seems to lack
> > inhibit functionality ...
> 
> And this I need to discuss with David too.

Cool, I thought about involving him in the discussion too.
Thanks