[gnome-screensaver] Remove inhibit interface



commit 9f742dff30719ea0d5889266c0d0b0a38ceadfe7
Author: William Jon McCann <jmccann redhat com>
Date:   Sat Mar 5 23:44:14 2011 -0500

    Remove inhibit interface
    
    This has been deprecated and handled by gnome-session for the last few releases.

 src/gnome-screensaver-command.c |  151 ----------
 src/gs-listener-dbus.c          |  614 +--------------------------------------
 src/gs-listener-dbus.h          |    1 -
 src/gs-monitor.c                |    4 +-
 4 files changed, 3 insertions(+), 767 deletions(-)
---
diff --git a/src/gnome-screensaver-command.c b/src/gnome-screensaver-command.c
index 92cc880..09da9ab 100644
--- a/src/gnome-screensaver-command.c
+++ b/src/gnome-screensaver-command.c
@@ -48,14 +48,10 @@ static gboolean do_activate   = FALSE;
 static gboolean do_deactivate = FALSE;
 static gboolean do_version    = FALSE;
 static gboolean do_poke       = FALSE;
-static gboolean do_inhibit    = FALSE;
 
 static gboolean do_query      = FALSE;
 static gboolean do_time       = FALSE;
 
-static char    *inhibit_reason      = NULL;
-static char    *inhibit_application = NULL;
-
 static GOptionEntry entries [] = {
         { "exit", 0, 0, G_OPTION_ARG_NONE, &do_quit,
           N_("Causes the screensaver to exit gracefully"), NULL },
@@ -71,12 +67,6 @@ static GOptionEntry entries [] = {
           N_("If the screensaver is active then deactivate it (un-blank the screen)"), NULL },
         { "poke", 'p', 0, G_OPTION_ARG_NONE, &do_poke,
           N_("Poke the running screensaver to simulate user activity"), NULL },
-        { "inhibit", 'i', 0, G_OPTION_ARG_NONE, &do_inhibit,
-          N_("Inhibit the screensaver from activating.  Command blocks while inhibit is active."), NULL },
-        { "application-name", 'n', 0, G_OPTION_ARG_STRING, &inhibit_application,
-          N_("The calling application that is inhibiting the screensaver"), NULL },
-        { "reason", 'r', 0, G_OPTION_ARG_STRING, &inhibit_reason,
-          N_("The reason for inhibiting the screensaver"), NULL },
         { "version", 'V', 0, G_OPTION_ARG_NONE, &do_version,
           N_("Version of this application"), NULL },
         { NULL }
@@ -85,46 +75,6 @@ static GOptionEntry entries [] = {
 static GMainLoop *loop = NULL;
 
 static DBusMessage *
-screensaver_send_message_inhibit (DBusConnection *connection,
-                                  const char     *application,
-                                  const char     *reason)
-{
-        DBusMessage    *message;
-        DBusMessage    *reply;
-        DBusError       error;
-        DBusMessageIter iter;
-
-        g_return_val_if_fail (connection != NULL, NULL);
-
-        dbus_error_init (&error);
-
-        message = dbus_message_new_method_call (GS_SERVICE, GS_PATH, GS_INTERFACE, "Inhibit");
-        if (message == NULL) {
-                g_warning ("Couldn't allocate the dbus message");
-                return NULL;
-        }
-
-        dbus_message_iter_init_append (message, &iter);
-        dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &application);
-        dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &reason);
-
-        reply = dbus_connection_send_with_reply_and_block (connection,
-                                                           message,
-                                                           -1, &error);
-        if (dbus_error_is_set (&error)) {
-                g_warning ("%s raised:\n %s\n\n", error.name, error.message);
-                reply = NULL;
-        }
-
-        dbus_connection_flush (connection);
-
-        dbus_message_unref (message);
-        dbus_error_free (&error);
-
-        return reply;
-}
-
-static DBusMessage *
 screensaver_send_message_bool (DBusConnection *connection,
                                const char     *name,
                                gboolean        value)
