From ba51e98e8467e2b4c70f8b2265b739e990f3dac1 Mon Sep 17 00:00:00 2001 From: David Zeuthen Date: Mon, 11 May 2009 17:14:37 -0400 Subject: [PATCH] Remove unneeded code for PolicyKit --- tools/devkit-disks.c | 95 ++++----------------------------------------------- tools/umount-devkit.c | 57 ++----------------------------- 2 files changed, 9 insertions(+), 143 deletions(-) diff --git a/tools/devkit-disks.c b/tools/devkit-disks.c index 1f556d0..41ffd6c 100644 --- a/tools/devkit-disks.c +++ b/tools/devkit-disks.c @@ -43,8 +43,6 @@ #include #include -#include - #include "devkit-disks-daemon-glue.h" #include "devkit-disks-device-glue.h" #include "devkit-disks-marshal.h" @@ -75,28 +73,6 @@ static char *opt_ata_smart_simulate = NULL; static gboolean do_monitor (void); static void do_show_info (const char *object_path); -static gboolean -polkit_dbus_gerror_parse (GError *error, - PolKitAction **action, - PolKitResult *result) -{ - gboolean ret; - const char *name; - - ret = FALSE; - if (error->domain != DBUS_GERROR || error->code != DBUS_GERROR_REMOTE_EXCEPTION) - goto out; - - name = dbus_g_error_get_name (error); - - ret = polkit_dbus_error_parse_from_strings (name, - error->message, - action, - result); -out: - return ret; -} - static void do_ata_smart_refresh (const gchar *object_path, gboolean wakeup, @@ -149,44 +125,15 @@ do_mount (const char *object_path, "org.freedesktop.DeviceKit.Disks", object_path, "org.freedesktop.DeviceKit.Disks.Device"); -try_again: error = NULL; if (!org_freedesktop_DeviceKit_Disks_Device_filesystem_mount (proxy, filesystem_type, (const char **) mount_options, &mount_path, &error)) { - PolKitAction *pk_action; - PolKitResult pk_result; - - if (polkit_dbus_gerror_parse (error, &pk_action, &pk_result)) { - if (pk_result != POLKIT_RESULT_NO) { - char *action_id; - DBusError d_error; - - polkit_action_get_action_id (pk_action, &action_id); - dbus_error_init (&d_error); - if (polkit_auth_obtain (action_id, - 0, - getpid (), - &d_error)) { - polkit_action_unref (pk_action); - goto try_again; - } else { - g_print ("Obtaining authorization failed: %s: %s\n", - d_error.name, d_error.message); - dbus_error_free (&d_error); - goto out; - } - } - polkit_action_unref (pk_action); - g_error_free (error); - goto out; - } else { - g_print ("Mount failed: %s\n", error->message); - g_error_free (error); - goto out; - } + g_print ("Mount failed: %s\n", error->message); + g_error_free (error); + goto out; } g_print ("Mounted %s at %s\n", object_path, mount_path); @@ -212,44 +159,14 @@ do_unmount (const char *object_path, object_path, "org.freedesktop.DeviceKit.Disks.Device"); -try_again: error = NULL; if (!org_freedesktop_DeviceKit_Disks_Device_filesystem_unmount (proxy, (const char **) unmount_options, &error)) { - PolKitAction *pk_action; - PolKitResult pk_result; - - if (polkit_dbus_gerror_parse (error, &pk_action, &pk_result)) { - if (pk_result != POLKIT_RESULT_NO) { - char *action_id; - DBusError d_error; - - polkit_action_get_action_id (pk_action, &action_id); - dbus_error_init (&d_error); - if (polkit_auth_obtain (action_id, - 0, - getpid (), - &d_error)) { - polkit_action_unref (pk_action); - goto try_again; - } else { - g_print ("Obtaining authorization failed: %s: %s\n", - d_error.name, d_error.message); - dbus_error_free (&d_error); - goto out; - } - } - polkit_action_unref (pk_action); - g_error_free (error); - goto out; - } else { - g_print ("Unmount failed: %s\n", error->message); - g_error_free (error); - goto out; - } + g_print ("Unmount failed: %s\n", error->message); + g_error_free (error); } -out: + g_strfreev (unmount_options); } diff --git a/tools/umount-devkit.c b/tools/umount-devkit.c index 68ccd15..730f26f 100644 --- a/tools/umount-devkit.c +++ b/tools/umount-devkit.c @@ -40,35 +40,12 @@ #include #include -#include #include "devkit-disks-daemon-glue.h" #include "devkit-disks-device-glue.h" static DBusGConnection *bus; -static gboolean -polkit_dbus_gerror_parse (GError *error, - PolKitAction **action, - PolKitResult *result) -{ - gboolean ret; - const char *name; - - ret = FALSE; - if (error->domain != DBUS_GERROR || error->code != DBUS_GERROR_REMOTE_EXCEPTION) - goto out; - - name = dbus_g_error_get_name (error); - - ret = polkit_dbus_error_parse_from_strings (name, - error->message, - action, - result); -out: - return ret; -} - static void do_unmount (const char *object_path, const char *options) @@ -91,37 +68,9 @@ try_again: if (!org_freedesktop_DeviceKit_Disks_Device_filesystem_unmount (proxy, (const char **) unmount_options, &error)) { - PolKitAction *pk_action; - PolKitResult pk_result; - - if (polkit_dbus_gerror_parse (error, &pk_action, &pk_result)) { - if (pk_result != POLKIT_RESULT_NO) { - char *action_id; - DBusError d_error; - - polkit_action_get_action_id (pk_action, &action_id); - dbus_error_init (&d_error); - if (polkit_auth_obtain (action_id, - 0, - getpid (), - &d_error)) { - polkit_action_unref (pk_action); - goto try_again; - } else { - g_print ("Obtaining authorization failed: %s: %s\n", - d_error.name, d_error.message); - dbus_error_free (&d_error); - goto out; - } - } - polkit_action_unref (pk_action); - g_error_free (error); - goto out; - } else { - g_print ("Unmount failed: %s\n", error->message); - g_error_free (error); - goto out; - } + g_print ("Unmount failed: %s\n", error->message); + g_error_free (error); + goto out; } out: g_strfreev (unmount_options); -- 2.7.4