From 95f355cd3bbc7cd11098593da39682c4ba3d4869 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 4 Feb 2010 23:15:17 -0500 Subject: [PATCH 11/22] Add initial inhibit api Add explict Inhibit/Uninhibit methods. --- data/ConsoleKit.conf | 6 ++ src/ck-manager.c | 86 ++++++++++++++++++++++++++++ src/ck-manager.h | 10 +++ src/org.freedesktop.ConsoleKit.Manager.xml | 79 +++++++++++++++++++++++++ 4 files changed, 181 insertions(+), 0 deletions(-) diff --git a/data/ConsoleKit.conf b/data/ConsoleKit.conf index f77a2e2..29ac07a 100644 --- a/data/ConsoleKit.conf +++ b/data/ConsoleKit.conf @@ -69,6 +69,12 @@ + + priv->inhibitors, GINT_TO_POINTER (cookie), inhibitor); + + dbus_g_method_return (context, cookie); + + return TRUE; +} + +gboolean +ck_manager_uninhibit (CkManager *manager, + guint cookie, + DBusGMethodInvocation *context) +{ + CkInhibitor *inhibitor; + + g_return_val_if_fail (CK_IS_MANAGER (manager), FALSE); + + g_debug ("GsmManager: Uninhibit %u", cookie); + + inhibitor = (CkInhibitor *) g_hash_table_lookup (manager->priv->inhibitors, GINT_TO_POINTER (cookie)); + + if (inhibitor == NULL) { + GError *error; + + error = g_error_new (CK_MANAGER_ERROR, + CK_MANAGER_ERROR_GENERAL, + "Unable to uninhibit: Invalid cookie"); + dbus_g_method_return_error (context, error); + g_debug ("Unable to uninhibit: %s", error->message); + g_error_free (error); + + return FALSE; + } + + g_hash_table_remove (manager->priv->inhibitors, GINT_TO_POINTER (cookie)); + + dbus_g_method_return (context); + + return TRUE; +} + diff --git a/src/ck-manager.h b/src/ck-manager.h index 4bd56e8..87bb839 100644 --- a/src/ck-manager.h +++ b/src/ck-manager.h @@ -87,6 +87,16 @@ gboolean ck_manager_can_stop (CkManager *manage DBusGMethodInvocation *context); gboolean ck_manager_can_restart (CkManager *manager, DBusGMethodInvocation *context); + +/* Inhibit api */ +gboolean ck_manager_inhibit (CkManager *manager, + const char *reason, + guint flags, + DBusGMethodInvocation *context); +gboolean ck_manager_uninhibit (CkManager *manager, + guint cookie, + DBusGMethodInvocation *context); + /* Authoritative properties */ gboolean ck_manager_open_session (CkManager *manager, DBusGMethodInvocation *context); diff --git a/src/org.freedesktop.ConsoleKit.Manager.xml b/src/org.freedesktop.ConsoleKit.Manager.xml index 7bb475d..f12ce69 100644 --- a/src/org.freedesktop.ConsoleKit.Manager.xml +++ b/src/org.freedesktop.ConsoleKit.Manager.xml @@ -354,6 +354,85 @@ + + + + + The reason for the inhibit + + + + + Flags that specify what should be inhibited + + + + + The cookie + + + + + + System services should invoke this method when they begin an + operation that should not be interrupted, such as a system backup, + or a file-system check. The types of actions that may be blocked + are specified by the flags parameter. When the service completes + the operation it should call Uninhibit() or disconnect from the + system bus. + + + System services should not expect that they will always be able + to block the action. In most cases, users will be given the option + to force the action to take place. + + + Reasons should be short and to the point. They may be shown + to the user. + + + The flags parameter must include at least one of the following: + + + + 1 + Inhibit Stop and Restart + + + + More values may be added in the future. Values for flags + may be bitwise or'ed together. + + + The returned cookie is used to uniquely identify this request. + It should be used as an argument to the Uninhibit() method + in order to remove the inhibitor. + + + org.freedesktop.ConsoleKit.Inhibitor + + + + + + + + + + The cookie + + + + + + Cancels a previous call to Inhibit() identified by the cookie. + Note that inhibitors are also removed when the requestor drops + off the system bus. + + + + + -- 1.6.6