@@ -205,67 +155,6 @@ screensaver_send_message_void (DBusConnection *connection,
         return reply;
 }
 
-static char **
-get_string_from_iter (DBusMessageIter *iter,
-                      int             *num_elements)
-{
-        int    count;
-        char **buffer;
-
-        if (num_elements != NULL) {
-                *num_elements = 0;
-        }
-
-        count = 0;
-        buffer = (char **)malloc (sizeof (char *) * 8);
-
-        if (buffer == NULL) {
-                goto oom;
-        }
-
-        buffer[0] = NULL;
-        while (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_STRING) {
-                const char *value;
-                char       *str;
-
-                if ((count % 8) == 0 && count != 0) {
-                        buffer = realloc (buffer, sizeof (char *) * (count + 8));
-                        if (buffer == NULL) {
-                                goto oom;
-                        }
-                }
-
-                dbus_message_iter_get_basic (iter, &value);
-                str = strdup (value);
-                if (str == NULL) {
-                        goto oom;
-                }
-
-                buffer[count] = str;
-
-                dbus_message_iter_next (iter);
-                count++;
-        }
-
-        if ((count % 8) == 0) {
-                buffer = realloc (buffer, sizeof (char *) * (count + 1));
-                if (buffer == NULL) {
-                        goto oom;
-                }
-        }
-
-        buffer[count] = NULL;
-        if (num_elements != NULL) {
-                *num_elements = count;
-        }
-        return buffer;
-
-oom:
-        g_debug ("%s %d : error allocating memory\n", __FILE__, __LINE__);
-        return NULL;
-
-}
-
 static gboolean
 screensaver_is_running (DBusConnection *connection)
 {
@@ -294,7 +183,6 @@ do_command (DBusConnection *connection)
 
         if (do_query) {
                 DBusMessageIter iter;
-                DBusMessageIter array;
                 dbus_bool_t     v;
 
                 if (!screensaver_is_running (connection)) {
@@ -313,32 +201,6 @@ do_command (DBusConnection *connection)
                 g_print (v ? _("The screensaver is active\n") : _("The screensaver is inactive\n"));
 
                 dbus_message_unref (reply);
-
-                reply = screensaver_send_message_void (connection, "GetInhibitors", TRUE);
-                if (! reply) {
-                        g_message ("Did not receive a reply from screensaver.");
-                        goto done;
-                }
-
-                dbus_message_iter_init (reply, &iter);
-                dbus_message_iter_recurse (&iter, &array);
-
-                if (dbus_message_iter_get_arg_type (&array) == DBUS_TYPE_INVALID) {
-                        g_print (_("The screensaver is not inhibited\n"));
-                } else {
-                        char **inhibitors;
-                        int    i;
-                        int    num;
-
-                        g_print (_("The screensaver is being inhibited by:\n"));
-                        inhibitors = get_string_from_iter (&array, &num);
-                        for (i = 0; i < num; i++) {
-                                g_print ("\t%s\n", inhibitors[i]);
-                        }
-                        g_strfreev (inhibitors);
-                }
-
-                dbus_message_unref (reply);
         }
 
         if (do_time) {
@@ -395,19 +257,6 @@ do_command (DBusConnection *connection)
                 dbus_message_unref (reply);
         }
 
-        if (do_inhibit) {
-                reply = screensaver_send_message_inhibit (connection,
-                                                          inhibit_application ? inhibit_application : "Unknown",
-                                                          inhibit_reason ? inhibit_reason : "Unknown");
-                if (! reply) {
-                        g_message ("Did not receive a reply from the screensaver.");
-                        goto done;
-                }
-                dbus_message_unref (reply);
-
-                return FALSE;
-        }
-
  done:
         g_main_loop_quit (loop);
 
diff --git a/src/gs-listener-dbus.c b/src/gs-listener-dbus.c
index beea33b..6d0d4e5 100644
--- a/src/gs-listener-dbus.c
+++ b/src/gs-listener-dbus.c
@@ -80,23 +80,11 @@ struct GSListenerPrivate
         guint           session_idle : 1;
         guint           active : 1;
         guint           activation_enabled : 1;
-        GHashTable     *inhibitors;
         time_t          active_start;
         time_t          session_idle_start;
         char           *session_id;
 };
 
-typedef struct
-{
-        int      entry_type;
-        char    *application;
-        char    *reason;
-        char    *connection;
-        guint32  cookie;
-        guint32  foreign_cookie;
-        GTimeVal since;
-} GSListenerRefEntry;
-
 enum {
         LOCK,
         QUIT,
@@ -113,10 +101,6 @@ enum {
         PROP_ACTIVATION_ENABLED,
 };
 
-enum {
-        REF_ENTRY_TYPE_INHIBIT,
-};
-
 static DBusObjectPathVTable
 gs_listener_vtable = { &gs_listener_unregister_handler,
                        &gs_listener_message_handler,
@@ -141,16 +125,6 @@ gs_listener_error_quark (void)
 }
 
 static void
-gs_listener_ref_entry_free (GSListenerRefEntry *entry)
-{
-        g_free (entry->connection);
-        g_free (entry->application);
-        g_free (entry->reason);
-        g_free (entry);
-        entry = NULL;
-}
-
-static void
 gs_listener_unregister_handler (DBusConnection *connection,
                                 void           *data)
 {
@@ -216,83 +190,9 @@ gs_listener_send_signal_active_changed (GSListener *listener)
         send_dbus_boolean_signal (listener, "ActiveChanged", listener->priv->active);
 }
 
-static const char *
-get_name_for_entry_type (int entry_type)
-{
-        const char *name;
-
-        switch (entry_type) {
-        case REF_ENTRY_TYPE_INHIBIT:
-                name = "inhibitor";
-                break;
-        default:
-                g_assert_not_reached ();
-                break;
-        }
-
-        return name;
-}
-
-static GHashTable *
-get_hash_for_entry_type (GSListener         *listener,
-                         int                 entry_type)
-{
-        GHashTable *hash;
-
-        switch (entry_type) {
-        case REF_ENTRY_TYPE_INHIBIT:
-                hash = listener->priv->inhibitors;
-                break;
-        default:
-                g_assert_not_reached ();
-                break;
-        }
-
-        return hash;
-}
-
-static void
-list_ref_entry (gpointer key,
-                gpointer value,
-                gpointer user_data)
-{
-        GSListenerRefEntry *entry;
-
-        entry =  (GSListenerRefEntry *)value;
-
-        gs_debug ("%s: %s for reason: %s",
-                  get_name_for_entry_type (entry->entry_type),
-                  entry->application,
-                  entry->reason);
-}
-
-static gboolean
-listener_ref_entry_is_present (GSListener *listener,
-                               int         entry_type)
-{
-        guint       n_entries;
-        gboolean    is_set;
-        GHashTable *hash;
-
-        hash = get_hash_for_entry_type (listener, entry_type);
-
-        /* if we aren't inhibited then activate */
-        n_entries = 0;
-        if (hash != NULL) {
-                n_entries = g_hash_table_size (hash);
-
-                g_hash_table_foreach (hash, list_ref_entry, NULL);
-        }
-
-        is_set = (n_entries > 0);
-
-        return is_set;
-}
-
 static gboolean
 listener_check_activation (GSListener *listener)
 {
-        gboolean inhibited;
         gboolean res;
 
         gs_debug ("Checking for activation");
@@ -305,14 +205,8 @@ listener_check_activation (GSListener *listener)
                 return TRUE;
         }
 
-        /* if we aren't inhibited then activate */
-        inhibited = listener_ref_entry_is_present (listener, REF_ENTRY_TYPE_INHIBIT);
-
-        res = FALSE;
-        if (! inhibited) {
-                gs_debug ("Trying to activate");
-                res = gs_listener_set_active (listener, TRUE);
-        }
+        gs_debug ("Trying to activate");
+        res = gs_listener_set_active (listener, TRUE);
 
         return res;
 }
@@ -403,17 +297,6 @@ gs_listener_set_session_idle (GSListener *listener,
                 return FALSE;
         }
 
-        if (idle) {
-                gboolean inhibited;
-
-                inhibited = listener_ref_entry_is_present (listener, REF_ENTRY_TYPE_INHIBIT);
-
-                /* if we are inhibited then do nothing */
-                if (inhibited) {
-                        return FALSE;
-                }
-        }
-
         listener->priv->session_idle = idle;
         res = listener_check_activation (listener);
 
@@ -436,18 +319,6 @@ gs_listener_get_activation_enabled (GSListener *listener)
         return listener->priv->activation_enabled;
 }
 
