summaryrefslogtreecommitdiffstats
path: root/src/gdu
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@redhat.com>2009-03-02 14:40:08 -0500
committerDavid Zeuthen <davidz@redhat.com>2009-03-02 14:40:08 -0500
commit5861bb10d046b447aac8c25995c80411df15b22a (patch)
tree2e348d9eb087b447e4241542738fd266235913c0 /src/gdu
parent0e6953b65a5cf8a8dc7e9b4b99ed1d15f6da498f (diff)
downloadgnome-disk-utility-5861bb10d046b447aac8c25995c80411df15b22a.tar.gz
gnome-disk-utility-5861bb10d046b447aac8c25995c80411df15b22a.tar.xz
gnome-disk-utility-5861bb10d046b447aac8c25995c80411df15b22a.zip
add support for handling when the daemon is inhibit
Diffstat (limited to 'src/gdu')
-rw-r--r--src/gdu/gdu-error.c2
-rw-r--r--src/gdu/gdu-error.h2
-rw-r--r--src/gdu/gdu-pool.c50
-rw-r--r--src/gdu/gdu-pool.h1
4 files changed, 55 insertions, 0 deletions
diff --git a/src/gdu/gdu-error.c b/src/gdu/gdu-error.c
index bdc446e..b1035f6 100644
--- a/src/gdu/gdu-error.c
+++ b/src/gdu/gdu-error.c
@@ -73,6 +73,8 @@ _gdu_error_fixup (GError *error)
matched = TRUE;
if (strcmp (name, "org.freedesktop.DeviceKit.Disks.Error.Failed") == 0)
error->code = GDU_ERROR_FAILED;
+ if (strcmp (name, "org.freedesktop.DeviceKit.Disks.Error.Inhibited") == 0)
+ error->code = GDU_ERROR_INHIBITED;
else if (strcmp (name, "org.freedesktop.DeviceKit.Disks.Error.Busy") == 0)
error->code = GDU_ERROR_BUSY;
else if (strcmp (name, "org.freedesktop.DeviceKit.Disks.Error.Cancelled") == 0)
diff --git a/src/gdu/gdu-error.h b/src/gdu/gdu-error.h
index 7e9f18f..26d0aaf 100644
--- a/src/gdu/gdu-error.h
+++ b/src/gdu/gdu-error.h
@@ -34,6 +34,7 @@ G_BEGIN_DECLS
/**
* GduError:
* @GDU_ERROR_FAILED: The operation failed.
+ * @GDU_ERROR_INHIBITED: The daemon is being inhibited.
* @GDU_ERROR_BUSY: The device is busy
* @GDU_ERROR_CANCELLED: The operation was cancelled
* @GDU_ERROR_INVALID_OPTION: An invalid option was passed
@@ -58,6 +59,7 @@ G_BEGIN_DECLS
typedef enum
{
GDU_ERROR_FAILED,
+ GDU_ERROR_INHIBITED,
GDU_ERROR_BUSY,
GDU_ERROR_CANCELLED,
GDU_ERROR_INVALID_OPTION,
diff --git a/src/gdu/gdu-pool.c b/src/gdu/gdu-pool.c
index 99d1236..00aa228 100644
--- a/src/gdu/gdu-pool.c
+++ b/src/gdu/gdu-pool.c
@@ -1519,6 +1519,56 @@ gdu_pool_get_daemon_version (GduPool *pool)
}
/**
+ * gdu_pool_is_daemon_inhibited:
+ * @pool: A #GduPool.
+ *
+ * Checks if the daemon is currently inhibited.
+ *
+ * Returns: %TRUE if the daemon is inhibited.
+ **/
+gboolean
+gdu_pool_is_daemon_inhibited (GduPool *pool)
+{
+ DBusGProxy *prop_proxy;
+ gboolean ret;
+ GError *error;
+ GValue value = {0};
+
+ /* TODO: this is a currently a synchronous call; when we port to EggDBus this will be fixed */
+
+ ret = TRUE;
+
+ prop_proxy = dbus_g_proxy_new_for_name (pool->priv->bus,
+ "org.freedesktop.DeviceKit.Disks",
+ "/",
+ "org.freedesktop.DBus.Properties");
+ error = NULL;
+ if (!dbus_g_proxy_call (prop_proxy,
+ "Get",
+ &error,
+ G_TYPE_STRING,
+ "org.freedesktop.DeviceKit.Disks",
+ G_TYPE_STRING,
+ "daemon-is-inhibited",
+ G_TYPE_INVALID,
+ G_TYPE_VALUE,
+ &value,
+ G_TYPE_INVALID)) {
+ g_warning ("Couldn't call Get() to determine if daemon is inhibited for /: %s", error->message);
+ g_error_free (error);
+ ret = TRUE;
+ goto out;
+ }
+
+ ret = g_value_get_boolean (&value);
+
+ out:
+ g_object_unref (prop_proxy);
+ return ret;
+}
+
+
+/**
* gdu_pool_get_known_filesystems:
* @pool: A #GduPool.
*
diff --git a/src/gdu/gdu-pool.h b/src/gdu/gdu-pool.h
index ae3c55e..6a5909a 100644
--- a/src/gdu/gdu-pool.h
+++ b/src/gdu/gdu-pool.h
@@ -68,6 +68,7 @@ GType gdu_pool_get_type (void);
GduPool *gdu_pool_new (void);
char *gdu_pool_get_daemon_version (GduPool *pool);
+gboolean gdu_pool_is_daemon_inhibited (GduPool *pool);
gboolean gdu_pool_supports_luks_devices (GduPool *pool);
GList *gdu_pool_get_known_filesystems (GduPool *pool);
GduKnownFilesystem *gdu_pool_get_known_filesystem_by_id (GduPool *pool, const char *id);