Remove unneeded code for PolicyKit
authorDavid Zeuthen <davidz@redhat.com>
Mon, 11 May 2009 21:14:37 +0000 (17:14 -0400)
committerDavid Zeuthen <davidz@redhat.com>
Mon, 11 May 2009 21:14:37 +0000 (17:14 -0400)
tools/devkit-disks.c
tools/umount-devkit.c

index 1f556d0..41ffd6c 100644 (file)
@@ -43,8 +43,6 @@
 #include <dbus/dbus-glib.h>
 #include <dbus/dbus-glib-lowlevel.h>
 
-#include <polkit-dbus/polkit-dbus.h>
-
 #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);
 }
 
index 68ccd15..730f26f 100644 (file)
 
 #include <dbus/dbus-glib.h>
 #include <dbus/dbus-glib-lowlevel.h>
-#include <polkit-dbus/polkit-dbus.h>
 
 #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);