-gboolean
-gs_listener_is_inhibited (GSListener *listener)
-{
-        gboolean inhibited;
-
-        g_return_val_if_fail (GS_IS_LISTENER (listener), FALSE);
-
-        inhibited = listener_ref_entry_is_present (listener, REF_ENTRY_TYPE_INHIBIT);
-
-        return inhibited;
-}
-
 void
 gs_listener_set_activation_enabled (GSListener *listener,
                                     gboolean    enabled)
@@ -517,454 +388,6 @@ raise_syntax (DBusConnection *connection,
                      method_name);
 }
 
-static guint32
-generate_cookie (void)
-{
-        guint32 cookie;
-
-        cookie = (guint32)g_random_int_range (1, G_MAXINT32);
-
-        return cookie;
-}
-
-static guint32
-listener_generate_unique_key (GSListener *listener,
-                              int         entry_type)
-{
-        guint32     cookie;
-        GHashTable *hash;
-
-        hash = get_hash_for_entry_type (listener, entry_type);
-
-        do {
-                cookie = generate_cookie ();
-        } while (g_hash_table_lookup (hash, &cookie) != NULL);
-
-        return cookie;
-}
-
-static void
-listener_ref_entry_check (GSListener *listener,
-                          int         entry_type)
-{
-        switch (entry_type) {
-        case REF_ENTRY_TYPE_INHIBIT:
-                listener_check_activation (listener);
-                break;
-        default:
-                g_assert_not_reached ();
-                break;
-        }
-}
-
-static void
-add_session_inhibit (GSListener         *listener,
-                     GSListenerRefEntry *entry)
-{
-        DBusMessage    *message;
-        DBusMessage    *reply;
-        DBusMessageIter iter;
-        DBusMessageIter reply_iter;
-        DBusError       error;
-        guint           xid;
-        guint           flags;
-
-        g_return_if_fail (listener != NULL);
-
-        dbus_error_init (&error);
-
-        message = dbus_message_new_method_call (SESSION_NAME,
-                                                SESSION_PATH,
-                                                SESSION_INTERFACE,
-                                                "Inhibit");
-        if (message == NULL) {
-                gs_debug ("Couldn't allocate the dbus message");
-                return;
-        }
-
-        dbus_message_iter_init_append (message, &iter);
-        xid = 0;
-        flags = 8;
-        dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &entry->application);
-        dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &xid);
-        dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &entry->reason);
-        dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &flags);
-
-        /* FIXME: use async? */
-        reply = dbus_connection_send_with_reply_and_block (listener->priv->connection,
-                                                           message,
-                                                           -1,
-                                                           &error);
-        dbus_message_unref (message);
-
-        if (dbus_error_is_set (&error)) {
-                gs_debug ("%s raised:\n %s\n\n", error.name, error.message);
-                dbus_error_free (&error);
-                return;
-        }
-
-        dbus_message_iter_init (reply, &reply_iter);
-        dbus_message_iter_get_basic (&reply_iter, &entry->foreign_cookie);
-
-        dbus_message_unref (reply);
-}
-
-static void
-remove_session_inhibit (GSListener         *listener,
-                        GSListenerRefEntry *entry)
-{
-        DBusMessage    *message;
-        DBusMessage    *reply;
-        DBusMessageIter iter;
-        DBusError       error;
-
-        g_return_if_fail (listener != NULL);
-
-        if (entry->foreign_cookie == 0) {
-                gs_debug ("Can't remove inhibitor from session: Session cookie not set");
-                return;
-        }
-
-        dbus_error_init (&error);
-
-        message = dbus_message_new_method_call (SESSION_NAME,
-                                                SESSION_PATH,
-                                                SESSION_INTERFACE,
-                                                "Uninhibit");
-        if (message == NULL) {
-                gs_debug ("Couldn't allocate the dbus message");
-                return;
-        }
-
-        dbus_message_iter_init_append (message, &iter);
-        dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &entry->foreign_cookie);
-
-        /* FIXME: use async? */
-        reply = dbus_connection_send_with_reply_and_block (listener->priv->connection,
-                                                           message,
-                                                           -1,
-                                                           &error);
-        dbus_message_unref (message);
-
-        if (dbus_error_is_set (&error)) {
-                gs_debug ("%s raised:\n %s\n\n", error.name, error.message);
-                dbus_error_free (&error);
-                return;
-        }
-
-        dbus_message_unref (reply);
-}
-
-static void
-listener_add_ref_entry (GSListener         *listener,
-                        int                 entry_type,
-                        GSListenerRefEntry *entry)
-{
-        GHashTable *hash;
-
-        gs_debug ("adding %s from %s for reason '%s' on connection %s",
-                  get_name_for_entry_type (entry_type),
-                  entry->application,
-                  entry->reason,
-                  entry->connection);
-
-        hash = get_hash_for_entry_type (listener, entry_type);
-        g_hash_table_insert (hash, &entry->cookie, entry);
-
-        if (entry_type == REF_ENTRY_TYPE_INHIBIT) {
-                /* proxy inhibit over to gnome session */
-                add_session_inhibit (listener, entry);
-        }
-
-        listener_ref_entry_check (listener, entry_type);
-}
-
-static gboolean
-listener_remove_ref_entry (GSListener *listener,
-                           int         entry_type,
-                           guint32     cookie)
-{
-        GHashTable         *hash;
-        gboolean            removed;
-        GSListenerRefEntry *entry;
-
-        removed = FALSE;
-
-        hash = get_hash_for_entry_type (listener, entry_type);
-
-        entry = g_hash_table_lookup (hash, &cookie);
-        if (entry == NULL) {
-                goto out;
-        }
-
-        gs_debug ("removing %s from %s for reason '%s' on connection %s",
-                  get_name_for_entry_type (entry_type),
-                  entry->application,
-                  entry->reason,
-                  entry->connection);
-
-        if (entry_type == REF_ENTRY_TYPE_INHIBIT) {
-                /* remove inhibit from gnome session */
-                remove_session_inhibit (listener, entry);
-        }
-
-        removed = g_hash_table_remove (hash, &cookie);
- out:
-        if (removed) {
-                listener_ref_entry_check (listener, entry_type);
-        } else {
-                gs_debug ("Cookie %u was not in the list!", cookie);
-        }
-
-        return removed;
-}
-
-#if GLIB_CHECK_VERSION(2,12,0)
-#define _g_time_val_to_iso8601(t) g_time_val_to_iso8601(t)
-#else
-/* copied from GLib */
-static gchar *
-_g_time_val_to_iso8601 (GTimeVal *time_)
-{
-  gchar *retval;
-
-  g_return_val_if_fail (time_->tv_usec >= 0 && time_->tv_usec < G_USEC_PER_SEC, NULL);
-
-#define ISO_8601_LEN    21
-#define ISO_8601_FORMAT "%Y-%m-%dT%H:%M:%SZ"
-  retval = g_new0 (gchar, ISO_8601_LEN + 1);
-
-  strftime (retval, ISO_8601_LEN,
-            ISO_8601_FORMAT,
-            gmtime (&(time_->tv_sec)));
-
-  return retval;
-}
-#endif
-
-static void
-accumulate_ref_entry (gpointer            key,
-                      GSListenerRefEntry *entry,
-                      DBusMessageIter    *iter)
-{
-        char *description;
-        char *time;
-
-        time = _g_time_val_to_iso8601 (&entry->since);
-
-        description = g_strdup_printf ("Application=\"%s\"; Since=\"%s\"; Reason=\"%s\";",
-                                       entry->application,
-                                       time,
-                                       entry->reason);
-
-        dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &description);
-
-        g_free (description);
-        g_free (time);
-}
-
-static DBusHandlerResult
-listener_dbus_get_ref_entries (GSListener     *listener,
-                               int             entry_type,
-                               DBusConnection *connection,
-                               DBusMessage    *message)
-{
-        DBusMessage        *reply;
-        GHashTable         *hash;
-        DBusMessageIter     iter;
-        DBusMessageIter     iter_array;
-
-        hash = get_hash_for_entry_type (listener, entry_type);
-
-        reply = dbus_message_new_method_return (message);
-        if (reply == NULL) {
-                g_error ("No memory");
-        }
-
-        dbus_message_iter_init_append (reply, &iter);
-        dbus_message_iter_open_container (&iter,
-                                          DBUS_TYPE_ARRAY,
-                                          DBUS_TYPE_STRING_AS_STRING,
-                                          &iter_array);
-
-        if (hash != NULL) {
-                g_hash_table_foreach (hash,
-                                      (GHFunc)accumulate_ref_entry,
-                                      &iter_array);
-        }
-
-        dbus_message_iter_close_container (&iter, &iter_array);
-
-        if (! dbus_connection_send (connection, reply, NULL)) {
-                g_error ("No memory");
-        }
-
-        dbus_message_unref (reply);
-
-        return DBUS_HANDLER_RESULT_HANDLED;
-}
-
-static DBusHandlerResult
-listener_dbus_add_ref_entry (GSListener     *listener,
-                             int             entry_type,
-                             DBusConnection *connection,
-                             DBusMessage    *message)
-{
-        DBusMessage        *reply;
-        DBusError           error;
-        const char         *application;
-        const char         *reason;
-        GSListenerRefEntry *entry;
-        DBusMessageIter     iter;
-
-        dbus_error_init (&error);
-        if (! dbus_message_get_args (message, &error,
-                                     DBUS_TYPE_STRING, &application,
-                                     DBUS_TYPE_STRING, &reason,
-                                     DBUS_TYPE_INVALID)) {
-                if (entry_type == REF_ENTRY_TYPE_INHIBIT) {
-                        raise_syntax (connection, message, "Inhibit");
-                } else {
-                        g_assert_not_reached ();
-                 }
-
-                return DBUS_HANDLER_RESULT_HANDLED;
-        }
-
-        reply = dbus_message_new_method_return (message);
-        if (reply == NULL) {
-                g_error ("No memory");
-        }
-
-        entry = g_new0 (GSListenerRefEntry, 1);
-        entry->entry_type = entry_type;
-        entry->connection = g_strdup (dbus_message_get_sender (message));
-        entry->cookie = listener_generate_unique_key (listener, entry_type);
-        entry->application = g_strdup (application);
-        entry->reason = g_strdup (reason);
-        g_get_current_time (&entry->since);
-
-        listener_add_ref_entry (listener, entry_type, entry);
-
-        dbus_message_iter_init_append (reply, &iter);
-        dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &entry->cookie);
-
-        if (! dbus_connection_send (connection, reply, NULL)) {
-                g_error ("No memory");
-        }
-
-        dbus_message_unref (reply);
-
-        return DBUS_HANDLER_RESULT_HANDLED;
-}
-
-static DBusHandlerResult
-listener_dbus_remove_ref_entry (GSListener     *listener,
-                                int             entry_type,
-                                DBusConnection *connection,
-                                DBusMessage    *message)
-{
-        DBusMessage        *reply;
-        DBusError           error;
-        const char         *sender;
-        guint32             cookie;
-
-        dbus_error_init (&error);
-        if (! dbus_message_get_args (message, &error,
-                                     DBUS_TYPE_UINT32, &cookie,
-                                     DBUS_TYPE_INVALID)) {
-                if (entry_type == REF_ENTRY_TYPE_INHIBIT) {
-                        raise_syntax (connection, message, "UnInhibit");
-                } else {
-                        g_assert_not_reached ();
-                }
-
-                return DBUS_HANDLER_RESULT_HANDLED;
-        }
-
-        reply = dbus_message_new_method_return (message);
-        if (reply == NULL)
-                g_error ("No memory");
-
-        /* FIXME: check sender is from same connection as entry */
-        sender = dbus_message_get_sender (message);
-
-        listener_remove_ref_entry (listener, entry_type, cookie);
-
-        /* FIXME:  Pointless? */
-        if (! dbus_connection_send (connection, reply, NULL)) {
-                g_error ("No memory");
-        }
-
-        dbus_message_unref (reply);
-
-        return DBUS_HANDLER_RESULT_HANDLED;
-}
-
-static gboolean
-listener_ref_entry_remove_for_connection (GSListener  *listener,
-                                          int          entry_type,
-                                          const char  *connection)
-{
-        gboolean    removed;
-        GHashTable *hash;
-        GHashTableIter iter;
-        GSListenerRefEntry *entry;
-
-        if (connection == NULL)
-                return FALSE;
-
-        hash = get_hash_for_entry_type (listener, entry_type);
-
-        removed = FALSE;
-        g_hash_table_iter_init (&iter, hash);
-        while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&entry)) {
-                if (entry->connection != NULL &&
-                    strcmp (connection, entry->connection) == 0) {
-                        gs_debug ("removing %s from %s for reason '%s' on connection %s",
-                                  get_name_for_entry_type (entry->entry_type),
-                                  entry->application,
-                                  entry->reason,
-                                  entry->connection);
-
-                        if (entry->entry_type == REF_ENTRY_TYPE_INHIBIT) {
-                                /* remove inhibit from gnome session */
-                                remove_session_inhibit (listener, entry);
-                        }
-
-                        g_hash_table_iter_remove (&iter);
-                        removed = TRUE;
-                }
-        }
-
-        return removed;
-}
-
-static void
-listener_service_deleted (GSListener  *listener,
-                          DBusMessage *message)
-{
-        const char *old_service_name;
-        const char *new_service_name;
-        gboolean    removed;
-
-        if (! dbus_message_get_args (message, NULL,
-                                     DBUS_TYPE_STRING, &old_service_name,
-                                     DBUS_TYPE_STRING, &new_service_name,
-                                     DBUS_TYPE_INVALID)) {
-                g_error ("Invalid NameOwnerChanged signal from bus!");
-                return;
-        }
-
-        gs_debug ("DBUS service deleted: %s", new_service_name);
-
-        removed = listener_ref_entry_remove_for_connection (listener, REF_ENTRY_TYPE_INHIBIT, new_service_name);
-        if (removed) {
-                listener_ref_entry_check (listener, REF_ENTRY_TYPE_INHIBIT);
-        }
-
-}
-
 static void
 raise_property_type_error (DBusConnection *connection,
                            DBusMessage    *in_reply_to,
@@ -1199,17 +622,6 @@ do_introspect (DBusConnection *connection,
                                "    </method>\n"
                                "    <method name=\"SimulateUserActivity\">\n"
                                "    </method>\n"
-                               "    <method name=\"Inhibit\">\n"
-                               "      <arg name=\"application_name\" direction=\"in\" type=\"s\"/>\n"
-                               "      <arg name=\"reason\" direction=\"in\" type=\"s\"/>\n"
-                               "      <arg name=\"cookie\" direction=\"out\" type=\"u\"/>\n"
-                               "    </method>\n"
-                               "    <method name=\"UnInhibit\">\n"
-                               "      <arg name=\"cookie\" direction=\"in\" type=\"u\"/>\n"
-                               "    </method>\n"
-                               "    <method name=\"GetInhibitors\">\n"
-                               "      <arg name=\"list\" direction=\"out\" type=\"as\"/>\n"
-                               "    </method>\n"
                                "    <method name=\"GetActive\">\n"
                                "      <arg name=\"value\" direction=\"out\" type=\"b\"/>\n"
                                "    </method>\n"
@@ -1304,15 +716,6 @@ listener_dbus_handle_session_message (DBusConnection *connection,
                 g_signal_emit (listener, signals [QUIT], 0);
                 return send_success_reply (connection, message);
         }
-        if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "Inhibit")) {
-                return listener_dbus_add_ref_entry (listener, REF_ENTRY_TYPE_INHIBIT, connection, message);
-        }
-        if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "UnInhibit")) {
-                return listener_dbus_remove_ref_entry (listener, REF_ENTRY_TYPE_INHIBIT, connection, message);
-        }
-        if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "GetInhibitors")) {
-                return listener_dbus_get_ref_entries (listener, REF_ENTRY_TYPE_INHIBIT, connection, message);
-        }
         if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "SetActive")) {
                 return listener_set_property (listener, connection, message, PROP_ACTIVE);
         }
@@ -1576,10 +979,6 @@ listener_dbus_filter_function (DBusConnection *connection,
         } else if (dbus_message_is_signal (message,
                                            DBUS_INTERFACE_DBUS,
                                            "NameOwnerChanged")) {
-
-                if (listener->priv->inhibitors != NULL) {
-                        listener_service_deleted (listener, message);
-                }
         } else {
                 return listener_dbus_handle_session_message (connection, message, user_data, FALSE);
         }
@@ -1927,11 +1326,6 @@ gs_listener_init (GSListener *listener)
         gs_listener_dbus_init (listener);
 
         init_session_id (listener);
-
-        listener->priv->inhibitors = g_hash_table_new_full (g_int_hash,
-                                                            g_int_equal,
-                                                            NULL,
-                                                            (GDestroyNotify)gs_listener_ref_entry_free);
 }
 
 static void
@@ -1946,10 +1340,6 @@ gs_listener_finalize (GObject *object)
 
         g_return_if_fail (listener->priv != NULL);
 
-        if (listener->priv->inhibitors) {
-                g_hash_table_destroy (listener->priv->inhibitors);
-        }
-
         g_free (listener->priv->session_id);
 
         G_OBJECT_CLASS (gs_listener_parent_class)->finalize (object);
diff --git a/src/gs-listener-dbus.h b/src/gs-listener-dbus.h
index 20541f9..bc2a9a4 100644
--- a/src/gs-listener-dbus.h
+++ b/src/gs-listener-dbus.h
@@ -81,7 +81,6 @@ gboolean    gs_listener_set_session_idle        (GSListener *listener,
 void        gs_listener_set_activation_enabled  (GSListener *listener,
                                                  gboolean    enabled);
 gboolean    gs_listener_get_activation_enabled  (GSListener *listener);
-gboolean    gs_listener_is_inhibited            (GSListener *listener);
 
 G_END_DECLS
 
diff --git a/src/gs-monitor.c b/src/gs-monitor.c
index cd1d093..414982d 100644
--- a/src/gs-monitor.c
+++ b/src/gs-monitor.c
@@ -119,18 +119,16 @@ watcher_idle_notice_cb (GSWatcher *watcher,
                         GSMonitor *monitor)
 {
         gboolean activation_enabled;
-        gboolean inhibited;
         gboolean handled;
 
         gs_debug ("Idle notice signal detected: %d", in_effect);
 
         /* only fade if screensaver can activate */
         activation_enabled = gs_listener_get_activation_enabled (monitor->priv->listener);
-        inhibited = gs_listener_is_inhibited (monitor->priv->listener);
 
         handled = FALSE;
         if (in_effect) {
-                if (activation_enabled && ! inhibited) {
+                if (activation_enabled) {
                         /* start slow fade */
                         if (gs_grab_grab_offscreen (monitor->priv->grab, FALSE)) {
                                 gs_fade_async (monitor->priv->fade, FADE_TIMEOUT, NULL, NULL);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]